Orca Whirlpools decoder

Decode Orca Whirlpools instructions, accounts and events in Rust with the carbon-orca-whirlpool-decoder crate.

On this page

carbon-orca-whirlpool-decoder decodes the instructions, accounts and events of the Orca Whirlpools program (whirLbMiicVdio4qvUfM5KAg6Ct8VwpYzGff3uctyCc): 66 instructions, 12 account types, 6 events. It is generated with Codama from the program's IDL; see decoders for how decoders plug into a pipeline.

Cratecarbon-orca-whirlpool-decoder 2.0.0
Installcargo add carbon-orca-whirlpool-decoder@2.0.0
Program IDwhirLbMiicVdio4qvUfM5KAg6Ct8VwpYzGff3uctyCc (carbon_orca_whirlpool_decoder::PROGRAM_ID)
CategoryDEX & AMM
Decodercarbon_orca_whirlpool_decoder::OrcaWhirlpoolDecoder
Instruction enuminstructions::OrcaWhirlpoolInstruction
Account enumaccounts::OrcaWhirlpoolAccount
Event enuminstructions::CpiEvent
Featuresserde, postgres, graphql (none enabled by default)
API docsdocs.rs/carbon-orca-whirlpool-decoder/2.0.0
Sourcedecoders/orca-whirlpool-decoder

Other DEX and AMM decoders: BonkSwap, FluxBeam, Gavel, Heaven, Jupiter Limit Order, Jupiter Limit Order v2, Kamino Limit Order, Lifinity AMM v2, Meteora DAMM v2, Meteora DLMM, Meteora Pools, OpenBook v2, PancakeSwap, Phoenix v1, PumpSwap, Raydium AMM v4, Raydium CLMM, Raydium CPMM, Raydium Stable Swap, Stabble Stable Swap, Stabble Weighted Swap. To decode several in one pipeline, see dEX and AMM decoders.

The serde feature derives Serialize/Deserialize on every type, postgres adds tables and processors for Postgres, and graphql adds a schema for the GraphQL server.

Usage#

This program crawls recent Orca Whirlpools transactions from the public RPC and prints every decoded Swap instruction. Add the dependencies:

Terminal
cargo add carbon-core@2.0.0 carbon-orca-whirlpool-decoder@2.0.0 carbon-rpc-transaction-crawler-datasource@2.0.0 carbon-log-metrics@2.0.0 env_logger tokio --features tokio/full
src/main.rs
use {
    carbon_core::{
        error::CarbonResult, instruction::InstructionProcessorInputType, pipeline::Pipeline,
        processor::Processor,
    },
    carbon_log_metrics::LogMetrics,
    carbon_orca_whirlpool_decoder::{
        instructions::OrcaWhirlpoolInstruction, OrcaWhirlpoolDecoder, PROGRAM_ID,
    },
    carbon_rpc_transaction_crawler_datasource::{ConnectionConfig, Filters, RpcTransactionCrawler},
    std::sync::Arc,
};

#[tokio::main]
async fn main() -> CarbonResult<()> {
    env_logger::init();

    // Fetches the program's recent transactions over JSON-RPC, newest first.
    let datasource = RpcTransactionCrawler::new(
        "https://api.mainnet-beta.solana.com".to_string(),
        PROGRAM_ID,
        ConnectionConfig::default(),
        Filters::new(None, None, None),
        None,
    );

    Pipeline::builder()
        .datasource(datasource)
        .metrics(Arc::new(LogMetrics::new()))
        .instruction(OrcaWhirlpoolDecoder, InstructionLogger)
        .build()?
        .run()
        .await
}

struct InstructionLogger;

impl Processor<InstructionProcessorInputType<'_, OrcaWhirlpoolInstruction>> for InstructionLogger {
    async fn process(
        &mut self,
        input: &InstructionProcessorInputType<'_, OrcaWhirlpoolInstruction>,
    ) -> CarbonResult<()> {
        let signature = input.metadata.transaction_metadata.signature;
        if let OrcaWhirlpoolInstruction::Swap { data, accounts, .. } = input.decoded_instruction {
            println!("swap {signature}: {data:?} token_program={}", accounts.token_program);
        }
        Ok(())
    }
}
Terminal
RUST_LOG=info cargo run

Each Swap instruction prints one line with the transaction signature and the decoded Swap data. The public endpoint rate-limits requests, so the first lines can take a while; use your own RPC URL for anything beyond a test. See stream with RPC for the crawler options.

Events published with Anchor's emit_cpi! arrive as the CpiEvent instruction. Match them with OrcaWhirlpoolInstruction::CpiEvent { data: CpiEvent::LiquidityDecreased(event), .. } (import instructions::CpiEvent); see Events. If CpiEvent never arrives, the program logs its events with emit! instead: decode them with decode_log_events.

Decode accounts#

The transaction crawler emits transactions only. To decode accounts, use a datasource that emits account updates. This program subscribes to the program's accounts with programSubscribe on the public WebSocket endpoint and prints every decoded Whirlpool account as it changes. Add the datasource and the Solana RPC types it takes:

Terminal
cargo add carbon-rpc-program-subscribe-datasource@2.0.0 solana-client@4.2.2
src/main.rs
use {
    carbon_core::{
        account::AccountProcessorInputType, error::CarbonResult, pipeline::Pipeline,
        processor::Processor,
    },
    carbon_log_metrics::LogMetrics,
    carbon_orca_whirlpool_decoder::{
        accounts::OrcaWhirlpoolAccount, OrcaWhirlpoolDecoder, PROGRAM_ID,
    },
    carbon_rpc_program_subscribe_datasource::{Filters, RpcProgramSubscribe},
    solana_client::rpc_config::{RpcAccountInfoConfig, RpcProgramAccountsConfig, UiAccountEncoding},
    std::sync::Arc,
};

#[tokio::main]
async fn main() -> CarbonResult<()> {
    env_logger::init();

    // Streams every change to an account owned by the program (programSubscribe).
    let config = RpcProgramAccountsConfig {
        account_config: RpcAccountInfoConfig {
            encoding: Some(UiAccountEncoding::Base64),
            ..Default::default()
        },
        ..Default::default()
    };
    let datasource = RpcProgramSubscribe::new(
        "wss://api.mainnet-beta.solana.com".to_string(),
        Filters::new(PROGRAM_ID, Some(config)),
    );

    Pipeline::builder()
        .datasource(datasource)
        .metrics(Arc::new(LogMetrics::new()))
        .account(OrcaWhirlpoolDecoder, AccountLogger)
        .build()?
        .run()
        .await
}

struct AccountLogger;

impl Processor<AccountProcessorInputType<'_, OrcaWhirlpoolAccount>> for AccountLogger {
    async fn process(
        &mut self,
        input: &AccountProcessorInputType<'_, OrcaWhirlpoolAccount>,
    ) -> CarbonResult<()> {
        if let OrcaWhirlpoolAccount::Whirlpool(whirlpool) = &input.decoded_account.data {
            println!("whirlpool {}: {whirlpool:?}", input.metadata.pubkey);
        }
        Ok(())
    }
}
Terminal
RUST_LOG=info cargo run

Each update to a Whirlpool account prints its address and decoded fields; the program runs until you stop it. Cargo resolves solana-client to 4.2.2, the exact version the datasource pins, so both use the same RpcProgramAccountsConfig type. To load every existing account once instead of streaming changes, see load account state.

Instructions#

Variants of OrcaWhirlpoolInstruction. Each is OrcaWhirlpoolInstruction::<Variant> { program_id, data, accounts }, where data and accounts are the types listed under the variant, exported from carbon_orca_whirlpool_decoder::instructions. Discriminators are the leading bytes of the instruction data, in hex.

How an instruction decodes. The decoder returns a variant only when all of these hold; otherwise the instruction is skipped and no processor is called:

  1. The instruction's program ID is whirLbMiicVdio4qvUfM5KAg6Ct8VwpYzGff3uctyCc.
  2. The data starts with the variant's discriminator, and the rest deserializes into its data type.
  3. The instruction has at least as many accounts as the variant requires (the "Required accounts" count under each variant).

Accounts. They are matched by position, in the order listed. An account marked optional is None only when the instruction ends before it; Anchor programs pass the program ID as a placeholder for an omitted optional account, so check for Some(PROGRAM_ID) too. Accounts after the listed ones are in accounts.remaining as AccountMetas. The decoder doesn't record whether an account signed or was writable: read that from input.raw_instruction.accounts[i].is_signer and .is_writable, which follow the same order. It doesn't check signer, writable, owner or PDA constraints either; the program enforced those when the transaction executed, so a decoded instruction from a successful transaction already satisfied them.

CloseBundledPosition#

From the program's IDL:

Close a bundled position in a Whirlpool.

Authority

  • position_bundle_authority - authority that owns the token corresponding to this desired position bundle.

Parameters

  • bundle_index - The bundle index that we'd like to close.

Special Errors

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

Discriminator 2924d8f51b556743 · data CloseBundledPosition · accounts CloseBundledPositionInstructionAccounts.

FieldType
bundle_indexu16

Required accounts: 5; extras go to remaining.

Fields of CloseBundledPositionInstructionAccounts, in account order:

#FieldType
0bundled_positionPubkey
1position_bundlePubkey
2position_bundle_token_accountPubkey
3position_bundle_authorityPubkey
4receiverPubkey
5…remainingVec<AccountMeta>

ClosePosition#

From the program's IDL:

Close a position in a Whirlpool. Burns the position token in the owner's wallet. ### Authority

  • "position_authority" - The authority that owns the position token.

Special Errors

  • ClosePositionNotEmpty - The provided position account is not empty.

Discriminator 7b86510031446262 · data ClosePosition · accounts ClosePositionInstructionAccounts.

No data fields.

Required accounts: 6; extras go to remaining.

Fields of ClosePositionInstructionAccounts, in account order:

#FieldType
0position_authorityPubkey
1receiverPubkey
2positionPubkey
3position_mintPubkey
4position_token_accountPubkey
5token_programPubkey
6…remainingVec<AccountMeta>

ClosePositionWithTokenExtensions#

From the program's IDL:

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. ### Authority

  • "position_authority" - The authority that owns the position token.

Special Errors

  • ClosePositionNotEmpty - The provided position account is not empty.

Discriminator 01b6873b9b1963df · data ClosePositionWithTokenExtensions · accounts ClosePositionWithTokenExtensionsInstructionAccounts.

No data fields.

Required accounts: 6; extras go to remaining.

Fields of ClosePositionWithTokenExtensionsInstructionAccounts, in account order:

#FieldType
0position_authorityPubkey
1receiverPubkey
2positionPubkey
3position_mintPubkey
4position_token_accountPubkey
5token2022_programPubkey
6…remainingVec<AccountMeta>

CollectFees#

From the program's IDL:

Collect fees accrued for this position.

Authority

  • position_authority - authority that owns the token corresponding to this desired position.

Discriminator a498cf631eba13b6 · data CollectFees · accounts CollectFeesInstructionAccounts.

No data fields.

Required accounts: 9; extras go to remaining.

Fields of CollectFeesInstructionAccounts, in account order:

#FieldType
0whirlpoolPubkey
1position_authorityPubkey
2positionPubkey
3position_token_accountPubkey
4token_owner_account_aPubkey
5token_vault_aPubkey
6token_owner_account_bPubkey
7token_vault_bPubkey
8token_programPubkey
9…remainingVec<AccountMeta>

CollectFeesV2#

From the program's IDL:

Collect fees accrued for this position.
This instruction works with both Token and Token-2022.

Authority

  • position_authority - authority that owns the token corresponding to this desired position.

Discriminator cf755fbfe5b4e20f · data CollectFeesV2 · accounts CollectFeesV2InstructionAccounts.

FieldType
remaining_accounts_infoOption<RemainingAccountsInfo>

Required accounts: 13; extras go to remaining.

Fields of CollectFeesV2InstructionAccounts, in account order:

#FieldType
0whirlpoolPubkey
1position_authorityPubkey
2positionPubkey
3position_token_accountPubkey
4token_mint_aPubkey
5token_mint_bPubkey
6token_owner_account_aPubkey
7token_vault_aPubkey
8token_owner_account_bPubkey
9token_vault_bPubkey
10token_program_aPubkey
11token_program_bPubkey
12memo_programPubkey
13…remainingVec<AccountMeta>

CollectProtocolFees#

From the program's IDL:

Collect the protocol fees accrued in this Whirlpool

Authority

  • collect_protocol_fees_authority - assigned authority in the WhirlpoolConfig that can collect protocol fees

Discriminator 1643176296b246dc · data CollectProtocolFees · accounts CollectProtocolFeesInstructionAccounts.

No data fields.

Required accounts: 8; extras go to remaining.

Fields of CollectProtocolFeesInstructionAccounts, in account order:

#FieldType
0whirlpools_configPubkey
1whirlpoolPubkey
2collect_protocol_fees_authorityPubkey
3token_vault_aPubkey
4token_vault_bPubkey
5token_destination_aPubkey
6token_destination_bPubkey
7token_programPubkey
8…remainingVec<AccountMeta>

CollectProtocolFeesV2#

From the program's IDL:

Collect the protocol fees accrued in this Whirlpool
This instruction works with both Token and Token-2022.

Authority

  • collect_protocol_fees_authority - assigned authority in the WhirlpoolConfig that can collect protocol fees

Discriminator 6780de8672c816c8 · data CollectProtocolFeesV2 · accounts CollectProtocolFeesV2InstructionAccounts.

FieldType
remaining_accounts_infoOption<RemainingAccountsInfo>

Required accounts: 12; extras go to remaining.

Fields of CollectProtocolFeesV2InstructionAccounts, in account order:

#FieldType
0whirlpools_configPubkey
1whirlpoolPubkey
2collect_protocol_fees_authorityPubkey
3token_mint_aPubkey
4token_mint_bPubkey
5token_vault_aPubkey
6token_vault_bPubkey
7token_destination_aPubkey
8token_destination_bPubkey
9token_program_aPubkey
10token_program_bPubkey
11memo_programPubkey
12…remainingVec<AccountMeta>

CollectReward#

From the program's IDL:

Collect rewards accrued for this position.

Authority

  • position_authority - authority that owns the token corresponding to this desired position.

Discriminator 4605845756ebb122 · data CollectReward · accounts CollectRewardInstructionAccounts.

FieldType
reward_indexu8

Required accounts: 7; extras go to remaining.

Fields of CollectRewardInstructionAccounts, in account order:

#FieldType
0whirlpoolPubkey
1position_authorityPubkey
2positionPubkey
3position_token_accountPubkey
4reward_owner_accountPubkey
5reward_vaultPubkey
6token_programPubkey
7…remainingVec<AccountMeta>

CollectRewardV2#

From the program's IDL:

Collect rewards accrued for this position.
This instruction works with both Token and Token-2022.

Authority

  • position_authority - authority that owns the token corresponding to this desired position.

Discriminator b16b25b4a01331d1 · data CollectRewardV2 · accounts CollectRewardV2InstructionAccounts.

FieldType
reward_indexu8
remaining_accounts_infoOption<RemainingAccountsInfo>

Required accounts: 9; extras go to remaining.

Fields of CollectRewardV2InstructionAccounts, in account order:

#FieldType
0whirlpoolPubkey
1position_authorityPubkey
2positionPubkey
3position_token_accountPubkey
4reward_owner_accountPubkey
5reward_mintPubkey
6reward_vaultPubkey
7reward_token_programPubkey
8memo_programPubkey
9…remainingVec<AccountMeta>

DecreaseLiquidity#

From the program's IDL:

Withdraw liquidity from a position in the Whirlpool. This call also updates the position's accrued fees and rewards. ### Authority

  • position_authority - authority that owns the token corresponding to this desired position.

Parameters

  • liquidity_amount - The total amount of Liquidity the user desires to withdraw.
  • token_min_a - The minimum amount of tokenA the user is willing to withdraw.
  • token_min_b - The minimum amount of tokenB the user is willing to withdraw.

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.

Discriminator a026d06f685b2c01 · data DecreaseLiquidity · accounts DecreaseLiquidityInstructionAccounts.

FieldType
liquidity_amountu128
token_min_au64
token_min_bu64

Required accounts: 11; extras go to remaining.

Fields of DecreaseLiquidityInstructionAccounts, in account order:

#FieldType
0whirlpoolPubkey
1token_programPubkey
2position_authorityPubkey
3positionPubkey
4position_token_accountPubkey
5token_owner_account_aPubkey
6token_owner_account_bPubkey
7token_vault_aPubkey
8token_vault_bPubkey
9tick_array_lowerPubkey
10tick_array_upperPubkey
11…remainingVec<AccountMeta>

DecreaseLiquidityV2#

From the program's IDL:

Withdraw liquidity from a position in the Whirlpool. This call also updates the position's accrued fees and rewards. This instruction works with both
Token and Token-2022. ### Authority

  • position_authority - authority that owns the token corresponding to this desired position.

Parameters

  • liquidity_amount - The total amount of Liquidity the user desires to withdraw.
  • token_min_a - The minimum amount of tokenA the user is willing to withdraw.
  • token_min_b - The minimum amount of tokenB the user is willing to withdraw.

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.

Discriminator 3a7fbc3e4f52c460 · data DecreaseLiquidityV2 · accounts DecreaseLiquidityV2InstructionAccounts.

FieldType
liquidity_amountu128
token_min_au64
token_min_bu64
remaining_accounts_infoOption<RemainingAccountsInfo>

Required accounts: 15; extras go to remaining.

Fields of DecreaseLiquidityV2InstructionAccounts, in account order:

#FieldType
0whirlpoolPubkey
1token_program_aPubkey
2token_program_bPubkey
3memo_programPubkey
4position_authorityPubkey
5positionPubkey
6position_token_accountPubkey
7token_mint_aPubkey
8token_mint_bPubkey
9token_owner_account_aPubkey
10token_owner_account_bPubkey
11token_vault_aPubkey
12token_vault_bPubkey
13tick_array_lowerPubkey
14tick_array_upperPubkey
15…remainingVec<AccountMeta>

DeletePositionBundle#

From the program's IDL:

Delete a PositionBundle account. Burns the position bundle token in the owner's wallet. ### Authority

  • position_bundle_owner - The owner that owns the position bundle token.

Special Errors

  • PositionBundleNotDeletable - The provided position bundle has open positions.

Discriminator 64196302d9ef7cad · data DeletePositionBundle · accounts DeletePositionBundleInstructionAccounts.

No data fields.

Required accounts: 6; extras go to remaining.

Fields of DeletePositionBundleInstructionAccounts, in account order:

#FieldType
0position_bundlePubkey
1position_bundle_mintPubkey
2position_bundle_token_accountPubkey
3position_bundle_ownerPubkey
4receiverPubkey
5token_programPubkey
6…remainingVec<AccountMeta>

DeleteTokenBadge#

From the program's IDL:

Delete a TokenBadge account.

Authority

  • "token_badge_authority" - Set authority in the WhirlpoolConfigExtension

Special Errors

  • FeatureIsNotEnabled - If the feature flag for token badges is not enabled.

Discriminator 35924408127511b9 · data DeleteTokenBadge · accounts DeleteTokenBadgeInstructionAccounts.

No data fields.

Required accounts: 6; extras go to remaining.

Fields of DeleteTokenBadgeInstructionAccounts, in account order:

#FieldType
0whirlpools_configPubkey
1whirlpools_config_extensionPubkey
2token_badge_authorityPubkey
3token_mintPubkey
4token_badgePubkey
5receiverPubkey
6…remainingVec<AccountMeta>

IdlInclude#

Discriminator dffd79793cc1811f · data IdlInclude · accounts IdlIncludeInstructionAccounts.

No data fields.

Required accounts: 2; extras go to remaining.

Fields of IdlIncludeInstructionAccounts, in account order:

#FieldType
0tick_arrayPubkey
1system_programPubkey
2…remainingVec<AccountMeta>

IncreaseLiquidity#

From the program's IDL:

Add liquidity to a position in the Whirlpool. This call also updates the position's accrued fees and rewards. ### Authority

  • position_authority - authority that owns the token corresponding to this desired position.

Parameters

  • liquidity_amount - The total amount of Liquidity the user is willing to deposit.
  • token_max_a - The maximum amount of tokenA the user is willing to deposit.
  • token_max_b - The maximum amount of tokenB the user is willing to deposit.

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.

Discriminator 2e9cf3760dcdfbb2 · data IncreaseLiquidity · accounts IncreaseLiquidityInstructionAccounts.

FieldType
liquidity_amountu128
token_max_au64
token_max_bu64

Required accounts: 11; extras go to remaining.

Fields of IncreaseLiquidityInstructionAccounts, in account order:

#FieldType
0whirlpoolPubkey
1token_programPubkey
2position_authorityPubkey
3positionPubkey
4position_token_accountPubkey
5token_owner_account_aPubkey
6token_owner_account_bPubkey
7token_vault_aPubkey
8token_vault_bPubkey
9tick_array_lowerPubkey
10tick_array_upperPubkey
11…remainingVec<AccountMeta>

IncreaseLiquidityByTokenAmountsV2#

From the program's IDL:

Add liquidity to a position by specifying token maxima, not liquidity.
This instruction works with both Token and Token-2022.
NOTE: This instruction is only implemented in Pinocchio, not Anchor.

Authority

  • position_authority - authority that owns the token corresponding to this desired position.

Parameters

  • token_max_a - The maximum amount of tokenA the user is willing to deposit.
  • token_max_b - The maximum amount of tokenB the user is willing to deposit.
  • min_sqrt_price - The minimum sqrt price allowed.
  • max_sqrt_price - The maximum sqrt price allowed.

Special Errors

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

Discriminator effb097cd2c6352b · data IncreaseLiquidityByTokenAmountsV2 · accounts IncreaseLiquidityByTokenAmountsV2InstructionAccounts.

