Gas: Optimize Conditional Statements in IndexTemplate.sol:deposit()
#300
Labels
bug
Something isn't working
G (Gas Optimization)
resolved
Finding has been patched by sponsor (sponsor pls link to PR containing fix)
sponsor confirmed
Sponsor agrees this is a problem and intends to fix it (OK to use w/ "disagree with severity")
Handle
Dravee
Vulnerability details
Impact
It's possible to save gas by optimizing the checks in conditional statements (
if
,else if
andelse
). This would save a few opcodes and avoid redundant checks.Proof of Concept
In
IndexTemplate.sol:deposit()
, the code is as follows:The conditions checks can be optimized with the following (read the
@audit-info
comments for further information):Tools Used
VS Code
Recommended Mitigation Steps
Compact conditions in mentioned logic statements
The text was updated successfully, but these errors were encountered: