Documentation
    Preparing search index...

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

    interface Position {
        collectFees: (
            updateFeesAndRewards?: boolean,
            ownerTokenAccountMap?: Partial<Record<string, Address>>,
            destinationWallet?: Address,
            positionWallet?: Address,
            ataPayer?: Address,
            opts?: SimpleAccountFetchOptions,
        ) => Promise<TransactionBuilder>;
        collectRewards: (
            rewardsToCollect?: Address[],
            updateFeesAndRewards?: boolean,
            ownerTokenAccountMap?: Partial<Record<string, Address>>,
            destinationWallet?: Address,
            positionWallet?: Address,
            ataPayer?: Address,
            opts?: SimpleAccountFetchOptions,
        ) => Promise<TransactionBuilder[]>;
        decreaseLiquidity: (
            liquidityInput: DecreaseLiquidityInput,
            resolveATA?: boolean,
            destinationWallet?: Address,
            positionWallet?: Address,
            ataPayer?: Address,
        ) => Promise<TransactionBuilder>;
        getAddress: () => PublicKey;
        getData: () => PositionData;
        getLockConfigData: () => Promise<null | LockConfigData>;
        getLowerTickData: () => TickData;
        getPositionMintTokenProgramId: () => PublicKey;
        getUpperTickData: () => TickData;
        getWhirlpoolData: () => WhirlpoolData;
        increaseLiquidity: (
            liquidityInput: IncreaseLiquidityInput,
            resolveATA?: boolean,
            wallet?: Address,
            positionWallet?: Address,
            ataPayer?: Address,
        ) => Promise<TransactionBuilder>;
        lock: (
            lockType: LockTypeData,
            positionWallet?: Address,
            funder?: Address,
        ) => Promise<TransactionBuilder>;
        refreshData: () => Promise<PositionData>;
        resetPositionRange: (
            tickLowerIndex: number,
            tickUpperIndex: number,
            positionWallet?: Address,
        ) => Promise<TransactionBuilder>;
    }

    Implemented by

    Index

    Properties

    collectFees: (
        updateFeesAndRewards?: boolean,
        ownerTokenAccountMap?: Partial<Record<string, Address>>,
        destinationWallet?: Address,
        positionWallet?: Address,
        ataPayer?: Address,
        opts?: SimpleAccountFetchOptions,
    ) => Promise<TransactionBuilder>

    Collect fees from this position

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

    Type declaration

      • (
            updateFeesAndRewards?: boolean,
            ownerTokenAccountMap?: Partial<Record<string, Address>>,
            destinationWallet?: Address,
            positionWallet?: Address,
            ataPayer?: Address,
            opts?: SimpleAccountFetchOptions,
        ): Promise<TransactionBuilder>
      • Parameters

        • OptionalupdateFeesAndRewards: boolean

          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

        • Optionalopts: SimpleAccountFetchOptions

          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

    collectRewards: (
        rewardsToCollect?: Address[],
        updateFeesAndRewards?: boolean,
        ownerTokenAccountMap?: Partial<Record<string, Address>>,
        destinationWallet?: Address,
        positionWallet?: Address,
        ataPayer?: Address,
        opts?: SimpleAccountFetchOptions,
    ) => Promise<TransactionBuilder[]>

    Collect rewards from this position

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

    Type declaration

      • (
            rewardsToCollect?: Address[],
            updateFeesAndRewards?: boolean,
            ownerTokenAccountMap?: Partial<Record<string, Address>>,
            destinationWallet?: Address,
            positionWallet?: Address,
            ataPayer?: Address,
            opts?: SimpleAccountFetchOptions,
        ): Promise<TransactionBuilder[]>
      • Parameters

        • OptionalrewardsToCollect: Address[]

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

        • OptionalupdateFeesAndRewards: boolean

          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

        • Optionalopts: SimpleAccountFetchOptions

          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.

    decreaseLiquidity: (
        liquidityInput: DecreaseLiquidityInput,
        resolveATA?: boolean,
        destinationWallet?: Address,
        positionWallet?: Address,
        ataPayer?: Address,
    ) => Promise<TransactionBuilder>

    Withdraw liquidity from this position.

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

    Type declaration

      • (
            liquidityInput: DecreaseLiquidityInput,
            resolveATA?: boolean,
            destinationWallet?: Address,
            positionWallet?: Address,
            ataPayer?: Address,
        ): Promise<TransactionBuilder>
      • Parameters

        • liquidityInput: DecreaseLiquidityInput

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

        • OptionalresolveATA: boolean

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

        • 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

        Returns Promise<TransactionBuilder>

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

    getAddress: () => PublicKey

    Return the address for this Whirlpool instance.

    Type declaration

      • (): PublicKey
      • Returns PublicKey

        the PublicKey for this Whirlpool instance.

    getData: () => PositionData

    Return the most recently fetched Position account data.

    Type declaration

    getLockConfigData: () => Promise<null | LockConfigData>

    Return LockConfig account data for this position if it is locked.

    Type declaration

      • (): Promise<null | LockConfigData>
      • Returns Promise<null | LockConfigData>

        LockConfigData for this position if it is locked. Otherwise, return null.

    getLowerTickData: () => TickData

    Return the most recently fetched TickData account data for this position's lower tick.

    Type declaration

      • (): TickData
      • Returns TickData

        most recently fetched TickData for this position's lower tick.

    getPositionMintTokenProgramId: () => PublicKey

    Return the program address owning the position token.

    Type declaration

      • (): PublicKey
      • Returns PublicKey

        the PublicKey for the program address owning the position token.

    getUpperTickData: () => TickData

    Return the most recently fetched TickData account data for this position's upper tick.

    Type declaration

      • (): TickData
      • Returns TickData

        most recently fetched TickData for this position's upper tick.

    getWhirlpoolData: () => WhirlpoolData

    Return the most recently fetched Whirlpool account data for this position.

    Type declaration

    increaseLiquidity: (
        liquidityInput: IncreaseLiquidityInput,
        resolveATA?: boolean,
        wallet?: Address,
        positionWallet?: Address,
        ataPayer?: Address,
    ) => Promise<TransactionBuilder>

    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.

    Type declaration

      • (
            liquidityInput: IncreaseLiquidityInput,
            resolveATA?: boolean,
            wallet?: Address,
            positionWallet?: Address,
            ataPayer?: Address,
        ): Promise<TransactionBuilder>
      • Parameters

        • liquidityInput: IncreaseLiquidityInput

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

        • OptionalresolveATA: boolean

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

        • Optionalwallet: Address

          to withdraw tokens to deposit into 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

        Returns Promise<TransactionBuilder>

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

    lock: (
        lockType: LockTypeData,
        positionWallet?: Address,
        funder?: Address,
    ) => Promise<TransactionBuilder>

    Lock this position.

    Please note that this function is only available for TokenExtensions based positions. Also the range of the position must be FullRange.

    Please be careful when using this function as it will lock the position and prevent any liquidity changes including withdrawals.

    Type declaration

      • (
            lockType: LockTypeData,
            positionWallet?: Address,
            funder?: Address,
        ): Promise<TransactionBuilder>
      • Parameters

        • lockType: LockTypeData

          the type of lock to apply to the position.

        • OptionalpositionWallet: Address

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

        • Optionalfunder: Address

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

        Returns Promise<TransactionBuilder>

        the transactions that will lock the position.

    refreshData: () => Promise<PositionData>

    Fetch and return the most recently fetched Position account data.

    Type declaration

    resetPositionRange: (
        tickLowerIndex: number,
        tickUpperIndex: number,
        positionWallet?: Address,
    ) => Promise<TransactionBuilder>

    Reset a position's range. Requires liquidity to be zero.

    Type declaration

      • (
            tickLowerIndex: number,
            tickUpperIndex: number,
            positionWallet?: Address,
        ): Promise<TransactionBuilder>
      • Parameters

        • tickLowerIndex: number

          the tick index for the lower bound of this position

        • tickUpperIndex: number

          the tick index for the upper bound of this position

        • OptionalpositionWallet: Address

        Returns Promise<TransactionBuilder>

        the transactions that will reset the position's range. The transactions must be executed serially.