Define Safety Module Configuration
Configuration for a Safety Module consists of ReservePoolConfig[]
, ControllerConfig[]
, and DelaysConfig
. These configs are passed to CozySafetyModuleManager.createSafetyModule
to deploy a new Safety Module.
/// @notice Parameters for configuration updates.
struct ConfigUpdateCalldataParams {
// The new reserve pool configs.
ReservePoolConfig[] reservePoolConfigs;
// The new controller configs.
ControllerConfig[] controllerConfigUpdates;
// The new delays config.
Delays delaysConfig;
}
/// @notice Deploys a new SafetyModule with the provided parameters.
/// @param owner_ The owner of the SafetyModule.
/// @param pauser_ The pauser of the SafetyModule.
/// @param configs_ The configuration for the SafetyModule.
/// @param salt_ Used to compute the resulting address of the SafetyModule.
function createSafetyModule(
address owner_,
address pauser_,
ConfigUpdateCalldataParams calldata configs_,
bytes32 salt_
) external returns (ISafetyModule safetyModule_);
Reserve Pool Config
struct ReservePoolConfig {
// The underlying asset of the reserve pool.
IERC20 asset;
}
Note: The order of the reserve pool configs in the ReservePoolConfig[]
array passed to CozySafetyModuleManager.createSafetyModule
are used to determine the resulting reserve pool IDs in the deployed Safety Module.
Reserve Pool Assets
Each reserve pool must have an underlying asset. Assets used by the Safety Module must follow the Token Integration Guidelines to avoid any unexpected behavior.
Controller Config
struct ControllerConfig {
// The controller that is being configured.
ISafetyModuleController controller;
// Whether the controller is used by the SafetyModule.
bool exists;
}
Safety Modules maintain a list of authorized controllers that can initiate a trigger event using SafetyModule.trigger(bytes32 triggerEventId_)
. The triggerEventId_
, generated by the controller, encodes information about the specific event. When triggered, the Safety Module updates the TriggerEventRaiseState
for that triggerEventId_
to PENDING_RAISE
. The controller can then call requestRaise(triggerEventId_)
to raise assets from the reserve pools, enabling them to be used as specified (see Safety Module Raising).
Controller
The controller to add to the Safety Module (see Creating a Controller).
Exists
A boolean which specifies whether or not the trigger is used by the Safety Module. This is helpful for configuration updates to remove triggers from the list of triggers that are allowed to trigger the Safety Module.
Delays Config
struct Delays {
// Duration between when SafetyModule updates are queued and when they can be executed.
uint64 configUpdateDelay;
// Defines how long the owner has to execute a configuration change, once it can be executed.
uint64 configUpdateGracePeriod;
// Delay for two-step withdraw process (for deposited reserve assets).
uint64 withdrawDelay;
}
The Delays config is for Safety Module-level delays.
Config Update Delay
The config update delay is the duration between when Safety Module updates are queued and when they can be applied / executed (see Manage a Safety Module). This delay should be longer than the withdraw delay to allow Safety Module depositors to respond to queued config updates before they are applied.
Config Update Grace Period
The config update grace period is the duration after the config update delay that the Safety Module owner is allowed to apply / execute the queued config changes (see Manage a Safety Module). If the owner does not apply the updates by the end of this period, they cannot be applied.
Withdraw Delay
The withdraw delay is for the two-step withdraw process (see Safety Module Deposits). This delay should be shorter than the config update delay to allow Safety Module depositors to respond to queued config updates before they are applied.
Last updated