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

**URL:** <https://community.bitquery.io/t/query-for-amount-of-bnb-bought-sold-of-a-given-token/729>\
**Category:** GraphQL API\
**Created:** [December 14, 2021, 10:38am UTC](https://community.bitquery.io/t/query-for-amount-of-bnb-bought-sold-of-a-given-token/729 "2021-12-14T10:38:42Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![usern](https://avatars.discourse-cdn.com/v4/letter/u/c6cbf5/32.png) [@usern](https://community.bitquery.io/u/usern)\
**Post date:** [December 14, 2021, 10:38am UTC](https://community.bitquery.io/t/query-for-amount-of-bnb-bought-sold-of-a-given-token/729/1 "2021-12-14T10:38:42Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![gaurav](https://avatars.discourse-cdn.com/v4/letter/g/b487fb/32.png) [@gaurav](https://community.bitquery.io/u/gaurav)\
**Post date:** [December 14, 2021, 1:43pm UTC](https://community.bitquery.io/t/query-for-amount-of-bnb-bought-sold-of-a-given-token/729/2 "2021-12-14T13:43:23Z")

</div>

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

> **[total base amount and quote amount for a currency](https://graphql.bitquery.io/ide/total-base-amount-and-quote-amount-for-a-currency)**
>
> total base amount and quote amount for a currency

---

<div class="post-metadata">

**Author:** ![Clicker7](https://avatars.discourse-cdn.com/v4/letter/c/ecae2f/32.png) [@Clicker7](https://community.bitquery.io/u/Clicker7)\
**Post date:** [December 14, 2021, 2:33pm UTC](https://community.bitquery.io/t/query-for-amount-of-bnb-bought-sold-of-a-given-token/729/3 "2021-12-14T14:33:57Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![usern](https://avatars.discourse-cdn.com/v4/letter/u/c6cbf5/32.png) [@usern](https://community.bitquery.io/u/usern)\
**Post date:** [December 14, 2021, 3:48pm UTC](https://community.bitquery.io/t/query-for-amount-of-bnb-bought-sold-of-a-given-token/729/4 "2021-12-14T15:48:51Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![aman](https://avatars.discourse-cdn.com/v4/letter/a/90ced4/32.png) [@aman](https://community.bitquery.io/u/aman)\
**Post date:** [December 15, 2021, 7:13am UTC](https://community.bitquery.io/t/query-for-amount-of-bnb-bought-sold-of-a-given-token/729/5 "2021-12-15T07:13:19Z")

</div>

> [@usern](#):
>
> 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?

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

---

<div class="post-metadata">

**Author:** ![gaurav](https://avatars.discourse-cdn.com/v4/letter/g/b487fb/32.png) [@gaurav](https://community.bitquery.io/u/gaurav)\
**Post date:** [December 15, 2021, 4:59pm UTC](https://community.bitquery.io/t/query-for-amount-of-bnb-bought-sold-of-a-given-token/729/6 "2021-12-15T16:59:41Z")

</div>

Because we don’t have USD value for those tokens

---

<div class="post-metadata">

**Author:** ![usern](https://avatars.discourse-cdn.com/v4/letter/u/c6cbf5/32.png) [@usern](https://community.bitquery.io/u/usern)\
**Post date:** [December 15, 2021, 5:15pm UTC](https://community.bitquery.io/t/query-for-amount-of-bnb-bought-sold-of-a-given-token/729/7 "2021-12-15T17:15:05Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![gaurav](https://avatars.discourse-cdn.com/v4/letter/g/b487fb/32.png) [@gaurav](https://community.bitquery.io/u/gaurav)\
**Post date:** [December 16, 2021, 3:29pm UTC](https://community.bitquery.io/t/query-for-amount-of-bnb-bought-sold-of-a-given-token/729/8 "2021-12-16T15:29:19Z")

</div>

`(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](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)`
