SSRN Id3722714
SSRN Id3722714
SSRN Id3722714
VIJAY MOHAN1
RMIT Blockchain Innovation Hub, RMIT University
& Lattice Analytics Pty Ltd
Email: [email protected]
Abstract
Recent advancements in decentralized finance (DeFi) have resulted in a rapid increase in the
use of Automated Market Makers (AMMs) for creating decentralized exchanges (DEXs). In
this paper, we organize these developments by treating an AMM as a neoclassical black-box
characterized by the conversion of inputs (tokens) to outputs (prices). The conversion is
governed by the technology of the AMM summarized by an ‘exchange function’. Various types
of AMMs are examined, including: Constant Product Market Makers; Constant Mean Market
Makers; Constant Sum Market Makers; Hybrid Function Market Makers; and, Dynamic
Automated Market Makers. The paper also looks at the impact of introducing concentrated
liquidity in an AMM. Overall, the framework presented here provides an intuitive geometric
representation of how an AMM operates, and a clear delineation of the similarities and
differences across the various types of AMMs.
1 I thank four anonymous referees for their comments and suggestions for improving the content in this paper
and eliminating errors. This paper is the outcome of numerous insightful discussions on DeFi over the course of
several months with colleagues at RMIT’s Blockchain Innovation Hub. The author would like to take the
opportunity to thank the multidisciplinary cohort of academics at the Hub for this: Darcy WE Allen, Chris Berg,
Sinclair Davidson, Oleksii Konashevych, Aaron M Lane, Elizabeth Morton, Kelsie Nabben, Vy Nguyen, Imon Palit,
Marta Poblet, Jason Potts, Ellie Rennie, Sarah Sinclair and Stuart Thomas.
1. Introduction
1.1 DeFi, DEXs and AMMs
The latest new thing in the blockchain space is decentralized finance (DeFi) which, broadly,
refers to financial digital applications built on decentralized blockchain networks. According
to one source, at the time of writing, the value of cryptocurrency locked in DeFi applications
is USD 89.23 billion, having more than quadrupled over a one-year period.2 In contrast to
traditional finance that is facilitated by centralized agencies, such as banks and stock
exchanges, the promise of DeFi is the elimination of centralized third-parties that act as
intermediaries in financial transactions.
While it is not clear at this stage whether DeFi will replace traditional financial institutions
with their decentralized substitutes, or even if many of the start-ups in this area will
eventually survive, the rapidly escalating advancements in DeFi applications suggest that
there is a need to step back and correlate ideas in this area with traditional concepts in
economics and finance. This paper represents an attempt at examining new developments in
DeFi using an old tool in economics – the neoclassical black-box. In doing so, we show that
the graphical and mathematical methods familiar to generations of students of economics
can provide broad insights into certain aspects of DeFi, and that many recent experiments in
DeFi are applications of more general production technologies. Ultimately, the motivation
here is to introduce these ideas to DeFi aficionados who are interested in an economic theory
perspective, and to present some wonderful new applications of old tools to economists,
especially students and educators.3
The application of DeFi that this paper focuses on is decentralized exchanges (DEXs). In
contrast to an over-the-counter (OTC) market that enables direct trading between two
agents, an exchange is an institution which standardizes assets and trading rules for multiple
participants. To do so, an exchange must provide mechanisms to maintain liquidity of assets
and to determine prices for assets. A stock exchange, for example, implements this through
an order book system, where buyers and sellers submit ‘orders’: prices and volumes for an
asset they would like to buy or sell. The trading price is determined by matching orders.
Typically, orders are public information, allowing market participants to gauge information
about interest in an asset and the price at which it is trading. In a centralized exchange, orders
are maintained and implemented by a central authority (say, the New York Stock Exchange).
4 Of course, a single agent is free to perform both functions – provide liquidity and trade – on an AMM.
5 See https://ethereum.org (accessed 20th September, 2021), and https://ethereum.org/en/whitepaper/
(accessed 20th September, 2021) or Buterin (2014).
address generated for a smart contract depends on the current state. So, if a bug is found in a smart contract
after deployment, a new contract deployed (in the future) with new code would receive a new address. Even
with this constraint, there exist ways to ‘upgrade’ a contract, for example by using a proxy contract, or by
deploying a new contract (with a new address) and migrating users and data to the new address (which can be
expensive). In 2019, as part of the Constantinople upgrade to the Ethereum blockchain, the CREATE2
functionality was introduced (see https://eips.ethereum.org/EIPS/eip-1014, accessed 20th September, 2021).
This essentially allows the address to be independent of future states, so it is possible to calculate a smart
contract’s address even without deployment. In terms of upgrading a smart contract, this implies that if a smart
contract is issued an address using the CREATE2 functionality, it can be instructed to self-destruct and a new
smart contract can be deployed with the same address.
9 See https://ethereum.org/en/developers/docs/standards/tokens/erc-20/ for a description of ERC-20 and
commonly used standards at this stage, other standards exist, such as ERC-777 and ERC-1155. Standards are
introduced in the Ethereum network through Ethereum Improvement Proposals (EIPs); for further details, see
https://eips.ethereum.org and https://eips.ethereum.org/erc. All websites accessed 20th September, 2021.
10 It is worth emphasizing that the omission of gas fees in our analysis is not due to their lack of importance;
rather, it is due to the fact of gas fees are network-wide fees, which are present irrespective of whether AMMs
exist or not. In as much as our focus is on modelling an AMM, gas fees can be viewed as an exogenous cost that
has been normalized to zero in this paper.
11 Uniswap-v2 (Adams et al, 2020), for example, introduced the possibility of a .05% protocol fee that is deducted
from the trading fees. So, protocol fees do no not affect the transaction cost of the traders on the exchange;
rather, they create a wedge between the fees paid by traders and the fees received by liquidity providers. In
that sense, protocol fees are a tax on the users of an AMM.
12 See Demsetz (1997), Hart (1995, Chapter 1), and Holmstrom and Tirole (1989) for overviews.
13 The term ‘exchange function’ is used because it captures different ways in which the word ‘exchange’ appears
in this context. First, the function governs the exchange of one token for another by traders in an AMM; second,
any given decentralized exchange will have a specific function associated with it.
14 See https://uniswap.org (accessed 20th September, 2021). As a disclaimer, the utilization of specific AMMs as
examples in this paper is purely for expository purposes, and is in no way meant to advocate their use.
features added to make it more “community friendly”. In what was subsequently termed a “vampire attack”,
Sushiswap sought to extract liquidity away from Unsiwap. For a summary of vampire attacks, see
https://finematics.com/vampire-attack-sushiswap-explained/. Mooniswap, on the other hand, attempts to
reduce the impact of price slippage from large trades on a CPMM. All websites accessed 20th September, 2021.
18 An application of these techniques can also be found in a graduate microeconomics text, such as Mas-Colell,
Dynamic weights
CSMM CMMM
(Balancer)
Special case
Mix
HFMM CPMM-v2, v1
(Curve) (Uniswap-v2, v1)
Recently, Uniswap released Version 3 (v3; Adams et al, 2021), which is a significant
departure from v2. In Section 5, we review the changes brought about by Uniswap-v3 and
turn to broadly outlining the geometry behind this AMM by examining the idea of
concentrated liquidity. We show here that Uniswap-v3 displays some characteristics of both
a CPMM and a CSMM.
Like the neoclassical firm, the black-box view of an AMM has limitations in describing other
aspects of an AMM, such as how decentralized governance of an AMM is organized, how
communities are formed in this space, and so on; this paper does not address these important
and interesting issues. Nor does this paper delve into the uses of AMMs other than for the
purpose of creating a DEX. Some concluding thoughts on this are offered in Section 6.
𝑏 𝑎 𝑦0
(1) 𝑃𝑌/𝑋 = 𝑃𝑌/𝑋 = 𝑥 0 = 𝑃𝑌/𝑋
There are a few features to take away from this example. First, equation (1) summarizes
the fact that the bid and ask prices collapse to a single price (𝑃𝑌/𝑋 ) for infinitesimally small
21 In the notation 𝑌/𝑋, 𝑋 is the ‘base’ token and 𝑌 is the ‘pricing’ token. As in traditional finance, we use the
terms ‘bid’ and ‘ask’ (or ‘offer’) as rates viewed from the perspective of the market maker. A trader, therefore,
sells at the bid price, and buys at the ask price.
22 See https://ethereum.org/en/eth/ (accessed 20th September, 2021).
10
Third, with no fees, 𝑘 0 remains the same for all subsequent trades, and only changes when
liquidity is injected into, or withdrawn from, the pool by liquidity providers.
Now consider a situation where the trader is required to pay an ad valorem trading fee, 𝜏.
Apart from the addition of fees, all the other features of the example are maintained. The
trading fee is assumed to be 𝜏 = .25% in the example constructed in the Uniswap-v1
whitepaper, which we follow here as well; in reality, the fee on Uniswap-v1 and v2 is 0.3%.
The trading fee is paid using the token that is added to the liquidity pool (that is, the token
sold by the trader). Assuming, as before, that the trader sells 1 ETH, the transaction cost of a
sale of 1 ETH by the trader is 𝜏 × 1 = .0025 ETH. This leaves (1 − 𝜏) × 1 = .9975 ETH
available for the trade. To save on notation, let (1 − 𝜏) = 𝜙. There are two stages to the
process now: in the first stage, the fee is deducted, and the trade is enforced using the initial
invariant 𝑘 0 . In the second stage, the fees are added to the liquidity pool, which gives rise to
a new invariant, 𝑘1 . This ensures that the value of 𝑘 changes with every trade; so, the term
‘constant’ or ‘invariant’ is somewhat misleading when there are trading fees – it is more of a
predetermined variable prior to a trade.
In the first stage, which we can think of as the interim trading stage, the amount of ETH in
the pool is 𝑥 1′ = 10.9975 ETH (where the superscript ′ denotes interim). Given 𝑘 0 = 5000,
𝑘0
the new amount of ABC balance in the pool is 𝑦 1 = 𝑥 1′ = 454.6488, implying a change 𝑦 1 −
𝑏
𝑦 0 = −45.3512 ABC. The trader effectively receives the bid price of 𝑝𝑌/𝑋 = 45.3512
ABC/ETH. In terms of notation, the lower-case 𝑝 indicates that the price now refers to a
scenario where a trading fee has been imposed. In the second stage of the trade, the fees are
added to the liquidity pool, giving a final ETH pool balance of 𝑥 1 = 11. The new value of 𝑘 at
the end of the trade is 𝑘1 = 𝑥 1 𝑦 1 = 5001.1368, which is higher than before and is a
predetermined variable for the next trade on the AMM.
Comparing the case with trading fees to the case without, we can see that the bid price of
𝑏 𝑏
ETH is lower than before (𝑝𝑌/𝑋 < 𝑃𝑌/𝑋 ), and the trader receives less ABC per ETH than when
there are no transaction costs. Secondly, the change in 𝑘 is 𝑘1 − 𝑘 0 = 1.1368. Greater the
number of transactions on Unsiwap-v1 or v2, more rapid is the expansion of 𝑘, even if liquidity
providers add no further tokens to the pool themselves.
Now suppose the trader were to buy one unit of ETH, which would leave 9 ETH in the pool.
The fee here is charged for the volume of ABC traded for 1 ETH. So, if the trader deposits an
amount ∆𝑦 ABC, after the fees are deducted the trader adds an interim (Stage 1) amount of
11
23 Two-point and three-point arbitrage in the context of foreign exchange markets are covered in most
undergraduate texts in international finance; see, for example, Moosa (2010). Our discussion draws on these
insights, along with simple ways to visualize the arbitrage process, such as Figure 2.
12
Similarly, in instances where 𝑃𝑌/𝑋 < 𝑀𝑌/𝑋 we would expect arbitrage to occur in the opposite
direction. Demand-supply forces would then result in (4) holding at equilibrium.
Now, suppose there is a trading fee of 𝜏 = 0.25% on AMM which, as we have seen earlier,
𝑏 𝑎
results in 𝑝𝑌/𝑋 = 49.875 and 𝑝𝑌/𝑋 = 50.125. With 𝑀𝑌/𝑋 = 49.9, arbitrage is no longer
feasible: buying ETH in the external market and selling in the AMM involves a loss of 0.025
ABC, and going in the reverse direction yields a loss of .225 ABC. Thus, the no-arbitrage
condition in equation (4) is transformed to:
𝑏 𝑎
(5) 𝑝𝑌/𝑋 ≤ 𝑀𝑌/𝑋 ≤ 𝑝𝑌/𝑋
In the range prescribed by equation (5), arbitrage between the external market and the AMM
is not profitable. If 𝑀𝑌/𝑋 moves outside this range, arbitrage is triggered which will result in
24 If the AMM is small relative to the external market, these trades may have only a small impact on the price
in the external market, so that the brunt of the adjustment occurs through changes in 𝑃𝑌/𝑋 .
13
14
𝑍 𝑌
25As Adams et al (2020) state: “A proliferation of pairs between arbitrary ERC-20s could make it somewhat more
difficult to find the best path to trade a particular pair, but routing can be handled at a higher layer…”.
15
To borrow some terminology from the foreign exchange rate literature, 𝑃𝑌/𝑍 is the cross-
rate (or cross-price) that can be derived from the other two prices (𝑃𝑌/𝑋 and 𝑃𝑋/𝑍 ). In CPMM-
v1, there are two prices, 𝑃𝑌/𝑋 and 𝑃𝑋/𝑍 , that are determined in the two liquidity pools that
are available, the 𝑋 − 𝑌 pool and the 𝑋 − 𝑍 pool. The third price, 𝑃𝑌/𝑍 , is derived from the
other two (using equation 7). Now, in CPMM-v2, a third market price exists due to the
creation of a direct 𝑌 − 𝑍 liquidity pool. The three liquidity pools (the 𝑋 − 𝑌, 𝑋 − 𝑍 and 𝑌 −
𝑍 pools) can move independently due to trader activities. Intuitively, we can see from Figure
2 that the presence of a third liquidity pool creates an independent price to connect the
vertices 𝑌 and 𝑍.
When equation (7) holds, three-point arbitrage is not feasible; it is, therefore, a no-
arbitrage condition. To see this, consider CPMM-v2 with 𝑋 − 𝑌, 𝑋 − 𝑍 and 𝑌 − 𝑍 liquidity
pools, along with prices (𝑃𝑌/𝑋 , 𝑃𝑋/𝑍 and 𝑃𝑌/𝑍 ). Let us further posit that these three pools yield
the relationship 𝑃𝑌/𝑍 < 𝑃𝑌/𝑋 × 𝑃𝑋/𝑍 , which violates equation (7). A trader could then perform
the sequence 𝑍 → 𝑋 → 𝑌 → 𝑍 to make a risk-free profit.26 Starting off with 1 unit of 𝑍, this
sequence of conversions yields 𝑃𝑍/𝑌 × 𝑃𝑌/𝑋 × 𝑃𝑋/𝑍 units of 𝑍 at the end of the cycle. As
1 𝑃𝑌/𝑋 ×𝑃𝑋/𝑍
𝑃𝑍/𝑌 = 𝑃 (equation 2), we can rewrite the expression 𝑃𝑍/𝑌 × 𝑃𝑌/𝑋 × 𝑃𝑋/𝑍 as and,
𝑌/𝑍 𝑃𝑌/𝑍
𝑃𝑌/𝑋 ×𝑃𝑋/𝑍
given the assumption that 𝑃𝑌/𝑍 < 𝑃𝑌/𝑋 × 𝑃𝑋/𝑍 , it follows that > 1.27
𝑃𝑌/𝑍
As enough traders do this, relative prices will change until the arbitrage opportunity is
wiped out, which occurs when 𝑃𝑌/𝑍 = 𝑃𝑌/𝑋 × 𝑃𝑋/𝑍 (in other words, 𝑃𝑍/𝑌 × 𝑃𝑌/𝑋 × 𝑃𝑋/𝑍 = 1)
and the inequality no longer holds. A simple demand-supply argument suffices to verify this.
In the first step of the arbitrage sequence 𝑍 → 𝑋 → 𝑌 → 𝑍, the trader sells 𝑍 in exchange for
𝑋, which decreases 𝑃𝑋/𝑍 . In the next step, the trader sells 𝑋 in exchange for 𝑌, which reduces
𝑃𝑌/𝑋 . In the last step, the trader sells 𝑌 in exchange for 𝑍, which reduces 𝑃𝑍/𝑌 . So, starting
with the inequality 𝑃𝑌/𝑍 < 𝑃𝑌/𝑋 × 𝑃𝑋/𝑍 , the arbitrage process increases the term on the left-
hand side of the inequality and reduces the terms on the right; the process stops only when
equality is restored and equation (7) holds, thereby making it a no-arbitrage condition.
In CPMM-v1, equation (7) always holds by construction, so one can think of this being an
identity in this type of AMM. On the other hand, in CPMM-v2, equation (7) holds as an
26 What is important here is not the vertex in Figure 2 that we start off with, but the direction around the triangle
that we take. Thus, the cycles 𝑌 → 𝑍 → 𝑋 → 𝑌 and 𝑋 → 𝑌 → 𝑍 → 𝑋 also yield arbitrage profits in this instance.
27 If the reverse inequality were to hold, the trader could make risk-free profits by cycling tokens in the opposite
direction: 𝑍 → 𝑌 → 𝑋 → 𝑍.
16
Equation (8) essentially states that it is never profitable to buy 𝑍 through one method
available to the trader and sell it through the other.28
28 𝑎
If the trader wishes to buy 𝑍 using the 𝑌 − 𝑍 pool, the trader incurs a price of 𝑝𝑌/𝑍 ; if the trader the sells the
𝑏 𝑏 𝑎 𝑏 𝑏
proceeds using the sequence 𝑍 → 𝑋 → 𝑌, the trader receives 𝑝𝑌/𝑋 × 𝑝𝑋/𝑍 . When 𝑝𝑦/𝑧 ≥ 𝑝𝑦/𝑥 × 𝑝𝑥/𝑧 holds, this
strategy is not profitable. Similarly, if the trader buys 𝑍 using the sequence 𝑌 → 𝑋 → 𝑍 the effective price is
𝑎 𝑎 𝑎 𝑎 𝑏
𝑝𝑌/𝑋 × 𝑝𝑋/𝑍 . When 𝑝𝑌/𝑋 × 𝑝𝑋/𝑍 ≥ 𝑝𝑌/𝑍 holds, selling the proceeds in the 𝑌 − 𝑍 pool is unprofitable. Equation
(8), therefore, describes the equilibrium no-arbitrage condition in CPMM-v2. No such arbitrage opportunities
𝑎 𝑎 𝑏 𝑏
can exist in CPMM-v1, since the trader has only the bid-ask spread 𝑝𝑌/𝑋 × 𝑝𝑋/𝑍 − 𝑝𝑌/𝑋 × 𝑝𝑋/𝑍 to work with.
17
Liquidity providers are entitled to the fees that are paid by traders on Uniswap, in
proportion to the amount a liquidity provider has contributed. To facilitate this, and the
process of adding and removing liquidity, Uniswap-v1 and v2 mints and distributes liquidity
tokens, with a specific token issued to each liquidity pool. These tokens are themselves
tradeable as fungible ERC-20 tokens.
Essentially, this states that if all the independent variables (𝑥1, 𝑥2 , … , 𝑥𝑛 ) are multiplied by
some factor 𝜆, the value of the function is multiplied by 𝜆𝑟 . The CPMM function 𝑥𝑦 is a
simplified version of this, with two independent variables. Utilizing Definition 1, it is evident
that this function is homogenous of degree 2: if 𝑥𝑦 = 𝑘, then (𝜆𝑥)(𝜆𝑦) = 𝜆2 𝑥𝑦 = 𝜆2 𝑘. So,
for instance, if one were to double both 𝑥 and 𝑦, 𝑘 would quadruple.
A homogenous function 𝑘 = 𝑓(𝑥1 , 𝑥2 , … , 𝑥𝑛 ) can be used in different contexts to
characterize different things. In consumer theory it describes, for example, the utility
function: the level of utility (𝑘) derived from the consumption of certain quantities of
commodities (𝑥1 , 𝑥2 , … , 𝑥𝑛 ). In production theory it describes the production function: the
quantity of good or service (𝑘) produced by a firm from a certain combination of factor inputs
(𝑥1 , 𝑥2 , … , 𝑥𝑛 ). In the current context of an AMM, we think of it as an exchange function that
links various amounts of tokens (𝑥1, 𝑥2 , … , 𝑥𝑛 ) to the AMM’s invariant, 𝑘.
Geometrically, the exchange function 𝑥𝑦 = 𝑘 generates level or contour curves that are
𝑦
29Specifically, (𝑦 + ∆𝑦) = (𝑥 + ∆𝑥) × 𝑃𝑌/𝑋 , which implies (𝑦 + ∆𝑦) = (𝑥 + ∆𝑥) × 𝑥 , which in turn implies that
(𝑦 + ∆𝑦)𝑥 = (𝑥 + ∆𝑥)𝑦. Simplifying yields the desired result.
18
𝐷
𝑅
𝑐
𝑦𝐶 𝐶
𝑎
𝑐 𝐸
𝐴 𝐴
𝑦
𝑘1
𝑎 𝐵
𝑦𝐵
𝑘0
𝑥
𝑂 𝑥𝐴 𝑥𝐶 𝑥𝐵
The intuition behind equation (9) is as follows. Suppose we consider a particular point, say
point 𝐴 in Figure 3, which has pool reserves of 𝑥 𝐴 and 𝑦 𝐴 . Starting from point 𝐴, if 𝑥 changes
30The corresponding level curves in the context of consumption are indifference curves, and in the context of
production are isoquants.
19
31 The proof is standard in any text on introductory mathematical economics (for example, Silberberg, 1990).
20
The homotheticity property is useful because it tells us what happens to level curves if we
start with a CPMM with an exchange function 𝑥𝑦 = 𝑘 and transform it monotonically.
Another handy property of homogenous functions is Euler’s theorem, which we will find
useful in the next section for valuing a liquidity pool:32
𝜕𝑓 𝜕𝑓 𝜕𝑓
𝑥1 + 𝑥2 + ⋯ . 𝑥𝑛 = 𝑟𝑓(𝑥1, 𝑥2 , … , 𝑥𝑛 )
𝜕𝑥1 𝜕𝑥2 𝜕𝑥𝑛
32 The interested reader is referred to Silberberg (1990) or Chiang (1984) for a proof.
21
𝑀
𝑦𝑀
𝑚 𝐴
𝐴 𝑎
𝑦
𝑎
𝑘0
𝑥
𝑂 𝑥𝑀 𝑥𝐴
33 Reserves can, of course, fall to zero if liquidity providers decide to withdraw their tokens.
22
Since the liquidity pool receives 𝑋, we have that ∆𝑥 > 0, from which it follows that ∆𝑦 < 0.
∆𝑦 𝜙𝑦 0
Simplifying, we get that = − 𝑥 0+𝜙∆𝑥. When changes are infinitesimal, this reduces to
∆𝑥
𝑑𝑦 ∆𝑦 𝑦0 𝑏 𝑑𝑦
𝑑𝑥
= lim = −𝜙 𝑥 0 . As 𝑝𝑌/𝑋 = − 𝑑𝑥 in this case, we get the bid-price as:
∆𝑥→0 ∆𝑥
𝑏 𝑦0
(12) 𝑝𝑌/𝑋 = 𝜙 𝑥0
Similar arguments when the trader buys 𝑋 from the CPMM (Δ𝑦 > 0) yields an ask-price of:
𝑎 1 𝑦0
(13) 𝑝𝑌/𝑋 = 𝜙 𝑥0
𝑏 𝑎 𝑦0
Given that that 𝜙 < 1, it is evident that 𝑝𝑌/𝑋 < 𝑃𝑌/𝑋 < 𝑝𝑌/𝑋 , where 𝑃𝑌/𝑋 = 𝑥 0.
34Other CPMMs may adopt different procedures. However, the broad ideas that follow from homotheticity and
so on described in this paper will not change due to small procedural changes.
23
𝑀′′
𝑃
𝑦0
𝑀
𝐵
𝑀′ 𝑘1
𝑘0
𝑥
𝑂 𝑥0
To bring in the idea of arbitrage in Figure 5, suppose the external market price is 𝑀𝑌/𝑋 .
This is represented by a point 𝑀, which (uniquely on curve 𝑘 0 ) satisfies the condition that the
slope of 𝑂𝑀 = 𝑀𝑌/𝑋 . In this particular instance, 𝑀 lies within the arc 𝐴𝐵. As the slope of 𝑂𝑀
𝑏 𝑎
is greater than that of 𝑂𝐵, but less than that of 𝑂𝐴, we have that 𝑝𝑌/𝑋 ≤ 𝑀𝑌/𝑋 ≤ 𝑝𝑌/𝑋 holds
at point 𝑀. This is, of course, nothing but the no-arbitrage condition in equation (5). This
inequality is true for any point we select in the arc 𝐴𝐵; thus, this arc corresponds to equation
(5) as the range where arbitrage is not feasible. It is evident that the range widens (and the
𝑏 𝑦0 𝑎 1 𝑦0
arc 𝐴𝐵 becomes longer) the greater the value 𝜏 takes, since 𝑝𝑌/𝑋 =𝜙 0 and 𝑝𝑌/𝑋 = . This
𝑥 𝜙 𝑥0
goes back to the point made earlier: larger transaction costs curtail arbitrage.
𝑏
If we consider a point outside arc 𝐴𝐵, such as point 𝑀′ , where 𝑝𝑌/𝑋 > 𝑀𝑌/𝑋 , then
24
(14) 𝑉𝑋,𝑌 = 2𝑥
Equation (14) states that in order to value a liquidity pool that has ETH in it, one simply needs
to double the amount of ETH in the pool. An implication of equation (14) is that the valuation
of a pool is independent of the price 𝑃𝑋/𝑌 at which 𝑋 and 𝑌 trade and, indeed, independent
of the value of 𝑘. This is shown in Figure 6 below. All three points, 𝐴, 𝐵 and 𝐶 have a valuation
of 2𝑥 0 , even though they lie on different level curves and are associated with different prices.
On the other hand, even though 𝐶, 𝐷 and 𝐸 have the same prices (they are on the same ray
from the origin), the liquidity pool has different valuations at these points, with the valuation
at 𝐶 being the highest as it has the highest amount of 𝑋.
35 See also Angeris et al (2019) and Angeris and Chitra (2020), who address the issue of pool valuation.
25
𝐶
𝐷
𝐸 𝐵
𝑘2
𝐴
𝑘1
𝑘0
𝑥
𝑂 𝑥0
This is, of course, not a unique way of valuing the pool. With trading fees and a bid-ask
𝑎 𝑏
𝑝𝑋/𝑌 +𝑝𝑋/𝑌 (1+𝜙 2 ) 𝑥
spread one may wish to use the mid-rate 𝑝̃𝑋/𝑌 = = (from equations (12),
2 2𝜙 𝑦
(13) and (3)) to value the pool. However, the mid-rate is a function of 𝜙, which implies that
the pool valuation using 𝑝̃𝑋/𝑌 to convert units of 𝑌 to 𝑋 would be sensitive to the fees.
Whether this is desirable or not depends on the context. The pool valuation in this case is:
(1+𝜙) 2
(15) 𝑉̃𝑋,𝑌 = 𝑥 + 𝑝̃𝑋/𝑌 𝑦 = 2𝜙 𝑥
In the extreme case where there are no trading fees, 𝜙 = 1 and it is evident that 𝑉̃𝑋,𝑌 = 𝑉𝑋,𝑌 .
𝑑 (1+𝜙)2
Moreover, as ( ) < 0, 𝑉̃𝑋,𝑌 falls as 𝜙 rises. This implies that as fees fall, the pool
𝑑𝜙 2𝜙
valuation decreases as well. This makes intuitive sense if one were to value the pool from the
perspective of liquidity providers. Lower fees signal lower returns to pool providers, and 𝑉̃𝑋,𝑌
is lower as well. Thus, whether one wishes to use (14) or (15) depends on the perspective one
takes. The valuation 𝑉𝑋,𝑌 is preferable if one looks at the liquidity pool as a whole. On the
26
𝜕𝑓⁄𝜕𝑦 𝑑𝑥 𝜕𝑓⁄𝜕𝑦
Since ( 𝜕𝑓⁄𝜕𝑥 ) = − 𝑑𝑦, it follows that 𝑃𝑋/𝑌 = ( 𝜕𝑓⁄𝜕𝑥 ).36 The left-hand side of equation (16) is,
𝜕𝑓
therefore, nothing but 𝑉𝑋,𝑌 . For the right-hand side, using 𝑓(𝑥, 𝑦) = 𝑥 𝛼 𝑦 𝛽 , = 𝛼𝑥 𝛼−1 𝑦 𝛽 ,
𝜕𝑥
and 𝑟 = (𝛼 + 𝛽), equation (16) reduces to:
𝛼+𝛽
(17) 𝑉𝑋,𝑌 = ( )𝑥
𝛼
Comparing (17) with (14), we see that the former collapses to the latter whenever 𝛼 = 𝛽. So,
doubling the amount of 𝑋 (ETH) in a liquidity pool to value a liquidity pool is a valid technique
for all AMMs that attach equal weights to 𝑋 and 𝑌 in the 𝑘 = 𝑥 𝛼 𝑦 𝛽 function, and is not limited
to the specific exchange function used by Uniswap. For this general class of exchange
functions, even when 𝛼 ≠ 𝛽, the pool valuation depends only on 𝑥 and some constant factor
𝛼+𝛽
( ).37 It is also worth noting that the share of value of 𝑋 to the value of the pool is 𝑥/𝑉𝑋,𝑌 ,
𝛼
𝛼
which equals 𝛼+𝛽 and is fixed once the parameters 𝛼 and 𝛽 are fixed.38 Similarly, the share of
𝛽
𝑌 is 𝑃𝑋/𝑌 𝑦/𝑉𝑋,𝑌 = 𝛼+𝛽 . When 𝛼 = 𝛽, each token’s share of the total pool value is ½.
Now suppose we would like to value an entire CPMM operating with an exchange function
𝑘 = 𝑥𝑦 across all liquidity pools that exist on the platform. In a CPMM-v1, as outlined earlier,
all liquidity pools have ETH as a common token. If there are 𝑛 liquidity pools, each of which
has 𝑋 as token, along with another token, 𝑌𝑖 , 𝑖 ∈ {1,2,3, … 𝑛}. The 𝑛 liquidity pools yield a set
of reserves: {(𝑥1 , 𝑦1 ), (𝑥1, 𝑦1 ) … (𝑥𝑛 , 𝑦𝑛 )}, where 𝑥𝑖 is the amount of 𝑋 (ETH) in the liquidity
pool with token 𝑌𝑖 . From (14), each liquidity pool has a valuation 𝑉𝑋,𝑌𝑖 = 2𝑥𝑖 , ∀𝑖 ∈
{1,2,3, … 𝑛}. This allows a simple method to value the entire CPMM-v1:
Equation (18) states that to value a CPMM-v1 with the exchange function 𝑘 = 𝑥𝑦, one needs
to simply add all the ETH cross the various liquidity pools on the platform and double it.
Valuing CPMM-v2 is slightly more complicated, because there are liquidity pools available
36 𝛽𝑥
It is evident that 𝑃𝑋/𝑌 = 𝛼 𝑦 in this case.
(1+𝜙 2) 𝛽 (1+𝜙2) 𝛽
37 For the alternative 𝑉̃𝑋,𝑌 , we have 𝑉̃𝑋,𝑌 = 𝑥 + 𝑝̃𝑋/𝑌 𝑦 = 𝑥 + 𝑥 = (1 + )𝑥.
2𝜙 𝛼 2𝜙 𝛼
38Later on, in Section 4.1, we show that other types of AMMs, such as a Constant Mean Market Maker, also
have a similar property of fixed shares of value.
27
Suppose we use an indicator 𝑑𝑖𝑗 = 1 if 𝑌𝑖 is used as the pricing token in the pool with 𝑌𝑗
and 𝑑𝑖𝑗 = 0 if it is not. The value of all pools 𝑌𝑖 − 𝑌𝑗 that uses 𝑌𝑖 as the pricing currency, but
denominated in units of 𝑋 is 𝑉𝑌′𝑖 = 2𝑃𝑋/𝑌𝑖 ∑𝑗≠𝑖 𝑑𝑖𝑗 𝑦𝑖𝑗 . The total value of the CPMM-v2 is then:
𝑥
(19) 𝑉𝐶𝑃𝑀𝑀−𝑣2 = ∑𝑛𝑖=1[2𝑃𝑋/𝑌𝑖 ∑𝑗≠𝑖 𝑑𝑖𝑗 𝑦𝑖𝑗 ] + 2 ∑𝑛𝑖=1 𝑥𝑖 , where 𝑃𝑋/𝑌𝑖 = 𝑦𝑖
𝑖
The second term in (19) corresponds to equation (18), and refers to the value of all pools that
involve 𝑋. The first term adds the values of all 𝑌𝑖 − 𝑌𝑗 pools after denominating them in 𝑋.
39
Alternatively, in the case where, 𝑘 = 𝑥𝑦, as in Figure 3, we can think of 𝑘 geometrically as the area of the
rectangle associated with a point; thus at point 𝐴 in Figure 3, we have that Area(𝑂𝑥 𝐴 𝐴𝑦 𝐴 ) = 𝑘 0 . However, the
dimension of the area is units of 𝑋 × units of 𝑌, which has little economic meaning as well.
28
1 1 𝑑𝐿 1 𝑑𝑥 1 𝑑𝑦 𝑑𝑦 𝑑𝑥 𝑑𝐿 𝑑𝑥
40 Taking log of 𝐿 = 𝑥 2 𝑦 2 and differentiating yields =2 +2 . Since = , it follows that = .
𝐿 𝑥 𝑦 𝑦 𝑥 𝐿 𝑥
29
−1. In terms of interaction with traders, the AMM essentially provides a service, and the
optimum fees from the point of view of liquidity providers balances the trade-offs between
the price of the service (𝜏) and the demand for the service (𝑣(𝜏)).
However, liquidity providers also have to contend with arbitrageurs. In Figure 5, traders
will participate even when the external market price lies within the arc 𝐴𝐵, but arbitrage is
not profitable in that range. When the external market price moves beyond 𝐴𝐵, arbitrageurs
are vital for AMMs such as Uniswap to achieve an alignment between the AMM price and the
external market price. If trading fees are increased to favor liquidity providers, the arc 𝐴𝐵
widens, which discourages arbitrage over a wider range of prices. This indicates an intuitive
trade-off between efficiency in terms of price alignment with external markets, and the
incentives for liquidity provision.
It is worthwhile exploring further how external market price movements and the resultant
arbitrage activities affect liquidity providers. To do so, we assume that there are no traders,
so that there is only interaction between liquidity providers and arbitrageurs. To begin with,
consider the case where 𝜏 = 0; Figure 4 serves as a visual reference. One way to measure the
performance of liquidity provision is to compare it to a situation when the same assets are
held in the external market. Essentially, this is the opportunity cost of placing the tokens in
the CPMM, assuming that the next best alternative is holding it in an external wallet.
0 0
At the initial equilibrium when 𝑃𝑌/𝑋 = 𝑀𝑌/𝑋 (say point 𝐴 in Figure 4), the reserves in a
CPMM are (𝑥 0 , 𝑦 0 ). Using the external price to value assets, the value of tokens in the CPMM
0
liquidity pool (measured in units of 𝑌) is 𝑣𝐶0 = 𝑦 0 + 𝑀𝑌/𝑋 𝑥 0 , which equals the value in the
1
external market, 𝑣𝐸0 . Now suppose the price in the external market were to change to 𝑀𝑌/𝑋 >
30
in the CPMM pool value relative to the external market value when there are no fees is: 41
𝑣𝐶1 −𝑣𝐸1 2√𝜃
(20) 𝐼 (𝜃 ) = = 1+𝜃 − 1
𝑣𝐸1
Since 2√𝜃 < (1 + 𝜃), we have that 𝐼 (𝜃) < 0, and liquidity providers suffer a loss in value
relative to holding a non-rebalanced portfolio in the external market. Moreover, as this
inequality holds for any price ratio 𝜃, the movement in the reverse direction (where say the
change is from point 𝐵 to 𝑀 in Figure 4) also yields similar results. In the DeFi community,
𝐼(𝜃) is referred to as impermanent loss or divergence loss, because this is an unrealized loss
0
relative to the external market; if the price were to revert to 𝑀𝑌/𝑋 again, we would have that
𝑣𝐶0 = 𝑣𝐸0 , and the loss disappears. As this primarily reflects the impact of rebalancing in the
CPMM, one could relabel this as a rebalancing cost.
Adding fees moves the analysis from Figure 4 to Figure 5, which introduces additional
features: first, there exists a range (the arc 𝐴𝐵) where no arbitrage takes place; and second,
𝑏 𝑎 1
there are multiple prices in the CPMM (𝑃𝑌/𝑋 , 𝑝𝑌/𝑋 = 𝜙𝑃𝑌/𝑋 and 𝑝𝑌/𝑋 = 𝜙 𝑃𝑌/𝑋 ). To see how
0
these features play out, suppose the initial equilibrium is at point 𝑃 in Figure 5, so that 𝑀𝑌/𝑋 =
1
𝑃𝑌/𝑋 . Now, if the external price reduces to 𝑀𝑌/𝑋 equal to slope of ray 𝑂𝑀, no arbitrage is
triggered and the CPMM reserve assets continue to be located at 𝑃. In this case no
rebalancing occurs, and the valuation exercise is trivial: if the same price is used for valuing
assets in both cases, there is no difference in the valuation of tokens.
Things become more meaningful once we reach the boundaries of the arc 𝐴𝐵. Suppose
0 𝑏0
the initial equilibrium is at 𝐵, where 𝑀𝑌/𝑋 = 𝑝𝑌/𝑋 . Now, a small fall in the external price to
1 0 𝑏1 1
𝑀𝑌/𝑋 < 𝑀𝑌/𝑋 (point 𝑀′ ) will trigger arbitrage till the new bid price satisfies 𝑝𝑌/𝑋 = 𝑀𝑌/𝑋 .42
41 𝑦
See Pintail (2019) for this formula, along with examples. Formally, from the relationships 𝑥𝑦 = 𝑘 and =
𝑥
𝑘
𝑃𝑌/𝑋 , we have that 𝑥 = √𝑃 and 𝑦 = √𝑘𝑃𝑌/𝑋 . This holds both before and after the price change, along with
𝑌/𝑋
the fact that 𝑀𝑌/𝑋 = 𝑃𝑌/𝑋 at equilibrium. So, 𝑣1𝐶 = 2√𝜃𝑘𝑃0𝑌/𝑋 and 𝑣𝐸1 = (1 + 𝜃)√𝑘𝑃𝑌/𝑋
0
; it follows that 𝐼(𝜃) =
2√𝜃
− 1. See Xu et al (2021) for calculations for other types of AMMs.
1+𝜃
42 We assume that the external market is large enough that arbitrage with the CPMM does not affect 𝑀𝑌/𝑋 .
31
1
It follows that 𝐼(𝜃, 𝜙) < 0 when 𝜃 < 𝜙2 , which must hold when 𝜃 < 1. As a result, fees do
not alter the fact that rebalancing costs exist beyond the range of the spread. A similar
0 𝑎0 𝑣𝐶1 −𝑣𝐸1 √𝜃(1+𝜙)
analysis occurs when 𝑀𝑌/𝑋 = 𝑝𝑌/𝑋 and 𝜃 > 1; in this case 𝐼(𝜃, 𝜙) = = − 1.45
𝑣𝐸1 𝜙+𝜃
Our comparative static analysis suggests that the costs of rebalancing are inevitable, and
liquidity providers must depend on fees from users to outweigh this. However, this does not
factor in how price movements impact the compounding of wealth over time. Tassy and
White (2020) show that, under certain circumstances, rebalancing is useful to minimize the
negative effect of losses on compounding. In this scenario, it can be optimal to set the fees as
low as possible (without being zero), thereby taking advantage of rebalancing when prices
are volatile around a narrow spread.46 While this presents some preliminary insights into the
dynamics in a specialized circumstance, there is more work to be done in this area.
Fees can impact the security of the system in terms exploits, such as a sandwich attack. 47
A sandwich attack involves both front-running and back-running a transaction. Suppose a
trader places an order to sell 𝑌 and buy 𝑋. Upon seeing the (public) order, an attacker can
𝑎0
front-run the transaction by buying 𝑋 at the offer price ( 𝑝𝑌/𝑋 ), thereby driving up the price
of 𝑋. The trader’s original transaction drives the price even higher,48 and the attack is then
𝑏1
completed with a back-run sale of 𝑋 by the attacker at a new bid price 𝑝𝑌/𝑋 ; the profit of the
𝑏1 𝑎0 1 0 1
attacker is 𝑝𝑌/𝑋 − 𝑝𝑌/𝑋 . For (no-fee) prices 𝑃𝑌/𝑋 and 𝑃𝑌/𝑋 , the profit equals 𝜙𝑃𝑌/𝑋 −
1 0
𝑃𝑌/𝑋 , which is decreasing in the trading fee 𝜏. A higher trading fee can, therefore, reduce
𝜙
43A large increase in price, of course, can trigger arbitrage if the new price is higher than slope 𝑂𝐴. But recalling
that these price formulas are for small changes, we focus on this case.
44 There are now three relationships we work with: 𝑏 𝑦 𝜙𝑘
𝑝𝑌/𝑋 = 𝜙𝑃𝑌/𝑋, 𝑃𝑌/𝑋 = 𝑥 and 𝑥𝑦 = 𝑘. These yield 𝑥 = √ 𝑏
𝑝𝑌/𝑋
𝑏
𝑘 𝑝𝑌/𝑋
and 𝑦 = √ , which hold both before and after the price change. The valuations are then 𝑣1𝐶 =
𝜙
√𝜃(1+𝜙)
45 We have that < 1 when 𝜃 > 𝜙 2 , which must be true for the relevant range where 𝜃 > 1.
𝜙+𝜃
46 See White et al (2020) for an intuitive description of these ideas.
47 See Zhou et al (2020) for a deeper analysis of sandwich attacks.See also Buterin (2018) for an early exploration.
48 As a practical matter, the exact amount by which price changes depends on the extent of the slippage; see
Zhou et al (2020).
32
The CPMM is a special case of (22) where 𝑛 = 2 and 𝑤𝑖 = 0.5 for 𝑖 ∈ {1,2}, which can then
be squared to yield a CPMM of the type examined before. An example of a DeFi platform
which operates as a CMMM is Balancer,50 and our analysis here is related to the Balancer
whitepaper (Martinelli and Mushegian, 2019). An important aspect of the Balancer protocol
is that the weights, once fixed, determine the share of the value a particular token has in
relation to the overall value of the pool; from this point of view, the Balancer protocol has
similarities to index funds that construct a portfolio of assets with fixed weights to each asset
49 Indeed, Uniswap-v3 allows for multiple fee structures, initially set at 0.05% (intended for stablecoins), 0.3%
(for standard token pairs) and 1% (for highly volatile tokens).
50 See https://balancer.finance (accessed on 20th September, 2021).
33
quantities 𝑥𝑖 and 𝑥𝑗 change in this transaction, 𝑑𝑥𝑙 = 0 for 𝑙 ≠ {𝑖, 𝑗}. Consequently, for any
𝑑𝑥𝑗 𝜕𝑓⁄𝜕𝑥 𝑤 𝑥
arbitrary reserve quantities (𝑥1, 𝑥2 , … 𝑥𝑛 ), = − 𝜕𝑓⁄𝜕𝑥𝑖 = − 𝑤 𝑖 𝑥𝑗, and we have:
𝑑𝑥𝑖 𝑗 𝑗 𝑖
𝑤 𝑥
(23) 𝑃𝑋𝑗/𝑋𝑖 = 𝑤 𝑖 𝑥𝑗
𝑗 𝑖
We are now in a position to see how the process of two-point arbitrage works in a CMMM.
𝑤 𝑥
Consider the case where 𝑀𝑋𝑗/𝑋𝑖 < 𝑃𝑋𝑗/𝑋𝑖 = 𝑤 𝑖 𝑥𝑗. Arbitrageurs will purchase 𝑋𝑖 in the external
𝑗 𝑖
𝑥𝑗
market and sell it in the CMMM in exchange for 𝑋𝑗 . This causes to fall till the no-arbitrage
𝑥𝑖
condition 𝑀𝑋𝑗/𝑋𝑖 = 𝑃𝑋𝑗/𝑋𝑖 is restored.
We can also calculate the liquidity pool value after selecting a numeraire to do the pricing.
Without loss of generality, let us suppose 𝑋1 is selected as the token to price the liquidity
pool; 𝑋1 could be, for example, ETH. Using Euler’s theorem:52
𝑥
(24) 𝑉𝑋1,𝑋2 ,…,𝑋𝑛 = 𝑤1
1
In a CMMM, therefore, the share of the value of any token to the value of the entire pool is
fixed and equal to the weight of each token in the liquidity pool, which is similar to a CPMM.
Now suppose we add ad valorem fees, 𝜏, to the price calculation problem assuming, as
before, that the fees are paid in units of the token sold by a trader into the liquidity pool.
𝑤 𝑥𝑗
While slightly more tedious to calculate, we can show that 𝑝𝑋𝑏𝑗 /𝑋𝑖 = 𝜙 𝑤 𝑖 𝑥 and 𝑝𝑋𝑎𝑗 /𝑋𝑖 =
𝑗 𝑖
1 𝑤𝑖 𝑥𝑗 53
. Using equation (5), the no-arbitrage condition is:
𝜙 𝑤𝑗 𝑥𝑖
34
𝑤𝑖
𝜙∆𝑥 −𝑤𝑗
𝑥𝑗 [(1+ 𝑥 𝑖 ) −1]
𝑖
𝑤 𝑥 𝑑𝑥
lim . Using L’Hôpital’s rule, the right-hand side is −𝜙 𝑤𝑖 𝑥𝑗 , and consequently, 𝑝𝑋𝑏 𝑗 /𝑋𝑖 = − 𝑑𝑥𝑗 =
∆𝑥𝑖 →0 ∆𝑥𝑖 𝑗 𝑖 𝑖
𝑤𝑖 𝑥 𝑗 1𝑤 𝑥
𝜙𝑤 . The proof for 𝑝𝑋𝑎𝑗 /𝑋𝑖 = 𝜙 𝑤𝑖 𝑥𝑗 follows along similar lines.
𝑗 𝑥𝑖 𝑗 𝑖
54An example of using a CSMM as the exchange function is mStable, which used a CSMM to initially develop
mUSD. However, as users identified concerns with the design, it has moved away from the CSMM model for
mBTC: see https://github.com/mstable/MIPs/blob/master/MIPS/mip-7.md (accessed 20th September, 2021).
Egorov (2020) discusses the problems with a CSMM, before utilizing a mix of the CSMM and CPMM exchange
functions to develop a hybrid AMM.
35
𝐴
𝑦𝐴
𝑦𝑀 𝐶
𝑘 = 𝑘0
𝑂 𝑥𝐴 𝐷 𝑥
In Figure 7, starting from point 𝐴, arbitrageurs can buy 𝑂𝑥 𝐴 units of 𝑋 by selling 𝐵𝑦 𝐴 units
of 𝑌 to the CSMM, which causes a movement to the corner point 𝐵. The line 𝐵𝐶 describes
the trading possibilities in the external market, and has a slope greater than 1, thereby
capturing the fact that 𝑀𝑌/𝑋 > 𝑃𝑌/𝑋 . Arbitrageurs can sell the 𝑂𝑥 𝐴 units of 𝑋 purchased in
the CSMM for 𝐵𝑦 𝑀 units of 𝑌 in the external market, making an overall profit of 𝑦 𝑀 𝑦 𝐴 units
of 𝑌. For the CSMM, the arbitrage process drains all 𝑋 reserves and the CSMM is left with 𝑘 0
units of 𝑌, leading to a corner equilibrium at point 𝐵.55 The arguments when 𝑀𝑌/𝑋 < 1 are
similar, with a corner equilibrium at 𝐷.
𝑏 𝑎 1
Adding trading fees as before, we have that 𝑝𝑌/𝑋 = 𝜙 and 𝑝𝑌/𝑋 = 𝜙 . In the scenario above
1
where an arbitrageur buys 𝑋 from the CPMM, the relevant price of 𝑋 is 𝜙
units of 𝑌. So, if
1
fees are high and 𝜙 > 𝑀𝑌/𝑋 , arbitrage is no longer profitable; on the other hand, if fees are
55 A corner solution such as this is discussed in many undergraduate microeconomics textbooks (see, for
example, Varian, 1987) in the context of perfect substitution between goods in a utility function. In this case,
indifference curves are straight lines. The consumer simply spends her entire budget on the lower priced good,
yielding a corner solution to the consumer utility maximization problem. The fact that the AMM will lose the
more valuable token in its reserves also bears some similarity in a macroeconomic context to Gresham’s Law:
bad money drives out good money (for example, see Dernburg, 1989). This phenomenon typically happens when
there are multiple competing reserves, for example, gold and silver in a bimetallic standard.
36
in the CSMM is 𝑃𝑋𝑗 /𝑋𝑖 = 1. Our goal is to mix these two AMMs to form a hybrid, and the
simplest way to do that is to take a weighted average of the two:
1
∑𝑛
𝑖=1 𝑥𝑖
(27) 𝜆 + (1 − 𝜆) ∏𝑛𝑖=1 𝑥𝑖𝑛 = 𝑘 , for some 𝜆 ∈ [0,1]
𝑛
The problem with this scheme, however, is that the weight attached to each function is
independent of the reserves (𝑥1 , 𝑥2 , … . 𝑥𝑛 ). Ideally, we would like to assign more weight to
the CMMM when any of these token reserve approaches zero to ensure its price escalates
rapidly. Similarly, when the amounts of the tokens are roughly equal, assigning greater weight
to the CSMM will ensure that prices do not change too rapidly, thereby minimizing slippage.
To construct a scheme where 𝜆 is sensitive to the quantity of reserves, we note the
∑𝑛
𝑖=1 𝑥𝑖 ∑𝑛
𝑖=1 𝑥𝑖
arithmetic mean (AM) of the reserves is 𝐴 = . The CSMM = 𝑘, consequently,
𝑛 𝑛
𝐷
56 Specifically, Egorov (2019) uses the exchange function 𝜒𝐷 𝑛−1 ∑ 𝑥𝑖 + ∏ 𝑥𝑖 = 𝜒𝐷 𝑛 + ( 𝑛 )𝑛, where 𝜒 is a
‘leverage’ parameter, 𝐷 is the sum all token balances, 𝑥𝑖 is the reserve of token 𝑖, and 𝑛 is the number of tokens.
37
Suppose we focus on the ratio 𝐺/𝐴, where 𝐴 ≠ 0. Given the AM-GM inequality, it follows
𝐺 𝐺
that ≤ 1 and that = 1 only when the reserves of all tokens are equal. Moreover, it is
𝐴 𝐴
𝐺 𝐺
evident that 𝐴 ≥ 0 and that 𝐴 = 0 only if at least one of the reserves (but not all, since 𝐴 ≠ 0)
𝐺 𝐺
satisfies 𝑥𝑖 = 0. So, 0≤ 𝐴 ≤ 1 holds, and 𝐴 is a feasible candidate for the weight 𝜆. Let us set,
𝐺
then, 𝜆 = 𝐴 in equation (27), which yields:
𝐺
(28) 𝐺 (2 − 𝐴 ) = 𝑘
From (28), we can derive the bilateral price using the same procedure as Section 4.1:
𝐺 𝜕𝐺 𝐺2 𝜕𝐴
𝑑𝑥𝑗 2(1−𝐴)𝜕𝑥 + 2 𝜕𝑥
𝑖 𝐴 𝑖
(29) 𝑃𝑋𝑗/𝑋𝑖 = − 𝑑𝑥 = 𝐺 𝜕𝐺 𝐺2 𝜕𝐴
𝑖 2(1−𝐴)𝜕𝑥 + 2 𝜕𝑥
𝑗 𝐴 𝑗
Equation (29) implies that when reserves of any token, say 𝑋𝑖 , tends to zero, we have that
𝐺 𝜕𝐺 ⁄𝜕𝑥
→ 0 and 𝑃𝑋𝑗 /𝑋𝑖 → 𝜕𝐺 ⁄𝜕𝑥 𝑖 , which is the price that would exist under a CMMM. Similarly,
𝐴 𝑗
𝐺 𝜕𝐴⁄𝜕𝑥𝑖
when 𝐴 → 1, 𝑃𝑋𝑗 /𝑋𝑖 → , which is the price that exists under a CSMM.
𝜕𝐴⁄𝜕𝑥𝑗
The outcome of this discussion is shown geometrically in Figure 8 for the two token case.
1 1
𝑥+𝑦
The curve 𝐺𝐺 represents the CMMM 𝑥 2 𝑦 2 = 𝑘 and the line 𝐴𝐴 represents the CSMM =
2
𝑘. The mixing of the two AMMs using a fixed 𝜆 is shown with the dashed-curve 𝐶𝐶, which has
been drawn with 𝜆 = 0.5. It is evident that 𝐶𝐶 reduces the problem of dwindling reserves
experienced by the CSMM 𝐴𝐴; however, there is still considerable price slippage as, starting
from the 45° line, the slopes change relatively rapidly. Choosing a different 𝜆 would involve a
different trade-off between the twin problems of draining reserves and price slippage; the
point is that this trade-off is fixed for all reserve combinations once 𝜆 is chosen. The HFMM
𝐺
with 𝜆 = is shown using the dotted-curve 𝐻𝐻. Compared to the 𝐶𝐶 curve, 𝐻𝐻 is closer to
𝐴
𝐴𝐴 when reserves are roughly equal and, at the same time, is closer to 𝐺𝐺 when one of the
reserves in the liquidity pool starts to fall, thereby transferring weight to the AMM that better
38
𝐶𝐻 𝐺
45°
𝐺
𝐻
𝐶 𝑥
𝐴
While this example of forming a hybrid represents one way of moving between a CSMM
and a CMMM, other possibilities exist. For example, one could specify the general CES
(Constant Elasticity of Substitution) function as the AMM exchange function. The CES function
1
with two tokens 𝑋 and 𝑌 is 𝐸[𝛼𝑥 𝜌 + (1 − 𝛼)𝑦 𝜌 ]𝜌, where 𝐸 is an efficiency parameter, 𝛼 is
the distribution parameter and 𝜌 is the substitution parameter. When 𝐸 = 1, this will
approach the two token CMMM exchange function 𝑥 𝛼 𝑦 1−𝛼 as 𝜌 → 0 and equals the CSMM
𝛼𝑥 + (1 − 𝛼)𝑦 when 𝜌 = 1.57 This allows for a way to change the curvature of the exchange
function parametrically, similar to changing a fixed 𝜆 above.58
39
arbitrageurs purchase 𝑋𝑖 in the external market and sell it in the CMMM in exchange for 𝑋𝑗
𝑥𝑗
till 𝑀𝑋𝑗 /𝑋𝑖 = 𝑃𝑋𝑗/𝑋𝑖 holds. All the response in this case is through changes in . There is,
𝑥𝑖
𝑤
however, an alternative way to get 𝑃𝑋𝑗/𝑋𝑖 to fall: by reducing 𝑤 𝑖 . If the CMMM were to adjust
𝑗
𝑤𝑖′ 𝑥𝑗
weights to 𝑤𝑖′ and 𝑤𝑗′ , we can have 𝑀𝑋𝑗 /𝑋𝑖 = 𝑃𝑋𝑗/𝑋𝑖 = 𝑤 ′ 𝑥 , with no change in the ratio of
𝑗 𝑖
𝑥𝑗
reserves 𝑥 . Prices in the two markets have become aligned not because of arbitrage activity,
𝑖
40
The numerator is the value of token 𝑋𝑖 denominated in units of 𝑌, while the denominator is
the total value of 𝑌 in the smart contract. Equation (30) essentially defines the connector
weight as the ratio of the value of reserves of 𝑋𝑖 to the total value of all the 𝑌 supplied. When
∑𝑛𝑖=1 𝑤𝑖 = 1, it follows that ∑𝑛𝑖=1 𝑃𝑌/𝑋𝑖 𝑥𝑖 = 𝑦 and the sum of the values of all the ‘connector
tokens’ exactly equals the value of 𝑌 minted by the smart contract.
Now, equation (30) can be rearranged to get 𝑃𝑌/𝑋𝑖 :
𝑦𝑤𝑖
(31) 𝑃𝑌/𝑋𝑖 = 𝑥𝑖
For any two tokens, 𝑋𝑖 and 𝑋𝑗 , we can get the cross-rate that is implied by (31):
𝑃𝑌/𝑋 𝑤 𝑥𝑗
(32) 𝑃𝑋𝑗 /𝑋𝑖 = 𝑃 𝑖
= 𝑤𝑖 𝑥
𝑌/𝑋𝑗 𝑗 𝑖
This is, of course, exactly the same as equation (23) for a CMMM. So, any set of reserves on
Bancor generates exactly the same price as a CMMM when the connector weight for each
token on Bancor equals the weight for that token on the CMMM. Consequently, Bancor and
Balancer can be viewed as being equivalent in terms of the technology for converting
quantities of tokens reserves to prices, even though the institutional mechanisms may be
different. It also follows straight away that when Bancor assigns dynamic weights, its
outcomes replicate the CMMM with dynamic weights outlined in Section 4.4.1 and the
intuition of price adjustment provided there is applicable here as well.
59 Our exposition here is meant to capture the overall logic of the system, rather than all the institutional details
of the Bancor protocol; see https://app.bancor.network/eth/data (accessed on 20th September, 2021), Hertzog
et al (2018) and Rosenfeld (2017) for further details.
60 Hertzog et al (2018) and Rosenfeld (2017) work with the price 𝑃
𝑋𝑖 /𝑌 , which (from equation 2) is the reciprocal
of 𝑃𝑌/𝑋𝑖 used here; the latter is used in this paper mainly for expositional ease.
41
42
𝑦 𝑦̂
𝐶
𝑦𝐶
𝑦𝐵 𝐵
𝐴
𝑦𝐴
𝐹
𝑦𝐹
𝑂̂ 𝑥̂
𝐸
𝑘
𝑥
𝑂 𝑥𝐶 𝑥𝐵 𝑥 𝐴 𝑥𝐹
There are now two aspects to focus on: first, what occurs in a position; and second, how
this relates to the overall exchange function. To distinguish between the two, Uniswap-v3
61 Uniswap-v3 keeps track of every .01% change between prices. Specifically, a pool tracks prices 𝑃 = 1.0001𝑖 ,
for 𝑖 ∈ {… , −2, −1,0,1,2, … }; each 𝑖 corresponds to a price ‘tick’. The change in prices between two ticks is then
𝑑𝑃
= 𝑃ln(1.0001) ≅ .0001 × 𝑃. This results in a discretization of the prices, a complication that we shall
𝑑𝑖
conveniently ignore here.
43
44
𝐶𝐹 𝑦 𝐶 −𝑦 𝐹
(33) 𝑃𝑌/𝑋 = 𝐹 𝐶
𝑥 −𝑥
To understand how the chord 𝐶𝐹 is related to the arc 𝐶𝐹, we utilize a fundamental theorem
in calculus, the Mean Value Theorem.
Mean Value Theorem: Consider a continuous function 𝑦 = 𝑓(𝑥) on an interval [𝑥1 , 𝑥2] that
is differentiable in (𝑥1 , 𝑥2 ). Then, there exists some 𝑥𝐴 ∈ (𝑥1, 𝑥2 ) such that:
𝑑𝑓(𝑥𝐴 ) 𝑓(𝑥2 )−𝑓(𝑥1 )
=
𝑑𝑥 𝑥2 −𝑥1
In terms of Figure 9, the Mean Value Theorem implies that there exists a point 𝐴 (as shown
in the figure) on the exchange function between 𝐶 and 𝐹 that has the same slope as the line
𝐶𝐹. Consequently, we can identify 𝐴 as a point on the exchange function that has the same
price as the average price of the liquidity position bounded by 𝐶 and 𝐹. It is straightforward
to show that this average price is the geometric mean of the price bounds: 62
𝐶𝐹 𝐹 𝐶
(34) 𝑃𝑌/𝑋 = √𝑃𝑌/𝑋 𝑃𝑌/𝑋
The average price is also the effective price for a range order in Unsiwap-v3, where a liquidity
provider contributes a single token in an inactive position (typically with a narrow price
range). In Figure 9, if the liquidity position becomes active at 𝐹 and the price moves through
arc 𝐶𝐹 before exiting at 𝐶, the average price for exchanging 𝑋 to 𝑌 is then given by (34).
It is worth noting that while “price equals the ratio of reserves” is an unambiguous
statement in Uniswap v1 and v2, this is no longer true in Uniswap-v3, where there are two
𝑦
reserve ratios to keep track of. First, the virtual reserve ratio (which equals 𝑃𝑌/𝑋 ) and
𝑥
𝑦̂
second, the real reserve ratio ̂ (which need not). To see the difference between the two, in
𝑥
𝑦𝐵
Figure 9 at point 𝐵, we have that the virtual reserve ratio 𝑥 𝐵 equals the slope of the ray 𝑂𝐵.
𝑦̂ 𝐵 𝑦 𝐵−𝑦 𝐹
However, the real reserve ratio is = , which is obviously different. Indeed, the real
𝑥̂ 𝐵 𝑥 𝐵−𝑥 𝐶
1 1
𝑦 𝐶 −𝑦 𝐹 𝑘( 𝐶 − 𝐹 ) 𝑘 𝑘2 𝑦𝐹𝑦𝐶
𝐶𝐹 𝐹 𝐶
62 Specifically, we have that 𝑃𝑌/𝑋 = 𝑥 𝐹 −𝑥 𝐶
= 𝑥 𝑥
𝑥 𝐹 −𝑥 𝐶
= 𝑥 𝐹𝑥 𝐶 = √(𝑥 𝐹 𝑥 𝐶)2 = √𝑥 𝐹𝑥 𝐶 = √𝑃𝑌/𝑋 𝑃𝑌/𝑋 .
45
𝐿 𝐹
(36) (𝑥̂ + )(𝑦̂ + 𝐿 √𝑃𝑌/𝑋 ) = 𝐿2
𝐶
√𝑃𝑌/𝑋
Equation (36) is useful because it tells us the various combinations of real reserves (𝑥̂, 𝑦̂) that
𝐶 𝐹
yield the same level of 𝐿 for given 𝑃𝑌/𝑋 and 𝑃𝑌/𝑋 . In other words, it describes the behavior of
real reserves in the arc 𝐹𝐶 in Figure 9.
Next, consider any arbitrary point on the arc 𝐹𝐶 characterized by virtual reserves (𝑥, 𝑦)
𝑦
and price 𝑃𝑌/𝑋 = 𝑥 . It is worthwhile to describe real reserves at that point, (𝑥̂, 𝑦̂) = (𝑥 −
𝐹 𝐶
𝑥 𝐶 ,𝑦 − 𝑦 𝐹 ), in terms of 𝐿, 𝑃𝑌/𝑋 , 𝑃𝑌/𝑋 and 𝑃𝑌/𝑋 :65
𝐿 𝐿 𝐹
(37) 𝑥̂ = − and 𝑦̂ = 𝐿 √𝑃𝑌/𝑋 − 𝐿√𝑃𝑌/𝑋
√𝑃𝑌/𝑋 𝐶
√𝑃𝑌/𝑋
Equation (37) allows us to see how logically consistent liquidity provision occurs on Uniswap-
v3 for an active position, when the current price is 𝑃𝑌/𝑋 . Eliminating 𝐿 in (37), we get:
𝐹
√𝑃𝑌/𝑋 −√𝑃𝑌/𝑋
(38) 𝑦̂ = 𝑥̂ ( 1 1 )
−
√𝑃𝑌/𝑋 √𝑃𝐶
𝑌/𝑋
63 However, as pointed out in Section 3.4.2, 𝐿 = √𝑘 is a better measure of liquidity. The idea of adding liquidity
from different positions is more intuitively captured using 𝐿.
64 At any arbitrary point (𝑥, 𝑦), we have that 𝑥𝑦 = 𝐿2 and 𝑦 = 𝑃 𝐿
𝑥 𝑌/𝑋 , which implies that 𝑥 = 𝑃 and 𝑦 =
√ 𝑌/𝑋
𝐿√𝑃𝑌/𝑋 . Since this is true at any arbitrary point, it holds at both points 𝐶 and 𝐹.
65 This follows directly from the previous footnote.
46
It is readily observed that summing these positions is equivalent to a single position with
𝑥̂ ′′′ = 𝑥̂ ′ + 𝑥̂ ′′ ; that is:
𝑥̂ ′ 𝑥̂ ′′ 𝑥̂ ′′′
(40) 𝐿′ + 𝐿′′ = 1 1 + 1 1 = 1 1 = 𝐿′′′
− − −
√𝑃𝑌/𝑋 √𝑃𝐶
𝑌/𝑋 √𝑃𝑌/𝑋 √𝑃𝐶
𝑌/𝑋 √𝑃𝑌/𝑋 √𝑃𝐶
𝑌/𝑋
This is shown graphically in Figure 10 below, where the real axes for the two positions have
been drawn with origins 𝑂̂ ′ and 𝑂̂ ′′ . The prices 𝑃𝑌/𝑋
𝐹 𝐶
, 𝑃𝑌/𝑋 and 𝑃𝑌/𝑋 correspond to the slopes
of rays 𝑂𝐹, 𝑂𝐶 and 𝑂𝑃, respectively. The amount of 𝑋 provided in the first position, 𝑥̂ ′ ,
corresponds to the distance 𝑂̂ ′ 𝑥̂ ′ . Once the user has determined the amount of 𝑋 to provide,
the corresponding amount of 𝑌 is given by equation (38) and is shown by the distance 𝑂̂ ′ 𝑦̂ ′.
The level curve corresponding to these real reserves can be determined by equation (39) and
is shown as 𝑘 ′ = (𝐿′ )2 . A similar set of arguments hold for the second position labelled with
‘’ on the graph. The combined liquidity provision is given by equation (40), and is depicted by
the level curve 𝑘 ′′′ = (𝐿′′′ )2 , where 𝐿′′′ = 𝐿′ + 𝐿′′ . The amount of 𝑋 in the combined position
is given by 𝑥̂ ′′′ = 𝑥̂ ′ + 𝑥̂ ′′ (the distance 𝑂̂ ′′′ 𝑥̂ ′′′ ), and the amount of 𝑌 is 𝑦̂ ′′′ = 𝑦̂ ′ + 𝑦̂ ′′ (the
47
𝐵
𝑃
𝑦̂ ′′′ 𝐴
𝐹
𝐷
′′′
𝑦̂ ′′ 𝑂̂′′ ′ 𝑥̂
𝑘 ′′′ = (𝐿′′ ′)2
𝑦̂ ′ 𝑂̂′ ′ 𝑥̂ ′′
′ 𝑘 ′′ = (𝐿′′ )2
𝑂̂′ 𝑥̂
𝑘 ′ = (𝐿′ )2
𝑥
𝑂
In general, intervals specified by liquidity providers may partially overlap (or not at all).
While this yields more complex graphs, the underlying logic is the same. In Figure 11 below,
we depict a scenario with a partial overlap, with the two user-specified price ranges being
𝐹′ 𝐶 ′ 𝐹 ′′ 𝐶 ′′
[𝑃𝑌/𝑋 , 𝑃𝑌/𝑋 ] and [𝑃𝑌/𝑋 , 𝑃𝑌/𝑋 ]. These price ranges and the corresponding liquidities translate
the axes to 𝑂̂′ and 𝑂̂ ′′ , respectively. The prices can be read off the graph as the slope of rays
𝑂𝐹′, 𝑂𝐹′′, 𝑂𝐶′ and 𝑂𝐶 ′ ′. To keep the graph devoid of clutter, the figure does not contain
information such as the current price, the real reserves and so on.
48
𝑦 𝐶 ′′
𝐶′
𝐸
𝐹 ′′
𝐷 𝐹′
𝐻
𝐺
𝑂̂′ ′
𝐵
𝐴
̂′
𝑂 𝑘 ′′
𝑘′
𝑥
𝑂
𝐹 𝐹 ′ ′′
In the price range [𝑃𝑌/𝑋 , 𝑃𝑌/𝑋 ], only this position provides liquidity, so the relevant level
𝐹 ′′
curve is 𝑘 ′ . This holds till point 𝐵, but once the price reaches 𝑃𝑌/𝑋 = 𝑃𝑌/𝑋 the second position
𝐹 𝐶 ′′ ′
is activated. Consequently, in the range [𝑃𝑌/𝑋 , 𝑃𝑌/𝑋 ], both positions are active, and the
relevant level curve of the exchange function is 𝑘, which combines both positions in that price
range. There is, in essence, a jump from point 𝐵 to 𝐷 to reflect the joining of a second position
49
66 Though, as mentioned earlier, since price moves in ticks on Uniswap-v3 and fees are charged as well, the
actual computations are more complicated than those described here.
67 Cyclos, for example, labels itself as a concentrated liquidity market maker for the Solana network; see
50
𝑘
𝑂 𝑥
6. Conclusions
This paper presented a unified framework based on the neoclassical black-box to
characterize different types of AMMs that are currently popular as DEXs. One of the main
advantages of such a framework is that it provides a set of simple tools that can be used to
visualize the geometry of a given AMM. This makes it easy to see, for example, why the price
remains unchanged when both reserves are doubled. It also allows for a simple way to check
when manipulating a given exchange function makes a significant difference and when it does
not. In a CPMM, for example, the homotheticity property suggests that any monotonic
transformation of the exchange function does not alter the price for any given set of reserves,
making these various functions equivalent. Other properties, such as Euler’s theorem provide
a convenient method to value a liquidity pool in an AMM.
Importantly, the methodology also allows for comparisons across a variety of AMMs, in
order to examine how similar or different various types of AMMs are. While the coverage of
AMMs in this paper is certainly not exhaustive, especially since this is a fertile area for
innovation with new ideas for AMMs are being developed at a rapid pace, the analytical and
51
68 See Daian et al (2019) for these and other issues related to vulnerabilities in the DeFi space. Robinson and
Konstantopoulos (2020) provide an interesting account of the Ethereum as a ‘dark forest’.
69 For a broader treatise on the current state of DeFi, see Harvey et al (2021).
70 In a memorable exchange between Sherlock Holmes and Dr. Watson in A Study in Scarlet, when the latter
expresses astonishment at the former’s lack of awareness of the solar system, Holmes responds, “A fool takes
in all the lumber of every sort that he comes across, so that the knowledge which might be useful to him gets
crowded out, or at best is jumbled up with a lot of other things, so that he has a difficulty in laying his hands
upon it. Now the skilful workman is very careful indeed as to what he takes into his brain-attic…” When Dr.
Watson persists, “But the solar system!”, Holmes counters with “What the deuce is it to me?”, and then goes
on to state, “You say that we go round the sun. If we went round the moon it would not make a pennyworth of
difference to me or to my work.”
52
53
54
55
56