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: 40/69
Findings: 2
Award: $107.00
🌟 Selected for report: 0
🚀 Solo Findings: 0
🌟 Selected for report: IllIllI
Also found by: 0x1f8b, 0xDjango, 0xNazgul, 0xc0ffEE, 8olidity, Bnke0x0, Chom, CodingNameKiki, Deivitto, Dravee, Funen, JC, JohnSmith, NoamYakov, ReyAdmirado, Rohan16, Rolezn, Sm4rty, SooYa, TomFrenchBlockchain, TomJ, Waze, __141345__, ajtra, ak1, aysha, bin2chen, bobirichman, brgltd, bulej93, c3phas, delfin454000, durianSausage, erictee, fatherOfBlocks, gogo, horsefacts, hyh, ladboy233, mics, natzuu, nxrblsrpr, oyc_109, rbserver, samruna, sikorico, simon135, tofunmi, wagmi
67.7324 USDC - $67.73
#1 Typo
typo can misleading the users. to increase readibility i suggest to fix the typo
"FlashloanDat data and struc" to "FlashloanData data and struct" "VaultState struct og the vault to rebalance" to "VaultState struct of the vault to rebalance"
#2 Missing natspec comment
A function has a natspec comment to explain utility about function or parameter but natspec comment vaultId is missing. So i suggest to add natspec comment for parameter vaultId.
#3 Missing indexed field
Each event should use three indexed fields if there are three or more fields. add indexed in proxy.
#4 factory must be immutable
the state factory can't be initialize by constructor. the constructor parameter mention state factory to initialize. so i suggest to add immutable on factory.
🌟 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.2722 USDC - $39.27
#1 Use storage instead memory
Use storage instead of memory to reduce the gas fee. i suggest to change this.
#2 Use calldata instead memory
In the external functions where the function argument is read-only, the function() has an inputed parameter that using memory, if this function didnt change the parameter, its cheaper to use calldata then memory. so we suggest to change it.
#3 Cache the target.code.length
cache the target.code.length to the local too for saving the gas fee. because mload is cheaper than sload.
#4 Cache response.length
cache the response.length to the local too for saving the gas fee. because mload is cheaper than sload.
#5 Use !=0 instead >0
for unsigned integer, >0 is less efficient then !=0, so use !=0 instead of >0. apply to others.
#6 Looping
default uint is 0 so remove unnecassary explicit can reduce gas. caching the array length can reduce gas it caused access to a local variable is more cheap than query storage / calldata / memory in solidity. pre increment e.g ++i more cheaper gas than post increment e.g i++. i suggest to use pre increment.
#7 Visibility
change visibility from public to private or internal can save gas. so i recommend to change it.