# OnChain Labs DEX v2 decoder (Carbon 2.0)

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

`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](https://carbon.sevenlabs.org/concepts/decoders.md) for how decoders plug into a pipeline.

|                  |                                                                                                                                 |
| ---------------- | ------------------------------------------------------------------------------------------------------------------------------- |
| Crate            | [`carbon-onchain-labs-dex-v2-decoder`](https://crates.io/crates/carbon-onchain-labs-dex-v2-decoder/2.0.0) 2.0.0                 |
| Install          | `cargo add carbon-onchain-labs-dex-v2-decoder@2.0.0`                                                                            |
| Program ID       | `proVF4pMXVaYqmy4NjniPh4pqKNfMmsihgd4wdkCX3u` (`carbon_onchain_labs_dex_v2_decoder::PROGRAM_ID`)                                |
| Category         | [Aggregators & routing](https://carbon.sevenlabs.org/decoders/aggregators.md)                                                   |
| Decoder          | `carbon_onchain_labs_dex_v2_decoder::OnchainLabsDexV2Decoder`                                                                   |
| Instruction enum | `instructions::OnchainLabsDexV2Instruction`                                                                                     |
| Account enum     | `accounts::OnchainLabsDexV2Account`                                                                                             |
| Event enum       | `instructions::CpiEvent`                                                                                                        |
| Features         | `serde`, `postgres`, `graphql` (none enabled by default)                                                                        |
| API docs         | [docs.rs/carbon-onchain-labs-dex-v2-decoder/2.0.0](https://docs.rs/carbon-onchain-labs-dex-v2-decoder/2.0.0)                    |
| Source           | [decoders/onchain-labs-dex-v2-decoder](https://github.com/sevenlabs-hq/carbon/tree/v2.0.0/decoders/onchain-labs-dex-v2-decoder) |

Other aggregator and routing decoders: [DFlow Aggregator v4](https://carbon.sevenlabs.org/decoders/dflow-aggregator-v4.md), [Jupiter Swap](https://carbon.sevenlabs.org/decoders/jupiter-swap.md), [OKX DEX](https://carbon.sevenlabs.org/decoders/okx-dex.md). To decode several in one pipeline, see [aggregator and routing decoders](https://carbon.sevenlabs.org/decoders/aggregators.md).

The `serde` feature derives `Serialize`/`Deserialize` on every type, `postgres` adds tables and processors for [Postgres](https://carbon.sevenlabs.org/guides/postgres.md), and `graphql` adds a schema for the [GraphQL server](https://carbon.sevenlabs.org/guides/graphql.md).

## Usage

This program crawls recent OnChain Labs DEX v2 transactions from the public RPC and prints every decoded `Swap` instruction. Add the dependencies:

```sh
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`:

```rust
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(())
    }
}
```

```sh
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](https://carbon.sevenlabs.org/guides/stream-with-rpc.md) 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](#events). If `CpiEvent` never arrives, the program logs its events with `emit!` instead: decode them with [`decode_log_events`](https://carbon.sevenlabs.org/concepts/instructions.md#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:

```sh
cargo add carbon-rpc-program-subscribe-datasource@2.0.0 solana-client@4.2.2
```

`src/main.rs`:

```rust
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(())
    }
}
```

```sh
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](https://carbon.sevenlabs.org/guides/load-account-state.md).

## 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 `AccountMeta`s. 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:

| #  | Field                       | Type               |
| -- | --------------------------- | ------------------ |
| 0  | `signer`                    | `Pubkey`           |
| 1  | `receiver`                  | `Pubkey`           |
| 2  | `source_token_account`      | `Option<Pubkey>`   |
| 3  | `destination_token_account` | `Option<Pubkey>`   |
| 4  | `sa_authority`              | `Pubkey`           |
| 5  | `token_mint`                | `Option<Pubkey>`   |
| 6  | `token_program`             | `Option<Pubkey>`   |
| 7  | `system_program`            | `Pubkey`           |
| 8  | `associated_token_program`  | `Option<Pubkey>`   |
| 9… | `remaining`                 | `Vec<AccountMeta>` |

### `ClaimCashbackPumpfun`

Discriminator `5301f57dc9cfd1f9` · data `ClaimCashbackPumpfun` · accounts `ClaimCashbackPumpfunInstructionAccounts`.

No data fields.

Required accounts: 7; extras go to `remaining`.

Fields of `ClaimCashbackPumpfunInstructionAccounts`, in account order:

| #  | Field                     | Type               |
| -- | ------------------------- | ------------------ |
| 0  | `signer`                  | `Pubkey`           |
| 1  | `sa_authority`            | `Pubkey`           |
| 2  | `user_volume_accumulator` | `Pubkey`           |
| 3  | `receiver`                | `Pubkey`           |
| 4  | `event_authority`         | `Pubkey`           |
| 5  | `system_program`          | `Pubkey`           |
| 6  | `pumpfun_program`         | `Pubkey`           |
| 7… | `remaining`               | `Vec<AccountMeta>` |

### `ClaimCashbackPumpswap`

Discriminator `fdf2b0add94e6419` · data `ClaimCashbackPumpswap` · accounts `ClaimCashbackPumpswapInstructionAccounts`.

No data fields.

Required accounts: 11; extras go to `remaining`.

Fields of `ClaimCashbackPumpswapInstructionAccounts`, in account order:

| #   | Field                     | Type               |
| --- | ------------------------- | ------------------ |
| 0   | `signer`                  | `Pubkey`           |
| 1   | `sa_authority`            | `Pubkey`           |
| 2   | `user_volume_accumulator` | `Pubkey`           |
| 3   | `wsol_mint`               | `Pubkey`           |
| 4   | `spl_token_program`       | `Pubkey`           |
| 5   | `uva_wsol_ata`            | `Pubkey`           |
| 6   | `sa_wsol_ata`             | `Pubkey`           |
| 7   | `receiver_wsol_ata`       | `Pubkey`           |
| 8   | `system_program`          | `Pubkey`           |
| 9   | `event_authority`         | `Pubkey`           |
| 10  | `pumpswap_program`        | `Pubkey`           |
| 11… | `remaining`               | `Vec<AccountMeta>` |

### `CreateTokenAccount`

Discriminator `93f17b64f484ae76` · data `CreateTokenAccount` · accounts `CreateTokenAccountInstructionAccounts`.

| Field  | Type |
| ------ | ---- |
| `bump` | `u8` |

Required accounts: 6; extras go to `remaining`.

Fields of `CreateTokenAccountInstructionAccounts`, in account order:

| #  | Field            | Type               |
| -- | ---------------- | ------------------ |
| 0  | `payer`          | `Pubkey`           |
| 1  | `owner`          | `Pubkey`           |
| 2  | `token_account`  | `Pubkey`           |
| 3  | `token_mint`     | `Pubkey`           |
| 4  | `token_program`  | `Pubkey`           |
| 5  | `system_program` | `Pubkey`           |
| 6… | `remaining`      | `Vec<AccountMeta>` |

### `CreateTokenAccountWithSeed`

Discriminator `7dbfef8c420809e4` · data `CreateTokenAccountWithSeed` · accounts `CreateTokenAccountWithSeedInstructionAccounts`.

| Field  | Type  |
| ------ | ----- |
| `bump` | `u8`  |
| `seed` | `u32` |

Required accounts: 6; extras go to `remaining`.

Fields of `CreateTokenAccountWithSeedInstructionAccounts`, in account order:

| #  | Field            | Type               |
| -- | ---------------- | ------------------ |
| 0  | `payer`          | `Pubkey`           |
| 1  | `owner`          | `Pubkey`           |
| 2  | `token_account`  | `Pubkey`           |
| 3  | `token_mint`     | `Pubkey`           |
| 4  | `token_program`  | `Pubkey`           |
| 5  | `system_program` | `Pubkey`           |
| 6… | `remaining`      | `Vec<AccountMeta>` |

### `InitTokenLedger`

Discriminator `9d74423b89b4319d` · data `InitTokenLedger` · accounts `InitTokenLedgerInstructionAccounts`.

| Field   | Type |
| ------- | ---- |
| `index` | `u8` |

Required accounts: 3; extras go to `remaining`.

Fields of `InitTokenLedgerInstructionAccounts`, in account order:

| #  | Field            | Type               |
| -- | ---------------- | ------------------ |
| 0  | `payer`          | `Pubkey`           |
| 1  | `token_ledger`   | `Pubkey`           |
| 2  | `system_program` | `Pubkey`           |
| 3… | `remaining`      | `Vec<AccountMeta>` |

### `ProxySwap`

Discriminator `132c829448382cee` · data `ProxySwap` · accounts `ProxySwapInstructionAccounts`.

| Field  | Type                    |
| ------ | ----------------------- |
| `args` | [`SwapArgs`](#swapargs) |

Required accounts: 14; extras go to `remaining`.

Fields of `ProxySwapInstructionAccounts`, in account order:

| #   | Field                       | Type               |
| --- | --------------------------- | ------------------ |
| 0   | `payer`                     | `Pubkey`           |
| 1   | `source_token_account`      | `Pubkey`           |
| 2   | `destination_token_account` | `Pubkey`           |
| 3   | `source_mint`               | `Pubkey`           |
| 4   | `destination_mint`          | `Pubkey`           |
| 5   | `sa_authority`              | `Option<Pubkey>`   |
| 6   | `source_token_sa`           | `Option<Pubkey>`   |
| 7   | `destination_token_sa`      | `Option<Pubkey>`   |
| 8   | `source_token_program`      | `Option<Pubkey>`   |
| 9   | `destination_token_program` | `Option<Pubkey>`   |
| 10  | `associated_token_program`  | `Option<Pubkey>`   |
| 11  | `system_program`            | `Option<Pubkey>`   |
| 12  | `event_authority`           | `Pubkey`           |
| 13  | `program`                   | `Pubkey`           |
| 14… | `remaining`                 | `Vec<AccountMeta>` |

### `SetTokenLedger`

Discriminator `e455b9704e4f4d02` · data `SetTokenLedger` · accounts `SetTokenLedgerInstructionAccounts`.

No data fields.

Required accounts: 2; extras go to `remaining`.

Fields of `SetTokenLedgerInstructionAccounts`, in account order:

| #  | Field           | Type               |
| -- | --------------- | ------------------ |
| 0  | `token_ledger`  | `Pubkey`           |
| 1  | `token_account` | `Pubkey`           |
| 2… | `remaining`     | `Vec<AccountMeta>` |

### `Swap`

Discriminator `f8c69e91e17587c8` · data `Swap` · accounts `SwapInstructionAccounts`.

| Field  | Type                    |
| ------ | ----------------------- |
| `args` | [`SwapArgs`](#swapargs) |

Required accounts: 7; extras go to `remaining`.

Fields of `SwapInstructionAccounts`, in account order:

| #  | Field                       | Type               |
| -- | --------------------------- | ------------------ |
| 0  | `payer`                     | `Pubkey`           |
| 1  | `source_token_account`      | `Pubkey`           |
| 2  | `destination_token_account` | `Pubkey`           |
| 3  | `source_mint`               | `Pubkey`           |
| 4  | `destination_mint`          | `Pubkey`           |
| 5  | `event_authority`           | `Pubkey`           |
| 6  | `program`                   | `Pubkey`           |
| 7… | `remaining`                 | `Vec<AccountMeta>` |

### `SwapTob`

Discriminator `aa2955b184501f35` · data `SwapTob` · accounts `SwapTobInstructionAccounts`.

| Field               | Type                    |
| ------------------- | ----------------------- |
| `args`              | [`SwapArgs`](#swapargs) |
| `commission_info`   | `u32`                   |
| `platform_fee_rate` | `u16`                   |
| `trim_rate`         | `u8`                    |

Required accounts: 16; extras go to `remaining`.

Fields of `SwapTobInstructionAccounts`, in account order:

| #   | Field                       | Type               |
| --- | --------------------------- | ------------------ |
| 0   | `payer`                     | `Pubkey`           |
| 1   | `source_token_account`      | `Pubkey`           |
| 2   | `destination_token_account` | `Pubkey`           |
| 3   | `source_mint`               | `Pubkey`           |
| 4   | `destination_mint`          | `Pubkey`           |
| 5   | `commission_account`        | `Option<Pubkey>`   |
| 6   | `platform_fee_account`      | `Option<Pubkey>`   |
| 7   | `sa_authority`              | `Option<Pubkey>`   |
| 8   | `source_token_sa`           | `Option<Pubkey>`   |
| 9   | `destination_token_sa`      | `Option<Pubkey>`   |
| 10  | `source_token_program`      | `Option<Pubkey>`   |
| 11  | `destination_token_program` | `Option<Pubkey>`   |
| 12  | `associated_token_program`  | `Option<Pubkey>`   |
| 13  | `system_program`            | `Option<Pubkey>`   |
| 14  | `event_authority`           | `Pubkey`           |
| 15  | `program`                   | `Pubkey`           |
| 16… | `remaining`                 | `Vec<AccountMeta>` |

### `SwapTobEnhanced`

Discriminator `be9ca9b0959aa16c` · data `SwapTobEnhanced` · accounts `SwapTobEnhancedInstructionAccounts`.

| Field               | Type                    |
| ------------------- | ----------------------- |
| `args`              | [`SwapArgs`](#swapargs) |
| `commission_info`   | `u32`                   |
| `platform_fee_rate` | `u16`                   |
| `trim_rate`         | `u8`                    |
| `charge_rate`       | `u16`                   |

Required accounts: 16; extras go to `remaining`.

Fields of `SwapTobEnhancedInstructionAccounts`, in account order:

| #   | Field                       | Type               |
| --- | --------------------------- | ------------------ |
| 0   | `payer`                     | `Pubkey`           |
| 1   | `source_token_account`      | `Pubkey`           |
| 2   | `destination_token_account` | `Pubkey`           |
| 3   | `source_mint`               | `Pubkey`           |
| 4   | `destination_mint`          | `Pubkey`           |
| 5   | `commission_account`        | `Option<Pubkey>`   |
| 6   | `platform_fee_account`      | `Option<Pubkey>`   |
| 7   | `sa_authority`              | `Option<Pubkey>`   |
| 8   | `source_token_sa`           | `Option<Pubkey>`   |
| 9   | `destination_token_sa`      | `Option<Pubkey>`   |
| 10  | `source_token_program`      | `Option<Pubkey>`   |
| 11  | `destination_token_program` | `Option<Pubkey>`   |
| 12  | `associated_token_program`  | `Option<Pubkey>`   |
| 13  | `system_program`            | `Option<Pubkey>`   |
| 14  | `event_authority`           | `Pubkey`           |
| 15  | `program`                   | `Pubkey`           |
| 16… | `remaining`                 | `Vec<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`.

| Field                    | Type                    |
| ------------------------ | ----------------------- |
| `args`                   | [`SwapArgs`](#swapargs) |
| `total_commission_info`  | `u32`                   |
| `parent_commission_rate` | `u32`                   |
| `platform_fee_rate`      | `u16`                   |
| `trim_rate`              | `u8`                    |

Required accounts: 17; extras go to `remaining`.

Fields of `SwapTobV2InstructionAccounts`, in account order:

| #   | Field                       | Type               |
| --- | --------------------------- | ------------------ |
| 0   | `payer`                     | `Pubkey`           |
| 1   | `source_token_account`      | `Pubkey`           |
| 2   | `destination_token_account` | `Pubkey`           |
| 3   | `source_mint`               | `Pubkey`           |
| 4   | `destination_mint`          | `Pubkey`           |
| 5   | `parent_commission_account` | `Pubkey`           |
| 6   | `child_commission_account`  | `Pubkey`           |
| 7   | `platform_fee_account`      | `Option<Pubkey>`   |
| 8   | `sa_authority`              | `Option<Pubkey>`   |
| 9   | `source_token_sa`           | `Option<Pubkey>`   |
| 10  | `destination_token_sa`      | `Option<Pubkey>`   |
| 11  | `source_token_program`      | `Option<Pubkey>`   |
| 12  | `destination_token_program` | `Option<Pubkey>`   |
| 13  | `associated_token_program`  | `Option<Pubkey>`   |
| 14  | `system_program`            | `Option<Pubkey>`   |
| 15  | `event_authority`           | `Pubkey`           |
| 16  | `program`                   | `Pubkey`           |
| 17… | `remaining`                 | `Vec<AccountMeta>` |

### `SwapTobWithReceiver`

Discriminator `dfaad8eacc06f119` · data `SwapTobWithReceiver` · accounts `SwapTobWithReceiverInstructionAccounts`.

| Field               | Type                    |
| ------------------- | ----------------------- |
| `args`              | [`SwapArgs`](#swapargs) |
| `commission_info`   | `u32`                   |
| `platform_fee_rate` | `u16`                   |
| `trim_rate`         | `u8`                    |

Required accounts: 17; extras go to `remaining`.

Fields of `SwapTobWithReceiverInstructionAccounts`, in account order:

| #   | Field                       | Type               |
| --- | --------------------------- | ------------------ |
| 0   | `payer`                     | `Pubkey`           |
| 1   | `source_token_account`      | `Pubkey`           |
| 2   | `destination_token_account` | `Pubkey`           |
| 3   | `source_mint`               | `Pubkey`           |
| 4   | `destination_mint`          | `Pubkey`           |
| 5   | `commission_account`        | `Option<Pubkey>`   |
| 6   | `platform_fee_account`      | `Option<Pubkey>`   |
| 7   | `sa_authority`              | `Option<Pubkey>`   |
| 8   | `source_token_sa`           | `Option<Pubkey>`   |
| 9   | `destination_token_sa`      | `Option<Pubkey>`   |
| 10  | `source_token_program`      | `Option<Pubkey>`   |
| 11  | `destination_token_program` | `Option<Pubkey>`   |
| 12  | `associated_token_program`  | `Option<Pubkey>`   |
| 13  | `system_program`            | `Option<Pubkey>`   |
| 14  | `sol_receiver`              | `Option<Pubkey>`   |
| 15  | `event_authority`           | `Pubkey`           |
| 16  | `program`                   | `Pubkey`           |
| 17… | `remaining`                 | `Vec<AccountMeta>` |

### `SwapTobWithReceiverTokenLedger`

Discriminator `ef5d0acaa1867f82` · data `SwapTobWithReceiverTokenLedger` · accounts `SwapTobWithReceiverTokenLedgerInstructionAccounts`.

| Field               | Type                                          |
| ------------------- | --------------------------------------------- |
| `args`              | [`SwapArgsTokenLedger`](#swapargstokenledger) |
| `commission_info`   | `u32`                                         |
| `platform_fee_rate` | `u16`                                         |
| `trim_rate`         | `u8`                                          |

Required accounts: 18; extras go to `remaining`.

Fields of `SwapTobWithReceiverTokenLedgerInstructionAccounts`, in account order:

| #   | Field                       | Type               |
| --- | --------------------------- | ------------------ |
| 0   | `payer`                     | `Pubkey`           |
| 1   | `source_token_account`      | `Pubkey`           |
| 2   | `destination_token_account` | `Pubkey`           |
| 3   | `source_mint`               | `Pubkey`           |
| 4   | `destination_mint`          | `Pubkey`           |
| 5   | `commission_account`        | `Option<Pubkey>`   |
| 6   | `platform_fee_account`      | `Option<Pubkey>`   |
| 7   | `sa_authority`              | `Option<Pubkey>`   |
| 8   | `source_token_sa`           | `Option<Pubkey>`   |
| 9   | `destination_token_sa`      | `Option<Pubkey>`   |
| 10  | `source_token_program`      | `Option<Pubkey>`   |
| 11  | `destination_token_program` | `Option<Pubkey>`   |
| 12  | `associated_token_program`  | `Option<Pubkey>`   |
| 13  | `system_program`            | `Option<Pubkey>`   |
| 14  | `sol_receiver`              | `Option<Pubkey>`   |
| 15  | `token_ledger`              | `Pubkey`           |
| 16  | `event_authority`           | `Pubkey`           |
| 17  | `program`                   | `Pubkey`           |
| 18… | `remaining`                 | `Vec<AccountMeta>` |

### `SwapTobWithTokenLedger`

Discriminator `245c93db1ab09f5a` · data `SwapTobWithTokenLedger` · accounts `SwapTobWithTokenLedgerInstructionAccounts`.

| Field               | Type                                          |
| ------------------- | --------------------------------------------- |
| `args`              | [`SwapArgsTokenLedger`](#swapargstokenledger) |
| `commission_info`   | `u32`                                         |
| `platform_fee_rate` | `u16`                                         |
| `trim_rate`         | `u8`                                          |

Required accounts: 17; extras go to `remaining`.

Fields of `SwapTobWithTokenLedgerInstructionAccounts`, in account order:

| #   | Field                       | Type               |
| --- | --------------------------- | ------------------ |
| 0   | `payer`                     | `Pubkey`           |
| 1   | `source_token_account`      | `Pubkey`           |
| 2   | `destination_token_account` | `Pubkey`           |
| 3   | `source_mint`               | `Pubkey`           |
| 4   | `destination_mint`          | `Pubkey`           |
| 5   | `commission_account`        | `Option<Pubkey>`   |
| 6   | `platform_fee_account`      | `Option<Pubkey>`   |
| 7   | `sa_authority`              | `Option<Pubkey>`   |
| 8   | `source_token_sa`           | `Option<Pubkey>`   |
| 9   | `destination_token_sa`      | `Option<Pubkey>`   |
| 10  | `source_token_program`      | `Option<Pubkey>`   |
| 11  | `destination_token_program` | `Option<Pubkey>`   |
| 12  | `associated_token_program`  | `Option<Pubkey>`   |
| 13  | `system_program`            | `Option<Pubkey>`   |
| 14  | `token_ledger`              | `Pubkey`           |
| 15  | `event_authority`           | `Pubkey`           |
| 16  | `program`                   | `Pubkey`           |
| 17… | `remaining`                 | `Vec<AccountMeta>` |

### `SwapToc`

Discriminator `bbc9d433109bec3c` · data `SwapToc` · accounts `SwapTocInstructionAccounts`.

| Field               | Type                    |
| ------------------- | ----------------------- |
| `args`              | [`SwapArgs`](#swapargs) |
| `commission_info`   | `u32`                   |
| `platform_fee_rate` | `u16`                   |

Required accounts: 16; extras go to `remaining`.

Fields of `SwapTocInstructionAccounts`, in account order:

| #   | Field                       | Type               |
| --- | --------------------------- | ------------------ |
| 0   | `payer`                     | `Pubkey`           |
| 1   | `source_token_account`      | `Pubkey`           |
| 2   | `destination_token_account` | `Pubkey`           |
| 3   | `source_mint`               | `Pubkey`           |
| 4   | `destination_mint`          | `Pubkey`           |
| 5   | `commission_account`        | `Option<Pubkey>`   |
| 6   | `platform_fee_account`      | `Option<Pubkey>`   |
| 7   | `sa_authority`              | `Option<Pubkey>`   |
| 8   | `source_token_sa`           | `Option<Pubkey>`   |
| 9   | `destination_token_sa`      | `Option<Pubkey>`   |
| 10  | `source_token_program`      | `Option<Pubkey>`   |
| 11  | `destination_token_program` | `Option<Pubkey>`   |
| 12  | `associated_token_program`  | `Option<Pubkey>`   |
| 13  | `system_program`            | `Option<Pubkey>`   |
| 14  | `event_authority`           | `Pubkey`           |
| 15  | `program`                   | `Pubkey`           |
| 16… | `remaining`                 | `Vec<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`.

| Field                    | Type                    |
| ------------------------ | ----------------------- |
| `args`                   | [`SwapArgs`](#swapargs) |
| `total_commission_info`  | `u32`                   |
| `parent_commission_rate` | `u32`                   |
| `platform_fee_rate`      | `u16`                   |

Required accounts: 17; extras go to `remaining`.

Fields of `SwapTocV2InstructionAccounts`, in account order:

| #   | Field                       | Type               |
| --- | --------------------------- | ------------------ |
| 0   | `payer`                     | `Pubkey`           |
| 1   | `source_token_account`      | `Pubkey`           |
| 2   | `destination_token_account` | `Pubkey`           |
| 3   | `source_mint`               | `Pubkey`           |
| 4   | `destination_mint`          | `Pubkey`           |
| 5   | `parent_commission_account` | `Pubkey`           |
| 6   | `child_commission_account`  | `Pubkey`           |
| 7   | `platform_fee_account`      | `Option<Pubkey>`   |
| 8   | `sa_authority`              | `Option<Pubkey>`   |
| 9   | `source_token_sa`           | `Option<Pubkey>`   |
| 10  | `destination_token_sa`      | `Option<Pubkey>`   |
| 11  | `source_token_program`      | `Option<Pubkey>`   |
| 12  | `destination_token_program` | `Option<Pubkey>`   |
| 13  | `associated_token_program`  | `Option<Pubkey>`   |
| 14  | `system_program`            | `Option<Pubkey>`   |
| 15  | `event_authority`           | `Pubkey`           |
| 16  | `program`                   | `Pubkey`           |
| 17… | `remaining`                 | `Vec<AccountMeta>` |

### `WrapUnwrap`

Discriminator `dc658bf929be76c7` · data `WrapUnwrap` · accounts `WrapUnwrapInstructionAccounts`.

| Field  | Type                                                      |
| ------ | --------------------------------------------------------- |
| `args` | [`PlatformFeeWrapUnwrapArgs`](#platformfeewrapunwrapargs) |

Required accounts: 12; extras go to `remaining`.

Fields of `WrapUnwrapInstructionAccounts`, in account order:

| #   | Field                  | Type               |
| --- | ---------------------- | ------------------ |
| 0   | `payer`                | `Pubkey`           |
| 1   | `payer_wsol_account`   | `Pubkey`           |
| 2   | `wsol_mint`            | `Pubkey`           |
| 3   | `temp_wsol_account`    | `Option<Pubkey>`   |
| 4   | `commission_account`   | `Option<Pubkey>`   |
| 5   | `platform_fee_account` | `Option<Pubkey>`   |
| 6   | `authority_pda`        | `Option<Pubkey>`   |
| 7   | `wsol_sa`              | `Option<Pubkey>`   |
| 8   | `token_program`        | `Pubkey`           |
| 9   | `system_program`       | `Pubkey`           |
| 10  | `event_authority`      | `Pubkey`           |
| 11  | `program`              | `Pubkey`           |
| 12… | `remaining`            | `Vec<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`.

| Field  | Type                                                      |
| ------ | --------------------------------------------------------- |
| `args` | [`PlatformFeeWrapUnwrapArgs`](#platformfeewrapunwrapargs) |

Required accounts: 13; extras go to `remaining`.

Fields of `WrapUnwrapWithReceiverInstructionAccounts`, in account order:

| #   | Field                  | Type               |
| --- | ---------------------- | ------------------ |
| 0   | `payer`                | `Pubkey`           |
| 1   | `payer_wsol_account`   | `Pubkey`           |
| 2   | `wsol_mint`            | `Pubkey`           |
| 3   | `temp_wsol_account`    | `Option<Pubkey>`   |
| 4   | `commission_account`   | `Option<Pubkey>`   |
| 5   | `platform_fee_account` | `Option<Pubkey>`   |
| 6   | `authority_pda`        | `Option<Pubkey>`   |
| 7   | `wsol_sa`              | `Option<Pubkey>`   |
| 8   | `token_program`        | `Pubkey`           |
| 9   | `system_program`       | `Pubkey`           |
| 10  | `receiver`             | `Pubkey`           |
| 11  | `event_authority`      | `Pubkey`           |
| 12  | `program`              | `Pubkey`           |
| 13… | `remaining`            | `Vec<AccountMeta>` |

### `CpiEvent`

Anchor self-CPI that carries one of the program's [events](#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_authority` | `Pubkey`           |
| 2… | `remaining`       | `Vec<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`.

| Field           | Type     |
| --------------- | -------- |
| `token_account` | `Pubkey` |
| `amount`        | `u64`    |

## 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`.

| Field                             | Type     |
| --------------------------------- | -------- |
| `order_id`                        | `u64`    |
| `source_mint`                     | `Pubkey` |
| `destination_mint`                | `Pubkey` |
| `source_token_account_owner`      | `Pubkey` |
| `destination_token_account_owner` | `Pubkey` |
| `amount_in`                       | `u64`    |
| `source_token_change`             | `u64`    |
| `destination_token_change`        | `u64`    |

### `SwapEvent`

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

| Field        | Type          |
| ------------ | ------------- |
| `dex`        | [`Dex`](#dex) |
| `amount_in`  | `u64`         |
| `amount_out` | `u64`         |

### `SwapTobV2CpiEvent2`

Discriminator `f469b85a3ca52421` · `events::swap_tob_v2_cpi_event2::SwapTobV2CpiEvent2Event`.

| Field                             | Type     |
| --------------------------------- | -------- |
| `order_id`                        | `u64`    |
| `source_mint`                     | `Pubkey` |
| `destination_mint`                | `Pubkey` |
| `source_token_account_owner`      | `Pubkey` |
| `destination_token_account_owner` | `Pubkey` |
| `amount_in`                       | `u64`    |
| `source_token_change`             | `u64`    |
| `destination_token_change`        | `u64`    |
| `commission_direction`            | `bool`   |
| `total_commission_rate`           | `u32`    |
| `parent_commission_rate`          | `u32`    |
| `parent_commission_amount`        | `u64`    |
| `parent_commission_account`       | `Pubkey` |
| `child_commission_rate`           | `u32`    |
| `child_commission_amount`         | `u64`    |
| `child_commission_account`        | `Pubkey` |
| `platform_fee_rate`               | `u16`    |
| `platform_fee_amount`             | `u64`    |
| `platform_fee_account`            | `Pubkey` |
| `trim_rate`                       | `u8`     |
| `trim_amount`                     | `u64`    |
| `trim_account`                    | `Pubkey` |

### `SwapTocV2CpiEvent2`

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

| Field                             | Type     |
| --------------------------------- | -------- |
| `order_id`                        | `u64`    |
| `source_mint`                     | `Pubkey` |
| `destination_mint`                | `Pubkey` |
| `source_token_account_owner`      | `Pubkey` |
| `destination_token_account_owner` | `Pubkey` |
| `amount_in`                       | `u64`    |
| `source_token_change`             | `u64`    |
| `destination_token_change`        | `u64`    |
| `commission_direction`            | `bool`   |
| `total_commission_rate`           | `u32`    |
| `parent_commission_rate`          | `u32`    |
| `parent_commission_amount`        | `u64`    |
| `parent_commission_account`       | `Pubkey` |
| `child_commission_rate`           | `u32`    |
| `child_commission_amount`         | `u64`    |
| `child_commission_account`        | `Pubkey` |
| `platform_fee_rate`               | `u16`    |
| `platform_fee_amount`             | `u64`    |
| `platform_fee_account`            | `Pubkey` |

### `SwapWithFeesCpiEvent2`

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

| Field                             | Type     |
| --------------------------------- | -------- |
| `order_id`                        | `u64`    |
| `source_mint`                     | `Pubkey` |
| `destination_mint`                | `Pubkey` |
| `source_token_account_owner`      | `Pubkey` |
| `destination_token_account_owner` | `Pubkey` |
| `amount_in`                       | `u64`    |
| `source_token_change`             | `u64`    |
| `destination_token_change`        | `u64`    |
| `commission_direction`            | `bool`   |
| `commission_rate`                 | `u32`    |
| `commission_amount`               | `u64`    |
| `commission_account`              | `Pubkey` |
| `platform_fee_rate`               | `u16`    |
| `platform_fee_amount`             | `u64`    |
| `platform_fee_account`            | `Pubkey` |
| `trim_rate`                       | `u8`     |
| `trim_amount`                     | `u64`    |
| `trim_account`                    | `Pubkey` |

### `SwapWithFeesCpiEventEnhanced2`

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

| Field                             | Type     |
| --------------------------------- | -------- |
| `order_id`                        | `u64`    |
| `source_mint`                     | `Pubkey` |
| `destination_mint`                | `Pubkey` |
| `source_token_account_owner`      | `Pubkey` |
| `destination_token_account_owner` | `Pubkey` |
| `amount_in`                       | `u64`    |
| `source_token_change`             | `u64`    |
| `destination_token_change`        | `u64`    |
| `commission_direction`            | `bool`   |
| `commission_rate`                 | `u32`    |
| `commission_amount`               | `u64`    |
| `commission_account`              | `Pubkey` |
| `platform_fee_rate`               | `u16`    |
| `platform_fee_amount`             | `u64`    |
| `platform_fee_account`            | `Pubkey` |
| `trim_rate`                       | `u8`     |
| `trim_amount`                     | `u64`    |
| `trim_account`                    | `Pubkey` |
| `charge_rate`                     | `u16`    |
| `charge_amount`                   | `u64`    |
| `charge_account`                  | `Pubkey` |

## Types

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

### `Dex`

Enum `types::Dex`.

| Variant                        | Fields                                                                                                                                                                                                                   |
| ------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `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`                      |                                                                                                                                                                                                                          |
| `SolRfq`                       | `rfq_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`                  |                                                                                                                                                                                                                          |
| `SugarMoneyBuy`                | `bonding_curve_bump`: `u8`, `bonding_curve_sol_associated_account_bump`: `u8`                                                                                                                                            |
| `SugarMoneySell`               | `bonding_curve_bump`: `u8`, `bonding_curve_sol_associated_account_bump`: `u8`                                                                                                                                            |
| `MeteoraDAMMV2Swap2`           |                                                                                                                                                                                                                          |
| `AlphaQ`                       |                                                                                                                                                                                                                          |
| `FutarchyAmm`                  |                                                                                                                                                                                                                          |
| `PumpfunBuy2`                  |                                                                                                                                                                                                                          |
| `PumpfunSell2`                 |                                                                                                                                                                                                                          |
| `HumidifiSwap2`                | `swap_id`: `u64`                                                                                                                                                                                                         |
| `Scorch`                       | `id`: `u128`                                                                                                                                                                                                             |
| `JupiterLendDeposit`           |                                                                                                                                                                                                                          |
| `JupiterLendRedeem`            |                                                                                                                                                                                                                          |
| `TaurusFi`                     |                                                                                                                                                                                                                          |
| `BisonFi`                      |                                                                                                                                                                                                                          |
| `GoonfiV2`                     |                                                                                                                                                                                                                          |
| `Quantum`                      |                                                                                                                                                                                                                          |
| `BoopfunBuy2`                  |                                                                                                                                                                                                                          |
| `BoopfunSell2`                 |                                                                                                                                                                                                                          |
| `ByrealClmm2`                  |                                                                                                                                                                                                                          |
| `Dooar2`                       |                                                                                                                                                                                                                          |
| `HeavenBuy2`                   |                                                                                                                                                                                                                          |
| `HeavenSell2`                  |                                                                                                                                                                                                                          |
| `MoonitBuy2`                   |                                                                                                                                                                                                                          |
| `MoonitSell2`                  |                                                                                                                                                                                                                          |
| `SaberDecimalWrapperDeposit2`  |                                                                                                                                                                                                                          |
| `SaberDecimalWrapperWithdraw2` |                                                                                                                                                                                                                          |
| `ByrealPropAmm`                |                                                                                                                                                                                                                          |
| `SanctumPrefundSwapViaStake`   | `swap_id`: `u64`                                                                                                                                                                                                         |
| `AbyssAmm`                     |                                                                                                                                                                                                                          |
| `Aquifer`                      |                                                                                                                                                                                                                          |
| `WhalestreetV2`                | `auth_amount_in`: `u64`, `auth`: `u64`                                                                                                                                                                                   |
| `SolfiV2WithSig`               | `unix_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`.

| Field               | Type   |
| ------------------- | ------ |
| `order_id`          | `u64`  |
| `amount_in`         | `u64`  |
| `commission_info`   | `u32`  |
| `platform_fee_rate` | `u16`  |
| `tob`               | `bool` |

### `Route`

Struct `types::Route`.

| Field    | Type          |
| -------- | ------------- |
| `dex`    | [`Dex`](#dex) |
| `weight` | `u16`         |
| `index`  | `u8`          |

### `SwapArgs`

Struct `types::SwapArgs`.

| Field               | Type                   |
| ------------------- | ---------------------- |
| `order_id`          | `u64`                  |
| `amount_in`         | `u64`                  |
| `expect_amount_out` | `u64`                  |
| `slippage`          | `u16`                  |
| `routes`            | [`Vec<Route>`](#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`.

| Field               | Type                   |
| ------------------- | ---------------------- |
| `order_id`          | `u64`                  |
| `expect_amount_out` | `u64`                  |
| `slippage`          | `u16`                  |
| `routes`            | [`Vec<Route>`](#route) |

### `SwapCpiEvent2`

Struct `types::SwapCpiEvent2`. Same fields as the [`SwapCpiEvent2`](#swapcpievent2) event.

### `SwapEvent`

Struct `types::SwapEvent`. Same fields as the [`SwapEvent`](#swapevent) event.

### `SwapTobV2CpiEvent2`

Struct `types::SwapTobV2CpiEvent2`. Same fields as the [`SwapTobV2CpiEvent2`](#swaptobv2cpievent2) event.

### `SwapTocV2CpiEvent2`

Struct `types::SwapTocV2CpiEvent2`. Same fields as the [`SwapTocV2CpiEvent2`](#swaptocv2cpievent2) event.

### `SwapWithFeesCpiEvent2`

Struct `types::SwapWithFeesCpiEvent2`. Same fields as the [`SwapWithFeesCpiEvent2`](#swapwithfeescpievent2) event.

### `SwapWithFeesCpiEventEnhanced2`

Struct `types::SwapWithFeesCpiEventEnhanced2`. Same fields as the [`SwapWithFeesCpiEventEnhanced2`](#swapwithfeescpieventenhanced2) event.

---

Carbon 2.0.0 documentation · Web: https://carbon.sevenlabs.org/decoders/onchain-labs-dex-v2 · Last updated 2026-11-09 · Index of all pages: https://carbon.sevenlabs.org/llms.txt
