Platform: Code4rena
Start Date: 02/08/2022
Pot Size: $50,000 USDC
Total HM: 12
Participants: 69
Period: 5 days
Judge: gzeon
Total Solo HM: 5
Id: 150
League: ETH
Rank: 67/69
Findings: 1
Award: $39.03
🌟 Selected for report: 0
🚀 Solo Findings: 0
🌟 Selected for report: Dravee
Also found by: 0x040, 0x1f8b, 0xDjango, 0xNazgul, 0xSmartContract, 0xc0ffEE, Aymen0909, Bnke0x0, Chom, CodingNameKiki, Deivitto, Fitraldys, Funen, IllIllI, JC, JohnSmith, NoamYakov, ReyAdmirado, Rolezn, TomJ, Waze, ajtra, bearonbike, bobirichman, brgltd, c3phas, durianSausage, fatherOfBlocks, gogo, ignacio, jag, joestakey, ladboy233, mics, oyc_109, rbserver, samruna, sikorico, simon135
39.0334 USDC - $39.03
If a variable is not set/initialized, it is assumed to have the default value (0 for uint or int, false for bool, address(0) for address…). Explicitly initializing it with its default value is an anti-pattern and wastes gas.
File: contracts/proxy/MIMOProxy.sol line 132 : for (uint256 i = 0; i < targets.length; i++)
Prefix increments are cheaper than postfix increments, It saves 5 gas per iteration
File: contracts/proxy/MIMOProxy.sol line 132 : for (uint256 i = 0; i < targets.length; i++)
File: contracts/proxy/MIMOProxy.sol line 132 : for (uint256 i = 0; i < targets.length; i++)
The default “checked” behavior costs more gas when adding/diving/multiplying, because under-the-hood those checks are implemented as a series of opcodes that, prior to performing the actual arithmetic, check for under/overflow and revert if it is detected.
if it can statically be determined there is no possible way for your arithmetic to under/overflow (such as a condition in an if statement), surrounding the arithmetic in an unchecked block will save gas
Instances includes :
File: contracts/actions/automated/MIMOAutoAction.sol line 101 : uint256 vaultVariation = (rebalanceValue - swapResultValue).wadDiv(rebalanceValue); // because of the condition line 97 , the underflow check is unnecessary File: contracts/actions/managed/MIMOManagedAction.sol line 124 : uint256 vaultVariation = (rebalanceValue - swapResultValue).wadDiv(rebalanceValue); // because of the condition line 120 , the underflow check is unnecessary File: contracts/actions/MIMOLeverage.sol line 133 : token.safeIncreaseAllowance(address(core), collateralBalanceAfter - flashloanRepayAmount); line 134 : core.deposit(address(token), collateralBalanceAfter - flashloanRepayAmount); // because of the condition line 132 & line 130 , the underflow check is unnecessary
Place the arithmetic operations in an unchecked block
#0 - gzeoneth
2022-08-21T16:13:56Z