Skip to main content

Tick Utilities

nearestUsableTick#

Returns the closest tick that is nearest a given tick and usable for the given tick spacing

nearestUsableTick(
tick: Int32! # The target tick
tickSpacing: Int32! # The spacing of the pool
): Int32!

tickToPrice#

Returns a price object corresponding to the input tick and the base/quote token. Inputs must be tokens because the address order is used to interpret the price represented by the tick.

tickToPrice(
baseToken: Token! # The base token of the price
quoteToken: Token! # The quote token of the price
tick: Int32! # The tick for which to return the price
): Price!

priceToClosestTick#

Returns the first tick for which the given price is greater than or equal to the tick price.

priceToClosestTick(
price: Price! # Price for which to return the closest tick that represents a price less than or equal to the input price, i.e. the price of the returned tick is less than or equal to the input price.
Note that a string price is not used as input here, so the 'price' property of the Price type can have any value without affecting the results.
): Int32!

tickIsBelowSmallest#

Returns true if the tick index is smaller than all tick indices in the list

tickIsBelowSmallest(
ticks: Tick[]! # Tick list to check
tick: Int32! # Input tick index
): Boolean!

tickIsAtOrAboveLargest#

Returns true if the tick index is greater than or equal to all tick indices in the list

tickIsAtOrAboveLargest(
ticks: Tick[]! # Tick list to check
tick: Int32! # Input tick index
): Boolean!

nextInitializedTick#

Returns next initialized tick following the input tick

nextInitializedTick(
ticks: Tick[]! # Tick list to check
tick: Int32! # Input tick index
lte: Boolean! # If true, searches list for next initialized tick that has index less than or equal to the input tick index
): Tick!

tickListIsSorted#

Returns true if a tick list is sorted by tick index

tickListIsSorted(
ticks: Tick[]! # The tick list
): Boolean!

getSqrtRatioAtTick#

Returns the sqrt ratio as a Q64.96 for the given tick. The sqrt ratio is computed as sqrt(1.0001)^tick

getSqrtRatioAtTick(
tick: Int32! # The tick for which to compute the sqrt ratio
): BigInt!

getTickAtSqrtRatio#

Returns the tick corresponding to a given sqrt ratio, such that getSqrtRatioAtTick(tick) <= sqrtRatioX96 and getSqrtRatioAtTick(tick + 1) > sqrtRatioX96

getTickAtSqrtRatio(
sqrtRatioX96: BigInt! # The sqrt ratio as a Q64.96 for which to compute the tick
): Int32!