Platform: Code4rena
Start Date: 03/10/2023
Pot Size: $24,500 USDC
Total HM: 6
Participants: 62
Period: 3 days
Judge: LSDan
Total Solo HM: 3
Id: 288
League: ETH
Rank: 20/62
Findings: 1
Award: $92.09
š Selected for report: 0
š Solo Findings: 0
š Selected for report: niser93
Also found by: 0xAnah, JCK, MatricksDeCoder, Polaris_tow, Raihan, SAQ, SY_S, debo, hihen, hunter_w3b, lsaudit, naman1778, pipidu83, shamsulhaq123, tabriz
92.085 USDC - $92.09
Total 12 instances over 3 issueswith 382 gas saved:
ID | Issue | Instances | Gas |
---|---|---|---|
[Gā01] | Use unchecked block for safe subtractions | 4 | 340 |
[Gā02] | Do not cache state variables that are used only once | 2 | 6 |
[Gā03] | Using assembly to check for zero can save gas | 6 | 36 |
unchecked
block for safe subtractionsIf it can be confirmed that the subtraction operation will not overflow, using an unchecked block can save gas.
For example, require(x <= y); z = y - x;
can be optimized to require(x <= y); unchecked { z = y - x; }
.
There are 4 instances:
/// @audit checked on line 50 56: : block.timestamp - time /// @audit checked on line 94 101: : block.timestamp - time /// @audit checked on line 207 213: : block.timestamp - time /// @audit checked on line 237 243: : block.timestamp - time
It's cheaper to access the state variable directly if it is accessed only once. This can save the 3 gas cost of the extra stack allocation.
There are 2 instances:
169: CurveMath.CurveState memory curve = curves_[poolIdx]; 261: CurveMath.CurveState memory curve = curves_[poolIdx];
Using assembly to check for zero can save gas by allowing more direct access to the evm and reducing some of the overhead associated with high-level operations in solidity.
There are 6 instances:
47: if (lastAccrued != 0) { 86: if (lastAccrued != 0) { 114: if (tickTracking.exitTimestamp == 0) { 142: if (tickTracking_[poolIdx][i][numTickTracking - 1].exitTimestamp == 0) { 204: if (lastAccrued != 0) { 233: if (lastAccrued != 0) {
#0 - c4-pre-sort
2023-10-09T17:16:48Z
141345 marked the issue as sufficient quality report
#1 - c4-judge
2023-10-18T23:44:07Z
dmvt marked the issue as grade-a