Learning Objectives – after this chapter you will be able to:
  • Explain DeFi and compare it with traditional finance.
  • Describe stablecoins, DEXs, AMMs, lending and liquidity pools.
  • Calculate a simple AMM swap using x × y = k.
  • Explain how a DAO is governed and the risks of DeFi and DAOs.
Decentralized Finance (DeFi)
DeFi refers to financial services – trading, lending, borrowing, saving, payments – provided by smart contracts on public blockchains instead of banks and brokers. Anyone with a wallet can use them, at any time, without asking permission.
BasisTraditional FinanceDeFi
IntermediaryBanks, brokers, clearing housesSmart contracts
AccessAccount opening, KYC, business hoursAnyone with a wallet, 24×7
CustodyInstitution holds fundsUser holds keys (non-custodial)
TransparencyInternal recordsOpen code and on-chain data
ProtectionRegulation, deposit insuranceLargely depends on code quality; limited recourse
Building Blocks of DeFi
  • Stablecoins – tokens designed to hold a stable value, usually 1 US dollar:
    • Fiat-backed – reserves held by an issuer (e.g. USDC).
    • Crypto-collateralised – over-collateralised by crypto in smart contracts (e.g. DAI).
    • Algorithmic – rely on supply rules; some have failed dramatically and lost their peg.
  • Decentralized exchanges (DEXs) – swap tokens directly from your wallet.
  • Automated Market Makers (AMMs) – instead of an order book, prices come from a formula applied to a liquidity pool.
  • Liquidity providers (LPs) deposit token pairs into pools, receive LP tokens and earn a share of trading fees.
  • Lending protocols – users deposit assets to earn interest; borrowers must lock more collateral than they borrow (over-collateralisation). If collateral value falls too far, the position is liquidated.
  • Flash loans – uncollateralised loans that must be borrowed and repaid within the same transaction, otherwise the whole transaction reverts.
Constant-Product AMM (x × y = k)

Pools such as Uniswap v2 keep the product of the two token reserves constant (before fees).

  • Pool: 10 ETH and 20,000 USDC → k = 10 × 20,000 = 200,000 (implied price 2,000 USDC per ETH).
  • A trader adds 1 ETH (ignoring fees): new ETH reserve = 11 → new USDC reserve = 200,000 ÷ 11 ≈ 18,181.82.
  • The trader receives 20,000 − 18,181.82 ≈ 1,818.18 USDC – less than 2,000 because of price impact (slippage). Larger trades relative to the pool size have larger impact.
  • Impermanent loss: when prices change, LPs may end up with less value than if they had simply held the tokens; fees may or may not compensate.
Decentralized Autonomous Organisations (DAOs)
A DAO is an organisation whose rules and treasury are managed by smart contracts, and whose decisions are made by its members – usually holders of a governance token – through on-chain or off-chain voting.
  1. A member submits a proposal (e.g. change a fee, fund a project).
  2. Token holders vote; voting power is usually proportional to tokens held or delegated.
  3. If quorum and majority are reached, the action is queued (often behind a timelock for safety) and then executed automatically by the contract.
  • Uses: governing DeFi protocols, managing shared treasuries, funding public goods, investment clubs, collectors’ groups.
  • Challenges: low voter participation, concentration of tokens in a few “whales”, governance attacks, smart-contract bugs (The DAO, 2016) and unclear legal status in many countries.
Risks of DeFi
  • Smart-contract risk – bugs or exploits can drain funds.
  • Oracle risk – manipulated or stale prices (Chapter 28).
  • Liquidation risk – volatile collateral can be sold automatically.
  • Stablecoin de-peg risk – a stablecoin can lose its target value.
  • Scams and “rug pulls” – developers abandoning a project with users’ funds.
  • Regulatory risk – rules differ by country and continue to evolve.
Key Takeaways
  • DeFi replaces financial intermediaries with open, non-custodial smart contracts.
  • AMMs price trades with x × y = k; larger trades cause more price impact.
  • DAOs govern through token-weighted proposals and votes executed by contracts.
Question / Answer (15 questions)

Answer : DeFi is the set of financial services – trading, lending, borrowing, saving and payments – implemented as smart contracts on public blockchains, available to anyone with a wallet without relying on banks or brokers.

Answer : DeFi uses smart contracts instead of institutions as intermediaries; it is open 24×7 to anyone with a wallet rather than requiring accounts and business hours; and users usually keep custody of their own assets while all code and transactions are publicly visible.

