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.
| Crate | carbon-jupiter-limit-order-2-decoder 2.0.0 |
| Install | cargo add carbon-jupiter-limit-order-2-decoder@2. |
| Program ID | j1o2qRpjcyUwEvwtcfhEQefh773ZgjxcVRry7LDqg5X (carbon_) |
| Category | DEX & AMM |
| Decoder | carbon_ |
| Instruction enum | instructions:: |
| Account enum | accounts:: |
| Event enum | instructions:: |
| Features | serde, postgres, graphql (none enabled by default) |
| API docs | docs.rs/carbon-jupiter-limit-order-2-decoder/2.0.0 |
| Source | decoders/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:
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/fulluse {
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(())
}
}RUST_LOG=info cargo runEach 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:: (import instructions::); see Events. If CpiEvent never arrives, the program logs its events with emit! instead: decode them with decode_.
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:
cargo add carbon-rpc-program-subscribe-datasource@2.0.0 solana-client@4.2.2use {
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(())
}
}RUST_LOG=info cargo runEach 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::, where data and accounts are the types listed under the variant, exported from carbon_. 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:
- The instruction's program ID is
j1o2qRpjcyUwEvwtcfhEQefh773ZgjxcVRry7LDqg5X. - The data starts with the variant's discriminator, and the rest deserializes into its data type.
- 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_ too. Accounts after the listed ones are in accounts. as AccountMetas. The decoder doesn't record whether an account signed or was writable: read that from input. and ., 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.
| Field | Type |
|---|---|
params | CancelDustOrderParams |
Required accounts: 11; extras go to remaining.
Fields of CancelDustOrderInstructionAccounts, in account order:
| # | Field | Type |
|---|---|---|
| 0 | signer | Pubkey |
| 1 | maker | Pubkey |
| 2 | order | Pubkey |
| 3 | input_ | Pubkey |
| 4 | maker_ | Pubkey |
| 5 | input_mint | Pubkey |
| 6 | input_ | Pubkey |
| 7 | system_ | Pubkey |
| 8 | associated_ | Pubkey |
| 9 | event_ | Pubkey |
| 10 | program | Pubkey |
| 11… | remaining | Vec< |
CancelOrder#
Discriminator 5f81edf00831df84 · data CancelOrder · accounts CancelOrderInstructionAccounts.
No data fields.
Required accounts: 9; extras go to remaining.
Fields of CancelOrderInstructionAccounts, in account order:
| # | Field | Type |
|---|---|---|
| 0 | signer | Pubkey |
| 1 | maker | Pubkey |
| 2 | order | Pubkey |
| 3 | input_ | Pubkey |
| 4 | maker_ | Option< |
| 5 | input_mint | Pubkey |
| 6 | input_ | Pubkey |
| 7 | event_ | Pubkey |
| 8 | program | Pubkey |
| 9… | remaining | Vec< |
FillOrder#
Discriminator e87a7319c78f88a2 · data FillOrder · accounts FillOrderInstructionAccounts.
| Field | Type |
|---|---|
params | FillOrderParams |
Required accounts: 16; extras go to remaining.
Fields of FillOrderInstructionAccounts, in account order:
| # | Field | Type |
|---|---|---|
| 0 | taker | Pubkey |
| 1 | maker | Pubkey |
| 2 | order | Pubkey |
| 3 | taker_ | Pubkey |
| 4 | taker_ | Pubkey |
| 5 | maker_ | Option< |
| 6 | fee_account | Pubkey |
| 7 | order_ | Pubkey |
| 8 | input_mint | Pubkey |
| 9 | input_ | Pubkey |
| 10 | output_mint | Pubkey |
| 11 | output_ | Pubkey |
| 12 | jupiter_ | Pubkey |
| 13 | system_ | Pubkey |
| 14 | event_ | Pubkey |
| 15 | program | Pubkey |
| 16… | remaining | Vec< |
FlashFillOrder#
Discriminator fc681286a44e128c · data FlashFillOrder · accounts FlashFillOrderInstructionAccounts.
| Field | Type |
|---|---|
params | FlashFillOrderParams |
Required accounts: 13; extras go to remaining.
Fields of FlashFillOrderInstructionAccounts, in account order:
| # | Field | Type |
|---|---|---|
| 0 | taker | Pubkey |
| 1 | maker | Pubkey |
| 2 | order | Pubkey |
| 3 | input_ | Pubkey |
| 4 | maker_ | Option< |
| 5 | taker_ | Option< |
| 6 | fee_account | Pubkey |
| 7 | input_ | Pubkey |
| 8 | output_mint | Pubkey |
| 9 | output_ | Pubkey |
| 10 | system_ | Pubkey |
| 11 | event_ | Pubkey |
| 12 | program | Pubkey |
| 13… | remaining | Vec< |
InitializeOrder#
Discriminator 856e4aaf709ff59f · data InitializeOrder · accounts InitializeOrderInstructionAccounts.
| Field | Type |
|---|---|
params | InitializeOrderParams |
Required accounts: 15; extras go to remaining.
Fields of InitializeOrderInstructionAccounts, in account order:
| # | Field | Type |
|---|---|---|
| 0 | payer | Pubkey |
| 1 | maker | Pubkey |
| 2 | order | Pubkey |
| 3 | input_ | Pubkey |
| 4 | maker_ | Pubkey |
| 5 | fee | Pubkey |
| 6 | referral | Option< |
| 7 | input_mint | Pubkey |
| 8 | output_mint | Pubkey |
| 9 | input_ | Pubkey |
| 10 | output_ | Pubkey |
| 11 | system_ | Pubkey |
| 12 | associated_ | Pubkey |
| 13 | event_ | Pubkey |
| 14 | program | Pubkey |
| 15… | remaining | Vec< |
PreFlashFillOrder#
Discriminator f02f99440dbee12a · data PreFlashFillOrder · accounts PreFlashFillOrderInstructionAccounts.
| Field | Type |
|---|---|
params | PreFlashFillOrderParams |
Required accounts: 7; extras go to remaining.
Fields of PreFlashFillOrderInstructionAccounts, in account order:
| # | Field | Type |
|---|---|---|
| 0 | taker | Pubkey |
| 1 | order | Pubkey |
| 2 | input_ | Pubkey |
| 3 | taker_ | Pubkey |
| 4 | input_mint | Pubkey |
| 5 | input_ | Pubkey |
| 6 | instruction | Pubkey |
| 7… | remaining | Vec< |
UpdateFee#
Discriminator e8fdc3f794d449de · data UpdateFee · accounts UpdateFeeInstructionAccounts.
| Field | Type |
|---|---|
params | UpdateFeeParams |
Required accounts: 3; extras go to remaining.
Fields of UpdateFeeInstructionAccounts, in account order:
| # | Field | Type |
|---|---|---|
| 0 | admin | Pubkey |
| 1 | fee_ | Pubkey |
| 2 | system_ | Pubkey |
| 3… | remaining | Vec< |
WithdrawFee#
Discriminator 0e7ae7da1feedf96 · data WithdrawFee · accounts WithdrawFeeInstructionAccounts.
No data fields.
Required accounts: 6; extras go to remaining.
Fields of WithdrawFeeInstructionAccounts, in account order:
| # | Field | Type |
|---|---|---|
| 0 | admin | Pubkey |
| 1 | fee_ | Pubkey |
| 2 | program_ | Pubkey |
| 3 | destination_ | Pubkey |
| 4 | token_ | Pubkey |
| 5 | mint | Pubkey |
| 6… | remaining | Vec< |
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:
| # | Field | Type |
|---|---|---|
| 0 | program | Pubkey |
| 1 | event_ | Pubkey |
| 2… | remaining | Vec< |
Accounts#
Variants of JupiterLimitOrder2Account. Each wraps a boxed struct from carbon_. decode_ only considers accounts owned by PROGRAM_ID and returns the first variant that matches.
Fee#
Discriminator 183796faa81b65b2 · accounts::.
| Field | Type |
|---|---|
normal_ | u16 |
stable_ | u16 |
Order#
Discriminator 86addfb94d561c33 · accounts::.
| Field | Type |
|---|---|
maker | Pubkey |
input_mint | Pubkey |
output_mint | Pubkey |
input_ | Pubkey |
output_ | Pubkey |
input_ | Pubkey |
unique_id | u64 |
ori_ | u64 |
ori_ | u64 |
making_ | u64 |
taking_ | u64 |
borrow_ | u64 |
expired_at | Option<i64> |
fee_bps | u16 |
fee_account | Pubkey |
created_at | i64 |
updated_at | i64 |
bump | u8 |
slippage_ | u16 |
Events#
Variants of instructions::, decoded from the CpiEvent instruction. Each wraps a struct from carbon_. The discriminator is the 8-byte event discriminator that follows the e445a52e51cb9a1d CPI-event tag.
CancelDustOrderEvent#
Discriminator 7cbe4a1cb128c8dc · events::.
| Field | Type |
|---|---|
order_key | Pubkey |
one_ | u64 |
CancelOrderEvent#
Discriminator ae428d1104e0a24d · events::.
| Field | Type |
|---|---|
order_key | Pubkey |
CreateOrderEvent#
Discriminator 318e48a6e61d5454 · events::.
| Field | Type |
|---|---|
order_key | Pubkey |
maker | Pubkey |
input_mint | Pubkey |
output_mint | Pubkey |
input_ | Pubkey |
output_ | Pubkey |
making_ | u64 |
taking_ | u64 |
expired_at | Option<i64> |
fee_bps | u16 |
fee_account | Pubkey |
slippage_ | u16 |
TradeEvent#
Discriminator bddb7fd34ee661ee · events::.
| Field | Type |
|---|---|
order_key | Pubkey |
taker | Pubkey |
remaining_ | u64 |
remaining_ | u64 |
making_ | u64 |
taking_ | u64 |
Types#
Types used by the instructions, accounts and events above, exported from carbon_.
CancelDustOrderEvent#
Struct types::. Same fields as the CancelDustOrderEvent event.
CancelDustOrderParams#
Struct types::.
| Field | Type |
|---|---|
one_ | u64 |
CancelOrderEvent#
Struct types::. Same fields as the CancelOrderEvent event.
CreateOrderEvent#
Struct types::. Same fields as the CreateOrderEvent event.
FillOrderParams#
Struct types::.
| Field | Type |
|---|---|
input_ | u64 |
swap_data | Vec<u8> |
FlashFillOrderParams#
Struct types::.
| Field | Type |
|---|---|
max_ | u64 |
InitializeOrderParams#
Struct types::.
| Field | Type |
|---|---|
unique_id | u64 |
making_ | u64 |
taking_ | u64 |
expired_at | Option<i64> |
fee_bps | Option<u16> |
slippage_ | Option<u16> |
PreFlashFillOrderParams#
Struct types::.
| Field | Type |
|---|---|
making_ | u64 |
TradeEvent#
Struct types::. Same fields as the TradeEvent event.
UpdateFeeParams#
Struct types::.
| Field | Type |
|---|---|
normal_ | u16 |
stable_ | u16 |