This paper was converted on www.awesomepapers.org from LaTeX by an anonymous user.
Want to know more? Visit the Converter page.

A General Framework for Impermanent Loss in Automated Market Makers

Neelesh Tiruviluamala     Alexander Port     Erik Lewis Emails: neel@thrackle.io, alex@thrackle.io, erik@thrackle.io
Abstract

We provide a framework for analyzing impermanent loss for general Automated Market Makers (AMMs) and show that Geometric Mean Market Makers (G3Ms) are in a rigorous sense the simplest class of AMMs from an impermanent loss viewpoint. In this context, it becomes clear why automated market makers like Curve ([Ego19]) require more parameters in order to specify impermanent loss. We suggest the proper parameter space on which impermanent loss should be considered and prove results that help in understanding the impermanent loss characteristics of different AMMs.

1 Introduction

Impermanent loss for protocols like Uniswap ([Ada18]) and Balancer ([MM19]) have been well studied ([Eva20], [AD21], [AEC20], [Aoy20], [Bou21]). These geometric mean market maker protocols (G3Ms) can give the false impression that certain non-trivial properties regarding impermanent loss should hold for all Automated Market Makers (AMMs). For instance, Figure 1 implicitly leverages the idea that impermanent loss is a one free parameter function in the case of two dimensional G3Ms. Not by design by true nevertheless, Curve’s StableSwap AMM protocol ([Ego19]) does not allow impermanent loss to be analyzed with one free parameter (so Curve could not be compared in Figure 1). At a high level, the goal of this paper is to provide a useful way to analyze impermanent loss as protocols continue to increase in complexity.

Refer to caption
Figure 1: Impermanent Loss for Uniswap and Balancer Pools Compared

Along these lines, we start by observing and codifying some of the properties of G3Ms. The major property that we focus on in this paper is what we call Exchange Rate Level Independence (ERLI). This property states that impermanent loss can be understood entirely in terms of ratios of initial and final exchange rates, as opposed to the actual rates themselves. In other words, moving from an Eth :: BTC exchange rate of 15:115:1 to an exchange rate of 30:130:1 has the same effect on impermanent loss as moving from an exchange rate of 10:110:1 to an exchange rate of 20:120:1, since in both scenarios the exchange rate has doubled. G3Ms exhibit this property, though to our knowledge, it has not been clearly formalized for higher dimensional AMMs until now. Among other conceptual benefits, exchange rate level independence allows us to analyze impermanent loss for AMMs with fewer parameters.

Showing that G3Ms (up to a simple transformation) have the ERLI property and are the only AMMs to have this property is the main result of this paper. The connection between portfolio value functions and trading functions pointed out in [AEC21] is a crucial first step towards establishing this result. However, a slightly different viewpoint is used in this paper. We focus on individual level surfaces of an AMM as opposed to the function AA that generates them. The following example might motivate this shift in focus. Consider

A(x,y)\displaystyle A(x,y) =xy\displaystyle=xy
B(x,y)\displaystyle B(x,y) =exy\displaystyle=e^{xy}

Both of these functions have the same level curves, namely the liquidity curves of Uniswap, but only the first function is a geometric mean market maker. As such, trying to infer properties of AA from its impermanent loss characteristics is misguided since both the above market makers would lead to the same impermanent loss. On the other hand, restricting a priori to the class of geometric mean market makers precludes some interesting AMMs like Curve’s StableSwap. Focusing on the level surfaces of AA has conceptual benefits as well, some of which are outlined in Section 5.

Readers familiar with the space can skip to Section 33, in which we derive an impermanent loss formula for higher dimensional constant product market makers. In the process of doing so, we note that these constant product market makers have some helpful properties that we work to concretize in the later sections. We then show that the smallest class of market makers with these properties is the class of market makers whose level surfaces match those of a geometric mean market maker.

2 Background and Notation

In what follows, we will use a definition for an automated market maker (AMM) motivated by [EH21].

Definition 1.

An automated market maker is a map A=A(x1,,xn):>0nA=A(x_{1},...,x_{n}):\mathbb{R}_{>0}^{n}\rightarrow\mathbb{R} where

  1. 1.

    AC2(>0n,)A\in C^{2}(\mathbb{R}_{>0}^{n},\mathbb{R})

  2. 2.

    Im(Axi)>0Im(A_{x_{i}})\subset\mathbb{R}_{>0} for all i{1,,n}i\in\{1,...,n\}

  3. 3.

    upper(A,k)={(x1,,xn)>0n:A(x1,,xn)k}upper(A,k)=\{(x_{1},...,x_{n})\in\mathbb{R}_{>0}^{n}:A(x_{1},...,x_{n})\geq k\} is strictly convex for all k0k\geq 0.

Note that some authors require that the AMM is homogeneous (i.e. A(cx1,,cxn)=cdA(x1,,xn)A(cx_{1},...,cx_{n})=c^{d}A(x_{1},...,x_{n}) for some d>0d>0) while other authors don’t; see [CJ21] and [EH21] respectively. In practical terms, an AMM provides a programmatic way for traders to swap tokens for one another. In the above definition, nn represents the number of tokens, and xix_{i} is the quantity of token ii. For a given state of quantities x=(x1,,xn)>0nx=(x_{1},...,x_{n})\in\mathbb{R}_{>0}^{n}, there is a level surface (or curve if n=2n=2) SS of AA that passes through this state. Traders are allowed to swap tokens in and out of the AMM in any manner that leaves the resulting state on the surface SS. In contrast, liquidity providers through their actions can move the state from one level surface to another. The first condition ensures smoothness of these surfaces, the second condition ensures that the level surfaces are sensibly indexed, and the third condition ensures that the level surfaces are convex. It is worth mentioning that the commonly presented two-dimensional hyperbolic constant product market makers correspond to the function A(x1,x2)=x1x2A(x_{1},x_{2})=x_{1}x_{2}, some of whose level curves are pictured below. For a more thorough introduction to these ideas, consult [AC20].

Refer to caption
Figure 2: Two level curves of the AMM A(x1,x2)=x1x2A(x_{1},x_{2})=x_{1}x_{2} are pictured in state space. The current state (4,3)(4,3) consists of 4 of the first token type and 44 of the second token type. A trader could, for example, extract 22 tokens of the first type in exchange for supplying 33 tokens of the second type. This would push the state to (4,3)+(2,3)=(2,6)(4,3)+(-2,3)=(2,6), which satisfies the requirement that it falls on the level curve A=12A=12. Alternatively, a liquidity provider could choose to add 22 tokens of the first type and 1.51.5 tokens of the second type, expanding the pool’s liquidity, but leaving its reserves in the same ratio.

A price vector p=(p1,,pn)p=(p_{1},...,p_{n}) assigns a price to each token so that pip_{i} is the price of token ii in terms of some measuring currency. A price vector can be thought of in state space as the gradient vector (it points in the direction of steepest increase) of the value function

V(x)=px=i=1npixiV(x)=p\cdot x=\sum_{i=1}^{n}p_{i}x_{i}

This value function is naturally defined in that it is the sum of the product of each token quantity by the corresponding token price. If we think of VV as a function on the state space (given a fixed price vector pp), we see that VV has a constant gradient pp. We see in Figure 3 the relationship between the price vector pp and the level curves of the value function VV that it induces.

Refer to caption
Figure 3: Several level curves of the value function VV corresponding to the price vector p=(6,2)p=(6,2) are pictured in state space. Note that the V=24V=24 level curve is tangent to the AMM level curve A=x1x2=12A=x_{1}x_{2}=12 at the state (2,6)(2,6). It is geometrically clear, then, that the AMM (for the A=12A=12 level curve) obtains its lowest value at the state (2,6)(2,6). As such, if the external market prices for the tokens were given by pp, arbitrageurs would drive the state to (2,6)(2,6).

In Figure 3, the state (2,6)(2,6) is referred to as a stable point, in that it is the state with the lowest value VV on the current trading curve A=12A=12. We will define stable points more formally below. Note that the measuring currency is not important in the context of defining stable points. Changing the measuring currency through which pp is defined would stretch or contract pp, but it would not change its direction. Also, changing the measuring currency would leave the family of level curves (surfaces) intact, though it would alter the VV values corresponding to these level curves (surfaces). If, for instance, the measuring currency were taken to be the first token, p1p_{1} would be 11 and p2p_{2} would be 26\frac{2}{6}, which would result in the same level curves for the value function as shown in Figure 3, but with the corresponding values divided by 66.

Let’s make a fixed choice of price p>0np\in\mathbb{R}_{>0}^{n}, AMM A:>0nA:\mathbb{R}_{>0}^{n}\rightarrow\mathbb{R}, and number kk\in\mathbb{R}. We say that a point (x1o,,xno){(x1,,xn)>0n:A(x1,,xn)=k}(x_{1}^{o},...,x_{n}^{o})\in\{(x_{1},...,x_{n})\in\mathbb{R}_{>0}^{n}:A(x_{1},...,x_{n})=k\} is stable if

