Vessel
  • βš“Introducing Vessel
    • Why Vessel Is The Exchange Crypto Needs?
    • Vessel's Roadmap for the Future of DeFi
  • βš™οΈTechnical Deep Dive
    • Sequencer
    • Prover
    • Contract
    • Data Availability
  • πŸ’°VAELOB
    • Terminology
    • Order Book and AMM: Can We Have the Best of Both?
    • A Typical Trade in Vessel
    • Liquidity Pool Math
    • Concentrated Liquidity
    • Fee Calculation
    • Multi-Pool with Different Tick Spacing
  • 🎁Vessel Voyage
    • Vessel Mileage for Liquidity Providing
    • Vessel Coins for Referral
  • πŸ›³οΈMainnet User Guide
    • Set up a Wallet
    • Deposit
    • Provide Liquidity to Vessel’s VAELOB
      • Access the Liquidity Pools
      • Add Liquidity
      • View Positions
      • Manage Positions
    • Trade
      • Order Types
      • Place Order
      • Cancel Order
      • Modify Order
      • Trading History
    • Internal Transfer - Send to Vessel's User
    • Withdraw Your Assets
    • Fees
      • Trading Fee
      • Gas Fee
      • AMM Fee
    • Trading Settings
  • πŸ›₯️Testnet User Guide
    • Log in with Invitation Code
    • Setting up a Wallet
    • Switching Network
    • Funding Your Wallet
    • How to Deposit
    • How to Trade
    • How to Withdraw
    • Community Contribution
    • Vessel’s Referral Program
    • FAQs
  • πŸ—ΊοΈSmart Contract Deployments
  • 🐚Vessel Community Hub
    • Vessel Community Update: Q1 2024
    • Vessel Community Update: Q2 2024
    • Vessel Community Update: Q3 2024
  • 🎨Brand Kit
Powered by GitBook
On this page
  • Terminology
  • Trading Function
  1. VAELOB

Liquidity Pool Math

PreviousA Typical Trade in VesselNextConcentrated Liquidity

Last updated 10 months ago

Terminology

To understand the process, let’s define key terms specific to the AMM:

  • Pool: Vessel’s AMM pool consists of two assets, the base asset and the quote asset, which align with trading pair terminology. For example, in an ETH/USDT pool, ETH is the base asset while USDT is the quote asset.

  • Tick: A tick represents discrete prices within the AMM pool. Each pool is instantiated with a predefined set of ticks that remain constant throughout its lifecycle. In Vessel, ticks are defined in an arithmetic sequence, represented as a tuple

<π‘‡π‘–π‘π‘˜0,π‘‡π‘œπ‘‘π‘Žπ‘™π‘‡π‘–π‘π‘˜π‘ ,π‘‡π‘–π‘π‘˜π‘†π‘π‘Žπ‘π‘–π‘›π‘”>

π‘‡π‘–π‘π‘˜0=π‘€π‘–π‘›π‘ƒπ‘Ÿπ‘–π‘π‘’

π‘‡π‘–π‘π‘˜π‘–=π‘‡π‘–π‘π‘˜0+π‘‡π‘–π‘π‘˜π‘†π‘π‘Žπ‘π‘–π‘›π‘”Γ—(π‘–βˆ’1),0≀𝑖<π‘‡π‘œπ‘‘π‘Žπ‘™π‘‡π‘–π‘π‘˜π‘ 

  • Interval: An interval is the minimal divisible price range in the AMM pool. Interval_i covers the price range,

[π‘‡π‘–π‘π‘˜π‘–,π‘‡π‘–π‘π‘˜π‘–+1]

  • managing buy orders at Tick_i and sell orders at Tick_{i+1}.

  • Liquidity: Liquidity is the total size in base asset of orders managed by the AMM within a specific range. The liquidity of Interval_i is the sum of buy order sizes at Tick_i and sell order sizes at Tick_{i+1}. The pool's total liquidity is the sum across all intervals.

  • Position: A position indicates how an LP provides liquidity within a specific range, defined by <Tick_l, Tick_r, L>, covering [Tick_l, Tick_r], with L liquidity in each interval.

Trading Function

When a trade is executed in an AMM pool, it happens within a specific interval. Trades in Interval_i follow the Constant Sum Market Maker (CSMM) model, governed by the trading function

𝑓(π‘₯,𝑦)=π‘₯𝑝+𝑦=𝑙

where x is the quantity of the quote asset (USDT), y is the quantity of the base asset (ETH), p is the price at Tick_i, and I is the liquidity in this interval.

However, Integrating this AMM trading function into the order book can cause complications. Users might see both buy and sell orders at price Tick_i if x and y are not zero. To resolve this, we slightly adjust the AMM pool’s operations: for each Interval_i, buy orders are placed at price Tick_i while sell orders are placed at price Tick_{i+1}. Consequently, a spread equal to TickSpacing is incurred when AMM orders are fulfilled in different directions. The spread reward is distributed to LPs as well.

This trading function allows each interval to manage incoming trades automatically, provided x ory reserves are sufficient. When these reserves are depleted, the process moves to the adjacent interval based on the trading direction. Each AMM pool tracks the current interval, aligning with the order book's trading pair price.

πŸ’°