What Is DeFi? Complete Guide
Decentralized Finance explained. From first principles to protocols, understand how finance is being rebuilt without intermediaries.
🎯 What You'll Learn
- Understand what DeFi is and why it matters
- Learn the core building blocks of DeFi
- Know the major DeFi protocols and their functions
- Recognize the risks and trade-offs
- See how DeFi connects to traditional finance
Finance Without Banks
What if you could lend money, earn interest, trade assets, and get loans-all without a bank? No credit checks, no applications, no waiting. Just code.
That’s DeFi: financial services powered by smart contracts instead of institutions. It’s available 24/7, to anyone with an internet connection, with no permission required.
But here’s what the hype doesn’t tell you: DeFi isn’t magic. It faces the same fundamental challenges as traditional finance-just with different trade-offs. Understanding these trade-offs is what separates successful DeFi users from victims.
What Is DeFi?
Decentralized Finance (DeFi) is a collection of financial applications built on blockchains, primarily Ethereum. They provide traditional financial services (lending, borrowing, trading) without centralized intermediaries.
DeFi vs Traditional Finance
| Aspect | Traditional Finance | DeFi |
|---|---|---|
| Custodian | Banks hold your assets | You hold your assets |
| Access | Bank account required | Wallet required |
| Hours | Business hours, weekdays | 24/7/365 |
| Permission | KYC, credit checks | Permissionless |
| Transparency | Audited quarterly | Every transaction public |
| Speed | Days for settlement | Minutes |
The Stack
Uniswap, Aave, Compound
Solidity code on chain
Ethereum, Polygon, etc.
The Core Building Blocks
DeFi is composed of modular building blocks, often called “money legos”:
1. Stablecoins
Cryptocurrencies pegged to stable assets (usually USD):
| Stablecoin | Type | Backed By |
|---|---|---|
| USDC | Fiat-backed | USD in bank accounts |
| USDT | Fiat-backed | USD + other assets |
| DAI | Crypto-backed | Overcollateralized ETH |
Why they matter: You can’t do finance with assets that swing 10% daily. Stablecoins provide the stability needed for lending, payments, and pricing.
2. Decentralized Exchanges (DEXs)
Trade assets without a centralized order book:
Traditional Exchange DEX (AMM)
Order Book vs Liquidity Pool
Bid/Ask x * y = k
Popular DEXs:
- Uniswap: Automated Market Maker (AMM) pioneer
- Curve: Optimized for stablecoin swaps
- dYdX: Derivatives and perpetuals
3. Lending Protocols
Borrow and lend without a bank:
Deposits DAI → Lending Pool
Aave, Compound → Borrower
Gets DAI, pays interest
Key difference: Loans are overcollateralized. To borrow 150 in ETH. If ETH’s price drops, you get liquidated.
4. Yield Aggregators
Automatically move your assets to the highest yield:
- Yearn Finance: Strategies that optimize yield
- Convex: Boosted Curve rewards
These protocols are like robo-advisors but on-chain.
How DeFi Protocols Work
Example: Borrowing on Aave
- Connect wallet (MetaMask, etc.)
- Deposit collateral (e.g., 1 ETH worth $2,000)
- Borrow up to 80% of collateral value ($1,600 in USDC)
- Pay interest (variable rate, typically 2-10% APR)
- Repay + get collateral back or get liquidated if collateral value drops
// Simplified Aave interaction
const aave = new ethers.Contract(AAVE_ADDRESS, AAVE_ABI, signer);
// Deposit ETH as collateral
await aave.deposit(ETH_ADDRESS, depositAmount, userAddress, 0);
// Borrow USDC
await aave.borrow(USDC_ADDRESS, borrowAmount, 2, 0, userAddress);
Example: Trading on Uniswap
Traditional exchanges match buyers and sellers. Uniswap uses liquidity pools and a mathematical formula:
x * y = k
Where:
x = amount of token A in pool
y = amount of token B in pool
k = constant
When you trade, you change the ratio, which changes the price:
Pool: 100 ETH, 200,000 USDC (k = 20,000,000)
Price: 1 ETH = 2,000 USDC
You buy 1 ETH:
- Remove 1 ETH (pool now has 99 ETH)
- Add USDC to maintain k: 200,000 / 99 * 100 = ~202,020 USDC needed
- You paid ~2,020 USDC for 1 ETH (0.1% slippage)
The Risks of DeFi
DeFi is permissionless, but it’s not risk-free:
1. Smart Contract Risk
Bugs in code = lost funds. There’s no customer service to call.
2020: $130M lost in various hacks
2021: $680M lost
2022: $3.1B lost (including bridges)
Mitigation: Use audited protocols, check TVL (Total Value Locked), start small.
2. Liquidation Risk
Your collateral can be seized if prices drop:
You deposit 1 ETH ($2,000) and borrow 1,500 USDC
ETH drops to $1,800: Collateral ratio = 120%, still safe
ETH drops to $1,500: Collateral ratio = 100%, LIQUIDATED
You lose your ETH, and you still owe the debt.
3. Oracle Risk
DeFi relies on oracles (Chainlink, etc.) for price data. If the oracle reports wrong prices, protocols make wrong decisions.
4. Impermanent Loss
Liquidity providers lose money when prices move:
You provide ETH + USDC to a pool
ETH price doubles
You would have been better off just holding ETH
The "lost" gains = impermanent loss
DeFi Safety Checklist
Before using any protocol:
- Audits: Has it been audited by reputable firms?
- TVL: How much value is locked? (Higher = more trust)
- Time: How long has it been running? (Longer = battle-tested)
- Team: Is the team public? (Doxxed teams have reputation at stake)
- Code: Is it open source? (Can be verified)
Practice Exercises
Exercise 1: Explore DeFi (Beginner)
Without transacting, explore:
- Visit DeFi Llama and find the top 5 protocols by TVL
- Check the TVL of Aave on Ethereum vs Polygon
- Look up the current borrow rate for USDC on Aave
Exercise 2: Calculate Liquidation (Intermediate)
You deposit 2 ETH (current price: 4,000 collateral) You borrow 2,400 USDC Liquidation threshold: 80%
At what ETH price will you be liquidated?
Answer
Liquidation occurs when: Collateral Value < Debt / 0.80
3,000 minimum collateral needed
1,500 per ETH**
If ETH drops to $1,500, you get liquidated.
Exercise 3: Impermanent Loss (Advanced)
You provide liquidity: 1 ETH ($2,000) + 2,000 USDC
After one month, ETH = $4,000
Calculate:
- What your position is worth in the pool (50/50 value split)
- What it would be worth if you just held
- Your impermanent loss
Answer
In pool: Total value = 2 * sqrt(1 * 2000 * 2 * 4000) = ~$5,656
If you held: 1 ETH (6,000
Impermanent loss: 5,656 = $344 (5.7%)
Knowledge Check
-
What makes DeFi “decentralized”?
-
Why are DeFi loans overcollateralized?
-
What is impermanent loss?
-
How does Uniswap determine prices?
-
You see a DeFi protocol offering 1000% APY. What questions should you ask?
Answers
-
No central custodian or intermediary. Smart contracts execute automatically; users maintain custody of their assets.
-
No credit checks. DeFi is permissionless-there’s no way to verify creditworthiness. Overcollateralization ensures the protocol can recover funds if the borrower defaults.
-
Loss from price divergence when providing liquidity. The AMM rebalances your position, so you end up with less of the appreciating asset than if you’d just held.
-
The constant product formula (x * y = k). Trading changes the ratio of tokens in the pool, which changes the price. Larger trades = more price impact.
-
Where does the yield come from? (Token emissions? Real revenue?) What are the risks? Is it audited? How long has it existed? (High APY often means high risk or unsustainable tokenomics.)
Summary
| Concept | Key Point |
|---|---|
| DeFi | Financial services without centralized intermediaries |
| Stablecoins | Price-stable tokens for DeFi payments and pricing |
| DEXs | Trade tokens via liquidity pools, not order books |
| Lending | Overcollateralized loans, algorithmic interest rates |
| Risks | Smart contract bugs, liquidation, oracles, impermanent loss |
What’s Next?
🎯 Continue learning:
- Crypto Wallet Types - Securing your keys
- Stablecoins Explained - The foundation of DeFi
🔬 Expert level: See DeFi Protocol Security for production considerations.
You now understand the infrastructure that’s rebuilding finance from first principles. 💰
Questions about this lesson? Working on related infrastructure?
Let's discuss