DEFI FINANCIAL MATHEMATICS AND MODELING

Mathematical Foundations of DeFi Interest Optimization

10 min read
#Smart Contracts #Risk Management #Yield Optimization #Stochastic Models #DeFi Interest
Mathematical Foundations of DeFi Interest Optimization

Introduction

Decentralized finance, or DeFi, has reshaped how we think about borrowing, lending, and earning interest. In a world where traditional banks are no longer the sole gatekeepers of credit, a new ecosystem of smart contracts governs the flow of assets. Behind the dashboards that show yield numbers and borrowing limits lies a set of mathematical tools that dictate how rates move, how liquidity is distributed, and how users can optimise returns while managing risk, as detailed in the Yield Calibration in Decentralized Lending Ecosystems article.

This article walks through the core mathematical concepts that power DeFi interest optimisation. It explains the purpose of utilisation curves, the derivation of dynamic interest rate formulas, and the optimisation problems faced by liquidity providers and borrowers alike. By the end, readers should understand how to read a rate curve, how to model borrowing costs, and how to build strategies that maximise yield within a given risk profile.


Core Concepts in DeFi Lending Protocols

Before delving into equations, it is essential to recognise the building blocks common to most DeFi lending protocols:

  1. Liquidity Pools – Collections of assets supplied by users, stored in smart contracts, and made available for borrowing.
  2. Borrowers – Users who take out loans against supplied collateral, paying interest that is paid to liquidity providers.
  3. Interest Rate ModelsAlgorithms that map the current utilisation of the pool to the rates charged or paid.
  4. Utilisation Ratio (U) – The proportion of supplied capital that is currently borrowed.
  5. Reserve Factor – A fraction of interest that is set aside for protocol maintenance and governance.

These elements interact through a set of mathematical relationships that keep the system self‑balancing. The most critical relationship is the utilisation‑to‑rate mapping, which ensures that as more capital is borrowed, the cost of borrowing rises to incentivise users to return funds or add more liquidity.


The Utilisation Curve

Definition

The utilisation ratio is calculated as:

[ U = \frac{B}{S + B} ]

where

  • ( B ) is the total borrowed amount,
  • ( S ) is the total supplied amount.

Thus, ( U ) ranges from 0 (no borrowing) to 1 (full utilisation).

Why a Curve?

A simple linear relationship between ( U ) and interest rates fails to capture the real‑world incentives needed to keep a pool liquid. A flat curve would lead to a runaway cycle: low rates attract borrowers, which deplete liquidity and force rates up, but the jump is too abrupt. DeFi protocols therefore use a piecewise or exponential curve that gradually increases rates as utilisation rises, a strategy explored in detail in the Dynamic Yield Optimization Using Utilization Curves guide.

Common Functional Forms

  1. Linear Segment with a Threshold

    [ r(U) = \begin{cases} r_{\text{base}} + m \cdot U & \text{if } U < U_{\text{threshold}} \ r_{\text{base}} + m \cdot U_{\text{threshold}} + k \cdot (U - U_{\text{threshold}}) & \text{otherwise} \end{cases} ]

    • ( r_{\text{base}} ) is the base borrowing rate.
    • ( m ) is the slope before the threshold.
    • ( k ) is the steeper slope after the threshold.
  2. Exponential Growth

    [ r(U) = r_{\text{base}} \cdot e^{\alpha U} ]

    • ( \alpha ) controls how quickly the rate rises.
  3. Logistic Function

    [ r(U) = \frac{r_{\text{max}}}{1 + e^{-\beta(U - U_{0}))}} ]

    • This ensures a smooth approach to a maximum rate ( r_{\text{max}} ).

These functions are calibrated by protocol designers to match risk appetite, expected inflation rates, and user behaviour.

Visualisation

A typical utilisation curve looks like a gentle slope that becomes steeper near the top end.


Deriving the Interest Rate Formula

The goal of the interest rate model is to satisfy two conditions:

  1. Liquidity Matching – The total interest paid by borrowers must cover the interest paid to suppliers and the reserve factor.
  2. Risk Management – Higher utilisation should increase the borrowing cost to discourage excessive leverage.

