Open code423n4 opened 2 years ago
0x0x0x
https://github.com/pooltogether/v4-periphery/blob/b520faea26bcf60371012f6cb246aa149abd3c7d/contracts/TwabRewards.sol#L98-L99
Here promotion id calculations are done as follows:
uint256 _nextPromotionId = _latestPromotionId + 1; _latestPromotionId = _nextPromotionId;
This calculation can be done much more efficiently as follows:
uint256 _nextPromotionId = ++_latestPromotionId;
Incrementing is cheaper than applying + 1 and this way less loads are required.
+ 1
It may be more gas efficient but it is also less legible, so for this reason, we won't implement this change.
This is a gas optimization, not a non-critical.
Handle
0x0x0x
Vulnerability details
https://github.com/pooltogether/v4-periphery/blob/b520faea26bcf60371012f6cb246aa149abd3c7d/contracts/TwabRewards.sol#L98-L99
Here promotion id calculations are done as follows:
This calculation can be done much more efficiently as follows:
uint256 _nextPromotionId = ++_latestPromotionId;
Incrementing is cheaper than applying
+ 1
and this way less loads are required.