diff --git a/token-lending/program/src/processor.rs b/token-lending/program/src/processor.rs index bf71614e3ea..f927644f7bf 100644 --- a/token-lending/program/src/processor.rs +++ b/token-lending/program/src/processor.rs @@ -28,6 +28,7 @@ use solana_program::{ use spl_token::solana_program::instruction::AccountMeta; use spl_token::state::{Account, Mint}; use std::convert::TryInto; +use std::result::Result; /// Processes an instruction pub fn process_instruction( @@ -449,6 +450,39 @@ fn process_deposit_reserve_liquidity( let clock = &Clock::from_account_info(next_account_info(account_info_iter)?)?; let token_program_id = next_account_info(account_info_iter)?; + // We don't care about the return value here, so just ignore it. + _process_deposit_reserve_liquidity( + program_id, + liquidity_amount, + source_liquidity_info, + destination_collateral_info, + reserve_info, + reserve_liquidity_supply_info, + reserve_collateral_mint_info, + lending_market_info, + lending_market_authority_info, + user_transfer_authority_info, + clock, + token_program_id, + )?; + Ok(()) +} + +#[allow(clippy::too_many_arguments)] +fn _process_deposit_reserve_liquidity<'a>( + program_id: &Pubkey, + liquidity_amount: u64, + source_liquidity_info: &AccountInfo<'a>, + destination_collateral_info: &AccountInfo<'a>, + reserve_info: &AccountInfo<'a>, + reserve_liquidity_supply_info: &AccountInfo<'a>, + reserve_collateral_mint_info: &AccountInfo<'a>, + lending_market_info: &AccountInfo<'a>, + lending_market_authority_info: &AccountInfo<'a>, + user_transfer_authority_info: &AccountInfo<'a>, + clock: &Clock, + token_program_id: &AccountInfo<'a>, +) -> Result { let lending_market = LendingMarket::unpack(&lending_market_info.data.borrow())?; if lending_market_info.owner != program_id { msg!("Lending market provided is not owned by the lending program"); @@ -526,7 +560,7 @@ fn process_deposit_reserve_liquidity( token_program: token_program_id.clone(), })?; - Ok(()) + Ok(collateral_amount) } fn process_redeem_reserve_collateral( @@ -818,7 +852,37 @@ fn process_deposit_obligation_collateral( let user_transfer_authority_info = next_account_info(account_info_iter)?; let clock = &Clock::from_account_info(next_account_info(account_info_iter)?)?; let token_program_id = next_account_info(account_info_iter)?; + _deposit_obligation_collateral( + program_id, + collateral_amount, + source_collateral_info, + destination_collateral_info, + deposit_reserve_info, + obligation_info, + lending_market_info, + lending_market_authority_info, + obligation_owner_info, + user_transfer_authority_info, + clock, + token_program_id, + ) +} +#[allow(clippy::too_many_arguments)] +fn _deposit_obligation_collateral<'a>( + program_id: &Pubkey, + collateral_amount: u64, + source_collateral_info: &AccountInfo<'a>, + destination_collateral_info: &AccountInfo<'a>, + deposit_reserve_info: &AccountInfo<'a>, + obligation_info: &AccountInfo<'a>, + lending_market_info: &AccountInfo<'a>, + lending_market_authority_info: &AccountInfo<'a>, + obligation_owner_info: &AccountInfo<'a>, + user_transfer_authority_info: &AccountInfo<'a>, + clock: &Clock, + token_program_id: &AccountInfo<'a>, +) -> ProgramResult { let lending_market = LendingMarket::unpack(&lending_market_info.data.borrow())?; if lending_market_info.owner != program_id { msg!("Lending market provided is not owned by the lending program");