FieldType
methodIncreaseLiquidityMethod
remaining_accounts_infoOption<RemainingAccountsInfo>

Required accounts: 15; extras go to remaining.

Fields of IncreaseLiquidityByTokenAmountsV2InstructionAccounts, in account order:

#FieldType
0whirlpoolPubkey
1token_program_aPubkey
2token_program_bPubkey
3memo_programPubkey
4position_authorityPubkey
5positionPubkey
6position_token_accountPubkey
7token_mint_aPubkey
8token_mint_bPubkey
9token_owner_account_aPubkey
10token_owner_account_bPubkey
11token_vault_aPubkey
12token_vault_bPubkey
13tick_array_lowerPubkey
14tick_array_upperPubkey
15…remainingVec<AccountMeta>

IncreaseLiquidityV2#

From the program's IDL:

Add liquidity to a position in the Whirlpool. This call also updates the position's accrued fees and rewards. This instruction works with both Token and Token-2022. ### Authority

  • position_authority - authority that owns the token corresponding to this desired position.

Parameters

  • liquidity_amount - The total amount of Liquidity the user is willing to deposit.
  • token_max_a - The maximum amount of tokenA the user is willing to deposit.
  • token_max_b - The maximum amount of tokenB the user is willing to deposit.

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.

Discriminator 851d59df45eeb00a · data IncreaseLiquidityV2 · accounts IncreaseLiquidityV2InstructionAccounts.

FieldType
liquidity_amountu128
token_max_au64
token_max_bu64
remaining_accounts_infoOption<RemainingAccountsInfo>

Required accounts: 15; extras go to remaining.

Fields of IncreaseLiquidityV2InstructionAccounts, in account order:

#FieldType
0whirlpoolPubkey
1token_program_aPubkey
2token_program_bPubkey
3memo_programPubkey
4position_authorityPubkey
5positionPubkey
6position_token_accountPubkey
7token_mint_aPubkey
8token_mint_bPubkey
9token_owner_account_aPubkey
10token_owner_account_bPubkey
11token_vault_aPubkey
12token_vault_bPubkey
13tick_array_lowerPubkey
14tick_array_upperPubkey
15…remainingVec<AccountMeta>

InitializeAdaptiveFeeTier#

From the program's IDL:

Initializes an adaptive_fee_tier account usable by Whirlpools in a
WhirlpoolConfig space. ### Authority

  • "fee_authority" - Set authority in the WhirlpoolConfig

Parameters

  • fee_tier_index - The index of the fee-tier that this adaptive fee tier will be initialized.
  • tick_spacing - The tick-spacing that this fee-tier suggests the default_fee_rate for.
  • initialize_pool_authority - The authority that can initialize pools with this adaptive fee-tier.
  • delegated_fee_authority - The authority that can set the base fee rate for pools using this adaptive fee-tier.
  • default_fee_rate - The default fee rate that a pool will use if the pool uses this

fee tier during initialization.

  • filter_period - Period determine high frequency trading time window.
    (seconds)
  • decay_period - Period determine when the adaptive fee start decrease.
    (seconds)
  • reduction_factor - Adaptive fee rate decrement rate.
  • adaptive_fee_control_factor - Adaptive fee control factor.
  • max_volatility_accumulator - Max volatility accumulator.
  • tick_group_size - Tick group size to define tick group index.
  • major_swap_threshold_ticks - Major swap threshold ticks to define major swap.

Special Errors

  • InvalidTickSpacing - If the provided tick_spacing is 0.
  • InvalidFeeTierIndex - If the provided fee_tier_index is same to tick_spacing.
  • FeeRateMaxExceeded - If the provided default_fee_rate exceeds
    MAX_FEE_RATE.
  • InvalidAdaptiveFeeConstants - If the provided adaptive fee constants are invalid.

Discriminator 4d63d0c88d7b7530 · data InitializeAdaptiveFeeTier · accounts InitializeAdaptiveFeeTierInstructionAccounts.

FieldType
fee_tier_indexu16
tick_spacingu16
initialize_pool_authorityPubkey
delegated_fee_authorityPubkey
default_base_fee_rateu16
filter_periodu16
decay_periodu16
reduction_factoru16
adaptive_fee_control_factoru32
max_volatility_accumulatoru32
tick_group_sizeu16
major_swap_threshold_ticksu16

Required accounts: 5; extras go to remaining.

Fields of InitializeAdaptiveFeeTierInstructionAccounts, in account order:

#FieldType
0whirlpools_configPubkey
1adaptive_fee_tierPubkey
2funderPubkey
3fee_authorityPubkey
4system_programPubkey
5…remainingVec<AccountMeta>

InitializeConfig#

From the program's IDL:

Initializes a WhirlpoolsConfig account that hosts info & authorities required to govern a set of Whirlpools.

Authority

  • "authority" - Set authority that is one of ADMINS.

Parameters

  • fee_authority - Authority authorized to initialize fee-tiers and set customs fees.
  • collect_protocol_fees_authority - Authority authorized to collect protocol fees.
  • reward_emissions_super_authority - Authority authorized to set reward authorities in pools.

Discriminator d07f1501c2bec446 · data InitializeConfig · accounts InitializeConfigInstructionAccounts.

FieldType
fee_authorityPubkey
collect_protocol_fees_authorityPubkey
reward_emissions_super_authorityPubkey
default_protocol_fee_rateu16

Required accounts: 3; extras go to remaining.

Fields of InitializeConfigInstructionAccounts, in account order:

#FieldType
0configPubkey
1funderPubkey
2system_programPubkey
3…remainingVec<AccountMeta>

InitializeConfigExtension#

From the program's IDL:

Initializes a WhirlpoolConfigExtension account that hosts info & authorities. ### Authority

  • "fee_authority" - Set authority in the WhirlpoolConfig

Discriminator 370935097239d134 · data InitializeConfigExtension · accounts InitializeConfigExtensionInstructionAccounts.

No data fields.

Required accounts: 5; extras go to remaining.

Fields of InitializeConfigExtensionInstructionAccounts, in account order:

#FieldType
0configPubkey
1config_extensionPubkey
2funderPubkey
3fee_authorityPubkey
4system_programPubkey
5…remainingVec<AccountMeta>

InitializeDynamicTickArray#

From the program's IDL:

Initialize a variable-length tick array for a Whirlpool.

Parameters

  • start_tick_index - The starting tick index for this tick-array.

Has to be a multiple of TickArray size & the tick spacing of this pool.

  • idempotent - If true, the instruction will not fail if the tick array already exists.

Note: The idempotent option exits successfully if a FixedTickArray is present as well as a DynamicTickArray. #### Special Errors

  • InvalidStartTick - if the provided start tick is out of bounds or is not a multiple of

TICK_ARRAY_SIZE * tick spacing.

Discriminator 2921a5c878e78e32 · data InitializeDynamicTickArray · accounts InitializeDynamicTickArrayInstructionAccounts.

FieldType
start_tick_indexi32
idempotentbool

Required accounts: 4; extras go to remaining.

Fields of InitializeDynamicTickArrayInstructionAccounts, in account order:

#FieldType
0whirlpoolPubkey
1funderPubkey
2tick_arrayPubkey
3system_programPubkey
4…remainingVec<AccountMeta>

InitializeFeeTier#

From the program's IDL:

Initializes a fee_tier account usable by Whirlpools in a WhirlpoolConfig space. ### Authority

  • "fee_authority" - Set authority in the WhirlpoolConfig

Parameters

  • tick_spacing - The tick-spacing that this fee-tier suggests the default_fee_rate for.
  • default_fee_rate - The default fee rate that a pool will use if the pool uses this

fee tier during initialization.

Special Errors

  • InvalidTickSpacing - If the provided tick_spacing is 0.
  • FeeRateMaxExceeded - If the provided default_fee_rate exceeds MAX_FEE_RATE.

Discriminator b74a9ca070022a1e · data InitializeFeeTier · accounts InitializeFeeTierInstructionAccounts.

FieldType
tick_spacingu16
default_fee_rateu16

Required accounts: 5; extras go to remaining.

Fields of InitializeFeeTierInstructionAccounts, in account order:

#FieldType
0configPubkey
1fee_tierPubkey
2funderPubkey
3fee_authorityPubkey
4system_programPubkey
5…remainingVec<AccountMeta>

InitializePool#

From the program's IDL:

Initializes a Whirlpool account.
Fee rate is set to the default values on the config and supplied fee_tier.

Parameters

  • bumps - The bump value when deriving the PDA of the Whirlpool address.
  • tick_spacing - The desired tick spacing for this pool.
  • initial_sqrt_price - The desired initial sqrt-price for this pool

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

Discriminator 5fb40aac54aee828 · data InitializePool · accounts InitializePoolInstructionAccounts.

FieldType
bumpsWhirlpoolBumps
tick_spacingu16
initial_sqrt_priceu128

Required accounts: 11; extras go to remaining.

Fields of InitializePoolInstructionAccounts, in account order:

#FieldType
0whirlpools_configPubkey
1token_mint_aPubkey
2token_mint_bPubkey
3funderPubkey
4whirlpoolPubkey
5token_vault_aPubkey
6token_vault_bPubkey
7fee_tierPubkey
8token_programPubkey
9system_programPubkey
10rentPubkey
11…remainingVec<AccountMeta>

InitializePoolV2#

From the program's IDL:

Initializes a Whirlpool account.
This instruction works with both Token and Token-2022.
Fee rate is set to the default values on the config and supplied fee_tier.

Parameters

  • bumps - The bump value when deriving the PDA of the Whirlpool address.
  • tick_spacing - The desired tick spacing for this pool.
  • initial_sqrt_price - The desired initial sqrt-price for this pool

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

Discriminator cf2d57f21b3fcc43 · data InitializePoolV2 · accounts InitializePoolV2InstructionAccounts.

FieldType
tick_spacingu16
initial_sqrt_priceu128

Required accounts: 14; extras go to remaining.

Fields of InitializePoolV2InstructionAccounts, in account order:

#FieldType
0whirlpools_configPubkey
1token_mint_aPubkey
2token_mint_bPubkey
3token_badge_aPubkey
4token_badge_bPubkey
5funderPubkey
6whirlpoolPubkey
7token_vault_aPubkey
8token_vault_bPubkey
9fee_tierPubkey
10token_program_aPubkey
11token_program_bPubkey
12system_programPubkey
13rentPubkey
14…remainingVec<AccountMeta>

InitializePoolWithAdaptiveFee#

From the program's IDL:

Initializes a Whirlpool account and Oracle account with adaptive fee.

Parameters

  • initial_sqrt_price - The desired initial sqrt-price for this pool
  • trade_enable_timestamp - The timestamp when trading is enabled for this pool (within 72 hours)

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 InvalidTradeEnableTimestamp - provided trade_enable_timestamp is not within 72 hours or the adaptive fee-tier is permission-less UnsupportedTokenMint - The provided token mint is not supported by the program (e.g. it has risky token extensions)

