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

Extract common verification into a modifier

Summary

It's convenient to not duplicate code and extract whenever possible such code into a function.

Vulnerability Details

The following code is used multiple times in Lender.sol:

if (pools[poolId].lender != msg.sender) revert Unauthorized();

In such cases, it is recommended to create a modifier that will be verifying that the msg.sender is allowed to use functions addToPool, removeFromPool, updateMaxLoanRatio and updateInterestRate.

It will also save gas by having less code implemented.

Tools Used

None

Recommendations

modifier onlyLender() virtual {
if (pools[poolId].lender != msg.sender) revert Unauthorized();
_;
}

Support

FAQs

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