carbon_pumpfun_decoder/instructions/
mod.rs1use crate::PROGRAM_ID;
2
3use super::PumpfunDecoder;
4pub mod buy;
5pub mod complete_event;
6pub mod create;
7pub mod create_event;
8pub mod initialize;
9pub mod sell;
10pub mod set_params;
11pub mod set_params_event;
12pub mod trade_event;
13pub mod withdraw;
14
15#[derive(
16 carbon_core::InstructionType,
17 serde::Serialize,
18 serde::Deserialize,
19 PartialEq,
20 Eq,
21 Debug,
22 Clone,
23 Hash,
24)]
25pub enum PumpfunInstruction {
26 Initialize(initialize::Initialize),
27 SetParams(set_params::SetParams),
28 Create(create::Create),
29 Buy(buy::Buy),
30 Sell(sell::Sell),
31 Withdraw(withdraw::Withdraw),
32 CreateEvent(create_event::CreateEvent),
33 TradeEvent(trade_event::TradeEvent),
34 CompleteEvent(complete_event::CompleteEvent),
35 SetParamsEvent(set_params_event::SetParamsEvent),
36}
37
38impl carbon_core::instruction::InstructionDecoder<'_> for PumpfunDecoder {
39 type InstructionType = PumpfunInstruction;
40
41 fn decode_instruction(
42 &self,
43 instruction: &solana_sdk::instruction::Instruction,
44 ) -> Option<carbon_core::instruction::DecodedInstruction<Self::InstructionType>> {
45 if !instruction.program_id.eq(&PROGRAM_ID) {
46 return None;
47 }
48
49 carbon_core::try_decode_instructions!(instruction,
50 PumpfunInstruction::Initialize => initialize::Initialize,
51 PumpfunInstruction::SetParams => set_params::SetParams,
52 PumpfunInstruction::Create => create::Create,
53 PumpfunInstruction::Buy => buy::Buy,
54 PumpfunInstruction::Sell => sell::Sell,
55 PumpfunInstruction::Withdraw => withdraw::Withdraw,
56 PumpfunInstruction::CreateEvent => create_event::CreateEvent,
57 PumpfunInstruction::TradeEvent => trade_event::TradeEvent,
58 PumpfunInstruction::CompleteEvent => complete_event::CompleteEvent,
59 PumpfunInstruction::SetParamsEvent => set_params_event::SetParamsEvent,
60 )
61 }
62}