Sample queries
This section provides sample examples on how you can query the subgraph to retrieve information about pools, tokens, transactions and more.
To query overall data you can pass in the Buni Flexible Pool Factory address and select from various fields.
Overall Stats
All time volume in USD, total liquidity in USD, all time transaction count.
{
buni(id: 1) {
totalLiquidity
totalSwapVolume
txCount
}
}
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.
{
buni(id: 1, block: {number: abc}) {
totalLiquidity
totalSwapVolume
txCount
}
}
Pool Overview
Returns a snapshot of the current state of the pool with common values.
{
pool(id: "abc") {
id
totalWeight
totalShares
totalSwapVolume
liquidity
tokensList
tokensCount
holdersCount
tokens {
id
symbol
balance
denormWeight
}
}
}
All Flexible Pools in Bunicorn
To fetch all flexible pools in Bunicorn might have to use a loop and graphql skip query, because of the limitation of Graph to return to 1000 per query.
{
query pools($skip: Int!) {
pools(first: 1000, skip: $skip) {
id
}
}
}
- where skip is an incrementing variable passed into your query
Most liquid pools
In the order of liquidity returns the most liquid flexible pools in Bunicorn.
{
pools(first: 1000, orderBy: liquidity, orderDirection: desc) {
id
}
}
You can visit the subgraph explorer play around to try out these queries and explore any other data you'd like.
Last modified 1yr ago