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

Constant Power Root Market Makers

Mike Wu, Will McTighe
{mike, will}@paretolabs.xyz
(February 2022)
Abstract

The paper introduces a new type of constant function market maker, the constant power root market marker. We show that the constant sum (used by mStable), constant product (used by Uniswap and Balancer), constant reserve (HOLD-ing), and constant harmonic mean trading functions are special cases of the constant power root trading function. We derive the value function for liquidity providers, marginal price function, price impact function, impermanent loss function, and greeks for constant power root market markers. In particular, we find that as the power qq varies from the range of 1-1 to 11, the power root function interpolates between the harmonic (q=1q=-1), geometric (q=0q=0), and arithmetic (q=1q=1) means. This provides a toggle that trades off between price slippage for traders and impermanent loss for liquidity providers. As the power qq approaches 1, slippage is low and impermanent loss is high. As qq approaches to -1, price slippage increases and impermanent loss decreases.

1 Preface

This paper is part of an exploration of alternative approaches to AMM curvature to incentivize trading and liquidity provision in specific use cases. The goal of an efficient market is to provide the most liquidity at the lowest price impact. In service of that goal, we had two initial hypotheses. First, there is low liquidity for long tail assets in existing automated market makers (AMMs) because it is unattractive for liquidity providers, absent liquidity incentives. We hypothesized that greater curvature than the constant product function could incentivize additional liquidity provision. Second, we reasoned that there could be an alternative AMM for stableswaps, providing more protection to LPs in edge cases, like the recent events of Terra. Flexing power could be a gas efficient approach to adjusting curvature but introduces issues such as reserve depletion and round-trip arbitrage. We explored these in follow up research. If you’d like to discuss these topics in more detail, please reach out.

2 Constant Function Market Makers

Constant function market makers (CFMMs) are a family of AMMs commonly used to parameterize asset exchange mechanisms on public blockchains. Critically, CFMMs rely on liquidity providers (LPs) who provide tokens to a supply of reserves for use by a smart contract. The contract contains code that executes swaps for traders. To preserve market stability, swaps must ensure a function of the reserves is constant. This function is known as the trading function, also called the scoring rule or the invariant.

For simplicity, we will assume the case of two tokens, although it should be straightforward to generalize to more than two. Let ψ:𝐑×𝐑𝐑\psi:\mathbf{R}\times\mathbf{R}\rightarrow\mathbf{R} be an invariant, and x,y𝐑+x,y\in\mathbf{R}_{+} be reserves. A reserve represents the amount of a token available for swaps in the contract pool. Let x,y𝐑+x^{\prime},y^{\prime}\in\mathbf{R}_{+} denote new values for the reserves after a trade. A trade is allowed if and only if ψ(x,y)=k\psi(x^{\prime},y^{\prime})=k for some constant value k𝐑+k\in\mathbf{R}_{+}, hence the name constant function.

Three examples of trading rules are, borrowing the notation from [1]:

