Open sh1ng opened 2 years ago
Tick is a 24-bit value which I believe is being maintained for twat observations. While SqrtPriceX96
contains more precision and is used for swap calculations, and based on it the tick is calculated and stored in the observation slots.
I found similar issue in transaction https://etherscan.io/tx/0x8bd6db6ee086f571da01b65101ca3368086f6184a662693e1c57d671b40bfbd6#eventlog
Price is supposedly in 203999 tick, when after calculating it, it goes into tick 204000.
What's interesting, this kind of discrepancy is relatively new. I've checked thousands of swaps and never encountered one before ~ August 2022.
https://etherscan.io/tx/0xcce64adbee9cca48db599f6cb60d34b8cc52afa4603ece1441c7986329f18e0f
The below code is in python, but I got the same in golang
and to get the human-readable price we need to invert it and mul by 1e12
I expect that you use an approximation somewhere. Could you provide more details? What value is used to perform a swap?