i=1npixio=inf{i=1npixi:(x1,,xn)>0n,A(x1,,xn)=k}\sum_{i=1}^{n}p_{i}x_{i}^{o}=inf\{\sum_{i=1}^{n}p_{i}x_{i}:(x_{1},...,x_{n})\in\mathbb{R}_{>0}^{n},A(x_{1},...,x_{n})=k\}

In other words, a state xox^{o} is stable if it has the lowest value V(xo)V(x^{o}) among all states on the level surface that it defines. This corresponds to the idea that arbitrageurs will drive the AMM state to this stable state based on the external market valuation of the assets. Finding such a stable point is a Lagrange multipliers problem; we are trying to minimize the value of V(x)V(x) subject to the condition that A(x)=kA(x)=k. We know that V=p\nabla V=p and therefore pp must be parallel to A=(Ax1,,Axn)\nabla A=(A_{x_{1}},...,A_{x_{n}}) evaluated at the given state. For instance, in Figure 3 one can observe that the gradient of AA at the stable point (2,6)(2,6) is parallel to pp.

In what follows, we assume that if the price vector changes (one can think of it as fluctuating exogenously), the state vector in the AMM changes to the corresponding stable point (thanks to arbitrageurs). In [EH21], it is shown that for a given price vector pp, there is a unique stable point xx on the A=kA=k surface. In other words, the stable state is a function of price

x=x(p)x=x(p)

but we will avoid using this notation to keep the exposition clean. Suppose that the price vector changes from pip^{i} to pfp^{f}. The following definition helps to quantify the loss liquidity providers face when compared to those who simply hold their assets. It is commonly referred to in the literature as impermanent loss or divergence loss.

Definition 2.

Fix an AMM A:>0nA:\mathbb{R}_{>0}^{n}\rightarrow\mathbb{R} and a level surface A=kA=k. Suppose the initial and final prices are given by pi=(p1i,,pni)p^{i}=(p_{1}^{i},...,p_{n}^{i}) and pf=(p1f,,pnf)p^{f}=(p_{1}^{f},...,p_{n}^{f}), and that the corresponding stable states are xi=(x1i,,xni)x^{i}=(x_{1}^{i},...,x_{n}^{i}) and xf=(x1f,,xnf)x^{f}=(x_{1}^{f},...,x_{n}^{f}). Then the impermanent loss is defined to be

IL\displaystyle IL =\displaystyle= Final value of pool assetsValue if assets were heldValue if assets were held\displaystyle\frac{\text{Final value of pool assets}-\text{Value if assets were held}}{\text{Value if assets were held}}
=\displaystyle= V(xf)V(xi)V(xi)=pfxfpfxipfxi=pfxfpfxi1\displaystyle\frac{V(x^{f})-V(x^{i})}{V(x^{i})}=\frac{p^{f}\cdot x^{f}-p^{f}\cdot x^{i}}{p^{f}\cdot x^{i}}=\frac{p^{f}\cdot x^{f}}{p^{f}\cdot x^{i}}-1

Note that the above formula for impermanent loss is dependent on pip^{i} since xix^{i} is a function of pip^{i}. Thus, impermanent loss at first glance seems to be a function of pip^{i} and pfp^{f}, which involves 2n2n parameters. In the next section, we will investigate whether we can in general reduce the number of parameters needed to compute impermanent loss. To provide context for this investigation, we will conclude this section with a simple example. We will derive the well known formula for the impermanent loss of a two dimensional constant product market maker.

Example 3.

For a constant product market maker with two assets x1x_{1} and x2x_{2} where A(x1,x2)=x1x2=kA(x_{1},x_{2})=x_{1}x_{2}=k, consider two assets with initial prices p1ip_{1}^{i} and p2ip_{2}^{i}, initial quantities x1ix_{1}^{i} and x2ix_{2}^{i}, final prices p1fp_{1}^{f} and p2fp_{2}^{f}, and final quantities x1fx_{1}^{f} and x2fx_{2}^{f}. The impermanent loss formula given by

IL=p1fx1f+p2fx2fp1fx1i+p2fx2i1  can be reduced to  2tt+11  where  t=p2fp1fp2ip1iIL=\frac{p_{1}^{f}x_{1}^{f}+p_{2}^{f}x_{2}^{f}}{p_{1}^{f}x_{1}^{i}+p_{2}^{f}x_{2}^{i}}-1\text{\thinspace\thinspace can be reduced to\thinspace\thinspace}\frac{2\sqrt{t}}{t+1}-1\text{\thinspace\thinspace where\thinspace\thinspace}t=\frac{\frac{p_{2}^{f}}{p_{1}^{f}}}{\frac{p_{2}^{i}}{p_{1}^{i}}}
Proof.

Before we prove the statement, we will provide intuition for what tt signifies. We first define mm to be the exchange rate between tokens 11 and 22, so that mm is the price of token 22 in terms of token 11. Concretely, mf=p2fp1fm_{f}=\frac{p_{2}^{f}}{p_{1}^{f}} and mi=p2ip1im_{i}=\frac{p_{2}^{i}}{p_{1}^{i}}. The parameter tt is the quotient of the final and initial exchange rates. The further tt is away from 11, the more drastically the exchange rate between the tokens has changed.

To prove the claim, we can start by expressing the quantities in terms of prices. As noted above, with the assumption that arbitrageurs will drive the value of the pool to a minimum, we can use Lagrange multipliers to find the stable state xx as a function of pp. We see that A=(x2,x1)\nabla A=(x_{2},x_{1}), so solving

x2=λp1x1=λp2x1x2=k\begin{array}[]{ccccc}x_{2}=\lambda p_{1}&&x_{1}=\lambda p_{2}&&x_{1}x_{2}=k\end{array}

yields x1=kp2p1x_{1}=\sqrt{k}\sqrt{\frac{p_{2}}{p_{1}}} and x2=kp1p2x_{2}=\sqrt{k}\sqrt{\frac{p_{1}}{p_{2}}}. Substituting this back into the original equation, we get

IL=p1fkp2fp1f+p2fkp1fp2fp1fkp2ip1i+p2fkp1ip2i1=2p1fp2fp1fp2ip1i+p2fp1ip2i1IL=\frac{p_{1}^{f}\sqrt{k}\sqrt{\frac{p_{2}^{f}}{p_{1}^{f}}}+p_{2}^{f}\sqrt{k}\sqrt{\frac{p_{1}^{f}}{p_{2}^{f}}}}{p_{1}^{f}\sqrt{k}\sqrt{\frac{p_{2}^{i}}{p_{1}^{i}}}+p_{2}^{f}\sqrt{k}\sqrt{\frac{p_{1}^{i}}{p_{2}^{i}}}}-1=\frac{2\sqrt{p_{1}^{f}p_{2}^{f}}}{p_{1}^{f}\sqrt{\frac{p_{2}^{i}}{p_{1}^{i}}}+p_{2}^{f}\sqrt{\frac{p_{1}^{i}}{p_{2}^{i}}}}-1

Dividing the numerator and denominator by p1fp2f\sqrt{p_{1}^{f}p_{2}^{f}}, we get

IL=2p1fp2fp2ip1i+p2fp1fp1ip2i1IL=\frac{2}{\sqrt{\frac{p_{1}^{f}}{p_{2}^{f}}\sqrt{\frac{p_{2}^{i}}{p_{1}^{i}}}+\sqrt{\frac{p_{2}^{f}}{p_{1}^{f}}}\sqrt{\frac{p_{1}^{i}}{p_{2}^{i}}}}}-1

Using the definition that m=p2p1m=\frac{p_{2}}{p_{1}}, we obtain

IL=2mimf+mfmi1IL=\frac{2}{\frac{\sqrt{m_{i}}}{\sqrt{m_{f}}}+\frac{\sqrt{m_{f}}}{\sqrt{m_{i}}}}-1

Finally, letting t=mfmit=\frac{m_{f}}{m_{i}}, we arrive at the desired result.

As is well known, the above formula demonstrates that impermanent loss is least destructive when t=1t=1, that is when the exchange rate between tokens does not change (here IL=0IL=0). The key takeaway that we will try to generalize in what follows is that impermanent loss is best understood in terms of this one parameter tt, as opposed to the four parameters p1ip_{1}^{i}, p2ip_{2}^{i}, p1fp_{1}^{f} and p2fp_{2}^{f}.

3 Higher Dimensional Constant Product Market Makers

To gain an intuition for the parameters that should be used to conceptualize impermanent loss in higher dimensions, we start by proving a theorem involving an nn dimensional constant product market maker.

Theorem 4.

Consider a constant product market maker with assets x1,,xnx_{1},...,x_{n} where

A(x1,,xn)=x1xn=kA(x_{1},...,x_{n})=x_{1}...x_{n}=k

Let the initial prices of the assets be given by p1i,,pnip_{1}^{i},...,p_{n}^{i}, initial quantities x1i,,xnix_{1}^{i},...,x_{n}^{i}, final prices p1f,,pnfp_{1}^{f},...,p_{n}^{f}, and final quantities x1f,,xnfx_{1}^{f},...,x_{n}^{f}. The impermanent loss formula given by

IL=j=1npjfxjfj=1npjfxji1 reduces to nj=2ntj1n1+j=2ntj1 where tj=pjfp1fpjip1iIL=\frac{\sum_{j=1}^{n}p_{j}^{f}x_{j}^{f}}{\sum_{j=1}^{n}p_{j}^{f}x_{j}^{i}}-1\text{\thinspace\thinspace reduces to\thinspace\thinspace}\frac{n\prod_{j=2}^{n}t_{j}^{\frac{1}{n}}}{1+\sum_{j=2}^{n}t_{j}}-1\text{\thinspace\thinspace where\thinspace\thinspace}t_{j}=\frac{\frac{p_{j}^{f}}{p_{1}^{f}}}{\frac{p_{j}^{i}}{p_{1}^{i}}}
Proof.

We again start by expressing the quantities in terms of prices. To do so, similarly as in Example 3, we must solve the Lagrange multipliers equations:

jixj\displaystyle\prod_{j\neq i}x_{j} =\displaystyle= λpi  for each   i{1,,n}\displaystyle\lambda p_{i}\text{\thinspace\thinspace for each\thinspace\thinspace\ $i\in\{1,...,n\}$}
j=1nxj\displaystyle\prod_{j=1}^{n}x_{j} =\displaystyle= k\displaystyle k

Multiplying the first nn equations leads to the equation

j=1nxjn1\displaystyle\prod_{j=1}^{n}x_{j}^{n-1} =\displaystyle= λnj=1npj\displaystyle\lambda^{n}\prod_{j=1}^{n}p_{j}

and so

kn1=λnj=1npjk^{n-1}=\lambda^{n}\prod_{j=1}^{n}p_{j}

Thus, λ=kn1nj=1npj1n\lambda=k^{\frac{n-1}{n}}\prod_{j=1}^{n}p_{j}^{-\frac{1}{n}}. Dividing the last of the Lagrange multiplier (the constraint equation) by the jthj^{th} equation yields

xj=kλ1pj1x_{j}=k\lambda^{-1}p_{j}^{-1}

Since the impermanent loss formula involves pjxjp_{j}x_{j} expressions, it is convenient to note that

pjxj\displaystyle p_{j}x_{j} =\displaystyle= kλ1\displaystyle k\lambda^{-1}
=\displaystyle= k1nl=1npl1n\displaystyle k^{\frac{1}{n}}\prod_{l=1}^{n}p_{l}^{\frac{1}{n}}

This demonstrates that the stable state for a constant product market maker occurs when each collection of tokens in the AMM has the same value. Substituting this back into the original equation, we get

IL\displaystyle IL =\displaystyle= j=1npjfxjfj=1npjfxji1\displaystyle\frac{\sum_{j=1}^{n}p_{j}^{f}x_{j}^{f}}{\sum_{j=1}^{n}p_{j}^{f}x_{j}^{i}}-1
=\displaystyle= n(j=1npjf)1n(j=1npji)1nj=1npjfpji1\displaystyle\frac{n\left(\prod_{j=1}^{n}p_{j}^{f}\right)^{\frac{1}{n}}}{\left(\prod_{j=1}^{n}p_{j}^{i}\right)^{\frac{1}{n}}\sum_{j=1}^{n}\frac{p_{j}^{f}}{p_{j}^{i}}}-1
=\displaystyle= (j=1npjfpji)1n1nj=1npjfpji1\displaystyle\frac{\left(\prod_{j=1}^{n}\frac{p_{j}^{f}}{p_{j}^{i}}\right)^{\frac{1}{n}}}{\frac{1}{n}\sum_{j=1}^{n}\frac{p_{j}^{f}}{p_{j}^{i}}}-1

We now introduce the analogs to the exchange rates in Example 3 by defining mj=pjp1m_{j}=\frac{p_{j}}{p_{1}}, so that mjm_{j} is the exchange rate between tokens 11 and jj. Then, we see that

IL\displaystyle IL =\displaystyle= (j=1npjfpjip1ip1f)1n1nj=1npjfpjip1ip1f1\displaystyle\frac{\left(\prod_{j=1}^{n}\frac{p_{j}^{f}}{p_{j}^{i}}\frac{p_{1}^{i}}{p_{1}^{f}}\right)^{\frac{1}{n}}}{\frac{1}{n}\sum_{j=1}^{n}\frac{p_{j}^{f}}{p_{j}^{i}}\frac{p_{1}^{i}}{p_{1}^{f}}}-1
=\displaystyle= (j=1nmjfmji)1n1nj=1nmjfmji1\displaystyle\frac{\left(\prod_{j=1}^{n}\frac{m_{j}^{f}}{m_{j}^{i}}\right)^{\frac{1}{n}}}{\frac{1}{n}\sum_{j=1}^{n}\frac{m_{j}^{f}}{m_{j}^{i}}}-1
=\displaystyle= (j=1ntj)1n1nj=1ntj1\displaystyle\frac{\left(\prod_{j=1}^{n}t_{j}\right)^{\frac{1}{n}}}{\frac{1}{n}\sum_{j=1}^{n}t_{j}}-1

Thus, noting that t1=1t_{1}=1 yields the final result:

IL=Geometric Mean of the  tj’sArithmetic Mean of the  tj’s1IL=\frac{\text{Geometric Mean of the\thinspace\thinspace}t_{j}\text{'s}}{\text{Arithmetic Mean of the\thinspace\thinspace}t_{j}\text{'s}}-1

Similarly to Example 3, tjt_{j} is the quotient of the final exchange rate and initial exchange rate between assets jj and 11. The fact that the IL0IL\leq 0 for constant product market makers is a direct consequence of the arithmetic mean-geometric mean inequality applied to these exchange rate quotients. Again, the key takeaway is that impermanent loss is best understood in terms of these n1n-1 tjt_{j} parameters, not the 2n2n price parameters. This result has important economic implications in addition to its overall simplifying nature.

The parameter reduction in the impermanent loss formula from nn initial prices and nn final prices to n1n-1 quotients of exchange rates can be decomposed into two parts. The first reduction consists of using relative pricing of one asset against another as opposed to the raw prices (in our case, we have been pricing assets in terms of the first asset). This is typically referred to as numeraire independence in finance, but we will refer to it as price level independence. The next reduction takes us from separate relative initial and final exchange rates to quotients of final and initial exchange rates. We call this exchange rate level independence, since the absolute levels of the initial and final exchange rates do not matter, only the quotients. In the next section, we will show that impermanent loss for all AMMs exhibits price level independence, but not necessarily exchange rate level independence.

4 Price Level Independence

The goal of this section is to generalize the above idea of reducing the number of parameters involved in defining impermanent loss. We will begin by showing that impermanent loss for all AMMs is price level independent. Price level independence is intuitive and not particularly deep in its own right, but we wish to build towards understanding exchange rate level independence systematically. To this end, we need the following lemma, which formalizes the concept introduced in the background section that rescaling price vectors does not affect stable points. In this section, we think of there being a fixed measuring currency through which pp and hence V(x)V(x) are defined. In other words, 2p2p corresponds to a world in which all prices have doubled, not one in which the measuring currency has changed.

Lemma 5.

Let AA be an AMM and for fixed kk, consider the liquidity surface A=kA=k. We know that we can express the stable point on the A=kA=k surface as a function of price pp: x=x(p)x=x(p). The function x(p)x(p) is homogeneous of degree 0 in pp. In other words,

x(cp)=x(p)x(cp)=x(p)

for all c>0c>0, and so stable points are price level independent.

Proof.

Fix a price vector pp and c>0c>0. Let x=x(p)x^{*}=x(p). Then, xx^{*} satisfies the following Lagrange multiplier equations:

xA(x)\displaystyle\nabla_{x}A(x^{*}) =\displaystyle= λp\displaystyle\lambda p
A(x)\displaystyle A(x^{*}) =\displaystyle= k\displaystyle k

for some λ\lambda. It follows that xx^{*} satisfies

xA(x)\displaystyle\nabla_{x}A(x^{*}) =\displaystyle= λ~cp\displaystyle\tilde{\lambda}cp
A(x)\displaystyle A(x^{*}) =\displaystyle= k\displaystyle k

for λ~=λc\tilde{\lambda}=\frac{\lambda}{c}. By uniqueness of stable points, x(cp)=xx(cp)=x^{*}.

Price level independence for the impermanent loss of an AMM follows immediately.

Theorem 6.

The impermanent loss of an AMM exhibits price level independence. In other words, impermanent loss can be expressed entirely in terms of exchange rates of tokens relative to the first token (or any token for that matter).

