乐闻世界logo
搜索文章和话题

What is DeFi? Detailed Explanation of Decentralized Finance Core Protocols and Liquidity Mining Mechanisms

3月7日 19:41

DeFi (Decentralized Finance) is a financial services ecosystem built on blockchain, implementing lending, trading, wealth management and other financial services through smart contracts without intermediaries.

DeFi vs Traditional Finance

shell
Traditional Finance (CeFi) DeFi (Decentralized Finance) ┌──────────────┐ ┌──────────────┐ │ Banks │ │ Smart Contracts│ │ Exchanges │ → │ Auto-execution │ │ Brokers │ │ Permissionless │ └──────────────┘ └──────────────┘ ↓ ↓ Trust institutions Trust code High barriers, censored Open, transparent
FeatureTraditional FinanceDeFi
Entry BarrierIdentity verification requiredPermissionless, wallet only
Operating HoursWeekdays 9-177×24 hours
TransparencyOpaqueFully on-chain transparent
ControlInstitution controlledUser self-custody
YieldLower (0.5-3%)Higher (5-20%+)
RiskInstitution credit riskSmart contract risk

DeFi Core Protocol Types

shell
DeFi Ecosystem ├── DEX (Decentralized Exchanges) │ ├── AMM (Automated Market Maker) │ └── Order Book Model ├── Lending Protocols │ ├── Over-collateralized Lending │ └── Flash Loans ├── Stablecoins │ ├── Collateralized (DAI) │ └── Algorithmic (UST) ├── Derivatives │ ├── Perpetual Contracts │ └── Options └── Yield Aggregators └── Liquidity Mining

1. DEX (Decentralized Exchanges)

AMM (Automated Market Maker) Mechanism

Traditional Order Book vs AMM:

shell
Order Book Model: AMM Model: Buy Orders Sell Orders Liquidity Pool ┌──────┐ ┌──────┐ ┌─────────────┐ 100 │ │ 102 │ │ ETH │ USDC │ 99 │ │ 103 │ │ 100 │ 200K │ 98 │ │ 104 │ └─────────────┘ └──────┘ └──────┘ ↑ Needs counterparty Trade with pool

Constant Product Formula (Uniswap):

shell
x × y = k Where: x = Token A amount y = Token B amount k = Constant (when liquidity unchanged) Example: Pool: 100 ETH + 200,000 USDC k = 100 × 200,000 = 20,000,000 How much USDC for 1 ETH? (100 + 1) × (200,000 - Δy) = 20,000,000 Δy ≈ 1,980 USDC

Impermanent Loss

shell
Risk for liquidity providers: Initial: Deposit 1 ETH + 2000 USDC (ETH price $2000) Scenario 1: ETH rises to $4000 - Without providing liquidity: 1 ETH × $4000 + 2000 USDC = $6000 - After providing liquidity: Pool auto-balances √k =(0.707 × 2828)$5656 - Impermanent Loss: $6000 - $5656 = $344 (5.7%)

2. Lending Protocols

Over-collateralized Lending

Aave/Compound Mechanism:

shell
Deposit Process: Borrow Process: ┌─────────┐ ┌─────────┐ │Deposit │ │Collateral│ │ ETH │ │ ETH │ │Receive │ │Borrow │ │ aETH │ │ USDC │ │Earn │ │ │ │interest │ │LTV: 75% │ └─────────┘ │ │ │Interest │ │Model: │ │ • Util↑ │ │ • Rate↑ │ └─────────┘

Key Parameters:

  • Collateral Factor: 75% (can borrow up to 75% of collateral value)
  • Liquidation Threshold: 80%
  • Health Factor: Triggers liquidation when < 1

Flash Loans

Principle: Borrow and repay within one block, no collateral needed.

shell
Flash Loan Process: 1. Borrow 1000 ETH (no collateral) 2. Buy tokens on DEX A (undervalued) 3. Sell tokens on DEX B (overvalued) 4. Repay 1000 ETH + 0.09% fee 5. Arbitrage profit stays in contract ⚠️ All operations must complete in one atomic transaction

Use Cases:

  • Arbitrage
  • Collateral swapping
  • Self-liquidation

3. Stablecoins

Type Comparison

TypeMechanismRepresentativeProsCons
Fiat-backed1:1 USD reserveUSDT, USDCPrice stableCentralized
Crypto-backedOver-collateralized cryptoDAIDecentralizedCapital inefficient
AlgorithmicAlgorithm adjusts supply/demandUST (collapsed)Capital efficientDeath spiral risk

DAI Mechanism

shell
DAI Generation Process: 1. Deposit 150 ETH (value $300,000) 2. Mint 100,000 DAI (150% collateral ratio) 3. Use DAI for trading/investment 4. Return 100,000 DAI + stability fee 5. Retrieve collateralized ETH Liquidation Mechanism: - Collateral ratio < 150%: Trigger liquidation - Keeper auctions collateral - Repay DAI debt

4. Liquidity Mining (Yield Farming)

Principle

Earn token rewards by providing liquidity.

shell
Liquidity Mining Process: 1. Provide Liquidity ETH + USDC → Uniswap Pool 2. Receive LP Token 3. Stake LP Token to Farm Contract 4. Receive Rewards • Trading fees (0.3%) • Platform tokens (UNI, SUSHI)

Yield Calculation

shell
APY (Annual Percentage Yield) Calculation: Basic Formula: APY = (1 + r/n)^n - 1 Where: r = Period yield n = Compounding times per year Example: Daily yield 0.1%, compounding APY = (1 + 0.001)^365 - 144% ⚠️ Note: APY fluctuates with price, not guaranteed

Risks

  • Impermanent Loss: Price fluctuation causes LP loss
  • Smart Contract Risk: Contract vulnerabilities exploited
  • IL + Mining Rewards < 0: Token price crash
  • Rug Pull: Project team runs away with funds

5. DeFi Composability

Lego Effect:

shell
Yield Maximization Strategy Example: 1. Deposit ETH in Aave receive aETH 2. Use aETH as collateral to borrow USDC on Compound 3. Provide USDC liquidity on Curve receive CRV 4. Stake CRV receive veCRV governance rights 5. Vote on pool reward allocation Risk: More combinations = More risk (risk contagion)

Interview Key Points

  • Understand AMM constant product formula
  • Master impermanent loss calculation and impact
  • Understand over-collateralized lending liquidation mechanism
  • Understand flash loan principles and use cases
  • Familiar with pros and cons of different stablecoin types
  • Master liquidity mining yield calculation
  • Understand risks of DeFi composability
  • Able to analyze DeFi protocol economic models
标签:Blockchain