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

0 stars 0 forks source link

Pre-calculate values that do not change #240

Closed code423n4 closed 2 years ago

code423n4 commented 3 years ago

Handle

pauliax

Vulnerability details

Impact

payout token exponent in function valueOfToken can be precalculated as this value is constant and does not change:

 value = _amount.mul(10**PAYOUT_TOKEN_DECIMALS).div(10**IERC20Metadata(_principalToken).decimals());

Extract 10**PAYOUT_TOKEN_DECIMALS as a constant.

Same situation here with 232 and 1010:

 uint32 blockTimestamp = uint32(block.timestamp % 2**32);
 sumUSD += uint256(price) * (10**10);