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