Module 9: DeFi Deep Dive

What DeFi Is

Chapter 1 of 14 · about 5 minutes

1.1 A bank made of code

Mint wanted to earn interest on some stablecoins. A bank would take days to open an account, ask for documents, and pay very little. A DeFi lending protocol took two minutes: connect a wallet, approve, deposit. Interest started accruing immediately.

"Who's paying me?" Mint asked. "There's no bank."

"Borrowers," said Hash. "Through a smart contract that matches them with lenders automatically, sets interest rates by formula, and liquidates borrowers who don't keep enough collateral. No staff, no branch, no opening hours. That's DeFi. It's powerful, and it fails in ways banks don't. This module is about both."

1.2 What DeFi is

Decentralised finance (DeFi) is the name for financial services built on smart contracts (Module 1, Chapter 4): trading, lending, borrowing, stablecoins, derivatives, staking, and more, running on public blockchains without a central company holding users' funds.

You've already met many DeFi building blocks in this series:

Building blockIntroduced in
Decentralised exchanges and AMMsModule 1, Chapter 8
StablecoinsModule 1, Chapter 5
Token approvals and signaturesModule 2, Chapters 7 and 8
Gas, MEV, and oraclesModule 3, Chapters 2, 11, and 12
Evaluating DeFi protocolsModule 5, Chapter 10
On-chain DeFi dataModule 6, Chapter 9
Decentralised perps and options vaultsModules 7 and 8

This module brings them together and goes deeper.

1.3 The core properties

PropertyWhat it meansWhy it matters
Non-custodialYou keep control of your assets until you deposit them into a smart contract, and often can withdraw any timeNo company can freeze or misuse your funds, though contracts can fail
PermissionlessAnyone with a wallet can use it, usually without accounts or approvalOpen to anyone, including people excluded from traditional finance
TransparentAll transactions and balances are visible on-chainRisks and activity can be checked by anyone (Module 6)
ComposableProtocols can plug into each other like building blocksRapid innovation, and chains of dependency
AutomatedRules are enforced by code, without human discretionPredictable, but unforgiving of bugs and edge cases

1.4 Money legos

Composability is often described as "money legos." Because DeFi protocols are open smart contracts, any protocol can use any other.

Here's a simple stack:

  1. Mint deposits ETH into a liquid staking protocol and receives a token representing staked ETH (Chapter 8).
  2. Mint deposits that token into a lending protocol as collateral (Chapter 5).
  3. Mint borrows stablecoins against it (Chapter 7).
  4. Mint deposits those stablecoins into a liquidity pool on a DEX (Chapter 3).

Four protocols, each building on the last, all in minutes, with no applications or approvals. That's remarkable. It's also a chain where any weak link can break the whole thing (Chapter 12).

"So it's like building with blocks where every block can fail independently," said Node.

"And where some blocks hold up others," said Hash. "Composability multiplies both the possibilities and the risks."

Chapter 1 · Money legos

ETH is staked into a liquid staking token, which is supplied as collateral to a lending market, against which USDC is borrowed and deposited into a DEX liquidity pool. Each layer adds contract, oracle, and liquidation risk from every layer beneath it.

DeFi protocols stack on top of each other like legos. That composability is powerful, but each layer inherits the risks of the ones below — a problem in the base can ripple all the way up the stack.

1.5 DeFi compared with traditional finance and CeFi

Traditional financeCentralised crypto finance (CeFi)DeFi
Who holds fundsBanks and brokersCrypto companiesSmart contracts
AccessAccounts, identity checksAccounts, usually KYCA wallet
Opening hoursBusiness hours for many services24/724/7
TransparencyLimited, periodic reportsLimited, sometimes proof of reservesFull on-chain visibility
Recourse if something goes wrongRegulation, deposit insurance, courtsVaries; often limitedUsually none
Main risksInstitutional failure, though often insuredCompany fraud or failure (Module 1, Chapter 7)Code bugs, oracle and economic failures, user error

The 2022 collapses of several crypto lending companies, which took customer deposits and made risky loans behind closed doors, were CeFi failures. Many DeFi protocols operating transparently on-chain continued working through that period, with liquidations executing automatically. That episode made DeFi's transparency argument concrete. But DeFi has had plenty of failures of its own, through hacks, bugs, and broken economic designs.

1.6 Where DeFi yields come from

Before using any DeFi product, ask where the yield comes from (Module 2, Chapter 11, and Module 5, Chapter 10).

SourceExampleSustainability
Borrowers paying interestLending protocolsDepends on borrowing demand
Traders paying feesDEX liquidity provisionDepends on trading volume, offset by impermanent loss (Chapter 4)
Network rewardsStaking (Chapter 8)Tied to network issuance and fees
Funding and basisDelta-neutral strategies (Module 7, Chapter 12)Depends on market conditions
Token incentivesLiquidity mining (Chapter 10)Temporary; paid through dilution
Points and expected airdropsNew protocolsSpeculative

1.7 The DeFi risk map

RiskExampleChapter
Smart contractA bug lets an attacker drain funds13
OracleManipulated prices trigger bad liquidations (Module 3, Chapter 12)13
Economic designA stablecoin's mechanism fails under stress7 and 12
LiquidationCollateral falls in value and your position is closed6
Impermanent lossPrice changes reduce liquidity provider value4
Composability and contagionA failure in one protocol spreads to others12
Governance and admin keysParameters changed or contracts upgraded against users' interests13
User errorWrong approvals, phishing, or sending to wrong networks (Module 2)13

1.8 Try it yourself

Open a DeFi analytics dashboard that lists protocols by category. Note the largest protocols in DEXs, lending, liquid staking, and stablecoins, and their total value locked. Then pick one lending protocol and find the current supply and borrow rates for USDC. Where would that supply rate come from?

Key takeaways from this chapter

  1. DeFi provides financial services through smart contracts on public blockchains, without central custodians.
  2. Its core properties are non-custodial, permissionless, transparent, composable, and automated.
  3. Composability lets protocols stack like building blocks, multiplying both innovation and risk.
  4. DeFi differs from traditional finance and CeFi in custody, access, transparency, recourse, and risks.
  5. Always trace where a yield comes from: borrowers, traders, network rewards, funding, incentives, or speculation.
  6. DeFi risks include smart contracts, oracles, economic design, liquidations, impermanent loss, contagion, governance, and user error.