Function: isSqrtPriceInRange()
gSwap SDK 2.0.0-rc.4 / isSqrtPriceInRange
Function: isSqrtPriceInRange()
isSqrtPriceInRange(
sqrtPrice,tickLower,tickUpper):boolean
Defined in: packages/gswap-sdk/dist/index.d.ts:4333
isTickInRange for a pool's square-root price instead of its tick (a position row that
carries sqrtPrice, tickLower and tickUpper). The tick is derived from the price exactly as
the contract does (sqrtPriceToTick: the greatest tick whose square-root price is no greater
than the price, exact to 60 digits), then the contract's rule applies: lower tick inclusive,
upper tick exclusive. So a pool sitting exactly on tickLower's price is in range, and exactly
on tickUpper's price is not, and no float rounding can flip either.
false for a price that is not positive and finite (not loaded, zero, NaN): it says nothing
about the position, so an app that must show a neutral state checks for the missing price
itself first. tickLower and tickUpper follow isTickInRange.
Parameters
sqrtPrice
Value
tickLower
tickUpper
Returns
boolean
Example
const inRange = isSqrtPriceInRange(position.sqrtPrice, position.tickLower, position.tickUpper);