Jupiter Limit Order decoder
Decode Jupiter Limit Order instructions, accounts and events in Rust with the carbon-jupiter-limit-order-decoder crate.
On this page
carbon-jupiter-limit-order-decoder decodes the instructions, accounts and events of the Jupiter Limit Order program (jupoNjAxXgZ4rjzxzPMP4oxduvQsQtZzyknqvzYNrNu): 9 instructions, 2 account types, 3 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-decoder 2.0.0 |
| Install | cargo add carbon-jupiter-limit-order-decoder@2. |
| Program ID | jupoNjAxXgZ4rjzxzPMP4oxduvQsQtZzyknqvzYNrNu (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-decoder/2.0.0 |
| Source | decoders/jupiter-limit-order-decoder |
Other DEX and AMM decoders: BonkSwap, FluxBeam, Gavel, Heaven, Jupiter Limit Order v2, 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 transactions from the public RPC and prints every decoded CancelExpiredOrder instruction. Add the dependencies:
cargo add carbon-core@2.0.0 carbon-jupiter-limit-order-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_decoder::{
instructions::JupiterLimitOrderInstruction, JupiterLimitOrderDecoder, 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(JupiterLimitOrderDecoder, InstructionLogger)
.build()?
.run()
.await
}
struct InstructionLogger;
impl Processor<InstructionProcessorInputType<'_, JupiterLimitOrderInstruction>> for InstructionLogger {
async fn process(
&mut self,
input: &InstructionProcessorInputType<'_, JupiterLimitOrderInstruction>,
) -> CarbonResult<()> {
let signature = input.metadata.transaction_metadata.signature;
if let JupiterLimitOrderInstruction::CancelExpiredOrder { data, accounts, .. } = input.decoded_instruction {
println!("cancel_expired_order {signature}: {data:?} order={}", accounts.order);
}
Ok(())
}
}RUST_LOG=info cargo runEach CancelExpiredOrder instruction prints one line with the transaction signature and the decoded CancelExpiredOrder 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 JupiterLimitOrderInstruction:: (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_decoder::{
accounts::JupiterLimitOrderAccount, JupiterLimitOrderDecoder, 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(JupiterLimitOrderDecoder, AccountLogger)
.build()?
.run()
.await
}
struct AccountLogger;
impl Processor<AccountProcessorInputType<'_, JupiterLimitOrderAccount>> for AccountLogger {
async fn process(
&mut self,
input: &AccountProcessorInputType<'_, JupiterLimitOrderAccount>,
) -> CarbonResult<()> {
if let JupiterLimitOrderAccount::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 JupiterLimitOrderInstruction. Each is JupiterLimitOrderInstruction::, 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
jupoNjAxXgZ4rjzxzPMP4oxduvQsQtZzyknqvzYNrNu. - 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.
CancelExpiredOrder#
Discriminator d87840eb9b13e563 · data CancelExpiredOrder · accounts CancelExpiredOrderInstructionAccounts.
No data fields.
Required accounts: 6 (7 listed); extras go to remaining.
Fields of CancelExpiredOrderInstructionAccounts, in account order:
| # | Field | Type |
|---|---|---|
| 0 | order | Pubkey |
| 1 | reserve | Pubkey |
| 2 | maker | Pubkey |
| 3 | maker_ | Pubkey |
| 4 | system_ | Pubkey |
| 5 | token_ | Pubkey |
| 6 | input_mint | Option< |
| 7… | remaining | Vec< |
CancelOrder#
Discriminator 5f81edf00831df84 · data CancelOrder · accounts CancelOrderInstructionAccounts.
No data fields.
Required accounts: 6 (7 listed); extras go to remaining.
Fields of CancelOrderInstructionAccounts, in account order:
| # | Field | Type |
|---|---|---|
| 0 | order | Pubkey |
| 1 | reserve | Pubkey |
| 2 | maker | Pubkey |
| 3 | maker_ | Pubkey |
| 4 | system_ | Pubkey |
| 5 | token_ | Pubkey |
| 6 | input_mint | Option< |
| 7… | remaining | Vec< |
FillOrder#
Discriminator e87a7319c78f88a2 · data FillOrder · accounts FillOrderInstructionAccounts.
| Field | Type |
|---|---|
making_ | u64 |
max_ | u64 |
Required accounts: 12; extras go to remaining.
Fields of FillOrderInstructionAccounts, in account order:
| # | Field | Type |
|---|---|---|
| 0 | order | Pubkey |
| 1 | reserve | Pubkey |
| 2 | maker | Pubkey |
| 3 | taker | Pubkey |
| 4 | taker_ | Pubkey |
| 5 | maker_ | Pubkey |
| 6 | taker_ | Pubkey |
| 7 | fee_ | Pubkey |
| 8 | program_ | Pubkey |
| 9 | referral | Option< |
| 10 | token_ | Pubkey |
| 11 | system_ | Pubkey |
| 12… | remaining | Vec< |
FlashFillOrder#
Discriminator fc681286a44e128c · data FlashFillOrder · accounts FlashFillOrderInstructionAccounts.
| Field | Type |
|---|---|
max_ | u64 |
Required accounts: 14; extras go to remaining.
Fields of FlashFillOrderInstructionAccounts, in account order:
| # | Field | Type |
|---|---|---|
| 0 | order | Pubkey |
| 1 | reserve | Pubkey |
| 2 | maker | Pubkey |
| 3 | taker | Pubkey |
| 4 | maker_ | Pubkey |
| 5 | taker_ | Pubkey |
| 6 | fee_ | Pubkey |
| 7 | program_ | Pubkey |
| 8 | referral | Option< |
| 9 | input_mint | Pubkey |
| 10 | input_ | Pubkey |
| 11 | output_mint | Pubkey |
| 12 | output_ | Pubkey |
| 13 | system_ | Pubkey |
| 14… | remaining | Vec< |
InitFee#
Discriminator 0d09d36b3eace043 · data InitFee · accounts InitFeeInstructionAccounts.
| Field | Type |
|---|---|
maker_fee | u64 |
maker_ | u64 |
taker_fee | u64 |
taker_ | u64 |
Required accounts: 3; extras go to remaining.
Fields of InitFeeInstructionAccounts, in account order:
| # | Field | Type |
|---|---|---|
| 0 | keeper | Pubkey |
| 1 | fee_ | Pubkey |
| 2 | system_ | Pubkey |
| 3… | remaining | Vec< |
InitializeOrder#
Discriminator 856e4aaf709ff59f · data InitializeOrder · accounts InitializeOrderInstructionAccounts.
| Field | Type |
|---|---|
making_ | u64 |
taking_ | u64 |
expired_at | Option<i64> |
Required accounts: 12; extras go to remaining.
Fields of InitializeOrderInstructionAccounts, in account order:
| # | Field | Type |
|---|---|---|
| 0 | base | Pubkey |
| 1 | maker | Pubkey |
| 2 | order | Pubkey |
| 3 | reserve | Pubkey |
| 4 | maker_ | Pubkey |
| 5 | input_mint | Pubkey |
| 6 | maker_ | Pubkey |
| 7 | referral | Option< |
| 8 | output_mint | Pubkey |
| 9 | system_ | Pubkey |
| 10 | token_ | Pubkey |
| 11 | rent | Pubkey |
| 12… | remaining | Vec< |
PreFlashFillOrder#
Discriminator f02f99440dbee12a · data PreFlashFillOrder · accounts PreFlashFillOrderInstructionAccounts.
| Field | Type |
|---|---|
making_ | u64 |
Required accounts: 8; extras go to remaining.
Fields of PreFlashFillOrderInstructionAccounts, in account order:
| # | Field | Type |
|---|---|---|
| 0 | order | Pubkey |
| 1 | reserve | Pubkey |
| 2 | taker | Pubkey |
| 3 | taker_ | Pubkey |
| 4 | input_mint | Pubkey |
| 5 | input_ | Pubkey |
| 6 | instruction | Pubkey |
| 7 | system_ | Pubkey |
| 8… | remaining | Vec< |
UpdateFee#
Discriminator e8fdc3f794d449de · data UpdateFee · accounts UpdateFeeInstructionAccounts.
| Field | Type |
|---|---|
maker_fee | u64 |
maker_ | u64 |
taker_fee | u64 |
taker_ | u64 |
Required accounts: 2; extras go to remaining.
Fields of UpdateFeeInstructionAccounts, in account order:
| # | Field | Type |
|---|---|---|
| 0 | keeper | Pubkey |
| 1 | fee_ | Pubkey |
| 2… | remaining | Vec< |
WithdrawFee#
Discriminator 0e7ae7da1feedf96 · data WithdrawFee · accounts WithdrawFeeInstructionAccounts.
| Field | Type |
|---|---|
amount | u64 |
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 | admin_ | 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 JupiterLimitOrderAccount. 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 |
|---|---|
maker_fee | u64 |
maker_ | u64 |
taker_fee | u64 |
taker_ | u64 |
Order#
Discriminator 86addfb94d561c33 · accounts::.
| Field | Type |
|---|---|
maker | Pubkey |
input_mint | Pubkey |
output_mint | Pubkey |
waiting | bool |
ori_ | u64 |
ori_ | u64 |
making_ | u64 |
taking_ | u64 |
maker_ | Pubkey |
maker_ | Pubkey |
reserve | Pubkey |
borrow_ | u64 |
expired_at | Option<i64> |
base | Pubkey |
referral | Option< |
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.
TradeEvent#
Discriminator bddb7fd34ee661ee · events::.
| Field | Type |
|---|---|
order_key | Pubkey |
taker | Pubkey |
remaining_ | u64 |
remaining_ | u64 |
in_amount | u64 |
out_amount | 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 |
in_amount | u64 |
out_amount | u64 |
expired_at | Option<i64> |
Types#
Types used by the instructions, accounts and events above, exported from carbon_.
CancelOrderEvent#
Struct types::. Same fields as the CancelOrderEvent event.
CreateOrderEvent#
Struct types::. Same fields as the CreateOrderEvent event.
TradeEvent#
Struct types::. Same fields as the TradeEvent event.