defituna_client/generated/instructions/
repay_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
11/// Accounts.
12#[derive(Debug)]
13pub struct RepayDebt {
14            /// 
15/// TUNA accounts
16/// 
17
18    
19              
20          pub authority: solana_program::pubkey::Pubkey,
21          
22              
23          pub mint_a: solana_program::pubkey::Pubkey,
24          
25              
26          pub mint_b: solana_program::pubkey::Pubkey,
27          
28              
29          pub market: solana_program::pubkey::Pubkey,
30          
31              
32          pub vault_a: solana_program::pubkey::Pubkey,
33          
34              
35          pub vault_b: solana_program::pubkey::Pubkey,
36          
37              
38          pub vault_a_ata: solana_program::pubkey::Pubkey,
39          
40              
41          pub vault_b_ata: solana_program::pubkey::Pubkey,
42          
43              
44          pub tuna_position: solana_program::pubkey::Pubkey,
45          
46              
47          pub tuna_position_ata_a: solana_program::pubkey::Pubkey,
48          
49              
50          pub tuna_position_ata_b: solana_program::pubkey::Pubkey,
51          
52              
53          pub tuna_position_owner_ata_a: solana_program::pubkey::Pubkey,
54          
55              
56          pub tuna_position_owner_ata_b: solana_program::pubkey::Pubkey,
57                /// 
58/// Other accounts
59/// 
60
61    
62              
63          pub token_program_a: solana_program::pubkey::Pubkey,
64          
65              
66          pub token_program_b: solana_program::pubkey::Pubkey,
67          
68              
69          pub memo_program: solana_program::pubkey::Pubkey,
70      }
71
72impl RepayDebt {
73  pub fn instruction(&self, args: RepayDebtInstructionArgs) -> solana_program::instruction::Instruction {
74    self.instruction_with_remaining_accounts(args, &[])
75  }
76  #[allow(clippy::arithmetic_side_effects)]
77  #[allow(clippy::vec_init_then_push)]
78  pub fn instruction_with_remaining_accounts(&self, args: RepayDebtInstructionArgs, remaining_accounts: &[solana_program::instruction::AccountMeta]) -> solana_program::instruction::Instruction {
79    let mut accounts = Vec::with_capacity(16+ remaining_accounts.len());
80                            accounts.push(solana_program::instruction::AccountMeta::new(
81            self.authority,
82            true
83          ));
84                                          accounts.push(solana_program::instruction::AccountMeta::new_readonly(
85            self.mint_a,
86            false
87          ));
88                                          accounts.push(solana_program::instruction::AccountMeta::new_readonly(
89            self.mint_b,
90            false
91          ));
92                                          accounts.push(solana_program::instruction::AccountMeta::new_readonly(
93            self.market,
94            false
95          ));
96                                          accounts.push(solana_program::instruction::AccountMeta::new(
97            self.vault_a,
98            false
99          ));
100                                          accounts.push(solana_program::instruction::AccountMeta::new(
101            self.vault_b,
102            false
103          ));
104                                          accounts.push(solana_program::instruction::AccountMeta::new(
105            self.vault_a_ata,
106            false
107          ));
108                                          accounts.push(solana_program::instruction::AccountMeta::new(
109            self.vault_b_ata,
110            false
111          ));
112                                          accounts.push(solana_program::instruction::AccountMeta::new(
113            self.tuna_position,
114            false
115          ));
116                                          accounts.push(solana_program::instruction::AccountMeta::new(
117            self.tuna_position_ata_a,
118            false
119          ));
120                                          accounts.push(solana_program::instruction::AccountMeta::new(
121            self.tuna_position_ata_b,
122            false
123          ));
124                                          accounts.push(solana_program::instruction::AccountMeta::new(
125            self.tuna_position_owner_ata_a,
126            false
127          ));
128                                          accounts.push(solana_program::instruction::AccountMeta::new(
129            self.tuna_position_owner_ata_b,
130            false
131          ));
132                                          accounts.push(solana_program::instruction::AccountMeta::new_readonly(
133            self.token_program_a,
134            false
135          ));
136                                          accounts.push(solana_program::instruction::AccountMeta::new_readonly(
137            self.token_program_b,
138            false
139          ));
140                                          accounts.push(solana_program::instruction::AccountMeta::new_readonly(
141            self.memo_program,
142            false
143          ));
144                      accounts.extend_from_slice(remaining_accounts);
145    let mut data = borsh::to_vec(&RepayDebtInstructionData::new()).unwrap();
146          let mut args = borsh::to_vec(&args).unwrap();
147      data.append(&mut args);
148    
149    solana_program::instruction::Instruction {
150      program_id: crate::TUNA_ID,
151      accounts,
152      data,
153    }
154  }
155}
156
157#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)]
158#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
159 pub struct RepayDebtInstructionData {
160            discriminator: [u8; 8],
161                  }
162
163impl RepayDebtInstructionData {
164  pub fn new() -> Self {
165    Self {
166                        discriminator: [79, 200, 30, 15, 252, 22, 162, 8],
167                                              }
168  }
169}
170
171impl Default for RepayDebtInstructionData {
172  fn default() -> Self {
173    Self::new()
174  }
175}
176
177#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)]
178#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
179 pub struct RepayDebtInstructionArgs {
180                  pub collateral_funds_a: u64,
181                pub collateral_funds_b: u64,
182      }
183
184
185/// Instruction builder for `RepayDebt`.
186///
187/// ### Accounts:
188///
189                      ///   0. `[writable, signer]` authority
190          ///   1. `[]` mint_a
191          ///   2. `[]` mint_b
192          ///   3. `[]` market
193                ///   4. `[writable]` vault_a
194                ///   5. `[writable]` vault_b
195                ///   6. `[writable]` vault_a_ata
196                ///   7. `[writable]` vault_b_ata
197                ///   8. `[writable]` tuna_position
198                ///   9. `[writable]` tuna_position_ata_a
199                ///   10. `[writable]` tuna_position_ata_b
200                ///   11. `[writable]` tuna_position_owner_ata_a
201                ///   12. `[writable]` tuna_position_owner_ata_b
202          ///   13. `[]` token_program_a
203          ///   14. `[]` token_program_b
204          ///   15. `[]` memo_program
205#[derive(Clone, Debug, Default)]
206pub struct RepayDebtBuilder {
207            authority: Option<solana_program::pubkey::Pubkey>,
208                mint_a: Option<solana_program::pubkey::Pubkey>,
209                mint_b: Option<solana_program::pubkey::Pubkey>,
210                market: Option<solana_program::pubkey::Pubkey>,
211                vault_a: Option<solana_program::pubkey::Pubkey>,
212                vault_b: Option<solana_program::pubkey::Pubkey>,
213                vault_a_ata: Option<solana_program::pubkey::Pubkey>,
214                vault_b_ata: Option<solana_program::pubkey::Pubkey>,
215                tuna_position: Option<solana_program::pubkey::Pubkey>,
216                tuna_position_ata_a: Option<solana_program::pubkey::Pubkey>,
217                tuna_position_ata_b: Option<solana_program::pubkey::Pubkey>,
218                tuna_position_owner_ata_a: Option<solana_program::pubkey::Pubkey>,
219                tuna_position_owner_ata_b: Option<solana_program::pubkey::Pubkey>,
220                token_program_a: Option<solana_program::pubkey::Pubkey>,
221                token_program_b: Option<solana_program::pubkey::Pubkey>,
222                memo_program: Option<solana_program::pubkey::Pubkey>,
223                        collateral_funds_a: Option<u64>,
224                collateral_funds_b: Option<u64>,
225        __remaining_accounts: Vec<solana_program::instruction::AccountMeta>,
226}
227
228impl RepayDebtBuilder {
229  pub fn new() -> Self {
230    Self::default()
231  }
232            /// 
233/// TUNA accounts
234/// 
235#[inline(always)]
236    pub fn authority(&mut self, authority: solana_program::pubkey::Pubkey) -> &mut Self {
237                        self.authority = Some(authority);
238                    self
239    }
240            #[inline(always)]
241    pub fn mint_a(&mut self, mint_a: solana_program::pubkey::Pubkey) -> &mut Self {
242                        self.mint_a = Some(mint_a);
243                    self
244    }
245            #[inline(always)]
246    pub fn mint_b(&mut self, mint_b: solana_program::pubkey::Pubkey) -> &mut Self {
247                        self.mint_b = Some(mint_b);
248                    self
249    }
250            #[inline(always)]
251    pub fn market(&mut self, market: solana_program::pubkey::Pubkey) -> &mut Self {
252                        self.market = Some(market);
253                    self
254    }
255            #[inline(always)]
256    pub fn vault_a(&mut self, vault_a: solana_program::pubkey::Pubkey) -> &mut Self {
257                        self.vault_a = Some(vault_a);
258                    self
259    }
260            #[inline(always)]
261    pub fn vault_b(&mut self, vault_b: solana_program::pubkey::Pubkey) -> &mut Self {
262                        self.vault_b = Some(vault_b);
263                    self
264    }
265            #[inline(always)]
266    pub fn vault_a_ata(&mut self, vault_a_ata: solana_program::pubkey::Pubkey) -> &mut Self {
267                        self.vault_a_ata = Some(vault_a_ata);
268                    self
269    }
270            #[inline(always)]
271    pub fn vault_b_ata(&mut self, vault_b_ata: solana_program::pubkey::Pubkey) -> &mut Self {
272                        self.vault_b_ata = Some(vault_b_ata);
273                    self
274    }
275            #[inline(always)]
276    pub fn tuna_position(&mut self, tuna_position: solana_program::pubkey::Pubkey) -> &mut Self {
277                        self.tuna_position = Some(tuna_position);
278                    self
279    }
280            #[inline(always)]
281    pub fn tuna_position_ata_a(&mut self, tuna_position_ata_a: solana_program::pubkey::Pubkey) -> &mut Self {
282                        self.tuna_position_ata_a = Some(tuna_position_ata_a);
283                    self
284    }
285            #[inline(always)]
286    pub fn tuna_position_ata_b(&mut self, tuna_position_ata_b: solana_program::pubkey::Pubkey) -> &mut Self {
287                        self.tuna_position_ata_b = Some(tuna_position_ata_b);
288                    self
289    }
290            #[inline(always)]
291    pub fn tuna_position_owner_ata_a(&mut self, tuna_position_owner_ata_a: solana_program::pubkey::Pubkey) -> &mut Self {
292                        self.tuna_position_owner_ata_a = Some(tuna_position_owner_ata_a);
293                    self
294    }
295            #[inline(always)]
296    pub fn tuna_position_owner_ata_b(&mut self, tuna_position_owner_ata_b: solana_program::pubkey::Pubkey) -> &mut Self {
297                        self.tuna_position_owner_ata_b = Some(tuna_position_owner_ata_b);
298                    self
299    }
300            /// 
301/// Other accounts
302/// 
303#[inline(always)]
304    pub fn token_program_a(&mut self, token_program_a: solana_program::pubkey::Pubkey) -> &mut Self {
305                        self.token_program_a = Some(token_program_a);
306                    self
307    }
308            #[inline(always)]
309    pub fn token_program_b(&mut self, token_program_b: solana_program::pubkey::Pubkey) -> &mut Self {
310                        self.token_program_b = Some(token_program_b);
311                    self
312    }
313            #[inline(always)]
314    pub fn memo_program(&mut self, memo_program: solana_program::pubkey::Pubkey) -> &mut Self {
315                        self.memo_program = Some(memo_program);
316                    self
317    }
318                    #[inline(always)]
319      pub fn collateral_funds_a(&mut self, collateral_funds_a: u64) -> &mut Self {
320        self.collateral_funds_a = Some(collateral_funds_a);
321        self
322      }
323                #[inline(always)]
324      pub fn collateral_funds_b(&mut self, collateral_funds_b: u64) -> &mut Self {
325        self.collateral_funds_b = Some(collateral_funds_b);
326        self
327      }
328        /// Add an additional account to the instruction.
329  #[inline(always)]
330  pub fn add_remaining_account(&mut self, account: solana_program::instruction::AccountMeta) -> &mut Self {
331    self.__remaining_accounts.push(account);
332    self
333  }
334  /// Add additional accounts to the instruction.
335  #[inline(always)]
336  pub fn add_remaining_accounts(&mut self, accounts: &[solana_program::instruction::AccountMeta]) -> &mut Self {
337    self.__remaining_accounts.extend_from_slice(accounts);
338    self
339  }
340  #[allow(clippy::clone_on_copy)]
341  pub fn instruction(&self) -> solana_program::instruction::Instruction {
342    let accounts = RepayDebt {
343                              authority: self.authority.expect("authority is not set"),
344                                        mint_a: self.mint_a.expect("mint_a is not set"),
345                                        mint_b: self.mint_b.expect("mint_b is not set"),
346                                        market: self.market.expect("market is not set"),
347                                        vault_a: self.vault_a.expect("vault_a is not set"),
348                                        vault_b: self.vault_b.expect("vault_b is not set"),
349                                        vault_a_ata: self.vault_a_ata.expect("vault_a_ata is not set"),
350                                        vault_b_ata: self.vault_b_ata.expect("vault_b_ata is not set"),
351                                        tuna_position: self.tuna_position.expect("tuna_position is not set"),
352                                        tuna_position_ata_a: self.tuna_position_ata_a.expect("tuna_position_ata_a is not set"),
353                                        tuna_position_ata_b: self.tuna_position_ata_b.expect("tuna_position_ata_b is not set"),
354                                        tuna_position_owner_ata_a: self.tuna_position_owner_ata_a.expect("tuna_position_owner_ata_a is not set"),
355                                        tuna_position_owner_ata_b: self.tuna_position_owner_ata_b.expect("tuna_position_owner_ata_b is not set"),
356                                        token_program_a: self.token_program_a.expect("token_program_a is not set"),
357                                        token_program_b: self.token_program_b.expect("token_program_b is not set"),
358                                        memo_program: self.memo_program.expect("memo_program is not set"),
359                      };
360          let args = RepayDebtInstructionArgs {
361                                                              collateral_funds_a: self.collateral_funds_a.clone().expect("collateral_funds_a is not set"),
362                                                                  collateral_funds_b: self.collateral_funds_b.clone().expect("collateral_funds_b is not set"),
363                                    };
364    
365    accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts)
366  }
367}
368
369  /// `repay_debt` CPI accounts.
370  pub struct RepayDebtCpiAccounts<'a, 'b> {
371                  /// 
372/// TUNA accounts
373/// 
374
375      
376                    
377              pub authority: &'b solana_program::account_info::AccountInfo<'a>,
378                
379                    
380              pub mint_a: &'b solana_program::account_info::AccountInfo<'a>,
381                
382                    
383              pub mint_b: &'b solana_program::account_info::AccountInfo<'a>,
384                
385                    
386              pub market: &'b solana_program::account_info::AccountInfo<'a>,
387                
388                    
389              pub vault_a: &'b solana_program::account_info::AccountInfo<'a>,
390                
391                    
392              pub vault_b: &'b solana_program::account_info::AccountInfo<'a>,
393                
394                    
395              pub vault_a_ata: &'b solana_program::account_info::AccountInfo<'a>,
396                
397                    
398              pub vault_b_ata: &'b solana_program::account_info::AccountInfo<'a>,
399                
400                    
401              pub tuna_position: &'b solana_program::account_info::AccountInfo<'a>,
402                
403                    
404              pub tuna_position_ata_a: &'b solana_program::account_info::AccountInfo<'a>,
405                
406                    
407              pub tuna_position_ata_b: &'b solana_program::account_info::AccountInfo<'a>,
408                
409                    
410              pub tuna_position_owner_ata_a: &'b solana_program::account_info::AccountInfo<'a>,
411                
412                    
413              pub tuna_position_owner_ata_b: &'b solana_program::account_info::AccountInfo<'a>,
414                        /// 
415/// Other accounts
416/// 
417
418      
419                    
420              pub token_program_a: &'b solana_program::account_info::AccountInfo<'a>,
421                
422                    
423              pub token_program_b: &'b solana_program::account_info::AccountInfo<'a>,
424                
425                    
426              pub memo_program: &'b solana_program::account_info::AccountInfo<'a>,
427            }
428
429/// `repay_debt` CPI instruction.
430pub struct RepayDebtCpi<'a, 'b> {
431  /// The program to invoke.
432  pub __program: &'b solana_program::account_info::AccountInfo<'a>,
433            /// 
434/// TUNA accounts
435/// 
436
437    
438              
439          pub authority: &'b solana_program::account_info::AccountInfo<'a>,
440          
441              
442          pub mint_a: &'b solana_program::account_info::AccountInfo<'a>,
443          
444              
445          pub mint_b: &'b solana_program::account_info::AccountInfo<'a>,
446          
447              
448          pub market: &'b solana_program::account_info::AccountInfo<'a>,
449          
450              
451          pub vault_a: &'b solana_program::account_info::AccountInfo<'a>,
452          
453              
454          pub vault_b: &'b solana_program::account_info::AccountInfo<'a>,
455          
456              
457          pub vault_a_ata: &'b solana_program::account_info::AccountInfo<'a>,
458          
459              
460          pub vault_b_ata: &'b solana_program::account_info::AccountInfo<'a>,
461          
462              
463          pub tuna_position: &'b solana_program::account_info::AccountInfo<'a>,
464          
465              
466          pub tuna_position_ata_a: &'b solana_program::account_info::AccountInfo<'a>,
467          
468              
469          pub tuna_position_ata_b: &'b solana_program::account_info::AccountInfo<'a>,
470          
471              
472          pub tuna_position_owner_ata_a: &'b solana_program::account_info::AccountInfo<'a>,
473          
474              
475          pub tuna_position_owner_ata_b: &'b solana_program::account_info::AccountInfo<'a>,
476                /// 
477/// Other accounts
478/// 
479
480    
481              
482          pub token_program_a: &'b solana_program::account_info::AccountInfo<'a>,
483          
484              
485          pub token_program_b: &'b solana_program::account_info::AccountInfo<'a>,
486          
487              
488          pub memo_program: &'b solana_program::account_info::AccountInfo<'a>,
489            /// The arguments for the instruction.
490    pub __args: RepayDebtInstructionArgs,
491  }
492
493impl<'a, 'b> RepayDebtCpi<'a, 'b> {
494  pub fn new(
495    program: &'b solana_program::account_info::AccountInfo<'a>,
496          accounts: RepayDebtCpiAccounts<'a, 'b>,
497              args: RepayDebtInstructionArgs,
498      ) -> Self {
499    Self {
500      __program: program,
501              authority: accounts.authority,
502              mint_a: accounts.mint_a,
503              mint_b: accounts.mint_b,
504              market: accounts.market,
505              vault_a: accounts.vault_a,
506              vault_b: accounts.vault_b,
507              vault_a_ata: accounts.vault_a_ata,
508              vault_b_ata: accounts.vault_b_ata,
509              tuna_position: accounts.tuna_position,
510              tuna_position_ata_a: accounts.tuna_position_ata_a,
511              tuna_position_ata_b: accounts.tuna_position_ata_b,
512              tuna_position_owner_ata_a: accounts.tuna_position_owner_ata_a,
513              tuna_position_owner_ata_b: accounts.tuna_position_owner_ata_b,
514              token_program_a: accounts.token_program_a,
515              token_program_b: accounts.token_program_b,
516              memo_program: accounts.memo_program,
517                    __args: args,
518          }
519  }
520  #[inline(always)]
521  pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult {
522    self.invoke_signed_with_remaining_accounts(&[], &[])
523  }
524  #[inline(always)]
525  pub fn invoke_with_remaining_accounts(&self, remaining_accounts: &[(&'b solana_program::account_info::AccountInfo<'a>, bool, bool)]) -> solana_program::entrypoint::ProgramResult {
526    self.invoke_signed_with_remaining_accounts(&[], remaining_accounts)
527  }
528  #[inline(always)]
529  pub fn invoke_signed(&self, signers_seeds: &[&[&[u8]]]) -> solana_program::entrypoint::ProgramResult {
530    self.invoke_signed_with_remaining_accounts(signers_seeds, &[])
531  }
532  #[allow(clippy::arithmetic_side_effects)]
533  #[allow(clippy::clone_on_copy)]
534  #[allow(clippy::vec_init_then_push)]
535  pub fn invoke_signed_with_remaining_accounts(
536    &self,
537    signers_seeds: &[&[&[u8]]],
538    remaining_accounts: &[(&'b solana_program::account_info::AccountInfo<'a>, bool, bool)]
539  ) -> solana_program::entrypoint::ProgramResult {
540    let mut accounts = Vec::with_capacity(16+ remaining_accounts.len());
541                            accounts.push(solana_program::instruction::AccountMeta::new(
542            *self.authority.key,
543            true
544          ));
545                                          accounts.push(solana_program::instruction::AccountMeta::new_readonly(
546            *self.mint_a.key,
547            false
548          ));
549                                          accounts.push(solana_program::instruction::AccountMeta::new_readonly(
550            *self.mint_b.key,
551            false
552          ));
553                                          accounts.push(solana_program::instruction::AccountMeta::new_readonly(
554            *self.market.key,
555            false
556          ));
557                                          accounts.push(solana_program::instruction::AccountMeta::new(
558            *self.vault_a.key,
559            false
560          ));
561                                          accounts.push(solana_program::instruction::AccountMeta::new(
562            *self.vault_b.key,
563            false
564          ));
565                                          accounts.push(solana_program::instruction::AccountMeta::new(
566            *self.vault_a_ata.key,
567            false
568          ));
569                                          accounts.push(solana_program::instruction::AccountMeta::new(
570            *self.vault_b_ata.key,
571            false
572          ));
573                                          accounts.push(solana_program::instruction::AccountMeta::new(
574            *self.tuna_position.key,
575            false
576          ));
577                                          accounts.push(solana_program::instruction::AccountMeta::new(
578            *self.tuna_position_ata_a.key,
579            false
580          ));
581                                          accounts.push(solana_program::instruction::AccountMeta::new(
582            *self.tuna_position_ata_b.key,
583            false
584          ));
585                                          accounts.push(solana_program::instruction::AccountMeta::new(
586            *self.tuna_position_owner_ata_a.key,
587            false
588          ));
589                                          accounts.push(solana_program::instruction::AccountMeta::new(
590            *self.tuna_position_owner_ata_b.key,
591            false
592          ));
593                                          accounts.push(solana_program::instruction::AccountMeta::new_readonly(
594            *self.token_program_a.key,
595            false
596          ));
597                                          accounts.push(solana_program::instruction::AccountMeta::new_readonly(
598            *self.token_program_b.key,
599            false
600          ));
601                                          accounts.push(solana_program::instruction::AccountMeta::new_readonly(
602            *self.memo_program.key,
603            false
604          ));
605                      remaining_accounts.iter().for_each(|remaining_account| {
606      accounts.push(solana_program::instruction::AccountMeta {
607          pubkey: *remaining_account.0.key,
608          is_signer: remaining_account.1,
609          is_writable: remaining_account.2,
610      })
611    });
612    let mut data = borsh::to_vec(&RepayDebtInstructionData::new()).unwrap();
613          let mut args = borsh::to_vec(&self.__args).unwrap();
614      data.append(&mut args);
615    
616    let instruction = solana_program::instruction::Instruction {
617      program_id: crate::TUNA_ID,
618      accounts,
619      data,
620    };
621    let mut account_infos = Vec::with_capacity(17 + remaining_accounts.len());
622    account_infos.push(self.__program.clone());
623                  account_infos.push(self.authority.clone());
624                        account_infos.push(self.mint_a.clone());
625                        account_infos.push(self.mint_b.clone());
626                        account_infos.push(self.market.clone());
627                        account_infos.push(self.vault_a.clone());
628                        account_infos.push(self.vault_b.clone());
629                        account_infos.push(self.vault_a_ata.clone());
630                        account_infos.push(self.vault_b_ata.clone());
631                        account_infos.push(self.tuna_position.clone());
632                        account_infos.push(self.tuna_position_ata_a.clone());
633                        account_infos.push(self.tuna_position_ata_b.clone());
634                        account_infos.push(self.tuna_position_owner_ata_a.clone());
635                        account_infos.push(self.tuna_position_owner_ata_b.clone());
636                        account_infos.push(self.token_program_a.clone());
637                        account_infos.push(self.token_program_b.clone());
638                        account_infos.push(self.memo_program.clone());
639              remaining_accounts.iter().for_each(|remaining_account| account_infos.push(remaining_account.0.clone()));
640
641    if signers_seeds.is_empty() {
642      solana_program::program::invoke(&instruction, &account_infos)
643    } else {
644      solana_program::program::invoke_signed(&instruction, &account_infos, signers_seeds)
645    }
646  }
647}
648
649/// Instruction builder for `RepayDebt` via CPI.
650///
651/// ### Accounts:
652///
653                      ///   0. `[writable, signer]` authority
654          ///   1. `[]` mint_a
655          ///   2. `[]` mint_b
656          ///   3. `[]` market
657                ///   4. `[writable]` vault_a
658                ///   5. `[writable]` vault_b
659                ///   6. `[writable]` vault_a_ata
660                ///   7. `[writable]` vault_b_ata
661                ///   8. `[writable]` tuna_position
662                ///   9. `[writable]` tuna_position_ata_a
663                ///   10. `[writable]` tuna_position_ata_b
664                ///   11. `[writable]` tuna_position_owner_ata_a
665                ///   12. `[writable]` tuna_position_owner_ata_b
666          ///   13. `[]` token_program_a
667          ///   14. `[]` token_program_b
668          ///   15. `[]` memo_program
669#[derive(Clone, Debug)]
670pub struct RepayDebtCpiBuilder<'a, 'b> {
671  instruction: Box<RepayDebtCpiBuilderInstruction<'a, 'b>>,
672}
673
674impl<'a, 'b> RepayDebtCpiBuilder<'a, 'b> {
675  pub fn new(program: &'b solana_program::account_info::AccountInfo<'a>) -> Self {
676    let instruction = Box::new(RepayDebtCpiBuilderInstruction {
677      __program: program,
678              authority: None,
679              mint_a: None,
680              mint_b: None,
681              market: None,
682              vault_a: None,
683              vault_b: None,
684              vault_a_ata: None,
685              vault_b_ata: None,
686              tuna_position: None,
687              tuna_position_ata_a: None,
688              tuna_position_ata_b: None,
689              tuna_position_owner_ata_a: None,
690              tuna_position_owner_ata_b: None,
691              token_program_a: None,
692              token_program_b: None,
693              memo_program: None,
694                                            collateral_funds_a: None,
695                                collateral_funds_b: None,
696                    __remaining_accounts: Vec::new(),
697    });
698    Self { instruction }
699  }
700      /// 
701/// TUNA accounts
702/// 
703#[inline(always)]
704    pub fn authority(&mut self, authority: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self {
705                        self.instruction.authority = Some(authority);
706                    self
707    }
708      #[inline(always)]
709    pub fn mint_a(&mut self, mint_a: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self {
710                        self.instruction.mint_a = Some(mint_a);
711                    self
712    }
713      #[inline(always)]
714    pub fn mint_b(&mut self, mint_b: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self {
715                        self.instruction.mint_b = Some(mint_b);
716                    self
717    }
718      #[inline(always)]
719    pub fn market(&mut self, market: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self {
720                        self.instruction.market = Some(market);
721                    self
722    }
723      #[inline(always)]
724    pub fn vault_a(&mut self, vault_a: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self {
725                        self.instruction.vault_a = Some(vault_a);
726                    self
727    }
728      #[inline(always)]
729    pub fn vault_b(&mut self, vault_b: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self {
730                        self.instruction.vault_b = Some(vault_b);
731                    self
732    }
733      #[inline(always)]
734    pub fn vault_a_ata(&mut self, vault_a_ata: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self {
735                        self.instruction.vault_a_ata = Some(vault_a_ata);
736                    self
737    }
738      #[inline(always)]
739    pub fn vault_b_ata(&mut self, vault_b_ata: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self {
740                        self.instruction.vault_b_ata = Some(vault_b_ata);
741                    self
742    }
743      #[inline(always)]
744    pub fn tuna_position(&mut self, tuna_position: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self {
745                        self.instruction.tuna_position = Some(tuna_position);
746                    self
747    }
748      #[inline(always)]
749    pub fn tuna_position_ata_a(&mut self, tuna_position_ata_a: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self {
750                        self.instruction.tuna_position_ata_a = Some(tuna_position_ata_a);
751                    self
752    }
753      #[inline(always)]
754    pub fn tuna_position_ata_b(&mut self, tuna_position_ata_b: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self {
755                        self.instruction.tuna_position_ata_b = Some(tuna_position_ata_b);
756                    self
757    }
758      #[inline(always)]
759    pub fn tuna_position_owner_ata_a(&mut self, tuna_position_owner_ata_a: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self {
760                        self.instruction.tuna_position_owner_ata_a = Some(tuna_position_owner_ata_a);
761                    self
762    }
763      #[inline(always)]
764    pub fn tuna_position_owner_ata_b(&mut self, tuna_position_owner_ata_b: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self {
765                        self.instruction.tuna_position_owner_ata_b = Some(tuna_position_owner_ata_b);
766                    self
767    }
768      /// 
769/// Other accounts
770/// 
771#[inline(always)]
772    pub fn token_program_a(&mut self, token_program_a: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self {
773                        self.instruction.token_program_a = Some(token_program_a);
774                    self
775    }
776      #[inline(always)]
777    pub fn token_program_b(&mut self, token_program_b: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self {
778                        self.instruction.token_program_b = Some(token_program_b);
779                    self
780    }
781      #[inline(always)]
782    pub fn memo_program(&mut self, memo_program: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self {
783                        self.instruction.memo_program = Some(memo_program);
784                    self
785    }
786                    #[inline(always)]
787      pub fn collateral_funds_a(&mut self, collateral_funds_a: u64) -> &mut Self {
788        self.instruction.collateral_funds_a = Some(collateral_funds_a);
789        self
790      }
791                #[inline(always)]
792      pub fn collateral_funds_b(&mut self, collateral_funds_b: u64) -> &mut Self {
793        self.instruction.collateral_funds_b = Some(collateral_funds_b);
794        self
795      }
796        /// Add an additional account to the instruction.
797  #[inline(always)]
798  pub fn add_remaining_account(&mut self, account: &'b solana_program::account_info::AccountInfo<'a>, is_writable: bool, is_signer: bool) -> &mut Self {
799    self.instruction.__remaining_accounts.push((account, is_writable, is_signer));
800    self
801  }
802  /// Add additional accounts to the instruction.
803  ///
804  /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not,
805  /// and a `bool` indicating whether the account is a signer or not.
806  #[inline(always)]
807  pub fn add_remaining_accounts(&mut self, accounts: &[(&'b solana_program::account_info::AccountInfo<'a>, bool, bool)]) -> &mut Self {
808    self.instruction.__remaining_accounts.extend_from_slice(accounts);
809    self
810  }
811  #[inline(always)]
812  pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult {
813    self.invoke_signed(&[])
814  }
815  #[allow(clippy::clone_on_copy)]
816  #[allow(clippy::vec_init_then_push)]
817  pub fn invoke_signed(&self, signers_seeds: &[&[&[u8]]]) -> solana_program::entrypoint::ProgramResult {
818          let args = RepayDebtInstructionArgs {
819                                                              collateral_funds_a: self.instruction.collateral_funds_a.clone().expect("collateral_funds_a is not set"),
820                                                                  collateral_funds_b: self.instruction.collateral_funds_b.clone().expect("collateral_funds_b is not set"),
821                                    };
822        let instruction = RepayDebtCpi {
823        __program: self.instruction.__program,
824                  
825          authority: self.instruction.authority.expect("authority is not set"),
826                  
827          mint_a: self.instruction.mint_a.expect("mint_a is not set"),
828                  
829          mint_b: self.instruction.mint_b.expect("mint_b is not set"),
830                  
831          market: self.instruction.market.expect("market is not set"),
832                  
833          vault_a: self.instruction.vault_a.expect("vault_a is not set"),
834                  
835          vault_b: self.instruction.vault_b.expect("vault_b is not set"),
836                  
837          vault_a_ata: self.instruction.vault_a_ata.expect("vault_a_ata is not set"),
838                  
839          vault_b_ata: self.instruction.vault_b_ata.expect("vault_b_ata is not set"),
840                  
841          tuna_position: self.instruction.tuna_position.expect("tuna_position is not set"),
842                  
843          tuna_position_ata_a: self.instruction.tuna_position_ata_a.expect("tuna_position_ata_a is not set"),
844                  
845          tuna_position_ata_b: self.instruction.tuna_position_ata_b.expect("tuna_position_ata_b is not set"),
846                  
847          tuna_position_owner_ata_a: self.instruction.tuna_position_owner_ata_a.expect("tuna_position_owner_ata_a is not set"),
848                  
849          tuna_position_owner_ata_b: self.instruction.tuna_position_owner_ata_b.expect("tuna_position_owner_ata_b is not set"),
850                  
851          token_program_a: self.instruction.token_program_a.expect("token_program_a is not set"),
852                  
853          token_program_b: self.instruction.token_program_b.expect("token_program_b is not set"),
854                  
855          memo_program: self.instruction.memo_program.expect("memo_program is not set"),
856                          __args: args,
857            };
858    instruction.invoke_signed_with_remaining_accounts(signers_seeds, &self.instruction.__remaining_accounts)
859  }
860}
861
862#[derive(Clone, Debug)]
863struct RepayDebtCpiBuilderInstruction<'a, 'b> {
864  __program: &'b solana_program::account_info::AccountInfo<'a>,
865            authority: Option<&'b solana_program::account_info::AccountInfo<'a>>,
866                mint_a: Option<&'b solana_program::account_info::AccountInfo<'a>>,
867                mint_b: Option<&'b solana_program::account_info::AccountInfo<'a>>,
868                market: Option<&'b solana_program::account_info::AccountInfo<'a>>,
869                vault_a: Option<&'b solana_program::account_info::AccountInfo<'a>>,
870                vault_b: Option<&'b solana_program::account_info::AccountInfo<'a>>,
871                vault_a_ata: Option<&'b solana_program::account_info::AccountInfo<'a>>,
872                vault_b_ata: Option<&'b solana_program::account_info::AccountInfo<'a>>,
873                tuna_position: Option<&'b solana_program::account_info::AccountInfo<'a>>,
874                tuna_position_ata_a: Option<&'b solana_program::account_info::AccountInfo<'a>>,
875                tuna_position_ata_b: Option<&'b solana_program::account_info::AccountInfo<'a>>,
876                tuna_position_owner_ata_a: Option<&'b solana_program::account_info::AccountInfo<'a>>,
877                tuna_position_owner_ata_b: Option<&'b solana_program::account_info::AccountInfo<'a>>,
878                token_program_a: Option<&'b solana_program::account_info::AccountInfo<'a>>,
879                token_program_b: Option<&'b solana_program::account_info::AccountInfo<'a>>,
880                memo_program: Option<&'b solana_program::account_info::AccountInfo<'a>>,
881                        collateral_funds_a: Option<u64>,
882                collateral_funds_b: Option<u64>,
883        /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`.
884  __remaining_accounts: Vec<(&'b solana_program::account_info::AccountInfo<'a>, bool, bool)>,
885}
886