Dynamic Fee

Bean's DLMM introduces a Dynamic Fee system — a smart, self-adjusting mechanism that tunes trading fees in real-time, based on volatility, price movement, and deposit behavior. The goal is simple: reward LPs fairly during volatile periods, keep costs low for traders during calm times, and make the protocol sustainable long-term.

Core Objectives

Stakeholder
Goals

Liquidity Providers (LPs)

✅ Volatility-adjusted returns

✅ Minimum guaranteed base fees

✅ Protection against toxic/imbalanced flow

Traders

✅ Lower fees during stable periods

✅ Predictable and transparent pricing

✅ Fair cost during volatility

Protocol

✅ Consistent revenue share

✅ Adaptive market efficiency

✅ Built-in risk controls


1. Fee Architecture

Bean calculates the total trading fee as:

TotalFee=BaseFee+VariableFeeTotalFee = Base Fee + Variable Fee

Base Fee : The fixed minimum charged regardless of volatility

Variable Fee: Increases as price volatility rises

All calculations utilize 9-decimal precision (1,000,000,000 = 100%)

System safeguards:

  • Max Total Fee: 10%

  • Max Protocol Share: 25% of total fees

Base Fee:

Provides a fixed floor to reward LPs even in calm markets.

BaseFee=BaseFactorBinStep10Base Fee = Base Factor * Bin Step * 10
  • Base Factor: Set during pool creation (e.g., 100)

  • Bin Step: The price gap between adjacent bins (e.g., 5)

  • 10: Fixed scaling Constant

Think of this as your guaranteed minimum paycheck.

Variable Fee:

Encourages LPs to stay in volatile markets by rewarding them with higher fees.

VariableFee=(VolatilityAccumulator×BinStep)2×VariableFeeControl÷100Variable Fee = (Volatility Accumulator × Bin Step)² × Variable Fee Control ÷ 100
  • Volatility Accumulator: Measures recent price fluctuations

  • Variable Fee Control: Adjusts sensitivity (e.g., 2500 = 0.25x)

The more the price jumps around, the more LPs earn.

Worked Example:

Given:

  • Base Factor = 100

  • Bin Step = 5

  • Volatility Accumulator = 50,000

  • Control = 2,500

Results:


2. Volatility Management System

To avoid manipulation and overreaction to short-term noise, Ferra introduces a decay-based tracking system.

Accumulator Formula:

VolatilityAccumulator=VolatilityReference+(CurrentBinIDReferenceBinID)×10,000Volatility Accumulator = Volatility Reference + (Current Bin ID − Reference Bin ID) × 10,000

Tracks how far price has moved from its last "anchor" bin.

Time-Weighted Decay Logic:

Time Passed Since Last Update (Δt)
Behavior

Δt < t_f (Filter)

No update — blocks spam/MEV

t_f ≤ Δt < t_d (Decay)

Volatility decays by reduction factor

Δt ≥ t_d (Reset)

Full reset of volatility tracker

Think of it like a memory that forgets old volatility if things calm down.

Worked Example:


3. Specialized Fee Types

Composition Fee:

Prevents LP manipulation from imbalanced deposits (e.g., only one token).

CompositionFee=ExcessAmount×TotalFee×(TotalFee+1)Composition Fee = Excess Amount × Total Fee × (Total Fee + 1)
  • Triggered when a deposit skews the ideal token ratio.

  • Applies only in active bins.

Flash Loan Fee:

Charged on flash loans independently of volatility.

FlashLoanFee=LoanAmount×FlashLoanRate÷1,000,000,000Flash Loan Fee = Loan Amount × Flash Loan Rate ÷ 1,000,000,000
  • Max Fee: 10%

  • Flat Rate: Does not vary with volatility

Worked Example:

Given:

  • Excess deposit: 300 USDC

  • Total fee: 1%

Results:


4. Fee Distribution Logic

Fees are distributed proportionally based on LP contribution per bin.

Bin-Level Fee Growth:

FeeGrowthPerUnit=AccumulatedFees÷TotalBinLiquidityFee Growth Per Unit = Accumulated Fees ÷ Total Bin Liquidity

LP Earnings Formula:

LPFees=LPLiquidity×(CurrentFeeGrowthLastClaimedGrowth)LP Fees = LP Liquidity × (Current Fee Growth - Last Claimed Growth)

Ensures long-term LPs earn more if they stay in active bins.

Worked Example:

Given:

  • Total Fee: 100 USDC

  • Protocol Share: 20%

Results:


5. Configuration Parameters

Type
Parameters

Static (Set on Pool Init)

Base Factor, Variable Fee Control, Protocol Share, Max Volatility, t_f, t_d, Reduction Factor

Dynamic (Updated with Trades)

Volatility Accumulator, Reference Bin, Last Update Timestamp

Last updated