Sparkn

CodeFox Inc.
DeFiFoundryProxy
15,000 USDC
View results
Submission Details
Severity: low

Duplicated code e.g use modifiers

Summary

There is duplication of code in various functions in ProxyFactory.sol

Vulnerability Details

There are various code parts reused in functions in ProxyFactory.sol that can be put in a modifier

if (saltToCloseTime[salt] == 0) revert ProxyFactory__ContestIsNotRegistered();
// above used in deployProxyAndDistribute(), deployProxyAndDistributeBySignature() and deployProxyAndDistributeByOwner, and
// distributeByOwner
if (saltToCloseTime[salt] > block.timestamp) revert ProxyFactory__ContestIsNotClosed();
// above used in deployProxyAndDistribute(), deployProxyAndDistributeBySignature(),

Above are example snippets reused in functions but can be turned into modifiers and applied to the functions

Impact

above reuse can introduce errors, makes code harder to read and reason, impacts maintainability, readability, cleanliness of code. It is best to ensure reused code parts that enforce certain checks can be in modifier

Tools Used

Manual Analysis

Recommendations

Recommended to create modifiers and apply to functions e.g

modifier onlyRegisteredContest() {
if (saltToCloseTime[salt] == 0) revert ProxyFactory__ContestIsNotRegistered();
_;
}
// apply to appropriate functions e.g
function deployProxyAndDistribute(...) onlyRegisteredContest() ..... {....} //etc

Support

FAQs

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