# Volatility Related

To make fees truly responsive to market conditions, Cetus DLMM tracks both recent trading activity and price movements across bins. This section explains how the Volatility Accumulator (*v*<sub>*a*</sub>), Volatility Reference (*v*<sub>*r*</sub>), and Index Reference (*i*<sub>*r*</sub>) work together to adjust variable fees dynamically, ensuring fair pricing and protecting against manipulation.

### **Volatility Accumulator (*****v***<sub>***a***</sub>**)**

The Volatility Accumulator measures cumulative price movements across bins during swaps. Each bin crossed represents a fixed price step, and Va adds up these crossings to reflect volatility beyond a single trade. For bin n, v<sub>a</sub> is calculated as:

$$
v\_a(n)=v\_rprev +∣i\_r−(activeBinID+n)∣
$$

Where:

* ***activeBinID*** is the ID of the currently active bin before the swap
* ***v***<sub>***r***</sub>***prev*** is the volatility reference from previous trades
* ***i***<sub>***r***</sub> is the index reference used to stabilize v<sub>a</sub> during rapid trades

### **Volatility Reference (*****v***<sub>***r***</sub>**)**

*v*<sub>*r*</sub> updates according to the elapsed time *t*<sub>*elapsed*</sub> since the last swap:

* **Filter period (*****t***<sub>***f***</sub>**)**: If *t*<sub>*elapsed*</sub>*&#x20;< t*<sub>*f*</sub> , *v*<sub>*r*</sub> remains unchanged to account for high-frequency trading.
* **Decay period (*****t***<sub>***d***</sub>**)**: If *t*<sub>*elapsed*</sub>*&#x20;≥ t*<sub>*d*</sub> , *v*<sub>*r*</sub> resets to zero due to inactivity.
* **Intermediate decay**: For *t*<sub>*f*</sub>*&#x20;≤ t*<sub>*elapsed*</sub>*&#x20;< t*<sub>*d*</sub> , *v*<sub>*r*</sub> decays proportionally with a decay factor *ρ* : *v*<sub>*r*</sub>*&#x20;= ρ⋅v*<sub>*a*</sub>*&#x20;prev*

This approach ensures that frequent trading increases accumulated volatility, while inactivity gradually reduces it.

### **Index Reference (*****i***<sub>***r***</sub>**)**

A variable called Index Reference (*i*<sub>*r*</sub>) is also introduced to stabilize the calculation of volatility and prevent fee manipulation through rapid, repeated small trades. By keeping track of a reference bin, *i*<sub>*r*</sub> ensures that high-frequency trading does not artificially inflate the Volatility Accumulator (*v*<sub>*a*</sub>), helping variable fees reflect real market activity rather than strategic splitting of swaps.

* If *t*<sub>*elapsed*</sub>*&#x20;≥ t*<sub>*f*</sub> (normal activity), then *i*<sub>*r*</sub>*&#x20;= activeBinID*
* If *t*<sub>*elapsed*</sub>*&#x20;< t*<sub>*f*</sub> (high-frequency trades), then *i*<sub>*r*</sub>*&#x20;= i*<sub>*r*</sub>*&#x20;prev*

### **Example**

*activeBinID = 200*

*t*<sub>*f*</sub>*&#x20;= 2 s, t*<sub>*d*</sub>*&#x20;= 6 s, ρ = 0.6*

*v*<sub>*r*</sub>*&#x20;at start = 0*

**Swap 1:** crosses +2 bins (200 → 202)

*i*<sub>*r*</sub>*&#x20;= 200*

*v*<sub>*a*</sub>*&#x20;progression:*

* *v*<sub>*a*</sub>*(0) = 0 + |200 − (200+0)| = 0*
* *v*<sub>*a*</sub>*(1) = 0 + |200 − (200+1)| = 1*
* *v*<sub>*a*</sub>*(2) = 0 + |200 − (200+2)| = 2*

*v*<sub>*a*</sub>*&#x20;at end = 2*

**Swap 2:** occurs 3 seconds later, crosses +5 bins (202 → 207)

*v*<sub>*r*</sub>*&#x20;decays: v*<sub>*r*</sub>*&#x20;= 0.6 \* 2 = 1.2*

*i*<sub>*r*</sub>*&#x20;= 202*

*v*<sub>*a*</sub>*&#x20;progression:*

* *v*<sub>*a*</sub>*&#x20;(0) = 1.2 + |202 − (202+0)| = 1.2*
* *v*<sub>*a*</sub>*&#x20;(1) = 1.2 + |202 − (202+1)| = 2.2*
* *v*<sub>*a*</sub>*&#x20;(2) = 1.2 + |202 − (202+2)| = 3.2*
* *v*<sub>*a*</sub>*&#x20;(3) = 1.2 + |202 − (202+3)| = 4.2*
* *v*<sub>*a*</sub>*&#x20;(4) = 1.2 + |202 − (202+4)| = 5.2*
* *v*<sub>*a*</sub>*&#x20;(5) = 1.2 + |202 − (202+5)| = 6.2*

*v*<sub>*a*</sub>*&#x20;at end = 6.2*

**Swap 3:** occurs 1 second later, crosses -3 bins (207 → 204)

*v*<sub>*r*</sub>*&#x20;= 1.2, i*<sub>*r*</sub>*&#x20;= 202 (remain unchanged)*

*v*<sub>*a*</sub>*&#x20;progression:*

* *v*<sub>*a*</sub>*&#x20;(0) = 1.2 + |202 − (207+0)| = 6.2*
* *v*<sub>*a*</sub>*&#x20;(-1) = 1.2 + |202 − (207-1)| = 5.2*
* *v*<sub>*a*</sub>*&#x20;(-2) = 1.2 + |202 − (207-2)| = 4.2*
* *v*<sub>*a*</sub>*&#x20;(-3) = 1.2 + |202 − (207-3)| = 3.2*

*v*<sub>*a*</sub>*&#x20;at end = 3.2*
