Hello again,
I am struggling to determine how historic quotes are calculated using the Bitquery graph.
Take for example, a quote of token “SAFU” in WBNB at txHash 0x6c26d2e320739be9022d8454fbdc68346e3a86c82224d0bd5c8b4ccb1ac2f3ab
{
ethereum(network: bsc) {
dexTrades(
options: {desc: ["block.height", "tradeIndex"], limit: 1}
exchangeName: {in: ["Pancake v2"]}
baseCurrency: {is: "0x2eba09fb8063aedba27424de9bf0dcb41567a943"}
quoteCurrency: {is: "0xbb4cdb9cbd36b01bd1cbaebf2de08d9173bc095c"}
txHash: {is: "0x6c26d2e320739be9022d8454fbdc68346e3a86c82224d0bd5c8b4ccb1ac2f3ab"}
) {
transaction {
hash
}
tradeIndex
smartContract {
address {
address
}
contractType
currency {
name
}
}
tradeIndex
block {
timestamp {
time(format: "%Y-%m-%d %H:%M:%S")
unixtime
}
height
}
baseCurrency {
symbol
address
}
quoteCurrency {
symbol
address
}
quotePrice
}
}
}
The result returned is 4.726269578406308e-16
However, if I look at the bscscan logs for this transaction and manually adjust the “Sync” reserve amounts to their pre-Swap equivalents, the calculated result is 4.7578e-16
(0.000000000000000475780) which is close, but not the same as the Bitquery result.
This can be confirmed by looking at the previous transaction and dividing the reserves in the sync event (reserve1 / reserve0 = 4.7578e-16):
Which result is the correct one, and am I missing something fundamental in deriving the token value using the sync/swap method above?
Many thanks!