Withdraw Rewards
Withdrawing rewards from a Rewards Manager
To allow depositors to reclaim unutilized incentives, the Rewards Manager supports withdrawals of undripped reward assets. A depositor can withdraw rewards they have previously contributed to a reward pool, provided those rewards have not yet dripped.
Depositors may call RewardsManager.withdrawRewardAssets
directly:
/// @notice Withdraw undripped reward assets.
/// @param rewardPoolId_ The ID of the reward pool to withdraw from.
/// @param rewardAssetAmount_ The amount of reward assets to withdraw.
/// @param receiver_ The address that will receive the withdrawn assets.
function withdrawRewardAssets(
uint16 rewardPoolId_,
uint256 rewardAssetAmount_,
address receiver_
) external;
This method will:
Preview withdrawable rewards: Check the caller’s current withdrawable rewards using
_previewCurrentWithdrawableRewards
.Validate request: Revert if
rewardAssetAmount_
exceeds the caller’s withdrawable rewards.Update accounting: Reduce the caller’s
depositorRewards
balance and the pool’sundrippedRewards
and asset totals.Transfer assets: Send the specified reward assets to the
receiver_
.Emit event: Log the withdrawal in a
Withdrawn
event.
Before withdrawing, users may use previewCurrentWithdrawableRewards
to determine how many rewards a depositor is eligible to withdraw:
/// @notice Preview the current withdrawable rewards for the depositor.
/// @param rewardPoolId_ The ID of the reward pool.
/// @param depositor_ The address of the depositor.
/// @return The depositor's current withdrawable rewards.
function previewCurrentWithdrawableRewards(
uint16 rewardPoolId_,
address depositor_
) external view returns (uint256);
This function accounts for:
Epoch changes: If the depositor’s rewards belong to an expired epoch, withdrawable rewards are set to 0.
Drip updates: If rewards have dripped since the last update, withdrawable rewards are scaled down accordingly.
Stable snapshots: If no drip has occurred since the depositor’s last update, withdrawable rewards remain unchanged.
Last updated