carbon_raydium_launchpad_decoder/instructions/
mod.rs

1use crate::PROGRAM_ID;
2
3use super::RaydiumLaunchpadDecoder;
4pub mod buy_exact_in;
5pub mod buy_exact_out;
6pub mod claim_creator_fee;
7pub mod claim_platform_fee;
8pub mod claim_platform_fee_from_vault;
9pub mod claim_vested_event;
10pub mod claim_vested_token;
11pub mod collect_fee;
12pub mod collect_migrate_fee;
13pub mod create_config;
14pub mod create_platform_config;
15pub mod create_vesting_account;
16pub mod create_vesting_event;
17pub mod initialize;
18pub mod initialize_v2;
19pub mod initialize_with_token_2022;
20pub mod migrate_to_amm;
21pub mod migrate_to_cpswap;
22pub mod pool_create_event;
23pub mod remove_platform_curve_param;
24pub mod sell_exact_in;
25pub mod sell_exact_out;
26pub mod trade_event;
27pub mod update_config;
28pub mod update_platform_config;
29pub mod update_platform_curve_param;
30
31#[derive(
32    carbon_core::InstructionType,
33    serde::Serialize,
34    serde::Deserialize,
35    PartialEq,
36    Eq,
37    Debug,
38    Clone,
39    Hash,
40)]
41pub enum RaydiumLaunchpadInstruction {
42    BuyExactIn(buy_exact_in::BuyExactIn),
43    BuyExactOut(buy_exact_out::BuyExactOut),
44    ClaimCreatorFee(claim_creator_fee::ClaimCreatorFee),
45    ClaimPlatformFee(claim_platform_fee::ClaimPlatformFee),
46    ClaimPlatformFeeFromVault(claim_platform_fee_from_vault::ClaimPlatformFeeFromVault),
47    ClaimVestedToken(claim_vested_token::ClaimVestedToken),
48    CollectFee(collect_fee::CollectFee),
49    CollectMigrateFee(collect_migrate_fee::CollectMigrateFee),
50    CreateConfig(create_config::CreateConfig),
51    CreatePlatformConfig(create_platform_config::CreatePlatformConfig),
52    CreateVestingAccount(create_vesting_account::CreateVestingAccount),
53    Initialize(initialize::Initialize),
54    InitializeV2(initialize_v2::InitializeV2),
55    InitializeWithToken2022(initialize_with_token_2022::InitializeWithToken2022),
56    MigrateToAmm(migrate_to_amm::MigrateToAmm),
57    MigrateToCpswap(migrate_to_cpswap::MigrateToCpswap),
58    RemovePlatformCurveParam(remove_platform_curve_param::RemovePlatformCurveParam),
59    SellExactIn(sell_exact_in::SellExactIn),
60    SellExactOut(sell_exact_out::SellExactOut),
61    UpdateConfig(update_config::UpdateConfig),
62    UpdatePlatformConfig(update_platform_config::UpdatePlatformConfig),
63    UpdatePlatformCurveParam(update_platform_curve_param::UpdatePlatformCurveParam),
64    ClaimVestedEvent(claim_vested_event::ClaimVestedEvent),
65    CreateVestingEvent(create_vesting_event::CreateVestingEvent),
66    PoolCreateEvent(pool_create_event::PoolCreateEvent),
67    TradeEvent(trade_event::TradeEvent),
68}
69
70impl carbon_core::instruction::InstructionDecoder<'_> for RaydiumLaunchpadDecoder {
71    type InstructionType = RaydiumLaunchpadInstruction;
72
73    fn decode_instruction(
74        &self,
75        instruction: &solana_instruction::Instruction,
76    ) -> Option<carbon_core::instruction::DecodedInstruction<Self::InstructionType>> {
77        if !instruction.program_id.eq(&PROGRAM_ID) {
78            return None;
79        }
80
81        carbon_core::try_decode_instructions!(instruction,
82            RaydiumLaunchpadInstruction::BuyExactIn => buy_exact_in::BuyExactIn,
83            RaydiumLaunchpadInstruction::BuyExactOut => buy_exact_out::BuyExactOut,
84            RaydiumLaunchpadInstruction::ClaimCreatorFee => claim_creator_fee::ClaimCreatorFee,
85            RaydiumLaunchpadInstruction::ClaimPlatformFee => claim_platform_fee::ClaimPlatformFee,
86            RaydiumLaunchpadInstruction::ClaimPlatformFeeFromVault => claim_platform_fee_from_vault::ClaimPlatformFeeFromVault,
87            RaydiumLaunchpadInstruction::ClaimVestedToken => claim_vested_token::ClaimVestedToken,
88            RaydiumLaunchpadInstruction::CollectFee => collect_fee::CollectFee,
89            RaydiumLaunchpadInstruction::CollectMigrateFee => collect_migrate_fee::CollectMigrateFee,
90            RaydiumLaunchpadInstruction::CreateConfig => create_config::CreateConfig,
91            RaydiumLaunchpadInstruction::CreatePlatformConfig => create_platform_config::CreatePlatformConfig,
92            RaydiumLaunchpadInstruction::CreateVestingAccount => create_vesting_account::CreateVestingAccount,
93            RaydiumLaunchpadInstruction::Initialize => initialize::Initialize,
94            RaydiumLaunchpadInstruction::InitializeV2 => initialize_v2::InitializeV2,
95            RaydiumLaunchpadInstruction::InitializeWithToken2022 => initialize_with_token_2022::InitializeWithToken2022,
96            RaydiumLaunchpadInstruction::MigrateToAmm => migrate_to_amm::MigrateToAmm,
97            RaydiumLaunchpadInstruction::MigrateToCpswap => migrate_to_cpswap::MigrateToCpswap,
98            RaydiumLaunchpadInstruction::RemovePlatformCurveParam => remove_platform_curve_param::RemovePlatformCurveParam,
99            RaydiumLaunchpadInstruction::SellExactIn => sell_exact_in::SellExactIn,
100            RaydiumLaunchpadInstruction::SellExactOut => sell_exact_out::SellExactOut,
101            RaydiumLaunchpadInstruction::UpdateConfig => update_config::UpdateConfig,
102            RaydiumLaunchpadInstruction::UpdatePlatformConfig => update_platform_config::UpdatePlatformConfig,
103            RaydiumLaunchpadInstruction::UpdatePlatformCurveParam => update_platform_curve_param::UpdatePlatformCurveParam,
104            RaydiumLaunchpadInstruction::ClaimVestedEvent => claim_vested_event::ClaimVestedEvent,
105            RaydiumLaunchpadInstruction::CreateVestingEvent => create_vesting_event::CreateVestingEvent,
106            RaydiumLaunchpadInstruction::PoolCreateEvent => pool_create_event::PoolCreateEvent,
107            RaydiumLaunchpadInstruction::TradeEvent => trade_event::TradeEvent,
108        )
109    }
110}