Discriminator 8f5e604cac7c77c7 · data InitializePoolWithAdaptiveFee · accounts InitializePoolWithAdaptiveFeeInstructionAccounts.

FieldType
initial_sqrt_priceu128
trade_enable_timestampOption<u64>

Required accounts: 16; extras go to remaining.

Fields of InitializePoolWithAdaptiveFeeInstructionAccounts, in account order:

#FieldType
0whirlpools_configPubkey
1token_mint_aPubkey
2token_mint_bPubkey
3token_badge_aPubkey
4token_badge_bPubkey
5funderPubkey
6initialize_pool_authorityPubkey
7whirlpoolPubkey
8oraclePubkey
9token_vault_aPubkey
10token_vault_bPubkey
11adaptive_fee_tierPubkey
12token_program_aPubkey
13token_program_bPubkey
14system_programPubkey
15rentPubkey
16…remainingVec<AccountMeta>

InitializePositionBundle#

From the program's IDL:

Initializes a PositionBundle account that bundles several positions.
A unique token will be minted to represent the position bundle in the users wallet.

Discriminator 752df1951812c241 · data InitializePositionBundle · accounts InitializePositionBundleInstructionAccounts.

No data fields.

Required accounts: 9; extras go to remaining.

Fields of InitializePositionBundleInstructionAccounts, in account order:

#FieldType
0position_bundlePubkey
1position_bundle_mintPubkey
2position_bundle_token_accountPubkey
3position_bundle_ownerPubkey
4funderPubkey
5token_programPubkey
6system_programPubkey
7rentPubkey
8associated_token_programPubkey
9…remainingVec<AccountMeta>

InitializePositionBundleWithMetadata#

From the program's IDL:

Initializes a PositionBundle account that bundles several positions.
A unique token will be minted to represent the position bundle in the users wallet. Additional Metaplex metadata is appended to identify the token.

Discriminator 5d7c10b3f98373f5 · data InitializePositionBundleWithMetadata · accounts InitializePositionBundleWithMetadataInstructionAccounts.

No data fields.

Required accounts: 12; extras go to remaining.

Fields of InitializePositionBundleWithMetadataInstructionAccounts, in account order:

#FieldType
0position_bundlePubkey
1position_bundle_mintPubkey
2position_bundle_metadataPubkey
3position_bundle_token_accountPubkey
4position_bundle_ownerPubkey
5funderPubkey
6metadata_update_authPubkey
7token_programPubkey
8system_programPubkey
9rentPubkey
10associated_token_programPubkey
11metadata_programPubkey
12…remainingVec<AccountMeta>

InitializeReward#

From the program's IDL:

Initialize reward for a Whirlpool. A pool can only support up to a set number of rewards. ### Authority

  • "reward_authority" - assigned authority by the reward_super_authority for the specified

reward-index in this Whirlpool

Parameters

  • reward_index - The reward index that we'd like to initialize. (0 <= index <= NUM_REWARDS)

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.

Discriminator 5f87c0c4f281e644 · data InitializeReward · accounts InitializeRewardInstructionAccounts.

FieldType
reward_indexu8

Required accounts: 8; extras go to remaining.

Fields of InitializeRewardInstructionAccounts, in account order:

#FieldType
0reward_authorityPubkey
1funderPubkey
2whirlpoolPubkey
3reward_mintPubkey
4reward_vaultPubkey
5token_programPubkey
6system_programPubkey
7rentPubkey
8…remainingVec<AccountMeta>

InitializeRewardV2#

From the program's IDL:

Initialize reward for a Whirlpool. A pool can only support up to a set number of rewards. This instruction works with both Token and Token-2022.

Authority

  • "reward_authority" - assigned authority by the reward_super_authority for the specified

reward-index in this Whirlpool

Parameters

  • reward_index - The reward index that we'd like to initialize. (0 <= index <= NUM_REWARDS)

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.

Discriminator 5b014d32ebe58531 · data InitializeRewardV2 · accounts InitializeRewardV2InstructionAccounts.

FieldType
reward_indexu8

Required accounts: 9; extras go to remaining.

Fields of InitializeRewardV2InstructionAccounts, in account order:

#FieldType
0reward_authorityPubkey
1funderPubkey
2whirlpoolPubkey
3reward_mintPubkey
4reward_token_badgePubkey
5reward_vaultPubkey
6reward_token_programPubkey
7system_programPubkey
8rentPubkey
9…remainingVec<AccountMeta>

InitializeTickArray#

From the program's IDL:

Initializes a fixed-length tick_array account to represent a tick-range in a
Whirlpool. ### Parameters

  • start_tick_index - The starting tick index for this tick-array.

Has to be a multiple of TickArray size & the tick spacing of this pool.

Special Errors

  • InvalidStartTick - if the provided start tick is out of bounds or is not a multiple of

TICK_ARRAY_SIZE * tick spacing.

Discriminator 0bbcc1d68d5b95b8 · data InitializeTickArray · accounts InitializeTickArrayInstructionAccounts.

FieldType
start_tick_indexi32

Required accounts: 4; extras go to remaining.

Fields of InitializeTickArrayInstructionAccounts, in account order:

#FieldType
0whirlpoolPubkey
1funderPubkey
2tick_arrayPubkey
3system_programPubkey
4…remainingVec<AccountMeta>

InitializeTokenBadge#

From the program's IDL:

Initialize a TokenBadge account.

Authority

  • "token_badge_authority" - Set authority in the WhirlpoolConfigExtension

Special Errors

  • FeatureIsNotEnabled - If the feature flag for token badges is not enabled.

Discriminator fd4dcd5f1be059df · data InitializeTokenBadge · accounts InitializeTokenBadgeInstructionAccounts.

No data fields.

Required accounts: 7; extras go to remaining.

Fields of InitializeTokenBadgeInstructionAccounts, in account order:

#FieldType
0whirlpools_configPubkey
1whirlpools_config_extensionPubkey
2token_badge_authorityPubkey
3token_mintPubkey
4token_badgePubkey
5funderPubkey
6system_programPubkey
7…remainingVec<AccountMeta>

LockPosition#

From the program's IDL:

Lock the position to prevent any liquidity changes.

Authority

  • position_authority - The authority that owns the position token.

Special Errors

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

Discriminator e33e02fcf70aabb9 · data LockPosition · accounts LockPositionInstructionAccounts.

FieldType
lock_typeLockType

Required accounts: 9; extras go to remaining.

Fields of LockPositionInstructionAccounts, in account order:

#FieldType
0funderPubkey
1position_authorityPubkey
2positionPubkey
3position_mintPubkey
4position_token_accountPubkey
5lock_configPubkey
6whirlpoolPubkey
7token2022_programPubkey
8system_programPubkey
9…remainingVec<AccountMeta>

MigrateRepurposeRewardAuthoritySpace#

From the program's IDL:

Migration instruction to repurpose the reward authority space in the
Whirlpool. TODO: This instruction should be removed once all pools have been migrated.

Discriminator d6a1f84f9862ace7 · data MigrateRepurposeRewardAuthoritySpace · accounts MigrateRepurposeRewardAuthoritySpaceInstructionAccounts.

No data fields.

Required accounts: 1; extras go to remaining.

Fields of MigrateRepurposeRewardAuthoritySpaceInstructionAccounts, in account order:

#FieldType
0whirlpoolPubkey
1…remainingVec<AccountMeta>

OpenBundledPosition#

From the program's IDL:

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.

Authority

  • position_bundle_authority - authority that owns the token corresponding to this desired position bundle.

Parameters

  • bundle_index - The bundle index that we'd like to open.
  • tick_lower_index - The tick specifying the lower end of the position range.
  • tick_upper_index - The tick specifying the upper end of the position range.

Special Errors

  • 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.

Discriminator a9717eabd5acd431 · data OpenBundledPosition · accounts OpenBundledPositionInstructionAccounts.

FieldType
bundle_indexu16
tick_lower_indexi32
tick_upper_indexi32

Required accounts: 8; extras go to remaining.

Fields of OpenBundledPositionInstructionAccounts, in account order:

#FieldType
0bundled_positionPubkey
1position_bundlePubkey
2position_bundle_token_accountPubkey
3position_bundle_authorityPubkey
4whirlpoolPubkey
5funderPubkey
6system_programPubkey
7rentPubkey
8…remainingVec<AccountMeta>

OpenPosition#

From the program's IDL:

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. ### Parameters

  • tick_lower_index - The tick specifying the lower end of the position range.
  • tick_upper_index - The tick specifying the upper end of the position range.

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.

Discriminator 87802f4d0f98f031 · data OpenPosition · accounts OpenPositionInstructionAccounts.

FieldType
bumpsOpenPositionBumps
tick_lower_indexi32
tick_upper_indexi32

Required accounts: 10; extras go to remaining.

Fields of OpenPositionInstructionAccounts, in account order:

#FieldType
0funderPubkey
1ownerPubkey
2positionPubkey
3position_mintPubkey
4position_token_accountPubkey
5whirlpoolPubkey
6token_programPubkey
7system_programPubkey
8rentPubkey
9associated_token_programPubkey
10…remainingVec<AccountMeta>

OpenPositionWithMetadata#

From the program's IDL:

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.

Parameters

  • tick_lower_index - The tick specifying the lower end of the position range.
  • tick_upper_index - The tick specifying the upper end of the position range.

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.

Discriminator f21d86303a6e0e3c · data OpenPositionWithMetadata · accounts OpenPositionWithMetadataInstructionAccounts.

FieldType
bumpsOpenPositionWithMetadataBumps
tick_lower_indexi32
tick_upper_indexi32

Required accounts: 13; extras go to remaining.

Fields of OpenPositionWithMetadataInstructionAccounts, in account order:

#FieldType
0funderPubkey
1ownerPubkey
2positionPubkey
3position_mintPubkey
4position_metadata_accountPubkey
5position_token_accountPubkey
6whirlpoolPubkey
7token_programPubkey
8system_programPubkey
9rentPubkey
10associated_token_programPubkey
11metadata_programPubkey
12metadata_update_authPubkey
13…remainingVec<AccountMeta>

OpenPositionWithTokenExtensions#

From the program's IDL:

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. Mint and TokenAccount are based on
Token-2022. The position will start off with 0 liquidity.

Parameters

  • tick_lower_index - The tick specifying the lower end of the position range.
  • tick_upper_index - The tick specifying the upper end of the position range.
  • with_token_metadata_extension - If true, the token metadata extension will be initialized.

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.

Discriminator d42f5f5c726683fa · data OpenPositionWithTokenExtensions · accounts OpenPositionWithTokenExtensionsInstructionAccounts.

FieldType
tick_lower_indexi32
tick_upper_indexi32
with_token_metadata_extensionbool

Required accounts: 10; extras go to remaining.

Fields of OpenPositionWithTokenExtensionsInstructionAccounts, in account order:

#FieldType
0funderPubkey
1ownerPubkey
2positionPubkey
3position_mintPubkey
4position_token_accountPubkey
5whirlpoolPubkey
6token2022_programPubkey
7system_programPubkey
8associated_token_programPubkey
9metadata_update_authPubkey
10…remainingVec<AccountMeta>

