Unnecessary Addition In Loop (PrizeDistributionBuffer.sol) #43
Labels
bug
Warden finding
G (Gas Optimization)
sponsor acknowledged
Technically the issue is correct, but we're not going to resolve it for XYZ reasons
Handle
ye0lde
Vulnerability details
Impact
Gas savings and code clarity
Proof of Concept
PrizeDistributionBuffer.sol:
"tiers" are summed within a for loop even when their value is zero.
Since "tiers" is uint32 and can't be below zero this is unnecessary.
https://github.com/pooltogether/v4-core/blob/35b00f710db422a6193131b7dc2de5202dc4677c/contracts/PrizeDistributionBuffer.sol#L209-L215
Tools Used
Visual Studio Code, Remix
Recommended Mitigation Steps
Replace this
https://github.com/pooltogether/v4-core/blob/35b00f710db422a6193131b7dc2de5202dc4677c/contracts/PrizeDistributionBuffer.sol#L209-L215
with this
for (uint256 index = 0; index < tiersLength; index++) {
if (_prizeDistribution.tiers[index] > 0) {
}
The text was updated successfully, but these errors were encountered: