use crate::generated::types::GraduationMethod;
use borsh::BorshDeserialize;
use borsh::BorshSerialize;
use solana_pubkey::Pubkey;
pub const BONDING_CURVE_INITIALIZE_DISCRIMINATOR: u8 = 48;
#[derive(Debug)]
pub struct BondingCurveInitialize {
pub authority: solana_pubkey::Pubkey,
pub bonding_curve: solana_pubkey::Pubkey,
pub base_mint: solana_pubkey::Pubkey,
pub quote_mint: solana_pubkey::Pubkey,
pub quote_vault: solana_pubkey::Pubkey,
pub authority_config: solana_pubkey::Pubkey,
pub system_program: solana_pubkey::Pubkey,
pub base_token_program: solana_pubkey::Pubkey,
pub quote_token_program: solana_pubkey::Pubkey,
pub ata_program: solana_pubkey::Pubkey,
}
impl BondingCurveInitialize {
pub fn instruction(
&self,
args: BondingCurveInitializeInstructionArgs,
) -> 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: BondingCurveInitializeInstructionArgs,
remaining_accounts: &[solana_instruction::AccountMeta],
) -> solana_instruction::Instruction {
let mut accounts = Vec::with_capacity(10 + remaining_accounts.len());
accounts.push(solana_instruction::AccountMeta::new(self.authority, true));
accounts.push(solana_instruction::AccountMeta::new(
self.bonding_curve,
false,
));
accounts.push(solana_instruction::AccountMeta::new_readonly(
self.base_mint,
false,
));
accounts.push(solana_instruction::AccountMeta::new_readonly(
self.quote_mint,
false,
));
accounts.push(solana_instruction::AccountMeta::new(
self.quote_vault,
false,
));
accounts.push(solana_instruction::AccountMeta::new_readonly(
self.authority_config,
false,
));
accounts.push(solana_instruction::AccountMeta::new_readonly(
self.system_program,
false,
));
accounts.push(solana_instruction::AccountMeta::new_readonly(
self.base_token_program,
false,
));
accounts.push(solana_instruction::AccountMeta::new_readonly(
self.quote_token_program,
false,
));
accounts.push(solana_instruction::AccountMeta::new_readonly(
self.ata_program,
false,
));
accounts.extend_from_slice(remaining_accounts);
let mut data = borsh::to_vec(&BondingCurveInitializeInstructionData::new()).unwrap();
let mut args = borsh::to_vec(&args).unwrap();
data.append(&mut args);
solana_instruction::Instruction {
program_id: crate::WAVEBREAK_ID,
accounts,
data,
}
}
}
#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct BondingCurveInitializeInstructionData {
discriminator: u8,
}
impl BondingCurveInitializeInstructionData {
pub fn new() -> Self {
Self { discriminator: 48 }
}
}
impl Default for BondingCurveInitializeInstructionData {
fn default() -> Self {
Self::new()
}
}
#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct BondingCurveInitializeInstructionArgs {
pub start_price: u128,
pub end_price: u128,
pub control_points: [u16; 4],
pub creator: Pubkey,
pub graduation_methods: [GraduationMethod; 8],
pub swap_fee_bps: u16,
pub quote_fee_bps: u16,
pub base_fee_bps: u16,
pub launch_time: i64,
pub creator_reward: u64,
pub graduation_reward: u64,
pub graduation_target: u64,
pub graduation_time: i64,
pub min_reserve_bps: u16,
pub buy_requires_permission: bool,
pub buy_permission_bitmap: [u8; 32],
pub sell_requires_permission: bool,
pub sell_permission_bitmap: [u8; 32],
pub max_buy_amount: u64,
pub max_sell_amount: u64,
pub retain_mint_authority: bool,
pub base_allocation_bps: u16,
}
#[derive(Clone, Debug, Default)]
pub struct BondingCurveInitializeBuilder {
authority: Option<solana_pubkey::Pubkey>,
bonding_curve: Option<solana_pubkey::Pubkey>,
base_mint: Option<solana_pubkey::Pubkey>,
quote_mint: Option<solana_pubkey::Pubkey>,
quote_vault: Option<solana_pubkey::Pubkey>,
authority_config: Option<solana_pubkey::Pubkey>,
system_program: Option<solana_pubkey::Pubkey>,
base_token_program: Option<solana_pubkey::Pubkey>,
quote_token_program: Option<solana_pubkey::Pubkey>,
ata_program: Option<solana_pubkey::Pubkey>,
start_price: Option<u128>,
end_price: Option<u128>,
control_points: Option<[u16; 4]>,
creator: Option<Pubkey>,
graduation_methods: Option<[GraduationMethod; 8]>,
swap_fee_bps: Option<u16>,
quote_fee_bps: Option<u16>,
base_fee_bps: Option<u16>,
launch_time: Option<i64>,
creator_reward: Option<u64>,
graduation_reward: Option<u64>,
graduation_target: Option<u64>,
graduation_time: Option<i64>,
min_reserve_bps: Option<u16>,
buy_requires_permission: Option<bool>,
buy_permission_bitmap: Option<[u8; 32]>,
sell_requires_permission: Option<bool>,
sell_permission_bitmap: Option<[u8; 32]>,
max_buy_amount: Option<u64>,
max_sell_amount: Option<u64>,
retain_mint_authority: Option<bool>,
base_allocation_bps: Option<u16>,
__remaining_accounts: Vec<solana_instruction::AccountMeta>,
}
impl BondingCurveInitializeBuilder {
pub fn new() -> Self {
Self::default()
}
#[inline(always)]
pub fn authority(&mut self, authority: solana_pubkey::Pubkey) -> &mut Self {
self.authority = Some(authority);
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 base_mint(&mut self, base_mint: solana_pubkey::Pubkey) -> &mut Self {
self.base_mint = Some(base_mint);
self
}
#[inline(always)]
pub fn quote_mint(&mut self, quote_mint: solana_pubkey::Pubkey) -> &mut Self {
self.quote_mint = Some(quote_mint);
self
}
#[inline(always)]
pub fn quote_vault(&mut self, quote_vault: solana_pubkey::Pubkey) -> &mut Self {
self.quote_vault = Some(quote_vault);
self
}
#[inline(always)]
pub fn authority_config(&mut self, authority_config: solana_pubkey::Pubkey) -> &mut Self {
self.authority_config = Some(authority_config);
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 base_token_program(&mut self, base_token_program: solana_pubkey::Pubkey) -> &mut Self {
self.base_token_program = Some(base_token_program);
self
}
#[inline(always)]
pub fn quote_token_program(&mut self, quote_token_program: solana_pubkey::Pubkey) -> &mut Self {
self.quote_token_program = Some(quote_token_program);
self
}
#[inline(always)]
pub fn ata_program(&mut self, ata_program: solana_pubkey::Pubkey) -> &mut Self {
self.ata_program = Some(ata_program);
self
}
#[inline(always)]
pub fn start_price(&mut self, start_price: u128) -> &mut Self {
self.start_price = Some(start_price);
self
}
#[inline(always)]
pub fn end_price(&mut self, end_price: u128) -> &mut Self {
self.end_price = Some(end_price);
self
}
#[inline(always)]
pub fn control_points(&mut self, control_points: [u16; 4]) -> &mut Self {
self.control_points = Some(control_points);
self
}
#[inline(always)]
pub fn creator(&mut self, creator: Pubkey) -> &mut Self {
self.creator = Some(creator);
self
}
#[inline(always)]
pub fn graduation_methods(&mut self, graduation_methods: [GraduationMethod; 8]) -> &mut Self {
self.graduation_methods = Some(graduation_methods);
self
}
#[inline(always)]
pub fn swap_fee_bps(&mut self, swap_fee_bps: u16) -> &mut Self {
self.swap_fee_bps = Some(swap_fee_bps);
self
}
#[inline(always)]
pub fn quote_fee_bps(&mut self, quote_fee_bps: u16) -> &mut Self {
self.quote_fee_bps = Some(quote_fee_bps);
self
}
#[inline(always)]
pub fn base_fee_bps(&mut self, base_fee_bps: u16) -> &mut Self {
self.base_fee_bps = Some(base_fee_bps);
self
}
#[inline(always)]
pub fn launch_time(&mut self, launch_time: i64) -> &mut Self {
self.launch_time = Some(launch_time);
self
}
#[inline(always)]
pub fn creator_reward(&mut self, creator_reward: u64) -> &mut Self {
self.creator_reward = Some(creator_reward);
self
}
#[inline(always)]
pub fn graduation_reward(&mut self, graduation_reward: u64) -> &mut Self {
self.graduation_reward = Some(graduation_reward);
self
}
#[inline(always)]
pub fn graduation_target(&mut self, graduation_target: u64) -> &mut Self {
self.graduation_target = Some(graduation_target);
self
}
#[inline(always)]
pub fn graduation_time(&mut self, graduation_time: i64) -> &mut Self {
self.graduation_time = Some(graduation_time);
self
}
#[inline(always)]
pub fn min_reserve_bps(&mut self, min_reserve_bps: u16) -> &mut Self {
self.min_reserve_bps = Some(min_reserve_bps);
self
}
#[inline(always)]
pub fn buy_requires_permission(&mut self, buy_requires_permission: bool) -> &mut Self {
self.buy_requires_permission = Some(buy_requires_permission);
self
}
#[inline(always)]
pub fn buy_permission_bitmap(&mut self, buy_permission_bitmap: [u8; 32]) -> &mut Self {
self.buy_permission_bitmap = Some(buy_permission_bitmap);
self
}
#[inline(always)]
pub fn sell_requires_permission(&mut self, sell_requires_permission: bool) -> &mut Self {
self.sell_requires_permission = Some(sell_requires_permission);
self
}
#[inline(always)]
pub fn sell_permission_bitmap(&mut self, sell_permission_bitmap: [u8; 32]) -> &mut Self {
self.sell_permission_bitmap = Some(sell_permission_bitmap);
self
}
#[inline(always)]
pub fn max_buy_amount(&mut self, max_buy_amount: u64) -> &mut Self {
self.max_buy_amount = Some(max_buy_amount);
self
}
#[inline(always)]
pub fn max_sell_amount(&mut self, max_sell_amount: u64) -> &mut Self {
self.max_sell_amount = Some(max_sell_amount);
self
}
#[inline(always)]
pub fn retain_mint_authority(&mut self, retain_mint_authority: bool) -> &mut Self {
self.retain_mint_authority = Some(retain_mint_authority);
self
}
#[inline(always)]
pub fn base_allocation_bps(&mut self, base_allocation_bps: u16) -> &mut Self {
self.base_allocation_bps = Some(base_allocation_bps);
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 = BondingCurveInitialize {
authority: self.authority.expect("authority is not set"),
bonding_curve: self.bonding_curve.expect("bonding_curve is not set"),
base_mint: self.base_mint.expect("base_mint is not set"),
quote_mint: self.quote_mint.expect("quote_mint is not set"),
quote_vault: self.quote_vault.expect("quote_vault is not set"),
authority_config: self.authority_config.expect("authority_config is not set"),
system_program: self
.system_program
.unwrap_or(solana_pubkey::pubkey!("11111111111111111111111111111111")),
base_token_program: self
.base_token_program
.expect("base_token_program is not set"),
quote_token_program: self
.quote_token_program
.expect("quote_token_program is not set"),
ata_program: self.ata_program.unwrap_or(solana_pubkey::pubkey!(
"ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL"
)),
};
let args = BondingCurveInitializeInstructionArgs {
start_price: self.start_price.clone().expect("start_price is not set"),
end_price: self.end_price.clone().expect("end_price is not set"),
control_points: self
.control_points
.clone()
.expect("control_points is not set"),
creator: self.creator.clone().expect("creator is not set"),
graduation_methods: self
.graduation_methods
.clone()
.expect("graduation_methods is not set"),
swap_fee_bps: self.swap_fee_bps.clone().expect("swap_fee_bps is not set"),
quote_fee_bps: self
.quote_fee_bps
.clone()
.expect("quote_fee_bps is not set"),
base_fee_bps: self.base_fee_bps.clone().expect("base_fee_bps is not set"),
launch_time: self.launch_time.clone().expect("launch_time is not set"),
creator_reward: self
.creator_reward
.clone()
.expect("creator_reward is not set"),
graduation_reward: self
.graduation_reward
.clone()
.expect("graduation_reward is not set"),
graduation_target: self
.graduation_target
.clone()
.expect("graduation_target is not set"),
graduation_time: self
.graduation_time
.clone()
.expect("graduation_time is not set"),
min_reserve_bps: self
.min_reserve_bps
.clone()
.expect("min_reserve_bps is not set"),
buy_requires_permission: self
.buy_requires_permission
.clone()
.expect("buy_requires_permission is not set"),
buy_permission_bitmap: self
.buy_permission_bitmap
.clone()
.expect("buy_permission_bitmap is not set"),
sell_requires_permission: self
.sell_requires_permission
.clone()
.expect("sell_requires_permission is not set"),
sell_permission_bitmap: self
.sell_permission_bitmap
.clone()
.expect("sell_permission_bitmap is not set"),
max_buy_amount: self
.max_buy_amount
.clone()
.expect("max_buy_amount is not set"),
max_sell_amount: self
.max_sell_amount
.clone()
.expect("max_sell_amount is not set"),
retain_mint_authority: self
.retain_mint_authority
.clone()
.expect("retain_mint_authority is not set"),
base_allocation_bps: self
.base_allocation_bps
.clone()
.expect("base_allocation_bps is not set"),
};
accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts)
}
}
pub struct BondingCurveInitializeCpiAccounts<'a, 'b> {
pub authority: &'b solana_account_info::AccountInfo<'a>,
pub bonding_curve: &'b solana_account_info::AccountInfo<'a>,
pub base_mint: &'b solana_account_info::AccountInfo<'a>,
pub quote_mint: &'b solana_account_info::AccountInfo<'a>,
pub quote_vault: &'b solana_account_info::AccountInfo<'a>,
pub authority_config: &'b solana_account_info::AccountInfo<'a>,
pub system_program: &'b solana_account_info::AccountInfo<'a>,
pub base_token_program: &'b solana_account_info::AccountInfo<'a>,
pub quote_token_program: &'b solana_account_info::AccountInfo<'a>,
pub ata_program: &'b solana_account_info::AccountInfo<'a>,
}
pub struct BondingCurveInitializeCpi<'a, 'b> {
pub __program: &'b solana_account_info::AccountInfo<'a>,
pub authority: &'b solana_account_info::AccountInfo<'a>,
pub bonding_curve: &'b solana_account_info::AccountInfo<'a>,
pub base_mint: &'b solana_account_info::AccountInfo<'a>,
pub quote_mint: &'b solana_account_info::AccountInfo<'a>,
pub quote_vault: &'b solana_account_info::AccountInfo<'a>,
pub authority_config: &'b solana_account_info::AccountInfo<'a>,
pub system_program: &'b solana_account_info::AccountInfo<'a>,
pub base_token_program: &'b solana_account_info::AccountInfo<'a>,
pub quote_token_program: &'b solana_account_info::AccountInfo<'a>,
pub ata_program: &'b solana_account_info::AccountInfo<'a>,
pub __args: BondingCurveInitializeInstructionArgs,
}
impl<'a, 'b> BondingCurveInitializeCpi<'a, 'b> {
pub fn new(
program: &'b solana_account_info::AccountInfo<'a>,
accounts: BondingCurveInitializeCpiAccounts<'a, 'b>,
args: BondingCurveInitializeInstructionArgs,
) -> Self {
Self {
__program: program,
authority: accounts.authority,
bonding_curve: accounts.bonding_curve,
base_mint: accounts.base_mint,
quote_mint: accounts.quote_mint,
quote_vault: accounts.quote_vault,
authority_config: accounts.authority_config,
system_program: accounts.system_program,
base_token_program: accounts.base_token_program,
quote_token_program: accounts.quote_token_program,
ata_program: accounts.ata_program,
__args: args,
}
}
#[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(10 + remaining_accounts.len());
accounts.push(solana_instruction::AccountMeta::new(
*self.authority.key,
true,
));
accounts.push(solana_instruction::AccountMeta::new(
*self.bonding_curve.key,
false,
));
accounts.push(solana_instruction::AccountMeta::new_readonly(
*self.base_mint.key,
false,
));
accounts.push(solana_instruction::AccountMeta::new_readonly(
*self.quote_mint.key,
false,
));
accounts.push(solana_instruction::AccountMeta::new(
*self.quote_vault.key,
false,
));
accounts.push(solana_instruction::AccountMeta::new_readonly(
*self.authority_config.key,
false,
));
accounts.push(solana_instruction::AccountMeta::new_readonly(
*self.system_program.key,
false,
));
accounts.push(solana_instruction::AccountMeta::new_readonly(
*self.base_token_program.key,
false,
));
accounts.push(solana_instruction::AccountMeta::new_readonly(
*self.quote_token_program.key,
false,
));
accounts.push(solana_instruction::AccountMeta::new_readonly(
*self.ata_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 mut data = borsh::to_vec(&BondingCurveInitializeInstructionData::new()).unwrap();
let mut args = borsh::to_vec(&self.__args).unwrap();
data.append(&mut args);
let instruction = solana_instruction::Instruction {
program_id: crate::WAVEBREAK_ID,
accounts,
data,
};
let mut account_infos = Vec::with_capacity(11 + remaining_accounts.len());
account_infos.push(self.__program.clone());
account_infos.push(self.authority.clone());
account_infos.push(self.bonding_curve.clone());
account_infos.push(self.base_mint.clone());
account_infos.push(self.quote_mint.clone());
account_infos.push(self.quote_vault.clone());
account_infos.push(self.authority_config.clone());
account_infos.push(self.system_program.clone());
account_infos.push(self.base_token_program.clone());
account_infos.push(self.quote_token_program.clone());
account_infos.push(self.ata_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 BondingCurveInitializeCpiBuilder<'a, 'b> {
instruction: Box<BondingCurveInitializeCpiBuilderInstruction<'a, 'b>>,
}
impl<'a, 'b> BondingCurveInitializeCpiBuilder<'a, 'b> {
pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self {
let instruction = Box::new(BondingCurveInitializeCpiBuilderInstruction {
__program: program,
authority: None,
bonding_curve: None,
base_mint: None,
quote_mint: None,
quote_vault: None,
authority_config: None,
system_program: None,
base_token_program: None,
quote_token_program: None,
ata_program: None,
start_price: None,
end_price: None,
control_points: None,
creator: None,
graduation_methods: None,
swap_fee_bps: None,
quote_fee_bps: None,
base_fee_bps: None,
launch_time: None,
creator_reward: None,
graduation_reward: None,
graduation_target: None,
graduation_time: None,
min_reserve_bps: None,
buy_requires_permission: None,
buy_permission_bitmap: None,
sell_requires_permission: None,
sell_permission_bitmap: None,
max_buy_amount: None,
max_sell_amount: None,
retain_mint_authority: None,
base_allocation_bps: None,
__remaining_accounts: Vec::new(),
});
Self { instruction }
}
#[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 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 base_mint(&mut self, base_mint: &'b solana_account_info::AccountInfo<'a>) -> &mut Self {
self.instruction.base_mint = Some(base_mint);
self
}
#[inline(always)]
pub fn quote_mint(
&mut self,
quote_mint: &'b solana_account_info::AccountInfo<'a>,
) -> &mut Self {
self.instruction.quote_mint = Some(quote_mint);
self
}
#[inline(always)]
pub fn quote_vault(
&mut self,
quote_vault: &'b solana_account_info::AccountInfo<'a>,
) -> &mut Self {
self.instruction.quote_vault = Some(quote_vault);
self
}
#[inline(always)]
pub fn authority_config(
&mut self,
authority_config: &'b solana_account_info::AccountInfo<'a>,
) -> &mut Self {
self.instruction.authority_config = Some(authority_config);
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 base_token_program(
&mut self,
base_token_program: &'b solana_account_info::AccountInfo<'a>,
) -> &mut Self {
self.instruction.base_token_program = Some(base_token_program);
self
}
#[inline(always)]
pub fn quote_token_program(
&mut self,
quote_token_program: &'b solana_account_info::AccountInfo<'a>,
) -> &mut Self {
self.instruction.quote_token_program = Some(quote_token_program);
self
}
#[inline(always)]
pub fn ata_program(
&mut self,
ata_program: &'b solana_account_info::AccountInfo<'a>,
) -> &mut Self {
self.instruction.ata_program = Some(ata_program);
self
}
#[inline(always)]
pub fn start_price(&mut self, start_price: u128) -> &mut Self {
self.instruction.start_price = Some(start_price);
self
}
#[inline(always)]
pub fn end_price(&mut self, end_price: u128) -> &mut Self {
self.instruction.end_price = Some(end_price);
self
}
#[inline(always)]
pub fn control_points(&mut self, control_points: [u16; 4]) -> &mut Self {
self.instruction.control_points = Some(control_points);
self
}
#[inline(always)]
pub fn creator(&mut self, creator: Pubkey) -> &mut Self {
self.instruction.creator = Some(creator);
self
}
#[inline(always)]
pub fn graduation_methods(&mut self, graduation_methods: [GraduationMethod; 8]) -> &mut Self {
self.instruction.graduation_methods = Some(graduation_methods);
self
}
#[inline(always)]
pub fn swap_fee_bps(&mut self, swap_fee_bps: u16) -> &mut Self {
self.instruction.swap_fee_bps = Some(swap_fee_bps);
self
}
#[inline(always)]
pub fn quote_fee_bps(&mut self, quote_fee_bps: u16) -> &mut Self {
self.instruction.quote_fee_bps = Some(quote_fee_bps);
self
}
#[inline(always)]
pub fn base_fee_bps(&mut self, base_fee_bps: u16) -> &mut Self {
self.instruction.base_fee_bps = Some(base_fee_bps);
self
}
#[inline(always)]
pub fn launch_time(&mut self, launch_time: i64) -> &mut Self {
self.instruction.launch_time = Some(launch_time);
self
}
#[inline(always)]
pub fn creator_reward(&mut self, creator_reward: u64) -> &mut Self {
self.instruction.creator_reward = Some(creator_reward);
self
}
#[inline(always)]
pub fn graduation_reward(&mut self, graduation_reward: u64) -> &mut Self {
self.instruction.graduation_reward = Some(graduation_reward);
self
}
#[inline(always)]
pub fn graduation_target(&mut self, graduation_target: u64) -> &mut Self {
self.instruction.graduation_target = Some(graduation_target);
self
}
#[inline(always)]
pub fn graduation_time(&mut self, graduation_time: i64) -> &mut Self {
self.instruction.graduation_time = Some(graduation_time);
self
}
#[inline(always)]
pub fn min_reserve_bps(&mut self, min_reserve_bps: u16) -> &mut Self {
self.instruction.min_reserve_bps = Some(min_reserve_bps);
self
}
#[inline(always)]
pub fn buy_requires_permission(&mut self, buy_requires_permission: bool) -> &mut Self {
self.instruction.buy_requires_permission = Some(buy_requires_permission);
self
}
#[inline(always)]
pub fn buy_permission_bitmap(&mut self, buy_permission_bitmap: [u8; 32]) -> &mut Self {
self.instruction.buy_permission_bitmap = Some(buy_permission_bitmap);
self
}
#[inline(always)]
pub fn sell_requires_permission(&mut self, sell_requires_permission: bool) -> &mut Self {
self.instruction.sell_requires_permission = Some(sell_requires_permission);
self
}
#[inline(always)]
pub fn sell_permission_bitmap(&mut self, sell_permission_bitmap: [u8; 32]) -> &mut Self {
self.instruction.sell_permission_bitmap = Some(sell_permission_bitmap);
self
}
#[inline(always)]
pub fn max_buy_amount(&mut self, max_buy_amount: u64) -> &mut Self {
self.instruction.max_buy_amount = Some(max_buy_amount);
self
}
#[inline(always)]
pub fn max_sell_amount(&mut self, max_sell_amount: u64) -> &mut Self {
self.instruction.max_sell_amount = Some(max_sell_amount);
self
}
#[inline(always)]
pub fn retain_mint_authority(&mut self, retain_mint_authority: bool) -> &mut Self {
self.instruction.retain_mint_authority = Some(retain_mint_authority);
self
}
#[inline(always)]
pub fn base_allocation_bps(&mut self, base_allocation_bps: u16) -> &mut Self {
self.instruction.base_allocation_bps = Some(base_allocation_bps);
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 args = BondingCurveInitializeInstructionArgs {
start_price: self
.instruction
.start_price
.clone()
.expect("start_price is not set"),
end_price: self
.instruction
.end_price
.clone()
.expect("end_price is not set"),
control_points: self
.instruction
.control_points
.clone()
.expect("control_points is not set"),
creator: self
.instruction
.creator
.clone()
.expect("creator is not set"),
graduation_methods: self
.instruction
.graduation_methods
.clone()
.expect("graduation_methods is not set"),
swap_fee_bps: self
.instruction
.swap_fee_bps
.clone()
.expect("swap_fee_bps is not set"),
quote_fee_bps: self
.instruction
.quote_fee_bps
.clone()
.expect("quote_fee_bps is not set"),
base_fee_bps: self
.instruction
.base_fee_bps
.clone()
.expect("base_fee_bps is not set"),
launch_time: self
.instruction
.launch_time
.clone()
.expect("launch_time is not set"),
creator_reward: self
.instruction
.creator_reward
.clone()
.expect("creator_reward is not set"),
graduation_reward: self
.instruction
.graduation_reward
.clone()
.expect("graduation_reward is not set"),
graduation_target: self
.instruction
.graduation_target
.clone()
.expect("graduation_target is not set"),
graduation_time: self
.instruction
.graduation_time
.clone()
.expect("graduation_time is not set"),
min_reserve_bps: self
.instruction
.min_reserve_bps
.clone()
.expect("min_reserve_bps is not set"),
buy_requires_permission: self
.instruction
.buy_requires_permission
.clone()
.expect("buy_requires_permission is not set"),
buy_permission_bitmap: self
.instruction
.buy_permission_bitmap
.clone()
.expect("buy_permission_bitmap is not set"),
sell_requires_permission: self
.instruction
.sell_requires_permission
.clone()
.expect("sell_requires_permission is not set"),
sell_permission_bitmap: self
.instruction
.sell_permission_bitmap
.clone()
.expect("sell_permission_bitmap is not set"),
max_buy_amount: self
.instruction
.max_buy_amount
.clone()
.expect("max_buy_amount is not set"),
max_sell_amount: self
.instruction
.max_sell_amount
.clone()
.expect("max_sell_amount is not set"),
retain_mint_authority: self
.instruction
.retain_mint_authority
.clone()
.expect("retain_mint_authority is not set"),
base_allocation_bps: self
.instruction
.base_allocation_bps
.clone()
.expect("base_allocation_bps is not set"),
};
let instruction = BondingCurveInitializeCpi {
__program: self.instruction.__program,
authority: self.instruction.authority.expect("authority is not set"),
bonding_curve: self
.instruction
.bonding_curve
.expect("bonding_curve is not set"),
base_mint: self.instruction.base_mint.expect("base_mint is not set"),
quote_mint: self.instruction.quote_mint.expect("quote_mint is not set"),
quote_vault: self
.instruction
.quote_vault
.expect("quote_vault is not set"),
authority_config: self
.instruction
.authority_config
.expect("authority_config is not set"),
system_program: self
.instruction
.system_program
.expect("system_program is not set"),
base_token_program: self
.instruction
.base_token_program
.expect("base_token_program is not set"),
quote_token_program: self
.instruction
.quote_token_program
.expect("quote_token_program is not set"),
ata_program: self
.instruction
.ata_program
.expect("ata_program is not set"),
__args: args,
};
instruction.invoke_signed_with_remaining_accounts(
signers_seeds,
&self.instruction.__remaining_accounts,
)
}
}
#[derive(Clone, Debug)]
struct BondingCurveInitializeCpiBuilderInstruction<'a, 'b> {
__program: &'b solana_account_info::AccountInfo<'a>,
authority: Option<&'b solana_account_info::AccountInfo<'a>>,
bonding_curve: Option<&'b solana_account_info::AccountInfo<'a>>,
base_mint: Option<&'b solana_account_info::AccountInfo<'a>>,
quote_mint: Option<&'b solana_account_info::AccountInfo<'a>>,
quote_vault: Option<&'b solana_account_info::AccountInfo<'a>>,
authority_config: Option<&'b solana_account_info::AccountInfo<'a>>,
system_program: Option<&'b solana_account_info::AccountInfo<'a>>,
base_token_program: Option<&'b solana_account_info::AccountInfo<'a>>,
quote_token_program: Option<&'b solana_account_info::AccountInfo<'a>>,
ata_program: Option<&'b solana_account_info::AccountInfo<'a>>,
start_price: Option<u128>,
end_price: Option<u128>,
control_points: Option<[u16; 4]>,
creator: Option<Pubkey>,
graduation_methods: Option<[GraduationMethod; 8]>,
swap_fee_bps: Option<u16>,
quote_fee_bps: Option<u16>,
base_fee_bps: Option<u16>,
launch_time: Option<i64>,
creator_reward: Option<u64>,
graduation_reward: Option<u64>,
graduation_target: Option<u64>,
graduation_time: Option<i64>,
min_reserve_bps: Option<u16>,
buy_requires_permission: Option<bool>,
buy_permission_bitmap: Option<[u8; 32]>,
sell_requires_permission: Option<bool>,
sell_permission_bitmap: Option<[u8; 32]>,
max_buy_amount: Option<u64>,
max_sell_amount: Option<u64>,
retain_mint_authority: Option<bool>,
base_allocation_bps: Option<u16>,
__remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>,
}