1. Decoders

DEX and AMM decoders

Decode 22 Solana DEX and AMM programs in Rust, including Raydium AMM v4, Raydium CPMM, Raydium CLMM and PumpSwap, with Carbon decoder crates.

On this page

Carbon 2.0.0 has decoder crates for 22 DEX and AMM programs on Solana: 543 instructions, 104 account types and 155 events in all. Use them to index swaps, liquidity deposits and withdrawals, pools, positions and order book markets as typed Rust values instead of parsing raw bytes. Each program's page lists every instruction with its discriminator, data fields and accounts, every account and event, and a complete program that runs against the public RPC.

Programs#

Program IDs are the mainnet addresses compiled into each crate as PROGRAM_ID. Instruction counts exclude the CpiEvent wrapper.

ProgramCrateProgram IDInstructionsAccountsEvents
BonkSwapcarbon-bonkswap-decoderBSwp6bEBihVLdqJRKGgzjcGLHkcTuzmSo1TQkHepzH8p1950
FluxBeamcarbon-fluxbeam-decoderFLUXubRmkEi2q6K3Y9kBPg9248ggaZVsoSFhtJHSrm1X600
Gavelcarbon-gavel-decodersrAMMzfVHVAtgSJc8iH6CfKzuWuUTzLHVCE81QU1rgi1020
Heavencarbon-heaven-decoderHEAVENoP2qxoeuF8Dj2oT1GHEnu49U5mJYkdeC8BAX2o5467
Jupiter Limit Ordercarbon-jupiter-limit-order-decoderjupoNjAxXgZ4rjzxzPMP4oxduvQsQtZzyknqvzYNrNu923
Jupiter Limit Order v2carbon-jupiter-limit-order-2-decoderj1o2qRpjcyUwEvwtcfhEQefh773ZgjxcVRry7LDqg5X824
Kamino Limit Ordercarbon-kamino-limit-order-decoderLiMoM9rMhrdYrfzUCxQppvxCSG1FcrUK9G8uLq4A1GF1532
Lifinity AMM v2carbon-lifinity-amm-v2-decoder2wT8Yq49kHgDzXuPxZSaeLaH1qbmGXtEyPy64bL7aD3c310
Meteora DAMM v2carbon-meteora-damm-v2-decodercpamdpZCGKUy5JxQXB4dcpGPiikHawvSWAd6mEn1sGG38923
Meteora DLMMcarbon-meteora-dlmm-decoderLBUZKhRxPF3XUpBCjp4YzTKgLccjZhTSDM9YuVaPwxo761230
Meteora Poolscarbon-meteora-pools-decoderEo7WjKq67rjJQSZxS6z3YkapzY3eMj6Xy8X5EQVn5UaB26318
OpenBook v2carbon-openbook-v2-decoderopnb2LAfJYbRMAHHvqjCwQxanZn7ReEHp1k81EohpZb2968
Orca Whirlpoolscarbon-orca-whirlpool-decoderwhirLbMiicVdio4qvUfM5KAg6Ct8VwpYzGff3uctyCc66126
PancakeSwapcarbon-pancake-swap-decoderHpNfyc2Saw7RKkQd8nEL4khUcuPhQ7WwY1B2qjx8jxFq271011
Phoenix v1carbon-phoenix-v1-decoderPhoeNiXZ8ByJGLkxNfZRnkUfjvmuYqLR89jjFHGqdXY2800
PumpSwapcarbon-pump-swap-decoderpAMMBay6oceH9fJKBRHGP5D4bD4sWpmSwMn52FMfXEA25722
Raydium AMM v4carbon-raydium-amm-v4-decoder675kPX9MHTjS2zt1qfr1NYHuzeLXfQM9H24wFSUt1Mp81830
Raydium CLMMcarbon-raydium-clmm-decoderCAMMCzo5YL8w4VFF8KVHrK22GGUsp5VTaW7grrKgrWqK341215
Raydium CPMMcarbon-raydium-cpmm-decoderCPMMoo8L3F4NbTegBCKVNunggL7H1ZpdTHKxQB5qKP1C1442
Raydium Stable Swapcarbon-raydium-stable-swap-decoder5quBtoiQqxF9Jv6KYKctB59NT3gtJD2Y65kdnB1Uev3h600
Stabble Stable Swapcarbon-stabble-stable-swap-decoderswapNyd8XiQwJ6ianp9snpu4brUqFxadzvHebnAXjJZ1932
Stabble Weighted Swapcarbon-stabble-weighted-swap-decoderswapFpHZwjELNnjvThjajtiVmkz3yPQEHjLtka2fwHW1322

Decode several in one pipeline#

Add carbon-core and the decoder crates you need, all at the same version. For every program in this category:

Terminal
cargo add carbon-core@2.0.0 carbon-bonkswap-decoder@2.0.0 carbon-fluxbeam-decoder@2.0.0 carbon-gavel-decoder@2.0.0 carbon-heaven-decoder@2.0.0 carbon-jupiter-limit-order-decoder@2.0.0 carbon-jupiter-limit-order-2-decoder@2.0.0 carbon-kamino-limit-order-decoder@2.0.0 carbon-lifinity-amm-v2-decoder@2.0.0 carbon-meteora-damm-v2-decoder@2.0.0 carbon-meteora-dlmm-decoder@2.0.0 carbon-meteora-pools-decoder@2.0.0 carbon-openbook-v2-decoder@2.0.0 carbon-orca-whirlpool-decoder@2.0.0 carbon-pancake-swap-decoder@2.0.0 carbon-phoenix-v1-decoder@2.0.0 carbon-pump-swap-decoder@2.0.0 carbon-raydium-amm-v4-decoder@2.0.0 carbon-raydium-clmm-decoder@2.0.0 carbon-raydium-cpmm-decoder@2.0.0 carbon-raydium-stable-swap-decoder@2.0.0 carbon-stabble-stable-swap-decoder@2.0.0 carbon-stabble-weighted-swap-decoder@2.0.0

Register each decoder with a processor for its instruction enum. This fragment goes in your pipeline setup; the processors are yours, one per program, each implementing Processor for that program's instruction input (see processors):

Rust
use carbon_raydium_amm_v4_decoder::RaydiumAmmV4Decoder;
use carbon_raydium_cpmm_decoder::RaydiumCpmmDecoder;
use carbon_raydium_clmm_decoder::RaydiumClmmDecoder;

Pipeline::builder()
    .datasource(datasource) // a datasource that emits these programs' transactions
    .instruction(RaydiumAmmV4Decoder, RaydiumAmmV4Processor)
    .instruction(RaydiumCpmmDecoder, RaydiumCpmmProcessor)
    .instruction(RaydiumClmmDecoder, RaydiumClmmProcessor)
    .build()?
    .run()
    .await

Each decoder only returns instructions whose program ID matches its own PROGRAM_ID, so one pipeline can hold all of them. For datasource filters that follow several programs, and one processor that sees every program's instructions in a transaction, see index multiple programs.

Guides#

A program that is not listed#

Generate a decoder from the program's Anchor or Codama IDL with the Carbon CLI: see generate a decoder. Every crate above was generated the same way. The full catalog lists decoders in every category.

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.