DEFI FINANCIAL MATHEMATICS AND MODELING

Practical Guide to DeFi Financial Modeling and Interest Calculations

9 min read
#DeFi Modeling #Smart Contracts #Financial Modeling #Token Economics #Yield Analysis
Practical Guide to DeFi Financial Modeling and Interest Calculations

When I first sat in front of my laptop, watching dollar signs dance across various DeFi dashboards, I felt that familiar mix of excitement and dread that follows anyone who has ever watched a market go on a roller‑coaster. It was not just about potential profits; it was about the feeling that if I didn’t understand the math behind the numbers, I might be chasing a mirage of excess returns that could evaporate in a flash. That fear carried me to the basics, and that’s where the first steps of modeling in DeFi start.

Knowing the shape of returns

The first thing most people do, whether they’re in a traditional brokerage or a decentralized protocol, is look at the yield. In DeFi parlance, it’s usually APY—annual percentage yield. That tells you how much you can earn in a year if you keep your funds locked in, with no withdrawals or re‑investments. But APY is a convenience figure that hides the underlying mechanics.

If you flip the screen and dig into the contract, you’ll see something like “compounded 0.01% per block.” That’s the raw, periodic interest. The block time varies by blockchain—around 15 seconds on Ethereum, 2–3 seconds on Solana, or even faster on newer chains—but the principle is the same: the block reward gets added to your balance, and then the next block adds a percentage of the new balance.

The trick is to convert the per‑block compounding into a yearly figure we can compare across protocols or against a bank savings account. The formula is simple:

APY = (1 + r/n) ^ n - 1

where r is the nominal annual rate and n is the number of compounding periods per year. In practice, DeFi projects publish the APY calculated this way, but it’s good to know that this number is a product of compounding.

If you prefer a more straightforward approach, you can calculate the simple interest:

Simple Interest = Principal × Rate × Time

That’s what you’ll see when lending on a platform that offers a fixed APR. The difference is that simple interest does not repeat; you only get the raw percentage of your original deposit, not the power of compounding.

Why does this distinction matter? Because in DeFi, interest can be reinvested automatically—your yields can be fed back into the pool, generating new yields. If you were to withdraw after a month, you might miss out on a whole layer of compounding that is invisible in the monthly snapshot.

Borrowing mechanics: collateral, liquidation, and risk

Borrowing in DeFi is like renting an apartment; your collateral is your security deposit. In most lending protocols—Aave, Compound, Maker—the borrower locks up collateral in the form of a stablecoin or a volatile asset. In return, they receive a borrowing token that represents their debt.

The collateral ratio is expressed as a percentage. For example, if you lock 2 ETH worth €4,000 and the protocol requires a 150% collateral ratio, you can borrow up to €2,666.66. That means you have €1,333.34 of buffer before the protocol initiates a liquidation.

Liquidation triggers when the value of your collateral falls below the required ratio. The protocol will automatically sell a portion of your collateral to cover the debt in a go‑to‑market sale. This is designed to protect the lenders, but it can leave borrowers with a loss if the liquidation occurs while the price is sloping down.

When modeling borrowing, the key inputs are:

  • Collateral value and volatility: A volatile asset means you’ll see the collateral ratio change faster.
  • Interest rate policy: Some protocols use a fixed APR, others have dynamic rates that scale with utilization. Knowing how the rate changes as the pool fills is essential.
  • Liquidation penalty: Protocols often charge extra fees if liquidation occurs (e.g., 0.5% on Maker). Factor this into your cost estimate.

It helps to create a simple spreadsheet that tracks collateral, debt, interest accrual, and risk thresholds over time. You can project how a 10% drop in collateral value pushes you towards liquidation or how a 1% increase in interest accrues extra debt.

Yield curves in DeFi: not as simple as the market

In traditional finance, a yield curve plots interest rates of bonds with different maturities. In DeFi, we can think of a yield curve as a spectrum of yields based on the duration of lock‑in, the type of asset, or the protocol’s risk premium.

Unlike a fixed‑term bond, DeFi yields are largely driven by supply and demand for liquidity. If a liquidity pool is underfunded, the protocol will increase the reward rate to attract more capital. Conversely, if the pool is flooded, rates drop. These dynamics create a moving curve that shifts day by day, sometimes even hour by hour.

A useful way to construct a DeFi yield curve is to plot the following on a graph:

  • Y‑axis: APY
  • X‑axis: Lock‑in period (days or weeks)
  • Series: Different protocol tiers (e.g., stablecoin, wrapped ETH, synthetic assets)

Using this visual, you’ll notice that short‑term yields on stablecoins tend to hover around 3–4%, while longer‑term yields, especially on yield aggregators or liquidity mining schemes, can spike up to 20% during bull markets. These spikes often come with higher volatility and risk of impermanent loss.

When constructing a personal model, start with a baseline assumption: “What is the historical average APY for this pool over the past month?” Adjust for expected slippage (the difference between the price you assume and the actual price paid during trades). Add a risk factor: perhaps a 5% chance of an event that reduces the yield by 50%.

