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