Skip to content

@gala-chain/apiAPI


API > liquidity0

Function: liquidity0()

liquidity0(amount, sqrtPriceA, sqrtPriceB): BigNumber

we know dx = d ( 1 / sqrt(p)) * L on rearranging dx = ( 1 / sqrt(pa) - 1/sqrt(pb)) * L dx = ( (sqrt(pb) - sqrt(pa))/ (sqrt(pb) * sqrt(pa))) * L dx * (sqrt(pb) * sqrt(pa)) / (sqrt(pb) - sqrt(pa)) = L since we adding liquidity within the price range then it will be pa will become pc (current price) dx * (sqrt(pb) * sqrt(pc)) / (sqrt(pb) - sqrt(pc)) = L

Parameters

amount: BigNumber

sqrtPriceA: BigNumber

sqrtPriceB: BigNumber

Returns

Source

chain-api/src/utils/dex/addLiquidity.helper.ts:36