Sample queries
This section provides sample examples on how you can query the subgraph to retrieve information about pools, tokens, transactions and more.

Overall Data

To query overall data you can pass in the Stable Factory address and select from various fields.
Overall Stats
All time volume in USD, total liquidity in USD, all time transaction count.
1
{
2
BuniCornFactory(id: "xyz"){
3
totalVolumeUSD
4
totalLiquidityUSD
5
txCount
6
}
7
}
Copied!
Overall Historical lookup
Use The Graph's block query feature and query at any earlier block to view the stats. This can be used to view things like 24hr volume etc.
1
{
2
BuniCornFactory(id: "xyz", block: {number: abc}){
3
totalVolumeUSD
4
totalLiquidityUSD
5
txCount
6
}
7
}
Copied!

Pools Data

Pool Overview
Returns a snapshot of the current state of the pool with common values. This example fetches the USDC/BUSD pool.
1
{
2
pool(id: "xyz"){
3
token0 {
4
id
5
symbol
6
name
7
USDC
8
}
9
token1 {
10
id
11
symbol
12
name
13
BUSD
14
}
15
reserve0
16
reserve1
17
reserveUSD
18
trackedReserveETH
19
token0Price
20
token1Price
21
volumeUSD
22
txCount
23
}
24
}
Copied!
All Pools in DMM
To fetch all pools on DMM might have to use a loop and graphql skip query, because of the limitation of Graph to return to 1000 per query.
1
{
2
query pools($skip: Int!) {
3
pools(first: 1000, skip: $skip) {
4
id
5
}
6
}
7
}
Copied!
    where skip is an incrementing variable passed into your query
Most liquid pools
In the order of liquidity returns the most liquid pools in Stable Pools.
1
{
2
pools(first: 1000, orderBy: reserveUSD, orderDirection: desc) {
3
id
4
}
5
}
Copied!
You can visit the subgraph sandbox play around to try out these queries and explore any other data you'd like.
Last modified 3mo ago
Copy link