use borsh::BorshDeserialize;
use borsh::BorshSerialize;
pub struct Swap {
pub pool: solana_program::pubkey::Pubkey,
pub user_source_token: solana_program::pubkey::Pubkey,
pub user_destination_token: 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 protocol_token_fee: solana_program::pubkey::Pubkey,
pub user: solana_program::pubkey::Pubkey,
pub vault_program: solana_program::pubkey::Pubkey,
pub token_program: solana_program::pubkey::Pubkey,
}
impl Swap {
pub fn instruction(
&self,
args: SwapInstructionArgs,
) -> solana_program::instruction::Instruction {
self.instruction_with_remaining_accounts(args, &[])
}
#[allow(clippy::vec_init_then_push)]
pub fn instruction_with_remaining_accounts(
&self,
args: SwapInstructionArgs,
remaining_accounts: &[solana_program::instruction::AccountMeta],
) -> solana_program::instruction::Instruction {
let mut accounts = Vec::with_capacity(15 + remaining_accounts.len());
accounts.push(solana_program::instruction::AccountMeta::new(
self.pool, false,
));
accounts.push(solana_program::instruction::AccountMeta::new(
self.user_source_token,
false,
));
accounts.push(solana_program::instruction::AccountMeta::new(
self.user_destination_token,
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.protocol_token_fee,
false,
));
accounts.push(solana_program::instruction::AccountMeta::new_readonly(
self.user, true,
));
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.extend_from_slice(remaining_accounts);
let mut data = SwapInstructionData::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 SwapInstructionData {
discriminator: [u8; 8],
}
impl SwapInstructionData {
pub fn new() -> Self {
Self {
discriminator: [248, 198, 158, 145, 225, 117, 135, 200],
}
}
}
impl Default for SwapInstructionData {
fn default() -> Self {
Self::new()
}
}
#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct SwapInstructionArgs {
pub in_amount: u64,
pub minimum_out_amount: u64,
}
#[derive(Clone, Debug, Default)]
pub struct SwapBuilder {
pool: Option<solana_program::pubkey::Pubkey>,
user_source_token: Option<solana_program::pubkey::Pubkey>,
user_destination_token: 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>,
protocol_token_fee: Option<solana_program::pubkey::Pubkey>,
user: Option<solana_program::pubkey::Pubkey>,
vault_program: Option<solana_program::pubkey::Pubkey>,
token_program: Option<solana_program::pubkey::Pubkey>,
in_amount: Option<u64>,
minimum_out_amount: Option<u64>,
__remaining_accounts: Vec<solana_program::instruction::AccountMeta>,
}
impl SwapBuilder {
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 user_source_token(
&mut self,
user_source_token: solana_program::pubkey::Pubkey,
) -> &mut Self {
self.user_source_token = Some(user_source_token);
self
}
#[inline(always)]
pub fn user_destination_token(
&mut self,
user_destination_token: solana_program::pubkey::Pubkey,
) -> &mut Self {
self.user_destination_token = Some(user_destination_token);
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 protocol_token_fee(
&mut self,
protocol_token_fee: solana_program::pubkey::Pubkey,
) -> &mut Self {
self.protocol_token_fee = Some(protocol_token_fee);
self
}
#[inline(always)]
pub fn user(&mut self, user: solana_program::pubkey::Pubkey) -> &mut Self {
self.user = Some(user);
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 in_amount(&mut self, in_amount: u64) -> &mut Self {
self.in_amount = Some(in_amount);
self
}
#[inline(always)]
pub fn minimum_out_amount(&mut self, minimum_out_amount: u64) -> &mut Self {
self.minimum_out_amount = Some(minimum_out_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 = Swap {
pool: self.pool.expect("pool is not set"),
user_source_token: self
.user_source_token
.expect("user_source_token is not set"),
user_destination_token: self
.user_destination_token
.expect("user_destination_token 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"),
protocol_token_fee: self
.protocol_token_fee
.expect("protocol_token_fee is not set"),
user: self.user.expect("user 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"
)),
};
let args = SwapInstructionArgs {
in_amount: self.in_amount.clone().expect("in_amount is not set"),
minimum_out_amount: self
.minimum_out_amount
.clone()
.expect("minimum_out_amount is not set"),
};
accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts)
}
}
pub struct SwapCpiAccounts<'a, 'b> {
pub pool: &'b solana_program::account_info::AccountInfo<'a>,
pub user_source_token: &'b solana_program::account_info::AccountInfo<'a>,
pub user_destination_token: &'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 protocol_token_fee: &'b solana_program::account_info::AccountInfo<'a>,
pub user: &'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 struct SwapCpi<'a, 'b> {
pub __program: &'b solana_program::account_info::AccountInfo<'a>,
pub pool: &'b solana_program::account_info::AccountInfo<'a>,
pub user_source_token: &'b solana_program::account_info::AccountInfo<'a>,
pub user_destination_token: &'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 protocol_token_fee: &'b solana_program::account_info::AccountInfo<'a>,
pub user: &'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 __args: SwapInstructionArgs,
}
impl<'a, 'b> SwapCpi<'a, 'b> {
pub fn new(
program: &'b solana_program::account_info::AccountInfo<'a>,
accounts: SwapCpiAccounts<'a, 'b>,
args: SwapInstructionArgs,
) -> Self {
Self {
__program: program,
pool: accounts.pool,
user_source_token: accounts.user_source_token,
user_destination_token: accounts.user_destination_token,
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,
protocol_token_fee: accounts.protocol_token_fee,
user: accounts.user,
vault_program: accounts.vault_program,
token_program: accounts.token_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(15 + remaining_accounts.len());
accounts.push(solana_program::instruction::AccountMeta::new(
*self.pool.key,
false,
));
accounts.push(solana_program::instruction::AccountMeta::new(
*self.user_source_token.key,
false,
));
accounts.push(solana_program::instruction::AccountMeta::new(
*self.user_destination_token.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.protocol_token_fee.key,
false,
));
accounts.push(solana_program::instruction::AccountMeta::new_readonly(
*self.user.key,
true,
));
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,
));
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 = SwapInstructionData::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(16 + remaining_accounts.len());
account_infos.push(self.__program.clone());
account_infos.push(self.pool.clone());
account_infos.push(self.user_source_token.clone());
account_infos.push(self.user_destination_token.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.protocol_token_fee.clone());
account_infos.push(self.user.clone());
account_infos.push(self.vault_program.clone());
account_infos.push(self.token_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 SwapCpiBuilder<'a, 'b> {
instruction: Box<SwapCpiBuilderInstruction<'a, 'b>>,
}
impl<'a, 'b> SwapCpiBuilder<'a, 'b> {
pub fn new(program: &'b solana_program::account_info::AccountInfo<'a>) -> Self {
let instruction = Box::new(SwapCpiBuilderInstruction {
__program: program,
pool: None,
user_source_token: None,
user_destination_token: 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,
protocol_token_fee: None,
user: None,
vault_program: None,
token_program: None,
in_amount: None,
minimum_out_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 user_source_token(
&mut self,
user_source_token: &'b solana_program::account_info::AccountInfo<'a>,
) -> &mut Self {
self.instruction.user_source_token = Some(user_source_token);
self
}
#[inline(always)]
pub fn user_destination_token(
&mut self,
user_destination_token: &'b solana_program::account_info::AccountInfo<'a>,
) -> &mut Self {
self.instruction.user_destination_token = Some(user_destination_token);
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 protocol_token_fee(
&mut self,
protocol_token_fee: &'b solana_program::account_info::AccountInfo<'a>,
) -> &mut Self {
self.instruction.protocol_token_fee = Some(protocol_token_fee);
self
}
#[inline(always)]
pub fn user(&mut self, user: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self {
self.instruction.user = Some(user);
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 in_amount(&mut self, in_amount: u64) -> &mut Self {
self.instruction.in_amount = Some(in_amount);
self
}
#[inline(always)]
pub fn minimum_out_amount(&mut self, minimum_out_amount: u64) -> &mut Self {
self.instruction.minimum_out_amount = Some(minimum_out_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 = SwapInstructionArgs {
in_amount: self
.instruction
.in_amount
.clone()
.expect("in_amount is not set"),
minimum_out_amount: self
.instruction
.minimum_out_amount
.clone()
.expect("minimum_out_amount is not set"),
};
let instruction = SwapCpi {
__program: self.instruction.__program,
pool: self.instruction.pool.expect("pool is not set"),
user_source_token: self
.instruction
.user_source_token
.expect("user_source_token is not set"),
user_destination_token: self
.instruction
.user_destination_token
.expect("user_destination_token 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"),
protocol_token_fee: self
.instruction
.protocol_token_fee
.expect("protocol_token_fee is not set"),
user: self.instruction.user.expect("user 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"),
__args: args,
};
instruction.invoke_signed_with_remaining_accounts(
signers_seeds,
&self.instruction.__remaining_accounts,
)
}
}
#[derive(Clone, Debug)]
struct SwapCpiBuilderInstruction<'a, 'b> {
__program: &'b solana_program::account_info::AccountInfo<'a>,
pool: Option<&'b solana_program::account_info::AccountInfo<'a>>,
user_source_token: Option<&'b solana_program::account_info::AccountInfo<'a>>,
user_destination_token: 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>>,
protocol_token_fee: Option<&'b solana_program::account_info::AccountInfo<'a>>,
user: 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>>,
in_amount: Option<u64>,
minimum_out_amount: Option<u64>,
__remaining_accounts: Vec<(
&'b solana_program::account_info::AccountInfo<'a>,
bool,
bool,
)>,
}