code-423n4 / 2021-12-vader-findings

0 stars 0 forks source link

Save gas with the unchecked keyword #81

Closed code423n4 closed 2 years ago

code423n4 commented 2 years ago

Handle

Jujic

Vulnerability details

Impact

Using the unchecked keyword to avoid redundant arithmetic underflow/overflow checks to save gas when an underflow/overflow cannot happen.

Proof of Concept

https://github.com/code-423n4/2021-12-vader/blob/00ed84015d4116da2f9db0c68db6742c89e73f65/contracts/tokens/USDV.sol#L79

cycleTimestamp = block.timestamp + 24 hours;

Tools Used

Remix

Recommended Mitigation Steps

Consider using 'unchecked' where it is safe to do so.

unchecked {
         cycleTimestamp = block.timestamp + 24 hours;
 }
jack-the-pug commented 2 years ago

Dup #130