This repo contains subgraphs defined using a set of standardized schemas. These subgraphs are used to extract raw blockchain data and transform them into meaningful metrics, for products and analytics. Our goal is to build a subgraph for every DeFi protocol in the space.
- Decide which protocol you want to build a subgraph for.
- Fork this repository.
- Add a folder under
subgraphs
with the name of the protocol you want to work on. - Copy over the corresponding schema from the root folder. For example, if you are working on a yield aggregator, you should copy over
schema-yield.graphql
to your folder and rename it toschema.graphql
. Noteschema-common.graphql
is used for schema design and reference, and should never be used for implementation. - Build the subgraph within that folder. Feel free to use the reference subgraph as a reference.
- Submit a PR (pull request) to this repo after you are done. Make sure you submit your PR as a draft if it's a work-in-progress. Include a link to your deployment in your PR description.
- Start with understanding the protocol. An easy start could be interacting with the protocol UI on testnets, check transaction details on Etherscan and pay attention to key events that are emitted.
- Go over the smart contracts. Identify the ones that we need to pull data from.
- Usually each protocol has a factory contract that's responsible for tracking other contracts (e.g. Uniswap's Factory contract, Aave's Lending Pool Registry, Yearn's Registry).
- Also a pool/vault contract that's responsible for pool level bookkeeping and transactions (e.g. Uniswap's Pair contract, Yearn's Vault contract, Aave's Lending Pool contract).
- Go over the schema and think about what data are needed from smart contract events/calls to map to the fields in each entity.
- It's easiest to start with more granular entities and build up to aggregated data.
- For example, usually it's easier to start writing mappings for transactions and usage metrics.
- Go over the documents in the
docs
folder. That should answer lots of questions you may have. - Implement the mappings, deploy and test your data using either Hosted Service or The Graph Studio.
- For metrics calculation (e.g. revenue, fees, TVL), please refer to the
README.md
in the protocol's subgraph folder for methodology. There is also a broader explanation of how different fields are defined in the schema indocs/Schema.md
. Feel free to reach out to me if anything isn't clear. - We've built a handy debugging/validation dashboard for you to quickly visualize the data in your subgraph. It's deployed to subgraphs.xyz and the source code is under
dashboard
if you want to spin it up locally. - Verify your subgraph against other sources and include specific links to these sources in the README. Below are some common sources:
- Project's official analytics dashboard
- DeFi Llama (for TVL)
- Dune Analytics
- TokenTerminal
- Learn the basics of GraphQL: https://graphql.org/learn/
- Query subgraphs using GraphQL: https://thegraph.com/docs/en/developer/graphql-api/
- Get familiar with The Graph: https://thegraph.academy/developers/
- Defining a subgraph: https://thegraph.academy/developers/defining-a-subgraph/
- Creating a subgraph: https://thegraph.com/docs/en/developer/create-subgraph-hosted/
- Deploying a subgraph using The Graph Studio: https://thegraph.com/docs/en/studio/deploy-subgraph-studio/
- AssemblyScript API
- Unit Test Using Matchstick
- Building a Subgraph for Sushiswap
- Building a Subgraph for Loopring
- Using templates (dynamic data sources)
- Indexing proxies
- Building ambitious subgraphs (Part I): https://www.youtube.com/watch?v=4V2o5YJooOM
- Schema design
- Error handling
- Interface and union types
- Building ambitious subgraphs (Part II) https://www.youtube.com/watch?v=1-8AW-lVfrA
- Performance tips and tricks (for both mappings and queries)
- Documentation for the graph-node
π¨ = In progress.
π = Feature complete. Additional testing required.
β
= Production-ready.
Protocol | Status | Versions β | Deployments |
---|---|---|---|
DEX AMM | |||
Apeswap | π | 1.3.0 / 1.1.1 / 1.0.0 | |
Balancer v2 | π | 1.3.0 / 1.1.2 / 1.0.0 | |
Bancor v3 | π | 1.3.0 / 1.0.0 / 1.0.0 | |
Beethoven X | π | 1.3.0 / 1.1.2 / 1.0.0 | |
Curve | π | 1.2.1 / 1.0.0 / 1.0.0 | |
DODO v2 | π¨ | ||
Ellipsis Finance | π | 1.2.1 / 1.0.0 / 1.0.0 | |
Quickswap | π | 1.3.0 / 1.0.0 / 1.0.0 | |
Platypus Finance | π | 1.3.0 / 1.3.0 / 1.0.0 | |
Saddle Finance | π | 1.3.0 / 1.1.0 / 1.0.0 | |
Solarbeam | π | 1.3.0 / 1.0.0 / 1.0.0 | |
SpiritSwap | π | 1.3.0 / 1.0.0 / 1.0.0 | |
SpookySwap | π | 1.3.0 / 1.1.1 / 1.0.0 | |
Ubeswap | π | 1.3.0 / 1.1.1 / 1.0.0 | |
VVS Finance | π | 1.3.0 / 1.1.1 / 1.0.0 | |
SushiSwap | π | 1.3.0 / 1.1.1 / 1.0.0 | |
Trader Joe | π | 1.3.0 / 1.0.0 / 1.0.0 | |
Uniswap v2 | π | 1.3.0 / 1.1.1 / 1.0.0 | |
Uniswap v3 | π | 1.3.0 / 1.1.1 / 1.0.0 | |
Lending Protocols | |||
Aave v2 | π | 1.3.0 / 1.2.3 / 1.0.0 | |
Aave v3 | π¨ | 1.3.0 / 1.0.0 / 1.0.0 | |
Aurigami | π | 1.3.0 / 1.0.6 / 1.0.0 | |
Bastion Protocol | π | 1.3.0 / 1.0.9 / 1.0.0 | |
Banker Joe | π | 1.3.0 / 1.0.5 / 1.0.0 | |
BENQI | π | 1.3.0 / 1.0.6 / 1.0.0 | |
Compound | π | 1.3.0 / 1.6.7 / 1.0.0 | |
CREAM Finance | π | 1.3.0 / 1.0.6 / 1.0.0 | |
dForce | π | 1.3.0 / 1.0.2 / 1.0.0 | |
Euler Finance | π¨ | ||
Geist | π | 1.3.0 / 1.0.1 / 1.0.0 | |
Iron Bank | π | 1.3.0 / 1.0.8 / 1.0.0 | |
Maple Finance | π | 1.2.1 / 1.1.0 / 1.0.0 | |
Moonwell Finance | π | 1.3.0 / 1.0.10 / 1.0.0 | |
Notional Finance | π¨ | ||
Rari Fuse | π¨ | 1.3.0 / 1.0.18 / 1.0.0 | |
SCREAM | π | 1.3.0 / 1.0.6 / 1.0.0 | |
Venus Protocol | π | 1.3.0 / 1.0.6 / 1.0.0 | |
Yeti Finance | π¨ | ||
CDPs | |||
Abracadabra | π | 1.3.0 / 1.0.5 / 1.0.0 | |
Alchemix | |||
Inverse Finance | π | 1.3.0 / 1.2.2 / 1.0.0 | |
Liquity | π | 1.3.0 / 1.1.4 / 1.0.1 | |
MakerDAO | π | 1.3.0 / 1.1.0 / 1.0.0 | |
QiDAO | π | 1.3.0 / 1.1.0 / 1.0.0 | |
Yield Aggregators | |||
Arrakis Finance | |||
Badger DAO | π¨ | 1.3.0 / 1.0.0 / 1.0.0 | |
Beefy Finance | π | ||
Belt Finance | π | 1.2.1 / 1.0.0 / 1.0.0 | |
Convex Finance | π | 1.3.0 / 1.1.1 / 1.0.0 | |
Gamma Strategy | π | 1.2.1 / 1.0.0 / 1.0.0 | |
Harvest Finance | π¨ | ||
Liquid Driver | π¨ | ||
Rari Vaults | π | 1.2.1 / 1.3.13 / 1.0.0 | |
Stake DAO | π | 1.3.0 / 1.3.0 / 1.0.0 | |
Tokemak | π | 1.2.1 / 1.0.0 / 1.0.0 | |
Vesper Finance | π¨ | ||
Yield Yak | π¨ | ||
Yearn v2 | π | 1.3.0 / 1.2.0 / 1.0.0 | |
Governance | |||
ENS Governor | π | 1.0.0 / 1.0.0 / 1.0.0 | |
FEI Governor | π¨ | ||
Silo Finance Governor | π¨ | ||
Hop Protocol Governor | π¨ | ||
Network Subgraph | |||
EVM | π¨ | ||
Cosmos | π¨ | ||
NEAR | π¨ | ||
Arweave | π¨ | ||
ERC20 Subgraph | |||
ERC20 | π¨ | 1.0.0 / 1.0.0 / 1.0.0 | |
ERC721 Subgraph | |||
TBD | π¨ |
β Versions are schema version, subgraph version, methodology version respectively