Jupiter Limit Order v2 decoder

Decode Jupiter Limit Order v2 instructions, accounts and events in Rust with the carbon-jupiter-limit-order-2-decoder crate.

On this page

carbon-jupiter-limit-order-2-decoder decodes the instructions, accounts and events of the Jupiter Limit Order v2 program (j1o2qRpjcyUwEvwtcfhEQefh773ZgjxcVRry7LDqg5X): 8 instructions, 2 account types, 4 events. It is generated with Codama from the program's IDL; see decoders for how decoders plug into a pipeline.

Cratecarbon-jupiter-limit-order-2-decoder 2.0.0
Installcargo add carbon-jupiter-limit-order-2-decoder@2.0.0
Program IDj1o2qRpjcyUwEvwtcfhEQefh773ZgjxcVRry7LDqg5X (carbon_jupiter_limit_order_2_decoder::PROGRAM_ID)
CategoryDEX & AMM
Decodercarbon_jupiter_limit_order_2_decoder::JupiterLimitOrder2Decoder
Instruction enuminstructions::JupiterLimitOrder2Instruction
Account enumaccounts::JupiterLimitOrder2Account
Event enuminstructions::CpiEvent
Featuresserde, postgres, graphql (none enabled by default)
API docsdocs.rs/carbon-jupiter-limit-order-2-decoder/2.0.0
Sourcedecoders/jupiter-limit-order-2-decoder

Other DEX and AMM decoders: BonkSwap, FluxBeam, Gavel, Heaven, Jupiter Limit Order, Kamino Limit Order, Lifinity AMM v2, Meteora DAMM v2, Meteora DLMM, Meteora Pools, OpenBook v2, Orca Whirlpools, PancakeSwap, Phoenix v1, PumpSwap, Raydium AMM v4, Raydium CLMM, Raydium CPMM, Raydium Stable Swap, Stabble Stable Swap, Stabble Weighted Swap. To decode several in one pipeline, see dEX and AMM 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 Limit Order v2 transactions from the public RPC and prints every decoded CancelDustOrder instruction. Add the dependencies:

Terminal
cargo add carbon-core@2.0.0 carbon-jupiter-limit-order-2-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_limit_order_2_decoder::{
        instructions::JupiterLimitOrder2Instruction, JupiterLimitOrder2Decoder, 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(JupiterLimitOrder2Decoder, InstructionLogger)
        .build()?
        .run()
        .await
}

struct InstructionLogger;

impl Processor<InstructionProcessorInputType<'_, JupiterLimitOrder2Instruction>> for InstructionLogger {
    async fn process(
        &mut self,
        input: &InstructionProcessorInputType<'_, JupiterLimitOrder2Instruction>,
    ) -> CarbonResult<()> {
        let signature = input.metadata.transaction_metadata.signature;
        if let JupiterLimitOrder2Instruction::CancelDustOrder { data, accounts, .. } = input.decoded_instruction {
            println!("cancel_dust_order {signature}: {data:?} signer={}", accounts.signer);
        }
        Ok(())
    }
}
Terminal
RUST_LOG=info cargo run

