top-traders-for-wld-usdc-pair

Historical data This query uses the realtime dataset (the default), which holds only a recent window - hours to days depending on the cube. For older data add a dataset to the top-level element: EVM(network: $network, dataset: combined) archive full history combined archive + realtime in one resu

By Kshitij Mahajan · saved 15 November 2024 · Bitquery API v2

What it returns

Filters

The query

# Historical data
#   This query uses the realtime dataset (the default), which holds only a
#   recent window - hours to days depending on the cube.
#
#   For older data add a dataset to the top-level element:
#
#     EVM(network: $network, dataset: combined)
#
#     archive   full history
#     combined  archive + realtime in one result
#
#   Archive and combined need the historical data add-on:
#   https://bitquery.io/pricing
#
# Datasets:  https://docs.bitquery.io/docs/graphql/dataset/archive/
# Retention: https://docs.bitquery.io/docs/graphql/data-coverage-retention/
#

query pairTopTraders($network: evm_network, $token: String, $base: String, $time_ago: DateTime) {
  EVM(network: $network) {
    DEXTradeByTokens(
      orderBy: {descendingByField: "volumeUsd"}
      limit: {count: 100}
      where: {Trade: {Currency: {SmartContract: {is: $base}}, Side: {Amount: {gt: "0"}, Currency: {SmartContract: {is: $token}}}}, Block: {Time: {since: $time_ago}}}
    ) {
      Trade {
        Buyer
      }
      bought: sum(of: Trade_Amount, if: {Trade: {Side: {Type: {is: buy}}}})
      sold: sum(of: Trade_Amount, if: {Trade: {Side: {Type: {is: sell}}}})
      volume: sum(of: Trade_Amount)
      sideVolume: sum(of: Trade_Side_Amount)
      volumeUsd: sum(of: Trade_Side_AmountInUSD)
    }
  }
}

Variables

{
  "network": "optimism",
  "base": "0xdc6ff44d5d932cbd77b52e5612ba0529dc6226f1",
  "token": "0x0b2c639c533813f4aa9d7837caf62653d097ff85",
  "time_ago": "2024-11-12T06:32:59Z"
}

Similar queries