Raydium AMM v4 decoder

Decode Raydium AMM v4 instructions and accounts in Rust with carbon-raydium-amm-v4-decoder 2.0.0. Program ID 675kPX9MHTjS2zt1qfr1NYHuzeLXfQM9H24wFSUt1Mp8.

On this page

carbon-raydium-amm-v4-decoder decodes the instructions and accounts of the Raydium AMM v4 program (675kPX9MHTjS2zt1qfr1NYHuzeLXfQM9H24wFSUt1Mp8): 18 instructions, 3 account types. It is generated with Codama from the program's IDL; see decoders for how decoders plug into a pipeline.

Cratecarbon-raydium-amm-v4-decoder 2.0.0
Installcargo add carbon-raydium-amm-v4-decoder@2.0.0
Program ID675kPX9MHTjS2zt1qfr1NYHuzeLXfQM9H24wFSUt1Mp8 (carbon_raydium_amm_v4_decoder::PROGRAM_ID)
CategoryDEX & AMM
Decodercarbon_raydium_amm_v4_decoder::RaydiumAmmV4Decoder
Instruction enuminstructions::RaydiumAmmV4Instruction
Account enumaccounts::RaydiumAmmV4Account
Featuresserde, postgres, graphql (none enabled by default)
API docsdocs.rs/carbon-raydium-amm-v4-decoder/2.0.0
Sourcedecoders/raydium-amm-v4-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, Orca Whirlpools, PancakeSwap, Phoenix v1, PumpSwap, 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 Raydium AMM v4 transactions from the public RPC and prints every decoded SwapBaseIn instruction. Add the dependencies:

Terminal
cargo add carbon-core@2.0.0 carbon-raydium-amm-v4-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_raydium_amm_v4_decoder::{
        instructions::RaydiumAmmV4Instruction, RaydiumAmmV4Decoder, 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(RaydiumAmmV4Decoder, InstructionLogger)
        .build()?
        .run()
        .await
}

struct InstructionLogger;

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

Each SwapBaseIn instruction prints one line with the transaction signature and the decoded SwapBaseIn 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.

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 AmmInfo 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_raydium_amm_v4_decoder::{accounts::RaydiumAmmV4Account, RaydiumAmmV4Decoder, 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(RaydiumAmmV4Decoder, AccountLogger)
        .build()?
        .run()
        .await
}

struct AccountLogger;

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

Each update to a AmmInfo 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 RaydiumAmmV4Instruction. Each is RaydiumAmmV4Instruction::<Variant> { program_id, data, accounts }, where data and accounts are the types listed under the variant, exported from carbon_raydium_amm_v4_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 675kPX9MHTjS2zt1qfr1NYHuzeLXfQM9H24wFSUt1Mp8.
  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.

AdminCancelOrders#

From the program's IDL:

Admin: cancel up to limit of the pool's open orders.

Discriminator 0d · data AdminCancelOrders · accounts AdminCancelOrdersInstructionAccounts.

FieldType
limitu16

Required accounts: 17 (18 listed); extras go to remaining.

Fields of AdminCancelOrdersInstructionAccounts, in account order:

#FieldType
0token_programPubkey
1ammPubkey
2amm_authorityPubkey
3amm_open_ordersPubkey
4amm_target_ordersPubkey
5amm_coin_vaultPubkey
6amm_pc_vaultPubkey
7amm_configPubkey
8adminPubkey
9market_programPubkey
10marketPubkey
11market_coin_vaultPubkey
12market_pc_vaultPubkey
13market_vault_signerPubkey
14market_event_queuePubkey
15market_bidsPubkey
16market_asksPubkey
17referrer_pc_accountOption<Pubkey>
18…remainingVec<AccountMeta>

CreateConfigAccount#

From the program's IDL:

Admin: create the singleton AmmConfig account.

Discriminator 0e · data CreateConfigAccount · accounts CreateConfigAccountInstructionAccounts.

No data fields.

Required accounts: 5; extras go to remaining.

