A Note on Optimal Fees for Constant Function Market Makers
Abstract
We suggest a framework to determine optimal trading fees for constant function market makers (CFMMs) in order to maximize liquidity provider returns. In a setting of multiple competing liquidity pools, we show that no race to the bottom occurs, but instead pure Nash equilibria of optimal fees exist. We theoretically prove the existence of these equilibria for pools using the constant product trade function used in popular CFMMs like Uniswap. We also numerically compute the equilibria for a number of examples and discuss the effects the equilibrium fees have on capital allocation among pools. Finally, we use our framework to compute optimal fees for real world pools using past trade data.
1 Introduction
In the past year, blockchains capable of executing smart contracts and decentralized finance (DeFi) applications built on top of them have seen tremendous growth in use. One particularly popular and novel kind of applications are constant function market makers (CFMMs) such as Uniswap, Balancer or Curve.
These decentralized exchanges (DEXs) allow users to trade tokens in a fully decentralized and non-custodial manner. Moreover, they constitute a completely new type of market design compared to traditional exchanges using central limit order books: Instead of matching orders of traders to liquidity providers’ orders in the order book, they let traders swap tokens directly with a smart contract that holds the reserves of the liquidity providers. For any pair of tokens, liquidity providers can create a pool and deposit reserves of both tokens into the contract. Traders can then send an amount of one of the tokens to the contract and receive a certain amount of the other token in return. The exact amount received is determined by a trade function depending on the reserves in the contract. In the case of Uniswap, the amount is chosen such that the product of the reserves in the pool stays constant. For every trade, the trader pays a small trading fee which is distributed pro rata among all liquidity providers contributing to the pool.
With the trading volume of CFMMs growing rapidly and already rivaling that of many centralized exchanges, it becomes essential to better understand this novel kind of market. Since the number of CFMMs and liquidity pools is also growing quickly, a particularly relevant aspect is to examine how these markets compete with each other. How should the pools optimally set their trading fees in order to attract the maximal possible fee revenue? And how should liquidity providers allocate their liquidity among the growing number of pools? In this paper, we suggest a framework to answer these questions.
We study the optimal fee problem in a setting of multiple liquidity pools competing with each other for trade volume. In such a scenario one clearly expects a race to the bottom: all pools successively lowering their fees until they are almost zero. We show however, that this is not the case. Instead, we find that pure Nash equilibria exist, i.e. configurations of optimal fees for which no pool can gain anything by changing its fees, neither by increasing nor decreasing them. For pools using the constant product trade function, such as Uniswap, we theoretically prove the existence of such pure Nash equilibria. We also numerically compute these equilibria for several examples. Here we find that larger pools can charge higher fees than smaller pools in the equilibria. However, we somewhat surprisingly find that in the equilibria smaller pools earn a higher amount of fees relative to their size compared to larger pools. In other words, the return on investment is better for smaller pools. This means liquidity is not always incentivized to concentrate: current or new liquidity providers would prefer to invest in smaller pools or might even create a new pool.
Using past trade data, we can also estimate optimal fees for real world pools. We find that equilibrium fees are significantly lower than today’s standard fee of suggesting that competition should lead to lower fees in the future. In particular, we see that the pools would profit from unilaterally lowering their fees.
In game theoretic terms, we study a continuous -person game where the liquidity pools are the players and the fees they choose to charge are their strategies. The utility of each pool is given by the amount of fees it receives. Due to the nature of CFMMs, we can calculate from the pool reserves and fees how traders should optimally execute their trades using all available pools. This makes it is possible to exactly quantify the change in trading volume the pools experience when changing their fees. Note it can be advantages to split a trade among multiple pools specially for balanced pools with similar fees. In practice, aggregators such as 1inch or Matcha help traders find and execute these optimal trades.
2 Related Work
The concept of automated market makers, i.e. mechanisms that automated the process of providing liquidity to a market, has been around for quite some time, e.g. in form of the logarithmic market scoring rule (LMSR) [12] which is used in prediction markets. The recently popularised decentralized exchanges such as Uniswap use a new type of automated market maker design called constant function market maker (CFMM) [2]. General properties of these markets, in particular how they behave alongside traditional centralized exchanges, have been studied in [4] and [5]. Furthermore, [3] analyzes how the curvature of a CFMM, i.e. the choice the of the constant function, influences liquidity provider returns. For a comparison between traditional limit order book systems and constant product market makers, in particular how the latter can be emulated with certain order book shapes, see [14].
The question of finding the optimal fees for constant function market makers has been discussed using a different model in [9]: Here arbitrage trading between the CFMM and an external reference market is considered. For asset prices following a geometric Brownian motion, it is proven that it is optimal from the liquidity provider’s perspective to set the fees arbitrarily low but not equal to zero. The returns and no-arbitrage prices of liquidity provider shares in CFMMs have also been studied in [13] and [8]. In contrast to these works, we study ”real”, i.e. non-arbitrage trades (these are sometimes referred to as uninformed trades since the traders do not have an information advantage over liquidity providers as arbitrageurs do). More precisely, we consider traders that simply want to execute a planned trade at the best possible price.
In this note, we briefly touch on the problem of finding the optimal trade across multiple CFMM pools. This problem of optimally routing trades though a network of constant function market makers is studied in detail in [6].
3 Model
We model the problem separately for each trading pair of tokens. For a pair of tokens, we consider a number of CFMM pools competing with each other for trade volume. All trades are uninformed, i.e. the trader simply wants to swap a certain amount of the source token for the greatest possible amount of the target token using all available pools. We assume that all pools are balanced before the trade. This means that an arbitrarily small amount can be swapped for the same price in all pools. This is a reasonable assumption as arbitragers will always keep the pools close to balanced. Small remaining imbalances (e.g. caused by fees preventing arbitrage) can be ignored as their effects will average out since trades will be made in both possible directions in the pool.
First, we consider a single trade from the source token to the target token of a certain size (in the source token). This trade is executed optimally using all available pools, i.e. split among the pools to maximize the amount of target tokens received. Later we will extend the model by assuming the size of the next trade is chosen from a distribution of trade sizes. This could be the distribution of trades observed in the recent past.
We assume pool fees are charged as a fixed percentage of the trade size (this is the norm on centralized and decentralized exchanges). For each pool, we look for the optimal such percentage from the liquidity provider’s perspective, i.e. the fee that maximizes the total amount of fees the pool collects from the trade(s).
Each pool has a trade function associated with it. This indicates for any non-negative amount of source tokens, how many target tokens a trader can receive in exchange in this pool. A trade function naturally satisfies , is monotonically increasing and continuous. Furthermore, it is concave as the marginal price is increasing, and bounded since the liquidity in the pool is finite. For our calculations and examples, we use the constant product trade function used by Uniswap and other CFMMs [1]. However, all of this also works for other trade functions. A Uniswap-like pool with reserves and a fee of has the trade function
Assume we are dealing with pools and let the -th pool have reserves and a fee of . Since we assumed that the pools are balanced, we have for all . W.l.o.g. we can choose the unit of measurement for the target token such that for all pools. Hence, the -th pool has the trade function
(1) |
In particular, we only need the numbers and to fully characterize a pool. We measure the size of a pool in source tokens meaning we say that the size of the -th pool size is .
Lastly, we do not consider any fees besides the pool fees. In particular, we do not consider blockchain transaction fees. This means there is no extra cost for trading with a greater instead of a smaller number of pools. While transaction fees are currently relatively high and only negligible for large trades on some blockchains, technological improvements are expected to lower transaction fees in near future making this assumption reasonable.
4 Optimal Trade
We use the following example to illustrate the next steps.
Example 4.1.
For a pair of tokens, there are two pools of sizes 2,000,000 and 4,000,000, respectively. Both pools have a trading fee of . A trader wants to swap 1,000 source tokens for as many target tokens as possible.
Figure 1 shows how many target tokens the trader receives when swapping a certain fraction of the trade in pool 1 and the remaining part in pool 2. In this example, it is optimal to execute of the trade in pool 1 and in pool 2.

