Query for amount of bnb bought/sold of a given token

Hi guys, I would like to retrieve through graphql the cumulated amount of bnb that has been used to buy a coin and the cumulated amount of bnb that has been earned by selling that same coin, how could I do that?

You can use a query like this aggregate trade amount for a currency pair.

from the example above:
1272552$ used to buy a token named Gold
token named Gold sold for 1243355$
profit 29197$ ?

Thanks @gaurav that is a step in the right direction, but for some coins the baseAmount(calculate: sum, in: USD) returns 0, omitting in: USD gives me the correct amount in tokens, but I would need the value expressed in USD or preferably on BNB (would be nice to see both)
any ways to achieve this?

This happens when we don’t have their value in our system

Because we don’t have USD value for those tokens

Can’t that be retrieved by summing the amount of bnb that went from the user to the dex to know how much he bought and from the token’s pool to the user to know how much he got selling? Assuming you target a single pool for a token

(calculate: sum, in: USD)

because we don’t have USD data for those token that’s why 0.

We know how to get enable USD price for each asset on dex, we actually wrote an article on the

https://bitquery.io/blog/dex-price-index

but for now we can’t calculate USD values but you can get any other value

such as try (calculate: sum, in: USDT) or (calculate: sum, in: BNB)