DEFI FINANCIAL MATHEMATICS AND MODELING

Financial Mathematics in DeFi From Yield Curves to Borrowing Strategies

10 min read
#DeFi #Yield Curve #Smart Contracts #Risk Management #Liquidity
Financial Mathematics in DeFi From Yield Curves to Borrowing Strategies

In the evolving world of decentralized finance (DeFi) the language of economics is being translated into smart contracts and on‑chain data. Where traditional finance relies on banks, central banks, and regulated markets, DeFi builds a network of liquidity pools, collateralized debt positions, and automated market makers that operate without intermediaries. This shift creates both new opportunities and fresh challenges for the practitioners of financial mathematics. In this article we walk through how classical concepts—yield curves, interest‑rate models, the Capital Asset Pricing Model (CAPM), and borrowing strategies—are being adapted to the blockchain environment.


Yield Curves in DeFi

A yield curve is a graph that shows the relationship between the maturity of an investment and its expected return. In traditional finance the curve is derived from bond prices, Treasury yields, or swap rates, and it informs decisions about asset allocation, risk assessment, and monetary policy. In DeFi, the concept is applied to on‑chain protocols such as liquidity pools, lending markets, and stable‑coin mechanisms.

What drives a DeFi yield curve?

  1. Liquidity Provision Rewards
    Protocols like Uniswap and Curve reward liquidity providers (LPs) with a share of trading fees and protocol‑specific tokens. The effective yield for an LP depends on the depth of the pool, the volatility of the underlying assets, and the fee schedule. For a single‑token pool the yield can be expressed as:

    [ Y = \frac{\text{Fees}{\text{daily}} + \text{Rewards}{\text{daily}}}{\text{Liquidity}} ]

  2. Collateralized Lending Rates
    In lending platforms such as Aave or Compound, borrowers pay an interest rate that varies with the utilization of the pool. The borrowing rate can be modelled as a function of supply and demand:

    [ r_{\text{borrow}}(u) = r_{\text{base}} + k \cdot u ]

    where (u) is the utilization ratio and (k) is the slope determined by the protocol.

  3. Stable‑Coin Collateral
    Stable‑coins that are backed by a basket of assets or over‑collateralized tokens introduce a different dynamic. The yield curve here reflects the cost of maintaining collateralisation and the risk of redemption.

Visualising the Curve

To help readers grasp the concept, the following image shows a stylised DeFi yield curve derived from an on‑chain lending pool:

The curve rises steeply at short maturities, reflecting high borrowing costs when liquidity is scarce, and flattens as the maturity extends, indicating diminishing marginal returns.


Modelling Interest Rates in On‑Chain Environments

Interest rates in DeFi are not set by central banks but by market forces embedded in smart contracts. Nonetheless, the same mathematical tools used in traditional finance—short‑rate models, stochastic differential equations, and Monte Carlo simulation—can be applied to forecast and analyse these rates.

Short‑Rate Models

A popular model for the evolution of short rates is the Vasicek model:

[ dr_t = a(b - r_t),dt + \sigma,dW_t ]

where (a) is the speed of mean reversion, (b) the long‑run mean, (\sigma) the volatility, and (W_t) a Wiener process. In a DeFi context, the short rate could represent the instantaneous borrowing cost in a protocol that supports variable rates.

Adapting the model to on‑chain data involves estimating the parameters from historical on‑chain rate observations, perhaps using Bayesian inference to incorporate uncertainty about the protocol’s future behaviour.

Stochastic Discount Factors

Because DeFi contracts execute deterministically, the discount factor for a future cash flow is simply the product of one‑period returns:

[ D_t = \prod_{i=1}^{t} \frac{1}{1 + r_i} ]

If a protocol offers a time‑dependent yield, the stochastic discount factor can be used to price complex derivatives such as options on borrowing rates or on LP tokens.


Borrowing Mechanics in DeFi

Borrowing is a core feature of many DeFi protocols. Unlike traditional loans, the collateral is usually held in a smart contract, and liquidation occurs automatically when the collateralisation ratio falls below a threshold. Understanding the mechanics requires a clear view of the mathematical relationships that govern the process.

