Function: isTickInRange()
gSwap SDK 2.0.0-rc.4 / isTickInRange
Function: isTickInRange()
isTickInRange(
currentTick,tickLower,tickUpper):boolean
Defined in: packages/gswap-sdk/dist/index.d.ts:4287
True when a position over [tickLower, tickUpper) is IN RANGE at currentTick: the lower tick
is INCLUSIVE and the upper tick is EXCLUSIVE. That is the GalaChainDex contract's rule
(DexV3Pool: tickCurrent >= tickLower && tickCurrent < tickUpper is the case in which a
position holds both tokens and earns fees). A pool whose tick equals tickUpper is already out
of range: the position is entirely token1 there, and a swap through the tick has crossed it.
currentTick is the pool's tick (slot0.tick, the greatest tick whose price is no greater than
the pool's price), not a rounded display value. A tick may be a number or the decimal string a
backend returns. Anything that is not an integer (NaN, undefined-like, an empty string, a
fraction) makes the answer false: an app that must tell "not loaded yet" from "out of range"
checks for the missing value itself first.
Do NOT decide range by comparing a price with a tick's price (tickToPrice) using <= on both
ends, or by mixing a square-root price with a price. A price exactly on a tick's boundary is
then in range at the upper edge (the contract says it is not), and two representations of the
same boundary can round to opposite sides. For a pool price use isSqrtPriceInRange, which
derives the tick the way the contract does and then applies this rule.
Parameters
currentTick
tickLower
tickUpper
Returns
boolean
Example
isTickInRange(-60, -60, 60); // true: the lower tick is inclusive
isTickInRange(60, -60, 60); // false: the upper tick is exclusive