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.
| Crate | carbon-fluxbeam-decoder 2.0.0 |
| Install | cargo add carbon-fluxbeam-decoder@2. |
| Program ID | FLUXubRmkEi2q6K3Y9kBPg9248ggaZVsoSFhtJHSrm1X (carbon_) |
| Category | DEX & AMM |
| Decoder | carbon_ |
| Instruction enum | instructions:: |
| Account enum | accounts:: (no variants) |
| Features | serde, postgres, graphql (none enabled by default) |
| API docs | docs.rs/carbon-fluxbeam-decoder/2.0.0 |
| Source | decoders/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:
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/fulluse {
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(())
}
}RUST_LOG=info cargo runEach 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::, where data and accounts are the types listed under the variant, exported from carbon_. 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:
- The instruction's program ID is
FLUXubRmkEi2q6K3Y9kBPg9248ggaZVsoSFhtJHSrm1X. - The data starts with the variant's discriminator, and the rest deserializes into its data type.
- 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_ too. Accounts after the listed ones are in accounts. as AccountMetas. The decoder doesn't record whether an account signed or was writable: read that from input. and ., 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_ | u64 |
maximum_ | u64 |
maximum_ | u64 |
Required accounts: 14; extras go to remaining.
Fields of DepositAllTokenTypesInstructionAccounts, in account order:
| # | Field | Type |
|---|---|---|
| 0 | swap | Pubkey |
| 1 | authority | Pubkey |
| 2 | user_ | Pubkey |
| 3 | deposit_ | Pubkey |
| 4 | deposit_ | Pubkey |
| 5 | swap_ | Pubkey |
| 6 | swap_ | Pubkey |
| 7 | pool_mint | Pubkey |
| 8 | destination | Pubkey |
| 9 | token_ | Pubkey |
| 10 | token_ | Pubkey |
| 11 | token_ | Pubkey |
| 12 | token_ | Pubkey |
| 13 | token_ | Pubkey |
| 14… | remaining | Vec< |
DepositSingleTokenTypeExactAmountIn#
Discriminator 04 · data DepositSingleTokenTypeExactAmountIn · accounts DepositSingleTokenTypeExactAmountInInstructionAccounts.
| Field | Type |
|---|---|
source_ | u64 |
minimum_ | u64 |
Required accounts: 11; extras go to remaining.
Fields of DepositSingleTokenTypeExactAmountInInstructionAccounts, in account order:
| # | Field | Type |
|---|---|---|
| 0 | swap | Pubkey |
| 1 | authority | Pubkey |
| 2 | user_ | Pubkey |
| 3 | source_ | Pubkey |
| 4 | swap_ | Pubkey |
| 5 | swap_ | Pubkey |
| 6 | pool_mint | Pubkey |
| 7 | destination | Pubkey |
| 8 | source_mint | Pubkey |
| 9 | token_ | Pubkey |
| 10 | token_ | Pubkey |
| 11… | remaining | Vec< |
Initialize#
Discriminator 00 · data Initialize · accounts InitializeInstructionAccounts.
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_ | Pubkey |
| 8… | remaining | Vec< |
Swap#
Discriminator 01 · data Swap · accounts SwapInstructionAccounts.
| Field | Type |
|---|---|
amount_in | u64 |
minimum_ | u64 |
Required accounts: 14; extras go to remaining.
Fields of SwapInstructionAccounts, in account order:
| # | Field | Type |
|---|---|---|
| 0 | swap | Pubkey |
| 1 | authority | Pubkey |
| 2 | user_ | Pubkey |
| 3 | source | Pubkey |
| 4 | swap_source | Pubkey |
| 5 | swap_ | Pubkey |
| 6 | destination | Pubkey |
| 7 | pool_mint | Pubkey |
| 8 | pool_fee | Pubkey |
| 9 | source_mint | Pubkey |
| 10 | destination_ | Pubkey |
| 11 | token_ | Pubkey |
| 12 | token_ | Pubkey |
| 13 | token_ | Pubkey |
| 14… | remaining | Vec< |
WithdrawAllTokenTypes#
Discriminator 03 · data WithdrawAllTokenTypes · accounts WithdrawAllTokenTypesInstructionAccounts.
| Field | Type |
|---|---|
pool_ | u64 |
minimum_ | u64 |
minimum_ | u64 |
Required accounts: 15; extras go to remaining.
Fields of WithdrawAllTokenTypesInstructionAccounts, in account order:
| # | Field | Type |
|---|---|---|
| 0 | swap | Pubkey |
| 1 | authority | Pubkey |
| 2 | user_ | Pubkey |
| 3 | pool_mint | Pubkey |
| 4 | source | Pubkey |
| 5 | swap_ | Pubkey |
| 6 | swap_ | Pubkey |
| 7 | destination_ | Pubkey |
| 8 | destination_ | Pubkey |
| 9 | fee_account | Pubkey |
| 10 | token_ | Pubkey |
| 11 | token_ | Pubkey |
| 12 | token_ | Pubkey |
| 13 | token_ | Pubkey |
| 14 | token_ | Pubkey |
| 15… | remaining | Vec< |
WithdrawSingleTokenTypeExactAmountOut#
Discriminator 05 · data WithdrawSingleTokenTypeExactAmountOut · accounts WithdrawSingleTokenTypeExactAmountOutInstructionAccounts.
| Field | Type |
|---|---|
destination_ | u64 |
maximum_ | u64 |
Required accounts: 12; extras go to remaining.
Fields of WithdrawSingleTokenTypeExactAmountOutInstructionAccounts, in account order:
| # | Field | Type |
|---|---|---|
| 0 | swap | Pubkey |
| 1 | authority | Pubkey |
| 2 | user_ | Pubkey |
| 3 | pool_mint | Pubkey |
| 4 | pool_ | Pubkey |
| 5 | swap_ | Pubkey |
| 6 | swap_ | Pubkey |
| 7 | destination | Pubkey |
| 8 | fee_account | Pubkey |
| 9 | destination_ | Pubkey |
| 10 | token_ | Pubkey |
| 11 | token_ | Pubkey |
| 12… | remaining | Vec< |
Types#
Types used by the instructions, accounts and events above, exported from carbon_.
ConstantPriceCurve#
Struct types::.
| Field | Type |
|---|---|
token_ | u64 |
ConstantProductCurve#
Struct types::.
No fields.
CurveType#
Enum types::.
| Variant |
|---|
ConstantProduct |
ConstantPrice |
Offset |
Fees#
Struct types::Fees.
| Field | Type |
|---|---|
trade_ | u64 |
trade_ | u64 |
owner_ | u64 |
owner_ | u64 |
owner_ | u64 |
owner_ | u64 |
host_ | u64 |
host_ | u64 |
OffsetCurve#
Struct types::.
| Field | Type |
|---|---|
token_ | u64 |
SwapCurve#
Struct types::.
| Field | Type |
|---|---|
curve_type | CurveType |
calculator | [u8; 32] |