Options
All
  • Public
  • Public/Protected
  • All
Menu

Helper class to interact with a Whirlpool account and build complex transactions.

Hierarchy

  • Whirlpool

Index

Methods

  • closePosition(positionAddress: Address, slippageTolerance: Percentage, destinationWallet?: Address, positionWallet?: Address, payer?: Address): Promise<TransactionBuilder[]>
  • Withdraw all tokens from a position, close the account and burn the position token.

    Users have to collect all fees and rewards from this position prior to closing the account.

    If positionWallet, payer is provided, the wallet owner has to sign this transaction.

    Parameters

    • positionAddress: Address

      The address of the position account.

    • slippageTolerance: Percentage

      The amount of slippage the caller is willing to accept when withdrawing liquidity.

    • Optional destinationWallet: Address

      The wallet that the tokens withdrawn and rent lamports will be sent to. If null, the WhirlpoolContext wallet is used.

    • Optional positionWallet: Address

      The wallet that houses the position token that corresponds to this position address. If null, the WhirlpoolContext wallet is used.

    • Optional payer: Address

      the wallet that will fund the cost needed to initialize the token ATA accounts. If null, the WhirlpoolContext wallet is used.

    Returns Promise<TransactionBuilder[]>

  • getAddress(): PublicKey
  • Return the address for this Whirlpool instance.

    Returns PublicKey

    the PublicKey for this Whirlpool instance.

  • Get the WhirlpoolRewardInfos for this pool.

    Returns WhirlpoolRewardInfo[]

    Array of 3 WhirlpoolRewardInfos. However, not all of them may be initialized. Use the initialized field on WhirlpoolRewardInfo to check if the reward is active.

  • getTokenVaultAInfo(): Account
  • Get the TokenAccountInfo for token vault A of this pool.

    Returns Account

    TokenAccountInfo for token vault A

  • getTokenVaultBInfo(): Account
  • Get the TokenAccountInfo for token vault B of this pool.

    Returns Account

    TokenAccountInfo for token vault B

  • initTickArrayForTicks(ticks: number[], funder?: Address, opts?: SimpleAccountFetchOptions): Promise<null | TransactionBuilder>
  • Initialize a set of tick-arrays that encompasses the provided ticks.

    If funder is provided, the funder wallet has to sign this transaction.

    Parameters

    • ticks: number[]

      A group of ticks that define the desired tick-arrays to initialize. If the tick's array has been initialized, it will be ignored.

    • Optional funder: Address

      the wallet that will fund the cost needed to initialize the position. If null, the WhirlpoolContext wallet is used.

    • Optional opts: SimpleAccountFetchOptions

      an WhirlpoolAccountFetchOptions object to define fetch and cache options when accessing on-chain accounts

    Returns Promise<null | TransactionBuilder>

    a transaction that will initialize the defined tick-arrays if executed. Return null if all of the tick's arrays are initialized.

  • openPosition(tickLower: number, tickUpper: number, liquidityInput: IncreaseLiquidityInput, wallet?: Address, funder?: Address, positionMint?: PublicKey): Promise<{ positionMint: PublicKey; tx: TransactionBuilder }>
  • Open and fund a position on this Whirlpool.

    User has to ensure the TickArray for tickLower and tickUpper has been initialized prior to calling this function.

    If wallet or funder is provided, those wallets have to sign this transaction.

    Parameters

    • tickLower: number

      the tick index for the lower bound of this position

    • tickUpper: number

      the tick index for the upper bound of this position

    • liquidityInput: IncreaseLiquidityInput

      an InputLiquidityInput type to define the desired liquidity amount to deposit

    • Optional wallet: Address

      the wallet to withdraw tokens to deposit into the position and house the position token. If null, the WhirlpoolContext wallet is used.

    • Optional funder: Address

      the wallet that will fund the cost needed to initialize the position. If null, the WhirlpoolContext wallet is used.

    • Optional positionMint: PublicKey

      the mint address of the position token to be created. If null, a new mint address will be created.

    Returns Promise<{ positionMint: PublicKey; tx: TransactionBuilder }>

    positionMint - the position to be created. tx - The transaction containing the instructions to perform the operation on chain.

  • openPositionWithMetadata(tickLower: number, tickUpper: number, liquidityInput: IncreaseLiquidityInput, wallet?: Address, funder?: Address, positionMint?: PublicKey): Promise<{ positionMint: PublicKey; tx: TransactionBuilder }>
  • Open and fund a position with meta-data on this Whirlpool.

    User has to ensure the TickArray for tickLower and tickUpper has been initialized prior to calling this function.

    If wallet or funder is provided, the wallet owners have to sign this transaction.

    Parameters

    • tickLower: number

      the tick index for the lower bound of this position

    • tickUpper: number

      the tick index for the upper bound of this position

    • liquidityInput: IncreaseLiquidityInput

      input that defines the desired liquidity amount and maximum tokens willing to be to deposited.

    • Optional wallet: Address

      the wallet to withdraw tokens to deposit into the position and house the position token. If null, the WhirlpoolContext wallet is used.

    • Optional funder: Address

      the wallet that will fund the cost needed to initialize the position. If null, the WhirlpoolContext wallet is used.

    • Optional positionMint: PublicKey

      the mint address of the position token to be created. If null, a new mint address will be created.

    Returns Promise<{ positionMint: PublicKey; tx: TransactionBuilder }>

    positionMint - the position to be created. tx - The transaction containing the instructions to perform the operation on chain.

  • Fetch and return the most recently fetched Whirlpool account data.

    Returns Promise<WhirlpoolData>

    the most up to date WhirlpoolData for this address.

  • swap(input: SwapInput, wallet?: PublicKey): Promise<TransactionBuilder>
  • Perform a swap between tokenA and tokenB on this pool.

    Parameters

    • input: SwapInput

      A quote on the desired tokenIn and tokenOut for this swap. Use swapQuoteWithParams or other swap quote functions to generate this object.

    • Optional wallet: PublicKey

      The wallet that tokens will be withdrawn and deposit into. If null, the WhirlpoolContext wallet is used.

    Returns Promise<TransactionBuilder>

    a transaction that will perform the swap once executed.

  • swapWithDevFees(input: DevFeeSwapInput, devFeeWallet: PublicKey, wallet?: PublicKey, payer?: PublicKey): Promise<TransactionBuilder>
  • Collect a developer fee and perform a swap between tokenA and tokenB on this pool.

    Parameters

    • input: DevFeeSwapInput

      A quote on the desired tokenIn and tokenOut for this swap. Use swapQuoteByInputTokenWithDevFees to generate this object.

    • devFeeWallet: PublicKey

      The wallet that developer fees will be deposited into.

    • Optional wallet: PublicKey

      The wallet that swap tokens will be withdrawn and deposit into. If null, the WhirlpoolContext wallet is used.

    • Optional payer: PublicKey

      The wallet that will fund the cost needed to initialize the dev wallet token ATA accounts. If null, the WhirlpoolContext wallet is used.

    Returns Promise<TransactionBuilder>

    a transaction that will perform the swap once executed.

Generated using TypeDoc