Options
All
  • Public
  • Public/Protected
  • All
Menu

Hierarchy

  • PoolUtil

Index

Other

  • getFeeRate(feeRate: number): Percentage
  • getProtocolFeeRate(protocolFeeRate: number): Percentage
  • orderMints(mintX: Address, mintY: Address): [Address, Address]

Whirlpool Utils

  • estimateLiquidityFromTokenAmounts(currTick: number, lowerTick: number, upperTick: number, tokenAmount: TokenAmounts): BN
  • Estimate the liquidity amount required to increase/decrease liquidity.

    // TODO: At the top end of the price range, tick calcuation is off therefore the results can be off

    Parameters

    • currTick: number

      Whirlpool's current tick index (aka price)

    • lowerTick: number

      Position lower tick index

    • upperTick: number

      Position upper tick index

    • tokenAmount: TokenAmounts

      The desired amount of tokens to deposit/withdraw

    Returns BN

    An estimated amount of liquidity needed to deposit/withdraw the desired amount of tokens.

  • getTickArrayPublicKeysForSwap(tickCurrentIndex: number, tickSpacing: number, aToB: boolean, programId: PublicKey, whirlpoolAddress: PublicKey): PublicKey[]
  • Given the current tick-index, returns the dervied PDA and fetched data for the tick-arrays that this swap may traverse across.

    TODO: Handle the edge case where the first tick-array may be the previous array of expected start-index due to slippage.

    Parameters

    • tickCurrentIndex: number

      The current tickIndex for the Whirlpool to swap on.

    • tickSpacing: number

      The tickSpacing for the Whirlpool.

    • aToB: boolean

      The direction of the trade.

    • programId: PublicKey

      The Whirlpool programId which the Whirlpool lives on.

    • whirlpoolAddress: PublicKey

      PublicKey of the whirlpool to swap on.

    Returns PublicKey[]

    An array of PublicKey[] for the tickArray accounts that this swap may traverse across.

  • getTokenAmountsFromLiquidity(liquidity: u64, currentPrice: u64, lowerPrice: u64, upperPrice: u64, round_up: boolean): TokenAmounts

Generated using TypeDoc