use borsh::BorshDeserialize;
use borsh::BorshSerialize;
pub const BONDING_CURVE_COLLECT_FEES_DISCRIMINATOR: u8 = 49;
#[derive(Debug)]
pub struct BondingCurveCollectFees {
pub signer: solana_pubkey::Pubkey,
pub fee_authority: solana_pubkey::Pubkey,
pub fee_authority_ata: 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 ata_program: solana_pubkey::Pubkey,
pub quote_token_program: solana_pubkey::Pubkey,
}
impl BondingCurveCollectFees {
pub fn instruction(&self) -> solana_instruction::Instruction {
self.instruction_with_remaining_accounts(&[])
}
#[allow(clippy::arithmetic_side_effects)]
#[allow(clippy::vec_init_then_push)]
pub fn instruction_with_remaining_accounts(
&self,
remaining_accounts: &[solana_instruction::AccountMeta],
) -> solana_instruction::Instruction {
let mut accounts = Vec::with_capacity(11 + remaining_accounts.len());
accounts.push(solana_instruction::AccountMeta::new(self.signer, true));
accounts.push(solana_instruction::AccountMeta::new_readonly(
self.fee_authority,
false,
));
accounts.push(solana_instruction::AccountMeta::new(
self.fee_authority_ata,
false,
));
accounts.push(solana_instruction::AccountMeta::new_readonly(
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.ata_program,
false,
));
accounts.push(solana_instruction::AccountMeta::new_readonly(
self.quote_token_program,
false,
));
accounts.extend_from_slice(remaining_accounts);
let data = borsh::to_vec(&BondingCurveCollectFeesInstructionData::new()).unwrap();
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 BondingCurveCollectFeesInstructionData {
discriminator: u8,
}
impl BondingCurveCollectFeesInstructionData {
pub fn new() -> Self {
Self { discriminator: 49 }
}
}
impl Default for BondingCurveCollectFeesInstructionData {
fn default() -> Self {
Self::new()
}
}
#[derive(Clone, Debug, Default)]
pub struct BondingCurveCollectFeesBuilder {
signer: Option<solana_pubkey::Pubkey>,
fee_authority: Option<solana_pubkey::Pubkey>,
fee_authority_ata: 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>,
ata_program: Option<solana_pubkey::Pubkey>,
quote_token_program: Option<solana_pubkey::Pubkey>,
__remaining_accounts: Vec<solana_instruction::AccountMeta>,
}
impl BondingCurveCollectFeesBuilder {
pub fn new() -> Self {
Self::default()
}
#[inline(always)]
pub fn signer(&mut self, signer: solana_pubkey::Pubkey) -> &mut Self {
self.signer = Some(signer);
self
}
#[inline(always)]
pub fn fee_authority(&mut self, fee_authority: solana_pubkey::Pubkey) -> &mut Self {
self.fee_authority = Some(fee_authority);
self
}
#[inline(always)]
pub fn fee_authority_ata(&mut self, fee_authority_ata: solana_pubkey::Pubkey) -> &mut Self {
self.fee_authority_ata = Some(fee_authority_ata);
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 ata_program(&mut self, ata_program: solana_pubkey::Pubkey) -> &mut Self {
self.ata_program = Some(ata_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 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 = BondingCurveCollectFees {
signer: self.signer.expect("signer is not set"),
fee_authority: self.fee_authority.expect("fee_authority is not set"),
fee_authority_ata: self
.fee_authority_ata
.expect("fee_authority_ata 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")),
ata_program: self.ata_program.unwrap_or(solana_pubkey::pubkey!(
"ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL"
)),
quote_token_program: self
.quote_token_program
.expect("quote_token_program is not set"),
};
accounts.instruction_with_remaining_accounts(&self.__remaining_accounts)
}
}
pub struct BondingCurveCollectFeesCpiAccounts<'a, 'b> {
pub signer: &'b solana_account_info::AccountInfo<'a>,
pub fee_authority: &'b solana_account_info::AccountInfo<'a>,
pub fee_authority_ata: &'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 ata_program: &'b solana_account_info::AccountInfo<'a>,
pub quote_token_program: &'b solana_account_info::AccountInfo<'a>,
}
pub struct BondingCurveCollectFeesCpi<'a, 'b> {
pub __program: &'b solana_account_info::AccountInfo<'a>,
pub signer: &'b solana_account_info::AccountInfo<'a>,
pub fee_authority: &'b solana_account_info::AccountInfo<'a>,
pub fee_authority_ata: &'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 ata_program: &'b solana_account_info::AccountInfo<'a>,
pub quote_token_program: &'b solana_account_info::AccountInfo<'a>,
}
impl<'a, 'b> BondingCurveCollectFeesCpi<'a, 'b> {
pub fn new(
program: &'b solana_account_info::AccountInfo<'a>,
accounts: BondingCurveCollectFeesCpiAccounts<'a, 'b>,
) -> Self {
Self {
__program: program,
signer: accounts.signer,
fee_authority: accounts.fee_authority,
fee_authority_ata: accounts.fee_authority_ata,
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,
ata_program: accounts.ata_program,
quote_token_program: accounts.quote_token_program,
}
}
#[inline(always)]
pub fn invoke(&self) -> solana_program_error::ProgramResult {
self.invoke_signed_with_remaining_accounts(&[], &[])
}
#[inline(always)]
pub fn invoke_with_remaining_accounts(
&self,
remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)],
) -> solana_program_error::ProgramResult {
self.invoke_signed_with_remaining_accounts(&[], remaining_accounts)
}
#[inline(always)]
pub fn invoke_signed(&self, signers_seeds: &[&[&[u8]]]) -> solana_program_error::ProgramResult {
self.invoke_signed_with_remaining_accounts(signers_seeds, &[])
}
#[allow(clippy::arithmetic_side_effects)]
#[allow(clippy::clone_on_copy)]
#[allow(clippy::vec_init_then_push)]
pub fn invoke_signed_with_remaining_accounts(
&self,
signers_seeds: &[&[&[u8]]],
remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)],
) -> solana_program_error::ProgramResult {
let mut accounts = Vec::with_capacity(11 + remaining_accounts.len());
accounts.push(solana_instruction::AccountMeta::new(*self.signer.key, true));
accounts.push(solana_instruction::AccountMeta::new_readonly(
*self.fee_authority.key,
false,
));
accounts.push(solana_instruction::AccountMeta::new(
*self.fee_authority_ata.key,
false,
));
accounts.push(solana_instruction::AccountMeta::new_readonly(
*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.ata_program.key,
false,
));
accounts.push(solana_instruction::AccountMeta::new_readonly(
*self.quote_token_program.key,
false,
));
remaining_accounts.iter().for_each(|remaining_account| {
accounts.push(solana_instruction::AccountMeta {
pubkey: *remaining_account.0.key,
is_signer: remaining_account.1,
is_writable: remaining_account.2,
})
});
let data = borsh::to_vec(&BondingCurveCollectFeesInstructionData::new()).unwrap();
let instruction = solana_instruction::Instruction {
program_id: crate::WAVEBREAK_ID,
accounts,
data,
};
let mut account_infos = Vec::with_capacity(12 + remaining_accounts.len());
account_infos.push(self.__program.clone());
account_infos.push(self.signer.clone());
account_infos.push(self.fee_authority.clone());
account_infos.push(self.fee_authority_ata.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.ata_program.clone());
account_infos.push(self.quote_token_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 BondingCurveCollectFeesCpiBuilder<'a, 'b> {
instruction: Box<BondingCurveCollectFeesCpiBuilderInstruction<'a, 'b>>,
}
impl<'a, 'b> BondingCurveCollectFeesCpiBuilder<'a, 'b> {
pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self {
let instruction = Box::new(BondingCurveCollectFeesCpiBuilderInstruction {
__program: program,
signer: None,
fee_authority: None,
fee_authority_ata: None,
bonding_curve: None,
base_mint: None,
quote_mint: None,
quote_vault: None,
authority_config: None,
system_program: None,
ata_program: None,
quote_token_program: None,
__remaining_accounts: Vec::new(),
});
Self { instruction }
}
#[inline(always)]
pub fn signer(&mut self, signer: &'b solana_account_info::AccountInfo<'a>) -> &mut Self {
self.instruction.signer = Some(signer);
self
}
#[inline(always)]
pub fn fee_authority(
&mut self,
fee_authority: &'b solana_account_info::AccountInfo<'a>,
) -> &mut Self {
self.instruction.fee_authority = Some(fee_authority);
self
}
#[inline(always)]
pub fn fee_authority_ata(
&mut self,
fee_authority_ata: &'b solana_account_info::AccountInfo<'a>,
) -> &mut Self {
self.instruction.fee_authority_ata = Some(fee_authority_ata);
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 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 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 add_remaining_account(
&mut self,
account: &'b solana_account_info::AccountInfo<'a>,
is_writable: bool,
is_signer: bool,
) -> &mut Self {
self.instruction
.__remaining_accounts
.push((account, is_writable, is_signer));
self
}
#[inline(always)]
pub fn add_remaining_accounts(
&mut self,
accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)],
) -> &mut Self {
self.instruction
.__remaining_accounts
.extend_from_slice(accounts);
self
}
#[inline(always)]
pub fn invoke(&self) -> solana_program_error::ProgramResult {
self.invoke_signed(&[])
}
#[allow(clippy::clone_on_copy)]
#[allow(clippy::vec_init_then_push)]
pub fn invoke_signed(&self, signers_seeds: &[&[&[u8]]]) -> solana_program_error::ProgramResult {
let instruction = BondingCurveCollectFeesCpi {
__program: self.instruction.__program,
signer: self.instruction.signer.expect("signer is not set"),
fee_authority: self
.instruction
.fee_authority
.expect("fee_authority is not set"),
fee_authority_ata: self
.instruction
.fee_authority_ata
.expect("fee_authority_ata 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"),
ata_program: self
.instruction
.ata_program
.expect("ata_program is not set"),
quote_token_program: self
.instruction
.quote_token_program
.expect("quote_token_program is not set"),
};
instruction.invoke_signed_with_remaining_accounts(
signers_seeds,
&self.instruction.__remaining_accounts,
)
}
}
#[derive(Clone, Debug)]
struct BondingCurveCollectFeesCpiBuilderInstruction<'a, 'b> {
__program: &'b solana_account_info::AccountInfo<'a>,
signer: Option<&'b solana_account_info::AccountInfo<'a>>,
fee_authority: Option<&'b solana_account_info::AccountInfo<'a>>,
fee_authority_ata: 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>>,
ata_program: Option<&'b solana_account_info::AccountInfo<'a>>,
quote_token_program: Option<&'b solana_account_info::AccountInfo<'a>>,
__remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>,
}