0% found this document useful (0 votes)
26 views54 pages

DeFi Primer: Automated Market Makers

This document provides an overview of automated market makers (AMMs) and how they enable decentralized exchanges (DEXs) in decentralized finance (DeFi). It discusses how AMMs work as market makers, providing liquidity for trading assets through algorithmically determined prices, without requiring a centralized third party. Various types of AMM models are examined, including constant product, constant mean, constant sum, hybrid, and dynamic models. The document aims to analyze AMMs through the lens of economic theory to provide both DeFi and economics audiences with an intuitive understanding of how these new decentralized applications operate.

Uploaded by

Sandy yoic
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
26 views54 pages

DeFi Primer: Automated Market Makers

This document provides an overview of automated market makers (AMMs) and how they enable decentralized exchanges (DEXs) in decentralized finance (DeFi). It discusses how AMMs work as market makers, providing liquidity for trading assets through algorithmically determined prices, without requiring a centralized third party. Various types of AMM models are examined, including constant product, constant mean, constant sum, hybrid, and dynamic models. The document aims to analyze AMMs through the lens of economic theory to provide both DeFi and economics audiences with an intuitive understanding of how these new decentralized applications operate.

Uploaded by

Sandy yoic
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

AUTOMATED MARKET MAKERS AND DECENTRALIZED EXCHANGES: A DEFI PRIMER

This version: 13th April, 2021

VIJAY MOHAN1
RMIT Blockchain Innovation Hub, RMIT University
& Lattice Analytics Pty Ltd
Email: [Link]@[Link]

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 use of traditional economic tools allows for an
intuitive geometric representation of how an AMM operates. The unified framework also
enables a clear delineation of the similarities and differences between the various types of
AMMs.

Keywords Decentralized finance (DeFi); automated market maker (AMM); decentralized


exchange (DEX); smart contract; Ethereum

1This 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.

Electronic copy available at: [Link]


AUTOMATED MARKET MAKERS AND DECENTRALIZED EXCHANGES: A DEFI PRIMER

Vijay Mohan

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 52.29 billion, having roughly doubled over a three-month period.1 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 these centralized third-parties that act
as intermediaries in financial transactions.
While it is not clear at this stage whether DeFi will be able to 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 to correlate ideas in this area with traditional concepts in
economics and finance. This paper represents an attempt at examining new developments in
DeFi using the oldest of tools invented by economists – 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 specific applications of more general production technologies.
Ultimately, the motivation behind this paper is to develop a self-contained primer that
introduces these simple techniques to DeFi aficionados who are interested in an economic
theory perspective, and that presents some wonderful new applications of old theories to
economists, especially students and educators.2
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. In order 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 a centralized order book system, where buyers and sellers submit ‘orders’: prices and

1 See [Link] accessed on 10th April, 2021.


2 To cater to audiences from both the DeFi community and economics, by and large the paper presumes
familiarity with the jargon of neither. The only assumed knowledge is some acquaintance with the concept of a
blockchain and the basic techniques of calculus.

Electronic copy available at: [Link]


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).
A DEX provides agents with the opportunity to exchange one asset for another without a
centralized third-party responsible for overseeing trading activity. The cryptocurrency space
has been dominated by centralized exchanges in the past, many of whom, such as Mt. Gox,
met with disastrous downfalls and losses that has, if anything, only strengthened the resolve
to make DEXs work. Schär (2020) and Pourpouneh et al (2020) list the various pros and cons
of centralized and decentralized exchanges. Specifically, centralized exchanges can be easier
to implement but suffer from a number or drawbacks: traders lose custody of assets and must
trust the exchange to not seize assets; they can be susceptible to security threats due to a
single point of attack; and, centralized exchanges for cryptocurrencies have been subject to
little regulation, which amplifies problems. DEXs, on the other hand, do not rely on trust in,
or security of, a single centralized party as traders retain custody of assets and smart contracts
(reviewed in the next section) that execute trades. They are, however, harder to design and
implement compared to a centralized exchange, and can be forced to charge higher fees to
attract liquidity.
DEXs can be implemented in different ways. Some replicate the order book format of a
centralized exchange. One way to do this is through an on-chain order book where every
order is recorded on the blockchain, but this can be expensive. An alternative approach
involves constructing an off-chain order book, which only uses the blockchain for settlement,
but orders are recorded elsewhere (possibly by some centralized third-party). This is less
expensive, but also less decentralized and secure compared to an on-chain order book (Schär,
2020; Pourpouneh et al, 2020).
Instead of using an order book, more recent attempts at establishing DEXs have revolved
around the use of automated market makers (AMMs), which is the subset that this paper
focuses on. Following Hanson (2003) and Hanson (2007), AMMs first gained popularity in
prediction markets for aggregating predictions of agents into prices. In general, a market
maker is an institution that offers to buy or sell an asset, making a profit from the bid-ask
spread: the difference between the ask or offer rate (the rate at which the market maker sells
an asset) and the bid rate (the rate at which the market maker buys an asset). An AMM
automates this by allowing traders to place orders with the AMM, which then algorithmically
provides a price. It is worth reiterating how this process is distinct from the order book system
which requires matches between price and volume orders provided by buyers and sellers.
With a market maker, an agent trades directly with the market maker by selecting a quantity
of an asset to trade at a price specified by the market maker. This is particularly beneficial in

Electronic copy available at: [Link]


thin markets where there are few buyers and sellers, so that there may be a wide gap
between the maximum price any buyer is willing to pay and the minimum price any seller is
willing to accept, thereby causing no trades to occur. With an AMM, the market maker acts
as the counterparty to all trades, and liquidity can be provided even when markets are thin.
Traders are interested in swapping one asset for another with the AMM. So, the question
that arises is: who exactly provides liquidity for an AMM to act as a DEX? The answer is that
owners of various assets do so by placing their assets within a liquidity pool in the AMM; the
quantities of assets in a liquidity pool are its reserves. Of course, a single agent is free to
perform both functions – provide liquidity and trade – on an AMM. In return for placing their
assets with the AMM, liquidity providers are typically entitled to a pro-rata share of the fees
paid by traders for exchanging assets on the AMM. Returns in the form of trading fees are the
main incentive for agents to act as liquidity providers. As we will show in Section 2, the
presence of fees creates a price bid-ask spread.
In an order book system, the matching of orders by buyers and sellers (or in other words,
the forces of demand and supply) produces a price. In an AMM, prices are determined
algorithmically; what guarantees, then, that the prices reflect demand and supply conditions
in the wider market for cryptocurrencies? For example, suppose there exists another
exchange (possibly centralized) that prices some token, say ABC token, at 2 XYZ tokens. If a
trader wants to swap between ABC and XYZ tokens at the AMM, for the two exchanges to be
comparable, the AMM’s algorithm must also allow a trade of 1 ABC for 2 XYZ. To frame this
slightly differently, given that the AMM’s pricing mechanism is automated through an
algorithm, how does it know that the other exchange – the ‘reference market’ – is offering a
price of 2 XYZ per ABC token? There are, in fact, a couple of different ways in which the price
in the AMM can be made to align with that of the reference market. The first, and most
common, is by the process of arbitrage, wherein arbitrageurs buy and sell assets across
markets to take advantage of price differentials in order to make (risk-free) profits, and by
doing so cause an alignment of prices. The second is by allowing the reference market to act
as an oracle, which is essentially an external source of information used by the AMM to set
its price.

1.2 Smart contracts


Smart contracts are at the heart of DeFi applications and, consequently, current DeFi
platforms are being built predominantly on Ethereum’s smart contract-based blockchain. 3
Smart contracts were first introduced by Szabo (1996), along with a working definition:

3See [Link] (accessed 30th March, 2021), and [Link] (accessed


30th March, 2021) or Buterin (2014).

Electronic copy available at: [Link]


“A smart contract is a set of promises, specified in digital form, including protocols within
which the parties perform on these promises” [emphasis added].
Closer examination of this definition reveals two distinct aspects of a smart contract: a legal
contractual aspect and a technological aspect. The contractual aspect of a smart contract
arises from the concepts of ‘promise’ and ‘performance’ contained in the definition.
Presumably, promises are based on intention and performance will involve consideration, so
one could compare this to a standard contract as defined by the legal profession. But the
definition also presumes that the contract is ‘digital’ and includes ‘protocols’ (read:
algorithms), which provides a distinct technological twist to the definition.
Using Szabo’s (1996) definition, therefore, one can come away with different impressions
of a smart contract, depending on which facet one wishes to emphasize. In this paper, we do
not approach a smart contract from a legal point of view, not least because the literature on
the issue of how standard contract law applies to smart contracts warrants its own separate
study. Nor do we focus on issues that economists typically examine in contract theory:
asymmetric information (the complete contract literature), or property rights and
organizational boundaries (the incomplete contract literature). Rather, for the purpose of this
paper, the most fruitful avenue is to focus on the technological aspects of a smart contract.
From the point of view of the technology, the US National Institute of Standards and
Technology defines a smart contract as “A collection of code and data (sometimes referred
to as functions and state) that is deployed using cryptographically signed transactions on the
blockchain network.”4 Similarly, the Ethereum whitepaper states that, “Smart contracts,
cryptographic ‘boxes’ that contain value and only unlock it if certain conditions are met, can
also be built on top of the platform, with vastly more power than that offered by Bitcoin
scripting because of the added powers of Turing-completeness, value-awareness, blockchain-
awareness and state.”5
In terms of how all this translates to the use-case of an AMM based DEX, the Ethereum
network essentially has two types of accounts: externally owned accounts (EOA; these are
essentially user accounts) and contract accounts (or smart contracts). EOAs in Ethereum are
standard cryptocurrency accounts and are characterized by three elements: a private key, a
public key and a balance of the cryptocurrency native to the blockchain, which in the case of
Ethereum is Ether (ETH). The public key is used to generate an address that identifies an EOA
in the network, and the private key, known only to the holder of the account, is used to
(cryptographically) authorize transactions. Thus, one agent can use her private key to
authorize the transfer of a certain amount of ETH to another agent on the network. When the
transaction is added to a block, the blockchain state is updated and the EOAs of both agents

4 See [Link] (accessed 30th March, 2021).


5 See [Link] (accessed 30th March, 2021).

Electronic copy available at: [Link]


change to reflect the transaction.
In contrast, a smart contract is characterized by an address, a balance and code. A number
of features follow. First, the absence of a private key associated with a smart contract implies
that no agent on the network can authorize a change to the smart contract code (even if it
has a bug). Rather, the smart contract is controlled by the code embedded within it, which is
immutable once the contract is added to the network and cannot be altered by any agent.6
Second, apart from ETH, a smart contract can hold compatible tokens such as ‘ERC-20’ tokens
(that conform to ERC-20 standards for fungible tokens) or ‘ERC-721’ tokens (that meet ERC-
721 standards for non-fungible tokens).7 This is a very useful feature because the smart
contract acts as a sort of custodian of tokens, receiving and disbursing tokens using algorithms
specified by the code.
A liquidity pool in an AMM is a smart contract with a certain set of tokens that the smart
contract can maintain balances of, as specified by the smart contract code. The balances of
tokens are the quantities that serve as reserves for the purpose of liquidity provision. The
reserves are provided by the liquidity providers, and the reserves change as traders swap
tokens in the liquidity pool. The code also specifies, among other things, the rules for trading,
how prices are determined based on reserves, the rules for liquidity provision, and the trading
fees that traders pay to utilize the liquidity pool. An AMM, then, is simply a set of liquidity
pools, each being a smart contract with its own code and specified token balances.
Finally, there are multiple costs an agent may incur when utilizing an AMM. First, as
mentioned above, the agent may have to pay a trading fee (or swap fee) for exchanging
tokens with the AMM; these fees act as returns for liquidity providers. Second, there is a cost
to changing ledger entries on the blockchain to record changes in the ownership of tokens.
These gas fees on Ethereum vary depending on the extent to which the blockchain is being
used for any purpose, DeFi or otherwise. In what follows, we do not factor in these network

6 The main problem to simply replacing a smart contract (say, that has a bug in it) with a new one occurs when
the 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 [Link] accessed 30th March, 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.
7 See [Link] for a description of ERC-20 and

[Link] for ERC-721 (accessed 30th March,


2021). While ERC-20 and ERC-721 are the two most commonly used standards at this stage, other standards also
exist, such as ERC-777 and ERC-1155. Standards are introduced in the Ethereum network through Ethereum
Improvement Proposals (EIPs); for further details, see [Link] and
[Link] (accessed 30th March, 2021).

Electronic copy available at: [Link]


level gas fees and focus entirely on the impact of trading fees charged by a specific AMM. In
reality, when performing DeFi transaction these gas fees have to be included in trading
decisions, and can sometimes be significant enough to deter use of DeFi applications. Both
these types of fees affect the transaction cost to any agent using an AMM to exchange
tokens.8 Finally, some AMMs have the ability to charge protocol fees that are, essentially, paid
by the liquidity providers for future development of the AMM. We do not examine protocol
fees in this paper.9

1.3 The approach and contribution of this paper


This paper examines how AMMs operate as DEXs to facilitate price discovery, arbitrage,
and the exchange of one cryptocurrency token for another. In order to achieve this, we view
an AMM in much the same way as neoclassical economic theory models a firm: as a ‘black-
box’. A neoclassical firm is characterized entirely by its ability to convert factor inputs, such
as labour and capital, into output using some technology made available by scientists and
engineers. The nature (or if one were to depict this graphically, the ‘shape’) of the technology
is summarized by a production function, which then delineates what combinations of inputs
and outputs are feasible. Given the costs associated with purchasing inputs and the revenues
generated by selling the output, different feasible combinations of inputs and outputs
generate different profits. The firm, automaton-like, simply picks the specific combination of
inputs and output from the set of all feasible combinations that yields the maximum profit.
In the neoclassical characterization of the firm there is scant attention paid to what goes
on inside a firm (hence the term ‘black-box’). Issues that real-world businesses must tackle
on a daily basis, such as providing incentives to workers to exert effort, determining
appropriate pay packages for employees, resolving problems associated with hierarchy and
authority, and so on, are entirely ignored in a black-box view, which is based on the premise
that the engineering technology behind the production of goods and services is of paramount
importance. Moreover, the neoclassical black-box model does little to address what
determines the boundaries of a firm – that is, why some activities are organized within a firm
and others through market transactions. Many of these problems were addressed in later

8 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, these gas fees can be viewed as an exogenous
cost that has been normalized to zero in this paper. Adding gas fees will not alter the analysis; it simply affects
the magnitude of bid-ask spreads, which influences the extent of arbitrage.
9 Uniswap-v2 (Adams et al, 2020), for example, introduced the possibility of a .05% protocol fee that is deducted

from the trading fees paid by the user. So, these fees do no not affect the transaction cost of the traders on the
exchange; rather, they create a wedge between the fees paid by the traders and the fees received by liquidity
providers. In that sense, protocol fees are essentially a tax on the users and liquidity providers of an AMM.

Electronic copy available at: [Link]


developments to the economic theory of the firm in the form of principal-agent models and
transaction cost theories.10
The drawbacks of the neoclassical black-box notwithstanding, it does what it’s supposed
to do – describing the conversion of inputs to outputs – extremely well. If in some context of
analysis the focus is indeed on the technology behind this conversion, the black-box nature
of the neoclassical firm is, to borrow a phrase from programmers, a feature and not a bug,
because it removes all the clutter about what goes in on inside a firm to hone in on what is
contextually important: the technology.
Given the myriad DEX platforms that have emerged in the recent past, one could make the
argument that our current understanding of AMMs is at a stage where it would benefit from
a careful examination of how inputs are converted to an output by an AMM. The approach
adopted by this paper is to view an AMM as a black-box that transforms quantities of tokens
in an AMM (inputs) into a price (output). The way the transformation takes place is governed
by the specification of an ‘exchange function’ that describes the technology of token trade in
an AMM.11 It worth emphasizing that we do not equate an AMM to a firm; rather, the
neoclassical methodology of treating the firm as a black-box is utilized here to model an AMM.
The exchange function that has received the most attention in the DeFi community is used
by a Constant Product Market Maker (CPMM), such as Uniswap.12 Since this is typically the
first type of AMM that many entrants into the DeFi space encounter, Section 2 provides a
detailed account, using examples, of how such an AMM operates as a DEX and how bid-ask
spreads are determined based on fees. Moreover, given the importance of arbitrage in
pricing, this section examines two and three-point arbitrage in depth, along with relevant no-
arbitrage conditions. Following its inception in 2018, Uniswap has undergone three iterations:
Uniswap version 1 (v1) was the original proof of concept; 13 this was upgraded to Version 2 in
2020 (v2; Adams et al, 2020); recently, Uniswap has also released the whitepaper for version
3 (v3; Adams et al, 2021).14 However, at the time of writing, Uniswap-v3 changes are yet to
be implemented; consequently, while this paper outlines some of the important features
introduced in v3, the main focus is on the core principles that follow from the use of a general
CPMM exchange function. While our analysis is based on the characteristics of Uniswap, other
CPMMs exist, such as Sushiswap and Mooniswapthat are similar to Uniswap.15 Consequently,

