Safety Module Redemptions / Withdrawals
Depositors are able to redeem deposit receipt tokens / withdraw assets from Safety Modules. Redemptions follow a two-step process in which the redemption is queued and then completed after a delay (see Withdraw Delay). Note: redemptions cannot be queued or completed when the Safety Module is triggered (see Safety Module States).
SafetyModule.redeem
is used to queue a redemption:
When a redemption is queued:
The user's deposit receipt tokens are burned.
The Safety Module's internal accounting for the reserve pool is updated -
SafetyModule.reservePools(reservePoolId_).pendingWithdrawalsAmount
gets incremented.A
Redemption
struct is inserted into the Safety Module'sredemptions
mapping. The redemption has an associatedredemptionId_
determined by a state variableredemptionCounter
which gets incremented by 1 on each new redemption. TheredemptionId_
If the Safety Module is
PAUSED
, the redemption gets immediately completed. Else, aRedemptionPending
event is emitted. This event includes theredemptionId_
necessary to complete the redemption.
Once a redemption is queued, anyone can complete the redemption on behalf of the user. The completion relies on the cached Redemption.receiver
to know where to send the redemption assets. When the redemption is completed:
The queued redemption data is obtained from the mapping,
redemptions[redemptionId_]
. It is then deleted from the mapping to ensure that redemption cannot be completed again.The contract checks that either the Safety Module is
PAUSED
or at leastSafetyModule.delays().withdrawDelay
amount of time has elapsed sinceRedemption.queueTime
.The final redemption assets gets computed, which may have decreased if reserve pool assets were slashed (see Safety Module Slashing).
SafetyModule.assetPool(asset_).amount
,SafetyModule.reservePool(reservePoolId_).pendingWithdrawalsAmount
, andSafetyModule.reservePool(reservePoolId_).depositAmount
are decreased.The final redemption assets are transferred to the receiver.
A
Redemption
event is emitted.
Queued vs final redemption assets
If the reserve pool assets have been slashed since a redemption was queued, the final redemption assets a user receives on completion may be smaller than the queued redemption assets.
All assets in the reserve pool, up to the maxSlashPercentage
, are made available to process payouts for slashes. This includes any pending redemption assets. So, the following scaling factor is retroactively applied to all pending redemptions on completion:
This scaling factor may compound if multiple slashes occur before a pending redemption is completed.
Last updated