# DFlow Aggregator v4 decoder (Carbon 2.0)

> Decode DFlow Aggregator v4 instructions, accounts and events in Rust with the carbon-dflow-aggregator-v4-decoder crate.

`carbon-dflow-aggregator-v4-decoder` decodes the instructions, accounts and events of the DFlow Aggregator v4 program (`DF1ow4tspfHX9JwWJsAb9epbkA8hmpSEAtxXy1V27QBH`): 17 instructions, 1 account type, 2 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-dflow-aggregator-v4-decoder`](https://crates.io/crates/carbon-dflow-aggregator-v4-decoder/2.0.0) 2.0.0                 |
| Install          | `cargo add carbon-dflow-aggregator-v4-decoder@2.0.0`                                                                            |
| Program ID       | `DF1ow4tspfHX9JwWJsAb9epbkA8hmpSEAtxXy1V27QBH` (`carbon_dflow_aggregator_v4_decoder::PROGRAM_ID`)                               |
| Category         | [Aggregators & routing](https://carbon.sevenlabs.org/decoders/aggregators.md)                                                   |
| Decoder          | `carbon_dflow_aggregator_v4_decoder::DflowAggregatorV4Decoder`                                                                  |
| Instruction enum | `instructions::DflowAggregatorV4Instruction`                                                                                    |
| Account enum     | `accounts::DflowAggregatorV4Account`                                                                                            |
| Event enum       | `instructions::CpiEvent`                                                                                                        |
| Features         | `serde`, `postgres`, `graphql` (none enabled by default)                                                                        |
| API docs         | [docs.rs/carbon-dflow-aggregator-v4-decoder/2.0.0](https://docs.rs/carbon-dflow-aggregator-v4-decoder/2.0.0)                    |
| Source           | [decoders/dflow-aggregator-v4-decoder](https://github.com/sevenlabs-hq/carbon/tree/v2.0.0/decoders/dflow-aggregator-v4-decoder) |

Other aggregator and routing decoders: [Jupiter Swap](https://carbon.sevenlabs.org/decoders/jupiter-swap.md), [OKX DEX](https://carbon.sevenlabs.org/decoders/okx-dex.md), [OnChain Labs DEX v2](https://carbon.sevenlabs.org/decoders/onchain-labs-dex-v2.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 DFlow Aggregator v4 transactions from the public RPC and prints every decoded `Swap` instruction. Add the dependencies:

```sh
cargo add carbon-core@2.0.0 carbon-dflow-aggregator-v4-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_dflow_aggregator_v4_decoder::{
        instructions::DflowAggregatorV4Instruction, DflowAggregatorV4Decoder, 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(DflowAggregatorV4Decoder, InstructionLogger)
        .build()?
        .run()
        .await
}

struct InstructionLogger;

