index/functions/priceTickRangeMapping.md
priceTickRangeMapping(
minPrice,maxPrice,tickSpacing?):object
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.
min price max tick spacing
Parameters
| Parameter | Type | Description |
|---|---|---|
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) |
min price big number max tick spacing
Returns
object
Object with computed ticks and the actual prices they represent
| Name | Type |
|---|---|
actualMaxPrice | BigNumber |
actualMinPrice | BigNumber |
maxTick | number |
minTick | number |
actual max price big number min tick
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...]"