Skip to main content

sol_parser_sdk/core/events/
route_intent.rs

1//! Instructions observed before execution, never confirmed fills.
2use super::EventMetadata;
3use serde::{Deserialize, Serialize};
4use solana_sdk::pubkey::Pubkey;
5
6#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
7pub enum PumpRouteKind {
8    MultiHopSwap,
9    MultiHopCurveSwap,
10    RapidBuy,
11    BuyPumpDelta,
12}
13
14#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
15pub struct PumpRouteHop {
16    pub base_mint: Pubkey,
17    pub quote_mint: Pubkey,
18    /// Pool or bonding curve; this does not assert which branch executed.
19    pub venue: Pubkey,
20    pub base_vault: Pubkey,
21    pub quote_vault: Pubkey,
22}
23
24/// A recognized outer instruction's route intent. Execution status, actual
25/// amounts, reserves and balances are deliberately absent. A wrapper may choose
26/// amounts or skip a CPI at runtime. Use execution metadata for confirmed fills.
27#[derive(Debug, Clone, Serialize, Deserialize)]
28pub struct PumpRouteIntentEvent {
29    pub metadata: EventMetadata,
30    pub kind: PumpRouteKind,
31    /// Intended direction relative to the single wrapper hop's base mint.
32    /// None for multi-hop routes; this does not assert that a trade executed.
33    #[serde(default)]
34    pub is_buy: Option<bool>,
35    /// Expected underlying Pump instruction, only when encoded in the validated
36    /// wrapper payload. Not the outer route name or a confirmed CPI invocation.
37    #[serde(default)]
38    pub ix_name: Option<String>,
39    pub program: Pubkey,
40    /// Index within the signed message, distinct from metadata.tx_index.
41    pub instruction_index: usize,
42    pub user: Pubkey,
43    pub input_account: Pubkey,
44    pub output_account: Pubkey,
45    /// Explicit instruction input only; None for balance-dependent wrappers.
46    pub amount_in: Option<u64>,
47    /// Explicit output constraint, never actual output.
48    pub min_amount_out: Option<u64>,
49    pub hops: Vec<PumpRouteHop>,
50    /// Original instruction data, including discriminator. Unknown wrapper
51    /// parameters remain opaque instead of being guessed as trade amounts.
52    pub instruction_data: Vec<u8>,
53}