Decentralized Finance Basics
DeFi (Decentralized Finance) is revolutionizing traditional financial services by eliminating intermediaries like banks. Built on blockchain technology, DeFi allows anyone with an internet connection to lend, borrow, trade, and earn interest on their crypto—all without permission from any central authority. Since 2020, DeFi has grown from a niche experiment to managing over $100 billion in assets. This lesson will teach you how DeFi works, its major components, and how to participate safely.
What is DeFi?
🏦 Traditional Finance vs DeFi
In traditional finance, banks act as middlemen—they hold your money, approve loans, set interest rates, and take fees. In DeFi, smart contracts on the blockchain replace banks, automating everything. No applications, no credit checks, no waiting. Just code executing based on predefined rules.
| Feature | Traditional Finance | DeFi |
|---|---|---|
| Access | Bank approval required, credit checks | Anyone with internet and wallet |
| Hours | Business hours, weekdays only | 24/7/365, never closes |
| Speed | Days for transfers, weeks for loans | Minutes to seconds |
| Custody | Bank holds your money | You control your assets |
| Transparency | Hidden fees, opaque processes | Open-source, on-chain data |
| Interest rates | Bank determines (usually low) | Market-driven (often higher) |
| Collateral | Credit score, income | Crypto assets (overcollateralized) |
How DeFi Works: The Building Blocks
DeFi is built on several foundational technologies:
1. Smart Contracts
Self-executing programs on the blockchain that automatically enforce rules. "If X happens, then do Y." No human intervention required once deployed.
2. Stablecoins
Cryptocurrencies pegged to $1 (USDC, USDT, DAI). Essential for DeFi because you need stable value for lending, borrowing, and trading without constant volatility exposure.
3. Liquidity Pools
Pools of tokens locked in smart contracts that provide liquidity for trading, lending, and other activities. Users who provide liquidity earn fees.
4. Governance Tokens
Tokens that give holders voting rights on protocol decisions. Own UNI? You can vote on Uniswap's future. This decentralizes control.
Decentralized Exchanges (DEXs)
🔄 Trade Without Middlemen
DEXs let you swap tokens directly from your wallet, without creating an account or depositing funds on an exchange. Your keys, your crypto, always.
How AMMs Work (Automated Market Makers)
Unlike traditional order books (buyers and sellers placing orders), DEXs use AMMs:
- Liquidity providers deposit pairs of tokens (e.g., ETH + USDC) into a pool
- A mathematical formula (x * y = k) determines prices based on pool ratios
- Traders swap against the pool, and price adjusts automatically
- LPs earn a fee (typically 0.3%) on every trade
💡 Uniswap Swap Example
You want to swap 1 ETH for USDC:
- Connect your wallet to app.uniswap.org
- Select ETH → USDC
- See the quote (e.g., 1 ETH = 2,000 USDC minus 0.3% fee)
- Approve and confirm the transaction
- ETH leaves your wallet, USDC arrives—all in one transaction
Major DEXs:
| DEX | Chain | Best For | TVL |
|---|---|---|---|
| Uniswap | Ethereum, Arbitrum, Polygon | Most tokens, highest liquidity | $5B+ |
| Curve | Ethereum, multi-chain | Stablecoin swaps, low slippage | $2B+ |
| PancakeSwap | BNB Chain | Low fees, BSC tokens | $1.5B+ |
| GMX | Arbitrum, Avalanche | Perpetual trading | $500M+ |
| Raydium | Solana | SOL ecosystem tokens | $100M+ |
Lending & Borrowing Protocols
💰 Be Your Own Bank
DeFi lending lets you earn interest by lending your crypto, or borrow against your holdings without selling them.
How DeFi Lending Works:
- Lenders deposit crypto into a lending pool and receive interest
- Borrowers deposit collateral (usually 150%+ of loan value) and borrow from the pool
- Interest rates are algorithmic—high demand = higher rates
- If collateral value drops below threshold, position is liquidated
💡 Aave Borrowing Example
You have 10 ETH ($20,000) and want cash without selling:
- Deposit 10 ETH as collateral on Aave
- Borrow up to ~75% LTV (Loan-to-Value) = $15,000 USDC
- You pay ~5% APY interest on the borrowed USDC
- Your ETH earns ~2% APY while deposited
- If ETH drops significantly, you risk liquidation—add collateral or repay loan
⚠️ Liquidation Risk
If your collateral value falls below the liquidation threshold (varies by protocol, typically 80-85% LTV), your position gets automatically liquidated at a penalty (often 5-10%). In volatile markets, this can happen fast. Don't max out your borrowing capacity!
Major Lending Protocols:
- Aave: Largest, multi-chain, flash loans, variable/stable rates
- Compound: Pioneer in DeFi lending, Ethereum-focused
- MakerDAO: Borrow DAI stablecoin against ETH and other collateral
- JustLend: Tron blockchain lending
Liquidity Providing (LP)
🌊 Providing Liquidity to DEXs
When you provide liquidity, you deposit pairs of tokens into a pool. Traders swap against your liquidity, and you earn fees from every trade.
LP Process:
- Choose a pool (e.g., ETH/USDC on Uniswap)
- Deposit equal value of both tokens (e.g., $5,000 ETH + $5,000 USDC)
- Receive LP tokens representing your share of the pool
- Earn trading fees (typically 0.3% of all trades, split among LPs)
- Withdraw anytime by burning LP tokens
🚨 Impermanent Loss Explained
The biggest risk for LPs. When token prices diverge from when you deposited, you end up with less value than if you had just held the tokens.
| Price Change | Impermanent Loss |
|---|---|
| 1.25x (25% change) | 0.6% |
| 1.50x (50% change) | 2.0% |
| 2x (100% change) | 5.7% |
| 3x (200% change) | 13.4% |
| 5x (400% change) | 25.5% |
You need to earn more in fees than you lose to IL. Stable pairs (USDC/USDT) have minimal IL. Volatile pairs have high IL risk.
Yield Farming
🌾 Maximizing Returns
Yield farming involves moving your assets between protocols to maximize returns. Often involves providing liquidity and staking LP tokens for additional rewards.
How Yield Farming Works:
- Deposit assets into a liquidity pool (earn trading fees)
- Receive LP tokens
- Stake LP tokens in a "farm" (earn governance tokens as rewards)
- Potentially stake governance tokens for more rewards (compounding)
💡 Yield Farming Example
- Provide ETH/USDC liquidity on SushiSwap → earn 0.25% of trading fees
- Stake LP tokens in SushiSwap farm → earn SUSHI tokens (additional 20% APY)
- Stake SUSHI in xSUSHI → earn more SUSHI (additional 10% APY)
- Total yield: Trading fees + SUSHI rewards + xSUSHI rewards = potentially 30-50% APY
⚠️ Yield Farming Risks
- Token emissions: High APY from token rewards can crash as more people farm
- Impermanent loss: Can exceed farming rewards in volatile markets
- Smart contract risk: Multiple protocols = multiple points of failure
- Rug pulls: Shady projects can drain pools
- Gas costs: Frequent compounding eats into profits on Ethereum
Staking
🥩 Earning by Locking Up Assets
Staking means locking up your crypto to help secure a network or protocol, earning rewards in return.
Types of Staking:
| Type | How It Works | Typical APY | Risk Level |
|---|---|---|---|
| Native PoS | Stake ETH/SOL/ADA to validate transactions | 3-8% | Low |
| Liquid Staking | Stake via Lido/RocketPool, get stETH/rETH | 3-5% | Low-Medium |
| Protocol Staking | Lock governance tokens (CRV, AAVE) | 5-20% | Medium |
| LP Staking | Stake LP tokens in farms | 10-100%+ | High |
💡 Liquid Staking Revolution
Traditional staking locks your assets (32 ETH minimum for Ethereum). Liquid staking protocols like Lido let you stake any amount and receive a liquid token (stETH) that you can use elsewhere in DeFi while still earning staking rewards. Best of both worlds!
DeFi Risks Deep Dive
⚠️ Critical Risks to Understand
🐛 Smart Contract Risk
Bugs in code can lead to loss of all funds. Even audited protocols have been hacked (Wormhole: $320M, Ronin: $620M).
💸 Impermanent Loss
LPs can lose value compared to simply holding. In volatile markets, IL can exceed all earned fees.
🏴☠️ Rug Pulls & Exploits
Malicious developers can steal funds or exploit vulnerabilities. New/unaudited protocols are highest risk.
⛽ Gas Fees
Ethereum gas can be $50-200+ per transaction during congestion. Can make small positions unprofitable.
📉 Liquidation Risk
Borrowers can lose collateral in volatile markets. Flash crashes have caused massive liquidation cascades.
🔗 Oracle Risk
Protocols rely on price oracles. Manipulated oracles have caused millions in losses.
Getting Started Safely
Step-by-Step Safe Entry into DeFi:
- Start on Layer 2: Use Arbitrum, Optimism, or Polygon for lower fees while learning
- Use established protocols: Uniswap, Aave, Curve—not random new projects
- Start with stablecoins: Lower risk, understand mechanics without volatility
- Check audits: Look for audits from Trail of Bits, OpenZeppelin, Certik
- Start small: Never deposit more than you can afford to lose
- Understand what you're doing: Don't chase APY blindly
- Use DeFi aggregators: DefiLlama for research, Zapper/Zerion for portfolio tracking
Essential DeFi Tools
| Tool | Purpose | Link |
|---|---|---|
| DefiLlama | Protocol TVL, yields, research | defillama.com |
| Zapper | Portfolio tracking, multi-chain | zapper.xyz |
| DeBank | Portfolio & protocol tracking | debank.com |
| Revoke.cash | Revoke token approvals | revoke.cash |
| DeFi Safety | Protocol safety scores | defisafety.com |
Key Takeaways
- DeFi removes intermediaries using smart contracts—be your own bank
- DEXs use AMMs to enable trading without order books or custodians
- Lending protocols let you earn interest or borrow against collateral
- Liquidity providing earns fees but comes with impermanent loss risk
- Yield farming compounds returns but multiplies risks
- Staking (especially liquid staking) offers lower-risk passive income
- Smart contract risk is real—even audited protocols can be hacked
- Start small, use established protocols, and understand what you're doing
