Free 30-min Web3 Consultation
Book Consultation
Smart Contract Security Audits
View Audit Services
Custom DeFi Protocol Development
Explore DeFi
Full-Stack Web3 dApp Development
View App Services
Free 30-min Web3 Consultation
Book Consultation
Smart Contract Security Audits
View Audit Services
Custom DeFi Protocol Development
Explore DeFi
Full-Stack Web3 dApp Development
View App Services
Free 30-min Web3 Consultation
Book Consultation
Smart Contract Security Audits
View Audit Services
Custom DeFi Protocol Development
Explore DeFi
Full-Stack Web3 dApp Development
View App Services
Free 30-min Web3 Consultation
Book Consultation
Smart Contract Security Audits
View Audit Services
Custom DeFi Protocol Development
Explore DeFi
Full-Stack Web3 dApp Development
View App Services
LABS
Guides

How to Design an Interest Rate Model for DeFi Lending

A developer guide to designing, implementing, and parameterizing interest rate models for decentralized lending protocols.
Chainscore © 2026
introduction
TUTORIAL

How to Design an Interest Rate Model for DeFi Lending

A practical guide to building the core mechanism that determines borrowing costs and supplier yields in decentralized finance protocols.

An interest rate model is the algorithm that dynamically sets the cost of borrowing and the reward for supplying assets in a DeFi lending protocol like Aave or Compound. It is the primary mechanism for balancing supply and demand for a specific asset pool. The model must achieve several key objectives: incentivize liquidity providers to deposit assets, manage the risk of liquidity shortages, and ensure the protocol remains solvent. A well-designed model directly impacts a protocol's capital efficiency, stability, and long-term viability.

The most foundational model is the linear kinked model, popularized by Compound v2. It defines two key utilization ratios: the optimal utilization U_optimal (e.g., 80-90%) and a maximum utilization U_max (e.g., 100%). Below U_optimal, the borrow rate increases slowly with utilization. Above this kink, the rate increases sharply, creating a strong economic incentive for borrowers to repay and suppliers to deposit more, protecting the protocol's liquidity. The formula for the borrow rate R_b is typically: R_b = R_0 + (U / U_optimal) * R_slope1 for U <= U_optimal, and R_b = R_0 + R_slope1 + ((U - U_optimal) / (U_max - U_optimal)) * R_slope2 for U > U_optimal.

When implementing a model in a smart contract, you define these parameters as immutable or governance-updatable constants. Here's a simplified Solidity snippet illustrating the calculation logic:

solidity
function getBorrowRate(uint256 cash, uint256 borrows) public view returns (uint256) {
    uint256 util = getUtilization(cash, borrows);
    if (util <= kink) {
        return baseRate + (util * slope1) / 1e18;
    } else {
        uint256 normalRate = baseRate + (kink * slope1) / 1e18;
        uint256 excessUtil = util - kink;
        return normalRate + (excessUtil * slope2) / 1e18;
    }
}

The supply rate is then derived from the borrow rate, factoring in a reserve factor (a protocol fee).

More advanced models move beyond a simple kink. Dynamic models, like those used by Aave v3, can adjust parameters based on market conditions or historical data. Jump-rate models introduce a discontinuous, steep rate increase at a critical utilization threshold to act as a circuit breaker. The choice depends on the asset's volatility and the desired market behavior. For a stablecoin pool, a model with a high U_optimal and gradual slopes may be suitable. For a volatile crypto asset, a model with a lower kink and steeper slopes is prudent to mitigate liquidity risk.

Testing and parameterization are critical. You must simulate your model under stress scenarios: a rapid drawdown to 100% utilization, sustained high utilization, and volatile asset prices. Use historical market data to backtest. Key metrics to analyze are protocol revenue, supplier APY stability, and frequency of hitting the U_max limit. Parameters like baseRate, slope1, slope2, and the kink are not set-and-forget; they often become governance parameters, allowing the protocol DAO to adjust them based on real-world performance.

Ultimately, designing a rate model is an exercise in applied mechanism design. It requires balancing economic incentives, risk management, and user experience. Start with a proven kinked model, rigorously test its parameters against historical and hypothetical data, and consider upgrade paths to more dynamic systems as your protocol matures. The Compound Whitepaper and Aave v3 documentation are essential references for understanding real-world implementations and their evolution.

prerequisites
PREREQUISITES AND CORE CONCEPTS

