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

Wrong calculation of `interest` in `_calculateInterest()`

Summary

Irrelevant values are used in the calculation of interest leading to wrong values being derived.

Vulnerability Details

In Structs.sol according to the comment, loan.interest is the interest rate of the loan per second (in debt tokens). Note the word second

File:Structs.sol
uint256 collateral;
/// @notice the interest rate of the loan per second (in debt tokens)
uint256 interestRate;

In _calculateInterest() interest is gotten by multiplying the interest rate, the debt and the time elapsed then dividing by 10000 and further division by 365.
The issue here results in the fact that the interest rate is supplied in terms of loan per second
so there is no need for further division by 365 days as the interest rate multiplied by the debt and time elapsed divided by 10000 is enough.

File:Lender.sol
interest = (l.interestRate * l.debt * timeElapsed) / 10000 / 365 days;

Impact

Wrong values for interest will be calculated and used throughout the protocol resulting in loss of funds.

Tools Used

Manual Review

Recommendations

Calculations for the interest should be reevaluated and adjusted to fit the interestRate in per seconds.

Support

FAQs

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