Raydium CPMM decoder

Decode Raydium CPMM instructions, accounts and events in Rust with carbon-raydium-cpmm-decoder 2.0.0. Program ID CPMMoo8L3F4NbTegBCKVNunggL7H1ZpdTHKxQB5qKP1C.

On this page

carbon-raydium-cpmm-decoder decodes the instructions, accounts and events of the Raydium CPMM program (CPMMoo8L3F4NbTegBCKVNunggL7H1ZpdTHKxQB5qKP1C): 14 instructions, 4 account types, 2 events. It is generated with Codama from the program's IDL; see decoders for how decoders plug into a pipeline.

Cratecarbon-raydium-cpmm-decoder 2.0.0
Installcargo add carbon-raydium-cpmm-decoder@2.0.0
Program IDCPMMoo8L3F4NbTegBCKVNunggL7H1ZpdTHKxQB5qKP1C (carbon_raydium_cpmm_decoder::PROGRAM_ID)
CategoryDEX & AMM
Decodercarbon_raydium_cpmm_decoder::RaydiumCpmmDecoder
Instruction enuminstructions::RaydiumCpmmInstruction
Account enumaccounts::RaydiumCpmmAccount
Event enuminstructions::CpiEvent
Featuresserde, postgres, graphql (none enabled by default)
API docsdocs.rs/carbon-raydium-cpmm-decoder/2.0.0
Sourcedecoders/raydium-cpmm-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 AMM v4, Raydium CLMM, Raydium Stable Swap, Stabble Stable Swap, Stabble Weighted Swap. To decode several in one pipeline, see dEX and AMM decoders.

Guide: Index swaps across DEXs.

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 CPMM transactions from the public RPC and prints every decoded SwapBaseInput instruction. Add the dependencies:

Terminal
cargo add carbon-core@2.0.0 carbon-raydium-cpmm-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_cpmm_decoder::{
        instructions::RaydiumCpmmInstruction, RaydiumCpmmDecoder, 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(RaydiumCpmmDecoder, InstructionLogger)
        .build()?
        .run()
        .await
}

struct InstructionLogger;

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

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

Raydium CPMM publishes its events with Anchor's emit!, as Program data: log lines, so they never arrive as the CpiEvent instruction. Decode them from the instruction that emitted them with decode_log_events; index swaps across DEXs has a complete example. The event types are listed under 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 PoolState 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_cpmm_decoder::{accounts::RaydiumCpmmAccount, RaydiumCpmmDecoder, 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(RaydiumCpmmDecoder, AccountLogger)
        .build()?
        .run()
        .await
}

struct AccountLogger;

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

Each update to a PoolState 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 RaydiumCpmmInstruction. Each is RaydiumCpmmInstruction::<Variant> { program_id, data, accounts }, where data and accounts are the types listed under the variant, exported from carbon_raydium_cpmm_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 CPMMoo8L3F4NbTegBCKVNunggL7H1ZpdTHKxQB5qKP1C.
  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.

ClosePermissionPda#

From the program's IDL:

Close a permission account

Arguments

  • ctx- The context of accounts

Discriminator 9c5420764587467b · data ClosePermissionPda · accounts ClosePermissionPdaInstructionAccounts.

No data fields.

Required accounts: 4; extras go to remaining.

Fields of ClosePermissionPdaInstructionAccounts, in account order:

#FieldType
0ownerPubkey
1permission_authorityPubkey
2permissionPubkey
3system_programPubkey
4…remainingVec<AccountMeta>

CollectCreatorFee#

From the program's IDL:

Collect the creator fee

Arguments

  • ctx - The context of accounts

Discriminator 1416567bc61cdb84 · data CollectCreatorFee · accounts CollectCreatorFeeInstructionAccounts.

No data fields.

Required accounts: 14; extras go to remaining.

Fields of CollectCreatorFeeInstructionAccounts, in account order:

#FieldType
0creatorPubkey
1authorityPubkey
2pool_statePubkey
3amm_configPubkey
4token0_vaultPubkey
5token1_vaultPubkey
6vault0_mintPubkey
7vault1_mintPubkey
8creator_token0Pubkey
9creator_token1Pubkey
10token0_programPubkey
11token1_programPubkey
12associated_token_programPubkey
13system_programPubkey
14…remainingVec<AccountMeta>

