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.
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.
| Program | Crate | Program ID | Instructions | Accounts | Events |
|---|---|---|---|---|---|
| BonkSwap | carbon-bonkswap-decoder | BSwp6bEBihVLdqJRKGgzjcGLHkcTuzmSo1TQkHepzH8p | 19 | 5 | 0 |
| FluxBeam | carbon-fluxbeam-decoder | FLUXubRmkEi2q6K3Y9kBPg9248ggaZVsoSFhtJHSrm1X | 6 | 0 | 0 |
| Gavel | carbon-gavel-decoder | srAMMzfVHVAtgSJc8iH6CfKzuWuUTzLHVCE81QU1rgi | 10 | 2 | 0 |
| Heaven | carbon-heaven-decoder | HEAVENoP2qxoeuF8Dj2oT1GHEnu49U5mJYkdeC8BAX2o | 54 | 6 | 7 |
| Jupiter Limit Order | carbon-jupiter-limit-order-decoder | jupoNjAxXgZ4rjzxzPMP4oxduvQsQtZzyknqvzYNrNu | 9 | 2 | 3 |
| Jupiter Limit Order v2 | carbon-jupiter-limit-order-2-decoder | j1o2qRpjcyUwEvwtcfhEQefh773ZgjxcVRry7LDqg5X | 8 | 2 | 4 |
| Kamino Limit Order | carbon-kamino-limit-order-decoder | LiMoM9rMhrdYrfzUCxQppvxCSG1FcrUK9G8uLq4A1GF | 15 | 3 | 2 |
| Lifinity AMM v2 | carbon-lifinity-amm-v2-decoder | 2wT8Yq49kHgDzXuPxZSaeLaH1qbmGXtEyPy64bL7aD3c | 3 | 1 | 0 |
| Meteora DAMM v2 | carbon-meteora-damm-v2-decoder | cpamdpZCGKUy5JxQXB4dcpGPiikHawvSWAd6mEn1sGG | 38 | 9 | 23 |
| Meteora DLMM | carbon-meteora-dlmm-decoder | LBUZKhRxPF3XUpBCjp4YzTKgLccjZhTSDM9YuVaPwxo | 76 | 12 | 30 |
| Meteora Pools | carbon-meteora-pools-decoder | Eo7WjKq67rjJQSZxS6z3YkapzY3eMj6Xy8X5EQVn5UaB | 26 | 3 | 18 |
| OpenBook v2 | carbon-openbook-v2-decoder | opnb2LAfJYbRMAHHvqjCwQxanZn7ReEHp1k81EohpZb | 29 | 6 | 8 |
| Orca Whirlpools | carbon-orca-whirlpool-decoder | whirLbMiicVdio4qvUfM5KAg6Ct8VwpYzGff3uctyCc | 66 | 12 | 6 |
| PancakeSwap | carbon-pancake-swap-decoder | HpNfyc2Saw7RKkQd8nEL4khUcuPhQ7WwY1B2qjx8jxFq | 27 | 10 | 11 |
| Phoenix v1 | carbon-phoenix-v1-decoder | PhoeNiXZ8ByJGLkxNfZRnkUfjvmuYqLR89jjFHGqdXY | 28 | 0 | 0 |
| PumpSwap | carbon-pump-swap-decoder | pAMMBay6oceH9fJKBRHGP5D4bD4sWpmSwMn52FMfXEA | 25 | 7 | 22 |
| Raydium AMM v4 | carbon-raydium-amm-v4-decoder | 675kPX9MHTjS2zt1qfr1NYHuzeLXfQM9H24wFSUt1Mp8 | 18 | 3 | 0 |
| Raydium CLMM | carbon-raydium-clmm-decoder | CAMMCzo5YL8w4VFF8KVHrK22GGUsp5VTaW7grrKgrWqK | 34 | 12 | 15 |
| Raydium CPMM | carbon-raydium-cpmm-decoder | CPMMoo8L3F4NbTegBCKVNunggL7H1ZpdTHKxQB5qKP1C | 14 | 4 | 2 |
| Raydium Stable Swap | carbon-raydium-stable-swap-decoder | 5quBtoiQqxF9Jv6KYKctB59NT3gtJD2Y65kdnB1Uev3h | 6 | 0 | 0 |
| Stabble Stable Swap | carbon-stabble-stable-swap-decoder | swapNyd8XiQwJ6ianp9snpu4brUqFxadzvHebnAXjJZ | 19 | 3 | 2 |
| Stabble Weighted Swap | carbon-stabble-weighted-swap-decoder | swapFpHZwjELNnjvThjajtiVmkz3yPQEHjLtka2fwHW | 13 | 2 | 2 |
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:
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.0Register 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):
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()
.awaitEach 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.