What Is DeFi? Complete Guide

Decentralized Finance explained. From first principles to protocols, understand how finance is being rebuilt without intermediaries.

Beginner 35 min read Expert Version →

🎯 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

📚 Prerequisites

Before this lesson, you should understand:

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

AspectTraditional FinanceDeFi
CustodianBanks hold your assetsYou hold your assets
AccessBank account requiredWallet required
HoursBusiness hours, weekdays24/7/365
PermissionKYC, credit checksPermissionless
TransparencyAudited quarterlyEvery transaction public
SpeedDays for settlementMinutes

The Stack

Applications
Uniswap, Aave, Compound
↓↑
Smart Contracts
Solidity code on chain
↓↑
Blockchain
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):

StablecoinTypeBacked By
USDCFiat-backedUSD in bank accounts
USDTFiat-backedUSD + other assets
DAICrypto-backedOvercollateralized 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:

Lender
Deposits DAI
Lending Pool
Aave, Compound
Borrower
Gets DAI, pays interest

Key difference: Loans are overcollateralized. To borrow 100,youmightdeposit100, you might deposit 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

  1. Connect wallet (MetaMask, etc.)
  2. Deposit collateral (e.g., 1 ETH worth $2,000)
  3. Borrow up to 80% of collateral value ($1,600 in USDC)
  4. Pay interest (variable rate, typically 2-10% APR)
  5. 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:

  1. Visit DeFi Llama and find the top 5 protocols by TVL
  2. Check the TVL of Aave on Ethereum vs Polygon
  3. Look up the current borrow rate for USDC on Aave

Exercise 2: Calculate Liquidation (Intermediate)

You deposit 2 ETH (current price: 2,000each=2,000 each = 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

2,400/0.80=2,400 / 0.80 = 3,000 minimum collateral needed

3,000/2ETH=3,000 / 2 ETH = **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:

  1. What your position is worth in the pool (50/50 value split)
  2. What it would be worth if you just held
  3. Your impermanent loss
Answer

In pool: Total value = 2 * sqrt(1 * 2000 * 2 * 4000) = ~$5,656

If you held: 1 ETH (4,000)+2,000USDC=4,000) + 2,000 USDC = 6,000

Impermanent loss: 6,0006,000 - 5,656 = $344 (5.7%)


Knowledge Check

  1. What makes DeFi “decentralized”?

  2. Why are DeFi loans overcollateralized?

  3. What is impermanent loss?

  4. How does Uniswap determine prices?

  5. You see a DeFi protocol offering 1000% APY. What questions should you ask?

Answers
  1. No central custodian or intermediary. Smart contracts execute automatically; users maintain custody of their assets.

  2. No credit checks. DeFi is permissionless-there’s no way to verify creditworthiness. Overcollateralization ensures the protocol can recover funds if the borrower defaults.

  3. 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.

  4. 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.

  5. 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

ConceptKey Point
DeFiFinancial services without centralized intermediaries
StablecoinsPrice-stable tokens for DeFi payments and pricing
DEXsTrade tokens via liquidity pools, not order books
LendingOvercollateralized loans, algorithmic interest rates
RisksSmart contract bugs, liquidation, oracles, impermanent loss

What’s Next?

🎯 Continue learning:

🔬 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