contracts
contracts copied to clipboard
Lending Facility & DFC
Overview
Implemented a lending facility that allows users to borrow collateral tokens against locked issuance tokens with dynamic fee calculation.
Key Changes
- Added lending facility logic module with borrow/repay functionality
- Integrated dynamic fee calculation based on utilization rates
- Added role-based access control for facility management
- Implemented borrowing limits and quotas
Technical Details
- Users lock issuance tokens as collateral to borrow collateral tokens
- Dynamic fees scale with system utilization
- Configurable individual and system-wide borrowing limits
- Automatic issuance token locking/unlocking during borrow/repay
- Fee collection and distribution to DBC FM
Formulas & Pricing
-
Borrow Capacity:
virtualIssuanceSupply × P_floor(where P_floor is first segment's initial price) -
Required Collateral:
borrowAmount ÷ floorPrice(issuance tokens needed) -
Utilization Rate:
currentlyBorrowedAmount ÷ borrowCapacity -
Dynamic Fee:
requestedAmount × feeRate(feeRate from DynamicFeeCalculator based on utilization) -
Floor Liquidity Rate:
(borrowableAmount - currentlyBorrowedAmount) ÷ borrowableAmount
Testing
- Borrow/repay flows verified with proper state management
- Fee calculation accuracy confirmed across utilization ranges
- Access control and limit enforcement tested
Missing
- Updates from tech specs and implementation that need to be made
- Looping feature for allowing multiple loops
- More fuzz tests
- Testing all unhappy paths
- Inverter Standard review
- Invariant tests