10 See Demsetz (1997), Hart (1995, Chapter 1), and Holmstrom and Tirole (1989) for overviews.
11 The term ‘exchange function’ is used because it captures the relevance of 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 (DEX) will have a specific function associated with it.
12 See [Link] (accessed 30th March, 2021).
13 See [Link] or for the v1 whitepaper (accessed 30th March, 2021).
14 As each version introduces new smart contracts, they can coexist as liquidity pools.
15 See [Link] and [Link] (both websites accessed on (accessed 30th

March, 2021). Sushiswap is a fork of Uniswap, with some small features added to make it more “community
friendly”. In what was subsequently termed a “vampire attack”, Sushiswap sought to extract liquidity away from

Electronic copy available at: [Link]


in order to generalize the ideas here, we will often refer to a CPMM-v1, v2 or v3 to
characterize a CPMM that has the characteristics of Unsiwap-v1, v2 or v3, respectively.
Section 3 introduces some basic tools of neoclassical economic modelling - homogeneous
functions and homothetic functions - as well the geometric properties characterizing these
tools. While the material here is fairly self-contained, more detailed and leisurely discussions
of these topics can be found in any introductory text on mathematical methods in economics,
such as Chiang (1984) or Silberberg (1990). These neoclassical tools facilitate a careful
examination of the properties and geometry of a CPMM, which complements and extends
existing contributions to the analysis of price formation and arbitrage in a CPMM, such as
Angeris et al (2019) and Zhang et al (2018). This section also showcases the usefulness of
Euler’s theorem in developing simple techniques for valuing a liquidity pool in a CPMM.
Section 4 examines other types of AMMs that have gathered interest as potential DEXs,
including a: Constant Mean Market Maker (CMMM), such as Balancer; Constant Sum Market
Maker (CSMM), which has severe drawbacks as a DEX; Hybrid Function Market Makers
(HFMM), such as Curve Finance; and, Dynamic Automated Market Maker (DAMM), such as
Bancor.16 The focus here is very much on fitting these AMMs into the framework developed
in Section 3, as well as on drawing out similarities and points of departure in their
characteristics.17 Consequently, the specific institutional features of each of these AMMs are
not described nearly as carefully as for the CPMM in Section 2, though in many instances, if
required, these features can be readily related to concepts introduced for a CPMM. Section 4
concludes with a return to an analysis of a CPMM by examining more closely the idea of
concentrated liquidity that forms a key feature of the proposed Unsiwap-v3 AMM.
Like the neoclassical firm, the black-box view of an AMM has severe 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, how incentives for participation are
structured, 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 5.

Unsiwap. For a simple explanation of vampire attacks, see [Link]


explained/ (accessed 30th March, 2021). Mooniswap, on the other hand, attempts to reduce the impact of price
slippage arising from large trades on a CPMM.
16 See: [Link] for Balancer and [Link] for Curve Finance; and

[Link] for Bancor. All websites accessed on 30th March, 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.
17 See also Angeris and Chitra (2020), who examine the properties of a general class of constant function market

makers, which include the CPMM, CMMM and HFMM.

Electronic copy available at: [Link]


2. The workings of a Constant Product Market Maker (CPMM): Uniswap-v1 and v2
In a CPMM, such as Uniswap, the product of the quantity of two tokens in a liquidity pool
is a constant. The example examined here replicates and extends the one developed in the
original Uniswap-v1 whitepaper. When needed, we will introduce the changes brought about
in Uniswap-v2, and how this impacts the workings of the AMM platform. We cover the
proposed changes in v3 in Section 2.4, and in more detail in Section 4.5.

2.1 An example and some basic pricing equations


The two tokens in focus here are token 𝑋 (which we assume to be ETH) and token 𝑌 (some
ERC-20 token, say ABC). In what follows, we use upper-case letters for the token in general
and lower-case letters for specific quantities of the tokens. For any given token quantities,
(𝑥, 𝑦), a CPMM utilizes the exchange function 𝑥𝑦 = 𝑘 to algorithmically govern trade
between the two tokens. To see how this works, let the initial amount of ETH supplied by
liquidity providers be 𝑥 0 = 10, and the amount of ABC provided be 𝑦 0 = 500; these are the
initial reserves of the two tokens in the AMM liquidity pool. In a CPMM, the product of the
two is a constant, 𝑘, which takes an initial value 𝑘 0 = 𝑥 0 𝑦 0 = 5000.
A trader in this market is any agent who exchanges one token for anther in the pool. In
order to do this, the trader must pay a trading fee (or swap fee), which accrues to the liquidity
providers. However, to establish a baseline case, let us first consider the situation where the
trading fee is zero.
Suppose a trader wishes to sell 1 ETH in exchange for ABC. In the absence of a trading fee,
this entire amount is added to the liquidity pool, resulting in a pool balance of 𝑥 1 = 11 ETH.
𝑘0
Given the constant, 𝑘 0 , the amount of ABC in the pool is 𝑦 1 = 𝑥 1 = 454.5454. The change in
the pool reserves of ABC is 𝑦 1 − 𝑦 0 = −45.4546, which is negative because the reserves of
ABC in the AMM have fallen: this quantity of 45.4546 ABC is sent to the trader’s account. The
trader has effectively sold 1 ETH in order to buy 45.4546 ABC with the AMM, which is the
counterparty to this trade; consequently, the liquidity providers for the AMM now, in
aggregate, hold 1 ETH more and 45.4546 less ABC. While the AMM has an altered reserve
profile (𝑥 1 , 𝑦 1 ), it is evident that 𝑥 1 𝑦 1 = 𝑘 0 , and the product of the two (new) reserve
𝑏
quantities equals the constant 𝑘 0 . The price of 1 ETH in terms of ABC in this example is 𝑃𝑌/𝑋 =
45.4546 ABC/ETH. In terms of the notation, the subscript 𝑌/𝑋 indicates that the price is for
one unit of token 𝑋 (ETH) in terms of token 𝑌 (ABC), while the superscript 𝑏 indicates that this
is the bid price: the price at which the AMM buys ETH.18
It is straightforward to work the example in reverse, where the trader buys 1 ETH from the

18In 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.

Electronic copy available at: [Link]


𝑘0
AMM in exchange for ABC. Proceeding as before: 𝑥 1 = 9, 𝑦 1 = 𝑥 1 = 555.5556 and 𝑦 1 −
𝑎
𝑦 0 = 55.5556. The price in this instance is 𝑃𝑌/𝑋 = 55.5566 ABC/ETH, where the superscript
𝑎 indicates that this is the ask (or offer) price of ETH in terms of ABC: the price at which the
AMM sells 1 unit of ETH to the trader.
The bid and ask rates in this example seem appreciably different – the bid-ask spread is
𝑎 𝑏
𝑃𝑌/𝑋 − 𝑃𝑌/𝑋 = 10.102, primarily because the changes considered here are lumpy and fairly
large in magnitude. In reality, ETH is divisible to 18 decimal places, so much smaller trades are
feasible.19 Suppose the trader were to buy and sell .01 ETH instead of 1 ETH in the example.
𝑏 𝑎
The bid and ask prices in this case are 𝑃𝑌/𝑋 = 49.9500 ABC/ETH and 𝑃𝑌/𝑋 = 50.0501
𝑎 𝑏
ABC/ETH, which are much closer together (the spread is 𝑃𝑌/𝑋 − 𝑃𝑌/𝑋 = 0.1001). Indeed, as
the change in ETH in the trade keeps getting smaller, the two converge towards the price of
50 ABC/ETH. In general, it can be shown (which we do subsequently) that with infinitesimal
changes and no trading fees:

𝑏 𝑎 𝑦0
(1) 𝑃𝑌/𝑋 = 𝑃𝑌/𝑋 = 𝑥 0 = 𝑃𝑌/𝑋

There are a few features to take away from this example when there are no trading fees.
First, equation (1) summarizes the fact that the bid and ask prices collapse to a single price
(𝑃𝑌/𝑋 ) for infinitesimally small changes, and that the price equals the ratio of the two tokens
𝑦0
in the reserve when the trade takes place ( 0). Second, it is readily calculated that the price
𝑥
of one unit of ABC in terms of ETH (that is, ETH/ABC) converges to:

1 𝑥0
(2) 𝑃𝑋/𝑌 = 𝑃 = 𝑦0
𝑌/𝑋

Changing the base token of the price quotation, therefore, simply involves taking the
reciprocal of the prices. Third, the constant, 𝑘 0 , which is determined by the liquidity injected
into the pool, 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 fee
is important for two reasons. First, it is transferred to the liquidity providers; the pro-rata
distribution of fees among the liquidity providers represents their return for the provision of
tokens to the AMM. However, it is worth emphasizing that this is not the sole determinant of
payoffs to the liquidity providers: as they are also the counterparty to all exchange of tokens

19 See [Link] (accessed 30th March, 2021).

10

Electronic copy available at: [Link]


by traders, they stand to lose from the arbitrage opportunities that traders seek to exploit. As
elaborated upon presently, this leads to the second reason why fees are important: they
provide a zone in which arbitrage is not profitable for traders and thereby reduce the
arbitrage opportunities available.
The trading fee is assumed to be 𝜏 = .25% in the example constructed in the Uniswap-v1
whitepaper, which we follow here as well.20 On Uniswap-v1 and v2, the trading fee is always
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 constant 𝑘 0 . In the second
stage, the fees are added to the liquidity pool, which gives rise to a new constant, 𝑘1 . This
ensures that the value of 𝑘 changes slightly with every trade; so, the term ‘constant’ here 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 that this is an interim quantity
of 𝑋 used for the trade). Given 𝑘 0 = 5000, the new amount of ABC balance in the pool is
𝑘0
𝑦 1 = 𝑥 1′ = 454.6488, implying a change in pool reserves of ABC equal to 𝑦 1 − 𝑦 0 =
−45.3512. This amount of ABC is then transferred to the trader, who 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 slightly
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. This is intuitively the reason why there are lower arbitrage
opportunities available in the presence of transaction costs. Secondly, the change in 𝑘 is 𝑘1 −
𝑘 0 = 1.1368; however, this is only for a single trade. 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 from the pool, which would leave 9
ETH in the pool. Since fees are denominated in terms of the token sold to the AMM, the fee
here is charged for the volume of ABC traded for 1 ETH. So, if the trader deposits an amount

20 In reality, the fees on Uniswap is .3%.

11

Electronic copy available at: [Link]


∆𝑦 ABC, after the fees are deducted, the trader adds an interim (Stage 1) amount of 𝜙∆𝑦 ABC
to the pool. The (interim) pool balance of ABC is now 𝑦 1′ = 𝑦 0 + 𝜙∆𝑦. Since we know that
1 𝑘0
𝑥 1 𝑦 1′ = 𝑘 0 in Stage 1, it follows that ∆𝑦 = 𝜙 [𝑥 1 − 𝑦 0 ] = 55.6948. It is evident that the ask
𝑎 𝑎
price has increased with the introduction of the transaction fee (𝑝𝑌/𝑋 > 𝑃𝑌/𝑋 ). Moreover, as
𝑎 𝑏
before, the bid-offer spread is fairly large (𝑝𝑌/𝑋 − 𝑝𝑌/𝑋 = 10.3436); in fact, it is even larger
than the case with no transaction fees, because the bid rate is lower and the ask rate is higher.
We can now ask, once again, what happens if a smaller ETH amount, say .01 ETH, is traded.
𝑏 𝑎 𝑎
Replicating the procedure, we find that 𝑝𝑌/𝑋 = 48.7025, while 𝑝𝑌/𝑋 = 50.1755, so 𝑝𝑌/𝑋 −
𝑏
𝑝𝑌/𝑋 = 1.473. While this is smaller than the spread when 1 ETH was traded, it is still fairly
significant. In fact, unlike the case with no transaction costs, we show analytically in the next
𝑏 𝑎
section that for infinitesimal changes, 𝑝𝑌/𝑋 = 49.875 and 𝑝𝑌/𝑋 = 50.1253, which implies
𝑎 𝑏
𝑝𝑌/𝑋 − 𝑝𝑌/𝑋 = 0.2503 is the minimum spread achievable in this example with a fee of 0.25%.
Unlike the case with no transaction fees, this wedge between the two prices cannot reduce
to zero, and equation (1) does not hold – we need to work with bid and ask rates even with
infinitesimal changes. Indeed, the bid-ask spread widens as the trading fees increase, or as
we have seen, when the volume of tokens exchanged increase in magnitude. These are
important features for arbitrage, which we will explore presently.
Finally, since the sale (purchase) of one token by a trader goes hand-in-hand with the
purchase (sale) of the other token, when there are trading fees equation (2) needs to be
modified to:

𝑏 1 𝑎 1
(3) 𝑝𝑌/𝑋 = 𝑝𝑎 and 𝑝𝑌/𝑋 = 𝑏
𝑋/𝑌 𝑝𝑋/𝑌

2.2 Arbitrage using AMMs


In this section, we consider two different ways in which an AMM can be used for arbitrage.
First, we consider the possibility of two-point arbitrage, which has, in fact, been discussed at
length by the DeFi community and is, in a way, the raison d’être for an AMM. Next, we
examine whether three-point arbitrage is feasible in an AMM, an issue that has, in contrast,
received little attention. The arbitrage terminology that we employ here is consistent with
standard usage in the finance literature (and the literature on foreign exchange markets).

2.2.1 Two-point arbitrage


Two-point arbitrage or, to borrow the term from foreign exchange markets, locational
arbitrage, is triggered due to a difference in prices across different markets (or exchanges or
platforms, as the case may be) for the same asset. Consider, then, a situation where there
exists another (possibly centralized) exchange, which we label as the ‘reference market’,

12

Electronic copy available at: [Link]


where an agent can trade between ABC (𝑌) and ETH (𝑋). Two-point arbitrage refers to the
fact that a token bought in one market (say the CPMM) can be sold in the other market
(reference market) in order to realize risk-free profits. Doing so is profitable (subject to
trading fees) if there is a mismatch in the prices quoted in the two markets. However, as
agents take advantage of arbitrage opportunities and transact in the two markets, the
demand and supply forces they set into motion eventually cause these opportunities to
disappear. An equilibrium occurs when there are no arbitrage opportunities left, and the
equilibrium no-arbitrage condition essentially involves there being no mismatch in the prices
between the two markets. Arbitrage is, in general, a powerful pricing tool: first, it is attractive
because it results in risk-free profits, so we can be sure agents will jump to take advantage of
arbitrage opportunities when they arise; second, the process of arbitrage conveniently
eliminates these opportunities eventually, so we can be confident that, all else being the
same, markets will gravitate towards an equilibrium where prices equalize (to the extent
permitted by transaction costs).
To examine two-point arbitrage in more detail, let the price of one unit of 𝑋 in terms of 𝑌
in the reference market be 𝑀𝑌/𝑋 . In keeping with the notation developed earlier, the upper-
case 𝑀 denotes a situation where there are no trading fees for transacting in the reference
market. At the expense of algebraic simplicity, this is altered readily enough by considering
𝑏 𝑎
bid and ask rates in the reference market: 𝑚𝑌/𝑋 and 𝑚𝑌/𝑋 . We could make the story even
more realistic by adding other transaction costs (such as gas fees) that must be paid to record
transfers in ledgers. In reality, for the purpose of evaluating profits or losses all such
transaction costs must be accounted for. However, for the task at hand of understanding the
mechanics of how arbitrage works, we can ignore these costs, with the caveat that they must
be factored in when actually trading. In what follows, therefore, the only transaction costs
incorporated in the analysis are the trading fees, 𝜏, charged by the AMM.
To begin with, consider the case when there are no trading fees and infinitesimal trade
volumes are possible. Suppose that the price of ETH (token 𝑋) in terms of ABC (token 𝑌) in
the reference market is 𝑀𝑌/𝑋 = 49.9, while the price of ETH in our focus AMM is 𝑃𝑌/𝑋 = 50.0.
An agent could arbitrage between the reference market and the AMM by buying ETH in the
reference market for 49.9 and selling it in the AMM for 50.0 ABC, thereby making a profit of
𝑃𝑌/𝑋 − 𝑀𝑌/𝑋 = 50.0 − 49.9 = 0.1 ABC for every unit ETH purchased and sold in this manner.
However, as arbitrageurs do this, the increased demand for ETH in the reference market
would increase the price there, so that 𝑀𝑌/𝑋 increases, and the increase sale of ETH in the
AMM reduces 𝑃𝑌/𝑋 till the arbitrage profits are wiped away.21 The prices in the two markets
are brought into alignment and prices in the AMM cannot diverge randomly for any significant

21 If the AMM is small relative to the reference market, these trades may have only a small impact on the price
in the reference market, so that the brunt of the adjustment occurs through changes in 𝑃𝑌/𝑋 .

13

Electronic copy available at: [Link]


period of time due to the actions of arbitrageurs. The equilibrium no-arbitrage condition
satisfies:

