Defi (1)

Defi History Map
  • 2009 BTC:用Scripts写的BTC不足以支持多样化的Defi应用场景
  • 2014 Maker: Dai
  • 2015 ETH:Solidity Language + ERC20 to create Token
  • 2017 EtherDelta: one of the first decentralized exchanges built on ETH that allows permissionless exchange for ERC20 Tokens based on Order Book. Hacked in 2018
  • 2017 ICO Mania:
    • Defi from ICO era: AAVE, Synthetix, Bancor
  • Before Comp: Ren, Kyber Network, ZeroX,
  • 2018 Uniswap: Liquidity Pool + AMM(CMM)
  • 2019 Synthetix: First liquidity incentive programme
  • 12 Mar 2020: ETH price dropped by 30%+, ETH gas fee raised dramatically to 200Gwei, the biggest ... for the still nascent Defi industry
  • Defi Summer in 2020
    • the main catalyst is liquidity mining program of Comp token launched by Compound. Incentivize to keep switching between supplying and borrowing. Compound Governance
    • Yearn Finance in early 2020: Automatically switch between different Defi protocols
    • Yam in August 2020: rewarding holders, YCRV-YAM
    • Sushiswap in August 2020: Vampire Attack
    • Uni — Uniswap Token: Liquidity mining program
      • notion image
  • Defi Winter in 2020 and bounced back
Types of Defi
  1. Lending and Borrowing
      • Compound: C Tokens — own price feed
      • Aave: A Tokens — reply on Chainlink
  1. Stable Coins (centralized)
  1. Dexes (Decentralized Exchanges)
    1. Supplying Capital to Liquidity Pools
      Supplying Capital to Liquidity Pools
  1. Derivatives
  1. Margin Trading
  1. Insurance
    1. Protection against smart contract failures
  1. Oracles (Data Feeds — Chainlink)
EIP 1559 Gas Fee Model
  • Original Fee Model:
    • First-price Auction, 油费不自动调整
  • EIP 1559: Ethereum Improvement Proposal
    • Smoothing fee spikes
    • Limiting the number of overpaid transactions by making fees more predictable
  • Improvements:
    • BaseFee:
      • Minimum gas fee has to be paid and can be adjusted depending on how congestion ETH network is. Equilibrium is 50% 基于前一个block的capacity与gas fee的信息set base fee, 25m表示100%负荷
    • Capacity:
      • change max gas limit per block from 12.5m to 25m — doubling the block size
notion image
  • FeeCap lower than current fee needs to wait to be included in the block
  • Less profit for the miners: only miner tip
  • BaseFee Burning:
Uniswap V3
  • Uniswap is a protocol (set of contracts) for decentralized exchange of tokens on Ethereum Blockchain built on the concept of liquidity pools(LP) and automated market makers(AMM) or, to be precise, a constant product market maker(CMM).
  • Ratios of the Tokens in the Pool Dictates Price
  • V1 Nov 2018: ERC20-ETH (impairment loss)
  • V2 May 2020: ERC20-ERC20
  • V3 Mar 2021: Better Capital Efficiency
    • Concentrated Liquidity
    • Active Liquidity
    • Range Limit Orders
    • Multiple Price Ranges
    • Non-fungible Liquidity ERC721
    • Flexible Fees
    • Improvement in Uniswap Oracle
    • Uniswap Layer2 (lower gas fees for users)
    • notion image
      notion image
  • Sushiswap steal
Liquidity Pools(Dai/ETH,BTC/ETH)
Liquidity pools, in essence, are pools of tokens that are locked in a smart contract. They are used to facilitate trading by providing liquidity and are extensively used by some of the decentralized exchanges a.k.a DEXes.
传统交易模式是 Market Maker 下的 Order Book
Defi 使用 Automated Money Maker(AMM)
交易是很难在处理能力有限的Layer1做,在Layer2做步骤又会太多,因此用Liquidity Pools
notion image
notion image
Uniswap 用的是Constant Product Market Maker Algorithm
Ratios of the Tokens in the Pool Dictates Price [区域性的兑换市场,那怎么做到一价定律? ]; 因此 pool越大,小规模兑换发生很大price impact(Slippage)的概率更低,Large pools can accommodate bigger trades without moving the price too much
The Ampleforth protocol translates price-volatility into supply-volatility. This means the number of AMPL tokens in user wallets automatically increases or decreases based on price:
Wallets
  • Metamask
  • Ledger (hardware wallet)
  • Argent (mobile app): Social Recovery
Yield Farming Strategies (Highly Volatile)
Yield farmers try to chase the highest yield by switching between multiple different strategies(crop rotation). The most profitable strategies usually involve at least a few DeFi protocols like Compound, Synthetix, Uniswap or Balancer.
  1. Liquidity Mining
    1. (类似于外汇? Supply Capital to liquidity pools)
      Liquidity mining is a process in which crypto holders lend assets to a decentralized exchange in return for rewards. These rewards commonly stem from trading fees accrued from traders swapping tokens and extra rewards from pools.
       
      notion image
  1. Leverage
    1. Deposit coins as collateral to borrow other coins, and further collateral
  1. Staking LP Tokens
    1. Represent participation in a Liquidity Pools
      staked on synthetix mintr?
Ampleforth (ERC20)
The Ampleforth protocol translates Price-Volatility into Supply-Volatility. This means the number of AMPL tokens in user wallets automatically increases or decreases based on price
Expansion:
  • When Price > $1, wallet balances Increase proportionally
Contraction:
  • When Price < $1, wallet balances Decrease proportionally
There are two main functions of price oracles in Ampleforth. The first one is to provide a current exchange rate of AMPL/USD. The second one is to provide a Consumer Price Index value. The CPI is used to establish a "Target Price" which is a price of 1 AMPL that the Ampleforth protocol tries to aim for.
notion image
Defi Hacks
  • The Rug Pull: Suddenly remove the majority of liquidity from a liquidity pool. “Exit Scam”
    • Meerkat Finance
    • DeTrade Fund: The man who’s backing it might be a deepfake tech
    • Economic Exploit: Flash Loan
    • Harvest Finance Hack:
    • Arbitrage: Saddle Finance/Immature Market
  • Code Audit can make mistakes
  • Iron Finance Collapse in Mar 2021:
    • Current ecosystem maintains peg to the US Dollar at the cost of
      • Avoid Centralization: the custody of USDC/USDT
      • Avoid Capital Inefficiency: Stable Coins(Dai) with full collaterals
    • IronFinance tried to address above two problems by creating a partially collateralized stablecoin - IRON.
      • First large-scale bank run in Defi
Impairment Loss