Meteora
  • Meteora: The most dynamic and sustainable liquidity layer on Solana
  • PRODUCT OVERVIEW
    • Meteora Liquidity Pools
      • DLMM Overview
        • What is DLMM?
        • DLMM Program
        • Dynamic Fees
        • Strategies & Use Cases
        • DLMM Farming Rewards
      • DLMM Launch Pool Overview
      • Dynamic AMM Overview
        • What is a Dynamic AMM Pool?
        • Dynamic AMM LP Fee and APY Calculation
        • Creating a Dynamic AMM Pool via the UI
        • Claiming Fees from Permanently Locked Liquidity
        • Dynamic AMM Stable Pools
        • Dynamic LST Pools
        • Additional yield from Dynamic Vaults
        • Dynamic AMM Farm Overview
      • DAMM v2 Overview
      • Memecoin Pool Overview
        • Memecoin Pool v2
          • What is Memecoin Pool v2?
        • Memecoin Pool v1
          • What is Memecoin Pool v1?
          • Permanently Locking Liquidity
      • Stake2Earn Pool Overview
        • What is a Stake2Earn Pool?
        • Stake2Earn for Launchpads
      • Multi-Token Stable Pool Overview
    • Alpha Vault Overview
    • Dynamic Vault Overview
      • What is a Dynamic Vault?
      • Dynamic Vault Program
      • Hermes - Meteora's Keeper
        • Algorithm to find optimal yield allocations
        • Rebalance crank
        • Operation fee calculation
      • Design Goals
      • Security
      • Dynamic Vaults Whitepaper
      • Dynamic Vaults Community Explainers
      • Affiliate Program for Dynamic Vault
        • Become an Affiliate Partner (Dynamic Vaults)
    • Dynamic Bonding Curve (DBC) Overview
      • What is the Dynamic Bonding Curve?
      • Customizable Pool Configuration
      • Bonding Curve Formula
      • DBC Migrator Keeper
  • Meteora's Anti-Sniper Suite (A.S.S.)
    • Meteora’s Anti-Sniper Suite
      • Dynamic Fees
      • Fee Scheduler
      • Alpha Vault
  • INTEGRATION
    • DLMM Integration
      • DLMM SDK
        • DLMM TypeScript SDK
        • CPI Examples
      • DLMM API
      • Fetching information on locked liquidity in a DLMM
    • Dynamic AMM Pool Integration
      • Dynamic AMM SDK
        • Dynamic AMM TypeScript SDK
        • CPI Examples
      • Dynamic AMM API
        • Pool Info
        • Pool State
      • Setting Pool and Fee Config for Dynamic AMM Pools
      • Create Dynamic Pool with Timestamp/Slot Activation
      • Dynamic AMM - Farm Integration
    • DAMM v2 Integration
      • DAMM v2 SDK
        • DAMM v2 TypeScript SDK
        • DAMM v2 Rust SDK
      • Setting Pool and Fee Config for DAMM v2
      • Technical FAQ
    • Memecoin Pool Integration
      • Memecoin Pool v2 Integration
        • Setting Pool and Fee Config for Memecoin Pool v2
      • Memecoin Pool v1 Integration
        • TypeScript Code Examples
        • CPI Examples
        • Setting Pool and Fee Config for Memecoin Pool v1
        • Track permanently-locked liquidity in Memecoin Pool v1
        • Track Protocol Fee from swaps in Memecoin Pool v1
    • Stake2Earn Pool Integration
    • Dynamic Vault Integration
      • Using TypeScript-Client
      • Using Rust-Client
      • Using CPI
      • Vault API
        • Vault Info
        • Vault State
      • Vault Developer Resources
    • Alpha Vault Integration
      • Alpha Vault TypeScript SDK
      • Alpha Vault without Whitelist Setup
      • Alpha Vault with Whitelist Setup
    • Dynamic Bonding Curve (DBC) Integration
      • DBC SDK
        • DBC TypeScript SDK
        • DBC Rust SDK
      • DBC Fee Scheduler Formula
      • DBC Scripts
      • Program Repo
      • Launchpad Template
      • Technical FAQ
  • TOKEN LAUNCH POOLS
    • Steps to Create a Pool for a Token Launch
      • Create: DLMM Launch Pool
      • Create: Dynamic AMM Pool
      • Create: Memecoin Pool v1
      • Create: Stake2Earn Pool
      • Create: Pools with Alpha Vault
        • Create: DLMM Launch Pool with Alpha Vault
        • Create: Dynamic AMM Pool with Alpha Vault
        • Create: Memecoin Pool with Alpha Vault
        • Create: Stake2Earn Pool with Alpha Vault
    • Anti-Sniper Fee Suite for a Token Launch
  • Resources
    • Audits
    • Meteora Program IDs
    • Meteora APIs
    • Devnet Testing
    • Community Data Dashboards & Tools
    • Meteora Brand Assets
    • THE MASSIVE METEORA STIMULUS PACKAGE
      • Overview
      • 1. Dynamic Liquidity Market Maker (DLMM)
      • 2. Formation Of An LP Army DAO
      • 3. The 10% Stimulus Proposal
  • USER FAQ
    • Getting Started LPing
      • Supported Wallets
      • Prepare SOL
      • SOL required for Rent
      • What is Wrapped SOL?
      • What is an AMM?
      • What does it mean to provide liquidity?
      • How to swap to the tokens required for adding liquidity to a pool
      • How to quickly check if a token has any risks
      • Viewing your transaction history
      • My wallet has been compromised. What should I do?
    • Differences between DLMM and Dynamic Pools
    • DLMM FAQ
    • Dynamic AMM FAQ
      • How is the pool price of the token calculated in a Dynamic AMM?
      • What is a Meteora LP token?
      • How do I see fees earned on a Dynamic AMM Pool?
      • How to track your earnings for a Dynamic Pool?
      • What is Virtual Price in a Dynamic Pool?
      • How do LP tokens, fees, and virtual price work for Dynamic Pools?
      • Why must I add liquidity in non-stable Dynamic Pools using a 50:50 value ratio?
      • What is AMP in a Dynamic Pool with stable coins?
      • Why is the USDT-USDC pool not 1:1 in ratio of assets?
      • Can I create an LST, FX, or Multi-token pool using the Dynamic Pool creation tool?
    • Alpha Vault FAQ
    • Why is the token sometimes not picked up and tradable on Jupiter?
    • How do I create a new farm?
    • Video Tutorials to Get Started
      • LP Army Boot Camp
      • DLMM Strategy Sessions / Jam Sessions
  • Security and Risks
    • Risk of Impermanent Loss (IL)
    • Risk of depositing into an imbalanced pool / pool with price out of sync
    • Smart contract risk
    • Risk of a stablecoin depeg
    • Operational risk for dynamic vaults and pools
    • Lending risk for dynamic vaults and pools
  • legal
    • Terms of Service
    • Stake2Earn Terms of Service
Powered by GitBook
On this page
  • Introduction
  • Base Fee
  • Variable Fee
  • Volatility Accumulator
  • Volatility Accumulator Example
  • DLMM Protocol Fee
  1. PRODUCT OVERVIEW
  2. Meteora Liquidity Pools
  3. DLMM Overview

Dynamic Fees

PreviousDLMM ProgramNextStrategies & Use Cases

Last updated 28 days ago

Introduction

DLMM implements dynamic fees with surge pricing based on market fluctuations and volatility.

LPs earn a swap fee from traders when they perform a swap. The total swap fee (fs)(f_s)(fs​) will have two components: a base fee (fb)(f_b)(fb​) and a variable fee (fv)(f_v)(fv​). Total swap fee fs=fb+fvf_s = f_b + f_vfs​=fb​+fv​

The variable fee (fv)(f_v)(fv​) is a function of real-time price volatility. The fee rate will be applied to the swap amount in each liquidity bin and distributed proportionally to the LPs in that bin.

LPs can claim these fees whenever they are available.

Base Fee

The base fee of a market is configured by the pool creator and determined by the base factor (B) and the bin step (s):

fb=B⋅sf_b=B \cdot sfb​=B⋅s

Base factor is the amplification to add to the bin step, to allow for adjustment of the pool base fees.

Variable Fee

The variable fee depends on the volatility of the market where it is affected by swap frequencies as well as swaps that span across many bins. Fees are calculated and distributed on a per bin basis, to allow for a fair fee distribution to the LPs of each bin that is crossed.

For large swaps that span across bins, fees are calculated iteratively. This means that if a large swap crosses nnn bins, total swap fee is calculated per bin kkk (such that 0≤k≤n0\leq k\leq n0≤k≤n), where kkk is the difference in the bin IDs from the initial bin where the swap originated and the current bin in which it is being calculated.

For example, let's use SOL/USDC. We also assume each bin step is $1 for simplicity. Let us assume that the active bin (ID = 1000) before swap is $100. A large buy order was made that pushed the price up to $102.

