What is exchangeAddress, baseCurrency, quoteCurrency? And how do I get these?

I am a developer, my buyer told me with a link to create a chart. I get a query from the forum tutorial and create a chart with it.

{
  ethereum(network: bsc) {
    dexTrades(
      options: {asc: "timeInterval.minute"}
      date: {since: "2021-06-20T07:23:21.000Z", till: "2021-06-23T15:23:21.000Z"}
      exchangeAddress: {is: "0xcA143Ce32Fe78f1f7019d7d551a6402fC5350c73"}
      baseCurrency: {is: "0x6E0fB6B19941FAf58982F09b33A9dceDa4377155"},
      quoteCurrency: {is: "0xbb4cdb9cbd36b01bd1cbaebf2de08d9173bc095c"},
      tradeAmountUsd: {gt: 10}
    ) 
    {
      timeInterval {
        minute(count: 15, format: "%Y-%m-%dT%H:%M:%SZ")  
      }
      volume: quoteAmount
      high: quotePrice(calculate: maximum)
      low: quotePrice(calculate: minimum)
      open: minimum(of: block, get: quote_price)
      close: maximum(of: block, get: quote_price) 
    }
  }
}

That’s exactly working. I have to query the address now, if I change the address, the query data will be change. I want to know where I can get this address and how to collect this exchangeAddress, baseCurrency, quoteCurrency, does it have a different API?

Does console.log() work for you in that case? As you need the exchangeAddress, baseCurrency & quoteCurrency.

I’m using vue js.

<script>
import axios from "axios";
import * as Bitquery from "./Bitquery";

export default {
    name: 'App',
    mounted() {
        this.getCoinInfo();
        this.getBar();
    },
    methods: {
        async getBar() {
            const response2 = await axios.post(Bitquery.endpoint, {
                query: Bitquery.GET_COIN_BARS,
                variables: {
                    "from": new Date("2021-06-20T07:23:21.000Z").toISOString(),
                    "to": new Date("2021-06-23T15:23:21.000Z").toISOString(),
                },
                mode: 'cors',
                headers: {
                    "Content-Type": "application/json",
                    "X-API-KEY": "BQYs3889A2N8x3q6euyZWtc3JMosXy6o"
                }
            })

            const bars = response2.data.data.ethereum.dexTrades.map(el => ({
                time: new Date(el.timeInterval.minute).getTime(), // date string in api response
                low: el.low,
                high: el.high,
                open: Number(el.open),
                close: Number(el.close),
                volume: el.volume
            }))

            console.log(bars)

        },
        async getCoinInfo() {
            const response = await axios.post(
                Bitquery.endpoint, {
                    query: Bitquery.GET_COIN_INFO,
                    variables: {
                        "tokenAddress": 'price'
                    },
                    mode: 'cors',
                    headers: {
                        "Content-Type": "application/json",
                        "X-API-KEY": "BQYs3889A2N8x3q6euyZWtc3JMosXy6o"
                    }
                }
            );

            const coin = response.data.data.ethereum.dexTrades[0].baseCurrency;

            if(!coin){
                console.log('no coin')
            }else{
                const symbol = {
                    ticker: 'price',
                    name: `${coin.symbol}/USD`,
                    session: '24x7',
                    timezone: 'Etc/UTC',
                    minmov: 1,
                    pricescale: 10000000,
                    has_intraday: true,
                    intraday_multipliers: ['1', '5', '15', '30', '60'],
                    has_empty_bars: true,
                    has_weekly_and_monthly: false,
                    supported_resolutions: ['1','5','15','30', '60','1D', '1W', '1M'],
                    volume_precision: 1,
                    data_status: 'streaming',
                }

                console.log(symbol)
            }


        }
    }

}
</script>

Bitquery.js

export const endpoint = 'https://graphql.bitquery.io';

export const GET_COIN_INFO =`
{
  ethereum(network: bsc) {
    dexTrades(
      options: {desc: ["block.height", "transaction.index"], limit: 1}
      exchangeAddress: {is: "0xcA143Ce32Fe78f1f7019d7d551a6402fC5350c73"}
      baseCurrency: {is: "0x2170ed0880ac9a755fd29b2688956bd959f933f8"}
      quoteCurrency: {is: "0xbb4cdb9cbd36b01bd1cbaebf2de08d9173bc095c"}
    ) 
    {
      block {
        height
        timestamp {
          time(format: "%Y-%m-%d %H:%M:%S") 
        }
      }
      transaction {
        index
      }
      baseCurrency {
        name
        symbol
        decimals
      }
      quotePrice
    }
  }
}
`;

export const GET_COIN_BARS = `
{
  ethereum(network: bsc) {
    dexTrades(
      options: {asc: "timeInterval.minute"}
      date: {since: "2021-06-20T07:23:21.000Z", till: "2021-06-23T15:23:21.000Z"}
      exchangeAddress: {is: "0xcA143Ce32Fe78f1f7019d7d551a6402fC5350c73"}
      baseCurrency: {is: "0xa93e15caa52c9c2517b709b0b986a80b51b58b01"},
      quoteCurrency: {is: "0xbb4cdb9cbd36b01bd1cbaebf2de08d9173bc095c"},
      tradeAmountUsd: {gt: 10}
    ) 
    {
      timeInterval {
        minute(count: 15, format: "%Y-%m-%dT%H:%M:%SZ")  
      }
      volume: quoteAmount
      high: quotePrice(calculate: maximum)
      low: quotePrice(calculate: minimum)
      open: minimum(of: block, get: quote_price)
      close: maximum(of: block, get: quote_price) 
    }
  }
}
`;

consol log

You need the values of exchangeAddress, baseCurrency & quoteCurrency right?

1 Like

Yes, this is what I need. Is there a separate API for collecting it?

From the GET_COIN_INFO query, you can simply console.log() the following

console.log(response.data.data.ethereum.dexTrades[0].baseCurrency.name)
console.log(response.data.data.ethereum.dexTrades[0].baseCurrency.symbol)
console.log(response.data.data.ethereum.dexTrades[0].quoteCurrency.name)
console.log(response.data.data.ethereum.dexTrades[0].quoteCurrency.symbol)

would get you the quoteCurrency & baseCurrency values

1 Like

I understand. Thank you

1 Like