<p>This can be done. I used to do it via the client. One can index the current price by looking at the script address of the dex and filtering the native asset to get the utxo that represents the liquidity pool. From that you can deduce the price by just dividing, <code>price = native asset amount in pool / ada amount in pool</code>. I used a bash script to watch this price together with awk, something like</p>
<pre><code>watch -n 1 'cardano cli query address $(cat addresOfDex) | awk \'*filter for line that contains native asset or pool id*\' | awk \'*devide the correct things*\'
</code></pre>
<p>Note that I ommitted the filters as I do not remember them. Db-sync can do something similar of course.</p>

CC BY-SA 4.0
2022-06-15T03:53:51.627Z
Thank you for the guidance to a possible solution!
RelevantData
CC BY-SA 4.0
2022-11-01T01:05:01.400Z
This is a useful answer except the equation should be: price in ada = ada amount / native asset amount
adjuric
CC BY-SA 4.0
2022-06-14T21:36:28.700Z
2022-06-14T21:36:28.700Z
Fermat
<p>Is there a way to query the price of a pair that's on a dex independent of the dex? For example: MIN/ADA or others? I am trying to see how the data in the cexplorer database could be used to do this.</p>

CC BY-SA 4.0
2022-06-14T21:14:33.933Z
`cardano-db-sync` does not track native asset prices.
Erik de Castro Lopo
CC BY-SA 4.0
2022-06-15T03:55:32.897Z
I do understand cardano-db-sync does not track prices of anything per-se, but I was asking if there is a method for extracting that information given the data available in cexplorer - i.e. a way of doing it yourself, not a way cardano-db-sync does it for you :|
RelevantData
CC BY-SA 4.0
2022-06-16T05:16:39.007Z
I would be surprised if all of the data you need is even in `db-sync`.
Erik de Castro Lopo
<cardano-db-sync>
Can the price of a Dex pair be tracked using the data in cexplorer / db-sync?
# Can the price of a Dex pair be tracked using the data in cexplorer / db-sync?

(Asked by: username_0 on 2022-06-14)

Is there a way to query the price of a pair that's on a dex independent of the dex? For example: MIN/ADA or others? I am trying to see how the data in the cexplorer database could be used to do this.

**Tags:** cardano-db-sync
> **Comments:**
> **username_1**: `cardano-db-sync` does not track native asset prices.  
> **username_0**: I do understand cardano-db-sync does not track prices of anything per-se, but I was asking if there is a method for extracting that information given the data available in cexplorer - i.e. a way of doing it yourself, not a way cardano-db-sync does it for you :|  
> **username_1**: I would be surprised if all of the data you need is even in `db-sync`.  

---

## 1 answers

### Answer by username_2 on 2022-06-14. Score: 0 | Accepted answer

This can be done. I used to do it via the client. One can index the current price by looking at the script address of the dex and filtering the native asset to get the utxo that represents the liquidity pool. From that you can deduce the price by just dividing, price = native asset amount in pool / ada amount in pool. I used a bash script to watch this price together with awk, something like
watch -n 1 'cardano cli query address $(cat addresOfDex) | awk \'*filter for line that contains native asset or pool id*\' | awk \'*devide the correct things*\'

Note that I ommitted the filters as I do not remember them. Db-sync can do something similar of course.

> **Comments:**
> **username_0**: Thank you for the guidance to a possible solution!  
> **username_3**: This is a useful answer except the equation should be: price in ada = ada amount / native asset amount  

---

