use borsh::BorshDeserialize;
use borsh::BorshSerialize;
pub const MIGRATE_DISCRIMINATOR: [u8; 8] = [155, 234, 231, 146, 236, 158, 162, 30];
#[derive(Debug)]
pub struct Migrate {
pub global: solana_pubkey::Pubkey,
pub withdraw_authority: solana_pubkey::Pubkey,
pub mint: solana_pubkey::Pubkey,
pub bonding_curve: solana_pubkey::Pubkey,
pub associated_bonding_curve: solana_pubkey::Pubkey,
pub user: solana_pubkey::Pubkey,
pub system_program: solana_pubkey::Pubkey,
pub token_program: solana_pubkey::Pubkey,
pub pump_amm: solana_pubkey::Pubkey,
pub pool: solana_pubkey::Pubkey,
pub pool_authority: solana_pubkey::Pubkey,
pub pool_authority_mint_account: solana_pubkey::Pubkey,
pub pool_authority_wsol_account: solana_pubkey::Pubkey,
pub amm_global_config: solana_pubkey::Pubkey,
pub wsol_mint: solana_pubkey::Pubkey,
pub lp_mint: solana_pubkey::Pubkey,
pub user_pool_token_account: solana_pubkey::Pubkey,
pub pool_base_token_account: solana_pubkey::Pubkey,
pub pool_quote_token_account: solana_pubkey::Pubkey,
pub token2022_program: solana_pubkey::Pubkey,
pub associated_token_program: solana_pubkey::Pubkey,
pub pump_amm_event_authority: solana_pubkey::Pubkey,
pub event_authority: solana_pubkey::Pubkey,
pub program: solana_pubkey::Pubkey,
}
impl Migrate {
pub fn instruction(&self) -> solana_instruction::Instruction {
self.instruction_with_remaining_accounts(&[])
}
#[allow(clippy::arithmetic_side_effects)]
#[allow(clippy::vec_init_then_push)]
pub fn instruction_with_remaining_accounts(
&self,
remaining_accounts: &[solana_instruction::AccountMeta],
) -> solana_instruction::Instruction {
let mut accounts = Vec::with_capacity(24 + remaining_accounts.len());
accounts.push(solana_instruction::AccountMeta::new_readonly(
self.global,
false,
));
accounts.push(solana_instruction::AccountMeta::new(
self.withdraw_authority,
false,
));
accounts.push(solana_instruction::AccountMeta::new_readonly(
self.mint, false,
));
accounts.push(solana_instruction::AccountMeta::new(
self.bonding_curve,
false,
));
accounts.push(solana_instruction::AccountMeta::new(
self.associated_bonding_curve,
false,
));
accounts.push(solana_instruction::AccountMeta::new_readonly(
self.user, true,
));
accounts.push(solana_instruction::AccountMeta::new_readonly(
self.system_program,
false,
));
accounts.push(solana_instruction::AccountMeta::new_readonly(
self.token_program,
false,
));
accounts.push(solana_instruction::AccountMeta::new_readonly(
self.pump_amm,
false,
));
accounts.push(solana_instruction::AccountMeta::new(self.pool, false));
accounts.push(solana_instruction::AccountMeta::new(
self.pool_authority,
false,
));
accounts.push(solana_instruction::AccountMeta::new(
self.pool_authority_mint_account,
false,
));
accounts.push(solana_instruction::AccountMeta::new(
self.pool_authority_wsol_account,
false,
));
accounts.push(solana_instruction::AccountMeta::new_readonly(
self.amm_global_config,
false,
));
accounts.push(solana_instruction::AccountMeta::new_readonly(
self.wsol_mint,
false,
));
accounts.push(solana_instruction::AccountMeta::new(self.lp_mint, false));
accounts.push(solana_instruction::AccountMeta::new(
self.user_pool_token_account,
false,
));
accounts.push(solana_instruction::AccountMeta::new(
self.pool_base_token_account,
false,
));
accounts.push(solana_instruction::AccountMeta::new(
self.pool_quote_token_account,
false,
));
accounts.push(solana_instruction::AccountMeta::new_readonly(
self.token2022_program,
false,
));
accounts.push(solana_instruction::AccountMeta::new_readonly(
self.associated_token_program,
false,
));
accounts.push(solana_instruction::AccountMeta::new_readonly(
self.pump_amm_event_authority,
false,
));
accounts.push(solana_instruction::AccountMeta::new_readonly(
self.event_authority,
false,
));
accounts.push(solana_instruction::AccountMeta::new_readonly(
self.program,
false,
));
accounts.extend_from_slice(remaining_accounts);
let data = MigrateInstructionData::new().try_to_vec().unwrap();
solana_instruction::Instruction {
program_id: crate::PUMP_ID,
accounts,
data,
}
}
}
#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct MigrateInstructionData {
discriminator: [u8; 8],
}
impl MigrateInstructionData {
pub fn new() -> Self {
Self {
discriminator: [155, 234, 231, 146, 236, 158, 162, 30],
}
}
pub(crate) fn try_to_vec(&self) -> Result<Vec<u8>, std::io::Error> {
borsh::to_vec(self)
}
}
impl Default for MigrateInstructionData {
fn default() -> Self {
Self::new()
}
}
#[derive(Clone, Debug, Default)]
pub struct MigrateBuilder {
global: Option<solana_pubkey::Pubkey>,
withdraw_authority: Option<solana_pubkey::Pubkey>,
mint: Option<solana_pubkey::Pubkey>,
bonding_curve: Option<solana_pubkey::Pubkey>,
associated_bonding_curve: Option<solana_pubkey::Pubkey>,
user: Option<solana_pubkey::Pubkey>,
system_program: Option<solana_pubkey::Pubkey>,
token_program: Option<solana_pubkey::Pubkey>,
pump_amm: Option<solana_pubkey::Pubkey>,
pool: Option<solana_pubkey::Pubkey>,
pool_authority: Option<solana_pubkey::Pubkey>,
pool_authority_mint_account: Option<solana_pubkey::Pubkey>,
pool_authority_wsol_account: Option<solana_pubkey::Pubkey>,
amm_global_config: Option<solana_pubkey::Pubkey>,
wsol_mint: Option<solana_pubkey::Pubkey>,
lp_mint: Option<solana_pubkey::Pubkey>,
user_pool_token_account: Option<solana_pubkey::Pubkey>,
pool_base_token_account: Option<solana_pubkey::Pubkey>,
pool_quote_token_account: Option<solana_pubkey::Pubkey>,
token2022_program: Option<solana_pubkey::Pubkey>,
associated_token_program: Option<solana_pubkey::Pubkey>,
pump_amm_event_authority: Option<solana_pubkey::Pubkey>,
event_authority: Option<solana_pubkey::Pubkey>,
program: Option<solana_pubkey::Pubkey>,
__remaining_accounts: Vec<solana_instruction::AccountMeta>,
}
impl MigrateBuilder {
pub fn new() -> Self {
Self::default()
}
#[inline(always)]
pub fn global(&mut self, global: solana_pubkey::Pubkey) -> &mut Self {
self.global = Some(global);
self
}
#[inline(always)]
pub fn withdraw_authority(&mut self, withdraw_authority: solana_pubkey::Pubkey) -> &mut Self {
self.withdraw_authority = Some(withdraw_authority);
self
}
#[inline(always)]
pub fn mint(&mut self, mint: solana_pubkey::Pubkey) -> &mut Self {
self.mint = Some(mint);
self
}
#[inline(always)]
pub fn bonding_curve(&mut self, bonding_curve: solana_pubkey::Pubkey) -> &mut Self {
self.bonding_curve = Some(bonding_curve);
self
}
#[inline(always)]
pub fn associated_bonding_curve(
&mut self,
associated_bonding_curve: solana_pubkey::Pubkey,
) -> &mut Self {
self.associated_bonding_curve = Some(associated_bonding_curve);
self
}
#[inline(always)]
pub fn user(&mut self, user: solana_pubkey::Pubkey) -> &mut Self {
self.user = Some(user);
self
}
#[inline(always)]
pub fn system_program(&mut self, system_program: solana_pubkey::Pubkey) -> &mut Self {
self.system_program = Some(system_program);
self
}
#[inline(always)]
pub fn token_program(&mut self, token_program: solana_pubkey::Pubkey) -> &mut Self {
self.token_program = Some(token_program);
self
}
#[inline(always)]
pub fn pump_amm(&mut self, pump_amm: solana_pubkey::Pubkey) -> &mut Self {
self.pump_amm = Some(pump_amm);
self
}
#[inline(always)]
pub fn pool(&mut self, pool: solana_pubkey::Pubkey) -> &mut Self {
self.pool = Some(pool);
self
}
#[inline(always)]
pub fn pool_authority(&mut self, pool_authority: solana_pubkey::Pubkey) -> &mut Self {
self.pool_authority = Some(pool_authority);
self
}
#[inline(always)]
pub fn pool_authority_mint_account(
&mut self,
pool_authority_mint_account: solana_pubkey::Pubkey,
) -> &mut Self {
self.pool_authority_mint_account = Some(pool_authority_mint_account);
self
}
#[inline(always)]
pub fn pool_authority_wsol_account(
&mut self,
pool_authority_wsol_account: solana_pubkey::Pubkey,
) -> &mut Self {
self.pool_authority_wsol_account = Some(pool_authority_wsol_account);
self
}
#[inline(always)]
pub fn amm_global_config(&mut self, amm_global_config: solana_pubkey::Pubkey) -> &mut Self {
self.amm_global_config = Some(amm_global_config);
self
}
#[inline(always)]
pub fn wsol_mint(&mut self, wsol_mint: solana_pubkey::Pubkey) -> &mut Self {
self.wsol_mint = Some(wsol_mint);
self
}
#[inline(always)]
pub fn lp_mint(&mut self, lp_mint: solana_pubkey::Pubkey) -> &mut Self {
self.lp_mint = Some(lp_mint);
self
}
#[inline(always)]
pub fn user_pool_token_account(
&mut self,
user_pool_token_account: solana_pubkey::Pubkey,
) -> &mut Self {
self.user_pool_token_account = Some(user_pool_token_account);
self
}
#[inline(always)]
pub fn pool_base_token_account(
&mut self,
pool_base_token_account: solana_pubkey::Pubkey,
) -> &mut Self {
self.pool_base_token_account = Some(pool_base_token_account);
self
}
#[inline(always)]
pub fn pool_quote_token_account(
&mut self,
pool_quote_token_account: solana_pubkey::Pubkey,
) -> &mut Self {
self.pool_quote_token_account = Some(pool_quote_token_account);
self
}
#[inline(always)]
pub fn token2022_program(&mut self, token2022_program: solana_pubkey::Pubkey) -> &mut Self {
self.token2022_program = Some(token2022_program);
self
}
#[inline(always)]
pub fn associated_token_program(
&mut self,
associated_token_program: solana_pubkey::Pubkey,
) -> &mut Self {
self.associated_token_program = Some(associated_token_program);
self
}
#[inline(always)]
pub fn pump_amm_event_authority(
&mut self,
pump_amm_event_authority: solana_pubkey::Pubkey,
) -> &mut Self {
self.pump_amm_event_authority = Some(pump_amm_event_authority);
self
}
#[inline(always)]
pub fn event_authority(&mut self, event_authority: solana_pubkey::Pubkey) -> &mut Self {
self.event_authority = Some(event_authority);
self
}
#[inline(always)]
pub fn program(&mut self, program: solana_pubkey::Pubkey) -> &mut Self {
self.program = Some(program);
self
}
#[inline(always)]
pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self {
self.__remaining_accounts.push(account);
self
}
#[inline(always)]
pub fn add_remaining_accounts(
&mut self,
accounts: &[solana_instruction::AccountMeta],
) -> &mut Self {
self.__remaining_accounts.extend_from_slice(accounts);
self
}
#[allow(clippy::clone_on_copy)]
pub fn instruction(&self) -> solana_instruction::Instruction {
let accounts = Migrate {
global: self.global.expect("global is not set"),
withdraw_authority: self
.withdraw_authority
.expect("withdraw_authority is not set"),
mint: self.mint.expect("mint is not set"),
bonding_curve: self.bonding_curve.expect("bonding_curve is not set"),
associated_bonding_curve: self
.associated_bonding_curve
.expect("associated_bonding_curve is not set"),
user: self.user.expect("user is not set"),
system_program: self
.system_program
.unwrap_or(solana_pubkey::pubkey!("11111111111111111111111111111111")),
token_program: self.token_program.unwrap_or(solana_pubkey::pubkey!(
"TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"
)),
pump_amm: self.pump_amm.unwrap_or(solana_pubkey::pubkey!(
"pAMMBay6oceH9fJKBRHGP5D4bD4sWpmSwMn52FMfXEA"
)),
pool: self.pool.expect("pool is not set"),
pool_authority: self.pool_authority.expect("pool_authority is not set"),
pool_authority_mint_account: self
.pool_authority_mint_account
.expect("pool_authority_mint_account is not set"),
pool_authority_wsol_account: self
.pool_authority_wsol_account
.expect("pool_authority_wsol_account is not set"),
amm_global_config: self
.amm_global_config
.expect("amm_global_config is not set"),
wsol_mint: self.wsol_mint.unwrap_or(solana_pubkey::pubkey!(
"So11111111111111111111111111111111111111112"
)),
lp_mint: self.lp_mint.expect("lp_mint is not set"),
user_pool_token_account: self
.user_pool_token_account
.expect("user_pool_token_account is not set"),
pool_base_token_account: self
.pool_base_token_account
.expect("pool_base_token_account is not set"),
pool_quote_token_account: self
.pool_quote_token_account
.expect("pool_quote_token_account is not set"),
token2022_program: self.token2022_program.unwrap_or(solana_pubkey::pubkey!(
"TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb"
)),
associated_token_program: self.associated_token_program.unwrap_or(
solana_pubkey::pubkey!("ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL"),
),
pump_amm_event_authority: self
.pump_amm_event_authority
.expect("pump_amm_event_authority is not set"),
event_authority: self.event_authority.expect("event_authority is not set"),
program: self.program.expect("program is not set"),
};
accounts.instruction_with_remaining_accounts(&self.__remaining_accounts)
}
}
pub struct MigrateCpiAccounts<'a, 'b> {
pub global: &'b solana_account_info::AccountInfo<'a>,
pub withdraw_authority: &'b solana_account_info::AccountInfo<'a>,
pub mint: &'b solana_account_info::AccountInfo<'a>,
pub bonding_curve: &'b solana_account_info::AccountInfo<'a>,
pub associated_bonding_curve: &'b solana_account_info::AccountInfo<'a>,
pub user: &'b solana_account_info::AccountInfo<'a>,
pub system_program: &'b solana_account_info::AccountInfo<'a>,
pub token_program: &'b solana_account_info::AccountInfo<'a>,
pub pump_amm: &'b solana_account_info::AccountInfo<'a>,
pub pool: &'b solana_account_info::AccountInfo<'a>,
pub pool_authority: &'b solana_account_info::AccountInfo<'a>,
pub pool_authority_mint_account: &'b solana_account_info::AccountInfo<'a>,
pub pool_authority_wsol_account: &'b solana_account_info::AccountInfo<'a>,
pub amm_global_config: &'b solana_account_info::AccountInfo<'a>,
pub wsol_mint: &'b solana_account_info::AccountInfo<'a>,
pub lp_mint: &'b solana_account_info::AccountInfo<'a>,
pub user_pool_token_account: &'b solana_account_info::AccountInfo<'a>,
pub pool_base_token_account: &'b solana_account_info::AccountInfo<'a>,
pub pool_quote_token_account: &'b solana_account_info::AccountInfo<'a>,
pub token2022_program: &'b solana_account_info::AccountInfo<'a>,
pub associated_token_program: &'b solana_account_info::AccountInfo<'a>,
pub pump_amm_event_authority: &'b solana_account_info::AccountInfo<'a>,
pub event_authority: &'b solana_account_info::AccountInfo<'a>,
pub program: &'b solana_account_info::AccountInfo<'a>,
}
pub struct MigrateCpi<'a, 'b> {
pub __program: &'b solana_account_info::AccountInfo<'a>,
pub global: &'b solana_account_info::AccountInfo<'a>,
pub withdraw_authority: &'b solana_account_info::AccountInfo<'a>,
pub mint: &'b solana_account_info::AccountInfo<'a>,
pub bonding_curve: &'b solana_account_info::AccountInfo<'a>,
pub associated_bonding_curve: &'b solana_account_info::AccountInfo<'a>,
pub user: &'b solana_account_info::AccountInfo<'a>,
pub system_program: &'b solana_account_info::AccountInfo<'a>,
pub token_program: &'b solana_account_info::AccountInfo<'a>,
pub pump_amm: &'b solana_account_info::AccountInfo<'a>,
pub pool: &'b solana_account_info::AccountInfo<'a>,
pub pool_authority: &'b solana_account_info::AccountInfo<'a>,
pub pool_authority_mint_account: &'b solana_account_info::AccountInfo<'a>,
pub pool_authority_wsol_account: &'b solana_account_info::AccountInfo<'a>,
pub amm_global_config: &'b solana_account_info::AccountInfo<'a>,
pub wsol_mint: &'b solana_account_info::AccountInfo<'a>,
pub lp_mint: &'b solana_account_info::AccountInfo<'a>,
pub user_pool_token_account: &'b solana_account_info::AccountInfo<'a>,
pub pool_base_token_account: &'b solana_account_info::AccountInfo<'a>,
pub pool_quote_token_account: &'b solana_account_info::AccountInfo<'a>,
pub token2022_program: &'b solana_account_info::AccountInfo<'a>,
pub associated_token_program: &'b solana_account_info::AccountInfo<'a>,
pub pump_amm_event_authority: &'b solana_account_info::AccountInfo<'a>,
pub event_authority: &'b solana_account_info::AccountInfo<'a>,
pub program: &'b solana_account_info::AccountInfo<'a>,
}
impl<'a, 'b> MigrateCpi<'a, 'b> {
pub fn new(
program: &'b solana_account_info::AccountInfo<'a>,
accounts: MigrateCpiAccounts<'a, 'b>,
) -> Self {
Self {
__program: program,
global: accounts.global,
withdraw_authority: accounts.withdraw_authority,
mint: accounts.mint,
bonding_curve: accounts.bonding_curve,
associated_bonding_curve: accounts.associated_bonding_curve,
user: accounts.user,
system_program: accounts.system_program,
token_program: accounts.token_program,
pump_amm: accounts.pump_amm,
pool: accounts.pool,
pool_authority: accounts.pool_authority,
pool_authority_mint_account: accounts.pool_authority_mint_account,
pool_authority_wsol_account: accounts.pool_authority_wsol_account,
amm_global_config: accounts.amm_global_config,
wsol_mint: accounts.wsol_mint,
lp_mint: accounts.lp_mint,
user_pool_token_account: accounts.user_pool_token_account,
pool_base_token_account: accounts.pool_base_token_account,
pool_quote_token_account: accounts.pool_quote_token_account,
token2022_program: accounts.token2022_program,
associated_token_program: accounts.associated_token_program,
pump_amm_event_authority: accounts.pump_amm_event_authority,
event_authority: accounts.event_authority,
program: accounts.program,
}
}
#[inline(always)]
pub fn invoke(&self) -> solana_program_error::ProgramResult {
self.invoke_signed_with_remaining_accounts(&[], &[])
}
#[inline(always)]
pub fn invoke_with_remaining_accounts(
&self,
remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)],
) -> solana_program_error::ProgramResult {
self.invoke_signed_with_remaining_accounts(&[], remaining_accounts)
}
#[inline(always)]
pub fn invoke_signed(&self, signers_seeds: &[&[&[u8]]]) -> solana_program_error::ProgramResult {
self.invoke_signed_with_remaining_accounts(signers_seeds, &[])
}
#[allow(clippy::arithmetic_side_effects)]
#[allow(clippy::clone_on_copy)]
#[allow(clippy::vec_init_then_push)]
pub fn invoke_signed_with_remaining_accounts(
&self,
signers_seeds: &[&[&[u8]]],
remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)],
) -> solana_program_error::ProgramResult {
let mut accounts = Vec::with_capacity(24 + remaining_accounts.len());
accounts.push(solana_instruction::AccountMeta::new_readonly(
*self.global.key,
false,
));
accounts.push(solana_instruction::AccountMeta::new(
*self.withdraw_authority.key,
false,
));
accounts.push(solana_instruction::AccountMeta::new_readonly(
*self.mint.key,
false,
));
accounts.push(solana_instruction::AccountMeta::new(
*self.bonding_curve.key,
false,
));
accounts.push(solana_instruction::AccountMeta::new(
*self.associated_bonding_curve.key,
false,
));
accounts.push(solana_instruction::AccountMeta::new_readonly(
*self.user.key,
true,
));
accounts.push(solana_instruction::AccountMeta::new_readonly(
*self.system_program.key,
false,
));
accounts.push(solana_instruction::AccountMeta::new_readonly(
*self.token_program.key,
false,
));
accounts.push(solana_instruction::AccountMeta::new_readonly(
*self.pump_amm.key,
false,
));
accounts.push(solana_instruction::AccountMeta::new(*self.pool.key, false));
accounts.push(solana_instruction::AccountMeta::new(
*self.pool_authority.key,
false,
));
accounts.push(solana_instruction::AccountMeta::new(
*self.pool_authority_mint_account.key,
false,
));
accounts.push(solana_instruction::AccountMeta::new(
*self.pool_authority_wsol_account.key,
false,
));
accounts.push(solana_instruction::AccountMeta::new_readonly(
*self.amm_global_config.key,
false,
));
accounts.push(solana_instruction::AccountMeta::new_readonly(
*self.wsol_mint.key,
false,
));
accounts.push(solana_instruction::AccountMeta::new(
*self.lp_mint.key,
false,
));
accounts.push(solana_instruction::AccountMeta::new(
*self.user_pool_token_account.key,
false,
));
accounts.push(solana_instruction::AccountMeta::new(
*self.pool_base_token_account.key,
false,
));
accounts.push(solana_instruction::AccountMeta::new(
*self.pool_quote_token_account.key,
false,
));
accounts.push(solana_instruction::AccountMeta::new_readonly(
*self.token2022_program.key,
false,
));
accounts.push(solana_instruction::AccountMeta::new_readonly(
*self.associated_token_program.key,
false,
));
accounts.push(solana_instruction::AccountMeta::new_readonly(
*self.pump_amm_event_authority.key,
false,
));
accounts.push(solana_instruction::AccountMeta::new_readonly(
*self.event_authority.key,
false,
));
accounts.push(solana_instruction::AccountMeta::new_readonly(
*self.program.key,
false,
));
remaining_accounts.iter().for_each(|remaining_account| {
accounts.push(solana_instruction::AccountMeta {
pubkey: *remaining_account.0.key,
is_signer: remaining_account.1,
is_writable: remaining_account.2,
})
});
let data = MigrateInstructionData::new().try_to_vec().unwrap();
let instruction = solana_instruction::Instruction {
program_id: crate::PUMP_ID,
accounts,
data,
};
let mut account_infos = Vec::with_capacity(25 + remaining_accounts.len());
account_infos.push(self.__program.clone());
account_infos.push(self.global.clone());
account_infos.push(self.withdraw_authority.clone());
account_infos.push(self.mint.clone());
account_infos.push(self.bonding_curve.clone());
account_infos.push(self.associated_bonding_curve.clone());
account_infos.push(self.user.clone());
account_infos.push(self.system_program.clone());
account_infos.push(self.token_program.clone());
account_infos.push(self.pump_amm.clone());
account_infos.push(self.pool.clone());
account_infos.push(self.pool_authority.clone());
account_infos.push(self.pool_authority_mint_account.clone());
account_infos.push(self.pool_authority_wsol_account.clone());
account_infos.push(self.amm_global_config.clone());
account_infos.push(self.wsol_mint.clone());
account_infos.push(self.lp_mint.clone());
account_infos.push(self.user_pool_token_account.clone());
account_infos.push(self.pool_base_token_account.clone());
account_infos.push(self.pool_quote_token_account.clone());
account_infos.push(self.token2022_program.clone());
account_infos.push(self.associated_token_program.clone());
account_infos.push(self.pump_amm_event_authority.clone());
account_infos.push(self.event_authority.clone());
account_infos.push(self.program.clone());
remaining_accounts
.iter()
.for_each(|remaining_account| account_infos.push(remaining_account.0.clone()));
if signers_seeds.is_empty() {
solana_cpi::invoke(&instruction, &account_infos)
} else {
solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds)
}
}
}
#[derive(Clone, Debug)]
pub struct MigrateCpiBuilder<'a, 'b> {
instruction: Box<MigrateCpiBuilderInstruction<'a, 'b>>,
}
impl<'a, 'b> MigrateCpiBuilder<'a, 'b> {
pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self {
let instruction = Box::new(MigrateCpiBuilderInstruction {
__program: program,
global: None,
withdraw_authority: None,
mint: None,
bonding_curve: None,
associated_bonding_curve: None,
user: None,
system_program: None,
token_program: None,
pump_amm: None,
pool: None,
pool_authority: None,
pool_authority_mint_account: None,
pool_authority_wsol_account: None,
amm_global_config: None,
wsol_mint: None,
lp_mint: None,
user_pool_token_account: None,
pool_base_token_account: None,
pool_quote_token_account: None,
token2022_program: None,
associated_token_program: None,
pump_amm_event_authority: None,
event_authority: None,
program: None,
__remaining_accounts: Vec::new(),
});
Self { instruction }
}
#[inline(always)]
pub fn global(&mut self, global: &'b solana_account_info::AccountInfo<'a>) -> &mut Self {
self.instruction.global = Some(global);
self
}
#[inline(always)]
pub fn withdraw_authority(
&mut self,
withdraw_authority: &'b solana_account_info::AccountInfo<'a>,
) -> &mut Self {
self.instruction.withdraw_authority = Some(withdraw_authority);
self
}
#[inline(always)]
pub fn mint(&mut self, mint: &'b solana_account_info::AccountInfo<'a>) -> &mut Self {
self.instruction.mint = Some(mint);
self
}
#[inline(always)]
pub fn bonding_curve(
&mut self,
bonding_curve: &'b solana_account_info::AccountInfo<'a>,
) -> &mut Self {
self.instruction.bonding_curve = Some(bonding_curve);
self
}
#[inline(always)]
pub fn associated_bonding_curve(
&mut self,
associated_bonding_curve: &'b solana_account_info::AccountInfo<'a>,
) -> &mut Self {
self.instruction.associated_bonding_curve = Some(associated_bonding_curve);
self
}
#[inline(always)]
pub fn user(&mut self, user: &'b solana_account_info::AccountInfo<'a>) -> &mut Self {
self.instruction.user = Some(user);
self
}
#[inline(always)]
pub fn system_program(
&mut self,
system_program: &'b solana_account_info::AccountInfo<'a>,
) -> &mut Self {
self.instruction.system_program = Some(system_program);
self
}
#[inline(always)]
pub fn token_program(
&mut self,
token_program: &'b solana_account_info::AccountInfo<'a>,
) -> &mut Self {
self.instruction.token_program = Some(token_program);
self
}
#[inline(always)]
pub fn pump_amm(&mut self, pump_amm: &'b solana_account_info::AccountInfo<'a>) -> &mut Self {
self.instruction.pump_amm = Some(pump_amm);
self
}
#[inline(always)]
pub fn pool(&mut self, pool: &'b solana_account_info::AccountInfo<'a>) -> &mut Self {
self.instruction.pool = Some(pool);
self
}
#[inline(always)]
pub fn pool_authority(
&mut self,
pool_authority: &'b solana_account_info::AccountInfo<'a>,
) -> &mut Self {
self.instruction.pool_authority = Some(pool_authority);
self
}
#[inline(always)]
pub fn pool_authority_mint_account(
&mut self,
pool_authority_mint_account: &'b solana_account_info::AccountInfo<'a>,
) -> &mut Self {
self.instruction.pool_authority_mint_account = Some(pool_authority_mint_account);
self
}
#[inline(always)]
pub fn pool_authority_wsol_account(
&mut self,
pool_authority_wsol_account: &'b solana_account_info::AccountInfo<'a>,
) -> &mut Self {
self.instruction.pool_authority_wsol_account = Some(pool_authority_wsol_account);
self
}
#[inline(always)]
pub fn amm_global_config(
&mut self,
amm_global_config: &'b solana_account_info::AccountInfo<'a>,
) -> &mut Self {
self.instruction.amm_global_config = Some(amm_global_config);
self
}
#[inline(always)]
pub fn wsol_mint(&mut self, wsol_mint: &'b solana_account_info::AccountInfo<'a>) -> &mut Self {
self.instruction.wsol_mint = Some(wsol_mint);
self
}
#[inline(always)]
pub fn lp_mint(&mut self, lp_mint: &'b solana_account_info::AccountInfo<'a>) -> &mut Self {
self.instruction.lp_mint = Some(lp_mint);
self
}
#[inline(always)]
pub fn user_pool_token_account(
&mut self,
user_pool_token_account: &'b solana_account_info::AccountInfo<'a>,
) -> &mut Self {
self.instruction.user_pool_token_account = Some(user_pool_token_account);
self
}
#[inline(always)]
pub fn pool_base_token_account(
&mut self,
pool_base_token_account: &'b solana_account_info::AccountInfo<'a>,
) -> &mut Self {
self.instruction.pool_base_token_account = Some(pool_base_token_account);
self
}
#[inline(always)]
pub fn pool_quote_token_account(
&mut self,
pool_quote_token_account: &'b solana_account_info::AccountInfo<'a>,
) -> &mut Self {
self.instruction.pool_quote_token_account = Some(pool_quote_token_account);
self
}
#[inline(always)]
pub fn token2022_program(
&mut self,
token2022_program: &'b solana_account_info::AccountInfo<'a>,
) -> &mut Self {
self.instruction.token2022_program = Some(token2022_program);
self
}
#[inline(always)]
pub fn associated_token_program(
&mut self,
associated_token_program: &'b solana_account_info::AccountInfo<'a>,
) -> &mut Self {
self.instruction.associated_token_program = Some(associated_token_program);
self
}
#[inline(always)]
pub fn pump_amm_event_authority(
&mut self,
pump_amm_event_authority: &'b solana_account_info::AccountInfo<'a>,
) -> &mut Self {
self.instruction.pump_amm_event_authority = Some(pump_amm_event_authority);
self
}
#[inline(always)]
pub fn event_authority(
&mut self,
event_authority: &'b solana_account_info::AccountInfo<'a>,
) -> &mut Self {
self.instruction.event_authority = Some(event_authority);
self
}
#[inline(always)]
pub fn program(&mut self, program: &'b solana_account_info::AccountInfo<'a>) -> &mut Self {
self.instruction.program = Some(program);
self
}
#[inline(always)]
pub fn add_remaining_account(
&mut self,
account: &'b solana_account_info::AccountInfo<'a>,
is_writable: bool,
is_signer: bool,
) -> &mut Self {
self.instruction
.__remaining_accounts
.push((account, is_writable, is_signer));
self
}
#[inline(always)]
pub fn add_remaining_accounts(
&mut self,
accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)],
) -> &mut Self {
self.instruction
.__remaining_accounts
.extend_from_slice(accounts);
self
}
#[inline(always)]
pub fn invoke(&self) -> solana_program_error::ProgramResult {
self.invoke_signed(&[])
}
#[allow(clippy::clone_on_copy)]
#[allow(clippy::vec_init_then_push)]
pub fn invoke_signed(&self, signers_seeds: &[&[&[u8]]]) -> solana_program_error::ProgramResult {
let instruction = MigrateCpi {
__program: self.instruction.__program,
global: self.instruction.global.expect("global is not set"),
withdraw_authority: self
.instruction
.withdraw_authority
.expect("withdraw_authority is not set"),
mint: self.instruction.mint.expect("mint is not set"),
bonding_curve: self
.instruction
.bonding_curve
.expect("bonding_curve is not set"),
associated_bonding_curve: self
.instruction
.associated_bonding_curve
.expect("associated_bonding_curve is not set"),
user: self.instruction.user.expect("user is not set"),
system_program: self
.instruction
.system_program
.expect("system_program is not set"),
token_program: self
.instruction
.token_program
.expect("token_program is not set"),
pump_amm: self.instruction.pump_amm.expect("pump_amm is not set"),
pool: self.instruction.pool.expect("pool is not set"),
pool_authority: self
.instruction
.pool_authority
.expect("pool_authority is not set"),
pool_authority_mint_account: self
.instruction
.pool_authority_mint_account
.expect("pool_authority_mint_account is not set"),
pool_authority_wsol_account: self
.instruction
.pool_authority_wsol_account
.expect("pool_authority_wsol_account is not set"),
amm_global_config: self
.instruction
.amm_global_config
.expect("amm_global_config is not set"),
wsol_mint: self.instruction.wsol_mint.expect("wsol_mint is not set"),
lp_mint: self.instruction.lp_mint.expect("lp_mint is not set"),
user_pool_token_account: self
.instruction
.user_pool_token_account
.expect("user_pool_token_account is not set"),
pool_base_token_account: self
.instruction
.pool_base_token_account
.expect("pool_base_token_account is not set"),
pool_quote_token_account: self
.instruction
.pool_quote_token_account
.expect("pool_quote_token_account is not set"),
token2022_program: self
.instruction
.token2022_program
.expect("token2022_program is not set"),
associated_token_program: self
.instruction
.associated_token_program
.expect("associated_token_program is not set"),
pump_amm_event_authority: self
.instruction
.pump_amm_event_authority
.expect("pump_amm_event_authority is not set"),
event_authority: self
.instruction
.event_authority
.expect("event_authority is not set"),
program: self.instruction.program.expect("program is not set"),
};
instruction.invoke_signed_with_remaining_accounts(
signers_seeds,
&self.instruction.__remaining_accounts,
)
}
}
#[derive(Clone, Debug)]
struct MigrateCpiBuilderInstruction<'a, 'b> {
__program: &'b solana_account_info::AccountInfo<'a>,
global: Option<&'b solana_account_info::AccountInfo<'a>>,
withdraw_authority: Option<&'b solana_account_info::AccountInfo<'a>>,
mint: Option<&'b solana_account_info::AccountInfo<'a>>,
bonding_curve: Option<&'b solana_account_info::AccountInfo<'a>>,
associated_bonding_curve: Option<&'b solana_account_info::AccountInfo<'a>>,
user: Option<&'b solana_account_info::AccountInfo<'a>>,
system_program: Option<&'b solana_account_info::AccountInfo<'a>>,
token_program: Option<&'b solana_account_info::AccountInfo<'a>>,
pump_amm: Option<&'b solana_account_info::AccountInfo<'a>>,
pool: Option<&'b solana_account_info::AccountInfo<'a>>,
pool_authority: Option<&'b solana_account_info::AccountInfo<'a>>,
pool_authority_mint_account: Option<&'b solana_account_info::AccountInfo<'a>>,
pool_authority_wsol_account: Option<&'b solana_account_info::AccountInfo<'a>>,
amm_global_config: Option<&'b solana_account_info::AccountInfo<'a>>,
wsol_mint: Option<&'b solana_account_info::AccountInfo<'a>>,
lp_mint: Option<&'b solana_account_info::AccountInfo<'a>>,
user_pool_token_account: Option<&'b solana_account_info::AccountInfo<'a>>,
pool_base_token_account: Option<&'b solana_account_info::AccountInfo<'a>>,
pool_quote_token_account: Option<&'b solana_account_info::AccountInfo<'a>>,
token2022_program: Option<&'b solana_account_info::AccountInfo<'a>>,
associated_token_program: Option<&'b solana_account_info::AccountInfo<'a>>,
pump_amm_event_authority: Option<&'b solana_account_info::AccountInfo<'a>>,
event_authority: Option<&'b solana_account_info::AccountInfo<'a>>,
program: Option<&'b solana_account_info::AccountInfo<'a>>,
__remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>,
}