@gala-chain/api ∙ API
API > getNextSqrtPriceFromInput
Function: getNextSqrtPriceFromInput()
getNextSqrtPriceFromInput(
sqrtPrice
,liquidity
,amountIn
,zeroForOne
):BigNumber
Gets the next square root price given an input amount of token0 or token1.
Parameters
▪ sqrtPrice: BigNumber
The starting price, before accounting for the input amount.
▪ liquidity: BigNumber
The amount of usable liquidity.
▪ amountIn: BigNumber
How much of token0 or token1 is being swapped in.
▪ zeroForOne: boolean
Whether the amount in is token0 (true
) or token1 (false
).
Returns
The price after adding the input amount to token0 or token1.
Throws
If price or liquidity are zero.