defituna_client/generated/instructions/
set_suspended_state.rs1use borsh::BorshSerialize;
9use borsh::BorshDeserialize;
10
11#[derive(Debug)]
13pub struct SetSuspendedState {
14
15
16 pub authority: solana_program::pubkey::Pubkey,
17
18
19 pub tuna_config: solana_program::pubkey::Pubkey,
20 }
21
22impl SetSuspendedState {
23 pub fn instruction(&self, args: SetSuspendedStateInstructionArgs) -> solana_program::instruction::Instruction {
24 self.instruction_with_remaining_accounts(args, &[])
25 }
26 #[allow(clippy::arithmetic_side_effects)]
27 #[allow(clippy::vec_init_then_push)]
28 pub fn instruction_with_remaining_accounts(&self, args: SetSuspendedStateInstructionArgs, remaining_accounts: &[solana_program::instruction::AccountMeta]) -> solana_program::instruction::Instruction {
29 let mut accounts = Vec::with_capacity(2+ remaining_accounts.len());
30 accounts.push(solana_program::instruction::AccountMeta::new(
31 self.authority,
32 true
33 ));
34 accounts.push(solana_program::instruction::AccountMeta::new(
35 self.tuna_config,
36 false
37 ));
38 accounts.extend_from_slice(remaining_accounts);
39 let mut data = borsh::to_vec(&SetSuspendedStateInstructionData::new()).unwrap();
40 let mut args = borsh::to_vec(&args).unwrap();
41 data.append(&mut args);
42
43 solana_program::instruction::Instruction {
44 program_id: crate::TUNA_ID,
45 accounts,
46 data,
47 }
48 }
49}
50
51#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)]
52#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
53 pub struct SetSuspendedStateInstructionData {
54 discriminator: [u8; 8],
55 }
56
57impl SetSuspendedStateInstructionData {
58 pub fn new() -> Self {
59 Self {
60 discriminator: [145, 13, 20, 161, 30, 62, 226, 32],
61 }
62 }
63}
64
65impl Default for SetSuspendedStateInstructionData {
66 fn default() -> Self {
67 Self::new()
68 }
69}
70
71#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)]
72#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
73 pub struct SetSuspendedStateInstructionArgs {
74 pub suspend_lending_deposits: bool,
75 pub suspend_lending_withdrawals: bool,
76 pub suspend_add_liquidity: bool,
77 pub suspend_remove_liquidity: bool,
78 }
79
80
81#[derive(Clone, Debug, Default)]
88pub struct SetSuspendedStateBuilder {
89 authority: Option<solana_program::pubkey::Pubkey>,
90 tuna_config: Option<solana_program::pubkey::Pubkey>,
91 suspend_lending_deposits: Option<bool>,
92 suspend_lending_withdrawals: Option<bool>,
93 suspend_add_liquidity: Option<bool>,
94 suspend_remove_liquidity: Option<bool>,
95 __remaining_accounts: Vec<solana_program::instruction::AccountMeta>,
96}
97
98impl SetSuspendedStateBuilder {
99 pub fn new() -> Self {
100 Self::default()
101 }
102 #[inline(always)]
103 pub fn authority(&mut self, authority: solana_program::pubkey::Pubkey) -> &mut Self {
104 self.authority = Some(authority);
105 self
106 }
107 #[inline(always)]
108 pub fn tuna_config(&mut self, tuna_config: solana_program::pubkey::Pubkey) -> &mut Self {
109 self.tuna_config = Some(tuna_config);
110 self
111 }
112 #[inline(always)]
113 pub fn suspend_lending_deposits(&mut self, suspend_lending_deposits: bool) -> &mut Self {
114 self.suspend_lending_deposits = Some(suspend_lending_deposits);
115 self
116 }
117 #[inline(always)]
118 pub fn suspend_lending_withdrawals(&mut self, suspend_lending_withdrawals: bool) -> &mut Self {
119 self.suspend_lending_withdrawals = Some(suspend_lending_withdrawals);
120 self
121 }
122 #[inline(always)]
123 pub fn suspend_add_liquidity(&mut self, suspend_add_liquidity: bool) -> &mut Self {
124 self.suspend_add_liquidity = Some(suspend_add_liquidity);
125 self
126 }
127 #[inline(always)]
128 pub fn suspend_remove_liquidity(&mut self, suspend_remove_liquidity: bool) -> &mut Self {
129 self.suspend_remove_liquidity = Some(suspend_remove_liquidity);
130 self
131 }
132 #[inline(always)]
134 pub fn add_remaining_account(&mut self, account: solana_program::instruction::AccountMeta) -> &mut Self {
135 self.__remaining_accounts.push(account);
136 self
137 }
138 #[inline(always)]
140 pub fn add_remaining_accounts(&mut self, accounts: &[solana_program::instruction::AccountMeta]) -> &mut Self {
141 self.__remaining_accounts.extend_from_slice(accounts);
142 self
143 }
144 #[allow(clippy::clone_on_copy)]
145 pub fn instruction(&self) -> solana_program::instruction::Instruction {
146 let accounts = SetSuspendedState {
147 authority: self.authority.expect("authority is not set"),
148 tuna_config: self.tuna_config.expect("tuna_config is not set"),
149 };
150 let args = SetSuspendedStateInstructionArgs {
151 suspend_lending_deposits: self.suspend_lending_deposits.clone().expect("suspend_lending_deposits is not set"),
152 suspend_lending_withdrawals: self.suspend_lending_withdrawals.clone().expect("suspend_lending_withdrawals is not set"),
153 suspend_add_liquidity: self.suspend_add_liquidity.clone().expect("suspend_add_liquidity is not set"),
154 suspend_remove_liquidity: self.suspend_remove_liquidity.clone().expect("suspend_remove_liquidity is not set"),
155 };
156
157 accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts)
158 }
159}
160
161 pub struct SetSuspendedStateCpiAccounts<'a, 'b> {
163
164
165 pub authority: &'b solana_program::account_info::AccountInfo<'a>,
166
167
168 pub tuna_config: &'b solana_program::account_info::AccountInfo<'a>,
169 }
170
171pub struct SetSuspendedStateCpi<'a, 'b> {
173 pub __program: &'b solana_program::account_info::AccountInfo<'a>,
175
176
177 pub authority: &'b solana_program::account_info::AccountInfo<'a>,
178
179
180 pub tuna_config: &'b solana_program::account_info::AccountInfo<'a>,
181 pub __args: SetSuspendedStateInstructionArgs,
183 }
184
185impl<'a, 'b> SetSuspendedStateCpi<'a, 'b> {
186 pub fn new(
187 program: &'b solana_program::account_info::AccountInfo<'a>,
188 accounts: SetSuspendedStateCpiAccounts<'a, 'b>,
189 args: SetSuspendedStateInstructionArgs,
190 ) -> Self {
191 Self {
192 __program: program,
193 authority: accounts.authority,
194 tuna_config: accounts.tuna_config,
195 __args: args,
196 }
197 }
198 #[inline(always)]
199 pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult {
200 self.invoke_signed_with_remaining_accounts(&[], &[])
201 }
202 #[inline(always)]
203 pub fn invoke_with_remaining_accounts(&self, remaining_accounts: &[(&'b solana_program::account_info::AccountInfo<'a>, bool, bool)]) -> solana_program::entrypoint::ProgramResult {
204 self.invoke_signed_with_remaining_accounts(&[], remaining_accounts)
205 }
206 #[inline(always)]
207 pub fn invoke_signed(&self, signers_seeds: &[&[&[u8]]]) -> solana_program::entrypoint::ProgramResult {
208 self.invoke_signed_with_remaining_accounts(signers_seeds, &[])
209 }
210 #[allow(clippy::arithmetic_side_effects)]
211 #[allow(clippy::clone_on_copy)]
212 #[allow(clippy::vec_init_then_push)]
213 pub fn invoke_signed_with_remaining_accounts(
214 &self,
215 signers_seeds: &[&[&[u8]]],
216 remaining_accounts: &[(&'b solana_program::account_info::AccountInfo<'a>, bool, bool)]
217 ) -> solana_program::entrypoint::ProgramResult {
218 let mut accounts = Vec::with_capacity(2+ remaining_accounts.len());
219 accounts.push(solana_program::instruction::AccountMeta::new(
220 *self.authority.key,
221 true
222 ));
223 accounts.push(solana_program::instruction::AccountMeta::new(
224 *self.tuna_config.key,
225 false
226 ));
227 remaining_accounts.iter().for_each(|remaining_account| {
228 accounts.push(solana_program::instruction::AccountMeta {
229 pubkey: *remaining_account.0.key,
230 is_signer: remaining_account.1,
231 is_writable: remaining_account.2,
232 })
233 });
234 let mut data = borsh::to_vec(&SetSuspendedStateInstructionData::new()).unwrap();
235 let mut args = borsh::to_vec(&self.__args).unwrap();
236 data.append(&mut args);
237
238 let instruction = solana_program::instruction::Instruction {
239 program_id: crate::TUNA_ID,
240 accounts,
241 data,
242 };
243 let mut account_infos = Vec::with_capacity(3 + remaining_accounts.len());
244 account_infos.push(self.__program.clone());
245 account_infos.push(self.authority.clone());
246 account_infos.push(self.tuna_config.clone());
247 remaining_accounts.iter().for_each(|remaining_account| account_infos.push(remaining_account.0.clone()));
248
249 if signers_seeds.is_empty() {
250 solana_program::program::invoke(&instruction, &account_infos)
251 } else {
252 solana_program::program::invoke_signed(&instruction, &account_infos, signers_seeds)
253 }
254 }
255}
256
257#[derive(Clone, Debug)]
264pub struct SetSuspendedStateCpiBuilder<'a, 'b> {
265 instruction: Box<SetSuspendedStateCpiBuilderInstruction<'a, 'b>>,
266}
267
268impl<'a, 'b> SetSuspendedStateCpiBuilder<'a, 'b> {
269 pub fn new(program: &'b solana_program::account_info::AccountInfo<'a>) -> Self {
270 let instruction = Box::new(SetSuspendedStateCpiBuilderInstruction {
271 __program: program,
272 authority: None,
273 tuna_config: None,
274 suspend_lending_deposits: None,
275 suspend_lending_withdrawals: None,
276 suspend_add_liquidity: None,
277 suspend_remove_liquidity: None,
278 __remaining_accounts: Vec::new(),
279 });
280 Self { instruction }
281 }
282 #[inline(always)]
283 pub fn authority(&mut self, authority: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self {
284 self.instruction.authority = Some(authority);
285 self
286 }
287 #[inline(always)]
288 pub fn tuna_config(&mut self, tuna_config: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self {
289 self.instruction.tuna_config = Some(tuna_config);
290 self
291 }
292 #[inline(always)]
293 pub fn suspend_lending_deposits(&mut self, suspend_lending_deposits: bool) -> &mut Self {
294 self.instruction.suspend_lending_deposits = Some(suspend_lending_deposits);
295 self
296 }
297 #[inline(always)]
298 pub fn suspend_lending_withdrawals(&mut self, suspend_lending_withdrawals: bool) -> &mut Self {
299 self.instruction.suspend_lending_withdrawals = Some(suspend_lending_withdrawals);
300 self
301 }
302 #[inline(always)]
303 pub fn suspend_add_liquidity(&mut self, suspend_add_liquidity: bool) -> &mut Self {
304 self.instruction.suspend_add_liquidity = Some(suspend_add_liquidity);
305 self
306 }
307 #[inline(always)]
308 pub fn suspend_remove_liquidity(&mut self, suspend_remove_liquidity: bool) -> &mut Self {
309 self.instruction.suspend_remove_liquidity = Some(suspend_remove_liquidity);
310 self
311 }
312 #[inline(always)]
314 pub fn add_remaining_account(&mut self, account: &'b solana_program::account_info::AccountInfo<'a>, is_writable: bool, is_signer: bool) -> &mut Self {
315 self.instruction.__remaining_accounts.push((account, is_writable, is_signer));
316 self
317 }
318 #[inline(always)]
323 pub fn add_remaining_accounts(&mut self, accounts: &[(&'b solana_program::account_info::AccountInfo<'a>, bool, bool)]) -> &mut Self {
324 self.instruction.__remaining_accounts.extend_from_slice(accounts);
325 self
326 }
327 #[inline(always)]
328 pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult {
329 self.invoke_signed(&[])
330 }
331 #[allow(clippy::clone_on_copy)]
332 #[allow(clippy::vec_init_then_push)]
333 pub fn invoke_signed(&self, signers_seeds: &[&[&[u8]]]) -> solana_program::entrypoint::ProgramResult {
334 let args = SetSuspendedStateInstructionArgs {
335 suspend_lending_deposits: self.instruction.suspend_lending_deposits.clone().expect("suspend_lending_deposits is not set"),
336 suspend_lending_withdrawals: self.instruction.suspend_lending_withdrawals.clone().expect("suspend_lending_withdrawals is not set"),
337 suspend_add_liquidity: self.instruction.suspend_add_liquidity.clone().expect("suspend_add_liquidity is not set"),
338 suspend_remove_liquidity: self.instruction.suspend_remove_liquidity.clone().expect("suspend_remove_liquidity is not set"),
339 };
340 let instruction = SetSuspendedStateCpi {
341 __program: self.instruction.__program,
342
343 authority: self.instruction.authority.expect("authority is not set"),
344
345 tuna_config: self.instruction.tuna_config.expect("tuna_config is not set"),
346 __args: args,
347 };
348 instruction.invoke_signed_with_remaining_accounts(signers_seeds, &self.instruction.__remaining_accounts)
349 }
350}
351
352#[derive(Clone, Debug)]
353struct SetSuspendedStateCpiBuilderInstruction<'a, 'b> {
354 __program: &'b solana_program::account_info::AccountInfo<'a>,
355 authority: Option<&'b solana_program::account_info::AccountInfo<'a>>,
356 tuna_config: Option<&'b solana_program::account_info::AccountInfo<'a>>,
357 suspend_lending_deposits: Option<bool>,
358 suspend_lending_withdrawals: Option<bool>,
359 suspend_add_liquidity: Option<bool>,
360 suspend_remove_liquidity: Option<bool>,
361 __remaining_accounts: Vec<(&'b solana_program::account_info::AccountInfo<'a>, bool, bool)>,
363}
364