FluxBeam decoder

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

On this page

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 for how decoders plug into a pipeline.

Cratecarbon-fluxbeam-decoder 2.0.0
Installcargo add carbon-fluxbeam-decoder@2.0.0
Program IDFLUXubRmkEi2q6K3Y9kBPg9248ggaZVsoSFhtJHSrm1X (carbon_fluxbeam_decoder::PROGRAM_ID)
CategoryDEX & AMM
Decodercarbon_fluxbeam_decoder::FluxbeamDecoder
Instruction enuminstructions::FluxbeamInstruction
Account enumaccounts::FluxbeamAccount (no variants)
Featuresserde, postgres, graphql (none enabled by default)
API docsdocs.rs/carbon-fluxbeam-decoder/2.0.0
Sourcedecoders/fluxbeam-decoder

Other DEX and AMM decoders: BonkSwap, Gavel, Heaven, Jupiter Limit Order, Jupiter Limit Order v2, Kamino Limit Order, Lifinity AMM v2, Meteora DAMM v2, Meteora DLMM, Meteora Pools, OpenBook v2, Orca Whirlpools, PancakeSwap, Phoenix v1, PumpSwap, Raydium AMM v4, Raydium CLMM, Raydium CPMM, Raydium Stable Swap, Stabble Stable Swap, Stabble Weighted Swap. To decode several in one pipeline, see dEX and AMM decoders.

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

Usage#

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

Terminal
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
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(())
    }
}
Terminal
RUST_LOG=info cargo run

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

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 AccountMetas. The decoder doesn't record whether an account signed or was writable: read that from input.raw_instruction.accounts[i].is_signer and .is_writable, which follow the same order. It doesn't check signer, writable, owner or PDA constraints either; the program enforced those when the transaction executed, so a decoded instruction from a successful transaction already satisfied them.

DepositAllTokenTypes#

Discriminator 02 · data DepositAllTokenTypes · accounts DepositAllTokenTypesInstructionAccounts.

FieldType
pool_token_amountu64
maximum_token_a_amountu64
maximum_token_b_amountu64

Required accounts: 14; extras go to remaining.

Fields of DepositAllTokenTypesInstructionAccounts, in account order:

#FieldType
0swapPubkey
1authorityPubkey
2user_transfer_authorityPubkey
3deposit_token_aPubkey
4deposit_token_bPubkey
5swap_token_aPubkey
6swap_token_bPubkey
7pool_mintPubkey
8destinationPubkey
9token_a_mintPubkey
10token_b_mintPubkey
11token_a_programPubkey
12token_b_programPubkey
13token_programPubkey
14…remainingVec<AccountMeta>

DepositSingleTokenTypeExactAmountIn#

Discriminator 04 · data DepositSingleTokenTypeExactAmountIn · accounts DepositSingleTokenTypeExactAmountInInstructionAccounts.

FieldType
source_token_amountu64
minimum_pool_token_amountu64

Required accounts: 11; extras go to remaining.

Fields of DepositSingleTokenTypeExactAmountInInstructionAccounts, in account order:

#FieldType
0swapPubkey
1authorityPubkey
2user_transfer_authorityPubkey
3source_tokenPubkey
4swap_token_aPubkey
5swap_token_bPubkey
6pool_mintPubkey
7destinationPubkey
8source_mintPubkey
9token_programPubkey
10token_program_bPubkey
11…remainingVec<AccountMeta>

Initialize#

Discriminator 00 · data Initialize · accounts InitializeInstructionAccounts.

FieldType
feesFees
swap_curveSwapCurve

Required accounts: 8; extras go to remaining.

Fields of InitializeInstructionAccounts, in account order:

#FieldType
0swapPubkey
1authorityPubkey
2token_aPubkey
3token_bPubkey
4poolPubkey
5feePubkey
6destinationPubkey
7token_programPubkey
8…remainingVec<AccountMeta>

Swap#

Discriminator 01 · data Swap · accounts SwapInstructionAccounts.

FieldType
amount_inu64
minimum_amount_outu64

Required accounts: 14; extras go to remaining.

Fields of SwapInstructionAccounts, in account order:

#FieldType
0swapPubkey
1authorityPubkey
2user_transfer_authorityPubkey
3sourcePubkey
4swap_sourcePubkey
5swap_destinationPubkey
6destinationPubkey
7pool_mintPubkey
8pool_feePubkey
9source_mintPubkey
10destination_mintPubkey
11token_programPubkey
12token_program_bPubkey
13token_program_cPubkey
14…remainingVec<AccountMeta>

WithdrawAllTokenTypes#

Discriminator 03 · data WithdrawAllTokenTypes · accounts WithdrawAllTokenTypesInstructionAccounts.

FieldType
pool_token_amountu64
minimum_token_a_amountu64
minimum_token_b_amountu64

Required accounts: 15; extras go to remaining.

Fields of WithdrawAllTokenTypesInstructionAccounts, in account order:

#FieldType
0swapPubkey
1authorityPubkey
2user_transfer_authorityPubkey
3pool_mintPubkey
4sourcePubkey
5swap_token_aPubkey
6swap_token_bPubkey
7destination_token_aPubkey
8destination_token_bPubkey
9fee_accountPubkey
10token_a_mintPubkey
11token_b_mintPubkey
12token_programPubkey
13token_a_programPubkey
14token_b_programPubkey
15…remainingVec<AccountMeta>

WithdrawSingleTokenTypeExactAmountOut#

Discriminator 05 · data WithdrawSingleTokenTypeExactAmountOut · accounts WithdrawSingleTokenTypeExactAmountOutInstructionAccounts.

FieldType
destination_token_amountu64
maximum_pool_token_amountu64

Required accounts: 12; extras go to remaining.

Fields of WithdrawSingleTokenTypeExactAmountOutInstructionAccounts, in account order:

#FieldType
0swapPubkey
1authorityPubkey
2user_transfer_authorityPubkey
3pool_mintPubkey
4pool_token_sourcePubkey
5swap_token_aPubkey
6swap_token_bPubkey
7destinationPubkey
8fee_accountPubkey
9destination_mintPubkey
10token_programPubkey
11token_program_bPubkey
12…remainingVec<AccountMeta>

Types#

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

ConstantPriceCurve#

Struct types::ConstantPriceCurve.

FieldType
token_b_priceu64

ConstantProductCurve#

Struct types::ConstantProductCurve.

No fields.

CurveType#

Enum types::CurveType.

Variant
ConstantProduct
ConstantPrice
Offset

Fees#

Struct types::Fees.

FieldType
trade_fee_numeratoru64
trade_fee_denominatoru64
owner_trade_fee_numeratoru64
owner_trade_fee_denominatoru64
owner_withdraw_fee_numeratoru64
owner_withdraw_fee_denominatoru64
host_fee_numeratoru64
host_fee_denominatoru64

OffsetCurve#

Struct types::OffsetCurve.

FieldType
token_b_offsetu64

SwapCurve#

Struct types::SwapCurve.

FieldType
curve_typeCurveType
calculator[u8; 32]

Generated from the crate’s source at Carbon v2.0.0, so it always matches the published code. Spotted a problem? Report it; edits to this page itself are overwritten on the next release.

Your endpoints

Code samples use these instead of the placeholders, so you can copy and run them as they are. They’re stored only in this browser and never sent anywhere.