ton top pairs

Returns 100 DEX trades by token on TON, sorted by USD, highest first: currency name, currency symbol, smart contract address, workchain, side currency name, side currency symbol, side smart contract address and 8 more fields.

By Srdjan Stankovic · saved 21 October 2024 · run 5 times · Bitquery API v2

What it returns

The query

query pairs(
  $min_count: String
  $time_ago: DateTime
  $weth: String!
  $usdc: String!
  $usdt: String!
  $time_10min_ago: DateTime
  $time_1h_ago: DateTime
  $time_3h_ago: DateTime
) {
  Ton {
    DEXTradeByTokens(
      where: {
        Block: { Time: { since: $time_ago } }
        any: [
          { Trade: { Side: { Currency: { Native: true } } } }
          {
            Trade: {
              Side: { Currency: { SmartContract: { Address: { is: $usdt } } } }
              Currency: { Native: false }
            }
          }
          {
            Trade: {
              Side: { Currency: { SmartContract: { Address: { is: $usdc } } } }
              Currency: { SmartContract: { Address: { notIn: [$usdt] } } }
            }
          }
          {
            Trade: {
              Side: { Currency: { SmartContract: { Address: { is: $weth } } } }
              Currency: {
                Native: false
                SmartContract: { Address: { notIn: [$usdc, $usdt] } }
              }
            }
          }
          {
            Trade: {
              Side: {
                Currency: {
                  Native: false
                  SmartContract: { Address: { notIn: [$usdc, $usdt, $weth] } }
                }
              }
              Currency: {
                Native: false
                SmartContract: { Address: { notIn: [$usdc, $usdt, $weth] } }
              }
            }
          }
        ]
      }
      orderBy: { descendingByField: "usd" }
      limit: { count: 100 }
    ) {
      Trade {
        Currency {
          Name
          Symbol
          SmartContract {
            Address
            Workchain
          }
        }
        Side {
          Currency {
            Name
            Symbol
            SmartContract {
              Address
              Workchain
            }
          }
        }

        price_last: PriceInUSD(maximum: Block_Number)
        price_10min_ago: PriceInUSD(
          maximum: Block_Number
          if: { Block: { Time: { before: $time_10min_ago } } }
        )
        price_1h_ago: PriceInUSD(
          maximum: Block_Number
          if: { Block: { Time: { before: $time_1h_ago } } }
        )
        price_3h_ago: PriceInUSD(
          maximum: Block_Number
          if: { Block: { Time: { before: $time_3h_ago } } }
        )
      }
      dexes: uniq(of: Trade_Dex_SmartContract_Address)
      amount: sum(of: Trade_Side_Amount)
      usd: sum(of: Trade_Side_AmountInUSD)
      sellers: uniq(of: Trade_Seller_Address)
      buyers: uniq(of: Trade_Buyer_Address)
      count(selectWhere: { ge: $min_count })
    }
  }
}

Variables

{
  "usdc": "EQB-MPwrd1G6WKNkLz_VnV6WqBDd142KMQv-g1O-8QUA3728",
  "usdt": "EQCxE6mUtQJKFnGfaROTKOt1lZbDiiX1kCixRv7Nw2Id_sDs",
  "pton": "EQAyvcnP0RexLvnsQMXfKYnk18Bzl3Y-iGt6bXqFB75ugXmE",
  "min_count": "100",
  "time_10min_ago": "2024-10-21T14:41:57Z",
  "time_1h_ago": "2024-10-21T13:51:57Z",
  "time_3h_ago": "2024-10-21T11:51:57Z"
}

Similar queries