UNPKG

@alcorexchange/alcor-swap-sdk

Version:

​​ **npm** ``` npm i @alcorexchange/alcor-swap-sdk ``` **yarn** ``` yarn add @alcorexchange/alcor-swap-sdk ``` ## Usage ### Import:

30 lines (29 loc) 1.4 kB
import { Tick } from "../entities/tick"; /**x * Utility methods for interacting with sorted lists of ticks */ export declare abstract class TickList { /** * Cannot be constructed */ private constructor(); static validateList(ticks: Tick[], tickSpacing: number): void; static isBelowSmallest(ticks: readonly Tick[], tick: number): boolean; static isAtOrAboveLargest(ticks: readonly Tick[], tick: number): boolean; static getTick(ticks: readonly Tick[], id: number): Tick; /** * Finds the largest tick in the list of ticks that is less than or equal to tick * @param ticks list of ticks * @param tick tick to find the largest tick that is less than or equal to tick * @private */ private static binarySearch; static nextInitializedTick(ticks: readonly Tick[], tick: number, lte: boolean): Tick; static nextInitializedTickWithinOneWord(ticks: readonly Tick[], tick: number, lte: boolean, tickSpacing: number): [number, boolean]; /** * Optimized version with cursor hint for sequential access (swap loops) * @param cursorHint - last known index position, -1 if unknown * @returns [tickId, initialized, newCursorIndex] */ static nextInitializedTickWithinOneWordWithCursor(ticks: readonly Tick[], tick: number, lte: boolean, tickSpacing: number, cursorHint: number): [number, boolean, number]; }