Overview
LinearInterestRateModelV3 implements a three-segment piecewise linear interest rate curve for Gearbox V3 pools. It features:- Obtuse region (0 to U₁): Gentle slope for low utilization
- Intermediate region (U₁ to U₂): Moderate slope to reduce rate jumps
- Steep region (U₂ to 100%): Sharp slope to encourage repayment at high utilization
contracts/pool/LinearInterestRateModelV3.sol
Key Features
- Three-Segment Curve: Smoother transitions than single-slope models
- Optional U₂ Borrowing Limit: Can restrict borrowing to maintain exit liquidity
- Stateless: Pure view functions with no state changes
- Immutable Parameters: Set at deployment for predictability
Architecture
Parameters
Utilization Points
First slope change point in basis points (obtuse → intermediate)
Second slope change point in basis points (intermediate → steep)
Rate Parameters
Base interest rate in basis points (rate at 0% utilization)
Slope of obtuse region in basis points
Slope of intermediate region in basis points
Slope of steep region in basis points
Configuration
Whether to prevent borrowing when utilization exceeds U₂
Constructor
U_2 < 10000(must be less than 100%)U_1 ≤ U_2R_base ≤ 10000R_slope2 ≤ 10000R_slope1 ≤ R_slope2 ≤ R_slope3(monotonically increasing slopes)
Core Functions
calcBorrowRate
Total expected liquidity (available + borrowed + interest)
Current available liquidity in the pool
Whether to enforce U₂ borrowing restriction if enabled
U = (expectedLiquidity - availableLiquidity) / expectedLiquidity
If U ≤ U₁:
If
isBorrowingMoreU2Forbidden is true and checkOptimalBorrowing is true, the function reverts with BorrowingMoreThanU2ForbiddenException when U > U₂.availableToBorrow
- If
isBorrowingMoreU2Forbiddenis false: returnsavailableLiquidity - If
isBorrowingMoreU2Forbiddenis true: returns amount that can be borrowed before reaching U₂
getModelParameters
serialize
Example Configurations
Conservative Stablecoin Pool
- At 0%: 2%
- At 50%: 2% + 3% * (50/80) = 3.875%
- At 80%: 2% + 3% = 5%
- At 95%: 2% + 3% + 10% * (15/15) = 15%
- At 100%: Borrowing prevented if trying to go from <95% to >95%
Aggressive ETH Pool
- At 0%: 5%
- At 60%: 5% + 10% = 15%
- At 80%: 5% + 10% + 30% = 45%
- At 100%: 5% + 10% + 30% + 100% * (20/20) = 145%
Interest Rate Visualization
Rate Calculation Example
Given model:U_1=70%, U_2=90%, R_base=1%, R_slope1=4%, R_slope2=10%, R_slope3=100%
Scenario 1: 50% utilization
- In obtuse region (U ≤ 70%)
- Rate = 1% + 4% * (50/70) = 1% + 2.857% = 3.857%
- In intermediate region (70% < U ≤ 90%)
- Rate = 1% + 4% + 10% * ((80-70)/(90-70)) = 1% + 4% + 5% = 10%
- In steep region (U > 90%)
- Rate = 1% + 4% + 10% + 100% * ((95-90)/(100-90)) = 1% + 4% + 10% + 50% = 65%
Integration with Pool
The pool calls the interest rate model on every state change:checkOptimalBorrowing is true:
- Deposit: false (deposits don’t increase utilization)
- Withdraw: false (allow withdrawals even at high utilization)
- Borrow: true (enforce U₂ limit when borrowing)
- Repay: false (repayments decrease utilization)
Security Considerations
Immutable Parameters: All rate parameters are set at deployment and cannot be changed, ensuring predictability.
U₂ Borrowing Restriction: When enabled, prevents utilization from exceeding U₂ during borrowing operations, maintaining exit liquidity reserve.
Parameter Validation: Constructor validates that slopes are monotonically increasing and utilization points are properly ordered.
Rate Bounds: Base rate and intermediate slope are capped at 100% to prevent misconfiguration.