20,000 USDC
View results
Submission Details
Severity: medium

Modifying the value of a variable when the function is protected by view modifier.

Vulnerability Details

In the function _calculateInterest() added the modifer view which means the function can't modify the state of the variable it will be consider as the read-only.But here we modify the state of the interest variable.

Proof

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; //This is wrong to modify the state because the function is view only.
}

Impact

It can produce the compilation errors and also can give the incorrect results which can affect the whole functionality.

Tools Used

Manual checking.

Support

FAQs

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