CBR Module
Overview
The CBR module is the protocol's core RWA lending ledger logic library, managing the full lifecycle of collateralized lending. It tracks all collateral supply status, loan positions, interest rate evolution, and provides a complete set of operations for creating loans, adjusting borrowing and collateral, calculating interest, and liquidation.
Functions and Responsibilities
Collateral Supply Management
Track each collateral's total supply (totalCollateral), total minting (totalMint), and accumulated earnings (totalEarn)
Support collateral pause and resume (pause/unpause)
Manage collateral interest rate configuration (interestRateStrategy), cap configuration (capManager), and liquidation parameters (rateConfig)
Loan Position Management
Support loan creation (createLoanPosition), allocate unique IDs and register to user position collections
Support loan additional borrowing (increaseBorrow) and borrowing reduction (decreaseBorrow)
Support collateral increase (increaseCollateral) and decrease (decreaseCollateral)
Interest Rate and Interest Calculation
Dynamically maintain collateral interest rate index (interestRateIndex), update with time progression (upkeepInterestRateIndex)
Accumulate interest on loan positions according to interest rate index (upkeepLoanInterest), creating compound interest effects
Allow packing and unpacking interest rate configuration parameters according to strategies (packRateConfig/unpackRateConfig)
Liquidation Mechanism
Allow liquidation when position collateral ratio is insufficient (liquidateLoan)
Liquidation process supports both proportional liquidation (limited by liquidationPercent) and full liquidation
Calculate receivable collateral (including penalty liquidationPenalty), update positions and global supply
Interactions and Dependencies
Users
Initiate loan-related operations: create loans, add/reduce borrowing, increase/decrease collateral, repayment/liquidation
Each loan is assigned a unique ID and recorded in user loan collections
Collateral Tokens
Managed through functions like createCollateralToken, updateOracle, updateInterestRateStrategy
Each collateral corresponds to a CBRSupply structure recording total supply, interest rate index, caps and liquidation parameters
Support pause function for emergency suspension during risk events
Cap Manager (ICapManagerCBR)
Control supply and borrowing caps for each collateral type
Interest Rate Strategy
Provide logic for updating loan interest rates
Last updated
Was this helpful?