Adding unchecked directive can save gas #111
Labels
bug
Something isn't working
G (Gas Optimization)
sponsor confirmed
Sponsor agrees this is a problem and intends to fix it (OK to use w/ "disagree with severity")
Handle
WatchPug
Vulnerability details
For the arithmetic operations that will never over/underflow, using the unchecked directive (Solidity v0.8 has default overflow/underflow checks) can save some gas from the unnecessary internal over/underflow checks.
For example:
https://github.com/pooltogether/v4-periphery/blob/0e94c54774a6fce29daf9cb23353208f80de63eb/contracts/TwabRewards.sol#L153-L153
_numberOfEpochs
is uint8_promotion.tokensPerEpoch
is uint216_numberOfEpochs * _promotion.tokensPerEpoch
will never overflow.The text was updated successfully, but these errors were encountered: