code-423n4 / 2021-10-pooltogether-findings

0 stars 0 forks source link

unchecked arithmetics #51

Open code423n4 opened 3 years ago

code423n4 commented 3 years ago

Handle

pauliax

Vulnerability details

Impact

You can save some gas by using the 'unchecked' keyword to avoid redundant arithmetic checks when an underflow/overflow cannot happen. For example, here: while (_prizeSplits.length > newPrizeSplitsLength) { uint256 _index = _prizeSplits.length - 1; or here: require(_accountDetails.balance >= _amount, _revertMessage); ... accountDetails.balance = _accountDetails.balance - _amount;

Recommended Mitigation Steps

Consider applying 'unchecked' keyword where overflows/underflows are not possible.

asselstine commented 3 years ago

I fixed it in the two places outlined in the issue.

The issue alludes to there being more, but that kind of hand-waving isn't very helpful. Give us a list to fix! Thank you

https://github.com/pooltogether/v4-core/pull/240

GalloDaSballo commented 3 years ago

Agree with the sponsor, please send links to specific lines That said 2 spots where found and the sponsor has applied the improvement