Shared Kron

Returns 100 DEX trades by token and DEX trades on Ethereum, where currency smart contract is 0x37f5…d6f7, DEX smart contract is 0x5f63…2754 and block time since 2024-11-14: currency name, smart contract, currency symbol, price in USD, protocol name, protocol family, side currency symbol and 29 more fields.

By Nisal Chandrasekara · saved 27 November 2024 · Bitquery API v2

What it returns

Filters

The query

query MyQuery($network: evm_network, $token: String, $pairAddress: String, $min5_timestamp: DateTime, $hr1_timestamp: DateTime) {
  EVM(dataset: archive, network: $network) {
    DEXTradeByTokens(
      where: {TransactionStatus: {Success: true}, Trade: {Currency: {SmartContract: {is: $token}}, Dex: {SmartContract: {is: $pairAddress}}}, Block: {Time: {since: $hr1_timestamp}}}
    ) {
      Trade {
        Currency {
          Name
          SmartContract
          Symbol
        }
        startPrice: PriceInUSD(minimum: Block_Time)
        Price_at_min5: PriceInUSD(
          minimum: Block_Time
          if: {Block: {Time: {after: $min5_timestamp}}}
        )
        current_price: PriceInUSD(maximum: Block_Time)
        Dex {
          ProtocolName
          ProtocolFamily
          SmartContract
        }
        Side {
          Currency {
            Symbol
            Name
            SmartContract
          }
        }
      }
      makers: count(distinct: Transaction_From)
      makers_5min: count(
        distinct: Transaction_From
        if: {Block: {Time: {after: $min5_timestamp}}}
      )
      buyers: count(
        distinct: Transaction_From
        if: {Trade: {Side: {Type: {is: sell}}}}
      )
      buyers_5min: count(
        distinct: Transaction_From
        if: {Trade: {Side: {Type: {is: sell}}}, Block: {Time: {after: $min5_timestamp}}}
      )
      sellers: count(
        distinct: Transaction_From
        if: {Trade: {Side: {Type: {is: buy}}}}
      )
      sellers_5min: count(
        distinct: Transaction_From
        if: {Trade: {Side: {Type: {is: buy}}}, Block: {Time: {after: $min5_timestamp}}}
      )
      trades: count
      trades_5min: count(if: {Block: {Time: {after: $min5_timestamp}}})
      traded_volume: sum(of: Trade_Side_AmountInUSD)
      traded_volume_5min: sum(
        of: Trade_Side_AmountInUSD
        if: {Block: {Time: {after: $min5_timestamp}}}
      )
      buy_volume: sum(
        of: Trade_Side_AmountInUSD
        if: {Trade: {Side: {Type: {is: sell}}}}
      )
      buy_volume_5min: sum(
        of: Trade_Side_AmountInUSD
        if: {Trade: {Side: {Type: {is: sell}}}, Block: {Time: {after: $min5_timestamp}}}
      )
      sell_volume: sum(
        of: Trade_Side_AmountInUSD
        if: {Trade: {Side: {Type: {is: buy}}}}
      )
      sell_volume_5min: sum(
        of: Trade_Side_AmountInUSD
        if: {Trade: {Side: {Type: {is: buy}}}, Block: {Time: {after: $min5_timestamp}}}
      )
      buys: count(if: {Trade: {Side: {Type: {is: sell}}}})
      buys_5min: count(
        if: {Trade: {Side: {Type: {is: sell}}}, Block: {Time: {after: $min5_timestamp}}}
      )
      sells: count(if: {Trade: {Side: {Type: {is: buy}}}})
      sells_5min: count(
        if: {Trade: {Side: {Type: {is: buy}}}, Block: {Time: {after: $min5_timestamp}}}
      )
    }
    DEXTrades(limit: {count: 100}) {
      Transaction {
        Cost
        CostInUSD
        Type
        Value
        ValueInUSD
        To
        From
        Hash
        Time
      }
      Trade {
        Buy {
          Amount
          AmountInUSD
          Price
          PriceInUSD
          Seller
          Buyer
          Currency {
            Name
          }
        }
        Dex {
          ProtocolName
          Pair {
            Name
            SmartContract
          }
        }
        Sell {
          Amount
          AmountInUSD
          Buyer
          Seller
          PriceInUSD
          Price
        }
        Sender
        Success
      }
      TransactionStatus {
        Success
      }
    }
  }
}

Variables

{
  "network": "eth",
  "token": "0x37f5ac1b0c1a07d19270983d6889c181a0a3d6f7",
  "pairAddress": "0x5f6343F4258a8830f5cC1677F87CaB2877A32754",
  "hr1_timestamp": "2024-11-14T03:20:00Z",
  "min5_timestamp": "2024-11-14T04:15:00Z"
}

Similar queries