Proof.
IL\displaystyle IL =\displaystyle= j=1npjfxj(pf)j=1npjfxj(pi)1\displaystyle\frac{\sum_{j=1}^{n}p_{j}^{f}x_{j}(p^{f})}{\sum_{j=1}^{n}p_{j}^{f}x_{j}(p^{i})}-1
=\displaystyle= j=1npjfp1fxj(pf)j=1npjfp1fxj(pi)1=j=1npjfp1fxj(pfp1f)j=1npjfp1fxj(pip1i)1\displaystyle\frac{\sum_{j=1}^{n}\frac{p_{j}^{f}}{p_{1}^{f}}x_{j}(p^{f})}{\sum_{j=1}^{n}\frac{p_{j}^{f}}{p_{1}^{f}}x_{j}(p^{i})}-1=\frac{\sum_{j=1}^{n}\frac{p_{j}^{f}}{p_{1}^{f}}x_{j}\left(\frac{p^{f}}{p_{1}^{f}}\right)}{\sum_{j=1}^{n}\frac{p_{j}^{f}}{p_{1}^{f}}x_{j}\left(\frac{p^{i}}{p_{1}^{i}}\right)}-1

where the last equality follows from the lemma. Using our previous notation and defining mj=pjp1m_{j}=\frac{p_{j}}{p_{1}}, we obtain

IL=j=1nmjfxj(mf)j=1nmjfxj(mi)1IL=\frac{\sum_{j=1}^{n}m_{j}^{f}x_{j}(m^{f})}{\sum_{j=1}^{n}m_{j}^{f}x_{j}(m^{i})}-1

Indeed, it is clear from the proof that we could express impermanent loss using exchange rates relative to any fixed asset. Along these lines, it will be convenient at times to change the base token from the first token to another of the nn tokens. In other words, we might define

mj=mj,k=pjpkm_{j}=m_{j,k}=\frac{p_{j}}{p_{k}}

so that we use the kthk^{\text{th}} token as the base token when computing exchange rates. In this case, mk=1m_{k}=1. To keep the notation uncluttered, though, we will suppress the kk and make sure that it is clear from context when important.

Example 7.

We will give context for the price level independence of impermanent loss through an example involving a two dimensional AMM A(x1,x2)A(x_{1},x_{2}). We make no assumptions about the specific formula for this AMM and we investigate a fixed liquidity curve A(x1,x2)=kA(x_{1},x_{2})=k. The price vectors pip^{i} and pfp^{f} are perpendicular to the liquidity curve at the initial and final stable states xix^{i} and xfx^{f} respectively. The above theorem formalizes the idea that impermanent loss can be understood using slopes alone. In other words, the sizes of the price vectors pip^{i} and pfp^{f} are irrelevant. If we use the second token as the base token, we see that the normalized versions of pip^{i} and pfp^{f} are (p1ip2i,1)\left(\frac{p_{1}^{i}}{p_{2}^{i}},1\right) and (p1fp2f,1)\left(\frac{p_{1}^{f}}{p_{2}^{f}},1\right) respectively. Thus, in two dimensions, each price vector is associated to a slope as is pictured, and these slopes are the negatives of the exchange rates. Instead of the four parameters p1ip_{1}^{i}, p2ip_{2}^{i}, p1fp_{1}^{f}, and p2fp_{2}^{f}, we only need two parameters: m1im_{1}^{i} and m1fm_{1}^{f}. Refer to Figure 4 for visualization.

Refer to caption
Figure 4: The tangent lines to the liquidity curve at xix^{i} and xfx^{f} are the negatives of these exchange rates. The blue and black lines are level curves of the value function V(x)=pfxV(x)=p^{f}\cdot x. It is convenient to use the x2x_{2} intercepts of these level curves to quantify value using the x2x_{2} currency.

Another way of interpreting Theorem 6 is that impermanent loss is agnostic to the measuring currency used for both pip^{i} and pfp^{f}. Indeed, we could use a different measuring currency for pip^{i} and pfp^{f} without affecting impermanent loss, though we will not do this. The above figure offers some insight into how we can choose the measuring currency so that V(x)=pxV(x)=p\cdot x can be gleaned geometrically. More concretely, if the x2x_{2} token is the measuring currency, the pool value is the x2x_{2} intercept111We could use any of the tokens as the measuring currency, and then the pool value would be the corresponding intercept value. of the line LL with the following properties:

  • LL passes through the current pool state

  • LL is perpendicular to pp

The slope of LL is the negative of the exchange rate between the two tokens. This line LL will be tangent to the A=kA=k curve if the pool state is the current stable state. In the above example, if the individual had just held their assets, the value of their assets would have been equivalent to the value of VHoldV_{\text{Hold}} x2x_{2} tokens. By providing liquidity, the value of their assets is instead VPoolV_{\text{Pool}} x2x_{2} tokens. This diagram makes it clear why the convexity condition for AMMs ensures that impermanent loss will always be negative.

5 The Legendre Transform and the Connection Between Value and State

As introduced in [AEC21], there is an elegant mathematical relationship between automated market makers and their corresponding portfolio value functions. In that paper, the relationship is formulated between the AMM A(x)A(x) and its value function V(x)V(x) via the Legendre-Fenchel transform. Example 7 motivates us to proceed a bit differently. The core object that we will work with instead of A(x)A(x) is f(x1,x2,xn1)f(x_{1},x_{2},\ldots x_{n-1}), which we will define as the function that defines the specific level curve (or surface) A(x)=kA(x)=k:

A(x1,,xn1,f(x1,,xn1))=kA(x_{1},\ldots,x_{n-1},f(x_{1},\ldots,x_{n-1}))=k

For those looking for a visual encapsulation of this section, and possibly to skip some of the rigmarole, the graphs at the end of this section illustrate the main ideas.

By our AMM assumptions and the implicit function theorem, xn=f(x1,x2,,xn1)x_{n}=f(x_{1},x_{2},\ldots,x_{n-1}) is a continuously differentiable surface. Henceforth, we will use the xnx_{n} token as the measuring currency through which pp and hence V(x)V(x) are defined. In other words, pn=1p_{n}=1 and pip_{i} is the exchange rate between token ii and token nn for 1in11\leq i\leq n-1. To maintain consistency with the previous section, we will use mi:=pim_{i}:=p_{i} to reference these exchange rates. Define V¯\bar{V} as

V(x1,,xn1)\displaystyle V(x_{1},\ldots,x_{n-1}) :=\displaystyle:= V(x1,,xn1,f(x1,,xn1))\displaystyle V(x_{1},\ldots,x_{n-1},f(x_{1},\ldots,x_{n-1}))
=\displaystyle= f(x1,,xn1)+j=1n1mjxj\displaystyle f(x_{1},\ldots,x_{n-1})+\sum_{j=1}^{n-1}m_{j}x_{j}

and define

W(m1,,mn1)\displaystyle W(m_{1},\ldots,m_{n-1}) :=\displaystyle:= V(x1(m1,,mn1,1),,xn1(m1,,mn1,1))\displaystyle V(x_{1}(m_{1},\ldots,m_{n-1},1),\ldots,x_{n-1}(m_{1},\ldots,m_{n-1},1))

In other words, given the exchange rates m1,m2,,mn1m_{1},m_{2},\ldots,m_{n-1}, a unique stable point xx is determined, and WW is the value of the corresponding stable portfolio. We will use xi(m1,,mn1,1)x_{i}(m_{1},\ldots,m_{n-1},1) interchangeably with xi(m1,,mn1)x_{i}(m_{1},\ldots,m_{n-1}), mainly to simplify notation and to avoid introducing new notation. From Example 7, we see that m1=f(x1(m1))-m_{1}=f^{\prime}(x_{1}(m_{1})). In other words, at stable points, we can obtain the exchange rate as the negative derivative of ff 222In Example 7, xfx^{f} is the stable point at the final exchange rate m1fm_{1}^{f}, while xix^{i} is not a stable point.. The following lemma proves and generalizes this observation to cases in which xx is a function of n1n-1 exchange rates.

Lemma 8.

With f(x1,x2,,xn1)f(x_{1},x_{2},\ldots,x_{n-1}) and mim_{i} for 1in11\leq i\leq n-1 defined as above, we have that

mi=fxi(x1(m1,,mn1),,xn1(m1,,mn1))-m_{i}=f_{x_{i}}(x_{1}(m_{1},\ldots,m_{n-1}),\ldots,x_{n-1}(m_{1},\ldots,m_{n-1}))
Proof.

For the stable point x(m)x(m), we have the Lagrange multiplier equations

xA(x(m))\displaystyle\nabla_{x}A(x(m)) =\displaystyle= λm\displaystyle\lambda m
A(x(m))\displaystyle A(x(m)) =\displaystyle= k\displaystyle k

for some λ\lambda. Differentiating the relation

A(x1,,xn1,f(x1,,xn1))=kA(x_{1},\ldots,x_{n-1},f(x_{1},\ldots,x_{n-1}))=k

with respect to xix_{i} yields

Axi(x1,,xn1,f(x1,,xn1))+Axn(x1,,xn1,f(x1,,xn1))fxi(x1,,xn1)=0A_{x_{i}}(x_{1},\ldots,x_{n-1},f(x_{1},\ldots,x_{n-1}))+A_{x_{n}}(x_{1},\ldots,x_{n-1},f(x_{1},\ldots,x_{n-1}))f_{x_{i}}(x_{1},\ldots,x_{n-1})=0
fxi(x1,,xn1)=Axi(x1,,xn1,f(x1,,xn1))Axn(x1,,xn1,f(x1,,xn1))\implies f_{x_{i}}(x_{1},\ldots,x_{n-1})=-\frac{A_{x_{i}}(x_{1},\ldots,x_{n-1},f(x_{1},\ldots,x_{n-1}))}{A_{x_{n}}(x_{1},\ldots,x_{n-1},f(x_{1},\ldots,x_{n-1}))}