Fields of CreateConfigAccountInstructionAccounts, in account order:

#FieldType
0adminPubkey
1amm_configPubkey
2ownerPubkey
3system_programPubkey
4rentPubkey
5…remainingVec<AccountMeta>

Deposit#

From the program's IDL:

Deposit tokens into the pool. Mints LP tokens to the user.

Discriminator 03 · data Deposit · accounts DepositInstructionAccounts.

FieldTypeDescription
max_coin_amountu64
max_pc_amountu64
base_sideu64
other_amount_minOption<u64>Optional trailing slippage bound; absent in legacy txs.

Required accounts: 14; extras go to remaining.

Fields of DepositInstructionAccounts, in account order:

#FieldType
0token_programPubkey
1ammPubkey
2amm_authorityPubkey
3amm_open_ordersPubkey
4amm_target_ordersPubkey
5amm_lp_mintPubkey
6amm_coin_vaultPubkey
7amm_pc_vaultPubkey
8marketPubkey
9user_token_coinPubkey
10user_token_pcPubkey
11user_token_lpPubkey
12user_ownerPubkey
13market_event_queuePubkey
14…remainingVec<AccountMeta>

Initialize#

From the program's IDL:

Deprecated. Use initialize2.

Discriminator 00 · data Initialize · accounts InitializeInstructionAccounts.

FieldType
nonceu8
open_timeu64

Required accounts: 16; extras go to remaining.

Fields of InitializeInstructionAccounts, in account order:

#FieldType
0token_programPubkey
1system_programPubkey
2rentPubkey
3ammPubkey
4amm_authorityPubkey
5amm_open_ordersPubkey
6amm_lp_mintPubkey
7amm_coin_mintPubkey
8amm_pc_mintPubkey
9amm_coin_vaultPubkey
10amm_pc_vaultPubkey
11amm_target_ordersPubkey
12pool_temp_lpPubkey
13market_programPubkey
14marketPubkey
15user_walletPubkey
16…remainingVec<AccountMeta>

Initialize2#

From the program's IDL:

Initializes a new AMM pool.

Discriminator 01 · data Initialize2 · accounts Initialize2InstructionAccounts.

FieldType
nonceu8
open_timeu64
init_pc_amountu64
init_coin_amountu64

Required accounts: 21; extras go to remaining.

Fields of Initialize2InstructionAccounts, in account order:

#FieldType
0token_programPubkey
1associated_token_programPubkey
2system_programPubkey
3rentPubkey
4ammPubkey
5amm_authorityPubkey
6amm_open_ordersPubkey
7amm_lp_mintPubkey
8amm_coin_mintPubkey
9amm_pc_mintPubkey
10amm_coin_vaultPubkey
11amm_pc_vaultPubkey
12amm_target_ordersPubkey
13amm_configPubkey
14create_fee_destinationPubkey
15market_programPubkey
16marketPubkey
17user_walletPubkey
18user_token_coinPubkey
19user_token_pcPubkey
20user_token_lpPubkey
21…remainingVec<AccountMeta>

MigrateToOpenBook#

From the program's IDL:

Migrate the associated market from Serum to OpenBook.

Discriminator 05 · data MigrateToOpenBook · accounts MigrateToOpenBookInstructionAccounts.

No data fields.

Required accounts: 21; extras go to remaining.

Fields of MigrateToOpenBookInstructionAccounts, in account order:

#FieldType
0token_programPubkey
1system_programPubkey
2rentPubkey
3ammPubkey
4amm_authorityPubkey
5amm_open_ordersPubkey
6amm_coin_vaultPubkey
7amm_pc_vaultPubkey
8amm_target_ordersPubkey
9market_programPubkey
10marketPubkey
11market_bidsPubkey
12market_asksPubkey
13market_event_queuePubkey
14market_coin_vaultPubkey
15market_pc_vaultPubkey
16market_vault_signerPubkey
17new_amm_open_ordersPubkey
18new_market_programPubkey
19new_marketPubkey
20adminPubkey
21…remainingVec<AccountMeta>

