Open code423n4 opened 2 years ago
Dravee
Strict inequalities add a check of non equality which costs around 3 gas.
The following should use an inclusive inequality to save gas:
File: RocketJoeStaking.sol 181: function _safeRJoeTransfer(address _to, uint256 _amount) internal { 182: uint256 rJoeBal = rJoe.balanceOf(address(this)); 183: if (_amount > rJoeBal) { //@audit should be >= to save gas 184: rJoe.transfer(_to, rJoeBal); 185: } else { 186: rJoe.transfer(_to, _amount); 187: } 188: }
VS Code
Use >= or <= instead of > and < when possible.
>=
<=
>
<
Handle
Dravee
Vulnerability details
Impact
Strict inequalities add a check of non equality which costs around 3 gas.
Proof of Concept
The following should use an inclusive inequality to save gas:
Tools Used
VS Code
Recommended Mitigation Steps
Use
>=
or<=
instead of>
and<
when possible.