(4) 𝑃𝑌/𝑋 = 𝑀𝑌/𝑋

In a similar fashion, in instances where 𝑃𝑌/𝑋 < 𝑀𝑌/𝑋 we would expect arbitrage to occur in
the opposite direction, with 𝑋 being bought in the AMM and sold in the reference market.
Demand-supply forces would then result in equation (4) holding at equilibrium.
Now, with the reference market price remaining the same as before (𝑀𝑌/𝑋 = 49.9)
suppose there is a transaction fee, 𝜏 = 0.25%, of trading in the AMM which, as we have seen,
𝑏 𝑎
results in 𝑝𝑌/𝑋 = 49.875 and 𝑝𝑌/𝑋 = 50.1253. It is evident that arbitrage is no longer
feasible. Buying ETH in the reference market and selling in the AMM involves a loss of 0.025
ABC, and going in the reverse direction yields a loss of .2253 ABC. Thus, the no-arbitrage
condition in equation (4) is transformed to:

𝑏 𝑎
(5) 𝑝𝑌/𝑋 ≤ 𝑀𝑌/𝑋 ≤ 𝑝𝑌/𝑋

In the range prescribed by (5), arbitrage between the reference market and the AMM is not
profitable. If 𝑀𝑌/𝑋 moves outside this range, arbitrage is triggered which will result in
demand-supply changes that bring the rates into alignment so that equation (5) holds again.
Two observations are worth noting about the arbitrage process described here. First, the
𝑏 𝑎
numbers we have used for 𝑝𝑌/𝑋 and 𝑝𝑌/𝑋 are taken from example in Section 2.1 with
infinitesimal trade volume. However, as described earlier, moving to discrete changes only
𝑎 𝑏
serve to widen the spread 𝑝𝑌/𝑋 − 𝑝𝑌/𝑋 , which extends the range in equation (5) for which
arbitrage is not profitable. A similar widening of the spread occurs when 𝜏 rises, so that
increased trading fees (and transaction costs in general) also reduce arbitrage opportunities.
𝑏 𝑎
Second, if one incorporates bid and offer rates in the reference market, 𝑚𝑌/𝑋 and 𝑚𝑌/𝑋 , the
equilibrium no-arbitrage condition in (5) will have to factor in these rates to ensure that the
trader always ends up buying a token at a higher price than the rate at which the trader can
sell it to prevent arbitrage; specifically:

𝑏 𝑎 𝑏 𝑎
(6) 𝑝𝑌/𝑋 ≤ 𝑚𝑌/𝑋 and 𝑚𝑌/𝑋 ≤ 𝑝𝑌/𝑋

2.2.2 Three-point (or triangular) arbitrage


Two-point arbitrage exploits differences in prices across markets and, as the name
suggests, requires two price quotes – one from each market – for arbitrage possibilities to
emerge. In contrast, three-point arbitrage (or triangular arbitrage) focuses on the internal

14

Electronic copy available at: [Link]


consistency in the prices offered within a single market and requires three price quotes for
its implementation. Although three-point arbitrage can also be performed across markets, it
is not necessary – a price misalignment in a single market can trigger three-point arbitrage
opportunities. In our context, as agents take advantage of three-point arbitrage within a
single AMM, the changing forces of demand and supply ensure that prices in different
liquidity pools within the AMM are ultimately aligned in a logically consistent way.
Intuitively, suppose there are three tokens, 𝑋, 𝑌 and 𝑍, that are offered for trade in an
AMM and that a trader can swap between any pair. The question is: can the trader start off
with 1 unit of any arbitrary token (say 𝑍) and cycle through the tokens by, for example, selling
𝑍 for 𝑋, then selling the 𝑋 proceeds for 𝑌 before converting back to 𝑍 in order to end up
(magically) with more than 1 unit of 𝑍? In terms of notation, we use the symbols 𝑍 → 𝑋 →
𝑌 → 𝑍 to describe this sequence of conversions. However, this is not the only sequence that
is feasible: the trader could also perform the sequence 𝑍 → 𝑌 → 𝑋 → 𝑍. In either one of these
cases, if the trader starts with 1 unit of 𝑍 at the beginning of the cycle in order to end up with
more than 1 unit of 𝑍 at the end of the cycle, the possibility of three-point arbitrage exists.
Moreover, the choice of 𝑍 as the starting token is arbitrary: a trader could realize arbitrage
profits by cycling through starting with 𝑋 or 𝑌. All these possibilities can be visualized using a
triangle (hence the name triangular arbitrage), with the three tokens located on the three
vertices, and a specific cycle forming a path along the sides starting an ending at a given
vertex.

𝑍 𝑌

Figure 1: Three-point arbitrage

The arrows in Figure 1 show the cycles 𝑍 → 𝑋 → 𝑌 → 𝑍, 𝑌 → 𝑍 → 𝑋 → 𝑌 and 𝑋 → 𝑌 → 𝑍 →


𝑋, depending on which vertex forms the starting point. The opposite cycles can be visualized
by reversing the direction of the arrows.

15

Electronic copy available at: [Link]


Uniswap runs on the Ethereum network and ETH (token 𝑋) is the native settlement token.
However, there are a number of ERC-20 tokens that can be traded on the network, and one
can swap between any two ERC-20 tokens 𝑌 and 𝑍 on Uniswap. How exactly this exchange is
facilitated varies between v1 and v2 of the Uniswap platform. In Uniswap-v1, the platform
performs an exchange between 𝑌 and 𝑍 by implicitly using ETH (𝑋) as a via medium. Uniswap
achieves this by maintaining a separate smart contract for the exchange of each ERC-20 token
with ETH. Uniswap-v1 does not incorporate the possibility of a smart contract for direct
conversions between 𝑌 and 𝑍. This feature changes in Uniswap-v2, where a distinct smart
contract can be created for direct exchanges between ERC-20 tokens. Adams et al (2020)
recognize the added complexity of this change,22 without explicitly outlining the new
possibilities for arbitrage this creates. Much of the focus of this section, then, is to outline
how Uniswap-v2 creates the possibility of three-point arbitrage that is absent in Uniswap-v1.
More generally, we explore the outcomes under two types of CPMMs: CPMM-v1 that uses
a token 𝑋 as an intermediary in the exchange between and 𝑌 and 𝑍; and CPMM-v2 that allows
for a smart contract that acts as a 𝑌 − 𝑍 liquidity pool.23 Consider CPMM-v1 to begin with. If
a trader wishes to sell 𝑍 and purchase 𝑌, for example, the AMM will proceed by converting 𝑍
to 𝑋 (ETH) and then by converting the proceeds to 𝑌, which are added to the trader’s account.
Suppose that there are no trading fees (𝜏 = 0). If the trader wishes to sell 1 unit of token 𝑍,
𝑃𝑋/𝑍 determines how many units of 𝑋 the AMM delivers in exchange using the 𝑋 − 𝑍 liquidity
pool. The 𝑃𝑋/𝑍 units of 𝑋 can then be converted to 𝑌 at the price 𝑃𝑌/𝑋 , yielding the trader
𝑃𝑌/𝑋 × 𝑃𝑋/𝑍 units of 𝑌. Consequently, the price offered by the AMM for converting 1 unit of
𝑍 to 𝑌, 𝑃𝑌/𝑍 , is given by equation (7) below:24

(7) 𝑃𝑌/𝑍 = 𝑃𝑌/𝑋 × 𝑃𝑋/𝑍

To borrow some terminology from the foreign exchange rate literature, 𝑃𝑌/𝑍 can be
termed as the cross-rate (or cross-price) that can be derived from the other two prices (𝑃𝑌/𝑋
and 𝑃𝑋/𝑍 ). In CPMM-v1, there are only two prices that are determined endogenously: 𝑃𝑌/𝑋
and 𝑃𝑋/𝑍 ; these two prices are determined in the two liquidity pools (smart contracts) that
are available, the 𝑋 − 𝑌 pool and the 𝑋 − 𝑍 pool. The third price, 𝑃𝑌/𝑍 , is derived by the AMM
from the other two (using equation 7) and cannot change independently due to trader action.
Now, in CPMM-v2, a third market price exists due to the creation of a third smart contract:
a direct 𝑌 − 𝑍 liquidity pool. The three liquidity pools (the 𝑍 − 𝑌 pool, the 𝑋 − 𝑍 pool and the

22 As 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…”.
23 While we focus on CPMMs here, the idea of 3-point arbitrage extends to any type of AMM.
24 The price for selling 1 unit of 𝑌 in exchange for 𝑍, 𝑃
𝑍/𝑌 , can be readily calculated using equation (2).

16

Electronic copy available at: [Link]


𝑌 − 𝑍 pool) can now move independently due to trader activities. Intuitively, one can see
from Figure 1 that the creation of a third smart contract creates an independent price to
connect the vertices 𝑌 and 𝑍. This was not true in CPMM-v1, where the price connecting 𝑌
and 𝑍 was derived from the other two prices.
What we would like to show is that when equation (7) holds (which it does by construction
in CPMM-v1) three-point arbitrage is not feasible. Equation (7) is, therefore, a no-arbitrage
condition. To see how the no-arbitrage condition works here, consider CPMM-v2, with three
liquidity pools (𝑋 − 𝑌 pool, an 𝑋 − 𝑍 pool and a 𝑌 − 𝑍 pool), and with three associated prices
(𝑃𝑌/𝑋 , 𝑃𝑋/𝑍 and 𝑃𝑌/𝑍 ). Let us further posit that these three pools yield, at some point in time,
the relationship 𝑃𝑌/𝑍 < 𝑃𝑌/𝑋 × 𝑃𝑋/𝑍 , which violates equation (7). A trader could then perform
the sequence 𝑍 → 𝑋 → 𝑌 → 𝑍 to make a risk-free profit.25 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. By cycling
𝑃𝑌/𝑍

through these tokens, therefore, the trader could start with 1 unit of 𝑍 and end up with more
than 1 unit, risk-free. 26
As enough traders do this, however, relative prices will change until the arbitrage
opportunity is wiped out, which occurs when 𝑃𝑌/𝑍 = 𝑃𝑌/𝑋 × 𝑃𝑋/𝑍 (or, in other words,
𝑃𝑍/𝑌 × 𝑃𝑌/𝑋 × 𝑃𝑋/𝑍 = 1) and the inequality no longer holds. 27 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 term 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
equilibrium condition after arbitrage opportunities have been eliminated. Thus, when the
Uniswap structure changes from Uniswap-v1 to an Unsiwap-v2, it creates additional arbitrage
opportunities that adds to the complexity of the analysis that traders must undertake. To put

25 What is important here is not the vertex in Figure 1 starts off with, but the direction around the triangle that
one takes. Thus, the cycles 𝑌 → 𝑍 → 𝑋 → 𝑌 and 𝑋 → 𝑌 → 𝑍 → 𝑋 also yield arbitrage profits in this instance.
26 It is straightforward to see that if the reverse inequality were to hold, the trader could make risk-free profits

by cycling tokens in the reverse direction: 𝑍 → 𝑌 → 𝑋 → 𝑍.


27 That there are ‘enough’ traders is not an innocuous statement. Essentially, the market has to be deep enough

that the demand-supply forces are set about rapidly in place; otherwise, arbitrage profits may persist for
significant periods of time.

17

Electronic copy available at: [Link]


this slightly differently, there exists only one price for exchanging between 𝑌 and 𝑍 a trader
can obtain in CPMM-v1, which is automatically determined by the AMM using equation (7).
In CPMM-v2, there are two prices that are available to a trader: 𝑃𝑌/𝑍 , that comes about by
trading in the 𝑌 − 𝑍 pool, and 𝑃𝑌/𝑋 × 𝑃𝑋/𝑍 , that can be obtained by performing the sequence
𝑍 → 𝑋 → 𝑌; the two are necessarily equal only at equilibrium. If there is disequilibrium, the
trader can make arbitrage profits by buying through the method that is cheaper and selling
through other method. Thus, when 𝑃𝑌/𝑍 < 𝑃𝑌/𝑋 × 𝑃𝑋/𝑍 , the trader can buy 𝑍 through the
𝑌 − 𝑍 pool and sell it through the sequence 𝑍 → 𝑋 → 𝑌 to make a profit.
Adding a transaction fee rate, 𝜏, does not alter the fundamental nature of the process; it
does make the calculations more cumbersome though, as a bid-ask spread has to be factored
in at each step. To see the implications of this, consider CPMM-v2. The 𝑌 − 𝑍 pool has a bid-
𝑎 𝑏
ask spread 𝑝𝑌/𝑍 − 𝑝𝑌/𝑍 , and the trader can directly buy 𝑍 at the ask-price and sell it at the
bid-price. However, the trader also has the alternative option of performing the sequence
𝑍 → 𝑋 → 𝑌 to sell 𝑍 and buy 𝑌, and the sequence 𝑌 → 𝑋 → 𝑍 to sell 𝑌 and buy 𝑍. This
alternative method requires two transaction fees: for the sequence 𝑍 → 𝑋 → 𝑌, the first step
𝑍 → 𝑋 involves a fee 𝜏 paid in units of 𝑍, the token being added to the 𝑋 − 𝑍 liquidity pool.
The second step 𝑋 → 𝑌 involves another transaction fee, 𝜏, which is paid in units of 𝑋, the
token being added to the 𝑋 − 𝑌 liquidity pool. Consequently, the first step involves the trader
𝑏 𝑏
selling 𝑍 at the bid-rate of 𝑝𝑋/𝑍 , while the second involves selling 𝑋 at the bid-rate 𝑝𝑌/𝑋 . This
𝑏 𝑏
implies that the cross-rate associated with the sequence 𝑍 → 𝑋 → 𝑌 is 𝑝𝑌/𝑋 × 𝑝𝑋/𝑍 . Similarly,
𝑎 𝑎
the cross-rate associated with the sequence 𝑌 → 𝑋 → 𝑍 is 𝑝𝑌/𝑋 × 𝑝𝑋/𝑍 . From this, one can
derive the no-arbitrage conditions:

𝑎 𝑏 𝑏 𝑎 𝑎 𝑏
(8) 𝑝𝑌/𝑍 ≥ 𝑝𝑌/𝑋 × 𝑝𝑋/𝑍 and 𝑝𝑌/𝑋 × 𝑝𝑋/𝑍 ≥ 𝑝𝑌/𝑍

Equation (8) essentially states that it is never profitable to buy 𝑍 through one method
available to the trader and sell it through the other. 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. It is trivial to see that no such arbitrage possibility can exist in CPMM-
𝑎 𝑎 𝑏 𝑏
v1, since the trader has only the bid-ask spread 𝑝𝑌/𝑋 × 𝑝𝑋/𝑍 − 𝑝𝑌/𝑋 × 𝑝𝑋/𝑍 to work with.

18

Electronic copy available at: [Link]


2.3 Liquidity provision and fees in a CPMM: Uniswap-v1 and v2
It is worth introducing at this stage how liquidity is added in Uniswap-v1 and v2. Any
liquidity provider on Uniswap-v1 and v2 simultaneously adds both tokens in a liquidity pool.
This is a desirable feature that ensures that prices do not fluctuate due to liquidity provision.
To begin with, suppose the price of 𝑋 in terms of 𝑌 (when there is no transaction fee) is 𝑃𝑌/𝑋 =
𝑦
, where 𝑥 and 𝑦 are the reserves of 𝑋 and 𝑌, respectively. Consider a situation where an
𝑥
agent wished to add liquidity to the 𝑋 − 𝑌 pool, and did so by only adding a certain amount
′ 𝑦′ 𝑦
of 𝑋, equal to ∆𝑥. This would result in a price of 𝑃𝑌/𝑋 = 𝑥 ′ = 𝑥+∆𝑥 < 𝑃𝑌/𝑋 . This implies that
adding a significant amount of 𝑋 to the pool by liquidity providers would depress the price of
𝑋, which is undesirable; ideally, we would like the price to change because of trading activity
and not due to the act of providing liquidity. To prevent a price change from occurring, we
would require 𝑦 ′ = 𝑥 ′ × 𝑃𝑌/𝑋 . If ∆𝑦 is the amount of 𝑌 that needs to be added to make this
∆𝑦 𝑦
condition hold, some algebraic manipulation then yields the fact that we would need ∆𝑥 = 𝑥 ;
that is, the two tokens have to be added in the same proportion as the existing reserves so as
to not cause a price change.28 Consequently, if one were to, for example, double the amount
of 𝑋 in the pool, one would also have to double the amount of 𝑌 in the pool to ensure that
the price does not change. For infinitesimally small changes, this can be rewritten as
𝑑𝑦 𝑑𝑥
differentials, = , which implies that the percentage change in the two tokens is the same.
𝑦 𝑥

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. On Uniswap-v1 and v2, these tokens
are themselves tradeable as fungible ERC-20 tokens, so that liquidity providers can sell tokens
to others without affecting the overall amount of tokens in a pool.
Fees are the main reward that liquidity providers earn on an AMM. However, as mentioned
earlier, liquidity providers are the counterparty to all arbitrage activities that are supported
by the AMM. Intuitively, suppose we start with the no-arbitrage condition (4) where 𝑃𝑌/𝑋 =
𝑀𝑌/𝑋 and the price in the CPMM is aligned with the external reference market. Now, if 𝑀𝑌/𝑋

