Safety Module Fees

The Cozy Safety Module protocol is able to set a rate at which reserve pool assets in all Safety Modules are dripped. The fees are received by the owner address of the protocol - CozySafetyModuleManager.owner(). Currently, the fee rate is set to zero.

How are fees dripped?

The Cozy Safety Module protocol uses a drip model which defines the rate at which fees drip from reserve pool assets. The drip model may use the last time fees were dripped in the Safety Module to pro-actively determine the amount of assets to drip to claimable fees.

interface IDripModel {
  /// @notice Returns the drip factor, the percentage of reserve assets which should drip to fees, as a wad. For
  /// example, it there are 100 reserve assets and this method returns 1e17, then 100 * 1e17 / 1e18 = 10 assets
  /// will drip to fees.
  /// @param lastDripTime_ Timestamp of the last drip
  function dripFactor(uint256 lastDripTime_) external view returns (uint256 dripFactor_);
}

An example of a drip model that may be used for fees is the exponential-rate drip model.

The core drip functionality is implemented in SafetyModule._dripFeesFromReservePool. When a reserve pool drips fees, the following happens:

  • The amount of dripped fees is calculated as (reservePool.depositAmount - reservePool.pendingWithdrawalsAmount) * dripModel.dripFactor(reservePool.lastFeesDripTime) / 1e18, rounded down.

  • reservePool.depositAmount gets decremented by the amount of dripped fees.

  • reservePool.feeAmount gets increased by that same amount of dripped fees.

  • reservePool.lastFeesDripTime updates to block.timestamp.

When do fees drip?

Fees can either drip simultaneously for all reserve pools or for a single reserve pool.

Many operations in the Safety Module internally drip fees. However, anyone can drip fees on-demand by calling SafetyModule.dripFees() for all reserve pools and SafetyModule.dripFeesFromReservePool(reservePoolId_) for a specific reserve pool, which are also public and external functions, respectively.

The following operations internally drip fees for all reserve pools:

  • SafetyModule.pause

  • SafetyModule.unpause

  • SafetyModule.trigger

The following operations internally drip fees for a single reserve pool:

  • SafetyModule.depositReserveAssets

  • SafetyModule.depositReserveAssetsWithoutTransfer

  • SafetyModule.redeem

  • SafetyModule.claimFees

How are fees collected?

Fees are collected with CozySafetyModuleManager.claimFees, which transfers all accrued fees in the specified Safety Modules to the protocol owner address CozySafetyModuleManager.owner().

/// @notice For all specified `safetyModules_`, transfers accrued fees to the owner address.
function claimFees(ISafetyModule[] calldata safetyModules_) external;

This calls SafetyModule.claimFees , which is only allowed to be called from CozySafetyModuleManager.

Last updated