Substituting xi(m1,,mn1)x_{i}(m_{1},\ldots,m_{n-1}) into the above yields

fxi(x1(m1,,mn1),,xn1(m1,,mn1))=λmiλ=mif_{x_{i}}(x_{1}(m_{1},\ldots,m_{n-1}),\ldots,x_{n-1}(m_{1},\ldots,m_{n-1}))=-\frac{\lambda m_{i}}{\lambda}=-m_{i}

and so the result is proved.

The next lemma frames the same relationship from the viewpoint that the mim_{i} are functions of the xix_{i}.

Lemma 9.

With f(x1,x2,,xn1)f(x_{1},x_{2},\ldots,x_{n-1}) defined as above and the mi(x1,,xn1)m_{i}(x_{1},\ldots,x_{n-1}) functions for 1in11\leq i\leq n-1 defined as the natural inverses to the xi(m1,,mn1)x_{i}(m_{1},\ldots,m_{n-1}) functions, we have that

mi(x1,,xn1)=fxi(x1,,xn1)m_{i}(x_{1},\ldots,x_{n-1})=-f_{x_{i}}(x_{1},\ldots,x_{n-1})
Proof.

From Lemma 8, it is clear that the map

(m1,,mn1)(x1(m1,,mn1),,xn1(m1,,mn1))(m_{1},\ldots,m_{n-1})\mapsto(x_{1}(m_{1},\ldots,m_{n-1}),\ldots,x_{n-1}(m_{1},\ldots,m_{n-1}))

is injective. Thus, mi(x1,,xn1)m_{i}(x_{1},\ldots,x_{n-1}) for 1in11\leq i\leq n-1 is well defined and plugging these expressions into both sides of the equality in Lemma 8 yields the result.

The following theorem gives a precise formulation of how A(x1,,xn1)A(x_{1},\ldots,x_{n-1}) and W(m1,,mn1)W(m_{1},\ldots,m_{n-1}) are dual functions. For readers unfamiliar with the Legendre transform, the remainder of the paper is self-contained: all properties that we need are readily derived from the formulas that we have established. As such, the following theorem is just a form of mental bookkeeping. We recommend [ZRM09] as a useful resource to learn more about the Legendre transform and its applications.

Theorem 10.

Denote the Legendre transform of a function g(x1,,xn1)g(x_{1},\ldots,x_{n-1}) in all of its variables as (g)\mathcal{L}(g). In other words,

(g)(m1,,mn1):=g(x1(m1,,mn1),,xn1(m1,,mn1))+i=1n1mixi(m1,,mn1)\mathcal{L}(g)(m_{1},\ldots,m_{n-1}):=-g(x_{1}(m_{1},\ldots,m_{n-1}),\ldots,x_{n-1}(m_{1},\ldots,m_{n-1}))+\sum_{i=1}^{n-1}m_{i}x_{i}(m_{1},\ldots,m_{n-1})

where mim_{i} is defined as

mi(x1,,xn1):=gxi(x1,,xn1)m_{i}(x_{1},\ldots,x_{n-1}):=-g_{x_{i}}(x_{1},\ldots,x_{n-1})

We then have that

(f)=W\mathcal{L}(f)=W
Proof.

The result follows from Lemma 8.

Again, the relationship between AA and VV via the Legendre-Fenchel transform was pointed out in [AEC21], and this observation accounts for the heavy lifting. It can be cumbersome in some settings, however, to think in terms of AA (a family of level curves or surfaces) as opposed to the single AMM surface given by xn=f(x1,,xn1)x_{n}=f(x_{1},\ldots,x_{n-1}). For instance, to replicate a payoff function W(x1,,xn1)W(x_{1},\ldots,x_{n-1}), one can extend WW to VV via 1-homogeneity, transform VV via the Legendre-Fenchel transform into an A~\tilde{A}, and then manipulate A~\tilde{A} to obtain a more amenable AMM form AA. Alternatively, one can use Theorem 10 to pass from WW to ff directly. The graphs in Figure 5 illustrate the relationship between ff and WW in two dimensions.

Refer to caption Refer to caption
Figure 5: A level curve of an AMM A(x1,x2)=kA(x_{1},x_{2})=k is displayed, with f(x1)f(x_{1}) satisfying A(x1,f(x1))=kA(x_{1},f(x_{1}))=k. For a given exchange rate m1m_{1}, there is an easy way to see what the value of the arbitrageur driven portfolio will be. This value is W~\tilde{W} and it is measured using x2x_{2} tokens. The (m~1,W~)(\tilde{m}_{1},\tilde{W}) pair is plotted in the bottom graph. By convexity, for every m1m_{1}, there will be a unique WW, and stitching these points together yields the Legendre transform pictured in the graph on the right.

6 Exchange Rate Level Independence

In general, price level independence of impermanent loss allows us to reduce the number of parameters from 2n2n to 2(n1)2(n-1). When we derived the impermanent loss formula for the nn-dimensional constant product market maker, however, we were able to reduce the number of relevant parameters even further to n1n-1. These n1n-1 parameters were quotients of the initial and final exchange rates (relative to a fixed token).

Definition 11.

Let AA be an AMM and fix a liquidity surface A=kA=k. Let pi,pfp^{i},p^{f} be price vectors and denote the corresponding stable states xi,xfx^{i},x^{f}. Define mj=pjpnm_{j}=\frac{p_{j}}{p_{n}} and tj=mjfmjit_{j}=\frac{m_{j}^{f}}{m_{j}^{i}}. We say that the AMM is exchange rate level independent (i.e. ERLI) if ILIL can be rewritten as a function of the exchange rate quotients t1,,tnt_{1},...,t_{n} (where tnt_{n} can be omitted because it is always equal to 11).

In other words, the AMM satisfies the ERLI conditions if its impermanent loss can be written purely as a function of exchange rate quotients. Before proceeding, let us consider an example that does not meet this requirement.

Example 12.

The Curve StableSwap AMM introduced in [Ego19] does not satisfy the ERLI condition. We will demonstrate this by using their proposed two dimensional AMM with parameter A=1A=1 (not to be confused with the AA that we have been using to denote our AMM). The D=1D=1 level curve of this AMM (where we use the notation from the paper) is given by

4(x1+x2)+1=4+14x1x24(x_{1}+x_{2})+1=4+\frac{1}{4x_{1}x_{2}}

which can be simplified to

16x12x2+16x1x2212x1x2=116x_{1}^{2}x_{2}+16x_{1}x_{2}^{2}-12x_{1}x_{2}=1

Note that

x2=12x116x12+256x14384x13+144x12+64x132x1x_{2}=\frac{12x_{1}-16x_{1}^{2}+\sqrt{256x_{1}^{4}-384x_{1}^{3}+144x_{1}^{2}+64x_{1}}}{32x_{1}}

is not homogeneous in x1x_{1}. There is a better way to see this without solving for x2x_{2}. Assume for a contradiction that x2=cx1αx_{2}=cx_{1}^{\alpha} for some cc. Then,

c1x1α+2+c2x12α+1+c3xα+1+c4=0c_{1}x_{1}^{\alpha+2}+c_{2}x_{1}^{2\alpha+1}+c_{3}x^{\alpha+1}+c_{4}=0

for all x1x_{1} and some nonzero constants c1,c2,c3,c_{1},c_{2},c_{3}, and c4c_{4}. This is impossible since the x1max{α+2,2α+1,0}x_{1}^{\max\{\alpha+2,2\alpha+1,0\}} term will grow unchecked in x1x_{1}. In this section, we will show that the lack of homogeneity of x2=f(x1)x_{2}=f(x_{1}) implies that the impermanent loss function for this liquidity curve does not satisfy the ERLI condition.

Our first goal will be to write impermanent loss in terms of the value function WW defined in the previous section. To this end, we need the following lemma. We warn the reader of the notational simplification

m\displaystyle m =\displaystyle= (m1,,mn1,1)=(m1,,mn1)\displaystyle(m_{1},\ldots,m_{n-1},1)=(m_{1},\ldots,m_{n-1})
x\displaystyle x =\displaystyle= (x1,,xn1,xn)=(x1,,xn1)\displaystyle(x_{1},\ldots,x_{n-1},x_{n})=(x_{1},\ldots,x_{n-1})

and define ff and WW as in the previous section.

Lemma 13.

For 1jn11\leq j\leq n-1, we have

xj(m)=Wmj(m)x_{j}(m)=W_{m_{j}}(m)
Proof.

We start with relation

W(m)f(x1(m),,xn1(m))=i=1n1mixi(m)W(m)-f(x_{1}(m),\ldots,x_{n-1}(m))=\sum_{i=1}^{n-1}m_{i}x_{i}(m)

