> For the complete documentation index, see [llms.txt](https://docs.riskprotocol.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.riskprotocol.io/protocol-design-and-specifications/risk-marketplace/dynamic-lp-fees.md).

# Dynamic LP Fees

## Overview

We have designed and implemented a novel "dynamic swap fee" mechanism that adjusts the swap fees LPs receive based on the real-time volatility of the underlying asset. The rationale is simple: higher volatility typically means greater potential impermanent loss for LPs, so to compensate them, swap fees rise as volatility increases and fall as it subsides. The swap fees are *calculated dynamically based on real-time market volatility*. The fees range from a base of 40 bps to a maximum of 150 bps during periods of high volatility and are adjusted every 1 min. Fees are automatically calculated and applied to each swap transaction.

The details below describe the analysis we did to design the fee mechanism, the overall design, the rationale for design, and the implementation results simulated historically.&#x20;

{% hint style="info" %}
The following shows the analysis and design for the BTC pool. The ETH pool works similarly.
{% endhint %}

## 1.  Data Foundation and Volatility Calculation

We looked at 6 years of historical data (as of July 2025) at a frequency of 1 minute intervals, amounting to approximately 3.15 million minute-level observations

The volatility calculation employs a 60-minute rolling window approach. The last 60 minutes of price data (1-minute sampling) are used to calculate 1-minute log returns. The volatility calculated is the annualized 1-hour realized volatility (computed from 1-minute returns with a 60-minute rolling window):

*annualized\_volatility = log\_returns.rolling(window=60).std() \* sqrt(365 \* 24 \* 60)*

Key Components:

* **Log Returns**: Natural logarithm of price ratios for continuous compounding
* **Rolling Window**: 60-minute (1-hour) lookback period
* **Annualization Factor**: √(365 × 24 × 60) = √525,600 ≈ 724.68

This approach captures short-term volatility patterns while providing sufficient data points for statistical significance.

## 2.  Volatility Distribution Analysis

The chart below shows the distribution of the hourly volatility over the last 6 years :

<figure><img src="/files/ALFuvMUn1KjKJGyyCGtA" alt=""><figcaption></figcaption></figure>

* **Minimum Volatility**: 0.0217 (2.17% annualized)
* **Maximum Volatility**: 13.9931 (1399.3% annualized)
* **Median**: 0.40 (40% annualized)
* **Mean**: 0.50 (50% annualized)
* **95th Percentile**: 1.19 (119% annualized)

The volatility distribution exhibits:

* **Right-skewed distribution**: Most observations cluster around low volatility levels
* **Heavy right tail**: Occasional extreme volatility spikes during market stress
* **Concentration**: Approximately 50% of observations below 40% annualized volatility

## 3.  Fee Structure Design

The fee structure operates within defined bounds:

* **Minimum Fee**: 0.004 (40 basis points)
* **Maximum Fee**: 0.015 (150 basis points)
* **Transition Start**: 0.40 (median volatility)
* **Transition End**: 1.19 (95th percentile volatility)

Minimum swap fees of 40 bps apply for measured volatility levels of 40% and below. Maximum swap fees of 150 bps apply to measured volatility levels of 40% or higher. Between these ranges, swap fees are interpolated based on a smoothstep mapping function as detailed below:

*def smooth\_fee(volatility, min\_fee, max\_fee, v\_min, v\_max):*

&#x20;   *t = (volatility - v\_min) / (v\_max - v\_min)*

&#x20;   *t = np.clip(t, 0, 1)*

&#x20;   *return min\_fee + (max\_fee - min\_fee) \* (3\*t² - 2\*t³)*

This results in a fee mechanism with the following mathematical properties:

* **Smooth Transitions**: First and second derivatives are continuous
* **Bounded Output**: Fees constrained between min\_fee and max\_fee
* **Non-linear Mapping**: Gentle acceleration in fee increases during moderate volatility
* **Plateau Behavior**: Minimal fee changes at volatility extremes

<figure><img src="/files/WUWnysJlUmyc1sh2qXE5" alt=""><figcaption></figcaption></figure>

**Design Rationale**

*Lower Bound (v\_min = 0.40)*:

* Represents median market conditions
* Ensures 50% of trading occurs at or near minimum fees
* Provides competitive pricing during normal market conditions

*Upper Bound (v\_max = 1.19)*:

* Captures 95% of historical volatility observations
* Prevents excessive fee spikes during extreme events
* Balances risk compensation with market accessibility

## 4.  Implementation Results

We applied the fee design to the last 6 years of historical data. The chart below shows the distribution of hourly fee outcomes.

<figure><img src="/files/ULwqxM4kfU6XcFYOy43Z" alt=""><figcaption></figcaption></figure>

The implemented fee structure produces:

* **Median of fee distribution**: 0.41% (41 basis points)
* **Mean of fee distribution**: 0.58% (58 basis points)
* **95th Percentile Fee**: 1.42% (142 basis points)
* **Fee Range**: 0.40% - 1.50%

&#x20;&#x20;

The charts below show the 1-hour and 1-day average fees in 2024 and 2025

<figure><img src="/files/runRrxHkGHoW6PDK3QVC" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/zFQ0qJUAcxqWzXQG7hls" alt=""><figcaption></figcaption></figure>

**This fee mechanism protects liquidity providers during volatile market conditions while offering competitive rates during stable periods, promoting efficient price discovery and fair value exchange.**


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.riskprotocol.io/protocol-design-and-specifications/risk-marketplace/dynamic-lp-fees.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
