BlockChain區塊鏈
  • 本書簡介
  • 區塊鏈運作原理
  • Bitcoin介紹
    • 簡介
    • Bitcoin其他知識
  • Bitcoin原理與實作
  • BitcoinJS
    • BTC 地址格式種類
    • 從 Mnemonic 轉為地址
  • Serverless 架構實作
  • Docker常用指令
  • ethereum初探
    • ethereum歷史
    • EVM
  • ethereum PoS 節點架設
  • ethereum(Docker)
  • ethereum(Geth)
    • Parity
  • ethereum(智能合約)
    • 合約測試 Unit Test
    • DAO
    • 可升級合約
    • 使用合約進行 multiswap
    • 合約安全
    • 開發工具
    • Hardhat 教學
      • Hardhat 寫測試
    • ERC-721 範例
      • 白名單機制
    • OpenZeppelin 合約 library
    • Truffle
    • 合約部屬
    • solidity 教學
  • ethereum(Dapp)
    • 相關 SDK
    • Multicall
    • Ethers.js 使用
    • Remix IDE
    • web3.js 使用
    • 在網頁上使用 web3 並操作區塊鏈
      • solidity筆記
  • Hyperledger Fabric
  • blockchainDB
  • 挖礦程式使用教學
    • 門羅幣/Monero (XMR)
  • Bitfinex API 使用
  • FTX API
  • CCXT 通用交易所 API
  • Solana 教學
  • Ethereum BigQuery
  • The Graph
    • yaml 定義
    • mapping 語法
    • Schema 定義
    • Query 範例
    • Unit test
  • DeFi 筆記
    • MEV 相關
    • Dex 聚合
    • Yearn
    • Curve
    • Uniswap
      • Swap 互動
    • AAVE、Compound
      • Compound 原理
      • AAVE 合約開發
Powered by GitBook
On this page
  • Fee
  • Swap Fee
  • 無償損失

Was this helpful?

  1. DeFi 筆記

Uniswap

PreviousCurveNextSwap 互動

Last updated 1 year ago

Was this helpful?

相關 AMM 原理:

Fee

Swap Fee

Swap 時的 Fee 會直接加入到 liquidity pool。

UniswapV3 後每個 token pair 會有多個 pool (不同 swap fee) ,所以用戶在 add liquidity 時可以選擇 fee %,但在 UI 上 swap 時不能選擇要用哪個 fee 來 Swap,平台會自動幫你選。

無償損失

存入 Pool 內的資產,不論原始兩個 token 價格在後續的時間段上漲或是下跌,未來把 Pool 內的資產取出,換回原本的兩種資產時,其取出後的價值一定會少於當初不把兩種資產存入 Pool 的價值。

公式:

price_ratio = 1 時,代表沒漲或疊。price_ratio = 2,意思類似 ETH 從 1000 USDT 變 2000 USDT,如果兩種資產價值都漲一倍(1000, 10000)變 (2000, 20000) 則 price_ratio 為 4

impermanent_loss = 2 * sqrt(price_ratio) / (1 + price_ratio) — 1

例如下圖:ETH 上漲兩倍後 impermanent_loss 為 5.7%

公式推導:

https://docs.uniswap.org/concepts/protocol/fees#pool-fees-tiers
https://stackoverflow.com/questions/71990434/what-is-the-difference-between-these-two-pools-in-uniswap
https://www.youtube.com/watch?v=jIB4ne9jU04
Programming DeFi: Uniswap V2. Part 1 - Going the distance
Logo
Uniswap V3 Development Book - Uniswap V3 Development Book
Logo
Understanding Returns | Uniswap
Impermanent Loss Explained With Examples & Math - The Chain Bulletin
Logo
Logo