# Perpetuals and derivatives decoders (Carbon 2.0)

> Decode 3 Solana perpetuals and derivatives programs in Rust, including Drift v2, Jupiter Perpetuals and Zeta Markets, with Carbon decoder crates.

Carbon 2.0.0 has decoder crates for 3 perpetuals and derivatives programs on Solana: 415 instructions, 58 account types and 59 events in all. Use them to index orders, fills, positions, funding and liquidations 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 |
| --------------------------------------------------------------------------------- | ----------------------------------- | --------------------------------------------- | -----------: | -------: | -----: |
| [Drift v2](https://carbon.sevenlabs.org/decoders/drift-v2.md)                     | `carbon-drift-v2-decoder`           | `dRiftyHA39MWEi3m9aunc5MzRF1JYuBsbn6VPcn33UH` |          249 |       27 |     26 |
| [Jupiter Perpetuals](https://carbon.sevenlabs.org/decoders/jupiter-perpetuals.md) | `carbon-jupiter-perpetuals-decoder` | `PERPHjGBqRHArX4DySjwM6UJHiR3sWAatqfdBS2qQJu` |           59 |        8 |     25 |
| [Zeta Markets](https://carbon.sevenlabs.org/decoders/zeta.md)                     | `carbon-zeta-decoder`               | `ZETAxsqBRek56DhiGXrn75yj2NHU3aYUnxvHXpkf3aD` |          107 |       23 |      8 |

## 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:

```sh
cargo add carbon-core@2.0.0 carbon-drift-v2-decoder@2.0.0 carbon-jupiter-perpetuals-decoder@2.0.0 carbon-zeta-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](https://carbon.sevenlabs.org/concepts/processors.md)):

```rust
use carbon_drift_v2_decoder::DriftV2Decoder;
use carbon_jupiter_perpetuals_decoder::JupiterPerpetualsDecoder;
use carbon_zeta_decoder::ZetaDecoder;

Pipeline::builder()
    .datasource(datasource) // a datasource that emits these programs' transactions
    .instruction(DriftV2Decoder, DriftV2Processor)
    .instruction(JupiterPerpetualsDecoder, JupiterPerpetualsProcessor)
    .instruction(ZetaDecoder, ZetaProcessor)
    .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](https://carbon.sevenlabs.org/guides/multiple-programs.md).

## 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](https://carbon.sevenlabs.org/guides/generate-a-decoder.md). Every crate above was generated the same way. The [full catalog](https://carbon.sevenlabs.org/decoders.md) lists decoders in every category.

---

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