Skip to main content

Function: priceTickRangeMapping()

Gala Launchpad SDK 9.0.0-rc.5


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

Function: priceTickRangeMapping()

priceTickRangeMapping(minPrice, maxPrice, tickSpacing?): object

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

Map price range to tick range and return both computed ticks and actual prices

Converts a human-readable price range to Uniswap V3 ticks, then converts back to compute the actual prices those ticks represent (due to rounding effects).

This bidirectional mapping is essential for liquidity position validation where users specify a price range but the actual executable range differs due to tick quantization.

Consolidates 3 occurrences of price-tick conversion with validation logic.

Parameters​

minPrice​

string | number | BigNumber

Minimum price (human-readable, e.g., "0.95")

maxPrice​

string | number | BigNumber

Maximum price (human-readable, e.g., "1.05")

tickSpacing?​

number

Tick spacing requirement (default: 60)

Returns​

object

Object with computed ticks and the actual prices they represent

actualMaxPrice​

actualMaxPrice: BigNumber

actualMinPrice​

actualMinPrice: BigNumber

maxTick​

maxTick: number

minTick​

minTick: number

Throws​

Error if minPrice >= maxPrice or if prices are non-positive

Example​

// Map price range [0.95, 1.05] to ticks with 60-tick spacing
const mapping = priceTickRangeMapping('0.95', '1.05', 60);
// Returns: {
// minTick: -2700,
// maxTick: 1320,
// actualMinPrice: BigNumber('0.949...'), // Slightly lower due to rounding
// actualMaxPrice: BigNumber('1.050...') // Slightly higher due to rounding
// }

// Confirms to user: "You requested [0.95, 1.05] but will get [0.949..., 1.050...]"