Collateralisation Ratio

The collateralisation ratio (CR) is defined as:

[ \text{CR} = \frac{P_{\text{collateral}} \cdot Q_{\text{collateral}}}{P_{\text{borrow}} \cdot Q_{\text{borrow}}} ]

where (P) denotes the price of the collateral or borrowed asset and (Q) the quantity. Protocols set a minimum CR (often 150 % or 200 %) to guard against price volatility.

Liquidation Threshold

If the CR falls below a liquidation threshold (L), the smart contract initiates a liquidation process. The cost of liquidation (C_{\text{liq}}) can be expressed as:

[ C_{\text{liq}} = \text{CR} \times \text{Penalty} + \text{Fee}_{\text{protocol}} ]

The penalty is usually a percentage of the collateral value, incentivising borrowers to maintain sufficient collateral.

Dynamic Borrowing Rates

Many DeFi protocols adjust borrowing rates dynamically based on utilisation. A simple linear model is:

[ r_{\text{borrow}} = r_{\text{base}} + \alpha \cdot u ]

where (u) is utilisation, (\alpha) is a protocol‑specific sensitivity factor, and (r_{\text{base}}) is the base rate. To capture the full distribution of possible rates, one can run simulations that sample utilisation from historical data and compute the resulting rate trajectories. For a deeper dive into how DeFi protocols design these rates and the mechanics behind automatic liquidations, see our guide on DeFi interest rate models and borrowing mechanics.


Applying CAPM to DeFi Assets

The Capital Asset Pricing Model (CAPM) offers a framework for understanding the relationship between systematic risk and expected return. Applying CAPM to DeFi requires re‑defining the market portfolio and beta.

Defining the Market Portfolio

In traditional finance, the market portfolio is often approximated by a broad index such as the S&P 500. In DeFi, a composite index of all high‑liquidity assets or the aggregate of protocol‑token holdings can serve as the market proxy. One approach is to calculate a weighted average return across all on‑chain tokens:

[ R_{\text{market}} = \sum_{i} w_i R_i ]

where (w_i) is the proportion of total market cap held by token (i).

Calculating Beta

Beta measures the sensitivity of an asset’s returns to movements in the market portfolio:

[ \beta = \frac{\operatorname{Cov}(R_{\text{asset}}, R_{\text{market}})}{\operatorname{Var}(R_{\text{market}})} ]

Because DeFi returns can be highly volatile and non‑normal, robust statistical methods (e.g., rolling window estimators, GARCH models) should be employed to produce stable beta estimates. For a practical example of how to compute beta and expected return for a DeFi token, check out our post on Modeling DeFi borrowing and risk with CAPM techniques.

Expected Return

The CAPM formula for the expected return of a DeFi asset becomes:

[ E[R_{\text{asset}}] = R_f + \beta \left( E[R_{\text{market}}] - R_f \right) ]

where (R_f) is a risk‑free rate, often taken as the yield on a stable‑coin collateralised by a low‑volatility asset. Using this framework, investors can compare the risk‑adjusted performance of different protocols or tokenized assets.


Borrowing Strategies in Practice

Once the mechanics and pricing are understood, borrowers can devise strategies that maximise yield while minimising risk.

Leveraged Yield Farming

Borrowing low‑interest collateral to supply liquidity in high‑yield pools is a common tactic. The net return (R_{\text{net}}) is:

[ R_{\text{net}} = R_{\text{farm}} - r_{\text{borrow}} \cdot \text{Debt} ]

where (R_{\text{farm}}) is the yield from the farming pool. A simple rule of thumb is to ensure (R_{\text{farm}} > r_{\text{borrow}}); otherwise the strategy is unprofitable.

Dynamic Collateralisation

By monitoring the volatility of the collateral asset, borrowers can adjust the collateralisation ratio to stay above the liquidation threshold. A threshold‑crossing model helps automate this:

if (CR < L + buffer):
    add_collateral()
else if (CR > L + high_buffer):
    reduce_collateral()

The buffer accounts for price slippage during large market moves.

