defituna_client/generated/instructions/
create_market.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 solana_pubkey::Pubkey;
9use borsh::BorshSerialize;
10use borsh::BorshDeserialize;
11
12pub const CREATE_MARKET_DISCRIMINATOR: [u8; 8] = [103, 226, 97, 235, 200, 188, 251, 254];
13
14/// Accounts.
15#[derive(Debug)]
16pub struct CreateMarket {
17      
18              
19          pub authority: solana_pubkey::Pubkey,
20          
21              
22          pub tuna_config: solana_pubkey::Pubkey,
23          
24              
25          pub market: solana_pubkey::Pubkey,
26          
27              
28          pub vault_a: solana_pubkey::Pubkey,
29          
30              
31          pub vault_b: solana_pubkey::Pubkey,
32          
33              
34          pub pool: solana_pubkey::Pubkey,
35          
36              
37          pub system_program: solana_pubkey::Pubkey,
38      }
39
40impl CreateMarket {
41  pub fn instruction(&self, args: CreateMarketInstructionArgs) -> solana_instruction::Instruction {
42    self.instruction_with_remaining_accounts(args, &[])
43  }
44  #[allow(clippy::arithmetic_side_effects)]
45  #[allow(clippy::vec_init_then_push)]
46  pub fn instruction_with_remaining_accounts(&self, args: CreateMarketInstructionArgs, remaining_accounts: &[solana_instruction::AccountMeta]) -> solana_instruction::Instruction {
47    let mut accounts = Vec::with_capacity(7+ remaining_accounts.len());
48                            accounts.push(solana_instruction::AccountMeta::new(
49            self.authority,
50            true
51          ));
52                                          accounts.push(solana_instruction::AccountMeta::new_readonly(
53            self.tuna_config,
54            false
55          ));
56                                          accounts.push(solana_instruction::AccountMeta::new(
57            self.market,
58            false
59          ));
60                                          accounts.push(solana_instruction::AccountMeta::new_readonly(
61            self.vault_a,
62            false
63          ));
64                                          accounts.push(solana_instruction::AccountMeta::new_readonly(
65            self.vault_b,
66            false
67          ));
68                                          accounts.push(solana_instruction::AccountMeta::new_readonly(
69            self.pool,
70            false
71          ));
72                                          accounts.push(solana_instruction::AccountMeta::new_readonly(
73            self.system_program,
74            false
75          ));
76                      accounts.extend_from_slice(remaining_accounts);
77    let mut data = borsh::to_vec(&CreateMarketInstructionData::new()).unwrap();
78          let mut args = borsh::to_vec(&args).unwrap();
79      data.append(&mut args);
80    
81    solana_instruction::Instruction {
82      program_id: crate::TUNA_ID,
83      accounts,
84      data,
85    }
86  }
87}
88
89#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)]
90#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
91 pub struct CreateMarketInstructionData {
92            discriminator: [u8; 8],
93                                                                                                }
94
95impl CreateMarketInstructionData {
96  pub fn new() -> Self {
97    Self {
98                        discriminator: [103, 226, 97, 235, 200, 188, 251, 254],
99                                                                                                                                                                                                                                    }
100  }
101}
102
103impl Default for CreateMarketInstructionData {
104  fn default() -> Self {
105    Self::new()
106  }
107}
108
109#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)]
110#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
111 pub struct CreateMarketInstructionArgs {
112                  pub address_lookup_table: Pubkey,
113                pub max_leverage: u32,
114                pub protocol_fee: u16,
115                pub protocol_fee_on_collateral: u16,
116                pub liquidation_fee: u32,
117                pub liquidation_threshold: u32,
118                pub limit_order_execution_fee: u32,
119                pub oracle_price_deviation_threshold: u32,
120                pub disabled: bool,
121                pub borrow_limit_a: u64,
122                pub borrow_limit_b: u64,
123                pub max_swap_slippage: u32,
124                pub rebalance_protocol_fee: u32,
125                pub spot_position_size_limit_a: u64,
126                pub spot_position_size_limit_b: u64,
127      }
128
129
130/// Instruction builder for `CreateMarket`.
131///
132/// ### Accounts:
133///
134                      ///   0. `[writable, signer]` authority
135          ///   1. `[]` tuna_config
136                ///   2. `[writable]` market
137          ///   3. `[]` vault_a
138          ///   4. `[]` vault_b
139          ///   5. `[]` pool
140                ///   6. `[optional]` system_program (default to `11111111111111111111111111111111`)
141#[derive(Clone, Debug, Default)]
142pub struct CreateMarketBuilder {
143            authority: Option<solana_pubkey::Pubkey>,
144                tuna_config: Option<solana_pubkey::Pubkey>,
145                market: Option<solana_pubkey::Pubkey>,
146                vault_a: Option<solana_pubkey::Pubkey>,
147                vault_b: Option<solana_pubkey::Pubkey>,
148                pool: Option<solana_pubkey::Pubkey>,
149                system_program: Option<solana_pubkey::Pubkey>,
150                        address_lookup_table: Option<Pubkey>,
151                max_leverage: Option<u32>,
152                protocol_fee: Option<u16>,
153                protocol_fee_on_collateral: Option<u16>,
154                liquidation_fee: Option<u32>,
155                liquidation_threshold: Option<u32>,
156                limit_order_execution_fee: Option<u32>,
157                oracle_price_deviation_threshold: Option<u32>,
158                disabled: Option<bool>,
159                borrow_limit_a: Option<u64>,
160                borrow_limit_b: Option<u64>,
161                max_swap_slippage: Option<u32>,
162                rebalance_protocol_fee: Option<u32>,
163                spot_position_size_limit_a: Option<u64>,
164                spot_position_size_limit_b: Option<u64>,
165        __remaining_accounts: Vec<solana_instruction::AccountMeta>,
166}
167
168impl CreateMarketBuilder {
169  pub fn new() -> Self {
170    Self::default()
171  }
172            #[inline(always)]
173    pub fn authority(&mut self, authority: solana_pubkey::Pubkey) -> &mut Self {
174                        self.authority = Some(authority);
175                    self
176    }
177            #[inline(always)]
178    pub fn tuna_config(&mut self, tuna_config: solana_pubkey::Pubkey) -> &mut Self {
179                        self.tuna_config = Some(tuna_config);
180                    self
181    }
182            #[inline(always)]
183    pub fn market(&mut self, market: solana_pubkey::Pubkey) -> &mut Self {
184                        self.market = Some(market);
185                    self
186    }
187            #[inline(always)]
188    pub fn vault_a(&mut self, vault_a: solana_pubkey::Pubkey) -> &mut Self {
189                        self.vault_a = Some(vault_a);
190                    self
191    }
192            #[inline(always)]
193    pub fn vault_b(&mut self, vault_b: solana_pubkey::Pubkey) -> &mut Self {
194                        self.vault_b = Some(vault_b);
195                    self
196    }
197            #[inline(always)]
198    pub fn pool(&mut self, pool: solana_pubkey::Pubkey) -> &mut Self {
199                        self.pool = Some(pool);
200                    self
201    }
202            /// `[optional account, default to '11111111111111111111111111111111']`
203#[inline(always)]
204    pub fn system_program(&mut self, system_program: solana_pubkey::Pubkey) -> &mut Self {
205                        self.system_program = Some(system_program);
206                    self
207    }
208                    #[inline(always)]
209      pub fn address_lookup_table(&mut self, address_lookup_table: Pubkey) -> &mut Self {
210        self.address_lookup_table = Some(address_lookup_table);
211        self
212      }
213                #[inline(always)]
214      pub fn max_leverage(&mut self, max_leverage: u32) -> &mut Self {
215        self.max_leverage = Some(max_leverage);
216        self
217      }
218                #[inline(always)]
219      pub fn protocol_fee(&mut self, protocol_fee: u16) -> &mut Self {
220        self.protocol_fee = Some(protocol_fee);
221        self
222      }
223                #[inline(always)]
224      pub fn protocol_fee_on_collateral(&mut self, protocol_fee_on_collateral: u16) -> &mut Self {
225        self.protocol_fee_on_collateral = Some(protocol_fee_on_collateral);
226        self
227      }
228                #[inline(always)]
229      pub fn liquidation_fee(&mut self, liquidation_fee: u32) -> &mut Self {
230        self.liquidation_fee = Some(liquidation_fee);
231        self
232      }
233                #[inline(always)]
234      pub fn liquidation_threshold(&mut self, liquidation_threshold: u32) -> &mut Self {
235        self.liquidation_threshold = Some(liquidation_threshold);
236        self
237      }
238                #[inline(always)]
239      pub fn limit_order_execution_fee(&mut self, limit_order_execution_fee: u32) -> &mut Self {
240        self.limit_order_execution_fee = Some(limit_order_execution_fee);
241        self
242      }
243                #[inline(always)]
244      pub fn oracle_price_deviation_threshold(&mut self, oracle_price_deviation_threshold: u32) -> &mut Self {
245        self.oracle_price_deviation_threshold = Some(oracle_price_deviation_threshold);
246        self
247      }
248                #[inline(always)]
249      pub fn disabled(&mut self, disabled: bool) -> &mut Self {
250        self.disabled = Some(disabled);
251        self
252      }
253                #[inline(always)]
254      pub fn borrow_limit_a(&mut self, borrow_limit_a: u64) -> &mut Self {
255        self.borrow_limit_a = Some(borrow_limit_a);
256        self
257      }
258                #[inline(always)]
259      pub fn borrow_limit_b(&mut self, borrow_limit_b: u64) -> &mut Self {
260        self.borrow_limit_b = Some(borrow_limit_b);
261        self
262      }
263                #[inline(always)]
264      pub fn max_swap_slippage(&mut self, max_swap_slippage: u32) -> &mut Self {
265        self.max_swap_slippage = Some(max_swap_slippage);
266        self
267      }
268                #[inline(always)]
269      pub fn rebalance_protocol_fee(&mut self, rebalance_protocol_fee: u32) -> &mut Self {
270        self.rebalance_protocol_fee = Some(rebalance_protocol_fee);
271        self
272      }
273                #[inline(always)]
274      pub fn spot_position_size_limit_a(&mut self, spot_position_size_limit_a: u64) -> &mut Self {
275        self.spot_position_size_limit_a = Some(spot_position_size_limit_a);
276        self
277      }
278                #[inline(always)]
279      pub fn spot_position_size_limit_b(&mut self, spot_position_size_limit_b: u64) -> &mut Self {
280        self.spot_position_size_limit_b = Some(spot_position_size_limit_b);
281        self
282      }
283        /// Add an additional account to the instruction.
284  #[inline(always)]
285  pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self {
286    self.__remaining_accounts.push(account);
287    self
288  }
289  /// Add additional accounts to the instruction.
290  #[inline(always)]
291  pub fn add_remaining_accounts(&mut self, accounts: &[solana_instruction::AccountMeta]) -> &mut Self {
292    self.__remaining_accounts.extend_from_slice(accounts);
293    self
294  }
295  #[allow(clippy::clone_on_copy)]
296  pub fn instruction(&self) -> solana_instruction::Instruction {
297    let accounts = CreateMarket {
298                              authority: self.authority.expect("authority is not set"),
299                                        tuna_config: self.tuna_config.expect("tuna_config is not set"),
300                                        market: self.market.expect("market is not set"),
301                                        vault_a: self.vault_a.expect("vault_a is not set"),
302                                        vault_b: self.vault_b.expect("vault_b is not set"),
303                                        pool: self.pool.expect("pool is not set"),
304                                        system_program: self.system_program.unwrap_or(solana_pubkey::pubkey!("11111111111111111111111111111111")),
305                      };
306          let args = CreateMarketInstructionArgs {
307                                                              address_lookup_table: self.address_lookup_table.clone().expect("address_lookup_table is not set"),
308                                                                  max_leverage: self.max_leverage.clone().expect("max_leverage is not set"),
309                                                                  protocol_fee: self.protocol_fee.clone().expect("protocol_fee is not set"),
310                                                                  protocol_fee_on_collateral: self.protocol_fee_on_collateral.clone().expect("protocol_fee_on_collateral is not set"),
311                                                                  liquidation_fee: self.liquidation_fee.clone().expect("liquidation_fee is not set"),
312                                                                  liquidation_threshold: self.liquidation_threshold.clone().expect("liquidation_threshold is not set"),
313                                                                  limit_order_execution_fee: self.limit_order_execution_fee.clone().expect("limit_order_execution_fee is not set"),
314                                                                  oracle_price_deviation_threshold: self.oracle_price_deviation_threshold.clone().expect("oracle_price_deviation_threshold is not set"),
315                                                                  disabled: self.disabled.clone().expect("disabled is not set"),
316                                                                  borrow_limit_a: self.borrow_limit_a.clone().expect("borrow_limit_a is not set"),
317                                                                  borrow_limit_b: self.borrow_limit_b.clone().expect("borrow_limit_b is not set"),
318                                                                  max_swap_slippage: self.max_swap_slippage.clone().expect("max_swap_slippage is not set"),
319                                                                  rebalance_protocol_fee: self.rebalance_protocol_fee.clone().expect("rebalance_protocol_fee is not set"),
320                                                                  spot_position_size_limit_a: self.spot_position_size_limit_a.clone().expect("spot_position_size_limit_a is not set"),
321                                                                  spot_position_size_limit_b: self.spot_position_size_limit_b.clone().expect("spot_position_size_limit_b is not set"),
322                                    };
323    
324    accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts)
325  }
326}
327
328  /// `create_market` CPI accounts.
329  pub struct CreateMarketCpiAccounts<'a, 'b> {
330          
331                    
332              pub authority: &'b solana_account_info::AccountInfo<'a>,
333                
334                    
335              pub tuna_config: &'b solana_account_info::AccountInfo<'a>,
336                
337                    
338              pub market: &'b solana_account_info::AccountInfo<'a>,
339                
340                    
341              pub vault_a: &'b solana_account_info::AccountInfo<'a>,
342                
343                    
344              pub vault_b: &'b solana_account_info::AccountInfo<'a>,
345                
346                    
347              pub pool: &'b solana_account_info::AccountInfo<'a>,
348                
349                    
350              pub system_program: &'b solana_account_info::AccountInfo<'a>,
351            }
352
353/// `create_market` CPI instruction.
354pub struct CreateMarketCpi<'a, 'b> {
355  /// The program to invoke.
356  pub __program: &'b solana_account_info::AccountInfo<'a>,
357      
358              
359          pub authority: &'b solana_account_info::AccountInfo<'a>,
360          
361              
362          pub tuna_config: &'b solana_account_info::AccountInfo<'a>,
363          
364              
365          pub market: &'b solana_account_info::AccountInfo<'a>,
366          
367              
368          pub vault_a: &'b solana_account_info::AccountInfo<'a>,
369          
370              
371          pub vault_b: &'b solana_account_info::AccountInfo<'a>,
372          
373              
374          pub pool: &'b solana_account_info::AccountInfo<'a>,
375          
376              
377          pub system_program: &'b solana_account_info::AccountInfo<'a>,
378            /// The arguments for the instruction.
379    pub __args: CreateMarketInstructionArgs,
380  }
381
382impl<'a, 'b> CreateMarketCpi<'a, 'b> {
383  pub fn new(
384    program: &'b solana_account_info::AccountInfo<'a>,
385          accounts: CreateMarketCpiAccounts<'a, 'b>,
386              args: CreateMarketInstructionArgs,
387      ) -> Self {
388    Self {
389      __program: program,
390              authority: accounts.authority,
391              tuna_config: accounts.tuna_config,
392              market: accounts.market,
393              vault_a: accounts.vault_a,
394              vault_b: accounts.vault_b,
395              pool: accounts.pool,
396              system_program: accounts.system_program,
397                    __args: args,
398          }
399  }
400  #[inline(always)]
401  pub fn invoke(&self) -> solana_program_error::ProgramResult {
402    self.invoke_signed_with_remaining_accounts(&[], &[])
403  }
404  #[inline(always)]
405  pub fn invoke_with_remaining_accounts(&self, remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)]) -> solana_program_error::ProgramResult {
406    self.invoke_signed_with_remaining_accounts(&[], remaining_accounts)
407  }
408  #[inline(always)]
409  pub fn invoke_signed(&self, signers_seeds: &[&[&[u8]]]) -> solana_program_error::ProgramResult {
410    self.invoke_signed_with_remaining_accounts(signers_seeds, &[])
411  }
412  #[allow(clippy::arithmetic_side_effects)]
413  #[allow(clippy::clone_on_copy)]
414  #[allow(clippy::vec_init_then_push)]
415  pub fn invoke_signed_with_remaining_accounts(
416    &self,
417    signers_seeds: &[&[&[u8]]],
418    remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)]
419  ) -> solana_program_error::ProgramResult {
420    let mut accounts = Vec::with_capacity(7+ remaining_accounts.len());
421                            accounts.push(solana_instruction::AccountMeta::new(
422            *self.authority.key,
423            true
424          ));
425                                          accounts.push(solana_instruction::AccountMeta::new_readonly(
426            *self.tuna_config.key,
427            false
428          ));
429                                          accounts.push(solana_instruction::AccountMeta::new(
430            *self.market.key,
431            false
432          ));
433                                          accounts.push(solana_instruction::AccountMeta::new_readonly(
434            *self.vault_a.key,
435            false
436          ));
437                                          accounts.push(solana_instruction::AccountMeta::new_readonly(
438            *self.vault_b.key,
439            false
440          ));
441                                          accounts.push(solana_instruction::AccountMeta::new_readonly(
442            *self.pool.key,
443            false
444          ));
445                                          accounts.push(solana_instruction::AccountMeta::new_readonly(
446            *self.system_program.key,
447            false
448          ));
449                      remaining_accounts.iter().for_each(|remaining_account| {
450      accounts.push(solana_instruction::AccountMeta {
451          pubkey: *remaining_account.0.key,
452          is_signer: remaining_account.1,
453          is_writable: remaining_account.2,
454      })
455    });
456    let mut data = borsh::to_vec(&CreateMarketInstructionData::new()).unwrap();
457          let mut args = borsh::to_vec(&self.__args).unwrap();
458      data.append(&mut args);
459    
460    let instruction = solana_instruction::Instruction {
461      program_id: crate::TUNA_ID,
462      accounts,
463      data,
464    };
465    let mut account_infos = Vec::with_capacity(8 + remaining_accounts.len());
466    account_infos.push(self.__program.clone());
467                  account_infos.push(self.authority.clone());
468                        account_infos.push(self.tuna_config.clone());
469                        account_infos.push(self.market.clone());
470                        account_infos.push(self.vault_a.clone());
471                        account_infos.push(self.vault_b.clone());
472                        account_infos.push(self.pool.clone());
473                        account_infos.push(self.system_program.clone());
474              remaining_accounts.iter().for_each(|remaining_account| account_infos.push(remaining_account.0.clone()));
475
476    if signers_seeds.is_empty() {
477      solana_cpi::invoke(&instruction, &account_infos)
478    } else {
479      solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds)
480    }
481  }
482}
483
484/// Instruction builder for `CreateMarket` via CPI.
485///
486/// ### Accounts:
487///
488                      ///   0. `[writable, signer]` authority
489          ///   1. `[]` tuna_config
490                ///   2. `[writable]` market
491          ///   3. `[]` vault_a
492          ///   4. `[]` vault_b
493          ///   5. `[]` pool
494          ///   6. `[]` system_program
495#[derive(Clone, Debug)]
496pub struct CreateMarketCpiBuilder<'a, 'b> {
497  instruction: Box<CreateMarketCpiBuilderInstruction<'a, 'b>>,
498}
499
500impl<'a, 'b> CreateMarketCpiBuilder<'a, 'b> {
501  pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self {
502    let instruction = Box::new(CreateMarketCpiBuilderInstruction {
503      __program: program,
504              authority: None,
505              tuna_config: None,
506              market: None,
507              vault_a: None,
508              vault_b: None,
509              pool: None,
510              system_program: None,
511                                            address_lookup_table: None,
512                                max_leverage: None,
513                                protocol_fee: None,
514                                protocol_fee_on_collateral: None,
515                                liquidation_fee: None,
516                                liquidation_threshold: None,
517                                limit_order_execution_fee: None,
518                                oracle_price_deviation_threshold: None,
519                                disabled: None,
520                                borrow_limit_a: None,
521                                borrow_limit_b: None,
522                                max_swap_slippage: None,
523                                rebalance_protocol_fee: None,
524                                spot_position_size_limit_a: None,
525                                spot_position_size_limit_b: None,
526                    __remaining_accounts: Vec::new(),
527    });
528    Self { instruction }
529  }
530      #[inline(always)]
531    pub fn authority(&mut self, authority: &'b solana_account_info::AccountInfo<'a>) -> &mut Self {
532                        self.instruction.authority = Some(authority);
533                    self
534    }
535      #[inline(always)]
536    pub fn tuna_config(&mut self, tuna_config: &'b solana_account_info::AccountInfo<'a>) -> &mut Self {
537                        self.instruction.tuna_config = Some(tuna_config);
538                    self
539    }
540      #[inline(always)]
541    pub fn market(&mut self, market: &'b solana_account_info::AccountInfo<'a>) -> &mut Self {
542                        self.instruction.market = Some(market);
543                    self
544    }
545      #[inline(always)]
546    pub fn vault_a(&mut self, vault_a: &'b solana_account_info::AccountInfo<'a>) -> &mut Self {
547                        self.instruction.vault_a = Some(vault_a);
548                    self
549    }
550      #[inline(always)]
551    pub fn vault_b(&mut self, vault_b: &'b solana_account_info::AccountInfo<'a>) -> &mut Self {
552                        self.instruction.vault_b = Some(vault_b);
553                    self
554    }
555      #[inline(always)]
556    pub fn pool(&mut self, pool: &'b solana_account_info::AccountInfo<'a>) -> &mut Self {
557                        self.instruction.pool = Some(pool);
558                    self
559    }
560      #[inline(always)]
561    pub fn system_program(&mut self, system_program: &'b solana_account_info::AccountInfo<'a>) -> &mut Self {
562                        self.instruction.system_program = Some(system_program);
563                    self
564    }
565                    #[inline(always)]
566      pub fn address_lookup_table(&mut self, address_lookup_table: Pubkey) -> &mut Self {
567        self.instruction.address_lookup_table = Some(address_lookup_table);
568        self
569      }
570                #[inline(always)]
571      pub fn max_leverage(&mut self, max_leverage: u32) -> &mut Self {
572        self.instruction.max_leverage = Some(max_leverage);
573        self
574      }
575                #[inline(always)]
576      pub fn protocol_fee(&mut self, protocol_fee: u16) -> &mut Self {
577        self.instruction.protocol_fee = Some(protocol_fee);
578        self
579      }
580                #[inline(always)]
581      pub fn protocol_fee_on_collateral(&mut self, protocol_fee_on_collateral: u16) -> &mut Self {
582        self.instruction.protocol_fee_on_collateral = Some(protocol_fee_on_collateral);
583        self
584      }
585                #[inline(always)]
586      pub fn liquidation_fee(&mut self, liquidation_fee: u32) -> &mut Self {
587        self.instruction.liquidation_fee = Some(liquidation_fee);
588        self
589      }
590                #[inline(always)]
591      pub fn liquidation_threshold(&mut self, liquidation_threshold: u32) -> &mut Self {
592        self.instruction.liquidation_threshold = Some(liquidation_threshold);
593        self
594      }
595                #[inline(always)]
596      pub fn limit_order_execution_fee(&mut self, limit_order_execution_fee: u32) -> &mut Self {
597        self.instruction.limit_order_execution_fee = Some(limit_order_execution_fee);
598        self
599      }
600                #[inline(always)]
601      pub fn oracle_price_deviation_threshold(&mut self, oracle_price_deviation_threshold: u32) -> &mut Self {
602        self.instruction.oracle_price_deviation_threshold = Some(oracle_price_deviation_threshold);
603        self
604      }
605                #[inline(always)]
606      pub fn disabled(&mut self, disabled: bool) -> &mut Self {
607        self.instruction.disabled = Some(disabled);
608        self
609      }
610                #[inline(always)]
611      pub fn borrow_limit_a(&mut self, borrow_limit_a: u64) -> &mut Self {
612        self.instruction.borrow_limit_a = Some(borrow_limit_a);
613        self
614      }
615                #[inline(always)]
616      pub fn borrow_limit_b(&mut self, borrow_limit_b: u64) -> &mut Self {
617        self.instruction.borrow_limit_b = Some(borrow_limit_b);
618        self
619      }
620                #[inline(always)]
621      pub fn max_swap_slippage(&mut self, max_swap_slippage: u32) -> &mut Self {
622        self.instruction.max_swap_slippage = Some(max_swap_slippage);
623        self
624      }
625                #[inline(always)]
626      pub fn rebalance_protocol_fee(&mut self, rebalance_protocol_fee: u32) -> &mut Self {
627        self.instruction.rebalance_protocol_fee = Some(rebalance_protocol_fee);
628        self
629      }
630                #[inline(always)]
631      pub fn spot_position_size_limit_a(&mut self, spot_position_size_limit_a: u64) -> &mut Self {
632        self.instruction.spot_position_size_limit_a = Some(spot_position_size_limit_a);
633        self
634      }
635                #[inline(always)]
636      pub fn spot_position_size_limit_b(&mut self, spot_position_size_limit_b: u64) -> &mut Self {
637        self.instruction.spot_position_size_limit_b = Some(spot_position_size_limit_b);
638        self
639      }
640        /// Add an additional account to the instruction.
641  #[inline(always)]
642  pub fn add_remaining_account(&mut self, account: &'b solana_account_info::AccountInfo<'a>, is_writable: bool, is_signer: bool) -> &mut Self {
643    self.instruction.__remaining_accounts.push((account, is_writable, is_signer));
644    self
645  }
646  /// Add additional accounts to the instruction.
647  ///
648  /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not,
649  /// and a `bool` indicating whether the account is a signer or not.
650  #[inline(always)]
651  pub fn add_remaining_accounts(&mut self, accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)]) -> &mut Self {
652    self.instruction.__remaining_accounts.extend_from_slice(accounts);
653    self
654  }
655  #[inline(always)]
656  pub fn invoke(&self) -> solana_program_error::ProgramResult {
657    self.invoke_signed(&[])
658  }
659  #[allow(clippy::clone_on_copy)]
660  #[allow(clippy::vec_init_then_push)]
661  pub fn invoke_signed(&self, signers_seeds: &[&[&[u8]]]) -> solana_program_error::ProgramResult {
662          let args = CreateMarketInstructionArgs {
663                                                              address_lookup_table: self.instruction.address_lookup_table.clone().expect("address_lookup_table is not set"),
664                                                                  max_leverage: self.instruction.max_leverage.clone().expect("max_leverage is not set"),
665                                                                  protocol_fee: self.instruction.protocol_fee.clone().expect("protocol_fee is not set"),
666                                                                  protocol_fee_on_collateral: self.instruction.protocol_fee_on_collateral.clone().expect("protocol_fee_on_collateral is not set"),
667                                                                  liquidation_fee: self.instruction.liquidation_fee.clone().expect("liquidation_fee is not set"),
668                                                                  liquidation_threshold: self.instruction.liquidation_threshold.clone().expect("liquidation_threshold is not set"),
669                                                                  limit_order_execution_fee: self.instruction.limit_order_execution_fee.clone().expect("limit_order_execution_fee is not set"),
670                                                                  oracle_price_deviation_threshold: self.instruction.oracle_price_deviation_threshold.clone().expect("oracle_price_deviation_threshold is not set"),
671                                                                  disabled: self.instruction.disabled.clone().expect("disabled is not set"),
672                                                                  borrow_limit_a: self.instruction.borrow_limit_a.clone().expect("borrow_limit_a is not set"),
673                                                                  borrow_limit_b: self.instruction.borrow_limit_b.clone().expect("borrow_limit_b is not set"),
674                                                                  max_swap_slippage: self.instruction.max_swap_slippage.clone().expect("max_swap_slippage is not set"),
675                                                                  rebalance_protocol_fee: self.instruction.rebalance_protocol_fee.clone().expect("rebalance_protocol_fee is not set"),
676                                                                  spot_position_size_limit_a: self.instruction.spot_position_size_limit_a.clone().expect("spot_position_size_limit_a is not set"),
677                                                                  spot_position_size_limit_b: self.instruction.spot_position_size_limit_b.clone().expect("spot_position_size_limit_b is not set"),
678                                    };
679        let instruction = CreateMarketCpi {
680        __program: self.instruction.__program,
681                  
682          authority: self.instruction.authority.expect("authority is not set"),
683                  
684          tuna_config: self.instruction.tuna_config.expect("tuna_config is not set"),
685                  
686          market: self.instruction.market.expect("market is not set"),
687                  
688          vault_a: self.instruction.vault_a.expect("vault_a is not set"),
689                  
690          vault_b: self.instruction.vault_b.expect("vault_b is not set"),
691                  
692          pool: self.instruction.pool.expect("pool is not set"),
693                  
694          system_program: self.instruction.system_program.expect("system_program is not set"),
695                          __args: args,
696            };
697    instruction.invoke_signed_with_remaining_accounts(signers_seeds, &self.instruction.__remaining_accounts)
698  }
699}
700
701#[derive(Clone, Debug)]
702struct CreateMarketCpiBuilderInstruction<'a, 'b> {
703  __program: &'b solana_account_info::AccountInfo<'a>,
704            authority: Option<&'b solana_account_info::AccountInfo<'a>>,
705                tuna_config: Option<&'b solana_account_info::AccountInfo<'a>>,
706                market: Option<&'b solana_account_info::AccountInfo<'a>>,
707                vault_a: Option<&'b solana_account_info::AccountInfo<'a>>,
708                vault_b: Option<&'b solana_account_info::AccountInfo<'a>>,
709                pool: Option<&'b solana_account_info::AccountInfo<'a>>,
710                system_program: Option<&'b solana_account_info::AccountInfo<'a>>,
711                        address_lookup_table: Option<Pubkey>,
712                max_leverage: Option<u32>,
713                protocol_fee: Option<u16>,
714                protocol_fee_on_collateral: Option<u16>,
715                liquidation_fee: Option<u32>,
716                liquidation_threshold: Option<u32>,
717                limit_order_execution_fee: Option<u32>,
718                oracle_price_deviation_threshold: Option<u32>,
719                disabled: Option<bool>,
720                borrow_limit_a: Option<u64>,
721                borrow_limit_b: Option<u64>,
722                max_swap_slippage: Option<u32>,
723                rebalance_protocol_fee: Option<u32>,
724                spot_position_size_limit_a: Option<u64>,
725                spot_position_size_limit_b: Option<u64>,
726        /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`.
727  __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>,
728}
729