Impact : In the checkWhitelist modifier instead of doing calculation every time this modifier is executed, its cheaper to make it a constant variable in the storage, and the checkWhitelist only need to call the constant variable.
Impact : In the solidity version 0.8 above there already default check on underflow and overflow, and since https://github.com/code-423n4/2022-02-jpyc/blob/main/contracts/v2/FiatTokenV2.sol#L326 there is already check on amount and balance[from], and check by default on solidity 0.8 above, its cheaper to use unchecked blok for the balance calculation the subtraction and add.
Impact : its cheaper to call decimals, name, and symbol as a constant value, since these variable shouldn't change after deployement. You can do this by hardcoded this value directly in the storage.
GAS :
Title : use constant value.
Impact : In the
checkWhitelist
modifier instead of doing calculation every time this modifier is executed, its cheaper to make it a constant variable in the storage, and thecheckWhitelist
only need to call the constant variable.POC : https://github.com/code-423n4/2022-02-jpyc/blob/main/contracts/v2/FiatTokenV2.sol#L624
2. Title : use unchecked is way cheaper
Impact : In the solidity version 0.8 above there already default check on underflow and overflow, and since
https://github.com/code-423n4/2022-02-jpyc/blob/main/contracts/v2/FiatTokenV2.sol#L326
there is already check on amount and balance[from], and check by default on solidity 0.8 above, its cheaper to use unchecked blok for the balance calculation the subtraction and add.POC : https://github.com/code-423n4/2022-02-jpyc/blob/main/contracts/v2/FiatTokenV2.sol#L326-L327
3. Title : its cheaper to use constant variable
Impact : its cheaper to call decimals, name, and symbol as a constant value, since these variable shouldn't change after deployement. You can do this by hardcoded this value directly in the storage.
POC : https://github.com/code-423n4/2022-02-jpyc/blob/main/contracts/v2/FiatTokenV2.sol#L51