Abstract
One of the most interesting applications of blockchain is given by the automated market makers (AMMs). In the paper, we discuss how arbitrage activity between the AMMs and the other exchange nodes can affect the volumes of assets in liquidity pools of constant function AMMs. In particular, we argue that arbitrage superimposes to the constant function in determining the liquidity volumes within the same AMM and across different AMMs. Yet, despite representing an additional condition in the model, equilibrium arbitrage is typically not unique because it may depend on several elements, such as the amount of liquidity in the system and the number of exchange nodes. Hence, the paper discusses how the constant function and arbitrage jointly determine the relationship across the assets’ liquidity volume in the pool but not a unique value for such volumes unless further constraints are introduced. Therefore, a platform interested in predicting the pool’s liquidity volumes may face indeterminacy as to which equilibrium would prevail. Though arbitrage has been discussed in related literature, equilibrium indeterminacy does not seem to have been pointed out.
1 Introduction
One of the most interesting applications of blockchain is given by the automated market makers (AMMs). These are platforms where tokens, typically cryptocurrencies, can be deposited by liquidity providers, forming liquidity pools, to obtain an interest for such service. The available assets can then be traded against each other through smart contracts at a price that is determined by the amount of liquidity of such assets in the AMM, together with a rule governing their exchange.
A widespread family of AMMs is the so-called constant function AMMs (CFAMMs), whose properties have been extensively studied in the literature (Di and Guida, 2017; Cliff, 2018; Angeris and Chitra, 2020; Angeris et al., 2020; Angeris et al., 2021; Angeris et al., 2022; Aoyagi, 2022; Bartoletti et al., 2022; Fabi et al., 2022; Mohan, 2022; Wang and Krishnamachari, 2022; Fabi et al., 2023; Doe et al., 2023; Xu et al., 2023; Milionis et al., 2024a; Milionis et al., 2024b; Tran et al., 2024). In pairwise liquidity pools with only two assets, the price at which they swap with each other depends on the liquidity volumes currently in the pool. In CFAMMs, the exchange price is characterized by the fact that, when swapping one asset for another, a certain specified function of the assets’ liquidity volumes must be kept at the same value (Fabi and Prat, 2023). That is, before and after the asset exchange, some function must preserve the same value. This is, the function defines the price at which one asset trades with the other. In particular, Uniswap has been the first successful platform to use CFAMM, followed by several others, such as Balancer and Curve.
Therefore, choosing which constant function to adopt is a policy decision taken by the platform because it is selected unilaterally by the AMM. However, the constant function can change its value whenever liquidity providers decide, for example, to deposit units of assets in the pool. Analogous considerations hold when providers decide to withdraw liquidity from the pool. In addtion to constant functions, the arbitrage activity taking place between the CFAMM and the other exchange nodes in the market represents an important additional element to consider when analyzing CFAMMs.
Indeed, arbitrage superimposes to the constant function in determining the CFAMM prices and liquidity volumes. As a matter of fact, it is intuitive to think that the price at which two assets trade in a CFAMM should typically be related to the price charged by other exchange nodes in the market. Looking for the most convenient prices, investors will trade quantities and, in so doing, tend to equalize such prices by exchanging assets in different nodes.
In the article, we investigate how arbitrage activity affects, in equilibrium, liquidity volumes in a CFAMM, where by “equilibrium,” we mean that arbitrage activity has taken place and that trading prices within a CFAMM are equal to the prices prevailing in the market exchange nodes. Although the importance of arbitrage is well known in the CFAMM literature (Aoyagi, 2020; Angeris et al., 2020; Angeris et al., 2021; Mohan, 2022; Tran et al., 2024), to our knowledge, no contribution has presented an articulated analysis of the implications of arbitrage in a variety of contexts, which is the goal of this paper. We think this is very important to envisage how the CFAMM and the market exchange nodes will relate. Yet, as we shall see, although the constant function and the arbitrage activity constrain liquidity pool volumes, arbitrage equilibria are typically not unique unless additional conditions are introduced. Such multiplicity depends on the amount of liquidity in the market, the number of users, their preferences, etc., and it is difficult to obtain uniqueness unless more specific additional conditions are introduced. Together with the equilibrium value determination of liquidity deposits, the issue of indeterminacy is our main contribution to the existing literature. In particular, the analysis suggests that arbitrage activity in a CFAMM can determine the relationship between the amount of assets’ liquidity deposited but not their absolute value. The work is structured as follows. In Section 2, we introduce the basics of CFAMMs and discuss how arbitrage affects price and liquidity volumes. Section 3 concludes the paper.
2 The model
In what follows, we shall begin by considering a CFAMM with liquidity pools composed of two assets. Later, we shall extend the pools to more than two assets. Such pools allow for swapping one asset with the other as well as for depositing liquidity on the part of liquidity providers who can obtain a fee from doing that. First, with no major loss of generality, we assume no fees are paid to liquidity providers or to the platform for swapping assets, etc. Transaction fees will be discussed later.
Suppose is the total liquidity value in the pool, expressed in terms of a currency, say , available in a two-asset pool , where the assets and can be swapped. If and are the quantities deposited in the pool, respectively, of and , thenwhere defines the function of the AMM that needs to take the constant value . This means that if one asset is swapped with the other when and are the initial liquidity volumes, and if the liquidity volumes are and after the swap, then .
Indeed, while the function is chosen by the platform, the number is determined by the amount of liquidity deposited, consistent with . For example, if , and , then . Therefore, if the liquidity in the pool does not change, any swap between and must keep the liquidity levels of and in such a way that Equation 1 is satisfied. For this reason, the constant should be more properly written as , to indicate that it depends on the liquidity levels and that for alternative liquidity levels, the constant would be different. This amounts to observing that may vary with time, and that in general, it could also be indicated where is time. Indeed, as a follow up to the above example, if now the liquidity is , that is scaled up by a multiplicative factor of in both assets, not to change their initial ratio, then . It is well known that higher liquidity volumes will change the terms of trade. Indeed, suppose ; then if units of are swapped against , the new liquidity volumes will be which means that units of traded against units of . However, if instead the liquidity was , then additional units of trade against units of with the new pair being . That is, the same amount of traded , units, would swap against a larger amount of due to the larger availability of .
Therefore, for small traded quantities, assuming to be partially differentiable by defining and , and equalizing the total differential of Equation 1 to , we obtain that in the CFAMM, the price of in terms of , expressed according to , can be found as follows:when the quantity of the two assets is and . Assuming , it follows that , that is, if is deposited, then is obtained by the liquidity provider and the contrary. Therefore, represents the number of units that can be obtained with a small amount of , that is, the price of assets in terms of in the CFAMM.
Similar reasoning could also be applied to the constant function when the asset liquidity and the constant change with time and where is time, to investigate their dynamics. Namely, if now Equation 1 is written asthen, assuming the differentiability of all the relevant functions,that is, if and experience some small changes with time, then reacts by adjusting its value accordingly. From Equation 4, it follows that whenever but also if Equation 2 holds when .
For example, if , with , then . Hence, if , then , that is, the price is given by the simple ratio of the two liquidity volumes, regardless of the values of .
2.1 Arbitrage condition
Suppose now the two assets are traded also in other exchange nodes, and that and are the prevailing market prices, that is, how many can be bought with, respectively, one unit of and . Then, the following holds:where, as above, is the total liquidity available in the pool, expressed in . In analogy with Equation 4, considering also as functions of time, and assuming differentiability of the relevant functions, the dynamics of Equation 5 are given by
Therefore, Equation 5 can be re-written as
It follows thatis the prevailing exchange rate in the market, which could also represent a market price between the two assets whenever and are also directly traded against each other in exchange nodes.
Therefore, arbitrage activity between a CFAMM and the market exchange nodes would implyso that Equation 5 becomes
Finally, replacing Equation 9 in Equation 1 provides
Equation 10 lays the ground for the following question. How does arbitrage activity affect the liquidity volumes and the prices in a CFAMM? That is, can the arbitrage condition and the constant function be both satisfied, and how will the liquidity volumes in the pool be influenced? We discuss the issue below.
2.2 Arbitrage equilibrium in CFAMMs
The above question can be rephrased as follows: is it possible to find values for that solve the set of Equations 1–9? If yes, we then define the solutions as an arbitrage equilibrium (AE). As said above, our main contribution with respect to the received literature will stand in pointing out the equilibrium multiplicity and its implications within the same CFAMM and across different CFAMMs.
Because the system has three equations and four unknowns, it would typically allow for multiple solutions.
To illustrate this point, take again . Then, fixing , , and the total liquidity value , we can solve Equations 1–9 to obtain
The above expressions represent one AE of the pool for a given pair and and an overall liquidity level .
For instance, if , then , and .
The interpretation of Equation 11 is immediate; there is a unique AE with given by , and . However, if instead, everything else is the same, and , then the unique AE is as before, except that now .
Thus, as and change, would also change. Indeed if , rather than , then with , it follows that and 00. Therefore, there exists an infinity of AE, each defined by Equation 11.
To summarize, and depend on the prevailing market prices, and , so they could not be kept under direct control by the CFAMM. Indeed, the market prices are subject to volatility, and their uncertainty would contribute to the equilibrium indeterminacy. If the platform has preferred values for and , it will have to intervene in the pool by depositing/withdrawing the desired amount of liquidity in case the providers do not spontaneously do so.
Moreover, Equation 11 implies that the market value, measured in , of the two assets deposited in the CFAMM must be the same and equal to . This is because , and it is immediate to verify that if, for example, , then . Additionally, it is worth noting that, for instance, is neither a necessary nor a sufficient condition for . Indeed, requires , which can be satisfied even with , as long as is sufficiently small.
Alternatively, if , rather than , is fixed, it follows that and in Equation 11 could be expressed aswhich shows that, at an AE, are increasing functions of , concave for , linear if , and convex for . It also shows that and are decreasing in their own price and increasing in the other asset’s price. The intuition is immediate and hinges on a substitution effect. If one asset becomes too expensive, then it is convenient to deposit the other asset.
Expression (Equation 12a) clarifies that once the triple and are fixed, then and , hence , are uniquely determined by the constant product and the arbitrage activity.
Therefore, given the market conditions, by choosing , the CFAMM could, in principle, control the amount of liquidity in the two asset pools, suggesting that the value of might, again in principle, become a policy instrument to regulate the system liquidity.
An additional perspective to determine the relationship between and the other quantities under arbitrage activity is the following. Suppose again, for simplicity, that Then , which, when replaced into Equation 5, provides
Then, Equation 12b is a quadratic equation that leads to the following two possible solutions when is solved:
Because , then , implying that Equation 13 always admits real number solutions. If then Equation 13 will have two positive roots. Consider firstthen from Equation 14 it follows , which would mean that arbitrage is also satisfied. However, this is impossible because implies and, therefore, that hence contradicts the initial assumption of .
Instead, consideringthe level of is left undetermined so that
In this case, any pair such that and would satisfy constant product but could not satisfy arbitrage. Therefore, with two roots, arbitrage would not be obtained.
Finally, the only way for arbitrage to be guaranteed is to have , that is, when Equation 12 has a unique root, which is a modality to characterize the value of , hence of , and obtain both constant product and arbitrage.
More in general, from one can find , which, when substituted into Equation 5, gives . If this is solvable in it provides the level of the two assets’ liquidity that satisfies constant sum but not necessarily arbitrage.
As an additional example, suppose Then, and so that for , in which case AE will not be achieved. However, if then any satisfies constant sum as well as arbitrage.
Finally, but no less important, AE could also be obtained as the solution to the following minimization problem (Milionis et al., 2024a), with :then
Differentiating Equation 15 with respect to , we obtainwhich, when solved, providesas in Equation 12, for . That is, AE obtains when the value of the pool subject to the constant function constraint is minimized for given , and .
Likewise, solving the following maximization problem:for given and would providewhich is the same solution. To summarize, arbitrage would either minimize for given or maximize for given .
2.3 Arbitrage equilibrium, within CFAMMs, with several liquidity pools
A CFAMM typically contains several liquidity pools, where one asset could be traded against different assets. When this is the case, arbitrage implies that the asset quantities in the liquidity pairwise pools must be related in a specific way.
Consider, for example, the following three assets: , which are traded in pairs in the pools within the same CFAMM. Furthermore, suppose are the quantities of the three assets in the three liquidity pools. Then, assumingit follows that, at an AE,
From Equation 16, we also obtainand Equation 17 implies thatwith Equation 18 also exhibiting multiple solutions. Hence, the asset quantities in the three liquidity pools must stand in a specific relationship when arbitrage takes place, and so , , and , too. Indeed, if , , and are the values, in , of the three liquidity pools, thenand therefore,which means that if and characterize the pools and , then and in the two liquidity pools need to satisfy Equation 19. In particular, Equation 19 suggests that the liquidity value in the pool increases linearly with the value in the pool , while it is a concave function of .
2.4 Arbitrage equilibrium across multiple CFAMMs
Suppose now that and are traded in two different CFAMMs with different types of constant functions. In one of them, the liquidity pool satisfies , while the liquidity pool in the other CFAMM satisfies . As above, arbitrage leads to and , and it is immediate to verify that arbitrage activity would lead to , and, hence, to Therefore, it follows that for both CFAMMs to satisfy arbitrage, it must be that , which may take place only with specific assets, such as, for example, stablecoins. In this case, with .
Arbitrage equilibrium in different markets for the same pair of assets introduces additional constraints. This suggests that, in general, different CFAMMs trading the same pair of assets could all achieve an AE in their liquidity pool only under very specific conditions on the market prices. In particular, if any CFAMM adopts the constant function, arbitrage would impose equal asset market prices to all the other CFAMMs trading the same assets. Therefore, with the constant product function, this would imply that in equilibrium, which, however, would not be a necessary condition for the constant sum function.
2.5 CFAMMs with multiple assets
We will now consider what happens when more than two assets are traded within the same CFAMM. To see our main point, consider again the simplest case of three assets, As we saw above, the three assets could be traded in three different pools, each composed of a pair of assets. In general, with assets, if all of them are traded against each other, there would be pairs which, for large , is a large number.
A distinguishing feature of trading pairs of assets is that, typically, the trading price in each pool is independent of the trading price in another pool. For example, suppose the quantities of the two assets in the pool are, respectively, and , while in the pool the prices are and . Then, assuming both pools adopt the constant product function, and , so that the price of in terms of is in the first pool, and the price of in terms of is in the second pool. Suppose now that the available amount of asset in the pool becomes so that, because the additional units are traded against the volume of the other asset reduces to , keeping their product equal to . Therefore, a trade in the will only affect the price in that pool but not in another pool.
That is, in the pool, the price would still be .
Suppose instead that the three assets are part of the same pool, , where any subset could be traded against the remaining assets. Assume the current liquidity level is , and . Furthermore, suppose we still have a constant product functionand that now in Equation 20 the liquidity of goes up to , where the additional units are traded against , which then decreases to to keep the product constant at Therefore, now the updated liquidity volumes become , and .
However, compared to trading in pairwise separate and independent pools, now the trade between and not only affects the price between them but also their prices with respect to . Indeed, while before the exchange, they were ; after the trade, they are and . That is, the exchange between and would induce an externality on the trading conditions between and the other two assets. In particular, now with unit of a user could obtain units of , that is more than before, and units of , namely, units less than before, and the opposite for and holders.
In principle, with different assets, the number of pools for trading assets that could be formed is , which is a potentially large number for large In the case that all, or many, of such pools would be formed, then arbitrage within the CFAMM would take place such that trading prices in each pool would equalize.
For example, suppose a CFAMM contains the pairwise pools and the pool , with the three of them. Moreover, suppose the four pools adopt the constant product function, with constants . Then, arbitrage would imply
Therefore, it follows that the value $ of the three assets in the four pools expressed in would be the same. Equation 21 has multiple solutions, one of which would be given by the same quantity for each asset in the four pools; that is, , which would imply that
Based on the above considerations, it is natural to ask if it would make sense for a platform to have separate pools with two assets, three assets, etc. For example, in case the solution is given by Equation 22, having a single pool with three assets and liquidity would generate a pool that could perfectly scale up the four individual pools with liquidity into a single pool three times as large.
We now extend the above considerations to CFAMMs with multiple assets. Suppose are assets traded in a CFAMM and assume thatEquation 23 is the generic constant value function with being the partial derivative with respect to , which we assume to exist. Therefore, if is the price of in terms of , then arbitrage implies
For example, takingthen and . Finally,
Considering Equations 24–26 and proceeding in analogy with the case of two assets, we obtain thatand also that
which, for the benchmark case of for all would lead towhere , for all .
In analogy to Equations 27–29, it is immediate to verify that ifthen for all and any non-negative profile such that Equation 30 is satisfied as an AE andwhere Equation 31 represents a simple linear relationship between k and M.
2.6 Some additional examples of CFAMMs
In the above examples with and , we saw that there exists a liquidity pool such that the arbitrage condition is satisfied. In what follows, we discuss some additional constant functions. Consider, for example, the following function:
Then, the arbitrage condition will lead to
which implies
and so
In the simple case of ,
then
while
Hence, based on Equations 33–38, Equation 32 becomes Equation 39 below.
Moreover, consider a convex combination, with 0<a<1, of the two expressions used individually as constant functions:A version of Equation 40 is used by the Curve platform. The discussion shows how finding the equilibrium arbitrage may not always be so immediate. Indeed,so that arbitrage impliesEquations 40–42 lead to
Equation 43 suggests that implies , while implies . Finally, for , then ; that is, not only the values but also the two assets’ quantities should be the same.
2.7 Transaction fees
As anticipated above, to conclude the paper, we introduce transaction fees to see how they may affect the AE. A simple way to do so in a two-asset liquidity pool is to define as follows:where , are, respectively, the share of deposits and available after having paid transaction fees. That is, if liquidity providers deposit , then what remains available in the pool is a share of them. Considering again the function : with transaction fees, it would become , and the AE solutions are given bynamely, now the deposits at an AE increase with the fees because part of the deposited sums will not be available in the pool.
Finally, the constant parameter is given by To summarise, Equations 44–46 suggest that the fees on the two assets will affect the absolute, and relative size, of their liquidity volumes.
3 Conclusion
In this paper, we discussed how arbitrage activity can affect the liquidity volumes and swap prices in a CFAMM. Indeed, CFAMMs do not typically operate in isolation but within a market where other exchange nodes can trade the same assets. Therefore, arbitrage activity superimposes to the constant function property, establishing the asset trading prices. In the analysis, we argued how the arbitrage equilibrium is not unique for a given CFAMM, as it can be obtained for different levels of liquidity available in the economy as well as with different numbers of exchange nodes trading the same assets.
We considered arbitrage in a variety of circumstances, within the same CFAMM but also across different CFAMMs and exchange nodes. The main intuitive message of the article is that arbitrage represents an additional important constraint to the relevant constant function in determining the trading prices and the deposit volumes in CFAMM liquidity pools.
Statements
Data availability statement
The original contributions presented in the study are included in the article/supplementary material; further inquiries can be directed to the corresponding author.
Author contributions
ND: writing–review and editing, writing–original draft, methodology, formal analysis, and conceptualization.
Funding
The author declares that no financial support was received for the research, authorship, and/or publication of this article.
Acknowledgments
I would like to thanks the Associate Editor and the reviewers for constructive comments.
Conflict of interest
The author declares that the research was conducted in the absence of any commercial or financial relationships that could be construed as a potential conflict of interest.
The author declared that they were an editorial board member of Frontiers, at the time of submission. This had no impact on the peer review process and the final decision.
Publisher’s note
All claims expressed in this article are solely those of the authors and do not necessarily represent those of their affiliated organizations, or those of the publisher, the editors, and the reviewers. Any product that may be evaluated in this article, or claim that may be made by its manufacturer, is not guaranteed or endorsed by the publisher.
References
1
AngerisG.AgrawalA.EvansA.ChitraT.BoydS. (2022). “Constant function market makers: multi-asset trades via convex optimization,” in Handbook on blockchain (Springer), 415–444.
2
AngerisG.ChitraT. (2020). “Improved price oracles: constant function market makers,” in Proceedings of the 2nd ACM Conference on Advances in Financial Technologies, New York, NY, October 21–23, 2020 (Association for Computing Machinery), 80–91.
3
AngerisG.EvansA.ChitraT. (2020).When does the tail wag the dog? Curvature and market making, arXivpreprintarXiv:2012.08040.
4
AngerisG.EvansA.ChitraT. (2021). Replicating market makers, arXivpreprint arXiv:2103.14769.
5
AoyagiJ. (2022). Liquidity provision by automated market makers. Available at: https://papers.ssrn.com/sol3/papers.cfm?abstract_id=3674178 (Accessed June 15, 2024).
6
BartolettiM.ChiangJ.Llluch-LafuenteA. (2022). A theory of automated market makers in DEFI. Log. Methods Comput. Sci.18, 1–46. 10.46298/lmcs-18(4:12)2022
7
CliffD. (2018). “An open-source limit-order-book exchange for teaching and research,” in Proceedings of the 2018 IEEE Symposium Series on Computational Intelligence, Bangalore, India, November 18–21, 2018 (IEEE), 1853–1860.
8
DiP. L.GuidaF. (2017). A discrete trinomial model for the birth and death of stock financial bubbles. AIP Conf. Proc.1906, 190007. 10.1063/1.5012470
9
DoeD. M.LiJ.DusitN.WangL.HanZ. (2023). Incentive mechanism design for mitigating frontrunning and transaction reordering in decentralized exchanges. IEEE Access11, 96014–96028. 10.1109/access.2023.3236891
10
FabiM.KassoulM.PratJ. (2023). SOK: constant functions market makers. Paris: Blockchain Politechnique. Working Paper 2023-02-07.
11
FabiM.PratJ. (2023). The economics of constant functions market makers. Blockchain Politechnique. Working Paper 2023-04-004.
12
MilionisJ.MoallemiC.RoughgardenT.ZhangA. (2024a). Automated market making and loss-versus rebalancing, arXiv:2208.06046 [q-fin.MF].
13
MilionisJ.MoallemiC. C.RoughgardenT. (2024b). “Extended abstract: the effect of trading fees on arbitrage profits in automated market makers,” in Lecture notes in computer science (including subseries lecture notes in artificial intelligence and lecture notes in bioinformatics), 13953, 262–265. 10.1007/978-3-031-48806-1_17
14
MohanV. (2022). Automated market makers and decentralized exchanges: a DeFi primer. Financ. Innov.8, 20. 10.1186/s40854-021-00314-5
15
TranT.TranD. A.NguyenT. (2024). Order book inspired automated market making. IEEE Access12, 36743–36763. 10.1109/access.2024.3372402
16
WangS.KrishnamachariB. (2022). “Optimal trading on a dynamic Curve automated market maker,” in IEEE International Conference on Blockchain and Cryptocurrency, Shanghai, China, May 02–05, 2022 (IEEE).
17
XuJ.ParuchC.CousaertS.FengJ. (2023). SOK: decentralized exchanges (DEX) with automated market maker (AMM) protocols. ACM Comput. Surv.55, 1–50. 10.1145/3570639
Summary
Keywords
arbitrage, automated market makers, constant functions, equilibrium multiplicity, liquidity pools
Citation
Dimitri N (2024) Arbitrage in automated market makers. Front. Blockchain 7:1455070. doi: 10.3389/fbloc.2024.1455070
Received
26 June 2024
Accepted
09 September 2024
Published
14 October 2024
Volume
7 - 2024
Edited by
Andrea Pinna, University of Cagliari, Italy
Reviewed by
Matteo Vaccargiu, University of Cagliari, Italy
Luca Di Persio, University of Verona, Italy
Updates
Copyright
© 2024 Dimitri.
This is an open-access article distributed under the terms of the Creative Commons Attribution License (CC BY). The use, distribution or reproduction in other forums is permitted, provided the original author(s) and the copyright owner(s) are credited and that the original publication in this journal is cited, in accordance with accepted academic practice. No use, distribution or reproduction is permitted which does not comply with these terms.
*Correspondence: Nicola Dimitri, dimitri@unisi.it
Disclaimer
All claims expressed in this article are solely those of the authors and do not necessarily represent those of their affiliated organizations, or those of the publisher, the editors and the reviewers. Any product that may be evaluated in this article or claim that may be made by its manufacturer is not guaranteed or endorsed by the publisher.