Developers
Search…
Subgraphs
The Balancer Subgraph indexes data on the Balancer smart contracts with a GraphQL interface. It updates data in response to function calls and contract events to maintain data on the Vault, Pools, AssetManagers etc, to power front-end apps and integrations.
Note that Balancer has not yet migrated to the new Subgraph Studio mainnet. Any Balancer subgraphs appearing there should not be considered "official" deployments. Use at your own risk!

GraphQL Schema

The schema of GraphQL elements available is defined in /schema.graphql
The data included in this subgraph data layer is the data that is most applicable to the front-end. It aims at the very least to keep track of all the resources in the Vault contract, and keep track of basic pool data.

Querying

For an in-depth explanation of how to query the Subgraph, check out the Balancer Subgraph article in Guides.

Examples

Pools with > $100k liquidity
1
{
2
pools(first: 1000, where: {totalLiquidity_gt: 100000}) {
3
address,
4
tokensList,
5
totalLiquidity
6
}
7
}
Copied!
Historical liquidity of a pool
1
{
2
poolHistoricalLiquidities (where: {poolId: "0x09253c3554fb7242608ff67ce048918ccf7f9a96000200000000000000000009"}) {
3
block,
4
poolLiquidity
5
}
6
}
Copied!
Fetch a Liquidity Provider's shares
1
{
2
poolShares(first: 1000, where: {userAddress: "0xef8305e140ac520225daf050e2f71d5fbcc543e7", balance_gt: 0}) {
3
balance
4
poolId {
5
tokensList,
6
totalShares
7
}
8
}
9
}
Copied!
Fetch historical metrics for a given pool
1
{
2
poolSnapshots(first:1000, orderBy: timestamp, orderDirection: asc, where: {pool: "0x5c6ee304399dbdb9c8ef030ab642b10820db8f56000200000000000000000014"}) {
3
amounts
4
totalShares
5
swapVolume
6
swapFees
7
liquidity
8
pool {
9
id
10
}
11
}
12
}
Copied!
Copy link