RepositionLiquidityV2#

From the program's IDL:

An atomic instruction that repositions liquidity for a position through the following steps:

  • Withdraws liquidity from the current position range
  • Resets the position to a new tick range
  • Adds liquidity to the new position range
  • Restores fees and rewards

This instruction works with both Token and Token-2022.

Authority

  • position_authority - authority that owns the token corresponding to this desired position.

Parameters

  • new_tick_lower_index - The new tick index for the lower end of the position range.
  • new_tick_upper_index - The new tick index for the upper end of the position range.
  • new_liquidity_amount - The total amount of Liquidity the user is willing to deposit.
  • existing_range_token_min_a - The minimum amount of tokenA the user is willing to withdraw from the existing range.
  • existing_range_token_min_b - The minimum amount of tokenB the user is willing to withdraw from the existing range.
  • new_range_token_max_a - The maximum amount of tokenA the user is willing to deposit into the new range.
  • new_range_token_max_b - The maximum amount of tokenB the user is willing to deposit into the new range.

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.
  • TokenMinSubceeded - The required token to perform this operation subceeds the user defined amount.
  • InvalidTickIndex - If a provided tick is out of bounds, out of order or not a multiple of

the tick-spacing in this pool.

  • SameTickRangeNotAllowed - The provided tick range is the same as the current tick range.

Discriminator bfa9e00b83139efd · data RepositionLiquidityV2 · accounts RepositionLiquidityV2InstructionAccounts.

FieldType
new_tick_lower_indexi32
new_tick_upper_indexi32
methodRepositionLiquidityMethod
remaining_accounts_infoOption<RemainingAccountsInfo>

Required accounts: 19; extras go to remaining.

Fields of RepositionLiquidityV2InstructionAccounts, in account order:

#FieldType
0whirlpoolPubkey
1token_program_aPubkey
2token_program_bPubkey
3memo_programPubkey
4position_authorityPubkey
5funderPubkey
6positionPubkey
7position_token_accountPubkey
8token_mint_aPubkey
9token_mint_bPubkey
10token_owner_account_aPubkey
11token_owner_account_bPubkey
12token_vault_aPubkey
13token_vault_bPubkey
14existing_tick_array_lowerPubkey
15existing_tick_array_upperPubkey
16new_tick_array_lowerPubkey
17new_tick_array_upperPubkey
18system_programPubkey
19…remainingVec<AccountMeta>

ResetPositionRange#

From the program's IDL:

Reset the position range to a new range.

Authority

  • position_authority - The authority that owns the position token.

Parameters

  • new_tick_lower_index - The new tick specifying the lower end of the position range.
  • new_tick_upper_index - The new tick specifying the upper end of the position range.

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.

  • ClosePositionNotEmpty - The provided position account is not empty.
  • SameTickRangeNotAllowed - The provided tick range is the same as the current tick range.

Discriminator a47bb48dc264a0af · data ResetPositionRange · accounts ResetPositionRangeInstructionAccounts.

FieldType
new_tick_lower_indexi32
new_tick_upper_indexi32

Required accounts: 6; extras go to remaining.

Fields of ResetPositionRangeInstructionAccounts, in account order:

#FieldType
0funderPubkey
1position_authorityPubkey
2whirlpoolPubkey
3positionPubkey
4position_token_accountPubkey
5system_programPubkey
6…remainingVec<AccountMeta>

SetAdaptiveFeeConstants#

From the program's IDL:

Sets specific adaptive fee constants for a pool. Only the provided constants will be updated, others remain unchanged. Caller should avoid invoking this instruction when a pool's adaptive fee is high to prevent LP revenue loss

Authority

  • fee_authority - Set authority in the WhirlpoolsConfig

Parameters

All parameters are optional. Only provided values will be updated.

  • filter_period - Period determine high frequency trading time window.
    (seconds)
  • decay_period - Period determine when the adaptive fee start decrease.
    (seconds)
  • reduction_factor - Adaptive fee rate decrement rate.
  • adaptive_fee_control_factor - Adaptive fee control factor.
  • max_volatility_accumulator - Max volatility accumulator.
  • tick_group_size - Tick group size to define tick group index.
  • major_swap_threshold_ticks - Major swap threshold ticks to define major swap.

Special Errors

  • InvalidAdaptiveFeeConstants - If the resulting constants are invalid for the pool's tick_spacing.
  • AdaptiveFeeConstantsUnchanged - If the provided adaptive fee constants are unchanged from the existing constants.

Discriminator 859ed4bded0c4927 · data SetAdaptiveFeeConstants · accounts SetAdaptiveFeeConstantsInstructionAccounts.

FieldType
filter_periodOption<u16>
decay_periodOption<u16>
reduction_factorOption<u16>
adaptive_fee_control_factorOption<u32>
max_volatility_accumulatorOption<u32>
tick_group_sizeOption<u16>
major_swap_threshold_ticksOption<u16>

Required accounts: 4; extras go to remaining.

Fields of SetAdaptiveFeeConstantsInstructionAccounts, in account order:

#FieldType
0whirlpoolPubkey
1whirlpools_configPubkey
2oraclePubkey
3fee_authorityPubkey
4…remainingVec<AccountMeta>

SetCollectProtocolFeesAuthority#

From the program's IDL:

Sets the fee authority to collect protocol fees for a WhirlpoolConfig.
Only the current collect protocol fee authority has permission to invoke this instruction. ### Authority

  • "fee_authority" - Set authority that can collect protocol fees in the
    WhirlpoolConfig

Discriminator 22965df48be1e943 · data SetCollectProtocolFeesAuthority · accounts SetCollectProtocolFeesAuthorityInstructionAccounts.

No data fields.

Required accounts: 3; extras go to remaining.

Fields of SetCollectProtocolFeesAuthorityInstructionAccounts, in account order:

#FieldType
0whirlpools_configPubkey
1collect_protocol_fees_authorityPubkey
2new_collect_protocol_fees_authorityPubkey
3…remainingVec<AccountMeta>

SetConfigExtensionAuthority#

From the program's IDL:

Sets the config extension authority for a WhirlpoolsConfigExtension.
Only the current config extension authority has permission to invoke this instruction. ### Authority

  • "config_extension_authority" - Set authority in the
    WhirlpoolConfigExtension

Discriminator 2c5ef17418bc3c8f · data SetConfigExtensionAuthority · accounts SetConfigExtensionAuthorityInstructionAccounts.

No data fields.

Required accounts: 4; extras go to remaining.

Fields of SetConfigExtensionAuthorityInstructionAccounts, in account order:

#FieldType
0whirlpools_configPubkey
1whirlpools_config_extensionPubkey
2config_extension_authorityPubkey
3new_config_extension_authorityPubkey
4…remainingVec<AccountMeta>

SetConfigFeatureFlag#

From the program's IDL:

Sets the feature flag for a WhirlpoolConfig.

Authority

  • "authority" - Set authority that is one of ADMINS.

Parameters

  • feature_flag - The feature flag that the WhirlpoolConfig will use.

Discriminator 47ade41243f7d239 · data SetConfigFeatureFlag · accounts SetConfigFeatureFlagInstructionAccounts.

FieldType
feature_flagConfigFeatureFlag

Required accounts: 2; extras go to remaining.

Fields of SetConfigFeatureFlagInstructionAccounts, in account order:

#FieldType
0whirlpools_configPubkey
1authorityPubkey
2…remainingVec<AccountMeta>

SetDefaultBaseFeeRate#

From the program's IDL:

Set the default_base_fee_rate for an AdaptiveFeeTier
Only the current fee authority in WhirlpoolsConfig has permission to invoke this instruction. ### Authority

  • "fee_authority" - Set authority in the WhirlpoolConfig

Parameters

  • default_base_fee_rate - The default base fee rate that a pool will use if the pool uses this

adaptive fee-tier during initialization.

Special Errors

  • FeeRateMaxExceeded - If the provided default_fee_rate exceeds MAX_FEE_RATE.

Discriminator e54254fba486b707 · data SetDefaultBaseFeeRate · accounts SetDefaultBaseFeeRateInstructionAccounts.

FieldType
default_base_fee_rateu16

Required accounts: 3; extras go to remaining.

Fields of SetDefaultBaseFeeRateInstructionAccounts, in account order:

#FieldType
0whirlpools_configPubkey
1adaptive_fee_tierPubkey
2fee_authorityPubkey
3…remainingVec<AccountMeta>

SetDefaultFeeRate#

From the program's IDL:

Set the default_fee_rate for a FeeTier
Only the current fee authority has permission to invoke this instruction.

Authority

  • "fee_authority" - Set authority in the WhirlpoolConfig

Parameters

  • default_fee_rate - The default fee rate that a pool will use if the pool uses this

fee tier during initialization.

Special Errors

  • FeeRateMaxExceeded - If the provided default_fee_rate exceeds MAX_FEE_RATE.

Discriminator 76d7d69db6e5d0e4 · data SetDefaultFeeRate · accounts SetDefaultFeeRateInstructionAccounts.

FieldType
default_fee_rateu16

Required accounts: 3; extras go to remaining.

Fields of SetDefaultFeeRateInstructionAccounts, in account order:

#FieldType
0whirlpools_configPubkey
1fee_tierPubkey
2fee_authorityPubkey
3…remainingVec<AccountMeta>

SetDefaultProtocolFeeRate#

From the program's IDL:

Sets the default protocol fee rate for a WhirlpoolConfig
Protocol fee rate is represented as a basis point.
Only the current fee authority has permission to invoke this instruction.

Authority

  • "fee_authority" - Set authority that can modify pool fees in the WhirlpoolConfig

Parameters

  • default_protocol_fee_rate - Rate that is referenced during the initialization of a Whirlpool using this config.

Special Errors

  • ProtocolFeeRateMaxExceeded - If the provided default_protocol_fee_rate exceeds MAX_PROTOCOL_FEE_RATE.

Discriminator 6bcdf9e297235600 · data SetDefaultProtocolFeeRate · accounts SetDefaultProtocolFeeRateInstructionAccounts.

FieldType
default_protocol_fee_rateu16

Required accounts: 2; extras go to remaining.

Fields of SetDefaultProtocolFeeRateInstructionAccounts, in account order:

#FieldType
0whirlpools_configPubkey
1fee_authorityPubkey
2…remainingVec<AccountMeta>

SetDelegatedFeeAuthority#

From the program's IDL:

Sets the delegated fee authority for an AdaptiveFeeTier.
The delegated fee authority can set the fee rate for individual pools initialized with the adaptive fee-tier. Only the current fee authority in
WhirlpoolsConfig has permission to invoke this instruction. ### Authority

  • "fee_authority" - Set authority in the WhirlpoolConfig

Discriminator c1eae7938a39037a · data SetDelegatedFeeAuthority · accounts SetDelegatedFeeAuthorityInstructionAccounts.

No data fields.

Required accounts: 4; extras go to remaining.

