Skip to main content

sol_parser_sdk/core/events/
raw_instruction.rs

1//! Lossless outer instruction payload, without assumptions about program behavior.
2use serde::{Deserialize, Serialize};
3use solana_sdk::pubkey::Pubkey;
4
5/// Original outer instruction associated with a DEX trade callback. Account
6/// order and duplicates are preserved; unresolved ALT addresses remain None.
7#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
8pub struct RawInstructionPayload {
9    pub program_id: Pubkey,
10    pub instruction_index: usize,
11    pub accounts: Vec<Option<Pubkey>>,
12    pub account_indices: Vec<u8>,
13    pub instruction_data: Vec<u8>,
14}
15
16/// Evidence available to the parser, not a guarantee that every amount is known.
17#[derive(Debug, Clone, Copy, Default, PartialEq, Eq, Serialize, Deserialize)]
18pub enum TradeParseStatus {
19    /// Outer instruction references a DEX; no trade or direction is proven.
20    Unresolved,
21    /// Instruction inputs were decoded; execution amounts are not established.
22    #[default]
23    InstructionDecoded,
24    /// Successful execution metadata/logs establish the DEX invocation.
25    /// Executed amounts may still be unavailable when event logs are missing.
26    ExecutionConfirmed,
27}
28
29/// Compatibility alias for the original Pump.fun-specific name.
30pub type PumpFunParseStatus = TradeParseStatus;
31
32/// Stable DEX identifiers retained for stock-price configuration compatibility.
33/// These identifiers do not trigger raw-instruction parsing.
34#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
35pub enum RawInstructionDexType {
36    #[serde(rename = "pumpfun")]
37    PumpFun,
38    #[serde(rename = "pumpswap")]
39    PumpSwap,
40    #[serde(rename = "raydium_launchlab")]
41    RaydiumLaunchlab,
42    #[serde(rename = "raydium_cpmm")]
43    RaydiumCpmm,
44    #[serde(rename = "raydium_clmm")]
45    RaydiumClmm,
46    #[serde(rename = "raydium_amm_v4")]
47    RaydiumAmmV4,
48    #[serde(rename = "orca_whirlpool")]
49    OrcaWhirlpool,
50    #[serde(rename = "meteora_pools")]
51    MeteoraPools,
52    #[serde(rename = "meteora_damm_v2")]
53    MeteoraDammV2,
54    #[serde(rename = "meteora_dlmm")]
55    MeteoraDlmm,
56    #[serde(rename = "meteora_dbc")]
57    MeteoraDbc,
58}
59
60impl RawInstructionDexType {
61    pub const fn as_str(self) -> &'static str {
62        match self {
63            Self::PumpFun => "pumpfun",
64            Self::PumpSwap => "pumpswap",
65            Self::RaydiumLaunchlab => "raydium_launchlab",
66            Self::RaydiumCpmm => "raydium_cpmm",
67            Self::RaydiumClmm => "raydium_clmm",
68            Self::RaydiumAmmV4 => "raydium_amm_v4",
69            Self::OrcaWhirlpool => "orca_whirlpool",
70            Self::MeteoraPools => "meteora_pools",
71            Self::MeteoraDammV2 => "meteora_damm_v2",
72            Self::MeteoraDlmm => "meteora_dlmm",
73            Self::MeteoraDbc => "meteora_dbc",
74        }
75    }
76}