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