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

0 stars 0 forks source link

Unchecked math operations #252

Closed code423n4 closed 2 years ago

code423n4 commented 3 years ago

Handle

pauliax

Vulnerability details

Impact

The unchecked keyword can be applied in the following lines of code since there are statements before to ensure the arithmetic operations would not cause an integer underflow or overflow:

  return a > b ? a - b : b - a;

By the way, here because Solidity 0.8.9 is used, this desired overflow will fail:

 // subtraction overflow is desired
 uint32 timeElapsed = blockTimestamp - blockTimestampLast;
 // addition overflow is desired
 // counterfactual
 price0Cumulative +=
     uint256(FixedPoint.fraction(reserve1, reserve0)._x) *
     timeElapsed;
SamSteinGG commented 2 years ago

The TWAP oracle module has been completely removed and redesigned from scratch as LBTwap that is subject of the new audit.