# FluxBeam decoder (Carbon 2.0)

> Decode FluxBeam instructions in Rust with carbon-fluxbeam-decoder 2.0.0. Program ID FLUXubRmkEi2q6K3Y9kBPg9248ggaZVsoSFhtJHSrm1X.

`carbon-fluxbeam-decoder` decodes the instructions of the FluxBeam program (`FLUXubRmkEi2q6K3Y9kBPg9248ggaZVsoSFhtJHSrm1X`): 6 instructions. It decodes no accounts: `FluxbeamAccount` has no variants. 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-fluxbeam-decoder`](https://crates.io/crates/carbon-fluxbeam-decoder/2.0.0) 2.0.0                 |
| Install          | `cargo add carbon-fluxbeam-decoder@2.0.0`                                                                 |
| Program ID       | `FLUXubRmkEi2q6K3Y9kBPg9248ggaZVsoSFhtJHSrm1X` (`carbon_fluxbeam_decoder::PROGRAM_ID`)                    |
| Category         | [DEX & AMM](https://carbon.sevenlabs.org/decoders/dex-and-amm.md)                                         |
| Decoder          | `carbon_fluxbeam_decoder::FluxbeamDecoder`                                                                |
| Instruction enum | `instructions::FluxbeamInstruction`                                                                       |
| Account enum     | `accounts::FluxbeamAccount` (no variants)                                                                 |
| Features         | `serde`, `postgres`, `graphql` (none enabled by default)                                                  |
| API docs         | [docs.rs/carbon-fluxbeam-decoder/2.0.0](https://docs.rs/carbon-fluxbeam-decoder/2.0.0)                    |
| Source           | [decoders/fluxbeam-decoder](https://github.com/sevenlabs-hq/carbon/tree/v2.0.0/decoders/fluxbeam-decoder) |

Other DEX and AMM decoders: [BonkSwap](https://carbon.sevenlabs.org/decoders/bonkswap.md), [Gavel](https://carbon.sevenlabs.org/decoders/gavel.md), [Heaven](https://carbon.sevenlabs.org/decoders/heaven.md), [Jupiter Limit Order](https://carbon.sevenlabs.org/decoders/jupiter-limit-order.md), [Jupiter Limit Order v2](https://carbon.sevenlabs.org/decoders/jupiter-limit-order-2.md), [Kamino Limit Order](https://carbon.sevenlabs.org/decoders/kamino-limit-order.md), [Lifinity AMM v2](https://carbon.sevenlabs.org/decoders/lifinity-amm-v2.md), [Meteora DAMM v2](https://carbon.sevenlabs.org/decoders/meteora-damm-v2.md), [Meteora DLMM](https://carbon.sevenlabs.org/decoders/meteora-dlmm.md), [Meteora Pools](https://carbon.sevenlabs.org/decoders/meteora-pools.md), [OpenBook v2](https://carbon.sevenlabs.org/decoders/openbook-v2.md), [Orca Whirlpools](https://carbon.sevenlabs.org/decoders/orca-whirlpool.md), [PancakeSwap](https://carbon.sevenlabs.org/decoders/pancake-swap.md), [Phoenix v1](https://carbon.sevenlabs.org/decoders/phoenix-v1.md), [PumpSwap](https://carbon.sevenlabs.org/decoders/pump-swap.md), [Raydium AMM v4](https://carbon.sevenlabs.org/decoders/raydium-amm-v4.md), [Raydium CLMM](https://carbon.sevenlabs.org/decoders/raydium-clmm.md), [Raydium CPMM](https://carbon.sevenlabs.org/decoders/raydium-cpmm.md), [Raydium Stable Swap](https://carbon.sevenlabs.org/decoders/raydium-stable-swap.md), [Stabble Stable Swap](https://carbon.sevenlabs.org/decoders/stabble-stable-swap.md), [Stabble Weighted Swap](https://carbon.sevenlabs.org/decoders/stabble-weighted-swap.md). To decode several in one pipeline, see [dEX and AMM decoders](https://carbon.sevenlabs.org/decoders/dex-and-amm.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 FluxBeam transactions from the public RPC and prints every decoded `Swap` instruction. Add the dependencies:

```sh
cargo add carbon-core@2.0.0 carbon-fluxbeam-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_fluxbeam_decoder::{instructions::FluxbeamInstruction, FluxbeamDecoder, 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(FluxbeamDecoder, InstructionLogger)
        .build()?
        .run()
        .await
}

struct InstructionLogger;

