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
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
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 |
|
isAtOrAboveLargest() - public
static
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 |
|
getTick() - public
static
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 |
---|---|
The tick that matches the given index number. |
binarySearch() - private
static
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
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 |
|
Returns
Type | Description |
---|---|
The next initialized tick from the specified tick. |
nextInitializedTickWithinOneWord() - public
static
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 |
|
tickSpacing | number | The spacing between usable ticks. |
Returns
Type | Description |
---|---|
[number, boolean] | An array whose indexes contain the following values:
|
nextInitializedTickWithinFixedDistance() - public
static
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 |
|
distance | number | The distance from the current active tick to search. Default is |
Returns
Type | Description |
---|---|
[number, boolean] | An array whose indexes contain the following values:
|
Last updated