20,000 USDC
View results
Submission Details
Severity: medium

Potential loss of precision due to incorrect ordering of multiplication and division.

Summary

The audit identified a potential loss of precision in the Lender._calculateInterest(Loan) function. To address this, the report recommends reordering the operations to perform multiplication before division. Thorough testing is advised to ensure accuracy.

Vulnerability Details

Lender._calculateInterest(Loan) function in Lender.sol (lines 720-727) performs a multiplication on the result of a division:

interest = (l.interestRate * l.debt * timeElapsed) / 10000 / 31536000 (2023-07-beedle/src/Lender.sol#724) - fees = (lenderFee * interest) / 10000

which could lead to a loss of precision due to Solidity's integer division behavior.

Impact

Potential loss of precision due to incorrect ordering of multiplication and division.

Tools Used

Slither

Recommendations

Consider ordering multiplication before division.

Support

FAQs

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