Answer : A stablecoin is a token designed to keep a stable value, usually pegged to a fiat currency such as the US dollar. Types: fiat-backed (reserves held by an issuer), crypto-collateralised (over-collateralised by crypto in contracts) and algorithmic (maintained by supply rules).

Answer : A DEX is a smart-contract-based exchange where users swap tokens directly from their own wallets without depositing funds with a central operator.

Answer : An AMM is a type of DEX that prices trades using a mathematical formula applied to token reserves in a liquidity pool, instead of matching buy and sell orders in an order book.

Answer : In a pool of two tokens with reserves x and y, every trade must keep the product x × y equal to the constant k (before fees). Adding one token increases its reserve, so the reserve of the other token must decrease, which determines how much the trader receives.

Answer : k = 200,000. After the trade the ETH reserve is 11, so the USDC reserve becomes 200,000 ÷ 11 ≈ 18,181.82. The trader receives about 20,000 − 18,181.82 = 1,818.18 USDC.

Answer : It is the difference between the expected price and the actual execution price caused by the trade itself moving the pool’s reserves. Larger trades relative to pool size cause greater price impact.

Answer : They earn a share of the trading fees in the pool, represented by LP tokens. They face impermanent loss, where price changes leave them with less value than simply holding the tokens.

Answer : Borrowers are pseudonymous and there is no credit check or legal recovery process. Requiring collateral worth more than the loan protects lenders; if collateral value falls too far, it is automatically liquidated.

Answer : An uncollateralised loan that must be borrowed and repaid within the same transaction. If it is not repaid by the end of the transaction, the entire transaction reverts as if it never happened.

Answer : A Decentralized Autonomous Organisation is an organisation whose rules and treasury are encoded in smart contracts and whose decisions are made collectively by members, usually governance-token holders, through voting.

Answer : A member creates a proposal; token holders vote with power proportional to their tokens or delegated votes; if quorum and majority are met, the decision is often queued behind a timelock and then executed automatically by the governance contract.

Answer : Low voter participation, concentration of voting power among a few large holders, and smart-contract or governance attacks; unclear legal status in many jurisdictions is another challenge.

Answer : Smart-contract bugs and exploits, oracle manipulation, liquidation of volatile collateral, stablecoin de-pegging; scams such as rug pulls and changing regulations are further risks.
MCQ Test : Check Your Understanding (5 questions)

Select an option and press Check Answer, or answer all questions and press Submit Test to see your score. Each answer comes with an explanation.

Q1. In a constant-product AMM, the invariant is:

Show Answer

Correct Answer : B. x × y = k
Constant-product pools keep the product of reserves constant.

Q2. A loan that must be repaid within the same transaction is a:

Show Answer

Correct Answer : A. Flash loan
If a flash loan is not repaid, the whole transaction reverts.

Q3. DAI is an example of a:

Show Answer

Correct Answer : C. Crypto-collateralised stablecoin
DAI is backed by over-collateralised crypto assets in smart contracts.

Q4. In most DAOs, voting power is based on:

Show Answer

Correct Answer : D. Governance tokens held or delegated
Token-weighted voting is the most common model.

Q5. Liquidity providers may receive less value than simply holding tokens due to:

Show Answer

Correct Answer : A. Impermanent loss
Price divergence between pooled tokens causes impermanent loss.

Bibliography/References

The notes, questions and MCQs on this page are original explanations written for this course. The works listed below were consulted and are cited for attribution and further reading. Product names, logos and trademarks belong to their respective owners. Short quotations, where used, are marked and attributed.

  1. ethereum.org. (n.d.). Decentralized finance (DeFi). https://ethereum.org/en/defi/
  2. ethereum.org. (n.d.). What are DAOs? https://ethereum.org/en/dao/
  3. Adams, H., Zinsmeister, N., & Robinson, D. (2020). Uniswap v2 Core (Whitepaper). https://uniswap.org/whitepaper.pdf
  4. ethereum.org. (n.d.). Oracles. Ethereum Developer Documentation. https://ethereum.org/en/developers/docs/oracles/
  5. ethereum.org. (n.d.). Smart contract security. Ethereum Developer Documentation. https://ethereum.org/en/developers/docs/smart-contracts/security/
  6. Antonopoulos, A. M., & Wood, G. (2018). Mastering Ethereum: Building Smart Contracts and DApps. O’Reilly Media.