code-423n4 / 2022-02-jpyc-findings

1 stars 0 forks source link

Gas Optimizations #60

Open code423n4 opened 2 years ago

code423n4 commented 2 years ago

Use of Constants Improves Readability and Gas Performance

In the checkWhitelist function of the FiatTokenV2.sol file, the following function can be found:

    modifier checkWhitelist(address _account, uint256 _value) {
        if (_value > 100000 * 10 ** 18) {//@audit Gas Optimization This should be moved to constant or 1e18
            require(
                whitelisted[_account],
                "Whitelistable: account is not whitelisted"
            );
        }
        _;
    }

Inside the if statement we have two things: a constant 100000 which is unexplained, and a 10**18 expression. Moving the 10**18 function to 1e18 or a constant would save on gas and be more readable.

Additionally, the use of 10000 instead of a constant like WHITELIST_LOWERBOUND or a similar constant would be more readable.