and differentiate both sides of the equality with respect to mjm_{j} to obtain

Wmj(m)i=1n1fxi(x1(m),,xn1(m))[xi]mj(m)=xj(m)+i=1n1mi[xi]mj(m)W_{m_{j}}(m)-\sum_{i=1}^{n-1}f_{x_{i}}(x_{1}(m),\ldots,x_{n-1}(m))[x_{i}]_{m_{j}}(m)=x_{j}(m)+\sum_{i=1}^{n-1}m_{i}[x_{i}]_{m_{j}}(m)

which yields the result since

fxi(x1(m),,xn1(m))=mi-f_{x_{i}}(x_{1}(m),\ldots,x_{n-1}(m))=m_{i}

for 1in11\leq i\leq n-1.

We are now ready to recast impermanent loss in terms of WW.

Theorem 14.

The expression for impermanent loss in terms of WW is

IL=W(mf)P(mf)1IL=\frac{W(m^{f})}{P(m^{f})}-1

where PP is the linear approximation to WW at mim^{i}.

Proof.

From Theorem 6, we have

IL\displaystyle IL =\displaystyle= j=1nmjfxj(mf)j=1nmjfxj(mi)1\displaystyle\frac{\sum_{j=1}^{n}m_{j}^{f}x_{j}(m^{f})}{\sum_{j=1}^{n}m_{j}^{f}x_{j}(m^{i})}-1
=\displaystyle= xn(mf)+j=1n1mjfxj(mf)j=1n(mjfmji)xj(mi)+j=1nmjixj(mi)1\displaystyle\frac{x_{n}(m^{f})+\sum_{j=1}^{n-1}m_{j}^{f}x_{j}(m^{f})}{\sum_{j=1}^{n}(m_{j}^{f}-m_{j}^{i})x_{j}(m^{i})+\sum_{j=1}^{n}m_{j}^{i}x_{j}(m^{i})}-1
=\displaystyle= f(x1(mf),,xn1(mf))+j=1n1mjfxj(mf)[j=1n1(mjfmji)xj(mi)]+f(x1(mi),,xn1(mi))+j=1n1mjixj(mi)1\displaystyle\frac{f(x_{1}(m^{f}),\ldots,x_{n-1}(m^{f}))+\sum_{j=1}^{n-1}m_{j}^{f}x_{j}(m^{f})}{\left[\sum_{j=1}^{n-1}(m_{j}^{f}-m_{j}^{i})x_{j}(m^{i})\right]+f(x_{1}(m^{i}),\ldots,x_{n-1}(m^{i}))+\sum_{j=1}^{n-1}m_{j}^{i}x_{j}(m^{i})}-1
=\displaystyle= W(mf)W(mi)+j=1n1(mjfmji)xj(mi)1\displaystyle\frac{W(m^{f})}{W(m^{i})+\sum_{j=1}^{n-1}(m_{j}^{f}-m_{j}^{i})x_{j}(m^{i})}-1
=\displaystyle= W(mf)W(mi)+j=1n1(mjfmji)Wmj(mi)1\displaystyle\frac{W(m^{f})}{W(m^{i})+\sum_{j=1}^{n-1}(m_{j}^{f}-m_{j}^{i})W_{m_{j}}(m^{i})}-1

where we have used Lemma 13 to obtain the final equality.

We will finish the section by providing a necessary and sufficient condition on AA for its impermanent loss to satisfy the ERLI condition. To this end, we need a lemma that connects the homogeneity properties of ff to the homogeneity properties of WW.

Lemma 15.

The following two statements are equivalent.

  1. 1.

    For each 1jn11\leq j\leq n-1, f(x1,,xn1)f(x_{1},\ldots,x_{n-1}) is homogeneous of degree αj\alpha_{j} in xjx_{j}.

  2. 2.

    For each 1jn11\leq j\leq n-1, W(m1,,mn1)W(m_{1},\ldots,m_{n-1}) is homogeneous of degree βj\beta_{j} in mjm_{j}.

Furthermore,

βj=αj1+i=1n1αi\beta_{j}=\frac{\alpha_{j}}{-1+\sum_{i=1}^{n-1}\alpha_{i}}

Note that the case that i=1n1αi=1\sum_{i=1}^{n-1}\alpha_{i}=1 is precluded by the condition that the AMM is strictly convex333To see this, consider the straight line parametric path r(t)r(t) in n1\mathbb{R}^{n-1} given by xi(t)=tx_{i}(t)=t, for 1in11\leq i\leq n-1. If i=1n1αi=1\sum_{i=1}^{n-1}\alpha_{i}=1, then f(r(t))=ctf(r(t))=ct for some constant cc. Fix 0<λ<10<\lambda<1. For any points p=(a,,a)p=(a,\ldots,a) and q=(b,,b)q=(b,\ldots,b) falling on r(t)r(t), λf(p)+(1λ)f(q)=λca+(1λ)cb=c(λa+(1λ)b)=f(λp+(1λ)q)\lambda f(p)+(1-\lambda)f(q)=\lambda ca+(1-\lambda)cb=c(\lambda a+(1-\lambda)b)=f(\lambda p+(1-\lambda)q). .

Proof.

From the way that x(m)x(m) was originally defined, it is clear that W(m)W(m) is the solution to the following value minimization problem

W(m)=minxn1[mx+f(x)]W(m)=\min_{x\in\mathbb{R}^{n-1}}\left[m\cdot x+f(x)\right]

Assume that the first statement holds. Then, with βj\beta_{j} defined as in the statement of the theorem,

W(m1,,cmj,,mn1)\displaystyle W(m_{1},\ldots,cm_{j},\ldots,m_{n-1}) =\displaystyle= minxn1[cmjxj+ijmixi+f(x1,,xj,,xn1)]\displaystyle\min_{x\in\mathbb{R}^{n-1}}\left[cm_{j}x_{j}+\sum_{i\neq j}m_{i}x_{i}+f(x_{1},\ldots,x_{j},\ldots,x_{n-1})\right]
=\displaystyle= minxn1[i=1n1mixi+f(x1,,c1xj,,xn1)]\displaystyle\min_{x\in\mathbb{R}^{n-1}}\left[\sum_{i=1}^{n-1}m_{i}x_{i}+f(x_{1},\ldots,c^{-1}x_{j},\ldots,x_{n-1})\right]
=\displaystyle= minxn1[i=1n1mixi+cαjf(x1,,xj,,xn1)]\displaystyle\min_{x\in\mathbb{R}^{n-1}}\left[\sum_{i=1}^{n-1}m_{i}x_{i}+c^{-\alpha_{j}}f(x_{1},\ldots,x_{j},\ldots,x_{n-1})\right]
=\displaystyle= minxn1[i=1n1mixi+cβjf(cβjx1,,cβjxj,,cβjxn1)]\displaystyle\min_{x\in\mathbb{R}^{n-1}}\left[\sum_{i=1}^{n-1}m_{i}x_{i}+c^{\beta_{j}}f(c^{-\beta_{j}}x_{1},\ldots,c^{-\beta_{j}}x_{j},\ldots,c^{-\beta_{j}}x_{n-1})\right]
=\displaystyle= minxn1[i=1n1micβjxi+cβjf(x1,,xj,,xn1)]\displaystyle\min_{x\in\mathbb{R}^{n-1}}\left[\sum_{i=1}^{n-1}m_{i}c^{\beta_{j}}x_{i}+c^{\beta_{j}}f(x_{1},\ldots,x_{j},\ldots,x_{n-1})\right]
=\displaystyle= cβjW(m1,,mj,,mn1)\displaystyle c^{\beta_{j}}W(m_{1},\ldots,m_{j},\ldots,m_{n-1})

Thus, we have shown that statement 11 implies statement 22. For the other direction, we note that

f(x)=maxmn1[V(m)mx]f(x)=\max_{m\in\mathbb{R}^{n-1}}\left[V(m)-m\cdot x\right] (1)

To see this, we can unpack the meanings of f(x)f(x) and V(m)mxV(m)-m\cdot x. Fix x=(x1,,xn1)x=(x_{1},\ldots,x_{n-1}) as the quantities for tokens 11 through n1n-1 in the AMM. Then: V(m)V(m) is the overall value in the AMM (measured in xnx_{n} tokens) at the stable point corresponding to exchange rate vector mm, and mxm\cdot x is the value of tokens tokens 11 through n1n-1 (measured in xnx_{n} tokens) assuming exchange rate vector mm. Thus, V(m)mxV(m)-m\cdot x is maximized by the exchange vector mm that allows for the most xnx_{n} tokens. This exchange rate vector mm corresponds to the world with the most profitable “hold” strategy. There are other more technical ways to show that above equation holds, but we omit these for expository flow. Using equation (1), we can prove the other direction of the lemma in an analogous manner to the first direction.

We need two final lemmas relating the homogeneity of AA to the homogeneity of ff before proceeding with the final theorem of this section.

Lemma 16.

If AA is homogeneous in each of its nn coordinates, then ff is homogeneous in each of its n1n-1 inputs.

