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

## [G-20] Duplicated require()/if() checks should be refactored to a modifier or function

Summary

[G-20] Duplicated require()/if() checks should be refactored to a modifier or function

to reduce code duplication and improve readability.
• Modifiers can be used to perform additional checks on the function inputs or state before it is executed. By defining a modifier to perform a specific check, we can reuse it across multiple functions that require the same check.
• A function can also be used to perform a specific check and return a boolean value indicating whether the check has passed or failed. This can be useful when the check is more complex and cannot be performed easily in a modifier.

file: /src/Lender.sol
///@audit the if statemet is duplicated on lines 199, 211, 222
183 if (pools[poolId].lender != msg.sender) revert Unauthorized();

https://github.com/Cyfrin/2023-07-beedle/blob/main/src/Lender.sol#L183

Support

FAQs

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