Raydium CLMM decoder
Decode Raydium CLMM instructions, accounts and events in Rust with carbon-raydium-clmm-decoder 2.0.0. Program ID CAMMCzo5YL8w4VFF8KVHrK22GGUsp5VTaW7grrKgrWqK.
On this page
carbon-raydium-clmm-decoder decodes the instructions, accounts and events of the Raydium CLMM program (CAMMCzo5YL8w4VFF8KVHrK22GGUsp5VTaW7grrKgrWqK): 34 instructions, 12 account types, 15 events. It is generated with Codama from the program's IDL; see decoders for how decoders plug into a pipeline.
| Crate | carbon-raydium-clmm-decoder 2.0.0 |
| Install | cargo add carbon-raydium-clmm-decoder@2. |
| Program ID | CAMMCzo5YL8w4VFF8KVHrK22GGUsp5VTaW7grrKgrWqK (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-clmm-decoder/2.0.0 |
| Source | decoders/raydium-clmm-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 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 CLMM transactions from the public RPC and prints every decoded Swap instruction. Add the dependencies:
cargo add carbon-core@2.0.0 carbon-raydium-clmm-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_clmm_decoder::{
instructions::RaydiumClmmInstruction, RaydiumClmmDecoder, 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(RaydiumClmmDecoder, InstructionLogger)
.build()?
.run()
.await
}
struct InstructionLogger;
impl Processor<InstructionProcessorInputType<'_, RaydiumClmmInstruction>> for InstructionLogger {
async fn process(
&mut self,
input: &InstructionProcessorInputType<'_, RaydiumClmmInstruction>,
) -> CarbonResult<()> {
let signature = input.metadata.transaction_metadata.signature;
if let RaydiumClmmInstruction::Swap { data, accounts, .. } = input.decoded_instruction {
println!("swap {signature}: {data:?} payer={}", accounts.payer);
}
Ok(())
}
}RUST_LOG=info cargo runEach 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 RaydiumClmmInstruction:: (import instructions::); see Events. If CpiEvent never arrives, the program logs its events with emit! instead: decode them with decode_.
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_clmm_decoder::{accounts::RaydiumClmmAccount, RaydiumClmmDecoder, 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(RaydiumClmmDecoder, AccountLogger)
.build()?
.run()
.await
}
struct AccountLogger;
impl Processor<AccountProcessorInputType<'_, RaydiumClmmAccount>> for AccountLogger {
async fn process(
&mut self,
input: &AccountProcessorInputType<'_, RaydiumClmmAccount>,
) -> CarbonResult<()> {
if let RaydiumClmmAccount::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 RaydiumClmmInstruction. Each is RaydiumClmmInstruction::, 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
CAMMCzo5YL8w4VFF8KVHrK22GGUsp5VTaW7grrKgrWqK. - 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.
CloseLimitOrder#
From the program's IDL:
Close a limit order
Closes the limit order account when unfilled amount is zeroArguments
ctx- The context of accounts
Discriminator 4c7c800fd55725fa · data CloseLimitOrder · accounts CloseLimitOrderInstructionAccounts.
No data fields.
Required accounts: 3; extras go to remaining.
Fields of CloseLimitOrderInstructionAccounts, in account order:
| # | Field | Type |
|---|---|---|
| 0 | signer | Pubkey |
| 1 | rent_ | Pubkey |
| 2 | limit_order | Pubkey |
| 3… | remaining | Vec< |
ClosePosition#
From the program's IDL:
Close the user's position and NFT account. If the NFT mint belongs to token2022, it will also be closed and the funds returned to the NFT owner. # Arguments
ctx- The context of accounts
Discriminator 7b86510031446262 · data ClosePosition · accounts ClosePositionInstructionAccounts.
No data fields.
Required accounts: 6; extras go to remaining.
Fields of ClosePositionInstructionAccounts, in account order:
| # | Field | Type |
|---|---|---|
| 0 | nft_owner | Pubkey |
| 1 | position_ | Pubkey |
| 2 | position_ | Pubkey |
| 3 | personal_ | Pubkey |
| 4 | system_ | Pubkey |
| 5 | token_ | Pubkey |
| 6… | remaining | Vec< |
CloseProtocolPosition#
From the program's IDL:
The CLMM protocol decides to discard the protocol position account, which can reduce users' opening costs. After the original protocol position account is closed, the gas fee will be refunded to the user who created it. # Arguments
ctx- The context of accounts
Discriminator c975989055556cb2 · data CloseProtocolPosition · accounts CloseProtocolPositionInstructionAccounts.
No data fields.
Required accounts: 2; extras go to remaining.
Fields of CloseProtocolPositionInstructionAccounts, in account order:
| # | Field | Type |
|---|---|---|
| 0 | admin | Pubkey |
| 1 | protocol_ | Pubkey |
| 2… | 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: 11; extras go to remaining.
Fields of CollectFundFeeInstructionAccounts, in account order:
| # | Field | Type |
|---|---|---|
| 0 | owner | Pubkey |
| 1 | pool_state | Pubkey |
| 2 | amm_config | Pubkey |
| 3 | token_ | Pubkey |
| 4 | token_ | Pubkey |
| 5 | vault0_mint | Pubkey |
| 6 | vault1_mint | Pubkey |
| 7 | recipient_ | Pubkey |
| 8 | recipient_ | Pubkey |
| 9 | token_ | Pubkey |
| 10 | token_ | Pubkey |
| 11… | 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: 11; extras go to remaining.
Fields of CollectProtocolFeeInstructionAccounts, in account order:
| # | Field | Type |
|---|---|---|
| 0 | owner | Pubkey |
| 1 | pool_state | Pubkey |
| 2 | amm_config | Pubkey |
| 3 | token_ | Pubkey |
| 4 | token_ | Pubkey |
| 5 | vault0_mint | Pubkey |
| 6 | vault1_mint | Pubkey |
| 7 | recipient_ | Pubkey |
| 8 | recipient_ | Pubkey |
| 9 | token_ | Pubkey |
| 10 | token_ | Pubkey |
| 11… | remaining | Vec< |
CollectRemainingRewards#
From the program's IDL:
Collect remaining reward token for reward founder
Arguments
ctx- The context of accountsreward_- the index to reward infoindex
Discriminator 12eda6c52210d590 · data CollectRemainingRewards · accounts CollectRemainingRewardsInstructionAccounts.
| Field | Type |
|---|---|
reward_ | u8 |
Required accounts: 8; extras go to remaining.
Fields of CollectRemainingRewardsInstructionAccounts, in account order:
| # | Field | Type |
|---|---|---|
| 0 | reward_ | Pubkey |
| 1 | funder_ | Pubkey |
| 2 | pool_state | Pubkey |
| 3 | reward_ | Pubkey |
| 4 | reward_ | Pubkey |
| 5 | token_ | Pubkey |
| 6 | token_ | Pubkey |
| 7 | memo_ | Pubkey |
| 8… | 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.tick_- The tickspacing binding with config, cannot be changed.spacing 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 limit_- The rate of limit order fee.fee_ rate
Discriminator 8934edd4d7756c68 · data CreateAmmConfig · accounts CreateAmmConfigInstructionAccounts.
| Field | Type |
|---|---|
index | u16 |
tick_ | u16 |
trade_ | u32 |
protocol_ | u32 |
fund_ | u32 |
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< |
CreateCustomizablePool#
From the program's IDL:
Creates a pool for the given token pair with customizable parameters
Arguments
ctx- The context of accountscustomizable_- the customizable parametersparams
Discriminator 2b44d4a7592fa401 · data CreateCustomizablePool · accounts CreateCustomizablePoolInstructionAccounts.
| Field | Type |
|---|---|
customizable_ | CreateCustomizableParams |
Required accounts: 13; extras go to remaining.
Fields of CreateCustomizablePoolInstructionAccounts, in account order:
| # | Field | Type |
|---|---|---|
| 0 | pool_ | Pubkey |
| 1 | amm_config | Pubkey |
| 2 | pool_state | Pubkey |
| 3 | token_mint0 | Pubkey |
| 4 | token_mint1 | Pubkey |
| 5 | token_ | Pubkey |
| 6 | token_ | Pubkey |
| 7 | observation_ | Pubkey |
| 8 | tick_ | Pubkey |
| 9 | token_ | Pubkey |
| 10 | token_ | Pubkey |
| 11 | system_ | Pubkey |
| 12 | rent | Pubkey |
| 13… | remaining | Vec< |
CreateDynamicFeeConfig#
From the program's IDL:
Create dynamic fee config
Arguments
ctx- The context of accountsindex- The index of dynamic fee configfilter_- The period of filterperiod decay_- The period of decayperiod reduction_- The reduction factorfactor adaptive_- The adaptive fee control factorfee_ control_ factor max_- The max volatility accumulatorvolatility_ accumulator tick_- The tick group sizegroup_ size
Discriminator bd0eb5785576e33e · data CreateDynamicFeeConfig · accounts CreateDynamicFeeConfigInstructionAccounts.
| Field | Type |
|---|---|
index | u16 |
filter_ | u16 |
decay_ | u16 |
reduction_ | u16 |
dynamic_ | u32 |
max_ | u32 |
Required accounts: 3; extras go to remaining.
Fields of CreateDynamicFeeConfigInstructionAccounts, in account order:
| # | Field | Type |
|---|---|---|
| 0 | owner | Pubkey |
| 1 | dynamic_ | Pubkey |
| 2 | system_ | Pubkey |
| 3… | remaining | Vec< |
CreateOperationAccount#
From the program's IDL:
Creates an operation account for the program
Arguments
ctx- The context of accounts
Discriminator 3f5794216d230868 · data CreateOperationAccount · accounts CreateOperationAccountInstructionAccounts.
No data fields.
Required accounts: 3; extras go to remaining.
Fields of CreateOperationAccountInstructionAccounts, in account order:
| # | Field | Type |
|---|---|---|
| 0 | owner | Pubkey |
| 1 | operation_ | Pubkey |
| 2 | system_ | Pubkey |
| 3… | remaining | Vec< |
CreatePool#
From the program's IDL:
Creates a pool for the given token pair and the initial price
Arguments
ctx- The context of accountssqrt_- the initial sqrt price (amount_token_1 / amount_token_0) of the pool as a Q64.64price_ x64 Note: The open_time must be smaller than the current block_timestamp on chain.
Discriminator e992d18ecf6840bc · data CreatePool · accounts CreatePoolInstructionAccounts.
| Field | Type |
|---|---|
sqrt_ | u128 |
open_time | u64 |
Required accounts: 13; extras go to remaining.
Fields of CreatePoolInstructionAccounts, in account order:
| # | Field | Type |
|---|---|---|
| 0 | pool_ | Pubkey |
| 1 | amm_config | Pubkey |
| 2 | pool_state | Pubkey |
| 3 | token_mint0 | Pubkey |
| 4 | token_mint1 | Pubkey |
| 5 | token_ | Pubkey |
| 6 | token_ | Pubkey |
| 7 | observation_ | Pubkey |
| 8 | tick_ | Pubkey |
| 9 | token_ | Pubkey |
| 10 | token_ | Pubkey |
| 11 | system_ | Pubkey |
| 12 | rent | Pubkey |
| 13… | remaining | Vec< |
CreateSupportMintAssociated#
From the program's IDL:
Create support token22 mint account which can create pool and send rewards while ignoring unsupported extensions.
Discriminator 11fb415c88f20ea9 · data CreateSupportMintAssociated · accounts CreateSupportMintAssociatedInstructionAccounts.
No data fields.
Required accounts: 4; extras go to remaining.
Fields of CreateSupportMintAssociatedInstructionAccounts, in account order:
| # | Field | Type |
|---|---|---|
| 0 | owner | Pubkey |
| 1 | token_mint | Pubkey |
| 2 | support_ | Pubkey |
| 3 | system_ | Pubkey |
| 4… | remaining | Vec< |
DecreaseLimitOrder#
From the program's IDL:
Decrease/Cancel a limit order
First settle the filled portion of the order; only the remaining unfilled amount can be decreased. Even if the specified amount is very large, the decrease will not exceed the remaining unfilled order amount.
It is recommended to call thesettle_instruction before invoking this instruction to settle any filled portions of the order.limit_ order
Make sure to check your order's remaining unfilled amount.Arguments
ctx- The context of accountsamount- The decrease amount of the order,amount_min- The minimum amount of the order, which serves as a slippage check
Discriminator 759d3c674231a300 · data DecreaseLimitOrder · accounts DecreaseLimitOrderInstructionAccounts.
| Field | Type |
|---|---|
amount | u64 |
amount_min | u64 |
Required accounts: 12; extras go to remaining.
Fields of DecreaseLimitOrderInstructionAccounts, in account order:
| # | Field | Type |
|---|---|---|
| 0 | owner | Pubkey |
| 1 | pool_state | Pubkey |
| 2 | tick_array | Pubkey |
| 3 | limit_order | Pubkey |
| 4 | input_ | Pubkey |
| 5 | output_ | Pubkey |
| 6 | input_vault | Pubkey |
| 7 | output_ | Pubkey |
| 8 | input_ | Pubkey |
| 9 | output_ | Pubkey |
| 10 | token_ | Pubkey |
| 11 | token_ | Pubkey |
| 12… | remaining | Vec< |
DecreaseLiquidity#
From the program's IDL:
#[deprecated(note = "Usedecrease_liquidity_v2instead.Decreases liquidity for an existing position")] Arguments
ctx- The context of accountsliquidity- The amount by which liquidity will be decreasedamount_- The minimum amount of token_0 that should be accounted for the burned liquidity0_ min amount_- The minimum amount of token_1 that should be accounted for the burned liquidity1_ min
Discriminator a026d06f685b2c01 · data DecreaseLiquidity · accounts DecreaseLiquidityInstructionAccounts.
| Field | Type |
|---|---|
liquidity | u128 |
amount0_min | u64 |
amount1_min | u64 |
Required accounts: 12; extras go to remaining.
Fields of DecreaseLiquidityInstructionAccounts, in account order:
| # | Field | Type |
|---|---|---|
| 0 | nft_owner | Pubkey |
| 1 | nft_account | Pubkey |
| 2 | personal_ | Pubkey |
| 3 | pool_state | Pubkey |
| 4 | protocol_ | Pubkey |
| 5 | token_ | Pubkey |
| 6 | token_ | Pubkey |
| 7 | tick_ | Pubkey |
| 8 | tick_ | Pubkey |
| 9 | recipient_ | Pubkey |
| 10 | recipient_ | Pubkey |
| 11 | token_ | Pubkey |
| 12… | remaining | Vec< |
DecreaseLiquidityV2#
From the program's IDL:
Decreases liquidity for an existing position, support Token2022
Arguments
ctx- The context of accountsliquidity- The amount by which liquidity will be decreasedamount_- The minimum amount of token_0 that should be accounted for the burned liquidity0_ min amount_- The minimum amount of token_1 that should be accounted for the burned liquidity1_ min
Discriminator 3a7fbc3e4f52c460 · data DecreaseLiquidityV2 · accounts DecreaseLiquidityV2InstructionAccounts.
| Field | Type |
|---|---|
liquidity | u128 |
amount0_min | u64 |
amount1_min | u64 |
Required accounts: 16; extras go to remaining.
Fields of DecreaseLiquidityV2InstructionAccounts, in account order:
| # | Field | Type |
|---|---|---|
| 0 | nft_owner | Pubkey |
| 1 | nft_account | Pubkey |
| 2 | personal_ | Pubkey |
| 3 | pool_state | Pubkey |
| 4 | protocol_ | Pubkey |
| 5 | token_ | Pubkey |
| 6 | token_ | Pubkey |
| 7 | tick_ | Pubkey |
| 8 | tick_ | Pubkey |
| 9 | recipient_ | Pubkey |
| 10 | recipient_ | Pubkey |
| 11 | token_ | Pubkey |
| 12 | token_ | Pubkey |
| 13 | memo_ | Pubkey |
| 14 | vault0_mint | Pubkey |
| 15 | vault1_mint | Pubkey |
| 16… | remaining | Vec< |
IncreaseLimitOrder#
From the program's IDL:
Increase a limit order
Arguments
ctx- The context of accountsamount- The increase amount of the orderis_increase- The direction of the order, true: increase, false: decrease
Discriminator b19059ecfaba7d63 · data IncreaseLimitOrder · accounts IncreaseLimitOrderInstructionAccounts.
| Field | Type |
|---|---|
amount | u64 |
Required accounts: 8; extras go to remaining.
Fields of IncreaseLimitOrderInstructionAccounts, in account order:
| # | Field | Type |
|---|---|---|
| 0 | owner | Pubkey |
| 1 | pool_state | Pubkey |
| 2 | tick_array | Pubkey |
| 3 | limit_order | Pubkey |
| 4 | input_ | Pubkey |
| 5 | input_vault | Pubkey |
| 6 | input_ | Pubkey |
| 7 | input_ | Pubkey |
| 8… | remaining | Vec< |
IncreaseLiquidity#
From the program's IDL:
#[deprecated(note = "Useincrease_liquidity_v2instead.Increases liquidity for an existing position, with amount paid by")] payerArguments
ctx- The context of accountsliquidity- The desired liquidity to be added, can't be zeroamount_- The max amount of token_0 to spend, which serves as a slippage check0_ max amount_- The max amount of token_1 to spend, which serves as a slippage check1_ max
Discriminator 2e9cf3760dcdfbb2 · data IncreaseLiquidity · accounts IncreaseLiquidityInstructionAccounts.
| Field | Type |
|---|---|
liquidity | u128 |
amount0_max | u64 |
amount1_max | u64 |
Required accounts: 12; extras go to remaining.
Fields of IncreaseLiquidityInstructionAccounts, in account order:
| # | Field | Type |
|---|---|---|
| 0 | nft_owner | Pubkey |
| 1 | nft_account | Pubkey |
| 2 | pool_state | Pubkey |
| 3 | protocol_ | Pubkey |
| 4 | personal_ | Pubkey |
| 5 | tick_ | Pubkey |
| 6 | tick_ | Pubkey |
| 7 | token_ | Pubkey |
| 8 | token_ | Pubkey |
| 9 | token_ | Pubkey |
| 10 | token_ | Pubkey |
| 11 | token_ | Pubkey |
| 12… | remaining | Vec< |
IncreaseLiquidityV2#
From the program's IDL:
Increases liquidity for an existing position, with amount paid by
payer, support Token2022 # Arguments
ctx- The context of accountsliquidity- The desired liquidity to be added, if zero, calculate liquidity base amount_0 or amount_1 according base_flagamount_- The max amount of token_0 to spend, which serves as a slippage check0_ max amount_- The max amount of token_1 to spend, which serves as a slippage check1_ max base_flag- must be specified if liquidity is zero, true: calculate liquidity base amount_0_max otherwise base amount_1_max
Discriminator 851d59df45eeb00a · data IncreaseLiquidityV2 · accounts IncreaseLiquidityV2InstructionAccounts.
| Field | Type |
|---|---|
liquidity | u128 |
amount0_max | u64 |
amount1_max | u64 |
base_flag | Option< |
Required accounts: 15; extras go to remaining.
Fields of IncreaseLiquidityV2InstructionAccounts, in account order:
| # | Field | Type |
|---|---|---|
| 0 | nft_owner | Pubkey |
| 1 | nft_account | Pubkey |
| 2 | pool_state | Pubkey |
| 3 | protocol_ | Pubkey |
| 4 | personal_ | Pubkey |
| 5 | tick_ | Pubkey |
| 6 | tick_ | Pubkey |
| 7 | token_ | Pubkey |
| 8 | token_ | Pubkey |
| 9 | token_ | Pubkey |
| 10 | token_ | Pubkey |
| 11 | token_ | Pubkey |
| 12 | token_ | Pubkey |
| 13 | vault0_mint | Pubkey |
| 14 | vault1_mint | Pubkey |
| 15… | remaining | Vec< |
InitializeReward#
From the program's IDL:
Initialize a reward info for a given pool and reward index
Arguments
ctx- The context of accountsreward_- the index to reward infoindex open_time- reward open timestampend_time- reward end timestampemissions_- Token reward per second are earned per unit of liquidity.per_ second_ x64
Discriminator 5f87c0c4f281e644 · data InitializeReward · accounts InitializeRewardInstructionAccounts.
| Field | Type |
|---|---|
param | InitializeRewardParam |
Required accounts: 10; extras go to remaining.
Fields of InitializeRewardInstructionAccounts, in account order:
| # | Field | Type |
|---|---|---|
| 0 | reward_ | Pubkey |
| 1 | funder_ | Pubkey |
| 2 | amm_config | Pubkey |
| 3 | pool_state | Pubkey |
| 4 | operation_ | Pubkey |
| 5 | reward_ | Pubkey |
| 6 | reward_ | Pubkey |
| 7 | reward_ | Pubkey |
| 8 | system_ | Pubkey |
| 9 | rent | Pubkey |
| 10… | remaining | Vec< |
OpenLimitOrder#
From the program's IDL:
Place a limit order
Arguments
ctx- The context of accountsnonce_index- The limit order nonce account index, used to create user's order nonce PDA account.zero_- The direction of the order, true: zero for one, false:for_ one
one for zerotick_index- The index of the tickamount- The amount of the orderwith_- The flag indicating whether to create NFT mint metadatametadata
Discriminator 9d20dab7471d1293 · data OpenLimitOrder · accounts OpenLimitOrderInstructionAccounts.
| Field | Type |
|---|---|
nonce_index | u8 |
zero_ | bool |
tick_index | i32 |
amount | u64 |
Required accounts: 10; extras go to remaining.
Fields of OpenLimitOrderInstructionAccounts, in account order:
| # | Field | Type |
|---|---|---|
| 0 | payer | Pubkey |
| 1 | pool_state | Pubkey |
| 2 | tick_array | Pubkey |
| 3 | limit_ | Pubkey |
| 4 | limit_order | Pubkey |
| 5 | input_ | Pubkey |
| 6 | input_vault | Pubkey |
| 7 | input_ | Pubkey |
| 8 | input_ | Pubkey |
| 9 | system_ | Pubkey |
| 10… | remaining | Vec< |
OpenPosition#
From the program's IDL:
#[deprecated(note = "Useopen_position_with_token22_nftinstead.Creates a new position wrapped in a NFT")] Arguments
ctx- The context of accountstick_- The low boundary of marketlower_ index tick_- The upper boundary of marketupper_ index tick_- The start index of tick array which includes tick lowarray_ lower_ start_ index tick_- The start index of tick array which includes tick upperarray_ upper_ start_ index liquidity- The liquidity to be addedamount_- The max amount of token_0 to spend, which serves as a slippage check0_ max amount_- The max amount of token_1 to spend, which serves as a slippage check1_ max
Discriminator 87802f4d0f98f031 · data OpenPosition · accounts OpenPositionInstructionAccounts.
| Field | Type |
|---|---|
tick_ | i32 |
tick_ | i32 |
tick_ | i32 |
tick_ | i32 |
liquidity | u128 |
amount0_max | u64 |
amount1_max | u64 |
Required accounts: 19; extras go to remaining.
Fields of OpenPositionInstructionAccounts, in account order:
| # | Field | Type |
|---|---|---|
| 0 | payer | Pubkey |
| 1 | position_ | Pubkey |
| 2 | position_ | Pubkey |
| 3 | position_ | Pubkey |
| 4 | metadata_ | Pubkey |
| 5 | pool_state | Pubkey |
| 6 | protocol_ | Pubkey |
| 7 | tick_ | Pubkey |
| 8 | tick_ | Pubkey |
| 9 | personal_ | Pubkey |
| 10 | token_ | Pubkey |
| 11 | token_ | Pubkey |
| 12 | token_ | Pubkey |
| 13 | token_ | Pubkey |
| 14 | rent | Pubkey |
| 15 | system_ | Pubkey |
| 16 | token_ | Pubkey |
| 17 | associated_ | Pubkey |
| 18 | metadata_ | Pubkey |
| 19… | remaining | Vec< |
OpenPositionV2#
From the program's IDL:
#[deprecated(note = "Useopen_position_with_token22_nftinstead.Creates a new position wrapped in a NFT, support Token2022")] Arguments
ctx- The context of accountstick_- The low boundary of marketlower_ index tick_- The upper boundary of marketupper_ index tick_- The start index of tick array which includes tick lowarray_ lower_ start_ index tick_- The start index of tick array which includes tick upperarray_ upper_ start_ index liquidity- The liquidity to be added, if zero, and the base_flag is specified, calculate liquidity base amount_0_max or amount_1_max according base_flag, otherwise open position with zero liquidityamount_- The max amount of token_0 to spend, which serves as a slippage check0_ max amount_- The max amount of token_1 to spend, which serves as a slippage check1_ max with_- The flag indicating whether to create NFT mint metadatametadata base_flag- if the liquidity specified as zero, true: calculate liquidity base amount_0_max otherwise base amount_1_max
Discriminator 4db84ad67056f1c7 · data OpenPositionV2 · accounts OpenPositionV2InstructionAccounts.
| Field | Type |
|---|---|
tick_ | i32 |
tick_ | i32 |
tick_ | i32 |
tick_ | i32 |
liquidity | u128 |
amount0_max | u64 |
amount1_max | u64 |
with_ | bool |
base_flag | Option< |
Required accounts: 22; extras go to remaining.
Fields of OpenPositionV2InstructionAccounts, in account order:
| # | Field | Type |
|---|---|---|
| 0 | payer | Pubkey |
| 1 | position_ | Pubkey |
| 2 | position_ | Pubkey |
| 3 | position_ | Pubkey |
| 4 | metadata_ | Pubkey |
| 5 | pool_state | Pubkey |
| 6 | protocol_ | Pubkey |
| 7 | tick_ | Pubkey |
| 8 | tick_ | Pubkey |
| 9 | personal_ | Pubkey |
| 10 | token_ | Pubkey |
| 11 | token_ | Pubkey |
| 12 | token_ | Pubkey |
| 13 | token_ | Pubkey |
| 14 | rent | Pubkey |
| 15 | system_ | Pubkey |
| 16 | token_ | Pubkey |
| 17 | associated_ | Pubkey |
| 18 | metadata_ | Pubkey |
| 19 | token_ | Pubkey |
| 20 | vault0_mint | Pubkey |
| 21 | vault1_mint | Pubkey |
| 22… | remaining | Vec< |
OpenPositionWithToken22Nft#
From the program's IDL:
Creates a new position wrapped in a Token2022 NFT without relying on metadata_program and metadata_account, reduce the cost for user to create a personal position. # Arguments
ctx- The context of accountstick_- The low boundary of marketlower_ index tick_- The upper boundary of marketupper_ index tick_- The start index of tick array which includes tick lowarray_ lower_ start_ index tick_- The start index of tick array which includes tick upperarray_ upper_ start_ index liquidity- The liquidity to be added, if zero, and the base_flag is specified, calculate liquidity base amount_0_max or amount_1_max according base_flag, otherwise open position with zero liquidityamount_- The max amount of token_0 to spend, which serves as a slippage check0_ max amount_- The max amount of token_1 to spend, which serves as a slippage check1_ max with_- The flag indicating whether to create NFT mint metadatametadata base_flag- if the liquidity specified as zero, true: calculate liquidity base amount_0_max otherwise base amount_1_max
Discriminator 4dffae527d1dc92e · data OpenPositionWithToken22Nft · accounts OpenPositionWithToken22NftInstructionAccounts.
| Field | Type |
|---|---|
tick_ | i32 |
tick_ | i32 |
tick_ | i32 |
tick_ | i32 |
liquidity | u128 |
amount0_max | u64 |
amount1_max | u64 |
with_ | bool |
base_flag | Option< |
Required accounts: 20; extras go to remaining.
Fields of OpenPositionWithToken22NftInstructionAccounts, in account order:
| # | Field | Type |
|---|---|---|
| 0 | payer | Pubkey |
| 1 | position_ | Pubkey |
| 2 | position_ | Pubkey |
| 3 | position_ | Pubkey |
| 4 | pool_state | Pubkey |
| 5 | protocol_ | Pubkey |
| 6 | tick_ | Pubkey |
| 7 | tick_ | Pubkey |
| 8 | personal_ | Pubkey |
| 9 | token_ | Pubkey |
| 10 | token_ | Pubkey |
| 11 | token_ | Pubkey |
| 12 | token_ | Pubkey |
| 13 | rent | Pubkey |
| 14 | system_ | Pubkey |
| 15 | token_ | Pubkey |
| 16 | associated_ | Pubkey |
| 17 | token_ | Pubkey |
| 18 | vault0_mint | Pubkey |
| 19 | vault1_mint | Pubkey |
| 20… | remaining | Vec< |
SetRewardParams#
From the program's IDL:
Reset reward param, start a new reward cycle or extend the current cycle.
Arguments
ctx- The context of accountsreward_- The index of reward token in the pool.index emissions_- The per second emission reward, when extend the current cycle,per_ second_ x64 new value can't be less than old value
open_time- reward open timestamp, must be set when starting a new cycleend_time- reward end timestamp
Discriminator 7034a74b20c9d389 · data SetRewardParams · accounts SetRewardParamsInstructionAccounts.
| Field | Type |
|---|---|
reward_ | u8 |
emissions_ | u128 |
open_time | u64 |
end_time | u64 |
Required accounts: 6; extras go to remaining.
Fields of SetRewardParamsInstructionAccounts, in account order:
| # | Field | Type |
|---|---|---|
| 0 | authority | Pubkey |
| 1 | amm_config | Pubkey |
| 2 | pool_state | Pubkey |
| 3 | operation_ | Pubkey |
| 4 | token_ | Pubkey |
| 5 | token_ | Pubkey |
| 6… | remaining | Vec< |
SettleLimitOrder#
From the program's IDL:
Settle a limit order
Arguments
ctx- The context of accounts
Discriminator cd4e74215c691a60 · data SettleLimitOrder · accounts SettleLimitOrderInstructionAccounts.
No data fields.
Required accounts: 8; extras go to remaining.
Fields of SettleLimitOrderInstructionAccounts, in account order:
| # | Field | Type |
|---|---|---|
| 0 | signer | Pubkey |
| 1 | pool_state | Pubkey |
| 2 | tick_array | Pubkey |
| 3 | limit_order | Pubkey |
| 4 | output_ | Pubkey |
| 5 | output_ | Pubkey |
| 6 | output_ | Pubkey |
| 7 | output_ | Pubkey |
| 8… | remaining | Vec< |
Swap#
From the program's IDL:
#[deprecated(note = "Useswap_v2instead.Swaps one token for as much as possible of another token across a single pool # Arguments")]
ctx- The context of accountsamount- Arranged in pairs with other_amount_threshold. (amount_in, amount_out_minimum) or (amount_out, amount_in_maximum)other_- For slippage checkamount_ threshold sqrt_- The Q64.64 sqrt price √P limit. If zero for one, the price cannotprice_ limit is_- swap base input or swap base outputbase_ input
Discriminator f8c69e91e17587c8 · data Swap · accounts SwapInstructionAccounts.
| Field | Type |
|---|---|
amount | u64 |
other_ | u64 |
sqrt_ | u128 |
is_ | bool |
Required accounts: 10; extras go to remaining.
Fields of SwapInstructionAccounts, in account order:
| # | Field | Type |
|---|---|---|
| 0 | payer | Pubkey |
| 1 | amm_config | Pubkey |
| 2 | pool_state | Pubkey |
| 3 | input_ | Pubkey |
| 4 | output_ | Pubkey |
| 5 | input_vault | Pubkey |
| 6 | output_ | Pubkey |
| 7 | observation_ | Pubkey |
| 8 | token_ | Pubkey |
| 9 | tick_array | Pubkey |
| 10… | remaining | Vec< |
SwapRouterBaseIn#
From the program's IDL:
Swap token for as much as possible of another token across the path provided, base input # Arguments
ctx- The context of accountsamount_in- Token amount to be swapped inamount_- Panic if output amount is below minimum amount. For slippage.out_ minimum
Discriminator 457d73daf5baf2c4 · data SwapRouterBaseIn · accounts SwapRouterBaseInInstructionAccounts.
| Field | Type |
|---|---|
amount_in | u64 |
amount_ | u64 |
Required accounts: 6; extras go to remaining.
Fields of SwapRouterBaseInInstructionAccounts, in account order:
| # | Field | Type |
|---|---|---|
| 0 | payer | Pubkey |
| 1 | input_ | Pubkey |
| 2 | input_ | Pubkey |
| 3 | token_ | Pubkey |
| 4 | token_ | Pubkey |
| 5 | memo_ | Pubkey |
| 6… | remaining | Vec< |
SwapV2#
From the program's IDL:
Swaps one token for as much as possible of another token across a single pool, support token program 2022 # Arguments
ctx- The context of accountsamount- Arranged in pairs with other_amount_threshold. (amount_in, amount_out_minimum) or (amount_out, amount_in_maximum)other_- For slippage checkamount_ threshold sqrt_- The Q64.64 sqrt price √P limit. If zero for one, the price cannotprice_ limit is_- swap base input or swap base outputbase_ input
Discriminator 2b04ed0b1ac91e62 · data SwapV2 · accounts SwapV2InstructionAccounts.
| Field | Type |
|---|---|
amount | u64 |
other_ | u64 |
sqrt_ | u128 |
is_ | bool |
Required accounts: 13; extras go to remaining.
Fields of SwapV2InstructionAccounts, in account order:
| # | Field | Type |
|---|---|---|
| 0 | payer | Pubkey |
| 1 | amm_config | Pubkey |
| 2 | pool_state | Pubkey |
| 3 | input_ | Pubkey |
| 4 | output_ | Pubkey |
| 5 | input_vault | Pubkey |
| 6 | output_ | Pubkey |
| 7 | observation_ | Pubkey |
| 8 | token_ | Pubkey |
| 9 | token_ | Pubkey |
| 10 | memo_ | Pubkey |
| 11 | input_ | Pubkey |
| 12 | output_ | Pubkey |
| 13… | remaining | Vec< |
TransferRewardOwner#
From the program's IDL:
Transfer reward owner
Arguments
ctx- The context of accountsnew_owner- new owner pubkey
Discriminator 07160c53f22b3079 · data TransferRewardOwner · accounts TransferRewardOwnerInstructionAccounts.
| Field | Type |
|---|---|
new_owner | Pubkey |
Required accounts: 2; extras go to remaining.
Fields of TransferRewardOwnerInstructionAccounts, in account order:
| # | Field | Type |
|---|---|---|
| 0 | authority | Pubkey |
| 1 | pool_state | Pubkey |
| 2… | 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 4limit_- The new limit protocol fee rate of amm config, be set whenprotocol_ fee_ rate paramis 5limit_- The new limit fund fee rate of amm config, be set whenfund_ fee_ rate paramis 6param- The value can be 0 | 1 | 2 | 3 | 4 | 5 | 6, otherwise will report an error
Discriminator 313cae889a1c74c8 · data UpdateAmmConfig · accounts UpdateAmmConfigInstructionAccounts.
| Field | Type |
|---|---|
param | u8 |
value | u32 |
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< |
UpdateDynamicFeeConfig#
From the program's IDL:
Updates the dynamic fee configuration constants.
This function allows updating the parameters that control dynamic fee calculation, such as filter period, decay period, reduction factor, fee control factor, etc. Only the admin or the amm config owner can update these settings. # Arguments
ctx- The context of accountsfilter_- Period that determines the high frequency trading time window (in seconds)period decay_- Period that determines when the dynamic fee starts to decrease (in seconds)period reduction_- Dynamic fee rate decrement rate, used for volatility reference decayfactor dynamic_- Factor used to scale the dynamic fee componentfee_ control max_- Maximum value for the volatility accumulatorvolatility_ accumulator create_- The new authority pubkey that can use this dynamic fee config to create poolspool_ authority
Discriminator 0707500802c784f0 · data UpdateDynamicFeeConfig · accounts UpdateDynamicFeeConfigInstructionAccounts.
| Field | Type |
|---|---|
filter_ | u16 |
decay_ | u16 |
reduction_ | u16 |
dynamic_ | u32 |
max_ | u32 |
Required accounts: 2; extras go to remaining.
Fields of UpdateDynamicFeeConfigInstructionAccounts, in account order:
| # | Field | Type |
|---|---|---|
| 0 | owner | Pubkey |
| 1 | dynamic_ | Pubkey |
| 2… | remaining | Vec< |
UpdateOperationAccount#
From the program's IDL:
Update the operation account
Arguments
ctx- The context of accountsparam- The value can be 0 | 1 | 2 | 3, otherwise will report an errorkeys- update operation owner when theparamis 0remove operation owner when the
paramis 1 update whitelist mint when theparamis 2 remove whitelist mint when theparamis 3
Discriminator 7f467728bce33d07 · data UpdateOperationAccount · accounts UpdateOperationAccountInstructionAccounts.
| Field | Type |
|---|---|
param | u8 |
keys | Vec<Pubkey> |
Required accounts: 3; extras go to remaining.
Fields of UpdateOperationAccountInstructionAccounts, in account order:
| # | Field | Type |
|---|---|---|
| 0 | owner | Pubkey |
| 1 | operation_ | Pubkey |
| 2 | system_ | Pubkey |
| 3… | 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< |
UpdateRewardInfos#
From the program's IDL:
Update rewards info of the given pool, can be called for everyone
Arguments
ctx- The context of accounts
Discriminator a3ace0340b9a6adf · data UpdateRewardInfos · accounts UpdateRewardInfosInstructionAccounts.
No data fields.
Required accounts: 1; extras go to remaining.
Fields of UpdateRewardInfosInstructionAccounts, in account order:
| # | Field | Type |
|---|---|---|
| 0 | pool_state | Pubkey |
| 1… | 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 RaydiumClmmAccount. 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 |
index | u16 | |
owner | Pubkey | Address of the protocol owner |
protocol_ | u32 | The protocol fee |
trade_ | u32 | The trade fee, denominated in hundredths of a bip (10^-6) |
tick_ | u16 | The tick spacing |
fund_ | u32 | The fund fee, denominated in hundredths of a bip (10^-6) |
padding_u32 | u32 | |
fund_owner | Pubkey | The fund owner |
padding | [u64; 3] |
DynamicFeeConfig#
Discriminator f4e258520e3bf6dc · accounts::.
| Field | Type |
|---|---|
index | u16 |
filter_ | u16 |
decay_ | u16 |
reduction_ | u16 |
dynamic_ | u32 |
max_ | u32 |
padding | [u64; 8] |
LimitOrderNonce#
Discriminator 1199ec3919c7e7f8 · accounts::.
| Field | Type |
|---|---|
user_wallet | Pubkey |
nonce_index | u8 |
order_nonce | u64 |
padding | [u64; 4] |
LimitOrderState#
Discriminator 01ee058ecf3e2ce4 · accounts::.
| Field | Type | Description |
|---|---|---|
pool_id | Pubkey | |
owner | Pubkey | Owner of this limit order |
tick_index | i32 | |
zero_ | bool | |
order_phase | u64 | Order phase of this limit order, aligned with TickState. for FIFO semantics |
total_ | u64 | Total amount of the limit order |
filled_ | u64 | Filled amount of the limit order (informational, for events/display) |
settle_base | u64 | The unfilled amount when the current computation segment started. Set to total_amount on open, reset on decrease. Never updated during settle — this avoids cascading floor-division error across multiple settles. |
settled_ | u64 | Cumulative output paid to user in the current segment. Reset on decrease. Each settle computes total_output from the segment base and pays the diff (total_output - settled_output), limiting dust deduction to once per segment. |
open_time | u64 | Order open time |
unfilled_ | u128 | Snapshot of TickState. at the time this segment started (Q64.64). Initialized to Q64 on open; reset to tick's current ratio on decrease. |
padding | [u64; 4] |
ObservationState#
Discriminator 7aaec5358109a584 · accounts::.
| Field | Type | Description |
|---|---|---|
initialized | bool | Whether the ObservationState is initialized |
recent_ | u64 | recent update epoch |
observation_ | u16 | the most-recently updated index of the observations array |
pool_id | Pubkey | belongs to which pool |
observations | [Observation; 100] | observation array |
padding | [u64; 4] | padding for feature update |
OperationState#
Discriminator 13ec3aed51deb7fc · accounts::.
| Field | Type | Description |
|---|---|---|
bump | u8 | Bump to identify PDA |
operation_ | [Pubkey; 10] | Address of the operation owner |
whitelist_ | [Pubkey; 100] | The mint address of whitelist to emit reward |
PersonalPositionState#
Discriminator 466f967ee60f1975 · accounts::.
| Field | Type | Description |
|---|---|---|
bump | [u8; 1] | Bump to identify PDA |
nft_mint | Pubkey | Mint address of the tokenized position |
pool_id | Pubkey | The ID of the pool with which this token is connected |
tick_ | i32 | The lower bound tick of the position |
tick_ | i32 | The upper bound tick of the position |
liquidity | u128 | The amount of liquidity owned by this position |
fee_ | u128 | The token_0 fee growth of the aggregate position as of the last action on the individual position |
fee_ | u128 | The token_1 fee growth of the aggregate position as of the last action on the individual position |
token_ | u64 | The fees owed to the position owner in token_0, as of the last computation |
token_ | u64 | The fees owed to the position owner in token_1, as of the last computation |
reward_ | [PositionRewardInfo; 3] | |
recent_ | u64 | |
padding | [u64; 7] |
PoolState#
Discriminator f7ede3f5d7c3de46 · accounts::.
| Field | Type | Description |
|---|---|---|
bump | [u8; 1] | Bump to identify PDA |
amm_config | Pubkey | |
owner | Pubkey | |
token_mint0 | Pubkey | Token pair of the pool, where token_mint_0 address < token_mint_1 address |
token_mint1 | Pubkey | |
token_ | Pubkey | Token pair vault |
token_ | Pubkey | |
observation_ | Pubkey | observation account key |
mint_ | u8 | mint0 and mint1 decimals |
mint_ | u8 | |
tick_ | u16 | The minimum number of ticks between initialized ticks |
liquidity | u128 | The currently in range liquidity available to the pool. |
sqrt_ | u128 | The current price of the pool as a sqrt(token_1/token_0) Q64.64 value |
tick_ | i32 | The current tick of the pool, i.e. according to the last tick transition that was run. |
padding3 | u16 | |
padding4 | u16 | |
fee_ | u128 | The fee growth as a Q64.64 number, i.e. fees of token_0 and token_1 collected per unit of liquidity for the entire life of the pool. |
fee_ | u128 | |
protocol_ | u64 | The amounts of token_0 and token_1 that are owed to the protocol. |
protocol_ | u64 | |
padding5 | [u128; 4] | |
status | u8 | Bitwise representation of the state of the pool bit0, 1: disable open position and increase liquidity, 0: normal bit1, 1: disable decrease liquidity, 0: normal bit2, 1: disable collect fee, 0: normal bit3, 1: disable collect reward, 0: normal bit4, 1: disable swap, 0: normal bit5, 1: disable limit order, 0: normal |
fee_on | u8 | Fee on which token (0 = FromInput, 1 = Token0Only, 2 = Token1Only) |
padding | [u8; 6] | Leave blank for future use |
reward_ | [RewardInfo; 3] | |
tick_ | [u64; 16] | Packed initialized tick array state |
padding6 | [u64; 4] | |
fund_ | u64 | |
fund_ | u64 | |
open_time | u64 | |
recent_ | u64 | |
dynamic_ | DynamicFeeInfo | Dynamic fee info |
padding1 | [u64; 14] | |
padding2 | [u64; 32] |
ProtocolPositionState#
Discriminator 64e2916392daa06a · accounts::.
| Field | Type | Description |
|---|---|---|
bump | u8 | Bump to identify PDA |
pool_id | Pubkey | The ID of the pool with which this token is connected |
tick_ | i32 | The lower bound tick of the position |
tick_ | i32 | The upper bound tick of the position |
liquidity | u128 | The amount of liquidity owned by this position |
fee_ | u128 | The token_0 fee growth per unit of liquidity as of the last update to liquidity or fees owed |
fee_ | u128 | The token_1 fee growth per unit of liquidity as of the last update to liquidity or fees owed |
token_ | u64 | The fees owed to the position owner in token_0 |
token_ | u64 | The fees owed to the position owner in token_1 |
reward_ | [u128; 3] | The reward growth per unit of liquidity as of the last update to liquidity |
recent_ | u64 | |
padding | [u64; 7] |
SupportMintAssociated#
Discriminator 8628b74f0c70a235 · accounts::.
| Field | Type | Description |
|---|---|---|
bump | u8 | Bump to identify PDA |
mint | Pubkey | Address of the supported token22 mint |
padding | [u64; 8] |
TickArrayBitmapExtension#
Discriminator 3c9624db61808b99 · accounts::.
| Field | Type | Description |
|---|---|---|
pool_id | Pubkey | |
positive_ | [[u64; 8]; 14] | Packed initialized tick array state for start_tick_index is positive |
negative_ | [[u64; 8]; 14] | Packed initialized tick array state for start_tick_index is negitive |
TickArrayState#
Discriminator c09b55cd31f9812a · accounts::.
| Field | Type |
|---|---|
pool_id | Pubkey |
start_ | i32 |
ticks | [TickState; 60] |
initialized_ | u8 |
recent_ | u64 |
padding | [u8; 107] |
Events#
Variants of instructions::, decoded from the CpiEvent instruction. Each wraps a struct from carbon_. The discriminator is the 8-byte event discriminator that follows the e445a52e51cb9a1d CPI-event tag.
CollectPersonalFeeEvent#
Discriminator a6ae69c051a15369 · events::.
| Field | Type | Description |
|---|---|---|
position_ | Pubkey | The ID of the token for which underlying tokens were collected |
recipient_ | Pubkey | The token account that received the collected token_0 tokens |
recipient_ | Pubkey | The token account that received the collected token_1 tokens |
amount0 | u64 | The amount of token_0 owed to the position that was collected |
amount1 | u64 | The amount of token_1 owed to the position that was collected |
CollectProtocolFeeEvent#
Discriminator ce57114f2d29d53d · events::.
| Field | Type | Description |
|---|---|---|
pool_state | Pubkey | The pool whose protocol fee is collected |
recipient_ | Pubkey | The address that receives the collected token_0 protocol fees |
recipient_ | Pubkey | The address that receives the collected token_1 protocol fees |
amount0 | u64 | The amount of token_0 protocol fees that is withdrawn |
amount1 | u64 | The amount of token_0 protocol fees that is withdrawn |
ConfigChangeEvent#
Discriminator f7bd07776a705f97 · events::.
| Field | Type |
|---|---|
index | u16 |
owner | Pubkey |
protocol_ | u32 |
trade_ | u32 |
tick_ | u16 |
fund_ | u32 |
fund_owner | Pubkey |
CreatePersonalPositionEvent#
Discriminator 641e57f9c4df9ace · events::.
| Field | Type | Description |
|---|---|---|
pool_state | Pubkey | The pool for which liquidity was added |
minter | Pubkey | The address that create the position |
nft_owner | Pubkey | The owner of the position and recipient of any minted liquidity |
tick_ | i32 | The lower tick of the position |
tick_ | i32 | The upper tick of the position |
liquidity | u128 | The amount of liquidity minted to the position range |
deposit_ | u64 | The amount of token_0 was deposit for the liquidity |
deposit_ | u64 | The amount of token_1 was deposit for the liquidity |
deposit_ | u64 | The token transfer fee for deposit_amount_0 |
deposit_ | u64 | The token transfer fee for deposit_amount_1 |
DecreaseLimitOrderEvent#
Discriminator 463028dddbedd4a3 · events::.
| Field | Type | Description |
|---|---|---|
pool_id | Pubkey | The pool whose limit order was decreased |
limit_order | Pubkey | The limit order account |
zero_ | bool | Direction of the limit order (true if zero_for_one) |
tick_index | i32 | Tick index of the limit order |
total_ | u64 | Total amount of the limit order |
filled_ | u64 | Filled amount of the limit order |
settled_ | u64 | Amount of output tokens settled (excluding fees) |
decreased_ | u64 | Amount of input tokens returned to user |
DecreaseLiquidityEvent#
Discriminator 3ade563a44325538 · events::.
| Field | Type | Description |
|---|---|---|
position_ | Pubkey | The ID of the token for which liquidity was decreased |
liquidity | u128 | The amount by which liquidity for the position was decreased |
decrease_ | u64 | The amount of token_0 that was paid for the decrease in liquidity |
decrease_ | u64 | The amount of token_1 that was paid for the decrease in liquidity |
fee_amount0 | u64 | |
fee_amount1 | u64 | The amount of token_1 fee |
reward_ | [u64; 3] | The amount of rewards |
transfer_ | u64 | The amount of token_0 transfer fee |
transfer_ | u64 | The amount of token_1 transfer fee |
IncreaseLimitOrderEvent#
Discriminator 0b780dccc75713c8 · events::.
| Field | Type | Description |
|---|---|---|
pool_id | Pubkey | The pool whose limit order was increased |
limit_order | Pubkey | The limit order account |
zero_ | bool | Direction of the limit order (true if zero_for_one) |
tick_index | i32 | Tick index of the limit order |
total_ | u64 | Total amount of the limit order |
increased_ | u64 | Increased amount of the limit order |
transfer_ | u64 | Transfer fee of the limit order |
IncreaseLiquidityEvent#
Discriminator 314f69d420221e54 · events::.
| Field | Type | Description |
|---|---|---|
position_ | Pubkey | The ID of the token for which liquidity was increased |
liquidity | u128 | The amount by which liquidity for the NFT position was increased |
amount0 | u64 | The amount of token_0 that was paid for the increase in liquidity |
amount1 | u64 | The amount of token_1 that was paid for the increase in liquidity |
amount0_ | u64 | The token transfer fee for amount_0 |
amount1_ | u64 | The token transfer fee for amount_1 |
LiquidityCalculateEvent#
Discriminator ed7094e63954b4a2 · events::.
| Field | Type | Description |
|---|---|---|
pool_ | u128 | The pool liquidity before decrease or increase |
pool_ | u128 | The pool price when decrease or increase in liquidity |
pool_tick | i32 | The pool tick when decrease or increase in liquidity |
calc_ | u64 | The amount of token_0 that was calculated for the decrease or increase in liquidity |
calc_ | u64 | The amount of token_1 that was calculated for the decrease or increase in liquidity |
trade_ | u64 | |
trade_ | u64 | The amount of token_1 fee |
transfer_ | u64 | The amount of token_0 transfer fee without trade_fee_amount_0 |
transfer_ | u64 | The amount of token_1 transfer fee without trade_fee_amount_0 |
LiquidityChangeEvent#
Discriminator 7ef0afce9e58996b · events::.
| Field | Type | Description |
|---|---|---|
pool_state | Pubkey | The pool for swap |
tick | i32 | The tick of the pool |
tick_lower | i32 | The tick lower of position |
tick_upper | i32 | The tick lower of position |
liquidity_ | u128 | The liquidity of the pool before liquidity change |
liquidity_ | u128 | The liquidity of the pool after liquidity change |
OpenLimitOrderEvent#
Discriminator 6a18475539a99ed8 · events::.
| Field | Type | Description |
|---|---|---|
pool_id | Pubkey | The pool whose limit order was opened |
limit_order | Pubkey | The limit order account |
zero_ | bool | Direction of the limit order (true if zero_for_one) |
tick_index | i32 | Tick index of the limit order |
total_ | u64 | Total amount of the limit order |
transfer_ | u64 | Transfer fee of the limit order |
PoolCreatedEvent#
Discriminator 195e4b2f7063353f · events::.
| Field | Type | Description |
|---|---|---|
token_mint0 | Pubkey | The first token of the pool by address sort order |
token_mint1 | Pubkey | The second token of the pool by address sort order |
tick_ | u16 | The minimum number of ticks between initialized ticks |
pool_state | Pubkey | The address of the created pool |
sqrt_ | u128 | The initial sqrt price of the pool, as a Q64.64 |
tick | i32 | The initial tick of the pool, i.e. log base 1.0001 of the starting price of the pool |
token_ | Pubkey | Vault of token_0 |
token_ | Pubkey | Vault of token_1 |
SettleLimitOrderEvent#
Discriminator 58774da47d7c0ac2 · events::.
| Field | Type | Description |
|---|---|---|
pool_id | Pubkey | The pool whose limit order was settled |
limit_order | Pubkey | The limit order account |
zero_ | bool | Direction of the limit order (true if zero_for_one) |
tick_index | i32 | Tick index of the limit order |
total_ | u64 | Total amount of the limit order |
filled_ | u64 | Filled amount of the limit order |
settled_ | u64 | Amount of output tokens transferred (excluding fees) |
SwapEvent#
Discriminator 40c6cde8260871e2 · events::.
| Field | Type | Description |
|---|---|---|
pool_state | Pubkey | The pool for which token_0 and token_1 were swapped |
sender | Pubkey | The address that initiated the swap call, and that received the callback |
token_ | Pubkey | The payer token account in zero for one swaps, or the recipient token account in one for zero swaps |
token_ | Pubkey | The payer token account in one for zero swaps, or the recipient token account in zero for one swaps |
amount0 | u64 | The real delta amount of the token_0 of the pool or user |
transfer_ | u64 | The transfer fee charged by the withheld_amount of the token_0 |
amount1 | u64 | The real delta of the token_1 of the pool or user |
transfer_ | u64 | The transfer fee charged by the withheld_amount of the token_1 |
zero_ | bool | if true, amount_0 is negtive and amount_1 is positive |
sqrt_ | u128 | The sqrt(price) of the pool after the swap, as a Q64.64 |
liquidity | u128 | The liquidity of the pool after the swap |
tick | i32 | The log base 1.0001 of price of the pool after the swap |
UpdateRewardInfosEvent#
Discriminator 6d7fba4e724125ec · events::.
| Field | Type | Description |
|---|---|---|
reward_ | [u128; 3] | Reward info |
Types#
Types used by the instructions, accounts and events above, exported from carbon_.
CollectFeeOn#
Enum types::.
| Variant |
|---|
FromInput |
Token0Only |
Token1Only |
CollectPersonalFeeEvent#
From the program's IDL:
Emitted when tokens are collected for a position
Struct types::. Same fields as the CollectPersonalFeeEvent event.
CollectProtocolFeeEvent#
From the program's IDL:
Emitted when the collected protocol fees are withdrawn by the factory owner
Struct types::. Same fields as the CollectProtocolFeeEvent event.
ConfigChangeEvent#
From the program's IDL:
Emitted when create or update a config
Struct types::. Same fields as the ConfigChangeEvent event.
CreateCustomizableParams#
Struct types::.
| Field | Type |
|---|---|
sqrt_ | u128 |
collect_ | CollectFeeOn |
enable_ | bool |
CreatePersonalPositionEvent#
From the program's IDL:
Emitted when create a new position
Struct types::. Same fields as the CreatePersonalPositionEvent event.
DecreaseLimitOrderEvent#
Struct types::. Same fields as the DecreaseLimitOrderEvent event.
DecreaseLiquidityEvent#
From the program's IDL:
Emitted when liquidity is decreased.
Struct types::. Same fields as the DecreaseLiquidityEvent event.
DynamicFeeInfo#
From the program's IDL:
Dynamic fee information for pool configuration
Struct types::.
| Field | Type | Description |
|---|---|---|
filter_ | u16 | Period that determines the high frequency trading time window (in seconds). |
decay_ | u16 | Period that determines when the dynamic fee starts to decrease (in seconds). |
reduction_ | u16 | Dynamic fee rate decrement rate, used for volatility reference decay. |
dynamic_ | u32 | Factor used to scale the dynamic fee component in the fee rate calculation. |
max_ | u32 | Maximum value for the volatility accumulator, used to cap the dynamic fee rate. |
tick_ | i32 | Active tick spacing index at the last reference update. |
volatility_ | u32 | Volatility reference value, stores the decayed volatility accumulator. |
volatility_ | u32 | Volatility accumulator, used to calculate the dynamic fee rate. |
last_ | u64 | Last timestamp (block time) when volatility_ and tick_ were updated. |
padding | [u8; 46] | Reserved for future upgrades. |
IncreaseLimitOrderEvent#
Struct types::. Same fields as the IncreaseLimitOrderEvent event.
IncreaseLiquidityEvent#
From the program's IDL:
Emitted when liquidity is increased.
Struct types::. Same fields as the IncreaseLiquidityEvent event.
InitializeRewardParam#
Struct types::.
| Field | Type | Description |
|---|---|---|
open_time | u64 | Reward open time |
end_time | u64 | Reward end time |
emissions_ | u128 | Token reward per second are earned per unit of liquidity |
LiquidityCalculateEvent#
From the program's IDL:
Emitted when liquidity decreased or increase.
Struct types::. Same fields as the LiquidityCalculateEvent event.
LiquidityChangeEvent#
From the program's IDL:
Emitted pool liquidity change when increase and decrease liquidity
Struct types::. Same fields as the LiquidityChangeEvent event.
Observation#
From the program's IDL:
The element of observations in ObservationState
Struct types::.
| Field | Type | Description |
|---|---|---|
block_ | u32 | The block timestamp of the observation |
tick_ | i64 | the cumulative of tick during the duration time |
padding | [u64; 4] | padding for feature update |
OpenLimitOrderEvent#
From the program's IDL:
Emitted when a limit order is opened
Struct types::. Same fields as the OpenLimitOrderEvent event.
PoolCreatedEvent#
From the program's IDL:
Emitted when a pool is created and initialized with a starting price
Struct types::. Same fields as the PoolCreatedEvent event.
PositionRewardInfo#
Struct types::.
| Field | Type |
|---|---|
growth_ | u128 |
reward_ | u64 |
RewardInfo#
Struct types::.
| Field | Type | Description |
|---|---|---|
reward_ | u8 | Reward state |
open_time | u64 | Reward open time |
end_time | u64 | Reward end time |
last_ | u64 | Reward last update time |
emissions_ | u128 | Q64.64 number indicates how many tokens per second are earned per unit of liquidity. |
reward_ | u64 | The total amount of reward emitted |
reward_ | u64 | The total amount of claimed reward |
token_mint | Pubkey | Reward token mint. |
token_vault | Pubkey | Reward vault token account. |
authority | Pubkey | The owner that has permission to set reward param |
reward_ | u128 | Q64.64 number that tracks the total tokens earned per unit of liquidity since the reward emissions were turned on. |
SettleLimitOrderEvent#
From the program's IDL:
Emitted when a limit order is settled and proceeds are transferred
Struct types::. Same fields as the SettleLimitOrderEvent event.
SwapEvent#
From the program's IDL:
Emitted by when a swap is performed for a pool
Struct types::. Same fields as the SwapEvent event.
TickState#
Struct types::.
| Field | Type | Description |
|---|---|---|
tick | i32 | |
liquidity_ | i128 | Amount of net liquidity added (subtracted) when tick is crossed from left to right (right to left) |
liquidity_ | u128 | The total position liquidity that references this tick |
fee_ | u128 | Fee growth per unit of liquidity on the other side of this tick (relative to the current tick) only has relative meaning, not absolute — the value depends on when the tick is initialized |
fee_ | u128 | |
reward_ | [u128; 3] | Reward growth per unit of liquidity like fee, array of Q64.64 |
order_phase | u64 | Order phase of the tick, used as a FIFO cohort index for limit orders |
orders_ | u64 | The amount of limit orders that have never been matched, only counts newly opened orders, not partially filled ones |
part_ | u64 | Remaining part filled orders amount |
unfilled_ | u128 | Cumulative unfilled ratio for the current part-filled cohort (Q64.64 format). Starts at Q64(1) when a new cohort forms, multiplied down as fills occur. |
padding | [u32; 3] |
UpdateRewardInfosEvent#
From the program's IDL:
Emitted when Reward are updated for a pool
Struct types::. Same fields as the UpdateRewardInfosEvent event.