MonitorStep#

From the program's IDL:

Step the AMM order-book state machine.

Discriminator 02 · data MonitorStep · accounts MonitorStepInstructionAccounts.

FieldType
plan_order_limitu16
place_order_limitu16
cancel_order_limitu16

Required accounts: 18 (20 listed); extras go to remaining.

Fields of MonitorStepInstructionAccounts, in account order:

#FieldType
0token_programPubkey
1rentPubkey
2clockPubkey
3ammPubkey
4amm_authorityPubkey
5amm_open_ordersPubkey
6amm_target_ordersPubkey
7amm_coin_vaultPubkey
8amm_pc_vaultPubkey
9market_programPubkey
10marketPubkey
11market_coin_vaultPubkey
12market_pc_vaultPubkey
13market_vault_signerPubkey
14market_request_queuePubkey
15market_event_queuePubkey
16market_bidsPubkey
17market_asksPubkey
18srm_accountOption<Pubkey>
19referrer_pc_accountOption<Pubkey>
20…remainingVec<AccountMeta>

PreInitialize#

From the program's IDL:

Deprecated. Use initialize2.

Discriminator 0a · data PreInitialize · accounts PreInitializeInstructionAccounts.

FieldType
nonceu8

Required accounts: 14; extras go to remaining.

Fields of PreInitializeInstructionAccounts, in account order:

#FieldType
0token_programPubkey
1system_programPubkey
2rentPubkey
3amm_target_ordersPubkey
4pool_withdraw_queuePubkey
5amm_authorityPubkey
6lp_mint_addressPubkey
7coin_mint_addressPubkey
8pc_mint_addressPubkey
9pool_coin_token_accountPubkey
10pool_pc_token_accountPubkey
11pool_temp_lp_token_accountPubkey
12serum_marketPubkey
13user_walletPubkey
14…remainingVec<AccountMeta>

SetParams#

From the program's IDL:

Admin: set an AMM parameter. The payload after param depends on the variant:

  • ammOwner: 32-byte Pubkey
  • fees: 64-byte Fees struct
  • lastOrderDistance: numerator(u64) + denominator(u64)
  • all other variants: value(u64)

Only value, newPubkey, fees, or lastOrderDistance is populated based on param.

Discriminator 06 · data SetParams · accounts SetParamsInstructionAccounts.

FieldType
paramAmmParams
valueOption<u64>
new_pubkeyOption<Pubkey>
feesOption<Fees>
last_order_distanceOption<LastOrderDistance>

Required accounts: 16 (17 listed); extras go to remaining.

Fields of SetParamsInstructionAccounts, in account order:

#FieldType
0token_programPubkey
1ammPubkey
2amm_authorityPubkey
3amm_open_ordersPubkey
4amm_target_ordersPubkey
5amm_coin_vaultPubkey
6amm_pc_vaultPubkey
7market_programPubkey
8marketPubkey
9market_coin_vaultPubkey
10market_pc_vaultPubkey
11market_vault_signerPubkey
12market_event_queuePubkey
13market_bidsPubkey
14market_asksPubkey
15adminPubkey
16new_amm_open_ordersOption<Pubkey>
17…remainingVec<AccountMeta>

SimulateInfo#

From the program's IDL:

Simulation-only instruction (used via simulateTransaction).
Payload after param depends on the variant:

  • poolInfo / runCrankInfo: no extra payload
  • swapBaseInInfo: amountIn(u64) + minimumAmountOut(u64)
  • swapBaseOutInfo: maxAmountIn(u64) + amountOut(u64)

Discriminator 0c · data SimulateInfo · accounts SimulateInfoInstructionAccounts.

FieldType
paramSimulateParams
swap_base_in_valueOption<SwapInstructionBaseIn>
swap_base_out_valueOption<SwapInstructionBaseOut>

Required accounts: 8; extras go to remaining.

Fields of SimulateInfoInstructionAccounts, in account order:

