Skip to content

Commit

Permalink
update subgraph endpoints (#208)
Browse files Browse the repository at this point in the history
* update subgraph endpoints

* fix mode endpoints

* make api key uppercase

* fix zkevm endpoints
  • Loading branch information
mendesfabio authored May 31, 2024
1 parent c2c2a61 commit 101a64f
Showing 1 changed file with 41 additions and 113 deletions.
154 changes: 41 additions & 113 deletions docs/reference/subgraph/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,116 +5,44 @@ title: Overview

# 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.

| Network | Subgraph URL |
|------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| Ethereum Mainnet | [https://api.thegraph.com/subgraphs/name/balancer-labs/balancer-v2](https://api.thegraph.com/subgraphs/name/balancer-labs/balancer-v2) |
| Polygon | [https://api.thegraph.com/subgraphs/name/balancer-labs/balancer-polygon-v2](https://api.thegraph.com/subgraphs/name/balancer-labs/balancer-polygon-v2) |
| Polygon zkEVM | [https://api.studio.thegraph.com/query/24660/balancer-polygon-zk-v2/version/latest](https://api.studio.thegraph.com/query/24660/balancer-polygon-zk-v2/version/latest) |
| Arbitrum | [https://api.thegraph.com/subgraphs/name/balancer-labs/balancer-arbitrum-v2](https://api.thegraph.com/subgraphs/name/balancer-labs/balancer-arbitrum-v2) |
| Optimism | [https://api.thegraph.com/subgraphs/name/balancer-labs/balancer-optimism-v2](https://api.thegraph.com/subgraphs/name/balancer-labs/balancer-optimism-v2) |
| Gnosis Chain | [https://api.thegraph.com/subgraphs/name/balancer-labs/balancer-gnosis-chain-v2](https://api.thegraph.com/subgraphs/name/balancer-labs/balancer-gnosis-chain-v2) |
| Avalanche | [https://api.thegraph.com/subgraphs/name/balancer-labs/balancer-avalanche-v2](https://api.thegraph.com/subgraphs/name/balancer-labs/balancer-avalanche-v2) |
| Base | [https://api.studio.thegraph.com/query/24660/balancer-base-v2/version/latest](https://api.studio.thegraph.com/query/24660/balancer-base-v2/version/latest) |
| Goerli | [https://api.thegraph.com/subgraphs/name/balancer-labs/balancer-goerli-v2](https://api.thegraph.com/subgraphs/name/balancer-labs/balancer-goerli-v2) |
| Sepolia | [https://api.studio.thegraph.com/query/24660/balancer-sepolia-v2/version/latest](https://api.studio.thegraph.com/query/24660/balancer-sepolia-v2/version/latest) |

### GraphQL Schema

The schema of GraphQL elements available is defined in [`/schema.graphql` ](https://github.com/balancer/balancer-subgraph-v2/blob/master/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.

#### Examples

Pools with > $100k liquidity

```graphql
{
pools(first: 1000, where: { totalLiquidity_gt: 100000 }) {
address
tokensList
totalLiquidity
}
}
```

Historical liquidity of a pool

```graphql
{
poolHistoricalLiquidities(
where: {
poolId: "0x09253c3554fb7242608ff67ce048918ccf7f9a96000200000000000000000009"
}
) {
block
poolLiquidity
}
}
```

Fetch a Liquidity Provider's shares

```graphql
{
poolShares(
first: 1000
where: {
userAddress: "0xef8305e140ac520225daf050e2f71d5fbcc543e7"
balance_gt: 0
}
) {
balance
poolId {
tokensList
totalShares
}
}
}
```

Fetch historical metrics for a given pool

```graphql
{
poolSnapshots(
first: 1000
orderBy: timestamp
orderDirection: asc
where: {
pool: "0x5c6ee304399dbdb9c8ef030ab642b10820db8f56000200000000000000000014"
}
) {
amounts
totalShares
swapVolume
swapFees
liquidity
pool {
id
}
}
}
```

Find pools that have specific tokens in them (WETH and BAL in this example)

```graphql
{
pools(
first: 100
where: {
tokensList_contains: [
"0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2"
"0xba100000625a3754423978a60c9317c58a424e3D"
]
}
) {
id
poolType
poolTypeVersion
}
}
```
The Balancer Subgraphs indexes data on the Balancer smart contracts with a GraphQL interface. It updates data in response to function calls and contract events to power front-end apps and integrations.

Balancer uses Subgraph Studio for development and deployment of its subgraphs. For querying non-rate-limited endpoints, users need to obtain an API key from The Graph. More information on querying The Graph can be found [here](https://thegraph.com/docs/en/querying/querying-the-graph/).

## V2 Subgraphs

The V2 Subgraphs contain data from the Balancer Vault, including pool token balances and pool parameters.

The schema of GraphQL elements available is defined in [`/schema.graphql` ](https://github.com/balancer/balancer-subgraph-v2/blob/master/schema.graphql).

| Network | Production Subgraph URL | Development Subgraph URL (rate-limited) |
| ------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Ethereum | [https://gateway-arbitrum.network.thegraph.com/api/[API-KEY]/subgraphs/id/C4ayEZP2yTXRAB8vSaTrgN4m9anTe9Mdm2ViyiAuV9TV](https://gateway-arbitrum.network.thegraph.com/api/[API-KEY]/subgraphs/id/C4ayEZP2yTXRAB8vSaTrgN4m9anTe9Mdm2ViyiAuV9TV) | [https://api.studio.thegraph.com/query/75376/balancer-v2/version/latest](https://api.studio.thegraph.com/query/75376/balancer-v2/version/latest) |
| Polygon | [https://gateway-arbitrum.network.thegraph.com/api/[API-KEY]/subgraphs/id/H9oPAbXnobBRq1cB3HDmbZ1E8MWQyJYQjT1QDJMrdbNp](https://gateway-arbitrum.network.thegraph.com/api/[API-KEY]/subgraphs/id/H9oPAbXnobBRq1cB3HDmbZ1E8MWQyJYQjT1QDJMrdbNp) | [https://api.studio.thegraph.com/query/75376/balancer-polygon-v2/version/latest](https://api.studio.thegraph.com/query/75376/balancer-polygon-v2/version/latest) |
| Arbitrum | [https://gateway-arbitrum.network.thegraph.com/api/[API-KEY]/subgraphs/id/98cQDy6tufTJtshDCuhh9z2kWXsQWBHVh2bqnLHsGAeS](https://gateway-arbitrum.network.thegraph.com/api/[API-KEY]/subgraphs/id/98cQDy6tufTJtshDCuhh9z2kWXsQWBHVh2bqnLHsGAeS) | [https://api.studio.thegraph.com/query/75376/balancer-arbitrum-v2/version/latest](https://api.studio.thegraph.com/query/75376/balancer-arbitrum-v2/version/latest) |
| Optimism | [https://gateway-arbitrum.network.thegraph.com/api/[API-KEY]/subgraphs/id/FsmdxmvBJLGjUQPxKMRtcWKzuCNpomKuMTbSbtRtggZ7](https://gateway-arbitrum.network.thegraph.com/api/[API-KEY]/subgraphs/id/FsmdxmvBJLGjUQPxKMRtcWKzuCNpomKuMTbSbtRtggZ7) | [https://api.studio.thegraph.com/query/75376/balancer-optimism-v2/version/latest](https://api.studio.thegraph.com/query/75376/balancer-optimism-v2/version/latest) |
| Gnosis Chain | [https://gateway-arbitrum.network.thegraph.com/api/[API-KEY]/subgraphs/id/EJezH1Cp31QkKPaBDerhVPRWsKVZLrDfzjrLqpmv6cGg](https://gateway-arbitrum.network.thegraph.com/api/[API-KEY]/subgraphs/id/EJezH1Cp31QkKPaBDerhVPRWsKVZLrDfzjrLqpmv6cGg) | [https://api.studio.thegraph.com/query/75376/balancer-gnosis-chain-v2/version/latest](https://api.studio.thegraph.com/query/75376/balancer-gnosis-chain-v2/version/latest) |
| Avalanche | [https://gateway-arbitrum.network.thegraph.com/api/[API-KEY]/subgraphs/id/7asfmtQA1KYu6CP7YVm5kv4bGxVyfAHEiptt2HMFgkHu](https://gateway-arbitrum.network.thegraph.com/api/[API-KEY]/subgraphs/id/7asfmtQA1KYu6CP7YVm5kv4bGxVyfAHEiptt2HMFgkHu) | [https://api.studio.thegraph.com/query/75376/balancer-avalanche-v2/version/latest](https://api.studio.thegraph.com/query/75376/balancer-avalanche-v2/version/latest) |
| Base | [https://api.studio.thegraph.com/query/24660/balancer-base-v2/version/latest](https://api.studio.thegraph.com/query/24660/balancer-base-v2/version/latest) | [https://api.studio.thegraph.com/query/24660/balancer-base-v2/version/latest](https://api.studio.thegraph.com/query/24660/balancer-base-v2/version/latest) |
| Sepolia | [https://api.studio.thegraph.com/query/24660/balancer-sepolia-v2/version/latest](https://api.studio.thegraph.com/query/24660/balancer-sepolia-v2/version/latest) | [https://api.studio.thegraph.com/query/24660/balancer-sepolia-v2/version/latest](https://api.studio.thegraph.com/query/24660/balancer-sepolia-v2/version/latest) |
| Mode | [https://api.studio.thegraph.com/query/75376/balancer-mode-v2/version/latest](https://api.studio.thegraph.com/query/75376/balancer-mode-v2/version/latest) | [https://api.studio.thegraph.com/query/75376/balancer-mode-v2/version/latest](https://api.studio.thegraph.com/query/75376/balancer-mode-v2/version/latest) |
| Polygon zkEVM | [https://api.studio.thegraph.com/query/24660/balancer-polygon-zk-v2/version/latest](https://api.studio.thegraph.com/query/24660/balancer-polygon-zk-v2/version/latest) | [https://api.studio.thegraph.com/query/24660/balancer-polygon-zk-v2/version/latest](https://api.studio.thegraph.com/query/24660/balancer-polygon-zk-v2/version/latest) |

## Gauges Subgraphs

The Gauges Subgraphs include data from liquidity gauges and veBAL contracts.

The schema of GraphQL elements available is defined in [`/schema.graphql` ](https://github.com/balancer/gauges-subgraph/blob/master/schema.graphql).

| Network | Production Subgraph URL | Development Subgraph URL (rate-limited) |
| ------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Ethereum | [https://gateway-arbitrum.network.thegraph.com/api/[API-KEY]/subgraphs/id/4sESujoqmztX6pbichs4wZ1XXyYrkooMuHA8sKkYxpTn](https://gateway-arbitrum.network.thegraph.com/api/[API-KEY]/subgraphs/id/4sESujoqmztX6pbichs4wZ1XXyYrkooMuHA8sKkYxpTn) | [https://api.studio.thegraph.com/query/75376/balancer-gauges/version/latest](https://api.studio.thegraph.com/query/75376/balancer-gauges/version/latest) |
| Polygon | [https://gateway-arbitrum.network.thegraph.com/api/[API-KEY]/subgraphs/id/FxSLKXiieSqBCjDGPbqayhqbxyNtwaEC5M3rxr6hUa8h](https://gateway-arbitrum.network.thegraph.com/api/[API-KEY]/subgraphs/id/FxSLKXiieSqBCjDGPbqayhqbxyNtwaEC5M3rxr6hUa8h) | [https://api.studio.thegraph.com/query/75376/balancer-gauges-polygon/version/latest](https://api.studio.thegraph.com/query/75376/balancer-gauges-polygon/version/latest) |
| Arbitrum | [https://gateway-arbitrum.network.thegraph.com/api/[API-KEY]/subgraphs/id/Bb1hVjJZ52kL23chZyyGWJKrGEg3S6euuNa1YA6XRU4J](https://gateway-arbitrum.network.thegraph.com/api/[API-KEY]/subgraphs/id/Bb1hVjJZ52kL23chZyyGWJKrGEg3S6euuNa1YA6XRU4J) | [https://api.studio.thegraph.com/query/75376/balancer-gauges-arbitrum/version/latest](https://api.studio.thegraph.com/query/75376/balancer-gauges-arbitrum/version/latest) |
| Optimism | [https://gateway-arbitrum.network.thegraph.com/api/[API-KEY]/subgraphs/id/CbLt7GqU7sypjRaCfwissEBkFeCw3dUz2emrvBNJ7dZu](https://gateway-arbitrum.network.thegraph.com/api/[API-KEY]/subgraphs/id/CbLt7GqU7sypjRaCfwissEBkFeCw3dUz2emrvBNJ7dZu) | [https://api.studio.thegraph.com/query/75376/balancer-gauges-optimism/version/latest](https://api.studio.thegraph.com/query/75376/balancer-gauges-optimism/version/latest) |
| Gnosis Chain | [https://gateway-arbitrum.network.thegraph.com/api/[API-KEY]/subgraphs/id/HW5XpZBi2iYDLBqqEEMiRJFx8ZJAQak9uu5TzyH9BBxy](https://gateway-arbitrum.network.thegraph.com/api/[API-KEY]/subgraphs/id/HW5XpZBi2iYDLBqqEEMiRJFx8ZJAQak9uu5TzyH9BBxy) | [https://api.studio.thegraph.com/query/75376/balancer-gauges-gnosis-chain/version/latest](https://api.studio.thegraph.com/query/75376/balancer-gauges-gnosis-chain/version/latest) |
| Avalanche | [https://gateway-arbitrum.network.thegraph.com/api/[API-KEY]/subgraphs/id/GzGBUh1X4Cq9RBdyKoCrPLhYW1saBYHwFBgcTsARPYUG](https://gateway-arbitrum.network.thegraph.com/api/[API-KEY]/subgraphs/id/GzGBUh1X4Cq9RBdyKoCrPLhYW1saBYHwFBgcTsARPYUG) | [https://api.studio.thegraph.com/query/75376/balancer-gauges-avalanche/version/latest](https://api.studio.thegraph.com/query/75376/balancer-gauges-avalanche/version/latest) |
| Base | [https://api.studio.thegraph.com/query/24660/balancer-base-v2/version/latest](https://api.studio.thegraph.com/query/24660/balancer-base-v2/version/latest) | [https://api.studio.thegraph.com/query/24660/balancer-gauges-base/version/latest](https://api.studio.thegraph.com/query/24660/balancer-gauges-base/version/latest) |
| Sepolia | [https://api.studio.thegraph.com/query/24660/balancer-sepolia-v2/version/latest](https://api.studio.thegraph.com/query/24660/balancer-sepolia-v2/version/latest) | [https://api.studio.thegraph.com/query/24660/balancer-gauges-sepolia/version/latest](https://api.studio.thegraph.com/query/24660/balancer-gauges-sepolia/version/latest) |
| Mode | [https://api.studio.thegraph.com/query/75376/balancer-gauges-mode/version/latest](https://api.studio.thegraph.com/query/75376/balancer-gauges-mode/version/latest) | [https://api.studio.thegraph.com/query/75376/balancer-gauges-mode/version/latest](https://api.studio.thegraph.com/query/75376/balancer-gauges-mode/version/latest) |
| Polygon zkEVM | [https://api.studio.thegraph.com/query/24660/balancer-gauges-polygon-zk/version/latest](https://api.studio.thegraph.com/query/24660/balancer-gauges-polygon-zk/version/latest) | [https://api.studio.thegraph.com/query/24660/balancer-gauges-polygon-zk/version/latest](https://api.studio.thegraph.com/query/24660/balancer-gauges-polygon-zk/version/latest) |

0 comments on commit 101a64f

Please sign in to comment.