0

This question asks how to convert sqrtPriceX96 to price in solidity, but I can't find information on doing the inverse.

How do you turn a price e.g. 55 ether into its sqrtPriceX96 with full precision?

Have tried

uint160 sqrtRatioX96 = 1827333235122231383957021222;
uint256 ratio = sqrtRatioX96.formatSqrtPriceX96ToPriceX96().formatX96ToX10_18();
uint256 sqrtRatioX96b = ratio.sqrt() << 96;

Which results in 1827333155895382849688627663268216832 (a different number than the original)

Ryan Sea
  • 638
  • 3
  • 20

0 Answers0