defituna_client/generated/instructions/
set_suspended_state.rs

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