1 Introduction

Central limit order books (CLOBs) are not ideal for decentralized exchanges (DEXs), which run on blockchains. The gas fees tend to be prohibitively expensive for this setup which usually has an ongoing stream of adjustments by the market makers. Consequently, automated market makers (AMMs) are an important feature of DEXs. Currently, these are typically implemented as constant function market makers (CFMM), which calculate an invariant value from the two or more token elements in the DEX; see also Angeris et al. (2023), and Cartea et al. (2023) for market maker designs beyond constant functions. CFMMs usually hold liquidity pools in the traded tokens, and these pools act as counterparties to anyone interacting with the DEX. Arbitrageurs would then make profitable follow-up trades, which reset the liquidity pools to the current market price. DEXs typically charge a transaction feeFootnote 1 of 0.15–0.35% on trades, and some or all of this fee ends up with the liquidity providers. In the Decentralized Finance (DeFi) summer of 2020, so-called yield farming became popular, and liquidity providers could earn additional returns by allocating newly created governance tokens; see Cousaert et al. (2022). This allocation can work to kick-start a project, but it is not a means which is medium-term sustainable, as the tokens will only retain value if their volume remains constrained. The most popular of these CFMMs is the constant product market maker (CPMM), which uses the product of the volumes of the two or more tokens involved as the invariant. The CPMM setup is simple; it is self-balancing through arbitrageurs, requires no active involvement from liquidity providers, and has low computational demands, making it suitable for a smart contract on a blockchain. However, it is not ideal either. It is capital intensive, exposes the liquidity providers to opportunity costs, and overall return-on-investments may range from fair to unacceptably bad once the yields from yield farming run out. The most commonly associated opportunity cost for CPMMs is called impermanent loss. This terminology can however be misleading as the corresponding loss rarely ever disappears in practice. Xu et al. (2023) therefore argues that the term divergence lossFootnote 2 would be more accurate for a scientific context. To generate a solid framework to investigate these problems further, we derive the formulas which apply in this context and look at some aspects in detail; we focus mainly on CPMM. In the mathematical treatment, we ignore gas fees and disregard the possibility of so-called maximum/miner extractable value attacks (MEV attacks), which correspond to a form of front running; see also Daian et al. (2020). Some aspects may be counterintuitive or tricky, although we basically only need elementary mathematics throughout the article. Topics covered include the following:

  • We investigate in the Sects. 2.2 and 3.2 the impact of transaction cost as they are commonly implemented in DeFi applications.

  • We show in the Sect. 3.3 how to exploit arbitrage opportunities in unbalanced liquidity pools.

  • We valuate in the Sect. 3.4 the hedging of the impermanent loss. We demonstrate that hedging the impermanent loss may be quite expensive and that prevalent risk compensations for CPMMs are likely too low.

  • We solve in the Sect. 3.8 an inverse problem such that one can rely on classical FX-rate dynamics in order to simulate consistent roll-forwards of liquidity pools. This is particularly relevant for risk management purposes. The publicly accessible Jupyter notebook illustrates an implementation in Python.

  • We elaborate in the Sect. 3.9 that absolute hedging for flat inventories is not a feasible option for liquidity providing. The costs are comparable to hedging the impermanent loss.

  • We propose in the Sect. 3.10order size as well as pool size dependent transaction cost, which may incentivize the desired levels of liquidity.

  • We derive in the Sect. 3.11 the optimal trade execution for different situations.

  • We tackle in the Sect. 3.12 an analytical argument of noise trades.

  • In the appendix, we briefly look at variations of the CPMM framework, namely Uniswap v3, Balancer, and Flat Curve.

AMM is an emerging field of application and research. There are already a number of publications in this regard; e.g., see Mohan (2022) for a comprehensive introduction and further references. There are also numerous pertinent blogs. Some of our discussion points are treated in greater generality in Cartea et al. (2022b). To the best of our knowledge, particularly the considerations of the Sects. 3.63.10 have not yet been addressed conclusively elsewhere.

2 Constant function market maker (CFMM)

2.1 Notation

Notation

Description

\(F(x,y)\equiv c\)

Isoline(s) of the liquidity pool

f(x)

Explicit solution \(y=f(x)\) of the implicit equation \(F(x,y)=c\)

\(x_t>0\)

Amount of the first token denoted by X (e.g., XTZ) at time t

\(y_t>0\)

Amount of the second token denoted by Y (e.g., YOU) at time t

\(c_t=F(x_t,y_t)\)

Available liquidity at time t

