Giter Site home page Giter Site logo

marginswap-subgraph's Introduction

Marginswap Subgraph

Deployed on legacy explorer

Polygon

https://thegraph.com/legacy-explorer/subgraph/marginswap/marginswap-v1-polygon

BSC

https://thegraph.com/legacy-explorer/subgraph/marginswap/marginswap-v1-bsc

Avalanche

https://thegraph.com/legacy-explorer/subgraph/marginswap/marginswap-v1-avalanche

Running Locally

  • Clone Graph Node git clone https://github.com/graphprotocol/graph-node/
  • Enter the Graph Node's Docker directory: cd graph-node/docker
  • Linux users need to run: ./setup.sh
  • docker-compose up -d
    • If this fails with a Mounts Denied error on mac, in docker desktop, go to Preferences > Resources > File Sharing and add the graph's docker directory as an allowed directory
  • Make your edits to the subgraph code
  • Create the subgraph locally: yarn create-local
  • Run codegen yarn codegen
  • Build the code yarn build
  • Deploy the subgraph locally: yarn deploy-local
  • Visit http://localhost:8000/subgraphs/name/marginswap/marginswap-subgraph/graphql

Logs

There are two options for getting logs:

  1. For basic logs, click on Docker Desktop > docker > docker_graph_node_1
  2. For more detailed, debug logs, run sudo docker ps -a then get the ID for the graph-node container, and then run sudo docker logs -f <project-id>

Local Chain

  • For local dev, this will talk to the local chain from the marginswap-core hardhat script. However, you'll need to swap out the infura URL in the hardhat config for an Alchemy one so you get the full archive node. Archive nodes are required for making contract method calls like we do in the margin-router event event handler.

Deploying

  • Run the deploy script for the network you want to deploy on. yarn prepare:bsc, yarn prepare:mainnet, yarn prepare:avalanche, or yarn prepare:polygon
  • Manually update the contract address in /src/mappings/margin-router.ts to the correct address for the CrossMarginTrading contract on the network you are deploying to. Get the address from the marginswap-core repo in /build/addresses.json
  • Authenticate: graph auth --product hosted-service <ACCESS_TOKEN> (get access token from another dev or from thegraph.com URL below)
  • Deploy: graph deploy --product hosted-service marginswap/marginswap-v1-<network>
  • In the browser, navigate to https://thegraph.com/legacy-explorer/subgraph/marginswap/marginswap-v1-<network> where <network> is either bsc, polygon, or mainnet

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.