# Jupiter DCA decoder (Carbon 2.0)

> Decode Jupiter DCA instructions, accounts and events in Rust with carbon-jupiter-dca-decoder 2.0.0. Program ID DCA265Vj8a9CEuX1eb1LWRnDT7uK6q1xMipnNyatn23M.

`carbon-jupiter-dca-decoder` decodes the instructions, accounts and events of the Jupiter DCA program (`DCA265Vj8a9CEuX1eb1LWRnDT7uK6q1xMipnNyatn23M`): 12 instructions, 1 account type, 6 events. It is generated with Codama from the program's IDL; see [decoders](https://carbon.sevenlabs.org/concepts/decoders.md) for how decoders plug into a pipeline.

|                  |                                                                                                                 |
| ---------------- | --------------------------------------------------------------------------------------------------------------- |
| Crate            | [`carbon-jupiter-dca-decoder`](https://crates.io/crates/carbon-jupiter-dca-decoder/2.0.0) 2.0.0                 |
| Install          | `cargo add carbon-jupiter-dca-decoder@2.0.0`                                                                    |
| Program ID       | `DCA265Vj8a9CEuX1eb1LWRnDT7uK6q1xMipnNyatn23M` (`carbon_jupiter_dca_decoder::PROGRAM_ID`)                       |
| Category         | [Other](https://carbon.sevenlabs.org/decoders/other.md)                                                         |
| Decoder          | `carbon_jupiter_dca_decoder::JupiterDcaDecoder`                                                                 |
| Instruction enum | `instructions::JupiterDcaInstruction`                                                                           |
| Account enum     | `accounts::JupiterDcaAccount`                                                                                   |
| Event enum       | `instructions::CpiEvent`                                                                                        |
| Features         | `serde`, `postgres`, `graphql` (none enabled by default)                                                        |
| API docs         | [docs.rs/carbon-jupiter-dca-decoder/2.0.0](https://docs.rs/carbon-jupiter-dca-decoder/2.0.0)                    |
| Source           | [decoders/jupiter-dca-decoder](https://github.com/sevenlabs-hq/carbon/tree/v2.0.0/decoders/jupiter-dca-decoder) |

More program decoders without a category: [Kamino Farms](https://carbon.sevenlabs.org/decoders/kamino-farms.md), [Pump Fees](https://carbon.sevenlabs.org/decoders/pump-fees.md), [Raydium Liquidity Locking](https://carbon.sevenlabs.org/decoders/raydium-liquidity-locking.md), [Swig](https://carbon.sevenlabs.org/decoders/swig.md). To decode several in one pipeline, see [other program decoders](https://carbon.sevenlabs.org/decoders/other.md).

The `serde` feature derives `Serialize`/`Deserialize` on every type, `postgres` adds tables and processors for [Postgres](https://carbon.sevenlabs.org/guides/postgres.md), and `graphql` adds a schema for the [GraphQL server](https://carbon.sevenlabs.org/guides/graphql.md).

## Usage

This program crawls recent Jupiter DCA transactions from the public RPC and prints every decoded `Deposit` instruction. Add the dependencies:

```sh
cargo add carbon-core@2.0.0 carbon-jupiter-dca-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`:

```rust
use {
    carbon_core::{
        error::CarbonResult, instruction::InstructionProcessorInputType, pipeline::Pipeline,
        processor::Processor,
    },
    carbon_log_metrics::LogMetrics,
    carbon_jupiter_dca_decoder::{
        instructions::JupiterDcaInstruction, JupiterDcaDecoder, 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(JupiterDcaDecoder, InstructionLogger)
        .build()?
        .run()
        .await
}

struct InstructionLogger;

impl Processor<InstructionProcessorInputType<'_, JupiterDcaInstruction>> for InstructionLogger {
    async fn process(
        &mut self,
        input: &InstructionProcessorInputType<'_, JupiterDcaInstruction>,
    ) -> CarbonResult<()> {
        let signature = input.metadata.transaction_metadata.signature;
        if let JupiterDcaInstruction::Deposit { data, accounts, .. } = input.decoded_instruction {
            println!("deposit {signature}: {data:?} user={}", accounts.user);
        }
        Ok(())
    }
}
```

```sh
RUST_LOG=info cargo run
```

Each `Deposit` instruction prints one line with the transaction signature and the decoded `Deposit` 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](https://carbon.sevenlabs.org/guides/stream-with-rpc.md) for the crawler options.

Events published with Anchor's `emit_cpi!` arrive as the `CpiEvent` instruction. Match them with `JupiterDcaInstruction::CpiEvent { data: CpiEvent::CollectedFee(event), .. }` (import `instructions::CpiEvent`); see [Events](#events). If `CpiEvent` never arrives, the program logs its events with `emit!` instead: decode them with [`decode_log_events`](https://carbon.sevenlabs.org/concepts/instructions.md#log-events).

### Decode accounts

The transaction crawler emits transactions only. To decode accounts, use a datasource that emits account updates. This program subscribes to the program's accounts with `programSubscribe` on the public WebSocket endpoint and prints every decoded `Dca` account as it changes. Add the datasource and the Solana RPC types it takes:

```sh
cargo add carbon-rpc-program-subscribe-datasource@2.0.0 solana-client@4.2.2
```

`src/main.rs`:

```rust
use {
    carbon_core::{
        account::AccountProcessorInputType, error::CarbonResult, pipeline::Pipeline,
        processor::Processor,
    },
    carbon_log_metrics::LogMetrics,
    carbon_jupiter_dca_decoder::{accounts::JupiterDcaAccount, JupiterDcaDecoder, PROGRAM_ID},
    carbon_rpc_program_subscribe_datasource::{Filters, RpcProgramSubscribe},
    solana_client::rpc_config::{RpcAccountInfoConfig, RpcProgramAccountsConfig, UiAccountEncoding},
    std::sync::Arc,
};

#[tokio::main]
async fn main() -> CarbonResult<()> {
    env_logger::init();

    // Streams every change to an account owned by the program (programSubscribe).
    let config = RpcProgramAccountsConfig {
        account_config: RpcAccountInfoConfig {
            encoding: Some(UiAccountEncoding::Base64),
            ..Default::default()
        },
        ..Default::default()
    };
    let datasource = RpcProgramSubscribe::new(
        "wss://api.mainnet-beta.solana.com".to_string(),
        Filters::new(PROGRAM_ID, Some(config)),
    );

    Pipeline::builder()
        .datasource(datasource)
        .metrics(Arc::new(LogMetrics::new()))
        .account(JupiterDcaDecoder, AccountLogger)
        .build()?
        .run()
        .await
}

struct AccountLogger;

impl Processor<AccountProcessorInputType<'_, JupiterDcaAccount>> for AccountLogger {
    async fn process(
        &mut self,
        input: &AccountProcessorInputType<'_, JupiterDcaAccount>,
    ) -> CarbonResult<()> {
        let JupiterDcaAccount::Dca(dca) = &input.decoded_account.data;
        println!("dca {}: {dca:?}", input.metadata.pubkey);
        Ok(())
    }
}
```

```sh
RUST_LOG=info cargo run
```

Each update to a `Dca` account prints its address and decoded fields; the program runs until you stop it. Cargo resolves `solana-client` to 4.2.2, the exact version the datasource pins, so both use the same `RpcProgramAccountsConfig` type. To load every existing account once instead of streaming changes, see [load account state](https://carbon.sevenlabs.org/guides/load-account-state.md).

## Instructions

Variants of `JupiterDcaInstruction`. Each is `JupiterDcaInstruction::<Variant> { program_id, data, accounts }`, where `data` and `accounts` are the types listed under the variant, exported from `carbon_jupiter_dca_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 `DCA265Vj8a9CEuX1eb1LWRnDT7uK6q1xMipnNyatn23M`.
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 `AccountMeta`s. 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.

### `CloseDca`

Discriminator `16072162a8b722f3` · data `CloseDca` · accounts `CloseDcaInstructionAccounts`.

No data fields.

Required accounts: 13; extras go to `remaining`.

Fields of `CloseDcaInstructionAccounts`, in account order:

| #   | Field                      | Type               |
| --- | -------------------------- | ------------------ |
| 0   | `user`                     | `Pubkey`           |
| 1   | `dca`                      | `Pubkey`           |
| 2   | `input_mint`               | `Pubkey`           |
| 3   | `output_mint`              | `Pubkey`           |
| 4   | `in_ata`                   | `Pubkey`           |
| 5   | `out_ata`                  | `Pubkey`           |
| 6   | `user_in_ata`              | `Pubkey`           |
| 7   | `user_out_ata`             | `Pubkey`           |
| 8   | `system_program`           | `Pubkey`           |
| 9   | `token_program`            | `Pubkey`           |
| 10  | `associated_token_program` | `Pubkey`           |
| 11  | `event_authority`          | `Pubkey`           |
| 12  | `program`                  | `Pubkey`           |
| 13… | `remaining`                | `Vec<AccountMeta>` |

### `Deposit`

Discriminator `f223c68952e1f2b6` · data `Deposit` · accounts `DepositInstructionAccounts`.

| Field        | Type  |
| ------------ | ----- |
| `deposit_in` | `u64` |

Required accounts: 7; extras go to `remaining`.

Fields of `DepositInstructionAccounts`, in account order:

| #  | Field             | Type               |
| -- | ----------------- | ------------------ |
| 0  | `user`            | `Pubkey`           |
| 1  | `dca`             | `Pubkey`           |
| 2  | `in_ata`          | `Pubkey`           |
| 3  | `user_in_ata`     | `Pubkey`           |
| 4  | `token_program`   | `Pubkey`           |
| 5  | `event_authority` | `Pubkey`           |
| 6  | `program`         | `Pubkey`           |
| 7… | `remaining`       | `Vec<AccountMeta>` |

### `EndAndClose`

Discriminator `537da645f7fc6785` · data `EndAndClose` · accounts `EndAndCloseInstructionAccounts`.

No data fields.

Required accounts: 15; extras go to `remaining`.

Fields of `EndAndCloseInstructionAccounts`, in account order:

| #   | Field                      | Type               |
| --- | -------------------------- | ------------------ |
| 0   | `keeper`                   | `Pubkey`           |
| 1   | `dca`                      | `Pubkey`           |
| 2   | `input_mint`               | `Pubkey`           |
| 3   | `output_mint`              | `Pubkey`           |
| 4   | `in_ata`                   | `Pubkey`           |
| 5   | `out_ata`                  | `Pubkey`           |
| 6   | `user`                     | `Pubkey`           |
| 7   | `user_out_ata`             | `Option<Pubkey>`   |
| 8   | `init_user_out_ata`        | `Option<Pubkey>`   |
| 9   | `intermediate_account`     | `Option<Pubkey>`   |
| 10  | `system_program`           | `Pubkey`           |
| 11  | `token_program`            | `Pubkey`           |
| 12  | `associated_token_program` | `Pubkey`           |
| 13  | `event_authority`          | `Pubkey`           |
| 14  | `program`                  | `Pubkey`           |
| 15… | `remaining`                | `Vec<AccountMeta>` |

### `FulfillDlmmFill`

Discriminator `01e676fb2db165bb` · data `FulfillDlmmFill` · accounts `FulfillDlmmFillInstructionAccounts`.

| Field          | Type  |
| -------------- | ----- |
| `repay_amount` | `u64` |

Required accounts: 15; extras go to `remaining`.

Fields of `FulfillDlmmFillInstructionAccounts`, in account order:

| #   | Field                      | Type               |
| --- | -------------------------- | ------------------ |
| 0   | `keeper`                   | `Pubkey`           |
| 1   | `dca`                      | `Pubkey`           |
| 2   | `input_mint`               | `Pubkey`           |
| 3   | `output_mint`              | `Pubkey`           |
| 4   | `keeper_in_ata`            | `Pubkey`           |
| 5   | `in_ata`                   | `Pubkey`           |
| 6   | `out_ata`                  | `Pubkey`           |
| 7   | `fee_authority`            | `Pubkey`           |
| 8   | `fee_ata`                  | `Pubkey`           |
| 9   | `instructions_sysvar`      | `Pubkey`           |
| 10  | `system_program`           | `Pubkey`           |
| 11  | `token_program`            | `Pubkey`           |
| 12  | `associated_token_program` | `Pubkey`           |
| 13  | `event_authority`          | `Pubkey`           |
| 14  | `program`                  | `Pubkey`           |
| 15… | `remaining`                | `Vec<AccountMeta>` |

### `FulfillFlashFill`

Discriminator `7340e24e21d369a2` · data `FulfillFlashFill` · accounts `FulfillFlashFillInstructionAccounts`.

| Field          | Type  |
| -------------- | ----- |
| `repay_amount` | `u64` |

Required accounts: 15; extras go to `remaining`.

Fields of `FulfillFlashFillInstructionAccounts`, in account order:

| #   | Field                      | Type               |
| --- | -------------------------- | ------------------ |
| 0   | `keeper`                   | `Pubkey`           |
| 1   | `dca`                      | `Pubkey`           |
| 2   | `input_mint`               | `Pubkey`           |
| 3   | `output_mint`              | `Pubkey`           |
| 4   | `keeper_in_ata`            | `Pubkey`           |
| 5   | `in_ata`                   | `Pubkey`           |
| 6   | `out_ata`                  | `Pubkey`           |
| 7   | `fee_authority`            | `Pubkey`           |
| 8   | `fee_ata`                  | `Pubkey`           |
| 9   | `instructions_sysvar`      | `Pubkey`           |
| 10  | `system_program`           | `Pubkey`           |
| 11  | `token_program`            | `Pubkey`           |
| 12  | `associated_token_program` | `Pubkey`           |
| 13  | `event_authority`          | `Pubkey`           |
| 14  | `program`                  | `Pubkey`           |
| 15… | `remaining`                | `Vec<AccountMeta>` |

### `InitiateDlmmFill`

Discriminator `9bc150795b93febb` · data `InitiateDlmmFill` · accounts `InitiateDlmmFillInstructionAccounts`.

No data fields.

Required accounts: 10; extras go to `remaining`.

Fields of `InitiateDlmmFillInstructionAccounts`, in account order:

| #   | Field                      | Type               |
| --- | -------------------------- | ------------------ |
| 0   | `keeper`                   | `Pubkey`           |
| 1   | `dca`                      | `Pubkey`           |
| 2   | `input_mint`               | `Pubkey`           |
| 3   | `keeper_in_ata`            | `Pubkey`           |
| 4   | `in_ata`                   | `Pubkey`           |
| 5   | `out_ata`                  | `Pubkey`           |
| 6   | `instructions_sysvar`      | `Pubkey`           |
| 7   | `system_program`           | `Pubkey`           |
| 8   | `token_program`            | `Pubkey`           |
| 9   | `associated_token_program` | `Pubkey`           |
| 10… | `remaining`                | `Vec<AccountMeta>` |

### `InitiateFlashFill`

Discriminator `8fcd03bfa2d7f531` · data `InitiateFlashFill` · accounts `InitiateFlashFillInstructionAccounts`.

No data fields.

Required accounts: 10; extras go to `remaining`.

Fields of `InitiateFlashFillInstructionAccounts`, in account order:

| #   | Field                      | Type               |
| --- | -------------------------- | ------------------ |
| 0   | `keeper`                   | `Pubkey`           |
| 1   | `dca`                      | `Pubkey`           |
| 2   | `input_mint`               | `Pubkey`           |
| 3   | `keeper_in_ata`            | `Pubkey`           |
| 4   | `in_ata`                   | `Pubkey`           |
| 5   | `out_ata`                  | `Pubkey`           |
| 6   | `instructions_sysvar`      | `Pubkey`           |
| 7   | `system_program`           | `Pubkey`           |
| 8   | `token_program`            | `Pubkey`           |
| 9   | `associated_token_program` | `Pubkey`           |
| 10… | `remaining`                | `Vec<AccountMeta>` |

### `OpenDca`

Discriminator `2441b93601d264a3` · data `OpenDca` · accounts `OpenDcaInstructionAccounts`.

| Field                 | Type           |
| --------------------- | -------------- |
| `application_idx`     | `u64`          |
| `in_amount`           | `u64`          |
| `in_amount_per_cycle` | `u64`          |
| `cycle_frequency`     | `i64`          |
| `min_out_amount`      | `Option<u64>`  |
| `max_out_amount`      | `Option<u64>`  |
| `start_at`            | `Option<i64>`  |
| `close_wsol_in_ata`   | `Option<bool>` |

Required accounts: 12; extras go to `remaining`.

Fields of `OpenDcaInstructionAccounts`, in account order:

| #   | Field                      | Type               |
| --- | -------------------------- | ------------------ |
| 0   | `dca`                      | `Pubkey`           |
| 1   | `user`                     | `Pubkey`           |
| 2   | `input_mint`               | `Pubkey`           |
| 3   | `output_mint`              | `Pubkey`           |
| 4   | `user_ata`                 | `Pubkey`           |
| 5   | `in_ata`                   | `Pubkey`           |
| 6   | `out_ata`                  | `Pubkey`           |
| 7   | `system_program`           | `Pubkey`           |
| 8   | `token_program`            | `Pubkey`           |
| 9   | `associated_token_program` | `Pubkey`           |
| 10  | `event_authority`          | `Pubkey`           |
| 11  | `program`                  | `Pubkey`           |
| 12… | `remaining`                | `Vec<AccountMeta>` |

### `OpenDcaV2`

Discriminator `8e772b6da2340bb1` · data `OpenDcaV2` · accounts `OpenDcaV2InstructionAccounts`.

| Field                 | Type          |
| --------------------- | ------------- |
| `application_idx`     | `u64`         |
| `in_amount`           | `u64`         |
| `in_amount_per_cycle` | `u64`         |
| `cycle_frequency`     | `i64`         |
| `min_out_amount`      | `Option<u64>` |
| `max_out_amount`      | `Option<u64>` |
| `start_at`            | `Option<i64>` |

Required accounts: 13; extras go to `remaining`.

Fields of `OpenDcaV2InstructionAccounts`, in account order:

| #   | Field                      | Type               |
| --- | -------------------------- | ------------------ |
| 0   | `dca`                      | `Pubkey`           |
| 1   | `user`                     | `Pubkey`           |
| 2   | `payer`                    | `Pubkey`           |
| 3   | `input_mint`               | `Pubkey`           |
| 4   | `output_mint`              | `Pubkey`           |
| 5   | `user_ata`                 | `Pubkey`           |
| 6   | `in_ata`                   | `Pubkey`           |
| 7   | `out_ata`                  | `Pubkey`           |
| 8   | `system_program`           | `Pubkey`           |
| 9   | `token_program`            | `Pubkey`           |
| 10  | `associated_token_program` | `Pubkey`           |
| 11  | `event_authority`          | `Pubkey`           |
| 12  | `program`                  | `Pubkey`           |
| 13… | `remaining`                | `Vec<AccountMeta>` |

### `Transfer`

Discriminator `a334c8e78c0345ba` · data `Transfer` · accounts `TransferInstructionAccounts`.

No data fields.

Required accounts: 12; extras go to `remaining`.

Fields of `TransferInstructionAccounts`, in account order:

| #   | Field                      | Type               |
| --- | -------------------------- | ------------------ |
| 0   | `keeper`                   | `Pubkey`           |
| 1   | `dca`                      | `Pubkey`           |
| 2   | `user`                     | `Pubkey`           |
| 3   | `output_mint`              | `Pubkey`           |
| 4   | `dca_out_ata`              | `Pubkey`           |
| 5   | `user_out_ata`             | `Option<Pubkey>`   |
| 6   | `intermediate_account`     | `Option<Pubkey>`   |
| 7   | `system_program`           | `Pubkey`           |
| 8   | `token_program`            | `Pubkey`           |
| 9   | `associated_token_program` | `Pubkey`           |
| 10  | `event_authority`          | `Pubkey`           |
| 11  | `program`                  | `Pubkey`           |
| 12… | `remaining`                | `Vec<AccountMeta>` |

### `Withdraw`

Discriminator `b712469c946da122` · data `Withdraw` · accounts `WithdrawInstructionAccounts`.

| Field             | Type                                |
| ----------------- | ----------------------------------- |
| `withdraw_params` | [`WithdrawParams`](#withdrawparams) |

Required accounts: 12; extras go to `remaining`.

Fields of `WithdrawInstructionAccounts`, in account order:

| #   | Field                      | Type               |
| --- | -------------------------- | ------------------ |
| 0   | `user`                     | `Pubkey`           |
| 1   | `dca`                      | `Pubkey`           |
| 2   | `input_mint`               | `Pubkey`           |
| 3   | `output_mint`              | `Pubkey`           |
| 4   | `dca_ata`                  | `Pubkey`           |
| 5   | `user_in_ata`              | `Option<Pubkey>`   |
| 6   | `user_out_ata`             | `Option<Pubkey>`   |
| 7   | `system_program`           | `Pubkey`           |
| 8   | `token_program`            | `Pubkey`           |
| 9   | `associated_token_program` | `Pubkey`           |
| 10  | `event_authority`          | `Pubkey`           |
| 11  | `program`                  | `Pubkey`           |
| 12… | `remaining`                | `Vec<AccountMeta>` |

### `WithdrawFees`

Discriminator `c6d4ab6d90d7ae59` · data `WithdrawFees` · accounts `WithdrawFeesInstructionAccounts`.

| Field    | Type  |
| -------- | ----- |
| `amount` | `u64` |

Required accounts: 8; extras go to `remaining`.

Fields of `WithdrawFeesInstructionAccounts`, in account order:

| #  | Field                      | Type               |
| -- | -------------------------- | ------------------ |
| 0  | `admin`                    | `Pubkey`           |
| 1  | `mint`                     | `Pubkey`           |
| 2  | `fee_authority`            | `Pubkey`           |
| 3  | `program_fee_ata`          | `Pubkey`           |
| 4  | `admin_fee_ata`            | `Pubkey`           |
| 5  | `system_program`           | `Pubkey`           |
| 6  | `token_program`            | `Pubkey`           |
| 7  | `associated_token_program` | `Pubkey`           |
| 8… | `remaining`                | `Vec<AccountMeta>` |

### `CpiEvent`

Anchor self-CPI that carries one of the program's [events](#events). `data` is the `CpiEvent` enum.

Discriminator `e445a52e51cb9a1d` · data `CpiEvent` · accounts `CpiEventInstructionAccounts`.

Required accounts: 2; extras go to `remaining`.

Fields of `CpiEventInstructionAccounts`, in account order:

| #  | Field             | Type               |
| -- | ----------------- | ------------------ |
| 0  | `program`         | `Pubkey`           |
| 1  | `event_authority` | `Pubkey`           |
| 2… | `remaining`       | `Vec<AccountMeta>` |

## Accounts

Variants of `JupiterDcaAccount`. Each wraps a boxed struct from `carbon_jupiter_dca_decoder::accounts::<module>`. `decode_account` only considers accounts owned by `PROGRAM_ID` and returns the first variant that matches.

### `Dca`

Discriminator `525d5a7f2865919a` · `accounts::dca::Dca`.

| Field                             | Type     |
| --------------------------------- | -------- |
| `user`                            | `Pubkey` |
| `input_mint`                      | `Pubkey` |
| `output_mint`                     | `Pubkey` |
| `idx`                             | `u64`    |
| `next_cycle_at`                   | `i64`    |
| `in_deposited`                    | `u64`    |
| `in_withdrawn`                    | `u64`    |
| `out_withdrawn`                   | `u64`    |
| `in_used`                         | `u64`    |
| `out_received`                    | `u64`    |
| `in_amount_per_cycle`             | `u64`    |
| `cycle_frequency`                 | `i64`    |
| `next_cycle_amount_left`          | `u64`    |
| `in_account`                      | `Pubkey` |
| `out_account`                     | `Pubkey` |
| `min_out_amount`                  | `u64`    |
| `max_out_amount`                  | `u64`    |
| `keeper_in_balance_before_borrow` | `u64`    |
| `dca_out_balance_before_swap`     | `u64`    |
| `created_at`                      | `i64`    |
| `bump`                            | `u8`     |

## Events

Variants of `instructions::CpiEvent`, decoded from the `CpiEvent` instruction. Each wraps a struct from `carbon_jupiter_dca_decoder::events::<module>`. The discriminator is the 8-byte event discriminator that follows the `e445a52e51cb9a1d` CPI-event tag.

### `CollectedFee`

Discriminator `2a88d874b5d16db5` · `events::collected_fee::CollectedFeeEvent`.

| Field      | Type     |
| ---------- | -------- |
| `user_key` | `Pubkey` |
| `dca_key`  | `Pubkey` |
| `mint`     | `Pubkey` |
| `amount`   | `u64`    |

### `Filled`

Discriminator `8604113fdd2db1ad` · `events::filled::FilledEvent`.

| Field         | Type     |
| ------------- | -------- |
| `user_key`    | `Pubkey` |
| `dca_key`     | `Pubkey` |
| `input_mint`  | `Pubkey` |
| `output_mint` | `Pubkey` |
| `in_amount`   | `u64`    |
| `out_amount`  | `u64`    |
| `fee_mint`    | `Pubkey` |
| `fee`         | `u64`    |

### `Opened`

Discriminator `a6ac61094d4cbd6d` · `events::opened::OpenedEvent`.

| Field                 | Type     |
| --------------------- | -------- |
| `user_key`            | `Pubkey` |
| `dca_key`             | `Pubkey` |
| `in_deposited`        | `u64`    |
| `input_mint`          | `Pubkey` |
| `output_mint`         | `Pubkey` |
| `cycle_frequency`     | `i64`    |
| `in_amount_per_cycle` | `u64`    |
| `created_at`          | `i64`    |

### `Closed`

Discriminator `321f579b87dcc3ef` · `events::closed::ClosedEvent`.

| Field                 | Type     |
| --------------------- | -------- |
| `user_key`            | `Pubkey` |
| `dca_key`             | `Pubkey` |
| `in_deposited`        | `u64`    |
| `input_mint`          | `Pubkey` |
| `output_mint`         | `Pubkey` |
| `cycle_frequency`     | `i64`    |
| `in_amount_per_cycle` | `u64`    |
| `created_at`          | `i64`    |
| `total_in_withdrawn`  | `u64`    |
| `total_out_withdrawn` | `u64`    |
| `unfilled_amount`     | `u64`    |
| `user_closed`         | `bool`   |

### `Withdraw`

Discriminator `c0f1c9d946965af7` · `events::withdraw::WithdrawEvent`.

| Field           | Type     |
| --------------- | -------- |
| `dca_key`       | `Pubkey` |
| `in_amount`     | `u64`    |
| `out_amount`    | `u64`    |
| `user_withdraw` | `bool`   |

### `Deposit`

Discriminator `3ecdf2aff4a98834` · `events::deposit::DepositEvent`.

| Field     | Type     |
| --------- | -------- |
| `dca_key` | `Pubkey` |
| `amount`  | `u64`    |

## Types

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

### `Closed`

Struct `types::Closed`. Same fields as the [`Closed`](#closed) event.

### `CollectedFee`

Struct `types::CollectedFee`. Same fields as the [`CollectedFee`](#collectedfee) event.

### `Deposit`

Struct `types::Deposit`. Same fields as the [`Deposit`](#deposit-1) event.

### `Filled`

Struct `types::Filled`. Same fields as the [`Filled`](#filled) event.

### `Opened`

Struct `types::Opened`. Same fields as the [`Opened`](#opened) event.

### `Withdraw`

Struct `types::Withdraw`. Same fields as the [`Withdraw`](#withdraw-1) event.

### `Withdrawal`

Enum `types::Withdrawal`.

| Variant |
| ------- |
| `In`    |
| `Out`   |

### `WithdrawParams`

Struct `types::WithdrawParams`.

| Field             | Type                        |
| ----------------- | --------------------------- |
| `withdraw_amount` | `u64`                       |
| `withdrawal`      | [`Withdrawal`](#withdrawal) |

---

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