Let’s formalise this. Suppose the protocol aims to maintain a target interest rate ( r_{\text{target}} ) for each token. The actual rate ( r(U) ) is a function of utilisation ( U ) and is defined such that the expected interest income equals the expected interest payout.

Assume:

  • ( \gamma ) is the annualised expected return that liquidity providers demand.
  • ( \theta ) is the reserve factor (e.g., 10%).

The expected interest income per unit of borrowed capital is ( r(U) \cdot (1 - \theta) ). The expected return required by suppliers is ( \gamma ). To balance, we set:

[ r(U) \cdot (1 - \theta) = \gamma ]

But ( \gamma ) itself is a function of ( U ) because higher utilisation generally increases expected returns. For a simple model, let ( \gamma = \gamma_0 + \eta U ) where ( \gamma_0 ) is the base return and ( \eta ) captures the premium for risk.

Substituting gives:

[ r(U) = \frac{\gamma_0 + \eta U}{1 - \theta} ]

This linear form is the backbone of many protocols. By selecting ( \gamma_0 ), ( \eta ), and ( \theta ), designers control the shape of the utilisation curve.


Optimisation for Liquidity Providers

Liquidity providers (LPs) wish to maximise the annual percentage yield (APY) while minimising the risk of liquidation or slippage. The APY is given by:

[ \text{APY} = (1 + r_{\text{borrow}} \cdot (1 - \theta))^{\frac{1}{n}} - 1 ]

where ( n ) is the number of compounding periods per year.

Maximising APY under Utilisation Constraints

LPs can influence utilisation by adding or withdrawing liquidity. If a pool is under‑utilised, adding liquidity decreases ( U ), which in turn lowers ( r_{\text{borrow}} ). This might reduce the APY for the provider. Conversely, if the pool is over‑utilised, withdrawing liquidity will increase ( U ), raising the borrowing rate and potentially increasing APY.

LPs can optimise their position by adding liquidity or by leveraging the insights from the Optimizing Yield Through DeFi Utilization Curves methodology, which shows how small adjustments in supply can shift the utilisation and consequently the rates.

Therefore, the optimisation problem can be stated as:

[ \max_{S} ; \text{APY}(S) \quad \text{subject to} \quad S_{\min} \leq S \leq S_{\max} ]

where ( S_{\min} ) and ( S_{\max} ) are protocol‑defined limits.

Because the APY is a function of both the supplied amount ( S ) and the current utilisation ( U ), LPs must forecast future borrowing behaviour. Monte Carlo simulations of borrowing patterns, combined with historical utilisation data, provide an estimate of the expected APY for different supply levels.

Risk Adjusted Return

Beyond raw APY, LPs should consider the risk‑adjusted return. The Sharpe ratio is a common metric:

[ \text{Sharpe} = \frac{\mathbb{E}[R] - R_{\text{risk-free}}}{\sigma_R} ]

where ( R ) is the return on the LP’s position, ( R_{\text{risk-free}} ) is a baseline return (e.g., stablecoin yield), and ( \sigma_R ) is the volatility of ( R ). In DeFi, volatility stems from market price changes, liquidity shocks, and protocol failures. By modelling the distribution of returns via simulation, LPs can identify the optimal liquidity depth that balances yield against exposure.


Optimisation for Borrowers

Borrowers aim to minimise their cost of debt while maintaining sufficient collateral to avoid liquidation. The borrowing cost is driven by the instantaneous rate ( r_{\text{borrow}}(U) ), but the effective cost also depends on the collateral factor ( CF ), which is the maximum borrowable fraction of collateral value.

The effective interest paid per year is:

[ \text{Cost} = r_{\text{borrow}}(U) \cdot \frac{B}{S + B} ]

where ( B ) is the borrowed amount. However, a borrower also faces the liquidation penalty ( P ) if collateral value drops below a threshold. The expected penalty can be modelled as:

[ \mathbb{E}[P] = \int_{V_{\text{min}}}^{V_{\text{max}}} P(v) \cdot f(v) , dv ]

where ( v ) is the collateral price, and ( f(v) ) is its probability density function.

Borrowers can optimise their position by selecting ( B ) that minimises:

[ \min_{B} ; \left( r_{\text{borrow}}(U) \cdot B + \mathbb{E}[P] \right) ]

