use crate::types::CurveType;
use borsh::BorshDeserialize;
use borsh::BorshSerialize;
pub struct InitializePermissionlessPool {
pub pool: solana_program::pubkey::Pubkey,
pub lp_mint: solana_program::pubkey::Pubkey,
pub token_a_mint: solana_program::pubkey::Pubkey,
pub token_b_mint: solana_program::pubkey::Pubkey,
pub a_vault: solana_program::pubkey::Pubkey,
pub b_vault: solana_program::pubkey::Pubkey,
pub a_token_vault: solana_program::pubkey::Pubkey,
pub b_token_vault: solana_program::pubkey::Pubkey,
pub a_vault_lp_mint: solana_program::pubkey::Pubkey,
pub b_vault_lp_mint: solana_program::pubkey::Pubkey,
pub a_vault_lp: solana_program::pubkey::Pubkey,
pub b_vault_lp: solana_program::pubkey::Pubkey,
pub payer_token_a: solana_program::pubkey::Pubkey,
pub payer_token_b: solana_program::pubkey::Pubkey,
pub payer_pool_lp: solana_program::pubkey::Pubkey,
pub protocol_token_a_fee: solana_program::pubkey::Pubkey,
pub protocol_token_b_fee: solana_program::pubkey::Pubkey,
pub payer: solana_program::pubkey::Pubkey,
pub fee_owner: solana_program::pubkey::Pubkey,
pub rent: solana_program::pubkey::Pubkey,
pub mint_metadata: solana_program::pubkey::Pubkey,
pub metadata_program: solana_program::pubkey::Pubkey,
pub vault_program: solana_program::pubkey::Pubkey,
pub token_program: solana_program::pubkey::Pubkey,
pub associated_token_program: solana_program::pubkey::Pubkey,
pub system_program: solana_program::pubkey::Pubkey,
}
impl InitializePermissionlessPool {
pub fn instruction(
&self,
args: InitializePermissionlessPoolInstructionArgs,
) -> solana_program::instruction::Instruction {
self.instruction_with_remaining_accounts(args, &[])
}
#[allow(clippy::vec_init_then_push)]
pub fn instruction_with_remaining_accounts(
&self,
args: InitializePermissionlessPoolInstructionArgs,
remaining_accounts: &[solana_program::instruction::AccountMeta],
) -> solana_program::instruction::Instruction {
let mut accounts = Vec::with_capacity(26 + remaining_accounts.len());
accounts.push(solana_program::instruction::AccountMeta::new(
self.pool, false,
));
accounts.push(solana_program::instruction::AccountMeta::new(
self.lp_mint,
false,
));
accounts.push(solana_program::instruction::AccountMeta::new_readonly(
self.token_a_mint,
false,
));
accounts.push(solana_program::instruction::AccountMeta::new_readonly(
self.token_b_mint,
false,
));
accounts.push(solana_program::instruction::AccountMeta::new(
self.a_vault,
false,
));
accounts.push(solana_program::instruction::AccountMeta::new(
self.b_vault,
false,
));
accounts.push(solana_program::instruction::AccountMeta::new(
self.a_token_vault,
false,
));
accounts.push(solana_program::instruction::AccountMeta::new(
self.b_token_vault,
false,
));
accounts.push(solana_program::instruction::AccountMeta::new(
self.a_vault_lp_mint,
false,
));
accounts.push(solana_program::instruction::AccountMeta::new(
self.b_vault_lp_mint,
false,
));
accounts.push(solana_program::instruction::AccountMeta::new(
self.a_vault_lp,
false,
));
accounts.push(solana_program::instruction::AccountMeta::new(
self.b_vault_lp,
false,
));
accounts.push(solana_program::instruction::AccountMeta::new(
self.payer_token_a,
false,
));
accounts.push(solana_program::instruction::AccountMeta::new(
self.payer_token_b,
false,
));
accounts.push(solana_program::instruction::AccountMeta::new(
self.payer_pool_lp,
false,
));
accounts.push(solana_program::instruction::AccountMeta::new(
self.protocol_token_a_fee,
false,
));
accounts.push(solana_program::instruction::AccountMeta::new(
self.protocol_token_b_fee,
false,
));
accounts.push(solana_program::instruction::AccountMeta::new(
self.payer, true,
));
accounts.push(solana_program::instruction::AccountMeta::new_readonly(
self.fee_owner,
false,
));
accounts.push(solana_program::instruction::AccountMeta::new_readonly(
self.rent, false,
));
accounts.push(solana_program::instruction::AccountMeta::new(
self.mint_metadata,
false,
));
accounts.push(solana_program::instruction::AccountMeta::new_readonly(
self.metadata_program,
false,
));
accounts.push(solana_program::instruction::AccountMeta::new_readonly(
self.vault_program,
false,
));
accounts.push(solana_program::instruction::AccountMeta::new_readonly(
self.token_program,
false,
));
accounts.push(solana_program::instruction::AccountMeta::new_readonly(
self.associated_token_program,
false,
));
accounts.push(solana_program::instruction::AccountMeta::new_readonly(
self.system_program,
false,
));
accounts.extend_from_slice(remaining_accounts);
let mut data = InitializePermissionlessPoolInstructionData::new()
.try_to_vec()
.unwrap();
let mut args = args.try_to_vec().unwrap();
data.append(&mut args);
solana_program::instruction::Instruction {
program_id: crate::AMM_ID,
accounts,
data,
}
}
}
#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct InitializePermissionlessPoolInstructionData {
discriminator: [u8; 8],
}
impl InitializePermissionlessPoolInstructionData {
pub fn new() -> Self {
Self {
discriminator: [118, 173, 41, 157, 173, 72, 97, 103],
}
}
}
impl Default for InitializePermissionlessPoolInstructionData {
fn default() -> Self {
Self::new()
}
}
#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct InitializePermissionlessPoolInstructionArgs {
pub curve_type: CurveType,
pub token_a_amount: u64,
pub token_b_amount: u64,
}
#[derive(Clone, Debug, Default)]
pub struct InitializePermissionlessPoolBuilder {
pool: Option<solana_program::pubkey::Pubkey>,
lp_mint: Option<solana_program::pubkey::Pubkey>,
token_a_mint: Option<solana_program::pubkey::Pubkey>,
token_b_mint: Option<solana_program::pubkey::Pubkey>,
a_vault: Option<solana_program::pubkey::Pubkey>,
b_vault: Option<solana_program::pubkey::Pubkey>,
a_token_vault: Option<solana_program::pubkey::Pubkey>,
b_token_vault: Option<solana_program::pubkey::Pubkey>,
a_vault_lp_mint: Option<solana_program::pubkey::Pubkey>,
b_vault_lp_mint: Option<solana_program::pubkey::Pubkey>,
a_vault_lp: Option<solana_program::pubkey::Pubkey>,
b_vault_lp: Option<solana_program::pubkey::Pubkey>,
payer_token_a: Option<solana_program::pubkey::Pubkey>,
payer_token_b: Option<solana_program::pubkey::Pubkey>,
payer_pool_lp: Option<solana_program::pubkey::Pubkey>,
protocol_token_a_fee: Option<solana_program::pubkey::Pubkey>,
protocol_token_b_fee: Option<solana_program::pubkey::Pubkey>,
payer: Option<solana_program::pubkey::Pubkey>,
fee_owner: Option<solana_program::pubkey::Pubkey>,
rent: Option<solana_program::pubkey::Pubkey>,
mint_metadata: Option<solana_program::pubkey::Pubkey>,
metadata_program: Option<solana_program::pubkey::Pubkey>,
vault_program: Option<solana_program::pubkey::Pubkey>,
token_program: Option<solana_program::pubkey::Pubkey>,
associated_token_program: Option<solana_program::pubkey::Pubkey>,
system_program: Option<solana_program::pubkey::Pubkey>,
curve_type: Option<CurveType>,
token_a_amount: Option<u64>,
token_b_amount: Option<u64>,
__remaining_accounts: Vec<solana_program::instruction::AccountMeta>,
}
impl InitializePermissionlessPoolBuilder {
pub fn new() -> Self {
Self::default()
}
#[inline(always)]
pub fn pool(&mut self, pool: solana_program::pubkey::Pubkey) -> &mut Self {
self.pool = Some(pool);
self
}
#[inline(always)]
pub fn lp_mint(&mut self, lp_mint: solana_program::pubkey::Pubkey) -> &mut Self {
self.lp_mint = Some(lp_mint);
self
}
#[inline(always)]
pub fn token_a_mint(&mut self, token_a_mint: solana_program::pubkey::Pubkey) -> &mut Self {
self.token_a_mint = Some(token_a_mint);
self
}
#[inline(always)]
pub fn token_b_mint(&mut self, token_b_mint: solana_program::pubkey::Pubkey) -> &mut Self {
self.token_b_mint = Some(token_b_mint);
self
}
#[inline(always)]
pub fn a_vault(&mut self, a_vault: solana_program::pubkey::Pubkey) -> &mut Self {
self.a_vault = Some(a_vault);
self
}
#[inline(always)]
pub fn b_vault(&mut self, b_vault: solana_program::pubkey::Pubkey) -> &mut Self {
self.b_vault = Some(b_vault);
self
}
#[inline(always)]
pub fn a_token_vault(&mut self, a_token_vault: solana_program::pubkey::Pubkey) -> &mut Self {
self.a_token_vault = Some(a_token_vault);
self
}
#[inline(always)]
pub fn b_token_vault(&mut self, b_token_vault: solana_program::pubkey::Pubkey) -> &mut Self {
self.b_token_vault = Some(b_token_vault);
self
}
#[inline(always)]
pub fn a_vault_lp_mint(
&mut self,
a_vault_lp_mint: solana_program::pubkey::Pubkey,
) -> &mut Self {
self.a_vault_lp_mint = Some(a_vault_lp_mint);
self
}
#[inline(always)]
pub fn b_vault_lp_mint(
&mut self,
b_vault_lp_mint: solana_program::pubkey::Pubkey,
) -> &mut Self {
self.b_vault_lp_mint = Some(b_vault_lp_mint);
self
}
#[inline(always)]
pub fn a_vault_lp(&mut self, a_vault_lp: solana_program::pubkey::Pubkey) -> &mut Self {
self.a_vault_lp = Some(a_vault_lp);
self
}
#[inline(always)]
pub fn b_vault_lp(&mut self, b_vault_lp: solana_program::pubkey::Pubkey) -> &mut Self {
self.b_vault_lp = Some(b_vault_lp);
self
}
#[inline(always)]
pub fn payer_token_a(&mut self, payer_token_a: solana_program::pubkey::Pubkey) -> &mut Self {
self.payer_token_a = Some(payer_token_a);
self
}
#[inline(always)]
pub fn payer_token_b(&mut self, payer_token_b: solana_program::pubkey::Pubkey) -> &mut Self {
self.payer_token_b = Some(payer_token_b);
self
}
#[inline(always)]
pub fn payer_pool_lp(&mut self, payer_pool_lp: solana_program::pubkey::Pubkey) -> &mut Self {
self.payer_pool_lp = Some(payer_pool_lp);
self
}
#[inline(always)]
pub fn protocol_token_a_fee(
&mut self,
protocol_token_a_fee: solana_program::pubkey::Pubkey,
) -> &mut Self {
self.protocol_token_a_fee = Some(protocol_token_a_fee);
self
}
#[inline(always)]
pub fn protocol_token_b_fee(
&mut self,
protocol_token_b_fee: solana_program::pubkey::Pubkey,
) -> &mut Self {
self.protocol_token_b_fee = Some(protocol_token_b_fee);
self
}
#[inline(always)]
pub fn payer(&mut self, payer: solana_program::pubkey::Pubkey) -> &mut Self {
self.payer = Some(payer);
self
}
#[inline(always)]
pub fn fee_owner(&mut self, fee_owner: solana_program::pubkey::Pubkey) -> &mut Self {
self.fee_owner = Some(fee_owner);
self
}
#[inline(always)]
pub fn rent(&mut self, rent: solana_program::pubkey::Pubkey) -> &mut Self {
self.rent = Some(rent);
self
}
#[inline(always)]
pub fn mint_metadata(&mut self, mint_metadata: solana_program::pubkey::Pubkey) -> &mut Self {
self.mint_metadata = Some(mint_metadata);
self
}
#[inline(always)]
pub fn metadata_program(
&mut self,
metadata_program: solana_program::pubkey::Pubkey,
) -> &mut Self {
self.metadata_program = Some(metadata_program);
self
}
#[inline(always)]
pub fn vault_program(&mut self, vault_program: solana_program::pubkey::Pubkey) -> &mut Self {
self.vault_program = Some(vault_program);
self
}
#[inline(always)]
pub fn token_program(&mut self, token_program: solana_program::pubkey::Pubkey) -> &mut Self {
self.token_program = Some(token_program);
self
}
#[inline(always)]
pub fn associated_token_program(
&mut self,
associated_token_program: solana_program::pubkey::Pubkey,
) -> &mut Self {
self.associated_token_program = Some(associated_token_program);
self
}
#[inline(always)]
pub fn system_program(&mut self, system_program: solana_program::pubkey::Pubkey) -> &mut Self {
self.system_program = Some(system_program);
self
}
#[inline(always)]
pub fn curve_type(&mut self, curve_type: CurveType) -> &mut Self {
self.curve_type = Some(curve_type);
self
}
#[inline(always)]
pub fn token_a_amount(&mut self, token_a_amount: u64) -> &mut Self {
self.token_a_amount = Some(token_a_amount);
self
}
#[inline(always)]
pub fn token_b_amount(&mut self, token_b_amount: u64) -> &mut Self {
self.token_b_amount = Some(token_b_amount);
self
}
#[inline(always)]
pub fn add_remaining_account(
&mut self,
account: solana_program::instruction::AccountMeta,
) -> &mut Self {
self.__remaining_accounts.push(account);
self
}
#[inline(always)]
pub fn add_remaining_accounts(
&mut self,
accounts: &[solana_program::instruction::AccountMeta],
) -> &mut Self {
self.__remaining_accounts.extend_from_slice(accounts);
self
}
#[allow(clippy::clone_on_copy)]
pub fn instruction(&self) -> solana_program::instruction::Instruction {
let accounts = InitializePermissionlessPool {
pool: self.pool.expect("pool is not set"),
lp_mint: self.lp_mint.expect("lp_mint is not set"),
token_a_mint: self.token_a_mint.expect("token_a_mint is not set"),
token_b_mint: self.token_b_mint.expect("token_b_mint is not set"),
a_vault: self.a_vault.expect("a_vault is not set"),
b_vault: self.b_vault.expect("b_vault is not set"),
a_token_vault: self.a_token_vault.expect("a_token_vault is not set"),
b_token_vault: self.b_token_vault.expect("b_token_vault is not set"),
a_vault_lp_mint: self.a_vault_lp_mint.expect("a_vault_lp_mint is not set"),
b_vault_lp_mint: self.b_vault_lp_mint.expect("b_vault_lp_mint is not set"),
a_vault_lp: self.a_vault_lp.expect("a_vault_lp is not set"),
b_vault_lp: self.b_vault_lp.expect("b_vault_lp is not set"),
payer_token_a: self.payer_token_a.expect("payer_token_a is not set"),
payer_token_b: self.payer_token_b.expect("payer_token_b is not set"),
payer_pool_lp: self.payer_pool_lp.expect("payer_pool_lp is not set"),
protocol_token_a_fee: self
.protocol_token_a_fee
.expect("protocol_token_a_fee is not set"),
protocol_token_b_fee: self
.protocol_token_b_fee
.expect("protocol_token_b_fee is not set"),
payer: self.payer.expect("payer is not set"),
fee_owner: self.fee_owner.expect("fee_owner is not set"),
rent: self.rent.unwrap_or(solana_program::pubkey!(
"SysvarRent111111111111111111111111111111111"
)),
mint_metadata: self.mint_metadata.expect("mint_metadata is not set"),
metadata_program: self.metadata_program.expect("metadata_program is not set"),
vault_program: self.vault_program.expect("vault_program is not set"),
token_program: self.token_program.unwrap_or(solana_program::pubkey!(
"TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"
)),
associated_token_program: self
.associated_token_program
.expect("associated_token_program is not set"),
system_program: self
.system_program
.unwrap_or(solana_program::pubkey!("11111111111111111111111111111111")),
};
let args = InitializePermissionlessPoolInstructionArgs {
curve_type: self.curve_type.clone().expect("curve_type is not set"),
token_a_amount: self
.token_a_amount
.clone()
.expect("token_a_amount is not set"),
token_b_amount: self
.token_b_amount
.clone()
.expect("token_b_amount is not set"),
};
accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts)
}
}
pub struct InitializePermissionlessPoolCpiAccounts<'a, 'b> {
pub pool: &'b solana_program::account_info::AccountInfo<'a>,
pub lp_mint: &'b solana_program::account_info::AccountInfo<'a>,
pub token_a_mint: &'b solana_program::account_info::AccountInfo<'a>,
pub token_b_mint: &'b solana_program::account_info::AccountInfo<'a>,
pub a_vault: &'b solana_program::account_info::AccountInfo<'a>,
pub b_vault: &'b solana_program::account_info::AccountInfo<'a>,
pub a_token_vault: &'b solana_program::account_info::AccountInfo<'a>,
pub b_token_vault: &'b solana_program::account_info::AccountInfo<'a>,
pub a_vault_lp_mint: &'b solana_program::account_info::AccountInfo<'a>,
pub b_vault_lp_mint: &'b solana_program::account_info::AccountInfo<'a>,
pub a_vault_lp: &'b solana_program::account_info::AccountInfo<'a>,
pub b_vault_lp: &'b solana_program::account_info::AccountInfo<'a>,
pub payer_token_a: &'b solana_program::account_info::AccountInfo<'a>,
pub payer_token_b: &'b solana_program::account_info::AccountInfo<'a>,
pub payer_pool_lp: &'b solana_program::account_info::AccountInfo<'a>,
pub protocol_token_a_fee: &'b solana_program::account_info::AccountInfo<'a>,
pub protocol_token_b_fee: &'b solana_program::account_info::AccountInfo<'a>,
pub payer: &'b solana_program::account_info::AccountInfo<'a>,
pub fee_owner: &'b solana_program::account_info::AccountInfo<'a>,
pub rent: &'b solana_program::account_info::AccountInfo<'a>,
pub mint_metadata: &'b solana_program::account_info::AccountInfo<'a>,
pub metadata_program: &'b solana_program::account_info::AccountInfo<'a>,
pub vault_program: &'b solana_program::account_info::AccountInfo<'a>,
pub token_program: &'b solana_program::account_info::AccountInfo<'a>,
pub associated_token_program: &'b solana_program::account_info::AccountInfo<'a>,
pub system_program: &'b solana_program::account_info::AccountInfo<'a>,
}
pub struct InitializePermissionlessPoolCpi<'a, 'b> {
pub __program: &'b solana_program::account_info::AccountInfo<'a>,
pub pool: &'b solana_program::account_info::AccountInfo<'a>,
pub lp_mint: &'b solana_program::account_info::AccountInfo<'a>,
pub token_a_mint: &'b solana_program::account_info::AccountInfo<'a>,
pub token_b_mint: &'b solana_program::account_info::AccountInfo<'a>,
pub a_vault: &'b solana_program::account_info::AccountInfo<'a>,
pub b_vault: &'b solana_program::account_info::AccountInfo<'a>,
pub a_token_vault: &'b solana_program::account_info::AccountInfo<'a>,
pub b_token_vault: &'b solana_program::account_info::AccountInfo<'a>,
pub a_vault_lp_mint: &'b solana_program::account_info::AccountInfo<'a>,
pub b_vault_lp_mint: &'b solana_program::account_info::AccountInfo<'a>,
pub a_vault_lp: &'b solana_program::account_info::AccountInfo<'a>,
pub b_vault_lp: &'b solana_program::account_info::AccountInfo<'a>,
pub payer_token_a: &'b solana_program::account_info::AccountInfo<'a>,
pub payer_token_b: &'b solana_program::account_info::AccountInfo<'a>,
pub payer_pool_lp: &'b solana_program::account_info::AccountInfo<'a>,
pub protocol_token_a_fee: &'b solana_program::account_info::AccountInfo<'a>,
pub protocol_token_b_fee: &'b solana_program::account_info::AccountInfo<'a>,
pub payer: &'b solana_program::account_info::AccountInfo<'a>,
pub fee_owner: &'b solana_program::account_info::AccountInfo<'a>,
pub rent: &'b solana_program::account_info::AccountInfo<'a>,
pub mint_metadata: &'b solana_program::account_info::AccountInfo<'a>,
pub metadata_program: &'b solana_program::account_info::AccountInfo<'a>,
pub vault_program: &'b solana_program::account_info::AccountInfo<'a>,
pub token_program: &'b solana_program::account_info::AccountInfo<'a>,
pub associated_token_program: &'b solana_program::account_info::AccountInfo<'a>,
pub system_program: &'b solana_program::account_info::AccountInfo<'a>,
pub __args: InitializePermissionlessPoolInstructionArgs,
}
impl<'a, 'b> InitializePermissionlessPoolCpi<'a, 'b> {
pub fn new(
program: &'b solana_program::account_info::AccountInfo<'a>,
accounts: InitializePermissionlessPoolCpiAccounts<'a, 'b>,
args: InitializePermissionlessPoolInstructionArgs,
) -> Self {
Self {
__program: program,
pool: accounts.pool,
lp_mint: accounts.lp_mint,
token_a_mint: accounts.token_a_mint,
token_b_mint: accounts.token_b_mint,
a_vault: accounts.a_vault,
b_vault: accounts.b_vault,
a_token_vault: accounts.a_token_vault,
b_token_vault: accounts.b_token_vault,
a_vault_lp_mint: accounts.a_vault_lp_mint,
b_vault_lp_mint: accounts.b_vault_lp_mint,
a_vault_lp: accounts.a_vault_lp,
b_vault_lp: accounts.b_vault_lp,
payer_token_a: accounts.payer_token_a,
payer_token_b: accounts.payer_token_b,
payer_pool_lp: accounts.payer_pool_lp,
protocol_token_a_fee: accounts.protocol_token_a_fee,
protocol_token_b_fee: accounts.protocol_token_b_fee,
payer: accounts.payer,
fee_owner: accounts.fee_owner,
rent: accounts.rent,
mint_metadata: accounts.mint_metadata,
metadata_program: accounts.metadata_program,
vault_program: accounts.vault_program,
token_program: accounts.token_program,
associated_token_program: accounts.associated_token_program,
system_program: accounts.system_program,
__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_program::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::clone_on_copy)]
#[allow(clippy::vec_init_then_push)]
pub fn invoke_signed_with_remaining_accounts(
&self,
signers_seeds: &[&[&[u8]]],
remaining_accounts: &[(
&'b solana_program::account_info::AccountInfo<'a>,
bool,
bool,
)],
) -> solana_program::entrypoint::ProgramResult {
let mut accounts = Vec::with_capacity(26 + remaining_accounts.len());
accounts.push(solana_program::instruction::AccountMeta::new(
*self.pool.key,
false,
));
accounts.push(solana_program::instruction::AccountMeta::new(
*self.lp_mint.key,
false,
));
accounts.push(solana_program::instruction::AccountMeta::new_readonly(
*self.token_a_mint.key,
false,
));
accounts.push(solana_program::instruction::AccountMeta::new_readonly(
*self.token_b_mint.key,
false,
));
accounts.push(solana_program::instruction::AccountMeta::new(
*self.a_vault.key,
false,
));
accounts.push(solana_program::instruction::AccountMeta::new(
*self.b_vault.key,
false,
));
accounts.push(solana_program::instruction::AccountMeta::new(
*self.a_token_vault.key,
false,
));
accounts.push(solana_program::instruction::AccountMeta::new(
*self.b_token_vault.key,
false,
));
accounts.push(solana_program::instruction::AccountMeta::new(
*self.a_vault_lp_mint.key,
false,
));
accounts.push(solana_program::instruction::AccountMeta::new(
*self.b_vault_lp_mint.key,
false,
));
accounts.push(solana_program::instruction::AccountMeta::new(
*self.a_vault_lp.key,
false,
));
accounts.push(solana_program::instruction::AccountMeta::new(
*self.b_vault_lp.key,
false,
));
accounts.push(solana_program::instruction::AccountMeta::new(
*self.payer_token_a.key,
false,
));
accounts.push(solana_program::instruction::AccountMeta::new(
*self.payer_token_b.key,
false,
));
accounts.push(solana_program::instruction::AccountMeta::new(
*self.payer_pool_lp.key,
false,
));
accounts.push(solana_program::instruction::AccountMeta::new(
*self.protocol_token_a_fee.key,
false,
));
accounts.push(solana_program::instruction::AccountMeta::new(
*self.protocol_token_b_fee.key,
false,
));
accounts.push(solana_program::instruction::AccountMeta::new(
*self.payer.key,
true,
));
accounts.push(solana_program::instruction::AccountMeta::new_readonly(
*self.fee_owner.key,
false,
));
accounts.push(solana_program::instruction::AccountMeta::new_readonly(
*self.rent.key,
false,
));
accounts.push(solana_program::instruction::AccountMeta::new(
*self.mint_metadata.key,
false,
));
accounts.push(solana_program::instruction::AccountMeta::new_readonly(
*self.metadata_program.key,
false,
));
accounts.push(solana_program::instruction::AccountMeta::new_readonly(
*self.vault_program.key,
false,
));
accounts.push(solana_program::instruction::AccountMeta::new_readonly(
*self.token_program.key,
false,
));
accounts.push(solana_program::instruction::AccountMeta::new_readonly(
*self.associated_token_program.key,
false,
));
accounts.push(solana_program::instruction::AccountMeta::new_readonly(
*self.system_program.key,
false,
));
remaining_accounts.iter().for_each(|remaining_account| {
accounts.push(solana_program::instruction::AccountMeta {
pubkey: *remaining_account.0.key,
is_signer: remaining_account.1,
is_writable: remaining_account.2,
})
});
let mut data = InitializePermissionlessPoolInstructionData::new()
.try_to_vec()
.unwrap();
let mut args = self.__args.try_to_vec().unwrap();
data.append(&mut args);
let instruction = solana_program::instruction::Instruction {
program_id: crate::AMM_ID,
accounts,
data,
};
let mut account_infos = Vec::with_capacity(27 + remaining_accounts.len());
account_infos.push(self.__program.clone());
account_infos.push(self.pool.clone());
account_infos.push(self.lp_mint.clone());
account_infos.push(self.token_a_mint.clone());
account_infos.push(self.token_b_mint.clone());
account_infos.push(self.a_vault.clone());
account_infos.push(self.b_vault.clone());
account_infos.push(self.a_token_vault.clone());
account_infos.push(self.b_token_vault.clone());
account_infos.push(self.a_vault_lp_mint.clone());
account_infos.push(self.b_vault_lp_mint.clone());
account_infos.push(self.a_vault_lp.clone());
account_infos.push(self.b_vault_lp.clone());
account_infos.push(self.payer_token_a.clone());
account_infos.push(self.payer_token_b.clone());
account_infos.push(self.payer_pool_lp.clone());
account_infos.push(self.protocol_token_a_fee.clone());
account_infos.push(self.protocol_token_b_fee.clone());
account_infos.push(self.payer.clone());
account_infos.push(self.fee_owner.clone());
account_infos.push(self.rent.clone());
account_infos.push(self.mint_metadata.clone());
account_infos.push(self.metadata_program.clone());
account_infos.push(self.vault_program.clone());
account_infos.push(self.token_program.clone());
account_infos.push(self.associated_token_program.clone());
account_infos.push(self.system_program.clone());
remaining_accounts
.iter()
.for_each(|remaining_account| account_infos.push(remaining_account.0.clone()));
if signers_seeds.is_empty() {
solana_program::program::invoke(&instruction, &account_infos)
} else {
solana_program::program::invoke_signed(&instruction, &account_infos, signers_seeds)
}
}
}
#[derive(Clone, Debug)]
pub struct InitializePermissionlessPoolCpiBuilder<'a, 'b> {
instruction: Box<InitializePermissionlessPoolCpiBuilderInstruction<'a, 'b>>,
}
impl<'a, 'b> InitializePermissionlessPoolCpiBuilder<'a, 'b> {
pub fn new(program: &'b solana_program::account_info::AccountInfo<'a>) -> Self {
let instruction = Box::new(InitializePermissionlessPoolCpiBuilderInstruction {
__program: program,
pool: None,
lp_mint: None,
token_a_mint: None,
token_b_mint: None,
a_vault: None,
b_vault: None,
a_token_vault: None,
b_token_vault: None,
a_vault_lp_mint: None,
b_vault_lp_mint: None,
a_vault_lp: None,
b_vault_lp: None,
payer_token_a: None,
payer_token_b: None,
payer_pool_lp: None,
protocol_token_a_fee: None,
protocol_token_b_fee: None,
payer: None,
fee_owner: None,
rent: None,
mint_metadata: None,
metadata_program: None,
vault_program: None,
token_program: None,
associated_token_program: None,
system_program: None,
curve_type: None,
token_a_amount: None,
token_b_amount: None,
__remaining_accounts: Vec::new(),
});
Self { instruction }
}
#[inline(always)]
pub fn pool(&mut self, pool: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self {
self.instruction.pool = Some(pool);
self
}
#[inline(always)]
pub fn lp_mint(
&mut self,
lp_mint: &'b solana_program::account_info::AccountInfo<'a>,
) -> &mut Self {
self.instruction.lp_mint = Some(lp_mint);
self
}
#[inline(always)]
pub fn token_a_mint(
&mut self,
token_a_mint: &'b solana_program::account_info::AccountInfo<'a>,
) -> &mut Self {
self.instruction.token_a_mint = Some(token_a_mint);
self
}
#[inline(always)]
pub fn token_b_mint(
&mut self,
token_b_mint: &'b solana_program::account_info::AccountInfo<'a>,
) -> &mut Self {
self.instruction.token_b_mint = Some(token_b_mint);
self
}
#[inline(always)]
pub fn a_vault(
&mut self,
a_vault: &'b solana_program::account_info::AccountInfo<'a>,
) -> &mut Self {
self.instruction.a_vault = Some(a_vault);
self
}
#[inline(always)]
pub fn b_vault(
&mut self,
b_vault: &'b solana_program::account_info::AccountInfo<'a>,
) -> &mut Self {
self.instruction.b_vault = Some(b_vault);
self
}
#[inline(always)]
pub fn a_token_vault(
&mut self,
a_token_vault: &'b solana_program::account_info::AccountInfo<'a>,
) -> &mut Self {
self.instruction.a_token_vault = Some(a_token_vault);
self
}
#[inline(always)]
pub fn b_token_vault(
&mut self,
b_token_vault: &'b solana_program::account_info::AccountInfo<'a>,
) -> &mut Self {
self.instruction.b_token_vault = Some(b_token_vault);
self
}
#[inline(always)]
pub fn a_vault_lp_mint(
&mut self,
a_vault_lp_mint: &'b solana_program::account_info::AccountInfo<'a>,
) -> &mut Self {
self.instruction.a_vault_lp_mint = Some(a_vault_lp_mint);
self
}
#[inline(always)]
pub fn b_vault_lp_mint(
&mut self,
b_vault_lp_mint: &'b solana_program::account_info::AccountInfo<'a>,
) -> &mut Self {
self.instruction.b_vault_lp_mint = Some(b_vault_lp_mint);
self
}
#[inline(always)]
pub fn a_vault_lp(
&mut self,
a_vault_lp: &'b solana_program::account_info::AccountInfo<'a>,
) -> &mut Self {
self.instruction.a_vault_lp = Some(a_vault_lp);
self
}
#[inline(always)]
pub fn b_vault_lp(
&mut self,
b_vault_lp: &'b solana_program::account_info::AccountInfo<'a>,
) -> &mut Self {
self.instruction.b_vault_lp = Some(b_vault_lp);
self
}
#[inline(always)]
pub fn payer_token_a(
&mut self,
payer_token_a: &'b solana_program::account_info::AccountInfo<'a>,
) -> &mut Self {
self.instruction.payer_token_a = Some(payer_token_a);
self
}
#[inline(always)]
pub fn payer_token_b(
&mut self,
payer_token_b: &'b solana_program::account_info::AccountInfo<'a>,
) -> &mut Self {
self.instruction.payer_token_b = Some(payer_token_b);
self
}
#[inline(always)]
pub fn payer_pool_lp(
&mut self,
payer_pool_lp: &'b solana_program::account_info::AccountInfo<'a>,
) -> &mut Self {
self.instruction.payer_pool_lp = Some(payer_pool_lp);
self
}
#[inline(always)]
pub fn protocol_token_a_fee(
&mut self,
protocol_token_a_fee: &'b solana_program::account_info::AccountInfo<'a>,
) -> &mut Self {
self.instruction.protocol_token_a_fee = Some(protocol_token_a_fee);
self
}
#[inline(always)]
pub fn protocol_token_b_fee(
&mut self,
protocol_token_b_fee: &'b solana_program::account_info::AccountInfo<'a>,
) -> &mut Self {
self.instruction.protocol_token_b_fee = Some(protocol_token_b_fee);
self
}
#[inline(always)]
pub fn payer(&mut self, payer: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self {
self.instruction.payer = Some(payer);
self
}
#[inline(always)]
pub fn fee_owner(
&mut self,
fee_owner: &'b solana_program::account_info::AccountInfo<'a>,
) -> &mut Self {
self.instruction.fee_owner = Some(fee_owner);
self
}
#[inline(always)]
pub fn rent(&mut self, rent: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self {
self.instruction.rent = Some(rent);
self
}
#[inline(always)]
pub fn mint_metadata(
&mut self,
mint_metadata: &'b solana_program::account_info::AccountInfo<'a>,
) -> &mut Self {
self.instruction.mint_metadata = Some(mint_metadata);
self
}
#[inline(always)]
pub fn metadata_program(
&mut self,
metadata_program: &'b solana_program::account_info::AccountInfo<'a>,
) -> &mut Self {
self.instruction.metadata_program = Some(metadata_program);
self
}
#[inline(always)]
pub fn vault_program(
&mut self,
vault_program: &'b solana_program::account_info::AccountInfo<'a>,
) -> &mut Self {
self.instruction.vault_program = Some(vault_program);
self
}
#[inline(always)]
pub fn token_program(
&mut self,
token_program: &'b solana_program::account_info::AccountInfo<'a>,
) -> &mut Self {
self.instruction.token_program = Some(token_program);
self
}
#[inline(always)]
pub fn associated_token_program(
&mut self,
associated_token_program: &'b solana_program::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_program::account_info::AccountInfo<'a>,
) -> &mut Self {
self.instruction.system_program = Some(system_program);
self
}
#[inline(always)]
pub fn curve_type(&mut self, curve_type: CurveType) -> &mut Self {
self.instruction.curve_type = Some(curve_type);
self
}
#[inline(always)]
pub fn token_a_amount(&mut self, token_a_amount: u64) -> &mut Self {
self.instruction.token_a_amount = Some(token_a_amount);
self
}
#[inline(always)]
pub fn token_b_amount(&mut self, token_b_amount: u64) -> &mut Self {
self.instruction.token_b_amount = Some(token_b_amount);
self
}
#[inline(always)]
pub fn add_remaining_account(
&mut self,
account: &'b solana_program::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_program::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 = InitializePermissionlessPoolInstructionArgs {
curve_type: self
.instruction
.curve_type
.clone()
.expect("curve_type is not set"),
token_a_amount: self
.instruction
.token_a_amount
.clone()
.expect("token_a_amount is not set"),
token_b_amount: self
.instruction
.token_b_amount
.clone()
.expect("token_b_amount is not set"),
};
let instruction = InitializePermissionlessPoolCpi {
__program: self.instruction.__program,
pool: self.instruction.pool.expect("pool is not set"),
lp_mint: self.instruction.lp_mint.expect("lp_mint is not set"),
token_a_mint: self
.instruction
.token_a_mint
.expect("token_a_mint is not set"),
token_b_mint: self
.instruction
.token_b_mint
.expect("token_b_mint is not set"),
a_vault: self.instruction.a_vault.expect("a_vault is not set"),
b_vault: self.instruction.b_vault.expect("b_vault is not set"),
a_token_vault: self
.instruction
.a_token_vault
.expect("a_token_vault is not set"),
b_token_vault: self
.instruction
.b_token_vault
.expect("b_token_vault is not set"),
a_vault_lp_mint: self
.instruction
.a_vault_lp_mint
.expect("a_vault_lp_mint is not set"),
b_vault_lp_mint: self
.instruction
.b_vault_lp_mint
.expect("b_vault_lp_mint is not set"),
a_vault_lp: self.instruction.a_vault_lp.expect("a_vault_lp is not set"),
b_vault_lp: self.instruction.b_vault_lp.expect("b_vault_lp is not set"),
payer_token_a: self
.instruction
.payer_token_a
.expect("payer_token_a is not set"),
payer_token_b: self
.instruction
.payer_token_b
.expect("payer_token_b is not set"),
payer_pool_lp: self
.instruction
.payer_pool_lp
.expect("payer_pool_lp is not set"),
protocol_token_a_fee: self
.instruction
.protocol_token_a_fee
.expect("protocol_token_a_fee is not set"),
protocol_token_b_fee: self
.instruction
.protocol_token_b_fee
.expect("protocol_token_b_fee is not set"),
payer: self.instruction.payer.expect("payer is not set"),
fee_owner: self.instruction.fee_owner.expect("fee_owner is not set"),
rent: self.instruction.rent.expect("rent is not set"),
mint_metadata: self
.instruction
.mint_metadata
.expect("mint_metadata is not set"),
metadata_program: self
.instruction
.metadata_program
.expect("metadata_program is not set"),
vault_program: self
.instruction
.vault_program
.expect("vault_program is not set"),
token_program: self
.instruction
.token_program
.expect("token_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"),
__args: args,
};
instruction.invoke_signed_with_remaining_accounts(
signers_seeds,
&self.instruction.__remaining_accounts,
)
}
}
#[derive(Clone, Debug)]
struct InitializePermissionlessPoolCpiBuilderInstruction<'a, 'b> {
__program: &'b solana_program::account_info::AccountInfo<'a>,
pool: Option<&'b solana_program::account_info::AccountInfo<'a>>,
lp_mint: Option<&'b solana_program::account_info::AccountInfo<'a>>,
token_a_mint: Option<&'b solana_program::account_info::AccountInfo<'a>>,
token_b_mint: Option<&'b solana_program::account_info::AccountInfo<'a>>,
a_vault: Option<&'b solana_program::account_info::AccountInfo<'a>>,
b_vault: Option<&'b solana_program::account_info::AccountInfo<'a>>,
a_token_vault: Option<&'b solana_program::account_info::AccountInfo<'a>>,
b_token_vault: Option<&'b solana_program::account_info::AccountInfo<'a>>,
a_vault_lp_mint: Option<&'b solana_program::account_info::AccountInfo<'a>>,
b_vault_lp_mint: Option<&'b solana_program::account_info::AccountInfo<'a>>,
a_vault_lp: Option<&'b solana_program::account_info::AccountInfo<'a>>,
b_vault_lp: Option<&'b solana_program::account_info::AccountInfo<'a>>,
payer_token_a: Option<&'b solana_program::account_info::AccountInfo<'a>>,
payer_token_b: Option<&'b solana_program::account_info::AccountInfo<'a>>,
payer_pool_lp: Option<&'b solana_program::account_info::AccountInfo<'a>>,
protocol_token_a_fee: Option<&'b solana_program::account_info::AccountInfo<'a>>,
protocol_token_b_fee: Option<&'b solana_program::account_info::AccountInfo<'a>>,
payer: Option<&'b solana_program::account_info::AccountInfo<'a>>,
fee_owner: Option<&'b solana_program::account_info::AccountInfo<'a>>,
rent: Option<&'b solana_program::account_info::AccountInfo<'a>>,
mint_metadata: Option<&'b solana_program::account_info::AccountInfo<'a>>,
metadata_program: Option<&'b solana_program::account_info::AccountInfo<'a>>,
vault_program: Option<&'b solana_program::account_info::AccountInfo<'a>>,
token_program: Option<&'b solana_program::account_info::AccountInfo<'a>>,
associated_token_program: Option<&'b solana_program::account_info::AccountInfo<'a>>,
system_program: Option<&'b solana_program::account_info::AccountInfo<'a>>,
curve_type: Option<CurveType>,
token_a_amount: Option<u64>,
token_b_amount: Option<u64>,
__remaining_accounts: Vec<(
&'b solana_program::account_info::AccountInfo<'a>,
bool,
bool,
)>,
}