Fields of SetDelegatedFeeAuthorityInstructionAccounts, in account order:

#FieldType
0whirlpools_configPubkey
1adaptive_fee_tierPubkey
2fee_authorityPubkey
3new_delegated_fee_authorityPubkey
4…remainingVec<AccountMeta>

SetFeeAuthority#

From the program's IDL:

Sets the fee authority for a WhirlpoolConfig.
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.

Authority

  • "fee_authority" - Set authority that can modify pool fees in the WhirlpoolConfig

Discriminator 1f013257ed656184 · data SetFeeAuthority · accounts SetFeeAuthorityInstructionAccounts.

No data fields.

Required accounts: 3; extras go to remaining.

Fields of SetFeeAuthorityInstructionAccounts, in account order:

#FieldType
0whirlpools_configPubkey
1fee_authorityPubkey
2new_fee_authorityPubkey
3…remainingVec<AccountMeta>

SetFeeRate#

From the program's IDL:

Sets the fee rate for a Whirlpool.
Fee rate is represented as hundredths of a basis point.
Only the current fee authority has permission to invoke this instruction.

Authority

  • "fee_authority" - Set authority that can modify pool fees in the WhirlpoolConfig

Parameters

  • fee_rate - The rate that the pool will use to calculate fees going onwards.

Special Errors

  • FeeRateMaxExceeded - If the provided fee_rate exceeds MAX_FEE_RATE.

Discriminator 35f38941088c9e06 · data SetFeeRate · accounts SetFeeRateInstructionAccounts.

FieldType
fee_rateu16

Required accounts: 3; extras go to remaining.

Fields of SetFeeRateInstructionAccounts, in account order:

#FieldType
0whirlpools_configPubkey
1whirlpoolPubkey
2fee_authorityPubkey
3…remainingVec<AccountMeta>

SetFeeRateByDelegatedFeeAuthority#

From the program's IDL:

Sets the fee rate for a Whirlpool by the delegated fee authority in
AdaptiveFeeTier. Fee rate is represented as hundredths of a basis point.

Authority

  • "delegated_fee_authority" - Set authority that can modify pool fees in the AdaptiveFeeTier

Parameters

  • fee_rate - The rate that the pool will use to calculate fees going onwards.

Special Errors

  • FeeRateMaxExceeded - If the provided fee_rate exceeds MAX_FEE_RATE.

Discriminator 7979367283e6a268 · data SetFeeRateByDelegatedFeeAuthority · accounts SetFeeRateByDelegatedFeeAuthorityInstructionAccounts.

FieldType
fee_rateu16

Required accounts: 3; extras go to remaining.

Fields of SetFeeRateByDelegatedFeeAuthorityInstructionAccounts, in account order:

#FieldType
0whirlpoolPubkey
1adaptive_fee_tierPubkey
2delegated_fee_authorityPubkey
3…remainingVec<AccountMeta>

SetInitializePoolAuthority#

From the program's IDL:

Sets the initialize pool authority for an AdaptiveFeeTier.
Only the initialize pool authority can initialize pools with the adaptive fee-tier. Only the current fee authority in WhirlpoolsConfig has permission to invoke this instruction. ### Authority

  • "fee_authority" - Set authority in the WhirlpoolConfig

Discriminator 7d2b7feb951a6aec · data SetInitializePoolAuthority · accounts SetInitializePoolAuthorityInstructionAccounts.

No data fields.

Required accounts: 4; extras go to remaining.

Fields of SetInitializePoolAuthorityInstructionAccounts, in account order:

#FieldType
0whirlpools_configPubkey
1adaptive_fee_tierPubkey
2fee_authorityPubkey
3new_initialize_pool_authorityPubkey
4…remainingVec<AccountMeta>

SetPresetAdaptiveFeeConstants#

From the program's IDL:

Sets the adaptive fee constants for an AdaptiveFeeTier.
Only the current fee authority in WhirlpoolsConfig has permission to invoke this instruction. ### Authority

  • "fee_authority" - Set authority in the WhirlpoolConfig

Parameters

  • filter_period - Period determine high frequency trading time window. (seconds)
  • decay_period - Period determine when the adaptive fee start decrease.
    (seconds)
  • reduction_factor - Adaptive fee rate decrement rate.
  • adaptive_fee_control_factor - Adaptive fee control factor.
  • max_volatility_accumulator - Max volatility accumulator.
  • tick_group_size - Tick group size to define tick group index.
  • major_swap_threshold_ticks - Major swap threshold ticks to define major swap.

Discriminator 84b94294535886c6 · data SetPresetAdaptiveFeeConstants · accounts SetPresetAdaptiveFeeConstantsInstructionAccounts.

FieldType
filter_periodu16
decay_periodu16
reduction_factoru16
adaptive_fee_control_factoru32
max_volatility_accumulatoru32
tick_group_sizeu16
major_swap_threshold_ticksu16

Required accounts: 3; extras go to remaining.

Fields of SetPresetAdaptiveFeeConstantsInstructionAccounts, in account order:

#FieldType
0whirlpools_configPubkey
1adaptive_fee_tierPubkey
2fee_authorityPubkey
3…remainingVec<AccountMeta>

SetProtocolFeeRate#

From the program's IDL:

Sets the protocol fee rate for a Whirlpool.
Protocol fee rate is represented as a basis point.
Only the current fee authority has permission to invoke this instruction.

Authority

  • "fee_authority" - Set authority that can modify pool fees in the WhirlpoolConfig

Parameters

  • protocol_fee_rate - The rate that the pool will use to calculate protocol fees going onwards.

Special Errors

  • ProtocolFeeRateMaxExceeded - If the provided default_protocol_fee_rate exceeds MAX_PROTOCOL_FEE_RATE.

Discriminator 5f0704329a4f9c83 · data SetProtocolFeeRate · accounts SetProtocolFeeRateInstructionAccounts.

FieldType
protocol_fee_rateu16

Required accounts: 3; extras go to remaining.

Fields of SetProtocolFeeRateInstructionAccounts, in account order:

#FieldType
0whirlpools_configPubkey
1whirlpoolPubkey
2fee_authorityPubkey
3…remainingVec<AccountMeta>

SetRewardAuthority#

From the program's IDL:

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. ### Authority

  • "reward_authority" - Set authority that can control reward emission for this particular reward.

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.

Discriminator 2227b7fc531c557f · data SetRewardAuthority · accounts SetRewardAuthorityInstructionAccounts.

FieldType
reward_indexu8

Required accounts: 3; extras go to remaining.

Fields of SetRewardAuthorityInstructionAccounts, in account order:

#FieldType
0whirlpoolPubkey
1reward_authorityPubkey
2new_reward_authorityPubkey
3…remainingVec<AccountMeta>

SetRewardAuthorityBySuperAuthority#

From the program's IDL:

Set the whirlpool reward authority at the provided reward_index.
Only the current reward super authority has permission to invoke this instruction. ### Authority

  • "reward_authority" - Set authority that can control reward emission for this particular reward.

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.

Discriminator f09ac9c6945d3819 · data SetRewardAuthorityBySuperAuthority · accounts SetRewardAuthorityBySuperAuthorityInstructionAccounts.

FieldType
reward_indexu8

Required accounts: 4; extras go to remaining.

Fields of SetRewardAuthorityBySuperAuthorityInstructionAccounts, in account order:

#FieldType
0whirlpools_configPubkey
1whirlpoolPubkey
2reward_emissions_super_authorityPubkey
3new_reward_authorityPubkey
4…remainingVec<AccountMeta>

SetRewardEmissions#

From the program's IDL:

Set the reward emissions for a reward in a Whirlpool.

Authority

  • "reward_authority" - assigned authority by the reward_super_authority for the specified

reward-index in this Whirlpool

Parameters

  • reward_index - The reward index (0 <= index <= NUM_REWARDS) that we'd like to modify.
  • emissions_per_second_x64 - The amount of rewards emitted in this pool.

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, or all reward slots for this pool has been initialized.

Discriminator 0dc556a86db01bf4 · data SetRewardEmissions · accounts SetRewardEmissionsInstructionAccounts.

FieldType
reward_indexu8
emissions_per_second_x64u128

Required accounts: 3; extras go to remaining.

Fields of SetRewardEmissionsInstructionAccounts, in account order:

#FieldType
0whirlpoolPubkey
1reward_authorityPubkey
2reward_vaultPubkey
3…remainingVec<AccountMeta>

SetRewardEmissionsSuperAuthority#

From the program's IDL:

Set the whirlpool reward super authority for a WhirlpoolConfig
Only the current reward super authority has permission to invoke this instruction. This instruction will not change the authority on any WhirlpoolRewardInfo whirlpool rewards. ### Authority

  • "reward_emissions_super_authority" - Set authority that can control reward authorities for all pools in this config space.

Discriminator cf05c8d17a3852b7 · data SetRewardEmissionsSuperAuthority · accounts SetRewardEmissionsSuperAuthorityInstructionAccounts.

No data fields.

Required accounts: 3; extras go to remaining.

Fields of SetRewardEmissionsSuperAuthorityInstructionAccounts, in account order:

#FieldType
0whirlpools_configPubkey
1reward_emissions_super_authorityPubkey
2new_reward_emissions_super_authorityPubkey
3…remainingVec<AccountMeta>

SetRewardEmissionsV2#

From the program's IDL:

Set the reward emissions for a reward in a Whirlpool.
This instruction works with both Token and Token-2022.

Authority

  • "reward_authority" - assigned authority by the reward_super_authority for the specified

reward-index in this Whirlpool

Parameters

  • reward_index - The reward index (0 <= index <= NUM_REWARDS) that we'd like to modify.
  • emissions_per_second_x64 - The amount of rewards emitted in this pool.

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, or all reward slots for this pool has been initialized.

Discriminator 72e44820c130a066 · data SetRewardEmissionsV2 · accounts SetRewardEmissionsV2InstructionAccounts.

FieldType
reward_indexu8
emissions_per_second_x64u128

Required accounts: 3; extras go to remaining.

Fields of SetRewardEmissionsV2InstructionAccounts, in account order:

#FieldType
0whirlpoolPubkey
1reward_authorityPubkey
2reward_vaultPubkey
3…remainingVec<AccountMeta>

SetTokenBadgeAttribute#

From the program's IDL:

Set an attribute on a TokenBadge account.

Authority

  • "token_badge_authority" - Set authority in the WhirlpoolConfigExtension

Parameters

  • attribute - The attribute to set on the TokenBadge account.

Special Errors

  • FeatureIsNotEnabled - If the feature flag for token badges is not enabled.

Discriminator e05841218a93f689 · data SetTokenBadgeAttribute · accounts SetTokenBadgeAttributeInstructionAccounts.

FieldType
attributeTokenBadgeAttribute

Required accounts: 5; extras go to remaining.

Fields of SetTokenBadgeAttributeInstructionAccounts, in account order:

#FieldType
0whirlpools_configPubkey
1whirlpools_config_extensionPubkey
2token_badge_authorityPubkey
3token_mintPubkey
4token_badgePubkey
5…remainingVec<AccountMeta>

