interface icon indicating copy to clipboard operation
interface copied to clipboard

ActiveTick is incorrectly determined for stablecoin pools.

Open beejuice opened this issue 1 year ago • 0 comments

Quite often in stablecoin pairs, the current tick can be equal to zero. And this check does not work correctly.

const getActiveTick = (tickCurrent: number | undefined, feeAmount: FeeAmount | undefined) => tickCurrent && feeAmount ? Math.floor(tickCurrent / TICK_SPACINGS[feeAmount]) * TICK_SPACINGS[feeAmount] : undefined

I suggest as a replacement:

const getActiveTick = (tickCurrent: number | undefined, feeAmount: FeeAmount | undefined) => typeof tickCurrent === 'number' && feeAmount ? Math.floor(tickCurrent / TICK_SPACINGS[feeAmount]) * TICK_SPACINGS[feeAmount] : undefined

beejuice avatar Mar 15 '24 11:03 beejuice