Skip to main content

Function: roundTickBoundaries()

Gala Launchpad SDK 9.0.0-rc.5


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

Function: roundTickBoundaries()

roundTickBoundaries(tickLower, tickUpper, tickSpacing): object

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

Round tick boundaries to valid Uniswap V3 spacing multiples

Uniswap V3 ticks must be multiples of tickSpacing (1, 10, 60, 200, etc.). This utility rounds tickLower down and tickUpper up to valid boundaries.

Consolidates 5 occurrences of inline Math.floor/Math.ceil logic in GSwap services.

Parameters​

tickLower​

number

Lower tick boundary (before rounding)

tickUpper​

number

Upper tick boundary (before rounding)

tickSpacing​

number

Tick spacing requirement (e.g., 60 for 0.3% fee tier)

Returns​

object

Object with rounded tickLower (floor) and tickUpper (ceil)

tickLower​

tickLower: number

tickUpper​

tickUpper: number

Throws​

Error if tickLower >= tickUpper or if tickSpacing <= 0

Example​

// Round to nearest 60-tick multiples
const rounded = roundTickBoundaries(1234, 5678, 60);
// Returns: { tickLower: 1200, tickUpper: 5700 }
// (1234 rounds down to 1200, 5678 rounds up to 5700)

// Handle negative ticks (below price 1.0)
const rounded = roundTickBoundaries(-1234, -1000, 10);
// Returns: { tickLower: -1240, tickUpper: -1000 }

// Ticks already valid (multiples of spacing)
const rounded = roundTickBoundaries(0, 60, 60);
// Returns: { tickLower: 0, tickUpper: 60 }