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