Volatility Accumulator

Volatility Accumulater:

Volatility Reference

High frequency trades will stack up volatility, while low frequency trades will slowly reduce the volatility. If a long time has passed without any trade, the volatility will reset to 0.

Volatility Accumulator Example

This example will show how the volatility accumulator will look as swaps are made.

Swap 1

Swap 2

Swap 3

You can see that the volatility accumulator is decreasing despite high frequency of transactions, preventing people from manipulating fees by making lots of small transactions that increase/decrease prices.

DLMM Protocol Fee

Protocol Fee is a percentage of the Dynamic Fee (total swap fee i.e. base + variable fee).

For our initial testing phase:

  • Protocol Fee is 5% of the Dynamic Fee for all standard DLMM Pools.

  • Protocol Fee is 20% of the Dynamic Fee for DLMM Bootstrapping Pools (Launch Pools).

The value of kkk for each bin is illustrated below:

$100 bin - ID = 1000; kkk = 0

$101 bin - ID = 1001; kkk = 1

$102 bin - ID = 1002; kkk = 2

Note that kkk can also be negative if it pushes the price downwards.

The variable fee for a bin fv(k)f_v(k)fv​(k)will be calculated using the variable fee control parameter (A)(A)(A), bin step (s)(s)(s)and volatility accumulator (va(k))(v_a(k))(va​(k)):

fv(k)=A(va(k)⋅s)2f_v(k) = A(v_a(k) \cdot s)^2fv​(k)=A(va​(k)⋅s)2

Volatility Accumulator (va(k))(v_a(k))(va​(k)) captures instantaneous volatility.

Variable Fee Control Parameter AAA is used to scale the variable fee component depending on the expected dynamics of the market.

Volatility on the DLMM is derived from the number of bin changes that occur over time. Each bin change is a fixed price movement of the bin step. The Volatility Accumulator (va(k))(v_a(k))(va​(k)) allows us to use bin crossovers as a measure of volatility beyond a single transaction.

Think of the Volatility Accumulator (va(k))(v_a(k))(va​(k)) as a witness of the current volatility of the token pair. Between each calculation step, this value will be kept in memory. It is calculated during a swap and depends on two factors:

Volatility Reference (vr)(v_r)(vr​) from the previous swaps

Introduced Volatility (∣ir−(activeID+k)∣)(|i_r - (activeID + k)|)(∣ir​−(activeID+k)∣)

va(k)=vr+∣ir−(activeID+k)∣v_a(k) = v_r + |i_r - (activeID + k) |va​(k)=vr​+∣ir​−(activeID+k)∣

(Note: activeIDactiveIDactiveID is the ID of the active bin before the swap is made.)

The volatility reference (vr)(v_r)(vr​) depends on the time passed since the last transaction (t).(t). (t).We will define a window with an upper and lower bound. The lower bound of this window is defined as filter period (tf)(t_f)(tf​), and upper bound as decay period (td)(t_d)(td​).

If ttt is smaller than the filter period(tf)(t_f)(tf​) (this indicates a high frequency of transactions occurring), then vrv_rvr​stays the same.

If ttt is greater than the decay period(td)(t_d)(td​) (this indicates a low frequency of transactions occurring), then vrv_rvr​is reset to 0.

If ttt is within the window bounded by tft_ftf​ & tdt_dtd​, then vrv_rvr​ takes the previous value of vav_ava​ decayed by a factor RRR

