Claim Rewards
To claim rewards, a staker can call RewardsManager.claimRewards
// Used to track which reward pool to claim from and whether to drip from the reward pool.
struct ClaimRewardsPoolData {
uint16 rewardPoolId;
bool drip;
}
/// @notice Claim rewards for a specific stake pool and all reward pools and transfer rewards to `receiver_`.
/// @dev Note that this function drips all reward pools. If you want to claim without dripping from specific reward
/// pools, you can use one of the claimRewards functions that accepts `ClaimRewardsPoolData[] calldata
/// claimRewardsPoolData_` as an arg.
/// @param stakePoolId_ The ID of the stake pool to claim rewards for.
/// @param receiver_ The address to transfer the claimed rewards to.
function claimRewards(uint16 stakePoolId_, address receiver_) external {}
/// @notice Claim rewards for a set of stake pools and all reward pools and transfer rewards to `receiver_`.
/// @dev Note that this function drips all reward pools. If you want to claim without dripping from specific reward
/// pools, you can use one of the claimRewards functions that accepts `ClaimRewardsPoolData[] calldata
/// claimRewardsPoolData_` as an arg.
/// @param stakePoolIds_ The IDs of the stake pools to claim rewards for.
/// @param receiver_ The address to transfer the claimed rewards to.
function claimRewards(uint16[] calldata stakePoolIds_, address receiver_) external {}
/// @notice Claim rewards for a specific stake pool and set of reward pools and transfer rewards to `receiver_`.
/// @dev Note that this function only drips and claims rewards for the reward pools specified in
/// `claimRewardsPoolData_`. If a reward pool is omitted from `claimRewardsPoolData_`, then no rewards will be dripped
/// or claimed for that reward pool. If drip is false, then no rewards will be dripped for that reward pool, but
/// rewards will still be claimed.
/// @dev The `claimRewardsPoolData_` must contain only valid reward pool IDs and no duplicates.
/// @param stakePoolId_ The ID of the stake pool to claim rewards for.
/// @param claimRewardsPoolData_ The reward pool IDs and whether to drip or not.
/// @param receiver_ The address to transfer the claimed rewards to.
function claimRewards(uint16 stakePoolId_, ClaimRewardsPoolData[] calldata claimRewardsPoolData_, address receiver_) external {}
/// @notice Claim rewards for a specific set of stake pools and set of reward pools and transfer rewards to
/// `receiver_`.
/// @dev Note that this function only drips and claims rewards for the reward pools specified in
/// `claimRewardsPoolData_`. If a reward pool is omitted from `claimRewardsPoolData_`, then no rewards will be dripped
/// or claimed for that reward pool. If drip is false, then no rewards will be dripped for that reward pool, but
/// rewards will still be claimed.
/// @dev The `claimRewardsPoolData_` must contain only valid reward pool IDs and no duplicates.
/// @param stakePoolIds_ The IDs of the stake pools to claim rewards for.
/// @param claimRewardsPoolData_ The reward pool IDs and whether to drip or not.
/// @param receiver_ The address to transfer the claimed rewards to.
function claimRewards(
uint16[] calldata stakePoolIds_,
ClaimRewardsPoolData[] calldata claimRewardsPoolData_,
address receiver_
) external {}There are 4 variations of the function that allow you to specify which stake pools you want to claim rewards for and which reward pools you want to drip and claim from. Accrued rewards are sent to the receiver_ address.
Claim rewards mechanics
On claiming rewards, we follow the following steps for each reward pool:
Drip from the reward pool since time may have passed since the last drip.
Compute and update the
ClaimableRewardsDatafor the (stake pool, reward pool) pair.Update the
UserRewardsDatafor the (stake pool, reward pool) pair.Transfer the user's
accruedRewardsfrom the reward pool to thereceiver_.Reset
accruedRewardsto 0.Emit a
ClaimedRewardsevent.
To claim rewards on behalf of another user, you may use RewardsManager.claimRewardsBySig
The owner must sign a digest that matches the above.
Fetch Domain Separator via external
domainSeparator()getter and nonce via externaleip712Nonces(owner, actionKey)(actionKey is the relevant typehash) getter. Both are exposed in IRewardsManager.The above
claimRewardsBySigfunction is truncated to only show the relevant structure of the digest.hashStakePoolIdsis a public exposed function that encodes each stakePoolId as a 32-byte word before hashing to satisfy EIP-712 array semantics.
To specify which reward pools to drip and claim from, you can use a similar claimRewardsBySig function with a slightly different set of typehashes and an additional claimRewardsPoolData_ arg in the signature. Its important that the signature has structured the data correctly before hashing to satisfy EIP-712 semantics. hashStakePoolIds and hashClaimRewardsPoolData are public exposed functions on IRewardsManager that can help you construct this part of the signature.
Last updated