Constant reserve We begin with a trivial invariant ψrsv(x,y)={0if x=k1 and y=k2otherwise\psi_{\text{rsv}}(x,y)=\left\{\begin{matrix}0&\textup{if }x=k_{1}\textup{ and }y=k_{2}\\ -\infty&\text{otherwise}\\ \end{matrix}\right. for k1,k2𝐑k_{1},k_{2}\in\mathbf{R}, which only allows trading if it keeps the reserves at fixed values a,b𝐑+a,b\in\mathbf{R}^{+}. When ψ\psi evaluates to -\infty, trading is not permitted. This is also known as HODL-ing.

Constant sum Define ψsum(x,y)={0if x+y=kotherwise\psi_{\text{sum}}(x,y)=\left\{\begin{matrix}0&\textup{if }x+y=k\\ -\infty&\text{otherwise}\\ \end{matrix}\right., also called the “arithmetic mean”. This function is only usable for asset pairs where the price ratio is fixed (e.g. USDT-USDC or wBTC-renBTC). Technically, it has no slippage (since price is fixed) and no impermanent loss (since we can always freely swap one xx for one yy), but no price adjustments as reserves fluctuate, meaning a reserve can be depleted entirely. For a real world example, mStable is a DEX for stablecoins that uses a constant sum trading function.

Constant product Define ψprod(x,y)={0if xy=kotherwise\psi_{\text{prod}}(x,y)=\left\{\begin{matrix}0&\textup{if }xy=k\\ -\infty&\text{otherwise}\\ \end{matrix}\right., also called a “geometric mean”. We can see that yy must grow exponentially large as xx nears zero, discouraging any traders from fully depleting reserves. (Similarly, the property holds if yy is the token nearing zero). The unfortunate consequence of this design is susceptibility to slippage. Uniswap [2, 3] and Balancer [4, 5] are instances of a constant product.

Curve [6] Define ψcurve(x,y)={0if α(x+y)+β(xy)=kotherwise\psi_{\text{curve}}(x,y)=\left\{\begin{matrix}0&\textup{if }\alpha(x+y)+\beta(xy)=k\\ -\infty&\text{otherwise}\\ \end{matrix}\right., an interpolation between the constant sum and product functions. As (αβ)\left(\frac{\alpha}{\beta}\right) increases, this converges to the constant sum. As (αβ)\left(\frac{\alpha}{\beta}\right) decreases, this converges to the constant product. In this paper, we explore another method to toggle between arithmetic and geometric means.

Constant harmonic mean Define ψhar(x,y)={0if 1(1x+1y)=kotherwise\psi_{\text{har}}(x,y)=\left\{\begin{matrix}0&\textup{if }\frac{1}{\left(\frac{1}{x}+\frac{1}{y}\right)}=k\\ -\infty&\text{otherwise}\\ \end{matrix}\right.. Like the geometric mean, there is no reserve depletion. To the best of our knowledge, this function has not been implemented in practice yet. One of the contributions of this paper is to explore the properties of this trading function and similar relatives.

In this paper, we will propose a new family of constant function market makers using a power root. Special cases of these power root functions (in particular, those with non-negative power) have been previously explored by Clipper [7] and Yieldspace [8].

2.1 Marginal Price and Impermanent Loss

We review the marginal price and impermanent loss for the constant sum and product functions, all well known results.

Lemma 2.1.

The marginal price for the constant sum function is Msum=1M_{\textup{sum}}=1. The marginal price for constant product function is Mprod=yxM_{\textup{prod}}=\frac{y}{x}.

Proof.

Consider (xΔx)+(y+Δy)=k(x-\Delta x)+(y+\Delta y)=k. Solving for Δy\Delta y, we obtain Δy=kx+Δxy\Delta y=k-x+\Delta x-y. Then, limΔx0(ΔyΔx)=limΔx0(kx+ΔxyΔx)=1\lim_{\Delta x\rightarrow 0}\left(\frac{\Delta y}{\Delta x}\right)=\lim_{\Delta x\rightarrow 0}\left(\frac{k-x+\Delta x-y}{\Delta x}\right)=1. Next, consider, (xΔx)(y+Δy)=k(x-\Delta x)(y+\Delta y)=k. Again, solving for Δy\Delta y, we get Δy=yΔxkΔx\Delta y=\frac{y\Delta x}{k-\Delta x}. So limΔx0ΔyΔx=limΔx0yxΔx=yx\lim_{\Delta x\rightarrow 0}\frac{\Delta y}{\Delta x}=\lim_{\Delta x\rightarrow 0}\frac{y}{x-\Delta x}=\frac{y}{x}. ∎

In other words, the price ratio for the constant sum function is fixed. The price is independent of the token reserves. This is not true for the constant product function.

Lemma 2.2.

Let M=αMM^{\prime}=\alpha M be a change in marginal price, α>0\alpha>0. Ignoring trading fees, the impermanent loss function for constant product function is Iprod=2αα+11I_{\textup{prod}}=\frac{2\sqrt{\alpha}}{\alpha+1}-1. For the constant sum function, Isum=0I_{\textup{sum}}=0 since the price marginal ratio of xx and yy must be fixed.

Proof.

Let x,yx^{\prime},y^{\prime} be the new reserves corresponding to MM^{\prime}. Define U(x,y,M)=Mx+yU(x,y,M)=Mx+y, the portfolio value at price MM. Then I=(U(x,y,M)U(x,y,M)U(x,y,M))I=\left(\frac{U(x^{\prime},y^{\prime},M^{\prime})-U(x,y,M^{\prime})}{U(x,y,M^{\prime})}\right), the normalized amount the liquidity provider would have been better off by keeping tokens out of the pool.

Starting with constant sum, we have U(x,y,M)=Mx+y=x+y=kU(x^{\prime},y^{\prime},M^{\prime})=M^{\prime}x^{\prime}+y^{\prime}=x^{\prime}+y^{\prime}=k, and U(x,y,M)=Mx+y=x+y=kU(x,y,M^{\prime})=M^{\prime}x+y=x+y=k. So Isum=kkk=0I_{\text{sum}}=\frac{k-k}{k}=0.

The constant product is slightly more intricate. Since M=yxM=\frac{y}{x}, we have y=Mxy=Mx and so xy=x2M=kxy=x^{2}M=k. Thus, x=kMx=\sqrt{\frac{k}{M}} and y=kMy=\sqrt{kM}. Now, U(x,y,M)=MkM+kM=2αkMU(x^{\prime},y^{\prime},M^{\prime})=M^{\prime}\sqrt{\frac{k}{M^{\prime}}}+\sqrt{kM^{\prime}}=2\sqrt{\alpha kM}. Similarly, U(x,y,M)=(αM)kM+kM=(α+1)kMU(x,y,M^{\prime})=(\alpha M)\sqrt{\frac{k}{M}}+\sqrt{kM}=(\alpha+1)\sqrt{kM}. So Iprod=2αkM(α+1)kM(α+1)kM=2αα+11I_{\text{prod}}=\frac{2\sqrt{\alpha}\sqrt{kM}-(\alpha+1)\sqrt{kM}}{(\alpha+1)\sqrt{kM}}=\frac{2\sqrt{\alpha}}{\alpha+1}-1. ∎

3 Value Functions for Liquidity Providers

Given a trading function, a reasonable question to ask is what is the LP payoff function? Similarly, given a LP payoff function, what is the corresponding trading function? To answer these questions, prior work [1] formulates the trading and value functions as dual convex optimization problems. We summarize the findings below:

Let a,b𝐑+a,b\in\mathbf{R}_{+} denote the true (external market) price of x,yx,y, respectively. Define a value function V:𝐑+×𝐑+𝐑V:\mathbf{R}_{+}\times\mathbf{R}_{+}\rightarrow\mathbf{R} as a function that maps true prices to a payoff amount [9]. Then, prior work [9] has shown that

V(a,b)=infx,y𝐑+{ax+by|ψ(x,y)=k}V(a,b)=\inf_{x,y\in\mathbf{R}_{+}}\{ax+by|\psi(x,y)=k\} (1)

Equation 1 shows that traders and LPs are at odds in a zero-sum game. That is, traders achieve maximum profit when LPs achieve minimum value, preserving the constant function. (The converse is also true.) This intuition leads to the foundational result that

ψ(x,y)=infa,b𝐑{ax+byV(a,b)}.\psi(x,y)=\inf_{a,b\in\mathbf{R}}\{ax+by-V(a,b)\}. (2)

In other words, the trading and value functions are Fenchel conjugates of one another. This duality does not hold for all value functions VV. We require VV to be consistent, which is composed of four requirements: concavity, non-decreasing, non-negative, and 1-homogeneous.

We list the value function for popular trading functions, and defer to [1] for derivations. It is straightforward to verify all value functions listed below are consistent.

Constant reserve Vrsv(a,b)=a+bV_{\text{rsv}}(a,b)=a+b, the sum value function.

Constant sum Vsum(a,b)=min{a,b}V_{\text{sum}}(a,b)=\min\{a,b\}, the minimum value function.

Constant product Vprod(a,b)=abV_{\text{prod}}(a,b)=\sqrt{ab}, the product value function.

While enlightening, this analysis so far leaves us wanting more. What is the relationship between these three value functions? Are there other value functions of the same family? Why does the constant product trading function map to a product value function but constant sum maps to a minimum function? Next, we take a step towards an answer.

4 Constant Power Root Market Makers

We structure the section as follows: first, we introduce a family of value functions that contain the constant reserve, sum, and product functions as special cases; second, we derive the corresponding trading function; third, we compute several properties of interest, such as marginal price and impermanent loss. Proofs are provided inline.

Refer to caption
Figure 1: Examples of power root value functions that interpolate between p=0p=0 (constant product) and p=1p=1 (constant reserve) and p=p=-\infty (constant sum).

4.1 Power Root Value Function

Define the power root value function as

Vpow(a,b,p)=(ap+bp)1pV_{\text{pow}}(a,b,p)=(a^{p}+b^{p})^{\frac{1}{p}} (3)

for a fixed constant p1p\leq 1. Note that pp does not have to be an integer. Equation 3 is equivalent to a pp-norm when a,b,p0a,b,p\geq 0. However, the two are not identical in properties, particularly in terms of concavity, as we will show in Section 4.2.

We claim that all the value functions corresponding to the constant reserve, sum, and product invariants are special cases of the power root value function. Consider:

Lemma 4.1.

Suppose a,b>0a,b>0. If p=1p=1, then Vpow(a,b,1)=VrsvV_{\text{pow}}(a,b,1)=V_{\text{rsv}}. As p0p\rightarrow 0, we have Vpow(a,b,0)VprodV_{\text{pow}}(a,b,0)\rightarrow V_{\text{prod}}. As pp\rightarrow-\infty, we have Vpow(a,b,)VsumV_{\text{pow}}(a,b,-\infty)\rightarrow V_{\text{sum}}.

Proof.

Begin with p=1p=1. We have Vpow(a,b,1)=a+b=VrsvV_{\text{pow}}(a,b,1)=a+b=V_{\textup{rsv}}.

Next, consider pp\rightarrow-\infty. Note that (ap+bp)1p(2min{a,b}p)1p=21pmin{a,b}(a^{p}+b^{p})^{\frac{1}{p}}\geq\left(2\min\{a,b\}^{p}\right)^{\frac{1}{p}}=2^{\frac{1}{p}}\min\{a,b\} by definition of minimum. But also (ap+bp)1p(min{a,b}p)1p=min{a,b}(a^{p}+b^{p})^{\frac{1}{p}}\leq\left(\min\{a,b\}^{p}\right)^{\frac{1}{p}}=\min\{a,b\} since p<0p<0. By squeeze theorem, we have (ap+bp)1p=min{a,b}(a^{p}+b^{p})^{\frac{1}{p}}=\min\{a,b\}.

Finally, consider p0p\rightarrow 0. If a,b0a,b\geq 0, then:

limp0(ap+bp)1p\displaystyle\lim_{p\rightarrow 0}(a^{p}+b^{p})^{\frac{1}{p}} =exploglimp0(ap+bp)1p=explimp0log(ap+bp)1p\displaystyle=\exp\log\lim_{p\rightarrow 0}(a^{p}+b^{p})^{\frac{1}{p}}=\exp\lim_{p\rightarrow 0}\log(a^{p}+b^{p})^{\frac{1}{p}}
=explimp0log(ap+bp)p=explimp0(aploga+bplogbap+bp)1\displaystyle=\exp\lim_{p\rightarrow 0}\frac{\log(a^{p}+b^{p})}{p}=\exp\lim_{p\rightarrow 0}\frac{\left(\frac{a^{p}\log a+b^{p}\log b}{a^{p}+b^{p}}\right)}{1}
=exp(loga+logb2)=ab\displaystyle=\exp\left(\frac{\log a+\log b}{2}\right)=\sqrt{ab}

Economic Interpretation. We can view value functions as production functions in economic theory. For instance, VprodV_{\text{prod}} is equivalent to the Cobb-Douglas production function, VrsvV_{\text{rsv}} is equivalent to the perfect substitute (linear) production function, and VsumV_{\text{sum}} is equivalent to the Leontief production function. Further, VpowV_{\text{pow}} is equivalent to the constant elasticity of substitution, of which the perfect substitute, Leontief, and Cobb-Douglas are special cases of. This matches the result shown in Lemma 4.1.

4.2 Power Root Trading Function

Before we can apply Equation 2 to derive a trading function, we must verify that VpowV_{\text{pow}} satisfies the four conditions for consistency [1].

Lemma 4.2.

f(a,b)=(ap+bp)1pf(a,b)=(a^{p}+b^{p})^{\frac{1}{p}} for p1p\leq 1, a,b𝐑a,b\in\mathbf{R} is concave.

Proof.

We first show that ff is quasiconcave, then 1-homogenous, which implies concavity.

A function is quasiconcave if it is a monotonically increasing function of a concave function. Let g(a,b)=ap+bpg(a,b)=a^{p}+b^{p}. If p>1p>1, this is not concave. Then, if 0p10\leq p\leq 1, set f(a,b)=g(a,b)1pf(a,b)=g(a,b)^{\frac{1}{p}}. Clearly ff is a monotonic function of gg. It remains to show that gg is concave. To see this, note that p,ag=pap1\nabla_{p,a}g=pa^{p-1}, and p,a2g=p(p1)ap20\nabla^{2}_{p,a}g=p(p-1)a^{p-2}\leq 0 since p10p-1\leq 0. Similarly, p,b2g0\nabla^{2}_{p,b}g\leq 0. Thus, the Hessian of gg is a diagonal matrix with non-positive entries, and hence semidefinite. We conclude gg is concave. Next, suppose p<0p<0. Then f=g1pf=g^{\frac{1}{p}} is a monotonically decreasing function of gg. But then ff is a monotonically increasing function of g-g. The Hessian of g-g has entries p(p1)ap2-p(p-1)a^{p-2} which are again non-positive, making g-g concave.

ff is also 1-homogeneous. To see this, note f(ka,kb)=((ka)p+(kb)p)1p=(kp(ap+bp))1p=k(ap+bp)1p=kf(a,b)f(ka,kb)=\left((ka)^{p}+(kb)^{p}\right)^{\frac{1}{p}}=\left(k^{p}\left(a^{p}+b^{p}\right)\right)^{\frac{1}{p}}=k\left(a^{p}+b^{p}\right)^{\frac{1}{p}}=kf(a,b). Given quasiconcavity and homogeneity, we have concavity. ∎

Lemma 4.2 shows the power root is a concave function for p1p\leq 1.

As a corollary, we obtain our first theorem.

Theorem 4.3.

The value function Vpow(a,b)=(ap+bp)1pV_{\text{pow}}(a,b)=(a^{p}+b^{p})^{\frac{1}{p}} is consistent.

Proof.

Lemma 4.2 shows concavity and homogeneity. For a,b0a,b\geq 0, it is true that Vpow(a,b)0V_{\text{pow}}(a,b)\geq 0 for all p1p\leq 1 so VpowV_{\text{pow}} is non-negative. Finally, pick aaa^{\prime}\geq a and bbb^{\prime}\geq b. Then Vpow(a,b)=((a)p+(b)p)1p(ap+bp)1p=Vpow(a,b)V_{\text{pow}}(a^{\prime},b^{\prime})=((a^{\prime})^{p}+(b^{\prime})^{p})^{\frac{1}{p}}\geq(a^{p}+b^{p})^{\frac{1}{p}}=V_{\text{pow}}(a,b), showing that it is non-decreasing. ∎

Now that we have shown VpowV_{\text{pow}} is consistent we are free to compute ψpow=infa,b𝐑{ax+byVpow(a,b)}\psi_{\text{pow}}=\inf_{a,b\in\mathbf{R}}\{ax+by-V_{\text{pow}}(a,b)\} as in Equation 2. We claim the following:

Theorem 4.4.

ψpow(x,y)={0if (xq+yq)1q1otherwise\psi_{\text{pow}}(x,y)=\left\{\begin{matrix}0&\text{if }\left(x^{q}+y^{q}\right)^{\frac{1}{q}}\leq 1\\ -\infty&\text{otherwise}\\ \end{matrix}\right. where q=pp1q=\frac{p}{p-1}.

Proof.

We will show this in the more general case of nn tokens 𝐱=(x1,xn)\mathbf{x}=(x_{1},\ldots x_{n}) with prices 𝐜=(c1,,cn)\mathbf{c}=(c_{1},\ldots,c_{n}). By definition, we have ψ(𝐱)=inf𝐜{xTc(icip)1p}\psi(\mathbf{x})=\inf_{\mathbf{c}}\left\{x^{T}c-\left(\sum_{i}c_{i}^{p}\right)^{\frac{1}{p}}\right\}. Note that this is a convex objective as xTcx^{T}c is affine and the negation of a concave function convex. Then:

ψ(𝐱)=inf𝐜{𝐱T𝐜(icip)1p}=sup𝐜{𝐱T𝐜+(icip)1p}=f(𝐱)\psi(\mathbf{x})=\inf_{\mathbf{c}}\left\{\mathbf{x}^{T}\mathbf{c}-\left(\sum_{i}c_{i}^{p}\right)^{\frac{1}{p}}\right\}=-\sup_{\mathbf{c}}\left\{-\mathbf{x}^{T}\mathbf{c}+\left(\sum_{i}c_{i}^{p}\right)^{\frac{1}{p}}\right\}=-f^{*}(-\mathbf{x})

where ff^{*} is the convex conjugate of f=(icip)1pf=-\left(\sum_{i}c_{i}^{p}\right)^{\frac{1}{p}}. This can be written as the closed form f(𝐱)={0if (ixiq)1q1otherwisef^{*}(-\mathbf{x})=\left\{\begin{matrix}0&\text{if }\left(\sum_{i}x_{i}^{q}\right)^{\frac{1}{q}}\leq 1\\ \infty&\text{otherwise}\\ \end{matrix}\right. where q=pp1q=\frac{p}{p-1}. Then ψpow(𝐱)=f(𝐱)={0if (ixiq)1q1otherwise\psi_{\text{pow}}(\mathbf{x})=-f^{*}(-\mathbf{x})=\left\{\begin{matrix}0&\text{if }\left(\sum_{i}x_{i}^{q}\right)^{\frac{1}{q}}\leq 1\\ -\infty&\text{otherwise}\\ \end{matrix}\right.. For two tokens, ψpow(x,y)={0if (xq+yq)1q1otherwise\psi_{\text{pow}}(x,y)=\left\{\begin{matrix}0&\text{if }\left(x^{q}+y^{q}\right)^{\frac{1}{q}}\leq 1\\ -\infty&\text{otherwise}\\ \end{matrix}\right.. ∎

Given the form of Theorem 4.4, we highlight a few special cases. If p0p\rightarrow 0, then q0q\rightarrow 0. If pp\rightarrow-\infty, then q1q\rightarrow 1. If p1p\rightarrow 1, then qq\rightarrow-\infty. This is consistent with what we know about constant reserve, sum, and product functions. The value function for the product invariant is also a product, which is shown by p,qp,q both converging to 0 (see Lemma 4.1). The value function for constant sum is a minimum function, which is captured by qq converging to 1 when pp converges to -\infty (again, recall Lemma 4.1).

Refer to caption
Figure 2: Examples of power root that interpolate between q=1q=-1 to q=1q=1 (constant sum), including q=0q=0 (constant product). We plot the constant reserve in the dotted line.

Figure 2 visualizes the trading curve for a range of powers qq. We include q=0q=0 (constant product), q=1q=1 (constant sum), and q=q=-\infty (constant reserve, shown in dotted line) for comparisons. We observe that varying q(,1]q\in(-\infty,1] predictably controls the curvature of the trading function between two extreme functions.

Harmonic Mean Result In the case q1q\rightarrow-1, we recover the constant harmonic mean invariant. By Theorem 4.3, we know ψhar(x,y)\psi_{\text{har}}(x,y) is concave. Further, by Theorem 4.4, we have that its value function is Vhar(a,b)=(a12+b12)2V_{\text{har}}(a,b)=(a^{\frac{1}{2}}+b^{\frac{1}{2}})^{2} as p=12p=\frac{1}{2} when q=1q=-1. This function has higher curvature than constant product.

4.3 Marginal Price Function

Given the constant power root trading function, we can derive an expression for the marginal price as a function of pp. The “marginal” price represents the price of one token in terms of the other assuming an infinitesimally small trade.

Begin with ((xΔx)q+(y+Δy)q)1q=k\left((x-\Delta x)^{q}+(y+\Delta y)^{q}\right)^{\frac{1}{q}}=k. Then Δy=(kq(xΔx)q)1qy\Delta y=(k^{q}-(x-\Delta x)^{q})^{\frac{1}{q}}-y. Dividing by Δx\Delta x, we obtain ΔyΔx=(kq(xΔx)q)1qyΔx\frac{\Delta y}{\Delta x}=\frac{(k^{q}-(x-\Delta x)^{q})^{\frac{1}{q}}-y}{\Delta x}. Derive the marginal price using L’Hopital’s rule:

Mpow(q)\displaystyle\small M_{\text{pow}}(q) =limΔx0ΔyΔx=limΔx0(dΔydΔxdΔxdΔx)=limΔx0(ddΔx((kq(xΔx)q)1qy))\displaystyle=\lim_{\Delta x\rightarrow 0}\frac{\Delta y}{\Delta x}=\lim_{\Delta x\rightarrow 0}\left(\frac{\frac{d\Delta y}{d\Delta x}}{\frac{d\Delta x}{d\Delta x}}\right)=\lim_{\Delta x\rightarrow 0}\left(\frac{d}{d\Delta x}\left((k^{q}-(x-\Delta x)^{q})^{\frac{1}{q}}-y\right)\right)
=limΔx0(1q(kq(xΔx)q)1q1q(xΔx)q11)\displaystyle=\lim_{\Delta x\rightarrow 0}\left(\frac{1}{q}(k^{q}-(x-\Delta x)^{q})^{\frac{1}{q}-1}\cdot-q(x-\Delta x)^{q-1}\cdot-1\right)
=(kqxq)1q1xq1=(yq)1q1xq1\displaystyle=(k^{q}-x^{q})^{\frac{1}{q}-1}\cdot x^{q-1}=(y^{q})^{\frac{1}{q}-1}\cdot x^{q-1}

Since 1q1=1qq\frac{1}{q}-1=\frac{1-q}{q}, we obtain the following expression

Mpow(q)=xq1y1qM_{\text{pow}}(q)=x^{q-1}y^{1-q} (4)

A quick inspection of Equation 4 and Lemma 2.1 shows that for q=1q=1, we have Mpow(1)=x0y0=1=MsumM_{\text{pow}}(1)=x^{0}y^{0}=1=M_{\text{sum}}, and Mpow(0)=x1y1=yx=MprodM_{\text{pow}}(0)=x^{-1}y^{1}=\frac{y}{x}=M_{\text{prod}}. That is, the marginal price for the constant sum and product invariants are again, special cases of the constant power root.

Figure 4(a) plots the marginal price as a function of the reserve ratios between xx and yy. As q1q\rightarrow 1, we see the marginal price converge to a constant function at 1. As qq\rightarrow-\infty, it approaches an exponentially increasing function. When q=0q=0, the price is linear.

4.4 Impermanent Loss Function

Using the result in Section 4.3, we show the following theorem:

Theorem 4.5.

Let α>0\alpha>0 be a change in marginal price M=Mpow(q)M=M_{\text{pow}}(q). The impermanent loss for the constant power root trading function is

Iproot(q)=(1+Mq1q1+(αM)q1q)1q(αM+(αM)11qαM+M11q)1.I_{\textup{proot}}(q)=\left(\frac{1+M^{\frac{q}{1-q}}}{1+(\alpha M)^{\frac{q}{1-q}}}\right)^{\frac{1}{q}}\left(\frac{\alpha M+(\alpha M)^{\frac{1}{1-q}}}{\alpha M+M^{\frac{1}{1-q}}}\right)-1. (5)
Proof.

First, we wish to represent xx and yy in terms of the constant kk and the marginal price MM only. Recall from Equation 4 that M=xq1y1qM=x^{q-1}y^{1-q}. So y=M11qxy=M^{\frac{1}{1-q}}x. Since (xq+yq)1q=k(x^{q}+y^{q})^{\frac{1}{q}}=k, we compute x=k(1+Mq1q)1qx=\frac{k}{(1+M^{\frac{q}{1-q}})^{\frac{1}{q}}}, and thus y=kM11q(1+Mq1q)1qy=\frac{kM^{\frac{1}{1-q}}}{(1+M^{\frac{q}{1-q}})^{\frac{1}{q}}}.

Second, we can compute value U(x,y,M)=Mx+yU(x,y,M)=Mx+y. Note M=αMM^{\prime}=\alpha M. Let x,yx^{\prime},y^{\prime} be the token reserves at the new marginal price MM^{\prime}. Then U(x,y,M)=M(k(1+(M)q1q)1q)+(k(M)11q(1+(M)q1q)1q)=αkM+k(αM)11q(1+(αM)q1q)1qU(x^{\prime},y^{\prime},M^{\prime})=M^{\prime}\left(\frac{k}{(1+(M^{\prime})^{\frac{q}{1-q}})^{\frac{1}{q}}}\right)+\left(\frac{k(M^{\prime})^{\frac{1}{1-q}}}{(1+(M^{\prime})^{\frac{q}{1-q}})^{\frac{1}{q}}}\right)=\frac{\alpha kM+k(\alpha M)^{\frac{1}{1-q}}}{(1+(\alpha M)^{\frac{q}{1-q}})^{\frac{1}{q}}}. Similarly, compute U(x,y,M)=αkM+kM11q(1+Mq1q)1qU(x,y,M^{\prime})=\frac{\alpha kM+kM^{\frac{1}{1-q}}}{(1+M^{\frac{q}{1-q}})^{\frac{1}{q}}}.

Now, use the definition that I=U(x,y,M)U(x,y,M)U(x,y,M)I=\frac{U(x^{\prime},y^{\prime},M^{\prime})-U(x,y,M^{\prime})}{U(x,y,M^{\prime})}. To be pedantic, we obtain

I=((1+Mq1q1+(αM)q1q)1q(αM+(αM)11q)(αM+M11q)αM+M11q).I=\left(\frac{\left(\frac{1+M^{\frac{q}{1-q}}}{1+(\alpha M)^{\frac{q}{1-q}}}\right)^{\frac{1}{q}}(\alpha M+(\alpha M)^{\frac{1}{1-q}})-(\alpha M+M^{\frac{1}{1-q}})}{\alpha M+M^{\frac{1}{1-q}}}\right).

Divide by the denominator to find the result. ∎

We aim to show special cases of this impermanent loss. As these require nontrivial work, we do so in the following corollaries.

Corollary 4.5.1.

limq0Iproot(q)=Iprod\lim_{q\rightarrow 0}I_{\textup{proot}}(q)=I_{\textup{prod}}.

Proof.

We compute the limit separately for the three pieces of Iproot(q)I_{\textup{proot}}(q).

  1. 1.

    limq0(1+Mq1q1+(αM)q1q)1q=explimq0(log(1+Mq1q1+(αM)q1q)q)=(MαM)12=α12\lim_{q\rightarrow 0}\left(\frac{1+M^{\frac{q}{1-q}}}{1+(\alpha M)^{\frac{q}{1-q}}}\right)^{\frac{1}{q}}=\exp\lim_{q\rightarrow 0}\left(\frac{\log\left(\frac{1+M^{\frac{q}{1-q}}}{1+(\alpha M)^{\frac{q}{1-q}}}\right)}{q}\right)=\left(\frac{M}{\alpha M}\right)^{\frac{1}{2}}=\alpha^{-\frac{1}{2}}.

  2. 2.

    limq0(αM+(αM)11qαM+M11q)=2αM(α+1)M=2αα+1\lim_{q\rightarrow 0}\left(\frac{\alpha M+(\alpha M)^{\frac{1}{1-q}}}{\alpha M+M^{\frac{1}{1-q}}}\right)=\frac{2\alpha M}{(\alpha+1)M}=\frac{2\alpha}{\alpha+1}.

Altogether, the limit evaluates to 1α2αα+11=2αα+11\frac{1}{\sqrt{\alpha}}\cdot\frac{2\alpha}{\alpha+1}-1=\frac{2\sqrt{\alpha}}{\alpha+1}-1. Recall Lemma 2.2 to see this is equivalent to IprodI_{\textup{prod}}. ∎

Corollary 4.5.2.

limq1Iproot(q)=Isum\lim_{q\rightarrow 1}I_{\textup{proot}}(q)=I_{\textup{sum}}.

Proof.

Consider only the first term in IprootI_{\textup{proot}} and apply exp-log to get separate limits. Let J(q)=Ipow(q)+1=(1+Mq1q1+(αM)q1q)1q(αM+(αM)11qαM+M11q)J(q)=I_{\text{pow}}(q)+1=\left(\frac{1+M^{\frac{q}{1-q}}}{1+(\alpha M)^{\frac{q}{1-q}}}\right)^{\frac{1}{q}}\left(\frac{\alpha M+(\alpha M)^{\frac{1}{1-q}}}{\alpha M+M^{\frac{1}{1-q}}}\right). Then,

limq1J(q)=exp(loglimq1A+loglimq1B).\lim_{q\rightarrow 1}J(q)=\exp\left(\log\lim_{q\rightarrow 1}A+\log\lim_{q\rightarrow 1}B\right).

Focusing on the expression inside the log\log, we will study each of these in turn. First,

loglimq1A\displaystyle\log\lim_{q\rightarrow 1}A =limq1log(1+Mq1q1+(αM)q1q)1q=limq11qlog(limq11+Mq1q1+(αM)q1q)\displaystyle=\lim_{q\rightarrow 1}\log\left(\frac{1+M^{\frac{q}{1-q}}}{1+(\alpha M)^{\frac{q}{1-q}}}\right)^{\frac{1}{q}}=\lim_{q\rightarrow 1}\frac{1}{q}\cdot\log\left(\lim_{q\rightarrow 1}\frac{1+M^{\frac{q}{1-q}}}{1+(\alpha M)^{\frac{q}{1-q}}}\right)
=log(Mqq1logM(q1)2(αM)qq1log(αM)(q1)2)=log(limq1αqq1logMlog(αM))\displaystyle=\log\left(\frac{\frac{M^{\frac{-q}{q-1}}\log M}{(q-1)^{2}}}{\frac{(\alpha M)^{\frac{-q}{q-1}}\log(\alpha M)}{(q-1)^{2}}}\right)=\log\left(\lim_{q\rightarrow 1}\alpha^{\frac{-q}{q-1}}\cdot\frac{\log M}{\log(\alpha M)}\right)
=limq1(qq1)logα+log(logMlog(αM))\displaystyle=\lim_{q\rightarrow 1}\left(\frac{q}{q-1}\right)\log\alpha+\log\left(\frac{\log M}{\log(\alpha M)}\right)

where the swaps between the limit and log follows by the continuity of log.

This limit is undefined but we can evaluate the left and right limits. If q1+q\rightarrow 1^{+}, then (qq1)\left(\frac{q}{q-1}\right)\rightarrow\infty, leaving loglimq1+A={0<α<10α=1α>1\log\lim_{q\rightarrow 1^{+}}A=\left\{\begin{matrix}-\infty&0<\alpha<1\\ 0&\alpha=1\\ \infty&\alpha>1\end{matrix}\right.. If q1q\rightarrow 1^{-}, we have (qq1)\left(\frac{q}{q-1}\right)\rightarrow-\infty, leaving loglimq1A={0<α<10α=1α>1\log\lim_{q\rightarrow 1^{-}}A=\left\{\begin{matrix}\infty&0<\alpha<1\\ 0&\alpha=1\\ -\infty&\alpha>1\end{matrix}\right..

Next, we can evaluate the second term:

loglimq1B\displaystyle\log\lim_{q\rightarrow 1}B =loglimq1(αM+(αM)11qαM+M11q)=loglimq1((αM)1q1log(αM)(q1)2M1q1logM(q1)2)\displaystyle=\log\lim_{q\rightarrow 1}\left(\frac{\alpha M+(\alpha M)^{\frac{1}{1-q}}}{\alpha M+M^{\frac{1}{1-q}}}\right)=\log\lim_{q\rightarrow 1}\left(\frac{\frac{(\alpha M)^{\frac{-1}{q-1}}\log(\alpha M)}{(q-1)^{2}}}{\frac{M^{\frac{-1}{q-1}}\log M}{(q-1)^{2}}}\right)
=loglimq1((αM)1q1log(αM)M1q1logM)=loglimq1(α1q1log(αM)logM)\displaystyle=\log\lim_{q\rightarrow 1}\left(\ \frac{(\alpha M)^{\frac{-1}{q-1}}\log(\alpha M)}{M^{\frac{-1}{q-1}}\log M}\right)=\log\lim_{q\rightarrow 1}\left(\alpha^{\frac{-1}{q-1}}\cdot\frac{\log(\alpha M)}{\log M}\right)

where the second equality follows by L’Hopital’s rule.

Again, this limit doesn’t exist but we can evaluate the left and right limits. If q1+q\rightarrow 1^{+}, then (1q1)\left(\frac{-1}{q-1}\right)\rightarrow-\infty, leaving loglimq1+A={0<α<10α=1α>1\log\lim_{q\rightarrow 1^{+}}A=\left\{\begin{matrix}\infty&0<\alpha<1\\ 0&\alpha=1\\ -\infty&\alpha>1\end{matrix}\right.. If q1q\rightarrow 1^{-}, we have (1q1)\left(\frac{-1}{q-1}\right)\rightarrow\infty, leaving loglimq1A={0<α<10α=1α>1\log\lim_{q\rightarrow 1^{-}}A=\left\{\begin{matrix}-\infty&0<\alpha<1\\ 0&\alpha=1\\ \infty&\alpha>1\\ \end{matrix}\right..

Now, we notice that loglimA+loglimB=0\log\lim A+\log\lim B=0 for all cases of α\alpha and qq coming from left or right. Note we cannot take the limit of A+BA+B as each is not defined.

Thus, we have limq1J(q)=exp0=1\lim_{q\rightarrow 1}J(q)=\exp 0=1. So limq1Iproot(q)=0\lim_{q\rightarrow 1}I_{\textup{proot}}(q)=0, which is IsumI_{\textup{sum}}. ∎

Corollaries 4.5.1 and 4.5.2 show that like the marginal price, the constant sum and product impermanent loss functions are special cases of the constant power root.

Refer to caption
Figure 3: Impermanent loss as a function of <q1-\infty<q\leq 1 with comparisons to constant sum, constant reserve, and constant product market makers (i.e. Uniswap).

We plot the impermanent loss as a function of qq in Figure 3, where the constant product (i.e. Uniswap) is shown in purple stars, constant reserve is shown in black hexagons, and the constant sum is shown with an orange cross (note this is only a single point as marginal price does not change for the constant sum invariant). Figure 3 shows a gradient of loss functions as qq varies. In particular, we see increased impermanent loss as qq approaches 1 and reduced impermanent loss as qq approaches -\infty. This is aligned with prior work [10] that suggests trading functions with flatter curvature have higher loss.

4.5 Price Impact

Next, we compute the price impact function [10], or the change to marginal price given a trade of size Δx\Delta x, as dΔydΔx\frac{d\Delta y}{d\Delta x}, the derivative of the price function. Equation 6 shows the price impact function for power roots.

dΔydΔx=(xq+yq(xΔx)q)1qq(xΔx)q1\frac{d\Delta y}{d\Delta x}=(x^{q}+y^{q}-(x-\Delta x)^{q})^{\frac{1-q}{q}}\cdot(x-\Delta x)^{q-1} (6)

Refer to [10] for derivations for the constant sum and product functions. It is straightforward to show that those are special cases of Equation 6 by q=0q=0 and q=1q=1. Figure 4(b) shows the price impact for constant power root market makers of varying qq. When q1q\rightarrow 1, the price impact function approaches 0 slope, which makes sense given that the marginal price is constant when q=1q=1. When qq\rightarrow-\infty, the price impact function has a faster increasing slope, representing higher levels of price sensitivity.

Practically, we note that price impact function is closely related to slippage as a constant function market maker with high price impact will likely experience higher slippage rates. As a base example, when q=1q=1, there is zero slippage due to the constant marginal price, or equivalently, its price impact function having zero slope.

Refer to caption
(a) Marginal price as a function of qq. On the x-axis, we plot a ratio of yx\frac{y}{x} with x=1x=1.
Refer to caption
(b) Impact of a trade on price as a function of the trade size (Δx[0,9000]\Delta x\in[0,9000], x,y=10000x,y=10000).
Figure 4: Marginal price is shown on the left, defined as the price in the limit of an infinitesimally small trade. Price impact is shown on the right, the sensitivity of price in response to trade size. In both figures, we see a continuum between q=1q=-1 and q=1q=1.

In summary, there is a trade-off between impermanent loss and price impact, which is perhaps not surprising. For large negative powers, the invariant has low loss for LPs but high price slippage for traders. For powers close to one, the opposite is true.

4.6 Value Derivatives

Since impermanent loss can be difficult to interpret, we also compute the value U(x,y,M)U(x,y,M) as well as derivatives with respect to price, such as delta Δ=δUδM\Delta=\frac{\delta U}{\delta M} and gamma Γ=δ2UδM2\Gamma=\frac{\delta^{2}U}{\delta M^{2}}. Continuing from Section 4.4, we can simplify the expression for value using only the liquidity amount kk and the marginal price MM, removing reserves from the equation:

U(M,k)=Mk(1+Mq1q)q1qU(M,k)=Mk\left(1+M^{\frac{q}{1-q}}\right)^{\frac{q-1}{q}} (7)

Taking first and second derivatives, we arrive at closed form expressions for the greeks:

Δ(M,k)=k(Mqq1+1)1q,Γ(M,k)=(11q)Mq1q1(Mq1q+1)1q1\Delta(M,k)=k\left(M^{\frac{q}{q-1}}+1\right)^{-\frac{1}{q}},\qquad\Gamma(M,k)=\left(\frac{-1}{1-q}\right)M^{\frac{q}{1-q}-1}\left(M^{\frac{q}{1-q}}+1\right)^{\frac{-1}{q}-1} (8)

In the following figure, we visualize the greeks for a variety of powers qq.

Refer to caption
(a) Value UU
Refer to caption
(b) Delta Δ\Delta
Refer to caption
(c) Gamma Γ\Gamma
Figure 5: Visualizing value, delta, and gamma for a range of powers. In particular, we compare q=0q=0 (constant product, Uniswap) to q=1q=1 (constant sum) to q=1q=-1 (constant harmonic mean) to q=100q=-100 (a proxy for q=q=-\infty, also called constant reserve or HODL).

In Figure 5, we vary the marginal price MM between 0 and 1 and study the effect on value, delta, and gamma. For each subplot, we normalize the y axis to be between 0 and 1 for visual comparison. As such, the reader should focus on the shape rather than the magnitudes. We make a few observations. First, in Figure 5(a), for positive powers, the larger the power, the less curvature in the value function. Interestingly, for larger negative powers, we observe a similar behavior, as q=100q=-100 and q=1q=1 have similar shape. Recalling payoff functions from Figure 2, we note that Figure 5(a) shows the same plot in lower dimensions.

Second, we observe more diverse delta functions as qq spans between 0 and 1 in Figure 5(b). For smaller positive powers, we observe delta to increase exponentially as price goes to zero, whereas for larger positive powers, we observe delta to increase exponentially as price grows large. For powers close to q=0.5q=0.5, we observe near linear change in delta. Third, in Figure 5(c), we observe that subtle differences in value are exaggerated as gamma functions across powers differ in behavior. This large range in gamma functions may suggest power roots to play a role in structured products to achieve a desired gamma. We note that delta and gamma for negatives powers closely mimic those of constant product.

4.7 Reserve Depletion

A benefit of the Uniswap trading function (q=0q=0) is a guarantee of no reserve depletion. For any value of token x>0x>0 and any constant kk, we have a y=kx>0y=\frac{k}{x}>0. In practice, this implies no trade can conduct a trade large enough to deplete resources. This property, however, does not hold for the sum invariant (q=1q=1), where the analogous expression y=kxy=k-x suggests that xkx\leq k, otherwise y0y\leq 0.

The power root invariant with q0q\leq 0 guarantees no reserve depletion. However for powers 0<q10<q\leq 1 it, like the sum, has the same point of reserve depletion, namely x=kx=k. One can see this from the equation y=(kqxq)1qy=(k^{q}-x^{q})^{\frac{1}{q}}, which implies kqxqk^{q}\geq x^{q} is required. As q0q\rightarrow 0, this constraint is removed, and power root collapses to product. However, for qq closer to 0, we observe more incentives to not deplete reserves due to price increases, though it is theoretically possible. For example, for q=ϵq=\epsilon close to 0, the marginal price is y1ϵx1ϵyx\frac{y^{1-\epsilon}}{x^{1-\epsilon}}\approx\frac{y}{x}. If xx is near depleted (and yy near kk), the price will be tending towards \infty.

Refer to caption
Figure 6: The price of token xx relative to token yy as a function of the trade size.

Figure 6 visualizes the relative price between two tokens as a function of trade size in token xx. Constant sum and product are shown with special markers. We make a few observations. First, the relative price decreases as trade size grows, which is expected given the concavity of the trading functions. Second, for 0<q<10<q<1, the plotted lines intersect the x-axis, representing points of depleted reserves (for q=1q=1, we have the point of depletion at x=1x=1). For q0q\leq 0, the plotted lines never intersect the x-axis. Third, for 0<q<10<q<1, there are segments where the price is better than constant product, which suggests better conditions for traders assuming small trades. This is not the case for large trades. Clipper [7] formalized this approach by only allowing small trades. For q<0q<0, prices are bounded above by constant product (q=0q=0), meaning traders face a higher cost.

5 Summary

We proposed a new constant function market maker using the power root equation ψpow(𝐱)=(ixiq)1q\psi_{\text{pow}}(\mathbf{x})=\left(\sum_{i}x_{i}^{q}\right)^{\frac{1}{q}} with the corresponding payoff (value) function for liquidity providers as Vpow(𝐜)=(icip)1pV_{\text{pow}}(\mathbf{c})=\left(\sum_{i}c_{i}^{p}\right)^{\frac{1}{p}} with q=pp1q=\frac{p}{p-1}. Inspired by economic production functions, we showed this choice to be a generalization of the constant reserve, sum, and product. The constant power root function interpolates between the constant reserve, sum, and product functions in terms of marginal price, price impact, and impermanent loss. In our analysis, we observe a trade-off between low slippage and impermanent loss, and susceptibility to reserve depletion.

Acknowledgement

A special thanks must go to Guillaume Lambert, Alok Vasudev, Theo Diamandis, Dan Robinson, and Joey Santoro for their helpful feedback and discussion.

References

  • [1] Guillermo Angeris, Alex Evans, and Tarun Chitra. Replicating market makers. arXiv preprint arXiv:2103.14769, 2021.
  • [2] Guillermo Angeris, Hsien-Tang Kao, Rei Chiang, Charlie Noyes, and Tarun Chitra. An analysis of uniswap markets. arXiv preprint arXiv:1911.03380, 2019.
  • [3] Hayden Adams, Noah Zinsmeister, Moody Salem, River Keefer, and Dan Robinson. Uniswap v3 core. Technical report, Technical report, 2021.
  • [4] Fernando Martinelli and Nikolai Mushegian. A non-custodial portfolio manager, liquidity provider, and price sensor. URl: https://balancer. finance/whitepaper, 2019.
  • [5] Alex Evans. Liquidity provider returns in geometric mean markets. arXiv preprint arXiv:2006.08806, 2020.
  • [6] Michael Egorov. Stableswap-efficient mechanism for stablecoin liquidity. Retrieved Feb, 24:2021, 2019.
  • [7] Abraham Othman. New invariants for automated market making. 2021.
  • [8] Allan Niemerg, Dan Robinson, and Lev Livnev. Yieldspace: An automated liquidity provider for fixed yield tokens. 2020.
  • [9] 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.
  • [10] Guillermo Angeris, Alex Evans, and Tarun Chitra. When does the tail wag the dog? curvature and market making. arXiv preprint arXiv:2012.08040, 2020.