Get Token Pair

Returns one DEX trade on Ethereum, where DEX protocol name is uniswap_v2: protocol name, owner address, smart contract, buy currency name, buy smart contract, sell currency name and sell smart contract.

By Gareth Rees · saved 3 February 2025 · Bitquery API v2

What it returns

Filters

The query

query getPair($fromToken: String, $toToken: String) {
  EVM(dataset: combined, network: eth) {
    DEXTrades(
      where: {Trade: {Buy: {Currency: {SmartContract: {is: $fromToken}}}, Sell: {Currency: {SmartContract: {is: $toToken}}}, Dex: {ProtocolName: {is: "uniswap_v2"}}}}
      limit: {count: 1}
      limitBy: {by: Trade_Sell_Currency_SmartContract, count: 1}
    ) {
      Trade {
        Dex {
          ProtocolName
          OwnerAddress
          SmartContract
        }
        Buy {
          Currency {
            Name
            SmartContract
          }
        }
        Sell {
          Currency {
            Name
            SmartContract
          }
        }
      }
    }
  }
}

Variables

{
  "fromToken": {
    "eq": "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2"
  }, 
  "toToken": {
    "eq": "0x50327c6c5a14dcade707abad2e27eb517df87ab5"
  }, 
}

Similar queries