use borsh::BorshSerialize;
use borsh::BorshDeserialize;
#[derive(Debug)]
pub struct ClaimFee {
pub lb_pair: solana_pubkey::Pubkey,
pub position: solana_pubkey::Pubkey,
pub bin_array_lower: solana_pubkey::Pubkey,
pub bin_array_upper: solana_pubkey::Pubkey,
pub sender: solana_pubkey::Pubkey,
pub reserve_x: solana_pubkey::Pubkey,
pub reserve_y: solana_pubkey::Pubkey,
pub user_token_x: solana_pubkey::Pubkey,
pub user_token_y: solana_pubkey::Pubkey,
pub token_x_mint: solana_pubkey::Pubkey,
pub token_y_mint: solana_pubkey::Pubkey,
pub token_program: solana_pubkey::Pubkey,
pub event_authority: solana_pubkey::Pubkey,
pub program: solana_pubkey::Pubkey,
}
impl ClaimFee {
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(14+ remaining_accounts.len());
accounts.push(solana_instruction::AccountMeta::new(
self.lb_pair,
false
));
accounts.push(solana_instruction::AccountMeta::new(
self.position,
false
));
accounts.push(solana_instruction::AccountMeta::new(
self.bin_array_lower,
false
));
accounts.push(solana_instruction::AccountMeta::new(
self.bin_array_upper,
false
));
accounts.push(solana_instruction::AccountMeta::new_readonly(
self.sender,
true
));
accounts.push(solana_instruction::AccountMeta::new(
self.reserve_x,
false
));
accounts.push(solana_instruction::AccountMeta::new(
self.reserve_y,
false
));
accounts.push(solana_instruction::AccountMeta::new(
self.user_token_x,
false
));
accounts.push(solana_instruction::AccountMeta::new(
self.user_token_y,
false
));
accounts.push(solana_instruction::AccountMeta::new_readonly(
self.token_x_mint,
false
));
accounts.push(solana_instruction::AccountMeta::new_readonly(
self.token_y_mint,
false
));
accounts.push(solana_instruction::AccountMeta::new_readonly(
self.token_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 = borsh::to_vec(&ClaimFeeInstructionData::new()).unwrap();
solana_instruction::Instruction {
program_id: crate::LB_CLMM_ID,
accounts,
data,
}
}
}
#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct ClaimFeeInstructionData {
discriminator: [u8; 8],
}
impl ClaimFeeInstructionData {
pub fn new() -> Self {
Self {
discriminator: [169, 32, 79, 137, 136, 232, 70, 137],
}
}
}
impl Default for ClaimFeeInstructionData {
fn default() -> Self {
Self::new()
}
}
#[derive(Clone, Debug, Default)]
pub struct ClaimFeeBuilder {
lb_pair: Option<solana_pubkey::Pubkey>,
position: Option<solana_pubkey::Pubkey>,
bin_array_lower: Option<solana_pubkey::Pubkey>,
bin_array_upper: Option<solana_pubkey::Pubkey>,
sender: Option<solana_pubkey::Pubkey>,
reserve_x: Option<solana_pubkey::Pubkey>,
reserve_y: Option<solana_pubkey::Pubkey>,
user_token_x: Option<solana_pubkey::Pubkey>,
user_token_y: Option<solana_pubkey::Pubkey>,
token_x_mint: Option<solana_pubkey::Pubkey>,
token_y_mint: Option<solana_pubkey::Pubkey>,
token_program: Option<solana_pubkey::Pubkey>,
event_authority: Option<solana_pubkey::Pubkey>,
program: Option<solana_pubkey::Pubkey>,
__remaining_accounts: Vec<solana_instruction::AccountMeta>,
}
impl ClaimFeeBuilder {
pub fn new() -> Self {
Self::default()
}
#[inline(always)]
pub fn lb_pair(&mut self, lb_pair: solana_pubkey::Pubkey) -> &mut Self {
self.lb_pair = Some(lb_pair);
self
}
#[inline(always)]
pub fn position(&mut self, position: solana_pubkey::Pubkey) -> &mut Self {
self.position = Some(position);
self
}
#[inline(always)]
pub fn bin_array_lower(&mut self, bin_array_lower: solana_pubkey::Pubkey) -> &mut Self {
self.bin_array_lower = Some(bin_array_lower);
self
}
#[inline(always)]
pub fn bin_array_upper(&mut self, bin_array_upper: solana_pubkey::Pubkey) -> &mut Self {
self.bin_array_upper = Some(bin_array_upper);
self
}
#[inline(always)]
pub fn sender(&mut self, sender: solana_pubkey::Pubkey) -> &mut Self {
self.sender = Some(sender);
self
}
#[inline(always)]
pub fn reserve_x(&mut self, reserve_x: solana_pubkey::Pubkey) -> &mut Self {
self.reserve_x = Some(reserve_x);
self
}
#[inline(always)]
pub fn reserve_y(&mut self, reserve_y: solana_pubkey::Pubkey) -> &mut Self {
self.reserve_y = Some(reserve_y);
self
}
#[inline(always)]
pub fn user_token_x(&mut self, user_token_x: solana_pubkey::Pubkey) -> &mut Self {
self.user_token_x = Some(user_token_x);
self
}
#[inline(always)]
pub fn user_token_y(&mut self, user_token_y: solana_pubkey::Pubkey) -> &mut Self {
self.user_token_y = Some(user_token_y);
self
}
#[inline(always)]
pub fn token_x_mint(&mut self, token_x_mint: solana_pubkey::Pubkey) -> &mut Self {
self.token_x_mint = Some(token_x_mint);
self
}
#[inline(always)]
pub fn token_y_mint(&mut self, token_y_mint: solana_pubkey::Pubkey) -> &mut Self {
self.token_y_mint = Some(token_y_mint);
self
}
#[inline(always)]
pub fn token_program(&mut self, token_program: solana_pubkey::Pubkey) -> &mut Self {
self.token_program = Some(token_program);
self
}
#[inline(always)]
pub fn event_authority(&mut self, event_authority: solana_pubkey::Pubkey) -> &mut Self {
self.event_authority = Some(event_authority);
self
}
#[inline(always)]
pub fn program(&mut self, program: solana_pubkey::Pubkey) -> &mut Self {
self.program = Some(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 = ClaimFee {
lb_pair: self.lb_pair.expect("lb_pair is not set"),
position: self.position.expect("position is not set"),
bin_array_lower: self.bin_array_lower.expect("bin_array_lower is not set"),
bin_array_upper: self.bin_array_upper.expect("bin_array_upper is not set"),
sender: self.sender.expect("sender is not set"),
reserve_x: self.reserve_x.expect("reserve_x is not set"),
reserve_y: self.reserve_y.expect("reserve_y is not set"),
user_token_x: self.user_token_x.expect("user_token_x is not set"),
user_token_y: self.user_token_y.expect("user_token_y is not set"),
token_x_mint: self.token_x_mint.expect("token_x_mint is not set"),
token_y_mint: self.token_y_mint.expect("token_y_mint is not set"),
token_program: self.token_program.unwrap_or(solana_pubkey::pubkey!("TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA")),
event_authority: self.event_authority.expect("event_authority is not set"),
program: self.program.expect("program is not set"),
};
accounts.instruction_with_remaining_accounts(&self.__remaining_accounts)
}
}
pub struct ClaimFeeCpiAccounts<'a, 'b> {
pub lb_pair: &'b solana_account_info::AccountInfo<'a>,
pub position: &'b solana_account_info::AccountInfo<'a>,
pub bin_array_lower: &'b solana_account_info::AccountInfo<'a>,
pub bin_array_upper: &'b solana_account_info::AccountInfo<'a>,
pub sender: &'b solana_account_info::AccountInfo<'a>,
pub reserve_x: &'b solana_account_info::AccountInfo<'a>,
pub reserve_y: &'b solana_account_info::AccountInfo<'a>,
pub user_token_x: &'b solana_account_info::AccountInfo<'a>,
pub user_token_y: &'b solana_account_info::AccountInfo<'a>,
pub token_x_mint: &'b solana_account_info::AccountInfo<'a>,
pub token_y_mint: &'b solana_account_info::AccountInfo<'a>,
pub token_program: &'b solana_account_info::AccountInfo<'a>,
pub event_authority: &'b solana_account_info::AccountInfo<'a>,
pub program: &'b solana_account_info::AccountInfo<'a>,
}
pub struct ClaimFeeCpi<'a, 'b> {
pub __program: &'b solana_account_info::AccountInfo<'a>,
pub lb_pair: &'b solana_account_info::AccountInfo<'a>,
pub position: &'b solana_account_info::AccountInfo<'a>,
pub bin_array_lower: &'b solana_account_info::AccountInfo<'a>,
pub bin_array_upper: &'b solana_account_info::AccountInfo<'a>,
pub sender: &'b solana_account_info::AccountInfo<'a>,
pub reserve_x: &'b solana_account_info::AccountInfo<'a>,
pub reserve_y: &'b solana_account_info::AccountInfo<'a>,
pub user_token_x: &'b solana_account_info::AccountInfo<'a>,
pub user_token_y: &'b solana_account_info::AccountInfo<'a>,
pub token_x_mint: &'b solana_account_info::AccountInfo<'a>,
pub token_y_mint: &'b solana_account_info::AccountInfo<'a>,
pub token_program: &'b solana_account_info::AccountInfo<'a>,
pub event_authority: &'b solana_account_info::AccountInfo<'a>,
pub program: &'b solana_account_info::AccountInfo<'a>,
}
impl<'a, 'b> ClaimFeeCpi<'a, 'b> {
pub fn new(
program: &'b solana_account_info::AccountInfo<'a>,
accounts: ClaimFeeCpiAccounts<'a, 'b>,
) -> Self {
Self {
__program: program,
lb_pair: accounts.lb_pair,
position: accounts.position,
bin_array_lower: accounts.bin_array_lower,
bin_array_upper: accounts.bin_array_upper,
sender: accounts.sender,
reserve_x: accounts.reserve_x,
reserve_y: accounts.reserve_y,
user_token_x: accounts.user_token_x,
user_token_y: accounts.user_token_y,
token_x_mint: accounts.token_x_mint,
token_y_mint: accounts.token_y_mint,
token_program: accounts.token_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_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_account_info::AccountInfo<'a>, bool, bool)]
) -> solana_program_entrypoint::ProgramResult {
let mut accounts = Vec::with_capacity(14+ remaining_accounts.len());
accounts.push(solana_instruction::AccountMeta::new(
*self.lb_pair.key,
false
));
accounts.push(solana_instruction::AccountMeta::new(
*self.position.key,
false
));
accounts.push(solana_instruction::AccountMeta::new(
*self.bin_array_lower.key,
false
));
accounts.push(solana_instruction::AccountMeta::new(
*self.bin_array_upper.key,
false
));
accounts.push(solana_instruction::AccountMeta::new_readonly(
*self.sender.key,
true
));
accounts.push(solana_instruction::AccountMeta::new(
*self.reserve_x.key,
false
));
accounts.push(solana_instruction::AccountMeta::new(
*self.reserve_y.key,
false
));
accounts.push(solana_instruction::AccountMeta::new(
*self.user_token_x.key,
false
));
accounts.push(solana_instruction::AccountMeta::new(
*self.user_token_y.key,
false
));
accounts.push(solana_instruction::AccountMeta::new_readonly(
*self.token_x_mint.key,
false
));
accounts.push(solana_instruction::AccountMeta::new_readonly(
*self.token_y_mint.key,
false
));
accounts.push(solana_instruction::AccountMeta::new_readonly(
*self.token_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_signer: remaining_account.1,
is_writable: remaining_account.2,
})
});
let data = borsh::to_vec(&ClaimFeeInstructionData::new()).unwrap();
let instruction = solana_instruction::Instruction {
program_id: crate::LB_CLMM_ID,
accounts,
data,
};
let mut account_infos = Vec::with_capacity(15 + remaining_accounts.len());
account_infos.push(self.__program.clone());
account_infos.push(self.lb_pair.clone());
account_infos.push(self.position.clone());
account_infos.push(self.bin_array_lower.clone());
account_infos.push(self.bin_array_upper.clone());
account_infos.push(self.sender.clone());
account_infos.push(self.reserve_x.clone());
account_infos.push(self.reserve_y.clone());
account_infos.push(self.user_token_x.clone());
account_infos.push(self.user_token_y.clone());
account_infos.push(self.token_x_mint.clone());
account_infos.push(self.token_y_mint.clone());
account_infos.push(self.token_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_cpi::invoke(&instruction, &account_infos)
} else {
solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds)
}
}
}
#[derive(Clone, Debug)]
pub struct ClaimFeeCpiBuilder<'a, 'b> {
instruction: Box<ClaimFeeCpiBuilderInstruction<'a, 'b>>,
}
impl<'a, 'b> ClaimFeeCpiBuilder<'a, 'b> {
pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self {
let instruction = Box::new(ClaimFeeCpiBuilderInstruction {
__program: program,
lb_pair: None,
position: None,
bin_array_lower: None,
bin_array_upper: None,
sender: None,
reserve_x: None,
reserve_y: None,
user_token_x: None,
user_token_y: None,
token_x_mint: None,
token_y_mint: None,
token_program: None,
event_authority: None,
program: None,
__remaining_accounts: Vec::new(),
});
Self { instruction }
}
#[inline(always)]
pub fn lb_pair(&mut self, lb_pair: &'b solana_account_info::AccountInfo<'a>) -> &mut Self {
self.instruction.lb_pair = Some(lb_pair);
self
}
#[inline(always)]
pub fn position(&mut self, position: &'b solana_account_info::AccountInfo<'a>) -> &mut Self {
self.instruction.position = Some(position);
self
}
#[inline(always)]
pub fn bin_array_lower(&mut self, bin_array_lower: &'b solana_account_info::AccountInfo<'a>) -> &mut Self {
self.instruction.bin_array_lower = Some(bin_array_lower);
self
}
#[inline(always)]
pub fn bin_array_upper(&mut self, bin_array_upper: &'b solana_account_info::AccountInfo<'a>) -> &mut Self {
self.instruction.bin_array_upper = Some(bin_array_upper);
self
}
#[inline(always)]
pub fn sender(&mut self, sender: &'b solana_account_info::AccountInfo<'a>) -> &mut Self {
self.instruction.sender = Some(sender);
self
}
#[inline(always)]
pub fn reserve_x(&mut self, reserve_x: &'b solana_account_info::AccountInfo<'a>) -> &mut Self {
self.instruction.reserve_x = Some(reserve_x);
self
}
#[inline(always)]
pub fn reserve_y(&mut self, reserve_y: &'b solana_account_info::AccountInfo<'a>) -> &mut Self {
self.instruction.reserve_y = Some(reserve_y);
self
}
#[inline(always)]
pub fn user_token_x(&mut self, user_token_x: &'b solana_account_info::AccountInfo<'a>) -> &mut Self {
self.instruction.user_token_x = Some(user_token_x);
self
}
#[inline(always)]
pub fn user_token_y(&mut self, user_token_y: &'b solana_account_info::AccountInfo<'a>) -> &mut Self {
self.instruction.user_token_y = Some(user_token_y);
self
}
#[inline(always)]
pub fn token_x_mint(&mut self, token_x_mint: &'b solana_account_info::AccountInfo<'a>) -> &mut Self {
self.instruction.token_x_mint = Some(token_x_mint);
self
}
#[inline(always)]
pub fn token_y_mint(&mut self, token_y_mint: &'b solana_account_info::AccountInfo<'a>) -> &mut Self {
self.instruction.token_y_mint = Some(token_y_mint);
self
}
#[inline(always)]
pub fn token_program(&mut self, token_program: &'b solana_account_info::AccountInfo<'a>) -> &mut Self {
self.instruction.token_program = Some(token_program);
self
}
#[inline(always)]
pub fn event_authority(&mut self, event_authority: &'b solana_account_info::AccountInfo<'a>) -> &mut Self {
self.instruction.event_authority = Some(event_authority);
self
}
#[inline(always)]
pub fn program(&mut self, program: &'b solana_account_info::AccountInfo<'a>) -> &mut Self {
self.instruction.program = Some(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_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 = ClaimFeeCpi {
__program: self.instruction.__program,
lb_pair: self.instruction.lb_pair.expect("lb_pair is not set"),
position: self.instruction.position.expect("position is not set"),
bin_array_lower: self.instruction.bin_array_lower.expect("bin_array_lower is not set"),
bin_array_upper: self.instruction.bin_array_upper.expect("bin_array_upper is not set"),
sender: self.instruction.sender.expect("sender is not set"),
reserve_x: self.instruction.reserve_x.expect("reserve_x is not set"),
reserve_y: self.instruction.reserve_y.expect("reserve_y is not set"),
user_token_x: self.instruction.user_token_x.expect("user_token_x is not set"),
user_token_y: self.instruction.user_token_y.expect("user_token_y is not set"),
token_x_mint: self.instruction.token_x_mint.expect("token_x_mint is not set"),
token_y_mint: self.instruction.token_y_mint.expect("token_y_mint is not set"),
token_program: self.instruction.token_program.expect("token_program is not set"),
event_authority: self.instruction.event_authority.expect("event_authority is not set"),
program: self.instruction.program.expect("program is not set"),
};
instruction.invoke_signed_with_remaining_accounts(signers_seeds, &self.instruction.__remaining_accounts)
}
}
#[derive(Clone, Debug)]
struct ClaimFeeCpiBuilderInstruction<'a, 'b> {
__program: &'b solana_account_info::AccountInfo<'a>,
lb_pair: Option<&'b solana_account_info::AccountInfo<'a>>,
position: Option<&'b solana_account_info::AccountInfo<'a>>,
bin_array_lower: Option<&'b solana_account_info::AccountInfo<'a>>,
bin_array_upper: Option<&'b solana_account_info::AccountInfo<'a>>,
sender: Option<&'b solana_account_info::AccountInfo<'a>>,
reserve_x: Option<&'b solana_account_info::AccountInfo<'a>>,
reserve_y: Option<&'b solana_account_info::AccountInfo<'a>>,
user_token_x: Option<&'b solana_account_info::AccountInfo<'a>>,
user_token_y: Option<&'b solana_account_info::AccountInfo<'a>>,
token_x_mint: Option<&'b solana_account_info::AccountInfo<'a>>,
token_y_mint: Option<&'b solana_account_info::AccountInfo<'a>>,
token_program: Option<&'b solana_account_info::AccountInfo<'a>>,
event_authority: Option<&'b solana_account_info::AccountInfo<'a>>,
program: Option<&'b solana_account_info::AccountInfo<'a>>,
__remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>,
}