#FieldType
0ammPubkey
1amm_authorityPubkey
2amm_open_ordersPubkey
3amm_coin_vaultPubkey
4amm_pc_vaultPubkey
5amm_lp_mintPubkey
6marketPubkey
7market_event_queuePubkey
8…remainingVec<AccountMeta>

SwapBaseIn#

From the program's IDL:

Swap a fixed input amount with a slippage-bounded output.

Discriminator 09 · data SwapBaseIn · accounts SwapBaseInInstructionAccounts.

FieldType
amount_inu64
minimum_amount_outu64

Required accounts: 18; extras go to remaining.

Fields of SwapBaseInInstructionAccounts, in account order:

#FieldType
0token_programPubkey
1ammPubkey
2amm_authorityPubkey
3amm_open_ordersPubkey
4amm_target_ordersOption<Pubkey>
5amm_coin_vaultPubkey
6amm_pc_vaultPubkey
7market_programPubkey
8marketPubkey
9market_bidsPubkey
10market_asksPubkey
11market_event_queuePubkey
12market_coin_vaultPubkey
13market_pc_vaultPubkey
14market_vault_signerPubkey
15user_source_token_accountPubkey
16user_destination_token_accountPubkey
17user_source_ownerPubkey
18…remainingVec<AccountMeta>

SwapBaseInV2#

From the program's IDL:

Order-book-disabled swap with fixed input amount.

Discriminator 10 · data SwapBaseInV2 · accounts SwapBaseInV2InstructionAccounts.

FieldType
amount_inu64
minimum_amount_outu64

Required accounts: 8; extras go to remaining.

Fields of SwapBaseInV2InstructionAccounts, in account order:

#FieldType
0token_programPubkey
1ammPubkey
2amm_authorityPubkey
3amm_coin_vaultPubkey
4amm_pc_vaultPubkey
5user_source_token_accountPubkey
6user_destination_token_accountPubkey
7user_source_ownerPubkey
8…remainingVec<AccountMeta>

SwapBaseOut#

From the program's IDL:

Swap to receive a fixed output amount with a slippage-bounded input.

Discriminator 0b · data SwapBaseOut · accounts SwapBaseOutInstructionAccounts.

FieldType
max_amount_inu64
amount_outu64

Required accounts: 18; extras go to remaining.

Fields of SwapBaseOutInstructionAccounts, in account order:

#FieldType
0token_programPubkey
1ammPubkey
2amm_authorityPubkey
3amm_open_ordersPubkey
4amm_target_ordersOption<Pubkey>
5amm_coin_vaultPubkey
6amm_pc_vaultPubkey
7market_programPubkey
8marketPubkey
9market_bidsPubkey
10market_asksPubkey
11market_event_queuePubkey
12market_coin_vaultPubkey
13market_pc_vaultPubkey
14market_vault_signerPubkey
15user_source_token_accountPubkey
16user_destination_token_accountPubkey
17user_source_ownerPubkey
18…remainingVec<AccountMeta>

SwapBaseOutV2#

From the program's IDL:

Order-book-disabled swap with fixed output amount.

Discriminator 11 · data SwapBaseOutV2 · accounts SwapBaseOutV2InstructionAccounts.

FieldType
max_amount_inu64
amount_outu64

Required accounts: 8; extras go to remaining.

Fields of SwapBaseOutV2InstructionAccounts, in account order:

#FieldType
0token_programPubkey
1ammPubkey
2amm_authorityPubkey
3amm_coin_vaultPubkey
4amm_pc_vaultPubkey
5user_source_token_accountPubkey
6user_destination_token_accountPubkey
7user_source_ownerPubkey
8…remainingVec<AccountMeta>

UpdateConfigAccount#

From the program's IDL:

Admin: update the AmmConfig. Payload after param depends on the variant:

  • pnlOwner / cancelOrderOwner: 32-byte Pubkey
  • createPoolFee: u64

Discriminator 0f · data UpdateConfigAccount · accounts UpdateConfigAccountInstructionAccounts.

