Skip to content
This repository has been archived by the owner on Dec 20, 2024. It is now read-only.

_requestedTip is not deduced from depositor rewards as intended #33

Open
CergyK opened this issue Dec 6, 2024 · 2 comments
Open

_requestedTip is not deduced from depositor rewards as intended #33

CergyK opened this issue Dec 6, 2024 · 2 comments
Labels
High A High severity issue.

Comments

@CergyK
Copy link
Collaborator

CergyK commented Dec 6, 2024

Description

GovernanceStaker introduces the concept of bumping earning power to control the amount of rewards claimable by depositors who delegate to inactive delegatees.

The bumpEarningPower function enables keepers to update earningPower on behalf of depositors, and take a fee to do so.

GovernanceStaker.sol#L508:

    // Send tip to the receiver
    SafeERC20.safeTransfer(REWARD_TOKEN, _tipReceiver, _requestedTip);

Some checks are done to ensure that depositor has enough rewards so that the _requestedTip can be covered out of the rewards.

GovernanceStaker.sol#L489-L497:

    if (_newEarningPower > deposit.earningPower && _unclaimedRewards < _requestedTip) {
      revert GovernanceStaker__InsufficientUnclaimedRewards();
    }


    // Note: underflow causes a revert if the requested  tip is more than unclaimed rewards
    if (_newEarningPower < deposit.earningPower && (_unclaimedRewards - _requestedTip) < maxBumpTip)
    {
      revert GovernanceStaker__InsufficientUnclaimedRewards();
    }

Unfortunately, the requested tip is never deducted from the depositor rewards. Which means that the accounting is incorrect, and some legitimate participants would not be able to claim their rewards.

Impact

Rewards are denied to legitimate participants (rewards insolvency)

Recommendation

Consider subtracting the tip from the depositor rewards:

GovernanceStaker.sol#L508:

    // Send tip to the receiver
    SafeERC20.safeTransfer(REWARD_TOKEN, _tipReceiver, _requestedTip);
+   deposit.scaledUnclaimedRewardCheckpoint =
+      deposit.scaledUnclaimedRewardCheckpoint - (_requestedTip * SCALE_FACTOR);
@alexkeating
Copy link

Will fix

@CergyK
Copy link
Collaborator Author

CergyK commented Dec 16, 2024

Fixed by withtally/staker#87

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
High A High severity issue.
Projects
None yet
Development

No branches or pull requests

2 participants