1. Decoders
  2. Other

Jupiter DCA decoder

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

On this page

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 for how decoders plug into a pipeline.

Cratecarbon-jupiter-dca-decoder 2.0.0
Installcargo add carbon-jupiter-dca-decoder@2.0.0
Program IDDCA265Vj8a9CEuX1eb1LWRnDT7uK6q1xMipnNyatn23M (carbon_jupiter_dca_decoder::PROGRAM_ID)
CategoryOther
Decodercarbon_jupiter_dca_decoder::JupiterDcaDecoder
Instruction enuminstructions::JupiterDcaInstruction
Account enumaccounts::JupiterDcaAccount
Event enuminstructions::CpiEvent
Featuresserde, postgres, graphql (none enabled by default)
API docsdocs.rs/carbon-jupiter-dca-decoder/2.0.0
Sourcedecoders/jupiter-dca-decoder

More program decoders without a category: Kamino Farms, Pump Fees, Raydium Liquidity Locking, Swig. To decode several in one pipeline, see other program 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 Jupiter DCA transactions from the public RPC and prints every decoded Deposit instruction. Add the dependencies:

Terminal
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
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(())
    }
}
Terminal
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 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. If CpiEvent never arrives, the program logs its events with emit! instead: decode them with decode_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:

Terminal
cargo add carbon-rpc-program-subscribe-datasource@2.0.0 solana-client@4.2.2
src/main.rs
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(())
    }
}
Terminal
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.

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 AccountMetas. 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:

#FieldType
0userPubkey
1dcaPubkey
2input_mintPubkey
3output_mintPubkey
4in_ataPubkey
5out_ataPubkey
6user_in_ataPubkey
7user_out_ataPubkey
8system_programPubkey
9token_programPubkey
10associated_token_programPubkey
11event_authorityPubkey
12programPubkey
13…remainingVec<AccountMeta>

Deposit#

Discriminator f223c68952e1f2b6 · data Deposit · accounts DepositInstructionAccounts.

FieldType
deposit_inu64

Required accounts: 7; extras go to remaining.

Fields of DepositInstructionAccounts, in account order:

#FieldType
0userPubkey
1dcaPubkey
2in_ataPubkey
3user_in_ataPubkey
4token_programPubkey
5event_authorityPubkey
6programPubkey
7…remainingVec<AccountMeta>

EndAndClose#

Discriminator 537da645f7fc6785 · data EndAndClose · accounts EndAndCloseInstructionAccounts.

No data fields.

Required accounts: 15; extras go to remaining.

Fields of EndAndCloseInstructionAccounts, in account order:

#FieldType
0keeperPubkey
1dcaPubkey
2input_mintPubkey
3output_mintPubkey
4in_ataPubkey
5out_ataPubkey
6userPubkey
7user_out_ataOption<Pubkey>
8init_user_out_ataOption<Pubkey>
9intermediate_accountOption<Pubkey>
10system_programPubkey
11token_programPubkey
12associated_token_programPubkey
13event_authorityPubkey
14programPubkey
15…remainingVec<AccountMeta>

FulfillDlmmFill#

Discriminator 01e676fb2db165bb · data FulfillDlmmFill · accounts FulfillDlmmFillInstructionAccounts.

FieldType
repay_amountu64

Required accounts: 15; extras go to remaining.

Fields of FulfillDlmmFillInstructionAccounts, in account order:

#FieldType
0keeperPubkey
1dcaPubkey
2input_mintPubkey
3output_mintPubkey
4keeper_in_ataPubkey
5in_ataPubkey
6out_ataPubkey
7fee_authorityPubkey
8fee_ataPubkey
9instructions_sysvarPubkey
10system_programPubkey
11token_programPubkey
12associated_token_programPubkey
13event_authorityPubkey
14programPubkey
15…remainingVec<AccountMeta>

FulfillFlashFill#

