The Cozy Safety Module protocol is able to take fees in two ways:
Reserve pool assets drip as fees at a pre-configured rate
A fixed % of all redemptions are paid as fees
All fees are received by the owner address of the protocol - CozySafetyModuleManager.owner(). Currently, both fees are 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./// @paramlastDripTime_ Timestamp of the last dripfunctiondripFactor(uint256lastDripTime_)externalviewreturns(uint256dripFactor_);}
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 from reserve pool drip collected?
Fees are collected with CozySafetyModuleManager.claimFees, which transfers all accrued fees in the specified Safety Modules to the protocol owner address CozySafetyModuleManager.owner().
This calls SafetyModule.claimFees , which is only allowed to be called from CozySafetyModuleManager.
Redemption Fees
The CozySafetyModuleManager defines a global redemptionFee which applies to all redemptions from the Safety Module. The redemption fee simply takes a fixed % of all reserve assets which are redeemed as fees and sends them to the CozySafetyModuleManager.owner().
/// @notice For all specified `safetyModules_`, transfers accrued fees to the owner address.
function claimFees(ISafetyModule[] calldata safetyModules_) external;