CollectFundFee#

From the program's IDL:

Collect the fund fee accrued to the pool

Arguments

  • ctx - The context of accounts
  • amount_0_requested - The maximum amount of token_0 to send, can be 0 to collect fees in only token_1
  • amount_1_requested - The maximum amount of token_1 to send, can be 0 to collect fees in only token_0

Discriminator a78a4e95dfc2067e · data CollectFundFee · accounts CollectFundFeeInstructionAccounts.

FieldType
amount0_requestedu64
amount1_requestedu64

Required accounts: 12; extras go to remaining.

Fields of CollectFundFeeInstructionAccounts, in account order:

#FieldType
0ownerPubkey
1authorityPubkey
2pool_statePubkey
3amm_configPubkey
4token0_vaultPubkey
5token1_vaultPubkey
6vault0_mintPubkey
7vault1_mintPubkey
8recipient_token0_accountPubkey
9recipient_token1_accountPubkey
10token_programPubkey
11token_program2022Pubkey
12…remainingVec<AccountMeta>

CollectProtocolFee#

From the program's IDL:

Collect the protocol fee accrued to the pool

Arguments

  • ctx - The context of accounts
  • amount_0_requested - The maximum amount of token_0 to send, can be 0 to collect fees in only token_1
  • amount_1_requested - The maximum amount of token_1 to send, can be 0 to collect fees in only token_0

Discriminator 8888fcddc2427e59 · data CollectProtocolFee · accounts CollectProtocolFeeInstructionAccounts.

FieldType
amount0_requestedu64
amount1_requestedu64

Required accounts: 12; extras go to remaining.

Fields of CollectProtocolFeeInstructionAccounts, in account order:

#FieldType
0ownerPubkey
1authorityPubkey
2pool_statePubkey
3amm_configPubkey
4token0_vaultPubkey
5token1_vaultPubkey
6vault0_mintPubkey
7vault1_mintPubkey
8recipient_token0_accountPubkey
9recipient_token1_accountPubkey
10token_programPubkey
11token_program2022Pubkey
12…remainingVec<AccountMeta>

CreateAmmConfig#

From the program's IDL:

Arguments

  • ctx- The accounts needed by instruction.
  • index - The index of amm config, there may be multiple config.
  • trade_fee_rate - Trade fee rate, can be changed.
  • protocol_fee_rate - The rate of protocol fee within trade fee.
  • fund_fee_rate - The rate of fund fee within trade fee.

Discriminator 8934edd4d7756c68 · data CreateAmmConfig · accounts CreateAmmConfigInstructionAccounts.

FieldType
indexu16
trade_fee_rateu64
protocol_fee_rateu64
fund_fee_rateu64
create_pool_feeu64
creator_fee_rateu64

Required accounts: 3; extras go to remaining.

Fields of CreateAmmConfigInstructionAccounts, in account order:

#FieldType
0ownerPubkey
1amm_configPubkey
2system_programPubkey
3…remainingVec<AccountMeta>

CreatePermissionPda#

From the program's IDL:

Create a permission account

Arguments

  • ctx- The context of accounts

Discriminator 878802d889a9b5ca · data CreatePermissionPda · accounts CreatePermissionPdaInstructionAccounts.

No data fields.

Required accounts: 4; extras go to remaining.

Fields of CreatePermissionPdaInstructionAccounts, in account order:

#FieldType
0ownerPubkey
1permission_authorityPubkey
2permissionPubkey
3system_programPubkey
4…remainingVec<AccountMeta>

Deposit#

From the program's IDL:

Deposit lp token to the pool

Arguments

  • ctx- The context of accounts
  • lp_token_amount - Increased number of LPs
  • maximum_token_0_amount - Maximum token 0 amount to deposit, prevents excessive slippage
  • maximum_token_1_amount - Maximum token 1 amount to deposit, prevents excessive slippage

Discriminator f223c68952e1f2b6 · data Deposit · accounts DepositInstructionAccounts.

FieldType
lp_token_amountu64
maximum_token0_amountu64
maximum_token1_amountu64

Required accounts: 13; extras go to remaining.

Fields of DepositInstructionAccounts, in account order:

