20,000 USDC
View results
Submission Details
Severity: medium

Borrower may not be able to refinance loans if the difference between new debt and debtToPay is too small

Summary

Borrower may not be able to refinance loans if the difference between new debt and debtToPay is too small

Vulnerability Details

When borrower refinances loans, if the new debt is larger than debtToPay, protocol will charge a borrower fee and transfer the fee to the fee receiver:

uint256 fee = (borrowerFee * (debt - debtToPay)) / 10000;
IERC20(loan.loanToken).transfer(feeReceiver, fee);

If the difference between new debt and debtToPay is too small, fee will be 0, for example, borrowerFee is 50 and (debt - debtToPay) is 199, then fee is 0 (50 * 199 / 10000).
This is problematic because some tokens do not support transfer if amount is 0, tranaction will revert and borrower cannot refinance.

Impact

Loans cannot be refinanced.

Tools Used

Manual Review

Recommendations

Do not transfer protocol fee is amount is 0.

uint256 fee = (borrowerFee * (debt - debtToPay)) / 10000;
+ if (fee > 0) {
IERC20(loan.loanToken).transfer(feeReceiver, fee);
+ }

Support

FAQs

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

Give us feedback!