Notice that it is always optimal split a trade across all pools if all fees are equal: Since we assumed the pools are balanced before the trade, the marginal price of an unused pool is always strictly lower than that of a used pool. Hence, moving an arbitrarily small amount to an unused pool leads to a better trade. Formally, the problem of finding the optimal trade can be stated as follows.
Definition 4.2 (Optimal Trade Problem).
Given pools with trade functions and a trade of size , finding the optimal trade means solving
maximize | |||||
subject to | (OTP) | ||||
This problem can easily be solved numerically since all are naturally concave. We use (multi-dimensional) ternary search to find the optimum. This technique does not required any specific knowledge about the trade function, in particular not their derivative.
Figure 2 shows the fraction of the trade that will optimally be traded in pool 1 for different fees in pool 1. (Note that while the graph looks piece-wise linear, it is not as the calculations below will show.)

In order to prove the existence of Nash equilibria, we will solve (OTP) analytically. For our purpose, it suffices to solve the problem ignoring the constraint . To see this, note that in every Nash equilibrium the pools will choose fees such that the optimal trade satisfies the constraint : Independent of all other fees, every pool can always attract a positive fraction of the trade (and consequently a positive amount of fees) by setting its fees arbitrarily close to 0. The derived formula will coincide with the actual solution shown in Figure 2 between about and while differing otherwise.
When ignoring the constraint, (OTP) can be solved using a Lagrange multiplier. This yields the equations for in addition to . For the constant product trade function (1), the former equation becomes
Solving this for yields
(2) |
Summing over all leads to
By solving this for and inserting the result back into (2), we conclude
(3) |
It can be quickly checked that if the fees are equal in all pools, i.e. , the term in (3) simplifies to . This implies the following observation.
Observation 4.3.
For Uniswap pools with identical fees, it is optimal for the trader to split the trade proportional to the pool sizes.
5 Optimal Fee Game
We now study how the pools optimize their fees while competing with each other. In other words, we study how the pools play the optimal fee game. In game theoretic terms, we can think of the situation as a continuous -person game in which each of the pools tries to maximize the amount of fees it collects. More precisely, each pool chooses a strategy (its fee) from the set of possible strategies. We write , and denote for the vector of the strategies of all pools except pool , i.e. .
The -th pool will then receive a trade of size according to (3) leading to a total of in fees. So the utility function of player is given by . Figure 3 shows the amount of fees pool 1 collects depending on its fee. The optimal strategy for pool 1 in these circumstances is to set its fee to about .

