KyberSwap Docs
Search
K

TickList

Contains utility methods that aids in searching and sorting ticks from a Ticks list.
GitHub File: tickList.ts

Constructor

Private constructor that cannot be constructed.

Methods

validateList() - public static

Validates the list of ticks and throws if the list is invalid.

Parameters

Params
Type
Description
ticks
Tick[]
Array of ticks, each with information on the tick index and liquidity values associated with the tick.
tickSpacing
number
The tick spacing. Used to validate correct tick spacing and check pool liquidity against the total net liquidity across ticks.

isBelowSmallest() - public static

Checks if a given tick is below the lowest tick in the ticks array.

Parameters

Params
Type
Description
ticks
Tick[]
Array of ticks, each with information on the tick index and liquidity values associated with the tick.
tick
number
The tick to check against the array.

Returns

Type
Description
boolean
true = The provided tick is smaller than the lowest tick in the provided ticks array. false = The provided tick is larger than the lowest tick in the provided ticks array.

isAtOrAboveLargest() - public static

Checks if a given tick is above or equal to the highest tick in the ticks array.

Parameters

Params
Type
Description
ticks
Tick[]
Array of ticks, each with information on the tick index and liquidity values associated with the tick.
tick
number
The tick to check against the array.

Returns

Type
Description
boolean
true = The provided tick is greater or equal to the largest tick in the provided ticks array. false = The provided tick is lower than the highest tick in the provided ticks array.

getTick() - public static

Returns the tick that corresponds to the specified index number.

Parameters

Params
Type
Description
ticks
Tick[]
Array of ticks, each with information on the tick index and liquidity values associated with the tick.
index
number
The index number of the tick to search.

Returns

Type
Description
JSBI
The tick that matches the given index number.

binarySearch() - private static

Returns the largest tick index that is less than or equal to the specified tick.

Parameters

Params
Type
Description
ticks
Tick[]
Array of ticks, each with information on the tick index and liquidity values associated with the tick.
tick
number
The tick to search for the largest tick that is less than or equal to this tick.

Returns

Type
Description
number
The tick index that is less than or equal to the specified tick.

nextInitializedTick() - public static

Returns the net initialized tick from the specified tick.

Parameters

Params
Type
Description
ticks
Tick[]
Array of ticks, each with information on the tick index and liquidity values associated with the tick.
tick
number
The tick number that functions as the strating point for the search.
lte
boolean
true = Searches for the next initialized tick that is less than or equal to the specified tick. false = Searches for the next initialized tick that is greater than the specified tick.

Returns

Type
Description
Tick
The next initialized tick from the specified tick.

nextInitializedTickWithinOneWord() - public static

Searches the current and neighbouring words and returns the next initialized tick.

Parameters

Params
Type
Description
ticks
Tick[]
Array of ticks, each with information on the tick index and liquidity values associated with the tick.
tick
number
The tick number that functions as the starting point for the search.
lte
boolean
true = Searches for the next initialized tick that is less than or equal to the specified tick. false = Searches for the next initialized tick that is greater than the specified tick.
tickSpacing
number
The spacing between usable ticks.

Returns

Type
Description
[number, boolean]
An array whose indexes contain the following values: 0 = The next initialized tick up to 256 ticks away from the current active tick. If the next initialized tick is not within ±256 ticks, the value returned will be the last uninitialized tick from the current active tick (currentTick - 256 OR currentTick + 256). 1 = true -> The tick number returned is initialized; false -> The tick number returned is uninitialized.

nextInitializedTickWithinFixedDistance() - public static

Searches for the next initialized tick up to the distance specified.

Parameters

Params
Type
Description
ticks
Tick[]
Array of ticks, each with information on the tick index and liquidity values associated with the tick.
tick
number
The tick number that functions as the starting point for the search.
lte
boolean
true = Searches for the next initialized tick that is less than or equal to the specified tick. false = Searches for the next initialized tick that is greater than the specified tick.
distance
number
The distance from the current active tick to search. Default is 480.

Returns

Type
Description
[number, boolean]
An array whose indexes contain the following values: 0 = The next initialized tick up to the distance specified from current active tick. If the next initialized tick is not within the distance specified, the value returned will be the last uninitialized tick from the current active tick (currentTick - distance OR currentTick + distance). 1 = true -> The tick number returned is initialized; false -> The tick number returned is uninitialized.