OnChain Labs DEX v2 decoder

Decode OnChain Labs DEX v2 instructions, accounts and events in Rust with the carbon-onchain-labs-dex-v2-decoder crate.

On this page

carbon-onchain-labs-dex-v2-decoder decodes the instructions, accounts and events of the OnChain Labs DEX v2 program (proVF4pMXVaYqmy4NjniPh4pqKNfMmsihgd4wdkCX3u): 19 instructions, 1 account type, 6 events. It is generated with Codama from the program's IDL; see decoders for how decoders plug into a pipeline.

Cratecarbon-onchain-labs-dex-v2-decoder 2.0.0
Installcargo add carbon-onchain-labs-dex-v2-decoder@2.0.0
Program IDproVF4pMXVaYqmy4NjniPh4pqKNfMmsihgd4wdkCX3u (carbon_onchain_labs_dex_v2_decoder::PROGRAM_ID)
CategoryAggregators & routing
Decodercarbon_onchain_labs_dex_v2_decoder::OnchainLabsDexV2Decoder
Instruction enuminstructions::OnchainLabsDexV2Instruction
Account enumaccounts::OnchainLabsDexV2Account
Event enuminstructions::CpiEvent
Featuresserde, postgres, graphql (none enabled by default)
API docsdocs.rs/carbon-onchain-labs-dex-v2-decoder/2.0.0
Sourcedecoders/onchain-labs-dex-v2-decoder

Other aggregator and routing decoders: DFlow Aggregator v4, Jupiter Swap, OKX DEX. To decode several in one pipeline, see aggregator and routing 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 OnChain Labs DEX v2 transactions from the public RPC and prints every decoded Swap instruction. Add the dependencies:

Terminal
cargo add carbon-core@2.0.0 carbon-onchain-labs-dex-v2-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_onchain_labs_dex_v2_decoder::{
        instructions::OnchainLabsDexV2Instruction, OnchainLabsDexV2Decoder, 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(OnchainLabsDexV2Decoder, InstructionLogger)
        .build()?
        .run()
        .await
}

struct InstructionLogger;

impl Processor<InstructionProcessorInputType<'_, OnchainLabsDexV2Instruction>> for InstructionLogger {
    async fn process(
        &mut self,
        input: &InstructionProcessorInputType<'_, OnchainLabsDexV2Instruction>,
    ) -> CarbonResult<()> {
        let signature = input.metadata.transaction_metadata.signature;
        if let OnchainLabsDexV2Instruction::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 OnchainLabsDexV2Instruction::CpiEvent { data: CpiEvent::SwapCpiEvent2(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 TokenLedger 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_onchain_labs_dex_v2_decoder::{
        accounts::OnchainLabsDexV2Account, OnchainLabsDexV2Decoder, 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(OnchainLabsDexV2Decoder, AccountLogger)
        .build()?
        .run()
        .await
}

struct AccountLogger;

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

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

Claim#

Discriminator 3ec6d6c1d59f6cd2 · data Claim · accounts ClaimInstructionAccounts.

No data fields.

Required accounts: 8 (9 listed); extras go to remaining.

Fields of ClaimInstructionAccounts, in account order:

#FieldType
0signerPubkey
1receiverPubkey
2source_token_accountOption<Pubkey>
3destination_token_accountOption<Pubkey>
4sa_authorityPubkey
5token_mintOption<Pubkey>
6token_programOption<Pubkey>
7system_programPubkey
8associated_token_programOption<Pubkey>
9…remainingVec<AccountMeta>

ClaimCashbackPumpfun#

Discriminator 5301f57dc9cfd1f9 · data ClaimCashbackPumpfun · accounts ClaimCashbackPumpfunInstructionAccounts.

No data fields.

Required accounts: 7; extras go to remaining.

Fields of ClaimCashbackPumpfunInstructionAccounts, in account order:

#FieldType
0signerPubkey
1sa_authorityPubkey
2user_volume_accumulatorPubkey
3receiverPubkey
4event_authorityPubkey
5system_programPubkey
6pumpfun_programPubkey
7…remainingVec<AccountMeta>

ClaimCashbackPumpswap#

Discriminator fdf2b0add94e6419 · data ClaimCashbackPumpswap · accounts ClaimCashbackPumpswapInstructionAccounts.

No data fields.

Required accounts: 11; extras go to remaining.

Fields of ClaimCashbackPumpswapInstructionAccounts, in account order:

#FieldType
0signerPubkey
1sa_authorityPubkey
2user_volume_accumulatorPubkey
3wsol_mintPubkey
4spl_token_programPubkey
5uva_wsol_ataPubkey
6sa_wsol_ataPubkey
7receiver_wsol_ataPubkey
8system_programPubkey
9event_authorityPubkey
10pumpswap_programPubkey
11…remainingVec<AccountMeta>

CreateTokenAccount#

Discriminator 93f17b64f484ae76 · data CreateTokenAccount · accounts CreateTokenAccountInstructionAccounts.

FieldType
bumpu8

Required accounts: 6; extras go to remaining.

Fields of CreateTokenAccountInstructionAccounts, in account order:

#FieldType
0payerPubkey
1ownerPubkey
2token_accountPubkey
3token_mintPubkey
4token_programPubkey
5system_programPubkey
6…remainingVec<AccountMeta>

CreateTokenAccountWithSeed#

Discriminator 7dbfef8c420809e4 · data CreateTokenAccountWithSeed · accounts CreateTokenAccountWithSeedInstructionAccounts.

FieldType
bumpu8
seedu32

Required accounts: 6; extras go to remaining.

Fields of CreateTokenAccountWithSeedInstructionAccounts, in account order:

#FieldType
0payerPubkey
1ownerPubkey
2token_accountPubkey
3token_mintPubkey
4token_programPubkey
5system_programPubkey
6…remainingVec<AccountMeta>

InitTokenLedger#

Discriminator 9d74423b89b4319d · data InitTokenLedger · accounts InitTokenLedgerInstructionAccounts.

FieldType
indexu8

Required accounts: 3; extras go to remaining.

Fields of InitTokenLedgerInstructionAccounts, in account order:

#FieldType
0payerPubkey
1token_ledgerPubkey
2system_programPubkey
3…remainingVec<AccountMeta>

ProxySwap#

Discriminator 132c829448382cee · data ProxySwap · accounts ProxySwapInstructionAccounts.

FieldType
argsSwapArgs

Required accounts: 14; extras go to remaining.

Fields of ProxySwapInstructionAccounts, in account order:

#FieldType
0payerPubkey
1source_token_accountPubkey
2destination_token_accountPubkey
3source_mintPubkey
4destination_mintPubkey
5sa_authorityOption<Pubkey>
6source_token_saOption<Pubkey>
7destination_token_saOption<Pubkey>
8source_token_programOption<Pubkey>
9destination_token_programOption<Pubkey>
10associated_token_programOption<Pubkey>
11system_programOption<Pubkey>
12event_authorityPubkey
13programPubkey
14…remainingVec<AccountMeta>

SetTokenLedger#

Discriminator e455b9704e4f4d02 · data SetTokenLedger · accounts SetTokenLedgerInstructionAccounts.

No data fields.

Required accounts: 2; extras go to remaining.

Fields of SetTokenLedgerInstructionAccounts, in account order:

#FieldType
0token_ledgerPubkey
1token_accountPubkey
2…remainingVec<AccountMeta>

Swap#

Discriminator f8c69e91e17587c8 · data Swap · accounts SwapInstructionAccounts.

FieldType
argsSwapArgs

Required accounts: 7; extras go to remaining.

Fields of SwapInstructionAccounts, in account order:

#FieldType
0payerPubkey
1source_token_accountPubkey
2destination_token_accountPubkey
3source_mintPubkey
4destination_mintPubkey
5event_authorityPubkey
6programPubkey
7…remainingVec<AccountMeta>

SwapTob#

Discriminator aa2955b184501f35 · data SwapTob · accounts SwapTobInstructionAccounts.

FieldType
argsSwapArgs
commission_infou32
platform_fee_rateu16
trim_rateu8

Required accounts: 16; extras go to remaining.

Fields of SwapTobInstructionAccounts, in account order:

#FieldType
0payerPubkey
1source_token_accountPubkey
2destination_token_accountPubkey
3source_mintPubkey
4destination_mintPubkey
5commission_accountOption<Pubkey>
6platform_fee_accountOption<Pubkey>
7sa_authorityOption<Pubkey>
8source_token_saOption<Pubkey>
9destination_token_saOption<Pubkey>
10source_token_programOption<Pubkey>
11destination_token_programOption<Pubkey>
12associated_token_programOption<Pubkey>
13system_programOption<Pubkey>
14event_authorityPubkey
15programPubkey
16…remainingVec<AccountMeta>

SwapTobEnhanced#

Discriminator be9ca9b0959aa16c · data SwapTobEnhanced · accounts SwapTobEnhancedInstructionAccounts.

FieldType
argsSwapArgs
commission_infou32
platform_fee_rateu16
trim_rateu8
charge_rateu16

Required accounts: 16; extras go to remaining.

Fields of SwapTobEnhancedInstructionAccounts, in account order:

#FieldType
0payerPubkey
1source_token_accountPubkey
2destination_token_accountPubkey
3source_mintPubkey
4destination_mintPubkey
5commission_accountOption<Pubkey>
6platform_fee_accountOption<Pubkey>
7sa_authorityOption<Pubkey>
8source_token_saOption<Pubkey>
9destination_token_saOption<Pubkey>
10source_token_programOption<Pubkey>
11destination_token_programOption<Pubkey>
12associated_token_programOption<Pubkey>
13system_programOption<Pubkey>
14event_authorityPubkey
15programPubkey
16…remainingVec<AccountMeta>

SwapTobV2#

From the program's IDL:

Used to support commission distribution between parent and child nodes in
TOB business

Discriminator 4801d7f2084b36d8 · data SwapTobV2 · accounts SwapTobV2InstructionAccounts.

FieldType
argsSwapArgs
total_commission_infou32
parent_commission_rateu32
platform_fee_rateu16
trim_rateu8

Required accounts: 17; extras go to remaining.

Fields of SwapTobV2InstructionAccounts, in account order:

#FieldType
0payerPubkey
1source_token_accountPubkey
2destination_token_accountPubkey
3source_mintPubkey
4destination_mintPubkey
5parent_commission_accountPubkey
6child_commission_accountPubkey
7platform_fee_accountOption<Pubkey>
8sa_authorityOption<Pubkey>
9source_token_saOption<Pubkey>
10destination_token_saOption<Pubkey>
11source_token_programOption<Pubkey>
12destination_token_programOption<Pubkey>
13associated_token_programOption<Pubkey>
14system_programOption<Pubkey>
15event_authorityPubkey
16programPubkey
17…remainingVec<AccountMeta>

SwapTobWithReceiver#

Discriminator dfaad8eacc06f119 · data SwapTobWithReceiver · accounts SwapTobWithReceiverInstructionAccounts.

FieldType
argsSwapArgs
commission_infou32
platform_fee_rateu16
trim_rateu8

Required accounts: 17; extras go to remaining.

Fields of SwapTobWithReceiverInstructionAccounts, in account order:

#FieldType
0payerPubkey
1source_token_accountPubkey
2destination_token_accountPubkey
3source_mintPubkey
4destination_mintPubkey
5commission_accountOption<Pubkey>
6platform_fee_accountOption<Pubkey>
7sa_authorityOption<Pubkey>
8source_token_saOption<Pubkey>
9destination_token_saOption<Pubkey>
10source_token_programOption<Pubkey>
11destination_token_programOption<Pubkey>
12associated_token_programOption<Pubkey>
13system_programOption<Pubkey>
14sol_receiverOption<Pubkey>
15event_authorityPubkey
16programPubkey
17…remainingVec<AccountMeta>

SwapTobWithReceiverTokenLedger#

Discriminator ef5d0acaa1867f82 · data SwapTobWithReceiverTokenLedger · accounts SwapTobWithReceiverTokenLedgerInstructionAccounts.

FieldType
argsSwapArgsTokenLedger
commission_infou32
platform_fee_rateu16
trim_rateu8

Required accounts: 18; extras go to remaining.

Fields of SwapTobWithReceiverTokenLedgerInstructionAccounts, in account order:

#FieldType
0payerPubkey
1source_token_accountPubkey
2destination_token_accountPubkey
3source_mintPubkey
4destination_mintPubkey
5commission_accountOption<Pubkey>
6platform_fee_accountOption<Pubkey>
7sa_authorityOption<Pubkey>
8source_token_saOption<Pubkey>
9destination_token_saOption<Pubkey>
10source_token_programOption<Pubkey>
11destination_token_programOption<Pubkey>
12associated_token_programOption<Pubkey>
13system_programOption<Pubkey>
14sol_receiverOption<Pubkey>
15token_ledgerPubkey
16event_authorityPubkey
17programPubkey
18…remainingVec<AccountMeta>

SwapTobWithTokenLedger#

Discriminator 245c93db1ab09f5a · data SwapTobWithTokenLedger · accounts SwapTobWithTokenLedgerInstructionAccounts.

FieldType
argsSwapArgsTokenLedger
commission_infou32
platform_fee_rateu16
trim_rateu8

Required accounts: 17; extras go to remaining.

Fields of SwapTobWithTokenLedgerInstructionAccounts, in account order:

#FieldType
0payerPubkey
1source_token_accountPubkey
2destination_token_accountPubkey
3source_mintPubkey
4destination_mintPubkey
5commission_accountOption<Pubkey>
6platform_fee_accountOption<Pubkey>
7sa_authorityOption<Pubkey>
8source_token_saOption<Pubkey>
9destination_token_saOption<Pubkey>
10source_token_programOption<Pubkey>
11destination_token_programOption<Pubkey>
12associated_token_programOption<Pubkey>
13system_programOption<Pubkey>
14token_ledgerPubkey
15event_authorityPubkey
16programPubkey
17…remainingVec<AccountMeta>

SwapToc#

Discriminator bbc9d433109bec3c · data SwapToc · accounts SwapTocInstructionAccounts.

FieldType
argsSwapArgs
commission_infou32
platform_fee_rateu16

Required accounts: 16; extras go to remaining.

Fields of SwapTocInstructionAccounts, in account order:

#FieldType
0payerPubkey
1source_token_accountPubkey
2destination_token_accountPubkey
3source_mintPubkey
4destination_mintPubkey
5commission_accountOption<Pubkey>
6platform_fee_accountOption<Pubkey>
7sa_authorityOption<Pubkey>
8source_token_saOption<Pubkey>
9destination_token_saOption<Pubkey>
10source_token_programOption<Pubkey>
11destination_token_programOption<Pubkey>
12associated_token_programOption<Pubkey>
13system_programOption<Pubkey>
14event_authorityPubkey
15programPubkey
16…remainingVec<AccountMeta>

SwapTocV2#

From the program's IDL:

Used to support commission distribution between parent and child nodes in
TOC business

Discriminator 7fd66bbd175a2f68 · data SwapTocV2 · accounts SwapTocV2InstructionAccounts.

FieldType
argsSwapArgs
total_commission_infou32
parent_commission_rateu32
platform_fee_rateu16

Required accounts: 17; extras go to remaining.

Fields of SwapTocV2InstructionAccounts, in account order:

#FieldType
0payerPubkey
1source_token_accountPubkey
2destination_token_accountPubkey
3source_mintPubkey
4destination_mintPubkey
5parent_commission_accountPubkey
6child_commission_accountPubkey
7platform_fee_accountOption<Pubkey>
8sa_authorityOption<Pubkey>
9source_token_saOption<Pubkey>
10destination_token_saOption<Pubkey>
11source_token_programOption<Pubkey>
12destination_token_programOption<Pubkey>
13associated_token_programOption<Pubkey>
14system_programOption<Pubkey>
15event_authorityPubkey
16programPubkey
17…remainingVec<AccountMeta>

WrapUnwrap#

Discriminator dc658bf929be76c7 · data WrapUnwrap · accounts WrapUnwrapInstructionAccounts.

Required accounts: 12; extras go to remaining.

Fields of WrapUnwrapInstructionAccounts, in account order:

#FieldType
0payerPubkey
1payer_wsol_accountPubkey
2wsol_mintPubkey
3temp_wsol_accountOption<Pubkey>
4commission_accountOption<Pubkey>
5platform_fee_accountOption<Pubkey>
6authority_pdaOption<Pubkey>
7wsol_saOption<Pubkey>
8token_programPubkey
9system_programPubkey
10event_authorityPubkey
11programPubkey
12…remainingVec<AccountMeta>

WrapUnwrapWithReceiver#

From the program's IDL:

Wrap/Unwrap with optional specified receiver

  • Wrap (SOL -> WSOL): receiver is WSOL token account (ATA)
  • Unwrap (WSOL -> SOL): receiver is system account (EOA)

Transfer amount:

  • From fee: amount_in
  • To fee: amount_in - fees

Discriminator 7b192f86e9a7abaa · data WrapUnwrapWithReceiver · accounts WrapUnwrapWithReceiverInstructionAccounts.

Required accounts: 13; extras go to remaining.

Fields of WrapUnwrapWithReceiverInstructionAccounts, in account order:

#FieldType
0payerPubkey
1payer_wsol_accountPubkey
2wsol_mintPubkey
3temp_wsol_accountOption<Pubkey>
4commission_accountOption<Pubkey>
5platform_fee_accountOption<Pubkey>
6authority_pdaOption<Pubkey>
7wsol_saOption<Pubkey>
8token_programPubkey
9system_programPubkey
10receiverPubkey
11event_authorityPubkey
12programPubkey
13…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 OnchainLabsDexV2Account. Each wraps a boxed struct from carbon_onchain_labs_dex_v2_decoder::accounts::<module>. decode_account only considers accounts owned by PROGRAM_ID and returns the first variant that matches.

TokenLedger#

Discriminator 9cf709bc366c554d · accounts::token_ledger::TokenLedger.

FieldType
token_accountPubkey
amountu64

Events#

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

SwapCpiEvent2#

Discriminator 155ee035dce8c15e · events::swap_cpi_event2::SwapCpiEvent2Event.

FieldType
order_idu64
source_mintPubkey
destination_mintPubkey
source_token_account_ownerPubkey
destination_token_account_ownerPubkey
amount_inu64
source_token_changeu64
destination_token_changeu64

SwapEvent#

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

FieldType
dexDex
amount_inu64
amount_outu64

SwapTobV2CpiEvent2#

Discriminator f469b85a3ca52421 · events::swap_tob_v2_cpi_event2::SwapTobV2CpiEvent2Event.

FieldType
order_idu64
source_mintPubkey
destination_mintPubkey
source_token_account_ownerPubkey
destination_token_account_ownerPubkey
amount_inu64
source_token_changeu64
destination_token_changeu64
commission_directionbool
total_commission_rateu32
parent_commission_rateu32
parent_commission_amountu64
parent_commission_accountPubkey
child_commission_rateu32
child_commission_amountu64
child_commission_accountPubkey
platform_fee_rateu16
platform_fee_amountu64
platform_fee_accountPubkey
trim_rateu8
trim_amountu64
trim_accountPubkey

SwapTocV2CpiEvent2#

Discriminator 6610b53ec947d429 · events::swap_toc_v2_cpi_event2::SwapTocV2CpiEvent2Event.

FieldType
order_idu64
source_mintPubkey
destination_mintPubkey
source_token_account_ownerPubkey
destination_token_account_ownerPubkey
amount_inu64
source_token_changeu64
destination_token_changeu64
commission_directionbool
total_commission_rateu32
parent_commission_rateu32
parent_commission_amountu64
parent_commission_accountPubkey
child_commission_rateu32
child_commission_amountu64
child_commission_accountPubkey
platform_fee_rateu16
platform_fee_amountu64
platform_fee_accountPubkey

SwapWithFeesCpiEvent2#

Discriminator 0c86265da7972a45 · events::swap_with_fees_cpi_event2::SwapWithFeesCpiEvent2Event.

FieldType
order_idu64
source_mintPubkey
destination_mintPubkey
source_token_account_ownerPubkey
destination_token_account_ownerPubkey
amount_inu64
source_token_changeu64
destination_token_changeu64
commission_directionbool
commission_rateu32
commission_amountu64
commission_accountPubkey
platform_fee_rateu16
platform_fee_amountu64
platform_fee_accountPubkey
trim_rateu8
trim_amountu64
trim_accountPubkey

SwapWithFeesCpiEventEnhanced2#

Discriminator 544fdbf7da9cdbb1 · events::swap_with_fees_cpi_event_enhanced2::SwapWithFeesCpiEventEnhanced2Event.

FieldType
order_idu64
source_mintPubkey
destination_mintPubkey
source_token_account_ownerPubkey
destination_token_account_ownerPubkey
amount_inu64
source_token_changeu64
destination_token_changeu64
commission_directionbool
commission_rateu32
commission_amountu64
commission_accountPubkey
platform_fee_rateu16
platform_fee_amountu64
platform_fee_accountPubkey
trim_rateu8
trim_amountu64
trim_accountPubkey
charge_rateu16
charge_amountu64
charge_accountPubkey

Types#

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

Dex#

Enum types::Dex.

VariantFields
SplTokenSwap
StableSwap
Whirlpool
MeteoraDynamicpool
RaydiumSwap
RaydiumStableSwap
RaydiumClmmSwap
AldrinExchangeV1
AldrinExchangeV2
LifinityV1
LifinityV2
RaydiumClmmSwapV2
FluxBeam
MeteoraDlmm
RaydiumCpmmSwap
OpenBookV2
WhirlpoolV2
Phoenix
ObricV2
SanctumAddLiq
SanctumRemoveLiq
SanctumNonWsolSwap
SanctumWsolSwap
PumpfunBuy
PumpfunSell
StabbleSwap
SanctumRouter
MeteoraVaultDeposit
MeteoraVaultWithdraw
Saros
MeteoraLst
Solfi
QualiaSwap
Zerofi
PumpfunammBuy
PumpfunammSell
Virtuals
VertigoBuy
VertigoSell
PerpetualsAddLiq
PerpetualsRemoveLiq
PerpetualsSwap
RaydiumLaunchpad
LetsBonkFun
Woofi
MeteoraDbc
MeteoraDlmmSwap2
MeteoraDAMMV2
Gavel
BoopfunBuy
BoopfunSell
MeteoraDbc2
GooseFX
Dooar
Numeraire
SaberDecimalWrapperDeposit
SaberDecimalWrapperWithdraw
SarosDlmm
OneDexSwap
Manifest
ByrealClmm
PancakeSwapV3Swap
PancakeSwapV3SwapV2
Tessera
SolRfqrfq_id: u64, expected_maker_amount: u64, expected_taker_amount: u64, maker_send_amount: u64, taker_send_amount: u64, expiry: u64, maker_use_native_sol: bool, taker_use_native_sol: bool
Humidifi
HeavenBuy
HeavenSell
SolfiV2
Goonfi
MoonitBuy
MoonitSell
RaydiumSwapV2
Whalestreet
SugarMoneyBuybonding_curve_bump: u8, bonding_curve_sol_associated_account_bump: u8
SugarMoneySellbonding_curve_bump: u8, bonding_curve_sol_associated_account_bump: u8
MeteoraDAMMV2Swap2
AlphaQ
FutarchyAmm
PumpfunBuy2
PumpfunSell2
HumidifiSwap2swap_id: u64
Scorchid: u128
JupiterLendDeposit
JupiterLendRedeem
TaurusFi
BisonFi
GoonfiV2
Quantum
BoopfunBuy2
BoopfunSell2
ByrealClmm2
Dooar2
HeavenBuy2
HeavenSell2
MoonitBuy2
MoonitSell2
SaberDecimalWrapperDeposit2
SaberDecimalWrapperWithdraw2
ByrealPropAmm
SanctumPrefundSwapViaStakeswap_id: u64
AbyssAmm
Aquifer
WhalestreetV2auth_amount_in: u64, auth: u64
SolfiV2WithSigunix_timestamp: u64, msg_amount_in: u64, expect_amount_out: u64, slippage: u16, user_request_slot: u64, signature: [u8; 64], recovery_id: u8
FusionAmm
ScaleAmmBuy
ScaleAmmSell
ScaleVmmBuy
ScaleVmmSell
PumpfunBuy3
PumpfunSell3
PumpfunammBuy2
PumpfunammSell2
Riptide
ZerofiSwapV2
TaurusFiV2

PlatformFeeWrapUnwrapArgs#

Struct types::PlatformFeeWrapUnwrapArgs.

FieldType
order_idu64
amount_inu64
commission_infou32
platform_fee_rateu16
tobbool

Route#

Struct types::Route.

FieldType
dexDex
weightu16
indexu8

SwapArgs#

Struct types::SwapArgs.

FieldType
order_idu64
amount_inu64
expect_amount_outu64
slippageu16
routesVec<Route>

SwapArgsTokenLedger#

From the program's IDL:

Swap args for token-ledger swaps: no amount_in parameter.
amount_in is derived on-chain from token_ledger delta.

Struct types::SwapArgsTokenLedger.

FieldType
order_idu64
expect_amount_outu64
slippageu16
routesVec<Route>

SwapCpiEvent2#

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

SwapEvent#

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

SwapTobV2CpiEvent2#

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

SwapTocV2CpiEvent2#

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

SwapWithFeesCpiEvent2#

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

SwapWithFeesCpiEventEnhanced2#

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