info@cyberlawacademy.com | +91-XXXXXXXXXX
Part 4 of 7

Decentralized Finance (DeFi) Protocols

Explore the architecture of lending platforms, decentralized exchanges, yield farming strategies, and stablecoin mechanisms that power the $50B+ DeFi ecosystem.

[T] ~120 minutes [S] 5 Sections [P] 8 Protocol Deep-Dives

4.1 What is DeFi?

Decentralized Finance (DeFi) recreates traditional financial services using smart contracts on public blockchains, eliminating intermediaries and enabling permissionless, programmable money.

Decentralized Finance (DeFi)
An ecosystem of financial applications built on blockchain networks that operate without traditional intermediaries, using smart contracts to automate financial services like lending, trading, and derivatives.

DeFi vs. Traditional Finance

AspectTraditional FinanceDeFi
IntermediariesBanks, brokers, clearinghousesSmart contracts
AccessKYC/AML required, geographic limitsPermissionless, global
Operating HoursBusiness hours, holidays24/7/365
TransparencyLimited, audited quarterlyReal-time, on-chain
CustodyThird-party (bank)Self-custody
SettlementT+2 days (stocks)Seconds to minutes
ComposabilitySiloed systems"Money Legos" - interoperable

Key DeFi Primitives

  • Lending/Borrowing: Collateralized loans without credit checks
  • Decentralized Exchanges: Token swaps without order books
  • Stablecoins: Price-stable assets pegged to fiat currencies
  • Yield Aggregators: Automated yield optimization
  • Derivatives: Synthetic assets and options
  • Insurance: Coverage against smart contract failures
Composability: "Money Legos"

DeFi protocols can be combined like building blocks. A user can: (1) deposit ETH as collateral, (2) borrow DAI, (3) swap DAI for USDC on a DEX, (4) provide liquidity to earn fees - all in a single transaction. This composability enables complex financial strategies but also creates systemic risk.

4.2 Lending Protocols

DeFi lending enables users to earn interest on deposits or borrow against collateral without intermediaries. Interest rates are determined algorithmically based on supply and demand.

How Lending Protocols Work

Lending Protocol Architecture
Lenders
Deposit assets, earn interest
-->
Liquidity Pool
Smart contract holds assets
-->
Borrowers
Post collateral, borrow

Major Lending Protocols

Aave TVL: $10B+

Multi-chain lending protocol with variable and stable interest rates, flash loans, and governance token (AAVE). Supports 7+ blockchains including Ethereum, Polygon, and Arbitrum.

  • aTokens: Interest-bearing tokens representing deposits
  • Flash Loans: Uncollateralized loans repaid in same transaction
  • Credit Delegation: Allows undercollateralized borrowing through trust
Compound TVL: $2B+

Pioneer of algorithmic interest rate markets. Users supply assets to earn interest or borrow against collateral. COMP governance token enables community control.

  • cTokens: ERC-20 tokens representing supplied assets
  • Interest Rate Model: Algorithmic rates based on utilization
  • Governance: COMP holders propose and vote on changes

Key Concepts

Collateralization Ratio
The ratio of collateral value to borrowed value. DeFi loans are typically over-collateralized (e.g., 150%) meaning $150 of collateral for $100 borrowed.
Liquidation
When collateral value falls below the required threshold, third parties (liquidators) can repay part of the debt and claim collateral at a discount, protecting the protocol from bad debt.
Utilization Rate
The percentage of deposited assets currently borrowed. Higher utilization = higher interest rates, incentivizing deposits and discouraging borrowing.
Legal Consideration: Securities

Interest-bearing tokens (aTokens, cTokens) may constitute securities under certain jurisdictions' laws. The Howey test analysis depends on expectations of profit, common enterprise, and reliance on others' efforts. Legal status remains unsettled.

4.3 Decentralized Exchanges (DEXs)

DEXs enable token swaps without centralized order books or custodians. The dominant model uses Automated Market Makers (AMMs) with liquidity pools.

Automated Market Makers (AMMs)

Automated Market Maker
A smart contract that holds reserves of two or more tokens and enables trading based on a mathematical formula, rather than matching buyers and sellers.

Constant Product Formula (Uniswap v2)

The most common AMM formula: x * y = k

  • x: Quantity of Token A in the pool
  • y: Quantity of Token B in the pool
  • k: Constant (product must remain unchanged)

Example: Pool has 100 ETH and 200,000 DAI (k = 20,000,000). To buy 1 ETH, you must add enough DAI to maintain k.

