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

Use modifier `isPoolLender` instead of repeating the same code block

Summary

There are several places where the same code block is repeated. These can be replaced with a modifier.

  • https://github.com/Cyfrin/2023-07-beedle/blob/658e046bda8b010a5b82d2d85e824f3823602d27/src/Lender.sol#L183C9-L183C71

  • https://github.com/Cyfrin/2023-07-beedle/blob/658e046bda8b010a5b82d2d85e824f3823602d27/src/Lender.sol#L199

  • https://github.com/Cyfrin/2023-07-beedle/blob/658e046bda8b010a5b82d2d85e824f3823602d27/src/Lender.sol#L211

  • https://github.com/Cyfrin/2023-07-beedle/blob/658e046bda8b010a5b82d2d85e824f3823602d27/src/Lender.sol#L222

Impact

redundant code. Effects readability.

Tools Used

manual code review

Recommendations

add isPoolLender modifier in Lender.sol

modifier isPoolLender(bytes32 _poolId) {
if (pools[_poolId].lender != msg.sender) revert Unauthorized();
_;
}

Support

FAQs

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