1use crate::generated::types::SlippageTolerance;
8use borsh::{BorshDeserialize, BorshSerialize};
9
10pub const SWAP_EXACT_IN_DISCRIMINATOR: u8 = 2;
11
12#[derive(Debug)]
14pub struct SwapExactIn {
15 pub authority: solana_pubkey::Pubkey,
17 pub market: solana_pubkey::Pubkey,
19 pub mint_a: solana_pubkey::Pubkey,
21 pub mint_b: solana_pubkey::Pubkey,
23 pub authority_a: solana_pubkey::Pubkey,
25 pub authority_b: solana_pubkey::Pubkey,
27 pub market_a: solana_pubkey::Pubkey,
29 pub market_b: solana_pubkey::Pubkey,
31 pub token_program_a: solana_pubkey::Pubkey,
33 pub token_program_b: solana_pubkey::Pubkey,
35 pub memo_program: solana_pubkey::Pubkey,
37 pub instructions_sysvar: solana_pubkey::Pubkey,
39}
40
41impl SwapExactIn {
42 pub fn instruction(&self, args: SwapExactInInstructionArgs) -> solana_instruction::Instruction {
43 self.instruction_with_remaining_accounts(args, &[])
44 }
45 #[allow(clippy::arithmetic_side_effects)]
46 #[allow(clippy::vec_init_then_push)]
47 pub fn instruction_with_remaining_accounts(
48 &self,
49 args: SwapExactInInstructionArgs,
50 remaining_accounts: &[solana_instruction::AccountMeta],
51 ) -> solana_instruction::Instruction {
52 let mut accounts = Vec::with_capacity(12 + remaining_accounts.len());
53 accounts.push(solana_instruction::AccountMeta::new_readonly(
54 self.authority,
55 true,
56 ));
57 accounts.push(solana_instruction::AccountMeta::new_readonly(
58 self.market,
59 false,
60 ));
61 accounts.push(solana_instruction::AccountMeta::new_readonly(
62 self.mint_a,
63 false,
64 ));
65 accounts.push(solana_instruction::AccountMeta::new_readonly(
66 self.mint_b,
67 false,
68 ));
69 accounts.push(solana_instruction::AccountMeta::new(
70 self.authority_a,
71 false,
72 ));
73 accounts.push(solana_instruction::AccountMeta::new(
74 self.authority_b,
75 false,
76 ));
77 accounts.push(solana_instruction::AccountMeta::new(self.market_a, false));
78 accounts.push(solana_instruction::AccountMeta::new(self.market_b, false));
79 accounts.push(solana_instruction::AccountMeta::new_readonly(
80 self.token_program_a,
81 false,
82 ));
83 accounts.push(solana_instruction::AccountMeta::new_readonly(
84 self.token_program_b,
85 false,
86 ));
87 accounts.push(solana_instruction::AccountMeta::new_readonly(
88 self.memo_program,
89 false,
90 ));
91 accounts.push(solana_instruction::AccountMeta::new_readonly(
92 self.instructions_sysvar,
93 false,
94 ));
95 accounts.extend_from_slice(remaining_accounts);
96 let mut data = SwapExactInInstructionData::new().try_to_vec().unwrap();
97 let mut args = args.try_to_vec().unwrap();
98 data.append(&mut args);
99
100 solana_instruction::Instruction {
101 program_id: crate::RIPTIDE_ID,
102 accounts,
103 data,
104 }
105 }
106}
107
108#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)]
109#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
110pub struct SwapExactInInstructionData {
111 discriminator: u8,
112}
113
114impl SwapExactInInstructionData {
115 pub fn new() -> Self {
116 Self { discriminator: 2 }
117 }
118
119 pub(crate) fn try_to_vec(&self) -> Result<Vec<u8>, std::io::Error> {
120 borsh::to_vec(self)
121 }
122}
123
124impl Default for SwapExactInInstructionData {
125 fn default() -> Self {
126 Self::new()
127 }
128}
129
130#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)]
131#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
132pub struct SwapExactInInstructionArgs {
133 pub amount_in: u64,
134 pub amount_is_token_a: bool,
135 pub slippage_tolerance: SlippageTolerance,
136 pub allow_partial_fill: bool,
137}
138
139impl SwapExactInInstructionArgs {
140 pub(crate) fn try_to_vec(&self) -> Result<Vec<u8>, std::io::Error> {
141 borsh::to_vec(self)
142 }
143}
144
145#[derive(Clone, Debug, Default)]
163pub struct SwapExactInBuilder {
164 authority: Option<solana_pubkey::Pubkey>,
165 market: Option<solana_pubkey::Pubkey>,
166 mint_a: Option<solana_pubkey::Pubkey>,
167 mint_b: Option<solana_pubkey::Pubkey>,
168 authority_a: Option<solana_pubkey::Pubkey>,
169 authority_b: Option<solana_pubkey::Pubkey>,
170 market_a: Option<solana_pubkey::Pubkey>,
171 market_b: Option<solana_pubkey::Pubkey>,
172 token_program_a: Option<solana_pubkey::Pubkey>,
173 token_program_b: Option<solana_pubkey::Pubkey>,
174 memo_program: Option<solana_pubkey::Pubkey>,
175 instructions_sysvar: Option<solana_pubkey::Pubkey>,
176 amount_in: Option<u64>,
177 amount_is_token_a: Option<bool>,
178 slippage_tolerance: Option<SlippageTolerance>,
179 allow_partial_fill: Option<bool>,
180 __remaining_accounts: Vec<solana_instruction::AccountMeta>,
181}
182
183impl SwapExactInBuilder {
184 pub fn new() -> Self {
185 Self::default()
186 }
187 #[inline(always)]
189 pub fn authority(&mut self, authority: solana_pubkey::Pubkey) -> &mut Self {
190 self.authority = Some(authority);
191 self
192 }
193 #[inline(always)]
195 pub fn market(&mut self, market: solana_pubkey::Pubkey) -> &mut Self {
196 self.market = Some(market);
197 self
198 }
199 #[inline(always)]
201 pub fn mint_a(&mut self, mint_a: solana_pubkey::Pubkey) -> &mut Self {
202 self.mint_a = Some(mint_a);
203 self
204 }
205 #[inline(always)]
207 pub fn mint_b(&mut self, mint_b: solana_pubkey::Pubkey) -> &mut Self {
208 self.mint_b = Some(mint_b);
209 self
210 }
211 #[inline(always)]
213 pub fn authority_a(&mut self, authority_a: solana_pubkey::Pubkey) -> &mut Self {
214 self.authority_a = Some(authority_a);
215 self
216 }
217 #[inline(always)]
219 pub fn authority_b(&mut self, authority_b: solana_pubkey::Pubkey) -> &mut Self {
220 self.authority_b = Some(authority_b);
221 self
222 }
223 #[inline(always)]
225 pub fn market_a(&mut self, market_a: solana_pubkey::Pubkey) -> &mut Self {
226 self.market_a = Some(market_a);
227 self
228 }
229 #[inline(always)]
231 pub fn market_b(&mut self, market_b: solana_pubkey::Pubkey) -> &mut Self {
232 self.market_b = Some(market_b);
233 self
234 }
235 #[inline(always)]
237 pub fn token_program_a(&mut self, token_program_a: solana_pubkey::Pubkey) -> &mut Self {
238 self.token_program_a = Some(token_program_a);
239 self
240 }
241 #[inline(always)]
243 pub fn token_program_b(&mut self, token_program_b: solana_pubkey::Pubkey) -> &mut Self {
244 self.token_program_b = Some(token_program_b);
245 self
246 }
247 #[inline(always)]
249 pub fn memo_program(&mut self, memo_program: solana_pubkey::Pubkey) -> &mut Self {
250 self.memo_program = Some(memo_program);
251 self
252 }
253 #[inline(always)]
256 pub fn instructions_sysvar(&mut self, instructions_sysvar: solana_pubkey::Pubkey) -> &mut Self {
257 self.instructions_sysvar = Some(instructions_sysvar);
258 self
259 }
260 #[inline(always)]
261 pub fn amount_in(&mut self, amount_in: u64) -> &mut Self {
262 self.amount_in = Some(amount_in);
263 self
264 }
265 #[inline(always)]
266 pub fn amount_is_token_a(&mut self, amount_is_token_a: bool) -> &mut Self {
267 self.amount_is_token_a = Some(amount_is_token_a);
268 self
269 }
270 #[inline(always)]
271 pub fn slippage_tolerance(&mut self, slippage_tolerance: SlippageTolerance) -> &mut Self {
272 self.slippage_tolerance = Some(slippage_tolerance);
273 self
274 }
275 #[inline(always)]
276 pub fn allow_partial_fill(&mut self, allow_partial_fill: bool) -> &mut Self {
277 self.allow_partial_fill = Some(allow_partial_fill);
278 self
279 }
280 #[inline(always)]
282 pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self {
283 self.__remaining_accounts.push(account);
284 self
285 }
286 #[inline(always)]
288 pub fn add_remaining_accounts(
289 &mut self,
290 accounts: &[solana_instruction::AccountMeta],
291 ) -> &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 = SwapExactIn {
298 authority: self.authority.expect("authority is not set"),
299 market: self.market.expect("market is not set"),
300 mint_a: self.mint_a.expect("mint_a is not set"),
301 mint_b: self.mint_b.expect("mint_b is not set"),
302 authority_a: self.authority_a.expect("authority_a is not set"),
303 authority_b: self.authority_b.expect("authority_b is not set"),
304 market_a: self.market_a.expect("market_a is not set"),
305 market_b: self.market_b.expect("market_b is not set"),
306 token_program_a: self.token_program_a.expect("token_program_a is not set"),
307 token_program_b: self.token_program_b.expect("token_program_b is not set"),
308 memo_program: self.memo_program.expect("memo_program is not set"),
309 instructions_sysvar: self.instructions_sysvar.unwrap_or(solana_pubkey::pubkey!(
310 "Sysvar1nstructions1111111111111111111111111"
311 )),
312 };
313 let args = SwapExactInInstructionArgs {
314 amount_in: self.amount_in.clone().expect("amount_in is not set"),
315 amount_is_token_a: self
316 .amount_is_token_a
317 .clone()
318 .expect("amount_is_token_a is not set"),
319 slippage_tolerance: self
320 .slippage_tolerance
321 .clone()
322 .expect("slippage_tolerance is not set"),
323 allow_partial_fill: self
324 .allow_partial_fill
325 .clone()
326 .expect("allow_partial_fill is not set"),
327 };
328
329 accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts)
330 }
331}
332
333pub struct SwapExactInCpiAccounts<'a, 'b> {
335 pub authority: &'b solana_account_info::AccountInfo<'a>,
337 pub market: &'b solana_account_info::AccountInfo<'a>,
339 pub mint_a: &'b solana_account_info::AccountInfo<'a>,
341 pub mint_b: &'b solana_account_info::AccountInfo<'a>,
343 pub authority_a: &'b solana_account_info::AccountInfo<'a>,
345 pub authority_b: &'b solana_account_info::AccountInfo<'a>,
347 pub market_a: &'b solana_account_info::AccountInfo<'a>,
349 pub market_b: &'b solana_account_info::AccountInfo<'a>,
351 pub token_program_a: &'b solana_account_info::AccountInfo<'a>,
353 pub token_program_b: &'b solana_account_info::AccountInfo<'a>,
355 pub memo_program: &'b solana_account_info::AccountInfo<'a>,
357 pub instructions_sysvar: &'b solana_account_info::AccountInfo<'a>,
359}
360
361pub struct SwapExactInCpi<'a, 'b> {
363 pub __program: &'b solana_account_info::AccountInfo<'a>,
365 pub authority: &'b solana_account_info::AccountInfo<'a>,
367 pub market: &'b solana_account_info::AccountInfo<'a>,
369 pub mint_a: &'b solana_account_info::AccountInfo<'a>,
371 pub mint_b: &'b solana_account_info::AccountInfo<'a>,
373 pub authority_a: &'b solana_account_info::AccountInfo<'a>,
375 pub authority_b: &'b solana_account_info::AccountInfo<'a>,
377 pub market_a: &'b solana_account_info::AccountInfo<'a>,
379 pub market_b: &'b solana_account_info::AccountInfo<'a>,
381 pub token_program_a: &'b solana_account_info::AccountInfo<'a>,
383 pub token_program_b: &'b solana_account_info::AccountInfo<'a>,
385 pub memo_program: &'b solana_account_info::AccountInfo<'a>,
387 pub instructions_sysvar: &'b solana_account_info::AccountInfo<'a>,
389 pub __args: SwapExactInInstructionArgs,
391}
392
393impl<'a, 'b> SwapExactInCpi<'a, 'b> {
394 pub fn new(
395 program: &'b solana_account_info::AccountInfo<'a>,
396 accounts: SwapExactInCpiAccounts<'a, 'b>,
397 args: SwapExactInInstructionArgs,
398 ) -> Self {
399 Self {
400 __program: program,
401 authority: accounts.authority,
402 market: accounts.market,
403 mint_a: accounts.mint_a,
404 mint_b: accounts.mint_b,
405 authority_a: accounts.authority_a,
406 authority_b: accounts.authority_b,
407 market_a: accounts.market_a,
408 market_b: accounts.market_b,
409 token_program_a: accounts.token_program_a,
410 token_program_b: accounts.token_program_b,
411 memo_program: accounts.memo_program,
412 instructions_sysvar: accounts.instructions_sysvar,
413 __args: args,
414 }
415 }
416 #[inline(always)]
417 pub fn invoke(&self) -> solana_program_error::ProgramResult {
418 self.invoke_signed_with_remaining_accounts(&[], &[])
419 }
420 #[inline(always)]
421 pub fn invoke_with_remaining_accounts(
422 &self,
423 remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)],
424 ) -> solana_program_error::ProgramResult {
425 self.invoke_signed_with_remaining_accounts(&[], remaining_accounts)
426 }
427 #[inline(always)]
428 pub fn invoke_signed(&self, signers_seeds: &[&[&[u8]]]) -> solana_program_error::ProgramResult {
429 self.invoke_signed_with_remaining_accounts(signers_seeds, &[])
430 }
431 #[allow(clippy::arithmetic_side_effects)]
432 #[allow(clippy::clone_on_copy)]
433 #[allow(clippy::vec_init_then_push)]
434 pub fn invoke_signed_with_remaining_accounts(
435 &self,
436 signers_seeds: &[&[&[u8]]],
437 remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)],
438 ) -> solana_program_error::ProgramResult {
439 let mut accounts = Vec::with_capacity(12 + remaining_accounts.len());
440 accounts.push(solana_instruction::AccountMeta::new_readonly(
441 *self.authority.key,
442 true,
443 ));
444 accounts.push(solana_instruction::AccountMeta::new_readonly(
445 *self.market.key,
446 false,
447 ));
448 accounts.push(solana_instruction::AccountMeta::new_readonly(
449 *self.mint_a.key,
450 false,
451 ));
452 accounts.push(solana_instruction::AccountMeta::new_readonly(
453 *self.mint_b.key,
454 false,
455 ));
456 accounts.push(solana_instruction::AccountMeta::new(
457 *self.authority_a.key,
458 false,
459 ));
460 accounts.push(solana_instruction::AccountMeta::new(
461 *self.authority_b.key,
462 false,
463 ));
464 accounts.push(solana_instruction::AccountMeta::new(
465 *self.market_a.key,
466 false,
467 ));
468 accounts.push(solana_instruction::AccountMeta::new(
469 *self.market_b.key,
470 false,
471 ));
472 accounts.push(solana_instruction::AccountMeta::new_readonly(
473 *self.token_program_a.key,
474 false,
475 ));
476 accounts.push(solana_instruction::AccountMeta::new_readonly(
477 *self.token_program_b.key,
478 false,
479 ));
480 accounts.push(solana_instruction::AccountMeta::new_readonly(
481 *self.memo_program.key,
482 false,
483 ));
484 accounts.push(solana_instruction::AccountMeta::new_readonly(
485 *self.instructions_sysvar.key,
486 false,
487 ));
488 remaining_accounts.iter().for_each(|remaining_account| {
489 accounts.push(solana_instruction::AccountMeta {
490 pubkey: *remaining_account.0.key,
491 is_signer: remaining_account.1,
492 is_writable: remaining_account.2,
493 })
494 });
495 let mut data = SwapExactInInstructionData::new().try_to_vec().unwrap();
496 let mut args = self.__args.try_to_vec().unwrap();
497 data.append(&mut args);
498
499 let instruction = solana_instruction::Instruction {
500 program_id: crate::RIPTIDE_ID,
501 accounts,
502 data,
503 };
504 let mut account_infos = Vec::with_capacity(13 + remaining_accounts.len());
505 account_infos.push(self.__program.clone());
506 account_infos.push(self.authority.clone());
507 account_infos.push(self.market.clone());
508 account_infos.push(self.mint_a.clone());
509 account_infos.push(self.mint_b.clone());
510 account_infos.push(self.authority_a.clone());
511 account_infos.push(self.authority_b.clone());
512 account_infos.push(self.market_a.clone());
513 account_infos.push(self.market_b.clone());
514 account_infos.push(self.token_program_a.clone());
515 account_infos.push(self.token_program_b.clone());
516 account_infos.push(self.memo_program.clone());
517 account_infos.push(self.instructions_sysvar.clone());
518 remaining_accounts
519 .iter()
520 .for_each(|remaining_account| account_infos.push(remaining_account.0.clone()));
521
522 if signers_seeds.is_empty() {
523 solana_cpi::invoke(&instruction, &account_infos)
524 } else {
525 solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds)
526 }
527 }
528}
529
530#[derive(Clone, Debug)]
547pub struct SwapExactInCpiBuilder<'a, 'b> {
548 instruction: Box<SwapExactInCpiBuilderInstruction<'a, 'b>>,
549}
550
551impl<'a, 'b> SwapExactInCpiBuilder<'a, 'b> {
552 pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self {
553 let instruction = Box::new(SwapExactInCpiBuilderInstruction {
554 __program: program,
555 authority: None,
556 market: None,
557 mint_a: None,
558 mint_b: None,
559 authority_a: None,
560 authority_b: None,
561 market_a: None,
562 market_b: None,
563 token_program_a: None,
564 token_program_b: None,
565 memo_program: None,
566 instructions_sysvar: None,
567 amount_in: None,
568 amount_is_token_a: None,
569 slippage_tolerance: None,
570 allow_partial_fill: None,
571 __remaining_accounts: Vec::new(),
572 });
573 Self { instruction }
574 }
575 #[inline(always)]
577 pub fn authority(&mut self, authority: &'b solana_account_info::AccountInfo<'a>) -> &mut Self {
578 self.instruction.authority = Some(authority);
579 self
580 }
581 #[inline(always)]
583 pub fn market(&mut self, market: &'b solana_account_info::AccountInfo<'a>) -> &mut Self {
584 self.instruction.market = Some(market);
585 self
586 }
587 #[inline(always)]
589 pub fn mint_a(&mut self, mint_a: &'b solana_account_info::AccountInfo<'a>) -> &mut Self {
590 self.instruction.mint_a = Some(mint_a);
591 self
592 }
593 #[inline(always)]
595 pub fn mint_b(&mut self, mint_b: &'b solana_account_info::AccountInfo<'a>) -> &mut Self {
596 self.instruction.mint_b = Some(mint_b);
597 self
598 }
599 #[inline(always)]
601 pub fn authority_a(
602 &mut self,
603 authority_a: &'b solana_account_info::AccountInfo<'a>,
604 ) -> &mut Self {
605 self.instruction.authority_a = Some(authority_a);
606 self
607 }
608 #[inline(always)]
610 pub fn authority_b(
611 &mut self,
612 authority_b: &'b solana_account_info::AccountInfo<'a>,
613 ) -> &mut Self {
614 self.instruction.authority_b = Some(authority_b);
615 self
616 }
617 #[inline(always)]
619 pub fn market_a(&mut self, market_a: &'b solana_account_info::AccountInfo<'a>) -> &mut Self {
620 self.instruction.market_a = Some(market_a);
621 self
622 }
623 #[inline(always)]
625 pub fn market_b(&mut self, market_b: &'b solana_account_info::AccountInfo<'a>) -> &mut Self {
626 self.instruction.market_b = Some(market_b);
627 self
628 }
629 #[inline(always)]
631 pub fn token_program_a(
632 &mut self,
633 token_program_a: &'b solana_account_info::AccountInfo<'a>,
634 ) -> &mut Self {
635 self.instruction.token_program_a = Some(token_program_a);
636 self
637 }
638 #[inline(always)]
640 pub fn token_program_b(
641 &mut self,
642 token_program_b: &'b solana_account_info::AccountInfo<'a>,
643 ) -> &mut Self {
644 self.instruction.token_program_b = Some(token_program_b);
645 self
646 }
647 #[inline(always)]
649 pub fn memo_program(
650 &mut self,
651 memo_program: &'b solana_account_info::AccountInfo<'a>,
652 ) -> &mut Self {
653 self.instruction.memo_program = Some(memo_program);
654 self
655 }
656 #[inline(always)]
658 pub fn instructions_sysvar(
659 &mut self,
660 instructions_sysvar: &'b solana_account_info::AccountInfo<'a>,
661 ) -> &mut Self {
662 self.instruction.instructions_sysvar = Some(instructions_sysvar);
663 self
664 }
665 #[inline(always)]
666 pub fn amount_in(&mut self, amount_in: u64) -> &mut Self {
667 self.instruction.amount_in = Some(amount_in);
668 self
669 }
670 #[inline(always)]
671 pub fn amount_is_token_a(&mut self, amount_is_token_a: bool) -> &mut Self {
672 self.instruction.amount_is_token_a = Some(amount_is_token_a);
673 self
674 }
675 #[inline(always)]
676 pub fn slippage_tolerance(&mut self, slippage_tolerance: SlippageTolerance) -> &mut Self {
677 self.instruction.slippage_tolerance = Some(slippage_tolerance);
678 self
679 }
680 #[inline(always)]
681 pub fn allow_partial_fill(&mut self, allow_partial_fill: bool) -> &mut Self {
682 self.instruction.allow_partial_fill = Some(allow_partial_fill);
683 self
684 }
685 #[inline(always)]
687 pub fn add_remaining_account(
688 &mut self,
689 account: &'b solana_account_info::AccountInfo<'a>,
690 is_writable: bool,
691 is_signer: bool,
692 ) -> &mut Self {
693 self.instruction
694 .__remaining_accounts
695 .push((account, is_writable, is_signer));
696 self
697 }
698 #[inline(always)]
704 pub fn add_remaining_accounts(
705 &mut self,
706 accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)],
707 ) -> &mut Self {
708 self.instruction
709 .__remaining_accounts
710 .extend_from_slice(accounts);
711 self
712 }
713 #[inline(always)]
714 pub fn invoke(&self) -> solana_program_error::ProgramResult {
715 self.invoke_signed(&[])
716 }
717 #[allow(clippy::clone_on_copy)]
718 #[allow(clippy::vec_init_then_push)]
719 pub fn invoke_signed(&self, signers_seeds: &[&[&[u8]]]) -> solana_program_error::ProgramResult {
720 let args = SwapExactInInstructionArgs {
721 amount_in: self
722 .instruction
723 .amount_in
724 .clone()
725 .expect("amount_in is not set"),
726 amount_is_token_a: self
727 .instruction
728 .amount_is_token_a
729 .clone()
730 .expect("amount_is_token_a is not set"),
731 slippage_tolerance: self
732 .instruction
733 .slippage_tolerance
734 .clone()
735 .expect("slippage_tolerance is not set"),
736 allow_partial_fill: self
737 .instruction
738 .allow_partial_fill
739 .clone()
740 .expect("allow_partial_fill is not set"),
741 };
742 let instruction = SwapExactInCpi {
743 __program: self.instruction.__program,
744
745 authority: self.instruction.authority.expect("authority is not set"),
746
747 market: self.instruction.market.expect("market is not set"),
748
749 mint_a: self.instruction.mint_a.expect("mint_a is not set"),
750
751 mint_b: self.instruction.mint_b.expect("mint_b is not set"),
752
753 authority_a: self
754 .instruction
755 .authority_a
756 .expect("authority_a is not set"),
757
758 authority_b: self
759 .instruction
760 .authority_b
761 .expect("authority_b is not set"),
762
763 market_a: self.instruction.market_a.expect("market_a is not set"),
764
765 market_b: self.instruction.market_b.expect("market_b is not set"),
766
767 token_program_a: self
768 .instruction
769 .token_program_a
770 .expect("token_program_a is not set"),
771
772 token_program_b: self
773 .instruction
774 .token_program_b
775 .expect("token_program_b is not set"),
776
777 memo_program: self
778 .instruction
779 .memo_program
780 .expect("memo_program is not set"),
781
782 instructions_sysvar: self
783 .instruction
784 .instructions_sysvar
785 .expect("instructions_sysvar is not set"),
786 __args: args,
787 };
788 instruction.invoke_signed_with_remaining_accounts(
789 signers_seeds,
790 &self.instruction.__remaining_accounts,
791 )
792 }
793}
794
795#[derive(Clone, Debug)]
796struct SwapExactInCpiBuilderInstruction<'a, 'b> {
797 __program: &'b solana_account_info::AccountInfo<'a>,
798 authority: Option<&'b solana_account_info::AccountInfo<'a>>,
799 market: Option<&'b solana_account_info::AccountInfo<'a>>,
800 mint_a: Option<&'b solana_account_info::AccountInfo<'a>>,
801 mint_b: Option<&'b solana_account_info::AccountInfo<'a>>,
802 authority_a: Option<&'b solana_account_info::AccountInfo<'a>>,
803 authority_b: Option<&'b solana_account_info::AccountInfo<'a>>,
804 market_a: Option<&'b solana_account_info::AccountInfo<'a>>,
805 market_b: Option<&'b solana_account_info::AccountInfo<'a>>,
806 token_program_a: Option<&'b solana_account_info::AccountInfo<'a>>,
807 token_program_b: Option<&'b solana_account_info::AccountInfo<'a>>,
808 memo_program: Option<&'b solana_account_info::AccountInfo<'a>>,
809 instructions_sysvar: Option<&'b solana_account_info::AccountInfo<'a>>,
810 amount_in: Option<u64>,
811 amount_is_token_a: Option<bool>,
812 slippage_tolerance: Option<SlippageTolerance>,
813 allow_partial_fill: Option<bool>,
814 __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>,
816}