EPOCH_CLIFF and EPOCH_DURATION are used for the same purpose and EPOCH_CLIFF could easily be removed to save gas.
[GAS - 02] InfinityStaker: no need to use SafeERC20
The SafeERC2O library is intended to be used when you don’t know if transfers will revert of return a boolean. In the case of this contract, the token is perfectly known as it’s supposed to be INFINITY_TOKEN, so you don’t need this and can save gas by removing this library.
[GAS - 03] InfinityStaker: useless balance checks
This line is useless as the transferFrom will revert anyway. So you could save gas by removing the require and the external call to balanceOf.
4 gas optimizations issues found.
[GAS - 01]
InfinityToken
:EPOCH_CLIFF
is uselessEPOCH_CLIFF
andEPOCH_DURATION
are used for the same purpose andEPOCH_CLIFF
could easily be removed to save gas.[GAS - 02]
InfinityStaker
: no need to useSafeERC20
The
SafeERC2O
library is intended to be used when you don’t know if transfers will revert of return a boolean. In the case of this contract, the token is perfectly known as it’s supposed to beINFINITY_TOKEN
, so you don’t need this and can save gas by removing this library.https://github.com/code-423n4/2022-06-infinity/blob/765376fa238bbccd8b1e2e12897c91098c7e5ac6/contracts/staking/InfinityStaker.sol#L16 https://github.com/code-423n4/2022-06-infinity/blob/765376fa238bbccd8b1e2e12897c91098c7e5ac6/contracts/staking/InfinityStaker.sol#L74
[GAS - 03]
InfinityStaker
: useless balance checks This line is useless as thetransferFrom
will revert anyway. So you could save gas by removing the require and the external call tobalanceOf
.Why it’d revert: https://github.com/OpenZeppelin/openzeppelin-contracts/blob/83277ff916ac4f58fec072b8f28a252c1245c2f1/contracts/token/ERC20/ERC20.sol#L237
[GAS - 04] Useless
nonReentrant
modifiers https://github.com/code-423n4/2022-06-infinity/blob/765376fa238bbccd8b1e2e12897c91098c7e5ac6/contracts/staking/InfinityStaker.sol#L67Here there is only one external call, which is even not really external as it’s you own token, so the
nonReentrant
modifier is useless.That being say, it’d be a better practice to modify the state after the transfer has been done.