Platform: Code4rena
Start Date: 12/08/2022
Pot Size: $35,000 USDC
Total HM: 10
Participants: 126
Period: 3 days
Judge: Justin Goro
Total Solo HM: 3
Id: 154
League: ETH
Rank: 112/126
Findings: 1
Award: $14.95
🌟 Selected for report: 0
🚀 Solo Findings: 0
🌟 Selected for report: IllIllI
Also found by: 0x040, 0x1f8b, 0xDjango, 0xHarry, 0xLovesleep, 0xNazgul, 0xNineDec, 0xSmartContract, 0xackermann, 0xbepresent, 2997ms, Amithuddar, Aymen0909, Bnke0x0, CRYP70, CertoraInc, Chom, CodingNameKiki, Deivitto, Dravee, ElKu, Fitraldys, Funen, GalloDaSballo, JC, JohnSmith, Junnon, LeoS, Metatron, MiloTruck, Noah3o6, NoamYakov, PaludoX0, RedOneN, Respx, ReyAdmirado, Rohan16, Rolezn, Ruhum, Sm4rty, SooYa, SpaceCake, TomJ, Tomio, Waze, Yiko, __141345__, a12jmx, ajtra, ak1, apostle0x01, asutorufos, bobirichman, brgltd, bulej93, c3phas, cRat1st0s, carlitox477, chrisdior4, csanuragjain, d3e4, defsec, delfin454000, djxploit, durianSausage, ellahi, erictee, fatherOfBlocks, gerdusx, gogo, ignacio, jag, ladboy233, m_Rassska, medikko, mics, natzuu, newfork01, oyc_109, paribus, pfapostol, rbserver, reassor, ret2basic, robee, rokinot, rvierdiiev, sach1r0, saian, sashik_eth, sikorico, simon135
14.9472 USDC - $14.95
Variables that are initialized in constructor and not updated later can be converted to immutable to save gas on storage read
IERC20 public token; string public name; string public symbol; uint256 public decimals = 18;
If a variables is not initialized, it is assumed to contain default values (0, address(0), false), explicitly intialising with default values is not necessary
int128 oldSlopeDelta = 0; int128 newSlopeDelta = 0;
uint256 blockSlope = 0; // dblock/dt
uint256 min = 0;
uint256 min = 0;
uint256 dBlock = 0; uint256 dTime = 0;
uint256 dTime = 0;
uEpoch
is 0Use index value of 1
if (uEpoch == 0) { userPointHistory[_addr][uEpoch + 1] = userOldPoint; }
Custom errors from solidity 0.8.4 are more efficient than revert strings with cheaper deployment and runtime time costs when revert condition is met
Refer: https://blog.soliditylang.org/2021/04/21/custom-errors/](https://blog.soliditylang.org/2021/04/21/custom-errors/
i++
with ++i
Pre-increment saves a small amount of gas than postfix increment because it doesnt have to store the previous value. This can be more significant in loops where this operation is done multiple times.
for (uint256 i = 0; i < 255; i++)
for (uint256 i = 0; i < 128; i++)
for (uint256 i = 0; i < 128; i++)
for (uint256 i = 0; i < 255; i++)
!= 0
instead of > 0
for unsigned integersUnsigned integers will never have value less than 0, so checking != 0 than > 0 costs less gas
require(_value > 0, "Only non zero amount");
require(_value > 0, "Only non zero amount");
L413 require(locked_.amount == 0, "Lock exists"); L418 locked_.amount += int128(int256(_value));
Storage variables that are read multiple times in the same function can be cached and re-used to avoid expensive SLOAD and save gas
penaltyRecipient
in
require(token.transfer(penaltyRecipient, amount), "Transfer failed"); emit CollectPenalty(amount, penaltyRecipient);