If for some reason the current contract reward token balance is lower than the rewards meant to be paid to onBehalf address, then this rewards can never be claimed.
function _claimRewardsOnBehalf(
address onBehalfOf,
address receiver,
bool forceUpdate
) internal {
if (forceUpdate) {
_collectAndUpdateRewards();
}
uint256 balance = balanceOf(onBehalfOf);
uint256 reward = _getClaimableRewards(onBehalfOf, balance, false); // @audit unclaimed + pending rewards
uint256 totBal = REWARD_TOKEN.balanceOf(address(this));
if (reward > totBal) {
reward = totBal; // @audit the idea here is to end up paying current rewards balance if the rewards to pay are greater. However, this also mean that there is still some unclaimed rewards pending to pay in a future. Current code does not take into account this.
}
if (reward > 0) {
_unclaimedRewards[onBehalfOf] = 0; // @audit This lines assumes that reward <= totBal always, something that is not true given previous conditional block
_updateUserSnapshotRewardsPerToken(onBehalfOf);
REWARD_TOKEN.safeTransfer(receiver, reward);
}
}
Lost of expected rewards
function _claimRewardsOnBehalf(
address onBehalfOf,
address receiver,
bool forceUpdate
) internal {
if (forceUpdate) {
_collectAndUpdateRewards();
}
uint256 balance = balanceOf(onBehalfOf);
uint256 reward = _getClaimableRewards(onBehalfOf, balance, false);
uint256 totBal = REWARD_TOKEN.balanceOf(address(this));
+ if (reward == 0) {
+ return;
+ }
if (reward > totBal) {
reward = totBal;
+ _unclaimedRewards[onBehalfOf] -= reward;
- }
+ } else {
+ _unclaimedRewards[onBehalfOf] = 0
+ }
+ _updateUserSnapshotRewardsPerToken(onBehalfOf);
+ REWARD_TOKEN.safeTransfer(receiver, reward);
- if (reward > 0) {
- _unclaimedRewards[onBehalfOf] = 0;
- _updateUserSnapshotRewardsPerToken(onBehalfOf);
- REWARD_TOKEN.safeTransfer(receiver, reward);
- }
}
Other
The text was updated successfully, but these errors were encountered:
All reactions