As a response to pool 1 optimally adjusting its fees, pool 2 might also decide to optimize its fees. This could in turn change the optimal fee for pool 1 again. This motivates us to find a configuration of fees such that none of the pools can gain anything from changing its fees, in other words: a pure Nash equilibrium. Before numerically calculating these equilibria, we first theoretically prove their existence for the case of Uniswap-like pools.
Theorem 5.1.
For any number pools using the constant product trade function and any trade size , a Nash equilibrium exists in the optimal fee game.
Proof.
We use the following sufficient condition due to Debreu [7], Fan [10] and Glicksberg [11]. In a continuous -person game, let be the strategy set and let be the utility function of the -th player for . Then a pure Nash equilibrium exists if for every
-
•
is compact and convex,
-
•
is continuous in , and
-
•
quasiconcave in .
In our setting, the set of strategies is clearly compact and convex and is continuous. So it only remains to prove the quasiconcavity of . (Remember that with given by (3).) We consider a fixed and write as for simplicity. By introducing the constants (in )
we can write as
(4) |
To prove that is quasiconcave, we need to show that is convex for all . This means we need to prove that is a single (possibly empty) interval. First, note that the multiplicative constant of in (4) can be ignored for this purpose. Furthermore, let us introduce and . Finally, we substitute . Since the inverse is continuous and strictly decreasing on , the set is an interval if and only if
is. The latter inequality is equivalent to
(5) |
Now we distinguish two cases. If , then and consequently . Thus, the left-hand side of (5) is always positive meaning the set is empty.
Otherwise, if , consider ’s derivative
(6) |
We see that . So in order for not to be a single interval, the function must attain the value 0 at least three times on . In particular, this implies that its derivative has two zeros in . This together with (6) means it can be written as with . However, this would imply which is a contradiction.
∎
In order to find the Nash equilibria, we consider the best response function of each pool. The best response function of a player returns the optimal strategy for this player for a given set of strategies of the other players. Formally, it is defined as . A Nash equilibrium then satisfies for all . We will numerically compute the equilibria by repeatedly applying for until converges.
6 Equilibrium Fees
We will now look at the fee equilibria for several examples. Figure 4 shows the equilibrium fees for two Uniswap-like pools with a varying difference in size.