Discriminator 7340e24e21d369a2 · data FulfillFlashFill · accounts FulfillFlashFillInstructionAccounts.

FieldType
repay_amountu64

Required accounts: 15; extras go to remaining.

Fields of FulfillFlashFillInstructionAccounts, in account order:

#FieldType
0keeperPubkey
1dcaPubkey
2input_mintPubkey
3output_mintPubkey
4keeper_in_ataPubkey
5in_ataPubkey
6out_ataPubkey
7fee_authorityPubkey
8fee_ataPubkey
9instructions_sysvarPubkey
10system_programPubkey
11token_programPubkey
12associated_token_programPubkey
13event_authorityPubkey
14programPubkey
15…remainingVec<AccountMeta>

InitiateDlmmFill#

Discriminator 9bc150795b93febb · data InitiateDlmmFill · accounts InitiateDlmmFillInstructionAccounts.

No data fields.

Required accounts: 10; extras go to remaining.

Fields of InitiateDlmmFillInstructionAccounts, in account order:

#FieldType
0keeperPubkey
1dcaPubkey
2input_mintPubkey
3keeper_in_ataPubkey
4in_ataPubkey
5out_ataPubkey
6instructions_sysvarPubkey
7system_programPubkey
8token_programPubkey
9associated_token_programPubkey
10…remainingVec<AccountMeta>

InitiateFlashFill#

Discriminator 8fcd03bfa2d7f531 · data InitiateFlashFill · accounts InitiateFlashFillInstructionAccounts.

No data fields.

Required accounts: 10; extras go to remaining.

Fields of InitiateFlashFillInstructionAccounts, in account order:

#FieldType
0keeperPubkey
1dcaPubkey
2input_mintPubkey
3keeper_in_ataPubkey
4in_ataPubkey
5out_ataPubkey
6instructions_sysvarPubkey
7system_programPubkey
8token_programPubkey
9associated_token_programPubkey
10…remainingVec<AccountMeta>

OpenDca#

Discriminator 2441b93601d264a3 · data OpenDca · accounts OpenDcaInstructionAccounts.

FieldType
application_idxu64
in_amountu64
in_amount_per_cycleu64
cycle_frequencyi64
min_out_amountOption<u64>
max_out_amountOption<u64>
start_atOption<i64>
close_wsol_in_ataOption<bool>

Required accounts: 12; extras go to remaining.

Fields of OpenDcaInstructionAccounts, in account order:

#FieldType
0dcaPubkey
1userPubkey
2input_mintPubkey
3output_mintPubkey
4user_ataPubkey
5in_ataPubkey
6out_ataPubkey
7system_programPubkey
8token_programPubkey
9associated_token_programPubkey
10event_authorityPubkey
11programPubkey
12…remainingVec<AccountMeta>

OpenDcaV2#

Discriminator 8e772b6da2340bb1 · data OpenDcaV2 · accounts OpenDcaV2InstructionAccounts.

FieldType
application_idxu64
in_amountu64
in_amount_per_cycleu64
cycle_frequencyi64
min_out_amountOption<u64>
max_out_amountOption<u64>
start_atOption<i64>

Required accounts: 13; extras go to remaining.

Fields of OpenDcaV2InstructionAccounts, in account order:

#FieldType
0dcaPubkey
1userPubkey
2payerPubkey
3input_mintPubkey
4output_mintPubkey
5user_ataPubkey
6in_ataPubkey
7out_ataPubkey
8system_programPubkey
9token_programPubkey
10associated_token_programPubkey
11event_authorityPubkey
12programPubkey
13…remainingVec<AccountMeta>

Transfer#

Discriminator a334c8e78c0345ba · data Transfer · accounts TransferInstructionAccounts.

No data fields.

Required accounts: 12; extras go to remaining.

Fields of TransferInstructionAccounts, in account order:

