StakedTokens: _withdrawRewards() can early return if accountBalance is zero
Closed this issue · 1 comments
daejunpark commented
In StakedTokens, _withdrawRewards()
can early return if the user has no stake.
The early return can save gas by avoiding unnecessary storage updates and an external function call. Also it can avoid emitting an unnecessary RewardWithdrawn log that could be confusing.
daejunpark commented
A fix suggestion.
Add the following early return:
if (accountBalance == 0) return;
immediately after:
contracts/contracts/tokens/StakedTokens.sol
Line 219 in df7224d