\(S_t=\dfrac{F_x(x_t,y_t)}{F_y(x_t,y_t)}=-f'(x_t)\)

Implied spot FX-rate (e.g., XTZYOU) at time t, i.e., the value of 1 token X denominated in Y

\(S_t^x>0\)

Value of 1 token X with respect to some numéraire (e.g., USD) at time t

\(S_t^y>0\)

Value of 1 token Y with respect to the same numéraire at time t

\(0\le \kappa _1<1\)

Transaction fee of the infrastructure provider

\(0\le \kappa _2<1\)

Transaction fee of the liquidity pool

\(0\le \kappa :=\kappa _1+\kappa _2<1\)

Total transaction fees

XTZ is the native token of the Tezos blockchain. YOU is the governance token of the youves ecosystem. We use these two tokens to illustrate the two generic placeholders X and Y; see also the schematic chart in the Fig. 1 for a better understanding. All quantities with a subscript t represent càdlàg stochastic processes in continuous time.

Fig. 1
figure 1

Overview of the liquidity pool with the posted amounts \(x_t\) and \(y_t\). The setup involves three currencies (X, Y, and the numéraire) as well as three FX-rates

2.2 Methodology

There are no fees for posting or withdrawing liquidity. If one exchanges X for Y, or vice versa, via the liquidity pool, one basically does not leave the current isoline from the implicit function definition (modulo transaction fees). Generally speaking, one has to bear a transaction fee of, e.g., \(\kappa =0.35\%\) (excluding gas fees). In fact, things are a bit more involved. On the one hand, the fee consists of a service fee, e.g., \(\kappa _1=0.10\%\) that leaves the pool and rewards the liquidity pool provider. On the other hand, it consists of a \(\kappa _2=0.25\%\) liquidity fee that remains in the pool and remunerates the liquidity providers. For illustration, e.g., see Plenty, Quipuswap.

Definition 1

Let us assume that a market participant initiates a swap at time t by posting \(\Delta x\) of X to the liquidity pool. In return, she receives \(-\Delta y(\Delta x)\) of Y (the sign is by convention), where \(\Delta y(\Delta x)<0\) solves the equation

$$\begin{aligned} F\big (x_t^\text{pre}+(1-\kappa )\Delta x,y^\text{pre}+\Delta y(\Delta x)\big ){\mathop {=}\limits ^{!}}F\big (x_t^\text{pre},y_t^\text{pre}). \end{aligned}$$
(1)

One part of the transaction fees is paid implicitly to the pool by increasing the liquidity to the updated isoline

$$\begin{aligned} c_t^\text{post}(\Delta x):=F\left( x_t^\text{post}(\Delta x),y_t^\text{post}(\Delta x)\right) :=F\left( x_t^\text{pre}+(1-\kappa _1)\Delta x,y_t^\text{pre}+\Delta y(\Delta x)\right) . \end{aligned}$$
(2)

The residual part \(\kappa _1\Delta x\) is paid out to the infrastructure provider and leaves our consideration. Analogously, if \(\Delta y\) of Y is posted to the liquidity pool for \(-\Delta x(\Delta y)\) of X in return, the corresponding equation reads

$$\begin{aligned} F\big (x_t^\text{pre}+\Delta x(\Delta y),y^\text{pre}+(1-\kappa )\Delta y\big ){\mathop {=}\limits ^{!}}F\big (x_t^\text{pre},y_t^\text{pre}). \end{aligned}$$
(3)

Similarly,

$$\begin{aligned} c_t^\text{post}(\Delta y):=F\left( x_t^\text{post}(\Delta y),y_t^\text{post}(\Delta y)\right) :=F\left( x_t^\text{pre}+\Delta x(\Delta y),y_t^\text{pre}+(1-\kappa _1)\Delta y\right) \end{aligned}$$
(4)

refers to as the updated liquidity level.

Fees are always paid in the posted currency that devaluates. As we shall see, the market impact of transactions is often much greater than the impact of common transaction costs. The superscripts «pre» and «post» indicate that a transaction is taking place at this time instance. Alternatively, one could use another common notation \(x_{t\text{--}}:=x_t^\text{pre}\) and \(x_{t}:=x_t^\text{post}\).

2.3 Consistency of the FX rates

By absence of arbitrage (and by neglecting transaction costs for the sake of simplicity), the parity \(S_t^x=S_tS_t^y\) must prevail. Any discrepancy can theoretically be exploited or constitutes an illiquidity premium. The spot FX-rate \(S_t\) changes with each swap. For the remainder of the article, we tacitly assume without loss of generality that the stochastic rate \(S_t^x\) is given exogenously and that it is not affected by swaps within the liquidity pool. Equivalently, the token X is comparatively liquid, and the size of the liquidity pool is negligible with respect to the total outstanding amount of X. Later on, we will need to distinguish two limiting cases depending on whether the CFMM is just a marketplace (Sect. 3.5) or the market (Sect. 3.6).

Assumption 2

We assume that \((S_t^x)_{t\ge 0}\) is independent of \((y_t)_{t\ge 0}\).

3 Constant product market maker (CPMM)

3.1 Model

Definition 3

F simply is the product of the two components, i.e.,

$$\begin{aligned} F(x,y):=xy. \end{aligned}$$
(5)

The involved isolines are hyperbolas. The spot FX-rate is given by

$$\begin{aligned} S_t=\dfrac{F_x(x_t,y_t)}{F_y(x_t,y_t)}=\dfrac{y_t}{x_t}. \end{aligned}$$
(6)

Definition 3 is a popular choice. There are various modifications, e.g., Uniswap v3 (see the section A in the appendix) with leveraged positions, or Balancer (see the section B) involving \(n>2\) assets. With the standard approach, the FX rate changes instantaneously with every transaction. In the context of stable token pairs, other CFMM approaches with less susceptibility toward medium-sized transactions are more suitable, e.g., see the section C for an applicable alternative.

3.2 Dynamics of the liquidity pool

3.2.1 Case of posting X

If one intends to withdraw the target amount \(\Delta y\in(0,y_t^\text{pre})\) of Y, then the required posting of X amounts to

$$\Delta x(\Delta y)=\frac{x_t^\text{pre}\Delta y}{(1-\kappa)(y_t^\text{pre}-\Delta y)}$$
(7)

Generally, posting \(\Delta x>0\) of X leads in the liquidity pool to an outflow of

$$\begin{aligned} \Delta y(\Delta x)&=\frac{x_t^\text{pre}y_t^\text{pre}}{x_t^\text{pre}+(1-\kappa )\Delta x}-y_t^\text{pre}=-\frac{(1-\kappa )y_t^\text{pre}\Delta x}{x_t^\text{pre}+(1-\kappa )\Delta x}{} & {} <0 \end{aligned}$$
(8)

in Y. On the isolated level of the liquidity pool, X devaluates while Y appreciates. The realized FX rate of the trade amounts to

$$\begin{aligned} {\widetilde{S}}_t(\Delta x)&=\frac{\big |\Delta y(\Delta x)\big |}{\Delta x}=\frac{(1-\kappa )y_t^\text{pre}}{x_t^\text{pre}+(1-\kappa )\Delta x}{} & {} <S_t^\text{pre}. \end{aligned}$$
(9)

The subsequent state of the liquidity pool consists of the components

$$\begin{aligned} x_t^\text{post}(\Delta x)&=x_t^\text{pre}+(1-\kappa _1)\Delta x{} & {} >x_t^\text{pre}, \end{aligned}$$
(10)
$$\begin{aligned} y_t^\text{post}(\Delta x)&=y_t^\text{pre}+\Delta y(\Delta x)=\frac{x_t^\text{pre}y_t^\text{pre}}{x_t^\text{pre}+(1-\kappa )\Delta x}{} & {} <y_t^\text{pre},\end{aligned}$$
(11)
$$\begin{aligned} S_t^\text{post}(\Delta x)&=\frac{x_t^\text{pre}y_t^\text{pre}}{\big (x_t^\text{pre}+(1-\kappa _1)\Delta x\big )\big (x_t^\text{pre}+(1-\kappa )\Delta x\big )}{} & {} <S_t^\text{pre}. \end{aligned}$$
(12)

\({{\widetilde{S}}_t(\Delta x)\in \big (S_t^\text{post}(\Delta x),S_t^\text{pre}\big )}\) holds, provided that the posted amount is sufficiently large, namely

$$\begin{aligned} \Delta x&{{\mathop {>}\limits ^{!}}}\frac{\kappa }{(1-\kappa _1)(1-\kappa )}x_t^\text{pre}; \end{aligned}$$
(13)

compare (9) and (12). Otherwise, it even holds \({\widetilde{S}}_t(\Delta x)\le S_t^\text{post}(\Delta x)<S_t^\text{pre}\). If \(\kappa =0\), then \({{\widetilde{S}}_t(\Delta x)}\) is the geometric mean of \(S_t^\text{post}(\Delta x)\) and \(S_t^\text{pre}\).

3.2.2 Case of posting Y

If one intends to withdraw the target amount \(\Delta x\in(0,x_t^\text{pre})\) of X, then the required posting of Y amounts to

$$\Delta y(\Delta x)=\frac{y_t^\text{pre}\Delta x}{(1-\kappa)(x_t^\text{pre}-\Delta x)}$$
(14)

Generally, posting \(\Delta y>0\) of Y leads in the liquidity pool to an outflow of

$$\begin{aligned} \Delta x(\Delta y)&=\frac{x_t^\text{pre}y_t^\text{pre}}{y_t^\text{pre}+(1-\kappa )\Delta y}-x_t^\text{pre}=-\frac{(1-\kappa )x_t^\text{pre}\Delta y}{y_t^\text{pre}+(1-\kappa )\Delta y}{} & {} <0 \end{aligned}$$
(15)

in X. On the isolated level of the liquidity pool, X appreciates while Y depreciates. The realized FX rate amounts to

$$\begin{aligned} {\widetilde{S}}_t(\Delta y)&=\frac{\Delta y}{\big |\Delta x(\Delta y)\big |}=\frac{y_t^\text{pre}+(1-\kappa )\Delta y}{(1-\kappa )x_t^\text{pre}}{} & {} >S_t^\text{pre}. \end{aligned}$$
(16)

The subsequent state of the liquidity pool consists of the components

$$\begin{aligned} x_t^\text{post}(\Delta y)&=x_t^\text{pre}+\Delta x(\Delta y)=\frac{x_t^\text{pre}y_t^\text{pre}}{y_t^\text{pre}+(1-\kappa )\Delta y}{} & {} <x_t^\text{pre}, \end{aligned}$$
(17)
$$\begin{aligned} y_t^\text{post}(\Delta y)&=y_t^\text{pre}+(1-\kappa _1)\Delta y{} & {} >y_t^\text{pre}, \end{aligned}$$
(18)
$$\begin{aligned} S_t^\text{post}(\Delta y)&=\frac{\big (y_t^\text{pre}+(1-\kappa _1)\Delta y\big )\big (y_t^\text{pre}+(1-\kappa )\Delta y\big )}{x_t^\text{pre}y_t^\text{pre}}{} & {} >S_t^\text{pre}. \end{aligned}$$
(19)

\({{\widetilde{S}}_t(\Delta y)\in \big (S_t^\text{pre},S_t^\text{post}(\Delta y)\big )}\) holds, provided that the posted amount is sufficiently large. Again,

$$\begin{aligned} \Delta y&{{\mathop {>}\limits ^{!}}}\frac{\kappa }{(1-\kappa _1)(1-\kappa )}y_t^\text{pre}; \end{aligned}$$
(20)

compare (16) and (19). Otherwise, it even holds \({\widetilde{S}}_t(\Delta x)\ge S_t^\text{post}(\Delta x)>S_t^\text{pre}\). If \(\kappa =0\), then \({{\widetilde{S}}_t(\Delta y)}\) is the geometric mean of \(S_t^\text{pre}\) and \(S_t^\text{post}(\Delta y)\).

3.3 Arbitrage

Both sides of the liquidity pool must have the same economic value at all times, i.e., \({S_t^xx_t^\text{pre}{\mathop {=}\limits ^{!}}S_t^yy_t^\text{pre}}\). Otherwise, at least if the discrepancy is sufficiently large, it can be exploited in terms of a roundtrip, ceteris paribus. There is usually a narrow no arbitrage corridor, whose boundaries can be determined explicitly without further ado.

Theorem 4

(Maximal Arbitrage Opportunity) Let us consider a CPMM of Definition 3 and set

$$\begin{aligned} s:=\dfrac{S_t^x}{S_t^y}. \end{aligned}$$
(21)
  1. 1.

    If it holds \(S_t^xx_t^\text{pre}<S_t^yy_t^\text{pre}\), then posting

    $$\begin{aligned} \Delta x=\frac{-sx_t^\text{pre}(2-\kappa _1-\kappa )+\sqrt{D_{\Delta x}}}{2s(1-\kappa _1)(1-\kappa )}, \end{aligned}$$
    (22)

    where \(D_{\Delta x}:=\big (sx_t^\text{pre}(2-\kappa _1-\kappa )\big )^2-4\big ( s(1-\kappa _1)(1-\kappa )\big )\big (s(x_t^\text{pre})^2-x_t^\text{pre}y_t^\text{pre}\big )>0,\) initiates the optimal arbitrage opportunity, provided that

    $$s<\frac{(1-\kappa_1)(1-\kappa)}{(1+\kappa_2)}\frac{y_t^\text{pre}}{x_t^\text{pre}}$$
    (23)

    is satisfied.

  2. 2.

    If it holds \(S_t^xx_t^\text{pre}>S_t^yy_t^\text{pre}\), then posting

    $$\begin{aligned} \Delta y=\frac{-y_t^\text{pre}(2-\kappa _1-\kappa )+\sqrt{D_{\Delta y}}}{2(1-\kappa _1)(1-\kappa )}, \end{aligned}$$
    (24)

    where \(D_{\Delta y}:=\big (y_t^\text{pre}(2-\kappa _1-\kappa )\big )^2-4\big ((1-\kappa _1)(1-\kappa )\big )\big ( (y_t^\text{pre})^2-sx_t^\text{pre}y_t^\text{pre}\big )>0\), initiates the optimal arbitrage opportunity, provided that

    $$s>\frac{(1+\kappa_2)}{(1-\kappa_1)(1-\kappa)}\frac{y_t^\text{pre}}{x_t^\text{pre}}$$
    (25)

    is satisfied.

Proof

  1. 1.

    For the regulation, we aim at bringing the liquidity pool back into its equilibrium state \(sx_t^\text{post}=y_t^\text{post}\) by posting \(\Delta x>0\). This leaves us with the Eq.

    $$\begin{aligned} S_t^x\left( x_t^\text{pre}+(1-\kappa _1)\Delta x\right) {\mathop {\, = \, } \limits ^{!}}S_t^y\frac{x_t^\text{pre}y_t^\text{pre}}{x_t^\text{pre}+(1-\kappa )\Delta x}. \end{aligned}$$
    (26)

    This quadratic equation in \(\Delta x\) can be rearranged into the standard form

    $$\begin{aligned} 0=\underbrace{s(1-\kappa _1)(1-\kappa )}_{>0}[\Delta x ]^2+\underbrace{sx_t^\text{pre}(2-\kappa _1-\kappa )}_{>0}\Delta x+\underbrace{s{\left( x_t^\text{pre}\right) }^2-x_t^\text{pre}y_t^\text{pre}}_{<0}. \end{aligned}$$
    (27)

    It has the two well-defined solutions

    $$\begin{aligned} \Delta x_{1,2}=\frac{-sx_t^\text{pre}(2-\kappa _1-\kappa )\pm \sqrt{D_{\Delta x}}}{2s(1-\kappa _1)(1-\kappa )}\gtrless 0; \end{aligned}$$
    (28)

    solely \(\Delta x_1\) is economically meaningful. \(\Delta x_2<-x_t^\text{pre}\) is not feasible economically since we cannot withdraw more than the available amounts from the liquidity pool. \(\Delta x_1\) vanishes for \(s=S_t^\text{pre}\). It needs to be noted that the net value \(-S_t^x\Delta x_1-S_t^y\Delta y(\Delta x_1)\) with respect to the numéraire is not necessarily positive. Hence, whether there is an arbitrage opportunity or not must be examined carefully by checking the validity of (13), which is satisfied exactlyFootnote 3 under the requirement (23).

  2. 2.

    Similarly, we need to establish the parity

    $$\begin{aligned} S_t^x\frac{x_t^\text{pre}y_t^\text{pre}}{y_t^\text{pre}+(1-\kappa )\Delta y}{\mathop {=}\limits ^{!}}S_t^y\big (y_t^\text{pre}+(1-\kappa _1)\Delta y\big ). \end{aligned}$$
    (29)

    The same procedure as above yields

    $$\begin{aligned} 0=\underbrace{(1-\kappa _1)(1-\kappa )}_{>0}[\Delta y]^2+\underbrace{y_t^\text{pre}(2-\kappa _1-\kappa )}_{>0}\Delta y+\underbrace{(y_t^\text{pre})^2-S_t^\text{post}x_t^\text{pre}y_t^\text{pre}}_{<0} \end{aligned}$$
    (30)

    with the two solutions

    $$\begin{aligned} \Delta y_{1,2}=\frac{-y_t^\text{pre}(2-\kappa _1-\kappa ) \pm \sqrt{D_{\Delta y}}}{2(1-\kappa _1)(1-\kappa )}\gtrless 0; \end{aligned}$$
    (31)

    again, solely \(\Delta y_1\) is economically meaningful. \(\Delta y_1\) vanishes for \(S_t^\text{post}=S_t^\text{pre}\). The validity of the condition (20) must be verified just as well, which is equivalent to the requirement (25).

This concludes the proof. \(\square\)

In the absence of transaction fees, the involved quantities simplify considerably, and the two cases unite in one formula. We leave the elementary adjustments of the proof to the knowledgeable reader.

Corollary 5

(Maximal Arbitrage Opportunity in the Absence of Transaction Costs) Let us consider the setting of Theorem 4 with \(\kappa =0\). In either case, eligible swappingFootnote 4

$$\begin{aligned} \Delta x=-x_t^\text{pre}+\sqrt{\frac{x_t^\text{pre}y_t^\text{pre}}{s}}\qquad \text{against}\qquad \Delta y=-y_t^\text{pre}+\sqrt{sx_t^\text{pre}y_t^\text{pre}} \end{aligned}$$
(32)

has an economic value of

$$\begin{aligned} -S_t^x\Delta x_1-S_t^y\Delta y_1=\bigg (\sqrt{S_t^xx_t^\text{pre}}-\sqrt{S_t^yy_t^\text{pre}}\bigg )^2\ge 0 \end{aligned}$$
(33)

with respect to the numéraire. For \(s\ne S_t^\text{pre}\), one can exploit an arbitrage opportunity indeed. It vanishes if and only if \(s=S_t^\text{pre}\).

3.4 Impermanent loss without transaction cost

For easier understanding, let us temporarily assume \(\kappa =0\); the general case is treated subsequently in the Sects. 3.5 and 3.6. If the intrinsic FX-rate \(S_t\) remained constant, then one could earn transaction cost from providing liquidity without adverse circumstances. If the FX rate changes in either direction, one has to bear substantial opportunity costs. Let us assume that we provided \(x_t\) and \(y_t\) to the liquidity pool at time t, which was worth

$$\begin{aligned} S_t^xx_t+S_t^yy_t=S_t^x\left( x_t+{S_t}^{-1}y_t\right) =2S_t^xx_t \end{aligned}$$
(34)

with respect to the numéraire. If the FX-rate at time \(t+\Delta t\) changed to \(S_{t+\Delta t}\), then arbitrageurs would have rebalanced the amounts to

$$\begin{aligned} x_{t+\Delta t}=\sqrt{\frac{c_t}{S_{t+\Delta t}}},\qquad y_{t+\Delta t}=\sqrt{c_tS_{t+\Delta t}}. \end{aligned}$$
(35)

Therefore, the opportunity cost would amount to

$$\begin{aligned} \underbrace{S_{t+\Delta t}^x\left( x_{t+\Delta t}+{S_{t+\Delta t}}^{-1}y_{t+\Delta t}\right) }_{\text{rebalanced liquidity pool}}-\underbrace{S_{t+\Delta t}^x\left( x_t+{S_{t+\Delta t}}^{-1}y_t\right) }_{\text{vanilla portfolio}}=-S_{t+\Delta t}^xx_t\left( 1-\sqrt{\frac{S_t}{S_{t+\Delta t}}}\right) ^2, \end{aligned}$$
(36)

which perfectly offsets the gain of the arbitrageurs; see (33). The Fig. 2 depicts the shape of the impermanent loss qualitatively. Note that the impermanent loss is symmetric in the sense that it basically only depends on the relative performance of \(S_{t+\Delta t}\) with respect to \(S_t\). It exceeds the revalued liquidity pool outside of the range \({S_t(2\pm \sqrt{3}\big )^2\approx [0.07S_t,14S_t]}\).

Fig. 2
figure 2

This chart is generated with the reference points \(x_t=125.00\), \(S_t^x=4.00\), \(y_t=156.25\), and \(S_t^y=3.20\). It indicates the shape of the impermanent loss. The blue line would depict the value of the vanilla portfolio with respect to movements of \(S_t^y\), ceteris paribus, if one held \(x_t\) and \(y_t\) in a wallet. The orange line represents the corresponding value of the liquidity pool, if it is regulated by arbitrageurs. The discrepancy between these two curves is the impermanent loss

Theoretically, as proposed by Fukasawa et al. (2023), the impermanent loss could be hedged (but typically at significant cost). By the general Carr-Madan-formula (see Carr & Madan, 1999), it holds for any \(g:(0,\infty )\longrightarrow {\mathbb {R}}\) subject to sufficient regularity

$$\begin{aligned} \begin{aligned} g(x)=g(x_0)+g'(x_0)(x-x_0)&+\int _{0}^{x_0}g''(k)\max \{k-x,0\}\,dk\\&+\int _{x_0}^{\infty }g''(k)\max \{x-k,0\}\,dk. \end{aligned} \end{aligned}$$
(37)

For the impermanent loss measured in X, it holds at \(S_t=\dfrac{y_t}{x_t}\)

$$\begin{aligned} \ell ^X(s)&=\left( \sqrt{x_t}-\sqrt{\dfrac{y_t}{s}}\right) ^2&\ell ^X(S_t)&=0, \end{aligned}$$
(38)
$$\begin{aligned} \partial _s\ell ^X(s)&=\sqrt{\frac{x_ty_t}{s^3}}-\frac{y_t}{s^2}&\partial _s\ell ^X(S_t)&=0,\end{aligned}$$
(39)
$$\begin{aligned} \partial _{ss}\ell ^X(s)&=-\frac{3}{2}\sqrt{\frac{x_ty_t}{s^5}}+\frac{2y_t}{s^3}. \end{aligned}$$
(40)

Thus, the impermanent loss with respect to some fixed maturity \(T>t\) (e.g., one year) can perfectly be replicated in X through a continuum of European put and call options. More precisely, it entails

$$\begin{aligned} \begin{aligned} \ell ^X(S_T)&=\int _0^{S_t}\Bigg (-\frac{3}{2}\sqrt{\frac{x_ty_t}{k^5}}+\frac{2y_t}{k^3}\Bigg )\max \{k-S_T,0\}\,dk\\&+\int _{S_t}^{\infty }\Bigg (-\frac{3}{2}\sqrt{\frac{x_ty_t}{k^5}}+\frac{2y_t}{k^3}\Bigg )\max \{S_T-k,0\}\,dk. \end{aligned} \end{aligned}$$
(41)

Furthermore, its economic value can be assessed by approximating the continuum using Riemann sums. For volatilities of \(S_t\) beyond \(100\%\) and \(150\%\) (as often observed with crypto currencies), it typically exceeds \(10\%\) and \(25\%\) respectively of the liquidity pool value over a target horizon of 1y; these estimates can be easily replicated using the Black-Scholes-Merton formulas (see Black & Scholes, 1973, Merton, 1974) and are also integrated in the Jupyter notebook. If \(\kappa =0.35\%\), this is equivalent to a roughly 28- and 70-fold circulation respectively of the entire liquidity pool (before liquidity fees are earned at all). For many crypto token pairs, this impediment is simply not realistic. This finding is corroborated by Loesch et al. (2021) and Cohen et al. (2023). The former examines empirically the encountered impermanent loss for Uniswap v3 (see the section A in the appendix). The latter relies on agent-based simulations.

3.5 Liquidity pool dynamics in the case 1: a marketplace

Consistently, both \(S_t^x\) and \(S_t^y\) remain unaffected by transactions and are given exogenously. On the one hand, \(S_t\) (one monetary unit of X denominated in Y) can be inferred from \(S_t^x\) and \(S_t^y\) by absence of arbitrage; see Theorem 4. On the other hand, \(S_t\) can be inferred from the state and the dynamics of the CPMM. Discrepancies in the FX rate from the two sources can be attributed to asset illiquidity. In the following, we derive several useful quantities of pool dynamics that depend exclusively on independent input parameters, namely

$$\begin{aligned}&S_t^x,\ S_t^y,\ x_t^\text{pre},\ \kappa =\kappa _1+\kappa _2,\ \text{contribution: either}\ \Delta x\ \text{or}\ \Delta y. \end{aligned}$$
(42)

0. Initial state of the liquidity pool in equilibrium:

$$\begin{aligned}&x_t^\text{pre}\ \text{with accounting value}\ S_t^xx_t^\text{pre} \end{aligned}$$
(43)
$$\begin{aligned}&y_t^\text{pre}=\dfrac{S_t^xx_t^\text{pre}}{S_t^y}\ \text{with accounting value}\ S_t^yy_t^\text{pre}=S_t^xx_t^\text{pre} \end{aligned}$$
(44)
$$\begin{aligned}&c_t^\text{pre}=x_t^\text{pre}y_t^\text{pre}=\dfrac{S_t^x(x_t^\text{pre})^2}{S_t^y} \end{aligned}$$
(45)
$$\begin{aligned}&\text{FX-rate of the liquidity pool:}\ S_t^\text{pre}=\dfrac{y_t^\text{pre}}{x_t^\text{pre}}=\dfrac{S_t^x}{S_t^y} \end{aligned}$$
(46)
$$\begin{aligned}&\begin{aligned} \text{Accounting value of the liquidity pool:}\ V_t^\text{pre}&=S_t^xx_t^\text{pre}+S_t^yy_t^\text{pre}\\&=2S_t^xx_t^\text{pre} \end{aligned} \end{aligned}$$
(47)

x. Swap \(\Delta x>0\) against the other token:

$$\begin{aligned}&\Delta y(\Delta x)=\dfrac{-S_t^xx_t^\text{pre}(1-\kappa )\Delta x}{S_t^y\left( x_t^\text{pre}+(1-\kappa )\Delta x\right) }<0\ \text{leave the liquidity pool} \end{aligned}$$
(48)
$$\begin{aligned}&\text{FX-rate of the transaction:}\ {\widetilde{S}}_t(\Delta x)=\dfrac{S_t^x(1-\kappa )x_t^\text{pre}}{S_t^y\left( x_t^\text{pre}+(1-\kappa )\Delta x\right) } \end{aligned}$$
(49)
$$\begin{aligned}&\text{Subsequent state of the liquidity pool after the transaction:}\nonumber \\&\ x_t^\text{post}(\Delta x)=x_t^\text{pre}+(1-\kappa _1)\Delta x \end{aligned}$$
(50)
$$\begin{aligned}&\ y_t^\text{post}(\Delta x)=\dfrac{S_t^x\left( x_t^\text{pre}\right) ^2}{S_t^y\left( x_t^\text{pre}+(1-\kappa )\Delta x\right) } \end{aligned}$$
(51)
$$\begin{aligned}&\ \begin{aligned} {c_t^\text{post}(\Delta x) }&{=\dfrac{x_t^\text{pre}+(1-\kappa _1)\Delta x}{x_t^\text{pre}+(1-\kappa )\Delta x}c_t^\text{pre}}\\&{=\dfrac{x_t^\text{pre}+(1-\kappa _1)\Delta x}{x_t^\text{pre}+(1-\kappa )\Delta x}\dfrac{S_t^x\left( x_t^\text{pre}\right) ^2}{S_t^y}} \end{aligned} \end{aligned}$$
(52)
$$\begin{aligned}&\ \begin{aligned} {S_t^\text{post}(\Delta x) }&{=\dfrac{c_t^\text{pre}}{\left( x_t^\text{pre}+(1-\kappa _1)\Delta x\right) \left( x_t^\text{pre}+(1-\kappa )\Delta x\right) }}\\&{=\dfrac{S_t^x(x_t^\text{pre})^2}{S_t^y\left( x_t^\text{pre}+(1-\kappa _1)\Delta x\right) \left( x_t^\text{pre}+(1-\kappa )\Delta x\right) }} \end{aligned} \end{aligned}$$
(53)
$$\begin{aligned}&\ \begin{aligned} {V_t^\text{post}(\Delta x)}&={S_t^x\left( x_t^\text{pre}+(1-\kappa _1)\Delta x\right) +S_t^y\dfrac{c_t^\text{pre}}{x_t^\text{pre}+(1-\kappa )\Delta x}}\\&={S_t^x\left( x_t^\text{pre}+(1-\kappa _1)\Delta x\right) +\dfrac{S_t^x(x_t^\text{pre})^2}{x_t^\text{pre}+(1-\kappa )\Delta x}>V_t^\text{pre}} \end{aligned} \end{aligned}$$
(54)
$$\begin{aligned}&\ \text{Return on capital:}\nonumber \\&\ \ \begin{aligned} {r_t(\Delta x)}&={\dfrac{S_t^x(1-\kappa _1)\Delta x+S_t^yy_t^\text{pre}\left( \dfrac{x_t^\text{pre}}{x_t^\text{pre}+(1-\kappa )\Delta x}-1\right) }{S_t^xx_t^\text{pre}+S_t^yy_t^\text{pre}}}\\&={\dfrac{\Delta x\left( \kappa _2x_t^\text{pre}+(1-\kappa _1)(1-\kappa )\Delta x\right) }{2x_t^\text{pre}\left( x_t^\text{pre}+(1-\kappa )\Delta x\right) }} \end{aligned} \end{aligned}$$
(55)
$$\begin{aligned}&\ \text{Return on transaction volume:}\nonumber \\&\quad \begin{aligned} {{\widetilde{r}}_t(\Delta x)}&={\dfrac{S_t^x(1-\kappa _1)\Delta x+S_t^yy_t^\text{pre}\bigg (\dfrac{x_t^\text{pre}}{x_t^\text{pre}+(1-\kappa )\Delta x}-1\bigg )}{-S_t^y\Delta y(\Delta x)}}\\&={\dfrac{S_t^x(1-\kappa _1)x_t^\text{pre}+S_t^x(1-\kappa _1)(1-\kappa )\Delta x-S_t^y(1-\kappa )y_t^\text{pre}}{S_t^x(1-\kappa )x_t^\text{pre}}} \end{aligned} \end{aligned}$$
(56)

y. Swap \(\Delta y>0\) against the other token:

$$\begin{aligned}&\Delta x(\Delta y)=\dfrac{-S_t^y(1-\kappa )x_t^\text{pre}\Delta y}{S_t^xx_t^\text{pre}+S_t^y(1-\kappa )\Delta y}<0\ \text{leave the liquidity pool} \end{aligned}$$
(57)
$$\begin{aligned}&\text{FX-rate of the transaction:}\ {\widetilde{S}}_t(\Delta y)=\dfrac{S_t^xx_t^\text{pre}+S_t^y(1-\kappa )\Delta y}{S_t^y(1-\kappa )x_t^\text{pre}} \end{aligned}$$
(58)
$$\begin{aligned}&\text{Subsequent state of the liquidity pool after the transaction:}\nonumber \\&\ x_t^\text{post}(\Delta y)=\dfrac{S_t^x(x_t^\text{pre})^2}{S_t^xx_t^\text{pre}+S_t^y(1-\kappa )\Delta y} \end{aligned}$$
(59)
$$\begin{aligned}&\ y_t^\text{post}(\Delta y)=\dfrac{S_t^xx_t^\text{pre}}{S_t^y}+(1-\kappa _1)\Delta y\end{aligned}$$
(60)
$$\begin{aligned}&\ \begin{aligned} {c_t^\text{post}(\Delta y) }&{=\dfrac{S_t^xx_t^\text{pre}+S_t^y(1-\kappa _1)\Delta y}{S_t^xx_t^\text{pre}+S_t^y(1-\kappa )\Delta y}c_t^\text{pre}}\\&{=\dfrac{S_t^xx_t^\text{pre}+S_t^y(1-\kappa _1)\Delta y}{S_t^xx_t^\text{pre}+S_t^y(1-\kappa )\Delta y}\dfrac{S_t^x\left( x_t^\text{pre}\right) ^2}{S_t^y}} \end{aligned} \end{aligned}$$
(61)
$$\begin{aligned}&\ \begin{aligned} {S_t^\text{post}(\Delta y)}&={\dfrac{\big (y_t^\text{pre}+(1-\kappa _1)\Delta y\big )\big (y_t^\text{pre}+(1-\kappa )\Delta y\big )}{c_t^\text{pre}}}\\&={\dfrac{\big (S_t^xx_t^\text{pre}+S_t^y(1-\kappa _1)\Delta y\big )\big (S_t^xx_t^\text{pre}+S_t^y(1-\kappa )\Delta y\big )}{S_t^xS_t^y(x_t^\text{pre})^2}}\\ \end{aligned} \end{aligned}$$
(62)
$$\begin{aligned}&\ \begin{aligned} {V_t^\text{post}(\Delta y)}&={S_t^x\dfrac{c_t^\text{pre}}{y_t^\text{pre}+(1-\kappa )\Delta y}+S_t^y\big (y_t^\text{pre}+(1-\kappa _1)\Delta y\big )}\\&={\dfrac{(S_t^xx_t^\text{pre})^2}{S_t^xx_t^\text{pre}+S_t^y(1-\kappa )\Delta y}+\big (S_t^xx_t^\text{pre}+S_t^y(1-\kappa _1)\Delta y\big )>V_t^\text{pre}} \end{aligned} \end{aligned}$$
(63)
$$\begin{aligned}&\ \text{Return on capital:}\nonumber \\&\ \ \begin{aligned} {r_t(\Delta y)}&={\dfrac{S_t^xx_t^\text{pre}\bigg (\dfrac{y_t^\text{pre}}{y_t^\text{pre}+(1-\kappa )\Delta y}-1\bigg )+S_t^y(1-\kappa _1)\Delta y}{S_t^xx_t^\text{pre}+S_t^yy_t^\text{pre}}}\\&={\dfrac{S_t^y\Delta y\big (S_t^x\kappa _2x_t^\text{pre}+S_t^y(1-\kappa _1)(1-\kappa )\Delta y\big )}{2S_t^xx_t^\text{pre}\big (S_t^xx_t^\text{pre}+S_t^y(1-\kappa )\Delta y\big )}} \end{aligned} \end{aligned}$$
(64)
$$\begin{aligned}&\ \text{Return on transaction volume:}\nonumber \\&\ \ \begin{aligned} {{\widetilde{r}}_t(\Delta y)}&={\dfrac{S_t^xx_t^\text{pre}\bigg (\dfrac{y_t^\text{pre}}{y_t^\text{pre}+(1-\kappa )\Delta y}-1\bigg )+S_t^y(1-\kappa _1)\Delta y}{-S_t^x\Delta x(\Delta y)}}\\&={\dfrac{-S_t^x(1-\kappa )x_t^\text{pre}+S_t^y(1-\kappa _1)(1-\kappa )\Delta y+S_t^y(1-\kappa _1)y_t^\text{pre}}{S_t^y(1-\kappa )x_t^\text{pre}}} \end{aligned} \end{aligned}$$
(65)

It needs to be noted that this market situation is somewhat pathological as it opens arbitrage opportunities after every excursion of \(S_t\) from the parity, ceteris paribus; see the Sect. 3.3. The liquidity pool can be regarded as immediate counterparty, whereas arbitrageurs assume the role of delayed counterparties who earn the slippage. Moreover, with respect to the numéraire, there is no impermanent loss in this comparatively small marketplace even in the absence of transaction cost; see (54) and (63). Neither X nor Y require the implicit rate \(S_t\) for valuation purposes.

3.6 Liquidity pool dynamics in the case 2: the market

Without loss of generality, let us assume that the CPMM is the only marketplace where Y can be bought and sold against X, whereas X is a comparatively liquid token. Consistently, \(S_t^x\) remains unaffected by the transaction and \(S_t\) is implied by the CPMM. Thus, \(S_t^y\) can be inferred by absence of arbitrage; see Theorem 4. On the one hand, buying and holding a crypto currency pair is a frictionless trading strategy which is far more promising than providing liquidity (since one does not incur an impermanent loss). On the other hand, a token without liquidity has no value. Therefore, one needs to come up with a risk management solution to incentivize liquidity. Apparently, this is not an easy task; we present a viable proposal in the Sect. 3.10. We proceed similarly as in the previous section. This time, the independent input parameters for the model comprise

$$\begin{aligned}&S_t^x,\ x_t^\text{pre},\ y_t^\text{pre},\ \kappa =\kappa _1+\kappa _2,\ \text{contribution: either}\ \Delta x\ \text{or}\ \Delta y. \end{aligned}$$
(66)

0. Initial state of the liquidity pool in equilibrium:

$$\begin{aligned}&x_t^\text{pre}\ \text{with accounting value}\ S_t^xx_t^\text{pre} \end{aligned}$$
(67)
$$\begin{aligned}&\begin{aligned} y_t^\text{pre}\ \text{with accounting value}\ S_t^{y,\text{pre}}y_t^\text{pre}&=S_t^xx_t^\text{pre},\ \text{where}\\ S_t^{y,\text{pre}}&{=S_t^x(S_t^\text{pre})^{-1}} \end{aligned} \end{aligned}$$
(68)
$$\begin{aligned}&{c_t^\text{pre}=x_t^\text{pre}y_t^\text{pre}} \end{aligned}$$
(69)
$$\begin{aligned}&\text{FX-rate of the liquidity pool:}\ S_t^\text{pre}=\dfrac{y_t^\text{pre}}{x_t^\text{pre}} \end{aligned}$$
(70)
$$\begin{aligned}&\begin{aligned} \text{Accounting value of the liquidity pool:}\ V_t^\text{pre}&{=S_t^xx_t^\text{pre}+S_t^{y,\text{pre}}y_t^\text{pre}}\\&{=2S_t^xx_t^\text{pre}} \end{aligned} \end{aligned}$$
(71)

x. Swap \(\Delta x>0\) against the other token:

$$\begin{aligned}&\Delta y(\Delta x)=\dfrac{-y_t^\text{pre}(1-\kappa )\Delta x}{x_t^\text{pre}+(1-\kappa )\Delta x}<0\ \text{leave the liquidity pool} \end{aligned}$$
(72)
$$\begin{aligned}&\text{FX-rate of the transaction:}\ {\widetilde{S}}_t(\Delta x)=\dfrac{(1-\kappa )y_t^\text{pre}}{x_t^\text{pre}+(1-\kappa )\Delta x} \end{aligned}$$
(73)
$$\begin{aligned}&\text{Subsequent state of the liquidity pool after the transaction:}\nonumber \\&\ {x_t^\text{post}(\Delta x)=x_t^\text{pre}+(1-\kappa _1)\Delta x} \end{aligned}$$
(74)
$$\begin{aligned}&\ {y_t^\text{post}(\Delta x)=\dfrac{x_t^\text{pre}y_t^\text{pre}}{x_t^\text{pre}+(1-\kappa )\Delta x}} \end{aligned}$$
(75)
$$\begin{aligned}&\ {c_t^\text{post}(\Delta x)=\dfrac{x_t^\text{pre}+(1-\kappa _1)\Delta x}{x_t^\text{pre}+(1-\kappa )\Delta x}x_t^\text{pre}y_t^\text{pre}} \end{aligned}$$
(76)
$$\begin{aligned}&\ \begin{aligned} {S_t^\text{post}(\Delta x)}&={\dfrac{c_t^\text{pre}}{\big (x_t^\text{pre}+(1-\kappa _1)\Delta x\big )\big (x_t^\text{pre}+(1-\kappa )\Delta x\big )}}\\&={\dfrac{x_t^\text{pre}y_t^\text{pre}}{\big (x_t^\text{pre}+(1-\kappa _1)\Delta x\big )\big (x_t^\text{pre}+(1-\kappa )\Delta x\big )}} \end{aligned} \end{aligned}$$
(77)
$$\begin{aligned}&\ \begin{aligned} {V_t^\text{post}(\Delta x)}&={S_t^x\big (x_t^\text{pre}+(1-\kappa _1)\Delta x\big )+S_t^{y,\text{post}}(\Delta x)\dfrac{c_t^\text{pre}}{x_t^\text{pre}+(1-\kappa )\Delta x}} \\&={2S_t^x\big (x_t^\text{pre}+(1-\kappa _1)\Delta x\big ){\mathop {\longrightarrow }\limits ^{\Delta x\rightarrow \infty }}\infty } \end{aligned} \end{aligned}$$
(78)
$$\begin{aligned}&\ \text{Return on capital:}\ r_t(\Delta x)=\dfrac{(1-\kappa _1)\Delta x}{x_t^\text{pre}} \end{aligned}$$
(79)
$$\begin{aligned}&\ \text{Return on transaction volume:}\nonumber \\&\ \ \begin{aligned} {{\widetilde{r}}_t(\Delta x)}&={\dfrac{2S_t^x\big (x_t^\text{pre}+(1-\kappa _1)\Delta x\big )-2S_t^xx_t^\text{pre}}{-S_t^{y,\text{pre}}\Delta y(\Delta x)}}\\&={\dfrac{2(1-\kappa _1)x_t^\text{pre}+2(1-\kappa _1)(1-\kappa )\Delta x}{(1-\kappa )x_t^\text{pre}}} \end{aligned} \end{aligned}$$
(80)

y. Swap \(\Delta y>0\) against the other token:

$$\begin{aligned}&\Delta x(\Delta y)=\dfrac{-x_t^\text{pre}(1-\kappa )\Delta y}{y_t^\text{pre}+(1-\kappa )\Delta y}<0\ \text{leave the liquidity pool} \end{aligned}$$
(81)
$$\begin{aligned}&\text{FX-rate of the transaction:}\ {\widetilde{S}}_t(\Delta y)=\dfrac{y_t^\text{pre}+(1-\kappa )\Delta y}{x_t^\text{pre}(1-\kappa )} \end{aligned}$$
(82)
$$\begin{aligned}&\text{Subsequent state of the liquidity pool after the transaction:}\nonumber \\&\ {x_t^\text{post}(\Delta y)=\dfrac{x_t^\text{pre}y_t^\text{pre}}{y_t^\text{pre}+(1-\kappa )\Delta y}} \end{aligned}$$
(83)
$$\begin{aligned}&\ {y_t^\text{post}(\Delta y)=y_t^\text{pre}+(1-\kappa _1)\Delta y} \end{aligned}$$
(84)
$$\begin{aligned}&\ {c_t^\text{post}(\Delta y)=\dfrac{y_t^\text{pre}+(1-\kappa _1)\Delta y}{y_t^\text{pre}+(1-\kappa )\Delta y}x_t^\text{pre}y_t^\text{pre}} \end{aligned}$$
(85)
$$\begin{aligned}&\ \begin{aligned} {S_t^\text{post}(\Delta y)}&={S_t^\text{post} =\dfrac{\big (y_t^\text{pre}+(1-\kappa _1)\Delta y\big )\big (y_t^\text{pre}+(1-\kappa )\Delta y\big )}{c_t^\text{pre}}}\\&={\dfrac{\big (y_t^\text{pre}+(1-\kappa _1)\Delta y\big )\big (y_t^\text{pre}+(1-\kappa )\Delta y\big )}{x_t^\text{pre}y_t^\text{pre}}}\\ \end{aligned} \end{aligned}$$
(86)
$$\begin{aligned}&\ \begin{aligned} {V_t^\text{post}(\Delta y)}&={S_t^x\dfrac{c_t^\text{pre}}{y_t^\text{pre}+(1-\kappa )\Delta y}+S_t^{y,\text{post}}\big (y_t^\text{pre}+(1-\kappa _1)\Delta y\big )}\\&={\dfrac{2S_t^xx_t^\text{pre}y_t^\text{pre}}{y_t^\text{pre}+(1-\kappa )\Delta y}{\mathop {\longrightarrow }\limits ^{\Delta x\rightarrow \infty }}0} \end{aligned} \end{aligned}$$
(87)
$$\begin{aligned}&\ \text{Return on capital:}\ r_t(\Delta y)=-\dfrac{(1-\kappa )\Delta y}{y_t^\text{pre}+(1-\kappa )\Delta y} \end{aligned}$$
(88)
$$\begin{aligned}&\ \text{Return on transaction volume:}\nonumber \\&\ \ {{\widetilde{r}}_t(\Delta y)=\dfrac{\dfrac{2S_t^xx_t^\text{pre}y_t^\text{pre}}{y_t^\text{pre}+(1-\kappa )\Delta y}-2S_t^xx_t^\text{pre}}{-S_t^x\Delta x(\Delta y)}=-2} \end{aligned}$$
(89)

The simplicity of \({\widetilde{r}}_t(\Delta y)\) in Eq. (89) is remarkable.

3.7 Market capitalization versus sale value

Firstly, let us assume that one holds \(\Delta y>0\) of Y. The accounting value of the holding amounts to

$$V_t=S_t^y\Delta y=S_t^x{S_t}^{-1}\Delta y=S_t^x\frac{x_t^\text{pre}}{y_t^\text{pre}}\Delta y$$
(90)

. In turn, by (81), if one wants to dispose of this holding, the realized sale value denominated in the numéraire amounts to

$$\begin{aligned} {{\widetilde{V}}_t=S_t^x {\dfrac{x_t^\text{pre}(1-\kappa ) \Delta y}{y_t^\text{pre}+(1-\kappa )\Delta y}}={{V}_t}} -\underbrace {\Big(1-{\dfrac{(1-\kappa ){y_t^\text{pre}}}{y_t^\text{pre}+(1-\kappa )\Delta y}}\Big) V_{t}}_{\text{illiquidity premium}}.\end{aligned}$$
(91)

Secondly, let us assume that one holds a fraction \(\lambda \in [0,1]\) of the liquidity pool. The accounting value of the holding amounts to \(V_t=2\lambda S_t^xx_t^\text{pre}\). In turn, the sale value can be calculated by withdrawing \(\lambda x_t^\text{pre}\) and \(\lambda y_t^\text{pre}\)—leading to a new liquidity of \(c_t^\text{post}=(1-\lambda)^2x_t^\text{pre}y_t^\text{pre}\)—and swapping \(\Delta y=\lambda y_t^\text{pre}\) against

$$\begin{aligned} \Delta x(\Delta y)=\frac{(1-\kappa )(1-\lambda )\lambda x_t^\text{pre}}{1-\kappa \lambda }. \end{aligned}$$
(92)

With respect to the numéraire, this leaves us with

$$\begin{aligned} {\widetilde{V}}_t=\frac{\lambda (2-\kappa -\lambda )}{1-\kappa \lambda }S_t^xx_t^\text{pre}=\underbrace{2\lambda S_t^xx_t^\text{pre}}_{=V_t}-\underbrace{\frac{\lambda (\kappa +\lambda -2\kappa \lambda )}{1-\kappa \lambda }S_t^xx_t^\text{pre}}_{\text{illiquidity premium}}. \end{aligned}$$
(93)

For \(\kappa=0\), the illiquidity premium reduces to \(\lambda^2S_t^xx_t^\text{pre}\).

3.8 Model-independent simulation and the inverse problem

For a given initial state of a liquidity pool, one can simulate arbitraryFootnote 5 non-negative paths of \(S_t^x\), \(S_t^y\) and \(S_t\) together with stochastic trading instances \({\mathbb {T}}\subset [0,\infty )\) over a predefined time horizon. From this, one derives the associated càdlàg step function \(S_t^\lrcorner :=S_{\max \{t_i\in {\mathbb {T}}|t_i\le t\}}\); see the Fig. 3 for an illustration. For each trading instance, one can utilize the Eqs. (28) or (31) respectively (depending on whether the updated \(S_t^\text{post}:=S_t^\lrcorner\) is larger or smaller than \(S_t^\text{pre}:=S_{t\text{--}}^\lrcorner\)) and back out the unique swap \((\Delta x,\Delta y)\) that caused this FX-rate shift. With this approach, one easily obtains empirically a rich class of consistent roll-forwards of a liquidity pool including all individual transactions. Notably, the approach works regardless of the model choice for the FX-rates and the trading instances. To this end, the following reparametrization of the inverse problem may be useful: Let \(p\in (0,\infty )\) and \(S_t^\text{post}=pS_t^\text{pre}\). Let us introduce the auxiliary quantity

$$\begin{aligned} \xi (\kappa _1,\kappa _2,p):=\frac{-p(2-2\kappa _1-\kappa _2)+\sqrt{p^2{\kappa _2}^2+4p(1-\kappa _1)(1-\kappa _1-\kappa _2)}}{2p(1-\kappa _1)(1-\kappa _1-\kappa _2)}. \end{aligned}$$
(94)

Note that \({\xi (0,0,p)=\dfrac{\sqrt{p}}{p}-1}\) and \(\xi (\kappa _1,\kappa _2,1)=0\). Then, one can retrieve the posted amounts

$$\begin{aligned}&{\left\{ \begin{array}{ll} \Delta x(p)=\xi \left( \kappa _1,\kappa _2,p\right) x_t^\text{pre}&{}\ \text{if}\ p\le 1,\\ \Delta y(p)=\xi \left( \kappa _1,\kappa _2,p^{-1}\right) y_t^\text{pre}&{}\ \text{if}\ p>1, \end{array}\right. } \end{aligned}$$
(95)

as well as the revaluation of the liquidity pool

$$\begin{aligned} V_t^\text{post}(p)=&{\left\{ \begin{array}{ll} 2S_t^xx_t^\text{pre}\left( 1+(1-\kappa _1)\xi (\kappa _1,\kappa _2,p)\right) &{}\ \text{if}\ p\le 1,\\ \dfrac{2S_t^xx_t^\text{pre}}{\left( 1+(1-\kappa )\xi (\kappa _1,\kappa _2,p^{-1})\right) }&{}\ \text{if}\ p>1. \end{array}\right. } \end{aligned}$$
(96)

The formulas (95) and (96) highlight a certain symmetry in both directions of FX movements. One obtains the updated accounting value of the liquidity pool through interest-like compounding and discounting respectively. See the Jupyter notebook for a readily available implementation of the simulation framework in Python as well as the Fig. 4.

Fig. 3
figure 3

The upper chart illustrates two sample paths of \((S_t^x)_{0\leq t\leq 1}\) and \((S_t)_{0\leq t\leq 1}\) respectively. The lower chart shows the inferred càdlàg step functions that jump on randomly sampled trading instances. In our considerations, changes in XTZYOU can only be observed through transactions

Fig. 4
figure 4

This chart depicts the accounting value of the liquidity pool consistent with Fig. 5. The impact of transaction cost is almost not visible, whereas the impermanent loss (the discrepancy between the performance of the liquidity pool and the vanilla portfolio) can become significantly large

3.9 Absolute hedge

Issuers of the token Y desire a suitable asset liquidity. Therefore, it is worth looking at whether an absolute hedge (i.e., keeping the economic value of the inventory flat) can be achieved in a CPMM at reasonable cost. Unfortunately, this is not the case. Hedging the significant downside risk at the cost of discarding upside potential comes at the same cost as hedging the impermanent loss. For illustration, we ignore transaction cost and measure everything with respect to X. We intend to replicate

$$\begin{aligned} h(s):=\underbrace{x_t+s_ty_t}_{\text{flat position}}-\Bigg (\underbrace{x_t+sy_t}_{\text{vanilla portfolio}}-\underbrace{\bigg (\sqrt{x_t}-\sqrt{sy_t}\bigg )^2}_{\text{impermanent loss}}\Bigg ), \end{aligned}$$
(97)

where \({s_t=\dfrac{x_t}{y_t}}\). Consistently, it holds

$$\begin{aligned} h(s)&={(s_t-s)y_t+\bigg (\sqrt{x_t}-\sqrt{sy_t}\bigg )^2}&h(s_t)&=0, \end{aligned}$$
(98)
$$\begin{aligned} \partial _sh(s)&=-\sqrt{\frac{x_ty_t}{s}}&\partial _sh(s_t)&=-y_t,\end{aligned}$$
(99)
$$\begin{aligned} \partial _{ss}h(s)&=\frac{1}{2}\sqrt{\frac{x_ty_t}{s^3}}. \end{aligned}$$
(100)

The Carr–Madan–formula corroborates that absolute hedges for CPMM are hardly feasible. Indeed,

$$\begin{aligned} \begin{aligned} h(s_T)=-y_t(s_T-s_t)&+\int _0^{s_t}\frac{1}{2}\frac{\sqrt{x_ty_t}}{k^{3/2}}\max \{k-s_T,0\}\,dk\\&+\int _{s_t}^{\infty }\frac{1}{2}\frac{\sqrt{x_ty_t}}{k^{3/2}}\max \{s_T-k,0\}\,dk. \end{aligned} \end{aligned}$$
(101)

By the put-call-parity, the short position of the flat delta hedge (consisting of \(y_t\) long at-the-money puts and \(y_t\) short at-the-money calls) comes at almost no cost. The continuum of European options has the same value as hedging the impermanent loss; see (41). Funding this significant value requires a lot of noise trading.

3.10 Break-even transaction cost

With automated market making as outlined in the Case 2, one encounters significant opportunity cost. Since we cannot accurately predict the fees earned out of noise trading, we need to come up with a different source of income that offsets the incurred impermanent loss. Whereas \(\kappa _1\) is determined externally (e.g., \(0.10\%\) of the trade volume plus gas), we can implement order size and pool size dependentFootnote 6\(\kappa _2(\Delta x)\) and \(\kappa _2(\Delta y)\) respectively; the higher the relative transaction volume, the higher the illiquidity fee to be borne. We need to distinguish the two cases of posting X and Y. We derive the minimal \(\kappa _2\) such that providing liquidity is at arm’s length with the vanilla portfolio. Hence, if one enforced these fair transaction costs, the impermanent loss would disappear with respect to any reference point repeatedly. We presume that no further spread on top is required in order to incentivize the desired liquidity. On the one hand, the transaction costs involved can become considerably large. On the other hand, one would have to bear comparatively prohibitive costs with market orders in a CLOB, if one trades through the entire order book. The approach also gets strong support from the agent-based considerations in Sabaté-Vidales and Šiška (2022).

Lemma 6

(Break-Even Transaction Cost) Let us consider a CPMM of Definition 3. If one establishes order size and pool size dependent transaction fees

$$\begin{aligned} \kappa _2(\Delta x)=\dfrac{(1-\kappa _1)^2}{\dfrac{x_t^\text{pre}}{\Delta x}+(1-\kappa _1)},\qquad \kappa _2(\Delta y)=\dfrac{(1-\kappa _1)^2}{\dfrac{y_t^\text{pre}}{\Delta y}+(1-\kappa _1)}, \end{aligned}$$
(102)

then the liquidity providers do not incur an impermanent loss. It obviously holds \({\displaystyle \lim _{\Delta x\rightarrow \infty }\kappa _2(\Delta x)=\displaystyle \lim _{\Delta y\rightarrow \infty }\kappa _2(\Delta y)=1-\kappa _1}\).

Proof

  1. 1.

    Posting \(\Delta x>0\) yields to

    $$\begin{aligned} {V_t^\text {post}(\Delta x)}&{\mathop {=}\limits ^{!}}{S_t^x\big (x_t^\text {pre}+S_t^\text {post}(\Delta x)^{-1}y_t^\text {pre}\big ),} \end{aligned}$$
    (103)

    where, because of (77) and (78) respectively,

    $$\begin{aligned} {V_t^\text{post}(\Delta x)}&={2S_t^x\big (x_t^\text{pre}+(1-\kappa _1)\Delta x\big ),} \end{aligned}$$
    (104)
    $$\begin{aligned} {S_t^\text{post}(\Delta x)^{-1}}&={\dfrac{\big (x_t^\text{pre}+(1-\kappa _1)\Delta x\big )\Big (x_t^\text{pre}+\big (1-\kappa _1-\kappa _2(\Delta x)\big )\Delta x\Big )}{x_t^\text{pre}y_t^\text{pre}}.} \end{aligned}$$
    (105)
    $$\begin{aligned} \Longleftrightarrow \qquad {\kappa _2(\Delta x)}&={\dfrac{(1-\kappa _1)^2\Delta x}{x_t^\text{pre}+(1-\kappa _1)\Delta x}=\dfrac{(1-\kappa _1)^2}{\dfrac{x_t^\text{pre}}{\Delta x}+(1-\kappa _1)}{\mathop {\longrightarrow }\limits ^{\Delta x\rightarrow \infty }}1-\kappa _1.} \end{aligned}$$
    (106)
  2. 2.

    Posting \(\Delta y>0\) yields to

    $$\begin{aligned} {V_t^\text{post}(\Delta y)}&{\mathop {=} \limits ^{!}}{S_t^x\left( x_t^\text{pre}+S_t^\text{post}(\Delta y)^{-1}y_t^\text{pre}\right) ,} \end{aligned}$$
    (107)

    where, because of (86) and (87) respectively,

    $$\begin{aligned} {V_t^\text{post}(\Delta y)}&={\dfrac{2S_t^xx_t^\text{pre}y_t^\text{pre}}{y_t^\text{pre}+\big (1-\kappa _1-\kappa _2(\Delta y)\big )\Delta y},} \end{aligned}$$
    (108)
    $$\begin{aligned} {S_t^\text{post}(\Delta y)^{-1}}&={\dfrac{x_t^\text{pre}y_t^\text{pre}}{\big (y_t^\text{pre}+(1-\kappa _1)\Delta y\big )\Big (y_t^\text{pre}+\big (1-\kappa _1-\kappa _2(\Delta y)\big )\Delta y\Big )}.} \end{aligned}$$
    (109)
    $$\begin{aligned} \Longleftrightarrow \qquad {\kappa _2(\Delta y)}&={\dfrac{(1-\kappa _1)^2\Delta y}{y_t^\text{pre}+(1-\kappa _1)\Delta y}=\dfrac{(1-\kappa _1)^2}{\dfrac{y_t^\text{pre}}{\Delta y}+(1-\kappa _1)}{\mathop {\longrightarrow }\limits ^{\Delta y\rightarrow \infty }}1-\kappa _1.} \end{aligned}$$
    (110)

This concludes the proof. \(\square\)

Lemma 7

Let the premises of Lemma 6 be given. For receiving a desired \(\Delta y\) of Y, where

$$0\stackrel{!}{<}\Delta y\stackrel{!}{<}\frac{y_t^\text{pre}}{2},$$
(111)

the required posting amounts to

$$\Delta x(\Delta y)=\frac{x_t^\text{pre}\Delta y}{(1-\kappa_1)(y_t^\text{pre}-2\Delta y)}\stackrel{\Delta y\to\frac{y_t^\text{pre}}{2}\mathrm{-}}{\longrightarrow}\infty. $$
(112)

Analogously, for receiving a desired \(\Delta x\) of X, where

$$0\stackrel{!}{<}\Delta x\stackrel{!}{<}\frac{x_t^\text{pre}}{2}, $$
(113)

the required posting entails

$$ \Delta y(\Delta x)=\frac{y_t^\text{pre}\Delta x}{(1-\kappa_1)(x_t^\text{pre}-2\Delta x)}\stackrel{\Delta x\to\frac{x_t^\text{pre}}{2}\mathrm{-}}{\longrightarrow}\infty. $$
(114)

Proof

By plugging \(\Delta x (\Delta y)\) from (112) and \(\kappa_2\big(\Delta x(\Delta y)\big)\) from (102) into (72), one easily verifies that

$$\dfrac{-y_t^\text{pre}\left(1-\kappa_1-\dfrac{(1-\kappa_1)^2}{\dfrac{x_t^\text{pre}}{\Delta x(\Delta y)}+(1-\kappa_1)}\right)\Delta x(\Delta y)}{x_t^\text{pre}+\left(1-\kappa_1-\dfrac{(1-\kappa_1)^2}{\dfrac{x_t^\text{pre}}{\Delta x(\Delta y)}+(1-\kappa_1)}\right)\Delta x(\Delta y)}=\Delta y $$
(115)

holds indeed. If (112) was not known, then one could solve (115) for \(\Delta x (\Delta y)\) and end up with a linear equation. Its solution is only economically meaningful within the specified boundaries of (111). Regarding (114), either one exploits the symmetry in the x- and y-directions, or one proceeds algebraically in the same way with the expressions (114), (102) and (81) respectively. Again, the algebraic solution makes only sense from the economic viewpoint up to half of the available amount \(x_t^\text{pre}\). \(\square\)

3.11 Optimal trade execution

Without further assumptions on the dynamics of the ecosystem, the question of optimal trade execution cannot be answered conclusively. Optimality highly depends on the behavior of the other market participants. Nonetheless, it is a relevant question whether it may be advisable to split a large transaction into n equally sized small trades, ceteris paribus. For a classical CPMM with flat transaction fees \(\kappa =\kappa _1+\kappa _2\), executing one large swap is better than its counterpart, although the impact is typically negligible. Exemplarily (with an abuse of notation), when posting \(\Delta x>0\) twice, the liquidity pool still ends up with

$$\begin{aligned}&\big (x_t^\text{post}(\Delta x)\big )(\Delta x)=x_t^\text{pre}+2(1-\kappa _1)\Delta x=x_t^\text{post}(2\Delta x), \end{aligned}$$
(116)

whereas

$$\begin{aligned}&\begin{aligned} \big (y_t^\text{post}(\Delta x)\big )(\Delta x)&=\frac{\big (x_t^\text{pre}+(1-\kappa _1)\Delta x\big )\dfrac{x_t^\text{pre}y_t^\text{pre}}{x_t^\text{pre}+(1-\kappa )\Delta x}}{\big (x_t^\text{pre}+(1-\kappa _1)\Delta x\big )+(1-\kappa )\Delta x}\\&=\frac{x_t^\text{pre}+(1-\kappa _1)\Delta x}{x_t^\text{pre}+(1-\kappa )\Delta x}\cdot \frac{x_t^\text{pre}y_t^\text{pre}}{\kappa _2\Delta x+x_t^\text{pre}+(1-\kappa )2\Delta x}\\&>\underbrace{\frac{x_t^\text{pre}+(1-\kappa _1)\Delta x}{x_t^\text{pre}+(1-\kappa )\Delta x+\kappa _2\Delta x}}_{=1}\cdot \frac{x_t^\text{pre}y_t^\text{pre}}{x_t^\text{pre}+(1-\kappa )2\Delta x}\\&=y_t^\text{post}(2\Delta x); \end{aligned} \end{aligned}$$
(117)

the strict inequality holds, because

$$\begin{aligned}&\big(x_t^\text{pre}+(1-\kappa)\Delta x+\kappa_2\Delta x\big)\big(x_t^{\text{pre}}+(1-\kappa)2\Delta x\big)\\-&\big(x_t^{\text{pre}}+(1-\kappa)\Delta x\big)\big(\kappa_2\Delta x+x_t^{\text{pre}}+(1-\kappa)2\Delta x\big)\\=&\kappa_2(1-\kappa)(\Delta x)^2.\end{aligned}$$
(118)

Consequently, one earns more tokens of Y by contributing \(2\Delta x\) once. Furthermore, for a classical CPMM without transaction cost, the same argument demonstrates that executing one large swap is identical to initiating n small swaps. For break-even transaction cost as in the Sect. 3.10, splitting trades into smaller portions may be worthwhile as the relatively applied \(\kappa _2\) grows with the order size. In this case, a trade-off must be solved between saved transaction fees and additionally required gas fees (which are not order-size-dependent, but due for each transaction). An in-depth analysis in this context can be found in Cartea et al. (2022a).

3.12 Estimating the impact of noise trades through roundtrips

First, we consider for \(\kappa _2\equiv c\) the change in the value of the liquidity pool due to successive posting of \(\Delta x\) and

$$\begin{aligned} \Delta y=\frac{(1-\kappa _1)y_t^\text{pre}\Delta x}{(1-\kappa )\big (x_t^\text{pre}+(1-\kappa )\Delta x\big )}, \end{aligned}$$
(119)

ceteris paribus. With an abuse of notation, the liquidity pool will then consist of \(\big (x_t^\text{post}(\Delta x)\big )(\Delta y)=x_t^\text{pre}\) tokens of X and

$$\begin{aligned} \left( y_t^\text{post}(\Delta x)\right) (\Delta y)=\frac{x_t^\text{pre}y_t^\text{pre}}{x_t^\text{pre}+(1-\kappa )\Delta x}+\frac{(1-\kappa _1)^2y_t^\text{pre}\Delta x}{(1-\kappa )\left( x_t^\text{pre}+(1-\kappa )\Delta x\right) } \end{aligned}$$
(120)

tokens of Y. In the Case 1 of a marketplace, the liquidity pool hosts a windfall profit. In the Case 2 of the market, the liquidity pool consists of the same amount of X tokens and more Y tokens compared to the starting point. Thus, the value of Y has slightly depreciated with respect to the numéraire. Second, we consider by symmetry the change in the value of the liquidity pool due to successive posting of \(\Delta y\) and the analog to (119) in \(\Delta x\). In the Case 1 of the marketplace, the liquidity pool hosts a windfall profit again. In the Case 2 of the market, the liquidity pool consists of more X tokens and the same amount of Y tokens compared to the starting point. Thus, the value of Y has slightly appreciated with respect to the numéraire. If \(\kappa _2\) is order size-dependent as in the section 3.10 (without additional spread), then the analog to (119) is

$$\begin{aligned} \Delta y&=\frac{(1-\kappa _1)y_t^\text{pre}\Delta x}{\big (1-\kappa _1-\kappa _2(\Delta y)\big )\Big (x_t^\text{pre}+\big (1-\kappa _1-\kappa _2(\Delta x)\big )\Delta x\Big )} \end{aligned}$$
(121)
$$\begin{aligned}&=\frac{\big (x_t^\text{pre}+(1-\kappa _1)\Delta x\big )y_t^\text{pre}\Delta x}{(x_t^\text{pre})^2+(1-\kappa _1)x_t^\text{pre}\Delta x-2(1-\kappa _1)^2(\Delta x)^2}. \end{aligned}$$
(122)

The first implicit expression may include an additional spread. The second quantity is only meaningful for sufficiently small \(\Delta x\) up until the singularity that occurs at the root of the numerator; the domain is \({\mathbb {D}}=\big \{\Delta x\ge 0\,\big |\,(1-\kappa _1)\Delta x< x_t^\text{pre}\big \}\). Beyond this root, a return to the starting point in X is no longer possible by means of one swap; see also Lemma 7. It is also worth parametrizing roundtrips in terms of returning to the initial FX-rate \(S_t^\text{pre}\); see the Jupyter notebook for a numeric implementation.