FieldType
paramConfigParam
ownerOption<Pubkey>
create_pool_feeOption<u64>

Required accounts: 2; extras go to remaining.

Fields of UpdateConfigAccountInstructionAccounts, in account order:

#FieldType
0adminPubkey
1amm_configPubkey
2…remainingVec<AccountMeta>

Withdraw#

From the program's IDL:

Burn LP tokens and withdraw the underlying assets.

Discriminator 04 · data Withdraw · accounts WithdrawInstructionAccounts.

FieldTypeDescription
amountu64
min_coin_amountOption<u64>Optional trailing slippage bound; both min fields are present or both absent.
min_pc_amountOption<u64>

Required accounts: 20; extras go to remaining.

Fields of WithdrawInstructionAccounts, in account order:

#FieldType
0token_programPubkey
1ammPubkey
2amm_authorityPubkey
3amm_open_ordersPubkey
4amm_target_ordersPubkey
5amm_lp_mintPubkey
6amm_coin_vaultPubkey
7amm_pc_vaultPubkey
8market_programPubkey
9marketPubkey
10market_coin_vaultPubkey
11market_pc_vaultPubkey
12market_vault_signerPubkey
13user_token_lpPubkey
14user_token_coinPubkey
15user_token_pcPubkey
16user_ownerPubkey
17market_event_queuePubkey
18market_bidsPubkey
19market_asksPubkey
20…remainingVec<AccountMeta>

WithdrawPnl#

From the program's IDL:

Protocol: withdraw accrued PnL from the pool.

Discriminator 07 · data WithdrawPnl · accounts WithdrawPnlInstructionAccounts.

No data fields.

Required accounts: 17 (18 listed); extras go to remaining.

Fields of WithdrawPnlInstructionAccounts, in account order:

#FieldType
0token_programPubkey
1ammPubkey
2amm_configPubkey
3amm_authorityPubkey
4amm_open_ordersPubkey
5amm_coin_vaultPubkey
6amm_pc_vaultPubkey
7user_coin_token_accountPubkey
8user_pc_token_accountPubkey
9user_ownerPubkey
10amm_target_ordersPubkey
11market_programPubkey
12marketPubkey
13market_event_queuePubkey
14market_coin_vaultPubkey
15market_pc_vaultPubkey
16market_vault_signerPubkey
17referrer_pc_accountOption<Pubkey>
18…remainingVec<AccountMeta>

WithdrawSrm#

From the program's IDL:

Admin: withdraw (M)SRM held for fee discounts.

Discriminator 08 · data WithdrawSrm · accounts WithdrawSrmInstructionAccounts.

FieldType
amountu64

Required accounts: 6; extras go to remaining.

Fields of WithdrawSrmInstructionAccounts, in account order:

#FieldType
0token_programPubkey
1ammPubkey
2adminPubkey
3amm_authorityPubkey
4srm_fromPubkey
5srm_toPubkey
6…remainingVec<AccountMeta>

Accounts#

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

AmmConfig#

From the program's IDL:

Global program config account.

Matched by data length (544 bytes) · accounts::amm_config::AmmConfig.

FieldType
pnl_ownerPubkey
cancel_ownerPubkey
pending1[u64; 28]
pending2[u64; 31]
create_pool_feeu64

AmmInfo#

From the program's IDL:

On-chain state of a single AMM pool.

Matched by data length (752 bytes) · accounts::amm_info::AmmInfo.

FieldType
statusu64
nonceu64
order_numu64
depthu64
coin_decimalsu64
pc_decimalsu64
stateu64
reset_flagu64
min_sizeu64
vol_max_cut_ratiou64
amount_waveu64
coin_lot_sizeu64
pc_lot_sizeu64
min_price_multiplieru64
max_price_multiplieru64
sys_decimal_valueu64
feesFees
state_dataStateData
coin_vaultPubkey
pc_vaultPubkey
coin_vault_mintPubkey
pc_vault_mintPubkey
lp_mintPubkey
open_ordersPubkey
marketPubkey
market_programPubkey
target_ordersPubkey
padding1[u64; 8]
amm_ownerPubkey
lp_amountu64
client_order_idu64
recent_epochu64
padding2u64

