Skip to content

@gala-chain/apiAPI


API > getNextSqrtPriceFromOutput

Function: getNextSqrtPriceFromOutput()

getNextSqrtPriceFromOutput(sqrtPrice, liquidity, amountOut, zeroForOne): BigNumber

Gets the next square root price given an output amount of token0 or token1.

Parameters

sqrtPrice: BigNumber

The starting price before accounting for the output amount.

liquidity: BigNumber

The amount of usable liquidity.

amountOut: BigNumber

How much of token0 or token1 is being swapped out.

zeroForOne: boolean

Whether the amount out is token0 (true) or token1 (false).

Returns

The price after removing the output amount of token0 or token1.

Throws

If price or liquidity are zero.

Source

chain-api/src/utils/dex/sqrtPriceMath.helper.ts:98