How to Design an Interest Rate Model for DeFi Lending

Interest rate models are the core mechanism that determines borrowing costs and deposit yields in DeFi lending protocols. This guide covers the foundational concepts and mathematical principles required to design one.

An interest rate model is a smart contract function that algorithmically sets the borrow rate and supply rate based on a pool's utilization rate. The utilization rate (U) is the key input, calculated as U = Total Borrows / Total Liquidity. When utilization is low, rates are low to encourage borrowing. As utilization approaches 100%, rates rise sharply to incentivize repayments and new deposits, protecting protocol solvency. This creates a dynamic, market-driven price for capital.

Design choices revolve around the model's kink, slope, and optimal utilization. The kink is the utilization point where the interest rate curve becomes steeper. The slope before the kink (slope1) is the base rate for normal operations, while the slope after the kink (slope2) is a much steeper penalty rate. A common approach, used by protocols like Compound and Aave, employs a piecewise linear function. The optimal utilization is typically set between 80-90%, balancing capital efficiency with a safety buffer.

Here is a simplified representation of a kinked model in pseudocode:

code
function getBorrowRate(utilization) {
  if (utilization <= kink) {
    return baseRate + (utilization * slope1);
  } else {
    return baseRate + (kink * slope1) + ((utilization - kink) * slope2);
  }
}

The supply rate is then derived from the borrow rate, accounting for a reserve factor (a protocol fee): supplyRate = borrowRate * utilization * (1 - reserveFactor).

Critical parameters must be calibrated for stability. Setting slope2 too low risks liquidity insolvency during high demand, as incentives to supply are insufficient. Setting the kink too high reduces the model's preventative effect. Parameters are often tuned via simulation against historical volatility data. Furthermore, models can be adaptive, with parameters governed by DAO votes to respond to long-term market shifts, as seen in Aave's Aave Improvement Proposals.

Beyond the standard kinked model, alternative designs exist. Jump Rate models introduce a discontinuous, fixed rate increase at a specific utilization threshold to create a stronger incentive cliff. Dynamic models can adjust rates based on external oracles for broader market rates. The choice depends on the target asset's volatility and the protocol's risk tolerance. For instance, a stablecoin pool may tolerate a higher optimal utilization than an altcoin pool.

Before deploying, thorough testing is non-negotiable. This includes unit tests for the rate function, integration tests simulating high utilization scenarios, and stress tests with volatile price feeds. The final model must be upgradeable or pausable to mitigate unforeseen economic attacks. A well-designed model is transparent, predictable for users, and robust enough to maintain protocol health across market cycles.

explanation
DEFI LENDING FUNDAMENTALS

How Utilization Rate Drives Interest

Interest rates in DeFi lending protocols are not static. They are dynamic algorithms that respond to supply and demand, with the utilization rate as the primary input. This guide explains how to design a model that balances liquidity and incentives.

The utilization rate (U) is the core metric for any lending market. It's calculated as U = Total Borrows / Total Supply. When U is low (e.g., 30%), most supplied assets are idle, signaling low borrowing demand. When U is high (e.g., 85%), the pool is nearly fully lent out, indicating high demand and potential liquidity scarcity. This single number dictates the cost of capital and the reward for suppliers, making it the engine of the interest rate model.

A well-designed model uses U to create economic incentives. The primary goal is to manage liquidity risk. If U gets too high, borrowers may be unable to repay, and suppliers cannot withdraw their funds. To prevent this, the model must make borrowing exponentially more expensive as U approaches 100%. Conversely, when U is low, rates should be minimal to attract borrowers and put capital to work. This creates a self-regulating system for the pool.

The most common implementation is a piecewise linear model or a kinked model. Below an optimal U_optimal (e.g., 80%), rates increase slowly with a low slope. Above U_optimal, rates increase sharply with a much steeper slope. Here's a simplified Solidity-inspired logic:

solidity
if (utilizationRate <= kink) {
    rate = baseRate + (utilizationRate * slope1);
} else {
    rate = baseRate + (kink * slope1) + ((utilizationRate - kink) * slope2);
}

Protocols like Compound and Aave use variations of this pattern.

Parameters must be calibrated for each asset. A stablecoin like USDC might have a kink at 90% with moderate slopes, as its value is predictable. A volatile asset like ETH might have a lower kink at 75% with steeper slopes to account for price volatility and liquidation risk. The baseRate is the minimum supplier yield, often set just above zero to cover gas costs for liquidations and protocol maintenance.