#FieldType
0keeperPubkey
1dcaPubkey
2userPubkey
3output_mintPubkey
4dca_out_ataPubkey
5user_out_ataOption<Pubkey>
6intermediate_accountOption<Pubkey>
7system_programPubkey
8token_programPubkey
9associated_token_programPubkey
10event_authorityPubkey
11programPubkey
12…remainingVec<AccountMeta>

Withdraw#

Discriminator b712469c946da122 · data Withdraw · accounts WithdrawInstructionAccounts.

FieldType
withdraw_paramsWithdrawParams

Required accounts: 12; extras go to remaining.

Fields of WithdrawInstructionAccounts, in account order:

#FieldType
0userPubkey
1dcaPubkey
2input_mintPubkey
3output_mintPubkey
4dca_ataPubkey
5user_in_ataOption<Pubkey>
6user_out_ataOption<Pubkey>
7system_programPubkey
8token_programPubkey
9associated_token_programPubkey
10event_authorityPubkey
11programPubkey
12…remainingVec<AccountMeta>

WithdrawFees#

Discriminator c6d4ab6d90d7ae59 · data WithdrawFees · accounts WithdrawFeesInstructionAccounts.

FieldType
amountu64

Required accounts: 8; extras go to remaining.

Fields of WithdrawFeesInstructionAccounts, in account order:

#FieldType
0adminPubkey
1mintPubkey
2fee_authorityPubkey
3program_fee_ataPubkey
4admin_fee_ataPubkey
5system_programPubkey
6token_programPubkey
7associated_token_programPubkey
8…remainingVec<AccountMeta>

CpiEvent#

Anchor self-CPI that carries one of the program's 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:

#FieldType
0programPubkey
1event_authorityPubkey
2…remainingVec<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.

FieldType
userPubkey
input_mintPubkey
output_mintPubkey
idxu64
next_cycle_ati64
in_depositedu64
in_withdrawnu64
out_withdrawnu64
in_usedu64
out_receivedu64
in_amount_per_cycleu64
cycle_frequencyi64
next_cycle_amount_leftu64
in_accountPubkey
out_accountPubkey
min_out_amountu64
max_out_amountu64
keeper_in_balance_before_borrowu64
dca_out_balance_before_swapu64
created_ati64
bumpu8

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.

FieldType
user_keyPubkey
dca_keyPubkey
mintPubkey
amountu64

Filled#

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

FieldType
user_keyPubkey
dca_keyPubkey
input_mintPubkey
output_mintPubkey
in_amountu64
out_amountu64
fee_mintPubkey
feeu64

Opened#

Discriminator a6ac61094d4cbd6d · events::opened::OpenedEvent.

FieldType
user_keyPubkey
dca_keyPubkey
in_depositedu64
input_mintPubkey
output_mintPubkey
cycle_frequencyi64
in_amount_per_cycleu64
created_ati64

Closed#

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

FieldType
user_keyPubkey
dca_keyPubkey
in_depositedu64
input_mintPubkey
output_mintPubkey
cycle_frequencyi64
in_amount_per_cycleu64
created_ati64
total_in_withdrawnu64
total_out_withdrawnu64
unfilled_amountu64
user_closedbool

Withdraw#

Discriminator c0f1c9d946965af7 · events::withdraw::WithdrawEvent.

FieldType
dca_keyPubkey
in_amountu64
out_amountu64
user_withdrawbool

Deposit#

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

FieldType
dca_keyPubkey
amountu64

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 event.

CollectedFee#

Struct types::CollectedFee. Same fields as the CollectedFee event.

Deposit#

Struct types::Deposit. Same fields as the Deposit event.

Filled#

Struct types::Filled. Same fields as the Filled event.

Opened#

Struct types::Opened. Same fields as the Opened event.

Withdraw#

Struct types::Withdraw. Same fields as the Withdraw event.

Withdrawal#

Enum types::Withdrawal.

Variant
In
Out

WithdrawParams#

Struct types::WithdrawParams.

FieldType
withdraw_amountu64
withdrawalWithdrawal

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.