Platform: Code4rena
Start Date: 26/05/2022
Pot Size: $75,000 USDT
Total HM: 31
Participants: 71
Period: 7 days
Judge: GalloDaSballo
Total Solo HM: 18
Id: 126
League: ETH
Rank: 68/71
Findings: 1
Award: $52.07
🌟 Selected for report: 0
🚀 Solo Findings: 0
🌟 Selected for report: IllIllI
Also found by: 0x1f8b, 0x29A, 0xKitsune, 0xNazgul, 0xf15ers, 0xkatana, Cityscape, Dravee, ElKu, FSchmoede, Funen, GalloDaSballo, Hawkeye, Kaiziron, MiloTruck, Randyyy, RoiEvenHaim, Ruhum, SecureZeroX, SmartSek, TerrierLover, TomJ, Tomio, WatchPug, Waze, _Adam, asutorufos, c3phas, catchup, cogitoergosumsw, delfin454000, ellahi, fatherOfBlocks, gzeon, hansfriese, horsefacts, jonatascm, minhquanym, oyc_109, pauliax, reassor, robee, sach1r0, saian, sashik_eth, simon135, z3s
52.0655 USDT - $52.07
#1 Default value uint
the default value of uint is 0, so just type to reduce the gas. Use
uint256 public incentiveVeAsset;
instead of
uint256 public incentiveVeAsset = 0;
apply to others
#2 Use != instead of >
for unsigned integer, >0 is less efficient then !=0, so use !=0 instead of >0. do to all line code
#3 Cache array length
caching the array length can reduce gas it caused access to a local variable is more cheap than query storage / calldata / memory in solidity.
#4 Change visibility from public to private
https://github.com/code-423n4/2022-05-vetoken/blob/2d7cd1f6780a9bcc8387dea8fecfbd758462c152/contracts/Booster.sol#L33 change visibility from public to private can save gas. so change these
uint256 public constant maxSupply = 30 * 1000000 * 1e18; //30mil
to
uint256 private constant maxSupply = 30 * 1000000 * 1e18; //30mil
apply to others
#5 Default value of boolean
the default value of boolean is false, so just type to reduce the gas. change this
if (protectedTokens[address(_asset)] == true)
to
if (protectedTokens[address(_asset)])
#6 Caching veAsset
caching veAsset to memory because its call multiple times. it can save gas fee.
IERC20(veAsset).safeApprove(escrow, 0); IERC20(veAsset).safeApprove(escrow, _value);
#7 Pre-Incremet
using pre increment more cheaper than post increment. so, i sugget to change i++ to ++i
#8 Use calldata
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.
#0 - GalloDaSballo
2022-07-18T23:57:47Z
Visibility will not save gas, same for constructor
Rest will save less than 500 gas