Building a practical DeFi financial model

Let’s walk through a concrete example: modeling returns from a stablecoin yield aggregator on a Lido‑backed pool.

Step 1: Gather data

  • Pool size: €100 million
  • Current APY: 8%
  • Token reward: 0.05% of pool value per second
  • Rewards distribution policy: Compounded daily
  • Impermanent loss risk: 2% (based on historic volatility)
  • Protocol fees: 0.3% of interest earned

Collect these figures from the pool’s dashboard or API. Note any footnotes about data collection intervals.

Step 2: Set up your spreadsheet

Columns: Date, Opening Balance, Daily Reward, Compounded Reward, Closing Balance, Cumulative Reward

Rows: One per day for 365 days.

Formulas:

  • Daily Reward = Opening Balance × (APY / 365)
  • Compounded Reward = Daily Reward + (Daily Reward × (1 - Fee %))
  • Closing Balance = Opening Balance + Compounded Reward

This simple model will give you a projection of how your balance will grow over a year, assuming a stable APY.

Step 3: Incorporate risk adjustments

Add an “Implied Volatility” column that adjusts the daily reward by a volatility factor.

Adjusted Reward = Daily Reward × (1 - Volatility % × sqrt(Days))

This approach applies a simplified version of the Black‑Scholes volatility adjustment to estimate how likely a sudden dip in yield might impact your returns.

Step 4: Visualize and interpret

Create a line chart of Closing Balance vs. Date. Overlay a dashed line that represents a scenario where the APY drops to 5% after a market shock. Notice that the gap widens over time.

Through this visual, you’ll see that the bulk of your returns come from compounding in the early months. A sudden yield drop early in the year will have a larger impact than one later, because you’re compounding less.

Step 5: Scenario testing

Run a “worst case” scenario where the APY falls to 2% and your collateral value drops by 30%. Add a liquidation event at day 200. Adjust the spreadsheet to subtract the collateral that gets liquidated, and recalculate your ending balance. This will illustrate the sensitivity of your portfolio to both yield changes and collateral value.

Risk management: the human side of the math

Mathematics can never account for every twist and turn. That’s why we need both analytical tools and a human perspective.

  • Impermanent loss: When you supply liquidity in an AMM (Automated Market Maker), you might lose value compared to simply holding the assets if their prices diverge. Quantify the probability of a 10% price divergence and factor that into your expected yield.

  • Smart contract risk: Bugs may allow attackers to drain funds. Look at audit reports and the number of audits. A protocol that has undergone multiple independent audits carries less perceived risk.

  • Oracle risk: Prices often come from aggregators. A manipulated price feed can skew your collateral ratio. Consider how many oracle sources the protocol uses and how they are weighted.

  • Liquidity risk: In a sudden market panic, redeeming a large position may cause slippage. Use depth charts to estimate the price impact of your withdrawal.

Add a risk adjustment factor in your spreadsheet, e.g., “Risk‑adjusted Yield = Yield × (1 – Risk %).” The risk % can be built from the sum of the above risks weighted by their probabilities.

A real-world view: 2024 DeFi landscape

In early 2024, a surge of new wrapped tokens entered the market. Their liquidity was thin, and the APYs advertised reached as high as 35%. While these numbers caught our eye, the underlying models revealed high volatility and potential impermanent loss.

One high‑yield protocol, “PoolX”, had a 12% historical volatility and an average liquidity depth of €2 million. Our model suggested that a 10% jump in token price could trigger a 20% yield dip the next week—a dramatic shift.

We compared this to a matured stablecoin protocol with a 3.5% APY but a liquidity depth of €150 million and a volatility of just 0.5%. The lower yield was outweighed by the certainty of returns.

The lesson? Higher numbers come with higher uncertainty. By layering simple interest calculations, collateral rules, and yield curves into a clean spreadsheet, you can make that trade‑off transparent instead of chasing hype.

Closing thoughts

We’ve walked through:

  • The conversion of block‑based compounding into an annual figure,
  • The mechanics of collateralized borrowing and liquidation,
  • The concept of a yield curve in a decentralized world,
  • A practical way to build a spreadsheet model, and
  • Risk factors that can't be hidden behind a shiny dashboard.

The take‑away is to approach DeFi with the same measured curiosity we apply to a garden: start with a seed (a simple model), water it with data, prune away assumptions that don’t hold, and watch it grow over time.

Actionable takeaway
Create a one‑page spreadsheet that lists, for each DeFi protocol you consider:

  1. APY (compound vs simple)
  2. Collateral ratio and liquidation penalty
  3. Volatility of the underlying asset
  4. Liquidity depth
  5. Historical uptime of the contract and audit history

Then, add a risk‑adjusted yield column. Use that to rank protocols by a consistent metric. That simple table turns ambiguity into clarity and keeps you from chasing fleeting high numbers without understanding the underlying math.

Stay curious, but stay calculated. That’s the only honest way to grow your financial garden in the wild world of DeFi.

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