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