Platform: Code4rena
Start Date: 27/10/2022
Pot Size: $33,500 USDC
Total HM: 8
Participants: 96
Period: 3 days
Judge: kirk-baird
Total Solo HM: 1
Id: 176
League: ETH
Rank: 85/96
Findings: 1
Award: $11.52
🌟 Selected for report: 0
🚀 Solo Findings: 0
🌟 Selected for report: c3phas
Also found by: 0x1f8b, 0xNazgul, 0xRoxas, 0xSmartContract, 0xbepresent, Amithuddar, Awesome, B2, Bnke0x0, Dravee, KoKo, Mathieu, Picodes, RaymondFam, RedOneN, ReyAdmirado, RockingMiles, Ruhum, SadBase, SooYa, Waze, __141345__, adriro, ajtra, ballx, carlitox477, ch0bu, cylzxje, djxploit, durianSausage, emrekocak, erictee, gogo, halden, horsefacts, imare, indijanc, karanctf, leosathya, lukris02, neko_nyaa, oyc_109, peiw, sakman, shark, skyle, tnevler
11.5153 USDC - $11.52
Variables that are the same value no matter the context can be made constant
to save gas.
minDelegationTime
can be made constant
. If it is not called by other functions (it is constant
now so it won't need to be) it can also be made private
to save more gas.
/contracts/WardenPledge.sol Line(s): 79
79: uint256 public minDelegationTime = 1 weeks;
If a variable is only initialized in the constructor of a function it can be made immutable
to save gas.
Example:
60: IVotingEscrow public votingEscrow;
to
60: IVotingEscrow public immutable votingEscrow;
/contracts/WardenPledge.sol Line(s): 60, 62
60: IVotingEscrow public votingEscrow; 62: IBoostV2 public delegationBoost;
unchecked
when Arithmetic Cnnot Oerflow Saves gasThere are mutliple occurances where arithmetic is performed that cannot overflow / underflow based on a previous require. Adding an unchecked
brace around these occurances will save gas (Solidity will not force an underflow / overflow).
NOTE: Findings show the check before each line that allows the second line to be unchecked
. Only the line following the check should be unchecked (NOT the check itself).
unchecked { //Code }
/contracts/WardenPledge.sol Line(s): 267-268, 383-385, 429/431
267: ewardAmount > pledgeAvailableRewardAmounts[pledgeId]) revert Errors.RewardsBalanceTooLow(); 268: eAvailableRewardAmounts[pledgeId] -= rewardAmount;
383: if(newEndTimestamp != _getRoundedTimestamp(newEndTimestamp) || newEndTimestamp < oldEndTimestamp) revert Errors.InvalidEndTimestamp(); 385: uint256 addedDuration = newEndTimestamp - oldEndTimestamp;
429: if(newRewardPerVote <= oldRewardPerVote) revert Errors.RewardsPerVotesTooLow(); 431: uint256 rewardPerVoteDiff = newRewardPerVote - oldRewardPerVote;
#0 - c4-judge
2022-11-12T00:47:53Z
kirk-baird marked the issue as grade-b