Diversified Borrowing

Borrowing across multiple protocols reduces concentration risk. The combined borrowing cost can be modelled using portfolio optimisation:

[ \min_{\mathbf{w}} \mathbf{w}^T \Sigma \mathbf{w} \quad \text{s.t.} \quad \mathbf{w}^T \mathbf{r} = r_{\text{target}} ]

where (\mathbf{w}) are the weights of each protocol’s borrowing position, (\Sigma) is the covariance matrix of borrowing rates, and (\mathbf{r}) the vector of expected rates.

Liquidation Protection

Borrowers can use synthetic insurance or over‑collateralise to guard against liquidation. For instance, adding a stable‑coin buffer that triggers before the protocol’s liquidation threshold ensures a margin of safety.


Risk Management and Stress Testing

The volatility of DeFi markets demands rigorous risk controls. Traditional tools such as Value‑at‑Risk (VaR), Expected Shortfall (ES), and scenario analysis remain relevant.

Scenario Generation

Because many DeFi prices are driven by automated market maker dynamics, scenarios can be generated by:

  1. Simulating price jumps using a jump‑diffusion process.
  2. Applying historical shock events (e.g., a 50 % drop in a major protocol’s price).
  3. Running a Monte Carlo simulation of utilization levels.

Each scenario feeds into the borrowing model to compute the probability of liquidation or loss.

Backtesting

Historical on‑chain data allows backtesting of borrowing strategies. By applying the strategy to past price and utilisation data, one can evaluate the realised returns, drawdowns, and frequency of liquidation events.

Monitoring Metrics

Real‑time dashboards should track:

  • Utilisation rates
  • Collateralisation ratios
  • Protocol‑specific risk indicators (e.g., liquidity depth)
  • Systemic metrics (e.g., total value locked, token volatility)

Automated alerts can be triggered when thresholds are breached, enabling timely action.


Case Study: Leveraged Yield Farming on Aave and Curve

To illustrate the application of these concepts, let’s walk through a concrete example.

  1. Borrowing
    The borrower takes out a 5 ETH loan from Aave. The current borrowing rate is 2 % per annum, and the protocol’s liquidation threshold is 120 %. The collateralisation ratio is 150 %, comfortably above the threshold.

  2. Liquidity Provision
    The borrowed ETH is supplied to the ETH‑DAI pool on Curve, which offers an average annual return of 8 % from fees and rewards.

  3. Net Return Calculation
    [ R_{\text{net}} = 0.08 - 0.02 = 0.06 \text{ or } 6% ] The borrower also earns a small portion of Curve’s governance token, which may appreciate, adding a potential upside.

  4. Risk Assessment
    The borrower monitors the ETH price and the pool’s liquidity. If ETH drops 30 % in a day, the collateralisation ratio may fall below the liquidation threshold. The borrower automatically transfers additional ETH to maintain a buffer.

  5. Stress Test
    A Monte Carlo simulation shows that under a 10 % daily volatility, the probability of liquidation over a 30‑day horizon is below 2 %. The strategy remains attractive given the expected net return.

This example demonstrates how yield curves, borrowing mechanics, and CAPM‑based risk assessment converge in a real DeFi operation.


Conclusion

Financial mathematics provides the rigorous foundation necessary to navigate the complex landscape of decentralized finance. Yield curves in DeFi translate the age‑old relationship between maturity and return into on‑chain rewards and borrowing costs. Modelling interest rates and discount factors remains crucial for pricing derivatives and managing portfolios. Borrowing mechanics, governed by collateralisation ratios and liquidation thresholds, demand precise mathematical treatment to avoid catastrophic loss. The CAPM framework adapts to DeFi by redefining the market portfolio and beta, offering a lens for risk‑adjusted performance evaluation.

Armed with these tools, investors and protocol designers can craft borrowing strategies that maximise yield, diversify risk, and protect against market shocks. As DeFi continues to evolve, the interplay between on‑chain data and classical financial theory will deepen, unlocking new opportunities for sophisticated participants.

Lucas Tanaka
Written by

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.

Contents