DeFi

DeFi Primitives

DeFi Primitives

Module 1 of DeFi


What Is DeFi?

DeFi = Decentralized Finance

Financial services built on blockchain without traditional intermediaries:

  • No banks
  • No brokers
  • No centralized exchanges
  • 24/7/365 operation
  • Permissionless access

"Be your own bank" — but actually.


The DeFi Stack

┌─────────────────────────────────────┐
│      AGGREGATORS & FRONTENDS        │ User interfaces
├─────────────────────────────────────┤
│      YIELD OPTIMIZERS               │ Auto-compound, strategies
├─────────────────────────────────────┤
│      DERIVATIVES                    │ Options, perps, synthetics
├─────────────────────────────────────┤
│      LENDING/BORROWING              │ Aave, Compound
├─────────────────────────────────────┤
│      DECENTRALIZED EXCHANGES        │ Uniswap, Curve
├─────────────────────────────────────┤
│      STABLECOINS                    │ USDC, DAI, USDT
├─────────────────────────────────────┤
│      BASE LAYER (Ethereum, L2s)     │ Settlement
└─────────────────────────────────────┘

Each layer builds on the ones below. This is composability.


Primitive 1: Stablecoins

Tokens pegged to stable assets (usually $1 USD).

Types

TypeExamplesMechanismTrade-off
Fiat-backedUSDC, USDTReserves in bankCentralized, censurable
Crypto-backedDAIOver-collateralized loansCapital inefficient
AlgorithmicFRAXPartial collateral + algoRisk of de-peg

Why They Matter

Stablecoins are DeFi's foundation:

  • Unit of account
  • Medium of exchange
  • Escape crypto volatility
  • On-ramp from TradFi

Primitive 2: Decentralized Exchanges (DEXs)

Trade without intermediaries.

Order Book vs AMM

Order Book (Traditional)AMM (DeFi)
Buyers/sellers post ordersLiquidity pools
Market makers neededAnyone provides liquidity
Complex, gas-intensiveSimple, gas-efficient
Examples: dYdX, SerumExamples: Uniswap, Curve

How AMMs Work

Liquidity providers deposit token pairs:

Pool: 100 ETH + 200,000 USDC
Price = 200,000 / 100 = $2,000/ETH

Buy 1 ETH:
  New pool: 99 ETH + 202,020 USDC
  Paid: 2,020 USDC (includes slippage)

Key Protocols

ProtocolSpecialty
UniswapGeneral purpose AMM
CurveStablecoin/pegged assets
BalancerMulti-asset pools
SushiSwapUniswap fork + extras

Primitive 3: Lending & Borrowing

Earn yield or access leverage without selling.

How It Works

Suppliers:

  1. Deposit assets (ETH, USDC, etc.)
  2. Receive interest-bearing tokens
  3. Earn yield from borrowers

Borrowers:

  1. Deposit collateral
  2. Borrow against it (typically 50-80% LTV)
  3. Pay interest
  4. Liquidated if collateral ratio falls

Key Protocols

ProtocolTVLKey Feature
Aave$10B+Flash loans, multiple markets
Compound$2B+cTokens, governance
MakerDAO$8B+DAI stablecoin

Liquidations

If collateral value drops too much:

Deposit: $10,000 ETH
Borrow: $6,000 USDC (60% LTV)
Liquidation threshold: 80% LTV

If ETH drops to $7,500 value:
  LTV = 6,000 / 7,500 = 80% → LIQUIDATED
  Liquidator repays debt, takes collateral at discount

Primitive 4: Derivatives

Synthetic exposure to assets or events.

Types

DerivativeDescriptionExamples
Perpetual SwapsFutures without expirydYdX, GMX
OptionsRight to buy/sellDopex, Lyra
SyntheticsTokens tracking any assetSynthetix
Prediction MarketsBet on outcomesPolymarket

Perpetual Swaps

Most popular DeFi derivative:

  • No expiry date
  • Funding rate keeps price aligned
  • High leverage (up to 100x)
  • $100B+ daily volume

Primitive 5: Yield Aggregators

Automatically optimize yield across protocols.

How They Work

1. User deposits asset
2. Protocol finds best yield opportunity
3. Auto-compounds rewards
4. Socializes gas costs

Example:
  Without aggregator: 10% APY, manual claims
  With aggregator: 12% APY (compounding), no effort

Key Protocols

ProtocolStrategy
YearnMulti-strategy vaults
ConvexCurve yield boosting
BeefyCross-chain yield

DeFi Composability

The magic of DeFi: protocols interact seamlessly.

Example: Yield Farming Loop

1. Deposit ETH as collateral (Aave)
2. Borrow stablecoins (Aave)
3. Provide liquidity (Curve)
4. Stake LP tokens (Convex)
5. Earn:
   - Aave deposit interest
   - Curve trading fees
   - CRV rewards
   - CVX rewards

All in one transaction with flash loans!


Risks in DeFi

Smart Contract Risk

Code bugs = lost funds. Major hacks:

  • The DAO ($60M, 2016)
  • Wormhole ($320M, 2022)
  • Ronin ($625M, 2022)

Oracle Risk

Price feeds can be manipulated.

Liquidation Risk

Volatility can trigger cascading liquidations.

Regulatory Risk

Uncertain legal status in many jurisdictions.

Rug Pulls

Anonymous teams can steal funds.


DeFi vs TradFi

AspectTradFiDeFi
AccessPermissionedPermissionless
HoursBusiness hours24/7/365
SettlementT+2 daysSeconds/minutes
CustodyCounterpartySelf-custody
TransparencyOpaqueFully auditable
ComposabilitySiloedInteroperable
InnovationSlow (regulation)Fast (open source)

Key Takeaways

  1. Stablecoins are foundational — DeFi's unit of account
  2. AMMs replaced order books — democratized market making
  3. Lending enables leverage — capital efficiency
  4. Derivatives add sophistication — hedging, speculation
  5. Composability is the superpower — protocols build on each other
  6. Risks are real — smart contract bugs, liquidations, hacks

Questions to Consider

  1. Can DeFi ever be as safe as TradFi?
  2. What happens when a major stablecoin de-pegs?
  3. Is over-collateralization sustainable long-term?
  4. How will regulation affect DeFi?