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

Repetitive checks should be used as modifiers instead

Summary

The following check - if (pools[poolId].lender != msg.sender) revert Unauthorized(); is observed 4 times in Lender.sol

Vulnerability Details

The check if (pools[poolId].lender != msg.sender) revert Unauthorized(); occurs 4 times in Lender.sol. This check is implemented in Lender.addToPool(); Lender.removeFromPool() ; Lender.updateMaxLoanRatio(); and Lender.updateInterestRate();

Tools Used

Manual Review

Recommendations

Consider creating a modifier onlyLender that implements this check and attach it to the above mentioned functions.
The modifier can look like this :
modifier onlyLender() {
if (pools[poolId].lender != msg.sender) revert Unauthorized();
_;
}

Support

FAQs

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