#![allow(
clippy::all,
clippy::pedantic,
clippy::nursery,
clippy::expect_used,
clippy::unwrap_used,
clippy::indexing_slicing,
clippy::allow_attributes,
clippy::allow_attributes_without_reason,
clippy::mem_forget,
unfulfilled_lint_expectations,
unexpected_cfgs,
unused_imports
)]
use borsh::BorshDeserialize;
use borsh::BorshSerialize;
pub const CLAIM_CREATOR_FEES_DISCRIMINATOR: [u8; 8] =
[0, 23, 125, 234, 156, 118, 134, 89];
#[derive(Debug)]
pub struct ClaimCreatorFees {
pub claimer: solana_address::Address,
pub payer: solana_address::Address,
pub pool: solana_address::Address,
pub creator_fee_config: solana_address::Address,
pub nexus_global_config: solana_address::Address,
pub base_mint: solana_address::Address,
pub quote_mint: solana_address::Address,
pub quote_vault: solana_address::Address,
pub destination_owner: solana_address::Address,
pub destination: solana_address::Address,
pub quote_token_program: solana_address::Address,
pub associated_token_program: solana_address::Address,
pub system_program: solana_address::Address,
pub event_authority: solana_address::Address,
pub program: solana_address::Address,
}
impl ClaimCreatorFees {
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(15 + remaining_accounts.len());
accounts.push(solana_instruction::AccountMeta::new_readonly(
self.claimer,
true,
));
accounts.push(solana_instruction::AccountMeta::new(self.payer, true));
accounts.push(solana_instruction::AccountMeta::new(self.pool, false));
accounts.push(solana_instruction::AccountMeta::new(
self.creator_fee_config,
false,
));
accounts.push(solana_instruction::AccountMeta::new_readonly(
self.nexus_global_config,
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.destination_owner,
false,
));
accounts.push(solana_instruction::AccountMeta::new(
self.destination,
false,
));
accounts.push(solana_instruction::AccountMeta::new_readonly(
self.quote_token_program,
false,
));
accounts.push(solana_instruction::AccountMeta::new_readonly(
self.associated_token_program,
false,
));
accounts.push(solana_instruction::AccountMeta::new_readonly(
self.system_program,
false,
));
accounts.push(solana_instruction::AccountMeta::new_readonly(
self.event_authority,
false,
));
accounts.push(solana_instruction::AccountMeta::new_readonly(
self.program,
false,
));
accounts.extend_from_slice(remaining_accounts);
let data = ClaimCreatorFeesInstructionData::new().try_to_vec().unwrap();
solana_instruction::Instruction {
program_id: crate::dex::generated::SEND_DEX_ID,
accounts,
data,
}
}
}
#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(feature = "serde", serde(rename_all = "camelCase"))]
pub struct ClaimCreatorFeesInstructionData {
discriminator: [u8; 8],
}
impl ClaimCreatorFeesInstructionData {
pub fn new() -> Self {
Self {
discriminator: [0, 23, 125, 234, 156, 118, 134, 89],
}
}
pub(crate) fn try_to_vec(&self) -> Result<Vec<u8>, std::io::Error> {
borsh::to_vec(self)
}
}
impl Default for ClaimCreatorFeesInstructionData {
fn default() -> Self {
Self::new()
}
}
#[derive(Clone, Debug)]
pub struct ClaimCreatorFeesBuilder {
claimer: solana_address::Address,
payer: solana_address::Address,
pool: Option<solana_address::Address>,
creator_fee_config: Option<solana_address::Address>,
base_mint: solana_address::Address,
quote_mint: solana_address::Address,
quote_vault: Option<solana_address::Address>,
destination_owner: solana_address::Address,
destination: Option<solana_address::Address>,
quote_token_program: solana_address::Address,
__remaining_accounts: Vec<solana_instruction::AccountMeta>,
}
impl ClaimCreatorFeesBuilder {
pub fn new(
claimer: solana_address::Address,
payer: solana_address::Address,
base_mint: solana_address::Address,
quote_mint: solana_address::Address,
destination_owner: solana_address::Address,
quote_token_program: solana_address::Address,
) -> Self {
Self {
claimer,
payer,
pool: None,
creator_fee_config: None,
base_mint,
quote_mint,
quote_vault: None,
destination_owner,
destination: None,
quote_token_program,
__remaining_accounts: Vec::new(),
}
}
#[inline(always)]
pub fn pool(&mut self, pool: solana_address::Address) -> &mut Self {
self.pool = Some(pool);
self
}
#[inline(always)]
pub fn creator_fee_config(
&mut self,
creator_fee_config: solana_address::Address,
) -> &mut Self {
self.creator_fee_config = Some(creator_fee_config);
self
}
#[inline(always)]
pub fn quote_vault(
&mut self,
quote_vault: solana_address::Address,
) -> &mut Self {
self.quote_vault = Some(quote_vault);
self
}
#[inline(always)]
pub fn destination(
&mut self,
destination: solana_address::Address,
) -> &mut Self {
self.destination = Some(destination);
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 claimer = self.claimer;
let payer = self.payer;
let base_mint = self.base_mint;
let quote_mint = self.quote_mint;
let pool = self.pool.unwrap_or_else(|| {
crate::dex::generated::pdas::find_pool_pda(
&self.base_mint,
&self.quote_mint,
)
.0
});
let creator_fee_config = self.creator_fee_config.unwrap_or_else(|| {
crate::dex::generated::pdas::find_creator_fee_config_pda(
&self.base_mint,
&self.quote_mint,
)
.0
});
let nexus_global_config = solana_address::address!(
"3bycfBeRULfXYqcg3DmiYFBjv6mMVidMuqKdFZJTGdNr"
);
let quote_token_program = self.quote_token_program;
let quote_vault = self.quote_vault.unwrap_or_else(|| {
solana_address::Address::find_program_address(
&[
pool.as_ref(),
self.quote_token_program.as_ref(),
self.quote_mint.as_ref(),
],
&solana_address::address!(
"ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL"
),
)
.0
});
let destination_owner = self.destination_owner;
let destination = self.destination.unwrap_or_else(|| {
solana_address::Address::find_program_address(
&[
self.destination_owner.as_ref(),
self.quote_token_program.as_ref(),
self.quote_mint.as_ref(),
],
&solana_address::address!(
"ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL"
),
)
.0
});
let associated_token_program = solana_address::address!(
"ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL"
);
let system_program =
solana_address::address!("11111111111111111111111111111111");
let event_authority =
crate::dex::generated::pdas::EVENT_AUTHORITY_ADDRESS;
let program = solana_address::address!(
"84qj5FPZZdXkQy8mfowyg6RBZ3XKuTds6XS4ZYT1sfDX"
);
let accounts = ClaimCreatorFees {
claimer,
payer,
pool,
creator_fee_config,
nexus_global_config,
base_mint,
quote_mint,
quote_vault,
destination_owner,
destination,
quote_token_program,
associated_token_program,
system_program,
event_authority,
program,
};
accounts.instruction_with_remaining_accounts(&self.__remaining_accounts)
}
}
pub struct ClaimCreatorFeesCpiAccounts<'a, 'b> {
pub claimer: &'b solana_program::account_info::AccountInfo<'a>,
pub payer: &'b solana_program::account_info::AccountInfo<'a>,
pub pool: &'b solana_program::account_info::AccountInfo<'a>,
pub creator_fee_config: &'b solana_program::account_info::AccountInfo<'a>,
pub nexus_global_config: &'b solana_program::account_info::AccountInfo<'a>,
pub base_mint: &'b solana_program::account_info::AccountInfo<'a>,
pub quote_mint: &'b solana_program::account_info::AccountInfo<'a>,
pub quote_vault: &'b solana_program::account_info::AccountInfo<'a>,
pub destination_owner: &'b solana_program::account_info::AccountInfo<'a>,
pub destination: &'b solana_program::account_info::AccountInfo<'a>,
pub quote_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 event_authority: &'b solana_program::account_info::AccountInfo<'a>,
pub program: &'b solana_program::account_info::AccountInfo<'a>,
}
pub struct ClaimCreatorFeesCpi<'a, 'b> {
pub __program: &'b solana_program::account_info::AccountInfo<'a>,
pub claimer: &'b solana_program::account_info::AccountInfo<'a>,
pub payer: &'b solana_program::account_info::AccountInfo<'a>,
pub pool: &'b solana_program::account_info::AccountInfo<'a>,
pub creator_fee_config: &'b solana_program::account_info::AccountInfo<'a>,
pub nexus_global_config: &'b solana_program::account_info::AccountInfo<'a>,
pub base_mint: &'b solana_program::account_info::AccountInfo<'a>,
pub quote_mint: &'b solana_program::account_info::AccountInfo<'a>,
pub quote_vault: &'b solana_program::account_info::AccountInfo<'a>,
pub destination_owner: &'b solana_program::account_info::AccountInfo<'a>,
pub destination: &'b solana_program::account_info::AccountInfo<'a>,
pub quote_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 event_authority: &'b solana_program::account_info::AccountInfo<'a>,
pub program: &'b solana_program::account_info::AccountInfo<'a>,
}
impl<'a, 'b> ClaimCreatorFeesCpi<'a, 'b> {
pub fn new(
program: &'b solana_program::account_info::AccountInfo<'a>,
accounts: ClaimCreatorFeesCpiAccounts<'a, 'b>,
) -> Self {
Self {
__program: program,
claimer: accounts.claimer,
payer: accounts.payer,
pool: accounts.pool,
creator_fee_config: accounts.creator_fee_config,
nexus_global_config: accounts.nexus_global_config,
base_mint: accounts.base_mint,
quote_mint: accounts.quote_mint,
quote_vault: accounts.quote_vault,
destination_owner: accounts.destination_owner,
destination: accounts.destination,
quote_token_program: accounts.quote_token_program,
associated_token_program: accounts.associated_token_program,
system_program: accounts.system_program,
event_authority: accounts.event_authority,
program: accounts.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(15 + remaining_accounts.len());
accounts.push(solana_instruction::AccountMeta::new_readonly(
*self.claimer.key,
true,
));
accounts
.push(solana_instruction::AccountMeta::new(*self.payer.key, true));
accounts
.push(solana_instruction::AccountMeta::new(*self.pool.key, false));
accounts.push(solana_instruction::AccountMeta::new(
*self.creator_fee_config.key,
false,
));
accounts.push(solana_instruction::AccountMeta::new_readonly(
*self.nexus_global_config.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.destination_owner.key,
false,
));
accounts.push(solana_instruction::AccountMeta::new(
*self.destination.key,
false,
));
accounts.push(solana_instruction::AccountMeta::new_readonly(
*self.quote_token_program.key,
false,
));
accounts.push(solana_instruction::AccountMeta::new_readonly(
*self.associated_token_program.key,
false,
));
accounts.push(solana_instruction::AccountMeta::new_readonly(
*self.system_program.key,
false,
));
accounts.push(solana_instruction::AccountMeta::new_readonly(
*self.event_authority.key,
false,
));
accounts.push(solana_instruction::AccountMeta::new_readonly(
*self.program.key,
false,
));
remaining_accounts.iter().for_each(|remaining_account| {
accounts.push(solana_instruction::AccountMeta {
pubkey: *remaining_account.0.key,
is_writable: remaining_account.1,
is_signer: remaining_account.2,
})
});
let data = ClaimCreatorFeesInstructionData::new().try_to_vec().unwrap();
let instruction = solana_instruction::Instruction {
program_id: crate::dex::generated::SEND_DEX_ID,
accounts,
data,
};
let mut account_infos =
Vec::with_capacity(16 + remaining_accounts.len());
account_infos.push(self.__program.clone());
account_infos.push(self.claimer.clone());
account_infos.push(self.payer.clone());
account_infos.push(self.pool.clone());
account_infos.push(self.creator_fee_config.clone());
account_infos.push(self.nexus_global_config.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.destination_owner.clone());
account_infos.push(self.destination.clone());
account_infos.push(self.quote_token_program.clone());
account_infos.push(self.associated_token_program.clone());
account_infos.push(self.system_program.clone());
account_infos.push(self.event_authority.clone());
account_infos.push(self.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 ClaimCreatorFeesCpiBuilder<'a, 'b> {
instruction: Box<ClaimCreatorFeesCpiBuilderInstruction<'a, 'b>>,
}
impl<'a, 'b> ClaimCreatorFeesCpiBuilder<'a, 'b> {
pub fn new(
__program: &'b solana_program::account_info::AccountInfo<'a>,
claimer: &'b solana_program::account_info::AccountInfo<'a>,
payer: &'b solana_program::account_info::AccountInfo<'a>,
pool: &'b solana_program::account_info::AccountInfo<'a>,
creator_fee_config: &'b solana_program::account_info::AccountInfo<'a>,
nexus_global_config: &'b solana_program::account_info::AccountInfo<'a>,
base_mint: &'b solana_program::account_info::AccountInfo<'a>,
quote_mint: &'b solana_program::account_info::AccountInfo<'a>,
quote_vault: &'b solana_program::account_info::AccountInfo<'a>,
destination_owner: &'b solana_program::account_info::AccountInfo<'a>,
destination: &'b solana_program::account_info::AccountInfo<'a>,
quote_token_program: &'b solana_program::account_info::AccountInfo<'a>,
associated_token_program: &'b solana_program::account_info::AccountInfo<
'a,
>,
system_program: &'b solana_program::account_info::AccountInfo<'a>,
event_authority: &'b solana_program::account_info::AccountInfo<'a>,
program: &'b solana_program::account_info::AccountInfo<'a>,
) -> Self {
let instruction = Box::new(ClaimCreatorFeesCpiBuilderInstruction {
__program,
claimer,
payer,
pool,
creator_fee_config,
nexus_global_config,
base_mint,
quote_mint,
quote_vault,
destination_owner,
destination,
quote_token_program,
associated_token_program,
system_program,
event_authority,
program,
__remaining_accounts: Vec::new(),
});
Self { instruction }
}
#[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 = ClaimCreatorFeesCpi {
__program: self.instruction.__program,
claimer: self.instruction.claimer,
payer: self.instruction.payer,
pool: self.instruction.pool,
creator_fee_config: self.instruction.creator_fee_config,
nexus_global_config: self.instruction.nexus_global_config,
base_mint: self.instruction.base_mint,
quote_mint: self.instruction.quote_mint,
quote_vault: self.instruction.quote_vault,
destination_owner: self.instruction.destination_owner,
destination: self.instruction.destination,
quote_token_program: self.instruction.quote_token_program,
associated_token_program: self.instruction.associated_token_program,
system_program: self.instruction.system_program,
event_authority: self.instruction.event_authority,
program: self.instruction.program,
};
instruction.invoke_signed_with_remaining_accounts(
signers_seeds,
&self.instruction.__remaining_accounts,
)
}
}
#[derive(Clone, Debug)]
struct ClaimCreatorFeesCpiBuilderInstruction<'a, 'b> {
__program: &'b solana_program::account_info::AccountInfo<'a>,
claimer: &'b solana_program::account_info::AccountInfo<'a>,
payer: &'b solana_program::account_info::AccountInfo<'a>,
pool: &'b solana_program::account_info::AccountInfo<'a>,
creator_fee_config: &'b solana_program::account_info::AccountInfo<'a>,
nexus_global_config: &'b solana_program::account_info::AccountInfo<'a>,
base_mint: &'b solana_program::account_info::AccountInfo<'a>,
quote_mint: &'b solana_program::account_info::AccountInfo<'a>,
quote_vault: &'b solana_program::account_info::AccountInfo<'a>,
destination_owner: &'b solana_program::account_info::AccountInfo<'a>,
destination: &'b solana_program::account_info::AccountInfo<'a>,
quote_token_program: &'b solana_program::account_info::AccountInfo<'a>,
associated_token_program: &'b solana_program::account_info::AccountInfo<'a>,
system_program: &'b solana_program::account_info::AccountInfo<'a>,
event_authority: &'b solana_program::account_info::AccountInfo<'a>,
program: &'b solana_program::account_info::AccountInfo<'a>,
__remaining_accounts: Vec<(
&'b solana_program::account_info::AccountInfo<'a>,
bool,
bool,
)>,
}