code-423n4 / 2021-11-vader-findings

0 stars 0 forks source link

Avoid unnecessary storage read can save gas #201

Closed code423n4 closed 2 years ago

code423n4 commented 2 years ago

Handle

WatchPug

Vulnerability details

https://github.com/code-423n4/2021-11-vader/blob/429970427b4dc65e37808d7116b9de27e395ce0c/contracts/staking-rewards/StakingRewards.sol#L162-L162

IERC20(tokenAddress).safeTransfer(owner, tokenAmount);

The recoverERC20() function is onlyOwner, therefore, at L162, owner can be change to msg.sender directly to avoid unnecessary storage read of owner to save some gas.

Recommendation

Change to:

IERC20(tokenAddress).safeTransfer(msg.sender, tokenAmount);