v3 Queries

Last modified:

Overview

Use v3 subgraph queries for analytics, dashboards, historical analysis, and position reporting. For transaction execution and mission-critical live reads, use direct RPC/contract reads.

Explorer: v3 deployment

Protocol Metrics

{
  factory(id: "0x1F98431c8aD98523631AE4a59f267346ea31F984") {
    poolCount
    txCount
    totalVolumeUSD
    totalValueLockedUSD
  }
}

Pool State

{
  pool(id: "0x8ad599c3a0ff1de082011efddc58f1908eb6e6d8") {
    token0 { symbol }
    token1 { symbol }
    feeTier
    liquidity
    tick
    sqrtPrice
    totalValueLockedUSD
  }
}

Recent Swaps

{
  swaps(
    first: 20
    where: { pool: "0x8ad599c3a0ff1de082011efddc58f1908eb6e6d8" }
    orderBy: timestamp
    orderDirection: desc
  ) {
    timestamp
    sender
    recipient
    amount0
    amount1
    amountUSD
  }
}

Position Data

{
  position(id: "3") {
    id
    liquidity
    collectedFeesToken0
    collectedFeesToken1
    token0 { symbol }
    token1 { symbol }
  }
}

Historical Snapshot

{
  factory(
    id: "0x1F98431c8aD98523631AE4a59f267346ea31F984"
    block: { number: 13380584 }
  ) {
    poolCount
    totalVolumeUSD
    totalValueLockedUSD
  }
}

Pagination Pattern

query Pools($skip: Int!) {
  pools(first: 1000, skip: $skip, orderBy: totalValueLockedUSD, orderDirection: desc) {
    id
    totalValueLockedUSD
  }
}

Increase skip by 1000 until the response count is less than 1000.

See Also