subject to ( B \leq CF \times \text{Collateral Value} ). This problem is solved numerically because ( r_{\text{borrow}}(U) ) depends on ( B ) itself through the utilisation ratio. A common approach is to iterate: estimate ( U ), compute ( r_{\text{borrow}}(U) ), evaluate cost, adjust ( B ), and repeat until convergence.

This strategy is elaborated in the Borrowing Mechanics for Maximum DeFi Returns guide, which provides practical tools for borrowers to compute optimal leverage levels.


Practical Example: Optimising a Liquidity Provider Position

Suppose an LP supplies 10,000 USDC to a lending pool. The current pool statistics are:

  • Supplied: 200,000 USDC
  • Borrowed: 150,000 USDC
  • Utilisation ( U = \frac{150,000}{200,000 + 150,000} = 0.4286 )

The protocol’s borrowing rate curve is linear with:

  • Base rate ( r_{\text{base}} = 1.5% )
  • Slope ( m = 5% ) per utilisation unit
  • Reserve factor ( \theta = 10% )

Thus, ( r_{\text{borrow}} = 0.015 + 0.05 \times 0.4286 = 0.0357 ) or 3.57% per year.

The LP’s expected APY is:

[ \text{APY} = \frac{0.0357 \times (1 - 0.1)}{1} = 3.213% ]

Now the LP considers adding an extra 5,000 USDC. New utilisation:

[ U_{\text{new}} = \frac{150,000}{205,000 + 150,000} = 0.4211 ]

New borrowing rate:

[ r_{\text{borrow,new}} = 0.015 + 0.05 \times 0.4211 = 0.0356 ]

The APY falls to ( 3.194% ). Therefore, adding liquidity would reduce yield. The LP should instead withdraw or hold the 5,000 USDC in another strategy that offers a higher return.

This simple calculation illustrates how small changes in supply can influence utilisation and rates, providing a foundation for more sophisticated optimisation.


Risk Management Considerations

Liquidity Shock

A sudden influx of borrowers can push utilisation above 90%, causing the borrowing rate to spike. If the rate jumps too high, borrowers may liquidate simultaneously, creating a cascade that depletes the pool. Protocols mitigate this through reserve buffers and by modelling incentives, as described in the Financial Mathematics Behind DeFi Borrowing Strategies framework.

Collateral Volatility

Large swings in collateral prices can trigger mass liquidations. Using the insights from the Advanced Modeling of Borrowing Incentives in DeFi research, protocols can design more robust collateralization mechanisms that absorb shocks.

Protocol Failure

Smart‑contract bugs or governance exploits can erode confidence and trigger withdrawals. Understanding the protocol risk premium added to expected returns is essential for accurate risk‑adjusted modelling. For an in‑depth look at how these risk‑adjusted models are constructed, see Financial Mathematics Behind DeFi Borrowing Strategies.


Tools for Analysis

Tool Description
Optimizing Yield Through DeFi Utilization Curves Techniques for small supply adjustments to shift utilisation and rates.
Dynamic Yield Optimization Using Utilization Curves Deep dive into curve design and its impact on pool stability.
Borrowing Mechanics for Maximum DeFi Returns Practical tools for borrowers to calculate optimal leverage levels.
Financial Mathematics Behind DeFi Borrowing Strategies Comprehensive view of risk‑adjusted return models.
Modeling Interest Rates in Decentralized Finance Framework for designing adaptive rate schedules.

Conclusion

The strategies discussed in this article are part of a broader ecosystem of research and tooling designed to help participants navigate the complex world of DeFi. By integrating the principles from Yield Calibration in Decentralized Lending Ecosystems, Modeling Interest Rates in Decentralized Finance, Dynamic Yield Optimization Using Utilization Curves, Optimizing Yield Through DeFi Utilization Curves, and Borrowing Mechanics for Maximum DeFi Returns, participants can craft more robust, profitable strategies that adapt to evolving market and protocol conditions.

JoshCryptoNomad
Written by

JoshCryptoNomad

CryptoNomad is a pseudonymous researcher traveling across blockchains and protocols. He uncovers the stories behind DeFi innovation, exploring cross-chain ecosystems, emerging DAOs, and the philosophical side of decentralized finance.

Contents