shaheem query

Returns the latest DEX trade on Ethereum, where buy currency smart contract is 0x62B6…D80C, sell currency smart contract is 0xC02a…6Cc2 and pair smart contract is 0x8B26…337c: buy currency symbol, buy price, buy price in USD, buy amount, buy buyer, sell currency symbol, protocol name and 2 more fields.

By Divyasshree · saved 25 December 2024 · Bitquery API v2

What it returns

Filters

The query

query ($baseTokenAddress: String, $quoteTokenAddress: String, $pairAddress: String) {
  EVM(network: eth) {
    DEXTrades(
      where: {Trade: {Buy: {Currency: {SmartContract: {is: $baseTokenAddress}}}, Sell: {Currency: {SmartContract: {is: $quoteTokenAddress}}}, Dex: {Pair: {SmartContract: {is: $pairAddress}}}}, TransactionStatus: {Success: true}}
      limit: {count: 1}
      orderBy: {descending: Block_Time}
    ) {
      Trade {
        Buy {
          Currency {
            Symbol
          }
          quotePrice: Price
          basePriceUsd: PriceInUSD
          Amount
          Buyer
        }
        Sell {
          Currency {
            Symbol
          }
        }
        Dex {
          ProtocolName
        }
      }
      Block {
        Time
        Number
      }
    }
  }
}

Variables

{
  "baseTokenAddress": "0x62B6d83d5aFBf395ece55136E7161c119a8FD80C",
  "quoteTokenAddress": "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2",
  "pairAddress": "0x8B26e5793aaaD4De63b4F990fceC08F3cE65337c"
}

Similar queries