v2 Protocol Query Examples

Last modified:

Subgraph Query Examples (v2)

This guide shows practical GraphQL queries for CenturionDEX v2 analytics data.

Run these queries in the v2 explorer.

Global Data

Current Global Data

{
  centurionFactory(id: "0x0000000000000000000000000000000000000000") {
    totalVolumeUSD
    totalLiquidityUSD
    txCount
  }
}

Historical Global Data

{
  centurionFactory(
    id: "0x0000000000000000000000000000000000000000"
    block: { number: 10291203 }
  ) {
    totalVolumeUSD
    totalLiquidityUSD
    txCount
  }
}

Pair Data

Pair Overview

{
  pair(id: "0xa478c2975ab1ea89e8196811f51a7b7ade33eb11") {
    token0 {
      id
      symbol
      name
      derivedCTN
    }
    token1 {
      id
      symbol
      name
      derivedCTN
    }
    reserve0
    reserve1
    reserveUSD
    trackedReserveCTN
    token0Price
    token1Price
    volumeUSD
    txCount
  }
}

Most Liquid Pairs

{
  pairs(first: 1000, orderBy: reserveUSD, orderDirection: desc) {
    id
  }
}

Recent Swaps in a Pair

{
  swaps(
    orderBy: timestamp
    orderDirection: desc
    where: { pair: "0xa478c2975ab1ea89e8196811f51a7b7ade33eb11" }
  ) {
    pair {
      token0 { symbol }
      token1 { symbol }
    }
    amount0In
    amount0Out
    amount1In
    amount1Out
    amountUSD
    to
  }
}

Pair Daily Aggregates

{
  pairDayDatas(
    first: 100
    orderBy: date
    orderDirection: asc
    where: {
      pairAddress: "0xa478c2975ab1ea89e8196811f51a7b7ade33eb11"
      date_gt: 1592505859
    }
  ) {
    date
    dailyVolumeToken0
    dailyVolumeToken1
    dailyVolumeUSD
    reserveUSD
  }
}

Token Data

Token Overview

{
  token(id: "0x6b175474e89094c44da98b954eedeac495271d0f") {
    name
    symbol
    decimals
    derivedCTN
    tradeVolumeUSD
    totalLiquidity
  }
}

Token Daily Aggregates

{
  tokenDayDatas(
    orderBy: date
    orderDirection: asc
    where: { token: "0x6b175474e89094c44da98b954eedeac495271d0f" }
  ) {
    id
    date
    priceUSD
    totalLiquidityToken
    totalLiquidityUSD
    totalLiquidityCTN
    dailyVolumeCTN
    dailyVolumeToken
    dailyVolumeUSD
  }
}

Pagination Patterns

Use first + skip for large result sets (The Graph returns up to 1000 entities per query).

query pairs($skip: Int!) {
  pairs(first: 1000, skip: $skip) {
    id
  }
}
query tokens($skip: Int!) {
  tokens(first: 1000, skip: $skip) {
    id
    name
    symbol
  }
}

Notes

  • Keep addresses lowercase in filters and IDs.
  • Use block-based queries for time-travel snapshots.
  • centurionFactory is the protocol-level aggregate entity for v2 subgraph metrics.

Further Reading