index/functions/roundTickToSpacing.md
roundTickToSpacing(
tick,tickSpacing):number
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.
tick spacing
Parameters
| Parameter | Type | Description |
|---|---|---|
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) |
tick spacing
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