Proof.

Assume that AA is homogeneous of degree γl\gamma_{l} in xlx_{l} for all 1ln1\leq l\leq n. Then,

k\displaystyle k =\displaystyle= A(x1,,xn)\displaystyle A(x_{1},\ldots,x_{n})
=\displaystyle= A(1,,1)x1γ1xnγn\displaystyle A(1,\ldots,1)x_{1}^{\gamma_{1}}\ldots x_{n}^{\gamma_{n}}

implying by uniqueness that

xn=f(x1,,xn1)=[kA(1,,1)]1γnx1γ1γnxn1γn1γnx_{n}=f(x_{1},\ldots,x_{n-1})=\left[\frac{k}{A(1,\ldots,1)}\right]^{-\frac{1}{\gamma_{n}}}x_{1}^{-\frac{\gamma_{1}}{\gamma_{n}}}\ldots x_{n-1}^{-\frac{\gamma_{n-1}}{\gamma_{n}}}

Lemma 17.

Assume for each kk, the function xn=f(x1,,xn1)x_{n}=f(x_{1},\ldots,x_{n-1}) induced by A=kA=k is homogeneous in each of its n1n-1 coordinates444Technically, ff should be subscripted by kk, but we drop the kk to simplify notation.. Then, there is a function B(x1,,xn)B(x_{1},\ldots,x_{n}) that is homogeneous in each of its coordinates and such that A(x)=g(B(x))A(x)=g(B(x)), where gg is a smooth function of one variable.

Proof.

For a fixed kk, assume that ff is homogeneous of degree λl\lambda_{l} for 1ln11\leq l\leq n-1. We start with

xn=f(x1,,xn1)=Cx1λ1xn1λn1x_{n}=f(x_{1},\ldots,x_{n-1})=Cx_{1}^{\lambda_{1}}\ldots x_{n-1}^{\lambda_{n-1}}

and proceed to obtain

C~=x1γ1xn1γn1xn\tilde{C}=x_{1}^{\gamma_{1}}\ldots x_{n-1}^{\gamma_{n-1}}x_{n}

where γj=λj\gamma_{j}=-\lambda_{j} for 1jn11\leq j\leq n-1. Observe that all level surfaces A=kA=k can be expressed using the same γ\gamma exponents since, otherwise, the level surfaces would cross. In other words, setting two surface equations like the one above with different C~\tilde{C}’s equal to one another would lead to solutions:

Cx1λ1xn1λn1\displaystyle Cx_{1}^{\lambda_{1}}\ldots x_{n-1}^{\lambda_{n-1}} =\displaystyle= C~x1λ~1xn1λ~n1\displaystyle\tilde{C}x_{1}^{\tilde{\lambda}_{1}}\ldots x_{n-1}^{\tilde{\lambda}_{n-1}}
x1r1xn1rn1\displaystyle x_{1}^{r_{1}}\ldots x_{n-1}^{r_{n-1}} =\displaystyle= C^\displaystyle\hat{C}

Define B(x)=x1γ1xn1γn1xnB(x)=x_{1}^{\gamma_{1}}\ldots x_{n-1}^{\gamma_{n-1}}x_{n}. Then AA and BB have the same level surfaces and gg can be defined accordingly.

We are now ready to state a necessary and sufficient condition on AA that ensures that its impermanent loss will satisfy the ERLI condition.

Theorem 18.

Let AA be an AMM. Then A=g(B)A=g(B), where gg is a smooth function of one real variable and BB is homogeneous in each coordinate if and only if the formula for impermanent loss is ERLI for every liquidity surface A=kA=k.

Proof.

We start with the forward direction. Fix kk. Without loss of generality, we can assume that AA is homogeneous in each coordinate since A=kA=k corresponds to some B=k~B=\tilde{k}. By Lemma 16, ff is homogeneous in each of its n1n-1 coordinates, and so then by Lemma 15, WW is homogeneous in each of its n1n-1 coordinates. Say that WW is homogeneous of degree αj\alpha_{j} in mjm_{j}. Defining tj=mjfmjit_{j}=\frac{m_{j}^{f}}{m_{j}^{i}} for 1jn11\leq j\leq n-1 and invoking Theorem 14, we have

IL\displaystyle IL =\displaystyle= W(mf)W(mi)+j=1n1(mjfmji)Wmj(mi)1\displaystyle\frac{W(m^{f})}{W(m^{i})+\sum_{j=1}^{n-1}(m_{j}^{f}-m_{j}^{i})W_{m_{j}}(m^{i})}-1
=\displaystyle= j=1n1[mji]αjj=1n1[mji]αjW(t)W(1,,1)+j=1n1(tj1)Wmj(1,,1)1\displaystyle\frac{\prod_{j=1}^{n-1}\left[m_{j}^{i}\right]^{\alpha_{j}}}{\prod_{j=1}^{n-1}\left[m_{j}^{i}\right]^{\alpha_{j}}}\frac{W(t)}{W(1,\ldots,1)+\sum_{j=1}^{n-1}(t_{j}-1)W_{m_{j}}(1,\ldots,1)}-1
=\displaystyle= W(t)W(1,,1)+j=1n1(tj1)Wmj(1,,1)1\displaystyle\frac{W(t)}{W(1,\ldots,1)+\sum_{j=1}^{n-1}(t_{j}-1)W_{m_{j}}(1,\ldots,1)}-1

where in the second equality we have used the fact that WmjW_{m_{j}} is homogeneous of degree αk\alpha_{k} in mkm_{k} if kjk\neq j and is homogeneous of degree αj1\alpha_{j}-1 in mjm_{j}. Thus, noting that IL has been expressed entirely in terms of the exchange rate ratios tjt_{j}, the forward direction is complete.

Fix kk and consider the surface A=kA=k with induced function xn=f(x1,,xn1)x_{n}=f(x_{1},\ldots,x_{n-1}). For the reverse direction, by Lemma 17, it suffices to show that ff is homogeneous in each of its n1n-1 coordinates. By Lemma 15, it then suffices to show that WW is homogeneous in each of its n1n-1 coordinates. Choose a coordinate mlm_{l} and fix c0c\neq 0. Fix all other coordinates aside from mlm_{l} in defining the following functions:

A(ml)\displaystyle A(m_{l}) =\displaystyle= W(m1,,ml,,mn1)\displaystyle W(m_{1},\ldots,m_{l},\ldots,m_{n-1})
B(ml)\displaystyle B(m_{l}) =\displaystyle= W(m1,,cml,,mn1)\displaystyle W(m_{1},\ldots,cm_{l},\ldots,m_{n-1})

The fact that impermanent loss is ERLI for the surface A=kA=k implies that

A(mlf)A(mli)+(mlfmli)A(mli)\displaystyle\frac{A(m_{l}^{f})}{A(m_{l}^{i})+(m_{l}^{f}-m_{l}^{i})A^{\prime}(m_{l}^{i})} =\displaystyle= B(mlf)B(mli)+(cmlfcmli)A(cmli)\displaystyle\frac{B(m_{l}^{f})}{B(m_{l}^{i})+(cm_{l}^{f}-cm_{l}^{i})A^{\prime}(cm_{l}^{i})}
=\displaystyle= B(mlf)B(mli)+(mlfmli)B(mli)\displaystyle\frac{B(m_{l}^{f})}{B(m_{l}^{i})+(m_{l}^{f}-m_{l}^{i})B^{\prime}(m_{l}^{i})}

for all mli,mlfm_{l}^{i},m_{l}^{f}\in\mathbb{R}. Thus, substituting mlf=1m_{l}^{f}=1 and mli=sm_{l}^{i}=s yields

A(1)A(s)+(1s)A(s)=B(1)B(s)+(1s)B(s)\frac{A(1)}{A(s)+(1-s)A^{\prime}(s)}=\frac{B(1)}{B(s)+(1-s)B^{\prime}(s)}

which simplifies to

(s1)[MA(s)B(s)]=[MA(s)B(s)](s-1)\left[MA^{\prime}(s)-B^{\prime}(s)\right]=\left[MA(s)-B(s)\right]

with M=B(1)A(1)M=\frac{B(1)}{A(1)}. Defining C(s)=MA(s)B(s)C(s)=MA(s)-B(s), we obtain the ODE

C(s)=C(s)s1C^{\prime}(s)=\frac{C(s)}{s-1}

This is a simple separable ODE with solutions of the form

C(s)=E(s1)C(s)=E(s-1)

for constant EE555EE might depend on mjm_{j} for jlj\neq l.. Note that even though the ODE has a singularity at s=1s=1, from its direction field, it is clear that the only differentiable functions that satisfy it are of this form. Using the fact that the equation C(0)=MA(0)B(0)=0C(0)=MA(0)-B(0)=0 holds, we conclude that E=0E=0 and hence that

A(s)=MB(s)=MA(cs)A(s)=MB(s)=MA(cs) (2)

The homogeneity of WW in mlm_{l} will follow from this equation, but there is a bit more work to do to see this. Since MM depends on cc, we have established that

A(cs)=g(c)A(s)A(cs)=g(c)A(s)

