---
description: Concentrated Liquidity ++ with volatility adjusted fees.
---

# v2: DMM

## v2: DMM\*

_\*in development\*_

Derp Market Maker (DMM) with volatility-adjusted fees. DerpDEX CLAMM with concentrated liquidity introduces a flexible and efficient way that can significantly improve capital efficiency and help LPs customize with range orders.&#x20;

While CLAMM concentrated liquidity gives LPs granular control over what price ranges their capital is allocated to, it introduces potentially bigger impermanent loss should there be any large one-way price action.



### Gen 2: Concentrated liquidity ++

This is where DMM, given its significant outperformance over CPAMM in protecting P\&L for LPs, can be perfectly combined with CLAMM. In detail look, the HMM combination with CLAMM can be easily adopted only with changes made to the swapping process within each active tick interval.

Same as CPMM, the available liquidity for both tokens within each interval can be easily calculated with![](http://web.archive.org/web/20220616195809im_/https://1497452446-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MbkTetpUX8ao4cmblic%2Fuploads%2F0PiEYPXI7vVkveV6Xka1%2FScreenshot%202021-10-15%20at%206.35.27%20PM.png?alt=media\&token=22dd7886-5827-4d4b-b7ae-21be2d9eb8e1)and![](http://web.archive.org/web/20220616195809im_/https://1497452446-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MbkTetpUX8ao4cmblic%2Fuploads%2FeTg1T2pHE4ZADae336si%2FScreenshot%202021-10-15%20at%206.35.50%20PM.png?alt=media\&token=f92ead8a-9fb4-4009-917b-85fc60b8f03a). This can be compared to remaining input token balance (positive or negative) to see if we need to cross the next tick. Within each price interval \[ $$P_0$$(starting tick price), $$P_1$$ (ending tick price)], the output token amount (positive or negative) can be calculated with DMM.

if $$P_1$$ is NOT between $$P_0$$ and $$P_i$$ (oracle price): **​**

<figure><img src="https://3050206827-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FYiUQ0TCTeU3ZWoBCdNEi%2Fuploads%2FaxdZMLSSyYSouanb6Qpi%2Fimage.png?alt=media&#x26;token=f89765e4-c637-4722-93cc-ca3f7a1a82af" alt=""><figcaption></figcaption></figure>

if $$P_1$$ is between $$P_0$$​ and $$P_i$$(oracle price):​

* If input token is X,

![](http://web.archive.org/web/20220616195809im_/https://1497452446-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MbkTetpUX8ao4cmblic%2Fuploads%2Fvs58eVU07Gf23w1vSAQa%2FScreenshot%202021-10-15%20at%206.43.39%20PM.png?alt=media\&token=c83e9406-e6b3-457f-964d-c3a56be21b50)

* If input token is Y,

![](http://web.archive.org/web/20220616195809im_/https://1497452446-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MbkTetpUX8ao4cmblic%2Fuploads%2FfdSZd5DT9Th1EN56O6e4%2FScreenshot%202021-10-15%20at%206.44.34%20PM.png?alt=media\&token=9819e9e5-7f09-4357-953e-7d105d97b402)



### Volatility adjusted fees

LPs providing liquidity in an AMM pool experience a volatility drag on their position i.e. they have volatility exposure. When markets are moving a lot, LP profits are eroded away by higher impermanent loss.&#x20;

Sophisticated LPs that dynamically rebalance their token inventories bleed more money doing these rebalancings in volatile markets. Conversely, AMMs accumulate profits in calm markets when there is trading activity around a stable price.&#x20;

Constant fee fails to reflect these market dynamics. This means LPs will be more inclined to take away liquidity from AMMs in volatile markets thus exacerbating market moves. In stable times, traders will be less inclined to pay the high fees on DEXes. This is the exact opposite of the desired dynamic!

Volatility sensitive pricing is needed for incentivising LPs to keep funds during volatile times and traders to continue using DEXes in stable times. LPs should earn higher fees in turbulent times and lower fees in calmer markets. This would lead to a fairer and a more robust trading ecosystem.

We present the heuristic for pricing AMM fee below.

Assuming an LP provides liquidity in a 2-asset constant product market making pool composed of tokens X and Y.

Treating Y as numeraire, we have marginal price $$P_0​=Y_0/X_0​$$ and $$X_t​Y_t​=k=L^2$$

$$X_t$$​ and $$Y_t$$​ denote the LP token balances and L is a constant denoting liquidity supplied by the LP. Value of LP assets in the pool ( $$W_t$$​ ) are given by![](http://web.archive.org/web/20220616195809im_/https://1497452446-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MbkTetpUX8ao4cmblic%2Fuploads%2FebZPm5ZPWVeSbNUmL5ua%2FScreenshot%202021-10-15%20at%206.49.40%20PM.png?alt=media\&token=0160fee7-b735-4782-957a-05c4609ff07c)

The value of LP assets follow a square root price process.Assuming geometric brownian motion for price $$P$$ ,we have:​

&#x20;$$dP = \mu Pdt + \sigma Pdz$$

​​Square root price process is given by:**​​**

![](http://web.archive.org/web/20220616195809im_/https://1497452446-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MbkTetpUX8ao4cmblic%2Fuploads%2FU7N7KhUbLBcTusvUKKYf%2FScreenshot%202021-10-15%20at%206.53.44%20PM.png?alt=media\&token=4ae3ffef-2e4c-4ee9-b76a-8f5670b1f204)

This means LPs experience a volatility drag =![](http://web.archive.org/web/20220616195809im_/https://1497452446-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MbkTetpUX8ao4cmblic%2Fuploads%2FAYAI3oh3w9lRISRrhb2p%2FScreenshot%202021-10-15%20at%206.54.49%20PM.png?alt=media\&token=abdfa364-eb17-46dd-adcc-1fc82002e102)

The above can also be modelled by explicitly calculating the delta-hedging p\&l of an LP that constantly hedges its delta to stay hedged in numeraire. This negative gamma pnl experienced by LPs between 2 periods is given by:

![](http://web.archive.org/web/20220616195809im_/https://1497452446-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MbkTetpUX8ao4cmblic%2Fuploads%2FeEtgBE4RYdtrqtWWF3BW%2FScreenshot%202021-10-15%20at%206.55.41%20PM.png?alt=media\&token=d4589879-5672-410e-8563-68ce76ee8f93)

![](http://web.archive.org/web/20220616195809im_/https://1497452446-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MbkTetpUX8ao4cmblic%2Fuploads%2FeVSIFasjazSzhtkI4uoZ%2FScreenshot%202021-10-15%20at%206.58.30%20PM.png?alt=media\&token=5a262ac0-2e36-4cc7-9837-23f3e7732e51)

![](http://web.archive.org/web/20220616195809im_/https://1497452446-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MbkTetpUX8ao4cmblic%2Fuploads%2FcsArkXvw82cgu06unUbl%2FScreenshot%202021-10-15%20at%206.59.02%20PM.png?alt=media\&token=f33d3243-45bd-4024-a784-dc0181c807f2)

Where $$W_0$$ is the initial value of the LP deposit and denotes the annualized volatility of log returns.

Considering a single day time frame, the expected value of LP loss equates to

![](http://web.archive.org/web/20220616195809im_/https://1497452446-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MbkTetpUX8ao4cmblic%2Fuploads%2FGFiYII5wV6MiPNUO3bV8%2FScreenshot%202021-10-15%20at%207.02.00%20PM.png?alt=media\&token=1d91c8d2-8210-44e5-9691-330be44a3a0a)

We want the expected fee earned from AMM to exceed that of the LP loss.

So:

![](http://web.archive.org/web/20220616195809im_/https://1497452446-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MbkTetpUX8ao4cmblic%2Fuploads%2FenrmUQ8IGTmqinTqgjml%2FScreenshot%202021-10-15%20at%207.02.48%20PM.png?alt=media\&token=a4a3d433-4360-4fc6-a86c-eeb5da783fe5)

Here ADV represents the average daily volume, TVL is the total value locked in the pool and $$\alpha$$ is the fee rate.&#x20;

We define _velocity_ as a measure of ADV / TVL. i.e. what multiple of the TVL does the AMM trade daily on average. This gives us the below heuristic for setting min AMM fee.

<figure><img src="https://3050206827-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FYiUQ0TCTeU3ZWoBCdNEi%2Fuploads%2FdbxJyhz0Bjn2roSvOVpM%2Fimage.png?alt=media&#x26;token=26cfb040-5970-40a4-88d4-18ca1e1a3fb0" alt=""><figcaption></figcaption></figure>

