I want to get a price of token in uniswapV3 pair. As example, i have pair https://etherscan.io/address/0x409634ea16d98b0b245f345079c8f3cfe3ef1fa6. Result of calling slot0() is [12934124507235850032763499380293, 101910, 0, 1, 1, 0, True], where 12934124507235850032763499380293 is sqrtPriceX96. I use this formula: price = (sqrtPriceX96 ** 2) / (2 ** 192). And result is 26666 in ETH, while real price is 0.09$. Token has 18 decimals, WETH as well. Where is the problem?
Correct formula to calculate price
I got it. If token0 in pair is base token, WETH in this example, you need to make reverse operation. 1 / price. Here i got 26666 -> 1 / 26666 * 2400 (ETH price) = 0.09$.