20,000 USDC
View results
Submission Details
Severity: medium
Valid

Precision loss in `_calculateInterest`

Summary

Risk of rounding down to zero in _calculateInterest

Vulnerability Details

If any of l.interestRate , l.debt , l.debt variables amount is too low, rounding down to zero can happen.

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

Impact

The interest amount for the lender would be zero.

Tools Used

Manual Review

Recommendations

Check if the product of the calculations in _calculateInterest is zero then revert.

Support

FAQs

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