increases in the reference market to 𝑀𝑌/𝑋 , then arbitrageurs can profit by buying 𝑋 in the

CPMM and selling it in the external market for a profit (measured in units of 𝑌 ) of 𝑀𝑌/𝑋 −
𝑃𝑌/𝑋 for every unit of 𝑋 bought and sold this way. The liquidity providers are, of course, selling

the 𝑋 to the arbitrageurs at 𝑃𝑌/𝑋 ; relative to the external market price their payoff is 𝑀𝑌/𝑋 −
𝑃𝑌/𝑋 < 0. As prices change in the CPMM due to the arbitrage activity, eventually the no-

𝑦
28Specifically, (𝑦 + ∆𝑦) = (𝑥 + ∆𝑥) × 𝑃𝑌/𝑋 , which implies (𝑦 + ∆𝑦) = (𝑥 + ∆𝑥) × 𝑥 , which in turn implies that
(𝑦 + ∆𝑦)𝑥 = (𝑥 + ∆𝑥)𝑦. Simplifying yields the desired result.

19

Electronic copy available at: [Link]


arbitrage condition is restored. This negative payoff received by a liquidity provider due to
arbitrage activity is often termed as an impermanent loss in the DeFi community.
There are a couple of points worth noting here. First, liquidity providers have negative
payoffs from arbitrage activity, no matter what the direction of changes. Thus, in the previous
example, liquidity providers again experience a negative payoff if the external market price
moves in the opposite direction, which reverses the direction of arbitrage activity. Intuitively,
arbitrage is a zero-sum game; by virtue of being the counterparty to all trading on the AMM,
liquidity providers always lose in the zero-sum game with arbitrageurs. Second, the possibility
of arbitrage is lowered with trading fees, which causes the no-arbitrage condition to be
transformed to (5), thereby providing a range over which movements in the external price
will not trigger arbitrage activity. Moreover, this range widens as the fees rise. Overall, trading
fees favor liquidity providers in two ways: first they provide a return for parking funds in the
AMM, which comes at the expense of traders; second, they lower the likelihood of arbitrage,
which reduces the cost of liquidity provision.
The design of AMM fees must, therefore, balance the interests of liquidity providers,
traders and arbitrageurs. If the trading fee is raised higher, it benefits liquidity providers, but
discourages trading and arbitrage (and the prices on the AMM may diverge significantly from
the external market), making it unattractive as a decentralized exchange. On the other hand,
if it is kept too low, liquidity provision becomes unattractive as returns are low and
arbitrageurs constantly drain providers’ payoffs. Designing the ‘right’ fees, consequently, can
be important for the success or failure of an AMM.

2.4 Proposed changes in Uniswap-v3


The Unswap-v3 whitepaper proposes three important changes to the v1 and v2 description
above, which we summarize briefly here.
First, in the Uniswap-v1 and v2 protocols, liquidity providers have no control over the price
at which the tokens they provide will be traded; implicitly, their tokens are pooled together
with the tokens of other liquidity providers and can be traded anywhere along the exchange
function. In contrast, Uniswap-v3 suggests implementing concentrated liquidity, where a
liquidity provider can specify a price range, [𝑃, 𝑃], within which to add liquidity. The main
purpose of this change is to improve capital efficiency. We take a closer look at the concept
of concentrated liquidity in Section 4.5.
One of the main implications of introducing concentrated liquidity is that each user’s
liquidity position is unique. Intuitively, in Uniswap-v1 and v2, liquidity provision was
characterized only by the amount ∆𝑥 added to the pool (the condition that tokens are
provided in equal value automatically determines ∆𝑦, as shown in Section 2.3); consequently,
fungible liquidity tokens are capable of tracking liquidity contributions by providers. In
Uniswap-v3, however, liquidity provision is characterized by ∆𝑥 and by a price range [𝑃, 𝑃]

20

Electronic copy available at: [Link]


specified by the provider, and the latter distinguishes the contribution of one provider from
another who also adds ∆𝑥 but species a different price range. As a result, the second major
change to the previous discussion is that v3 protocol uses non-fungible tokens to track
liquidity.
The third change occurs to trading fees and how these fees are distributed to liquidity
providers. In Uniswap-v1 and v2, all pools have a uniform trading fee of .3% and these were
automatically added to the liquidity pool causing 𝑘 to expand over time from fees alone. In
v3, multiple pools can exist for the same token pair with varying fees, with .05%, .3% or 1%
being the initial fee tiers (with the capability to add more tiers). Moreover, fees are no longer
added to the liquidity pool, and are stored separately in the tokens they are paid with by a
trader. In many ways, the addition of fee tiers is an alternative strategy to ex ante designing
an ‘optimal’ fee for the AMM; liquidity providers can select their preferred fees for any pair
of tokens and the market can converge towards a trading fee for the token pair. One would
expect that, over time, this will also be conditioned by the extent of competition that exists
between AMMs providing similar services.

3. The geometry of a CPMM


In this section, we present a black-box view of a CPMM. The benefit of doing so is that
many of the features described in Section 2 can be visualized geometrically. Moreover, this
paves the way towards a unified framework for examining other types of AMMs used as DEXs,
a task that we undertake in Section 4.

3.1 Preliminaries: homogenous and homothetic functions


The function 𝑥𝑦 = 𝑘 used in a CPMM is an example of a class of functions referred to as
homogenous functions, which we define formally below.

Homogenous functions: A function 𝑓(𝑥1 , 𝑥2 , … , 𝑥𝑛 ) is defined to be homogenous of degree


𝑟 when the following condition is satisfied:
𝑓 (𝜆𝑥1 , 𝜆𝑥2, … , 𝜆𝑥𝑛 ) = 𝜆𝑟 𝑓(𝑥1 , 𝑥2, … , 𝑥𝑛 )

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

21

Electronic copy available at: [Link]


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, 𝑘. Subsequently, in
Section 3.4, we will provide some intuition on the economic interpretation of 𝑘.
Geometrically, the exchange function 𝑥𝑦 = 𝑘 generates level or contour curves that are
rectangular hyperbolas in a two-dimensional graph, as shown in Figure 2 below. A level curve
shows, in the 𝑥 − 𝑦 plane, various combinations of 𝑥 and 𝑦 that yield a specific value of 𝑘.
Figure 2 shows two level curves; the first shows all the combinations of 𝑥 and 𝑦 that yield a
specific value of 𝑘 0 for 𝑘; the second shows all the combination of 𝑥 and 𝑦 that yield a value
of 𝑘1 . Since 𝑘 can take any value (greater than zero), there are an infinite such level curves
that can be drawn, each corresponding to a particular value of 𝑘. In economics, the
corresponding level curves in the context of consumption are indifference curves, and in the
context of production are isoquants. Subsequently, in Section 3.4, we will argue that the level
curves of the exchange function can best be thought of as ‘isoliquidity’ curves.

𝑅
𝑐

𝑦𝐶 𝐶
𝑎
𝑐
𝐴 𝐴
𝑦

𝑘1
𝑎 𝐵
𝑦𝐵

𝑘0
𝑥
𝑂 𝑥𝐴 𝑥𝐶 𝑥𝐵

Figure 2: The 𝒙𝒚 = 𝒌 function

22

Electronic copy available at: [Link]


In general, suppose we allow 𝑥 and 𝑦 to change. Taking the total derivative of 𝑥𝑦 = 𝑘, we
𝜕𝑓 𝜕𝑓
get 𝑑𝑥 + 𝜕𝑦 𝑑𝑦 = 𝑑𝑘, which implies that 𝑦𝑑𝑥 + 𝑥𝑑𝑦 = 𝑑𝑘. Along any particular level
𝜕𝑥

curve, however, 𝑑𝑘 = 0, and so:

𝑑𝑦 𝑦
(9) = −𝑥
𝑑𝑥

The intuition behind equation (9) is as follows. Suppose we consider a particular point, say
point 𝐴 in Figure 2, which has pool reserves of 𝑥 𝐴 and 𝑦 𝐴 . Starting from point 𝐴, if 𝑥 changes
infinitesimally, 𝑦 has to change by a certain amount so that 𝑥𝑦 = 𝑘 0 continues to hold if we
wish to remain on the level curve 𝑘 = 𝑘 0 . The left-hand side of equation (9) is the slope of
the curve at 𝐴, which corresponds to the slope of the line 𝑎𝑎 in Figure 2. This slope is negative
due the fact that if 𝑥 increases, 𝑦 must decrease in order for the value of 𝑘 not to change. The
right-hand side of equation (9) is the slope of the ray 𝑂𝐴 connecting 𝐴 to the origin 𝑂. So,
equation (9) then states that if 𝑥 and 𝑦 change along curve 𝑘 0 , the slope of the tangent at 𝐴
𝑑𝑦 𝐴 𝑦𝐴
exactly equals the negative of the slope of the line 𝑂𝐴; that is: 𝑑𝑥 | = − 𝑥 𝐴. Similarly, at point
𝑑𝑦 𝐵 𝑦𝐵
𝐵 we have that 𝑑𝑥 | = − 𝑥 𝐵 , and it is evident that the absolute value of the slope is lower at
point 𝐵 compared to point 𝐴.
One of the features of a homogenous function is that the slope along a given ray remains
unchanged as we move from one level curve to another. While we do not provide a formal
proof of this here for a general homogenous function, it can be shown for our context in a
straightforward manner using Figure 2. 29 Specifically, since points 𝐴 and 𝐶 both lie on the ray
𝑦𝐴 𝑦𝐶
𝑂𝑅, the slope of 𝑂𝐴 is equal to the slope of 𝑂𝐶; that is, 𝑥 𝐴 = 𝑥 𝐶. From (9) it then follows that
𝑑𝑦 𝐴 𝑑𝑦 𝐶
| = 𝑑𝑥 | , and the slopes are equal at 𝐴 and 𝐶. In fact, this property of slopes of level
𝑑𝑥
curves being invariant along a ray from the origin is termed homotheticity and is true of a
broader class of functions: homothetic functions.

Homothetic functions: If 𝑘 = 𝑓(𝑥1, 𝑥2 , … , 𝑥𝑛 ) is a homogenous function of any degree 𝑟, a


𝜕ℎ
homothetic function is a composite function 𝐻 = ℎ(𝑘) = ℎ(𝑓(𝑥1, 𝑥2 , … , 𝑥𝑛 )), such that ≠
𝜕𝑘
0 for any 𝑘.

A homothetic function is, essentially, a monotonic transformation of a homogenous function.


While the transformation can, in general, be positive or negative, it is useful to focus on the

29The proof is standard in any text on introductory mathematical economics – see, for example, Silberberg
(1990).

23

Electronic copy available at: [Link]


𝜕ℎ
positive transformation where 𝜕𝑘 > 0, because this has the desirable property that a higher
𝑘 is associated with a higher 𝐻.
Though a homothetic function transforms a homogenous function, it is itself not
necessarily homogenous. The classic example of this is a log transformation. If we start with
𝑘 = 𝑥𝑦 (which is homogeneous of degree 2), 𝐻(𝑥, 𝑦) = log(𝑘) = log( 𝑥𝑦) is a homothetic
𝜕 log 𝑘
function since > 0. However, 𝐻 is not a homogenous function, because log(λ 𝑥 ×
𝜕𝑘
𝜆𝑦) ≠ 𝜆2 log(𝑥𝑦). Nevertheless, 𝐻 inherits the homotheticity property from the
homogenous function that is transformed. This is because at any arbitrary point the level
curves of 𝐻(∙) function have exactly the same slope as the corresponding level curve of 𝑓(∙)
through that point. For example, consider the two-independent variable case, where 𝑘 =
𝑓(𝑥, 𝑦) is homogenous of degree 𝑟, and 𝐻(𝑥, 𝑦) = ℎ(𝑘) = ℎ(𝑓(𝑥, 𝑦)). The slope of the level
𝑑𝑦 𝜕𝐻⁄𝜕𝑥
curve of 𝐻(∙) at any point is | = − 𝜕𝐻⁄𝜕𝑦, while the slope of the level curve of the 𝑓(∙)
𝑑𝑥 𝐻
𝑑𝑦 𝜕𝑓⁄𝜕𝑥
function through that point is 𝑑𝑥 | = − 𝜕𝑓⁄𝜕𝑦 . To show that the slopes of the two level curves
𝑓
are the same, we have that:

𝑑𝑦 𝜕𝐻⁄𝜕𝑥 𝜕ℎ⁄𝜕𝑘 𝜕𝑓⁄𝜕𝑥 𝜕𝑓⁄𝜕𝑥 𝑑𝑦


(10) | = − 𝜕𝐻⁄𝜕𝑦 = − 𝜕ℎ⁄𝜕𝑘 𝜕𝑓⁄𝜕𝑦 = − 𝜕𝑓⁄𝜕𝑦 = 𝑑𝑥 |
𝑑𝑥 𝐻 𝑓

The homotheticity property is a useful one because it tells us what happens to level curves if
we start with a CPMM with an exchange function 𝑥𝑦 = 𝑘 and transform it monotonically, an
issue we return to in the next section.
Another handy property of homogenous functions is Euler’s theorem, which is stated
below.30

Euler’s Theorem: Suppose 𝑘 = 𝑓(𝑥1 , 𝑥2, … , 𝑥𝑛 ) is a homogenous function of degree 𝑟. Then:


𝜕𝑓 𝜕𝑓 𝜕𝑓
𝑥1 + 𝜕𝑥 𝑥2 + ⋯ . 𝜕𝑥 𝑥𝑛 = 𝑟𝑘
𝜕𝑥1 2 𝑛

We will find this theorem useful in the next section for valuing a liquidity pool.

3.2 Arbitrage and price determination in a CPMM


We are now in a position to provide a simple graphical representation of much our
discussion on arbitrage and price determination. As before, we begin with the situation where
there are no transaction fees, and 𝜏 = 0. Our goal is to represent equation (1) geometrically,

30 The interested reader is referred to Silberberg (1990) or Chiang (1984) for a proof, and more in-depth
treatment of the usefulness of Euler’s theorem in microeconomics.

24

Electronic copy available at: [Link]


and link this to the idea of two-point arbitrage. In order to do this, we can contextualize Figure
2 as the exchange function of a CPMM.
The price of 𝑋 in terms of 𝑌, 𝑃𝑌/𝑋 , is the amount of 𝑌 that can be traded for 1 unit of 𝑋 on
𝑑𝑦
the CPMM; graphically, this translates to the absolute value of the slope (− 𝑑𝑥 ) of the function
𝑘 = 𝑥𝑦. For any combination of reserves (𝑥, 𝑦), from equation (9) we have that for a given
𝑑𝑦 𝑦
point, 𝑃𝑌/𝑋 = − 𝑑𝑥 = 𝑥 , which is essentially equation (1). So, for example, consider point 𝐴 in
Figure 2 above, which corresponds to liquidity pool reserves (𝑥 𝐴 , 𝑦 𝐴 ). 𝑃𝑌/𝑋 offered by the
CPMM can be read off the diagram in one of two equivalent ways: either as the absolute value
𝑑𝑦 𝐴 𝑦𝐴
of the slope of the tangent 𝑎𝑎 at 𝐴 (− 𝑑𝑥 | ), or as the slope of the ray 𝑂𝐴 (𝑥 𝐴 ).31
As mentioned in Section 1, our view here is that an AMM is a black-box for converting
𝑦
inputs (token quantities) into outputs (prices). The equation 𝑃𝑌/𝑋 = links the inputs in our
𝑥
black-box (𝑥 and 𝑦) to the output (𝑃𝑌/𝑋 ) using the exchange function 𝑘 = 𝑥𝑦. Graphically, the
output of the AMM is the slope of a level curve of the exchange function.32
There are a couple of other issues about price determination in a CPMM that are worth
noting. First, the exchange function 𝑘 = 𝑥𝑦 is homogenous of degree 2 and the slopes of level
curves are the same along a ray from the origin. Since 𝑃𝑌/𝑋 is equal to the absolute value of
the slope, it follows that all points (reserve pairs) on a specific ray from the origin will entail
the same price. Thus, returning to Figure 2, 𝑃𝑌/𝑋 is exactly the same at points 𝐴 (where 𝑘 =
𝑘 0 ) and 𝐶 (where 𝑘 = 𝑘1 ), and indeed at every point along the ray 𝑂𝑅, each of which falls on
a different level curve. From the point of view of price determination in a CPMM, the
magnitude of 𝑘 is immaterial; all that matters is which ray from the origin a particular reserve
pair (𝑥, 𝑦) falls on. Secondly, the price of a token can never fall to zero in a CPMM. When the
amount of a token, say 𝑥, approaches zero, the slope of the level curve tends to infinity, and
the token’s price tends to infinity. Consequently, the amount of reserves of a token can never
fall to zero due to trading activity and the level curves never intercept the axes. The fact that
a CPMM can never be drained of one reserve due to trading is important for its stability.33
Figure 2 also describes what happens if liquidity providers were to add tokens to the pool.
Starting from reserves (𝑥 𝐴 , 𝑦 𝐴 ), suppose liquidity providers add reserves in the same
∆𝑦 𝑦𝐴
proportion as the initial reserves, so that = . In fact, in Section 2.3, we saw that this is a
∆𝑥 𝑥𝐴
requirement in CPMMs such as Uniswap-v1 and v2, and is required to ensure that prices do
not change due to liquidity provision. We are now in a position to translate this