impl Processor<InstructionProcessorInputType<'_, DflowAggregatorV4Instruction>> for InstructionLogger {
    async fn process(
        &mut self,
        input: &InstructionProcessorInputType<'_, DflowAggregatorV4Instruction>,
    ) -> CarbonResult<()> {
        let signature = input.metadata.transaction_metadata.signature;
        if let DflowAggregatorV4Instruction::Swap { data, accounts, .. } = input.decoded_instruction {
            println!("swap {signature}: {data:?} token_program={}", accounts.token_program);
        }
        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 `DflowAggregatorV4Instruction::CpiEvent { data: CpiEvent::FeeEvent(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 `Order` 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_dflow_aggregator_v4_decoder::{
        accounts::DflowAggregatorV4Account, DflowAggregatorV4Decoder, 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(DflowAggregatorV4Decoder, AccountLogger)
        .build()?
        .run()
        .await
}

struct AccountLogger;

impl Processor<AccountProcessorInputType<'_, DflowAggregatorV4Account>> for AccountLogger {
    async fn process(
        &mut self,
        input: &AccountProcessorInputType<'_, DflowAggregatorV4Account>,
    ) -> CarbonResult<()> {
        let DflowAggregatorV4Account::Order(order) = &input.decoded_account.data;
        println!("order {}: {order:?}", input.metadata.pubkey);
        Ok(())
    }
}
```

```sh
RUST_LOG=info cargo run
```

Each update to a `Order` 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 `DflowAggregatorV4Instruction`. Each is `DflowAggregatorV4Instruction::<Variant> { program_id, data, accounts }`, where `data` and `accounts` are the types listed under the variant, exported from `carbon_dflow_aggregator_v4_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 `DF1ow4tspfHX9JwWJsAb9epbkA8hmpSEAtxXy1V27QBH`.
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.

### `CloseEmptyTokenAccount`

> _From the program's IDL:_
>
> Closes a token account if it has a zero balance

Discriminator `e84b8c88fa4ee0bc` · data `CloseEmptyTokenAccount` · accounts `CloseEmptyTokenAccountInstructionAccounts`.

No data fields.

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

Fields of `CloseEmptyTokenAccountInstructionAccounts`, in account order:

| #  | Field           | Type               |
| -- | --------------- | ------------------ |
| 0  | `token_account` | `Pubkey`           |
| 1  | `authority`     | `Pubkey`           |
| 2  | `destination`   | `Pubkey`           |
| 3  | `token_program` | `Pubkey`           |
| 4… | `remaining`     | `Vec<AccountMeta>` |

### `CloseOrder`

> _From the program's IDL:_
>
> Closes an order, returning tokens from the order vault

Discriminator `5a67d11c073fa804` · data `CloseOrder` · accounts `CloseOrderInstructionAccounts`.

No data fields.

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

Fields of `CloseOrderInstructionAccounts`, in account order:

| #  | Field                        | Type               |
| -- | ---------------------------- | ------------------ |
| 0  | `order`                      | `Pubkey`           |
| 1  | `order_vault`                | `Pubkey`           |
| 2  | `return_input_token_account` | `Pubkey`           |
| 3  | `return_rent_to`             | `Pubkey`           |
| 4  | `closer`                     | `Pubkey`           |
| 5  | `token_program`              | `Pubkey`           |
| 6  | `system_program`             | `Pubkey`           |
| 7… | `remaining`                  | `Vec<AccountMeta>` |

### `CreateReferralTokenAccountIdempotent`

> _From the program's IDL:_
>
> Create a referral token account if it doesn't already exist

Discriminator `2ee829905525aaaf` · data `CreateReferralTokenAccountIdempotent` · accounts `CreateReferralTokenAccountIdempotentInstructionAccounts`.

No data fields.

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

Fields of `CreateReferralTokenAccountIdempotentInstructionAccounts`, in account order:

| #  | Field                    | Type               |
| -- | ------------------------ | ------------------ |
| 0  | `payer`                  | `Pubkey`           |
| 1  | `project`                | `Pubkey`           |
| 2  | `referral_account`       | `Pubkey`           |
| 3  | `referral_token_account` | `Pubkey`           |
| 4  | `mint`                   | `Pubkey`           |
| 5  | `system_program`         | `Pubkey`           |
| 6  | `token_program`          | `Pubkey`           |
| 7  | `referral_program`       | `Pubkey`           |
| 8… | `remaining`              | `Vec<AccountMeta>` |

### `FillOrder`

> _From the program's IDL:_
>
> Fills an order, closing the order after filling it

Discriminator `e87a7319c78f88a2` · data `FillOrder` · accounts `FillOrderInstructionAccounts`.

| Field    | Type                                  |
| -------- | ------------------------------------- |
| `params` | [`FillOrderParams`](#fillorderparams) |

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

Fields of `FillOrderInstructionAccounts`, in account order:

| #   | Field                         | Type               |
| --- | ----------------------------- | ------------------ |
| 0   | `order`                       | `Pubkey`           |
| 1   | `order_vault`                 | `Pubkey`           |
| 2   | `output_token_account`        | `Pubkey`           |
| 3   | `return_input_token_account`  | `Pubkey`           |
| 4   | `return_rent_to`              | `Pubkey`           |
| 5   | `filler_input_token_account`  | `Pubkey`           |
| 6   | `input_mint`                  | `Option<Pubkey>`   |
| 7   | `filler_output_token_account` | `Pubkey`           |
| 8   | `output_mint`                 | `Option<Pubkey>`   |
| 9   | `filler`                      | `Pubkey`           |
| 10  | `token_program`               | `Pubkey`           |
| 11  | `associated_token_program`    | `Pubkey`           |
| 12  | `system_program`              | `Pubkey`           |
| 13  | `event_authority`             | `Pubkey`           |
| 14  | `program`                     | `Pubkey`           |
| 15… | `remaining`                   | `Vec<AccountMeta>` |

### `InitMarketLedgerIdempotent`

> _From the program's IDL:_
>
> Initialize a market ledger if it doesn't already exist

Discriminator `b72b8b4f7de1239f` · data `InitMarketLedgerIdempotent` · accounts `InitMarketLedgerIdempotentInstructionAccounts`.

| Field       | Type       |
| ----------- | ---------- |
| `market_id` | `[u8; 32]` |

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

Fields of `InitMarketLedgerIdempotentInstructionAccounts`, in account order:

| #   | Field                            | Type               |
| --- | -------------------------------- | ------------------ |
| 0   | `predictions_program`            | `Pubkey`           |
| 1   | `market_ledger`                  | `Pubkey`           |
| 2   | `market_ledger_redemption_vault` | `Pubkey`           |
| 3   | `market_ledger_order_vault`      | `Pubkey`           |
| 4   | `market_ledger_reduce_yes_vault` | `Pubkey`           |
| 5   | `market_ledger_reduce_no_vault`  | `Pubkey`           |
| 6   | `settlement_escrow`              | `Pubkey`           |
| 7   | `escrow_mint`                    | `Pubkey`           |
| 8   | `market_yes_outcome_mint`        | `Pubkey`           |
| 9   | `market_no_outcome_mint`         | `Pubkey`           |
| 10  | `payer`                          | `Pubkey`           |
| 11  | `outcome_token_program`          | `Pubkey`           |
| 12  | `escrow_token_program`           | `Pubkey`           |
| 13  | `system_program`                 | `Pubkey`           |
| 14… | `remaining`                      | `Vec<AccountMeta>` |

### `OpenOrder`

> _From the program's IDL:_
>
> Opens an order, escrowing the input tokens in the order vault

Discriminator `ce58588f268832e0` · data `OpenOrder` · accounts `OpenOrderInstructionAccounts`.

| Field    | Type                                  |
| -------- | ------------------------------------- |
| `params` | [`OpenOrderParams`](#openorderparams) |

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

Fields of `OpenOrderInstructionAccounts`, in account order:

| #   | Field                        | Type               |
| --- | ---------------------------- | ------------------ |
| 0   | `order`                      | `Pubkey`           |
| 1   | `order_vault`                | `Pubkey`           |
| 2   | `input_token_account`        | `Pubkey`           |
| 3   | `output_token_account`       | `Pubkey`           |
| 4   | `return_input_token_account` | `Pubkey`           |
| 5   | `input_mint`                 | `Pubkey`           |
| 6   | `user_token_authority`       | `Pubkey`           |
| 7   | `fee_payer`                  | `Pubkey`           |
| 8   | `fee_receiver`               | `Pubkey`           |
| 9   | `rent_depositor`             | `Pubkey`           |
| 10  | `token_program`              | `Pubkey`           |
| 11  | `system_program`             | `Pubkey`           |
| 12  | `rent`                       | `Pubkey`           |
| 13… | `remaining`                  | `Vec<AccountMeta>` |

### `Swap`

> _From the program's IDL:_
>
> Executes a token swap

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

| Field    | Type                        |
| -------- | --------------------------- |
| `params` | [`SwapParams`](#swapparams) |

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

Fields of `SwapInstructionAccounts`, in account order:

| #  | Field                      | Type               |
| -- | -------------------------- | ------------------ |
| 0  | `token_program`            | `Pubkey`           |
| 1  | `associated_token_program` | `Pubkey`           |
| 2  | `system_program`           | `Pubkey`           |
| 3  | `user_token_authority`     | `Pubkey`           |
| 4  | `event_authority`          | `Pubkey`           |
| 5  | `program`                  | `Pubkey`           |
| 6… | `remaining`                | `Vec<AccountMeta>` |

### `Swap2`

> _From the program's IDL:_
>
> Executes a token swap with a slippage fee

Discriminator `414b3f4ceb5b5b88` · data `Swap2` · accounts `Swap2InstructionAccounts`.

| Field    | Type                          |
| -------- | ----------------------------- |
| `params` | [`Swap2Params`](#swap2params) |

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

Fields of `Swap2InstructionAccounts`, in account order:

| #  | Field                      | Type               |
| -- | -------------------------- | ------------------ |
| 0  | `token_program`            | `Pubkey`           |
| 1  | `associated_token_program` | `Pubkey`           |
| 2  | `system_program`           | `Pubkey`           |
| 3  | `user_token_authority`     | `Pubkey`           |
| 4  | `event_authority`          | `Pubkey`           |
| 5  | `program`                  | `Pubkey`           |
| 6… | `remaining`                | `Vec<AccountMeta>` |

### `Swap2WithDestination`

> _From the program's IDL:_
>
> Executes a token swap with a slippage fee. Outputs to the specified destination account.

Discriminator `5f7bd5f67a0156e7` · data `Swap2WithDestination` · accounts `Swap2WithDestinationInstructionAccounts`.

| Field    | Type                          |
| -------- | ----------------------------- |
| `params` | [`Swap2Params`](#swap2params) |

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

Fields of `Swap2WithDestinationInstructionAccounts`, in account order:

| #  | Field                         | Type               |
| -- | ----------------------------- | ------------------ |
| 0  | `token_program`               | `Pubkey`           |
| 1  | `associated_token_program`    | `Pubkey`           |
| 2  | `system_program`              | `Pubkey`           |
| 3  | `user_token_authority`        | `Pubkey`           |
| 4  | `destination_token_account`   | `Pubkey`           |
| 5  | `destination_token_authority` | `Pubkey`           |
| 6  | `destination_mint`            | `Pubkey`           |
| 7  | `event_authority`             | `Pubkey`           |
| 8  | `program`                     | `Pubkey`           |
| 9… | `remaining`                   | `Vec<AccountMeta>` |

### `Swap2WithDestinationNative`

> _From the program's IDL:_
>
> Executes a token swap with a slippage fee. Outputs native SOL to the specified destination account by unwrapping WSOL.

Discriminator `de64b892bac469a5` · data `Swap2WithDestinationNative` · accounts `Swap2WithDestinationNativeInstructionAccounts`.

| Field    | Type                          |
| -------- | ----------------------------- |
| `params` | [`Swap2Params`](#swap2params) |

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

Fields of `Swap2WithDestinationNativeInstructionAccounts`, in account order:

| #  | Field                      | Type               |
| -- | -------------------------- | ------------------ |
| 0  | `token_program`            | `Pubkey`           |
| 1  | `associated_token_program` | `Pubkey`           |
| 2  | `system_program`           | `Pubkey`           |
| 3  | `user_token_authority`     | `Pubkey`           |
| 4  | `destination_account`      | `Pubkey`           |
| 5  | `event_authority`          | `Pubkey`           |
| 6  | `program`                  | `Pubkey`           |
| 7… | `remaining`                | `Vec<AccountMeta>` |

### `SwapWithDestination`

> _From the program's IDL:_
>
> Executes a token swap. Outputs to the specified destination account.

Discriminator `a8ac184dc59c8765` · data `SwapWithDestination` · accounts `SwapWithDestinationInstructionAccounts`.

| Field    | Type                        |
| -------- | --------------------------- |
| `params` | [`SwapParams`](#swapparams) |

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

Fields of `SwapWithDestinationInstructionAccounts`, in account order:

| #  | Field                         | Type               |
| -- | ----------------------------- | ------------------ |
| 0  | `token_program`               | `Pubkey`           |
| 1  | `associated_token_program`    | `Pubkey`           |
| 2  | `system_program`              | `Pubkey`           |
| 3  | `user_token_authority`        | `Pubkey`           |
| 4  | `destination_token_account`   | `Pubkey`           |
| 5  | `destination_token_authority` | `Pubkey`           |
| 6  | `destination_mint`            | `Pubkey`           |
| 7  | `event_authority`             | `Pubkey`           |
| 8  | `program`                     | `Pubkey`           |
| 9… | `remaining`                   | `Vec<AccountMeta>` |

### `SwapWithDestinationNative`

> _From the program's IDL:_
>
> Executes a token swap. Outputs native SOL to the specified destination account by unwrapping WSOL.

Discriminator `cd4d7f6cf120c4c3` · data `SwapWithDestinationNative` · accounts `SwapWithDestinationNativeInstructionAccounts`.

| Field    | Type                        |
| -------- | --------------------------- |
| `params` | [`SwapParams`](#swapparams) |

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

Fields of `SwapWithDestinationNativeInstructionAccounts`, in account order:

| #  | Field                      | Type               |
| -- | -------------------------- | ------------------ |
| 0  | `token_program`            | `Pubkey`           |
| 1  | `associated_token_program` | `Pubkey`           |
| 2  | `system_program`           | `Pubkey`           |
| 3  | `user_token_authority`     | `Pubkey`           |
| 4  | `destination_account`      | `Pubkey`           |
| 5  | `event_authority`          | `Pubkey`           |
| 6  | `program`                  | `Pubkey`           |
| 7… | `remaining`                | `Vec<AccountMeta>` |

### `TransferFee`

> _From the program's IDL:_
>
> Transfer an SPL token fee if the receiving account can receive it

Discriminator `81a4c415b130b4a2` · data `TransferFee` · accounts `TransferFeeInstructionAccounts`.

| Field    | Type  |
| -------- | ----- |
| `amount` | `u64` |

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

Fields of `TransferFeeInstructionAccounts`, in account order:

| #  | Field             | Type               |
| -- | ----------------- | ------------------ |
| 0  | `from`            | `Pubkey`           |
| 1  | `to`              | `Pubkey`           |
| 2  | `authority`       | `Pubkey`           |
| 3  | `token_program`   | `Pubkey`           |
| 4  | `event_authority` | `Pubkey`           |
| 5  | `program`         | `Pubkey`           |
| 6… | `remaining`       | `Vec<AccountMeta>` |

### `TransferSol`

> _From the program's IDL:_
>
> Transfer native SOL from one account to another

Discriminator `4e0aecf76d75154c` · data `TransferSol` · accounts `TransferSolInstructionAccounts`.

| Field      | Type  |
| ---------- | ----- |
| `lamports` | `u64` |

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

Fields of `TransferSolInstructionAccounts`, in account order:

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

### `TransferToSponsor`

> _From the program's IDL:_
>
> Transfer an SPL token to a sponsor's token account, creating the sponsor's token account if necessary.

Discriminator `9bb38297c48bfda3` · data `TransferToSponsor` · accounts `TransferToSponsorInstructionAccounts`.

| Field    | Type  |
| -------- | ----- |
| `amount` | `u64` |

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

Fields of `TransferToSponsorInstructionAccounts`, in account order:

| #  | Field                      | Type               |
| -- | -------------------------- | ------------------ |
| 0  | `user_token_authority`     | `Pubkey`           |
| 1  | `user_token_account`       | `Pubkey`           |
| 2  | `sponsor`                  | `Pubkey`           |
| 3  | `sponsor_token_account`    | `Pubkey`           |
| 4  | `mint`                     | `Pubkey`           |
| 5  | `token_program`            | `Pubkey`           |
| 6  | `associated_token_program` | `Pubkey`           |
| 7  | `system_program`           | `Pubkey`           |
| 8… | `remaining`                | `Vec<AccountMeta>` |

### `UnwrapSol`

> _From the program's IDL:_
>
> Unwrap all SOL in the provided wrapped SOL token account

Discriminator `63280e692d6bacc9` · data `UnwrapSol` · accounts `UnwrapSolInstructionAccounts`.

No data fields.

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

Fields of `UnwrapSolInstructionAccounts`, in account order:

| #  | Field                                  | Type               |
| -- | -------------------------------------- | ------------------ |
| 0  | `owner`                                | `Pubkey`           |
| 1  | `wrapped_sol_associated_token_account` | `Pubkey`           |
| 2  | `token_program`                        | `Pubkey`           |
| 3… | `remaining`                            | `Vec<AccountMeta>` |

### `WrapSol`

> _From the program's IDL:_
>
> Wrap SOL, creating a wrapped SOL associated token account if necessary

Discriminator `2f3e9bac83cd25c9` · data `WrapSol` · accounts `WrapSolInstructionAccounts`.

| Field      | Type  |
| ---------- | ----- |
| `lamports` | `u64` |

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

Fields of `WrapSolInstructionAccounts`, in account order:

| #  | Field                                  | Type               |
| -- | -------------------------------------- | ------------------ |
| 0  | `from`                                 | `Pubkey`           |
| 1  | `wrapped_sol_associated_token_account` | `Pubkey`           |
| 2  | `native_mint`                          | `Pubkey`           |
| 3  | `token_program`                        | `Pubkey`           |
| 4  | `associated_token_program`             | `Pubkey`           |
| 5  | `system_program`                       | `Pubkey`           |
| 6… | `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 `DflowAggregatorV4Account`. Each wraps a boxed struct from `carbon_dflow_aggregator_v4_decoder::accounts::<module>`. `decode_account` only considers accounts owned by `PROGRAM_ID` and returns the first variant that matches.

### `Order`

Discriminator `86addfb94d561c33` · `accounts::order::Order`.

| Field                        | Type     | Description                                                                                                                                                                                                                                                                                                                                                    |
| ---------------------------- | -------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `closer`                     | `Pubkey` | Account that is authorized to close the order                                                                                                                                                                                                                                                                                                                  |
| `output_token_account`       | `Pubkey` | Account to which output from the fill should be sent. If the order specifies that it should output native SOL, then this should be the user's wallet, although any account is allowed. If the order doesn't specify that it should output native SOL, then this must be an SPL token account, and the token account's mint determines the order's output mint. |
| `return_input_token_account` | `Pubkey` | Account to which leftover tokens in the order vault should be returned when the order is filled or closed. If the input is native SOL, this should be the user's wallet, although any account is allowed. If the input is wrapped SOL or an SPL token, this must be an SPL token account for the input mint.                                                   |
| `return_rent_to`             | `Pubkey` | Account to which rent for the account should be returned when the account is closed                                                                                                                                                                                                                                                                            |
| `id`                         | `u64`    | ID used to produce a unique PDA for the order account                                                                                                                                                                                                                                                                                                          |
| `quoted_out_amount`          | `u64`    |                                                                                                                                                                                                                                                                                                                                                                |
| `last_fillable_slot`         | `u64`    | Highest slot at which the order can be filled                                                                                                                                                                                                                                                                                                                  |
| `slippage_bps`               | `u16`    | Max allowed slippage in basis points. Along with `quoted_out_amount`, this is used to calculate the minimum allowed output amount for the order.                                                                                                                                                                                                               |
| `bump`                       | `u8`     |                                                                                                                                                                                                                                                                                                                                                                |
| `vault_bump`                 | `u8`     | Bump seed for the vault token account associated with the order                                                                                                                                                                                                                                                                                                |
| `flags`                      | `u8`     | Flags for the order                                                                                                                                                                                                                                                                                                                                            |
| `padding1`                   | `u8`     |                                                                                                                                                                                                                                                                                                                                                                |
| `padding2`                   | `u8`     |                                                                                                                                                                                                                                                                                                                                                                |
| `padding3`                   | `u8`     |                                                                                                                                                                                                                                                                                                                                                                |

## Events

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

### `FeeEvent`

Discriminator `494f4e7fb8d50ddc` · `events::fee_event::FeeEventEvent`.

| Field     | Type     |
| --------- | -------- |
| `account` | `Pubkey` |
| `mint`    | `Pubkey` |
| `amount`  | `u64`    |

### `SwapEvent`

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

| Field           | Type     |
| --------------- | -------- |
| `amm`           | `Pubkey` |
| `input_mint`    | `Pubkey` |
| `input_amount`  | `u64`    |
| `output_mint`   | `Pubkey` |
| `output_amount` | `u64`    |

## Types

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

### `A`

Enum `types::A`.

| Variant | Fields    |
| ------- | --------- |
| `B`     | [`C`](#c) |

### `Action`

Enum `types::Action`.

| Variant                     | Fields                                                                  |
| --------------------------- | ----------------------------------------------------------------------- |
| `WhirlpoolsSwap`            | [`WhirlpoolsSwapOptions`](#whirlpoolsswapoptions)                       |
| `ClearpoolsSwap`            | [`ClearpoolsSwapOptions`](#clearpoolsswapoptions)                       |
| `RaydiumAmmSwap`            | [`RaydiumAmmSwapOptions`](#raydiumammswapoptions)                       |
| `LifinityV2Swap`            | [`LifinityV2SwapOptions`](#lifinityv2swapoptions)                       |
| `MeteoraDlmmSwap`           | [`MeteoraDlmmSwapOptions`](#meteoradlmmswapoptions)                     |
| `RaydiumClmmSwap`           | [`RaydiumClmmSwapOptions`](#raydiumclmmswapoptions)                     |
| `RaydiumClmmSwapV2`         | [`RaydiumClmmSwapV2Options`](#raydiumclmmswapv2options)                 |
| `PhoenixSwap`               | [`PhoenixSwapOptions`](#phoenixswapoptions)                             |
| `PumpFunBuy`                | [`PumpFunBuyOptions`](#pumpfunbuyoptions)                               |
| `PumpFunSell`               | [`PumpFunSellOptions`](#pumpfunselloptions)                             |
| `GammaSwap`                 | [`GammaSwapOptions`](#gammaswapoptions)                                 |
| `ObricV2Swap`               | [`ObricV2SwapOptions`](#obricv2swapoptions)                             |
| `PumpFunAmmBuy`             | [`PumpFunAmmBuyOptions`](#pumpfunammbuyoptions)                         |
| `PumpFunAmmSell`            | [`PumpFunAmmSellOptions`](#pumpfunammselloptions)                       |
| `SolFiSwap`                 | [`SolFiSwapOptions`](#solfiswapoptions)                                 |
| `RubiconSwap`               | [`RubiconSwapOptions`](#rubiconswapoptions)                             |
| `MeteoraDammV1Swap`         | [`MeteoraDammV1SwapOptions`](#meteoradammv1swapoptions)                 |
| `RaydiumCpSwap`             | [`RaydiumCpSwapOptions`](#raydiumcpswapoptions)                         |
| `StabbleStableSwap`         | [`StabbleStableSwapOptions`](#stabblestableswapoptions)                 |
| `TesseraVSwap`              | [`TesseraVSwapOptions`](#tesseravswapoptions)                           |
| `MeteoraDammV2Swap`         | [`MeteoraDammV2SwapOptions`](#meteoradammv2swapoptions)                 |
| `RaydiumLaunchlabSwap`      | [`RaydiumLaunchlabSwapOptions`](#raydiumlaunchlabswapoptions)           |
| `MeteoraDbcSwap`            | [`MeteoraDbcSwapOptions`](#meteoradbcswapoptions)                       |
| `HumidiFiSwap`              | [`HumidiFiSwapOptions`](#humidifiswapoptions)                           |
| `WhirlpoolsSwapV2`          | [`WhirlpoolsSwapV2Options`](#whirlpoolsswapv2options)                   |
| `MeteoraDlmmSwapV2`         | [`MeteoraDlmmSwapV2Options`](#meteoradlmmswapv2options)                 |
| `ZeroFiSwap`                | [`ZeroFiSwapOptions`](#zerofiswapoptions)                               |
| `AlphaQSwap`                | [`AlphaQSwapOptions`](#alphaqswapoptions)                               |
| `TokenSwap`                 | [`TokenSwapOptions`](#tokenswapoptions)                                 |
| `SolFiV2Swap`               | [`SolFiV2SwapOptions`](#solfiv2swapoptions)                             |
| `MozartSwap`                | [`MozartSwapOptions`](#mozartswapoptions)                               |
| `DFlowDynamicRouteV1`       | [`DFlowDynamicRouteV1Options`](#dflowdynamicroutev1options)             |
| `HeavenSwap`                | [`HeavenSwapOptions`](#heavenswapoptions)                               |
| `NexusSwap`                 | [`NexusSwapOptions`](#nexusswapoptions)                                 |
| `SarosDlmmSwap`             | [`SarosDlmmSwapOptions`](#sarosdlmmswapoptions)                         |
| `TransferFee`               | [`TransferFeeOptions`](#transferfeeoptions)                             |
| `TransferFeeWithMint`       | [`TransferFeeOptions`](#transferfeeoptions)                             |
| `RecordId`                  | [`RecordIdOptions`](#recordidoptions)                                   |
| `RecordId2`                 | [`RecordId2Options`](#recordid2options)                                 |
| `ManifestSwap`              | [`ManifestSwapOptions`](#manifestswapoptions)                           |
| `BisonFiSwap`               | [`BisonFiSwapOptions`](#bisonfiswapoptions)                             |
| `SanctumInfinitySwap`       | [`SanctumInfinitySwapOptions`](#sanctuminfinityswapoptions)             |
| `SanctumInfinityLiquidity`  | [`SanctumInfinityLiquidityOptions`](#sanctuminfinityliquidityoptions)   |
| `OpenPredictionsOrder`      | [`OpenPredictionsOrderOptions`](#openpredictionsorderoptions)           |
| `ScorchSwap`                | [`ScorchSwapOptions`](#scorchswapoptions)                               |
| `IncludeAccount`            |                                                                         |
| `StabbleWeightedSwap`       | [`StabbleWeightedSwapOptions`](#stabbleweightedswapoptions)             |
| `VertigoSwap`               | [`VertigoSwapOptions`](#vertigoswapoptions)                             |
| `SetMinimumLegOutputs`      | [`SetMinimumLegOutputsOptions`](#setminimumlegoutputsoptions)           |
| `SetMinimumLegPrices`       | [`SetMinimumLegPricesOptions`](#setminimumlegpricesoptions)             |
| `SetSponsor`                |                                                                         |
| `WrapSol`                   | [`WrapSolOptions`](#wrapsoloptions)                                     |
| `UnwrapSol`                 |                                                                         |
| `KDEXSwap`                  | [`KDEXSwapOptions`](#kdexswapoptions)                                   |
| `DeriverseSwap`             | [`DeriverseSwapOptions`](#deriverseswapoptions)                         |
| `VaultSwap`                 | [`VaultSwapOptions`](#vaultswapoptions)                                 |
| `MetaDaoSwap`               | [`MetaDaoSwapOptions`](#metadaoswapoptions)                             |
| `D`                         | [`O`](#o)                                                               |
| `XoCashExchangeSwap`        | [`XoCashExchangeSwapOptions`](#xocashexchangeswapoptions)               |
| `LemmingsFiSwap`            | [`LemmingsFiSwapOptions`](#lemmingsfiswapoptions)                       |
| `InitAtaIdempotent`         |                                                                         |
| `SetMaxUnderconsumptionBps` | [`SetMaxUnderconsumptionBpsOptions`](#setmaxunderconsumptionbpsoptions) |
| `GhostSwap`                 | [`GhostSwapOptions`](#ghostswapoptions)                                 |
| `TransferFeeV2`             | [`TransferFeeOptions`](#transferfeeoptions)                             |
| `TransferFeeWithMintV2`     | [`TransferFeeOptions`](#transferfeeoptions)                             |

### `AlphaQDynamicRouteV1Options`

Struct `types::AlphaQDynamicRouteV1Options`.

No fields.

### `AlphaQSwapOptions`

Struct `types::AlphaQSwapOptions`.

| Field                | Type                                      | Description                 |
| -------------------- | ----------------------------------------- | --------------------------- |
| `amount`             | `u64`                                     |                             |
| `orchestrator_flags` | [`OrchestratorFlags`](#orchestratorflags) | Optional flags for the swap |

### `BisonFiDynamicRouteV1Options`

Struct `types::BisonFiDynamicRouteV1Options`.

No fields.

### `BisonFiSwapOptions`

Struct `types::BisonFiSwapOptions`.

| Field                | Type                                      | Description                 |
| -------------------- | ----------------------------------------- | --------------------------- |
| `amount`             | `u64`                                     |                             |
| `orchestrator_flags` | [`OrchestratorFlags`](#orchestratorflags) | Optional flags for the swap |

### `C`

Struct `types::C`.

| Field     | Type |
| --------- | ---- |
| `padding` | `u8` |

### `ClearpoolsSwapOptions`

Struct `types::ClearpoolsSwapOptions`.

| Field                | Type                                      | Description                 |
| -------------------- | ----------------------------------------- | --------------------------- |
| `amount`             | `u64`                                     |                             |
| `a_to_b`             | `bool`                                    |                             |
| `orchestrator_flags` | [`OrchestratorFlags`](#orchestratorflags) | Optional flags for the swap |

### `DeriverseSwapOptions`

Struct `types::DeriverseSwapOptions`.

| Field                | Type                                      | Description                 |
| -------------------- | ----------------------------------------- | --------------------------- |
| `amount`             | `u64`                                     |                             |
| `orchestrator_flags` | [`OrchestratorFlags`](#orchestratorflags) | Optional flags for the swap |

### `DFlowDynamicRouteV1Options`

Struct `types::DFlowDynamicRouteV1Options`.

| Field                | Type                                                                   | Description                 |
| -------------------- | ---------------------------------------------------------------------- | --------------------------- |
| `candidate_actions`  | [`Vec<DynamicRouteV1CandidateAction>`](#dynamicroutev1candidateaction) |                             |
| `amount`             | `u64`                                                                  |                             |
| `orchestrator_flags` | [`OrchestratorFlags`](#orchestratorflags)                              | Optional flags for the swap |

### `DynamicRouteV1CandidateAction`

Enum `types::DynamicRouteV1CandidateAction`.

| Variant      | Fields                                                                |
| ------------ | --------------------------------------------------------------------- |
| `SolFi`      | [`SolFiDynamicRouteV1Options`](#solfidynamicroutev1options)           |
| `Rubicon`    | [`RubiconDynamicRouteV1Options`](#rubicondynamicroutev1options)       |
| `TesseraV`   | [`TesseraVDynamicRouteV1Options`](#tesseravdynamicroutev1options)     |
| `HumidiFi`   | [`HumidiFiDynamicRouteV1Options`](#humidifidynamicroutev1options)     |
| `SolFiV2`    | [`SolFiV2DynamicRouteV1Options`](#solfiv2dynamicroutev1options)       |
| `Mozart`     | [`MozartDynamicRouteV1Options`](#mozartdynamicroutev1options)         |
| `ObricV2`    | [`ObricV2DynamicRouteV1Options`](#obricv2dynamicroutev1options)       |
| `Nexus`      | [`NexusDynamicRouteV1Options`](#nexusdynamicroutev1options)           |
| `BisonFi`    | [`BisonFiDynamicRouteV1Options`](#bisonfidynamicroutev1options)       |
| `ZeroFi`     | [`ZeroFiDynamicRouteV1Options`](#zerofidynamicroutev1options)         |
| `Manifest`   | [`ManifestDynamicRouteV1Options`](#manifestdynamicroutev1options)     |
| `AlphaQ`     | [`AlphaQDynamicRouteV1Options`](#alphaqdynamicroutev1options)         |
| `LemmingsFi` | [`LemmingsFiDynamicRouteV1Options`](#lemmingsfidynamicroutev1options) |

### `FeeEvent`

Struct `types::FeeEvent`. Same fields as the [`FeeEvent`](#feeevent) event.

### `FillOrderParams`

Struct `types::FillOrderParams`.

| Field               | Type                     |
| ------------------- | ------------------------ |
| `swap_actions`      | [`Vec<Action>`](#action) |
| `platform_fee_ubps` | `u32`                    |

### `GammaSwapOptions`

Struct `types::GammaSwapOptions`.

| Field                | Type                                      | Description                 |
| -------------------- | ----------------------------------------- | --------------------------- |
| `amount`             | `u64`                                     |                             |
| `endorsed`           | `bool`                                    |                             |
| `orchestrator_flags` | [`OrchestratorFlags`](#orchestratorflags) | Optional flags for the swap |

### `GhostSwapOptions`

Struct `types::GhostSwapOptions`.

| Field                | Type                                      | Description                 |
| -------------------- | ----------------------------------------- | --------------------------- |
| `amount`             | `u64`                                     |                             |
| `orchestrator_flags` | [`OrchestratorFlags`](#orchestratorflags) | Optional flags for the swap |

### `HeavenSwapOptions`

Struct `types::HeavenSwapOptions`.

| Field                | Type                                      | Description                 |
| -------------------- | ----------------------------------------- | --------------------------- |
| `amount`             | `u64`                                     |                             |
| `orchestrator_flags` | [`OrchestratorFlags`](#orchestratorflags) | Optional flags for the swap |

### `HumidiFiDynamicRouteV1Options`

Struct `types::HumidiFiDynamicRouteV1Options`.

| Field     | Type  |
| --------- | ----- |
| `swap_id` | `u64` |

### `HumidiFiSwapOptions`

Struct `types::HumidiFiSwapOptions`.

| Field                | Type                                      | Description                 |
| -------------------- | ----------------------------------------- | --------------------------- |
| `amount`             | `u64`                                     |                             |
| `swap_id`            | `u64`                                     |                             |
| `orchestrator_flags` | [`OrchestratorFlags`](#orchestratorflags) | Optional flags for the swap |

### `KDEXSwapOptions`

Struct `types::KDEXSwapOptions`.

| Field                | Type                                      | Description                 |
| -------------------- | ----------------------------------------- | --------------------------- |
| `amount`             | `u64`                                     |                             |
| `orchestrator_flags` | [`OrchestratorFlags`](#orchestratorflags) | Optional flags for the swap |

### `LegPrice`

Struct `types::LegPrice`.

| Field                          | Type  |
| ------------------------------ | ----- |
| `output_atoms_per_input_token` | `u64` |
| `input_mint_decimals`          | `u8`  |

### `LemmingsFiDynamicRouteV1Options`

Struct `types::LemmingsFiDynamicRouteV1Options`.

No fields.

### `LemmingsFiSwapOptions`

Struct `types::LemmingsFiSwapOptions`.

| Field                | Type                                      | Description                 |
| -------------------- | ----------------------------------------- | --------------------------- |
| `amount`             | `u64`                                     |                             |
| `orchestrator_flags` | [`OrchestratorFlags`](#orchestratorflags) | Optional flags for the swap |

### `LifinityV2SwapOptions`

Struct `types::LifinityV2SwapOptions`.

| Field                | Type                                      | Description                 |
| -------------------- | ----------------------------------------- | --------------------------- |
| `amount`             | `u64`                                     |                             |
| `orchestrator_flags` | [`OrchestratorFlags`](#orchestratorflags) | Optional flags for the swap |

### `ManifestDynamicRouteV1Options`

Struct `types::ManifestDynamicRouteV1Options`.

| Field            | Type   |
| ---------------- | ------ |
| `include_global` | `bool` |

### `ManifestSwapOptions`

Struct `types::ManifestSwapOptions`.

| Field                | Type                                      | Description                 |
| -------------------- | ----------------------------------------- | --------------------------- |
| `amount`             | `u64`                                     |                             |
| `orchestrator_flags` | [`OrchestratorFlags`](#orchestratorflags) | Optional flags for the swap |

### `MetaDaoSwapOptions`

Struct `types::MetaDaoSwapOptions`.

| Field                | Type                                      | Description                 |
| -------------------- | ----------------------------------------- | --------------------------- |
| `amount`             | `u64`                                     |                             |
| `orchestrator_flags` | [`OrchestratorFlags`](#orchestratorflags) | Optional flags for the swap |

### `MeteoraDammV1SwapOptions`

Struct `types::MeteoraDammV1SwapOptions`.

| Field                | Type                                      | Description                 |
| -------------------- | ----------------------------------------- | --------------------------- |
| `amount`             | `u64`                                     |                             |
| `orchestrator_flags` | [`OrchestratorFlags`](#orchestratorflags) | Optional flags for the swap |

### `MeteoraDammV2SwapOptions`

Struct `types::MeteoraDammV2SwapOptions`.

| Field                | Type                                      | Description                 |
| -------------------- | ----------------------------------------- | --------------------------- |
| `amount`             | `u64`                                     |                             |
| `orchestrator_flags` | [`OrchestratorFlags`](#orchestratorflags) | Optional flags for the swap |

### `MeteoraDbcSwapOptions`

Struct `types::MeteoraDbcSwapOptions`.

| Field                     | Type                                      | Description                 |
| ------------------------- | ----------------------------------------- | --------------------------- |
| `amount`                  | `u64`                                     |                             |
| `is_rate_limiter_applied` | `bool`                                    |                             |
| `orchestrator_flags`      | [`OrchestratorFlags`](#orchestratorflags) | Optional flags for the swap |

### `MeteoraDlmmSwapOptions`

Struct `types::MeteoraDlmmSwapOptions`.

| Field                | Type                                      | Description                 |
| -------------------- | ----------------------------------------- | --------------------------- |
| `amount`             | `u64`                                     |                             |
| `num_bin_arrays`     | `u8`                                      |                             |
| `orchestrator_flags` | [`OrchestratorFlags`](#orchestratorflags) | Optional flags for the swap |

### `MeteoraDlmmSwapV2Options`

Struct `types::MeteoraDlmmSwapV2Options`.

| Field                | Type                                      | Description                 |
| -------------------- | ----------------------------------------- | --------------------------- |
| `amount`             | `u64`                                     |                             |
| `num_bin_arrays`     | `u8`                                      |                             |
| `orchestrator_flags` | [`OrchestratorFlags`](#orchestratorflags) | Optional flags for the swap |

### `MozartDynamicRouteV1Options`

Struct `types::MozartDynamicRouteV1Options`.

No fields.

### `MozartSwapOptions`

Struct `types::MozartSwapOptions`.

| Field                | Type                                      | Description                 |
| -------------------- | ----------------------------------------- | --------------------------- |
| `amount`             | `u64`                                     |                             |
| `orchestrator_flags` | [`OrchestratorFlags`](#orchestratorflags) | Optional flags for the swap |

### `NexusDynamicRouteV1Options`

Struct `types::NexusDynamicRouteV1Options`.

No fields.

### `NexusSwapOptions`

Struct `types::NexusSwapOptions`.

| Field                | Type                                      | Description                 |
| -------------------- | ----------------------------------------- | --------------------------- |
| `amount`             | `u64`                                     |                             |
| `orchestrator_flags` | [`OrchestratorFlags`](#orchestratorflags) | Optional flags for the swap |

### `O`

Struct `types::O`.

| Field                | Type                                      |
| -------------------- | ----------------------------------------- |
| `a`                  | [`Vec<A>`](#a)                            |
| `amount`             | `u64`                                     |
| `orchestrator_flags` | [`OrchestratorFlags`](#orchestratorflags) |
| `pfs`                | `u16`                                     |
| `dfs`                | `u16`                                     |

### `ObricV2DynamicRouteV1Options`

Struct `types::ObricV2DynamicRouteV1Options`.

No fields.

### `ObricV2SwapOptions`

Struct `types::ObricV2SwapOptions`.

| Field                | Type                                      | Description                 |
| -------------------- | ----------------------------------------- | --------------------------- |
| `amount`             | `u64`                                     |                             |
| `orchestrator_flags` | [`OrchestratorFlags`](#orchestratorflags) | Optional flags for the swap |

### `OpenOrderParams`

Struct `types::OpenOrderParams`.

| Field                | Type     | Description                                                                                                                                                                        |
| -------------------- | -------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `input_amount`       | `u64`    |                                                                                                                                                                                    |
| `quoted_out_amount`  | `u64`    | Quoted output amount after platform fee                                                                                                                                            |
| `fee_budget`         | `u64`    | Maximum amount in lamports that the fee payer will pay to have the order filled or closed                                                                                          |
| `order_account_id`   | `u64`    |                                                                                                                                                                                    |
| `fillable_for_slots` | `u32`    | Number of slots after the slot in which the order is opened for which the order is fillable. If zero, the order is only fillable in the slot in which the open transaction landed. |
| `slippage_bps`       | `u16`    | Max allowed slippage in basis points. Along with `quoted_out_amount`, this is used to calculate the minimum allowed output amount.                                                 |
| `closer`             | `Pubkey` | Account that is authorized to close the order                                                                                                                                      |
| `flags`              | `u8`     | Flags for the order                                                                                                                                                                |

### `OpenPredictionsOrderOptions`

Struct `types::OpenPredictionsOrderOptions`.

| Field                          | Type     | Description                                                      |
| ------------------------------ | -------- | ---------------------------------------------------------------- |
| `nonce`                        | `u64`    |                                                                  |
| `order_outcome`                | `u8`     |                                                                  |
| `quoted_out_amount`            | `u64`    | Quoted output amount for the predictions order                   |
| `slippage_bps`                 | `u16`    | Slippage for the predictions order (separate from swap slippage) |
| `platform_fee_recipient_vault` | `Pubkey` |                                                                  |
| `platform_fee_scale`           | `u16`    |                                                                  |

### `OrchestratorFlags`

Struct `types::OrchestratorFlags`.

| Field   | Type |
| ------- | ---- |
| `flags` | `u8` |

### `PhoenixSwapOptions`

Struct `types::PhoenixSwapOptions`.

| Field                | Type                                      | Description                 |
| -------------------- | ----------------------------------------- | --------------------------- |
| `amount`             | `u64`                                     |                             |
| `side`               | [`Side`](#side)                           |                             |
| `orchestrator_flags` | [`OrchestratorFlags`](#orchestratorflags) | Optional flags for the swap |

### `PumpFunAmmBuyOptions`

Struct `types::PumpFunAmmBuyOptions`.

| Field                | Type                                      | Description                 |
| -------------------- | ----------------------------------------- | --------------------------- |
| `amount`             | `u64`                                     |                             |
| `orchestrator_flags` | [`OrchestratorFlags`](#orchestratorflags) | Optional flags for the swap |

### `PumpFunAmmSellOptions`

Struct `types::PumpFunAmmSellOptions`.

| Field                | Type                                      | Description                 |
| -------------------- | ----------------------------------------- | --------------------------- |
| `amount`             | `u64`                                     |                             |
| `orchestrator_flags` | [`OrchestratorFlags`](#orchestratorflags) | Optional flags for the swap |

### `PumpFunBuyOptions`

Struct `types::PumpFunBuyOptions`.

| Field                | Type                                      | Description                 |
| -------------------- | ----------------------------------------- | --------------------------- |
| `amount`             | `u64`                                     |                             |
| `orchestrator_flags` | [`OrchestratorFlags`](#orchestratorflags) | Optional flags for the swap |

### `PumpFunSellOptions`

Struct `types::PumpFunSellOptions`.

| Field                | Type                                      | Description                 |
| -------------------- | ----------------------------------------- | --------------------------- |
| `amount`             | `u64`                                     |                             |
| `orchestrator_flags` | [`OrchestratorFlags`](#orchestratorflags) | Optional flags for the swap |

### `RaydiumAmmSwapOptions`

Struct `types::RaydiumAmmSwapOptions`.

| Field                | Type                                      | Description                 |
| -------------------- | ----------------------------------------- | --------------------------- |
| `amount`             | `u64`                                     |                             |
| `orchestrator_flags` | [`OrchestratorFlags`](#orchestratorflags) | Optional flags for the swap |

### `RaydiumClmmSwapOptions`

Struct `types::RaydiumClmmSwapOptions`.

| Field                    | Type                                      | Description                 |
| ------------------------ | ----------------------------------------- | --------------------------- |
| `amount`                 | `u64`                                     |                             |
| `num_remaining_accounts` | `u8`                                      |                             |
| `orchestrator_flags`     | [`OrchestratorFlags`](#orchestratorflags) | Optional flags for the swap |

### `RaydiumClmmSwapV2Options`

Struct `types::RaydiumClmmSwapV2Options`.

| Field                    | Type                                      | Description                 |
| ------------------------ | ----------------------------------------- | --------------------------- |
| `amount`                 | `u64`                                     |                             |
| `num_remaining_accounts` | `u8`                                      |                             |
| `orchestrator_flags`     | [`OrchestratorFlags`](#orchestratorflags) | Optional flags for the swap |

### `RaydiumCpSwapOptions`

Struct `types::RaydiumCpSwapOptions`.

| Field                | Type                                      | Description                 |
| -------------------- | ----------------------------------------- | --------------------------- |
| `amount`             | `u64`                                     |                             |
| `orchestrator_flags` | [`OrchestratorFlags`](#orchestratorflags) | Optional flags for the swap |

### `RaydiumLaunchlabSwapOptions`

Struct `types::RaydiumLaunchlabSwapOptions`.

| Field                | Type                                      | Description                 |
| -------------------- | ----------------------------------------- | --------------------------- |
| `amount`             | `u64`                                     |                             |
| `orchestrator_flags` | [`OrchestratorFlags`](#orchestratorflags) | Optional flags for the swap |

### `RecordId2Options`

Struct `types::RecordId2Options`.

| Field | Type      |
| ----- | --------- |
| `id`  | `[u8; 4]` |

### `RecordIdOptions`

Struct `types::RecordIdOptions`.

| Field | Type       |
| ----- | ---------- |
| `id`  | `[u8; 76]` |

### `RubiconDynamicRouteV1Options`

Struct `types::RubiconDynamicRouteV1Options`.

No fields.

### `RubiconSwapOptions`

Struct `types::RubiconSwapOptions`.

| Field                | Type                                      | Description                 |
| -------------------- | ----------------------------------------- | --------------------------- |
| `amount`             | `u64`                                     |                             |
| `orchestrator_flags` | [`OrchestratorFlags`](#orchestratorflags) | Optional flags for the swap |

### `SanctumInfinityLiquidityOptions`

Struct `types::SanctumInfinityLiquidityOptions`.

| Field                 | Type                                      | Description                 |
| --------------------- | ----------------------------------------- | --------------------------- |
| `amount`              | `u64`                                     |                             |
| `lst_value_calc_accs` | `u8`                                      |                             |
| `lst_index`           | `u32`                                     |                             |
| `orchestrator_flags`  | [`OrchestratorFlags`](#orchestratorflags) | Optional flags for the swap |

### `SanctumInfinitySwapOptions`

Struct `types::SanctumInfinitySwapOptions`.

| Field                     | Type                                      | Description                 |
| ------------------------- | ----------------------------------------- | --------------------------- |
| `amount`                  | `u64`                                     |                             |
| `src_lst_value_calc_accs` | `u8`                                      |                             |
| `dst_lst_value_calc_accs` | `u8`                                      |                             |
| `src_lst_index`           | `u32`                                     |                             |
| `dst_lst_index`           | `u32`                                     |                             |
| `orchestrator_flags`      | [`OrchestratorFlags`](#orchestratorflags) | Optional flags for the swap |

### `SarosDlmmSwapOptions`

Struct `types::SarosDlmmSwapOptions`.

| Field                | Type                                      | Description                 |
| -------------------- | ----------------------------------------- | --------------------------- |
| `amount`             | `u64`                                     |                             |
| `orchestrator_flags` | [`OrchestratorFlags`](#orchestratorflags) | Optional flags for the swap |

### `ScorchSwapOptions`

Struct `types::ScorchSwapOptions`.

| Field                | Type                                      | Description                 |
| -------------------- | ----------------------------------------- | --------------------------- |
| `amount`             | `u64`                                     |                             |
| `id`                 | `u128`                                    |                             |
| `orchestrator_flags` | [`OrchestratorFlags`](#orchestratorflags) | Optional flags for the swap |

### `SetMaxUnderconsumptionBpsOptions`

Struct `types::SetMaxUnderconsumptionBpsOptions`.

| Field                      | Type  |
| -------------------------- | ----- |
| `max_underconsumption_bps` | `u16` |

### `SetMinimumLegOutputsOptions`

Struct `types::SetMinimumLegOutputsOptions`.

| Field             | Type       | Description                                     |
| ----------------- | ---------- | ----------------------------------------------- |
| `minimum_outputs` | `Vec<u64>` | Minimum allowed output amount for each swap leg |

### `SetMinimumLegPricesOptions`

Struct `types::SetMinimumLegPricesOptions`.

| Field            | Type                         | Description                             |
| ---------------- | ---------------------------- | --------------------------------------- |
| `minimum_prices` | [`Vec<LegPrice>`](#legprice) | Minimum allowed price for each swap leg |

### `Side`

Enum `types::Side`.

| Variant |
| ------- |
| `Bid`   |
| `Ask`   |

### `SolFiDynamicRouteV1Options`

Struct `types::SolFiDynamicRouteV1Options`.

No fields.

### `SolFiSwapOptions`

Struct `types::SolFiSwapOptions`.

| Field                | Type                                      | Description                 |
| -------------------- | ----------------------------------------- | --------------------------- |
| `amount`             | `u64`                                     |                             |
| `orchestrator_flags` | [`OrchestratorFlags`](#orchestratorflags) | Optional flags for the swap |

### `SolFiV2DynamicRouteV1Options`

Struct `types::SolFiV2DynamicRouteV1Options`.

No fields.

### `SolFiV2SwapOptions`

Struct `types::SolFiV2SwapOptions`.

| Field                | Type                                      | Description                 |
| -------------------- | ----------------------------------------- | --------------------------- |
| `amount`             | `u64`                                     |                             |
| `orchestrator_flags` | [`OrchestratorFlags`](#orchestratorflags) | Optional flags for the swap |

### `StabbleStableSwapOptions`

Struct `types::StabbleStableSwapOptions`.

| Field                | Type                                      | Description                 |
| -------------------- | ----------------------------------------- | --------------------------- |
| `amount`             | `u64`                                     |                             |
| `orchestrator_flags` | [`OrchestratorFlags`](#orchestratorflags) | Optional flags for the swap |

### `StabbleWeightedSwapOptions`

Struct `types::StabbleWeightedSwapOptions`.

| Field                | Type                                      | Description                 |
| -------------------- | ----------------------------------------- | --------------------------- |
| `amount`             | `u64`                                     |                             |
| `orchestrator_flags` | [`OrchestratorFlags`](#orchestratorflags) | Optional flags for the swap |

### `Swap2Params`

Struct `types::Swap2Params`.

| Field                             | Type                     | Description                                                                                                                                                                                                                                                                                                                                                                         |
| --------------------------------- | ------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `actions`                         | [`Vec<Action>`](#action) |                                                                                                                                                                                                                                                                                                                                                                                     |
| `quoted_out_amount`               | `u64`                    | Quoted output amount for the swap after platform fee                                                                                                                                                                                                                                                                                                                                |
| `slippage_bps`                    | `u16`                    | Max allowed slippage in basis points. Along with `quoted_out_amount`, this is used to calculate the minimum allowed output amount for the swap.                                                                                                                                                                                                                                     |
| `platform_fee_bps`                | `u16`                    | Platform fee in basis points. If nonzero, this percentage of the output amount will be transferred to the platform fee account, and the instruction must include the platform fee account as the last account. The platform fee account must be a valid token account for the output mint, and it must specify the public key of the Referral program's DFlow project as its owner. |
| `positive_slippage_fee_limit_pct` | `u8`                     | Limit on the positive slippage fee in percent. The positive slippage fee is limited to the lesser of (1) the excess actual out amount above the quoted amount and (2) this percentage of the actual out amount after platform fee.                                                                                                                                                  |

### `SwapEvent`

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

### `SwapParams`

Struct `types::SwapParams`.

| Field               | Type                     | Description                                                                                                                                                                                                                                                                                                                                                                         |
| ------------------- | ------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `actions`           | [`Vec<Action>`](#action) |                                                                                                                                                                                                                                                                                                                                                                                     |
| `quoted_out_amount` | `u64`                    | Quoted output amount for the swap after platform fee                                                                                                                                                                                                                                                                                                                                |
| `slippage_bps`      | `u16`                    | Max allowed slippage in basis points. Along with `quoted_out_amount`, this is used to calculate the minimum allowed output amount for the swap.                                                                                                                                                                                                                                     |
| `platform_fee_bps`  | `u16`                    | Platform fee in basis points. If nonzero, this percentage of the output amount will be transferred to the platform fee account, and the instruction must include the platform fee account as the last account. The platform fee account must be a valid token account for the output mint, and it must specify the public key of the Referral program's DFlow project as its owner. |

### `TesseraVDynamicRouteV1Options`

Struct `types::TesseraVDynamicRouteV1Options`.

No fields.

### `TesseraVSwapOptions`

Struct `types::TesseraVSwapOptions`.

| Field                | Type                                      | Description                 |
| -------------------- | ----------------------------------------- | --------------------------- |
| `amount`             | `u64`                                     |                             |
| `orchestrator_flags` | [`OrchestratorFlags`](#orchestratorflags) | Optional flags for the swap |

### `TokenSwapOptions`

Struct `types::TokenSwapOptions`.

| Field                | Type                                      | Description                 |
| -------------------- | ----------------------------------------- | --------------------------- |
| `amount`             | `u64`                                     |                             |
| `orchestrator_flags` | [`OrchestratorFlags`](#orchestratorflags) | Optional flags for the swap |

### `TransferFeeOptions`

Struct `types::TransferFeeOptions`.

| Field    | Type  |
| -------- | ----- |
| `amount` | `u64` |

### `VaultSwapOptions`

Struct `types::VaultSwapOptions`.

| Field                | Type                                      | Description                 |
| -------------------- | ----------------------------------------- | --------------------------- |
| `amount`             | `u64`                                     |                             |
| `orchestrator_flags` | [`OrchestratorFlags`](#orchestratorflags) | Optional flags for the swap |

### `VertigoSwapOptions`

Struct `types::VertigoSwapOptions`.

| Field                | Type                                      | Description                 |
| -------------------- | ----------------------------------------- | --------------------------- |
| `amount`             | `u64`                                     |                             |
| `orchestrator_flags` | [`OrchestratorFlags`](#orchestratorflags) | Optional flags for the swap |

### `WhirlpoolsSwapOptions`

Struct `types::WhirlpoolsSwapOptions`.

| Field                | Type                                      | Description                 |
| -------------------- | ----------------------------------------- | --------------------------- |
| `amount`             | `u64`                                     |                             |
| `a_to_b`             | `bool`                                    |                             |
| `orchestrator_flags` | [`OrchestratorFlags`](#orchestratorflags) | Optional flags for the swap |

### `WhirlpoolsSwapV2Options`

Struct `types::WhirlpoolsSwapV2Options`.

| Field                | Type                                      | Description                 |
| -------------------- | ----------------------------------------- | --------------------------- |
| `amount`             | `u64`                                     |                             |
| `a_to_b`             | `bool`                                    |                             |
| `orchestrator_flags` | [`OrchestratorFlags`](#orchestratorflags) | Optional flags for the swap |

### `WrapSolOptions`

Struct `types::WrapSolOptions`.

| Field      | Type  |
| ---------- | ----- |
| `lamports` | `u64` |

### `XoCashExchangeSwapOptions`

Struct `types::XoCashExchangeSwapOptions`.

| Field                | Type                                      | Description                 |
| -------------------- | ----------------------------------------- | --------------------------- |
| `amount`             | `u64`                                     |                             |
| `orchestrator_flags` | [`OrchestratorFlags`](#orchestratorflags) | Optional flags for the swap |

### `ZeroFiDynamicRouteV1Options`

Struct `types::ZeroFiDynamicRouteV1Options`.

No fields.

### `ZeroFiSwapOptions`

Struct `types::ZeroFiSwapOptions`.

| Field                | Type                                      | Description                 |
| -------------------- | ----------------------------------------- | --------------------------- |
| `amount`             | `u64`                                     |                             |
| `orchestrator_flags` | [`OrchestratorFlags`](#orchestratorflags) | Optional flags for the swap |

---

Carbon 2.0.0 documentation · Web: https://carbon.sevenlabs.org/decoders/dflow-aggregator-v4 · Last updated 2026-11-09 · Index of all pages: https://carbon.sevenlabs.org/llms.txt