SetTokenBadgeAuthority#

From the program's IDL:

Sets the token badge authority for a WhirlpoolsConfigExtension.
Only the config extension authority has permission to invoke this instruction. ### Authority

  • "config_extension_authority" - Set authority in the
    WhirlpoolConfigExtension

Discriminator cfca0420cd4f0db2 · data SetTokenBadgeAuthority · accounts SetTokenBadgeAuthorityInstructionAccounts.

No data fields.

Required accounts: 4; extras go to remaining.

Fields of SetTokenBadgeAuthorityInstructionAccounts, in account order:

#FieldType
0whirlpools_configPubkey
1whirlpools_config_extensionPubkey
2config_extension_authorityPubkey
3new_token_badge_authorityPubkey
4…remainingVec<AccountMeta>

Swap#

From the program's IDL:

Perform a swap in this Whirlpool

Authority

  • "token_authority" - The authority to withdraw tokens from the input token account.

Parameters

  • amount - The amount of input or output token to swap from (depending on amount_specified_is_input).
  • other_amount_threshold - The maximum/minimum of input/output token to swap into (depending on amount_specified_is_input).
  • sqrt_price_limit - The maximum/minimum price the swap will swap to.
  • amount_specified_is_input - Specifies the token the parameter amountrepresents. If true, the amount represents the input token of the swap.
  • a_to_b - The direction of the swap. True if swapping from A to B. False if swapping from B to A.

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.

Discriminator f8c69e91e17587c8 · data Swap · accounts SwapInstructionAccounts.

FieldType
amountu64
other_amount_thresholdu64
sqrt_price_limitu128
amount_specified_is_inputbool
a_to_bbool

Required accounts: 11; extras go to remaining.

Fields of SwapInstructionAccounts, in account order:

#FieldType
0token_programPubkey
1token_authorityPubkey
2whirlpoolPubkey
3token_owner_account_aPubkey
4token_vault_aPubkey
5token_owner_account_bPubkey
6token_vault_bPubkey
7tick_array0Pubkey
8tick_array1Pubkey
9tick_array2Pubkey
10oraclePubkey
11…remainingVec<AccountMeta>

SwapV2#

From the program's IDL:

Perform a swap in this Whirlpool
This instruction works with both Token and Token-2022.

Authority

  • "token_authority" - The authority to withdraw tokens from the input token account.

Parameters

  • amount - The amount of input or output token to swap from (depending on amount_specified_is_input).
  • other_amount_threshold - The maximum/minimum of input/output token to swap into (depending on amount_specified_is_input).
  • sqrt_price_limit - The maximum/minimum price the swap will swap to.
  • amount_specified_is_input - Specifies the token the parameter amountrepresents. If true, the amount represents the input token of the swap.
  • a_to_b - The direction of the swap. True if swapping from A to B. False if swapping from B to A.

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.

Discriminator 2b04ed0b1ac91e62 · data SwapV2 · accounts SwapV2InstructionAccounts.

FieldType
amountu64
other_amount_thresholdu64
sqrt_price_limitu128
amount_specified_is_inputbool
a_to_bbool
remaining_accounts_infoOption<RemainingAccountsInfo>

Required accounts: 15; extras go to remaining.

Fields of SwapV2InstructionAccounts, in account order:

#FieldType
0token_program_aPubkey
1token_program_bPubkey
2memo_programPubkey
3token_authorityPubkey
4whirlpoolPubkey
5token_mint_aPubkey
6token_mint_bPubkey
7token_owner_account_aPubkey
8token_vault_aPubkey
9token_owner_account_bPubkey
10token_vault_bPubkey
11tick_array0Pubkey
12tick_array1Pubkey
13tick_array2Pubkey
14oraclePubkey
15…remainingVec<AccountMeta>

TransferLockedPosition#

From the program's IDL:

Transfer a locked position to a different token account.

Authority

  • position_authority - The authority that owns the position token.

Discriminator b379e52e438ac28a · data TransferLockedPosition · accounts TransferLockedPositionInstructionAccounts.

No data fields.

Required accounts: 8; extras go to remaining.

Fields of TransferLockedPositionInstructionAccounts, in account order:

#FieldType
0position_authorityPubkey
1receiverPubkey
2positionPubkey
3position_mintPubkey
4position_token_accountPubkey
5destination_token_accountPubkey
6lock_configPubkey
7token2022_programPubkey
8…remainingVec<AccountMeta>

TwoHopSwap#

From the program's IDL:

Perform a two-hop swap in this Whirlpool

Authority

  • "token_authority" - The authority to withdraw tokens from the input token account.

Parameters

  • amount - The amount of input or output token to swap from (depending on amount_specified_is_input).
  • other_amount_threshold - The maximum/minimum of input/output token to swap into (depending on amount_specified_is_input).
  • amount_specified_is_input - Specifies the token the parameter amountrepresents. If true, the amount represents the input token of the swap.
  • a_to_b_one - The direction of the swap of hop one. True if swapping from
    A to B. False if swapping from B to A.
  • a_to_b_two - The direction of the swap of hop two. True if swapping from
    A to B. False if swapping from B to A.
  • sqrt_price_limit_one - The maximum/minimum price the swap will swap to in the first hop.
  • sqrt_price_limit_two - The maximum/minimum price the swap will swap to in the second hop.

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.
  • InvalidIntermediaryMint - Error if the intermediary mint between hop one and two do not equal.
  • DuplicateTwoHopPool - Error if whirlpool one & two are the same pool.

Discriminator c360ed6c44a2dbe6 · data TwoHopSwap · accounts TwoHopSwapInstructionAccounts.

FieldType
amountu64
other_amount_thresholdu64
amount_specified_is_inputbool
a_to_b_onebool
a_to_b_twobool
sqrt_price_limit_oneu128
sqrt_price_limit_twou128

Required accounts: 20; extras go to remaining.

Fields of TwoHopSwapInstructionAccounts, in account order:

#FieldType
0token_programPubkey
1token_authorityPubkey
2whirlpool_onePubkey
3whirlpool_twoPubkey
4token_owner_account_one_aPubkey
5token_vault_one_aPubkey
6token_owner_account_one_bPubkey
7token_vault_one_bPubkey
8token_owner_account_two_aPubkey
9token_vault_two_aPubkey
10token_owner_account_two_bPubkey
11token_vault_two_bPubkey
12tick_array_one0Pubkey
13tick_array_one1Pubkey
14tick_array_one2Pubkey
15tick_array_two0Pubkey
16tick_array_two1Pubkey
17tick_array_two2Pubkey
18oracle_onePubkey
19oracle_twoPubkey
20…remainingVec<AccountMeta>

TwoHopSwapV2#

From the program's IDL:

Perform a two-hop swap in this Whirlpool
This instruction works with both Token and Token-2022.

Authority

  • "token_authority" - The authority to withdraw tokens from the input token account.

Parameters

  • amount - The amount of input or output token to swap from (depending on amount_specified_is_input).
  • other_amount_threshold - The maximum/minimum of input/output token to swap into (depending on amount_specified_is_input).
  • amount_specified_is_input - Specifies the token the parameter amountrepresents. If true, the amount represents the input token of the swap.
  • a_to_b_one - The direction of the swap of hop one. True if swapping from
    A to B. False if swapping from B to A.
  • a_to_b_two - The direction of the swap of hop two. True if swapping from
    A to B. False if swapping from B to A.
  • sqrt_price_limit_one - The maximum/minimum price the swap will swap to in the first hop.
  • sqrt_price_limit_two - The maximum/minimum price the swap will swap to in the second hop.

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.
  • InvalidIntermediaryMint - Error if the intermediary mint between hop one and two do not equal.
  • DuplicateTwoHopPool - Error if whirlpool one & two are the same pool.

Discriminator ba8fd11dfe02c275 · data TwoHopSwapV2 · accounts TwoHopSwapV2InstructionAccounts.

FieldType
amountu64
other_amount_thresholdu64
amount_specified_is_inputbool
a_to_b_onebool
a_to_b_twobool
sqrt_price_limit_oneu128
sqrt_price_limit_twou128
remaining_accounts_infoOption<RemainingAccountsInfo>

Required accounts: 24; extras go to remaining.

Fields of TwoHopSwapV2InstructionAccounts, in account order:

#FieldType
0whirlpool_onePubkey
1whirlpool_twoPubkey
2token_mint_inputPubkey
3token_mint_intermediatePubkey
4token_mint_outputPubkey
5token_program_inputPubkey
6token_program_intermediatePubkey
7token_program_outputPubkey
8token_owner_account_inputPubkey
9token_vault_one_inputPubkey
10token_vault_one_intermediatePubkey
11token_vault_two_intermediatePubkey
12token_vault_two_outputPubkey
13token_owner_account_outputPubkey
14token_authorityPubkey
15tick_array_one0Pubkey
16tick_array_one1Pubkey
17tick_array_one2Pubkey
18tick_array_two0Pubkey
19tick_array_two1Pubkey
20tick_array_two2Pubkey
21oracle_onePubkey
22oracle_twoPubkey
23memo_programPubkey
24…remainingVec<AccountMeta>

UpdateFeesAndRewards#

From the program's IDL:

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.

Discriminator 9ae6fa0decd14bdf · data UpdateFeesAndRewards · accounts UpdateFeesAndRewardsInstructionAccounts.

No data fields.

Required accounts: 4; extras go to remaining.

Fields of UpdateFeesAndRewardsInstructionAccounts, in account order:

#FieldType
0whirlpoolPubkey
1positionPubkey
2tick_array_lowerPubkey
3tick_array_upperPubkey
4…remainingVec<AccountMeta>

CpiEvent#

Anchor self-CPI that carries one of the program's events. data is the CpiEvent enum.

Discriminator e445a52e51cb9a1d · data CpiEvent · accounts CpiEventInstructionAccounts.

Required accounts: 2; extras go to remaining.

Fields of CpiEventInstructionAccounts, in account order:

#FieldType
0programPubkey
1event_authorityPubkey
2…remainingVec<AccountMeta>

Accounts#

Variants of OrcaWhirlpoolAccount. Each wraps a boxed struct from carbon_orca_whirlpool_decoder::accounts::<module>. decode_account only considers accounts owned by PROGRAM_ID and returns the first variant that matches.

AdaptiveFeeTier#

Discriminator 931090742f92952e · accounts::adaptive_fee_tier::AdaptiveFeeTier.

FieldType
whirlpools_configPubkey
fee_tier_indexu16
tick_spacingu16
initialize_pool_authorityPubkey
delegated_fee_authorityPubkey
default_base_fee_rateu16
filter_periodu16
decay_periodu16
reduction_factoru16
adaptive_fee_control_factoru32
max_volatility_accumulatoru32
tick_group_sizeu16
major_swap_threshold_ticksu16

DynamicTickArray#

Discriminator 11d8f68ee1c7da38 · accounts::dynamic_tick_array::DynamicTickArray.

