20,000 USDC
View results
Submission Details
Severity: medium

Borrower may not able to repay loan if interest rate is 0

Summary

Borrower may not able to repay loan if interest rate is 0.

Vulnerability Details

When borrower repays a loan, protocol fee will be transferred to the fee receiver:

// transfer the protocol fee to the fee receiver
IERC20(loan.loanToken).transferFrom(
msg.sender,
feeReceiver,
protocolInterest
);

The protocol fee is a portion of loan interest fee and is calculated in _calculateInterest(…) function:

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;
}

If no interest rate is set by lender, there will be no protocol fee either, then 0 amount of loan tokens will be tranferred to the fee receiver. However, Some tokens do not support transfer if amount is 0, tranaction will revert and borrower cannot repay.

Impact

Loan cannot be repaied.

Tools Used

Mannual Review

Recommendations

Do not transfer protocol fee is amount is 0.

+ if (protocolInterest > 0) {
// transfer the protocol fee to the fee receiver
IERC20(loan.loanToken).transferFrom(
msg.sender,
feeReceiver,
protocolInterest
);
+ }

Support

FAQs

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

Give us feedback!