calculate avg price across time

Returns DEX trades on Ethereum and BNB Chain, where base currency is 0x07e5…Ee36, quote currency is 0xbb4C…095c and smart contract address is 0xdd81…bd71: minute and quote price.

By Belac · saved 17 April 2022 · run 5 times · Bitquery API v1

What it returns

Filters

The query

{
  ethereum(network: bsc) { # change as needed
    dexTrades(
      # date: {since: "2022-01-01"}
      baseCurrency: {is: "0x07e551E31A793E20dc18494ff6b03095A8F8Ee36"} # token traded to 
      quoteCurrency: {is: "0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c"} # token traded from
      exchangeName: {in: ["Pancake v2"]} # the protocol you want to check
      smartContractAddress: {is: "0xdd8124318d3dbfb486b4d9fbaba8a97409eebd71"} #the liquidity pool
      height: {lteq: 16967666, gteq: 16960000} #lteq is the maximum block (when the trade happened) gteq is the lowest block you want to check from
    ) {
      timeInterval {
        minute(format: "%FT%TZ", count: 60) #count is the number of minutes
      }
      price: quotePrice(calculate: maximum) # the maximum price across the "count" time period
    }
  }
}

Similar queries