TickMath
Math library for computing sqrt prices from ticks and vice versa. Sets the minimum and maximum of ticks and sqrt prices.
As digital calls and puts are priced between [0.01, 0.99] per collateral, per put-call parity, the sqrtPrice is the sqrt ratio of shieldPrice/spearPrice is between [sqrt(1/99), sqrt(99)]. sqrtPrice is computed for ticks of size 1.0001, i.e. sqrt(1.0001^tick) as fixed point Q64.96 numbers.
getSqrtRatioAtTick
Calculates and returns the square root ratio at the given tick.
Params:
Name | Type | Description |
tick | int24 | The input tick for the above formula |
Returns:
Name | Type | Description |
sqrtPriceX96 | uint160 | A fixed point Q64.96 number representing the sqrt of the ratio of shieldPrice/spearPrice |
getTickAtSqrtRatio
Calculates and returns the tick value at the given square root ratio.
Params:
Name | Type | Description |
sqrtPriceX96 | uint160 | The sqrt ratio for which to compute the tick as a Q64.96 |
Returns:
Name | Type | Description |
tick | int24 | The greatest tick for which the price is less than or equal to the input ratio |
Last updated