#FieldType
0ownerPubkey
1authorityPubkey
2pool_statePubkey
3owner_lp_tokenPubkey
4token0_accountPubkey
5token1_accountPubkey
6token0_vaultPubkey
7token1_vaultPubkey
8token_programPubkey
9token_program2022Pubkey
10vault0_mintPubkey
11vault1_mintPubkey
12lp_mintPubkey
13…remainingVec<AccountMeta>

Initialize#

From the program's IDL:

Creates a pool for the given token pair and the initial price

Arguments

  • ctx- The context of accounts
  • init_amount_0 - the initial amount_0 to deposit
  • init_amount_1 - the initial amount_1 to deposit
  • open_time - the timestamp allowed for swap

Discriminator afaf6d1f0d989bed · data Initialize · accounts InitializeInstructionAccounts.

FieldType
init_amount0u64
init_amount1u64
open_timeu64

Required accounts: 20; extras go to remaining.

Fields of InitializeInstructionAccounts, in account order:

#FieldType
0creatorPubkey
1amm_configPubkey
2authorityPubkey
3pool_statePubkey
4token0_mintPubkey
5token1_mintPubkey
6lp_mintPubkey
7creator_token0Pubkey
8creator_token1Pubkey
9creator_lp_tokenPubkey
10token0_vaultPubkey
11token1_vaultPubkey
12create_pool_feePubkey
13observation_statePubkey
14token_programPubkey
15token0_programPubkey
16token1_programPubkey
17associated_token_programPubkey
18system_programPubkey
19rentPubkey
20…remainingVec<AccountMeta>

InitializeWithPermission#

From the program's IDL:

Create a pool with permission

Arguments

  • ctx- The context of accounts
  • init_amount_0 - the initial amount_0 to deposit
  • init_amount_1 - the initial amount_1 to deposit
  • open_time - the timestamp allowed for swap
  • creator_fee_on - creator fee model, 0:both token0 and token1 (depends on the input), 1: only token0, 2: only token1

Discriminator 3f37fe4131b25979 · data InitializeWithPermission · accounts InitializeWithPermissionInstructionAccounts.

FieldType
init_amount0u64
init_amount1u64
open_timeu64
creator_fee_onCreatorFeeOn

Required accounts: 21; extras go to remaining.

Fields of InitializeWithPermissionInstructionAccounts, in account order:

#FieldType
0payerPubkey
1creatorPubkey
2amm_configPubkey
3authorityPubkey
4pool_statePubkey
5token0_mintPubkey
6token1_mintPubkey
7lp_mintPubkey
8payer_token0Pubkey
9payer_token1Pubkey
10payer_lp_tokenPubkey
11token0_vaultPubkey
12token1_vaultPubkey
13create_pool_feePubkey
14observation_statePubkey
15permissionPubkey
16token_programPubkey
17token0_programPubkey
18token1_programPubkey
19associated_token_programPubkey
20system_programPubkey
21…remainingVec<AccountMeta>

SwapBaseInput#

From the program's IDL:

Swap the tokens in the pool base input amount

Arguments

  • ctx- The context of accounts
  • amount_in - input amount to transfer, output to DESTINATION is based on the exchange rate
  • minimum_amount_out - Minimum amount of output token, prevents excessive slippage

Discriminator 8fbe5adac41e33de · data SwapBaseInput · accounts SwapBaseInputInstructionAccounts.

FieldType
amount_inu64
minimum_amount_outu64

Required accounts: 13; extras go to remaining.

Fields of SwapBaseInputInstructionAccounts, in account order:

#FieldType
0payerPubkey
1authorityPubkey
2amm_configPubkey
3pool_statePubkey
4input_token_accountPubkey
5output_token_accountPubkey
6input_vaultPubkey
7output_vaultPubkey
8input_token_programPubkey
9output_token_programPubkey
10input_token_mintPubkey
11output_token_mintPubkey
12observation_statePubkey
13…remainingVec<AccountMeta>

SwapBaseOutput#

From the program's IDL:

Swap the tokens in the pool base output amount

Arguments

  • ctx- The context of accounts
  • max_amount_in - input amount prevents excessive slippage
  • amount_out - amount of output token

