defituna_client/generated/instructions/
open_position_fusion.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 OpenPositionFusion {
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 token_program_a: solana_program::pubkey::Pubkey,
30          
31              
32          pub token_program_b: solana_program::pubkey::Pubkey,
33          
34              
35          pub market: solana_program::pubkey::Pubkey,
36          
37              
38          pub tuna_position: solana_program::pubkey::Pubkey,
39          
40              
41          pub tuna_position_mint: solana_program::pubkey::Pubkey,
42          
43              
44          pub tuna_position_ata: 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/// Fusion AMM accounts
53/// 
54
55    
56              
57          pub fusionamm_program: solana_program::pubkey::Pubkey,
58          
59              
60          pub fusion_pool: solana_program::pubkey::Pubkey,
61          
62              
63          pub fusion_position: solana_program::pubkey::Pubkey,
64          
65              
66          pub metadata_update_auth: 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 OpenPositionFusion {
83  pub fn instruction(&self, args: OpenPositionFusionInstructionArgs) -> 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: OpenPositionFusionInstructionArgs, 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.token_program_a,
104            false
105          ));
106                                          accounts.push(solana_program::instruction::AccountMeta::new_readonly(
107            self.token_program_b,
108            false
109          ));
110                                          accounts.push(solana_program::instruction::AccountMeta::new_readonly(
111            self.market,
112            false
113          ));
114                                          accounts.push(solana_program::instruction::AccountMeta::new(
115            self.tuna_position,
116            false
117          ));
118                                          accounts.push(solana_program::instruction::AccountMeta::new(
119            self.tuna_position_mint,
120            true
121          ));
122                                          accounts.push(solana_program::instruction::AccountMeta::new(
123            self.tuna_position_ata,
124            false
125          ));
126                                          accounts.push(solana_program::instruction::AccountMeta::new(
127            self.tuna_position_ata_a,
128            false
129          ));
130                                          accounts.push(solana_program::instruction::AccountMeta::new(
131            self.tuna_position_ata_b,
132            false
133          ));
134                                          accounts.push(solana_program::instruction::AccountMeta::new_readonly(
135            self.fusionamm_program,
136            false
137          ));
138                                          accounts.push(solana_program::instruction::AccountMeta::new_readonly(
139            self.fusion_pool,
140            false
141          ));
142                                          accounts.push(solana_program::instruction::AccountMeta::new(
143            self.fusion_position,
144            false
145          ));
146                                          accounts.push(solana_program::instruction::AccountMeta::new_readonly(
147            self.metadata_update_auth,
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(&OpenPositionFusionInstructionData::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 OpenPositionFusionInstructionData {
178            discriminator: [u8; 8],
179                                    }
180
181impl OpenPositionFusionInstructionData {
182  pub fn new() -> Self {
183    Self {
184                        discriminator: [78, 68, 77, 41, 132, 42, 34, 238],
185                                                                                        }
186  }
187}
188
189impl Default for OpenPositionFusionInstructionData {
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 OpenPositionFusionInstructionArgs {
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 `OpenPositionFusion`.
207///
208/// ### Accounts:
209///
210                      ///   0. `[writable, signer]` authority
211          ///   1. `[]` mint_a
212          ///   2. `[]` mint_b
213          ///   3. `[]` token_program_a
214          ///   4. `[]` token_program_b
215          ///   5. `[]` market
216                ///   6. `[writable]` tuna_position
217                      ///   7. `[writable, signer]` tuna_position_mint
218                ///   8. `[writable]` tuna_position_ata
219                ///   9. `[writable]` tuna_position_ata_a
220                ///   10. `[writable]` tuna_position_ata_b
221          ///   11. `[]` fusionamm_program
222          ///   12. `[]` fusion_pool
223                ///   13. `[writable]` fusion_position
224          ///   14. `[]` metadata_update_auth
225          ///   15. `[]` token2022_program
226                ///   16. `[optional]` system_program (default to `11111111111111111111111111111111`)
227          ///   17. `[]` associated_token_program
228#[derive(Clone, Debug, Default)]
229pub struct OpenPositionFusionBuilder {
230            authority: Option<solana_program::pubkey::Pubkey>,
231                mint_a: Option<solana_program::pubkey::Pubkey>,
232                mint_b: Option<solana_program::pubkey::Pubkey>,
233                token_program_a: Option<solana_program::pubkey::Pubkey>,
234                token_program_b: Option<solana_program::pubkey::Pubkey>,
235                market: Option<solana_program::pubkey::Pubkey>,
236                tuna_position: Option<solana_program::pubkey::Pubkey>,
237                tuna_position_mint: Option<solana_program::pubkey::Pubkey>,
238                tuna_position_ata: Option<solana_program::pubkey::Pubkey>,
239                tuna_position_ata_a: Option<solana_program::pubkey::Pubkey>,
240                tuna_position_ata_b: Option<solana_program::pubkey::Pubkey>,
241                fusionamm_program: Option<solana_program::pubkey::Pubkey>,
242                fusion_pool: Option<solana_program::pubkey::Pubkey>,
243                fusion_position: Option<solana_program::pubkey::Pubkey>,
244                metadata_update_auth: 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 OpenPositionFusionBuilder {
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 token_program_a(&mut self, token_program_a: solana_program::pubkey::Pubkey) -> &mut Self {
280                        self.token_program_a = Some(token_program_a);
281                    self
282    }
283            #[inline(always)]
284    pub fn token_program_b(&mut self, token_program_b: solana_program::pubkey::Pubkey) -> &mut Self {
285                        self.token_program_b = Some(token_program_b);
286                    self
287    }
288            #[inline(always)]
289    pub fn market(&mut self, market: solana_program::pubkey::Pubkey) -> &mut Self {
290                        self.market = Some(market);
291                    self
292    }
293            #[inline(always)]
294    pub fn tuna_position(&mut self, tuna_position: solana_program::pubkey::Pubkey) -> &mut Self {
295                        self.tuna_position = Some(tuna_position);
296                    self
297    }
298            #[inline(always)]
299    pub fn tuna_position_mint(&mut self, tuna_position_mint: solana_program::pubkey::Pubkey) -> &mut Self {
300                        self.tuna_position_mint = Some(tuna_position_mint);
301                    self
302    }
303            #[inline(always)]
304    pub fn tuna_position_ata(&mut self, tuna_position_ata: solana_program::pubkey::Pubkey) -> &mut Self {
305                        self.tuna_position_ata = Some(tuna_position_ata);
306                    self
307    }
308            #[inline(always)]
309    pub fn tuna_position_ata_a(&mut self, tuna_position_ata_a: solana_program::pubkey::Pubkey) -> &mut Self {
310                        self.tuna_position_ata_a = Some(tuna_position_ata_a);
311                    self
312    }
313            #[inline(always)]
314    pub fn tuna_position_ata_b(&mut self, tuna_position_ata_b: solana_program::pubkey::Pubkey) -> &mut Self {
315                        self.tuna_position_ata_b = Some(tuna_position_ata_b);
316                    self
317    }
318            /// 
319/// Fusion AMM accounts
320/// 
321#[inline(always)]
322    pub fn fusionamm_program(&mut self, fusionamm_program: solana_program::pubkey::Pubkey) -> &mut Self {
323                        self.fusionamm_program = Some(fusionamm_program);
324                    self
325    }
326            #[inline(always)]
327    pub fn fusion_pool(&mut self, fusion_pool: solana_program::pubkey::Pubkey) -> &mut Self {
328                        self.fusion_pool = Some(fusion_pool);
329                    self
330    }
331            #[inline(always)]
332    pub fn fusion_position(&mut self, fusion_position: solana_program::pubkey::Pubkey) -> &mut Self {
333                        self.fusion_position = Some(fusion_position);
334                    self
335    }
336            #[inline(always)]
337    pub fn metadata_update_auth(&mut self, metadata_update_auth: solana_program::pubkey::Pubkey) -> &mut Self {
338                        self.metadata_update_auth = Some(metadata_update_auth);
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 = OpenPositionFusion {
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                                        token_program_a: self.token_program_a.expect("token_program_a is not set"),
404                                        token_program_b: self.token_program_b.expect("token_program_b is not set"),
405                                        market: self.market.expect("market is not set"),
406                                        tuna_position: self.tuna_position.expect("tuna_position is not set"),
407                                        tuna_position_mint: self.tuna_position_mint.expect("tuna_position_mint is not set"),
408                                        tuna_position_ata: self.tuna_position_ata.expect("tuna_position_ata is not set"),
409                                        tuna_position_ata_a: self.tuna_position_ata_a.expect("tuna_position_ata_a is not set"),
410                                        tuna_position_ata_b: self.tuna_position_ata_b.expect("tuna_position_ata_b is not set"),
411                                        fusionamm_program: self.fusionamm_program.expect("fusionamm_program is not set"),
412                                        fusion_pool: self.fusion_pool.expect("fusion_pool is not set"),
413                                        fusion_position: self.fusion_position.expect("fusion_position is not set"),
414                                        metadata_update_auth: self.metadata_update_auth.expect("metadata_update_auth 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 = OpenPositionFusionInstructionArgs {
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_fusion` CPI accounts.
432  pub struct OpenPositionFusionCpiAccounts<'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 token_program_a: &'b solana_program::account_info::AccountInfo<'a>,
449                
450                    
451              pub token_program_b: &'b solana_program::account_info::AccountInfo<'a>,
452                
453                    
454              pub market: &'b solana_program::account_info::AccountInfo<'a>,
455                
456                    
457              pub tuna_position: &'b solana_program::account_info::AccountInfo<'a>,
458                
459                    
460              pub tuna_position_mint: &'b solana_program::account_info::AccountInfo<'a>,
461                
462                    
463              pub tuna_position_ata: &'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/// Fusion AMM accounts
472/// 
473
474      
475                    
476              pub fusionamm_program: &'b solana_program::account_info::AccountInfo<'a>,
477                
478                    
479              pub fusion_pool: &'b solana_program::account_info::AccountInfo<'a>,
480                
481                    
482              pub fusion_position: &'b solana_program::account_info::AccountInfo<'a>,
483                
484                    
485              pub metadata_update_auth: &'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_fusion` CPI instruction.
502pub struct OpenPositionFusionCpi<'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 token_program_a: &'b solana_program::account_info::AccountInfo<'a>,
521          
522              
523          pub token_program_b: &'b solana_program::account_info::AccountInfo<'a>,
524          
525              
526          pub market: &'b solana_program::account_info::AccountInfo<'a>,
527          
528              
529          pub tuna_position: &'b solana_program::account_info::AccountInfo<'a>,
530          
531              
532          pub tuna_position_mint: &'b solana_program::account_info::AccountInfo<'a>,
533          
534              
535          pub tuna_position_ata: &'b solana_program::account_info::AccountInfo<'a>,
536          
537              
538          pub tuna_position_ata_a: &'b solana_program::account_info::AccountInfo<'a>,
539          
540              
541          pub tuna_position_ata_b: &'b solana_program::account_info::AccountInfo<'a>,
542                /// 
543/// Fusion AMM accounts
544/// 
545
546    
547              
548          pub fusionamm_program: &'b solana_program::account_info::AccountInfo<'a>,
549          
550              
551          pub fusion_pool: &'b solana_program::account_info::AccountInfo<'a>,
552          
553              
554          pub fusion_position: &'b solana_program::account_info::AccountInfo<'a>,
555          
556              
557          pub metadata_update_auth: &'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: OpenPositionFusionInstructionArgs,
573  }
574
575impl<'a, 'b> OpenPositionFusionCpi<'a, 'b> {
576  pub fn new(
577    program: &'b solana_program::account_info::AccountInfo<'a>,
578          accounts: OpenPositionFusionCpiAccounts<'a, 'b>,
579              args: OpenPositionFusionInstructionArgs,
580      ) -> Self {
581    Self {
582      __program: program,
583              authority: accounts.authority,
584              mint_a: accounts.mint_a,
585              mint_b: accounts.mint_b,
586              token_program_a: accounts.token_program_a,
587              token_program_b: accounts.token_program_b,
588              market: accounts.market,
589              tuna_position: accounts.tuna_position,
590              tuna_position_mint: accounts.tuna_position_mint,
591              tuna_position_ata: accounts.tuna_position_ata,
592              tuna_position_ata_a: accounts.tuna_position_ata_a,
593              tuna_position_ata_b: accounts.tuna_position_ata_b,
594              fusionamm_program: accounts.fusionamm_program,
595              fusion_pool: accounts.fusion_pool,
596              fusion_position: accounts.fusion_position,
597              metadata_update_auth: accounts.metadata_update_auth,
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.token_program_a.key,
639            false
640          ));
641                                          accounts.push(solana_program::instruction::AccountMeta::new_readonly(
642            *self.token_program_b.key,
643            false
644          ));
645                                          accounts.push(solana_program::instruction::AccountMeta::new_readonly(
646            *self.market.key,
647            false
648          ));
649                                          accounts.push(solana_program::instruction::AccountMeta::new(
650            *self.tuna_position.key,
651            false
652          ));
653                                          accounts.push(solana_program::instruction::AccountMeta::new(
654            *self.tuna_position_mint.key,
655            true
656          ));
657                                          accounts.push(solana_program::instruction::AccountMeta::new(
658            *self.tuna_position_ata.key,
659            false
660          ));
661                                          accounts.push(solana_program::instruction::AccountMeta::new(
662            *self.tuna_position_ata_a.key,
663            false
664          ));
665                                          accounts.push(solana_program::instruction::AccountMeta::new(
666            *self.tuna_position_ata_b.key,
667            false
668          ));
669                                          accounts.push(solana_program::instruction::AccountMeta::new_readonly(
670            *self.fusionamm_program.key,
671            false
672          ));
673                                          accounts.push(solana_program::instruction::AccountMeta::new_readonly(
674            *self.fusion_pool.key,
675            false
676          ));
677                                          accounts.push(solana_program::instruction::AccountMeta::new(
678            *self.fusion_position.key,
679            false
680          ));
681                                          accounts.push(solana_program::instruction::AccountMeta::new_readonly(
682            *self.metadata_update_auth.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(&OpenPositionFusionInstructionData::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.token_program_a.clone());
719                        account_infos.push(self.token_program_b.clone());
720                        account_infos.push(self.market.clone());
721                        account_infos.push(self.tuna_position.clone());
722                        account_infos.push(self.tuna_position_mint.clone());
723                        account_infos.push(self.tuna_position_ata.clone());
724                        account_infos.push(self.tuna_position_ata_a.clone());
725                        account_infos.push(self.tuna_position_ata_b.clone());
726                        account_infos.push(self.fusionamm_program.clone());
727                        account_infos.push(self.fusion_pool.clone());
728                        account_infos.push(self.fusion_position.clone());
729                        account_infos.push(self.metadata_update_auth.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 `OpenPositionFusion` via CPI.
744///
745/// ### Accounts:
746///
747                      ///   0. `[writable, signer]` authority
748          ///   1. `[]` mint_a
749          ///   2. `[]` mint_b
750          ///   3. `[]` token_program_a
751          ///   4. `[]` token_program_b
752          ///   5. `[]` market
753                ///   6. `[writable]` tuna_position
754                      ///   7. `[writable, signer]` tuna_position_mint
755                ///   8. `[writable]` tuna_position_ata
756                ///   9. `[writable]` tuna_position_ata_a
757                ///   10. `[writable]` tuna_position_ata_b
758          ///   11. `[]` fusionamm_program
759          ///   12. `[]` fusion_pool
760                ///   13. `[writable]` fusion_position
761          ///   14. `[]` metadata_update_auth
762          ///   15. `[]` token2022_program
763          ///   16. `[]` system_program
764          ///   17. `[]` associated_token_program
765#[derive(Clone, Debug)]
766pub struct OpenPositionFusionCpiBuilder<'a, 'b> {
767  instruction: Box<OpenPositionFusionCpiBuilderInstruction<'a, 'b>>,
768}
769
770impl<'a, 'b> OpenPositionFusionCpiBuilder<'a, 'b> {
771  pub fn new(program: &'b solana_program::account_info::AccountInfo<'a>) -> Self {
772    let instruction = Box::new(OpenPositionFusionCpiBuilderInstruction {
773      __program: program,
774              authority: None,
775              mint_a: None,
776              mint_b: None,
777              token_program_a: None,
778              token_program_b: None,
779              market: None,
780              tuna_position: None,
781              tuna_position_mint: None,
782              tuna_position_ata: None,
783              tuna_position_ata_a: None,
784              tuna_position_ata_b: None,
785              fusionamm_program: None,
786              fusion_pool: None,
787              fusion_position: None,
788              metadata_update_auth: 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 token_program_a(&mut self, token_program_a: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self {
821                        self.instruction.token_program_a = Some(token_program_a);
822                    self
823    }
824      #[inline(always)]
825    pub fn token_program_b(&mut self, token_program_b: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self {
826                        self.instruction.token_program_b = Some(token_program_b);
827                    self
828    }
829      #[inline(always)]
830    pub fn market(&mut self, market: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self {
831                        self.instruction.market = Some(market);
832                    self
833    }
834      #[inline(always)]
835    pub fn tuna_position(&mut self, tuna_position: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self {
836                        self.instruction.tuna_position = Some(tuna_position);
837                    self
838    }
839      #[inline(always)]
840    pub fn tuna_position_mint(&mut self, tuna_position_mint: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self {
841                        self.instruction.tuna_position_mint = Some(tuna_position_mint);
842                    self
843    }
844      #[inline(always)]
845    pub fn tuna_position_ata(&mut self, tuna_position_ata: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self {
846                        self.instruction.tuna_position_ata = Some(tuna_position_ata);
847                    self
848    }
849      #[inline(always)]
850    pub fn tuna_position_ata_a(&mut self, tuna_position_ata_a: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self {
851                        self.instruction.tuna_position_ata_a = Some(tuna_position_ata_a);
852                    self
853    }
854      #[inline(always)]
855    pub fn tuna_position_ata_b(&mut self, tuna_position_ata_b: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self {
856                        self.instruction.tuna_position_ata_b = Some(tuna_position_ata_b);
857                    self
858    }
859      /// 
860/// Fusion AMM accounts
861/// 
862#[inline(always)]
863    pub fn fusionamm_program(&mut self, fusionamm_program: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self {
864                        self.instruction.fusionamm_program = Some(fusionamm_program);
865                    self
866    }
867      #[inline(always)]
868    pub fn fusion_pool(&mut self, fusion_pool: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self {
869                        self.instruction.fusion_pool = Some(fusion_pool);
870                    self
871    }
872      #[inline(always)]
873    pub fn fusion_position(&mut self, fusion_position: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self {
874                        self.instruction.fusion_position = Some(fusion_position);
875                    self
876    }
877      #[inline(always)]
878    pub fn metadata_update_auth(&mut self, metadata_update_auth: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self {
879                        self.instruction.metadata_update_auth = Some(metadata_update_auth);
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 = OpenPositionFusionInstructionArgs {
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 = OpenPositionFusionCpi {
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          token_program_a: self.instruction.token_program_a.expect("token_program_a is not set"),
964                  
965          token_program_b: self.instruction.token_program_b.expect("token_program_b is not set"),
966                  
967          market: self.instruction.market.expect("market is not set"),
968                  
969          tuna_position: self.instruction.tuna_position.expect("tuna_position is not set"),
970                  
971          tuna_position_mint: self.instruction.tuna_position_mint.expect("tuna_position_mint is not set"),
972                  
973          tuna_position_ata: self.instruction.tuna_position_ata.expect("tuna_position_ata is not set"),
974                  
975          tuna_position_ata_a: self.instruction.tuna_position_ata_a.expect("tuna_position_ata_a is not set"),
976                  
977          tuna_position_ata_b: self.instruction.tuna_position_ata_b.expect("tuna_position_ata_b is not set"),
978                  
979          fusionamm_program: self.instruction.fusionamm_program.expect("fusionamm_program is not set"),
980                  
981          fusion_pool: self.instruction.fusion_pool.expect("fusion_pool is not set"),
982                  
983          fusion_position: self.instruction.fusion_position.expect("fusion_position is not set"),
984                  
985          metadata_update_auth: self.instruction.metadata_update_auth.expect("metadata_update_auth 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 OpenPositionFusionCpiBuilderInstruction<'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                token_program_a: Option<&'b solana_program::account_info::AccountInfo<'a>>,
1005                token_program_b: Option<&'b solana_program::account_info::AccountInfo<'a>>,
1006                market: Option<&'b solana_program::account_info::AccountInfo<'a>>,
1007                tuna_position: Option<&'b solana_program::account_info::AccountInfo<'a>>,
1008                tuna_position_mint: Option<&'b solana_program::account_info::AccountInfo<'a>>,
1009                tuna_position_ata: Option<&'b solana_program::account_info::AccountInfo<'a>>,
1010                tuna_position_ata_a: Option<&'b solana_program::account_info::AccountInfo<'a>>,
1011                tuna_position_ata_b: Option<&'b solana_program::account_info::AccountInfo<'a>>,
1012                fusionamm_program: Option<&'b solana_program::account_info::AccountInfo<'a>>,
1013                fusion_pool: Option<&'b solana_program::account_info::AccountInfo<'a>>,
1014                fusion_position: Option<&'b solana_program::account_info::AccountInfo<'a>>,
1015                metadata_update_auth: 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