Pool queries
Endpoint: https://subgraph.barkswap.fi/subgraphs/name/barkswap/core
These are the queries the BarkSwap app uses for pool data.
List pools
query PoolsList {
pools {
id
fee
deployer
token0 { id symbol name decimals derivedMatic }
token1 { id symbol name decimals derivedMatic }
sqrtPrice
liquidity
tick
tickSpacing
totalValueLockedUSD
volumeUSD
feesUSD
token0Price
token1Price
poolDayData(first: 1, orderBy: date, orderDirection: desc) {
id
date
feesUSD
tvlUSD
volumeUSD
}
}
}
Add first, skip, orderBy, and where to paginate/sort, e.g. the top pools by TVL:
{
pools(first: 20, orderBy: totalValueLockedUSD, orderDirection: desc) {
id
token0 { symbol }
token1 { symbol }
totalValueLockedUSD
}
}
A single pool
id is the pool address, lowercased.
query SinglePool($poolId: ID!) {
pool(id: $poolId) {
id
fee
token0 { id symbol decimals }
token1 { id symbol decimals }
sqrtPrice
liquidity
tick
tickSpacing
totalValueLockedUSD
volumeUSD
}
}
{ "poolId": "0x1234abcd…" }
Pools for a token pair
{
pools(where: { token0: "0xaaa…", token1: "0xbbb…" }) {
id
fee
totalValueLockedUSD
}
}
Pool ticks (liquidity distribution)
Ticks are paginated 1000 at a time; increment skip until you get fewer than 1000 back.
query allTicks($poolAddress: String!, $skip: Int!) {
ticks(
first: 1000
skip: $skip
where: { poolAddress: $poolAddress }
orderBy: tickIdx
) {
tickIdx
liquidityNet
liquidityGross
price0
price1
}
}
{ "poolAddress": "0x1234abcd…", "skip": 0 }
Daily history
{
pool(id: "0x1234abcd…") {
poolDayData(first: 365, orderBy: date, orderDirection: desc) {
date
volumeUSD
feesUSD
tvlUSD
}
}
}
See the schema reference for every available Pool field.