vr={vr,t<tfR⋅va,tf≤t<td0,td≤tv_r = \begin{cases} v_r,&t<t_f\\R \cdot v_a,&t_f \leq t <t_d\\0,&t_d \leq t\end{cases}vr​=⎩⎨⎧​vr​,R⋅va​,0,​t<tf​tf​≤t<td​td​≤t​

We introduce a new variable, the index reference (ir)(i_r)(ir​) to calculate the volatility introduced by the trade. In most cases, iri_rir​ will be the ID of the active bin before the swap is made. In times of high frequency transactions, iri_rir​will keep its old value instead. Doing this will help prevent people from manipulating fees through making small lots of small transaction that increase and decrease price.

ir={ir,t<tfactiveID,tf≤ti_r=\begin{cases}i_r,&t<t_f\\ \mathit{activeID},&t_f\leq t\end{cases}ir​={ir​,activeID,​t<tf​tf​≤t​

The volatility accumulated vrv_rvr​ for the bin kkk will then be used to calculate the fees generated by swapping through this bin and be allocated to the liquidity providers of the bin.

The final fee for the bin kkk will be:

fee=(swap amount)k⋅(fb+fv)kfee = (\mathit{swap\ amount})_k\cdot (f_b+f_v)_kfee=(swap amount)k​⋅(fb​+fv​)k​

Quick :

Volatility Accumulator: va(k)=vr+∣ir−(activeID+k)∣v_a(k) = v_r + |i_r - (\mathit{activeID} + k) |va​(k)=vr​+∣ir​−(activeID+k)∣

ttt is time elapsed since last transaction

tft_ftf​ is filter period

tdt_dtd​ is decay period

R is the factor that decays vav_ava​, the volatility accumulator R⋅vaR \cdot v_aR⋅va​ when tf≤t<tdt_f≤t<t_dtf​≤t<td​

Let tft_ftf​ = 1 sec, tdt_dtd​ = 5 secs, RRR = 0.5 sec, and active bin ID is 100.

You make a trade that crosses +3 bins to 103. So 0≤k≤30≤k≤30≤k≤3:

ir=100vr=0va(0)=0+∣100−(100+0)∣=0va(1)=0+∣100−(100+1)∣=1va(2)=0+∣100−(100+2)∣=2va(3)=0+∣100−(100+3)∣=3\begin{align*} i_r&=100\\v_r&=0\\v_a(0) &= 0 + |100 - (100 + 0)| = 0\\v_a(1) &= 0 + |100 - (100 + 1)| = 1\\ v_a(2) &= 0 + |100 - (100 + 2)| = 2\\v_a(3) &= 0 + |100 - (100 + 3)| = 3 \end{align*}ir​vr​va​(0)va​(1)va​(2)va​(3)​=100=0=0+∣100−(100+0)∣=0=0+∣100−(100+1)∣=1=0+∣100−(100+2)∣=2=0+∣100−(100+3)∣=3​

At the end of swap 1, va=3v_a = 3va​=3.

John makes a trade 4 seconds later that crosses +5 bins to 108. As t=4t = 4t=4, vr=R⋅vav_r= R \cdot v_avr​=R⋅va​. So 0≤k≤50≤k≤50≤k≤5:

ir=103vr=0.5⋅3=1.5va(0)=1.5+∣103−(103+0)∣=1.5va(1)=1.5+∣103−(103+1)∣=2.5va(2)=1.5+∣103−(103+2)∣=3.5⋯va(5)=1.5+∣103−(103+5)∣=6.5\begin{align*} i_r&=103\\v_r&=0.5\cdot3=1.5\\v_a(0) &= 1.5 + |103 - (103 + 0)| = 1.5\\v_a(1) &= 1.5 + |103 - (103 + 1)| = 2.5\\ v_a(2) &= 1.5 + |103 - (103 + 2)| = 3.5\\ & \cdots \\v_a(5) &= 1.5 + |103 - (103 + 5)| = 6.5 \end{align*}ir​vr​va​(0)va​(1)va​(2)va​(5)​=103=0.5⋅3=1.5=1.5+∣103−(103+0)∣=1.5=1.5+∣103−(103+1)∣=2.5=1.5+∣103−(103+2)∣=3.5⋯=1.5+∣103−(103+5)∣=6.5​

At the end of swap 2, va=6.5v_a = 6.5va​=6.5.

Jane makes a trade 0.3 seconds later that crosses -2 bins to 106. As t=0.3t = 0.3t=0.3, which is <tf< t_f<tf​ of 1 second, iri_rir​ and vrv_r vr​ stays the same. So −2≤k≤0-2≤k≤0−2≤k≤0:

ir=103vr=1.5va(0)=1.5+∣103−(108+0)∣=6.5va(−1)=1.5+∣103−(108−1)∣=5.5va(−2)=1.5+∣103−(108−2)∣=4.5i_r=103\\v_r = 1.5 \\ v_a(0) = 1.5 + |103 - (108 + 0)| = 6.5\\v_a(-1) = 1.5 + |103 - (108 - 1)| = 5.5\\ v_a(-2) = 1.5 + |103 - (108 - 2)| = 4.5ir​=103vr​=1.5va​(0)=1.5+∣103−(108+0)∣=6.5va​(−1)=1.5+∣103−(108−1)∣=5.5va​(−2)=1.5+∣103−(108−2)∣=4.5

At the end of swap 3, va=4.5v_a = 4.5va​=4.5.

Recap