Deposit Rewards

To incentivize stakers, users can deposit rewards into a Rewards Manager.

Depositors receive receipt tokens, which can be exchanged for undripped rewards (see Redeem Undripped Rewards), not dripped rewards.

To deposit reward assets, RewardsManager.depositRewardAssets or RewardsManager.depositRewardAssetsWithoutTransfer can be used:

/// @notice Deposit `rewardAssetAmount_` assets into the `rewardPoolId_` reward pool on behalf of `from_` and mint
/// `depositReceiptTokenAmount_` tokens to `receiver_`.
/// @dev Assumes that `from_` has approved the rewards manager to spend `rewardAssetAmount_` of the reward pool's
/// asset.
/// @param rewardPoolId_ The ID of the reward pool.
/// @param rewardAssetAmount_ The amount of the reward pool's asset to deposit.
/// @param receiver_ The address to mint the deposit receipt tokens to.
/// @param from_ The address to pull the reward pool's asset from.
/// @return depositReceiptTokenAmount_ The amount of deposit receipt tokens minted.
function depositRewardAssets(uint16 rewardPoolId_, uint256 rewardAssetAmount_, address receiver_, address from_)
    external returns (uint256 depositReceiptTokenAmount_);
    
/// @notice Deposit `rewardAssetAmount_` assets into the `rewardPoolId_` reward pool and mint
/// `depositReceiptTokenAmount_` tokens to `receiver_`.
/// @dev Assumes that the user has already transferred `rewardAssetAmount_` of the reward pool's asset to the rewards
/// manager.
/// @param rewardPoolId_ The ID of the reward pool.
/// @param rewardAssetAmount_ The amount of the reward pool's asset to deposit.
/// @param receiver_ The address to mint the deposit receipt tokens to.
/// @return depositReceiptTokenAmount_ The amount of deposit receipt tokens minted.
function depositRewardAssetsWithoutTransfer(uint16 rewardPoolId_, uint256 rewardAssetAmount_, address receiver_)
    external returns (uint256 depositReceiptTokenAmount_);

RewardsManager.depositRewardAssets requires the depositor to have approved RewardsManager to a spend sufficient amount of their RewardsManager.rewardPools(rewardPoolId).asset balance.

RewardsManager.depositRewardAssetsWithoutTransfer requires the RewardsManager.rewardPools(rewardPoolId).asset amount being deposited to be transferred to the Rewards Manager beforehand.

Using CozyRouter to deposit assets

Using the CozyRouter may be preferable in cases where integrators would like to batch several Safety Module / Rewards Manager related function calls into a single transaction (e.g. wrap ETH to WETH and deposit).

To deposit assets using the CozyRouter, integrators can use CozyRouter.depositRewardAssets:

function depositRewardAssets(
    IRewardsManager rewardsManager_,
    uint16 rewardPoolId_,
    uint256 rewardAssetAmount_,
    address receiver_
) external payable returns (uint256 depositReceiptTokenAmount_);

This method will:

  • Transfer the underlying reward assets from the msg.sender to the Rewards Manager.

  • Call RewardsManager.depositRewardAssetsWithoutTransfer.

Prior to calling this function, the user must have approved CozyRouter to a spend sufficient amount of their RewardsManager.rewardPools(rewardId).asset balance.

Deposit mechanics

RewardsManager.depositRewardAssetsWithoutTransfer assumes that the assets to be deposited has already been transferred to the Rewards Manager. Any excess assets transferred will be kept by the Rewards Manager.

On deposit, high-level the Rewards Manager does the following:

  • Check if the Rewards Manager is PAUSED. If so, revert.

  • Check the Rewards Manager's asset balance to determine if the total deposit amount was transferred. If not, revert.

  • Update the relevant reward pool's internal rewardPool.undrippedRewards value.

  • Mint the receiver_ address deposit receipt tokens.

  • Emit a Deposited event.

Last updated