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

Allow rewards to be batch claimed onBehalf #65

Open
jcmonte opened this issue Feb 23, 2022 · 0 comments
Open

Allow rewards to be batch claimed onBehalf #65

jcmonte opened this issue Feb 23, 2022 · 0 comments
Assignees
Labels
architecture Larger restructuring required, consideration needed core dev enhancement New feature or request smart-contract StakingRewards.sol

Comments

@jcmonte
Copy link
Contributor

jcmonte commented Feb 23, 2022

Auditor Recommendation

It is regarded as best practice to allow keeper bots to claim rewards on users' behalf. This will allow users to receive their rewards even when they are inactive for a short period. This could be achieved by adding
a function similar to the following to the StakingRewards contract:

function getRewardOnBehalf(address[] stakers) external returns (bool) {
    for (uint i; i < stakers.length; i++) {
        _updateRewards(stakers[i]);
        uint256 reward = rewards[stakers[i]];
        if (reward > 0) {
      rewards[stakers[i]] = 0;
      // Send the rewards to Escrow for 1 year
      stakingToken.transfer(address(rewardEscrow), reward);
      rewardEscrow.appendVestingEntry(stakers[i], reward, 52 weeks);
      emit RewardPaid(stakers[i], reward);
    }
}

By allowing a keeper bot to claim multiple users' rewards in a single transaction, the overall gas cost can be decreased to the gas refunds given for reaccessing storage slots.

@jcmonte jcmonte added enhancement New feature or request StakingRewards.sol labels Feb 23, 2022
@jcmonte jcmonte changed the title Allow rewards to be passively claimed by anyone Allow rewards to be batch claimed onBehalf Feb 23, 2022
@jcmonte jcmonte added the architecture Larger restructuring required, consideration needed label Feb 23, 2022
@jcmonte jcmonte self-assigned this Mar 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
architecture Larger restructuring required, consideration needed core dev enhancement New feature or request smart-contract StakingRewards.sol
Projects
None yet
Development

No branches or pull requests

2 participants