Discriminator 37d96256a34ab4ad · data SwapBaseOutput · accounts SwapBaseOutputInstructionAccounts.

FieldType
max_amount_inu64
amount_outu64

Required accounts: 13; extras go to remaining.

Fields of SwapBaseOutputInstructionAccounts, in account order:

#FieldType
0payerPubkey
1authorityPubkey
2amm_configPubkey
3pool_statePubkey
4input_token_accountPubkey
5output_token_accountPubkey
6input_vaultPubkey
7output_vaultPubkey
8input_token_programPubkey
9output_token_programPubkey
10input_token_mintPubkey
11output_token_mintPubkey
12observation_statePubkey
13…remainingVec<AccountMeta>

UpdateAmmConfig#

From the program's IDL:

Updates the owner of the amm config
Must be called by the current owner or admin

Arguments

  • ctx- The context of accounts
  • trade_fee_rate- The new trade fee rate of amm config, be set when param is 0
  • protocol_fee_rate- The new protocol fee rate of amm config, be set when param is 1
  • fund_fee_rate- The new fund fee rate of amm config, be set when param is 2
  • new_owner- The config's new owner, be set when param is 3
  • new_fund_owner- The config's new fund owner, be set when param is 4
  • param- The value can be 0 | 1 | 2 | 3 | 4, otherwise will report a error

Discriminator 313cae889a1c74c8 · data UpdateAmmConfig · accounts UpdateAmmConfigInstructionAccounts.

FieldType
paramu8
valueu64

Required accounts: 2; extras go to remaining.

Fields of UpdateAmmConfigInstructionAccounts, in account order:

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

UpdatePoolStatus#

From the program's IDL:

Update pool status for given value

Arguments

  • ctx- The context of accounts
  • status - The value of status

Discriminator 82576c062ee0757b · data UpdatePoolStatus · accounts UpdatePoolStatusInstructionAccounts.

FieldType
statusu8

Required accounts: 2; extras go to remaining.

Fields of UpdatePoolStatusInstructionAccounts, in account order:

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

Withdraw#

From the program's IDL:

Withdraw lp for token0 and token1

Arguments

  • ctx- The context of accounts
  • lp_token_amount - Amount of pool tokens to burn. User receives an output of token a and b based on the percentage of the pool tokens that are returned.
  • minimum_token_0_amount - Minimum amount of token 0 to receive, prevents excessive slippage
  • minimum_token_1_amount - Minimum amount of token 1 to receive, prevents excessive slippage

Discriminator b712469c946da122 · data Withdraw · accounts WithdrawInstructionAccounts.

FieldType
lp_token_amountu64
minimum_token0_amountu64
minimum_token1_amountu64

Required accounts: 14; extras go to remaining.

Fields of WithdrawInstructionAccounts, in account order:

#FieldType
0ownerPubkey
1authorityPubkey
2pool_statePubkey
3owner_lp_tokenPubkey
4token0_accountPubkey
5token1_accountPubkey
6token0_vaultPubkey
7token1_vaultPubkey
8token_programPubkey
9token_program2022Pubkey
10vault0_mintPubkey
11vault1_mintPubkey
12lp_mintPubkey
13memo_programPubkey
14…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 RaydiumCpmmAccount. Each wraps a boxed struct from carbon_raydium_cpmm_decoder::accounts::<module>. decode_account only considers accounts owned by PROGRAM_ID and returns the first variant that matches.

AmmConfig#

Discriminator daf42168cbcb2b6f · accounts::amm_config::AmmConfig.

FieldTypeDescription
bumpu8Bump to identify PDA
disable_create_poolboolStatus to control if new pool can be create
indexu16Config index
trade_fee_rateu64The trade fee, denominated in hundredths of a bip (10^-6)
protocol_fee_rateu64The protocol fee
fund_fee_rateu64The fund fee, denominated in hundredths of a bip (10^-6)
create_pool_feeu64Fee for create a new pool
protocol_ownerPubkeyAddress of the protocol fee owner
fund_ownerPubkeyAddress of the fund fee owner
creator_fee_rateu64The pool creator fee, denominated in hundredths of a bip (10^-6)
padding[u64; 15]padding

ObservationState#

Discriminator 7aaec5358109a584 · accounts::observation_state::ObservationState.

