Skip to main content

Function: roundTickToSpacing()

Gala Launchpad SDK 9.0.0-rc.5


Gala Launchpad SDK 9.0.0-rc.5 / index / roundTickToSpacing

Function: roundTickToSpacing()

roundTickToSpacing(tick, tickSpacing): number

Defined in: packages/launchpad-sdk/dist/utils/numeric-patterns.d.ts:256

Round a Uniswap V3 tick to a valid spacing multiple

Uniswap V3 ticks must be multiples of tickSpacing (e.g., 1, 10, 60, 200). This utility rounds down to the nearest valid tick spacing using integer arithmetic.

Formula: Math.floor(tick / tickSpacing) * tickSpacing

Consolidates 4 occurrences of inline tick rounding logic in GSwap services.

Parameters​

tick​

number

The tick value to round (can be negative for prices below 1.0)

tickSpacing​

number

The tick spacing requirement (e.g., 1, 10, 60, 200)

Returns​

number

The rounded tick (multiple of tickSpacing)

Throws​

Error if tickSpacing <= 0

Example​

// Round tick 1055 to nearest tick spacing of 10
const rounded = roundTickToSpacing(1055, 10); // 1050

// Round tick 101 to spacing 60
const rounded = roundTickToSpacing(101, 60); // 60

// Negative ticks are also supported (for prices below 1.0)
const rounded = roundTickToSpacing(-1055, 10); // -1060