-
Notifications
You must be signed in to change notification settings - Fork 2
Description
Related issue
Related PR
Context
Introduce a new stabilityFeeRate parameter that is applied in updateInterestRates by reducing debitIncome.
The combination of insuranceRate + stabilityFeeRate would be deducted from the amount paid out to lenders.
Funds collected via stabilityFeeRate can be withdrawn from the protocol by the owner and used to ensure the stability of MOET. This is a more permissioned feature than insuranceRate, which is intended to remain within the protocol and not be extracted.
This task includes integrating stabilityFeeRate into interest rate calculations and ensuring the collected funds are properly tracked and withdrawable.
Proposed solution
Stability Fee Implementation
- Add fields to
TokenState+ initialize defaults ininit().
access(all) var stabilityFeeRate: UFix64
access(all) var lastStabilityFeeCollection: UFix64
- Add setters for
stabilityFeeRateandlastStabilityFeeCollectionwithaccess(EImplementation). - Add Add
stabilityFundsmap toPoolresource + initialize.
access(self) var stabilityFunds: @{Type: {FungibleToken.Vault}}
- Update
updateInterestRates()function to include stability fee.
-
FixedRateInterestCurve:
creditRate = debitRate - insuranceRate - stabilityFee -
KinkInterestCurve:
stabilityAmount = totalCreditBalance * stabilityFee
creditRate = (debitIncome - insuranceAmount - stabilityAmount) / totalCreditBalance
-
Add
collectStabilityFee() function.
Similar tocollectInsurance()but simpler - no swap, just withdraw fromreservesand returnvault.
(collectInsurance()impl here) -
Update the logic and rename
updateInterestRatesAndCollectInsurance() toupdateInterestRatesAndCollectFees().
(updateInterestRatesAndCollectInsurance()impl here) -
Update
Poolresource with additional functions.
access(EGovernance) fun setStabilityFeeRate(tokenType: Type, stabilityFeeRate: UFix64)
access(EGovernance) fun withdrawStabilityFund(tokenType: Type, amount: UFix64, recipient: &{FungibleToken.Receiver})
access(all) view fun stabilityFundBalance(tokenType: Type): UFix64
Questions to discuss
- What should be the default value for
stabilityFeeRate? - Should events be added for
stabilityFeeRateandlastStabilityFeeCollectionupdates? - What access control should the stability fund withdrawal function have -
EGovernanceor another entitlement? - Who manages the logic that determines when stability fund withdrawals occur?