stakewise/contracts

StakedTokens: _withdrawRewards() can early return if accountBalance is zero

Closed this issue · 1 comments

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.

A fix suggestion.

Add the following early return:

if (accountBalance == 0) return;

immediately after:

uint256 accountBalance = balances[_token][_account];