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

interface Position {
    collectFees: ((updateFeesAndRewards?, ownerTokenAccountMap?, destinationWallet?, positionWallet?, ataPayer?, opts?) => Promise<TransactionBuilder>);
    collectRewards: ((rewardsToCollect?, updateFeesAndRewards?, ownerTokenAccountMap?, destinationWallet?, positionWallet?, ataPayer?, opts?) => Promise<TransactionBuilder[]>);
    decreaseLiquidity: ((liquidityInput, resolveATA?, destinationWallet?, positionWallet?, ataPayer?) => Promise<TransactionBuilder>);
    getAddress: (() => PublicKey);
    getData: (() => PositionData);
    getLowerTickData: (() => TickData);
    getUpperTickData: (() => TickData);
    getWhirlpoolData: (() => WhirlpoolData);
    increaseLiquidity: ((liquidityInput, resolveATA?, wallet?, positionWallet?, ataPayer?) => Promise<TransactionBuilder>);
    refreshData: (() => Promise<PositionData>);
}

Properties

collectFees: ((updateFeesAndRewards?, ownerTokenAccountMap?, destinationWallet?, positionWallet?, ataPayer?, opts?) => Promise<TransactionBuilder>)

Collect fees from this position

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

Type declaration

    • (updateFeesAndRewards?, ownerTokenAccountMap?, destinationWallet?, positionWallet?, ataPayer?, opts?): Promise<TransactionBuilder>
    • Collect fees from this position

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

      Parameters

      • Optional updateFeesAndRewards: 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)

      • Optional ownerTokenAccountMap: 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)

      • Optional destinationWallet: Address

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

      • Optional positionWallet: Address

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

      • Optional ataPayer: Address

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

      • Optional opts: 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

Param: updateFeesAndRewards

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)

Param: ownerTokenAccountMap

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)

Param: destinationWallet

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

Param: positionWallet

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

Param: ataPayer

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

Param: opts

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

Returns

the transaction that will collect fees from the position

collectRewards: ((rewardsToCollect?, updateFeesAndRewards?, ownerTokenAccountMap?, destinationWallet?, positionWallet?, ataPayer?, opts?) => Promise<TransactionBuilder[]>)

Collect rewards from this position

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

Type declaration

    • (rewardsToCollect?, updateFeesAndRewards?, ownerTokenAccountMap?, destinationWallet?, positionWallet?, ataPayer?, opts?): Promise<TransactionBuilder[]>
    • Collect rewards from this position

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

      Parameters

      • Optional rewardsToCollect: Address[]

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

      • Optional updateFeesAndRewards: 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)

      • Optional ownerTokenAccountMap: 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)

      • Optional destinationWallet: Address

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

      • Optional positionWallet: Address

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

      • Optional ataPayer: Address

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

      • Optional opts: 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.

Param: rewardsToCollect

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

Param: updateFeesAndRewards

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)

Param: ownerTokenAccountMap

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)

Param: destinationWallet

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

Param: positionWallet

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

Param: ataPayer

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

Param: opts

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

Returns

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

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

Withdraw liquidity from this position.

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

Type declaration

    • (liquidityInput, resolveATA?, destinationWallet?, positionWallet?, ataPayer?): Promise<TransactionBuilder>
    • 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.

      • Optional resolveATA: boolean

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

      • Optional destinationWallet: Address

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

      • Optional positionWallet: Address

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

      • Optional ataPayer: 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.

Param: liquidityInput

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

Param: resolveATA

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

Param: destinationWallet

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

Param: positionWallet

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

Param: ataPayer

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

Returns

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

getAddress: (() => PublicKey)

Return the address for this Whirlpool instance.

Type declaration

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

      Returns PublicKey

      the PublicKey for this Whirlpool instance.

Returns

the PublicKey for this Whirlpool instance.

getData: (() => PositionData)

Return the most recently fetched Position account data.

Type declaration

    • (): PositionData
    • Return the most recently fetched Position account data.

      Returns PositionData

      most recently fetched PositionData for this address.

Returns

most recently fetched PositionData for this address.

getLowerTickData: (() => TickData)

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

Type declaration

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

      Returns TickData

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

Returns

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

getUpperTickData: (() => TickData)

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

Type declaration

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

      Returns TickData

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

Returns

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

    • (): WhirlpoolData
    • Return the most recently fetched Whirlpool account data for this position.

      Returns WhirlpoolData

      most recently fetched WhirlpoolData for this position.

Returns

most recently fetched WhirlpoolData for this position.

increaseLiquidity: ((liquidityInput, resolveATA?, wallet?, positionWallet?, ataPayer?) => 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, resolveATA?, wallet?, positionWallet?, ataPayer?): 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.

      Parameters

      • liquidityInput: IncreaseLiquidityInput

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

      • Optional resolveATA: boolean

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

      • Optional wallet: Address

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

      • Optional positionWallet: Address

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

      • Optional ataPayer: 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.

Param: liquidityInput

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

Param: resolveATA

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

Param: wallet

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

Param: positionWallet

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

Param: ataPayer

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

Returns

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

refreshData: (() => Promise<PositionData>)

Fetch and return the most recently fetched Position account data.

Type declaration

    • (): Promise<PositionData>
    • Fetch and return the most recently fetched Position account data.

      Returns Promise<PositionData>

      the most up to date PositionData for this address.

Returns

the most up to date PositionData for this address.

Generated using TypeDoc