20,000 USDC
View results
Submission Details
Severity: medium

Missing return Statement in `_calculateInterest()`

Summary

The smart contract function _calculateInterest() lacks a return statement, preventing it from providing the calculated interest and fees values to the caller.

Vulnerability Details

The vulnerable function _calculateInterest() in the smart contract fails to return the computed interest and fees values, resulting in undefined behavior when accessed externally or by other critical functions within the contract.

Code Snippet

File: Lender.sol
720: function _calculateInterest(
721: Loan memory l
722: ) internal view returns (uint256 interest, uint256 fees) {
723: uint256 timeElapsed = block.timestamp - l.startTimestamp;
724: interest = (l.interestRate * l.debt * timeElapsed) / 10000 / 365 days;
725: fees = (lenderFee * interest) / 10000;
726: interest -= fees;
727: }

Impact

the missing return statement in the _calculateInterest() function can lead to significant complications within the smart contract. The lack of proper return values from this function affects the accurate calculation and handling of interest and fees which are the most important part of the contract.

Tools Used

Manual Review

Recommendations

To rectify the vulnerability, it is recommended to modify the _calculateInterest() function by adding a return statement at the end. This will ensure that the correct interest and fees values are provided to the caller, maintaining the expected behavior of the contract.

Support

FAQs

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