Safety Module Deposits
Last updated
Last updated
Assets deposited into a Safety Module are available to payout handlers for slashing if the Safety Module is triggered (see ). In return, depositors are minted receipt tokens which may be used to earn rewards (see ) and withdraw their assets.
To deposit assets, SafetyModule.depositReserveAssets
or SafetyModule.depositReserveAssetsWithoutTransfer
can be used:
SafetyModule.depositReserveAssets
requires msg.sender
to have approved SafetyModule
to a spend sufficient amount of their SafetyModule.reservePools(reservePoolId).asset
balance.
SafetyModule.depositReserveAssetsWithoutTransfer
requires the SafetyModule.reservePools(reservePoolId).asset
amount being deposited to be transferred to the Safety Module beforehand.
Using the CozyRouter may be preferable in cases where integrators would like to batch several Safety Module 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.depositReserveAssets
:
This method will:
Transfer the underlying reserve assets from the msg.sender
to the Safety Module.
Call SafetyModule.depositReserveAssetsWithoutTransfer.
CozyRouter.depositReserveAssets
requires the depositor to have approved CozyRouter
to a spend sufficient amount of their SafetyModule.reservePools(reservePoolId).asset
balance.
On deposit, high-level the Safety Module does the following:
Check if the Safety Module is PAUSED
. If so, revert.
Check the Safety Module's asset balance to determine if the total deposit amount was transferred to it. If not, revert.
Update the relevant reserve pool's internal accounting.
Mint the receiver_
address deposit receipt tokens.
Emit a Deposited
event.