Open code423n4 opened 2 years ago
Jujic
The rJoe variable can be cached to slightly reduce gas usage
rJoe
https://github.com/code-423n4/2022-01-trader-joe/blob/a1579f6453bc4bf9fb0db9c627beaa41135438ed/contracts/RocketJoeStaking.sol#L181-L188
function _safeRJoeTransfer(address _to, uint256 _amount) internal { uint256 rJoeBal = rJoe.balanceOf(address(this)); if (_amount > rJoeBal) { rJoe.transfer(_to, rJoeBal); } else { rJoe.transfer(_to, _amount); } }
Remix
Consider caching those variable for read and make sure write back to storage
Handle
Jujic
Vulnerability details
Impact
The
rJoe
variable can be cached to slightly reduce gas usageProof of Concept
https://github.com/code-423n4/2022-01-trader-joe/blob/a1579f6453bc4bf9fb0db9c627beaa41135438ed/contracts/RocketJoeStaking.sol#L181-L188
Tools Used
Remix
Recommended Mitigation Steps
Consider caching those variable for read and make sure write back to storage