PancakeSwap decoder

Decode PancakeSwap instructions, accounts and events in Rust with carbon-pancake-swap-decoder 2.0.0. Program ID HpNfyc2Saw7RKkQd8nEL4khUcuPhQ7WwY1B2qjx8jxFq.

On this page

carbon-pancake-swap-decoder decodes the instructions, accounts and events of the PancakeSwap program (HpNfyc2Saw7RKkQd8nEL4khUcuPhQ7WwY1B2qjx8jxFq): 27 instructions, 10 account types, 11 events. It is generated with Codama from the program's IDL; see decoders for how decoders plug into a pipeline.

Cratecarbon-pancake-swap-decoder 2.0.0
Installcargo add carbon-pancake-swap-decoder@2.0.0
Program IDHpNfyc2Saw7RKkQd8nEL4khUcuPhQ7WwY1B2qjx8jxFq (carbon_pancake_swap_decoder::PROGRAM_ID)
CategoryDEX & AMM
Decodercarbon_pancake_swap_decoder::PancakeSwapDecoder
Instruction enuminstructions::PancakeSwapInstruction
Account enumaccounts::PancakeSwapAccount
Event enuminstructions::CpiEvent
Featuresserde, postgres, graphql (none enabled by default)
API docsdocs.rs/carbon-pancake-swap-decoder/2.0.0
Sourcedecoders/pancake-swap-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, Phoenix v1, PumpSwap, Raydium AMM v4, Raydium CLMM, Raydium CPMM, Raydium Stable Swap, Stabble Stable Swap, Stabble Weighted Swap. To decode several in one pipeline, see dEX and AMM decoders.

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

Usage#

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

Terminal
cargo add carbon-core@2.0.0 carbon-pancake-swap-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_pancake_swap_decoder::{
        instructions::PancakeSwapInstruction, PancakeSwapDecoder, 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(PancakeSwapDecoder, InstructionLogger)
        .build()?
        .run()
        .await
}

struct InstructionLogger;

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

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

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

Decode accounts#

The transaction crawler emits transactions only. To decode accounts, use a datasource that emits account updates. This program subscribes to the program's accounts with programSubscribe on the public WebSocket endpoint and prints every decoded 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_pancake_swap_decoder::{accounts::PancakeSwapAccount, PancakeSwapDecoder, 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(PancakeSwapDecoder, AccountLogger)
        .build()?
        .run()
        .await
}

struct AccountLogger;

