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.
1 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.
-
-
This is a useful answer except the equation should be: price in ada = ada amount / native asset amount– adjuricNov 1, 2022 at 1:05
cardano-db-sync
does not track native asset prices.db-sync
.