1#![allow(
2 clippy::all,
3 clippy::pedantic,
4 clippy::nursery,
5 clippy::expect_used,
6 clippy::unwrap_used,
7 clippy::indexing_slicing,
8 clippy::allow_attributes,
9 clippy::allow_attributes_without_reason,
10 clippy::mem_forget,
11 unfulfilled_lint_expectations,
12 unexpected_cfgs,
13 unused_imports
14)]
15
16use borsh::BorshDeserialize;
24use borsh::BorshSerialize;
25
26pub const MIGRATE_DISCRIMINATOR: [u8; 8] =
27 [155, 234, 231, 146, 236, 158, 162, 30];
28
29#[derive(Debug)]
31pub struct Migrate {
32 pub caller: solana_address::Address,
33 pub bonding_curve: solana_address::Address,
34 pub base_mint: solana_address::Address,
35 pub quote_mint: solana_address::Address,
36 pub base_vault: solana_address::Address,
37 pub quote_vault: solana_address::Address,
38 pub dex_program: solana_address::Address,
39 pub migration_authority: solana_address::Address,
40 pub pool: solana_address::Address,
41 pub lp_mint: solana_address::Address,
42 pub pool_base_vault: solana_address::Address,
43 pub pool_quote_vault: solana_address::Address,
44 pub pool_lp_account: solana_address::Address,
45 pub dex_event_authority: solana_address::Address,
46 pub nexus_program: solana_address::Address,
47 pub creator_fee_config: solana_address::Address,
48 pub base_token_program: solana_address::Address,
49 pub quote_token_program: solana_address::Address,
50 pub associated_token_program: solana_address::Address,
51 pub system_program: solana_address::Address,
52 pub event_authority: solana_address::Address,
53 pub program: solana_address::Address,
54}
55
56impl Migrate {
57 pub fn instruction(&self) -> solana_instruction::Instruction {
58 self.instruction_with_remaining_accounts(&[])
59 }
60 #[allow(clippy::arithmetic_side_effects)]
61 #[allow(clippy::vec_init_then_push)]
62 pub fn instruction_with_remaining_accounts(
63 &self,
64 remaining_accounts: &[solana_instruction::AccountMeta],
65 ) -> solana_instruction::Instruction {
66 let mut accounts = Vec::with_capacity(22 + remaining_accounts.len());
67 accounts.push(solana_instruction::AccountMeta::new(self.caller, true));
68 accounts.push(solana_instruction::AccountMeta::new(
69 self.bonding_curve,
70 false,
71 ));
72 accounts
73 .push(solana_instruction::AccountMeta::new(self.base_mint, false));
74 accounts.push(solana_instruction::AccountMeta::new_readonly(
75 self.quote_mint,
76 false,
77 ));
78 accounts
79 .push(solana_instruction::AccountMeta::new(self.base_vault, false));
80 accounts.push(solana_instruction::AccountMeta::new(
81 self.quote_vault,
82 false,
83 ));
84 accounts.push(solana_instruction::AccountMeta::new_readonly(
85 self.dex_program,
86 false,
87 ));
88 accounts.push(solana_instruction::AccountMeta::new_readonly(
89 self.migration_authority,
90 false,
91 ));
92 accounts.push(solana_instruction::AccountMeta::new(self.pool, false));
93 accounts
94 .push(solana_instruction::AccountMeta::new(self.lp_mint, false));
95 accounts.push(solana_instruction::AccountMeta::new(
96 self.pool_base_vault,
97 false,
98 ));
99 accounts.push(solana_instruction::AccountMeta::new(
100 self.pool_quote_vault,
101 false,
102 ));
103 accounts.push(solana_instruction::AccountMeta::new(
104 self.pool_lp_account,
105 false,
106 ));
107 accounts.push(solana_instruction::AccountMeta::new_readonly(
108 self.dex_event_authority,
109 false,
110 ));
111 accounts.push(solana_instruction::AccountMeta::new_readonly(
112 self.nexus_program,
113 false,
114 ));
115 accounts.push(solana_instruction::AccountMeta::new_readonly(
116 self.creator_fee_config,
117 false,
118 ));
119 accounts.push(solana_instruction::AccountMeta::new_readonly(
120 self.base_token_program,
121 false,
122 ));
123 accounts.push(solana_instruction::AccountMeta::new_readonly(
124 self.quote_token_program,
125 false,
126 ));
127 accounts.push(solana_instruction::AccountMeta::new_readonly(
128 self.associated_token_program,
129 false,
130 ));
131 accounts.push(solana_instruction::AccountMeta::new_readonly(
132 self.system_program,
133 false,
134 ));
135 accounts.push(solana_instruction::AccountMeta::new_readonly(
136 self.event_authority,
137 false,
138 ));
139 accounts.push(solana_instruction::AccountMeta::new_readonly(
140 self.program,
141 false,
142 ));
143 accounts.extend_from_slice(remaining_accounts);
144 let data = MigrateInstructionData::new().try_to_vec().unwrap();
145
146 solana_instruction::Instruction {
147 program_id: crate::launchpad::generated::SEND_LAUNCHPAD_ID,
148 accounts,
149 data,
150 }
151 }
152}
153
154#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)]
155#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
156#[cfg_attr(feature = "serde", serde(rename_all = "camelCase"))]
157pub struct MigrateInstructionData {
158 discriminator: [u8; 8],
159}
160
161impl MigrateInstructionData {
162 pub fn new() -> Self {
163 Self {
164 discriminator: [155, 234, 231, 146, 236, 158, 162, 30],
165 }
166 }
167
168 pub(crate) fn try_to_vec(&self) -> Result<Vec<u8>, std::io::Error> {
169 borsh::to_vec(self)
170 }
171}
172
173impl Default for MigrateInstructionData {
174 fn default() -> Self {
175 Self::new()
176 }
177}
178
179#[derive(Clone, Debug)]
206pub struct MigrateBuilder {
207 caller: solana_address::Address,
208 bonding_curve: Option<solana_address::Address>,
209 base_mint: solana_address::Address,
210 quote_mint: solana_address::Address,
211 base_vault: Option<solana_address::Address>,
212 quote_vault: Option<solana_address::Address>,
213 pool: Option<solana_address::Address>,
214 lp_mint: Option<solana_address::Address>,
215 pool_base_vault: solana_address::Address,
216 pool_quote_vault: solana_address::Address,
217 pool_lp_account: solana_address::Address,
218 creator_fee_config: solana_address::Address,
219 quote_token_program: solana_address::Address,
220 __remaining_accounts: Vec<solana_instruction::AccountMeta>,
221}
222
223impl MigrateBuilder {
224 pub fn new(
225 caller: solana_address::Address,
226 base_mint: solana_address::Address,
227 quote_mint: solana_address::Address,
228 pool_base_vault: solana_address::Address,
229 pool_quote_vault: solana_address::Address,
230 pool_lp_account: solana_address::Address,
231 creator_fee_config: solana_address::Address,
232 quote_token_program: solana_address::Address,
233 ) -> Self {
234 Self {
235 caller,
236 bonding_curve: None,
237 base_mint,
238 quote_mint,
239 base_vault: None,
240 quote_vault: None,
241 pool: None,
242 lp_mint: None,
243 pool_base_vault,
244 pool_quote_vault,
245 pool_lp_account,
246 creator_fee_config,
247 quote_token_program,
248 __remaining_accounts: Vec::new(),
249 }
250 }
251 #[inline(always)]
253 pub fn bonding_curve(
254 &mut self,
255 bonding_curve: solana_address::Address,
256 ) -> &mut Self {
257 self.bonding_curve = Some(bonding_curve);
258 self
259 }
260 #[inline(always)]
262 pub fn base_vault(
263 &mut self,
264 base_vault: solana_address::Address,
265 ) -> &mut Self {
266 self.base_vault = Some(base_vault);
267 self
268 }
269 #[inline(always)]
271 pub fn quote_vault(
272 &mut self,
273 quote_vault: solana_address::Address,
274 ) -> &mut Self {
275 self.quote_vault = Some(quote_vault);
276 self
277 }
278 #[inline(always)]
280 pub fn pool(&mut self, pool: solana_address::Address) -> &mut Self {
281 self.pool = Some(pool);
282 self
283 }
284 #[inline(always)]
286 pub fn lp_mint(&mut self, lp_mint: solana_address::Address) -> &mut Self {
287 self.lp_mint = Some(lp_mint);
288 self
289 }
290 #[inline(always)]
292 pub fn add_remaining_account(
293 &mut self,
294 account: solana_instruction::AccountMeta,
295 ) -> &mut Self {
296 self.__remaining_accounts.push(account);
297 self
298 }
299 #[inline(always)]
301 pub fn add_remaining_accounts(
302 &mut self,
303 accounts: &[solana_instruction::AccountMeta],
304 ) -> &mut Self {
305 self.__remaining_accounts.extend_from_slice(accounts);
306 self
307 }
308 #[allow(clippy::clone_on_copy)]
309 pub fn instruction(&self) -> solana_instruction::Instruction {
310 let caller = self.caller;
311 let base_mint = self.base_mint;
312 let quote_mint = self.quote_mint;
313 let bonding_curve = self.bonding_curve.unwrap_or_else(|| {
314 crate::launchpad::generated::pdas::find_bonding_curve_pda(
315 &self.base_mint,
316 &self.quote_mint,
317 )
318 .0
319 });
320 let base_vault = self.base_vault.unwrap_or_else(|| {
321 solana_address::Address::find_program_address(
322 &[
323 bonding_curve.as_ref(),
324 &[
325 6, 221, 246, 225, 238, 117, 143, 222, 24, 66, 93, 188,
326 228, 108, 205, 218, 182, 26, 252, 77, 131, 185, 13, 39,
327 254, 189, 249, 40, 216, 161, 139, 252,
328 ],
329 self.base_mint.as_ref(),
330 ],
331 &solana_address::address!(
332 "ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL"
333 ),
334 )
335 .0
336 });
337 let quote_token_program = self.quote_token_program;
338 let quote_vault = self.quote_vault.unwrap_or_else(|| {
339 solana_address::Address::find_program_address(
340 &[
341 bonding_curve.as_ref(),
342 self.quote_token_program.as_ref(),
343 self.quote_mint.as_ref(),
344 ],
345 &solana_address::address!(
346 "ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL"
347 ),
348 )
349 .0
350 });
351 let dex_program = solana_address::address!(
352 "84qj5FPZZdXkQy8mfowyg6RBZ3XKuTds6XS4ZYT1sfDX"
353 );
354 let migration_authority =
355 crate::launchpad::generated::pdas::MIGRATION_AUTHORITY_ADDRESS;
356 let pool = self.pool.unwrap_or_else(|| {
357 solana_address::Address::find_program_address(
358 &[
359 &[112, 111, 111, 108],
360 self.base_mint.as_ref(),
361 self.quote_mint.as_ref(),
362 ],
363 &solana_address::address!(
364 "84qj5FPZZdXkQy8mfowyg6RBZ3XKuTds6XS4ZYT1sfDX"
365 ),
366 )
367 .0
368 });
369 let lp_mint = self.lp_mint.unwrap_or_else(|| {
370 solana_address::Address::find_program_address(
371 &[
372 &[108, 112, 95, 109, 105, 110, 116],
373 self.base_mint.as_ref(),
374 self.quote_mint.as_ref(),
375 ],
376 &solana_address::address!(
377 "84qj5FPZZdXkQy8mfowyg6RBZ3XKuTds6XS4ZYT1sfDX"
378 ),
379 )
380 .0
381 });
382 let pool_base_vault = self.pool_base_vault;
383 let pool_quote_vault = self.pool_quote_vault;
384 let pool_lp_account = self.pool_lp_account;
385 let dex_event_authority = solana_address::address!(
386 "4pTDYKRFdmxTQYFceGZkzPGd3kb8ShMA9n6XKRaPZn8t"
387 );
388 let nexus_program = solana_address::address!(
389 "7rrCurqdWFesbzwtYPo95fM8waTtVXgXwCom45x1sfNX"
390 );
391 let creator_fee_config = self.creator_fee_config;
392 let base_token_program = solana_address::address!(
393 "TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb"
394 );
395 let associated_token_program = solana_address::address!(
396 "ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL"
397 );
398 let system_program =
399 solana_address::address!("11111111111111111111111111111111");
400 let event_authority =
401 crate::launchpad::generated::pdas::EVENT_AUTHORITY_ADDRESS;
402 let program = solana_address::address!(
403 "5R1uFyEE4oxqkm7hJDqHq6gXaLVF9dxeF3LF4yz1sfLP"
404 );
405 let accounts = Migrate {
406 caller,
407 bonding_curve,
408 base_mint,
409 quote_mint,
410 base_vault,
411 quote_vault,
412 dex_program,
413 migration_authority,
414 pool,
415 lp_mint,
416 pool_base_vault,
417 pool_quote_vault,
418 pool_lp_account,
419 dex_event_authority,
420 nexus_program,
421 creator_fee_config,
422 base_token_program,
423 quote_token_program,
424 associated_token_program,
425 system_program,
426 event_authority,
427 program,
428 };
429
430 accounts.instruction_with_remaining_accounts(&self.__remaining_accounts)
431 }
432}
433
434pub struct MigrateCpiAccounts<'a, 'b> {
436 pub caller: &'b solana_program::account_info::AccountInfo<'a>,
437 pub bonding_curve: &'b solana_program::account_info::AccountInfo<'a>,
438 pub base_mint: &'b solana_program::account_info::AccountInfo<'a>,
439 pub quote_mint: &'b solana_program::account_info::AccountInfo<'a>,
440 pub base_vault: &'b solana_program::account_info::AccountInfo<'a>,
441 pub quote_vault: &'b solana_program::account_info::AccountInfo<'a>,
442 pub dex_program: &'b solana_program::account_info::AccountInfo<'a>,
443 pub migration_authority: &'b solana_program::account_info::AccountInfo<'a>,
444 pub pool: &'b solana_program::account_info::AccountInfo<'a>,
445 pub lp_mint: &'b solana_program::account_info::AccountInfo<'a>,
446 pub pool_base_vault: &'b solana_program::account_info::AccountInfo<'a>,
447 pub pool_quote_vault: &'b solana_program::account_info::AccountInfo<'a>,
448 pub pool_lp_account: &'b solana_program::account_info::AccountInfo<'a>,
449 pub dex_event_authority: &'b solana_program::account_info::AccountInfo<'a>,
450 pub nexus_program: &'b solana_program::account_info::AccountInfo<'a>,
451 pub creator_fee_config: &'b solana_program::account_info::AccountInfo<'a>,
452 pub base_token_program: &'b solana_program::account_info::AccountInfo<'a>,
453 pub quote_token_program: &'b solana_program::account_info::AccountInfo<'a>,
454 pub associated_token_program:
455 &'b solana_program::account_info::AccountInfo<'a>,
456 pub system_program: &'b solana_program::account_info::AccountInfo<'a>,
457 pub event_authority: &'b solana_program::account_info::AccountInfo<'a>,
458 pub program: &'b solana_program::account_info::AccountInfo<'a>,
459}
460
461pub struct MigrateCpi<'a, 'b> {
463 pub __program: &'b solana_program::account_info::AccountInfo<'a>,
465 pub caller: &'b solana_program::account_info::AccountInfo<'a>,
466 pub bonding_curve: &'b solana_program::account_info::AccountInfo<'a>,
467 pub base_mint: &'b solana_program::account_info::AccountInfo<'a>,
468 pub quote_mint: &'b solana_program::account_info::AccountInfo<'a>,
469 pub base_vault: &'b solana_program::account_info::AccountInfo<'a>,
470 pub quote_vault: &'b solana_program::account_info::AccountInfo<'a>,
471 pub dex_program: &'b solana_program::account_info::AccountInfo<'a>,
472 pub migration_authority: &'b solana_program::account_info::AccountInfo<'a>,
473 pub pool: &'b solana_program::account_info::AccountInfo<'a>,
474 pub lp_mint: &'b solana_program::account_info::AccountInfo<'a>,
475 pub pool_base_vault: &'b solana_program::account_info::AccountInfo<'a>,
476 pub pool_quote_vault: &'b solana_program::account_info::AccountInfo<'a>,
477 pub pool_lp_account: &'b solana_program::account_info::AccountInfo<'a>,
478 pub dex_event_authority: &'b solana_program::account_info::AccountInfo<'a>,
479 pub nexus_program: &'b solana_program::account_info::AccountInfo<'a>,
480 pub creator_fee_config: &'b solana_program::account_info::AccountInfo<'a>,
481 pub base_token_program: &'b solana_program::account_info::AccountInfo<'a>,
482 pub quote_token_program: &'b solana_program::account_info::AccountInfo<'a>,
483 pub associated_token_program:
484 &'b solana_program::account_info::AccountInfo<'a>,
485 pub system_program: &'b solana_program::account_info::AccountInfo<'a>,
486 pub event_authority: &'b solana_program::account_info::AccountInfo<'a>,
487 pub program: &'b solana_program::account_info::AccountInfo<'a>,
488}
489
490impl<'a, 'b> MigrateCpi<'a, 'b> {
491 pub fn new(
492 program: &'b solana_program::account_info::AccountInfo<'a>,
493 accounts: MigrateCpiAccounts<'a, 'b>,
494 ) -> Self {
495 Self {
496 __program: program,
497 caller: accounts.caller,
498 bonding_curve: accounts.bonding_curve,
499 base_mint: accounts.base_mint,
500 quote_mint: accounts.quote_mint,
501 base_vault: accounts.base_vault,
502 quote_vault: accounts.quote_vault,
503 dex_program: accounts.dex_program,
504 migration_authority: accounts.migration_authority,
505 pool: accounts.pool,
506 lp_mint: accounts.lp_mint,
507 pool_base_vault: accounts.pool_base_vault,
508 pool_quote_vault: accounts.pool_quote_vault,
509 pool_lp_account: accounts.pool_lp_account,
510 dex_event_authority: accounts.dex_event_authority,
511 nexus_program: accounts.nexus_program,
512 creator_fee_config: accounts.creator_fee_config,
513 base_token_program: accounts.base_token_program,
514 quote_token_program: accounts.quote_token_program,
515 associated_token_program: accounts.associated_token_program,
516 system_program: accounts.system_program,
517 event_authority: accounts.event_authority,
518 program: accounts.program,
519 }
520 }
521 #[inline(always)]
522 pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult {
523 self.invoke_signed_with_remaining_accounts(&[], &[])
524 }
525 #[inline(always)]
526 pub fn invoke_with_remaining_accounts(
527 &self,
528 remaining_accounts: &[(
529 &'b solana_program::account_info::AccountInfo<'a>,
530 bool,
531 bool,
532 )],
533 ) -> solana_program::entrypoint::ProgramResult {
534 self.invoke_signed_with_remaining_accounts(&[], remaining_accounts)
535 }
536 #[inline(always)]
537 pub fn invoke_signed(
538 &self,
539 signers_seeds: &[&[&[u8]]],
540 ) -> solana_program::entrypoint::ProgramResult {
541 self.invoke_signed_with_remaining_accounts(signers_seeds, &[])
542 }
543 #[allow(clippy::arithmetic_side_effects)]
544 #[allow(clippy::clone_on_copy)]
545 #[allow(clippy::vec_init_then_push)]
546 pub fn invoke_signed_with_remaining_accounts(
547 &self,
548 signers_seeds: &[&[&[u8]]],
549 remaining_accounts: &[(
550 &'b solana_program::account_info::AccountInfo<'a>,
551 bool,
552 bool,
553 )],
554 ) -> solana_program::entrypoint::ProgramResult {
555 let mut accounts = Vec::with_capacity(22 + remaining_accounts.len());
556 accounts
557 .push(solana_instruction::AccountMeta::new(*self.caller.key, true));
558 accounts.push(solana_instruction::AccountMeta::new(
559 *self.bonding_curve.key,
560 false,
561 ));
562 accounts.push(solana_instruction::AccountMeta::new(
563 *self.base_mint.key,
564 false,
565 ));
566 accounts.push(solana_instruction::AccountMeta::new_readonly(
567 *self.quote_mint.key,
568 false,
569 ));
570 accounts.push(solana_instruction::AccountMeta::new(
571 *self.base_vault.key,
572 false,
573 ));
574 accounts.push(solana_instruction::AccountMeta::new(
575 *self.quote_vault.key,
576 false,
577 ));
578 accounts.push(solana_instruction::AccountMeta::new_readonly(
579 *self.dex_program.key,
580 false,
581 ));
582 accounts.push(solana_instruction::AccountMeta::new_readonly(
583 *self.migration_authority.key,
584 false,
585 ));
586 accounts
587 .push(solana_instruction::AccountMeta::new(*self.pool.key, false));
588 accounts.push(solana_instruction::AccountMeta::new(
589 *self.lp_mint.key,
590 false,
591 ));
592 accounts.push(solana_instruction::AccountMeta::new(
593 *self.pool_base_vault.key,
594 false,
595 ));
596 accounts.push(solana_instruction::AccountMeta::new(
597 *self.pool_quote_vault.key,
598 false,
599 ));
600 accounts.push(solana_instruction::AccountMeta::new(
601 *self.pool_lp_account.key,
602 false,
603 ));
604 accounts.push(solana_instruction::AccountMeta::new_readonly(
605 *self.dex_event_authority.key,
606 false,
607 ));
608 accounts.push(solana_instruction::AccountMeta::new_readonly(
609 *self.nexus_program.key,
610 false,
611 ));
612 accounts.push(solana_instruction::AccountMeta::new_readonly(
613 *self.creator_fee_config.key,
614 false,
615 ));
616 accounts.push(solana_instruction::AccountMeta::new_readonly(
617 *self.base_token_program.key,
618 false,
619 ));
620 accounts.push(solana_instruction::AccountMeta::new_readonly(
621 *self.quote_token_program.key,
622 false,
623 ));
624 accounts.push(solana_instruction::AccountMeta::new_readonly(
625 *self.associated_token_program.key,
626 false,
627 ));
628 accounts.push(solana_instruction::AccountMeta::new_readonly(
629 *self.system_program.key,
630 false,
631 ));
632 accounts.push(solana_instruction::AccountMeta::new_readonly(
633 *self.event_authority.key,
634 false,
635 ));
636 accounts.push(solana_instruction::AccountMeta::new_readonly(
637 *self.program.key,
638 false,
639 ));
640 remaining_accounts.iter().for_each(|remaining_account| {
641 accounts.push(solana_instruction::AccountMeta {
642 pubkey: *remaining_account.0.key,
643 is_writable: remaining_account.1,
644 is_signer: remaining_account.2,
645 })
646 });
647 let data = MigrateInstructionData::new().try_to_vec().unwrap();
648
649 let instruction = solana_instruction::Instruction {
650 program_id: crate::launchpad::generated::SEND_LAUNCHPAD_ID,
651 accounts,
652 data,
653 };
654 let mut account_infos =
655 Vec::with_capacity(23 + remaining_accounts.len());
656 account_infos.push(self.__program.clone());
657 account_infos.push(self.caller.clone());
658 account_infos.push(self.bonding_curve.clone());
659 account_infos.push(self.base_mint.clone());
660 account_infos.push(self.quote_mint.clone());
661 account_infos.push(self.base_vault.clone());
662 account_infos.push(self.quote_vault.clone());
663 account_infos.push(self.dex_program.clone());
664 account_infos.push(self.migration_authority.clone());
665 account_infos.push(self.pool.clone());
666 account_infos.push(self.lp_mint.clone());
667 account_infos.push(self.pool_base_vault.clone());
668 account_infos.push(self.pool_quote_vault.clone());
669 account_infos.push(self.pool_lp_account.clone());
670 account_infos.push(self.dex_event_authority.clone());
671 account_infos.push(self.nexus_program.clone());
672 account_infos.push(self.creator_fee_config.clone());
673 account_infos.push(self.base_token_program.clone());
674 account_infos.push(self.quote_token_program.clone());
675 account_infos.push(self.associated_token_program.clone());
676 account_infos.push(self.system_program.clone());
677 account_infos.push(self.event_authority.clone());
678 account_infos.push(self.program.clone());
679 remaining_accounts.iter().for_each(|remaining_account| {
680 account_infos.push(remaining_account.0.clone())
681 });
682
683 if signers_seeds.is_empty() {
684 solana_program::program::invoke(&instruction, &account_infos)
685 } else {
686 solana_program::program::invoke_signed(
687 &instruction,
688 &account_infos,
689 signers_seeds,
690 )
691 }
692 }
693}
694
695#[derive(Clone, Debug)]
722pub struct MigrateCpiBuilder<'a, 'b> {
723 instruction: Box<MigrateCpiBuilderInstruction<'a, 'b>>,
724}
725
726impl<'a, 'b> MigrateCpiBuilder<'a, 'b> {
727 pub fn new(
728 __program: &'b solana_program::account_info::AccountInfo<'a>,
729 caller: &'b solana_program::account_info::AccountInfo<'a>,
730 bonding_curve: &'b solana_program::account_info::AccountInfo<'a>,
731 base_mint: &'b solana_program::account_info::AccountInfo<'a>,
732 quote_mint: &'b solana_program::account_info::AccountInfo<'a>,
733 base_vault: &'b solana_program::account_info::AccountInfo<'a>,
734 quote_vault: &'b solana_program::account_info::AccountInfo<'a>,
735 dex_program: &'b solana_program::account_info::AccountInfo<'a>,
736 migration_authority: &'b solana_program::account_info::AccountInfo<'a>,
737 pool: &'b solana_program::account_info::AccountInfo<'a>,
738 lp_mint: &'b solana_program::account_info::AccountInfo<'a>,
739 pool_base_vault: &'b solana_program::account_info::AccountInfo<'a>,
740 pool_quote_vault: &'b solana_program::account_info::AccountInfo<'a>,
741 pool_lp_account: &'b solana_program::account_info::AccountInfo<'a>,
742 dex_event_authority: &'b solana_program::account_info::AccountInfo<'a>,
743 nexus_program: &'b solana_program::account_info::AccountInfo<'a>,
744 creator_fee_config: &'b solana_program::account_info::AccountInfo<'a>,
745 base_token_program: &'b solana_program::account_info::AccountInfo<'a>,
746 quote_token_program: &'b solana_program::account_info::AccountInfo<'a>,
747 associated_token_program: &'b solana_program::account_info::AccountInfo<
748 'a,
749 >,
750 system_program: &'b solana_program::account_info::AccountInfo<'a>,
751 event_authority: &'b solana_program::account_info::AccountInfo<'a>,
752 program: &'b solana_program::account_info::AccountInfo<'a>,
753 ) -> Self {
754 let instruction = Box::new(MigrateCpiBuilderInstruction {
755 __program,
756 caller,
757 bonding_curve,
758 base_mint,
759 quote_mint,
760 base_vault,
761 quote_vault,
762 dex_program,
763 migration_authority,
764 pool,
765 lp_mint,
766 pool_base_vault,
767 pool_quote_vault,
768 pool_lp_account,
769 dex_event_authority,
770 nexus_program,
771 creator_fee_config,
772 base_token_program,
773 quote_token_program,
774 associated_token_program,
775 system_program,
776 event_authority,
777 program,
778 __remaining_accounts: Vec::new(),
779 });
780 Self { instruction }
781 }
782 #[inline(always)]
784 pub fn add_remaining_account(
785 &mut self,
786 account: &'b solana_program::account_info::AccountInfo<'a>,
787 is_writable: bool,
788 is_signer: bool,
789 ) -> &mut Self {
790 self.instruction.__remaining_accounts.push((
791 account,
792 is_writable,
793 is_signer,
794 ));
795 self
796 }
797 #[inline(always)]
802 pub fn add_remaining_accounts(
803 &mut self,
804 accounts: &[(
805 &'b solana_program::account_info::AccountInfo<'a>,
806 bool,
807 bool,
808 )],
809 ) -> &mut Self {
810 self.instruction
811 .__remaining_accounts
812 .extend_from_slice(accounts);
813 self
814 }
815 #[inline(always)]
816 pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult {
817 self.invoke_signed(&[])
818 }
819 #[allow(clippy::clone_on_copy)]
820 #[allow(clippy::vec_init_then_push)]
821 pub fn invoke_signed(
822 &self,
823 signers_seeds: &[&[&[u8]]],
824 ) -> solana_program::entrypoint::ProgramResult {
825 let instruction = MigrateCpi {
826 __program: self.instruction.__program,
827 caller: self.instruction.caller,
828 bonding_curve: self.instruction.bonding_curve,
829 base_mint: self.instruction.base_mint,
830 quote_mint: self.instruction.quote_mint,
831 base_vault: self.instruction.base_vault,
832 quote_vault: self.instruction.quote_vault,
833 dex_program: self.instruction.dex_program,
834 migration_authority: self.instruction.migration_authority,
835 pool: self.instruction.pool,
836 lp_mint: self.instruction.lp_mint,
837 pool_base_vault: self.instruction.pool_base_vault,
838 pool_quote_vault: self.instruction.pool_quote_vault,
839 pool_lp_account: self.instruction.pool_lp_account,
840 dex_event_authority: self.instruction.dex_event_authority,
841 nexus_program: self.instruction.nexus_program,
842 creator_fee_config: self.instruction.creator_fee_config,
843 base_token_program: self.instruction.base_token_program,
844 quote_token_program: self.instruction.quote_token_program,
845 associated_token_program: self.instruction.associated_token_program,
846 system_program: self.instruction.system_program,
847 event_authority: self.instruction.event_authority,
848 program: self.instruction.program,
849 };
850 instruction.invoke_signed_with_remaining_accounts(
851 signers_seeds,
852 &self.instruction.__remaining_accounts,
853 )
854 }
855}
856
857#[derive(Clone, Debug)]
858struct MigrateCpiBuilderInstruction<'a, 'b> {
859 __program: &'b solana_program::account_info::AccountInfo<'a>,
860 caller: &'b solana_program::account_info::AccountInfo<'a>,
861 bonding_curve: &'b solana_program::account_info::AccountInfo<'a>,
862 base_mint: &'b solana_program::account_info::AccountInfo<'a>,
863 quote_mint: &'b solana_program::account_info::AccountInfo<'a>,
864 base_vault: &'b solana_program::account_info::AccountInfo<'a>,
865 quote_vault: &'b solana_program::account_info::AccountInfo<'a>,
866 dex_program: &'b solana_program::account_info::AccountInfo<'a>,
867 migration_authority: &'b solana_program::account_info::AccountInfo<'a>,
868 pool: &'b solana_program::account_info::AccountInfo<'a>,
869 lp_mint: &'b solana_program::account_info::AccountInfo<'a>,
870 pool_base_vault: &'b solana_program::account_info::AccountInfo<'a>,
871 pool_quote_vault: &'b solana_program::account_info::AccountInfo<'a>,
872 pool_lp_account: &'b solana_program::account_info::AccountInfo<'a>,
873 dex_event_authority: &'b solana_program::account_info::AccountInfo<'a>,
874 nexus_program: &'b solana_program::account_info::AccountInfo<'a>,
875 creator_fee_config: &'b solana_program::account_info::AccountInfo<'a>,
876 base_token_program: &'b solana_program::account_info::AccountInfo<'a>,
877 quote_token_program: &'b solana_program::account_info::AccountInfo<'a>,
878 associated_token_program: &'b solana_program::account_info::AccountInfo<'a>,
879 system_program: &'b solana_program::account_info::AccountInfo<'a>,
880 event_authority: &'b solana_program::account_info::AccountInfo<'a>,
881 program: &'b solana_program::account_info::AccountInfo<'a>,
882 __remaining_accounts: Vec<(
884 &'b solana_program::account_info::AccountInfo<'a>,
885 bool,
886 bool,
887 )>,
888}