📇Indexer

📇 Indexer

Query Examples

This doc will teach you how to query TONCO analytics by writing GraphQL queries on the subgraph.

Explore

Explorer page: https://indexer.tonco.io

GraphQL endpoint: https://indexer.tonco.io

Global Data

An example querying total pool count, transaction count, and total volume in USD and TON for 2 days. Same way you can query historical data.

{
  dexData(from: 1733173200000, to: 1733259600000, groupBy: DAY) {
    poolCount
    txCount
    totalVolumeTon
    totalVolumeUsd
    totalValueLockedUsd
  }
}

Pool Data

To get data about a certain pool, pass in the pool address. Reference the full pool schema and adjust the query fields to retrieve the data points you want.

All Possible Pools

The query below returns the fee, spot price and liquidity for all pools

{
  pools {
    fee
    liquidity
    priceSqrt
    jetton0 {
      address
      symbol
      decimals
    }
    jetton1 {
      address
      symbol
      decimals
    }
  }
}

Specific Pool Query

The query below returns the fee, spot price and liquidity for the TON-USDT pool.

{
  pools (where: { address: "0:f6e6f4ad13073e875413d6a96c60f430a94e4888e868c79208d02ff1b0336931" }) {
    fee
    liquidity
    priceSqrt
    jetton0 {
      address
      symbol
      decimals
    }
    jetton1 {
      address
      symbol
      decimals
    }
  }
}

Most Liquid Pools

Retrieve the top 10 most liquid pools. You can use this similar set up to orderBy other variables.

{
  pools ( filter: { first: 10, orderBy: "liquidity", orderDirection: desc }) {
    liquidity
  }
}

Swap Data

General Swap Data

To query data about a particular swap, input the transaction hash

{
  swaps (where: { hash: "9de6d148d6f6e5479bb50741c401b0f492d378ec798bc97b6ca5140b753c8ab4" } ) {
    hash
    time
    from
    to
    amount
    toRefund0
    toRefund1
    isZeroToOne
    pool {
      address
      jetton0 {
        address
        symbol
      }
      jetton1 {
        address
        symbol
      }
    }
  }
}

Recent Swaps Within a Pool

You can set the where field to filter swap data by pool address. This example fetches data about multiple swaps for the TON-USDT pool, ordered by time.

{
  swaps (where: { pool: "0:f6e6f4ad13073e875413d6a96c60f430a94e4888e868c79208d02ff1b0336931" }, filter: { orderBy: "time", orderDirection: desc }) {
    hash
    time
    from
    to
    amount
    toRefund0
    toRefund1
    isZeroToOne
    pool {
      address
      jetton0 {
        address
        symbol
      }
      jetton1 {
        address
        symbol
      }
    }
  }
}

Jetton Data

Input the jetton contract address to fetch jetton data. Any jetton that exists in at least one TONCO pool can be queried. The output will aggregate data across all pools that include the jetton.

General Jetton Data

This queries the decimals, symbol, name and volume in USD for the USDT token.

{
  jettons (where: { address: "0:b113a994b5024a16719f69139328eb759596c38a25f59028b146fecdc3621dfe" }) {
    symbol
    name
    decimals
    volumeUsd
  }
}

Jetton Daily Aggregated

You can fetch aggregate data about a specific token over a 24-hour period. This query gets 10-days of the 24-hour volume data for the TONCO token ordered from oldest to newest.

{
  jettonData(id: "0:b113a994b5024a16719f69139328eb759596c38a25f59028b146fecdc3621dfe", from: 1732395600000, to: 1733173200000, groupBy: DAY) {
    time
    totalValueLocked
  }
}

All Jettons

{
  jettons {
    address
    symbol
    name
    decimals
  }
}

Position Data

General Position Data

To get data about a specific position, input the NFT ID in the "tokenId:poolAddress" format. This queries the collected fees for token0 and token1 and current liquidity for the position with tokedId 502 in TON-USDT pool.

{
  positions (where: { id: "502:0:f6e6f4ad13073e875413d6a96c60f430a94e4888e868c79208d02ff1b0336931" }) {
    id
    collectedFeesJetton0
    collectedFeesJetton1
    liquidity
    jetton0 {
      symbol
      decimals
    }
    jetton1 {
      symbol
      decimals
    }
  }
}

Last updated