carbon_pump_swap_decoder/instructions/
mod.rs

1use carbon_core::deserialize::CarbonDeserialize;
2use solana_instruction::Instruction;
3
4use crate::PROGRAM_ID;
5
6use super::PumpSwapDecoder;
7pub mod admin_set_coin_creator;
8pub mod admin_set_coin_creator_event;
9pub mod admin_update_token_incentives;
10pub mod admin_update_token_incentives_event;
11pub mod buy;
12pub mod buy_event;
13pub mod buy_exact_quote_in;
14pub mod claim_token_incentives;
15pub mod claim_token_incentives_event;
16pub mod close_user_volume_accumulator;
17pub mod close_user_volume_accumulator_event;
18pub mod collect_coin_creator_fee;
19pub mod collect_coin_creator_fee_event;
20pub mod create_config;
21pub mod create_config_event;
22pub mod create_pool;
23pub mod create_pool_event;
24pub mod deposit;
25pub mod deposit_event;
26pub mod disable;
27pub mod disable_event;
28pub mod extend_account;
29pub mod extend_account_event;
30pub mod init_user_volume_accumulator;
31pub mod init_user_volume_accumulator_event;
32pub mod sell;
33pub mod sell_event;
34pub mod set_bonding_curve_coin_creator_event;
35pub mod set_coin_creator;
36pub mod set_metaplex_coin_creator_event;
37pub mod sync_user_volume_accumulator;
38pub mod sync_user_volume_accumulator_event;
39pub mod update_admin;
40pub mod update_admin_event;
41pub mod update_fee_config;
42pub mod update_fee_config_event;
43pub mod withdraw;
44pub mod withdraw_event;
45
46#[derive(
47    carbon_core::InstructionType,
48    serde::Serialize,
49    serde::Deserialize,
50    PartialEq,
51    Eq,
52    Debug,
53    Clone,
54    Hash,
55)]
56pub enum PumpSwapInstruction {
57    AdminSetCoinCreator(admin_set_coin_creator::AdminSetCoinCreator),
58    AdminUpdateTokenIncentives(admin_update_token_incentives::AdminUpdateTokenIncentives),
59    Buy(buy::Buy),
60    BuyExactQuoteIn(buy_exact_quote_in::BuyExactQuoteIn),
61    ClaimTokenIncentives(claim_token_incentives::ClaimTokenIncentives),
62    CloseUserVolumeAccumulator(close_user_volume_accumulator::CloseUserVolumeAccumulator),
63    CollectCoinCreatorFee(collect_coin_creator_fee::CollectCoinCreatorFee),
64    CreateConfig(create_config::CreateConfig),
65    CreatePool(create_pool::CreatePool),
66    Deposit(deposit::Deposit),
67    Disable(disable::Disable),
68    ExtendAccount(extend_account::ExtendAccount),
69    InitUserVolumeAccumulator(init_user_volume_accumulator::InitUserVolumeAccumulator),
70    Sell(sell::Sell),
71    SetCoinCreator(set_coin_creator::SetCoinCreator),
72    SyncUserVolumeAccumulator(sync_user_volume_accumulator::SyncUserVolumeAccumulator),
73    UpdateAdmin(update_admin::UpdateAdmin),
74    UpdateFeeConfig(update_fee_config::UpdateFeeConfig),
75    Withdraw(withdraw::Withdraw),
76    AdminSetCoinCreatorEvent(admin_set_coin_creator_event::AdminSetCoinCreatorEvent),
77    AdminUpdateTokenIncentivesEvent(
78        admin_update_token_incentives_event::AdminUpdateTokenIncentivesEvent,
79    ),
80    BuyEvent(buy_event::BuyEvent),
81    ClaimTokenIncentivesEvent(claim_token_incentives_event::ClaimTokenIncentivesEvent),
82    CloseUserVolumeAccumulatorEvent(
83        close_user_volume_accumulator_event::CloseUserVolumeAccumulatorEvent,
84    ),
85    CollectCoinCreatorFeeEvent(collect_coin_creator_fee_event::CollectCoinCreatorFeeEvent),
86    CreateConfigEvent(create_config_event::CreateConfigEvent),
87    CreatePoolEvent(create_pool_event::CreatePoolEvent),
88    DepositEvent(deposit_event::DepositEvent),
89    DisableEvent(disable_event::DisableEvent),
90    ExtendAccountEvent(extend_account_event::ExtendAccountEvent),
91    InitUserVolumeAccumulatorEvent(
92        init_user_volume_accumulator_event::InitUserVolumeAccumulatorEvent,
93    ),
94    SellEvent(sell_event::SellEvent),
95    SetBondingCurveCoinCreatorEvent(
96        set_bonding_curve_coin_creator_event::SetBondingCurveCoinCreatorEvent,
97    ),
98    SetMetaplexCoinCreatorEvent(set_metaplex_coin_creator_event::SetMetaplexCoinCreatorEvent),
99    SyncUserVolumeAccumulatorEvent(
100        sync_user_volume_accumulator_event::SyncUserVolumeAccumulatorEvent,
101    ),
102    UpdateAdminEvent(update_admin_event::UpdateAdminEvent),
103    UpdateFeeConfigEvent(update_fee_config_event::UpdateFeeConfigEvent),
104    WithdrawEvent(withdraw_event::WithdrawEvent),
105}
106
107impl carbon_core::instruction::InstructionDecoder<'_> for PumpSwapDecoder {
108    type InstructionType = PumpSwapInstruction;
109
110    fn decode_instruction(
111        &self,
112        instruction: &solana_instruction::Instruction,
113    ) -> Option<carbon_core::instruction::DecodedInstruction<Self::InstructionType>> {
114        if !instruction.program_id.eq(&PROGRAM_ID) {
115            return None;
116        }
117        let instruction = if !instruction.data.is_empty()
118            && instruction.data[..8] == *buy::Buy::DISCRIMINATOR
119            && instruction.data.len() == 24
120        {
121            let mut data = instruction.data.clone();
122            data.push(0);
123            &Instruction {
124                program_id: instruction.program_id,
125                accounts: instruction.accounts.clone(),
126                data,
127            }
128        } else {
129            instruction
130        };
131        carbon_core::try_decode_instructions!(instruction,
132            PumpSwapInstruction::AdminSetCoinCreator => admin_set_coin_creator::AdminSetCoinCreator,
133            PumpSwapInstruction::AdminUpdateTokenIncentives => admin_update_token_incentives::AdminUpdateTokenIncentives,
134            PumpSwapInstruction::Buy => buy::Buy,
135            PumpSwapInstruction::BuyExactQuoteIn => buy_exact_quote_in::BuyExactQuoteIn,
136            PumpSwapInstruction::ClaimTokenIncentives => claim_token_incentives::ClaimTokenIncentives,
137            PumpSwapInstruction::CloseUserVolumeAccumulator => close_user_volume_accumulator::CloseUserVolumeAccumulator,
138            PumpSwapInstruction::CollectCoinCreatorFee => collect_coin_creator_fee::CollectCoinCreatorFee,
139            PumpSwapInstruction::CreateConfig => create_config::CreateConfig,
140            PumpSwapInstruction::CreatePool => create_pool::CreatePool,
141            PumpSwapInstruction::Deposit => deposit::Deposit,
142            PumpSwapInstruction::Disable => disable::Disable,
143            PumpSwapInstruction::ExtendAccount => extend_account::ExtendAccount,
144            PumpSwapInstruction::InitUserVolumeAccumulator => init_user_volume_accumulator::InitUserVolumeAccumulator,
145            PumpSwapInstruction::Sell => sell::Sell,
146            PumpSwapInstruction::SetCoinCreator => set_coin_creator::SetCoinCreator,
147            PumpSwapInstruction::SyncUserVolumeAccumulator => sync_user_volume_accumulator::SyncUserVolumeAccumulator,
148            PumpSwapInstruction::UpdateAdmin => update_admin::UpdateAdmin,
149            PumpSwapInstruction::UpdateFeeConfig => update_fee_config::UpdateFeeConfig,
150            PumpSwapInstruction::Withdraw => withdraw::Withdraw,
151            PumpSwapInstruction::AdminSetCoinCreatorEvent => admin_set_coin_creator_event::AdminSetCoinCreatorEvent,
152            PumpSwapInstruction::AdminUpdateTokenIncentivesEvent => admin_update_token_incentives_event::AdminUpdateTokenIncentivesEvent,
153            PumpSwapInstruction::BuyEvent => buy_event::BuyEvent,
154            PumpSwapInstruction::ClaimTokenIncentivesEvent => claim_token_incentives_event::ClaimTokenIncentivesEvent,
155            PumpSwapInstruction::CloseUserVolumeAccumulatorEvent => close_user_volume_accumulator_event::CloseUserVolumeAccumulatorEvent,
156            PumpSwapInstruction::CollectCoinCreatorFeeEvent => collect_coin_creator_fee_event::CollectCoinCreatorFeeEvent,
157            PumpSwapInstruction::CreateConfigEvent => create_config_event::CreateConfigEvent,
158            PumpSwapInstruction::CreatePoolEvent => create_pool_event::CreatePoolEvent,
159            PumpSwapInstruction::DepositEvent => deposit_event::DepositEvent,
160            PumpSwapInstruction::DisableEvent => disable_event::DisableEvent,
161            PumpSwapInstruction::ExtendAccountEvent => extend_account_event::ExtendAccountEvent,
162            PumpSwapInstruction::InitUserVolumeAccumulatorEvent => init_user_volume_accumulator_event::InitUserVolumeAccumulatorEvent,
163            PumpSwapInstruction::SellEvent => sell_event::SellEvent,
164            PumpSwapInstruction::SetBondingCurveCoinCreatorEvent => set_bonding_curve_coin_creator_event::SetBondingCurveCoinCreatorEvent,
165            PumpSwapInstruction::SetMetaplexCoinCreatorEvent => set_metaplex_coin_creator_event::SetMetaplexCoinCreatorEvent,
166            PumpSwapInstruction::SyncUserVolumeAccumulatorEvent => sync_user_volume_accumulator_event::SyncUserVolumeAccumulatorEvent,
167            PumpSwapInstruction::UpdateAdminEvent => update_admin_event::UpdateAdminEvent,
168            PumpSwapInstruction::UpdateFeeConfigEvent => update_fee_config_event::UpdateFeeConfigEvent,
169            PumpSwapInstruction::WithdrawEvent => withdraw_event::WithdrawEvent,
170        )
171    }
172}