query_long

Returns the latest transfer: transfer amount, smart contract, sum of trade buy amount in USD, sum of trade sell amount in USD, count and trade price.

By Omkar_BQ · saved 1 July 2024 · Bitquery API v2

What it returns

The query

query PairData($pairAddress: String!, $network: evm_network!, $createdAt: DateTime!, $tokenAddress: String!, $weth: String!) {
  EVM(dataset: combined, network: $network) {
    initialLiquidity: Transfers(
      limit: {count: 2}
      orderBy: {ascending: Block_Time}
      where: {Transfer: {Receiver: {is: $pairAddress}}}
    ) {
      Transfer {
        Amount
        Currency {
          SmartContract
        }
      }
    }
    volume: DEXTrades(
      where: {Block: {Time: {since: $createdAt}}, Trade: {Dex: {Pair: {SmartContract: {is: $pairAddress}}}}}
    ) {
      token1_vol: sum(of: Trade_Buy_AmountInUSD)
      token2_vol: sum(of: Trade_Sell_AmountInUSD)
      sellTrades: count(
        if: {Trade: {Buy: {Currency: {SmartContract: {is: $tokenAddress}}}}}
      )
      buyTrades: count(if: {Trade: {Buy: {Currency: {SmartContract: {is: $weth}}}}})
    }
    price: DEXTradeByTokens(
      where: {Trade: {Dex: {Pair: {SmartContract: {is: $pairAddress}}}, Currency: {SmartContract: {is: $tokenAddress}}}}
      orderBy: {descending: Block_Time}
      limit: {count: 1}
    ) {
      Trade {
        Price
      }
    }
  }
}

Similar queries