use borsh::BorshDeserialize;
use borsh::BorshSerialize;
#[derive(Debug)]
pub struct Initialize {
pub creator: solana_pubkey::Pubkey,
pub amm_config: solana_pubkey::Pubkey,
pub authority: solana_pubkey::Pubkey,
pub pool_state: solana_pubkey::Pubkey,
pub token0_mint: solana_pubkey::Pubkey,
pub token1_mint: solana_pubkey::Pubkey,
pub lp_mint: solana_pubkey::Pubkey,
pub creator_token0: solana_pubkey::Pubkey,
pub creator_token1: solana_pubkey::Pubkey,
pub creator_lp_token: solana_pubkey::Pubkey,
pub token0_vault: solana_pubkey::Pubkey,
pub token1_vault: solana_pubkey::Pubkey,
pub create_pool_fee: solana_pubkey::Pubkey,
pub observation_state: solana_pubkey::Pubkey,
pub token_program: solana_pubkey::Pubkey,
pub token0_program: solana_pubkey::Pubkey,
pub token1_program: solana_pubkey::Pubkey,
pub associated_token_program: solana_pubkey::Pubkey,
pub system_program: solana_pubkey::Pubkey,
pub rent: solana_pubkey::Pubkey,
}
impl Initialize {
pub fn instruction(&self, args: InitializeInstructionArgs) -> solana_instruction::Instruction {
self.instruction_with_remaining_accounts(args, &[])
}
#[allow(clippy::arithmetic_side_effects)]
#[allow(clippy::vec_init_then_push)]
pub fn instruction_with_remaining_accounts(
&self,
args: InitializeInstructionArgs,
remaining_accounts: &[solana_instruction::AccountMeta],
) -> solana_instruction::Instruction {
let mut accounts = Vec::with_capacity(20 + remaining_accounts.len());
accounts.push(solana_instruction::AccountMeta::new(self.creator, true));
accounts.push(solana_instruction::AccountMeta::new_readonly(
self.amm_config,
false,
));
accounts.push(solana_instruction::AccountMeta::new_readonly(
self.authority,
false,
));
accounts.push(solana_instruction::AccountMeta::new(self.pool_state, false));
accounts.push(solana_instruction::AccountMeta::new_readonly(
self.token0_mint,
false,
));
accounts.push(solana_instruction::AccountMeta::new_readonly(
self.token1_mint,
false,
));
accounts.push(solana_instruction::AccountMeta::new(self.lp_mint, false));
accounts.push(solana_instruction::AccountMeta::new(
self.creator_token0,
false,
));
accounts.push(solana_instruction::AccountMeta::new(
self.creator_token1,
false,
));
accounts.push(solana_instruction::AccountMeta::new(
self.creator_lp_token,
false,
));
accounts.push(solana_instruction::AccountMeta::new(
self.token0_vault,
false,
));
accounts.push(solana_instruction::AccountMeta::new(
self.token1_vault,
false,
));
accounts.push(solana_instruction::AccountMeta::new(
self.create_pool_fee,
false,
));
accounts.push(solana_instruction::AccountMeta::new(
self.observation_state,
false,
));
accounts.push(solana_instruction::AccountMeta::new_readonly(
self.token_program,
false,
));
accounts.push(solana_instruction::AccountMeta::new_readonly(
self.token0_program,
false,
));
accounts.push(solana_instruction::AccountMeta::new_readonly(
self.token1_program,
false,
));
accounts.push(solana_instruction::AccountMeta::new_readonly(
self.associated_token_program,
false,
));
accounts.push(solana_instruction::AccountMeta::new_readonly(
self.system_program,
false,
));
accounts.push(solana_instruction::AccountMeta::new_readonly(
self.rent, false,
));
accounts.extend_from_slice(remaining_accounts);
let mut data = borsh::to_vec(&InitializeInstructionData::new()).unwrap();
let mut args = borsh::to_vec(&args).unwrap();
data.append(&mut args);
solana_instruction::Instruction {
program_id: crate::RAYDIUM_CP_SWAP_ID,
accounts,
data,
}
}
}
#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct InitializeInstructionData {
discriminator: [u8; 8],
}
impl InitializeInstructionData {
pub fn new() -> Self {
Self {
discriminator: [175, 175, 109, 31, 13, 152, 155, 237],
}
}
}
impl Default for InitializeInstructionData {
fn default() -> Self {
Self::new()
}
}
#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct InitializeInstructionArgs {
pub init_amount0: u64,
pub init_amount1: u64,
pub open_time: u64,
}
#[derive(Clone, Debug, Default)]
pub struct InitializeBuilder {
creator: Option<solana_pubkey::Pubkey>,
amm_config: Option<solana_pubkey::Pubkey>,
authority: Option<solana_pubkey::Pubkey>,
pool_state: Option<solana_pubkey::Pubkey>,
token0_mint: Option<solana_pubkey::Pubkey>,
token1_mint: Option<solana_pubkey::Pubkey>,
lp_mint: Option<solana_pubkey::Pubkey>,
creator_token0: Option<solana_pubkey::Pubkey>,
creator_token1: Option<solana_pubkey::Pubkey>,
creator_lp_token: Option<solana_pubkey::Pubkey>,
token0_vault: Option<solana_pubkey::Pubkey>,
token1_vault: Option<solana_pubkey::Pubkey>,
create_pool_fee: Option<solana_pubkey::Pubkey>,
observation_state: Option<solana_pubkey::Pubkey>,
token_program: Option<solana_pubkey::Pubkey>,
token0_program: Option<solana_pubkey::Pubkey>,
token1_program: Option<solana_pubkey::Pubkey>,
associated_token_program: Option<solana_pubkey::Pubkey>,
system_program: Option<solana_pubkey::Pubkey>,
rent: Option<solana_pubkey::Pubkey>,
init_amount0: Option<u64>,
init_amount1: Option<u64>,
open_time: Option<u64>,
__remaining_accounts: Vec<solana_instruction::AccountMeta>,
}
impl InitializeBuilder {
pub fn new() -> Self {
Self::default()
}
#[inline(always)]
pub fn creator(&mut self, creator: solana_pubkey::Pubkey) -> &mut Self {
self.creator = Some(creator);
self
}
#[inline(always)]
pub fn amm_config(&mut self, amm_config: solana_pubkey::Pubkey) -> &mut Self {
self.amm_config = Some(amm_config);
self
}
#[inline(always)]
pub fn authority(&mut self, authority: solana_pubkey::Pubkey) -> &mut Self {
self.authority = Some(authority);
self
}
#[inline(always)]
pub fn pool_state(&mut self, pool_state: solana_pubkey::Pubkey) -> &mut Self {
self.pool_state = Some(pool_state);
self
}
#[inline(always)]
pub fn token0_mint(&mut self, token0_mint: solana_pubkey::Pubkey) -> &mut Self {
self.token0_mint = Some(token0_mint);
self
}
#[inline(always)]
pub fn token1_mint(&mut self, token1_mint: solana_pubkey::Pubkey) -> &mut Self {
self.token1_mint = Some(token1_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 creator_token0(&mut self, creator_token0: solana_pubkey::Pubkey) -> &mut Self {
self.creator_token0 = Some(creator_token0);
self
}
#[inline(always)]
pub fn creator_token1(&mut self, creator_token1: solana_pubkey::Pubkey) -> &mut Self {
self.creator_token1 = Some(creator_token1);
self
}
#[inline(always)]
pub fn creator_lp_token(&mut self, creator_lp_token: solana_pubkey::Pubkey) -> &mut Self {
self.creator_lp_token = Some(creator_lp_token);
self
}
#[inline(always)]
pub fn token0_vault(&mut self, token0_vault: solana_pubkey::Pubkey) -> &mut Self {
self.token0_vault = Some(token0_vault);
self
}
#[inline(always)]
pub fn token1_vault(&mut self, token1_vault: solana_pubkey::Pubkey) -> &mut Self {
self.token1_vault = Some(token1_vault);
self
}
#[inline(always)]
pub fn create_pool_fee(&mut self, create_pool_fee: solana_pubkey::Pubkey) -> &mut Self {
self.create_pool_fee = Some(create_pool_fee);
self
}
#[inline(always)]
pub fn observation_state(&mut self, observation_state: solana_pubkey::Pubkey) -> &mut Self {
self.observation_state = Some(observation_state);
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 token0_program(&mut self, token0_program: solana_pubkey::Pubkey) -> &mut Self {
self.token0_program = Some(token0_program);
self
}
#[inline(always)]
pub fn token1_program(&mut self, token1_program: solana_pubkey::Pubkey) -> &mut Self {
self.token1_program = Some(token1_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 system_program(&mut self, system_program: solana_pubkey::Pubkey) -> &mut Self {
self.system_program = Some(system_program);
self
}
#[inline(always)]
pub fn rent(&mut self, rent: solana_pubkey::Pubkey) -> &mut Self {
self.rent = Some(rent);
self
}
#[inline(always)]
pub fn init_amount0(&mut self, init_amount0: u64) -> &mut Self {
self.init_amount0 = Some(init_amount0);
self
}
#[inline(always)]
pub fn init_amount1(&mut self, init_amount1: u64) -> &mut Self {
self.init_amount1 = Some(init_amount1);
self
}
#[inline(always)]
pub fn open_time(&mut self, open_time: u64) -> &mut Self {
self.open_time = Some(open_time);
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 = Initialize {
creator: self.creator.expect("creator is not set"),
amm_config: self.amm_config.expect("amm_config is not set"),
authority: self.authority.expect("authority is not set"),
pool_state: self.pool_state.expect("pool_state is not set"),
token0_mint: self.token0_mint.expect("token0_mint is not set"),
token1_mint: self.token1_mint.expect("token1_mint is not set"),
lp_mint: self.lp_mint.expect("lp_mint is not set"),
creator_token0: self.creator_token0.expect("creator_token0 is not set"),
creator_token1: self.creator_token1.expect("creator_token1 is not set"),
creator_lp_token: self.creator_lp_token.expect("creator_lp_token is not set"),
token0_vault: self.token0_vault.expect("token0_vault is not set"),
token1_vault: self.token1_vault.expect("token1_vault is not set"),
create_pool_fee: self.create_pool_fee.unwrap_or(solana_pubkey::pubkey!(
"DNXgeM9EiiaAbaWvwjHj9fQQLAX5ZsfHyvmYUNRAdNC8"
)),
observation_state: self
.observation_state
.expect("observation_state is not set"),
token_program: self.token_program.unwrap_or(solana_pubkey::pubkey!(
"TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"
)),
token0_program: self.token0_program.expect("token0_program is not set"),
token1_program: self.token1_program.expect("token1_program is not set"),
associated_token_program: self.associated_token_program.unwrap_or(
solana_pubkey::pubkey!("ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL"),
),
system_program: self
.system_program
.unwrap_or(solana_pubkey::pubkey!("11111111111111111111111111111111")),
rent: self.rent.unwrap_or(solana_pubkey::pubkey!(
"SysvarRent111111111111111111111111111111111"
)),
};
let args = InitializeInstructionArgs {
init_amount0: self.init_amount0.clone().expect("init_amount0 is not set"),
init_amount1: self.init_amount1.clone().expect("init_amount1 is not set"),
open_time: self.open_time.clone().expect("open_time is not set"),
};
accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts)
}
}
pub struct InitializeCpiAccounts<'a, 'b> {
pub creator: &'b solana_account_info::AccountInfo<'a>,
pub amm_config: &'b solana_account_info::AccountInfo<'a>,
pub authority: &'b solana_account_info::AccountInfo<'a>,
pub pool_state: &'b solana_account_info::AccountInfo<'a>,
pub token0_mint: &'b solana_account_info::AccountInfo<'a>,
pub token1_mint: &'b solana_account_info::AccountInfo<'a>,
pub lp_mint: &'b solana_account_info::AccountInfo<'a>,
pub creator_token0: &'b solana_account_info::AccountInfo<'a>,
pub creator_token1: &'b solana_account_info::AccountInfo<'a>,
pub creator_lp_token: &'b solana_account_info::AccountInfo<'a>,
pub token0_vault: &'b solana_account_info::AccountInfo<'a>,
pub token1_vault: &'b solana_account_info::AccountInfo<'a>,
pub create_pool_fee: &'b solana_account_info::AccountInfo<'a>,
pub observation_state: &'b solana_account_info::AccountInfo<'a>,
pub token_program: &'b solana_account_info::AccountInfo<'a>,
pub token0_program: &'b solana_account_info::AccountInfo<'a>,
pub token1_program: &'b solana_account_info::AccountInfo<'a>,
pub associated_token_program: &'b solana_account_info::AccountInfo<'a>,
pub system_program: &'b solana_account_info::AccountInfo<'a>,
pub rent: &'b solana_account_info::AccountInfo<'a>,
}
pub struct InitializeCpi<'a, 'b> {
pub __program: &'b solana_account_info::AccountInfo<'a>,
pub creator: &'b solana_account_info::AccountInfo<'a>,
pub amm_config: &'b solana_account_info::AccountInfo<'a>,
pub authority: &'b solana_account_info::AccountInfo<'a>,
pub pool_state: &'b solana_account_info::AccountInfo<'a>,
pub token0_mint: &'b solana_account_info::AccountInfo<'a>,
pub token1_mint: &'b solana_account_info::AccountInfo<'a>,
pub lp_mint: &'b solana_account_info::AccountInfo<'a>,
pub creator_token0: &'b solana_account_info::AccountInfo<'a>,
pub creator_token1: &'b solana_account_info::AccountInfo<'a>,
pub creator_lp_token: &'b solana_account_info::AccountInfo<'a>,
pub token0_vault: &'b solana_account_info::AccountInfo<'a>,
pub token1_vault: &'b solana_account_info::AccountInfo<'a>,
pub create_pool_fee: &'b solana_account_info::AccountInfo<'a>,
pub observation_state: &'b solana_account_info::AccountInfo<'a>,
pub token_program: &'b solana_account_info::AccountInfo<'a>,
pub token0_program: &'b solana_account_info::AccountInfo<'a>,
pub token1_program: &'b solana_account_info::AccountInfo<'a>,
pub associated_token_program: &'b solana_account_info::AccountInfo<'a>,
pub system_program: &'b solana_account_info::AccountInfo<'a>,
pub rent: &'b solana_account_info::AccountInfo<'a>,
pub __args: InitializeInstructionArgs,
}
impl<'a, 'b> InitializeCpi<'a, 'b> {
pub fn new(
program: &'b solana_account_info::AccountInfo<'a>,
accounts: InitializeCpiAccounts<'a, 'b>,
args: InitializeInstructionArgs,
) -> Self {
Self {
__program: program,
creator: accounts.creator,
amm_config: accounts.amm_config,
authority: accounts.authority,
pool_state: accounts.pool_state,
token0_mint: accounts.token0_mint,
token1_mint: accounts.token1_mint,
lp_mint: accounts.lp_mint,
creator_token0: accounts.creator_token0,
creator_token1: accounts.creator_token1,
creator_lp_token: accounts.creator_lp_token,
token0_vault: accounts.token0_vault,
token1_vault: accounts.token1_vault,
create_pool_fee: accounts.create_pool_fee,
observation_state: accounts.observation_state,
token_program: accounts.token_program,
token0_program: accounts.token0_program,
token1_program: accounts.token1_program,
associated_token_program: accounts.associated_token_program,
system_program: accounts.system_program,
rent: accounts.rent,
__args: args,
}
}
#[inline(always)]
pub fn invoke(&self) -> solana_program_entrypoint::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_entrypoint::ProgramResult {
self.invoke_signed_with_remaining_accounts(&[], remaining_accounts)
}
#[inline(always)]
pub fn invoke_signed(
&self,
signers_seeds: &[&[&[u8]]],
) -> solana_program_entrypoint::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_entrypoint::ProgramResult {
let mut accounts = Vec::with_capacity(20 + remaining_accounts.len());
accounts.push(solana_instruction::AccountMeta::new(
*self.creator.key,
true,
));
accounts.push(solana_instruction::AccountMeta::new_readonly(
*self.amm_config.key,
false,
));
accounts.push(solana_instruction::AccountMeta::new_readonly(
*self.authority.key,
false,
));
accounts.push(solana_instruction::AccountMeta::new(
*self.pool_state.key,
false,
));
accounts.push(solana_instruction::AccountMeta::new_readonly(
*self.token0_mint.key,
false,
));
accounts.push(solana_instruction::AccountMeta::new_readonly(
*self.token1_mint.key,
false,
));
accounts.push(solana_instruction::AccountMeta::new(
*self.lp_mint.key,
false,
));
accounts.push(solana_instruction::AccountMeta::new(
*self.creator_token0.key,
false,
));
accounts.push(solana_instruction::AccountMeta::new(
*self.creator_token1.key,
false,
));
accounts.push(solana_instruction::AccountMeta::new(
*self.creator_lp_token.key,
false,
));
accounts.push(solana_instruction::AccountMeta::new(
*self.token0_vault.key,
false,
));
accounts.push(solana_instruction::AccountMeta::new(
*self.token1_vault.key,
false,
));
accounts.push(solana_instruction::AccountMeta::new(
*self.create_pool_fee.key,
false,
));
accounts.push(solana_instruction::AccountMeta::new(
*self.observation_state.key,
false,
));
accounts.push(solana_instruction::AccountMeta::new_readonly(
*self.token_program.key,
false,
));
accounts.push(solana_instruction::AccountMeta::new_readonly(
*self.token0_program.key,
false,
));
accounts.push(solana_instruction::AccountMeta::new_readonly(
*self.token1_program.key,
false,
));
accounts.push(solana_instruction::AccountMeta::new_readonly(
*self.associated_token_program.key,
false,
));
accounts.push(solana_instruction::AccountMeta::new_readonly(
*self.system_program.key,
false,
));
accounts.push(solana_instruction::AccountMeta::new_readonly(
*self.rent.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 mut data = borsh::to_vec(&InitializeInstructionData::new()).unwrap();
let mut args = borsh::to_vec(&self.__args).unwrap();
data.append(&mut args);
let instruction = solana_instruction::Instruction {
program_id: crate::RAYDIUM_CP_SWAP_ID,
accounts,
data,
};
let mut account_infos = Vec::with_capacity(21 + remaining_accounts.len());
account_infos.push(self.__program.clone());
account_infos.push(self.creator.clone());
account_infos.push(self.amm_config.clone());
account_infos.push(self.authority.clone());
account_infos.push(self.pool_state.clone());
account_infos.push(self.token0_mint.clone());
account_infos.push(self.token1_mint.clone());
account_infos.push(self.lp_mint.clone());
account_infos.push(self.creator_token0.clone());
account_infos.push(self.creator_token1.clone());
account_infos.push(self.creator_lp_token.clone());
account_infos.push(self.token0_vault.clone());
account_infos.push(self.token1_vault.clone());
account_infos.push(self.create_pool_fee.clone());
account_infos.push(self.observation_state.clone());
account_infos.push(self.token_program.clone());
account_infos.push(self.token0_program.clone());
account_infos.push(self.token1_program.clone());
account_infos.push(self.associated_token_program.clone());
account_infos.push(self.system_program.clone());
account_infos.push(self.rent.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 InitializeCpiBuilder<'a, 'b> {
instruction: Box<InitializeCpiBuilderInstruction<'a, 'b>>,
}
impl<'a, 'b> InitializeCpiBuilder<'a, 'b> {
pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self {
let instruction = Box::new(InitializeCpiBuilderInstruction {
__program: program,
creator: None,
amm_config: None,
authority: None,
pool_state: None,
token0_mint: None,
token1_mint: None,
lp_mint: None,
creator_token0: None,
creator_token1: None,
creator_lp_token: None,
token0_vault: None,
token1_vault: None,
create_pool_fee: None,
observation_state: None,
token_program: None,
token0_program: None,
token1_program: None,
associated_token_program: None,
system_program: None,
rent: None,
init_amount0: None,
init_amount1: None,
open_time: None,
__remaining_accounts: Vec::new(),
});
Self { instruction }
}
#[inline(always)]
pub fn creator(&mut self, creator: &'b solana_account_info::AccountInfo<'a>) -> &mut Self {
self.instruction.creator = Some(creator);
self
}
#[inline(always)]
pub fn amm_config(
&mut self,
amm_config: &'b solana_account_info::AccountInfo<'a>,
) -> &mut Self {
self.instruction.amm_config = Some(amm_config);
self
}
#[inline(always)]
pub fn authority(&mut self, authority: &'b solana_account_info::AccountInfo<'a>) -> &mut Self {
self.instruction.authority = Some(authority);
self
}
#[inline(always)]
pub fn pool_state(
&mut self,
pool_state: &'b solana_account_info::AccountInfo<'a>,
) -> &mut Self {
self.instruction.pool_state = Some(pool_state);
self
}
#[inline(always)]
pub fn token0_mint(
&mut self,
token0_mint: &'b solana_account_info::AccountInfo<'a>,
) -> &mut Self {
self.instruction.token0_mint = Some(token0_mint);
self
}
#[inline(always)]
pub fn token1_mint(
&mut self,
token1_mint: &'b solana_account_info::AccountInfo<'a>,
) -> &mut Self {
self.instruction.token1_mint = Some(token1_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 creator_token0(
&mut self,
creator_token0: &'b solana_account_info::AccountInfo<'a>,
) -> &mut Self {
self.instruction.creator_token0 = Some(creator_token0);
self
}
#[inline(always)]
pub fn creator_token1(
&mut self,
creator_token1: &'b solana_account_info::AccountInfo<'a>,
) -> &mut Self {
self.instruction.creator_token1 = Some(creator_token1);
self
}
#[inline(always)]
pub fn creator_lp_token(
&mut self,
creator_lp_token: &'b solana_account_info::AccountInfo<'a>,
) -> &mut Self {
self.instruction.creator_lp_token = Some(creator_lp_token);
self
}
#[inline(always)]
pub fn token0_vault(
&mut self,
token0_vault: &'b solana_account_info::AccountInfo<'a>,
) -> &mut Self {
self.instruction.token0_vault = Some(token0_vault);
self
}
#[inline(always)]
pub fn token1_vault(
&mut self,
token1_vault: &'b solana_account_info::AccountInfo<'a>,
) -> &mut Self {
self.instruction.token1_vault = Some(token1_vault);
self
}
#[inline(always)]
pub fn create_pool_fee(
&mut self,
create_pool_fee: &'b solana_account_info::AccountInfo<'a>,
) -> &mut Self {
self.instruction.create_pool_fee = Some(create_pool_fee);
self
}
#[inline(always)]
pub fn observation_state(
&mut self,
observation_state: &'b solana_account_info::AccountInfo<'a>,
) -> &mut Self {
self.instruction.observation_state = Some(observation_state);
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 token0_program(
&mut self,
token0_program: &'b solana_account_info::AccountInfo<'a>,
) -> &mut Self {
self.instruction.token0_program = Some(token0_program);
self
}
#[inline(always)]
pub fn token1_program(
&mut self,
token1_program: &'b solana_account_info::AccountInfo<'a>,
) -> &mut Self {
self.instruction.token1_program = Some(token1_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 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 rent(&mut self, rent: &'b solana_account_info::AccountInfo<'a>) -> &mut Self {
self.instruction.rent = Some(rent);
self
}
#[inline(always)]
pub fn init_amount0(&mut self, init_amount0: u64) -> &mut Self {
self.instruction.init_amount0 = Some(init_amount0);
self
}
#[inline(always)]
pub fn init_amount1(&mut self, init_amount1: u64) -> &mut Self {
self.instruction.init_amount1 = Some(init_amount1);
self
}
#[inline(always)]
pub fn open_time(&mut self, open_time: u64) -> &mut Self {
self.instruction.open_time = Some(open_time);
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_entrypoint::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_entrypoint::ProgramResult {
let args = InitializeInstructionArgs {
init_amount0: self
.instruction
.init_amount0
.clone()
.expect("init_amount0 is not set"),
init_amount1: self
.instruction
.init_amount1
.clone()
.expect("init_amount1 is not set"),
open_time: self
.instruction
.open_time
.clone()
.expect("open_time is not set"),
};
let instruction = InitializeCpi {
__program: self.instruction.__program,
creator: self.instruction.creator.expect("creator is not set"),
amm_config: self.instruction.amm_config.expect("amm_config is not set"),
authority: self.instruction.authority.expect("authority is not set"),
pool_state: self.instruction.pool_state.expect("pool_state is not set"),
token0_mint: self
.instruction
.token0_mint
.expect("token0_mint is not set"),
token1_mint: self
.instruction
.token1_mint
.expect("token1_mint is not set"),
lp_mint: self.instruction.lp_mint.expect("lp_mint is not set"),
creator_token0: self
.instruction
.creator_token0
.expect("creator_token0 is not set"),
creator_token1: self
.instruction
.creator_token1
.expect("creator_token1 is not set"),
creator_lp_token: self
.instruction
.creator_lp_token
.expect("creator_lp_token is not set"),
token0_vault: self
.instruction
.token0_vault
.expect("token0_vault is not set"),
token1_vault: self
.instruction
.token1_vault
.expect("token1_vault is not set"),
create_pool_fee: self
.instruction
.create_pool_fee
.expect("create_pool_fee is not set"),
observation_state: self
.instruction
.observation_state
.expect("observation_state is not set"),
token_program: self
.instruction
.token_program
.expect("token_program is not set"),
token0_program: self
.instruction
.token0_program
.expect("token0_program is not set"),
token1_program: self
.instruction
.token1_program
.expect("token1_program is not set"),
associated_token_program: self
.instruction
.associated_token_program
.expect("associated_token_program is not set"),
system_program: self
.instruction
.system_program
.expect("system_program is not set"),
rent: self.instruction.rent.expect("rent is not set"),
__args: args,
};
instruction.invoke_signed_with_remaining_accounts(
signers_seeds,
&self.instruction.__remaining_accounts,
)
}
}
#[derive(Clone, Debug)]
struct InitializeCpiBuilderInstruction<'a, 'b> {
__program: &'b solana_account_info::AccountInfo<'a>,
creator: Option<&'b solana_account_info::AccountInfo<'a>>,
amm_config: Option<&'b solana_account_info::AccountInfo<'a>>,
authority: Option<&'b solana_account_info::AccountInfo<'a>>,
pool_state: Option<&'b solana_account_info::AccountInfo<'a>>,
token0_mint: Option<&'b solana_account_info::AccountInfo<'a>>,
token1_mint: Option<&'b solana_account_info::AccountInfo<'a>>,
lp_mint: Option<&'b solana_account_info::AccountInfo<'a>>,
creator_token0: Option<&'b solana_account_info::AccountInfo<'a>>,
creator_token1: Option<&'b solana_account_info::AccountInfo<'a>>,
creator_lp_token: Option<&'b solana_account_info::AccountInfo<'a>>,
token0_vault: Option<&'b solana_account_info::AccountInfo<'a>>,
token1_vault: Option<&'b solana_account_info::AccountInfo<'a>>,
create_pool_fee: Option<&'b solana_account_info::AccountInfo<'a>>,
observation_state: Option<&'b solana_account_info::AccountInfo<'a>>,
token_program: Option<&'b solana_account_info::AccountInfo<'a>>,
token0_program: Option<&'b solana_account_info::AccountInfo<'a>>,
token1_program: Option<&'b solana_account_info::AccountInfo<'a>>,
associated_token_program: Option<&'b solana_account_info::AccountInfo<'a>>,
system_program: Option<&'b solana_account_info::AccountInfo<'a>>,
rent: Option<&'b solana_account_info::AccountInfo<'a>>,
init_amount0: Option<u64>,
init_amount1: Option<u64>,
open_time: Option<u64>,
__remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>,
}