Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Liquidation protocol fee #71

Closed
wants to merge 22 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
account checks
  • Loading branch information
ra authored and nope-finance committed Feb 17, 2022
commit d657f7dac17a593c13b7dc6b857d6dceb80723b3
9 changes: 8 additions & 1 deletion token-lending/program/src/processor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2084,6 +2084,10 @@ fn process_claim_protocol_fees(program_id: &Pubkey, accounts: &[AccountInfo]) ->
}

let lending_market = LendingMarket::unpack(&lending_market_info.data.borrow())?;
if &lending_market.token_program_id != token_program_id.key {
msg!("Lending market token program does not match the token program provided");
return Err(LendingError::InvalidTokenProgram.into());
}
if lending_market_info.owner != program_id {
msg!(
"Lending market provided is not owned by the lending program {} != {}",
Expand Down Expand Up @@ -2114,7 +2118,10 @@ fn process_claim_protocol_fees(program_id: &Pubkey, accounts: &[AccountInfo]) ->
return Err(LendingError::InvalidMarketAuthority.into());
}

// TODO - add checks for the reserve liquidity supply, fee receiver, and token program
if &reserve.config.fee_receiver != reserve_liquidity_fee_receiver_info.key {
msg!("Reserve liquidity fee receiver does not match the reserve liquidity fee receiver provided");
return Err(LendingError::InvalidAccountInput.into());
}

// transfer accumulated fees to fee receiver
let amount_to_transfer = reserve
Expand Down