Core Libraries
SqrtPriceMath
Contains the math that uses square root of price as a Q64.96 and liquidity to compute deltas
Gets the next sqrt price given a delta of token0
Always rounds up, because in the exact output case (increasing price) we need to move the price at least
far enough to get the desired output amount, and in the exact input case (decreasing price) we need to move the
price less in order to not send too much output.
The most precise formula for this is liquidity * sqrtPX96 / (liquidity +- amount * sqrtPX96),
if this is impossible because of overflow, we calculate liquidity / (liquidity / sqrtPX96 +- amount).
Gets the next sqrt price given a delta of token1
Always rounds down, because in the exact output case (decreasing price) we need to move the price at least
far enough to get the desired output amount, and in the exact input case (increasing price) we need to move the
price less in order to not send too much output.
The formula we compute is within <1 wei of the lossless version: sqrtPX96 +- amount / liquidity
Gets the next sqrt price given an input amount of token0 or token1
Throws if price or liquidity are 0, or if the next price is out of bounds
Gets the next sqrt price given an output amount of token0 or token1
Throws if price or liquidity are 0 or the next price is out of bounds
Gets the amount0 delta between two prices
Calculates liquidity / sqrt(lower) - liquidity / sqrt(upper),
i.e. liquidity * (sqrt(upper) - sqrt(lower)) / (sqrt(upper) * sqrt(lower))
Gets the amount1 delta between two prices
Calculates liquidity * (sqrt(upper) - sqrt(lower))
Helper that gets signed token0 delta
Helper that gets signed token1 delta