31 𝑑𝑥 𝑥
It is evident that the price of 𝑦 in terms of 𝑥 is 𝑃𝑥/𝑦 = − = .
𝑑𝑦 𝑦
32 To draw a parallel with consumer theory in economics, the price here corresponds to the marginal rate of
substitution, and in production theory, to the marginal rate of technical substitution.
33 Reserves can, of course, fall to zero if liquidity providers decide to withdraw their tokens.

25

Electronic copy available at: [Link]


diagrammatically. Adding liquidity in the same proportion implies that new reserves, (𝑥 𝐶 , 𝑦 𝐶 )
𝑦𝐶 𝑦𝐴
satisfy = 𝑥 𝐴; in other words, we move along ray 𝑂𝑅. But as we have seen, for a
𝑥𝐶
homogeneous function this implies that the slopes at 𝐴 and 𝐶 are the same which, in turn,
implies that prices are the same at the two points. Liquidity provision conducted in this
manner changes the level curve from 𝑘 0 to 𝑘1 without changing the price.
Now, consider the process of two-point arbitrage. Suppose the price of 𝑋 in the external
market is 𝑀𝑌/𝑋 , where 𝑀𝑌/𝑋 > 𝑃𝑌/𝑋 . This reference market price is shown in Figure 3 by the
point 𝑀, where the absolute value of the slope of the tangent 𝑚𝑚 equals to the reference
𝑑𝑦 𝑀
market price. If the reserve levels in the CPMM is at point 𝐴, we have that 𝑀𝑌/𝑋 = − 𝑑𝑥 | >
𝑑𝑦 𝐴
− 𝑑𝑥 | = 𝑃𝑌/𝑋 .34 This price differential triggers two-point arbitrage with arbitrageurs buying
𝑋 from the CPMM and selling it in the reference market. The arbitrage-driven buying activity
in the CPMM increases 𝑃𝑌/𝑋 (while the selling in the reference market can decrease 𝑀𝑌/𝑋 ),
and the price in the CPMM will approach 𝑀, as shown by the arrow in Figure 3.

𝑀
𝑦𝑀

𝑚 𝐴
𝐴 𝑎
𝑦
𝑎
𝑘0
𝑥
𝑂 𝑥𝑀 𝑥𝐴
Figure 3: Price and arbitrage in a CPMM
with no transaction fees

34 Equivalently, the slope of the ray 𝑂𝑀 is greater than the slope of the ray 𝑂𝐴.

26

Electronic copy available at: [Link]


This process continues till the no-arbitrage condition in equation (4) is met and 𝑀𝑌/𝑋 =
𝑃𝑌/𝑋 , which can occur anywhere between points 𝐴 and 𝑀. In the extreme case where the
reference market is large, the sale of 𝑋 in the reference market may have little impact on
𝑀𝑌/𝑋 ; in that case, 𝑃𝑌/𝑋 will settle at point 𝑀, with reserves (𝑥 𝑀 , 𝑦 𝑀 ). It is straightforward to
construct the reverse argument if 𝑀𝑌/𝑋 < 𝑃𝑌/𝑋 , and the starting point is point 𝐵 in Figure 3.
Now consider the case when there is a trading fee, 𝜏. Our focus is to show diagrammatically
how arbitrage possibilities are curtailed due to the presence of the fee, as described by
equation (5). In order to do this, we follow the analytical procedure described in Angeris et al
(2019) to derive the bounds of arbitrage. Suppose we start with a certain amount of reserves
of the two tokens, (𝑥 0 , 𝑦 0 ), which implies that 𝑘 0 = 𝑥 0 𝑦 0 is the starting value for 𝑘. In the
𝑦0
absence of transaction fees, the price would be 𝑃𝑌/𝑋 = , irrespective of whether a trader
𝑥0
wished to buy or sell 𝑋. The first task, then, is to derive how this price changes with a fee in
place. The two-step process followed by Uniswap-v1 and v2 is described in detail in Section
2.1; we replicate that process now analytically, assuming that it holds for any arbitrary CPMM-
v1 or v2.35
To begin with, suppose a trader wishes to sell 𝑋 to the CPMM in exchange for 𝑌; the trader
𝑏
will be able to do this at a bid-price 𝑝𝑌/𝑋 . If the trader sells an amount ∆𝑥, the AMM retains
𝜏∆𝑥, and the remainder (1 − 𝜏)∆𝑥 = 𝜙∆𝑥 is available for the trade, which occurs utilizing the
initial value of the constant, 𝑘 0 . If the trader receives ∆𝑦 in return, we have that:

(11) (𝑥 0 + 𝜙∆𝑥 )(𝑦 0 + Δ𝑦) = 𝑘 0

Since the liquidity pool receives 𝑋, we have that ∆𝑥 > 0, from which it follows that ∆𝑦 < 0
∆𝑦
(the pool gives 𝑌 to the trader). Opening the brackets and simplifying, we get that =
∆𝑥
𝜙𝑦 0
− . When changes are infinitesimal:
𝑥 0 +𝜙∆𝑥

𝑑𝑦 ∆𝑦 𝑦0
(12) 𝑑𝑥
= lim = −𝜙 𝑥 0
∆𝑥→0 ∆𝑥

𝑏 𝑑𝑦
As 𝑝𝑌/𝑋 = − 𝑑𝑥 , we get the bid-price as:

𝑏 𝑦0
(13) 𝑝𝑌/𝑋 = 𝜙 𝑥0

35Other CPMMs may adopt different procedures. However, any departure from the Uniswap paradigm should
not pose any significant challenges analytically. Moreover, the broad ideas that follow from homotheticity and
so on described in this paper will not change due to small procedural changes.

27

Electronic copy available at: [Link]


Similar arguments when the trader buys 𝑋 from the CPMM (so that (𝑥 0 + ∆𝑥)(𝑦 0 + 𝜙Δ𝑦) =
𝑘 0 , with Δ𝑦 > 0) yielding an ask-price of:

𝑎 1 𝑦0
(14) 𝑝𝑌/𝑋 = 𝜙 𝑥0

𝑦0
Given that the price without a trading fee, 𝑃𝑋/𝑌 = 𝑥 0, and that 𝜙 < 1, it is evident that a
trading fee lowers the price at which a trader can sell 𝑋 to the CPMM and raises the price at
𝑏 𝑎
which the trader can buy 𝑋 from the CPMM; that is, 𝑝𝑌/𝑋 < 𝑃𝑌/𝑋 < 𝑝𝑌/𝑋 .
Figure 4 below shows the bid and offer rate graphically. The original reserves are depicted
𝑦0
at point 𝑃, and the slope of ray 𝑂𝑃 is 𝑥 0 = 𝑃𝑋/𝑌 , the price with no transaction fees. This point
lies on the level curve 𝑘 0 , the original value of the CPMM constant. The slope of the ray 𝑂𝐵
𝑦0 𝑏
is 𝜙 𝑥 0 = 𝑝𝑌/𝑋 ; we can visually associate point 𝐵, therefore, with the bid-price. Similarly, the
1 𝑦0 𝑎
slope of 𝑂𝐴 is 𝜙 𝑥 0 = 𝑝𝑌/𝑋 and point 𝐴 is in that sense associated with the ask-price.

𝑀′′

𝑃
𝑦0
𝑀
𝐵
𝑀′ 𝑘1

𝑘0
𝑥
𝑂 𝑥0

Figure 4: Price and arbitrage in a CPMM


with transaction fees

28

Electronic copy available at: [Link]


To bring in the idea of arbitrage in Figure 4, suppose the reference market price is 𝑀𝑌/𝑋 .
This is represented by a point 𝑀, which (uniquely on level curve 𝑘 0 ) satisfies the condition
that the slope of 𝑂𝑀 = 𝑀𝑌/𝑋 . In this particular instance, 𝑀 lies in the arc between the two
points 𝐴 and 𝐵. As the slope of 𝑂𝑀 is greater than that of 𝑂𝐵, but less than that of 𝑂𝐴, we
𝑏 𝑎
must have that 𝑝𝑌/𝑋 ≤ 𝑀𝑌/𝑋 ≤ 𝑝𝑌/𝑋 is true at point 𝑀. This is, of course, nothing but the no-
arbitrage condition in equation (5). When the market price is 𝑀𝑌/𝑋 , therefore, it is not
profitable for an arbitrageur to buy 𝑋 in the reference market and sell in the CPMM because
𝑏
𝑝𝑌/𝑋 < 𝑀𝑌/𝑋 . Similarly, no profits are to be had by trading in the reverse direction because
𝑎
𝑀𝑌/𝑋 < 𝑝𝑌/𝑋 . It is evident that this logic holds 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
𝑏
this range widens (and the arc 𝐴𝐵 becomes longer) the greater the value 𝜏 takes, since 𝑝𝑌/𝑋 =
𝑦0 𝑎 1 𝑦0
𝜙 𝑥 0 and 𝑝𝑌/𝑋 = 𝜙 𝑥 0. This goes back to the point made earlier: larger transaction costs curtail
arbitrage.
If we consider a point outside arc 𝐴𝐵, such as point 𝑀′ , which represents a situation
𝑏
where 𝑝𝑌/𝑋 > 𝑀𝑌/𝑋 , then arbitrageurs can buy 𝑋 in the reference market and sell it in the
CPMM to make profits. This sale of 𝑋 to the CPMM will drive 𝑃 to the right, and the arc 𝐴𝐵
𝑏
along with it, till 𝑝𝑌/𝑋 = 𝑀𝑌/𝑋 . Similar arguments in the reverse direction hold if the reference
market price is represented by 𝑀′′ .
The second step of the exchange process in Uniswap-v1 and v2 is that the fees are added
to generate a new value of 𝑘 that satisfies 𝑘1 = (𝑥 0 + ∆𝑥)(𝑦 0 + Δ𝑦) = 𝑥 1 𝑦 1. In the case
where 𝑋 is sold to the CPMM, for example, 𝜏∆𝑥 is added to the pool reserves, which causes
a rightward shift of the level curve to 𝑘1 . The starting point for the next trade is then the
𝑦1
reserve pair (𝑥 1 , 𝑦 1 ) on 𝑘1 , which has a no-transaction fee price of 𝑃𝑋/𝑌 = 𝑥 1 and a
corresponding bid-ask spread as derived earlier.

3.3 Valuing a liquidity pool and a CPMM: Uniswap-v1 and v2


Consider a specific liquidity pool with tokens 𝑋 and 𝑌 in CPMM-v1 or v2. If the amount of
reserves in the pool are (𝑥, 𝑦), there are circumstances where one may wish to value the
liquidity pool. Since 𝑥 and 𝑦 are denominated in different tokens, they have to be brought to
the same unit of account before their values can be added. Given that ETH is likely to be the
settlement token when a CPMM operates on the Ethereum network, including Uniswap, let
us suppose again that 𝑋 is ETH. One way to value the liquidity pool is then 𝑉𝑋,𝑌 = 𝑥 + 𝑃𝑋/𝑌 𝑦.36
𝑥
This converts 𝑌 to an equivalent amount of 𝑋 using 𝑃𝑋/𝑌 = 𝑦, the price of 𝑌 in terms of 𝑋
(ETH) when there are no transaction fees. This is, of course, not a unique way of valuing the

36 See also Angeris et al (2019) and Angeris and Chitra (2020), who address the issue of pool valuation.

29

Electronic copy available at: [Link]


pool. With transaction fees and a bid-ask spread one may, for example, wish to use the mid-
𝑎 𝑏
𝑝𝑋/𝑌 +𝑝𝑋/𝑌 (1+𝜙 2 ) 𝑥
rate 𝑝̃𝑋/𝑌 = = (from equations (13), (14) and (3)) to value the pool.
2 2𝜙 𝑦

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.
𝑥
Suppose we work with 𝑉𝑋,𝑌 = 𝑥 + 𝑃𝑋/𝑌 𝑦. Substituting 𝑃𝑋/𝑌 = 𝑦, it follows that:

(15) 𝑉𝑋,𝑌 = 2𝑥

Equation (15) 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 (15) 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 5 below.

𝐶
𝐷

𝐸 𝐵

𝑘2
𝐴
𝑘1

𝑘0

𝑥
𝑂 𝑥0

Figure 5: Liquidity pool valuation

30

Electronic copy available at: [Link]


In Figure 5, 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 𝑋.
The fact that pool valuation depends on neither the price nor the value of 𝑘 is maintained
if 𝑝̃𝑋/𝑌 is used to value the pool instead of 𝑃𝑋/𝑌 . In that case:

(1+𝜙) 2
(16) 𝑉̃𝑋,𝑌 = 𝑥 + 𝑝̃𝑋/𝑌 𝑦 = 2𝜙 𝑥

In the extreme case where there are no transaction fees, 𝜙 = 1 and it is evident that 𝑉̃𝑋,𝑌 =
𝑑 (1+𝜙)2
𝑉𝑉,𝑌 . Moreover, as 𝑑𝜙 ( ) < 0, 𝑉̃𝑋,𝑌 falls as 𝜙 rises. Since 𝜙 = 1 − 𝜏, this implies that as
2𝜙
fees fall, the pool 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 (15) or (16) depends on
the perspective one takes. The valuation 𝑉𝑋,𝑌 is preferable if one looks at the liquidity pool as
a whole, without factoring the relative payoffs of traders and liquidity providers. On the other
hand, if the focus is on liquidity providers, then 𝑉̃𝑋,𝑌 is a candidate for pool valuation.
Equation (15) presents a stark independence result for pool valuation, so one may well
query whether this is true only for a CPMM that employs an exchange function 𝑘 = 𝑥𝑦, or if
it is true for a broader class of functions. So, suppose one considers 𝑘 = 𝑓(𝑥, 𝑦) = 𝑥 𝛼 𝑦 𝛽 ,
where 𝛼, 𝛽 > 0; the 𝑘 = 𝑥𝑦 function is simply a special case of this where 𝛼 = 1 and 𝛽 = 1.
From Euler’s theorem from Section 3.1 for this two-variable case, we have that:

𝜕𝑓⁄𝜕𝑦 𝑟𝑘
(17) 𝑥 + ( 𝜕𝑓⁄𝜕𝑥 ) 𝑦 = 𝜕𝑓⁄𝜕𝑥

𝜕𝑓⁄𝜕𝑦 𝑑𝑥 𝜕𝑓⁄𝜕𝑦
Since ( )=− , have that 𝑃𝑋/𝑌 = ( ).37 The left-hand side of equation (17) is,
𝜕𝑓⁄𝜕𝑥 𝑑𝑦 𝜕𝑓⁄𝜕𝑥
𝜕𝑓
therefore, nothing but 𝑉𝑋,𝑌 . For the right-hand side, using 𝑘 = 𝑥 𝛼 𝑦 𝛽 , 𝜕𝑥 = 𝛼𝑥 𝛼−1 𝑦 𝛽 , and 𝑟 =
(𝛼 + 𝛽), equation (17) reduces to:

𝛼+𝛽
(18) 𝑉𝑋,𝑌 = ( )𝑥
𝛼

Comparing (18) with (15), we see that the former collapses to the latter whenever 𝛼 = 𝛽. So,

37 𝛽𝑥
It is evident that 𝑃𝑋/𝑌 = 𝛼 𝑦.

31

Electronic copy available at: [Link]


doubling the amount of 𝑋 (ETH) in a liquidity pool to value a liquidity pool is a valid technique
for all CPMMs that attach equal weights to 𝑋 and 𝑌 in the constant product function, and is
not limited to the specific exchange function 𝑘 = 𝑥𝑦 used by Uniswap. More importantly, for
this general class of CPMMs, even when 𝛼 ≠ 𝛽, the pool valuation does not depend on prices
𝛼+𝛽
or on the value of 𝑘, only on 𝑥 and some constant factor ( ).38 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. 39 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. Suppose 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 (15), we have that each liquidity pool has a valuation 𝑉𝑋,𝑌𝑖 =
2𝑥𝑖 , ∀𝑖 ∈ {1,2,3, … 𝑛}. This allows a simple method to value the entire CPMM-v1:

(19) 𝑉𝐶𝑃𝑀𝑀−𝑣1 = ∑𝑛𝑖=1 𝑉𝑋,𝑌𝑖 = 2 ∑𝑛𝑖=1 𝑥𝑖