Beyond the kinked model, advanced protocols implement dynamic rate adjustments. Some models use an interest rate curve (like a smooth polynomial) instead of a kink. Others, like Euler Finance, introduced a borrow isolation framework that adjusts rates based on the risk of specific assets. The constant is that the utilization rate remains the fundamental signal, ensuring the model responds in real-time to market conditions.

When designing or auditing a model, test its behavior at extremes. Simulate a bank run scenario where utilization hits 99%: does the borrow rate spike sufficiently to disincentivize new loans and incentivize repayments? Also, verify the supplier APY calculation: Supply APY = Borrow APY * U * (1 - Reserve Factor). The reserve factor, a small fee taken from interest (e.g., 10%), funds protocol development and safety modules, completing the economic design.

COMPARISON

Interest Rate Model Types and Parameters

Key characteristics and typical parameters for common interest rate models used in DeFi lending protocols.

Parameter / FeatureLinear (Jump Rate)Kinked (Compound v2)Exponential (Aave v3)Dynamic (Euler Finance)

Core Formula

Base + (Utilization * Multiplier)

Piecewise linear with a kink point

Uoptimal * (Base + (Utilization/Uoptimal)^Slope)

Governance-updated via on-chain oracles

Adjustment Speed

Instant (per block)

Instant (per block)

Instant (per block)

Governance-controlled (e.g., weekly)

Utilization Kink

Not applicable

Typically 80-90%

Uoptimal parameter (e.g., 45%)

Not applicable

Max Borrow APR at 100% Util

Capped (e.g., 1000%)

Theoretical infinite slope

Capped by formula (e.g., 1000%)

Governance-defined cap

Parameter Governance

Off-chain, manual update

Off-chain, manual update

Off-chain, manual update

On-chain, permissioned or DAO

Real-World Example

Compound v1 (historic)

Compound v2 (USDC, DAI)

Aave v3 (Ethereum mainnet)

Euler Finance (stableswap module)

Primary Use Case

Simplicity, predictable rates

Strong disincentive at high utilization

Smooth, continuous rate curve

Market-responsive, adaptable policy

implement-jump-rate
DEFI LENDING PRIMER

Implementing a Jump-Rate Model (Compound Style)

A technical guide to designing and coding a variable interest rate model for decentralized lending protocols, inspired by Compound Finance's v2 implementation.

A jump-rate model is a core smart contract component for DeFi lending protocols that algorithmically adjusts borrowing costs based on pool utilization. Unlike a fixed or linear model, it introduces a kink—a specific utilization point where the interest rate curve steepens dramatically. This design serves two key purposes: it offers competitive rates during normal market conditions (below the kink) and acts as a strong economic incentive for borrowers to repay or for lenders to supply more assets when utilization becomes dangerously high (above the kink). This mechanism is fundamental to maintaining protocol solvency.

The model is defined by several parameters you must configure: the base rate per year (a minimum rate), the multiplier (slope before the kink), the jump multiplier (steeper slope after the kink), and the kink utilization rate. For example, a common configuration might be: base = 2%, multiplier = 20%, jump multiplier = 150%, kink = 80%. At 50% utilization, the rate is 2% + (20% * 0.5) = 12%. If utilization hits 90%, the rate jumps to 2% + (20% * 0.8) + (150% * (0.9-0.8)) = 35%. This sharp increase is the "jump."

Here is a simplified Solidity implementation of the getBorrowRate function, mirroring the logic from Compound's JumpRateModelV2:

solidity
function getBorrowRate(
    uint256 cash,
    uint256 borrows,
    uint256 reserves
) public view returns (uint256) {
    uint256 util = utilizationRate(cash, borrows, reserves);
    if (util <= kink) {
        return baseRatePerYear + (util * multiplierPerYear) / 1e18;
    } else {
        uint256 normalRate = baseRatePerYear + (kink * multiplierPerYear) / 1e18;
        uint256 excessUtil = util - kink;
        return normalRate + (excessUtil * jumpMultiplierPerYear) / 1e18;
    }
}
function utilizationRate(
    uint256 cash,
    uint256 borrows,
    uint256 reserves
) public pure returns (uint256) {
    if (borrows == 0) return 0;
    return (borrows * 1e18) / (cash + borrows - reserves);
}

All rates and utilization are expressed with 18 decimals for precision (e.g., 5% is 0.05e18).

