re-al-Foundation / rwa-contracts

0 stars 0 forks source link

[RDR-01C] Ineffectual Usage of Safe Arithmetics #92

Closed chasebrownn closed 5 months ago

chasebrownn commented 5 months ago

RDR-01C: Ineffectual Usage of Safe Arithmetics

Type Severity Location
Language Specific RevenueDistributor.sol:L167, L211

Description:

The linked mathematical operations are guaranteed to be performed safely by surrounding conditionals evaluated in either require checks or if-else constructs.

Example:

uint256 _before = IERC20(_token).balanceOf(address(this));
require(_before >= _amount, "Insufficient balance");

_amountOut = _convertToken(_token, _amount, _target, _data);
require(_amountOut != 0, "insufficient output amount");

uint256 _after = IERC20(_token).balanceOf(address(this));
require(_after == _before - _amount, "invalid input amount");

Recommendation:

Given that safe arithmetics are toggled on by default in pragma versions of 0.8.X, we advise the linked statements to be wrapped in unchecked code blocks thereby optimizing their execution cost.

chasebrownn commented 5 months ago

Acknowledged