Equation (19) 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
that do not involve ETH. So apart from the 𝑛 original liquidity pools with reserves
{(𝑥1, 𝑦1 ), (𝑥1, 𝑦1 ) … (𝑥𝑛 , 𝑦𝑛 )} that were available in CPMM-v1, CPMM-v2 allows for an
𝑛(𝑛−1)
additional liquidity pools between tokens 𝑌𝑖 and 𝑌𝑗 , ∀𝑖, 𝑗 ∈ {1,2, … 𝑛}, 𝑖 ≠ 𝑗. In terms
2
of notation, let 𝑦𝑖𝑗 denote the quantity of 𝑌𝑖 in a 𝑌𝑖 − 𝑌𝑗 liquidity pool. In order to value a
liquidity pool with 𝑌𝑖 and 𝑌𝑗 as the tokens, we would first to pick a pricing token (say 𝑌𝑖 ); as
before, then, it follows from a parallel to equation (15) that 𝑉𝑌𝑖 ,𝑌𝑗 = 2𝑦𝑖𝑗 . However, this is
denominated in units of token 𝑌𝑖 ; to convert this to units of 𝑋 (ETH), so that there exists a
𝑥
common unit of account to value different pools, we can use the price 𝑃𝑋/𝑌𝑖 = 𝑖 , that is
𝑦𝑖

generated by the reserves (𝑥𝑖 , 𝑦𝑖 ) in the 𝑋 − 𝑌𝑖 liquidity pool. Thus, we get 𝑉𝑌′𝑖 ,𝑌𝑗 =
𝑥
𝑉𝑌𝑖 ,𝑌𝑗 × 𝑃𝑋/𝑌𝑖 = 2 𝑦𝑖 𝑦𝑖𝑗 , which is denominated in 𝑋.
𝑖

38 The alternative 𝑉̃𝑋,𝑌 also displays this feature of independence. Specifically, for 𝑘 = 𝑥 𝛼 𝑦 𝛽 , 𝑉̃𝑋,𝑌 = 𝑥 +
(1+𝜙2 ) 𝛽 (1+𝜙2 ) 𝛽
𝑝̃𝑋/𝑌 𝑦 = 𝑥 + 𝑥 = (1 + )𝑥.
2𝜙 𝛼 2𝜙 𝛼
39
Later on, in Section 4.1, we show that more generalized types of AMMs, such as a Constant Mean Market
Maker, also have a similar property of fixed shares of value.

32

Electronic copy available at: [Link]


Suppose we use an indicator 𝑑𝑖𝑗 = 1 if 𝑌𝑖 is used as the pricing token in the pool with 𝑌𝑗
and 𝑑𝑖𝑗 = 0 if 𝑌𝑖 is not used as the pricing token in the pool with 𝑌𝑗 . Since every liquidity pool
𝑛(𝑛−1)
𝑌𝑖 − 𝑌𝑗 has a unique valuing token in this procedure, it follows that ∑𝑛𝑖=1(∑𝑗≠𝑖 𝑑𝑖𝑗 ) = .
2
The total valuation of all pools 𝑌𝑖 − 𝑌𝑗 that uses 𝑌𝑖 as the pricing currency, but denominated
in units of 𝑋 is:

(20) 𝑉𝑌′𝑖 = 2𝑃𝑋/𝑌𝑖 ∑𝑗≠𝑖 𝑑𝑖𝑗 𝑦𝑖𝑗

The total value of the CPMM-v2 is then:

𝑥
(21) 𝑉𝐶𝑃𝑀𝑀−𝑣2 = ∑𝑛𝑖=1[2𝑃𝑋/𝑌𝑖 ∑𝑗≠𝑖 𝑑𝑖𝑗 𝑦𝑖𝑗 ] + 2 ∑𝑛𝑖=1 𝑥𝑖 , where 𝑃𝑋/𝑌𝑖 = 𝑦𝑖
𝑖

The second term in equation (21) corresponds to equation (19), and refers to the value of all
the liquidity pools which involve 𝑋 directly. The first term adds the values all the 𝑌𝑖 − 𝑌𝑗 pools
after denominating them in units of 𝑋.

3.4 Measuring liquidity in a CPMM


3.4.1 Interpreting 𝑘
If the valuation of a liquidity pool is independent of 𝑘, how exactly is one to interpret the
economic meaning of 𝑘 in the exchange function 𝑘 = 𝑓(𝑥1 , 𝑥2, … , 𝑥𝑛 )? As mentioned before,
in consumer theory, 𝑘 is interpreted as the level of utility, while in production theory, it is the
quantity of goods and services produced. In an AMM, the ‘output’ that we are interest in is
the price of one token in terms of the other, which is slope of the level curves of 𝑓(. ); this
corresponds to the marginal rate of substitution in consumer theory and to the marginal rate
of technical substitution in production theory. There is no direct economic significance of 𝑘
that can be derived when calculating these slopes.
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.
Geometrically, we can also associate a value of 𝑘 with a level curve generated by the
exchange function, as we have done in Figure 3. This affords the most satisfactory
interpretation that one can ascribe to 𝑘 - as an ordinal measure of liquidity, in much the same
way as utility serves as an ordinal measure of satisfaction in consumer theory. Viewed in this
way, we can think of the level curves of the exchange function as ‘isoliquidity’ curves.
Thus, if 𝑘1 > 𝑘 0 in a given liquidity pool, it is intuitive to infer that the liquidity level at 𝑘1
is higher than the liquidity level at 𝑘 0 because, starting at any point on 𝑘 0 , the injection of
tokens by liquidity providers will move the reserves to a higher level curve like 𝑘1 .

33

Electronic copy available at: [Link]


Importantly, this provides a valid way of comparing the liquidity levels provided by any two
arbitrary reserve token pairs (𝑥 0 , 𝑦 0 ) and (𝑥 1 , 𝑦 1 ) in a liquidity pool even if, say, 𝑥 0 < 𝑥 1 but
𝑦 0 > 𝑦 1; (𝑥 1 , 𝑦 1 ) can be said to provide a higher level of liquidity if 𝑥 1 𝑦 1 = 𝑘1 > 𝑘 0 = 𝑥 0 𝑦 0.
Like the concept of utility, the ranking of 𝑘 level curves is what is important, and this
ranking is preserved with any monotonic transformation of the exchange function. We have
already seen one implication of this: any monotonic transformation of a homogeneous
exchange function preserves prices due to the homotheticity property, and prices do not
depend on 𝑘. The number attached to an isoliquidity curve does not carry cardinal properties,
and algebraic operations such as taking the difference, 𝑘1 − 𝑘 0 , or adding, 𝑘1 + 𝑘 0 , does not
convey any economic information.
The nature of the concept of liquidity as defined here suggests that inter-pool comparisons
of 𝑘 are meaningless. So, if we have two liquidity pools with different tokens and calculate
that 𝑥 1 𝑦 1 = 𝑘1 > 𝑘 0 = 𝑥 0 𝑧 0, we cannot conclude that the 𝑋 − 𝑍 pool has a lower level of
liquidity than the 𝑋 − 𝑌 pool in any way. Essentially, the numbers 𝑘1 and 𝑘 0 are not
comparable in this case because their units of measurement are different.

3.4.2 Liquidity in a CPMM


While the parameter 𝑘 is an (ordinal) measure of liquidity in a pool, it has a few problems,
arising from the fact the function 𝑘 = 𝑥𝑦 is homogeneous of degree two. To see the
implications of this for using 𝑘 to measure liquidity, suppose one liquidity provider doubles
the amount of tokens in the pool. The new value of the invariant is 4𝑥𝑦 = 4𝑘; in other words,
𝑘 has quadrupled even though ‘liquidity’ has, for all practical purposes, only doubled due to
the doubling of token volume. This is particularly problematic in CPMM-v1 and CPMM-v2,
where fungible ERC-20 liquidity tokens are issued. If these tokens are issued one-to-one with
the value of 𝑘, by doubling the tokens the liquidity provider in this example would have
received 75% of the liquidity tokens in circulation, even though the provider has accounted
for only half the tokens.
In order to keep track of liquidity in general, and to keep track of liquidity tokens in
particular, a far better measure would involve using a function that is homogenous of degree
1 1
1. To that end, suppose we define 𝐿 = √𝑘 = 𝑥 2 𝑦 2. Now, if a liquidity provider, for example,
doubles both tokens, the value of 𝐿 also doubles. Indeed, we can generalize the benefits of
utilizing 𝐿 to measure liquidity even for small additions to the liquidity pool. As shown in
Section 2.3, in order for liquidity provision not to change price in CPMM-v1 and v2, the
𝑑𝑦 𝑑𝑥 𝑑𝐿 𝑑𝑥
condition = holds. It is readily seen that = also holds,40 implying that the
𝑦 𝑥 𝐿 𝑥
percentage change in 𝐿 equals the percentage change in either token. If 𝑋 is ETH, then CPMM-

1 1 𝑑𝐿 1 𝑑𝑥 1 𝑑𝑦 𝑑𝑦 𝑑𝑥 𝑑𝐿 𝑑𝑥
40 Taking log of 𝐿 = 𝑥 2 𝑦 2 and totally differentiating yields =2 +2 . Since = , it follows that = .
𝐿 𝑥 𝑦 𝑦 𝑥 𝐿 𝑥

34

Electronic copy available at: [Link]


𝑑𝑥
v1 and V2 can distribute new liquidity tokens based on changes in 𝐿; specifically, 𝑑𝐿 = ×𝐿
𝑥
∆𝑥
(or its discrete counterpart, ∆𝐿 = × 𝐿). Consequently, 𝐿 serves as a better measure of
𝑥
liquidity in CPMMs that distribute fungible liquidity tokens.41

4. Other types of AMMs for decentralized exchanges


In this section, we introduce other types of AMMs, with a focus again on decentralized
exchanges for converting one token to another. While these are not covered in nearly the
same detail as the CPMM, many of the techniques and insights from Sections 2 and 3 carry
over here, so that they can be extrapolated in a straightforward way.

4.1 Constant Mean Market Makers (CMMM)


The CPMM analyzed in sections 2 and 3 is a specific example of a more general AMM, the
constant mean market maker (CMMM) where the reserves (𝑥1 , 𝑥2, … 𝑥𝑛 ) of 𝑛 tokens
𝑋1 , 𝑋2 , … 𝑋𝑛 satisfy the exchange function:

(22) ∏𝑛𝑖=1 𝑥𝑖𝑤𝑖 = 𝑘 , where ∑𝑛𝑖=1 𝑤𝑖 = 1

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, 42 and our analysis
here is related to the Balancer whitepaper (Martinelli and Mushegian, 2019). Like Uniswap,
Balancer liquidity providers earn fees from traders, and act as the counterparty to all trading
activity on the AMM, including actions by arbitrageurs. While the types of smart contracts
available on Balancer are richer than Uniswap, 43 the pricing and arbitrage mechanisms that
we review below are similar to Uniswap. 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 a fixed weight to each asset (Martinelli
and Mushegian, 2019).44
To begin with, suppose there are no trading fees for trading on the CMMM. The bilateral
𝑤 𝑑𝑥
trading price of one unit of 𝑋𝑖 in terms of 𝑋𝑗 is 𝑃𝑋𝑗/𝑋𝑖 = − 𝑑𝑥𝑗 . Letting ∏𝑛𝑖=1 𝑥𝑖 𝑖 =
𝑖

1 1
41 It is worth mentioning that while Uniswap-v3 will no longer use fungible liquidity tokens, it still uses 𝐿 = 𝑥 2 𝑦 2
to track contributions to liquidity in the pool.
42 See [Link] (accessed on 30th March, 2021).
43 We do not review these various possibilities here; the interested reader is referred to Martinelli and
Mushegian (2019).
44 As shown earlier, a CPMM also shares this feature.

35

Electronic copy available at: [Link]


𝜕𝑓
𝑓(𝑥1, 𝑥2 , … 𝑥𝑛 ), the total derivative of (22) yields ∑𝑛𝑖=1 𝜕𝑥 𝑑𝑥𝑖 = 𝑑𝑘 . Along any particular level
𝑖

curve 𝑑𝑘 = 0; moreover, since only quantities 𝑥𝑖 and 𝑥𝑗 change in this transaction, 𝑑𝑥𝑙 = 0
for 𝑙 ≠ {𝑖, 𝑗}. Consequently, for any arbitrary reserve quantities (𝑥1, 𝑥2 , … 𝑥𝑛 ):

𝑑𝑥𝑗 𝜕𝑓⁄𝜕𝑥 𝑤 𝑥 𝑤 𝑥
(23) = − 𝜕𝑓⁄𝜕𝑥 𝑖 = − 𝑤 𝑖 𝑥𝑗 ⇒ 𝑃𝑋𝑗/𝑋𝑖 = 𝑤𝑖 𝑥𝑗
𝑑𝑥𝑖 𝑗 𝑗 𝑖 𝑗 𝑖

The parallel between this and the case examined in Section 3.3 where 𝑥 𝛼 𝑦 𝛽 = 𝑘 is evident
straight away: the price in a 2-token CMMM is exactly the same as a 2-token CPMM with the
same exponents as weights. We are now in a position to see how the process of two-point
𝑤 𝑥𝑗
arbitrage works in a CMMM. Consider the case where 𝑀𝑋𝑗 /𝑋𝑖 < 𝑃𝑋𝑗/𝑋𝑖 = 𝑤 𝑖 𝑥 . Two-point
𝑗 𝑖

arbitrage suggests arbitrageurs will purchase 𝑋𝑖 in the reference market and sell it in the
𝑥
CMMM in exchange for 𝑋𝑗 . This causes 𝑥𝑗 to fall till the no-arbitrage condition 𝑀𝑋𝑗/𝑋𝑖 = 𝑃𝑋𝑗/𝑋𝑖
𝑖

is restored.
As in Section 3.3, 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:45

𝑥
(24) 𝑉𝑋1,𝑋2 ,…,𝑋𝑛 = 𝑤1
1

The share of any token value to the pool value is, then:

𝑥𝑖 𝑃𝑋1 /𝑋𝑖
(25) 𝑠𝑖 = 𝑉 = 𝑤𝑖 , ∀𝑖 ∈ {1,2, … 𝑛}
𝑋1 ,𝑋2 ,…,𝑋𝑛

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. This is similar to a CPMM,
where we found that share of each token in a bilateral pool with a certain value equalled the
relative weight of the token in the CPMM function.
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, it is relatively straightforward to show 𝑝𝑋𝑏𝑗/𝑋𝑖 =

𝜕𝑓 ⁄𝜕𝑥2 𝜕𝑓 ⁄𝜕𝑥𝑛 𝑟𝑘 𝜕𝑓 ⁄𝜕𝑥𝑖 𝑤𝑖 𝑥1


45 From Euler’s theorem we have that 𝑥1 +
𝜕𝑓 ⁄𝜕𝑥1
𝑥2 + ⋯
𝜕𝑓 ⁄𝜕𝑥1
𝑥𝑛 =
𝜕𝑓 ⁄𝜕𝑥1
. As before,
𝜕𝑓 ⁄𝜕𝑥1
=
𝑤1 𝑥𝑖
=
𝑃𝑋1 /𝑋𝑖 , so that the left hand side of Euler’s equation is 𝑥1 + 𝑃𝑋1 /𝑋2 𝑥2 + ⋯ 𝑃𝑋1 /𝑋 𝑥𝑛 ≡ 𝑉𝑋1 ,𝑋2 ,…,𝑋𝑛 . Given the
𝑥1
constraint that ∑𝑛𝑖=1 𝑤𝑖 = 1, we have that 𝑟 = 1, and the right-hand side equals .
𝑤1

36

Electronic copy available at: [Link]


𝑤 𝑥 1𝑤 𝑥
𝜙 𝑤𝑖 𝑥𝑗 and 𝑝𝑋𝑎𝑗/𝑋𝑖 = 𝜙 𝑤𝑖 𝑥𝑗 .46 Using equation (5), then, the no-arbitrage condition is:
𝑗 𝑖 𝑗 𝑖

𝑤 𝑥 1𝑤 𝑥
(26) 𝜙 𝑤𝑖 𝑥𝑗 ≤ 𝑀𝑋𝑗/𝑋𝑖 ≤ 𝜙 𝑤𝑖 𝑥𝑗
𝑗 𝑖 𝑗 𝑖

4.2 Constant Sum Market Makers (CSMM)