Choosing the right parameters requires analyzing historical market data and stress-testing scenarios. The kink is typically set between 80-90%, a threshold considered high utilization. The multiplier dictates rate sensitivity in normal markets; a higher value means rates rise faster as the pool is used. The jump multiplier must be sufficiently punitive to disincentivize borrowing near 100% utilization, often being 5-10x the normal multiplier. These parameters are often set by governance and can be updated via timelock to adapt to changing market conditions.

When integrating this model, you must also calculate the supply rate for lenders. This is derived from the borrow rate, adjusted for the reserve factor. The protocol takes a cut of the interest (the reserve factor) to build a treasury or insure against bad debt. The formula is: supplyRate = borrowRate * utilization * (1 - reserveFactor). For instance, with a 10% borrow rate, 80% utilization, and a 15% reserve factor, the supply rate would be 0.10 * 0.80 * 0.85 = 0.068 or 6.8% APY.

Key considerations for production use include gas efficiency (pre-calculating and caching rates per block), oracle security for accurate utilization data, and upgradability via proxy patterns. Always audit the mathematical logic for overflow scenarios and implement comprehensive unit tests that simulate the full utilization range from 0% to 100%. Reference implementations can be studied in Compound's v2 contracts and OpenZeppelin's Solidity libraries.

parameter-calibration
GUIDE

How to Design an Interest Rate Model for DeFi Lending

Interest rate models are the core economic engines of DeFi lending protocols like Aave and Compound. This guide explains how to design and calibrate these models to balance capital efficiency, protocol safety, and user incentives.

An interest rate model is a smart contract function that algorithmically sets borrowing and lending rates based on a pool's utilization rate—the percentage of supplied assets that are currently borrowed. The primary goal is to create a self-regulating system: high utilization signals capital scarcity, triggering higher borrowing rates to attract more lenders and discourage new borrowing. Conversely, low utilization leads to lower rates to stimulate borrowing demand. This dynamic equilibrium is critical for maintaining liquidity and solvency, ensuring lenders can always withdraw their funds.

Most models, including the widely adopted Compound v2 and Aave v2 models, use a piecewise linear function with distinct "kink points." The model operates in three zones: 1) A low-utilization zone with a low, stable rate to encourage initial borrowing. 2) An optimal zone where the rate increases linearly, balancing growth and safety. 3) A high-utilization zone (post-kink) where the rate increases sharply to a maximum (R_max), creating a strong incentive for lenders to supply more capital or borrowers to repay. The kink parameter defines the utilization threshold (e.g., 80%) where the slope changes.

Calibration involves setting four key parameters: the base rate at 0% utilization (R_0), the slope in the optimal zone (R_slope1), the slope in the high-utilization zone (R_slope2), and the kink point. For a stablecoin pool, you might set R_0 to 0.5% to provide a minimal yield, a kink at 90% to allow high capital efficiency, and a steep R_slope2 to quickly reach a R_max of 50%+ during crises. These values are asset-specific; a volatile asset like ETH may require a lower kink (e.g., 70%) and higher slopes to mitigate liquidity risk.

The model must be tested under extreme market conditions using simulations. You should stress-test scenarios like a liquidity crunch where utilization hits 99% for extended periods, or a market crash causing mass liquidations. Tools like Gauntlet and Chaos Labs provide frameworks for this. The model should generate sufficient borrowing yield to attract lenders during normal operations while ensuring the protocol remains solvent during black swan events. A poorly calibrated model can lead to bank runs if lenders fear being unable to withdraw.

Beyond the kinked model, advanced designs incorporate oracle-based rates to peg borrowing costs to traditional finance (e.g., SOFR) or use dynamic parameters that adjust based on historical volatility. When deploying, you must also consider the interest rate accrual method, typically using linear compounding with per-second exponents for gas efficiency, as seen in Compound's JumpRateModelV2. Always verify calculations in your smart contract using established libraries and conduct audits before mainnet deployment.

testing-simulation
VALIDATION

Testing and Simulating Rate Behavior

A robust interest rate model requires rigorous testing before deployment. This guide covers methodologies for simulating rate behavior under various market conditions.

Effective testing begins with unit tests for the core rate calculation function. For a model like a kinked rate model or a jump rate model, you must verify the piecewise logic. Write tests that check the rate at specific utilization thresholds (e.g., utilization < kink, utilization == kink, utilization > kink). Use a testing framework like Foundry's forge test or Hardhat to assert that the calculated borrowRate and supplyRate match expected values derived from the model's formula.

