20,000 USDC
View results
Submission Details
Severity: medium

Multiplication before Division

Summary

Despite the solidity version having safe-math in-built it is still a good practice to divide before you multiply in your business logic to avoid potential integer overflow/underflow bugs in the interest rate calculations.

Vulnerability Details

This funtion has potential overflow/underflow vulnerabilities

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

Impact

Loss of funds and unexpected behavior

Tools Used

Manual review

Recommendations

Always divide before you multiply in your business logic.

Support

FAQs

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

Give us feedback!