carbon_atlas_staking_decoder/instructions/
mod.rs1use crate::AtlasStakingDecoder;
3use crate::PROGRAM_ID;
4
5pub mod cancel_unstake;
6pub mod create_staking_account;
7pub mod harvest;
8pub mod initialize_staking;
9pub mod register_stake;
10pub mod settle;
11pub mod stake_tokens;
12pub mod unstake_tokens;
13pub mod update_cooldown_period;
14pub mod update_reward_multiplier;
15pub mod withdraw_tokens;
16
17pub use self::cancel_unstake::*;
18pub use self::create_staking_account::*;
19pub use self::harvest::*;
20pub use self::initialize_staking::*;
21pub use self::register_stake::*;
22pub use self::settle::*;
23pub use self::stake_tokens::*;
24pub use self::unstake_tokens::*;
25pub use self::update_cooldown_period::*;
26pub use self::update_reward_multiplier::*;
27pub use self::withdraw_tokens::*;
28
29#[derive(Debug, Clone, PartialEq, Eq, Hash)]
30#[cfg_attr(
31 feature = "serde",
32 derive(carbon_core::InstructionType, serde::Serialize, serde::Deserialize)
33)]
34#[cfg_attr(feature = "serde", serde(tag = "type", content = "data"))]
35pub enum AtlasStakingInstruction {
36 CancelUnstake(CancelUnstake),
37 CreateStakingAccount(CreateStakingAccount),
38 Harvest(Harvest),
39 InitializeStaking(InitializeStaking),
40 RegisterStake(RegisterStake),
41 Settle(Settle),
42 StakeTokens(StakeTokens),
43 UnstakeTokens(UnstakeTokens),
44 UpdateCooldownPeriod(UpdateCooldownPeriod),
45 UpdateRewardMultiplier(UpdateRewardMultiplier),
46 WithdrawTokens(WithdrawTokens),
47}
48
49impl carbon_core::instruction::InstructionDecoder<'_> for AtlasStakingDecoder {
50 type InstructionType = AtlasStakingInstruction;
51
52 fn decode_instruction(
53 &self,
54 instruction: &solana_instruction::Instruction,
55 ) -> Option<carbon_core::instruction::DecodedInstruction<Self::InstructionType>> {
56 if !instruction.program_id.eq(&PROGRAM_ID) {
57 return None;
58 }
59
60 let data = instruction.data.as_slice();
61
62 {
63 if let Some(decoded) = cancel_unstake::CancelUnstake::decode(data) {
64 return Some(carbon_core::instruction::DecodedInstruction {
65 program_id: instruction.program_id,
66 data: AtlasStakingInstruction::CancelUnstake(decoded),
67 accounts: instruction.accounts.clone(),
68 });
69 }
70 }
71 {
72 if let Some(decoded) = create_staking_account::CreateStakingAccount::decode(data) {
73 return Some(carbon_core::instruction::DecodedInstruction {
74 program_id: instruction.program_id,
75 data: AtlasStakingInstruction::CreateStakingAccount(decoded),
76 accounts: instruction.accounts.clone(),
77 });
78 }
79 }
80 {
81 if let Some(decoded) = harvest::Harvest::decode(data) {
82 return Some(carbon_core::instruction::DecodedInstruction {
83 program_id: instruction.program_id,
84 data: AtlasStakingInstruction::Harvest(decoded),
85 accounts: instruction.accounts.clone(),
86 });
87 }
88 }
89 {
90 if let Some(decoded) = initialize_staking::InitializeStaking::decode(data) {
91 return Some(carbon_core::instruction::DecodedInstruction {
92 program_id: instruction.program_id,
93 data: AtlasStakingInstruction::InitializeStaking(decoded),
94 accounts: instruction.accounts.clone(),
95 });
96 }
97 }
98 {
99 if let Some(decoded) = register_stake::RegisterStake::decode(data) {
100 return Some(carbon_core::instruction::DecodedInstruction {
101 program_id: instruction.program_id,
102 data: AtlasStakingInstruction::RegisterStake(decoded),
103 accounts: instruction.accounts.clone(),
104 });
105 }
106 }
107 {
108 if let Some(decoded) = settle::Settle::decode(data) {
109 return Some(carbon_core::instruction::DecodedInstruction {
110 program_id: instruction.program_id,
111 data: AtlasStakingInstruction::Settle(decoded),
112 accounts: instruction.accounts.clone(),
113 });
114 }
115 }
116 {
117 if let Some(decoded) = stake_tokens::StakeTokens::decode(data) {
118 return Some(carbon_core::instruction::DecodedInstruction {
119 program_id: instruction.program_id,
120 data: AtlasStakingInstruction::StakeTokens(decoded),
121 accounts: instruction.accounts.clone(),
122 });
123 }
124 }
125 {
126 if let Some(decoded) = unstake_tokens::UnstakeTokens::decode(data) {
127 return Some(carbon_core::instruction::DecodedInstruction {
128 program_id: instruction.program_id,
129 data: AtlasStakingInstruction::UnstakeTokens(decoded),
130 accounts: instruction.accounts.clone(),
131 });
132 }
133 }
134 {
135 if let Some(decoded) = update_cooldown_period::UpdateCooldownPeriod::decode(data) {
136 return Some(carbon_core::instruction::DecodedInstruction {
137 program_id: instruction.program_id,
138 data: AtlasStakingInstruction::UpdateCooldownPeriod(decoded),
139 accounts: instruction.accounts.clone(),
140 });
141 }
142 }
143 {
144 if let Some(decoded) = update_reward_multiplier::UpdateRewardMultiplier::decode(data) {
145 return Some(carbon_core::instruction::DecodedInstruction {
146 program_id: instruction.program_id,
147 data: AtlasStakingInstruction::UpdateRewardMultiplier(decoded),
148 accounts: instruction.accounts.clone(),
149 });
150 }
151 }
152 {
153 if let Some(decoded) = withdraw_tokens::WithdrawTokens::decode(data) {
154 return Some(carbon_core::instruction::DecodedInstruction {
155 program_id: instruction.program_id,
156 data: AtlasStakingInstruction::WithdrawTokens(decoded),
157 accounts: instruction.accounts.clone(),
158 });
159 }
160 }
161
162 None
163 }
164}