getTokenPoolPrice

Returns the latest DEX trade on Ethereum, where buy currency smart contract is 0x8c1b…6549, sell currency smart contract is 0xc02a…6cc2 and pair smart contract is 0x: average of trade buy price.

By Jose · saved 8 October 2024 · run 3 times · Bitquery API v2

What it returns

Filters

The query

query getTokenPoolPrice(
  $dataset: dataset_arg_enum!
  $network: evm_network
  $tokenAddress: String!
  $sideTokenAddress: String!
  $pairAddress: String!
) {
  EVM(network: $network, dataset: $dataset) {
    DEXTrades(
      limit: { count: 1 }
      orderBy: { descending: Block_Time }
      where: {
        Trade: {
          Buy: { Currency: { SmartContract: { is: $tokenAddress } } }
          Sell: { Currency: { SmartContract: { is: $sideTokenAddress } } }
          Dex: { Pair: { SmartContract: { is: $pairAddress } } }
        }
        TransactionStatus: { Success: true }
      }
    ) {
      AveragePrice: average(of: Trade_Buy_Price)
    }
  }
}

Variables

{
  "dataset": "combined",
  "network": "eth",
  "pairAddress": "0x",
  "tokenAddress": "0x8c1bed5b9a0928467c9b1341da1d7bd5e10b6549",
  "sideTokenAddress": "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2"
}

Similar queries