carbon_pumpfun_decoder/instructions/
mod.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58


use super::PumpfunDecoder;
pub mod buy;
pub mod complete_event;
pub mod create;
pub mod create_event;
pub mod initialize;
pub mod sell;
pub mod set_params;
pub mod set_params_event;
pub mod trade_event;
pub mod withdraw;

#[derive(
    carbon_core::InstructionType,
    serde::Serialize,
    serde::Deserialize,
    PartialEq,
    Eq,
    Debug,
    Clone,
    Hash,
)]
pub enum PumpfunInstruction {
    Initialize(initialize::Initialize),
    SetParams(set_params::SetParams),
    Create(create::Create),
    Buy(buy::Buy),
    Sell(sell::Sell),
    Withdraw(withdraw::Withdraw),
    CreateEvent(create_event::CreateEvent),
    TradeEvent(trade_event::TradeEvent),
    CompleteEvent(complete_event::CompleteEvent),
    SetParamsEvent(set_params_event::SetParamsEvent),
}

impl<'a> carbon_core::instruction::InstructionDecoder<'a> for PumpfunDecoder {
    type InstructionType = PumpfunInstruction;

    fn decode_instruction(
        &self,
        instruction: &solana_sdk::instruction::Instruction,
    ) -> Option<carbon_core::instruction::DecodedInstruction<Self::InstructionType>> {
        carbon_core::try_decode_instructions!(instruction,
            PumpfunInstruction::Initialize => initialize::Initialize,
            PumpfunInstruction::SetParams => set_params::SetParams,
            PumpfunInstruction::Create => create::Create,
            PumpfunInstruction::Buy => buy::Buy,
            PumpfunInstruction::Sell => sell::Sell,
            PumpfunInstruction::Withdraw => withdraw::Withdraw,
            PumpfunInstruction::CreateEvent => create_event::CreateEvent,
            PumpfunInstruction::TradeEvent => trade_event::TradeEvent,
            PumpfunInstruction::CompleteEvent => complete_event::CompleteEvent,
            PumpfunInstruction::SetParamsEvent => set_params_event::SetParamsEvent,
        )
    }
}