Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feisty Opaque Vulture - lastCheckpointTime is updated even when the totalEarningPower is zero and causes reward tokens to be stuck in the contract #86

Open
sherlock-admin2 opened this issue Dec 22, 2024 · 0 comments
Labels
Won't Fix The sponsor confirmed this issue will not be fixed

Comments

@sherlock-admin2
Copy link

Feisty Opaque Vulture

Medium

lastCheckpointTime is updated even when the totalEarningPower is zero and causes reward tokens to be stuck in the contract

Summary

Stakers accumulate rewards monotonically over time. But when the totalEarningPower equals 0, the lastCheckpointTime is updated even though the rewardPerTokenAccumulatedCheckpoint stays the same. Consequently, the total amount of reward tokens that has been sent to the contract cannot be accumulated and will remain in the contract.

Vulnerability Detail

When rewardPerTokenAccumulated() is called but the totalEarningPower equals 0, it is not updated. However, the lastCheckpointTime is updated.

  function _checkpointGlobalReward() internal virtual {
    rewardPerTokenAccumulatedCheckpoint = rewardPerTokenAccumulated();
    lastCheckpointTime = lastTimeRewardDistributed();
  }

As a result, reward tokens will remain in the contract and cannot be accumulated in the future.

Impact

Reward tokens which have not been accumulated will remain in the contract. If noone staked during the whole reward duration, the whole reward amount remains in the contract.

Code Snippet

https://github.com/sherlock-audit/2024-11-tally/blob/b125d1f2b52170a3789b1060a52fc6609e6e2262/staker/src/GovernanceStaker.sol#L439-L441
https://github.com/sherlock-audit/2024-11-tally/blob/b125d1f2b52170a3789b1060a52fc6609e6e2262/staker/src/GovernanceStaker.sol#L304

Tool used

Manual Review

Recommendation

Consider implementing a withdraw functionality so that leftover reward tokens can be withdrawn.

@sherlock-admin3 sherlock-admin3 added the Won't Fix The sponsor confirmed this issue will not be fixed label Jan 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Won't Fix The sponsor confirmed this issue will not be fixed
Projects
None yet
Development

No branches or pull requests

2 participants