Candles

Returns DEX trades and DEX trades by token on Ethereum, where buy currency smart contract is 0xc02a…6cc2, sell currency smart contract is 0xdac1…1ec7 and side currency smart contract is 0xc02a…6cc2, sorted by block time: sum of trade buy amount, sum of trade sell amount, count, block time, sum of trade amount and trade price.

By CC · saved 3 April 2024 · run 11 times · Bitquery API v2

What it returns

Filters

The query

query($since:DateTime!, $token0: String!, $token1: String!) {
  EVM(dataset: realtime, network: eth) {
    Total_Buy_Amount: DEXTrades(
      where: {Block: {Time: {since: $since}}, Trade: {Buy: {Currency: {SmartContract: {is: $token0}}}, Sell: {Currency: {SmartContract: {is: $token1}}}}}
    ) {
      sum(of:Trade_Buy_Amount)
    }
    Total_Sell_Amount: DEXTrades(
      where: {Block: {Time: {since: $since }}, Trade: {Buy: {Currency: {SmartContract: {is: $token0}}}, Sell: {Currency: {SmartContract: {is: $token1}}}}}
    ) {
      sum(of:Trade_Sell_Amount)
    }
    Total_Transactions: DEXTrades(
      where: {Block: {Time: {since: $since}}, Trade: {Buy: {Currency: {SmartContract: {is: $token0}}}, Sell: {Currency: {SmartContract: {is: $token1}}}}}
    ) {
      count(distinct: Transaction_Hash)
    }
    DEXTradeByTokens(
      orderBy: {ascendingByField: "Block_Time"}
      where: {Block: {Time: {since: $since }}, Trade: {Side: {Currency: {SmartContract: {is: $token0}}}, Currency: {SmartContract: {is: $token1}}}},
    ) {
      Block {
        Time(interval: {in: minutes})
      }
      volume: sum(of: Trade_Amount)
      Trade {
        high: Price(maximum: Trade_Price)
        low: Price(minimum: Trade_Price)
        open: Price(minimum: Block_Number)
        close: Price(maximum: Block_Number)
      }
      count
    }
  }
}

Variables

{
  "since": "2024-04-03T11:53:15.839Z", "token0":"0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2", "token1":"0xdac17f958d2ee523a2206206994597c13d831ec7"
}

Similar queries