FieldType
start_tick_indexi32
whirlpoolPubkey
tick_bitmapu128
ticks[DynamicTick; 88]

FeeTier#

Discriminator 384b9f4c8e44be69 · accounts::fee_tier::FeeTier.

FieldType
whirlpools_configPubkey
tick_spacingu16
default_fee_rateu16

LockConfig#

Discriminator 6a2fee9f7c0ca0c0 · accounts::lock_config::LockConfig.

FieldType
positionPubkey
position_ownerPubkey
whirlpoolPubkey
locked_timestampu64
lock_typeLockTypeLabel

Oracle#

Discriminator 8bc283b38cb3e5f4 · accounts::oracle::Oracle.

FieldType
whirlpoolPubkey
trade_enable_timestampu64
adaptive_fee_constantsAdaptiveFeeConstants
adaptive_fee_variablesAdaptiveFeeVariables
reserved[u8; 128]

Position#

Discriminator aabc8fe47a40f7d0 · accounts::position::Position.

FieldType
whirlpoolPubkey
position_mintPubkey
liquidityu128
tick_lower_indexi32
tick_upper_indexi32
fee_growth_checkpoint_au128
fee_owed_au64
fee_growth_checkpoint_bu128
fee_owed_bu64
reward_infos[PositionRewardInfo; 3]

PositionBundle#

Discriminator 81a9af41b95f2064 · accounts::position_bundle::PositionBundle.

FieldType
position_bundle_mintPubkey
position_bitmap[u8; 32]

TickArray#

Discriminator 4561bdbe6e0742bb · accounts::tick_array::TickArray.

FieldType
start_tick_indexi32
ticks[Tick; 88]
whirlpoolPubkey

TokenBadge#

Discriminator 74dbcce5f974ff96 · accounts::token_badge::TokenBadge.

FieldType
whirlpools_configPubkey
token_mintPubkey
attribute_require_non_transferable_positionbool

Whirlpool#

Discriminator 3f95d10ce1806309 · accounts::whirlpool::Whirlpool.

FieldType
whirlpools_configPubkey
whirlpool_bump[u8; 1]
tick_spacingu16
fee_tier_index_seed[u8; 2]
fee_rateu16
protocol_fee_rateu16
liquidityu128
sqrt_priceu128
tick_current_indexi32
protocol_fee_owed_au64
protocol_fee_owed_bu64
token_mint_aPubkey
token_vault_aPubkey
fee_growth_global_au128
token_mint_bPubkey
token_vault_bPubkey
fee_growth_global_bu128
reward_last_updated_timestampu64
reward_infos[WhirlpoolRewardInfo; 3]

WhirlpoolsConfig#

Discriminator 9d1431e0d957c1fe · accounts::whirlpools_config::WhirlpoolsConfig.

FieldType
fee_authorityPubkey
collect_protocol_fees_authorityPubkey
reward_emissions_super_authorityPubkey
default_protocol_fee_rateu16
feature_flagsu16

WhirlpoolsConfigExtension#

Discriminator 0263d7a3f01a993a · accounts::whirlpools_config_extension::WhirlpoolsConfigExtension.

FieldType
whirlpools_configPubkey
config_extension_authorityPubkey
token_badge_authorityPubkey

Events#

Variants of instructions::CpiEvent, decoded from the CpiEvent instruction. Each wraps a struct from carbon_orca_whirlpool_decoder::events::<module>. The discriminator is the 8-byte event discriminator that follows the e445a52e51cb9a1d CPI-event tag.

LiquidityDecreased#

Discriminator a601244770cab5ab · events::liquidity_decreased::LiquidityDecreasedEvent.

FieldType
whirlpoolPubkey
positionPubkey
tick_lower_indexi32
tick_upper_indexi32
liquidityu128
token_a_amountu64
token_b_amountu64
token_a_transfer_feeu64
token_b_transfer_feeu64

LiquidityIncreased#

Discriminator 1e0790b566fe9ba1 · events::liquidity_increased::LiquidityIncreasedEvent.

FieldType
whirlpoolPubkey
positionPubkey
tick_lower_indexi32
tick_upper_indexi32
liquidityu128
token_a_amountu64
token_b_amountu64
token_a_transfer_feeu64
token_b_transfer_feeu64

LiquidityRepositioned#

Discriminator 5f82b584fb32c326 · events::liquidity_repositioned::LiquidityRepositionedEvent.

FieldType
whirlpoolPubkey
positionPubkey
existing_range_tick_lower_indexi32
existing_range_tick_upper_indexi32
new_range_tick_lower_indexi32
new_range_tick_upper_indexi32
existing_range_liquidityu128
new_range_liquidityu128
existing_range_token_a_amountu64
existing_range_token_b_amountu64
new_range_token_a_amountu64
new_range_token_b_amountu64
token_a_transfer_amountu64
token_a_transfer_feeu64
is_token_a_transfer_from_ownerbool
token_b_transfer_amountu64
token_b_transfer_feeu64
is_token_b_transfer_from_ownerbool

PoolInitialized#

Discriminator 6476ad570cc6fee5 · events::pool_initialized::PoolInitializedEvent.

FieldType
whirlpoolPubkey
whirlpools_configPubkey
token_mint_aPubkey
token_mint_bPubkey
tick_spacingu16
token_program_aPubkey
token_program_bPubkey
decimals_au8
decimals_bu8
initial_sqrt_priceu128

PositionOpened#

Discriminator edaff3e693756579 · events::position_opened::PositionOpenedEvent.

FieldType
whirlpoolPubkey
positionPubkey
tick_lower_indexi32
tick_upper_indexi32

Traded#

Discriminator e1ca49af932ba096 · events::traded::TradedEvent.

FieldType
whirlpoolPubkey
a_to_bbool
pre_sqrt_priceu128
post_sqrt_priceu128
input_amountu64
output_amountu64
input_transfer_feeu64
output_transfer_feeu64
lp_feeu64
protocol_feeu64

Types#

Types used by the instructions, accounts and events above, exported from carbon_orca_whirlpool_decoder::types.

AccountsType#

Enum types::AccountsType.

Variant
TransferHookA
TransferHookB
TransferHookReward
TransferHookInput
TransferHookIntermediate
TransferHookOutput
SupplementalTickArrays
SupplementalTickArraysOne
SupplementalTickArraysTwo
TransferHookDepositA
TransferHookDepositB
TransferHookWithdrawalA
TransferHookWithdrawalB

AdaptiveFeeConstants#

Struct types::AdaptiveFeeConstants.

FieldType
filter_periodu16
decay_periodu16
reduction_factoru16
adaptive_fee_control_factoru32
max_volatility_accumulatoru32
tick_group_sizeu16
major_swap_threshold_ticksu16
reserved[u8; 16]

AdaptiveFeeVariables#

Struct types::AdaptiveFeeVariables.

FieldType
last_reference_update_timestampu64
last_major_swap_timestampu64
volatility_referenceu32
tick_group_index_referencei32
volatility_accumulatoru32
reserved[u8; 16]

ConfigFeatureFlag#

Enum types::ConfigFeatureFlag.

VariantFields
TokenBadgebool

DynamicTick#

Enum types::DynamicTick.

VariantFields
Uninitialized
InitializedDynamicTickData

DynamicTickData#

Struct types::DynamicTickData.

FieldType
liquidity_neti128
liquidity_grossu128
fee_growth_outside_au128
fee_growth_outside_bu128
reward_growths_outside[u128; 3]

IncreaseLiquidityMethod#

Enum types::IncreaseLiquidityMethod.

VariantFields
ByTokenAmountstoken_max_a: u64, token_max_b: u64, min_sqrt_price: u128, max_sqrt_price: u128

LiquidityDecreased#

Struct types::LiquidityDecreased. Same fields as the LiquidityDecreased event.

LiquidityIncreased#

Struct types::LiquidityIncreased. Same fields as the LiquidityIncreased event.

LiquidityRepositioned#

Struct types::LiquidityRepositioned. Same fields as the LiquidityRepositioned event.

LockType#

Enum types::LockType.

Variant
Permanent

LockTypeLabel#

Enum types::LockTypeLabel.

Variant
Permanent

OpenPositionBumps#

Struct types::OpenPositionBumps.

FieldType
position_bumpu8

OpenPositionWithMetadataBumps#

Struct types::OpenPositionWithMetadataBumps.

FieldType
position_bumpu8
metadata_bumpu8

PoolInitialized#

Struct types::PoolInitialized. Same fields as the PoolInitialized event.

PositionOpened#

Struct types::PositionOpened. Same fields as the PositionOpened event.

PositionRewardInfo#

Struct types::PositionRewardInfo.

FieldType
growth_inside_checkpointu128
amount_owedu64

RemainingAccountsInfo#

Struct types::RemainingAccountsInfo.

RemainingAccountsSlice#

Struct types::RemainingAccountsSlice.

FieldType
accounts_typeAccountsType
lengthu8

RepositionLiquidityMethod#

Enum types::RepositionLiquidityMethod.

VariantFields
ByLiquiditynew_liquidity_amount: u128, existing_range_token_min_a: u64, existing_range_token_min_b: u64, new_range_token_max_a: u64, new_range_token_max_b: u64

Tick#

Struct types::Tick.

FieldType
initializedbool
liquidity_neti128
liquidity_grossu128
fee_growth_outside_au128
fee_growth_outside_bu128
reward_growths_outside[u128; 3]

TokenBadgeAttribute#

Enum types::TokenBadgeAttribute.

VariantFields
RequireNonTransferablePositionbool

Traded#

Struct types::Traded. Same fields as the Traded event.

WhirlpoolBumps#

Struct types::WhirlpoolBumps.

FieldType
whirlpool_bumpu8

WhirlpoolRewardInfo#

From the program's IDL:

Stores the state relevant for tracking liquidity mining rewards at the Whirlpool level. These values are used in conjunction with PositionRewardInfo, Tick.reward_growths_outside, and Whirlpool.\ reward_last_updated_timestamp to determine how many rewards are earned by open positions.

Struct types::WhirlpoolRewardInfo.

FieldTypeDescription
mintPubkeyReward token mint.
vaultPubkeyReward vault token account.
extension[u8; 32]reward_infos[0]: Authority account that has permission to initialize the reward and set emissions. reward_infos[1]: used for a struct that contains fields for extending the functionality of Whirlpool. reward_infos[2]: reserved for future use. Historical notes: Originally, this was a field named "authority", but it was found that there was no opportunity to set different authorities for the three rewards. Therefore, the use of this field was changed for Whirlpool's future extensibility.
emissions_per_second_x64u128Q64.64 number that indicates how many tokens per second are earned per unit of liquidity.
growth_global_x64u128Q64.64 number that tracks the total tokens earned per unit of liquidity since the reward emissions were turned on.

Generated from the crate’s source at Carbon v2.0.0, so it always matches the published code. Spotted a problem? Report it; edits to this page itself are overwritten on the next release.

Your endpoints

Code samples use these instead of the placeholders, so you can copy and run them as they are. They’re stored only in this browser and never sent anywhere.