Skip to content
This repository has been archived by the owner on Jan 18, 2023. It is now read-only.

SetProtocol/set-protocol-v2-subgraph

 
 

Repository files navigation

Set Protocol V2 Subgraph

Indexer of Set Protocol v2 events. Built on The Graph.

SETUP

Requirements:

  • Docker >= 20.10

Local Deployment (Hardhat)

  1. Build the Set Protocol Docker subgraph image

    task docker-build

  2. Deploy a Hardhat node and custom script to the network

    task deploy-hardhat [-- HARDHAT_STATE_TARGET_REPO HARDHAT_STATE_TEST_SCRIPT]

    Note: HARDHAT_STATE_TARGET_REPO and HARDHAT_STATE_TEST_SCRIPT must be provided as input arguments or defined in the dotenv configuration. Input arguments take precendence over dotenv configurations. For input arguments, you can specify just the target repo, or both the repo and test script, but you cannot provide the test script alone.

  3. Monitor the Hardhat node until fully deployed and tests are executed

  4. In a new terminal, compile the Set Protocol ABIs

    task gen-abi

  5. Deploy local subgraph

    task deploy-local

  6. Once deployed, query the subgraph in the browser at http://127.0.0.1:8000/subgraphs/name/GITHUB_REPO/SUBGRAPH_NAME

    Be sure to specify the correct GITHUB_REPO and SUBGRAPH_NAME. Example queries to run can be found in samples/sample-query.txt.

External Deployment to Hosted Service

  1. Build the Set Protocol Docker subgraph image

    task docker-build

  2. Deploy hosted subgraph to network specified by the NETWORK_EXTERNAL argument

    task deploy-hosted [-- NETWORK_EXTERNAL SUBGRAPH_ACCESS_TOKEN]

    Note: NETWORK_EXTERNAL and SUBGRAPH_ACCESS_TOKEN must be provided as input arguments or defined in the dotenv configuration. Input arguments take precendence over dotenv configurations. For input arguments, you can specify just the network, or both the network and the access token, but you cannot provide the access token alone.

IMPORTANT NOTE

Per the documentation on the Hosted Service:

A subgraph is defined as "inactive" if it was deployed to the Hosted Service more than 45 days ago, and if it has received 0 queries in the last 30 days.

External Deployment to Subgraph Studio

  1. Build the Set Protocol Docker subgraph image

    task docker-build

  2. Deploy subgraph to slug identified by the NETWORK_EXTERNAL argument

    task deploy-studio [-- NETWORK_EXTERNAL SUBGRAPH_DEPLOY_KEY]

    Note: NETWORK_EXTERNAL and SUBGRAPH_DEPLOY_KEY must be provided as input arguments or defined in the dotenv configuration (as per arguments for Hosted Service deployments; see above).

  3. Complete steps to test and publish following the documentation: https://thegraph.com/docs/en/studio/subgraph-studio/

USAGE

Available tasks for this project:

COMMAND [OPTS] DESCRIPTION
clean [-- all|subgraph|hardhat] Clean up local subgraph deployment; all arg additionally removes all volumes and the Hardhat node.
deploy-hardhat [-- HARDHAT_STATE_TARGET_REPO HARDHAT_STATE_TEST_SCRIPT] Deploy a local Hardhat node from REPO_URL and run a node state deployment test script. HARDHAT_STATE_TARGET_REPO and HARDHAT_STATE_TEST_SCRIPT must be provided or defined in a private dotenv.
deploy-hosted [-- NETWORK_EXTERNAL SUBGRAPH_ACCESS_TOKEN] Build and deploy subgraph to NETWORK_EXTERNAL on Hosted Service. NETWORK_EXTERNAL and SUBGRAPH_ACCESS_TOKEN must be provided or defined in a private dotenv.
deploy-local [-- detach] Build and deploy graph-node and ipfs services on local network followed by deployment of the subgraph; detach runs containers in detached mode.
deploy-local-graphnode [-- detach] Build and deploy graph-node and ipfs services on local network; detach runs containers in detached mode.
deploy-local-subgraph [-- refresh] Compile and deploy the subgraph onto running graph-node and ipfs services on local network. refresh first deletes all IPFS data and restarts the service.
deploy-studio [-- NETWORK_EXTERNAL SUBGRAPH_DEPLOY_KEY] Build and deploy subgraph to NETWORK_EXTERNAL on Subgraph Studio. NETWORK_EXTERNAL and SUBGRAPH_DEPLOY_KEY must be provided or defined in a private dotenv.
docker-build Build Set Protocol base Docker image on defined node version (default: 16-slim).
gen-abi Pull latest Set Protocol ABIs into the build environment.
gen-schema [-- hosted] Compile the subgraph schema but do not deploy the subgraph; default target subgraph network is local unless hosted argument is provided.

KEY FILES

schema.graphql - Subgraph schema

templates/subgraph.yaml - configure watched contracts and events

deployments.json - configure deployed contract addresses on each chain

src/ - AssemblyScript code for subgraph handlers

src/mappings/ - Event handlers

src/utils/ - Entity mappings functions and other helper utilities

REFERENCES

The Graph Docs

Set Protocol Subgraph Docs

Set Protocol V2 Docs

Set Protocol V2 Contracts

Set Protocol V2 Strategies Contracts

About

Subgraph for Set Protocol V2

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • TypeScript 67.3%
  • Shell 32.7%