impl Processor<InstructionProcessorInputType<'_, FluxbeamInstruction>> for InstructionLogger {
    async fn process(
        &mut self,
        input: &InstructionProcessorInputType<'_, FluxbeamInstruction>,
    ) -> CarbonResult<()> {
        let signature = input.metadata.transaction_metadata.signature;
        if let FluxbeamInstruction::Swap { data, accounts, .. } = input.decoded_instruction {
            println!("swap {signature}: {data:?} swap={}", accounts.swap);
        }
        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.

## Instructions

Variants of `FluxbeamInstruction`. Each is `FluxbeamInstruction::<Variant> { program_id, data, accounts }`, where `data` and `accounts` are the types listed under the variant, exported from `carbon_fluxbeam_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 `FLUXubRmkEi2q6K3Y9kBPg9248ggaZVsoSFhtJHSrm1X`.
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.

### `DepositAllTokenTypes`

Discriminator `02` · data `DepositAllTokenTypes` · accounts `DepositAllTokenTypesInstructionAccounts`.

| Field                    | Type  |
| ------------------------ | ----- |
| `pool_token_amount`      | `u64` |
| `maximum_token_a_amount` | `u64` |
| `maximum_token_b_amount` | `u64` |

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

Fields of `DepositAllTokenTypesInstructionAccounts`, in account order:

| #   | Field                     | Type               |
| --- | ------------------------- | ------------------ |
| 0   | `swap`                    | `Pubkey`           |
| 1   | `authority`               | `Pubkey`           |
| 2   | `user_transfer_authority` | `Pubkey`           |
| 3   | `deposit_token_a`         | `Pubkey`           |
| 4   | `deposit_token_b`         | `Pubkey`           |
| 5   | `swap_token_a`            | `Pubkey`           |
| 6   | `swap_token_b`            | `Pubkey`           |
| 7   | `pool_mint`               | `Pubkey`           |
| 8   | `destination`             | `Pubkey`           |
| 9   | `token_a_mint`            | `Pubkey`           |
| 10  | `token_b_mint`            | `Pubkey`           |
| 11  | `token_a_program`         | `Pubkey`           |
| 12  | `token_b_program`         | `Pubkey`           |
| 13  | `token_program`           | `Pubkey`           |
| 14… | `remaining`               | `Vec<AccountMeta>` |

### `DepositSingleTokenTypeExactAmountIn`

Discriminator `04` · data `DepositSingleTokenTypeExactAmountIn` · accounts `DepositSingleTokenTypeExactAmountInInstructionAccounts`.

| Field                       | Type  |
| --------------------------- | ----- |
| `source_token_amount`       | `u64` |
| `minimum_pool_token_amount` | `u64` |

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

Fields of `DepositSingleTokenTypeExactAmountInInstructionAccounts`, in account order:

| #   | Field                     | Type               |
| --- | ------------------------- | ------------------ |
| 0   | `swap`                    | `Pubkey`           |
| 1   | `authority`               | `Pubkey`           |
| 2   | `user_transfer_authority` | `Pubkey`           |
| 3   | `source_token`            | `Pubkey`           |
| 4   | `swap_token_a`            | `Pubkey`           |
| 5   | `swap_token_b`            | `Pubkey`           |
| 6   | `pool_mint`               | `Pubkey`           |
| 7   | `destination`             | `Pubkey`           |
| 8   | `source_mint`             | `Pubkey`           |
| 9   | `token_program`           | `Pubkey`           |
| 10  | `token_program_b`         | `Pubkey`           |
| 11… | `remaining`               | `Vec<AccountMeta>` |

### `Initialize`

Discriminator `00` · data `Initialize` · accounts `InitializeInstructionAccounts`.

| Field        | Type                      |
| ------------ | ------------------------- |
| `fees`       | [`Fees`](#fees)           |
| `swap_curve` | [`SwapCurve`](#swapcurve) |

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

Fields of `InitializeInstructionAccounts`, in account order:

| #  | Field           | Type               |
| -- | --------------- | ------------------ |
| 0  | `swap`          | `Pubkey`           |
| 1  | `authority`     | `Pubkey`           |
| 2  | `token_a`       | `Pubkey`           |
| 3  | `token_b`       | `Pubkey`           |
| 4  | `pool`          | `Pubkey`           |
| 5  | `fee`           | `Pubkey`           |
| 6  | `destination`   | `Pubkey`           |
| 7  | `token_program` | `Pubkey`           |
| 8… | `remaining`     | `Vec<AccountMeta>` |

### `Swap`

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

| Field                | Type  |
| -------------------- | ----- |
| `amount_in`          | `u64` |
| `minimum_amount_out` | `u64` |

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

Fields of `SwapInstructionAccounts`, in account order:

| #   | Field                     | Type               |
| --- | ------------------------- | ------------------ |
| 0   | `swap`                    | `Pubkey`           |
| 1   | `authority`               | `Pubkey`           |
| 2   | `user_transfer_authority` | `Pubkey`           |
| 3   | `source`                  | `Pubkey`           |
| 4   | `swap_source`             | `Pubkey`           |
| 5   | `swap_destination`        | `Pubkey`           |
| 6   | `destination`             | `Pubkey`           |
| 7   | `pool_mint`               | `Pubkey`           |
| 8   | `pool_fee`                | `Pubkey`           |
| 9   | `source_mint`             | `Pubkey`           |
| 10  | `destination_mint`        | `Pubkey`           |
| 11  | `token_program`           | `Pubkey`           |
| 12  | `token_program_b`         | `Pubkey`           |
| 13  | `token_program_c`         | `Pubkey`           |
| 14… | `remaining`               | `Vec<AccountMeta>` |

### `WithdrawAllTokenTypes`

Discriminator `03` · data `WithdrawAllTokenTypes` · accounts `WithdrawAllTokenTypesInstructionAccounts`.

| Field                    | Type  |
| ------------------------ | ----- |
| `pool_token_amount`      | `u64` |
| `minimum_token_a_amount` | `u64` |
| `minimum_token_b_amount` | `u64` |

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

Fields of `WithdrawAllTokenTypesInstructionAccounts`, in account order:

| #   | Field                     | Type               |
| --- | ------------------------- | ------------------ |
| 0   | `swap`                    | `Pubkey`           |
| 1   | `authority`               | `Pubkey`           |
| 2   | `user_transfer_authority` | `Pubkey`           |
| 3   | `pool_mint`               | `Pubkey`           |
| 4   | `source`                  | `Pubkey`           |
| 5   | `swap_token_a`            | `Pubkey`           |
| 6   | `swap_token_b`            | `Pubkey`           |
| 7   | `destination_token_a`     | `Pubkey`           |
| 8   | `destination_token_b`     | `Pubkey`           |
| 9   | `fee_account`             | `Pubkey`           |
| 10  | `token_a_mint`            | `Pubkey`           |
| 11  | `token_b_mint`            | `Pubkey`           |
| 12  | `token_program`           | `Pubkey`           |
| 13  | `token_a_program`         | `Pubkey`           |
| 14  | `token_b_program`         | `Pubkey`           |
| 15… | `remaining`               | `Vec<AccountMeta>` |

### `WithdrawSingleTokenTypeExactAmountOut`

Discriminator `05` · data `WithdrawSingleTokenTypeExactAmountOut` · accounts `WithdrawSingleTokenTypeExactAmountOutInstructionAccounts`.

| Field                       | Type  |
| --------------------------- | ----- |
| `destination_token_amount`  | `u64` |
| `maximum_pool_token_amount` | `u64` |

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

Fields of `WithdrawSingleTokenTypeExactAmountOutInstructionAccounts`, in account order:

| #   | Field                     | Type               |
| --- | ------------------------- | ------------------ |
| 0   | `swap`                    | `Pubkey`           |
| 1   | `authority`               | `Pubkey`           |
| 2   | `user_transfer_authority` | `Pubkey`           |
| 3   | `pool_mint`               | `Pubkey`           |
| 4   | `pool_token_source`       | `Pubkey`           |
| 5   | `swap_token_a`            | `Pubkey`           |
| 6   | `swap_token_b`            | `Pubkey`           |
| 7   | `destination`             | `Pubkey`           |
| 8   | `fee_account`             | `Pubkey`           |
| 9   | `destination_mint`        | `Pubkey`           |
| 10  | `token_program`           | `Pubkey`           |
| 11  | `token_program_b`         | `Pubkey`           |
| 12… | `remaining`               | `Vec<AccountMeta>` |

## Types

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

### `ConstantPriceCurve`

Struct `types::ConstantPriceCurve`.

| Field           | Type  |
| --------------- | ----- |
| `token_b_price` | `u64` |

### `ConstantProductCurve`

Struct `types::ConstantProductCurve`.

No fields.

### `CurveType`

Enum `types::CurveType`.

| Variant           |
| ----------------- |
| `ConstantProduct` |
| `ConstantPrice`   |
| `Offset`          |

### `Fees`

Struct `types::Fees`.

| Field                            | Type  |
| -------------------------------- | ----- |
| `trade_fee_numerator`            | `u64` |
| `trade_fee_denominator`          | `u64` |
| `owner_trade_fee_numerator`      | `u64` |
| `owner_trade_fee_denominator`    | `u64` |
| `owner_withdraw_fee_numerator`   | `u64` |
| `owner_withdraw_fee_denominator` | `u64` |
| `host_fee_numerator`             | `u64` |
| `host_fee_denominator`           | `u64` |

### `OffsetCurve`

Struct `types::OffsetCurve`.

| Field            | Type  |
| ---------------- | ----- |
| `token_b_offset` | `u64` |

### `SwapCurve`

Struct `types::SwapCurve`.

| Field        | Type                      |
| ------------ | ------------------------- |
| `curve_type` | [`CurveType`](#curvetype) |
| `calculator` | `[u8; 32]`                |

---

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