Safety Module Redemptions / Withdrawals
Last updated
Last updated
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 ). Note: redemptions cannot be queued or completed when the Safety Module is triggered (see ).
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's redemptions
mapping. The redemption has an associated redemptionId_
determined by a state variable redemptionCounter
which gets incremented by 1 on each new redemption. The redemptionId_
If the Safety Module is PAUSED
, the redemption gets immediately completed. Else, a RedemptionPending
event is emitted. This event includes the redemptionId_
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 least SafetyModule.delays().withdrawDelay
amount of time has elapsed since Redemption.queueTime
.
SafetyModule.assetPool(asset_).amount
, SafetyModule.reservePool(reservePoolId_).pendingWithdrawalsAmount
, and SafetyModule.reservePool(reservePoolId_).depositAmount
are decreased.
The final redemption assets are transferred to the receiver.
A Redemption
event is emitted.
This scaling factor may compound if multiple slashes occur before a pending redemption is completed.
The final redemption assets gets computed, which may have decreased if reserve pool assets were slashed (see ).
If the reserve pool assets have been 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 , 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: