1use 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#[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 oracle_price_deviation_threshold: u32,
119 pub disabled: bool,
120 pub borrow_limit_a: u64,
121 pub borrow_limit_b: u64,
122 pub max_swap_slippage: u32,
123 pub rebalance_protocol_fee: u32,
124 pub spot_position_size_limit_a: u64,
125 pub spot_position_size_limit_b: u64,
126 }
127
128
129#[derive(Clone, Debug, Default)]
141pub struct CreateMarketBuilder {
142 authority: Option<solana_pubkey::Pubkey>,
143 tuna_config: Option<solana_pubkey::Pubkey>,
144 market: Option<solana_pubkey::Pubkey>,
145 vault_a: Option<solana_pubkey::Pubkey>,
146 vault_b: Option<solana_pubkey::Pubkey>,
147 pool: Option<solana_pubkey::Pubkey>,
148 system_program: Option<solana_pubkey::Pubkey>,
149 address_lookup_table: Option<Pubkey>,
150 max_leverage: Option<u32>,
151 protocol_fee: Option<u16>,
152 protocol_fee_on_collateral: Option<u16>,
153 liquidation_fee: Option<u32>,
154 liquidation_threshold: Option<u32>,
155 oracle_price_deviation_threshold: Option<u32>,
156 disabled: Option<bool>,
157 borrow_limit_a: Option<u64>,
158 borrow_limit_b: Option<u64>,
159 max_swap_slippage: Option<u32>,
160 rebalance_protocol_fee: Option<u32>,
161 spot_position_size_limit_a: Option<u64>,
162 spot_position_size_limit_b: Option<u64>,
163 __remaining_accounts: Vec<solana_instruction::AccountMeta>,
164}
165
166impl CreateMarketBuilder {
167 pub fn new() -> Self {
168 Self::default()
169 }
170 #[inline(always)]
171 pub fn authority(&mut self, authority: solana_pubkey::Pubkey) -> &mut Self {
172 self.authority = Some(authority);
173 self
174 }
175 #[inline(always)]
176 pub fn tuna_config(&mut self, tuna_config: solana_pubkey::Pubkey) -> &mut Self {
177 self.tuna_config = Some(tuna_config);
178 self
179 }
180 #[inline(always)]
181 pub fn market(&mut self, market: solana_pubkey::Pubkey) -> &mut Self {
182 self.market = Some(market);
183 self
184 }
185 #[inline(always)]
186 pub fn vault_a(&mut self, vault_a: solana_pubkey::Pubkey) -> &mut Self {
187 self.vault_a = Some(vault_a);
188 self
189 }
190 #[inline(always)]
191 pub fn vault_b(&mut self, vault_b: solana_pubkey::Pubkey) -> &mut Self {
192 self.vault_b = Some(vault_b);
193 self
194 }
195 #[inline(always)]
196 pub fn pool(&mut self, pool: solana_pubkey::Pubkey) -> &mut Self {
197 self.pool = Some(pool);
198 self
199 }
200 #[inline(always)]
202 pub fn system_program(&mut self, system_program: solana_pubkey::Pubkey) -> &mut Self {
203 self.system_program = Some(system_program);
204 self
205 }
206 #[inline(always)]
207 pub fn address_lookup_table(&mut self, address_lookup_table: Pubkey) -> &mut Self {
208 self.address_lookup_table = Some(address_lookup_table);
209 self
210 }
211 #[inline(always)]
212 pub fn max_leverage(&mut self, max_leverage: u32) -> &mut Self {
213 self.max_leverage = Some(max_leverage);
214 self
215 }
216 #[inline(always)]
217 pub fn protocol_fee(&mut self, protocol_fee: u16) -> &mut Self {
218 self.protocol_fee = Some(protocol_fee);
219 self
220 }
221 #[inline(always)]
222 pub fn protocol_fee_on_collateral(&mut self, protocol_fee_on_collateral: u16) -> &mut Self {
223 self.protocol_fee_on_collateral = Some(protocol_fee_on_collateral);
224 self
225 }
226 #[inline(always)]
227 pub fn liquidation_fee(&mut self, liquidation_fee: u32) -> &mut Self {
228 self.liquidation_fee = Some(liquidation_fee);
229 self
230 }
231 #[inline(always)]
232 pub fn liquidation_threshold(&mut self, liquidation_threshold: u32) -> &mut Self {
233 self.liquidation_threshold = Some(liquidation_threshold);
234 self
235 }
236 #[inline(always)]
237 pub fn oracle_price_deviation_threshold(&mut self, oracle_price_deviation_threshold: u32) -> &mut Self {
238 self.oracle_price_deviation_threshold = Some(oracle_price_deviation_threshold);
239 self
240 }
241 #[inline(always)]
242 pub fn disabled(&mut self, disabled: bool) -> &mut Self {
243 self.disabled = Some(disabled);
244 self
245 }
246 #[inline(always)]
247 pub fn borrow_limit_a(&mut self, borrow_limit_a: u64) -> &mut Self {
248 self.borrow_limit_a = Some(borrow_limit_a);
249 self
250 }
251 #[inline(always)]
252 pub fn borrow_limit_b(&mut self, borrow_limit_b: u64) -> &mut Self {
253 self.borrow_limit_b = Some(borrow_limit_b);
254 self
255 }
256 #[inline(always)]
257 pub fn max_swap_slippage(&mut self, max_swap_slippage: u32) -> &mut Self {
258 self.max_swap_slippage = Some(max_swap_slippage);
259 self
260 }
261 #[inline(always)]
262 pub fn rebalance_protocol_fee(&mut self, rebalance_protocol_fee: u32) -> &mut Self {
263 self.rebalance_protocol_fee = Some(rebalance_protocol_fee);
264 self
265 }
266 #[inline(always)]
267 pub fn spot_position_size_limit_a(&mut self, spot_position_size_limit_a: u64) -> &mut Self {
268 self.spot_position_size_limit_a = Some(spot_position_size_limit_a);
269 self
270 }
271 #[inline(always)]
272 pub fn spot_position_size_limit_b(&mut self, spot_position_size_limit_b: u64) -> &mut Self {
273 self.spot_position_size_limit_b = Some(spot_position_size_limit_b);
274 self
275 }
276 #[inline(always)]
278 pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self {
279 self.__remaining_accounts.push(account);
280 self
281 }
282 #[inline(always)]
284 pub fn add_remaining_accounts(&mut self, accounts: &[solana_instruction::AccountMeta]) -> &mut Self {
285 self.__remaining_accounts.extend_from_slice(accounts);
286 self
287 }
288 #[allow(clippy::clone_on_copy)]
289 pub fn instruction(&self) -> solana_instruction::Instruction {
290 let accounts = CreateMarket {
291 authority: self.authority.expect("authority is not set"),
292 tuna_config: self.tuna_config.expect("tuna_config is not set"),
293 market: self.market.expect("market is not set"),
294 vault_a: self.vault_a.expect("vault_a is not set"),
295 vault_b: self.vault_b.expect("vault_b is not set"),
296 pool: self.pool.expect("pool is not set"),
297 system_program: self.system_program.unwrap_or(solana_pubkey::pubkey!("11111111111111111111111111111111")),
298 };
299 let args = CreateMarketInstructionArgs {
300 address_lookup_table: self.address_lookup_table.clone().expect("address_lookup_table is not set"),
301 max_leverage: self.max_leverage.clone().expect("max_leverage is not set"),
302 protocol_fee: self.protocol_fee.clone().expect("protocol_fee is not set"),
303 protocol_fee_on_collateral: self.protocol_fee_on_collateral.clone().expect("protocol_fee_on_collateral is not set"),
304 liquidation_fee: self.liquidation_fee.clone().expect("liquidation_fee is not set"),
305 liquidation_threshold: self.liquidation_threshold.clone().expect("liquidation_threshold is not set"),
306 oracle_price_deviation_threshold: self.oracle_price_deviation_threshold.clone().expect("oracle_price_deviation_threshold is not set"),
307 disabled: self.disabled.clone().expect("disabled is not set"),
308 borrow_limit_a: self.borrow_limit_a.clone().expect("borrow_limit_a is not set"),
309 borrow_limit_b: self.borrow_limit_b.clone().expect("borrow_limit_b is not set"),
310 max_swap_slippage: self.max_swap_slippage.clone().expect("max_swap_slippage is not set"),
311 rebalance_protocol_fee: self.rebalance_protocol_fee.clone().expect("rebalance_protocol_fee is not set"),
312 spot_position_size_limit_a: self.spot_position_size_limit_a.clone().expect("spot_position_size_limit_a is not set"),
313 spot_position_size_limit_b: self.spot_position_size_limit_b.clone().expect("spot_position_size_limit_b is not set"),
314 };
315
316 accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts)
317 }
318}
319
320 pub struct CreateMarketCpiAccounts<'a, 'b> {
322
323
324 pub authority: &'b solana_account_info::AccountInfo<'a>,
325
326
327 pub tuna_config: &'b solana_account_info::AccountInfo<'a>,
328
329
330 pub market: &'b solana_account_info::AccountInfo<'a>,
331
332
333 pub vault_a: &'b solana_account_info::AccountInfo<'a>,
334
335
336 pub vault_b: &'b solana_account_info::AccountInfo<'a>,
337
338
339 pub pool: &'b solana_account_info::AccountInfo<'a>,
340
341
342 pub system_program: &'b solana_account_info::AccountInfo<'a>,
343 }
344
345pub struct CreateMarketCpi<'a, 'b> {
347 pub __program: &'b solana_account_info::AccountInfo<'a>,
349
350
351 pub authority: &'b solana_account_info::AccountInfo<'a>,
352
353
354 pub tuna_config: &'b solana_account_info::AccountInfo<'a>,
355
356
357 pub market: &'b solana_account_info::AccountInfo<'a>,
358
359
360 pub vault_a: &'b solana_account_info::AccountInfo<'a>,
361
362
363 pub vault_b: &'b solana_account_info::AccountInfo<'a>,
364
365
366 pub pool: &'b solana_account_info::AccountInfo<'a>,
367
368
369 pub system_program: &'b solana_account_info::AccountInfo<'a>,
370 pub __args: CreateMarketInstructionArgs,
372 }
373
374impl<'a, 'b> CreateMarketCpi<'a, 'b> {
375 pub fn new(
376 program: &'b solana_account_info::AccountInfo<'a>,
377 accounts: CreateMarketCpiAccounts<'a, 'b>,
378 args: CreateMarketInstructionArgs,
379 ) -> Self {
380 Self {
381 __program: program,
382 authority: accounts.authority,
383 tuna_config: accounts.tuna_config,
384 market: accounts.market,
385 vault_a: accounts.vault_a,
386 vault_b: accounts.vault_b,
387 pool: accounts.pool,
388 system_program: accounts.system_program,
389 __args: args,
390 }
391 }
392 #[inline(always)]
393 pub fn invoke(&self) -> solana_program_error::ProgramResult {
394 self.invoke_signed_with_remaining_accounts(&[], &[])
395 }
396 #[inline(always)]
397 pub fn invoke_with_remaining_accounts(&self, remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)]) -> solana_program_error::ProgramResult {
398 self.invoke_signed_with_remaining_accounts(&[], remaining_accounts)
399 }
400 #[inline(always)]
401 pub fn invoke_signed(&self, signers_seeds: &[&[&[u8]]]) -> solana_program_error::ProgramResult {
402 self.invoke_signed_with_remaining_accounts(signers_seeds, &[])
403 }
404 #[allow(clippy::arithmetic_side_effects)]
405 #[allow(clippy::clone_on_copy)]
406 #[allow(clippy::vec_init_then_push)]
407 pub fn invoke_signed_with_remaining_accounts(
408 &self,
409 signers_seeds: &[&[&[u8]]],
410 remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)]
411 ) -> solana_program_error::ProgramResult {
412 let mut accounts = Vec::with_capacity(7+ remaining_accounts.len());
413 accounts.push(solana_instruction::AccountMeta::new(
414 *self.authority.key,
415 true
416 ));
417 accounts.push(solana_instruction::AccountMeta::new_readonly(
418 *self.tuna_config.key,
419 false
420 ));
421 accounts.push(solana_instruction::AccountMeta::new(
422 *self.market.key,
423 false
424 ));
425 accounts.push(solana_instruction::AccountMeta::new_readonly(
426 *self.vault_a.key,
427 false
428 ));
429 accounts.push(solana_instruction::AccountMeta::new_readonly(
430 *self.vault_b.key,
431 false
432 ));
433 accounts.push(solana_instruction::AccountMeta::new_readonly(
434 *self.pool.key,
435 false
436 ));
437 accounts.push(solana_instruction::AccountMeta::new_readonly(
438 *self.system_program.key,
439 false
440 ));
441 remaining_accounts.iter().for_each(|remaining_account| {
442 accounts.push(solana_instruction::AccountMeta {
443 pubkey: *remaining_account.0.key,
444 is_signer: remaining_account.1,
445 is_writable: remaining_account.2,
446 })
447 });
448 let mut data = borsh::to_vec(&CreateMarketInstructionData::new()).unwrap();
449 let mut args = borsh::to_vec(&self.__args).unwrap();
450 data.append(&mut args);
451
452 let instruction = solana_instruction::Instruction {
453 program_id: crate::TUNA_ID,
454 accounts,
455 data,
456 };
457 let mut account_infos = Vec::with_capacity(8 + remaining_accounts.len());
458 account_infos.push(self.__program.clone());
459 account_infos.push(self.authority.clone());
460 account_infos.push(self.tuna_config.clone());
461 account_infos.push(self.market.clone());
462 account_infos.push(self.vault_a.clone());
463 account_infos.push(self.vault_b.clone());
464 account_infos.push(self.pool.clone());
465 account_infos.push(self.system_program.clone());
466 remaining_accounts.iter().for_each(|remaining_account| account_infos.push(remaining_account.0.clone()));
467
468 if signers_seeds.is_empty() {
469 solana_cpi::invoke(&instruction, &account_infos)
470 } else {
471 solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds)
472 }
473 }
474}
475
476#[derive(Clone, Debug)]
488pub struct CreateMarketCpiBuilder<'a, 'b> {
489 instruction: Box<CreateMarketCpiBuilderInstruction<'a, 'b>>,
490}
491
492impl<'a, 'b> CreateMarketCpiBuilder<'a, 'b> {
493 pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self {
494 let instruction = Box::new(CreateMarketCpiBuilderInstruction {
495 __program: program,
496 authority: None,
497 tuna_config: None,
498 market: None,
499 vault_a: None,
500 vault_b: None,
501 pool: None,
502 system_program: None,
503 address_lookup_table: None,
504 max_leverage: None,
505 protocol_fee: None,
506 protocol_fee_on_collateral: None,
507 liquidation_fee: None,
508 liquidation_threshold: None,
509 oracle_price_deviation_threshold: None,
510 disabled: None,
511 borrow_limit_a: None,
512 borrow_limit_b: None,
513 max_swap_slippage: None,
514 rebalance_protocol_fee: None,
515 spot_position_size_limit_a: None,
516 spot_position_size_limit_b: None,
517 __remaining_accounts: Vec::new(),
518 });
519 Self { instruction }
520 }
521 #[inline(always)]
522 pub fn authority(&mut self, authority: &'b solana_account_info::AccountInfo<'a>) -> &mut Self {
523 self.instruction.authority = Some(authority);
524 self
525 }
526 #[inline(always)]
527 pub fn tuna_config(&mut self, tuna_config: &'b solana_account_info::AccountInfo<'a>) -> &mut Self {
528 self.instruction.tuna_config = Some(tuna_config);
529 self
530 }
531 #[inline(always)]
532 pub fn market(&mut self, market: &'b solana_account_info::AccountInfo<'a>) -> &mut Self {
533 self.instruction.market = Some(market);
534 self
535 }
536 #[inline(always)]
537 pub fn vault_a(&mut self, vault_a: &'b solana_account_info::AccountInfo<'a>) -> &mut Self {
538 self.instruction.vault_a = Some(vault_a);
539 self
540 }
541 #[inline(always)]
542 pub fn vault_b(&mut self, vault_b: &'b solana_account_info::AccountInfo<'a>) -> &mut Self {
543 self.instruction.vault_b = Some(vault_b);
544 self
545 }
546 #[inline(always)]
547 pub fn pool(&mut self, pool: &'b solana_account_info::AccountInfo<'a>) -> &mut Self {
548 self.instruction.pool = Some(pool);
549 self
550 }
551 #[inline(always)]
552 pub fn system_program(&mut self, system_program: &'b solana_account_info::AccountInfo<'a>) -> &mut Self {
553 self.instruction.system_program = Some(system_program);
554 self
555 }
556 #[inline(always)]
557 pub fn address_lookup_table(&mut self, address_lookup_table: Pubkey) -> &mut Self {
558 self.instruction.address_lookup_table = Some(address_lookup_table);
559 self
560 }
561 #[inline(always)]
562 pub fn max_leverage(&mut self, max_leverage: u32) -> &mut Self {
563 self.instruction.max_leverage = Some(max_leverage);
564 self
565 }
566 #[inline(always)]
567 pub fn protocol_fee(&mut self, protocol_fee: u16) -> &mut Self {
568 self.instruction.protocol_fee = Some(protocol_fee);
569 self
570 }
571 #[inline(always)]
572 pub fn protocol_fee_on_collateral(&mut self, protocol_fee_on_collateral: u16) -> &mut Self {
573 self.instruction.protocol_fee_on_collateral = Some(protocol_fee_on_collateral);
574 self
575 }
576 #[inline(always)]
577 pub fn liquidation_fee(&mut self, liquidation_fee: u32) -> &mut Self {
578 self.instruction.liquidation_fee = Some(liquidation_fee);
579 self
580 }
581 #[inline(always)]
582 pub fn liquidation_threshold(&mut self, liquidation_threshold: u32) -> &mut Self {
583 self.instruction.liquidation_threshold = Some(liquidation_threshold);
584 self
585 }
586 #[inline(always)]
587 pub fn oracle_price_deviation_threshold(&mut self, oracle_price_deviation_threshold: u32) -> &mut Self {
588 self.instruction.oracle_price_deviation_threshold = Some(oracle_price_deviation_threshold);
589 self
590 }
591 #[inline(always)]
592 pub fn disabled(&mut self, disabled: bool) -> &mut Self {
593 self.instruction.disabled = Some(disabled);
594 self
595 }
596 #[inline(always)]
597 pub fn borrow_limit_a(&mut self, borrow_limit_a: u64) -> &mut Self {
598 self.instruction.borrow_limit_a = Some(borrow_limit_a);
599 self
600 }
601 #[inline(always)]
602 pub fn borrow_limit_b(&mut self, borrow_limit_b: u64) -> &mut Self {
603 self.instruction.borrow_limit_b = Some(borrow_limit_b);
604 self
605 }
606 #[inline(always)]
607 pub fn max_swap_slippage(&mut self, max_swap_slippage: u32) -> &mut Self {
608 self.instruction.max_swap_slippage = Some(max_swap_slippage);
609 self
610 }
611 #[inline(always)]
612 pub fn rebalance_protocol_fee(&mut self, rebalance_protocol_fee: u32) -> &mut Self {
613 self.instruction.rebalance_protocol_fee = Some(rebalance_protocol_fee);
614 self
615 }
616 #[inline(always)]
617 pub fn spot_position_size_limit_a(&mut self, spot_position_size_limit_a: u64) -> &mut Self {
618 self.instruction.spot_position_size_limit_a = Some(spot_position_size_limit_a);
619 self
620 }
621 #[inline(always)]
622 pub fn spot_position_size_limit_b(&mut self, spot_position_size_limit_b: u64) -> &mut Self {
623 self.instruction.spot_position_size_limit_b = Some(spot_position_size_limit_b);
624 self
625 }
626 #[inline(always)]
628 pub fn add_remaining_account(&mut self, account: &'b solana_account_info::AccountInfo<'a>, is_writable: bool, is_signer: bool) -> &mut Self {
629 self.instruction.__remaining_accounts.push((account, is_writable, is_signer));
630 self
631 }
632 #[inline(always)]
637 pub fn add_remaining_accounts(&mut self, accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)]) -> &mut Self {
638 self.instruction.__remaining_accounts.extend_from_slice(accounts);
639 self
640 }
641 #[inline(always)]
642 pub fn invoke(&self) -> solana_program_error::ProgramResult {
643 self.invoke_signed(&[])
644 }
645 #[allow(clippy::clone_on_copy)]
646 #[allow(clippy::vec_init_then_push)]
647 pub fn invoke_signed(&self, signers_seeds: &[&[&[u8]]]) -> solana_program_error::ProgramResult {
648 let args = CreateMarketInstructionArgs {
649 address_lookup_table: self.instruction.address_lookup_table.clone().expect("address_lookup_table is not set"),
650 max_leverage: self.instruction.max_leverage.clone().expect("max_leverage is not set"),
651 protocol_fee: self.instruction.protocol_fee.clone().expect("protocol_fee is not set"),
652 protocol_fee_on_collateral: self.instruction.protocol_fee_on_collateral.clone().expect("protocol_fee_on_collateral is not set"),
653 liquidation_fee: self.instruction.liquidation_fee.clone().expect("liquidation_fee is not set"),
654 liquidation_threshold: self.instruction.liquidation_threshold.clone().expect("liquidation_threshold is not set"),
655 oracle_price_deviation_threshold: self.instruction.oracle_price_deviation_threshold.clone().expect("oracle_price_deviation_threshold is not set"),
656 disabled: self.instruction.disabled.clone().expect("disabled is not set"),
657 borrow_limit_a: self.instruction.borrow_limit_a.clone().expect("borrow_limit_a is not set"),
658 borrow_limit_b: self.instruction.borrow_limit_b.clone().expect("borrow_limit_b is not set"),
659 max_swap_slippage: self.instruction.max_swap_slippage.clone().expect("max_swap_slippage is not set"),
660 rebalance_protocol_fee: self.instruction.rebalance_protocol_fee.clone().expect("rebalance_protocol_fee is not set"),
661 spot_position_size_limit_a: self.instruction.spot_position_size_limit_a.clone().expect("spot_position_size_limit_a is not set"),
662 spot_position_size_limit_b: self.instruction.spot_position_size_limit_b.clone().expect("spot_position_size_limit_b is not set"),
663 };
664 let instruction = CreateMarketCpi {
665 __program: self.instruction.__program,
666
667 authority: self.instruction.authority.expect("authority is not set"),
668
669 tuna_config: self.instruction.tuna_config.expect("tuna_config is not set"),
670
671 market: self.instruction.market.expect("market is not set"),
672
673 vault_a: self.instruction.vault_a.expect("vault_a is not set"),
674
675 vault_b: self.instruction.vault_b.expect("vault_b is not set"),
676
677 pool: self.instruction.pool.expect("pool is not set"),
678
679 system_program: self.instruction.system_program.expect("system_program is not set"),
680 __args: args,
681 };
682 instruction.invoke_signed_with_remaining_accounts(signers_seeds, &self.instruction.__remaining_accounts)
683 }
684}
685
686#[derive(Clone, Debug)]
687struct CreateMarketCpiBuilderInstruction<'a, 'b> {
688 __program: &'b solana_account_info::AccountInfo<'a>,
689 authority: Option<&'b solana_account_info::AccountInfo<'a>>,
690 tuna_config: Option<&'b solana_account_info::AccountInfo<'a>>,
691 market: Option<&'b solana_account_info::AccountInfo<'a>>,
692 vault_a: Option<&'b solana_account_info::AccountInfo<'a>>,
693 vault_b: Option<&'b solana_account_info::AccountInfo<'a>>,
694 pool: Option<&'b solana_account_info::AccountInfo<'a>>,
695 system_program: Option<&'b solana_account_info::AccountInfo<'a>>,
696 address_lookup_table: Option<Pubkey>,
697 max_leverage: Option<u32>,
698 protocol_fee: Option<u16>,
699 protocol_fee_on_collateral: Option<u16>,
700 liquidation_fee: Option<u32>,
701 liquidation_threshold: Option<u32>,
702 oracle_price_deviation_threshold: Option<u32>,
703 disabled: Option<bool>,
704 borrow_limit_a: Option<u64>,
705 borrow_limit_b: Option<u64>,
706 max_swap_slippage: Option<u32>,
707 rebalance_protocol_fee: Option<u32>,
708 spot_position_size_limit_a: Option<u64>,
709 spot_position_size_limit_b: Option<u64>,
710 __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>,
712}
713