Master Guide
Decentralized Finance Guide: Lending, Yield and Risk
Understand decentralized finance with worked health-factor and yield examples. Check contracts, oracles, asset issuers and withdrawal dependencies.
Decentralized finance, or DeFi, lets users interact with financial contracts through a wallet. The practical question is not simply whether a bank is absent. It is which contracts, price feeds, administrators and assets stand between a deposit and a successful withdrawal. This guide follows those dependencies through a lending example, then gives you the checks, tables and record-keeping habits to apply them to any position.
Updated 24 October 2026 · By Adam · Examples below are original educational scenarios, not live market data or product tests.
Decentralized finance: identify what you receive
A lending deposit may produce a receipt token or an accounting balance. A liquidity deposit may produce a pool share or a position NFT. A staking service may issue a token representing a claim on staked assets. None of these is automatically equivalent to cash in a bank account. Read the redemption route and its conditions before comparing the advertised yield.
Ethereum's smart-contract overview explains executable onchain code. A deployed contract can still depend on mutable parameters, administrators and external services. “Non-custodial” describes part of the control model; it does not mean no other actor can affect your position.
Many yield vaults now follow ERC-4626, a finalised Ethereum standard for tokenised vault shares. Its read functions name the questions to ask of any receipt. convertToAssets estimates what your shares represent, excluding fees. previewRedeem simulates a redemption now, including withdrawal fees. maxWithdraw reports the most you can withdraw at present. Not every vault uses the standard, but the questions apply to all of them: what is my claim worth, what would redeeming pay today, and what limits it?
Compare DeFi positions by their exit route
Positions that look similar in a dashboard can have very different exits. Use the table to choose your checks before depositing.
| Position | What you hold | How you normally exit | What can delay or reduce the exit | Where to check first |
|---|---|---|---|---|
| Lending deposit | Receipt token or internal balance | Withdraw from the pool | Funds lent out to borrowers, a paused market, bad debt | Available liquidity and utilisation for that market |
| Borrow position | Debt plus locked collateral | Repay, then withdraw collateral | Liquidation, a rising debt asset, interest accrual | Health factor and the oracle price used |
| Full-range AMM pool share | Fungible pool token | Burn the token for both assets | Holding more of whichever asset fell, a broken token in the pair | Pool reserves and both token contracts |
| Concentrated-liquidity position | A position NFT for a price range | Remove liquidity from that NFT | Price leaving your range, so the position holds a single asset | Your range against the current price |
| Vault share | Share token, often ERC-4626 | Redeem shares for the underlying asset | Withdrawal fees, queues, strategy losses | previewRedeem and maxWithdraw |
| Liquid staking token | Token claiming staked assets | Protocol withdrawal or a market sale | Validator exit queue, market discount, slashing | Withdrawal queue length and pool depth |
The liquid staking row has a dated lesson. Ethereum stakers could not withdraw staked ETH at protocol level until the Shapella upgrade activated on 12 April 2023, according to ethereum.org's fork history. Before then, a liquid staking token holder could exit only by selling at whatever price the market offered. Withdrawals now pass through a rate-limited queue, so the market route still matters when you need speed. The liquid staking entry and the validator exit queue entry explain both routes.
Calculate a lending safety margin
Aave describes health factor as collateral value multiplied by its weighted liquidation threshold, divided by debt value. A value below one can make a position liquidatable. Actual thresholds and liquidation terms depend on the market and collateral. Check Aave's current explanation and the live market configuration.
Worked example: collateral falls while debt stays unchanged
Assume $4,000 of collateral, an illustrative 80% liquidation threshold and $2,000 debt. Health factor is 4,000 × 0.80 / 2,000 = 1.60. If collateral value falls 30%, it becomes $2,800 and health factor falls to 1.12. A 40% fall leaves $2,400 and health factor 0.96, below one.
Interest can grow the debt, and the borrowed asset can change value too. The example holds both constant to isolate the collateral effect. At $2,800 collateral, reducing debt to $1,600 would raise the factor to 1.40. This calculation is a scenario, not a universal recommended buffer; collateral volatility and correlated failures matter.
Collateral price is only one of five things that move a health factor. Check each when you review a loan:
- Collateral price, as reported by the protocol's oracle, not your screen.
- Debt asset price. If the borrowed asset rises, your debt rises in dollar terms.
- Interest accrual. Variable rates change with demand and compound into the debt.
- Parameter changes. Governance can lower a liquidation threshold or freeze a market.
- Market liquidity. Liquidators must be able to sell what they seize, or the protocol can be left with unpaid debt.
Worked example: debt that grows while you are not watching
Assume $3,000 of collateral that holds its value, an illustrative 80% threshold and $1,800 of debt. Health factor is 3,000 × 0.80 / 1,800 = 1.33. Leave the loan for a year at an illustrative 9% variable rate, compounded once for simplicity, and the debt becomes 1,800 × 1.09 = $1,962. Health factor is now 2,400 / 1,962 = 1.22 without any market move.
Now suppose the borrowed asset also rises 10% against the dollar. The debt is worth 1,962 × 1.10 = $2,158.20 and the factor is 2,400 / 2,158.20 = 1.11. Two quiet changes have removed most of the margin. Recalculate any open loan regularly with current figures.
The fifth item has a dated case. In November 2022 a single account on Aave's version 2 Ethereum market built a large short position by borrowing, at its peak, roughly 92 million CRV against USDC collateral and selling it. When the CRV price rose sharply on 22 November, the position was liquidated, but the collateral did not cover everything. Aave's governance proposal of 23 November 2022 put the remaining bad debt at about $1.6 million and proposed covering it from treasury and risk-provider funds. A pool's solvency depends on liquidations working in thin markets, not only on correct rules.
Separate earned yield from token price exposure
Worked example: more tokens, less purchasing power
A fictional deposit of 100 tokens earns five tokens over a year. If each token starts at $10 and ends at $7, the ending value is 105 × $7 = $735, compared with $1,000 initially. A 5% token yield coexists with a 26.5% decline in dollar value, before costs.
Break a yield quotation into borrowing interest, trading fees and incentive tokens. Ask which part depends on new demand or temporary subsidies. Annualising a short promotional interval is not a forecast of the next year.
Check whether a rate is APR (no compounding) or APY (with compounding). APY is (1 + APR / n) to the power n, minus one, for n compounding periods a year, so a 12% APR compounded daily is about 12.75% APY. Comparing one product's APY with another's APR overstates the gap between them.
Worked example: when transaction costs swallow a small deposit
Suppose a deposit of $400 earns an illustrative 5% a year, or $20. Entering takes two transactions (an approval and the deposit) and leaving takes one withdrawal. At an illustrative $4 per transaction, costs are $12, so the net return is $8, or 2% on the money deployed. The same three transactions on a $1,000 deposit cost the same $12 against $50 of yield, leaving $38, or 3.8%.
Network fees vary widely by chain and by hour, so measure your own. If total costs exceed a few months of yield, small changes in the rate or fees can erase the return.
Build a dependency map before depositing
- Asset: issuer, peg or redemption mechanism, and freeze powers.
- Contract: verified deployment, upgrades, audit scope and privileged accounts.
- Pricing: oracle source, freshness checks and response to a market outage.
- Chain: transaction costs, congestion and any bridge used.
- Exit: available pool liquidity, withdrawal queues and redemption delays.
Restaking or layered yield strategies can combine several dependencies. A receipt token from one system used as collateral in another does not erase the first system's risk. An audit addresses a defined scope at a point in time; use the audit explainer to read limitations.
Add a row people often leave out: the toolchain that compiled the contract. On 30 July 2023 several Curve liquidity pools were drained through a flaw in the Vyper compiler, not the pools' own logic. The Vyper team's post-mortem explains that versions 0.2.15, 0.2.16 and 0.3.0 implemented reentrancy guards incorrectly, and that the bug had been fixed in version 0.3.1 without affected projects being told. Readers of the source would have seen a guard that looked correct. A dependency map cannot list every unknown, but it shows how many things must keep working.
Verify contract controls yourself
You do not need to read code fluently for this procedure; a block explorer and the protocol's documentation are enough:
- Confirm the address and chain from the protocol's documentation, not a search result or social post.
- Check the source is verified. Verified source means the published code compiles to the deployed bytecode. Unverified code is a reason to stop.
- Check for a proxy. A proxy forwards calls to a separate implementation that can be swapped. EIP-1967 defines standard storage slots for the implementation and admin addresses, so many explorers detect proxies automatically. With a proxy, today's rules can change; see the upgradeable contract entry.
- Identify who holds the admin role. One ordinary wallet means one key can change the system. A multisig exposes its signers and threshold (Safe contracts have
getOwnersandgetThresholdread functions). A timelock exposes its delay, for examplegetMinDelayin OpenZeppelin's timelock; a two-day delay gives depositors two days to read a queued change and leave. - Read the admin history. Frequent unannounced upgrades are a different risk from one documented upgrade.
- Find the price source. The documentation should name the oracle for each collateral asset. The oracle entry explains what to look for.
- Record the answers and the date. An old check is history, not a current fact.
Practice a complete exit
For a learning exercise, use a small amount you can afford to lose and document deposit, fees, receipt and withdrawal. A successful test demonstrates the path under those conditions, not future solvency. Keep a reserve for gas and records for every step. Work through Academy School's DeFi chapter, then the tax-record guide before combining strategies.
Before the test, write down the receipt you expect and the withdrawal steps. Save each transaction hash, then compare what came back with what went in. In a pooled lending market you can withdraw only funds not currently lent out, so note available liquidity on the day. A withdrawal that worked at 40% borrowed says little about a fully borrowed day.
Common DeFi mistakes and how they happen
Many losses that are not hacks come from a few repeatable errors, each with a check that catches it.
| Mistake | How it usually happens | Check that prevents it |
|---|---|---|
| Depositing the wrong version of a token | A bridged copy on another chain shares the name and ticker but has a different issuer and redemption route | Match the token contract to the issuer's published list for that chain; see the bridges entry |
| Treating a receipt as the asset | A dashboard shows the receipt's value at par, so the holder forgets it depends on redemption working | Run previewRedeem or a small withdrawal and compare |
| Looping leverage | Borrowed funds are redeposited as collateral several times, so a small price move compounds | Calculate the health factor of the whole loop, not the first step |
| No gas reserve | The whole balance of the native asset is deposited, leaving nothing to pay for repayment during a fall | Keep a separate amount of the native asset for several transactions |
Keep records for tax and disputes
DeFi tax treatment is unsettled and differs by country, so treat this as general education. Good records let you or an adviser apply whichever rule actually applies to you.
The UK shows how much turns on detail. As of October 2026, HMRC's Cryptoassets Manual says a DeFi loan or liquidity deposit is a disposal for Capital Gains Tax when beneficial ownership of the tokens passes to the borrower or platform, which depends on the terms. On 13 July 2026 the government published draft legislation that would treat certain loans and liquidity pool deposits by individuals and trustees as “no gain, no loss”, with effect from 6 April 2027. Draft rules can change, and other countries differ.
Whatever your country, keep these for every position:
- Date, time, chain and transaction hash of each deposit, claim and withdrawal.
- Token amounts in and out, including receipt tokens, and the fee paid in the native asset.
- A value in your home currency at the time of each event, with the price source you used.
- Reward tokens received, and saved copies of the terms when you deposited.
Compare any wallet export with the explorer, because exports often miss contract interactions. The transaction export guide shows what a typical export contains and what it leaves out.
Sources and verification
Primary references checked on 24 October 2026. Protocol settings and local rules can change; verify the linked version before acting.
- Ethereum: smart contracts
- Aave: health factor and liquidations
- EIP-4626: Tokenized Vaults
- EIP-1967: Proxy storage slots
- ethereum.org: history of Ethereum upgrades, including Shapella
- Aave governance: repay excess debt in the CRV market (23 November 2022)
- Vyper: nonreentrancy lock vulnerability post-mortem
- HMRC Cryptoassets Manual: DeFi lending and staking, chargeable gains
- GOV.UK: tax treatment of cryptoasset loans and liquidity pools (13 July 2026)
Knowledge check
Apply the example before checking the answer.
Question 1 of 3What is the lending example health factor after a 40% collateral decline?
Question 2 of 3Does a 5% token yield guarantee a 5% dollar gain?
Question 3 of 3Does non-custodial DeFi remove all third-party dependencies?