impl Processor<AccountProcessorInputType<'_, PancakeSwapAccount>> for AccountLogger {
    async fn process(
        &mut self,
        input: &AccountProcessorInputType<'_, PancakeSwapAccount>,
    ) -> CarbonResult<()> {
        if let PancakeSwapAccount::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 PancakeSwapInstruction. Each is PancakeSwapInstruction::<Variant> { program_id, data, accounts }, where data and accounts are the types listed under the variant, exported from carbon_pancake_swap_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 HpNfyc2Saw7RKkQd8nEL4khUcuPhQ7WwY1B2qjx8jxFq.
  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.

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:

#FieldType
0nft_ownerPubkey
1position_nft_mintPubkey
2position_nft_accountPubkey
3personal_positionPubkey
4system_programPubkey
5token_programPubkey
6…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: 11; extras go to remaining.

Fields of CollectFundFeeInstructionAccounts, in account order:

#FieldType
0ownerPubkey
1pool_statePubkey
2amm_configPubkey
3token_vault0Pubkey
4token_vault1Pubkey
5vault0_mintPubkey
6vault1_mintPubkey
7recipient_token_account0Pubkey
8recipient_token_account1Pubkey
9token_programPubkey
10token_program2022Pubkey
11…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: 11; extras go to remaining.

Fields of CollectProtocolFeeInstructionAccounts, in account order:

#FieldType
0ownerPubkey
1pool_statePubkey
2amm_configPubkey
3token_vault0Pubkey
4token_vault1Pubkey
5vault0_mintPubkey
6vault1_mintPubkey
7recipient_token_account0Pubkey
8recipient_token_account1Pubkey
9token_programPubkey
10token_program2022Pubkey
11…remainingVec<AccountMeta>

CollectRemainingRewards#

From the program's IDL:

Collect remaining reward token for reward founder

Arguments

  • ctx- The context of accounts
  • reward_index - the index to reward info

Discriminator 12eda6c52210d590 · data CollectRemainingRewards · accounts CollectRemainingRewardsInstructionAccounts.

FieldType
reward_indexu8

Required accounts: 8; extras go to remaining.

Fields of CollectRemainingRewardsInstructionAccounts, in account order:

#FieldType
0reward_funderPubkey
1funder_token_accountPubkey
2pool_statePubkey
3reward_token_vaultPubkey
4reward_vault_mintPubkey
5token_programPubkey
6token_program2022Pubkey
7memo_programPubkey
8…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.
  • tick_spacing - The tickspacing binding with config, cannot be changed.
  • 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
tick_spacingu16
trade_fee_rateu32
protocol_fee_rateu32
fund_fee_rateu32

Required accounts: 3; extras go to remaining.

Fields of CreateAmmConfigInstructionAccounts, in account order:

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

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:

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

CreatePermissionlessFarmSwitch#

From the program's IDL:

Creates a permissionless farm switch account for the program

Arguments

  • ctx- The context of accounts

Discriminator 58f2c646f106c4fb · data CreatePermissionlessFarmSwitch · accounts CreatePermissionlessFarmSwitchInstructionAccounts.

No data fields.

Required accounts: 3; extras go to remaining.

Fields of CreatePermissionlessFarmSwitchInstructionAccounts, in account order:

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

CreatePool#

From the program's IDL:

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

Arguments

  • ctx- The context of accounts
  • sqrt_price_x64 - the initial sqrt price (amount_token_1 / amount_token_0) of the pool as a Q64.64

Note: The open_time must be smaller than the current block_timestamp on chain.

Discriminator e992d18ecf6840bc · data CreatePool · accounts CreatePoolInstructionAccounts.

FieldType
sqrt_price_x64u128
open_timeu64

Required accounts: 13; extras go to remaining.

Fields of CreatePoolInstructionAccounts, in account order:

#FieldType
0pool_creatorPubkey
1amm_configPubkey
2pool_statePubkey
3token_mint0Pubkey
4token_mint1Pubkey
5token_vault0Pubkey
6token_vault1Pubkey
7observation_statePubkey
8tick_array_bitmapPubkey
9token_program0Pubkey
10token_program1Pubkey
11system_programPubkey
12rentPubkey
13…remainingVec<AccountMeta>

CreateSupportMintAssociated#

From the program's IDL:

Create support token22 mint account which can create pool and send rewards with ignoring the not support extensions.

Discriminator 11fb415c88f20ea9 · data CreateSupportMintAssociated · accounts CreateSupportMintAssociatedInstructionAccounts.

No data fields.

Required accounts: 4; extras go to remaining.

Fields of CreateSupportMintAssociatedInstructionAccounts, in account order:

#FieldType
0ownerPubkey
1token_mintPubkey
2support_mint_associatedPubkey
3system_programPubkey
4…remainingVec<AccountMeta>

DecreaseLiquidity#

From the program's IDL:

#[deprecated(note = "Use decrease_liquidity_v2 instead.")] Decreases liquidity for an existing position

Arguments

  • ctx - The context of accounts
  • liquidity - The amount by which liquidity will be decreased
  • amount_0_min - The minimum amount of token_0 that should be accounted for the burned liquidity
  • amount_1_min - The minimum amount of token_1 that should be accounted for the burned liquidity

Discriminator a026d06f685b2c01 · data DecreaseLiquidity · accounts DecreaseLiquidityInstructionAccounts.

FieldType
liquidityu128
amount0_minu64
amount1_minu64

Required accounts: 12; extras go to remaining.

Fields of DecreaseLiquidityInstructionAccounts, in account order:

#FieldType
0nft_ownerPubkey
1nft_accountPubkey
2personal_positionPubkey
3pool_statePubkey
4protocol_positionPubkey
5token_vault0Pubkey
6token_vault1Pubkey
7tick_array_lowerPubkey
8tick_array_upperPubkey
9recipient_token_account0Pubkey
10recipient_token_account1Pubkey
11token_programPubkey
12…remainingVec<AccountMeta>

DecreaseLiquidityV2#

From the program's IDL:

Decreases liquidity for an existing position, support Token2022

Arguments

  • ctx - The context of accounts
  • liquidity - The amount by which liquidity will be decreased
  • amount_0_min - The minimum amount of token_0 that should be accounted for the burned liquidity
  • amount_1_min - The minimum amount of token_1 that should be accounted for the burned liquidity

Discriminator 3a7fbc3e4f52c460 · data DecreaseLiquidityV2 · accounts DecreaseLiquidityV2InstructionAccounts.

FieldType
liquidityu128
amount0_minu64
amount1_minu64

Required accounts: 16; extras go to remaining.

Fields of DecreaseLiquidityV2InstructionAccounts, in account order:

#FieldType
0nft_ownerPubkey
1nft_accountPubkey
2personal_positionPubkey
3pool_statePubkey
4protocol_positionPubkey
5token_vault0Pubkey
6token_vault1Pubkey
7tick_array_lowerPubkey
8tick_array_upperPubkey
9recipient_token_account0Pubkey
10recipient_token_account1Pubkey
11token_programPubkey
12token_program2022Pubkey
13memo_programPubkey
14vault0_mintPubkey
15vault1_mintPubkey
16…remainingVec<AccountMeta>

IncreaseLiquidity#

From the program's IDL:

#[deprecated(note = "Use increase_liquidity_v2 instead.")] Increases liquidity for an existing position, with amount paid by payer

Arguments

  • ctx - The context of accounts
  • liquidity - The desired liquidity to be added, can't be zero
  • amount_0_max - The max amount of token_0 to spend, which serves as a slippage check
  • amount_1_max - The max amount of token_1 to spend, which serves as a slippage check

Discriminator 2e9cf3760dcdfbb2 · data IncreaseLiquidity · accounts IncreaseLiquidityInstructionAccounts.

FieldType
liquidityu128
amount0_maxu64
amount1_maxu64

Required accounts: 12; extras go to remaining.

Fields of IncreaseLiquidityInstructionAccounts, in account order:

#FieldType
0nft_ownerPubkey
1nft_accountPubkey
2pool_statePubkey
3protocol_positionPubkey
4personal_positionPubkey
5tick_array_lowerPubkey
6tick_array_upperPubkey
7token_account0Pubkey
8token_account1Pubkey
9token_vault0Pubkey
10token_vault1Pubkey
11token_programPubkey
12…remainingVec<AccountMeta>

IncreaseLiquidityV2#

From the program's IDL:

Increases liquidity for an existing position, with amount paid by payer, support Token2022 # Arguments

  • ctx - The context of accounts
  • liquidity - The desired liquidity to be added, if zero, calculate liquidity base amount_0 or amount_1 according base_flag
  • amount_0_max - The max amount of token_0 to spend, which serves as a slippage check
  • amount_1_max - The max amount of token_1 to spend, which serves as a slippage check
  • 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.

FieldType
liquidityu128
amount0_maxu64
amount1_maxu64
base_flagOption<bool>

Required accounts: 15; extras go to remaining.

Fields of IncreaseLiquidityV2InstructionAccounts, in account order:

#FieldType
0nft_ownerPubkey
1nft_accountPubkey
2pool_statePubkey
3protocol_positionPubkey
4personal_positionPubkey
5tick_array_lowerPubkey
6tick_array_upperPubkey
7token_account0Pubkey
8token_account1Pubkey
9token_vault0Pubkey
10token_vault1Pubkey
11token_programPubkey
12token_program2022Pubkey
13vault0_mintPubkey
14vault1_mintPubkey
15…remainingVec<AccountMeta>

InitializeReward#

From the program's IDL:

Initialize a reward info for a given pool and reward index

Arguments

  • ctx- The context of accounts
  • reward_index - the index to reward info
  • open_time - reward open timestamp
  • end_time - reward end timestamp
  • emissions_per_second_x64 - Token reward per second are earned per unit of liquidity.

Discriminator 5f87c0c4f281e644 · data InitializeReward · accounts InitializeRewardInstructionAccounts.

FieldType
paramInitializeRewardParam

Required accounts: 11; extras go to remaining.

Fields of InitializeRewardInstructionAccounts, in account order:

#FieldType
0reward_funderPubkey
1funder_token_accountPubkey
2amm_configPubkey
3pool_statePubkey
4operation_statePubkey
5permissionless_farm_switchPubkey
6reward_token_mintPubkey
7reward_token_vaultPubkey
8reward_token_programPubkey
9system_programPubkey
10rentPubkey
11…remainingVec<AccountMeta>

OpenPosition#

From the program's IDL:

#[deprecated(note = "Use open_position_with_token22_nft instead.")] Creates a new position wrapped in a NFT

Arguments

  • ctx - The context of accounts
  • tick_lower_index - The low boundary of market
  • tick_upper_index - The upper boundary of market
  • tick_array_lower_start_index - The start index of tick array which include tick low
  • tick_array_upper_start_index - The start index of tick array which include tick upper
  • liquidity - The liquidity to be added
  • amount_0_max - The max amount of token_0 to spend, which serves as a slippage check
  • amount_1_max - The max amount of token_1 to spend, which serves as a slippage check

Discriminator 87802f4d0f98f031 · data OpenPosition · accounts OpenPositionInstructionAccounts.

FieldType
tick_lower_indexi32
tick_upper_indexi32
tick_array_lower_start_indexi32
tick_array_upper_start_indexi32
liquidityu128
amount0_maxu64
amount1_maxu64

Required accounts: 19; extras go to remaining.

Fields of OpenPositionInstructionAccounts, in account order:

#FieldType
0payerPubkey
1position_nft_ownerPubkey
2position_nft_mintPubkey
3position_nft_accountPubkey
4metadata_accountPubkey
5pool_statePubkey
6protocol_positionPubkey
7tick_array_lowerPubkey
8tick_array_upperPubkey
9personal_positionPubkey
10token_account0Pubkey
11token_account1Pubkey
12token_vault0Pubkey
13token_vault1Pubkey
14rentPubkey
15system_programPubkey
16token_programPubkey
17associated_token_programPubkey
18metadata_programPubkey
19…remainingVec<AccountMeta>

OpenPositionV2#

From the program's IDL:

#[deprecated(note = "Use open_position_with_token22_nft instead.")] Creates a new position wrapped in a NFT, support Token2022

Arguments

  • ctx - The context of accounts
  • tick_lower_index - The low boundary of market
  • tick_upper_index - The upper boundary of market
  • tick_array_lower_start_index - The start index of tick array which include tick low
  • tick_array_upper_start_index - The start index of tick array which include tick upper
  • 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 liquidity
  • amount_0_max - The max amount of token_0 to spend, which serves as a slippage check
  • amount_1_max - The max amount of token_1 to spend, which serves as a slippage check
  • with_metadata - The flag indicating whether to create NFT mint metadata
  • 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.

FieldType
tick_lower_indexi32
tick_upper_indexi32
tick_array_lower_start_indexi32
tick_array_upper_start_indexi32
liquidityu128
amount0_maxu64
amount1_maxu64
with_metadatabool
base_flagOption<bool>

Required accounts: 22; extras go to remaining.

Fields of OpenPositionV2InstructionAccounts, in account order:

#FieldType
0payerPubkey
1position_nft_ownerPubkey
2position_nft_mintPubkey
3position_nft_accountPubkey
4metadata_accountPubkey
5pool_statePubkey
6protocol_positionPubkey
7tick_array_lowerPubkey
8tick_array_upperPubkey
9personal_positionPubkey
10token_account0Pubkey
11token_account1Pubkey
12token_vault0Pubkey
13token_vault1Pubkey
14rentPubkey
15system_programPubkey
16token_programPubkey
17associated_token_programPubkey
18metadata_programPubkey
19token_program2022Pubkey
20vault0_mintPubkey
21vault1_mintPubkey
22…remainingVec<AccountMeta>

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 accounts
  • tick_lower_index - The low boundary of market
  • tick_upper_index - The upper boundary of market
  • tick_array_lower_start_index - The start index of tick array which include tick low
  • tick_array_upper_start_index - The start index of tick array which include tick upper
  • 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 liquidity
  • amount_0_max - The max amount of token_0 to spend, which serves as a slippage check
  • amount_1_max - The max amount of token_1 to spend, which serves as a slippage check
  • with_metadata - The flag indicating whether to create NFT mint metadata
  • 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.

FieldType
tick_lower_indexi32
tick_upper_indexi32
tick_array_lower_start_indexi32
tick_array_upper_start_indexi32
liquidityu128
amount0_maxu64
amount1_maxu64
with_metadatabool
base_flagOption<bool>

Required accounts: 20; extras go to remaining.

Fields of OpenPositionWithToken22NftInstructionAccounts, in account order:

#FieldType
0payerPubkey
1position_nft_ownerPubkey
2position_nft_mintPubkey
3position_nft_accountPubkey
4pool_statePubkey
5protocol_positionPubkey
6tick_array_lowerPubkey
7tick_array_upperPubkey
8personal_positionPubkey
9token_account0Pubkey
10token_account1Pubkey
11token_vault0Pubkey
12token_vault1Pubkey
13rentPubkey
14system_programPubkey
15token_programPubkey
16associated_token_programPubkey
17token_program2022Pubkey
18vault0_mintPubkey
19vault1_mintPubkey
20…remainingVec<AccountMeta>

SetRewardParams#

From the program's IDL:

Reset reward param, start a new reward cycle or extend the current cycle.

Arguments

  • ctx - The context of accounts
  • reward_index - The index of reward token in the pool.
  • emissions_per_second_x64 - The per second emission reward, when extend the current cycle,

new value can't be less than old value

  • open_time - reward open timestamp, must be set when starting a new cycle
  • end_time - reward end timestamp

Discriminator 7034a74b20c9d389 · data SetRewardParams · accounts SetRewardParamsInstructionAccounts.

FieldType
reward_indexu8
emissions_per_second_x64u128
open_timeu64
end_timeu64

Required accounts: 6; extras go to remaining.

Fields of SetRewardParamsInstructionAccounts, in account order:

#FieldType
0authorityPubkey
1amm_configPubkey
2pool_statePubkey
3operation_statePubkey
4token_programPubkey
5token_program2022Pubkey
6…remainingVec<AccountMeta>

Swap#

From the program's IDL:

#[deprecated(note = "Use swap_v2 instead.")] Swaps one token for as much as possible of another token across a single pool # Arguments

  • ctx - The context of accounts
  • amount - Arranged in pairs with other_amount_threshold. (amount_in, amount_out_minimum) or (amount_out, amount_in_maximum)
  • other_amount_threshold - For slippage check
  • sqrt_price_limit - The Q64.64 sqrt price √P limit. If zero for one, the price cannot
  • is_base_input - swap base input or swap base output

Discriminator f8c69e91e17587c8 · data Swap · accounts SwapInstructionAccounts.

FieldType
amountu64
other_amount_thresholdu64
sqrt_price_limit_x64u128
is_base_inputbool

Required accounts: 10; extras go to remaining.

Fields of SwapInstructionAccounts, in account order:

#FieldType
0payerPubkey
1amm_configPubkey
2pool_statePubkey
3input_token_accountPubkey
4output_token_accountPubkey
5input_vaultPubkey
6output_vaultPubkey
7observation_statePubkey
8token_programPubkey
9tick_arrayPubkey
10…remainingVec<AccountMeta>

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 accounts
  • amount_in - Token amount to be swapped in
  • amount_out_minimum - Panic if output amount is below minimum amount. For slippage.

Discriminator 457d73daf5baf2c4 · data SwapRouterBaseIn · accounts SwapRouterBaseInInstructionAccounts.

FieldType
amount_inu64
amount_out_minimumu64

Required accounts: 6; extras go to remaining.

Fields of SwapRouterBaseInInstructionAccounts, in account order:

#FieldType
0payerPubkey
1input_token_accountPubkey
2input_token_mintPubkey
3token_programPubkey
4token_program2022Pubkey
5memo_programPubkey
6…remainingVec<AccountMeta>

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 accounts
  • amount - Arranged in pairs with other_amount_threshold. (amount_in, amount_out_minimum) or (amount_out, amount_in_maximum)
  • other_amount_threshold - For slippage check
  • sqrt_price_limit - The Q64.64 sqrt price √P limit. If zero for one, the price cannot
  • is_base_input - swap base input or swap base output

Discriminator 2b04ed0b1ac91e62 · data SwapV2 · accounts SwapV2InstructionAccounts.

FieldType
amountu64
other_amount_thresholdu64
sqrt_price_limit_x64u128
is_base_inputbool

Required accounts: 13; extras go to remaining.

Fields of SwapV2InstructionAccounts, in account order:

#FieldType
0payerPubkey
1amm_configPubkey
2pool_statePubkey
3input_token_accountPubkey
4output_token_accountPubkey
5input_vaultPubkey
6output_vaultPubkey
7observation_statePubkey
8token_programPubkey
9token_program2022Pubkey
10memo_programPubkey
11input_vault_mintPubkey
12output_vault_mintPubkey
13…remainingVec<AccountMeta>

TogglePermissionlessFarmSwitch#

From the program's IDL:

Toggle the permissionless farm switch account

Arguments

  • ctx- The context of accounts
  • is_on- Is the permissionless farm allowed or not

Discriminator 967036e9eea10756 · data TogglePermissionlessFarmSwitch · accounts TogglePermissionlessFarmSwitchInstructionAccounts.

FieldType
is_onbool

Required accounts: 3; extras go to remaining.

Fields of TogglePermissionlessFarmSwitchInstructionAccounts, in account order:

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

TransferRewardOwner#

From the program's IDL:

Transfer reward owner

Arguments

  • ctx- The context of accounts
  • new_owner- new owner pubkey

Discriminator 07160c53f22b3079 · data TransferRewardOwner · accounts TransferRewardOwnerInstructionAccounts.

FieldType
new_ownerPubkey

Required accounts: 2; extras go to remaining.

Fields of TransferRewardOwnerInstructionAccounts, in account order:

#FieldType
0authorityPubkey
1pool_statePubkey
2…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
valueu32

Required accounts: 2; extras go to remaining.

Fields of UpdateAmmConfigInstructionAccounts, in account order:

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

UpdateOperationAccount#

From the program's IDL:

Update the operation account

Arguments

  • ctx- The context of accounts
  • param- The value can be 0 | 1 | 2 | 3, otherwise will report a error
  • keys- update operation owner when the param is 0

remove operation owner when the param is 1 update whitelist mint when the param is 2 remove whitelist mint when the param is 3

Discriminator 7f467728bce33d07 · data UpdateOperationAccount · accounts UpdateOperationAccountInstructionAccounts.

FieldType
paramu8
keysVec<Pubkey>

Required accounts: 3; extras go to remaining.

Fields of UpdateOperationAccountInstructionAccounts, in account order:

#FieldType
0ownerPubkey
1operation_statePubkey
2system_programPubkey
3…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>

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:

#FieldType
0pool_statePubkey
1…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 PancakeSwapAccount. Each wraps a boxed struct from carbon_pancake_swap_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
indexu16
ownerPubkeyAddress of the protocol owner
protocol_fee_rateu32The protocol fee
trade_fee_rateu32The trade fee, denominated in hundredths of a bip (10^-6)
tick_spacingu16The tick spacing
fund_fee_rateu32The fund fee, denominated in hundredths of a bip (10^-6)
padding_u32u32
fund_ownerPubkey
padding[u64; 3]

ObservationState#

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

FieldTypeDescription
initializedboolWhether the ObservationState is initialized
recent_epochu64recent update epoch
observation_indexu16the most-recently updated index of the observations array
pool_idPubkeybelongs to which pool
observations[Observation; 100]observation array
padding[u64; 4]padding for feature update

OperationState#

Discriminator 13ec3aed51deb7fc · accounts::operation_state::OperationState.

FieldTypeDescription
bumpu8Bump to identify PDA
operation_owners[Pubkey; 10]Address of the operation owner
whitelist_mints[Pubkey; 100]The mint address of whitelist to emit reward

PermissionlessFarmSwitch#

Discriminator 255c934efa649389 · accounts::permissionless_farm_switch::PermissionlessFarmSwitch.

FieldTypeDescription
bumpu8Bump to identify PDA
is_onboolIs the permissionless farm allowed or not

PersonalPositionState#

Discriminator 466f967ee60f1975 · accounts::personal_position_state::PersonalPositionState.

FieldTypeDescription
bump[u8; 1]Bump to identify PDA
nft_mintPubkeyMint address of the tokenized position
pool_idPubkeyThe ID of the pool with which this token is connected
tick_lower_indexi32The lower bound tick of the position
tick_upper_indexi32The upper bound tick of the position
liquidityu128The amount of liquidity owned by this position
fee_growth_inside0_last_x64u128The token_0 fee growth of the aggregate position as of the last action on the individual position
fee_growth_inside1_last_x64u128The token_1 fee growth of the aggregate position as of the last action on the individual position
token_fees_owed0u64The fees owed to the position owner in token_0, as of the last computation
token_fees_owed1u64The fees owed to the position owner in token_1, as of the last computation
reward_infos[PositionRewardInfo; 3]
recent_epochu64
padding[u64; 7]

PoolState#

Discriminator f7ede3f5d7c3de46 · accounts::pool_state::PoolState.

FieldTypeDescription
bump[u8; 1]Bump to identify PDA
amm_configPubkey
ownerPubkey
token_mint0PubkeyToken pair of the pool, where token_mint_0 address < token_mint_1 address
token_mint1Pubkey
token_vault0PubkeyToken pair vault
token_vault1Pubkey
observation_keyPubkeyobservation account key
mint_decimals0u8mint0 and mint1 decimals
mint_decimals1u8
tick_spacingu16The minimum number of ticks between initialized ticks
liquidityu128The currently in range liquidity available to the pool.
sqrt_price_x64u128The current price of the pool as a sqrt(token_1/token_0) Q64.64 value
tick_currenti32The current tick of the pool, i.e. according to the last tick transition that was run.
padding3u16
padding4u16
fee_growth_global0_x64u128The 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_growth_global1_x64u128
protocol_fees_token0u64The amounts of token_0 and token_1 that are owed to the protocol.
protocol_fees_token1u64
swap_in_amount_token0u128The amounts in and out of swap token_0 and token_1
swap_out_amount_token1u128
swap_in_amount_token1u128
swap_out_amount_token0u128
statusu8Bitwise 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
padding[u8; 7]Leave blank for future use
reward_infos[RewardInfo; 3]
tick_array_bitmap[u64; 16]Packed initialized tick array state
total_fees_token0u64except protocol_fee and fund_fee
total_fees_claimed_token0u64except protocol_fee and fund_fee
total_fees_token1u64
total_fees_claimed_token1u64
fund_fees_token0u64
fund_fees_token1u64
open_timeu64
recent_epochu64
padding1[u64; 24]
padding2[u64; 32]

ProtocolPositionState#

Discriminator 64e2916392daa06a · accounts::protocol_position_state::ProtocolPositionState.

FieldTypeDescription
bumpu8Bump to identify PDA
pool_idPubkeyThe ID of the pool with which this token is connected
tick_lower_indexi32The lower bound tick of the position
tick_upper_indexi32The upper bound tick of the position
liquidityu128The amount of liquidity owned by this position
fee_growth_inside0_last_x64u128The token_0 fee growth per unit of liquidity as of the last update to liquidity or fees owed
fee_growth_inside1_last_x64u128The token_1 fee growth per unit of liquidity as of the last update to liquidity or fees owed
token_fees_owed0u64The fees owed to the position owner in token_0
token_fees_owed1u64The fees owed to the position owner in token_1
reward_growth_inside[u128; 3]The reward growth per unit of liquidity as of the last update to liquidity
recent_epochu64
padding[u64; 7]

SupportMintAssociated#

Discriminator 8628b74f0c70a235 · accounts::support_mint_associated::SupportMintAssociated.

FieldTypeDescription
bumpu8Bump to identify PDA
mintPubkeyAddress of the supported token22 mint
padding[u64; 8]

TickArrayBitmapExtension#

Discriminator 3c9624db61808b99 · accounts::tick_array_bitmap_extension::TickArrayBitmapExtension.

FieldTypeDescription
pool_idPubkey
positive_tick_array_bitmap[[u64; 8]; 14]Packed initialized tick array state for start_tick_index is positive
negative_tick_array_bitmap[[u64; 8]; 14]Packed initialized tick array state for start_tick_index is negitive

TickArrayState#

Discriminator c09b55cd31f9812a · accounts::tick_array_state::TickArrayState.

FieldType
pool_idPubkey
start_tick_indexi32
ticks[TickState; 60]
initialized_tick_countu8
recent_epochu64
padding[u8; 107]

Events#

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

CollectPersonalFeeEvent#

Discriminator a6ae69c051a15369 · events::collect_personal_fee_event::CollectPersonalFeeEventEvent.

FieldTypeDescription
position_nft_mintPubkeyThe ID of the token for which underlying tokens were collected
recipient_token_account0PubkeyThe token account that received the collected token_0 tokens
recipient_token_account1PubkeyThe token account that received the collected token_1 tokens
amount0u64The amount of token_0 owed to the position that was collected
amount1u64The amount of token_1 owed to the position that was collected

CollectProtocolFeeEvent#

Discriminator ce57114f2d29d53d · events::collect_protocol_fee_event::CollectProtocolFeeEventEvent.

FieldTypeDescription
pool_statePubkeyThe pool whose protocol fee is collected
recipient_token_account0PubkeyThe address that receives the collected token_0 protocol fees
recipient_token_account1PubkeyThe address that receives the collected token_1 protocol fees
amount0u64The amount of token_0 protocol fees that is withdrawn
amount1u64The amount of token_0 protocol fees that is withdrawn

ConfigChangeEvent#

Discriminator f7bd07776a705f97 · events::config_change_event::ConfigChangeEventEvent.

FieldType
indexu16
ownerPubkey
protocol_fee_rateu32
trade_fee_rateu32
tick_spacingu16
fund_fee_rateu32
fund_ownerPubkey

CreatePersonalPositionEvent#

Discriminator 641e57f9c4df9ace · events::create_personal_position_event::CreatePersonalPositionEventEvent.

FieldTypeDescription
pool_statePubkeyThe pool for which liquidity was added
minterPubkeyThe address that create the position
nft_ownerPubkeyThe owner of the position and recipient of any minted liquidity
tick_lower_indexi32The lower tick of the position
tick_upper_indexi32The upper tick of the position
liquidityu128The amount of liquidity minted to the position range
deposit_amount0u64The amount of token_0 was deposit for the liquidity
deposit_amount1u64The amount of token_1 was deposit for the liquidity
deposit_amount0_transfer_feeu64The token transfer fee for deposit_amount_0
deposit_amount1_transfer_feeu64The token transfer fee for deposit_amount_1

DecreaseLiquidityEvent#

Discriminator 3ade563a44325538 · events::decrease_liquidity_event::DecreaseLiquidityEventEvent.

FieldTypeDescription
position_nft_mintPubkeyThe ID of the token for which liquidity was decreased
liquidityu128The amount by which liquidity for the position was decreased
decrease_amount0u64The amount of token_0 that was paid for the decrease in liquidity
decrease_amount1u64The amount of token_1 that was paid for the decrease in liquidity
fee_amount0u64
fee_amount1u64The amount of token_1 fee
reward_amounts[u64; 3]The amount of rewards
transfer_fee0u64The amount of token_0 transfer fee
transfer_fee1u64The amount of token_1 transfer fee

IncreaseLiquidityEvent#

Discriminator 314f69d420221e54 · events::increase_liquidity_event::IncreaseLiquidityEventEvent.

FieldTypeDescription
position_nft_mintPubkeyThe ID of the token for which liquidity was increased
liquidityu128The amount by which liquidity for the NFT position was increased
amount0u64The amount of token_0 that was paid for the increase in liquidity
amount1u64The amount of token_1 that was paid for the increase in liquidity
amount0_transfer_feeu64The token transfer fee for amount_0
amount1_transfer_feeu64The token transfer fee for amount_1

LiquidityCalculateEvent#

Discriminator ed7094e63954b4a2 · events::liquidity_calculate_event::LiquidityCalculateEventEvent.

FieldTypeDescription
pool_liquidityu128The pool liquidity before decrease or increase
pool_sqrt_price_x64u128The pool price when decrease or increase in liquidity
pool_ticki32The pool tick when decrease or increase in liquidity
calc_amount0u64The amount of token_0 that was calculated for the decrease or increase in liquidity
calc_amount1u64The amount of token_1 that was calculated for the decrease or increase in liquidity
trade_fee_owed0u64
trade_fee_owed1u64The amount of token_1 fee
transfer_fee0u64The amount of token_0 transfer fee without trade_fee_amount_0
transfer_fee1u64The amount of token_1 transfer fee without trade_fee_amount_0

LiquidityChangeEvent#

Discriminator 7ef0afce9e58996b · events::liquidity_change_event::LiquidityChangeEventEvent.

FieldTypeDescription
pool_statePubkeyThe pool for swap
ticki32The tick of the pool
tick_loweri32The tick lower of position
tick_upperi32The tick lower of position
liquidity_beforeu128The liquidity of the pool before liquidity change
liquidity_afteru128The liquidity of the pool after liquidity change

PoolCreatedEvent#

Discriminator 195e4b2f7063353f · events::pool_created_event::PoolCreatedEventEvent.

FieldTypeDescription
token_mint0PubkeyThe first token of the pool by address sort order
token_mint1PubkeyThe second token of the pool by address sort order
tick_spacingu16The minimum number of ticks between initialized ticks
pool_statePubkeyThe address of the created pool
sqrt_price_x64u128The initial sqrt price of the pool, as a Q64.64
ticki32The initial tick of the pool, i.e. log base 1.0001 of the starting price of the pool
token_vault0PubkeyVault of token_0
token_vault1PubkeyVault of token_1

SwapEvent#

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

FieldTypeDescription
pool_statePubkeyThe pool for which token_0 and token_1 were swapped
senderPubkeyThe address that initiated the swap call, and that received the callback
token_account0PubkeyThe payer token account in zero for one swaps, or the recipient token account in one for zero swaps
token_account1PubkeyThe payer token account in one for zero swaps, or the recipient token account in zero for one swaps
amount0u64The real delta amount of the token_0 of the pool or user
transfer_fee0u64The transfer fee charged by the withheld_amount of the token_0
amount1u64The real delta of the token_1 of the pool or user
transfer_fee1u64The transfer fee charged by the withheld_amount of the token_1
zero_for_oneboolif true, amount_0 is negtive and amount_1 is positive
sqrt_price_x64u128The sqrt(price) of the pool after the swap, as a Q64.64
liquidityu128The liquidity of the pool after the swap
ticki32The log base 1.0001 of price of the pool after the swap

UpdateRewardInfosEvent#

Discriminator 6d7fba4e724125ec · events::update_reward_infos_event::UpdateRewardInfosEventEvent.

FieldTypeDescription
reward_growth_global_x64[u128; 3]Reward info

Types#

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

CollectPersonalFeeEvent#

From the program's IDL:

Emitted when tokens are collected for a position

Struct types::CollectPersonalFeeEvent. 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::CollectProtocolFeeEvent. Same fields as the CollectProtocolFeeEvent event.

ConfigChangeEvent#

From the program's IDL:

Emitted when create or update a config

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

CreatePersonalPositionEvent#

From the program's IDL:

Emitted when create a new position

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

DecreaseLiquidityEvent#

From the program's IDL:

Emitted when liquidity is decreased.

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

IncreaseLiquidityEvent#

From the program's IDL:

Emitted when liquidity is increased.

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

InitializeRewardParam#

Struct types::InitializeRewardParam.

FieldTypeDescription
open_timeu64Reward open time
end_timeu64Reward end time
emissions_per_second_x64u128Token reward per second are earned per unit of liquidity

LiquidityCalculateEvent#

From the program's IDL:

Emitted when liquidity decreased or increase.

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

LiquidityChangeEvent#

From the program's IDL:

Emitted pool liquidity change when increase and decrease liquidity

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

Observation#

From the program's IDL:

The element of observations in ObservationState

Struct types::Observation.

FieldTypeDescription
block_timestampu32The block timestamp of the observation
tick_cumulativei64the cumulative of tick during the duration time
padding[u64; 4]padding for feature update

PoolCreatedEvent#

From the program's IDL:

Emitted when a pool is created and initialized with a starting price

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

PositionRewardInfo#

Struct types::PositionRewardInfo.

FieldType
growth_inside_last_x64u128
reward_amount_owedu64

RewardInfo#

Struct types::RewardInfo.

FieldTypeDescription
reward_stateu8Reward state
open_timeu64Reward open time
end_timeu64Reward end time
last_update_timeu64Reward last update time
emissions_per_second_x64u128Q64.64 number indicates how many tokens per second are earned per unit of liquidity.
reward_total_emissionedu64The total amount of reward emissioned
reward_claimedu64The total amount of claimed reward
token_mintPubkeyReward token mint.
token_vaultPubkeyReward vault token account.
authorityPubkeyThe owner that has permission to set reward param
reward_growth_global_x64u128Q64.64 number that tracks the total tokens earned per unit of liquidity since the reward emissions were turned on.

SwapEvent#

From the program's IDL:

Emitted by when a swap is performed for a pool

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

TickState#

Struct types::TickState.

FieldTypeDescription
ticki32
liquidity_neti128Amount of net liquidity added (subtracted) when tick is crossed from left to right (right to left)
liquidity_grossu128The total position liquidity that references this tick
fee_growth_outside0_x64u128Fee 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_growth_outside1_x64u128
reward_growths_outside_x64[u128; 3]
padding[u32; 13]

UpdateRewardInfosEvent#

From the program's IDL:

Emitted when Reward are updated for a pool

Struct types::UpdateRewardInfosEvent. Same fields as the UpdateRewardInfosEvent 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.