use borsh::BorshSerialize;
use borsh::BorshDeserialize;
pub const CREATE_KAMINO_USER_ACCOUNTS_DISCRIMINATOR: [u8; 8] = [37, 248, 26, 124, 176, 250, 89, 196];
#[derive(Debug)]
pub struct CreateKaminoUserAccounts {
pub main: solana_pubkey::Pubkey,
pub controller: solana_pubkey::Pubkey,
pub admin: solana_pubkey::Pubkey,
pub admin_permissions: solana_pubkey::Pubkey,
pub instruction_sysvar_account: solana_pubkey::Pubkey,
pub rent: solana_pubkey::Pubkey,
pub system_program: solana_pubkey::Pubkey,
pub user_metadata: solana_pubkey::Pubkey,
pub obligation: solana_pubkey::Pubkey,
pub lending_market: solana_pubkey::Pubkey,
pub lending_market_authority: solana_pubkey::Pubkey,
pub reserve: solana_pubkey::Pubkey,
pub obligation_farm_state: solana_pubkey::Pubkey,
pub reserve_farm_state: solana_pubkey::Pubkey,
pub klend_program: solana_pubkey::Pubkey,
pub farms_program: solana_pubkey::Pubkey,
pub earn_mint: solana_pubkey::Pubkey,
pub controller_token_account: solana_pubkey::Pubkey,
pub user_usdc_account: solana_pubkey::Pubkey,
pub reserve_collateral: solana_pubkey::Pubkey,
pub scope_oracle: solana_pubkey::Pubkey,
pub token_program: solana_pubkey::Pubkey,
pub reserve_liquidity_supply: solana_pubkey::Pubkey,
pub reserve_collateral_mint: solana_pubkey::Pubkey,
pub reserve_destination_deposit_collateral: solana_pubkey::Pubkey,
}
impl CreateKaminoUserAccounts {
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(25+ remaining_accounts.len());
accounts.push(solana_instruction::AccountMeta::new(
self.main,
false
));
accounts.push(solana_instruction::AccountMeta::new(
self.controller,
false
));
accounts.push(solana_instruction::AccountMeta::new(
self.admin,
true
));
accounts.push(solana_instruction::AccountMeta::new_readonly(
self.admin_permissions,
false
));
accounts.push(solana_instruction::AccountMeta::new_readonly(
self.instruction_sysvar_account,
false
));
accounts.push(solana_instruction::AccountMeta::new_readonly(
self.rent,
false
));
accounts.push(solana_instruction::AccountMeta::new_readonly(
self.system_program,
false
));
accounts.push(solana_instruction::AccountMeta::new(
self.user_metadata,
false
));
accounts.push(solana_instruction::AccountMeta::new(
self.obligation,
false
));
accounts.push(solana_instruction::AccountMeta::new_readonly(
self.lending_market,
false
));
accounts.push(solana_instruction::AccountMeta::new_readonly(
self.lending_market_authority,
false
));
accounts.push(solana_instruction::AccountMeta::new(
self.reserve,
false
));
accounts.push(solana_instruction::AccountMeta::new(
self.obligation_farm_state,
false
));
accounts.push(solana_instruction::AccountMeta::new(
self.reserve_farm_state,
false
));
accounts.push(solana_instruction::AccountMeta::new_readonly(
self.klend_program,
false
));
accounts.push(solana_instruction::AccountMeta::new_readonly(
self.farms_program,
false
));
accounts.push(solana_instruction::AccountMeta::new_readonly(
self.earn_mint,
false
));
accounts.push(solana_instruction::AccountMeta::new(
self.controller_token_account,
false
));
accounts.push(solana_instruction::AccountMeta::new(
self.user_usdc_account,
false
));
accounts.push(solana_instruction::AccountMeta::new_readonly(
self.reserve_collateral,
false
));
accounts.push(solana_instruction::AccountMeta::new_readonly(
self.scope_oracle,
false
));
accounts.push(solana_instruction::AccountMeta::new_readonly(
self.token_program,
false
));
accounts.push(solana_instruction::AccountMeta::new(
self.reserve_liquidity_supply,
false
));
accounts.push(solana_instruction::AccountMeta::new(
self.reserve_collateral_mint,
false
));
accounts.push(solana_instruction::AccountMeta::new(
self.reserve_destination_deposit_collateral,
false
));
accounts.extend_from_slice(remaining_accounts);
let data = CreateKaminoUserAccountsInstructionData::new().try_to_vec().unwrap();
solana_instruction::Instruction {
program_id: crate::REFLECT_MAIN_ID,
accounts,
data,
}
}
}
#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct CreateKaminoUserAccountsInstructionData {
discriminator: [u8; 8],
}
impl CreateKaminoUserAccountsInstructionData {
pub fn new() -> Self {
Self {
discriminator: [37, 248, 26, 124, 176, 250, 89, 196],
}
}
pub(crate) fn try_to_vec(&self) -> Result<Vec<u8>, std::io::Error> {
borsh::to_vec(self)
}
}
impl Default for CreateKaminoUserAccountsInstructionData {
fn default() -> Self {
Self::new()
}
}
#[derive(Clone, Debug, Default)]
pub struct CreateKaminoUserAccountsBuilder {
main: Option<solana_pubkey::Pubkey>,
controller: Option<solana_pubkey::Pubkey>,
admin: Option<solana_pubkey::Pubkey>,
admin_permissions: Option<solana_pubkey::Pubkey>,
instruction_sysvar_account: Option<solana_pubkey::Pubkey>,
rent: Option<solana_pubkey::Pubkey>,
system_program: Option<solana_pubkey::Pubkey>,
user_metadata: Option<solana_pubkey::Pubkey>,
obligation: Option<solana_pubkey::Pubkey>,
lending_market: Option<solana_pubkey::Pubkey>,
lending_market_authority: Option<solana_pubkey::Pubkey>,
reserve: Option<solana_pubkey::Pubkey>,
obligation_farm_state: Option<solana_pubkey::Pubkey>,
reserve_farm_state: Option<solana_pubkey::Pubkey>,
klend_program: Option<solana_pubkey::Pubkey>,
farms_program: Option<solana_pubkey::Pubkey>,
earn_mint: Option<solana_pubkey::Pubkey>,
controller_token_account: Option<solana_pubkey::Pubkey>,
user_usdc_account: Option<solana_pubkey::Pubkey>,
reserve_collateral: Option<solana_pubkey::Pubkey>,
scope_oracle: Option<solana_pubkey::Pubkey>,
token_program: Option<solana_pubkey::Pubkey>,
reserve_liquidity_supply: Option<solana_pubkey::Pubkey>,
reserve_collateral_mint: Option<solana_pubkey::Pubkey>,
reserve_destination_deposit_collateral: Option<solana_pubkey::Pubkey>,
__remaining_accounts: Vec<solana_instruction::AccountMeta>,
}
impl CreateKaminoUserAccountsBuilder {
pub fn new() -> Self {
Self::default()
}
#[inline(always)]
pub fn main(&mut self, main: solana_pubkey::Pubkey) -> &mut Self {
self.main = Some(main);
self
}
#[inline(always)]
pub fn controller(&mut self, controller: solana_pubkey::Pubkey) -> &mut Self {
self.controller = Some(controller);
self
}
#[inline(always)]
pub fn admin(&mut self, admin: solana_pubkey::Pubkey) -> &mut Self {
self.admin = Some(admin);
self
}
#[inline(always)]
pub fn admin_permissions(&mut self, admin_permissions: solana_pubkey::Pubkey) -> &mut Self {
self.admin_permissions = Some(admin_permissions);
self
}
#[inline(always)]
pub fn instruction_sysvar_account(&mut self, instruction_sysvar_account: solana_pubkey::Pubkey) -> &mut Self {
self.instruction_sysvar_account = Some(instruction_sysvar_account);
self
}
#[inline(always)]
pub fn rent(&mut self, rent: solana_pubkey::Pubkey) -> &mut Self {
self.rent = Some(rent);
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 user_metadata(&mut self, user_metadata: solana_pubkey::Pubkey) -> &mut Self {
self.user_metadata = Some(user_metadata);
self
}
#[inline(always)]
pub fn obligation(&mut self, obligation: solana_pubkey::Pubkey) -> &mut Self {
self.obligation = Some(obligation);
self
}
#[inline(always)]
pub fn lending_market(&mut self, lending_market: solana_pubkey::Pubkey) -> &mut Self {
self.lending_market = Some(lending_market);
self
}
#[inline(always)]
pub fn lending_market_authority(&mut self, lending_market_authority: solana_pubkey::Pubkey) -> &mut Self {
self.lending_market_authority = Some(lending_market_authority);
self
}
#[inline(always)]
pub fn reserve(&mut self, reserve: solana_pubkey::Pubkey) -> &mut Self {
self.reserve = Some(reserve);
self
}
#[inline(always)]
pub fn obligation_farm_state(&mut self, obligation_farm_state: solana_pubkey::Pubkey) -> &mut Self {
self.obligation_farm_state = Some(obligation_farm_state);
self
}
#[inline(always)]
pub fn reserve_farm_state(&mut self, reserve_farm_state: solana_pubkey::Pubkey) -> &mut Self {
self.reserve_farm_state = Some(reserve_farm_state);
self
}
#[inline(always)]
pub fn klend_program(&mut self, klend_program: solana_pubkey::Pubkey) -> &mut Self {
self.klend_program = Some(klend_program);
self
}
#[inline(always)]
pub fn farms_program(&mut self, farms_program: solana_pubkey::Pubkey) -> &mut Self {
self.farms_program = Some(farms_program);
self
}
#[inline(always)]
pub fn earn_mint(&mut self, earn_mint: solana_pubkey::Pubkey) -> &mut Self {
self.earn_mint = Some(earn_mint);
self
}
#[inline(always)]
pub fn controller_token_account(&mut self, controller_token_account: solana_pubkey::Pubkey) -> &mut Self {
self.controller_token_account = Some(controller_token_account);
self
}
#[inline(always)]
pub fn user_usdc_account(&mut self, user_usdc_account: solana_pubkey::Pubkey) -> &mut Self {
self.user_usdc_account = Some(user_usdc_account);
self
}
#[inline(always)]
pub fn reserve_collateral(&mut self, reserve_collateral: solana_pubkey::Pubkey) -> &mut Self {
self.reserve_collateral = Some(reserve_collateral);
self
}
#[inline(always)]
pub fn scope_oracle(&mut self, scope_oracle: solana_pubkey::Pubkey) -> &mut Self {
self.scope_oracle = Some(scope_oracle);
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 reserve_liquidity_supply(&mut self, reserve_liquidity_supply: solana_pubkey::Pubkey) -> &mut Self {
self.reserve_liquidity_supply = Some(reserve_liquidity_supply);
self
}
#[inline(always)]
pub fn reserve_collateral_mint(&mut self, reserve_collateral_mint: solana_pubkey::Pubkey) -> &mut Self {
self.reserve_collateral_mint = Some(reserve_collateral_mint);
self
}
#[inline(always)]
pub fn reserve_destination_deposit_collateral(&mut self, reserve_destination_deposit_collateral: solana_pubkey::Pubkey) -> &mut Self {
self.reserve_destination_deposit_collateral = Some(reserve_destination_deposit_collateral);
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 = CreateKaminoUserAccounts {
main: self.main.expect("main is not set"),
controller: self.controller.expect("controller is not set"),
admin: self.admin.expect("admin is not set"),
admin_permissions: self.admin_permissions.expect("admin_permissions is not set"),
instruction_sysvar_account: self.instruction_sysvar_account.unwrap_or(solana_pubkey::pubkey!("Sysvar1nstructions1111111111111111111111111")),
rent: self.rent.unwrap_or(solana_pubkey::pubkey!("SysvarRent111111111111111111111111111111111")),
system_program: self.system_program.unwrap_or(solana_pubkey::pubkey!("11111111111111111111111111111111")),
user_metadata: self.user_metadata.expect("user_metadata is not set"),
obligation: self.obligation.expect("obligation is not set"),
lending_market: self.lending_market.expect("lending_market is not set"),
lending_market_authority: self.lending_market_authority.expect("lending_market_authority is not set"),
reserve: self.reserve.expect("reserve is not set"),
obligation_farm_state: self.obligation_farm_state.expect("obligation_farm_state is not set"),
reserve_farm_state: self.reserve_farm_state.expect("reserve_farm_state is not set"),
klend_program: self.klend_program.unwrap_or(solana_pubkey::pubkey!("KLend2g3cP87fffoy8q1mQqGKjrxjC8boSyAYavgmjD")),
farms_program: self.farms_program.unwrap_or(solana_pubkey::pubkey!("FarmsPZpWu9i7Kky8tPN37rs2TpmMrAZrC7S7vJa91Hr")),
earn_mint: self.earn_mint.expect("earn_mint is not set"),
controller_token_account: self.controller_token_account.expect("controller_token_account is not set"),
user_usdc_account: self.user_usdc_account.expect("user_usdc_account is not set"),
reserve_collateral: self.reserve_collateral.expect("reserve_collateral is not set"),
scope_oracle: self.scope_oracle.expect("scope_oracle is not set"),
token_program: self.token_program.unwrap_or(solana_pubkey::pubkey!("TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA")),
reserve_liquidity_supply: self.reserve_liquidity_supply.expect("reserve_liquidity_supply is not set"),
reserve_collateral_mint: self.reserve_collateral_mint.expect("reserve_collateral_mint is not set"),
reserve_destination_deposit_collateral: self.reserve_destination_deposit_collateral.expect("reserve_destination_deposit_collateral is not set"),
};
accounts.instruction_with_remaining_accounts(&self.__remaining_accounts)
}
}
pub struct CreateKaminoUserAccountsCpiAccounts<'a, 'b> {
pub main: &'b solana_account_info::AccountInfo<'a>,
pub controller: &'b solana_account_info::AccountInfo<'a>,
pub admin: &'b solana_account_info::AccountInfo<'a>,
pub admin_permissions: &'b solana_account_info::AccountInfo<'a>,
pub instruction_sysvar_account: &'b solana_account_info::AccountInfo<'a>,
pub rent: &'b solana_account_info::AccountInfo<'a>,
pub system_program: &'b solana_account_info::AccountInfo<'a>,
pub user_metadata: &'b solana_account_info::AccountInfo<'a>,
pub obligation: &'b solana_account_info::AccountInfo<'a>,
pub lending_market: &'b solana_account_info::AccountInfo<'a>,
pub lending_market_authority: &'b solana_account_info::AccountInfo<'a>,
pub reserve: &'b solana_account_info::AccountInfo<'a>,
pub obligation_farm_state: &'b solana_account_info::AccountInfo<'a>,
pub reserve_farm_state: &'b solana_account_info::AccountInfo<'a>,
pub klend_program: &'b solana_account_info::AccountInfo<'a>,
pub farms_program: &'b solana_account_info::AccountInfo<'a>,
pub earn_mint: &'b solana_account_info::AccountInfo<'a>,
pub controller_token_account: &'b solana_account_info::AccountInfo<'a>,
pub user_usdc_account: &'b solana_account_info::AccountInfo<'a>,
pub reserve_collateral: &'b solana_account_info::AccountInfo<'a>,
pub scope_oracle: &'b solana_account_info::AccountInfo<'a>,
pub token_program: &'b solana_account_info::AccountInfo<'a>,
pub reserve_liquidity_supply: &'b solana_account_info::AccountInfo<'a>,
pub reserve_collateral_mint: &'b solana_account_info::AccountInfo<'a>,
pub reserve_destination_deposit_collateral: &'b solana_account_info::AccountInfo<'a>,
}
pub struct CreateKaminoUserAccountsCpi<'a, 'b> {
pub __program: &'b solana_account_info::AccountInfo<'a>,
pub main: &'b solana_account_info::AccountInfo<'a>,
pub controller: &'b solana_account_info::AccountInfo<'a>,
pub admin: &'b solana_account_info::AccountInfo<'a>,
pub admin_permissions: &'b solana_account_info::AccountInfo<'a>,
pub instruction_sysvar_account: &'b solana_account_info::AccountInfo<'a>,
pub rent: &'b solana_account_info::AccountInfo<'a>,
pub system_program: &'b solana_account_info::AccountInfo<'a>,
pub user_metadata: &'b solana_account_info::AccountInfo<'a>,
pub obligation: &'b solana_account_info::AccountInfo<'a>,
pub lending_market: &'b solana_account_info::AccountInfo<'a>,
pub lending_market_authority: &'b solana_account_info::AccountInfo<'a>,
pub reserve: &'b solana_account_info::AccountInfo<'a>,
pub obligation_farm_state: &'b solana_account_info::AccountInfo<'a>,
pub reserve_farm_state: &'b solana_account_info::AccountInfo<'a>,
pub klend_program: &'b solana_account_info::AccountInfo<'a>,
pub farms_program: &'b solana_account_info::AccountInfo<'a>,
pub earn_mint: &'b solana_account_info::AccountInfo<'a>,
pub controller_token_account: &'b solana_account_info::AccountInfo<'a>,
pub user_usdc_account: &'b solana_account_info::AccountInfo<'a>,
pub reserve_collateral: &'b solana_account_info::AccountInfo<'a>,
pub scope_oracle: &'b solana_account_info::AccountInfo<'a>,
pub token_program: &'b solana_account_info::AccountInfo<'a>,
pub reserve_liquidity_supply: &'b solana_account_info::AccountInfo<'a>,
pub reserve_collateral_mint: &'b solana_account_info::AccountInfo<'a>,
pub reserve_destination_deposit_collateral: &'b solana_account_info::AccountInfo<'a>,
}
impl<'a, 'b> CreateKaminoUserAccountsCpi<'a, 'b> {
pub fn new(
program: &'b solana_account_info::AccountInfo<'a>,
accounts: CreateKaminoUserAccountsCpiAccounts<'a, 'b>,
) -> Self {
Self {
__program: program,
main: accounts.main,
controller: accounts.controller,
admin: accounts.admin,
admin_permissions: accounts.admin_permissions,
instruction_sysvar_account: accounts.instruction_sysvar_account,
rent: accounts.rent,
system_program: accounts.system_program,
user_metadata: accounts.user_metadata,
obligation: accounts.obligation,
lending_market: accounts.lending_market,
lending_market_authority: accounts.lending_market_authority,
reserve: accounts.reserve,
obligation_farm_state: accounts.obligation_farm_state,
reserve_farm_state: accounts.reserve_farm_state,
klend_program: accounts.klend_program,
farms_program: accounts.farms_program,
earn_mint: accounts.earn_mint,
controller_token_account: accounts.controller_token_account,
user_usdc_account: accounts.user_usdc_account,
reserve_collateral: accounts.reserve_collateral,
scope_oracle: accounts.scope_oracle,
token_program: accounts.token_program,
reserve_liquidity_supply: accounts.reserve_liquidity_supply,
reserve_collateral_mint: accounts.reserve_collateral_mint,
reserve_destination_deposit_collateral: accounts.reserve_destination_deposit_collateral,
}
}
#[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(25+ remaining_accounts.len());
accounts.push(solana_instruction::AccountMeta::new(
*self.main.key,
false
));
accounts.push(solana_instruction::AccountMeta::new(
*self.controller.key,
false
));
accounts.push(solana_instruction::AccountMeta::new(
*self.admin.key,
true
));
accounts.push(solana_instruction::AccountMeta::new_readonly(
*self.admin_permissions.key,
false
));
accounts.push(solana_instruction::AccountMeta::new_readonly(
*self.instruction_sysvar_account.key,
false
));
accounts.push(solana_instruction::AccountMeta::new_readonly(
*self.rent.key,
false
));
accounts.push(solana_instruction::AccountMeta::new_readonly(
*self.system_program.key,
false
));
accounts.push(solana_instruction::AccountMeta::new(
*self.user_metadata.key,
false
));
accounts.push(solana_instruction::AccountMeta::new(
*self.obligation.key,
false
));
accounts.push(solana_instruction::AccountMeta::new_readonly(
*self.lending_market.key,
false
));
accounts.push(solana_instruction::AccountMeta::new_readonly(
*self.lending_market_authority.key,
false
));
accounts.push(solana_instruction::AccountMeta::new(
*self.reserve.key,
false
));
accounts.push(solana_instruction::AccountMeta::new(
*self.obligation_farm_state.key,
false
));
accounts.push(solana_instruction::AccountMeta::new(
*self.reserve_farm_state.key,
false
));
accounts.push(solana_instruction::AccountMeta::new_readonly(
*self.klend_program.key,
false
));
accounts.push(solana_instruction::AccountMeta::new_readonly(
*self.farms_program.key,
false
));
accounts.push(solana_instruction::AccountMeta::new_readonly(
*self.earn_mint.key,
false
));
accounts.push(solana_instruction::AccountMeta::new(
*self.controller_token_account.key,
false
));
accounts.push(solana_instruction::AccountMeta::new(
*self.user_usdc_account.key,
false
));
accounts.push(solana_instruction::AccountMeta::new_readonly(
*self.reserve_collateral.key,
false
));
accounts.push(solana_instruction::AccountMeta::new_readonly(
*self.scope_oracle.key,
false
));
accounts.push(solana_instruction::AccountMeta::new_readonly(
*self.token_program.key,
false
));
accounts.push(solana_instruction::AccountMeta::new(
*self.reserve_liquidity_supply.key,
false
));
accounts.push(solana_instruction::AccountMeta::new(
*self.reserve_collateral_mint.key,
false
));
accounts.push(solana_instruction::AccountMeta::new(
*self.reserve_destination_deposit_collateral.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 = CreateKaminoUserAccountsInstructionData::new().try_to_vec().unwrap();
let instruction = solana_instruction::Instruction {
program_id: crate::REFLECT_MAIN_ID,
accounts,
data,
};
let mut account_infos = Vec::with_capacity(26 + remaining_accounts.len());
account_infos.push(self.__program.clone());
account_infos.push(self.main.clone());
account_infos.push(self.controller.clone());
account_infos.push(self.admin.clone());
account_infos.push(self.admin_permissions.clone());
account_infos.push(self.instruction_sysvar_account.clone());
account_infos.push(self.rent.clone());
account_infos.push(self.system_program.clone());
account_infos.push(self.user_metadata.clone());
account_infos.push(self.obligation.clone());
account_infos.push(self.lending_market.clone());
account_infos.push(self.lending_market_authority.clone());
account_infos.push(self.reserve.clone());
account_infos.push(self.obligation_farm_state.clone());
account_infos.push(self.reserve_farm_state.clone());
account_infos.push(self.klend_program.clone());
account_infos.push(self.farms_program.clone());
account_infos.push(self.earn_mint.clone());
account_infos.push(self.controller_token_account.clone());
account_infos.push(self.user_usdc_account.clone());
account_infos.push(self.reserve_collateral.clone());
account_infos.push(self.scope_oracle.clone());
account_infos.push(self.token_program.clone());
account_infos.push(self.reserve_liquidity_supply.clone());
account_infos.push(self.reserve_collateral_mint.clone());
account_infos.push(self.reserve_destination_deposit_collateral.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 CreateKaminoUserAccountsCpiBuilder<'a, 'b> {
instruction: Box<CreateKaminoUserAccountsCpiBuilderInstruction<'a, 'b>>,
}
impl<'a, 'b> CreateKaminoUserAccountsCpiBuilder<'a, 'b> {
pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self {
let instruction = Box::new(CreateKaminoUserAccountsCpiBuilderInstruction {
__program: program,
main: None,
controller: None,
admin: None,
admin_permissions: None,
instruction_sysvar_account: None,
rent: None,
system_program: None,
user_metadata: None,
obligation: None,
lending_market: None,
lending_market_authority: None,
reserve: None,
obligation_farm_state: None,
reserve_farm_state: None,
klend_program: None,
farms_program: None,
earn_mint: None,
controller_token_account: None,
user_usdc_account: None,
reserve_collateral: None,
scope_oracle: None,
token_program: None,
reserve_liquidity_supply: None,
reserve_collateral_mint: None,
reserve_destination_deposit_collateral: None,
__remaining_accounts: Vec::new(),
});
Self { instruction }
}
#[inline(always)]
pub fn main(&mut self, main: &'b solana_account_info::AccountInfo<'a>) -> &mut Self {
self.instruction.main = Some(main);
self
}
#[inline(always)]
pub fn controller(&mut self, controller: &'b solana_account_info::AccountInfo<'a>) -> &mut Self {
self.instruction.controller = Some(controller);
self
}
#[inline(always)]
pub fn admin(&mut self, admin: &'b solana_account_info::AccountInfo<'a>) -> &mut Self {
self.instruction.admin = Some(admin);
self
}
#[inline(always)]
pub fn admin_permissions(&mut self, admin_permissions: &'b solana_account_info::AccountInfo<'a>) -> &mut Self {
self.instruction.admin_permissions = Some(admin_permissions);
self
}
#[inline(always)]
pub fn instruction_sysvar_account(&mut self, instruction_sysvar_account: &'b solana_account_info::AccountInfo<'a>) -> &mut Self {
self.instruction.instruction_sysvar_account = Some(instruction_sysvar_account);
self
}
#[inline(always)]
pub fn rent(&mut self, rent: &'b solana_account_info::AccountInfo<'a>) -> &mut Self {
self.instruction.rent = Some(rent);
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 user_metadata(&mut self, user_metadata: &'b solana_account_info::AccountInfo<'a>) -> &mut Self {
self.instruction.user_metadata = Some(user_metadata);
self
}
#[inline(always)]
pub fn obligation(&mut self, obligation: &'b solana_account_info::AccountInfo<'a>) -> &mut Self {
self.instruction.obligation = Some(obligation);
self
}
#[inline(always)]
pub fn lending_market(&mut self, lending_market: &'b solana_account_info::AccountInfo<'a>) -> &mut Self {
self.instruction.lending_market = Some(lending_market);
self
}
#[inline(always)]
pub fn lending_market_authority(&mut self, lending_market_authority: &'b solana_account_info::AccountInfo<'a>) -> &mut Self {
self.instruction.lending_market_authority = Some(lending_market_authority);
self
}
#[inline(always)]
pub fn reserve(&mut self, reserve: &'b solana_account_info::AccountInfo<'a>) -> &mut Self {
self.instruction.reserve = Some(reserve);
self
}
#[inline(always)]
pub fn obligation_farm_state(&mut self, obligation_farm_state: &'b solana_account_info::AccountInfo<'a>) -> &mut Self {
self.instruction.obligation_farm_state = Some(obligation_farm_state);
self
}
#[inline(always)]
pub fn reserve_farm_state(&mut self, reserve_farm_state: &'b solana_account_info::AccountInfo<'a>) -> &mut Self {
self.instruction.reserve_farm_state = Some(reserve_farm_state);
self
}
#[inline(always)]
pub fn klend_program(&mut self, klend_program: &'b solana_account_info::AccountInfo<'a>) -> &mut Self {
self.instruction.klend_program = Some(klend_program);
self
}
#[inline(always)]
pub fn farms_program(&mut self, farms_program: &'b solana_account_info::AccountInfo<'a>) -> &mut Self {
self.instruction.farms_program = Some(farms_program);
self
}
#[inline(always)]
pub fn earn_mint(&mut self, earn_mint: &'b solana_account_info::AccountInfo<'a>) -> &mut Self {
self.instruction.earn_mint = Some(earn_mint);
self
}
#[inline(always)]
pub fn controller_token_account(&mut self, controller_token_account: &'b solana_account_info::AccountInfo<'a>) -> &mut Self {
self.instruction.controller_token_account = Some(controller_token_account);
self
}
#[inline(always)]
pub fn user_usdc_account(&mut self, user_usdc_account: &'b solana_account_info::AccountInfo<'a>) -> &mut Self {
self.instruction.user_usdc_account = Some(user_usdc_account);
self
}
#[inline(always)]
pub fn reserve_collateral(&mut self, reserve_collateral: &'b solana_account_info::AccountInfo<'a>) -> &mut Self {
self.instruction.reserve_collateral = Some(reserve_collateral);
self
}
#[inline(always)]
pub fn scope_oracle(&mut self, scope_oracle: &'b solana_account_info::AccountInfo<'a>) -> &mut Self {
self.instruction.scope_oracle = Some(scope_oracle);
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 reserve_liquidity_supply(&mut self, reserve_liquidity_supply: &'b solana_account_info::AccountInfo<'a>) -> &mut Self {
self.instruction.reserve_liquidity_supply = Some(reserve_liquidity_supply);
self
}
#[inline(always)]
pub fn reserve_collateral_mint(&mut self, reserve_collateral_mint: &'b solana_account_info::AccountInfo<'a>) -> &mut Self {
self.instruction.reserve_collateral_mint = Some(reserve_collateral_mint);
self
}
#[inline(always)]
pub fn reserve_destination_deposit_collateral(&mut self, reserve_destination_deposit_collateral: &'b solana_account_info::AccountInfo<'a>) -> &mut Self {
self.instruction.reserve_destination_deposit_collateral = Some(reserve_destination_deposit_collateral);
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 = CreateKaminoUserAccountsCpi {
__program: self.instruction.__program,
main: self.instruction.main.expect("main is not set"),
controller: self.instruction.controller.expect("controller is not set"),
admin: self.instruction.admin.expect("admin is not set"),
admin_permissions: self.instruction.admin_permissions.expect("admin_permissions is not set"),
instruction_sysvar_account: self.instruction.instruction_sysvar_account.expect("instruction_sysvar_account is not set"),
rent: self.instruction.rent.expect("rent is not set"),
system_program: self.instruction.system_program.expect("system_program is not set"),
user_metadata: self.instruction.user_metadata.expect("user_metadata is not set"),
obligation: self.instruction.obligation.expect("obligation is not set"),
lending_market: self.instruction.lending_market.expect("lending_market is not set"),
lending_market_authority: self.instruction.lending_market_authority.expect("lending_market_authority is not set"),
reserve: self.instruction.reserve.expect("reserve is not set"),
obligation_farm_state: self.instruction.obligation_farm_state.expect("obligation_farm_state is not set"),
reserve_farm_state: self.instruction.reserve_farm_state.expect("reserve_farm_state is not set"),
klend_program: self.instruction.klend_program.expect("klend_program is not set"),
farms_program: self.instruction.farms_program.expect("farms_program is not set"),
earn_mint: self.instruction.earn_mint.expect("earn_mint is not set"),
controller_token_account: self.instruction.controller_token_account.expect("controller_token_account is not set"),
user_usdc_account: self.instruction.user_usdc_account.expect("user_usdc_account is not set"),
reserve_collateral: self.instruction.reserve_collateral.expect("reserve_collateral is not set"),
scope_oracle: self.instruction.scope_oracle.expect("scope_oracle is not set"),
token_program: self.instruction.token_program.expect("token_program is not set"),
reserve_liquidity_supply: self.instruction.reserve_liquidity_supply.expect("reserve_liquidity_supply is not set"),
reserve_collateral_mint: self.instruction.reserve_collateral_mint.expect("reserve_collateral_mint is not set"),
reserve_destination_deposit_collateral: self.instruction.reserve_destination_deposit_collateral.expect("reserve_destination_deposit_collateral is not set"),
};
instruction.invoke_signed_with_remaining_accounts(signers_seeds, &self.instruction.__remaining_accounts)
}
}
#[derive(Clone, Debug)]
struct CreateKaminoUserAccountsCpiBuilderInstruction<'a, 'b> {
__program: &'b solana_account_info::AccountInfo<'a>,
main: Option<&'b solana_account_info::AccountInfo<'a>>,
controller: Option<&'b solana_account_info::AccountInfo<'a>>,
admin: Option<&'b solana_account_info::AccountInfo<'a>>,
admin_permissions: Option<&'b solana_account_info::AccountInfo<'a>>,
instruction_sysvar_account: Option<&'b solana_account_info::AccountInfo<'a>>,
rent: Option<&'b solana_account_info::AccountInfo<'a>>,
system_program: Option<&'b solana_account_info::AccountInfo<'a>>,
user_metadata: Option<&'b solana_account_info::AccountInfo<'a>>,
obligation: Option<&'b solana_account_info::AccountInfo<'a>>,
lending_market: Option<&'b solana_account_info::AccountInfo<'a>>,
lending_market_authority: Option<&'b solana_account_info::AccountInfo<'a>>,
reserve: Option<&'b solana_account_info::AccountInfo<'a>>,
obligation_farm_state: Option<&'b solana_account_info::AccountInfo<'a>>,
reserve_farm_state: Option<&'b solana_account_info::AccountInfo<'a>>,
klend_program: Option<&'b solana_account_info::AccountInfo<'a>>,
farms_program: Option<&'b solana_account_info::AccountInfo<'a>>,
earn_mint: Option<&'b solana_account_info::AccountInfo<'a>>,
controller_token_account: Option<&'b solana_account_info::AccountInfo<'a>>,
user_usdc_account: Option<&'b solana_account_info::AccountInfo<'a>>,
reserve_collateral: Option<&'b solana_account_info::AccountInfo<'a>>,
scope_oracle: Option<&'b solana_account_info::AccountInfo<'a>>,
token_program: Option<&'b solana_account_info::AccountInfo<'a>>,
reserve_liquidity_supply: Option<&'b solana_account_info::AccountInfo<'a>>,
reserve_collateral_mint: Option<&'b solana_account_info::AccountInfo<'a>>,
reserve_destination_deposit_collateral: Option<&'b solana_account_info::AccountInfo<'a>>,
__remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>,
}