carbon_stabble_stable_swap_decoder/instructions/
mod.rs1use crate::PROGRAM_ID;
2
3use super::StableSwapDecoder;
4pub mod accept_owner;
5pub mod approve_strategy;
6pub mod change_amp_factor;
7pub mod change_max_supply;
8pub mod change_swap_fee;
9pub mod create_strategy;
10pub mod deposit;
11pub mod exec_strategy;
12pub mod initialize;
13pub mod pause;
14pub mod pool_balance_updated_event;
15pub mod pool_updated_event;
16pub mod reject_owner;
17pub mod shutdown;
18pub mod swap;
19pub mod swap_v2;
20pub mod transfer_owner;
21pub mod unpause;
22pub mod withdraw;
23
24#[derive(
25 carbon_core::InstructionType,
26 serde::Serialize,
27 serde::Deserialize,
28 PartialEq,
29 Eq,
30 Debug,
31 Clone,
32 Hash,
33)]
34pub enum StableSwapInstruction {
35 AcceptOwner(accept_owner::AcceptOwner),
36 ApproveStrategy(approve_strategy::ApproveStrategy),
37 ChangeAmpFactor(change_amp_factor::ChangeAmpFactor),
38 ChangeMaxSupply(change_max_supply::ChangeMaxSupply),
39 ChangeSwapFee(change_swap_fee::ChangeSwapFee),
40 CreateStrategy(create_strategy::CreateStrategy),
41 Deposit(deposit::Deposit),
42 ExecStrategy(exec_strategy::ExecStrategy),
43 Initialize(initialize::Initialize),
44 Pause(pause::Pause),
45 RejectOwner(reject_owner::RejectOwner),
46 Shutdown(shutdown::Shutdown),
47 Swap(swap::Swap),
48 SwapV2(swap_v2::SwapV2),
49 TransferOwner(transfer_owner::TransferOwner),
50 Unpause(unpause::Unpause),
51 Withdraw(withdraw::Withdraw),
52 PoolBalanceUpdatedEvent(pool_balance_updated_event::PoolBalanceUpdatedEvent),
53 PoolUpdatedEvent(pool_updated_event::PoolUpdatedEvent),
54}
55
56impl carbon_core::instruction::InstructionDecoder<'_> for StableSwapDecoder {
57 type InstructionType = StableSwapInstruction;
58
59 fn decode_instruction(
60 &self,
61 instruction: &solana_instruction::Instruction,
62 ) -> Option<carbon_core::instruction::DecodedInstruction<Self::InstructionType>> {
63 if !instruction.program_id.eq(&PROGRAM_ID) {
64 return None;
65 }
66
67 carbon_core::try_decode_instructions!(instruction,
68 StableSwapInstruction::AcceptOwner => accept_owner::AcceptOwner,
69 StableSwapInstruction::ApproveStrategy => approve_strategy::ApproveStrategy,
70 StableSwapInstruction::ChangeAmpFactor => change_amp_factor::ChangeAmpFactor,
71 StableSwapInstruction::ChangeMaxSupply => change_max_supply::ChangeMaxSupply,
72 StableSwapInstruction::ChangeSwapFee => change_swap_fee::ChangeSwapFee,
73 StableSwapInstruction::CreateStrategy => create_strategy::CreateStrategy,
74 StableSwapInstruction::Deposit => deposit::Deposit,
75 StableSwapInstruction::ExecStrategy => exec_strategy::ExecStrategy,
76 StableSwapInstruction::Initialize => initialize::Initialize,
77 StableSwapInstruction::Pause => pause::Pause,
78 StableSwapInstruction::RejectOwner => reject_owner::RejectOwner,
79 StableSwapInstruction::Shutdown => shutdown::Shutdown,
80 StableSwapInstruction::Swap => swap::Swap,
81 StableSwapInstruction::SwapV2 => swap_v2::SwapV2,
82 StableSwapInstruction::TransferOwner => transfer_owner::TransferOwner,
83 StableSwapInstruction::Unpause => unpause::Unpause,
84 StableSwapInstruction::Withdraw => withdraw::Withdraw,
85 StableSwapInstruction::PoolBalanceUpdatedEvent => pool_balance_updated_event::PoolBalanceUpdatedEvent,
86 StableSwapInstruction::PoolUpdatedEvent => pool_updated_event::PoolUpdatedEvent,
87 )
88 }
89}