From Interest Rates to Liquidation Fees A Complete DeFi Modeling Guide
The Journey From Interest Rates to Liquidation Fees: A Complete DeFi Modeling Guide
In the fast‑moving world of decentralized finance, every token holder, liquidity provider, and protocol architect depends on a clear mathematical framework. Interest rates determine how much borrowers pay, while liquidation fees and bonuses protect the system’s solvency. Together, these variables form a complex yet structured ecosystem that can be modeled, analyzed, and optimized. This guide walks you through the key concepts, demonstrates how to translate them into equations, and gives a step‑by‑step tutorial for building a robust DeFi borrowing model.
The Building Blocks of DeFi Lending
1. Interest Rate Fundamentals
Interest rates in DeFi are typically expressed as an annual percentage yield (APY), derived from a daily or hourly compounding process—a topic also covered in depth in the article on Interest Rate Dynamics and Borrowing Strategies in DeFi Platforms. Two core components shape the APY:
- Base Rate: Often set by protocol governance or algorithmic rules, it represents the risk‑free portion of the yield.
- Liquidity Incentive: A dynamic factor that rewards lenders when the market is under‑funded and punishes them when the market is over‑funded.
The interest formula for a borrower’s debt D over a time interval Δt (in days) can be written as:
D(Δt) = D0 × (1 + r_daily)^Δt
Where r_daily is the daily interest rate (APY / 365). The daily rate is itself a function of the current utilization u of the pool:
r_daily(u) = base_rate_daily + liquidity_incentive(u)
2. Borrowing Mechanics and Collateralization
Borrowers must supply collateral to access credit. Two key ratios govern this process:
- Loan‑to‑Value (LTV): Maximum permissible borrowing expressed as a percentage of the collateral’s market value.
- Liquidation Threshold (LT): When the collateral’s value falls below this percentage relative to the outstanding debt, the position becomes eligible for liquidation.
For a collateral amount C priced at P_C, the maximum borrowable amount is:
MaxBorrow = C × P_C × LTV
The health factor (HF) is the ratio of the current collateral value to the debt required to trigger liquidation:
HF = (C × P_C × LT) / D
If HF < 1, the position can be liquidated.
Dynamic Interest Rate Models
Protocols employ several mathematical models to keep rates responsive:
| Model | Formula | Typical Use |
|---|---|---|
| Fixed‑Rate | r = constant |
Simple, low risk |
| Proportional | r = base + k × u |
Linear growth with utilization |
| Hump‑Shaped | r = base + (k × u × (1-u)) |
Peaks at mid‑utilization |
| Exponential | r = base + α × e^(βu) |
Sharp increase at high utilization |
Choosing a model depends on the protocol’s risk appetite and market conditions; see Optimizing Liquidation Penalties and Incentive Structures in DeFi for how these choices affect overall risk.
Liquidity Pools and Interest Calculation
Liquidity pools gather supplied assets into a single fund. The pool’s utilization u is defined as:
u = TotalBorrowed / TotalSupplied
When u rises, the supply side sees a higher incentive, and the borrow side sees a higher cost. This feedback loop is essential for self‑balancing markets.
Daily Compound Example
Assume a pool with:
- Total supplied: 1,000,000 USDC
- Total borrowed: 400,000 USDC
- Base rate: 0.5% APY
- Liquidity incentive: 1% APY when
u > 0.5
u = 0.4, so the incentive is not triggered. Borrowers pay:
APY = 0.5%
Daily rate = 0.5% / 365 ≈ 0.00137%
If the pool grows to 800,000 USDC borrowed:
u = 0.8 → Incentive applies
APY = 0.5% + 1% = 1.5%
Daily rate = 1.5% / 365 ≈ 0.00411%
Risk Parameters: LTV, Liquidation Threshold, and Liquidation Bonus
| Parameter | Definition | Typical Values |
|---|---|---|
| LTV | Max borrowable ratio | 0.5–0.9 |
| Liquidation Threshold | Value below which liquidation is possible | 0.8–0.95 |
| Liquidation Bonus | Extra collateral awarded to liquidators | 5–10% |
Typical values for these parameters are also explored in Building a Robust DeFi Financial Model for Borrowing and Liquidation.
Liquidation Process
- Trigger:
HF < 1. - Liquidator Action: Repays part or all of the borrower’s debt.
- Reward: Receives a portion of the collateral plus the bonus.
- Collateral Transfer: Remaining collateral is redistributed to the pool.
The liquidation penalty ensures that borrowers are incentivized to maintain healthy collateral levels, while the bonus compensates liquidators for their effort.
Modeling Liquidation Fees and Penalties
The liquidation fee can be derived from the difference between the collateral value and the debt amount at the moment of liquidation. For a debt D, collateral value C_val, and bonus b, the fee F is:
F = (C_val × (1 + b)) - D
The derivation follows the principles outlined in The Mathematics Behind DeFi Borrowing and Liquidation Incentives.
If F is negative, the borrower still has a shortfall; if positive, the liquidator has profited. In most protocols, the fee is capped to prevent excessive payouts.
Example
- Debt: 200 USDC
- Collateral value at liquidation: 250 USDC
- Bonus: 10%
F = (250 × 1.10) - 200 = 275 - 200 = 75 USDC
The liquidator receives 75 USDC, which is 37.5% of the initial collateral value.
Step‑by‑Step Guide to Building a DeFi Borrowing Model
1. Define Input Variables
- Market price of collateral (
P_C) - Total supplied (
S) - Total borrowed (
B) - Base interest rate (
r_base) - Liquidity incentive function (
r_incentive(u)) - LTV (
LTV) - Liquidation threshold (
LT) - Liquidation bonus (
b)
2. Compute Utilization
u = B / S
3. Calculate Daily Interest Rate
r_daily = (r_base + r_incentive(u)) / 365
4. Update Borrowed Amount
B_new = B × (1 + r_daily)
5. Determine Health Factor
HF = (C × P_C × LT) / B_new
6. Check for Liquidation
If HF < 1, compute liquidation fee:
C_val = C × P_C
F = (C_val × (1 + b)) - B_new
7. Update Pool Balances
- If liquidation occurs, reduce
Cby the portion sold to liquidator. - Adjust
SandBaccordingly.
8. Iterate Over Time
Repeat steps 2–7 daily or hourly to simulate the pool’s evolution.
Practical Example: Aave v2 Model
Aave v2 uses a stable‑rate and a variable‑rate borrowing mode. For the variable mode, the model is:
r_variable = r_base + k × u
Where k is a protocol‑specific constant that increases with utilization. For the stable mode, the rate is capped at a maximum stable rate to provide predictability.
Liquidation Conditions in Aave
- Borrower’s Health Factor = (
Collateral Value × LT) /Borrowed Amount - Minimum Health Factor to avoid liquidation: 1.0
- Liquidation Bonus: 0.08 (8%) for ERC‑20 tokens
Implementing Aave’s exact formulas requires access to the protocol’s contract data, but the general structure follows the guide above.
Sensitivity Analysis
Understanding how changes in key parameters affect outcomes is essential for risk management, as discussed in DeFi Risk Management Through Advanced Interest Rate and Liquidation Models.
- Impact of LTV: Raising LTV increases borrowing power but lowers the buffer before liquidation.
- Effect of Liquidation Bonus: A higher bonus attracts more liquidators but reduces the protocol’s margin.
- Utilization Threshold: Lower thresholds trigger more frequent liquidations, tightening liquidity but enhancing safety.
Run simulations varying each parameter to see the effect on pool health, borrower payoff, and protocol revenue.
Visualizing the Model
Below is a conceptual diagram that shows how rates adjust with utilization and how liquidation flows through the system.
Common Pitfalls and How to Avoid Them
| Pitfall | Description | Mitigation |
|---|---|---|
| Ignoring price volatility | Collateral value can drop quickly, triggering liquidation. | Use real‑time oracle feeds and set conservative LTV. |
| Over‑simplifying incentive functions | Linear models may misrepresent real‑world behavior. | Validate with historical data and adjust coefficients. |
| Neglecting gas costs | Liquidation can be expensive on congested networks. | Factor in transaction fees into the model. |
| Assuming static interest rates | Rates adapt to supply/demand. | Implement dynamic rate updates in the simulation loop. |
Conclusion
DeFi lending combines straightforward financial concepts with sophisticated mathematical modeling. By carefully defining interest rates, collateral parameters, and liquidation mechanics, one can build a transparent, predictive model that serves both borrowers and protocol designers. The step‑by‑step framework outlined above is adaptable to any DeFi platform, whether it follows Aave’s design, Compound’s proportional model, or a custom protocol’s logic.
With this guide, you now have a solid foundation to build, test, and refine a DeFi borrowing model that balances profitability, risk, and user experience. Happy modeling!
Lucas Tanaka
Lucas is a data-driven DeFi analyst focused on algorithmic trading and smart contract automation. His background in quantitative finance helps him bridge complex crypto mechanics with practical insights for builders, investors, and enthusiasts alike.
Random Posts
Exploring Minimal Viable Governance in Decentralized Finance Ecosystems
Minimal Viable Governance shows how a lean set of rules can keep DeFi protocols healthy, boost participation, and cut friction, proving that less is more for decentralized finance.
1 month ago
Building Protocol Resilience to Flash Loan Induced Manipulation
Flash loans let attackers manipulate prices instantly. Learn how to shield protocols with robust oracles, slippage limits, and circuit breakers to prevent cascading failures and protect users.
1 month ago
Building a DeFi Library: Core Principles and Advanced Protocol Vocabulary
Discover how decentralization, liquidity pools, and new vocab like flash loans shape DeFi, and see how parametric insurance turns risk into a practical tool.
3 months ago
Data-Driven DeFi: Building Models from On-Chain Transactions
Turn blockchain logs into a data lake: extract on, chain events, build models that drive risk, strategy, and compliance in DeFi continuous insight from every transaction.
9 months ago
Economic Modeling for DeFi Protocols Supply Demand Dynamics
Explore how DeFi token economics turn abstract math into real world supply demand insights, revealing how burn schedules, elasticity, and governance shape token behavior under market stress.
2 months ago
Latest Posts
Foundations Of DeFi Core Primitives And Governance Models
Smart contracts are DeFi’s nervous system: deterministic, immutable, transparent. Governance models let protocols evolve autonomously without central authority.
1 day ago
Deep Dive Into L2 Scaling For DeFi And The Cost Of ZK Rollup Proof Generation
Learn how Layer-2, especially ZK rollups, boosts DeFi with faster, cheaper transactions and uncovering the real cost of generating zk proofs.
1 day ago
Modeling Interest Rates in Decentralized Finance
Discover how DeFi protocols set dynamic interest rates using supply-demand curves, optimize yields, and shield against liquidations, essential insights for developers and liquidity providers.
1 day ago