Skip to content

perspectivefi/spectra-subgraph

Repository files navigation

Spectra Subgraph

Spectra is the ultimate marketplace for yield derivatives and the first protocol for future yield tokenisation.

Networks and Performance

This subgraph can be found on The Graph Hosted Service for the following networks:

You can also run this subgraph locally, if you wish. Instructions for that can be found in The Graph Documentation.

Prerequisites

  • Foundry, along with anvil (included)
  • The IPFS CLI
  • A running instance of Postgres
    • The quickest way to get this up and running is through the official Docker image (docker run -it --rm --network some-network postgres psql -h some-postgres -U postgres).
  • The cargo Rust package manager
  • The Graph CLI

Setup

1. Install subgraph dependencies

yarn

2. Generate subgraph config per network

  • Mainnet
yarn generate-config
  • other supported networks
yarn generate-config:<NETWORK>

3. Generate contract and schema dependencies

This step will load all contract ABIs used by our subgraph and generate the corresponding TypeScript interfaces.

yarn codegen

Local development

To deploy and run test scenarios on the locally running blockchain:

1. Run local blockchain with predefined genesis timestamp

anvil --timestamp 100

2. Configure and run ipfs

ipfs init
ipfs daemon

3. Create new database

createdb db_subgraph

4. Clone local graph node

git clone https://github.com/graphprotocol/graph-node/

5. Run the graph-node cloned in the previous step with setup

RUST_BACKTRACE=1 cargo run -p graph-node --release -- \
--postgres-url postgresql://<USER>:@localhost:5432/db_subgraph \
--ethereum-rpc mainnet:http://127.0.0.1:8545 \
--ipfs 127.0.0.1:5001 \
--debug

6. Go back to the subgraph repository and generate config file for local development

yarn generate-config:local

7. Create local node

yarn create:local

8. Deploy subgraph locally

yarn deploy:local

9. Go to core-v2 repository and install its dependencies

npm i

10. Run test scenarios on the running blockchain

forge test --fork-url http://localhost:8545

11. For playground go to

http://127.0.0.1:8000/subgraphs/name/perspectivefi/spectra-mainnet/graphql

Deployment

1. Generate subgraph config file for the network you want to deploy the subgraph

  • Mainnet
yarn generate-config
  • other supported networks
generate-config:<NETWORK>

2. Generate contract and schema dependencies

yarn codegen

3. Create subgraph

yarn create

4. Authorize your TheGraph account

graph auth https://api.thegraph.com/deploy/ <ACCESS_TOKEN>

5. Create deployment script in package.json (if not exists for your network)

6. Add network id (if missing) to the ChainId class in src/utils/ChainId.ts file

7. Deploy the subgraph

  • Mainnet
yarn deploy
  • other network
yarn deploy:<NETWORK>

IMPORTANT: If your network is not supported you have to go to src/configs and add new config file.

Schema

Graph definition written in PlantUML framework - schema.puml

Example queries

Coming soon


About

APWine subgraph for core-v2

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •