Documentation
    Preparing search index...

    Instruction builders for the Whirlpools program.

    Index

    Instructions

    • Close a position in a Whirlpool. Burns the position token in the owner's wallet. Mint and TokenAccount are based on Token-2022. And Mint accout will be also closed.

      Parameters

      • program: Program<Whirlpool>

        program object containing services required to generate the instruction

      • params: ClosePositionWithTokenExtensionsParams

        ClosePositionWithTokenExtensionsParams object

      Returns Instruction

      • Instruction to perform the action.
    • Lock the position to prevent any liquidity changes.

      PositionAlreadyLocked - The provided position is already locked. PositionNotLockable - The provided position is not lockable (e.g. An empty position).

      Parameters

      • program: Program<Whirlpool>

        program object containing services required to generate the instruction

      • params: LockPositionParams

        LockPositionParams object.

      Returns Instruction

      • Instruction to perform the action.
    • Updates an adaptive fee tier account with a new default base fee rate. The new rate will not retroactively update initialized pools.

      Parameters

      Returns Instruction

      • Instruction to perform the action.

    Other

    • Close a bundled position in a Whirlpool.

      InvalidBundleIndex - If the provided bundle index is out of bounds. ClosePositionNotEmpty - The provided position account is not empty.

      Parameters

      • program: Program<Whirlpool>

        program object containing services required to generate the instruction

      • params: CloseBundledPositionParams

        CloseBundledPositionParams object

      Returns Instruction

      • Instruction to perform the action.
    • Close a position in a Whirlpool. Burns the position token in the owner's wallet.

      Parameters

      • program: Program<Whirlpool>

        program object containing services required to generate the instruction

      • params: ClosePositionParams

        ClosePositionParams object

      Returns Instruction

      • Instruction to perform the action.
    • Collect fees accrued for this position. Call updateFeesAndRewards before this to update the position to the newest accrued values.

      Parameters

      • program: Program<Whirlpool>

        program object containing services required to generate the instruction

      • params: CollectFeesParams

        CollectFeesParams object

      Returns Instruction

      • Instruction to perform the action.
    • Collect protocol fees accrued in this Whirlpool.

      Parameters

      • program: Program<Whirlpool>

        program object containing services required to generate the instruction

      • params: CollectProtocolFeesParams

        CollectProtocolFeesParams object

      Returns Instruction

      • Instruction to perform the action.
    • Collect rewards accrued for this reward index in a position. Call updateFeesAndRewards before this to update the position to the newest accrued values.

      Parameters

      • program: Program<Whirlpool>

        program object containing services required to generate the instruction

      • params: CollectRewardParams

        CollectRewardParams object

      Returns Instruction

      • Instruction to perform the action.
    • Remove liquidity to a position in the Whirlpool. This call also updates the position's accrued fees and rewards.

      • LiquidityZero - Provided liquidity amount is zero.
      • LiquidityTooHigh - Provided liquidity exceeds u128::max.
      • TokenMinSubceeded - The required token to perform this operation subceeds the user defined amount.

      Parameters

      • program: Program<Whirlpool>

        program object containing services required to generate the instruction

      • params: DecreaseLiquidityParams

        DecreaseLiquidityParams object

      Returns Instruction

      • Instruction to perform the action.
    • Deletes a PositionBundle account.

      PositionBundleNotDeletable - The provided position bundle has open positions.

      Parameters

      • program: Program<Whirlpool>

        program object containing services required to generate the instruction

      • params: DeletePositionBundleParams

        DeletePositionBundleParams object

      Returns Instruction

      • Instruction to perform the action.
    • Add liquidity to a position in the Whirlpool. This call also updates the position's accrued fees and rewards.

      LiquidityZero - Provided liquidity amount is zero. LiquidityTooHigh - Provided liquidity exceeds u128::max. TokenMaxExceeded - The required token to perform this operation exceeds the user defined amount.

      Parameters

      • program: Program<Whirlpool>

        program object containing services required to generate the instruction

      • params: IncreaseLiquidityParams

        IncreaseLiquidityParams object

      Returns Instruction

      • Instruction to perform the action.
    • Initializes a WhirlpoolsConfig account that hosts info & authorities required to govern a set of Whirlpools.

      Parameters

      • program: Program<Whirlpool>

        program object containing services required to generate the instruction

      • params: InitConfigParams

        InitConfigParams object

      Returns Instruction

      • Instruction to perform the action.
    • Initializes a fee tier account usable by Whirlpools in this WhirlpoolsConfig space.

      Special Errors FeeRateMaxExceeded - If the provided default_fee_rate exceeds MAX_FEE_RATE.

      Parameters

      • program: Program<Whirlpool>

        program object containing services required to generate the instruction

      • params: InitFeeTierParams

        InitFeeTierParams object

      Returns Instruction

      • Instruction to perform the action.
    • Initializes a tick_array account to represent a tick-range in a Whirlpool.

      Special Errors InvalidTokenMintOrder - The order of mints have to be ordered by SqrtPriceOutOfBounds - provided initial_sqrt_price is not between 2^-64 to 2^64

      Parameters

      • program: Program<Whirlpool>

        program object containing services required to generate the instruction

      • params: InitPoolParams

        InitPoolParams object

      Returns Instruction

      • Instruction to perform the action.
    • Initializes a PositionBundle account. Additional Metaplex metadata is appended to identify the token.

      Parameters

      • program: Program<Whirlpool>

        program object containing services required to generate the instruction

      • params: InitializePositionBundleParams & { positionBundleMetadataPda: PDA }

        InitializePositionBundleParams object

      Returns Instruction

      • Instruction to perform the action.
    • Initialize reward for a Whirlpool. A pool can only support up to a set number of rewards. The initial emissionsPerSecond is set to 0.

      • InvalidRewardIndex - If the provided reward index doesn't match the lowest uninitialized index in this pool, or exceeds NUM_REWARDS, or all reward slots for this pool has been initialized.

      Parameters

      • program: Program<Whirlpool>

        program object containing services required to generate the instruction

      • params: InitializeRewardParams

        InitializeRewardParams object

      Returns Instruction

      • Instruction to perform the action.
    • Initializes a TickArray account.

      InvalidStartTick - if the provided start tick is out of bounds or is not a multiple of TICK_ARRAY_SIZE * tick spacing.

      Parameters

      • program: Program<Whirlpool>

        program object containing services required to generate the instruction

      • params: InitTickArrayParams

        InitTickArrayParams object

      Returns Instruction

      • Instruction to perform the action.
    • Open a bundled position in a Whirlpool. No new tokens are issued because the owner of the position bundle becomes the owner of the position. The position will start off with 0 liquidity.

      InvalidBundleIndex - If the provided bundle index is out of bounds. InvalidTickIndex - If a provided tick is out of bounds, out of order or not a multiple of the tick-spacing in this pool.

      Parameters

      • program: Program<Whirlpool>

        program object containing services required to generate the instruction

      • params: OpenBundledPositionParams

        OpenBundledPositionParams object

      Returns Instruction

      • Instruction to perform the action.
    • Open a position in a Whirlpool. A unique token will be minted to represent the position in the users wallet. The position will start off with 0 liquidity.

      InvalidTickIndex - If a provided tick is out of bounds, out of order or not a multiple of the tick-spacing in this pool.

      Parameters

      • program: Program<Whirlpool>

        program object containing services required to generate the instruction

      • params: OpenPositionParams

        OpenPositionParams object

      Returns Instruction

      • Instruction to perform the action.
    • Open a position in a Whirlpool. A unique token will be minted to represent the position in the users wallet. Additional Metaplex metadata is appended to identify the token. The position will start off with 0 liquidity.

      InvalidTickIndex - If a provided tick is out of bounds, out of order or not a multiple of the tick-spacing in this pool.

      Parameters

      • program: Program<Whirlpool>

        program object containing services required to generate the instruction

      • params: OpenPositionParams & { metadataPda: PDA }

        OpenPositionParams object and a derived PDA that hosts the position's metadata.

      Returns Instruction

      • Instruction to perform the action.
    • Open a position in a Whirlpool. A unique token will be minted to represent the position in the users wallet. Additional TokenMetadata extension is initialized to identify the token if requested. Mint and Token account are based on Token-2022. The position will start off with 0 liquidity.

      InvalidTickIndex - If a provided tick is out of bounds, out of order or not a multiple of the tick-spacing in this pool.

      Parameters

      • program: Program<Whirlpool>

        program object containing services required to generate the instruction

      • params: OpenPositionWithTokenExtensionsParams

        OpenPositionWithTokenExtensionsParams object and a derived PDA that hosts the position's metadata.

      Returns Instruction

      • Instruction to perform the action.
    • Reset a position's range. Requires liquidity to be zero.

      InvalidTickIndex - If a provided tick is out of bounds, out of order or not a multiple of the tick-spacing in this pool. ClosePositionNotEmpty - The provided position account is not empty. SameTickRangeNotAllowed - The provided tick range is the same as the current tick range.

      Parameters

      • program: Program<Whirlpool>

        program object containing services required to generate the instruction

      • params: ResetPositionRangeParams

        ResetPositionRangeParams object

      Returns Instruction

      • Instruction to perform the action.
    • Sets the fee authority to collect protocol fees for a WhirlpoolsConfig. Only the current collect protocol fee authority has permission to invoke this instruction.

      Parameters

      • program: Program<Whirlpool>

        program object containing services required to generate the instruction

      • params: SetCollectProtocolFeesAuthorityParams

        SetCollectProtocolFeesAuthorityParams object

      Returns Instruction

      • Instruction to perform the action.
    • Updates a fee tier account with a new default fee rate. The new rate will not retroactively update initialized pools.

      • FeeRateMaxExceeded - If the provided default_fee_rate exceeds MAX_FEE_RATE.

      Parameters

      • program: Program<Whirlpool>

        program object containing services required to generate the instruction

      • params: SetDefaultFeeRateParams

        SetDefaultFeeRateParams object

      Returns Instruction

      • Instruction to perform the action.
    • Updates a WhirlpoolsConfig with a new default protocol fee rate. The new rate will not retroactively update initialized pools.

      • ProtocolFeeRateMaxExceeded - If the provided default_protocol_fee_rate exceeds MAX_PROTOCOL_FEE_RATE.

      Parameters

      • program: Program<Whirlpool>

        program object containing services required to generate the instruction

      • params: SetDefaultProtocolFeeRateParams

        SetDefaultFeeRateParams object

      Returns Instruction

      • Instruction to perform the action.
    • Sets the fee authority for a WhirlpoolsConfig. The fee authority can set the fee & protocol fee rate for individual pools or set the default fee rate for newly minted pools. Only the current fee authority has permission to invoke this instruction.

      Parameters

      • program: Program<Whirlpool>

        program object containing services required to generate the instruction

      • params: SetFeeAuthorityParams

        SetFeeAuthorityParams object

      Returns Instruction

      • Instruction to perform the action.
    • Sets the fee rate for a Whirlpool. Only the current fee authority has permission to invoke this instruction.

      • FeeRateMaxExceeded - If the provided fee_rate exceeds MAX_FEE_RATE.

      Parameters

      • program: Program<Whirlpool>

        program object containing services required to generate the instruction

      • params: SetFeeRateParams

        SetFeeRateParams object

      Returns Instruction

      • Instruction to perform the action.
    • Sets the protocol fee rate for a Whirlpool. Only the current fee authority has permission to invoke this instruction.

      • ProtocolFeeRateMaxExceeded - If the provided default_protocol_fee_rate exceeds MAX_PROTOCOL_FEE_RATE.

      Parameters

      • program: Program<Whirlpool>

        program object containing services required to generate the instruction

      • params: SetProtocolFeeRateParams

        SetFeeRateParams object

      Returns Instruction

      • Instruction to perform the action.
    • Set the whirlpool reward authority at the provided reward_index. Only the current reward super authority has permission to invoke this instruction.

      • InvalidRewardIndex - If the provided reward index doesn't match the lowest uninitialized index in this pool, or exceeds NUM_REWARDS.

      Parameters

      Returns Instruction

      • Instruction to perform the action.
    • Set the whirlpool reward authority at the provided reward_index. Only the current reward authority for this reward index has permission to invoke this instruction.

      • InvalidRewardIndex - If the provided reward index doesn't match the lowest uninitialized index in this pool, or exceeds NUM_REWARDS.

      Parameters

      • program: Program<Whirlpool>

        program object containing services required to generate the instruction

      • params: SetRewardAuthorityParams

        SetRewardAuthorityParams object

      Returns Instruction

      • Instruction to perform the action.
    • Set the reward emissions for a reward in a Whirlpool.

      • RewardVaultAmountInsufficient - The amount of rewards in the reward vault cannot emit more than a day of desired emissions.
      • InvalidTimestamp - Provided timestamp is not in order with the previous timestamp.
      • InvalidRewardIndex - If the provided reward index doesn't match the lowest uninitialized index in this pool, or exceeds NUM_REWARDS.

      Parameters

      • program: Program<Whirlpool>

        program object containing services required to generate the instruction

      • params: SetRewardEmissionsParams

        SetRewardEmissionsParams object

      Returns Instruction

      • Instruction to perform the action.
    • Set the whirlpool reward super authority for a WhirlpoolsConfig Only the current reward super authority has permission to invoke this instruction. This instruction will not change the authority on any WhirlpoolRewardInfo whirlpool rewards.

      Parameters

      • program: Program<Whirlpool>

        program object containing services required to generate the instruction

      • params: SetRewardEmissionsSuperAuthorityParams

        SetRewardEmissionsSuperAuthorityParams object

      Returns Instruction

      • Instruction to perform the action.
    • Perform a swap in this Whirlpool

      • ZeroTradableAmount - User provided parameter amount is 0.
      • InvalidSqrtPriceLimitDirection - User provided parameter sqrt_price_limit does not match the direction of the trade.
      • SqrtPriceOutOfBounds - User provided parameter sqrt_price_limit is over Whirlppool's max/min bounds for sqrt-price.
      • InvalidTickArraySequence - User provided tick-arrays are not in sequential order required to proceed in this trade direction.
      • TickArraySequenceInvalidIndex - The swap loop attempted to access an invalid array index during the query of the next initialized tick.
      • TickArrayIndexOutofBounds - The swap loop attempted to access an invalid array index during tick crossing.
      • LiquidityOverflow - Liquidity value overflowed 128bits during tick crossing.
      • InvalidTickSpacing - The swap pool was initialized with tick-spacing of 0.
      • AmountCalcOverflow - The required token amount exceeds the u64 range.
      • AmountRemainingOverflow - Result does not match the specified amount.
      • DifferentWhirlpoolTickArrayAccount - The provided tick array account does not belong to the whirlpool.
      • PartialFillError - Partially filled when sqrtPriceLimit = 0 and amountSpecifiedIsInput = false.

      Parameters

      • program: Program<Whirlpool>

        program object containing services required to generate the instruction

      • params: SwapParams

      Returns Instruction

      • Instruction to perform the action.
    • Transfer a position in a Whirlpool.

      Parameters

      • program: Program<Whirlpool>

        program object containing services required to generate the instruction

      • params: TransferLockedPositionParams

        TransferPositionParams object

      Returns Instruction

      • Instruction to perform the action.
    • Perform a two-hop-swap in this Whirlpool

      • ZeroTradableAmount - User provided parameter amount is 0.
      • InvalidSqrtPriceLimitDirection - User provided parameter sqrt_price_limit does not match the direction of the trade.
      • SqrtPriceOutOfBounds - User provided parameter sqrt_price_limit is over Whirlppool's max/min bounds for sqrt-price.
      • InvalidTickArraySequence - User provided tick-arrays are not in sequential order required to proceed in this trade direction.
      • TickArraySequenceInvalidIndex - The swap loop attempted to access an invalid array index during the query of the next initialized tick.
      • TickArrayIndexOutofBounds - The swap loop attempted to access an invalid array index during tick crossing.
      • LiquidityOverflow - Liquidity value overflowed 128bits during tick crossing.
      • InvalidTickSpacing - The swap pool was initialized with tick-spacing of 0.
      • DuplicateTwoHopPool - Swaps on the same pool are not allowed.
      • InvalidIntermediaryMint - The first and second leg of the hops do not share a common token.
      • AmountCalcOverflow - The required token amount exceeds the u64 range.
      • AmountRemainingOverflow - Result does not match the specified amount.
      • DifferentWhirlpoolTickArrayAccount - The provided tick array account does not belong to the whirlpool.
      • PartialFillError - Partially filled when sqrtPriceLimit = 0 and amountSpecifiedIsInput = false.
      • IntermediateTokenAmountMismatch - The amount of tokens received from the first hop does not match the amount sent to the second hop.

      Parameters

      • program: Program<Whirlpool>

        program object containing services required to generate the instruction

      • params: TwoHopSwapParams

        TwoHopSwapParams object

      Returns Instruction

      • Instruction to perform the action.
    • Update the accrued fees and rewards for a position.

      TickNotFound - Provided tick array account does not contain the tick for this position. LiquidityZero - Position has zero liquidity and therefore already has the most updated fees and reward values.

      Parameters

      • program: Program<Whirlpool>

        program object containing services required to generate the instruction

      • params: UpdateFeesAndRewardsParams

        UpdateFeesAndRewardsParams object

      Returns Instruction

      • Instruction to perform the action.