Skip to main content

Subgraph API

Swaap Labs uses subgraph to index data based on events emitted by the Factory and by the Swaap Pools.

This guide helps you get different analytics by using GraphQL.

Subgraph URL: https://api.thegraph.com/subgraphs/name/swaap-labs/swaapv1

Examples

  1. Get the Pools in order of liquidity
{
pools: pools(orderBy: liquidity, orderDirection: desc, where: {finalized: true}) {
id
tokens {
address
}
liquidity
swapFee
}
}


  1. Get the Pools with specific tokens
{
pools (orderBy: liquidity, orderDirection: desc,
where: {tokensList_contains: ["0x7ceb23fd6bc0add59e62ac25578270cff1b9f619","0x2791bca1f2de4661ed88a30c99a7a9449aa84174"],
publicSwap: true,
liquidity_gt: 0}) {
id
liquidity
tokens {
address
decimals
}
}
}


  1. Get the Pools total volume
{
pools (orderBy: totalSwapVolume, orderDirection: desc,
where: {tokensList_contains: ["0x7ceb23fd6bc0add59e62ac25578270cff1b9f619","0x2791bca1f2de4661ed88a30c99a7a9449aa84174"],
publicSwap: true,
liquidity_gt: 0}) {
id
totalSwapVolume
liquidity
tokens {
address
decimals
}
}
}


  1. Get a Pool's parameters
{
pools (orderBy: liquidity, orderDirection: desc,
where: {id: "0x7f5f7411c2c7ec60e2db946abbe7dc354254870b",}) {
id
tokens {
address
decimals
oracleInitialState {
proxy
price: fixedPointPrice
decimals
}
}
liquidity
swapFee
dynamicCoverageFeesZ
dynamicCoverageFeesHorizon
priceStatisticsLookbackInSec
priceStatisticsLookbackInRound
priceStatisticsLookbackStepInRound
maxPriceUnpegRatio
}
}