There has been some discussion in the DeFi literature about the usefulness of a constant
sum market maker (CSMM). For reserves (𝑥, 𝑦) for tokens 𝑋 and 𝑌, a CSMM holds the sum
of reserves constant, that is, the exchange function satisfies 𝑥 + 𝑦 = 𝑘. Of course, one could
generalize this to 𝑎𝑥 + 𝑏𝑦 = 𝑘, or if there are more tokens in the pool, to 𝑎1 𝑥1 + 𝑎2 𝑥2 + ⋯ +
𝑎𝑛 𝑥𝑛 = 𝑘.
The main point we wish to make here is that a CSMM functions poorly as a decentralized
exchange because arbitrage activity can entirely drain the liquidity pool of a token, and the
simple 𝑥 + 𝑦 = 𝑘 case suffices to show that. Before doing so, however, it is worthwhile
examining why a CSMM may be attractive. One of the features of a CPMM (and a CMMM) is
that along a particular level curve, say 𝑘 0 in Figure 3, the slope varies at every point, and
consequently the price changes every time the reserves change, even if by a small amount. In
𝑑𝑦 𝑎
contrast, in a CSMM 𝑎𝑥 + 𝑏𝑦 = 𝑘, the price is constant and equal to 𝑃𝑌/𝑋 = − 𝑑𝑥 = 𝑏 ;
indeed, in the special case where 𝑎 = 𝑏 = 1, 𝑃𝑌/𝑋 = 1, and the two tokens trade on a one-
to-one basis. The price stability is attractive in that it reduces price slippage: a change in price
before a trading order is executed by the AMM. While this is true, for the purpose of a
decentralized exchange, however, the constant price in a CSMM is problematic if the
reference market price is variable. Intuitively, arbitrageurs will constantly take advantage of
the price differential in the two markets and because the constant price in the CSMM cannot,
by construction, respond to this pressure by arbitrageurs, they may drain the CSMM of one
token or the other.
The intuition above is described more systematically in Figure 6 below, which considers
the simple CSMM with exchange function 𝑥 + 𝑦 = 𝑘. Suppose, to begin with, that the CSMM
charges no trading fees and 𝜏 = 0. Consider a situation where the reserves in the CSMM are

