20,000 USDC
View results
Submission Details
Severity: medium

Transaction may revert when a borrower repays a loan

Summary

Transaction may revert when a borrower repays a loan.

Vulnerability Details

When a borrower repys a loan, the interest is calculated.

function _calculateInterest(
Loan memory l
) internal view returns (uint256 interest, uint256 fees) {
uint256 timeElapsed = block.timestamp - l.startTimestamp;
interest = (l.interestRate * l.debt * timeElapsed) / 10000 / 365 days;
fees = (lenderFee * interest) / 10000;
interest -= fees;
}

The protocol interest will be transferred to the fee receicer.

IERC20(loan.loanToken).transferFrom(
msg.sender,
feeReceiver,
protocolInterest
);

If the loan's interest rate is 0, protocol interest will be 0 too, transaction will revert if the loanToken used in the contract is an unconventional token that reverts when attempting to transfer 0 tokens.

Impact

Repay transaction reverts.

Tools Used

Manual Review

Recommendations

If the calculated protocol interest amount is 0, skip transferring protocol interest to the fee receiver.

Support

FAQs

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