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