Major DEX Protocols

Uniswap Volume: $1T+ cumulative

The largest DEX by volume. Pioneered the constant product AMM model. Uniswap v3 introduced concentrated liquidity positions for capital efficiency.

Curve Finance TVL: $2B+

Optimized for stablecoin swaps with minimal slippage using the StableSwap invariant. Critical infrastructure for DeFi stablecoin liquidity.

Liquidity Provision

Users deposit token pairs into pools and earn trading fees proportional to their share. However, liquidity providers face impermanent loss.

Impermanent Loss
The difference between holding tokens in a liquidity pool vs. simply holding them. When token prices diverge, LPs end up with more of the depreciated token and less of the appreciated one.
Impermanent Loss Example

You deposit $1,000 worth of ETH and $1,000 USDC into a pool.
ETH price doubles. If you had just held: $2,000 ETH + $1,000 USDC = $3,000
In the pool: Arbitragers rebalance, you now have ~$1,414 ETH + ~$1,414 USDC = $2,828
Impermanent loss: $172 (5.7%)
Trading fees may or may not compensate for this loss.

4.4 Yield Farming & Aggregators

Yield Farming
The practice of moving assets between DeFi protocols to maximize returns through interest, trading fees, and token incentives. Also called "liquidity mining."

Sources of Yield

SourceDescriptionRisk Level
Lending InterestInterest paid by borrowersLow-Medium
Trading FeesShare of DEX swap feesMedium
Liquidity MiningToken incentives for providing liquidityMedium-High
Staking RewardsProof-of-Stake validator rewardsLow-Medium
Governance TokensProtocol token distributionsHigh (volatile)

Yield Aggregators

Automated protocols that optimize yield by automatically moving funds between strategies.

Yearn Finance TVL: $300M+

Pioneer of yield aggregation. "Vaults" automatically compound and optimize yields across DeFi protocols. Users deposit assets and receive yield-bearing vault tokens.

Yield Farming Risks

Smart Contract Risk: Bugs in any protocol in the strategy chain
Impermanent Loss: For strategies involving LP positions
Token Price Risk: Reward tokens may collapse in value
Rug Pull Risk: New protocols may be malicious
Gas Costs: Frequent transactions can erode returns
Regulatory Risk: Unclear legal status of yield farming

4.5 Stablecoins

Stablecoins maintain a stable value (usually $1 USD) and are essential DeFi infrastructure for trading, lending, and payments.

Stablecoin Types

TypeMechanismExamplesRisks
Fiat-Backed1:1 reserves in bank accountsUSDC, USDT, BUSDCounterparty, regulatory
Crypto-BackedOver-collateralized crypto depositsDAI, LUSDLiquidation cascades
AlgorithmicAlgorithmic supply adjustmentFRAX (partial)Death spiral (see UST)

Case Study: MakerDAO & DAI

DAI is a decentralized, crypto-collateralized stablecoin governed by MakerDAO.

  1. Users deposit collateral (ETH, WBTC, etc.) into a "Vault"
  2. Users mint DAI against their collateral (minimum 150% collateralization)
  3. Users pay a "Stability Fee" (interest) when repaying DAI
  4. If collateral falls below threshold, position is liquidated
  5. DAI Savings Rate (DSR) incentivizes DAI holding
Algorithmic Stablecoin Collapse: UST/LUNA

In May 2022, the algorithmic stablecoin UST (backed by LUNA) collapsed from $1 to near $0, destroying $40+ billion in value. The "death spiral" occurred when UST lost its peg, causing LUNA hyperinflation as the algorithm tried to restore the peg. This event triggered increased regulatory scrutiny of stablecoins globally.

Regulatory Landscape

US: Proposed legislation (Stablecoin TRUST Act) would require federal or state licensing
EU: MiCA requires stablecoin issuers to be authorized credit institutions
UK: Financial Services and Markets Bill brings stablecoins under FCA regulation
Singapore: MAS regulates stablecoins pegged to Singapore dollar

Key Takeaways

  • DeFi recreates financial services using smart contracts, enabling permissionless, 24/7 access
  • Lending protocols require over-collateralization and automated liquidation
  • AMM DEXs use mathematical formulas instead of order books
  • Impermanent loss is a key risk for liquidity providers
  • Yield farming combines multiple DeFi primitives for returns - and risks
  • Stablecoins are critical infrastructure but face regulatory scrutiny
  • Composability enables innovation but creates systemic contagion risk