Beyond unit tests, you need property-based testing and fuzz testing. Tools like Foundry's fuzzing allow you to input random utilization values (from 0 to 1) and cash/borrows amounts to ensure the function never reverts with invalid math, such as division by zero, and that rates always remain within sane bounds (e.g., 0% to 1000% APY). This catches edge cases manual tests might miss, like when total borrows are zero.

Simulation is the next critical phase. Create a script that models market cycles. Simulate a sequence of user actions: deposits, withdrawals, borrows, and repayments. Track how the utilization ratio moves and how the interest rates respond. The goal is to observe behavior during stress scenarios, like a liquidity crunch where utilization spikes to 95% or a period of stagnation where it sits at 10%. Plot the resulting rates to visualize the model's responsiveness.

Compare your model's output against historical data or alternative models. For instance, benchmark your new model's rates against Compound's JumpRateModelV2 or Aave's StableRate model under the same simulated cash flow. Analyze key metrics: rate volatility, protocol revenue generated at different utilizations, and the supplier APY. This comparative analysis reveals if your model is too aggressive, too passive, or appropriately incentivizes liquidity.

Finally, implement integration tests within a forked mainnet environment. Use tools like Foundry's cheatcodes to fork Ethereum mainnet at a specific block and deploy your rate model to a test version of a lending protocol (e.g., a modified Compound Comptroller). Execute complex interaction flows to ensure the model integrates correctly with the broader protocol mechanics and that oracles and governance interactions don't introduce unexpected behavior.

INTEREST RATE MODELS

Frequently Asked Questions

Common questions and technical clarifications for developers designing or implementing interest rate models for DeFi lending protocols.

An interest rate model is a smart contract algorithm that dynamically calculates borrowing and lending rates based on real-time market conditions, primarily the utilization rate of a liquidity pool. Its primary purposes are:

  • Capital Efficiency: Incentivize borrowers and lenders by adjusting rates to balance supply and demand.
  • Protocol Solvency: Protect lenders by making borrowing prohibitively expensive when liquidity is critically low (near 100% utilization), reducing the risk of a liquidity crunch.
  • Market Responsiveness: Automatically adjust rates without manual governance, creating a self-regulating financial market.

Models like Aave's and Compound's use piecewise linear or kinked formulas where the slope of the interest rate curve increases sharply after a specified optimal utilization rate (often ~80-90%).

conclusion
IMPLEMENTATION CHECKLIST

Conclusion and Next Steps

This guide has covered the core principles of DeFi interest rate model design. The final step is to synthesize these concepts into a production-ready implementation.

A robust interest rate model is more than a mathematical formula; it's a dynamic economic engine for a lending protocol. Your model must balance three competing objectives: capital efficiency for lenders, borrower accessibility, and protocol solvency. The JumpRateModelV2 and WhitePaperInterestRateModel from Compound provide excellent, audited starting points. Remember to parameterize your model based on realistic assumptions about your target asset's volatility and the expected utilization range.

Before deploying, conduct extensive simulations. Use historical price data for your collateral asset to stress-test the model under extreme market conditions like the March 2020 crash or the LUNA collapse. Monitor key metrics: utilization rate spikes, reserve factor accrual, and the speed of rate adjustments. Tools like Foundry's fuzzing and forked mainnet tests are essential for identifying edge cases where the model could fail or be exploited.

Your work doesn't end at deployment. An effective model requires continuous monitoring and governance. Implement off-chain analytics to track model performance against real-world usage. Be prepared to adjust kink, multiplier, or jumpMultiplier parameters via governance proposals if the market behavior of the asset deviates from initial forecasts. Transparent communication about parameter changes is critical for maintaining user trust.

For further learning, study the implementations of advanced models. Aave's stable and variable rate models, Euler's asset-tiered borrowing, and newer LLAMMA-style models for volatile collateral offer insights into next-generation design. The Compound Finance documentation and OpenZeppelin contracts remain indispensable resources for understanding the secure integration of these models into a larger protocol.

To proceed, fork and modify a battle-tested model from a major protocol, deploy it on a testnet like Sepolia, and create a simple UI to visualize the interest rate curve. Engage with the developer community on forums like the Ethereum Research forum to present your design and gather feedback. The next step is to move from theory to a verified, on-chain implementation.