We see from the two curves in the upper graph that the larger of the two pools can always set a higher fee than the smaller one. That was to be expected as the larger pool has greater market power. By only looking at the blue curve, we see a pool’s equilibrium fee is high either when the pool is particularly large compared to its competitor or when it is particularly small. As one might expect, the lowest effective fee for the trader occurs when both pools have a similar size, i.e. when competition between the pools is ”strongest”.
Somewhat surprisingly, the lower graph shows that the smaller of the two pools earns a larger amount of fees relative to its size. So the liquidity providers providing liquidity to the smaller pool earn a higher return on their investment. This incentivizes liquidity to move from the larger to the smaller pool. An equilibrium of this process is reached when both pools have the same size.
Next we consider three pools competing with each other. We vary the sizes of the first two pools while keeping the size of the third pools fixed.

Figure 5 show that for three pools, we see similar effects as in the previous scenario with two pools: Larger pools can charge higher fees while smaller pools earn more fees relative to their liquidity.
Furthermore, we can compare two-pool and three-pool scenarios and reason about when it is advantages for one pool to split up into two new pools or for two pools to merge into one. The relative fees of pools 2 and 3 for values on the -axis close to 0 in Figure 5 show the situation when we have two pools with size 3,000,000 each. We see that as long as the fraction of liquidity in pool 1 is between about 10% to 90%, the relative fees of pools 1 and 2 are both lower than the relative fees in the two-pool scenario. So in these cases, it is beneficial for pools 1 and 2 to merge into a single pool. In the remaining cases however, the smaller pool is better off alone. This also implies that for two equal-sized pools, it is beneficial for a small fraction of one of the pools to split off into a new pool. On the other hand, the fact that the (weighted) average relative fee of pools 1 and 2 (the dashed black line) attains its maximum at 0 and 100 means that for the total liquidity in pools 1 and 2 as a whole it is always best to be combined in a single pool.
7 Trade Size Distribution
Obviously, in reality not all trades are of equal size. Accordingly, we now generalize our framework to more than a single trade size. We assume trades are chosen from a discrete distribution, i.e. trade size occurs with a certain probability for . This distribution could be derived from all trades observed in the recent past for a certain pair of tokens. For a fee and a trade size , let be the solution of (OTP). Then the expected fees for pool are
(7) |
Using this utility function, we can calculate optimal fees from past trade data for real CFMM pools. We consider the latest 1000 trades before block 12,000,000 (which occurred on 8 March 2021) from both the Uniswap and Sushiswap WETH-USDC pool, i.e. a sample of 2000 trades. The liquidity of these pools stood at about $262 million and $401 million, respectively, at that time. Assuming all these trades are executed optimally with the current fees, the Uniswap and Sushiswap pools would have received $80,044 and $122,051 in fees, respectively.
If the Sushiswap fee stays fixed, the best option for Uniswap would have been to lower its fee to . This would have increased its earnings to $102,892 with Sushiswap receiving $76,225. On the other hand, assuming Uniswap’s fee remains untouched, Sushiswap’s optimal fee choice would have been leading to $53,285 and $134,094 in earnings, respectively.
When considering more than one trade, it is no longer clear that a pure Nash equilibrium exists. We can however use the average trades size of our sample to get an idea of the equilibrium-like fees. Note that the formula for in (2) is actually linear in , so using this formula with the utility function (7) is equivalent to simply using the average trade size. However, this is not completely accurate for multiple trade sizes: To arrive at the formula for we assumed that all pools attract a positive fraction of the trade in an equilibrium. But this is only true for a single trade at a time. Nonetheless, taking the average trading size should give a reasonable estimate, in particular for relatively narrow distributions. Using the average trade size, the equilibrium fee is and for Uniswap and Sushiswap, respectively. These fees would mean $11,875 and $16,867 in collected fees.
8 Conclusion
In this paper, we introduced a framework that allows us to determine optimal CFMM fees and reason about how the liquidity allocation among CFMM pools might evolve. Of course, this does not answer the question of how to optimally set CFMM fees once and for all: Other aspects such as attracting fees from arbitrage trading (see related work) also need to be considered. Also, trading fees for volatile tokens should be higher than for stable tokens to reward liquidity providers for the extra risk. In any case, the situation of multiple pools for the same trading pair competing with each other is a relevant aspect of the problem. So the equilibria we find do give an indication how market forces could shape the fees.
References
- [1] Hayden Adams “Uniswap Whitepaper”, 2018 URL: https://hackmd.io/@HaydenAdams/HJ9jLsfTz
- [2] Guillermo Angeris and Tarun Chitra “Improved Price Oracles: Constant Function Market Makers” In Proceedings of the 2nd ACM Conference on Advances in Financial Technologies, AFT ’20 New York, NY, USA: Association for Computing Machinery, 2020, pp. 80–91 DOI: 10.1145/3419614.3423251
- [3] Guillermo Angeris, Alex Evans and Tarun Chitra “When does the tail wag the dog? Curvature and market making”, 2020 arXiv:2012.08040 [q-fin.TR]
- [4] Guillermo Angeris et al. “An analysis of Uniswap markets”, 2019 arXiv:1911.03380 [q-fin.TR]
- [5] Jun Aoyagi and Yuki Ito “Liquidity Implication of Constant Product Market Makers” In Available at SSRN 3808755, 2021
- [6] Vincent Danos, Hamza El Khalloufi and Julien Prat “Global order routing on exchange networks” In Working Draft, 2020
- [7] Gerard Debreu “A Social Equilibrium Existence Theorem” In Proceedings of the National Academy of Sciences of the United States of America 38.10 National Academy of Sciences, 1952, pp. 886–893 URL: http://www.jstor.org/stable/88720
- [8] Alex Evans “Liquidity Provider Returns in Geometric Mean Markets”, 2020 arXiv:2006.08806 [q-fin.MF]
- [9] Alex Evans, Guillermo Angeris and Tarun Chitra “Optimal Fees for Geometric Mean Market Makers”, 2021 arXiv:2104.00446 [q-fin.MF]
- [10] Ky Fan “Fixed-point and Minimax Theorems in Locally Convex Topological Linear Spaces” In Proceedings of the National Academy of Sciences 38.2 National Academy of Sciences, 1952, pp. 121–126 DOI: 10.1073/pnas.38.2.121
- [11] I.. Glicksberg “A Further Generalization of the Kakutani Fixed Point Theorem, with Application to Nash Equilibrium Points” In Proceedings of the American Mathematical Society 3.1 American Mathematical Society, 1952, pp. 170–174 URL: http://www.jstor.org/stable/2032478
- [12] Robin Hanson “Combinatorial Information Market Design” In Information Systems Frontiers 5.1, 2003, pp. 107–119 DOI: 10.1023/A:1022058209073
- [13] Martin Tassy and David White “Growth rate of a liquidity provider’s wealth in xy= c automated market makers”, 2020
- [14] Jamie E. Young “On Equivalence of Automated Market Maker and Limit Order Book Systems”, 2020 URL: https://professorjey.com/assets/papers/AMM_Order_Book_Equivalence_DRAFT_2020_10_16.pdf