for some function gg. It turns out that this is enough to show that A(s)A(s) is homogeneous since gg satisfies the property g(ab)=g(a)g(b)g(ab)=g(a)g(b):

A(abs)\displaystyle A(abs) =\displaystyle= g(ab)A(s)\displaystyle g(ab)A(s)
=\displaystyle= g(a)A(bs)=g(a)g(b)A(s)\displaystyle g(a)A(bs)=g(a)g(b)A(s)

Thus, gg is a solution to Cauchy’s multiplicative functional equation and this implies that g(c)=cγg(c)=c^{\gamma} for some γ\gamma. For more background on such equations, consult [Kuc09].

Note that we are still not quite done. We have shown that A(cs)=cγA(s)A(cs)=c^{\gamma}A(s), but our γ\gamma may in theory depend on the mjm_{j} for jlj\neq l. To see that this is not the case, fix two vectors (m1a,,ml1a,ml+1a,,mn1a)(m_{1}^{a},\ldots,m_{l-1}^{a},m_{l+1}^{a},...,m_{n-1}^{a}) and (m1b,,ml1b,ml+1b,,mn1b)(m_{1}^{b},\ldots,m_{l-1}^{b},m_{l+1}^{b},...,m_{n-1}^{b}) in n2\mathbb{R}^{n-2}. We know that

W(m1a,,cml,,mn1a)\displaystyle W(m_{1}^{a},\ldots,cm_{l},\ldots,m_{n-1}^{a}) =\displaystyle= cγaW(m1a,,ml,,mn1a)\displaystyle c^{\gamma_{a}}W(m_{1}^{a},\ldots,m_{l},\ldots,m_{n-1}^{a})
W(m1b,,cml,,mn1b)\displaystyle W(m_{1}^{b},\ldots,cm_{l},\ldots,m_{n-1}^{b}) =\displaystyle= cγbW(m1b,,ml,,mn1b)\displaystyle c^{\gamma_{b}}W(m_{1}^{b},\ldots,m_{l},\ldots,m_{n-1}^{b})

The fact that impermanent loss is ERLI for the surface A=kA=k implies that

cγaW(m1a,,1,,mn1a)W(m1a,,1,,mn1a)+(c1)Wml(m1a,,1,,mn1a)=W(m1a,,c,,mn1a)W(m1a,,1,,mn1a)+(c1)Wml(m1a,,1,,mn1a)=W(m1b,,c,,mn1b)W(m1b,,1,,mn1b)+(c1)Wml(m1b,,1,,mn1b)=cγbW(m1b,,1,,mn1b)W(m1b,,1,,mn1b)+(c1)Wml(m1b,,1,,mn1b)\begin{array}[]{c}\frac{c^{\gamma_{a}}W(m_{1}^{a},\ldots,1,\ldots,m_{n-1}^{a})}{W(m_{1}^{a},\ldots,1,\ldots,m_{n-1}^{a})+(c-1)W_{m_{l}}(m_{1}^{a},\ldots,1,\ldots,m_{n-1}^{a})}\\ =\frac{W(m_{1}^{a},\ldots,c,\ldots,m_{n-1}^{a})}{W(m_{1}^{a},\ldots,1,\ldots,m_{n-1}^{a})+(c-1)W_{m_{l}}(m_{1}^{a},\ldots,1,\ldots,m_{n-1}^{a})}\\ =\frac{W(m_{1}^{b},\ldots,c,\ldots,m_{n-1}^{b})}{W(m_{1}^{b},\ldots,1,\ldots,m_{n-1}^{b})+(c-1)W_{m_{l}}(m_{1}^{b},\ldots,1,\ldots,m_{n-1}^{b})}\\ =\frac{c^{\gamma_{b}}W(m_{1}^{b},\ldots,1,\ldots,m_{n-1}^{b})}{W(m_{1}^{b},\ldots,1,\ldots,m_{n-1}^{b})+(c-1)W_{m_{l}}(m_{1}^{b},\ldots,1,\ldots,m_{n-1}^{b})}\end{array}

Absorbing terms depending on mjam_{j}^{a} and mjbm_{j}^{b} into constants yields

cγaK1aK2a+cK3a=cγbK1bK2b+cK3b\frac{c^{\gamma_{a}}K_{1}^{a}}{K_{2}^{a}+cK_{3}^{a}}=\frac{c^{\gamma_{b}}K_{1}^{b}}{K_{2}^{b}+cK_{3}^{b}}

and once more simplified, an equation of the form

J1cγa+1+J2cγa+J3cγb+1+J4cγb=0,J_{1}c^{\gamma_{a}+1}+J_{2}c^{\gamma_{a}}+J_{3}c^{\gamma_{b}+1}+J_{4}c^{\gamma_{b}}=0,

where the JJs and KKs are constants that depend on the mjam_{j}^{a}s and mjbm_{j}^{b}s. By the strict concavity of WW (established by the relation in Lemma 15), it is clear that J1J_{1}, J2J_{2}, J3J_{3}, and J4J_{4} are nonzero. As such, for the above equation to hold for all cc, J1=J3J_{1}=-J_{3}, J2=J4J_{2}=-J_{4}, and

γa=γb\gamma_{a}=\gamma_{b}

The following corollaries are useful when it is not immediately obvious whether AA is of the form g(B)g(B) with BB homogeneous in each of its coordinates.

Corollary 19.

Let AA be an AMM. Let A=kA=k be a liquidity surface and let xn=f(x1,,xn1)x_{n}=f(x_{1},\ldots,x_{n-1}) be the function that it induces. Then ff is homogeneous in each of its coordinates if and only if the impermanent loss for A=kA=k is ERLI.

Corollary 20.

Geometric mean market makers and compositions of these market makers with smooth real valued functions compose the space of ERLI market makers.

7 Conclusion

In this paper, we have established a framework for reducing the parameters involved in describing impermanent loss for automated market makers. In doing so, we have shown that geometric mean market makers are the simplest class of market makers from an impermanent loss standpoint. More concretely, G3Ms exhibit a condition that we call Exchange Rate Level Independence (ERLI). ERLI is an interesting property in that it is connected to how the dynamics of AMMs are affected when token quantities are rescaled. Such rescalings can be done for either conceptual or computational purposes. An example of this sort of rescaling transformation can be found in the Curve V2 whitepaper [Ego21] and we believe that this mechanism also shifts Curve V2’s impermanent loss profile to a new profile that is closer to having ERLI. We will work to quantify this in future work, and more generally, we are interested in exploring how to extend our framework to dynamic AMMs.

8 Acknowledgements

The authors would like to thank Jamie Irvine for several interesting conversations and for his insight regarding a critical lemma in this paper. We would also like to thank Austin Pollok for sharing his insights regarding parallels between DeFi and TradFi. Finally, we would like to thank Guillermo Angeris for sharing his ideas and useful feedback with us.

References

  • [AC20] Guillermo Angeris and Tarun Chitra. Improved price oracles: Constant function market makers. In Proceedings of the 2nd ACM Conference on Advances in Financial Technologies, pages 80–91, 2020.
  • [AD21] Andreas A Aigner and Gurvinder Dhaliwal. Uniswap: Impermanent loss and risk profile of a liquidity provider.arXiv preprint arXiv:2106.14404, 2021.
  • [Ada18] Hayden Adams. Uniswap whitepaper. URL: https://hackmd.io/C-DvwDSfSxuh-Gd4WKEig, 2018.
  • [AEC20] Guillermo Angeris, Alex Evans, and Tarun Chitra. When does the tail wag the dog? Curvature and market making. arXiv preprint arXiv:2012.08040, 2020.
  • [AEC21] Guillermo Angeris, Alex Evans, and Tarun Chitra. Replicating market makers, 2021.
  • [Aoy20] Jun Aoyagi. Liquidity provision by automated market makers. Available at SSRN 3674178,2020.
  • [Bou21] Nassib Boueri. G3m impermanent loss dynamics. arXiv preprint arXiv:2108.06593, 2021.
  • [CJ21] Agostino Capponi and Ruizhe Jia. The adoption of blockchain-based decentralized exchanges, 2021.
  • [Ego19] M. Egorov. Stableswap-efficient mechanism for stablecoin liquidity. Tech. Rep., 2019.
  • [Ego21] M. Egorov. Automatic market-making with dynamic peg., 2021.
  • [EH21] Daniel Engel and Maurice Herlihy. Composing networks of automated market makers. CoRR, abs/2106.00083, 2021.
  • [Eva20] Alex Evans. Liquidity provider returns in geometric mean markets. arXiv preprint arXiv:2006.08806, 2020.
  • [Kuc09] Marek Kuczma. An introduction to the theory of functional equations and inequalities. 01 2009.
  • [MM19] Fernando Martinelli and Nikolai Mushegian. Balancer whitepaper. URL: https://balancer.fi/whitepaper.pdf, 2019.
  • [ZRM09] R. K. P. Zia, Edward F. Redish, and Susan R. McKay. Making sense of the Legendre transform. American Journal of Physics, 77(7):614–622, Jul 2009.