A Blockchain Primer › Module 5 › Lesson 5.1
Lesson 5.1: When Financial Services Become Code — DeFi Products, Mechanisms, and Risks
- #1. The Core Question
- #2. An Everyday Analogy
- #3. Core Concepts Explained
- #4. Diagrams
- #5. Key Takeaways
- #6. Quiz
The last lesson covered on-chain tokens. This lesson looks at the kind of financial system those tokens can build, like lending, stablecoins, staking pools, and flash loans, and why it's both appealing and dangerous.
1. The Core Question
What if opening a bank didn't take an office building, staff, and a license anymore, just a piece of code? The program could take deposits, make loans, and liquidate collateral on its own. But one bug or one oracle error could also blow it up in an instant.
This lesson answers three questions: What exactly is DeFi? What are its typical products? And does it really reach the goal of "decentralized finance"?
The short version: DeFi writes financial products as smart contracts that run on public, permissionless chains, and it swaps central middlemen for code and collateral. It opens up access, but it also magnifies code, collateral, and legal risks.
2. An Everyday Analogy
Opening a Bank with a Program
A traditional bank needs capital, offices, employees, equipment, and a license. The DeFi vision is to write a set of smart contracts that manage accounts, take deposits, make loans, collect interest, and handle collateral automatically. Then the bank is "open for business."
The upside is automation, global reach, and transparency. The downside is that code doesn't do favors, and when something goes wrong, there's no teller at a counter to help you fix it.
Vending-Machine Finance
A vending machine takes your money and hands out goods by the rules, with no clerk needed. DeFi contracts follow rules too. Put up enough collateral, and the loan goes out. Let the price drop below the line, and liquidation kicks in.
But when a vending machine jams, you can still find someone to help. When a smart contract has a bug, there may be nobody who can help you get your money back.
3. Core Concepts Explained
3.1 Defining DeFi: Two Conditions Must Both Hold
DeFi (decentralized finance) is a decentralized financial system that offers financial products and services. It has to meet both of these conditions:
- It runs on a public, permissionless blockchain.
- It doesn't depend on middlemen.
Projects that run only on private, permissioned chains, or that a central institution still operates, don't count as DeFi. They may use a blockchain, but they don't meet the two conditions of "public and permissionless + no middlemen."
3.2 What DeFi Wants to Change
DeFi supporters usually want to change five things about traditional finance:
- Access: anyone with an internet connection can use financial services.
- Transparency: anyone can inspect transactions and contracts.
- Cost: smart contracts cut out middlemen, which lowers fees and speeds up settlement.
- Control: users control their own assets instead of handing them to third-party custodians.
- Innovation: an open, programmable environment can produce new financial products.
3.3 The Tiers of DeFi Products
Like traditional finance, DeFi products come in basic, advanced, and complex tiers.
Basic products:
- Creating, distributing, managing the supply of, and transferring cryptocurrencies and money-like tokens.
- Lending and borrowing cryptocurrencies.
Advanced products:
- Investment products that chase yield.
- Trading platforms for the basic products.
Complex services:
- Derivatives for hedging and speculation.
- Insurance.
- Portfolio management and balancing risk against return.
Complex products are built on top of basic ones, and their risks stack up too.
3.4 ICOs
An ICO (initial coin offering) is crowdfunding on a blockchain. A project creates its own tokens and sells them, usually in exchange for mainstream cryptocurrencies.
Here's how it usually works:
- Publish a whitepaper laying out the idea, goals, business model, how the funds will be used, the technical approach, and the terms of the token sale.
- Create the tokens in a smart contract.
- Sell the tokens within a limited time window.
- Use the money raised to build the project.
- Token holders use the tokens the way the contract specifies, for example to access services, pay, vote, or claim returns.
The upsides are reach across borders, speed, and very little paperwork. The downside is that there's no central vetting, which scammers take advantage of. Many ICO projects failed or ran off with the money, and the model cooled off fast.
3.5 Meme Coins
A meme coin is a digital token created and handed out to celebrate an event, a person, or an internet trend, a lot like commemorative coins, stamps, or souvenirs in the real world.
Meme coins usually:
- Spread through social media, viral sharing, and community involvement.
- Have their supply, distribution, and trading set by smart contracts.
- Get their value mostly from sentiment, hype, and community, not from technology or real uses.
The risks: wild price swings, heavy speculation, and often no practical use.
3.6 Stablecoins
Stablecoins try to keep their value close to a reference asset, like the US dollar, the euro, or gold.
There are two main approaches:
Reserve-backed. The issuer holds reserves of the matching real-world assets, and a certain amount of reserves backs each stablecoin unit. Oracles connect the reserves to the on-chain stablecoin.
Algorithmic. There are no real-world reserves. Instead, smart contract algorithms adjust supply and demand: they mint more when the price is above the target and burn coins when it's below. The algorithm needs oracles to keep feeding it the reference price and the market price.
The risks include murky reserve management, dependence on a centralized issuer, dependence on oracles, and algorithms that can fail.
3.7 Lending
DeFi lending pools users' funds together and lends them out to borrowers. Smart contracts run the whole process automatically.
The biggest difference from traditional banking is that DeFi usually only offers collateralized loans, and it often requires over-collateralization.
- Borrowers have to put up collateral worth more than the loan.
- There are no credit checks. The collateral stands in for credit.
- If the collateral's price falls to a set threshold, it's liquidated automatically and the loan ends early.
The upsides are speed, transparency, and no credit review. The downsides: collateral that swings in price can trigger surprise liquidations, and people without enough digital assets can't take part.
3.8 Staking Pools
A staking pool gathers users' cryptocurrencies to take part in PoS consensus. The pool operator handles validation and block production, and returns get split among participants based on how much each one put in.
That lets people who don't have the hardware, software, or time to run a validator node take part in staking and earn passive income. The risks: funds are usually locked up for a long time, and the operator can make mistakes or act in bad faith.
3.9 Flash Loans
A flash loan is a DeFi loan that doesn't need any collateral, but it comes with one strict condition: borrowing, using the funds, and paying back (with interest) all have to happen within a single transaction.
If any step fails, the whole transaction rolls back as if it never happened. So flash loans almost never end in "borrow and don't pay back" defaults.
The typical use is arbitrage on price differences between platforms:
- Borrow 100 tokens.
- Buy a digital asset on the cheaper platform.
- Sell it on the pricier one.
- Pay back the principal and interest.
- Keep whatever profit is left.
The risks of flash loans have more to do with law, market manipulation, and smart contract vulnerabilities than with credit risk in the traditional sense.
3.10 The DeFi Debate
Supporters point to: no central point of failure and no censorship, availability around the world and around the clock, transparent products and prices, and no formal barriers that shut users out.
Critics point to: a high risk of smart contract vulnerabilities and fraud, collateral requirements that shut out people without assets, the technical know-how users need to read contracts and understand the risks, unclear tax and legal status, and a lack of consumer protection and human advice.
People are still debating whether DeFi really reaches its goals. It'll keep changing, and regulation will reshape it too.
3.11 NFTs and DeFi
NFTs often get lumped into the DeFi ecosystem, but many NFTs have nothing to do with finance, like ID cards, driver's licenses, and academic credentials. They're closer to tokenized certificates than to financial products.
4. Diagrams
Figure 5-1-1: The Tiers of DeFi Products
Figure 5-1-2: Six Representative DeFi Products
5. Key Takeaways
- DeFi has to meet both conditions: a public, permissionless chain + no middlemen.
- DeFi's goals include access, transparency, low cost, user control, and innovation.
- Product tiers: basic products, advanced products, and complex services.
- ICOs are on-chain crowdfunding. They're fast, but prone to fraud and short on oversight.
- Meme coins run on community and hype. They're highly speculative, with little practical use.
- Stablecoins hold their value through reserves or algorithms. The risks include centralization, oracles, and algorithm failure.
- DeFi lending usually requires over-collateralization, has no credit checks, and liquidates automatically when prices fall.
- Staking pools let users pool assets for PoS, with returns split by how much each person put in, but funds may be locked up.
- Flash loans handle borrowing, using, and paying back within one transaction. If any step fails, everything rolls back.
- DeFi opens up access but brings contract vulnerabilities, exclusion of people without collateral, and legal and consumer protection problems.
6. Quiz
Part 1: Single Choice (1–4)
Question 1
What are DeFi's two necessary conditions?
A. A public, permissionless chain + no middlemen
B. A private chain + a central bank
C. High-performance servers + real-name verification
D. Fiat reserves + central clearing
Show answer
Answer: A
Explanation: DeFi has to run on a public, permissionless chain and not depend on middlemen. Private chains and centrally operated projects don't count.
Question 2
Which traditional activity is an ICO closest to?
A. Crowdfunding
B. A mortgage loan
C. An insurance claim
D. A central bank issuing currency
Show answer
Answer: A
Explanation: An ICO is on-chain crowdfunding that sells project tokens to raise money.
Question 3
What does DeFi lending usually require?
A. Over-collateralization, with no credit checks
B. Only a credit score
C. No assets at all
D. Manual approval by a bank
Show answer
Answer: A
Explanation: DeFi lending usually requires over-collateralization, with no credit checks. The collateral is what keeps the risk in check.
Question 4
What's the core feature of a flash loan?
A. Borrowing, using, and paying back all happen within a single transaction
B. You never have to pay it back
C. You can only borrow fiat
D. A central bank has to approve it
Show answer
Answer: A
Explanation: With a flash loan, borrowing, using, and paying back have to happen within one transaction, or everything rolls back.
Part 2: Multiple Choice (5–7)
Question 5
Which aspects of traditional finance do DeFi supporters want to improve?
A. Access
B. Transparency
C. Cost
D. User control
Show answer
Answer: A, B, C, D
Explanation: Access, transparency, cost, and user control are all things DeFi supporters want to improve.
Question 6
What are the risks of stablecoins?
A. Murky reserve management
B. Dependence on a centralized issuer
C. Dependence on oracles
D. Algorithms that can fail
Show answer
Answer: A, B, C, D
Explanation: Reserves, centralization, oracles, and algorithms are all sources of risk for stablecoins.
Question 7
What are DeFi's potential risks?
A. Smart contract vulnerabilities
B. Liquidations triggered by swings in collateral prices
C. Unclear legal and tax status
D. A lack of consumer protection
Show answer
Answer: A, B, C, D
Explanation: Contract vulnerabilities, liquidations, legal and tax uncertainty, and consumer protection are all DeFi risks.
Part 3: True or False (8–9)
Question 8
True or false: anything that uses a blockchain is automatically DeFi.
Show answer
Answer: False
Explanation: Using a blockchain doesn't make something DeFi. It also has to meet the public-permissionless and no-middlemen conditions.
Question 9
True or false: if any step of a flash loan fails, the whole transaction rolls back.
Show answer
Answer: True
Explanation: A flash loan is an atomic transaction. If any step fails, the whole thing rolls back.
Part 4: Scenario Analysis (10)
Question 10
A user wants to take out a DeFi loan but doesn't have enough digital assets to put up as collateral. All they've heard is that flash loans don't need collateral.
Answer the following:
- Why don't flash loans need collateral?
- Why does ordinary DeFi lending usually require over-collateralization?
- Can this user fix a "long-term cash shortage" with a flash loan?
Show answer
Answer:
- Borrowing, using, and paying back happen within a single transaction, and if any step fails, everything rolls back, so the protocol takes on no default risk.
- Ordinary loans stretch over time and carry default risk, so the collateral has to be worth more than the loan, and it gets liquidated automatically when prices fall.
- No. A flash loan has to be paid back within the same transaction, so it can't cover long-term funding needs. Long-term borrowing still needs collateral or credit behind it.