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.
| Crate | carbon-raydium-cpmm-decoder 2.0.0 |
| Install | cargo add carbon-raydium-cpmm-decoder@2. |
| Program ID | CPMMoo8L3F4NbTegBCKVNunggL7H1ZpdTHKxQB5qKP1C (carbon_) |
| Category | DEX & AMM |
| Decoder | carbon_ |
| Instruction enum | instructions:: |
| Account enum | accounts:: |
| Event enum | instructions:: |
| Features | serde, postgres, graphql (none enabled by default) |
| API docs | docs.rs/carbon-raydium-cpmm-decoder/2.0.0 |
| Source | decoders/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:
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/fulluse {
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(())
}
}RUST_LOG=info cargo runEach 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_; 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:
cargo add carbon-rpc-program-subscribe-datasource@2.0.0 solana-client@4.2.2use {
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(())
}
}RUST_LOG=info cargo runEach 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::, where data and accounts are the types listed under the variant, exported from carbon_. 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:
- The instruction's program ID is
CPMMoo8L3F4NbTegBCKVNunggL7H1ZpdTHKxQB5qKP1C. - The data starts with the variant's discriminator, and the rest deserializes into its data type.
- 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_ too. Accounts after the listed ones are in accounts. as AccountMetas. The decoder doesn't record whether an account signed or was writable: read that from input. and ., 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:
| # | Field | Type |
|---|---|---|
| 0 | owner | Pubkey |
| 1 | permission_ | Pubkey |
| 2 | permission | Pubkey |
| 3 | system_ | Pubkey |
| 4… | remaining | Vec< |
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:
| # | Field | Type |
|---|---|---|
| 0 | creator | Pubkey |
| 1 | authority | Pubkey |
| 2 | pool_state | Pubkey |
| 3 | amm_config | Pubkey |
| 4 | token0_ | Pubkey |
| 5 | token1_ | Pubkey |
| 6 | vault0_mint | Pubkey |
| 7 | vault1_mint | Pubkey |
| 8 | creator_ | Pubkey |
| 9 | creator_ | Pubkey |
| 10 | token0_ | Pubkey |
| 11 | token1_ | Pubkey |
| 12 | associated_ | Pubkey |
| 13 | system_ | Pubkey |
| 14… | remaining | Vec< |
CollectFundFee#
From the program's IDL:
Collect the fund fee accrued to the pool
Arguments
ctx- The context of accountsamount_- The maximum amount of token_0 to send, can be 0 to collect fees in only token_10_ requested amount_- The maximum amount of token_1 to send, can be 0 to collect fees in only token_01_ requested
Discriminator a78a4e95dfc2067e · data CollectFundFee · accounts CollectFundFeeInstructionAccounts.
| Field | Type |
|---|---|
amount0_ | u64 |
amount1_ | u64 |
Required accounts: 12; extras go to remaining.
Fields of CollectFundFeeInstructionAccounts, in account order:
| # | Field | Type |
|---|---|---|
| 0 | owner | Pubkey |
| 1 | authority | Pubkey |
| 2 | pool_state | Pubkey |
| 3 | amm_config | Pubkey |
| 4 | token0_ | Pubkey |
| 5 | token1_ | Pubkey |
| 6 | vault0_mint | Pubkey |
| 7 | vault1_mint | Pubkey |
| 8 | recipient_ | Pubkey |
| 9 | recipient_ | Pubkey |
| 10 | token_ | Pubkey |
| 11 | token_ | Pubkey |
| 12… | remaining | Vec< |
CollectProtocolFee#
From the program's IDL:
Collect the protocol fee accrued to the pool
Arguments
ctx- The context of accountsamount_- The maximum amount of token_0 to send, can be 0 to collect fees in only token_10_ requested amount_- The maximum amount of token_1 to send, can be 0 to collect fees in only token_01_ requested
Discriminator 8888fcddc2427e59 · data CollectProtocolFee · accounts CollectProtocolFeeInstructionAccounts.
| Field | Type |
|---|---|
amount0_ | u64 |
amount1_ | u64 |
Required accounts: 12; extras go to remaining.
Fields of CollectProtocolFeeInstructionAccounts, in account order:
| # | Field | Type |
|---|---|---|
| 0 | owner | Pubkey |
| 1 | authority | Pubkey |
| 2 | pool_state | Pubkey |
| 3 | amm_config | Pubkey |
| 4 | token0_ | Pubkey |
| 5 | token1_ | Pubkey |
| 6 | vault0_mint | Pubkey |
| 7 | vault1_mint | Pubkey |
| 8 | recipient_ | Pubkey |
| 9 | recipient_ | Pubkey |
| 10 | token_ | Pubkey |
| 11 | token_ | Pubkey |
| 12… | remaining | Vec< |
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_- Trade fee rate, can be changed.fee_ rate protocol_- The rate of protocol fee within trade fee.fee_ rate fund_- The rate of fund fee within trade fee.fee_ rate
Discriminator 8934edd4d7756c68 · data CreateAmmConfig · accounts CreateAmmConfigInstructionAccounts.
| Field | Type |
|---|---|
index | u16 |
trade_ | u64 |
protocol_ | u64 |
fund_ | u64 |
create_ | u64 |
creator_ | u64 |
Required accounts: 3; extras go to remaining.
Fields of CreateAmmConfigInstructionAccounts, in account order:
| # | Field | Type |
|---|---|---|
| 0 | owner | Pubkey |
| 1 | amm_config | Pubkey |
| 2 | system_ | Pubkey |
| 3… | remaining | Vec< |
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:
| # | Field | Type |
|---|---|---|
| 0 | owner | Pubkey |
| 1 | permission_ | Pubkey |
| 2 | permission | Pubkey |
| 3 | system_ | Pubkey |
| 4… | remaining | Vec< |
Deposit#
From the program's IDL:
Deposit lp token to the pool
Arguments
ctx- The context of accountslp_- Increased number of LPstoken_ amount maximum_- Maximum token 0 amount to deposit, prevents excessive slippagetoken_ 0_ amount maximum_- Maximum token 1 amount to deposit, prevents excessive slippagetoken_ 1_ amount
Discriminator f223c68952e1f2b6 · data Deposit · accounts DepositInstructionAccounts.
| Field | Type |
|---|---|
lp_ | u64 |
maximum_ | u64 |
maximum_ | u64 |
Required accounts: 13; extras go to remaining.
Fields of DepositInstructionAccounts, in account order:
| # | Field | Type |
|---|---|---|
| 0 | owner | Pubkey |
| 1 | authority | Pubkey |
| 2 | pool_state | Pubkey |
| 3 | owner_ | Pubkey |
| 4 | token0_ | Pubkey |
| 5 | token1_ | Pubkey |
| 6 | token0_ | Pubkey |
| 7 | token1_ | Pubkey |
| 8 | token_ | Pubkey |
| 9 | token_ | Pubkey |
| 10 | vault0_mint | Pubkey |
| 11 | vault1_mint | Pubkey |
| 12 | lp_mint | Pubkey |
| 13… | remaining | Vec< |
Initialize#
From the program's IDL:
Creates a pool for the given token pair and the initial price
Arguments
ctx- The context of accountsinit_- the initial amount_0 to depositamount_ 0 init_- the initial amount_1 to depositamount_ 1 open_time- the timestamp allowed for swap
Discriminator afaf6d1f0d989bed · data Initialize · accounts InitializeInstructionAccounts.
| Field | Type |
|---|---|
init_ | u64 |
init_ | u64 |
open_time | u64 |
Required accounts: 20; extras go to remaining.
Fields of InitializeInstructionAccounts, in account order:
| # | Field | Type |
|---|---|---|
| 0 | creator | Pubkey |
| 1 | amm_config | Pubkey |
| 2 | authority | Pubkey |
| 3 | pool_state | Pubkey |
| 4 | token0_mint | Pubkey |
| 5 | token1_mint | Pubkey |
| 6 | lp_mint | Pubkey |
| 7 | creator_ | Pubkey |
| 8 | creator_ | Pubkey |
| 9 | creator_ | Pubkey |
| 10 | token0_ | Pubkey |
| 11 | token1_ | Pubkey |
| 12 | create_ | Pubkey |
| 13 | observation_ | Pubkey |
| 14 | token_ | Pubkey |
| 15 | token0_ | Pubkey |
| 16 | token1_ | Pubkey |
| 17 | associated_ | Pubkey |
| 18 | system_ | Pubkey |
| 19 | rent | Pubkey |
| 20… | remaining | Vec< |
InitializeWithPermission#
From the program's IDL:
Create a pool with permission
Arguments
ctx- The context of accountsinit_- the initial amount_0 to depositamount_ 0 init_- the initial amount_1 to depositamount_ 1 open_time- the timestamp allowed for swapcreator_- creator fee model, 0:both token0 and token1 (depends on the input), 1: only token0, 2: only token1fee_ on
Discriminator 3f37fe4131b25979 · data InitializeWithPermission · accounts InitializeWithPermissionInstructionAccounts.
| Field | Type |
|---|---|
init_ | u64 |
init_ | u64 |
open_time | u64 |
creator_ | CreatorFeeOn |
Required accounts: 21; extras go to remaining.
Fields of InitializeWithPermissionInstructionAccounts, in account order:
| # | Field | Type |
|---|---|---|
| 0 | payer | Pubkey |
| 1 | creator | Pubkey |
| 2 | amm_config | Pubkey |
| 3 | authority | Pubkey |
| 4 | pool_state | Pubkey |
| 5 | token0_mint | Pubkey |
| 6 | token1_mint | Pubkey |
| 7 | lp_mint | Pubkey |
| 8 | payer_ | Pubkey |
| 9 | payer_ | Pubkey |
| 10 | payer_ | Pubkey |
| 11 | token0_ | Pubkey |
| 12 | token1_ | Pubkey |
| 13 | create_ | Pubkey |
| 14 | observation_ | Pubkey |
| 15 | permission | Pubkey |
| 16 | token_ | Pubkey |
| 17 | token0_ | Pubkey |
| 18 | token1_ | Pubkey |
| 19 | associated_ | Pubkey |
| 20 | system_ | Pubkey |
| 21… | remaining | Vec< |
SwapBaseInput#
From the program's IDL:
Swap the tokens in the pool base input amount
Arguments
ctx- The context of accountsamount_in- input amount to transfer, output to DESTINATION is based on the exchange rateminimum_- Minimum amount of output token, prevents excessive slippageamount_ out
Discriminator 8fbe5adac41e33de · data SwapBaseInput · accounts SwapBaseInputInstructionAccounts.
| Field | Type |
|---|---|
amount_in | u64 |
minimum_ | u64 |
Required accounts: 13; extras go to remaining.
Fields of SwapBaseInputInstructionAccounts, in account order:
| # | Field | Type |
|---|---|---|
| 0 | payer | Pubkey |
| 1 | authority | Pubkey |
| 2 | amm_config | Pubkey |
| 3 | pool_state | Pubkey |
| 4 | input_ | Pubkey |
| 5 | output_ | Pubkey |
| 6 | input_vault | Pubkey |
| 7 | output_ | Pubkey |
| 8 | input_ | Pubkey |
| 9 | output_ | Pubkey |
| 10 | input_ | Pubkey |
| 11 | output_ | Pubkey |
| 12 | observation_ | Pubkey |
| 13… | remaining | Vec< |
SwapBaseOutput#
From the program's IDL:
Swap the tokens in the pool base output amount
Arguments
ctx- The context of accountsmax_- input amount prevents excessive slippageamount_ in amount_out- amount of output token
Discriminator 37d96256a34ab4ad · data SwapBaseOutput · accounts SwapBaseOutputInstructionAccounts.
| Field | Type |
|---|---|
max_ | u64 |
amount_out | u64 |
Required accounts: 13; extras go to remaining.
Fields of SwapBaseOutputInstructionAccounts, in account order:
| # | Field | Type |
|---|---|---|
| 0 | payer | Pubkey |
| 1 | authority | Pubkey |
| 2 | amm_config | Pubkey |
| 3 | pool_state | Pubkey |
| 4 | input_ | Pubkey |
| 5 | output_ | Pubkey |
| 6 | input_vault | Pubkey |
| 7 | output_ | Pubkey |
| 8 | input_ | Pubkey |
| 9 | output_ | Pubkey |
| 10 | input_ | Pubkey |
| 11 | output_ | Pubkey |
| 12 | observation_ | Pubkey |
| 13… | remaining | Vec< |
UpdateAmmConfig#
From the program's IDL:
Updates the owner of the amm config
Must be called by the current owner or adminArguments
ctx- The context of accountstrade_- The new trade fee rate of amm config, be set whenfee_ rate paramis 0protocol_- The new protocol fee rate of amm config, be set whenfee_ rate paramis 1fund_- The new fund fee rate of amm config, be set whenfee_ rate paramis 2new_owner- The config's new owner, be set whenparamis 3new_- The config's new fund owner, be set whenfund_ owner paramis 4param- The value can be 0 | 1 | 2 | 3 | 4, otherwise will report a error
Discriminator 313cae889a1c74c8 · data UpdateAmmConfig · accounts UpdateAmmConfigInstructionAccounts.
| Field | Type |
|---|---|
param | u8 |
value | u64 |
Required accounts: 2; extras go to remaining.
Fields of UpdateAmmConfigInstructionAccounts, in account order:
| # | Field | Type |
|---|---|---|
| 0 | owner | Pubkey |
| 1 | amm_config | Pubkey |
| 2… | remaining | Vec< |
UpdatePoolStatus#
From the program's IDL:
Update pool status for given value
Arguments
ctx- The context of accountsstatus- The value of status
Discriminator 82576c062ee0757b · data UpdatePoolStatus · accounts UpdatePoolStatusInstructionAccounts.
| Field | Type |
|---|---|
status | u8 |
Required accounts: 2; extras go to remaining.
Fields of UpdatePoolStatusInstructionAccounts, in account order:
| # | Field | Type |
|---|---|---|
| 0 | authority | Pubkey |
| 1 | pool_state | Pubkey |
| 2… | remaining | Vec< |
Withdraw#
From the program's IDL:
Withdraw lp for token0 and token1
Arguments
ctx- The context of accountslp_- 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.token_ amount minimum_- Minimum amount of token 0 to receive, prevents excessive slippagetoken_ 0_ amount minimum_- Minimum amount of token 1 to receive, prevents excessive slippagetoken_ 1_ amount
Discriminator b712469c946da122 · data Withdraw · accounts WithdrawInstructionAccounts.
| Field | Type |
|---|---|
lp_ | u64 |
minimum_ | u64 |
minimum_ | u64 |
Required accounts: 14; extras go to remaining.
Fields of WithdrawInstructionAccounts, in account order:
| # | Field | Type |
|---|---|---|
| 0 | owner | Pubkey |
| 1 | authority | Pubkey |
| 2 | pool_state | Pubkey |
| 3 | owner_ | Pubkey |
| 4 | token0_ | Pubkey |
| 5 | token1_ | Pubkey |
| 6 | token0_ | Pubkey |
| 7 | token1_ | Pubkey |
| 8 | token_ | Pubkey |
| 9 | token_ | Pubkey |
| 10 | vault0_mint | Pubkey |
| 11 | vault1_mint | Pubkey |
| 12 | lp_mint | Pubkey |
| 13 | memo_ | Pubkey |
| 14… | remaining | Vec< |
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:
| # | Field | Type |
|---|---|---|
| 0 | program | Pubkey |
| 1 | event_ | Pubkey |
| 2… | remaining | Vec< |
Accounts#
Variants of RaydiumCpmmAccount. Each wraps a boxed struct from carbon_. decode_ only considers accounts owned by PROGRAM_ID and returns the first variant that matches.
AmmConfig#
Discriminator daf42168cbcb2b6f · accounts::.
| Field | Type | Description |
|---|---|---|
bump | u8 | Bump to identify PDA |
disable_ | bool | Status to control if new pool can be create |
index | u16 | Config index |
trade_ | u64 | The trade fee, denominated in hundredths of a bip (10^-6) |
protocol_ | u64 | The protocol fee |
fund_ | u64 | The fund fee, denominated in hundredths of a bip (10^-6) |
create_ | u64 | Fee for create a new pool |
protocol_ | Pubkey | Address of the protocol fee owner |
fund_owner | Pubkey | Address of the fund fee owner |
creator_ | u64 | The pool creator fee, denominated in hundredths of a bip (10^-6) |
padding | [u64; 15] | padding |
ObservationState#
Discriminator 7aaec5358109a584 · accounts::.
| Field | Type | Description |
|---|---|---|
initialized | bool | Whether the ObservationState is initialized |
observation_ | u16 | the most-recently updated index of the observations array |
pool_id | Pubkey | |
observations | [Observation; 100] | observation array |
last_ | u64 | the last update timestamp |
padding | [u64; 3] | padding for feature update |
Permission#
Discriminator e0531c4f0afda11c · accounts::.
| Field | Type | Description |
|---|---|---|
authority | Pubkey | authority |
padding | [u64; 30] | padding |
PoolState#
Discriminator f7ede3f5d7c3de46 · accounts::.
| Field | Type | Description |
|---|---|---|
amm_config | Pubkey | Which config the pool belongs |
pool_ | Pubkey | pool creator |
token0_ | Pubkey | Token A |
token1_ | Pubkey | Token B |
lp_mint | Pubkey | Pool tokens are issued when A or B tokens are deposited. Pool tokens can be withdrawn back to the original A or B token. |
token0_mint | Pubkey | Mint information for token A |
token1_mint | Pubkey | Mint information for token B |
token0_ | Pubkey | token_0 program |
token1_ | Pubkey | token_1 program |
observation_ | Pubkey | observation account to store oracle data |
auth_bump | u8 | |
status | u8 | Bitwise 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_ | u8 | |
mint0_ | u8 | mint0 and mint1 decimals |
mint1_ | u8 | |
lp_supply | u64 | True circulating supply without burns and lock ups |
protocol_ | u64 | The amounts of token_0 and token_1 that are owed to the liquidity provider. |
protocol_ | u64 | |
fund_ | u64 | |
fund_ | u64 | |
open_time | u64 | The timestamp allowed for swap in the pool. |
recent_ | u64 | recent epoch |
creator_ | u8 | Creator 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_ | bool | |
padding1 | [u8; 6] | |
creator_ | u64 | |
creator_ | u64 | |
padding | [u64; 28] | padding for future updates |
Events#
Structs in carbon_, also listed as variants of instructions::. Raydium CPMM logs these events with emit! rather than emitting them through a self-CPI, so read them with decode_ 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::.
| Field | Type | Description |
|---|---|---|
pool_id | Pubkey | |
lp_ | u64 | |
token0_ | u64 | pool vault sub trade fees |
token1_ | u64 | pool vault sub trade fees |
token0_ | u64 | calculate result without transfer fee |
token1_ | u64 | calculate result without transfer fee |
token0_ | u64 | |
token1_ | u64 | |
change_type | u8 |
SwapEvent#
Discriminator 40c6cde8260871e2 · events::.
| Field | Type | Description |
|---|---|---|
pool_id | Pubkey | |
input_ | u64 | pool vault sub trade fees |
output_ | u64 | pool vault sub trade fees |
input_ | u64 | calculate result without transfer fee |
output_ | u64 | calculate result without transfer fee |
input_ | u64 | |
output_ | u64 | |
base_input | bool | |
input_mint | Pubkey | |
output_mint | Pubkey | |
trade_fee | u64 | |
creator_fee | u64 | Amount of fee tokens going to creator |
creator_ | bool |
Types#
Types used by the instructions, accounts and events above, exported from carbon_.
CreatorFeeOn#
Enum types::.
| Variant |
|---|
BothToken |
OnlyToken0 |
OnlyToken1 |
LpChangeEvent#
From the program's IDL:
Emitted when deposit and withdraw
Struct types::. Same fields as the LpChangeEvent event.
Observation#
From the program's IDL:
The element of observations in ObservationState
Struct types::.
| Field | Type | Description |
|---|---|---|
block_ | u64 | The block timestamp of the observation |
cumulative_ | u128 | the cumulative of token0 price during the duration time, Q32.32, the remaining 64 bit for overflow |
cumulative_ | u128 | the 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::. Same fields as the SwapEvent event.