Part 1: Dynamic Fees and Impermanent Loss

Minswap Labs
9 min readJun 5, 2024

--

This article was authored in its entirety by two Minswap community members: Marco and Elder Millennial. We immensely appreciate the work by expert community members such as Elder and Marco that have helped Minswap progress since day 1.

Introduction

This article is Part 1 of a series of articles dedicated to one of the new features in Minswap V2: Dynamic Fees. To better understand why Minswap V2 is adopting dynamic fees, this article begins with an explanation of traditional markets and how automated market makers (AMMs) are related to them. Understanding how AMMs are related to traditional market makers helps to provide context to why dynamic fees are important to liquidity providers. It also helps us in designing a formula for Dynamic Fees that could make providing Liquidity a much better experience, similar to how traditional market makers do.

Traditional Markets

Decentralized exchanges attempt to mirror traditional markets, with innovative features that overcome common centralization problems. Traditional markets use order books, where people can place bids (to buy) and set asking/offer prices (to sell) assets. In order for buying and selling of assets to operate smoothly, markets need a large supply of liquidity. Institutions help smooth the buying and selling of assets by injecting their own liquidity, with the centralized order book matching bids and asks. These institutions are often called Market Makers. Market makers can use the mid price (the middle point between the top bid and ask) and add a spread on top to offset their risk and increase their profitability.

Order books allow a variety of order types (like market orders and limit orders) that are executed based on specific conditions. The liquidity in the order book is based on limit orders from all traders, but often market makers provide the most liquidity. Market makers’ job is to quote an asset around the mid price. The mid price is the price between the best buy price (bid price) and the best sell price (ask price). Market makers will quote a spread around that mid price based on the asset itself. More volatile assets will have wider spreads, the bid and ask are further from mid. Also the spread on the same asset will evolve over time as the volatility in general evolves over time. Market makers will also quote asymmetrically across a specific asset as well based on their balance sheet risk (if they already hold too much of an asset they may quote to sell the asset closer to the mid versus bid quotes).

Example of an Order Book with deep liquidity — BTC/USDT

Decentralized Exchanges (DEXs)

Unlike traditional markets, decentralized exchanges generally suffer from a lack of liquidity. One approach to solving this problem is the Automated Market Makers (AMMs), which are smart contracts with analogous concepts to a traditional market maker. In DeFi, most AMMs pool assets together, and use that pool as the liquidity for traders to trade against. Thus, traders always have a pool of liquidity (sometimes deep and sometimes shallow). Traders pay a total fee that is based on the quoted fee of the AMM, and the slippage they experience based on the size of their trade relative to the liquidity of the pool (slippage is based on the type of AMM as well, referring to the difference between the effective price the trader receives and the mid price of the pool).

Most AMMs quote a fixed price per pool (the mid price is usually defined as a ratio of tokens in the pool) and often a fixed fee across all pools. Minswap V1 charges a 0.3% fixed fee for traders to trade against any pool, and 0.05% of that fee goes to MIN stakers. This fixed fee, multiplied by 2, can be compared to the spread a market maker quotes in a specific market. So for example, a pool that is charging a 0.3% fee is basically saying you need to pay 0.3% above the quoted price to buy the asset, and 0.3% below the quoted price to sell the asset (at a minimum, this ignores slippage). But charging this fixed spread all the time, across all pools isn’t the most efficient.

Is there a way to make this spread more dynamic, like institutional market makers would quote in order books?

Dynamic Fees

Some DeFi protocols have begun experimenting with having their AMM’s pool fee be dynamic, changing based on different market conditions. Uniswap, the most well-known DEX, in their Uniswap V3 has started offering different fee tiers for one trading pair. For example, the WETH/USDC pair has 3 different V3 fee pools, 0.05%, 0.3%, and 1%. However, liquidity provisioners (LPs) must move their liquidity to different fee pools manually. And traders must pick which pool they want to trade against, based on slippage price and fees (though most users just use an aggregator). So, Uniswap has started to offer multiple fee tiers but not necessarily dynamic fees. Note that Uniswap V4 (when it launches) plans to allow for hooks that could allow pool creators to build dynamic fees.

Other protocols like Trader Joe, Ambient, Swap, Algebra, and more have all taken different approaches to offering pools with fees that actually change within the pool itself, dynamic fees.

There are multiple ways to implement dynamic fees based on market conditions and the type of DEX (Constant Product Market Maker versus Concentrated Liquidity AMM versus Discretized Liquidity AMM). Some will use a volatility measure to inform how the dynamic fee evolves. Others will use historical profitability of different fee pools. Some may use price momentum. Some also may use price oracles to inform the fee (maybe setting fee based on CEX price difference from DEX pool price, etc). For a great overview of different methodologies, see this Medium article.

