Candles

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

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

What it returns

Filters

The query

query ($since: DateTime!, $token0: String!) {
  EVM(dataset: realtime, network: eth) {
    candles: DEXTradeByTokens(
      orderBy: {ascendingByField: "Block_Time"}
      where: {Block: {Time: {since: $since}}, Trade: {Side: {Currency: {SmartContract: {is: $token0}}, Type: {}}}}
    ) {
      Block {
        Time(interval: {in: minutes, count: 10})
      }
      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
    },
    buy_volumes: DEXTradeByTokens(
      orderBy: {ascendingByField: "Block_Time"}
      where: {Block: {Time: {since: $since}}, Trade: {Side: {Currency: {SmartContract: {is: $token0}}, Type: {in: buy}}}}
    ) {
      Block {
        Time(interval: {in: minutes, count: 10})
      }
      volume: sum(of: Trade_Amount)
      count
    }
     sell_volumes: DEXTradeByTokens(
      orderBy: {ascendingByField: "Block_Time"}
      where: {Block: {Time: {since: $since}}, Trade: {Side: {Currency: {SmartContract: {is: $token0}}, Type: {in: sell}}}}
    ) {
      Block {
        Time(interval: {in: minutes, count: 10})
      }
      volume: sum(of: Trade_Amount)
      count
    }
  }
  }

Variables

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

Similar queries