FieldTypeDescription
initializedboolWhether the ObservationState is initialized
observation_indexu16the most-recently updated index of the observations array
pool_idPubkey
observations[Observation; 100]observation array
last_update_timestampu64the last update timestamp
padding[u64; 3]padding for feature update

Permission#

Discriminator e0531c4f0afda11c · accounts::permission::Permission.

FieldTypeDescription
authorityPubkeyauthority
padding[u64; 30]padding

PoolState#

Discriminator f7ede3f5d7c3de46 · accounts::pool_state::PoolState.

FieldTypeDescription
amm_configPubkeyWhich config the pool belongs
pool_creatorPubkeypool creator
token0_vaultPubkeyToken A
token1_vaultPubkeyToken B
lp_mintPubkeyPool tokens are issued when A or B tokens are deposited. Pool tokens can be withdrawn back to the original A or B token.
token0_mintPubkeyMint information for token A
token1_mintPubkeyMint information for token B
token0_programPubkeytoken_0 program
token1_programPubkeytoken_1 program
observation_keyPubkeyobservation account to store oracle data
auth_bumpu8
statusu8Bitwise representation of the state of the pool bit0, 1: disable deposit(value is 1), 0: normal bit1, 1: disable withdraw(value is 2), 0: normal bit2, 1: disable swap(value is 4), 0: normal
lp_mint_decimalsu8
mint0_decimalsu8mint0 and mint1 decimals
mint1_decimalsu8
lp_supplyu64True circulating supply without burns and lock ups
protocol_fees_token0u64The amounts of token_0 and token_1 that are owed to the liquidity provider.
protocol_fees_token1u64
fund_fees_token0u64
fund_fees_token1u64
open_timeu64The timestamp allowed for swap in the pool.
recent_epochu64recent epoch
creator_fee_onu8Creator fee collect mode 0: both token_0 and token_1 can be used as trade fees. It depends on what the input token is when swapping 1: only token_0 as trade fee 2: only token_1 as trade fee
enable_creator_feebool
padding1[u8; 6]
creator_fees_token0u64
creator_fees_token1u64
padding[u64; 28]padding for future updates

Events#

Structs in carbon_raydium_cpmm_decoder::events::<module>, also listed as variants of instructions::CpiEvent. Raydium CPMM logs these events with emit! rather than emitting them through a self-CPI, so read them with decode_log_events on the instruction that logged them. The discriminator is the event's 8-byte discriminator at the start of the logged data.

LpChangeEvent#

Discriminator 79a3cdc939da753c · events::lp_change_event::LpChangeEventEvent.

FieldTypeDescription
pool_idPubkey
lp_amount_beforeu64
token0_vault_beforeu64pool vault sub trade fees
token1_vault_beforeu64pool vault sub trade fees
token0_amountu64calculate result without transfer fee
token1_amountu64calculate result without transfer fee
token0_transfer_feeu64
token1_transfer_feeu64
change_typeu8

SwapEvent#

Discriminator 40c6cde8260871e2 · events::swap_event::SwapEventEvent.

FieldTypeDescription
pool_idPubkey
input_vault_beforeu64pool vault sub trade fees
output_vault_beforeu64pool vault sub trade fees
input_amountu64calculate result without transfer fee
output_amountu64calculate result without transfer fee
input_transfer_feeu64
output_transfer_feeu64
base_inputbool
input_mintPubkey
output_mintPubkey
trade_feeu64
creator_feeu64Amount of fee tokens going to creator
creator_fee_on_inputbool

Types#

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

CreatorFeeOn#

Enum types::CreatorFeeOn.

Variant
BothToken
OnlyToken0
OnlyToken1

LpChangeEvent#

From the program's IDL:

Emitted when deposit and withdraw

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

Observation#

From the program's IDL:

The element of observations in ObservationState

Struct types::Observation.

FieldTypeDescription
block_timestampu64The block timestamp of the observation
cumulative_token0_price_x32u128the cumulative of token0 price during the duration time, Q32.32, the remaining 64 bit for overflow
cumulative_token1_price_x32u128the cumulative of token1 price during the duration time, Q32.32, the remaining 64 bit for overflow

SwapEvent#

From the program's IDL:

Emitted when swap

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

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.