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

Implements

Constructors

Properties

address: PublicKey
positionMintTokenProgramId: PublicKey

Methods

  • Collect fees from this position

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

    Parameters

    • updateFeesAndRewards: boolean = true

      if true, add instructions to refresh the accumulated fees and rewards data (default to true unless you know that the collect fees quote and on-chain data match for the "feeOwedA" and "feeOwedB" fields in the Position account)

    • OptionalownerTokenAccountMap: Partial<Record<string, Address>>

      A record that maps a given mint to the owner's token account for that mint (if an entry doesn't exist, it will be automatically resolved)

    • OptionaldestinationWallet: Address

      the wallet to deposit tokens into when withdrawing from the position. If null, the WhirlpoolContext wallet is used.

    • OptionalpositionWallet: Address

      the wallet to that houses the position token. If null, the WhirlpoolContext wallet is used.

    • OptionalataPayer: Address

      wallet that will fund the creation of the new associated token accounts

    • opts: SimpleAccountFetchOptions = PREFER_CACHE

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

    Returns Promise<TransactionBuilder>

    the transaction that will collect fees from the position

  • Collect rewards from this position

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

    Parameters

    • OptionalrewardsToCollect: Address[]

      reward mints to collect (omitting this parameter means all rewards will be collected)

    • updateFeesAndRewards: boolean = true

      if true, add instructions to refresh the accumulated fees and rewards data (default to true unless you know that the collect fees quote and on-chain data match for the "feeOwedA" and "feeOwedB" fields in the Position account)

    • OptionalownerTokenAccountMap: Partial<Record<string, Address>>

      A record that maps a given mint to the owner's token account for that mint (if an entry doesn't exist, it will be automatically resolved)

    • OptionaldestinationWallet: Address

      the wallet to deposit tokens into when withdrawing from the position. If null, the WhirlpoolContext wallet is used.

    • OptionalpositionWallet: Address

      the wallet to that houses the position token. If null, the WhirlpoolContext wallet is used.

    • OptionalataPayer: Address

      wallet that will fund the creation of the new associated token accounts

    • opts: SimpleAccountFetchOptions = IGNORE_CACHE

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

    Returns Promise<TransactionBuilder[]>

    the transactions that will collect rewards from the position. The transactions must be executed serially.

  • Withdraw liquidity from this position.

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

    Parameters

    • liquidityInput: DecreaseLiquidityInput

      input that defines the desired liquidity amount and minimum tokens willing to be to withdrawn from the position.

    • resolveATA: boolean = true

      if true, add instructions to create associated token accounts for tokenA,B for the destinationWallet if necessary. (RPC call required)

    • OptionalsourceWallet: Address
    • OptionalpositionWallet: Address

      the wallet to that houses the position token. If null, the WhirlpoolContext wallet is used.

    • OptionalataPayer: Address

      wallet that will fund the creation of the new associated token accounts

    Returns Promise<TransactionBuilder>

    the transaction that will deposit the tokens into the position when executed.

  • Deposit additional tokens into this postiion. The wallet must contain the position token and the necessary token A & B to complete the deposit. If positionWallet and wallet is provided, the wallet owners have to sign this transaction.

    Parameters

    • liquidityInput: IncreaseLiquidityInput

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

    • resolveATA: boolean = true

      if true, add instructions to create associated token accounts for tokenA,B for the destinationWallet if necessary. (RPC call required)

    • OptionalsourceWallet: Address
    • OptionalpositionWallet: Address

      the wallet to that houses the position token. If null, the WhirlpoolContext wallet is used.

    • OptionalataPayer: Address

      wallet that will fund the creation of the new associated token accounts

    Returns Promise<TransactionBuilder>

    the transaction that will deposit the tokens into the position when executed.