use borsh::BorshSerialize;
use borsh::BorshDeserialize;
#[derive(Debug)]
pub struct CollectCycloneProtocolFees {
pub vortex_config: solana_program::pubkey::Pubkey,
pub cyclone: solana_program::pubkey::Pubkey,
pub collect_protocol_fees_authority: solana_program::pubkey::Pubkey,
pub token_vault_b: solana_program::pubkey::Pubkey,
pub token_destination_b: solana_program::pubkey::Pubkey,
pub token_program: solana_program::pubkey::Pubkey,
}
impl CollectCycloneProtocolFees {
pub fn instruction(&self) -> solana_program::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_program::instruction::AccountMeta]) -> solana_program::instruction::Instruction {
let mut accounts = Vec::with_capacity(6+ remaining_accounts.len());
accounts.push(solana_program::instruction::AccountMeta::new_readonly(
self.vortex_config,
false
));
accounts.push(solana_program::instruction::AccountMeta::new(
self.cyclone,
false
));
accounts.push(solana_program::instruction::AccountMeta::new_readonly(
self.collect_protocol_fees_authority,
true
));
accounts.push(solana_program::instruction::AccountMeta::new(
self.token_vault_b,
false
));
accounts.push(solana_program::instruction::AccountMeta::new(
self.token_destination_b,
false
));
accounts.push(solana_program::instruction::AccountMeta::new_readonly(
self.token_program,
false
));
accounts.extend_from_slice(remaining_accounts);
let data = borsh::to_vec(&CollectCycloneProtocolFeesInstructionData::new()).unwrap();
solana_program::instruction::Instruction {
program_id: crate::VORTEX_ID,
accounts,
data,
}
}
}
#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct CollectCycloneProtocolFeesInstructionData {
discriminator: [u8; 8],
}
impl CollectCycloneProtocolFeesInstructionData {
pub fn new() -> Self {
Self {
discriminator: [11, 203, 25, 187, 179, 81, 17, 122],
}
}
}
impl Default for CollectCycloneProtocolFeesInstructionData {
fn default() -> Self {
Self::new()
}
}
#[derive(Clone, Debug, Default)]
pub struct CollectCycloneProtocolFeesBuilder {
vortex_config: Option<solana_program::pubkey::Pubkey>,
cyclone: Option<solana_program::pubkey::Pubkey>,
collect_protocol_fees_authority: Option<solana_program::pubkey::Pubkey>,
token_vault_b: Option<solana_program::pubkey::Pubkey>,
token_destination_b: Option<solana_program::pubkey::Pubkey>,
token_program: Option<solana_program::pubkey::Pubkey>,
__remaining_accounts: Vec<solana_program::instruction::AccountMeta>,
}
impl CollectCycloneProtocolFeesBuilder {
pub fn new() -> Self {
Self::default()
}
#[inline(always)]
pub fn vortex_config(&mut self, vortex_config: solana_program::pubkey::Pubkey) -> &mut Self {
self.vortex_config = Some(vortex_config);
self
}
#[inline(always)]
pub fn cyclone(&mut self, cyclone: solana_program::pubkey::Pubkey) -> &mut Self {
self.cyclone = Some(cyclone);
self
}
#[inline(always)]
pub fn collect_protocol_fees_authority(&mut self, collect_protocol_fees_authority: solana_program::pubkey::Pubkey) -> &mut Self {
self.collect_protocol_fees_authority = Some(collect_protocol_fees_authority);
self
}
#[inline(always)]
pub fn token_vault_b(&mut self, token_vault_b: solana_program::pubkey::Pubkey) -> &mut Self {
self.token_vault_b = Some(token_vault_b);
self
}
#[inline(always)]
pub fn token_destination_b(&mut self, token_destination_b: solana_program::pubkey::Pubkey) -> &mut Self {
self.token_destination_b = Some(token_destination_b);
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 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 = CollectCycloneProtocolFees {
vortex_config: self.vortex_config.expect("vortex_config is not set"),
cyclone: self.cyclone.expect("cyclone is not set"),
collect_protocol_fees_authority: self.collect_protocol_fees_authority.expect("collect_protocol_fees_authority is not set"),
token_vault_b: self.token_vault_b.expect("token_vault_b is not set"),
token_destination_b: self.token_destination_b.expect("token_destination_b is not set"),
token_program: self.token_program.unwrap_or(solana_program::pubkey!("TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA")),
};
accounts.instruction_with_remaining_accounts(&self.__remaining_accounts)
}
}
pub struct CollectCycloneProtocolFeesCpiAccounts<'a, 'b> {
pub vortex_config: &'b solana_program::account_info::AccountInfo<'a>,
pub cyclone: &'b solana_program::account_info::AccountInfo<'a>,
pub collect_protocol_fees_authority: &'b solana_program::account_info::AccountInfo<'a>,
pub token_vault_b: &'b solana_program::account_info::AccountInfo<'a>,
pub token_destination_b: &'b solana_program::account_info::AccountInfo<'a>,
pub token_program: &'b solana_program::account_info::AccountInfo<'a>,
}
pub struct CollectCycloneProtocolFeesCpi<'a, 'b> {
pub __program: &'b solana_program::account_info::AccountInfo<'a>,
pub vortex_config: &'b solana_program::account_info::AccountInfo<'a>,
pub cyclone: &'b solana_program::account_info::AccountInfo<'a>,
pub collect_protocol_fees_authority: &'b solana_program::account_info::AccountInfo<'a>,
pub token_vault_b: &'b solana_program::account_info::AccountInfo<'a>,
pub token_destination_b: &'b solana_program::account_info::AccountInfo<'a>,
pub token_program: &'b solana_program::account_info::AccountInfo<'a>,
}
impl<'a, 'b> CollectCycloneProtocolFeesCpi<'a, 'b> {
pub fn new(
program: &'b solana_program::account_info::AccountInfo<'a>,
accounts: CollectCycloneProtocolFeesCpiAccounts<'a, 'b>,
) -> Self {
Self {
__program: program,
vortex_config: accounts.vortex_config,
cyclone: accounts.cyclone,
collect_protocol_fees_authority: accounts.collect_protocol_fees_authority,
token_vault_b: accounts.token_vault_b,
token_destination_b: accounts.token_destination_b,
token_program: accounts.token_program,
}
}
#[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::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_program::account_info::AccountInfo<'a>, bool, bool)]
) -> solana_program::entrypoint::ProgramResult {
let mut accounts = Vec::with_capacity(6+ remaining_accounts.len());
accounts.push(solana_program::instruction::AccountMeta::new_readonly(
*self.vortex_config.key,
false
));
accounts.push(solana_program::instruction::AccountMeta::new(
*self.cyclone.key,
false
));
accounts.push(solana_program::instruction::AccountMeta::new_readonly(
*self.collect_protocol_fees_authority.key,
true
));
accounts.push(solana_program::instruction::AccountMeta::new(
*self.token_vault_b.key,
false
));
accounts.push(solana_program::instruction::AccountMeta::new(
*self.token_destination_b.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 data = borsh::to_vec(&CollectCycloneProtocolFeesInstructionData::new()).unwrap();
let instruction = solana_program::instruction::Instruction {
program_id: crate::VORTEX_ID,
accounts,
data,
};
let mut account_infos = Vec::with_capacity(7 + remaining_accounts.len());
account_infos.push(self.__program.clone());
account_infos.push(self.vortex_config.clone());
account_infos.push(self.cyclone.clone());
account_infos.push(self.collect_protocol_fees_authority.clone());
account_infos.push(self.token_vault_b.clone());
account_infos.push(self.token_destination_b.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 CollectCycloneProtocolFeesCpiBuilder<'a, 'b> {
instruction: Box<CollectCycloneProtocolFeesCpiBuilderInstruction<'a, 'b>>,
}
impl<'a, 'b> CollectCycloneProtocolFeesCpiBuilder<'a, 'b> {
pub fn new(program: &'b solana_program::account_info::AccountInfo<'a>) -> Self {
let instruction = Box::new(CollectCycloneProtocolFeesCpiBuilderInstruction {
__program: program,
vortex_config: None,
cyclone: None,
collect_protocol_fees_authority: None,
token_vault_b: None,
token_destination_b: None,
token_program: None,
__remaining_accounts: Vec::new(),
});
Self { instruction }
}
#[inline(always)]
pub fn vortex_config(&mut self, vortex_config: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self {
self.instruction.vortex_config = Some(vortex_config);
self
}
#[inline(always)]
pub fn cyclone(&mut self, cyclone: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self {
self.instruction.cyclone = Some(cyclone);
self
}
#[inline(always)]
pub fn collect_protocol_fees_authority(&mut self, collect_protocol_fees_authority: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self {
self.instruction.collect_protocol_fees_authority = Some(collect_protocol_fees_authority);
self
}
#[inline(always)]
pub fn token_vault_b(&mut self, token_vault_b: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self {
self.instruction.token_vault_b = Some(token_vault_b);
self
}
#[inline(always)]
pub fn token_destination_b(&mut self, token_destination_b: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self {
self.instruction.token_destination_b = Some(token_destination_b);
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 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 instruction = CollectCycloneProtocolFeesCpi {
__program: self.instruction.__program,
vortex_config: self.instruction.vortex_config.expect("vortex_config is not set"),
cyclone: self.instruction.cyclone.expect("cyclone is not set"),
collect_protocol_fees_authority: self.instruction.collect_protocol_fees_authority.expect("collect_protocol_fees_authority is not set"),
token_vault_b: self.instruction.token_vault_b.expect("token_vault_b is not set"),
token_destination_b: self.instruction.token_destination_b.expect("token_destination_b is not set"),
token_program: self.instruction.token_program.expect("token_program is not set"),
};
instruction.invoke_signed_with_remaining_accounts(signers_seeds, &self.instruction.__remaining_accounts)
}
}
#[derive(Clone, Debug)]
struct CollectCycloneProtocolFeesCpiBuilderInstruction<'a, 'b> {
__program: &'b solana_program::account_info::AccountInfo<'a>,
vortex_config: Option<&'b solana_program::account_info::AccountInfo<'a>>,
cyclone: Option<&'b solana_program::account_info::AccountInfo<'a>>,
collect_protocol_fees_authority: Option<&'b solana_program::account_info::AccountInfo<'a>>,
token_vault_b: Option<&'b solana_program::account_info::AccountInfo<'a>>,
token_destination_b: Option<&'b solana_program::account_info::AccountInfo<'a>>,
token_program: Option<&'b solana_program::account_info::AccountInfo<'a>>,
__remaining_accounts: Vec<(&'b solana_program::account_info::AccountInfo<'a>, bool, bool)>,
}