I'm looking at the uniswap docs which states this example:
An example of finding the price of WETH in a WETH / USDC pool, where WETH is token0 and USDC is token1:
You have an oracle reading that shows a return of tickCumulative as [70_000, 1_070_000], with an elapsed time between the observations of 10 seconds.
We can derive the average tick over this interval by taking the difference in accumulator values (1_070_000 - 70_000 = 1_000_000), and dividing by the time elapsed (1_000_000 / 10 = 100_000).
With a tick reading of 100_000, we can find the value of token1 (USDC) in terms of token0 (WETH) by using the current tick as i in the formula p(i) = 1.0001**i (see 6.1 in the whitepaper).
1.0001**100_000 ≅ 22015.5 USDC / WETH
The price of WETH is not $22015.50. I though maybe they just use an example with easy numbers. So I decided to try the example from the whitepaper on the USDC/WETH pool
Calling slot0
on the contract returns:
Making the price
1.0001 ** 205930 = 876958666.4726943
Clearly the price for ETH is not 876958666 USDC. The current tick is 205930, but the price for ETH is just 1200.49 USDC. How do I get the correct USDC price of ETH from the tick?