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
  • Introduction
  • Example: Fee Calculation
  • Protocol Fee
  1. VAELOB

Fee Calculation

Introduction

The AMM pool manages liquidity by placing limit orders at specific price ticks, and fees are incurred when these orders are matched with traders' orders. To ensure that traders have a consistent experience whether trading with the AMM pool or other users, the fee structure remains uniform across the trading pair and its corresponding AMM pools.

For simplicity, consider trades in the ETH/USDT pair, with ETH as the base asset and USDT as the quote asset, assuming a fixed fee rate rrr and an AMM pool with tick spacing tststs.

Fee Calculation when AMM's Buy Order is Filled

When a buy order from the AMM is executed at TickiTick_iTicki​, the fee is derived solely from the trading fee, paid by the trader in USDT. If the AMM’s buy order of size sss is fulfilled, the trading fee is calculated as:

TradingFee=Ticki×s×rTradingFee=Tick_i \times s \times rTradingFee=Ticki​×s×r

Fee Calculation when AMM's Sell Order is Filled

When a sell order from the AMM is executed at , the fee includes both the trading fee and the spread reward. From the trader's standpoint, the fee is paid in ETH. If the AMM’s sell order of size sss is fulfilled, the trading fee is:

TradingFee=s×rTradingFee=s \times rTradingFee=s×r

Since sell orders are placed at higher prices than buy orders within the same interval, each fulfillment generates a spread reward due to the price spread tststs:

SpreadReward=s×tsSpreadReward=s \times tsSpreadReward=s×ts

In summary, the fee calculations for AMM orders ensure that traders experience consistent fees whether they trade with the AMM pool or other users. Additionally, AMM sell orders placed at higher prices than buy orders within the same interval always generate a spread reward, benefiting liquidity providers.

Example: Fee Calculation

To clarify how AMM fees are calculated, let's revisit the previous exmaple with a trading fee rate of 0.1% for the ETH/USDT pair.

Trade 1

Alice’s buy order is filled for 0.7 ETH at a price of 3800 USDT. The AMM's order contributes 0.4 ETH, while the remaining 0.3 ETH comes from other users. Here, s=0.4s=0.4s=0.4, ts=1ts=1ts=1 , and r=0.001r=0.001r=0.001.

The total trading fee collected by the AMM pool is:

TradingFee=0.4×0.001=0.0004 ETHTradingFee=0.4\times0.001=0.0004 \text{ ETH}TradingFee=0.4×0.001=0.0004 ETH

Additionally, the spread reward collected by the AMM pool is:

SpreadReward=0.4×1=0.4 USDTSpreadReward=0.4 \times 1 = 0.4 \text{ USDT}SpreadReward=0.4×1=0.4 USDT

Thus, the total AMM fees amount to ( 0.0004 ETH + 0.4 USDT ). If an LP contributed 0.1 ETH in the interval [3799, 3800], they would receive 25% of the collected fees from this trade, equating to ( 0.0001 ETH + 0.1 USDT ).

Trade 2

The remaining 0.3 ETH of Alice’s buy order is filled at a price of 3801 USDT, entirely by the AMM's order. Here, s=0.3s=0.3s=0.3, ts=1ts=1ts=1 , and r=0.001r=0.001r=0.001.

The calculations are:

TradingFee=0.3×0.001=0.0003 ETHTradingFee=0.3\times0.001=0.0003 \text{ ETH}TradingFee=0.3×0.001=0.0003 ETH
SpreadReward=0.3×1=0.3 USDTSpreadReward=0.3 \times 1 = 0.3 \text{ USDT}SpreadReward=0.3×1=0.3 USDT

Therefore, from this trade, a total of ( 0.0003 ETH + 0.4 USDT ) will be added to the AMM pool and distributed proportionally among the LPs within the interval [3800, 3801].

Protocol Fee

To cover the hardware costs associated with SNARK proof generation, the Vessel protocol takes a small percentage of all AMM fees. This protocol fee is set as a percentage and is encoded directly into the circuit.

PreviousConcentrated LiquidityNextMulti-Pool with Different Tick Spacing

Last updated 11 months ago

💰