Each CancelDustOrder instruction prints one line with the transaction signature and the decoded CancelDustOrder 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 JupiterLimitOrder2Instruction::CpiEvent { data: CpiEvent::CancelDustOrderEvent(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 Fee 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_limit_order_2_decoder::{
        accounts::JupiterLimitOrder2Account, JupiterLimitOrder2Decoder, 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(JupiterLimitOrder2Decoder, AccountLogger)
        .build()?
        .run()
        .await
}

struct AccountLogger;

impl Processor<AccountProcessorInputType<'_, JupiterLimitOrder2Account>> for AccountLogger {
    async fn process(
        &mut self,
        input: &AccountProcessorInputType<'_, JupiterLimitOrder2Account>,
    ) -> CarbonResult<()> {
        if let JupiterLimitOrder2Account::Fee(fee) = &input.decoded_account.data {
            println!("fee {}: {fee:?}", input.metadata.pubkey);
        }
        Ok(())
    }
}
Terminal
RUST_LOG=info cargo run

Each update to a Fee 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 JupiterLimitOrder2Instruction. Each is JupiterLimitOrder2Instruction::<Variant> { program_id, data, accounts }, where data and accounts are the types listed under the variant, exported from carbon_jupiter_limit_order_2_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 j1o2qRpjcyUwEvwtcfhEQefh773ZgjxcVRry7LDqg5X.
  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.

CancelDustOrder#

Discriminator c570bda44f3017f6 · data CancelDustOrder · accounts CancelDustOrderInstructionAccounts.

FieldType
paramsCancelDustOrderParams

Required accounts: 11; extras go to remaining.

Fields of CancelDustOrderInstructionAccounts, in account order:

#FieldType
0signerPubkey
1makerPubkey
2orderPubkey
3input_mint_reservePubkey
4maker_input_mint_accountPubkey
5input_mintPubkey
6input_token_programPubkey
7system_programPubkey
8associated_token_programPubkey
9event_authorityPubkey
10programPubkey
11…remainingVec<AccountMeta>

CancelOrder#

Discriminator 5f81edf00831df84 · data CancelOrder · accounts CancelOrderInstructionAccounts.

No data fields.

Required accounts: 9; extras go to remaining.

Fields of CancelOrderInstructionAccounts, in account order:

#FieldType
0signerPubkey
1makerPubkey
2orderPubkey
3input_mint_reservePubkey
4maker_input_mint_accountOption<Pubkey>
5input_mintPubkey
6input_token_programPubkey
7event_authorityPubkey
8programPubkey
9…remainingVec<AccountMeta>

FillOrder#

Discriminator e87a7319c78f88a2 · data FillOrder · accounts FillOrderInstructionAccounts.

FieldType
paramsFillOrderParams

Required accounts: 16; extras go to remaining.

Fields of FillOrderInstructionAccounts, in account order:

#FieldType
0takerPubkey
1makerPubkey
2orderPubkey
3taker_input_mint_accountPubkey
4taker_output_mint_accountPubkey
5maker_output_mint_accountOption<Pubkey>
6fee_accountPubkey
7order_input_mint_accountPubkey
8input_mintPubkey
9input_token_programPubkey
10output_mintPubkey
11output_token_programPubkey
12jupiter_programPubkey
13system_programPubkey
14event_authorityPubkey
15programPubkey
16…remainingVec<AccountMeta>

FlashFillOrder#

Discriminator fc681286a44e128c · data FlashFillOrder · accounts FlashFillOrderInstructionAccounts.

FieldType
paramsFlashFillOrderParams

Required accounts: 13; extras go to remaining.

Fields of FlashFillOrderInstructionAccounts, in account order:

#FieldType
0takerPubkey
1makerPubkey
2orderPubkey
3input_mint_reservePubkey
4maker_output_mint_accountOption<Pubkey>
5taker_output_mint_accountOption<Pubkey>
6fee_accountPubkey
7input_token_programPubkey
8output_mintPubkey
9output_token_programPubkey
10system_programPubkey
11event_authorityPubkey
12programPubkey
13…remainingVec<AccountMeta>

InitializeOrder#

Discriminator 856e4aaf709ff59f · data InitializeOrder · accounts InitializeOrderInstructionAccounts.

FieldType
paramsInitializeOrderParams

Required accounts: 15; extras go to remaining.

Fields of InitializeOrderInstructionAccounts, in account order:

#FieldType
0payerPubkey
1makerPubkey
2orderPubkey
3input_mint_reservePubkey
4maker_input_mint_accountPubkey
5feePubkey
6referralOption<Pubkey>
7input_mintPubkey
8output_mintPubkey
9input_token_programPubkey
10output_token_programPubkey
11system_programPubkey
12associated_token_programPubkey
13event_authorityPubkey
14programPubkey
15…remainingVec<AccountMeta>

PreFlashFillOrder#

Discriminator f02f99440dbee12a · data PreFlashFillOrder · accounts PreFlashFillOrderInstructionAccounts.

Required accounts: 7; extras go to remaining.

Fields of PreFlashFillOrderInstructionAccounts, in account order:

#FieldType
0takerPubkey
1orderPubkey
2input_mint_reservePubkey
3taker_input_mint_accountPubkey
4input_mintPubkey
5input_token_programPubkey
6instructionPubkey
7…remainingVec<AccountMeta>

UpdateFee#

Discriminator e8fdc3f794d449de · data UpdateFee · accounts UpdateFeeInstructionAccounts.

FieldType
paramsUpdateFeeParams

Required accounts: 3; extras go to remaining.

Fields of UpdateFeeInstructionAccounts, in account order:

#FieldType
0adminPubkey
1fee_authorityPubkey
2system_programPubkey
3…remainingVec<AccountMeta>

WithdrawFee#

Discriminator 0e7ae7da1feedf96 · data WithdrawFee · accounts WithdrawFeeInstructionAccounts.

No data fields.

Required accounts: 6; extras go to remaining.

Fields of WithdrawFeeInstructionAccounts, in account order:

#FieldType
0adminPubkey
1fee_authorityPubkey
2program_fee_accountPubkey
3destination_token_accountPubkey
4token_programPubkey
5mintPubkey
6…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 JupiterLimitOrder2Account. Each wraps a boxed struct from carbon_jupiter_limit_order_2_decoder::accounts::<module>. decode_account only considers accounts owned by PROGRAM_ID and returns the first variant that matches.

Fee#

Discriminator 183796faa81b65b2 · accounts::fee::Fee.

FieldType
normal_fee_bpsu16
stable_fee_bpsu16

Order#

Discriminator 86addfb94d561c33 · accounts::order::Order.

FieldType
makerPubkey
input_mintPubkey
output_mintPubkey
input_token_programPubkey
output_token_programPubkey
input_mint_reservePubkey
unique_idu64
ori_making_amountu64
ori_taking_amountu64
making_amountu64
taking_amountu64
borrow_making_amountu64
expired_atOption<i64>
fee_bpsu16
fee_accountPubkey
created_ati64
updated_ati64
bumpu8
slippage_bpsu16

Events#

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

CancelDustOrderEvent#

Discriminator 7cbe4a1cb128c8dc · events::cancel_dust_order_event::CancelDustOrderEventEvent.

FieldType
order_keyPubkey
one_usd_input_mint_amountu64

CancelOrderEvent#

Discriminator ae428d1104e0a24d · events::cancel_order_event::CancelOrderEventEvent.

FieldType
order_keyPubkey

CreateOrderEvent#

Discriminator 318e48a6e61d5454 · events::create_order_event::CreateOrderEventEvent.

FieldType
order_keyPubkey
makerPubkey
input_mintPubkey
output_mintPubkey
input_token_programPubkey
output_token_programPubkey
making_amountu64
taking_amountu64
expired_atOption<i64>
fee_bpsu16
fee_accountPubkey
slippage_bpsu16

TradeEvent#

Discriminator bddb7fd34ee661ee · events::trade_event::TradeEventEvent.

FieldType
order_keyPubkey
takerPubkey
remaining_making_amountu64
remaining_taking_amountu64
making_amountu64
taking_amountu64

Types#

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

CancelDustOrderEvent#

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

CancelDustOrderParams#

Struct types::CancelDustOrderParams.

FieldType
one_usd_input_mint_amountu64

CancelOrderEvent#

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

CreateOrderEvent#

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

FillOrderParams#

Struct types::FillOrderParams.

FieldType
input_amountu64
swap_dataVec<u8>

FlashFillOrderParams#

Struct types::FlashFillOrderParams.

FieldType
max_taking_amountu64

InitializeOrderParams#

Struct types::InitializeOrderParams.

FieldType
unique_idu64
making_amountu64
taking_amountu64
expired_atOption<i64>
fee_bpsOption<u16>
slippage_bpsOption<u16>

PreFlashFillOrderParams#

Struct types::PreFlashFillOrderParams.

FieldType
making_amountu64

TradeEvent#

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

UpdateFeeParams#

Struct types::UpdateFeeParams.

FieldType
normal_fee_bpsu16
stable_fee_bpsu16

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.