In this article, we will be focusing on 2 different types of inputs for our dynamic fees: volatility and Impermanent Loss (IL).

Volatility as an Input to Dynamic Fees

Volatility is a measure of risk used commonly in traditional finance and many other disciplines. The most common measure of volatility is standard deviation. Standard deviation gives you an idea of the width of a probability distribution of some random variable. So in this case the standard deviation of an asset’s price gives you an idea of how much the price may move up or down in any given day week month etc. relative to the average price.

Why should we use volatility as an input into dynamic fees? Many people have done a lot of research on what an actual LP can be compared to in traditional finance. LPs can be modeled as holding both assets and writing options on those assets. When you write options (call or put options, which are derivative contracts on an underlying asset that give you the option to buy or sell the underlying in return for a premium paid up front) you are short volatility. Meaning when volatility increases it is bad for your position. So if we think LP’s are short volatility, then as volatility increases that is bad for the LP, so we should increase the fee ( revenue ) of the LP in high volatile times.

Many have written about LPing (Liquidity Providing) and the expression of LPs as options and their “Greeks” (exposures you have when buying or selling an option), including Marco in different medium articles like here and here. Feel free to reach out to Marco if you are curious.

Here is a stylized example of impermanent loss (IL) versus price change from the first link above. As volatility increases, the price moves further away from 0.0 price change, and IL increases.

Another way of looking at it is… what is the cost of LPing. There are two schools of thought on this, the first is Impermanent Loss (IL) and the second is Loss Versus Rebalancing (LVR). Most readers will be very familiar with IL. IL is the opportunity cost of LPing versus holding both assets in their original quantities. IL could be thought of as loss versus holding. LVR is a similar concept except it assumes you can rebalance the position at a no fee CEX price. A great description comes from Delphi Digital here: “If the LP held a rebalancing portfolio and executed the same trades as the liquidity pool on an external exchange like Binance, they would have performed much better”. Please see this paper for more details on LVR.

Both expected LVR and IL can be modeled based on formulas that have a direct positive relationship to standard deviation, really forward looking (ex-ante) standard deviation, also known as Implied Volatility, an extremely important input in option pricing theory. A great analysis on expected IL can be seen below by Guillaume Lambert.

As a side note, an entire suite of protocols is being developed that allows users to lend and borrow LP positions in order to effectively create synthetic options from LP positions based on all of the thoughtful analysis referenced above. Some examples of these protocols are Panoptic (what Guillaume is working on), Smilee, Gammaswap, and many more.

Hopefully you can see from the text above that volatility is an important input into the profitability of LPing, thus it makes sense to be an important input into the calculation of dynamic fees.

Impermanent Loss as an Input into Dynamic Fees

IL is an extremely important measure for LPs as it measures the opportunity cost of LPing versus holding both assets in their initial quantities. We can measure IL using the formula below from the following paper.

Epsilon is the price change of the token. So if MIN versus ADA goes up 10% from 0.05 to 0.055, then Epsilon is 0.055/0.05= 1.1.

Gamma is 1 + fee. So many times we will use 1.003 as gamma, given a fixed 0.3% fee.

In our example the IL of a 10% move in ADA/MIN with a 0.3% fee would be -0.1133%.

We know how much a swap will change the price of a token, so we can measure IL and charge a fee based on the amount of IL incurred by the swap. However, we need to be thoughtful in how this fee works. If we increase the fee too much, it’s highly possible that another DEX in the ecosystem will end up having a better all in price (slippage plus fee given pool price and liquidity). The trader (especially if using an aggregator) will likely go to another DEX. So we want to balance the increased compensation for LPs incurring higher IL with the fact that we want traders to trade in our pool. So we must use IL as an input into a separate function that will determine our fee.

Conclusion

DeFi is continually evolving. There are parts of DeFi that are novel and unique to crypto, but that doesn’t mean that we shouldn’t learn from TradFi and evolve our protocols to best practices that benefit DeFi users. Dynamic fees and updating static fees gets us closer to traditional market makers whose goal is not only to make markets more efficient, but also to maximize their own profits. LPs in DeFi and DEXs have the same goals.

This concludes part one of our primer on Dynamic Fees. We covered the theoretical underpinning on why dynamic fees make sense, along with two potentially useful inputs to dynamic fees. Part 2 will cover the possible implementation that Minswap LPs could choose, some back tests and ideas around parameterization of Fees in LPs. Look out for part 2 soon(™).

--

--

Minswap Labs

Minswap is the multi-pool decentralized exchange on the Cardano blockchain: https://minswap.org