TradeLabs AILearn

DeFi Basics

DeFi offers trading, lending and borrowing through smart contracts instead of banks. Learn the building blocks, where yields come from and the risks.

Advanced3 min readUpdated 3 Oct 2026
Markdown
Lesson 17 of 24

Decentralised finance, or DeFi, recreates financial services such as trading, lending, borrowing and derivatives using smart contracts on public blockchains, mainly Ethereum and similar networks. Anyone with a wallet can use these services without an account or approval, and the rules are written in open code. DeFi grew from a few hundred million dollars of deposits in 2019 to more than $100 billion at its peaks. It offers new opportunities, but its risks, from code bugs to liquidation cascades, are just as real.

The building blocks#

ServiceHow it worksExamples
Decentralised exchangesSwap tokens through liquidity poolsUniswap, Curve. See Centralized vs Decentralized Exchanges
Lending and borrowingDeposit assets to earn interest; borrow against collateralAave, Compound
StablecoinsDollar tokens, some created through DeFi collateralDAI/USDS. See Stablecoins
Liquid stakingStake tokens and receive a tradable receipt tokenLido. See Staking and Restaking
DerivativesPerpetuals and options on chainHyperliquid, dYdX
Yield aggregatorsMove funds between protocols to chase yieldYearn

Total value locked (TVL)#

TVL measures the value of assets deposited in DeFi protocols. It rises with deposits and with token prices, so it is a rough gauge of DeFi activity rather than a precise measure. Analytics sites such as DefiLlama track TVL across chains and protocols.

How DeFi lending works#

  1. Lenders deposit tokens into a pool and earn interest.
  2. Borrowers deposit collateral worth more than they borrow (overcollateralisation).
  3. Interest rates adjust automatically with supply and demand: when most of a pool is borrowed, rates rise.
  4. If collateral value falls below a threshold, anyone can liquidate the position, repaying part of the debt and receiving collateral at a discount.

Where DeFi yields come from#

SourceExample
Borrowing demandTraders borrowing stablecoins for leverage
Trading feesLiquidity providers earn swap fees
Staking rewardsNetwork rewards passed through liquid staking
Token incentivesProtocols paying users in their own tokens, often temporary
Real world assetsTokenised Treasury bills paying interest

If a yield seems very high, ask where it comes from. Yields paid in newly printed tokens can collapse as token prices fall.

Liquidity providing and impermanent loss#

Liquidity providers deposit two tokens into a pool and earn fees. If prices move a lot, they end up with more of the token that fell and less of the token that rose, compared with simply holding. This is impermanent loss. For a 50/50 pool, if one token doubles in price relative to the other, the loss compared with holding is about 5.7%; if it rises fourfold, about 20%. Fees must exceed this loss to profit.

The risks of DeFi#

  • Smart contract bugs: hacks have drained billions. See Bridge and Smart Contract Risk.
  • Oracle manipulation: bad price feeds can trigger wrong liquidations. See Oracles.
  • Liquidation cascades in sharp market falls.
  • Stablecoin depegs.
  • Governance attacks: attackers buy or borrow voting tokens to change protocol rules.
  • MEV: bots extract value from users' transactions. See MEV.
  • Regulatory uncertainty.
  • User error: wrong addresses, malicious approvals, phishing sites.

Getting started sensibly#

  1. Start small and use well audited, established protocols.
  2. Understand the source of yield before depositing.
  3. Monitor collateral ratios on loans.
  4. Use a separate wallet for experimenting.
  5. Revoke approvals you no longer need.

Frequently asked questions#

What is DeFi?#

Decentralised finance: financial services like trading, lending and borrowing provided by smart contracts on public blockchains instead of banks or brokers.

How do DeFi lending protocols work?#

Lenders deposit assets into pools to earn interest, and borrowers lock collateral worth more than their loans; if collateral value falls too far, the loan is liquidated.

Is DeFi safe?#

It carries significant risks, including smart contract hacks, oracle failures, liquidations and scams, so users should start small and use established protocols.

Next, learn how blockchains get price data in Oracles.

Check your understanding

3 quick questions on this lesson. Get them all right to finish it.

Turn on JavaScript to take the quiz.

Finished this lesson?Sign in to save your progress across devices.
Next lessonOraclesOracles bring outside data like prices and event results onto blockchains. Learn how Chainlink feeds and UMA's optimistic oracle work, and how attacks happen.

Mentioned in