20,000 USDC
View results
Submission Details
Severity: medium

Inadequate Debt Calculation in Lender Smart Contract

Summary

The Lender.sol smart contract contains a vulnerability that leads to an incorrect calculation of the borrowed debt, resulting in borrowers receiving less debt than intended due to the deduction of fees from the loan amount.

Vulnerability Details

In the borrow function of the Lender contract, the calculation of the debt variable, which represents the loan amount to be borrowed, does not account for the deduction of fees before transferring the loan tokens to the borrower. The fees are subtracted from the loan amount after calculating the accrued interest, leading to borrowers receiving less debt than they expect.

The relevant code snippet is as follows:

// calculate the fees
uint256 fees = (debt * borrowerFee) / 10000;
// transfer fees
IERC20(loan.loanToken).transfer(feeReceiver, fees);
// transfer the loan tokens from the pool to the borrower
IERC20(loan.loanToken).transfer(msg.sender, debt - fees);

Impact

The vulnerability allows an borrower to borrow less than the intended loan amount, affecting the usability and functionality of the Lender contract. Borrowers might unknowingly receive reduced funds, potentially leading to incorrect financial decisions or service disruptions.

Tools Used

Manual Review

Recommendations

To address this issue, the debt calculation should deduct the fees before transferring the loan tokens to the borrower.

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.