"Calculating Liquidity" formula question #38
-
in the Also, |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
The For For For the decimals, I think it's just for simplicity that 18 decimals are assumed for both tokens, and thus it's not the real USDC ERC20 definition. If you want to use 6 decimals (to be "true" to USDC), the differences in decimals will be reflected in the prices (which will account for any difference in decimals between the two tokens), and they'll all come out in the wash from the formula eventually. |
Beta Was this translation helpful? Give feedback.
The
sqrtp
s are stored as Q64.96. To get back to a "normal" number (not in Q64.96), you need to "compensate" for thatq96
conversion.For
liquidity0()
, you have twosqrtp
s multiplied together in the numerator, one of them is cancelled out by the lot ofsqrtp
in the denominator, so there is still one conversion ofq96
left to be "compensated" for, and thus you just divide byq96
to cancel it out.For
liquidity1()
, you only have the lot ofsqrtp
in the denominator, and to compensate for that you multiply byq96
to cancel it out.For the decimals, I think it's just for simplicity that 18 decimals are assumed for both tokens, and thus it's not the real USDC ERC20 definition. If you want to use…