@renec-foundation/redex-sdk
Version:
Typescript SDK to interact with Orca's Whirlpool program.
350 lines (345 loc) • 19.9 kB
TypeScript
import { PDA } from "@orca-so/common-sdk";
import { Program } from "@project-serum/anchor";
import { WhirlpoolContext } from ".";
import { Whirlpool } from "./artifacts/whirlpool";
import * as ix from "./instructions";
/**
* Instruction builders for the Whirlpools program.
*
* @category Core
*/
export declare class WhirlpoolIx {
/**
* Initializes a WhirlpoolsConfig account that hosts info & authorities
* required to govern a set of Whirlpools.
*
* @param program - program object containing services required to generate the instruction
* @param params - InitConfigParams object
* @returns - Instruction to perform the action.
*/
static initializeConfigIx(program: Program<Whirlpool>, params: ix.InitConfigParams): import("@orca-so/common-sdk").Instruction;
/**
* 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.
*
* @param program - program object containing services required to generate the instruction
* @param params - InitFeeTierParams object
* @returns - Instruction to perform the action.
*/
static initializeFeeTierIx(program: Program<Whirlpool>, params: ix.InitFeeTierParams): import("@orca-so/common-sdk").Instruction;
/**
* 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
*
* @param program - program object containing services required to generate the instruction
* @param params - InitPoolParams object
* @returns - Instruction to perform the action.
*/
static initializePoolIx(program: Program<Whirlpool>, params: ix.InitPoolParams): import("@orca-so/common-sdk").Instruction;
/**
* Initialize reward for a Whirlpool. A pool can only support up to a set number of rewards.
* The initial emissionsPerSecond is set to 0.
*
* #### Special Errors
* - `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.
*
* @param program - program object containing services required to generate the instruction
* @param params - InitializeRewardParams object
* @returns - Instruction to perform the action.
*/
static initializeRewardIx(program: Program<Whirlpool>, params: ix.InitializeRewardParams): import("@orca-so/common-sdk").Instruction;
/**
* Initializes a TickArray account.
*
* #### Special Errors
* `InvalidStartTick` - if the provided start tick is out of bounds or is not a multiple of TICK_ARRAY_SIZE * tick spacing.
*
* @param program - program object containing services required to generate the instruction
* @param params - InitTickArrayParams object
* @returns - Instruction to perform the action.
*/
static initTickArrayIx(program: Program<Whirlpool>, params: ix.InitTickArrayParams): import("@orca-so/common-sdk").Instruction;
/**
* 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.
*
* #### Special Errors
* `InvalidTickIndex` - If a provided tick is out of bounds, out of order or not a multiple of the tick-spacing in this pool.
*
* @param program - program object containing services required to generate the instruction
* @param params - OpenPositionParams object
* @returns - Instruction to perform the action.
*/
static openPositionIx(program: Program<Whirlpool>, params: ix.OpenPositionParams): import("@orca-so/common-sdk").Instruction;
/**
* 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.
*
* #### Special Errors
* `InvalidTickIndex` - If a provided tick is out of bounds, out of order or not a multiple of the tick-spacing in this pool.
*
* @param program - program object containing services required to generate the instruction
* @param params - OpenPositionParams object and a derived PDA that hosts the position's metadata.
* @returns - Instruction to perform the action.
*/
static openPositionWithMetadataIx(program: Program<Whirlpool>, params: ix.OpenPositionParams & {
metadataPda: PDA;
}): import("@orca-so/common-sdk").Instruction;
/**
* Add liquidity to a position in the Whirlpool. This call also updates the position's accrued fees and rewards.
*
* #### Special Errors
* `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.
*
* @param program - program object containing services required to generate the instruction
* @param params - IncreaseLiquidityParams object
* @returns - Instruction to perform the action.
*/
static increaseLiquidityIx(program: Program<Whirlpool>, params: ix.IncreaseLiquidityParams): import("@orca-so/common-sdk").Instruction;
/**
* Remove liquidity to a position in the Whirlpool. This call also updates the position's accrued fees and rewards.
*
* #### Special Errors
* - `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.
*
* @param program - program object containing services required to generate the instruction
* @param params - DecreaseLiquidityParams object
* @returns - Instruction to perform the action.
*/
static decreaseLiquidityIx(program: Program<Whirlpool>, params: ix.DecreaseLiquidityParams): import("@orca-so/common-sdk").Instruction;
/**
* Close a position in a Whirlpool. Burns the position token in the owner's wallet.
*
* @param program - program object containing services required to generate the instruction
* @param params - ClosePositionParams object
* @returns - Instruction to perform the action.
*/
static closePositionIx(program: Program<Whirlpool>, params: ix.ClosePositionParams): import("@orca-so/common-sdk").Instruction;
/**
* Perform a swap in this Whirlpool
*
* #### Special Errors
* - `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.
*
* ### Parameters
* @param program - program object containing services required to generate the instruction
* @param params - {@link SwapParams}
* @returns - Instruction to perform the action.
*/
static swapIx(program: Program<Whirlpool>, params: ix.SwapParams): import("@orca-so/common-sdk").Instruction;
/**
* Perform a two-hop-swap in this Whirlpool
*
* #### Special Errors
* - `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.
*
* ### Parameters
* @param program - program object containing services required to generate the instruction
* @param params - TwoHopSwapParams object
* @returns - Instruction to perform the action.
*/
static twoHopSwapIx(program: Program<Whirlpool>, params: ix.TwoHopSwapParams): import("@orca-so/common-sdk").Instruction;
/**
* Update the accrued fees and rewards for a position.
*
* #### Special Errors
* `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.
*
* @param program - program object containing services required to generate the instruction
* @param params - UpdateFeesAndRewardsParams object
* @returns - Instruction to perform the action.
*/
static updateFeesAndRewardsIx(program: Program<Whirlpool>, params: ix.UpdateFeesAndRewardsParams): import("@orca-so/common-sdk").Instruction;
/**
* Collect fees accrued for this position.
* Call updateFeesAndRewards before this to update the position to the newest accrued values.
*
* @param program - program object containing services required to generate the instruction
* @param params - CollectFeesParams object
* @returns - Instruction to perform the action.
*/
static collectFeesIx(program: Program<Whirlpool>, params: ix.CollectFeesParams): import("@orca-so/common-sdk").Instruction;
/**
* Collect protocol fees accrued in this Whirlpool.
*
* @param program - program object containing services required to generate the instruction
* @param params - CollectProtocolFeesParams object
* @returns - Instruction to perform the action.
*/
static collectProtocolFeesIx(program: Program<Whirlpool>, params: ix.CollectProtocolFeesParams): import("@orca-so/common-sdk").Instruction;
/**
* Collect rewards accrued for this reward index in a position.
* Call updateFeesAndRewards before this to update the position to the newest accrued values.
*
* @param program - program object containing services required to generate the instruction
* @param params - CollectRewardParams object
* @returns - Instruction to perform the action.
*/
static collectRewardIx(program: Program<Whirlpool>, params: ix.CollectRewardParams): import("@orca-so/common-sdk").Instruction;
/**
* Sets the fee authority to collect protocol fees for a WhirlpoolsConfig.
* Only the current collect protocol fee authority has permission to invoke this instruction.
*
* @param program - program object containing services required to generate the instruction
* @param params - SetCollectProtocolFeesAuthorityParams object
* @returns - Instruction to perform the action.
*/
static setCollectProtocolFeesAuthorityIx(program: Program<Whirlpool>, params: ix.SetCollectProtocolFeesAuthorityParams): import("@orca-so/common-sdk").Instruction;
/**
* Updates a fee tier account with a new default fee rate. The new rate will not retroactively update
* initialized pools.
*
* #### Special Errors
* - `FeeRateMaxExceeded` - If the provided default_fee_rate exceeds MAX_FEE_RATE.
*
* @param program - program object containing services required to generate the instruction
* @param params - SetDefaultFeeRateParams object
* @returns - Instruction to perform the action.
*/
static setDefaultFeeRateIx(program: Program<Whirlpool>, params: ix.SetDefaultFeeRateParams): import("@orca-so/common-sdk").Instruction;
/**
* Updates a WhirlpoolsConfig with a new default protocol fee rate. The new rate will not retroactively update
* initialized pools.
*
* #### Special Errors
* - `ProtocolFeeRateMaxExceeded` - If the provided default_protocol_fee_rate exceeds MAX_PROTOCOL_FEE_RATE.
*
* @param program - program object containing services required to generate the instruction
* @param params - SetDefaultFeeRateParams object
* @returns - Instruction to perform the action.
*/
static setDefaultProtocolFeeRateIx(program: Program<Whirlpool>, params: ix.SetDefaultProtocolFeeRateParams): import("@orca-so/common-sdk").Instruction;
/**
* 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.
*
* @param program - program object containing services required to generate the instruction
* @param params - SetFeeAuthorityParams object
* @returns - Instruction to perform the action.
*/
static setFeeAuthorityIx(program: Program<Whirlpool>, params: ix.SetFeeAuthorityParams): import("@orca-so/common-sdk").Instruction;
/**
* Sets the pool creator authority for a WhirlpoolsConfig.
* Only the current pool creator authority has permission to invoke this instruction.
*
* @param program - program object containing services required to generate the instruction
* @param params - SetPoolCreatorAuthorityParams object
* @returns - Instruction to perform the action.
*/
static setPoolCreatorAuthorityIx(program: Program<Whirlpool>, params: ix.SetPoolCreatorAuthorityParams): import("@orca-so/common-sdk").Instruction;
/**
* Sets the fee rate for a Whirlpool.
* Only the current fee authority has permission to invoke this instruction.
*
* #### Special Errors
* - `FeeRateMaxExceeded` - If the provided fee_rate exceeds MAX_FEE_RATE.
*
* @param program - program object containing services required to generate the instruction
* @param params - SetFeeRateParams object
* @returns - Instruction to perform the action.
*/
static setFeeRateIx(program: Program<Whirlpool>, params: ix.SetFeeRateParams): import("@orca-so/common-sdk").Instruction;
/**
* Sets the protocol fee rate for a Whirlpool.
* Only the current fee authority has permission to invoke this instruction.
*
* #### Special Errors
* - `ProtocolFeeRateMaxExceeded` - If the provided default_protocol_fee_rate exceeds MAX_PROTOCOL_FEE_RATE.
*
* @param program - program object containing services required to generate the instruction
* @param params - SetFeeRateParams object
* @returns - Instruction to perform the action.
*/
static setProtocolFeeRateIx(program: Program<Whirlpool>, params: ix.SetProtocolFeeRateParams): import("@orca-so/common-sdk").Instruction;
/**
* Set the whirlpool reward authority at the provided `reward_index`.
* Only the current reward super authority has permission to invoke this instruction.
*
* #### Special Errors
* - `InvalidRewardIndex` - If the provided reward index doesn't match the lowest uninitialized index in this pool,
* or exceeds NUM_REWARDS.
*
* @param program - program object containing services required to generate the instruction
* @param params - SetRewardAuthorityParams object
* @returns - Instruction to perform the action.
*/
static setRewardAuthorityBySuperAuthorityIx(program: Program<Whirlpool>, params: ix.SetRewardAuthorityBySuperAuthorityParams): import("@orca-so/common-sdk").Instruction;
/**
* 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.
*
* #### Special Errors
* - `InvalidRewardIndex` - If the provided reward index doesn't match the lowest uninitialized index in this pool,
* or exceeds NUM_REWARDS.
*
* @param program - program object containing services required to generate the instruction
* @param params - SetRewardAuthorityParams object
* @returns - Instruction to perform the action.
*/
static setRewardAuthorityIx(program: Program<Whirlpool>, params: ix.SetRewardAuthorityParams): import("@orca-so/common-sdk").Instruction;
/**
* Set the reward emissions for a reward in a Whirlpool.
*
* #### Special Errors
* - `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.
*
* @param program - program object containing services required to generate the instruction
* @param params - SetRewardEmissionsParams object
* @returns - Instruction to perform the action.
*/
static setRewardEmissionsIx(program: Program<Whirlpool>, params: ix.SetRewardEmissionsParams): import("@orca-so/common-sdk").Instruction;
/**
* 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.
*
* @param program - program object containing services required to generate the instruction
* @param params - SetRewardEmissionsSuperAuthorityParams object
* @returns - Instruction to perform the action.
*/
static setRewardEmissionsSuperAuthorityIx(program: Program<Whirlpool>, params: ix.SetRewardEmissionsSuperAuthorityParams): import("@orca-so/common-sdk").Instruction;
/**
* DEPRECATED - use ${@link WhirlpoolClient} collectFeesAndRewardsForPositions function
* A set of transactions to collect all fees and rewards from a list of positions.
*
* @deprecated
* @param ctx - WhirlpoolContext object for the current environment.
* @param params - CollectAllPositionAddressParams object.
* @param refresh - if true, will always fetch for the latest values on chain to compute.
* @returns
*/
static collectAllForPositionsTxns(ctx: WhirlpoolContext, params: ix.CollectAllPositionAddressParams, refresh: boolean): Promise<import("@orca-so/common-sdk").TransactionBuilder[]>;
static setEnableFlagIx(program: Program<Whirlpool>, params: ix.SetEnableFlagParams): import("@orca-so/common-sdk").Instruction;
}