The total swap fee (fs) will have two components:
A base fee (fb)
A variable fee (fv)
The total swap fee is calculated as:fs=fb+fvThe variable fee (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.
The base fee of a pool can be configured by the pool creator in the following ways:
Fixed Base Fee: A fixed fee that is applied to the swap amount.
Fee Scheduler: A fee decay mechanism that decays the fee from a high starting fee to an ending fixed base fee over a period of time. The ending fee will be the fixed base fee of the pool after the fee scheduler is finished.
Rate Limiter: Coming Soon
You can only choose one of the three options for the base fee.
Fixed base fee is a fixed fee that is applied to the swap amount. The fee can range from 0.01% to 50%. It is specified in the config key used for the pool creation.
Fee scheduler is a fee decay mechanism that decays the fee from a high starting fee to an ending base fee over time.The fee math calculation for the scheduler can be found here.
The price change is calculated based on the change in the square root of the price.Δp=(pc/pr−1)/s×2where pc is current price and pr is reference price.
To ensure that the dynamic fee reflects recent volatility, the Volatility Reference decays over time.vr=va×R/10000The decay mechanism is based on the time elapsed since the last significant trade:
If elapsed time < filter period: No change. This ignores very high-frequency trades.
If filter period ≤ elapsed time < decay period: The volatility reference is reduced.
If elapsed time ≥ decay period: The volatility reference is reset to 0. This happens if there are no significant trades for an extended period.