TargetOrders#

From the program's IDL:

Per-pool target orders book.

No discriminator (matched by Borsh layout) · accounts::target_orders::TargetOrders.

FieldType
owner[u64; 4]
buy_orders[TargetOrder; 50]
padding1[u64; 8]
target_xu128
target_yu128
plan_x_buyu128
plan_y_buyu128
plan_x_sellu128
plan_y_sellu128
placed_xu128
placed_yu128
calc_pnl_xu128
calc_pnl_yu128
sell_orders[TargetOrder; 50]
padding2[u64; 6]
replace_buy_client_id[u64; 10]
replace_sell_client_id[u64; 10]
last_order_numeratoru64
last_order_denominatoru64
plan_orders_curu64
place_orders_curu64
valid_buy_order_numu64
valid_sell_order_numu64
padding3[u64; 10]
free_slot_bitsu128

Types#

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

AmmParams#

From the program's IDL:

SetParams.param values.

Enum types::AmmParams.

Variant
Status
State
OrderNum
Depth
AmountWave
MinPriceMultiplier
MaxPriceMultiplier
MinSize
VolMaxCutRatio
Fees
AmmOwner
SetOpenTime
LastOrderDistance
InitOrderDepth
SetSwitchTime
ClearOpenTime
Seek
EnableOrderBook
DisableOrderBook

AmmResetFlag#

Enum types::AmmResetFlag.

Variant
ResetYes
ResetNo

AmmState#

From the program's IDL:

AmmInfo.state machine (stored as u64).

Enum types::AmmState.

Variant
IdleState
CancelAllOrdersState
PlanOrdersState
CancelOrderState
PlaceOrdersState
PurgeOrderState

AmmStatus#

From the program's IDL:

AmmInfo.status discriminator (stored as u64).

Enum types::AmmStatus.

Variant
Uninitialized
Initialized
Disabled
WithdrawOnly
LiquidityOnly
OrderBookOnly
SwapOnly
WaitingTrade

ConfigParam#

From the program's IDL:

UpdateConfigAccount.param values.

Enum types::ConfigParam.

Variant
PnlOwner
CancelOrderOwner
CreatePoolFee

Fees#

From the program's IDL:

Fee parameters for a pool.

Struct types::Fees.

FieldType
min_separate_numeratoru64
min_separate_denominatoru64
trade_fee_numeratoru64
trade_fee_denominatoru64
pnl_numeratoru64
pnl_denominatoru64
swap_fee_numeratoru64
swap_fee_denominatoru64

LastOrderDistance#

Struct types::LastOrderDistance.

FieldType
last_order_numeratoru64
last_order_denominatoru64

SimulateParams#

From the program's IDL:

SimulateInfo.param values.

Enum types::SimulateParams.

Variant
PoolInfo
SwapBaseInInfo
SwapBaseOutInfo
RunCrankInfo

StateData#

From the program's IDL:

Mutable pool statistics embedded in AmmInfo.

Struct types::StateData.

FieldType
need_take_pnl_coinu64
need_take_pnl_pcu64
total_pnl_pcu64
total_pnl_coinu64
pool_open_timeu64
padding[u64; 2]
orderbook_to_init_timeu64
swap_coin_in_amountu128
swap_pc_out_amountu128
swap_acc_pc_feeu64
swap_pc_in_amountu128
swap_coin_out_amountu128
swap_acc_coin_feeu64

SwapInstructionBaseIn#

Struct types::SwapInstructionBaseIn.

FieldType
amount_inu64
minimum_amount_outu64

SwapInstructionBaseOut#

Struct types::SwapInstructionBaseOut.

FieldType
max_amount_inu64
amount_outu64

TargetOrder#

Struct types::TargetOrder.

FieldType
priceu64
volu64

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.