46 Suppose the trader sells 𝑋𝑖 and purchases 𝑋𝑗 ; this yields the bid-price 𝑝𝑋𝑏 𝑗 /𝑋𝑖 . Suppose we start with pool
𝑤
reserves (𝑥1 , 𝑥2 , … , 𝑥𝑛 ) which satisfies the constant mean function ∏𝑛𝑖=1 𝑥𝑖 𝑖 = 𝑘. For the trade we have
𝑤 𝑤 𝑤
(∏𝑛𝑟=1 𝑥𝑟 𝑟 ) (𝑥𝑖 + 𝜙∆𝑥𝑖 )𝑤𝑗 (𝑥𝑗 + ∆𝑥𝑗 ) 𝑗 = ∏𝑛𝑖=1 𝑥𝑖 𝑖 = 𝑘 (recall that the fees are not added to the pool in the
𝑟≠𝑖,𝑗
𝑤
𝑖
𝜙∆𝑥𝑖 −𝑤𝑗 ∆𝑥𝑗
first step). This implies that ∆𝑥𝑗 = 𝑥𝑗 [(1 + ) − 1], from which it follows that lim =
𝑥𝑖 ∆𝑥𝑖 →0 ∆𝑥𝑖
𝑤𝑖
𝜙∆𝑥𝑖 −𝑤𝑗
𝑥𝑗 [(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.
𝑗 𝑥 𝑖 𝑗 𝑖

37

Electronic copy available at: [Link]


(𝑥 𝐴 , 𝑦 𝐴 ), and the liquidity level is 𝑘 = 𝑘 0 . The absolute value of slope of the line 𝐵𝐷 is 𝑃𝑌/𝑋 =
1, and describes the trading possibilities on the CSMM.

𝐴
𝑦𝐴

𝑦𝑀 𝐶
𝑘 = 𝑘0

𝑥𝐴 𝐷 𝑥
𝑂

Figure 6: Price and arbitrage in a CSMM


with no transaction fees

Now suppose the reference market price is 𝑀𝑌/𝑋 > 1. In this case, arbitrageurs will buy 𝑋
in the CSMM and sell it in the reference market to make a profit of 𝑀𝑌/𝑋 − 𝑃𝑌/𝑋 for every unit
of 𝑋 bought and sold this way. If the CSMM is small in size compared to the reference market,
the 𝑀𝑌/𝑋 may change little in response to the sale of 𝑋 there, and the process will continue
till the CSMM is drained of all 𝑋 since 𝑃𝑌/𝑋 is fixed. In Figure 6, 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
reference market, and has a slope greater that 1, thereby capturing the fact that 𝑀𝑌/𝑋 >
𝑃𝑌/𝑋 .
Arbitrageurs can sell the 𝑂𝑥 𝐴 units of 𝑋 purchased in the CSMM for 𝐵𝑦 𝑀 units of 𝑌 in the
reference 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 𝐵. The arguments when 𝑀𝑌/𝑋 < 1 are similar, with a corner equilibrium
at 𝐷.

38

Electronic copy available at: [Link]


𝑏 𝑎 1
Adding trading fees as before, it is readily seen that 𝑝𝑌/𝑋 = 𝜙 and 𝑝𝑌/𝑋 = 𝜙 . In the
1
scenario above where an arbitrageur buys 𝑋 from the CPMM, the relevant price of 𝑋 is 𝜙
1
units of 𝑌. So, if fees are high and 𝜙 > 𝑀𝑌/𝑋 , arbitrage is no longer profitable; on the other
1
hand, if fees are low and < 𝑀𝑌/𝑋 , arbitrage continues as before and yields a corner
𝜙
1
equilibrium. Overall, the no-arbitrage condition in this case is 𝜙 ≤ 𝑀𝑌/𝑋 ≤ 𝜙. Higher the fees,
wider is the gap and it is less likely that the CSMM is depleted of one token due to the action
of arbitrageurs. Higher fees, therefore, add to the stability of the CSMM in terms of
preventing a corner equilibrium and favor liquidity providers, but makes operating on the
CSMM less attractive for traders.

4.3 Hybrid Function Market Makers (HFMM)


One of the desirable features of a CSMM is that there is no price slippage, and a fixed rate
of exchange between tokens is maintained, no matter what the relative quantities are of the
two tokens in the liquidity pool. As we saw, the drawback of this is the tendency towards a
corner equilibrium with the reserves of one token falling to zero. A corner equilibrium can
never occur in a CPMM or CMMM as the price of a token would tend to infinity as its reserves
approached zero. The problem with a CPMM/CMMM, however, is that every trade leads to a
change in price, which makes price slippage more problematic.
A mix of a CPMM/CMMM and a CSMM that emphasizes both their advantages, while
minimizing their problems would be a desirable middle-ground in many situations. One such
situation is in the exchange of stablecoins: tokens that have their values fixed against another
asset, typically the USD, and hence against each other in any reference market. Price
movements in the AMM are problematic here because if stablecoins are trading, say, on a
one-to-one basis, any movement away from that (accounting for trading fees) in the AMM
would create two-point arbitrage activity which, as we have seen, reduces the returns to
returns to liquidity providers. A CPMM/CMMM is unattractive in this context due to the
sensitivity of price to trading activity. There are two possible solutions to this. The first is to
reduce arbitrage opportunities by increasing fees, but that widens the bid-ask spread and is
less than optimal for traders to utilizing the AMM to exchange tokens. The second, is to
maintain price stability like a CSMM, but attempt to do so while reducing the possibility of a
corner equilibrium in the AMM.
The Hybrid Function Market Maker (HFMM) is an AMM that integrates the features of a
CPMM/CMMM and a CSMM in order to draw upon their positive characteristics. Much of the
discussion below is inspired by Egorov (2019), which represents the whitepaper for Curve
Finance (or, formerly, Stableswap), an AMM that focuses on trade in stablecoins. Our focus
here is to bring out the intuition behind how an integration of a CPMM/CMMM and CSMM

39

Electronic copy available at: [Link]


may be achieved in this instance and the HFMM described here is, consequently, less complex
than that of Egorov (2019).47 To keep the exposition simple, trading fees are assumed to be
zero.
1
Consider a CMMM described in equation (22), with equal weights so that ∏𝑛𝑖=1 𝑥𝑖𝑛 = 𝑘 and
1
a CSMM 𝑎1 𝑥1 + 𝑎2 𝑥2 + ⋯ + 𝑎𝑛 𝑥𝑛 = 𝑘, also with equal coefficients 𝑎1 = 𝑎2 = ⋯ = 𝑎𝑛 = 𝑛,
∑𝑛
𝑖=1 𝑥𝑖
which yields = 𝑘. Why these special cases with equalized weights and coefficients were
𝑛
𝑥𝑗
chosen will become apparent presently. The bilateral price in the CMMM is 𝑃𝑋𝑗/𝑋𝑖 = 𝑥𝑖

(equation 23; note the this is the same price as would obtain in a CPMM due to the
homotheticity property), and 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 first note the
∑𝑛
𝑖=1 𝑥𝑖 ∑𝑛
𝑖=1 𝑥𝑖
arithmetic mean of the reserves is 𝐴 = . The CSMM = 𝑘, consequently, simply
𝑛 𝑛
specifies various combinations of reserves that yield a particular arithmetic mean. Similarly,
1 1
the geometric mean of the reserves is 𝐺 = ∏𝑛𝑖=1 𝑥𝑖𝑛; the CMMM ∏𝑛𝑖=1 𝑥𝑖𝑛 = 𝑘 looks at
combinations of reserves yielding a specific geometric mean.
Now, consider the relationship between 𝐴 and 𝐺. A well-known theorem governing this
relationship (which we do not prove here) is the AM-GM inequality:

The AM-GM inequality: For any non-negative real numbers 𝑥1, 𝑥2 , … , 𝑥𝑛 :


1
∑𝑛
𝑖=1 𝑥𝑖
(i) ≥ ∏𝑛𝑖=1 𝑥𝑖𝑛
𝑛
1
∑𝑛
𝑖=1 𝑥𝑖
(ii) = ∏𝑛𝑖=1 𝑥𝑖𝑛 if and only if 𝑥1 = 𝑥2 = ⋯ = 𝑥𝑛
𝑛

𝐷
47 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.

40

Electronic copy available at: [Link]


The AM-GM inequality states, essentially, that the arithmetic mean is at least as large as the
geometric mean, and that the two are equal only when all the numbers are equal. This is a
useful result given the CSMM and CMMM functions we are working with. Specifically,
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, the ratio satisfies 0≤ ≤ 1, and is consequently 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, and prevents
𝐴 𝑗
𝐺 𝜕𝐴⁄𝜕𝑥
the reserve from being depleted. Similarly, when 𝐴 → 1, 𝑃𝑋𝑗/𝑋𝑖 → 𝜕𝐴⁄𝜕𝑥 𝑖 , which is the price
𝑗

that exists under a CSMM.


The outcome of the above discussion is shown geometrically in Figure 7 below for the two-
1 1
token case, where the curve 𝐺𝐺 represents the CMMM 𝑥 2 𝑦 2 = 𝑘 and the line 𝐴𝐴 represents
𝑥+𝑦
the CSMM = 𝑘. The mixing of the two AMMs using a fixed 𝜆 is shown with the dashed-
2
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 resolves the more damaging problem for a specific reserve
combination.

41

Electronic copy available at: [Link]


𝑦

𝐶𝐻 𝐺

45°

𝐺
𝐻
𝐶 𝑥
𝐴

Figure 7: Hybrid Function Market Makers

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.48 This allows for a way to change the curvature of the exchange
function parametrically, similar to changing a fixed 𝜆 above.49

48 See Chiang (1984) or Silberberg (1990) for a proof of convergence to 𝑥𝛼 𝑦1−𝛼 as 𝜌 → 0.


1 1
1 1 1 1
49When 𝐸 = 1, 𝛼 = 1/2 and 𝜌 = 1/2, the function becomes (2 𝑥 2 + 2 𝑦 2 )2. When expanded this is 2 𝐴 + 2 𝐺,
the weighted average of 𝐴 and 𝐺, with 𝜆 = 0.5. This yields the curve 𝐶𝐶 in Figure 7.

42

Electronic copy available at: [Link]


4.4 Dynamic Automated Market Makers (DAMM)
4.4.1 Dynamic weights in a CMMM
Section 4.3 provided the basic intuition behind how a HFMM attempts to modify a CMMM
to keep prices relatively stable. A HFMM provides a satisfactory solution in the context of
stablecoins where prices are less volatile in external reference markets, and the goal is to
bring prices close to a CSMM during normal times, but to switch to a CMMM in case there is
any possibility of pool reserves falling to zero for one reserve. However, the HFMM method
of changing the shape of the AMM function may be less suitable when dealing with volatile
tokens, where arbitrage activity may be high due to the price volatility in reference markets
and the fixed prices offered by a CSMM is not attractive.
As we have seen, arbitrage performs a vital pricing function, but occurs at the detriment
of liquidity providers. Fees reduce arbitrage by widening bid-ask spreads but negatively affect
all trading activity and reduce the pricing efficiency of an AMM. The question that now arises
is can arbitrage activity on a CMMM be reduced: (a) while still reflecting the reference market
𝑤
price; but, (b) without changing the ∏𝑛𝑖=1 𝑥𝑖 𝑖 = 𝑘 exchange function; and (c) without
increasing fees?
In Section 4.1, the CMMM required assumed that the weights were fixed at some level.
Consider, now, a scenario where the CMMM could alter the weights dynamically in response
to some reference market stimulus. To see the implications of this possibility, let us recap the
𝑤 𝑥
CMMM arbitrage response with zero trading fees. If 𝑀𝑋𝑗 /𝑋𝑖 < 𝑃𝑋𝑗 /𝑋𝑖 = 𝑤 𝑖 𝑥𝑗, for example,
𝑗 𝑖

arbitrageurs purchase 𝑋𝑖 in the reference 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 the weight ratio 𝑤 𝑖 . If the CMMM
𝑗

𝑤𝑖′ 𝑥𝑗
were to adjust weights to 𝑤𝑖′ and 𝑤𝑗′ , we can have 𝑀𝑋𝑗/𝑋𝑖 = 𝑃𝑋𝑗/𝑋𝑖 = , with no change in
𝑤𝑗′ 𝑥𝑖
𝑥
the ratio of reserves 𝑥𝑗. In other words, prices in the two markets have become aligned not
𝑖

because of arbitrage activity, but rather due to weights changing from the ‘dynamic’
adjustments to the weights.
The above discussion suggests that weights that are flexible provides an additional
equilibrating factor other than arbitrage to ensure that AMM prices track reference market
prices. The reference market prices now serve the purpose of an oracle: an external source
of information that is fed into the smart contract. The relative importance of dynamic weights
and arbitrage in keeping prices aligned between the two markets then depends on how
frequently and reliably the oracle provides information to the AMM. Finally, it is worth noting
that dynamic weights cause two important changes to the CMMM. First, as summarized by
equation (25): that the value share of a token in a liquidity pool in a CMMM is determined by

43

Electronic copy available at: [Link]


the token’s weight. When weights are dynamic, this share is no longer fixed, causing the
CMMM to no longer be analogous to a standard fixed weight index fund. Second, from
equation (24), we have that the value of the liquidity pool can be measured using the reserves
and weight of the pricing token (say 𝑋1). In the standard CMMM, the valuation changes only
when the quantity 𝑥1 changes. Changing weights, however, present an additional source of
change for pool valuation, potentially making the pool value more volatile.

4.4.2 An example of a DAMM: Bancor


Bancor is an example of an AMM that attempts to dynamically adjust weights as the
reference market price changes, thereby reducing arbitrage activity. Bancor does not directly
use a CMMM function as its trading technology; our goal here is to show that the price output
is, nevertheless, the same as the CMMM discussed above. The important institutional
features of the Bancor protocol described here are based on Hertzog et al (2018) and
Rosenfeld (2017).50
A smart contract in Bancor has two types of tokens: a ‘smart token’ (say 𝑌) and a set of
𝑛 ‘connected tokens’, where 𝑛 ≥ 1. To make this comparable with a CMMM, let the
connected tokens be 𝑋1 , 𝑋2 … , 𝑋𝑛 . Let 𝑃𝑌/𝑋𝑖 denote the price of 1 unit of 𝑋𝑖 in terms of 𝑌 (in
the absence of any trading fees).51 A trader can purchase or sell 𝑋𝑖 against 𝑌 at any time using
the smart contract at the going price. When a trader sells 𝑋𝑖 its reserve balance, 𝑥𝑖 , increases
and the smart contract automatically increases supply of 𝑌. The opposite occurs when a
trader buys 𝑋𝑖 : reserve 𝑥𝑖 decreases, as does the supply of 𝑌. The mechanics of operation
thus far appear entirely different than a CMMM. What makes the two comparable are
‘connector weights’ or ‘fractional reserve ratios’, 𝑤𝑖 , 𝑖 ∈ {1,2, … 𝑛}. Letting 𝑦 denote the total
quantity of 𝑌 in the smart contract, 𝑤𝑖 satisfies the condition:

𝑃𝑌/𝑋𝑖 𝑥𝑖
(30) 𝑤𝑖 = for all , 𝑖 ∈ {1,2, … 𝑛}.
𝑦

The numerator is the value of token 𝑋𝑖 denominated in units of 𝑌, while the denominator is
the total value of 𝑌 in the smart contract. So 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 𝑃𝑌/𝑋𝑖 :

50 Our exposition here is meant to capture the overall logic of the system, rather than all the institutional details
of the Bancor protocol; see [Link] (accessed on 30th March, 2021), Hertzog et al
(2018) and Rosenfeld (2017) for further details.
51 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.

44

Electronic copy available at: [Link]


(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, websites
such as 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.

4.5 CPMM revisited: Uniswap-v3


One of the main changes to the Uniswap AMM in v3 relates to the idea of concentrated
liquidity, where a liquidity provider can identify a price interval over which to spread liquidity.
As mentioned in Section 2, this is in contrast to Uniswap-v2 where a liquidity provider has no
such control. In this section, we focus on the representing this change to Uniswap
geometrically to gain an overall understanding of how v3 relates to v2 and, indeed, the other
types of AMMs presented here. In what follows, we assume that trading fees are zero for
simplicity. We refer to an AMM having the characteristics of Uniswap-v3 generally as CPMM-
v3. Since liquidity providers can specify any arbitrary range for bounding their liquidity, there
has to be a way to specify different regions of the AMM exchange curve. Uniswap-v3 achieves
this by keeping track of every .01% change between prices.52 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 × 𝑃.
Consider the exchange function 𝑘 = 𝑥𝑦 in Figure 8 below, which is the same as the
Uniswap-v2 exchange function. For simplicity, suppose a number of liquidity providers have
𝐹 𝐶
specified a price interval [𝑃𝑌/𝑋 , 𝑃𝑌/𝑋 ] for their liquidity bounds.53 These prices correspond to

52 As a technicality, the Uniswap-v3 protocol actually utilizes .005% changes in prices in calculations; the exact
magnitude of what constitutes a tick is not important for the purpose of this exposition.
53 In general, users may specify any arbitrary price range, so there can be overlaps in the intervals they specify.

This does not alter the analysis. Every time a liquidity provider specifies a new price as a bound (that was not
specified by any other provider), it activates or initializes the corresponding tick as a bound. In Figure 8, 𝐶 and
𝐹 can be thought of as points on the exchange function between any two initialized ticks (with prices 𝑃𝐶 and
𝑃𝐹 ).

45

Electronic copy available at: [Link]


𝐶 𝑦𝐶
the absolute values of slopes at points 𝐶 and 𝐹 in Figure 8; as before, we have that 𝑃𝑌/𝑋 = 𝑥𝐶
𝐹 𝑦𝐹
and 𝑃𝑌/𝑋 = 𝑥 𝐹 . Following the Uniswap-v3 whitepaper, we refer to the range of the exchange
function level curve between 𝐶 and 𝐹 as a liquidity position.

𝑦 𝑦̂

𝐶
𝑦𝐶

𝐴
𝑦𝐴

𝐹
𝑦𝐹
𝑂̂ 𝑥̂

𝑘0
𝑥
𝑂 𝑥𝐶 𝑥𝐴 𝑥𝐹

Figure 8: A position in a Uniswap-v3 pool

There are now two aspects of Uniswap-v3 to keep track of: first, what occurs in a specific
position; and second, how this relates to the overall liquidity pool. In order to distinguish
between the two, Uniswap-v3 uses the term real to describe the behavior of reserves within
a liquidity position and virtual to refer to the overall pool. Geometrically, Figure 8
differentiates between the two by drawing separate set of position or real axes, 𝑥̂ and 𝑦̂ (with
origin 𝑂̂ ), to keep track of reserves within the position 𝐶𝐹, and the pool or virtual axes, 𝑥 and
𝑦, to keep track of the overall liquidity pool. Thus, measuring from 𝑂̂ , at point 𝐶 the position
has reserves of 𝑌 shown by the distance 𝑂̂𝐶, which equals (𝑦 𝐶 − 𝑦 𝐹 ) and zero reserves of 𝑋.
In terms of the terminology of the Uniswap-v3 whitepaper, the real reserves of 𝑌 and 𝑋 at 𝐶
are (𝑦 𝐶 − 𝑦 𝐹 ) and 0, respectively, while the virtual reserves are 𝑦 𝐶 and 𝑥 𝐶 . Similarly, at 𝐹,
the real reserves of 𝑌 and 𝑋 are 0 and (𝑥 𝐹 − 𝑥 𝐶 ), respectively, while the pool or virtual

46

Electronic copy available at: [Link]


reserves are 𝑦 𝐹 and 𝑥 𝐹 . At some intermediate point like 𝐴, again measuring from the position
origin 𝑂̂ , the real reserves are (𝑦 𝐴 − 𝑦 𝐹 ) and (𝑥 𝐴 − 𝑥 𝐶 ), and virtual reserves are 𝑦 𝐴 and 𝑥 𝐴 .
The main point of drawing the position axes 𝑥̂ and 𝑦̂ is to highlight that even though the
virtual reserves can never fall to zero for any asset due to the curvature of the 𝑥𝑦 = 𝑘
exchange function, positional real reserves can indeed do so. The latter occurs when the
exchange function level curve intersects the 𝑦̂ (or 𝑥̂) axis, in which case the real reserves of 𝑋
(or 𝑌) have fallen to zero. At point 𝐶, for example, the liquidity providers hold only token 𝑌 in
the position 𝐶𝐹. This also necessitates a difference between active positions and inactive
𝐹 𝐶
positions: when the actual trading price is in the range (𝑃𝑌/𝑋 , 𝑃𝑌/𝑋 ), the position 𝐶𝐹 is active;
outside that range it is inactive. Inactive positions earn no fees on Uniswap-v3.
This feature of real reserves falling to zero bears similarity to a CSMM, such as the one
shown in Figure 6. To highlight the similarity, we have drawn the chord connecting 𝐶 and 𝐹
in Figure 8; with respect to the axes 𝑥̂ and 𝑦̂, the line 𝐶𝐹 behaves like a CSMM. As pointed
out in Section 4.2, the slope of the CSMM is the fixed price at which the two assets trade. It
is worth investigating, then, what information the slope of the line 𝐶𝐹 provides in Uniswap-
𝑦 𝐶 −𝑦 𝐹
v3. Intuitively, the slope of line 𝐶𝐹 is 𝑥 𝐶−𝑥 𝐹 , which is the rate at which the two assets exchange
on average in the position. We can, therefore, think of the absolute value of the slope of 𝐶𝐹
𝐹 𝐶
as the average price of the liquidity position bounded by the prices 𝑃𝑌/𝑋 and 𝑃𝑌/𝑋 . That is,
𝐶𝐹
denoting the average price as 𝑃𝑌/𝑋 :

𝐶𝐹 𝑦 𝐶 −𝑦 𝐹
(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 8, 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 point 𝐴 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

47

Electronic copy available at: [Link]


straightforward to show that this average price is the geometric mean of the price bounds: 54

𝐶𝐹 𝐹 𝐶
(34) 𝑃𝑌/𝑋 = √𝑃𝑌/𝑋 𝑃𝑌/𝑋

A specific liquidity position in a CPMM-v3, therefore, is approximately replicated by a CSMM


with the same price as the average price of the position, with the main difference between
the two being that real reserves on the CPMM-v3 track the arc 𝐶𝐹 whereas the reserves in
the CSMM move along the line 𝐶𝐹. However, the smaller the length of the arc, the closer the
line 𝐶𝐹 will approximate the arc 𝐶𝐹. We can interpret a CPMM-v3, then, as an approximation
of a series of CSMM, with each CSMM tracking a specific position. This is shown in Figure 9.

𝑘
𝑂 𝑥
Figure 9: CPMM-v3 as a series of
connected CSMMs

1 1
𝑦 𝐶 −𝑦 𝐹 𝑘( 𝐶 − 𝐹 ) 𝑘 𝑘2 𝑦𝐹𝑦𝐶
𝐶𝐹 𝐹 𝐶
54 Specifically, we have that 𝑃𝑌/𝑋 = 𝑥 𝐹 −𝑥 𝐶
= 𝑥 𝑥
𝑥 𝐹 −𝑥 𝐶
= 𝑥 𝐹𝑥 𝐶 = √(𝑥 𝐹 𝑥 𝐶)2 = √𝑥 𝐹𝑥 𝐶 = √𝑃𝑌/𝑋 𝑃𝑌/𝑋 . This 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 8, for example, if an agent
𝐹 𝐶
contributes token 𝑋 alone in the price range [𝑃𝑌/𝑋 , 𝑃𝑌/𝑋 ], the liquidity position becomes active when the price
𝐹
reaches 𝑃𝑌/𝑋 . If the price moves through arc 𝐶𝐹 and exits at 𝐶, the position is converted entirely to 𝑌. The
average price for exchanging 𝑋 to 𝑌 is then given by (33) or (34). Graphically, the range order gives the same
price as a market order executed at point 𝐴.

48

Electronic copy available at: [Link]


Figure 9 depicts four liquidity positions along with their real axes and corresponding CSMMs.
It is easy to visualize in Figure 9 that as the positions get smaller and smaller, the connected
CSMMs will more closely approximate the curvature of the CPMM-v3, with the latter being
the limiting case of the former as the contract positions become infinitesimally small.55

4.6 Summary of relationships between AMMs


This section looked at a number of different types of AMMs, which are linked in a myriad of
ways. To conclude this section, we summarize the connections between these black-boxes in
Figure 10 below. Figure 10 serves to highlight that while there have been a number of
different types of AMMs that have emerged to trade tokens in a decentralized manner, their
performance and attributes are connected. A CPMM such as Uniswap-v2 (or v1) is a special
case of a CMMM like Balancer; allowing for weights to change in a CMMM replicates the
performance (in terms of price adjustments) of a DAMM such as Bancor. Mixing a CSMM with
a CMMM yields a HFMM such as Curve that is more suitable for trading stablecoins. An
alternative way to bring in attributes of a CSMM into a CPMM is to follow Uniswap-v3 which
essentially connects a series of CSMMs. While the possibilities for experimenting with AMMs
appear endless, simple geometric tools based on homogeneity and homotheticity are often
suffice to discern similarities and differences in their structures.

DAMM
(Bancor)

Dynamic weights

CSMM CMMM
(Balancer)
Combine at
different Special case
prices Mix

CPMM-v3 HFMM CPMM-v2


(Uniswap-v3) (Curve) (Uniswap-v2)

Figure 10: Links between AMMs

55 Though the presence of fees will imply that a trade will always spill across two liquidity positions if the size of
the position is smaller than the spread. This can be costly since crossing between initialized ticks can impose gas
costs on a trader. In order to prevent this, there has to be some minimum spacing between ticks that can be
initialized. This is factored in through a parameter ‘tickspacing’ in the Unswap-v3 protocol.

49

Electronic copy available at: [Link]


5. 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 insights 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
geometric tools described here are fairly general and (hopefully) present an intuitive
framework to allow new AMMs to be scrutinized and contrasted with existing AMMs.
The focus of this paper has been on the analytical framework behind AMMs. As such,
AMMs rely on arbitrage or oracles to align prices with the broader market. Our understanding
of how well arbitrage operates in this space and how it performs relative to oracles is still
nascent. This is partly an empirical endeavour (which has not been addressed in this paper at
all), but there are theoretical considerations here as well. For example, there are many
impediments (other than transaction fees) to how efficiently AMMs can operate. These
include phenomena such as frontrunning and backrunning of trades, sandwich attacks, the
worrisome presence of generalized bots that are capable of traversing the landscape of the
Ethereum terrain to ‘snipe’ arbitrage transactions entered into by others, the reordering of
transactions by miners, and so on.56 The last couple are particularly interesting, because they
can destroy incentives to engage in arbitrage: if arbitrage opportunities spotted by an agent
(in the broadest of being any entity, including a human or program, that spots an arbitrage
opportunity) are likely to be stolen by a bot, there is little incentive to spot arbitrage
opportunities in the first place. This questions the incentive structure for arbitrage to be
undertaken.
While this primer takes a fairly deep look at AMMs and DEXs, it barely scratches the surface
of advancements to financial instruments and institutions that are taking place in the DeFi
space. This paper does not, for example, examine borrowing and lending institutions being

56 See Daian et al (2019) for these and other issues related to vulnerabilities in the DeFi space. See also this
interesting account of the Ethereum ‘dark forest’ by Dan Robinson:
[Link] (accessed 30th March, 2021).

50

Electronic copy available at: [Link]


developed, the use of derivatives such as perpetual swaps, or how stablecoins operate.
Moreover, as mentioned in the introduction, the main disadvantage of the black-box
approach is that it precludes an examination of many interesting issues, such as how
communities are formed in a decentralized environment, how they are provided with
incentives, what restrictions are imposed by the ability to fork, and so on. In other words,
there is much scope for exciting research to be done in the DeFi space.
Like blockchains in general, DeFi is the amalgamation of different fields of expertise:
computer science, cryptography, finance, economics and game theory, to name a few. These
fields have developed with their own jargon, methodologies and tools of analysis, with ever
growing levels of sub-specialization and narrowness in expertise.57 It comes as no surprise,
then, that computers scientists and entrepreneurs at the forefront of the technological
developments in the blockchain space often invent new jargon and methodologies to
describe phenomena that economists have examined over many decades. At best this creates
confusion; at worst, it creates inefficiencies in the scientific process as one field reinvents the
knowledge already accumulated by another, or as one field eschews incorporating useful new
ideas due to the barriers imposed by multidisciplinary communication. This primer presents
an attempt to connect advancements in DeFi with the traditional toolkit of economics for one
use-case of DeFi, and in doing so takes a few, admittedly small, steps forward in the direction
of developing an integrated theory of DeFi.

57 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.”

51

Electronic copy available at: [Link]


References
Adams, H., Zinsmeister, N. and Robinson, D. 2020. Unsiwap v2 Core.
[Link] retrieved on 30th March, 2021.
Adams, H., Zinsmeister, N., Salem, M., Keefer, R. and Robinson, D. 2021. Uniswap v3 Core.
[Link] retrieved on 30th March, 2021.
Angeris, G., Kao, H., Chiang, R., Noyes, C. and Chitra, T. 2019. An Analysis of Uniswap Markets.
[Link] retrieved on 30th March, 2021.
Angeris, G. and Chitra, T. 2020. Improved Price Oracles: Constant Function Market Makers. In
Proceedings of the 2nd ACM Conference on Advances in Financial Technologies (AFT '20).
Association for Computing Machinery, New York, NY, USA, 80–91. DOI:
[Link]
Buterin, V. 2014. A Next Generation Smart Contract and Decentralized Application Platform.
Available: [Link]
retrieved on 30th March, 2021.
Chiang, A.C. 1984. Fundamental Methods of Mathematical Economics. McGraw-Hill, Inc.,
USA.
Daian, P., Goldfeder, S., Kell, T., Li, Y., Zhao, X., Bentov, I., Breidenbach, L., Juels, A. 2019. Flash
Boys 2.0: Frontrunning, Transaction Reordering and Consensus Instability in Decentralized
Exchanges. Available at [Link] retrieved on 30th March,
2021.
Demsetz, H. 1997. The Firm in Economic Theory: A Quiet Revolution. The American Economic
Review, 87: 426 – 429.
Egorov, M. 2019. StableSwap – Efficient Mechanism for Stablecoin Liquidity.
[Link] retrieved on 30th March, 2021.
Hanson, R. 2003. Combinatorial Information Market Design. Information Systems Frontiers,
5: 107 – 119.
Hanson, R. 2007. Logarithmic Market Scoring Rules for Modular Combinatorial Information
Aggregation. The Journal of Prediction Markets, 1: 3 – 15.
Hart, O. 1995. Firms, Contracts and Financial Structure. Oxford University Press, New York.
Hertzog, E., Benartzi, G. and Benartzi, G. 2018. Bancor Protocol.
[Link]
bancor_protocol_whitepaper_en.pdf, accessed 30th March, 2021.
Holmstrom, B. and Tirole, J. 1989. The Theory of the Firm. In R. Schmalensee and R.D. Willig
(eds.), Handbook of Industrial Organization, vol 1, Handbooks in Economics, no. 10,
Amsterdam: North Holland, 61 – 133.
Martinelli, F. and Mushegian, N. 2019. Balancer: A Non-custodial Portfolio Manager, Liquidity
Provider, and Price Sensor. [Link] retrieved on 30th March,
2021.

52

Electronic copy available at: [Link]


Pourpuneh, M. Nielsen, K. and Ross, O. 2020. Automated Market Makers. IFRO Working Paper
2020/08, available at [Link] retrieved on 30th
March, 2021.
Rosenfeld, M. 2017. Formulas for Bancor System. Available:
[Link] retrieved on 30th March,
2021.
Schär, F. 2020. Decentralized Finance: On Blockchain and Smart Contract-based Financial
Markets. [Link] retrieved on 30th
March, 2021.
Silberberg, E. 1990. The Structure of Economics: A Mathematical Analysis. McGraw Hill, Inc.,
USA.
Szabo, N. 1996. Smart Contracts: Building Blocks for Digital Markets.
[Link]
nterschool2006/[Link]/smart_contracts_2.html, retrieved in 30th March,
2021.
Zhang, Y., Chen, X. Park, D. 2018. Formal Specification of Constant Product (𝑥𝑦 = 𝑘) Market
Maker Model and Implementation. [Link]
contracts/blob/uniswap/uniswap/[Link], retrieved on 30th March, 2021.

53

Electronic copy available at: [Link]

You might also like