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.
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#
| Service | How it works | Examples |
|---|---|---|
| Decentralised exchanges | Swap tokens through liquidity pools | Uniswap, Curve. See Centralized vs Decentralized Exchanges |
| Lending and borrowing | Deposit assets to earn interest; borrow against collateral | Aave, Compound |
| Stablecoins | Dollar tokens, some created through DeFi collateral | DAI/USDS. See Stablecoins |
| Liquid staking | Stake tokens and receive a tradable receipt token | Lido. See Staking and Restaking |
| Derivatives | Perpetuals and options on chain | Hyperliquid, dYdX |
| Yield aggregators | Move funds between protocols to chase yield | Yearn |
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#
- Lenders deposit tokens into a pool and earn interest.
- Borrowers deposit collateral worth more than they borrow (overcollateralisation).
- Interest rates adjust automatically with supply and demand: when most of a pool is borrowed, rates rise.
- 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#
| Source | Example |
|---|---|
| Borrowing demand | Traders borrowing stablecoins for leverage |
| Trading fees | Liquidity providers earn swap fees |
| Staking rewards | Network rewards passed through liquid staking |
| Token incentives | Protocols paying users in their own tokens, often temporary |
| Real world assets | Tokenised 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#
- Start small and use well audited, established protocols.
- Understand the source of yield before depositing.
- Monitor collateral ratios on loans.
- Use a separate wallet for experimenting.
- 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.
3 quick questions on this lesson. Get them all right to finish it.
Turn on JavaScript to take the quiz.
Mentioned in
- EthereumCrypto
- AltcoinsCrypto
- Wallet and Exchange FlowsCrypto
- MEVCrypto
- Tokenomics and Protocol RevenueCrypto
- Crypto and Prediction Markets Learning PathStart Here