Skip to main content

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