Options
All
  • Public
  • Public/Protected
  • All
Menu

A collection of utility functions when interacting with Ticks.

Hierarchy

  • TickUtil

Index

Methods

  • checkTickInBounds(tick: number): boolean
  • findNextInitializedTickIndex(account: TickArrayData, currentTickIndex: number, tickSpacing: number): null | number
  • findPreviousInitializedTickIndex(account: TickArrayData, currentTickIndex: number, tickSpacing: number): null | number
  • getFullRangeTickIndex(tickSpacing: number): [number, number]
  • Get the minimum and maximum tick index that can be initialized.

    Parameters

    • tickSpacing: number

      The tickSpacing for the Whirlpool

    Returns [number, number]

    An array of numbers where the first element is the minimum tick index and the second element is the maximum tick index.

  • getInitializableTickIndex(tickIndex: number, tickSpacing: number): number
  • Get the nearest (rounding down) valid tick index from the tickIndex. A valid tick index is a point on the tick spacing grid line.

    Parameters

    • tickIndex: number
    • tickSpacing: number

    Returns number

  • getNextInitializableTickIndex(tickIndex: number, tickSpacing: number): number
  • getOffsetIndex(tickIndex: number, arrayStartIndex: number, tickSpacing: number): number
  • Get the offset index to access a tick at a given tick-index in a tick-array

    Parameters

    • tickIndex: number

      The tick index for the tick that this offset would access

    • arrayStartIndex: number

      The starting tick for the array that this tick-index resides in

    • tickSpacing: number

      The tickSpacing for the Whirlpool that this tickArray belongs to

    Returns number

    The offset index that can access the desired tick at the given tick-array

  • getPrevInitializableTickIndex(tickIndex: number, tickSpacing: number): number
  • getStartTickIndex(tickIndex: number, tickSpacing: number, offset?: number): number
  • Get the startIndex of the tick array containing tickIndex.

    Parameters

    • tickIndex: number
    • tickSpacing: number
    • offset: number = 0

      can be used to get neighboring tick array startIndex.

    Returns number

  • invertTick(tick: number): number
  • Returns the tick for the inverse of the price that this tick represents. Eg: Consider tick i where Pb/Pa = 1.0001 ^ i inverse of this, i.e. Pa/Pb = 1 / (1.0001 ^ i) = 1.0001^-i

    Parameters

    • tick: number

      The tick to invert

    Returns number

  • isFullRange(tickSpacing: number, tickLowerIndex: number, tickUpperIndex: number): boolean
  • Check if the tick range is the full range of the Whirlpool.

    Parameters

    • tickSpacing: number

      The tickSpacing for the Whirlpool

    • tickLowerIndex: number

      The lower tick index of the range

    • tickUpperIndex: number

      The upper tick index of the range

    Returns boolean

    true if the range is the full range of the Whirlpool, false otherwise.

  • isTickInitializable(tick: number, tickSpacing: number): boolean

Generated using TypeDoc