1 Introduction

Constant Function Market Makers (CFMMs) (Angeris & Chitra, 2020) are a family of automated market makers that enable censorship-resistant asset exchange on public blockchains. CFMMs are capitalized by liquidity providers (LPs) who supply reserves to an on-chain smart contract. The CFMM uses these reserves to execute swaps for traders, allowing a swap only if it preserves some function of reserves, known as the trading function or invariant. This, in turn, implies that the total value of LPs’ position changes as the market buys (or sells) assets from the CFMM. For example, Uniswap (Zhang et al., 2018) only allows trades that keep the product of the reserves after the trade equal to the product of the reserves before the trade.

A key question first explored in Angeris et al. (2021) concerns the returns that LPs receive for their capital; the total value of this position is known as the liquidity provider payoff. As shown in Angeris and Chitra (2020), the liquidity provider payoff in a CFMM can be determined by solving a convex problem over the CFMM’s trading set. This method allows one to compute explicit expressions for the value LPs receive from most popular CFMMs, such as Uniswap and Balancer, as well practical lower bounds for a larger class for trading functions. Additional work, such as Angeris et al. (2022) and Evans et al. (2021), has explored the impact of parameters, such as trading-function curvature and swap fees on LP returns.

Here, we consider what may be called the ‘inverse’ problem. Rather than deriving the LP’s payoff for a given trading function, we seek to find the trading function that guarantees that LPs receive a certain payoff. By contributing capital to the CFMM, LPs will statically replicate their desired payoff. This is a generalization of the problem considered in Evans (2020, section 5) that shows how to replicate continuously differentiable payoffs using constant-mean trading functions with dynamically adjusted weights. These constructions require continual updates from on-chain oracles that may be expensive, complex to manage, and are often vulnerable to front-running attacks. In contrast, the trading functions we derive in this work are not time-varying and do not depend on external price oracles, so they are likely easier to implement in practice.

Hedging One obvious question is: why would one want to implement such desired payoffs? Trading on blockchains has a number of idiosyncrasies that make dynamic hedging strategies expensive to execute. In particular, unlike centralized venues, most blockchains prevent spam and denial of service attacks by charging users a fee per transaction. This fee, known as gas on networks like Ethereum, can be a dominant cost to on-chain traders during times of high market volatility (Daian, 2019; Kao et al., 2020). Moreover, the volatility of gas costs on Ethereum makes on-chain dynamic hedging strategies more complex to manage successfully.

In contrast, CFMMs allow the LP to achieve a desired payoff by passively contributing capital. Rather than requiring LPs to continually rebalance their holdings through on-chain trades, CFMMs incentivize arbitrageurs to adjust reserves to the level required to achieve their desired hedge. In effect, this approach outsources the cost and complexity of on-chain trading to specialized parties. As discussed in Appendix, the added simplicity for the hedger is not without trade-offs as LPs are subject to arbitrage losses. However, small fees have been shown to mitigate these costs in certain settings (Evans et al., 2021).

Limitations The payoffs one can replicate using the methodology presented in this paper are limited to concave, nonnegative, nondecreasing functions of price. An instructive analogy is as follows. In limit order books, a resting limit order can roughly be thought of as an option which the market maker sells to participants—who are executing market (liquidity removing) orders—that allows them to purchase or sell a quantity of an asset at a given price (Gregoriou, 2016, Chapter 6). [The precise replication of a market maker’s portfolio of limit orders as a covered options is complicated somewhat by the fact that trades depend on the positions in the queue (Foucault et al., 2007; Moallemi & Yuan, 2014), but this point is not essential here.] Being short, an option generates a concave, or ‘negative gamma,’ payoff. By virtue of allowing users to execute a set of trades at predetermined prices, CFMMs can also be seen as having negative gamma payoffs which lead to ‘impermanent loss’ (Angeris & Chitra, 2020; Angeris et al., 2020; Clark, 2020) for LPs. On the other hand, replicating convex payoffs (such as long positions in options) requires the ability to short shares in a CFMM, or to use external price oracles, as described in Evans et al. (2020).

Summary The outline of this article is as follows. In the next section, we describe the problem of constructing a trading function that produces a CFMM with a desired payoff function. In Sect. 2, we present some basic definitions along with a solution method for recovering the desired trading set and corresponding (equivalent) trading functions. We derive trading functions for some basic examples such as linear and quadratic payoffs in Sect. 3. In Sect. 4, we proceed with practical applications, such as recovering the constant-mean function used in Balancer (Martinelli & Mushegian, 2019) as well as constructing trading functions for replicating the Black–Scholes prices of covered European calls and perpetual American puts. We give some possible future directions in Sect. 5. We also note that some of the results of this paper, posted originally as a preprint, have been implemented as a new decentralized finance protocol (Sterrett et al., 2021).

2 General solution

In this section, we will present a general method for constructing a CFMM trading function whose value function matches a desired payoff function, within a reasonable domain. We start with some basic definitions and provide a relatively general solution method. We continue with some basic (and not so basic) applications of the method.

Trading function A (path-independent) CFMM is defined by its trading function \(\psi : {{\textbf {R}}}^n \rightarrow {{\textbf {R}}}\) and its reserves \(R \in {{\textbf {R}}}^n_+\). The reserve \(R_i\) specifies the quantity of coin i available to the CFMM contract, while the function \(\psi \) specifies the behavior of the contract. More specifically, the contract will allow any agent to trade with the reserves, so long as the new reserves, \(R' \in {{\textbf {R}}}_+^n\), after the agent has added or withdrawn the required quantities, satisfy

$$\begin{aligned} \psi (R') \ge \psi (R). \end{aligned}$$

Some definitions require that the inequality be an exact equality, but this point is not essential, since, in practice, \(\psi \) can always be made an increasing function in its arguments, so any rational agent will ensure that the inequality is saturated; see, e.g., Angeris (2020, section 2.1) for more. We note that all trading functions used in practice are concave or have an equivalent concave trading function.

Portfolio value function We will assume that there exists some external market with a fixed reference price \(c \in {{\textbf {R}}}_+^n\). Here, c is the price vector for the n coins the CFMM trades, such that \(c_i\) is the price of coin i, in some numéraire (e.g., USD) in this external market. We will call the total value of reserves, after arbitrage, the portfolio value or liquidity provider payoff of a CFMM, represented by some function \(V: {{\textbf {R}}}_+^n\rightarrow {{\textbf {R}}}\). In the case where the CFMM is path-independent, with concave nonincreasing trading function \(\psi : {{\textbf {R}}}^n \rightarrow {{\textbf {R}}}\) and constant k (Angeris, 2020, section 2.5) shows that the function V is equal to

$$\begin{aligned} V(c) = \inf \{c^{\textrm{T}}R \mid \psi (R) \ge k, \, R \in {{\textbf {R}}}_+^n\}, \end{aligned}$$

where k is a constant. The economic interpretation of this definition of V is simple: an arbitrageur is engaged in a zero-sum game with liquidity providers. The arbitrageur’s payoff is maximized when the portfolio value, \(c^{\textrm{T}}R\), of a liquidity provider is minimized over the valid reserves R; i.e., those that satisfy \(\psi (R) \ge k\). [This is a simple restatement of the optimal arbitrage problem. For more, see, e.g., Angeris and Chitra (2020) and Evans et al. (2021).]

Very generally, we will define the portfolio value over a feasible set of reserves \(S\subseteq {{\textbf {R}}}^n\) as

$$\begin{aligned} V(c) = \inf \{c^{\textrm{T}}R \mid R \in S\}. \end{aligned}$$
(1)

This includes the previous definition by setting \(S = \{R \in {{\textbf {R}}}^n_+ \mid \psi (R) \ge k\}\), and this ‘more general’ definition will slightly simplify the derivation presented below. (In fact, both definitions are equivalent in that, given a convex set S, we can construct a concave function \(\psi \) whose 0-superlevel set is equal to S. We give an explicit construction later in this section.)

As a side note, this definition assumes that the entire pool’s liquidity is owned by one liquidity provider. In reality, a liquidity provider owns some pro-rata share of the total payoff, where the proportion of a given LP’s ownership depends on the value they contributed to the whole pool when initially providing liquidity. We note that this is the same as the LP owning the entire payoff for a specific pool containing only their provided liquidity, when the portfolio value depends only on the external market price, as above. See, e.g., Angeris (2022, section 2.6) for more on the mechanics of liquidity provision.

Desired payoff One very natural question is: given a desired payoff function (i.e., a desired V), is it possible to create a trading function \(\psi \) which results in this payoff? Another slightly more casual way of phrasing this problem is: can we ‘invert’ formula (1), given V?

In general, the answer is no. It is nearly immediate, given any \(\psi \), the function V is always a concave function, because it is the infimum of a family of linear functions, indexed by \(R \in S\). (Even when \(\psi \) or the set S are not convex.) Second, because V(c) is some infimum over \(c^{\textrm{T}}R\) with both c and R nonnegative, it must be nonnegative. Third, given any \(c' \ge c \ge 0\), we have that

$$\begin{aligned} V(c') = V(c + c' - c) \ge V(c)+ V(c' - c) \ge V(c), \end{aligned}$$

so V is nondecreasing in its arguments. And, finally, note that the function V is 1-homogeneous in terms of c, by definition; i.e., for any \(\eta \ge 0\), the payoff function V satisfies

$$\begin{aligned} V(\eta c) = \eta V(c). \end{aligned}$$

This limits the set of payoff functions we can find a CFMM trading function for, since V must be concave, nonnegative, nondecreasing, and 1-homogeneous in order for there to exist a CFMM trading function with V as its liquidity provider payoff. (We will see that 1-homogeneity is not as strong of a condition as it appears at first glance, and we show how to deal with this in Sect. 3.)

Consistent payoff functions We will then say V is a consistent payoff function if it is concave, nonnegative, nondecreasing, and 1-homogeneous. Clearly, then, the value function of any CFMM will always be consistent, from the discussion above. In the next section, we will also see that the converse of the above statement is true: any consistent payoff function has a path-independent CFMM that yields this payoff. We will also show how to construct a CFMM with a desired consistent payoff.

Discussion The conditions above all have nice economic interpretations. The concavity of the function implies that ‘impermanent loss’ (Angeris & Chitra, 2020), related to the notion of ‘negative gamma’ in finance, is an intrinsic property of liquidity provision in path-independent CFMMs, as it is present for any possible CFMM in practice. The nonnegativity simply implies that a liquidity provider position always has nonnegative value, while the fact that V is nondecreasing implies that the position of liquidity providers does not get worse as coins increase in value. Finally, the 1-homogeneity is a notion of ‘scale-invariance,’ i.e., scaling the numéraire should simply scale the total portfolio value of a liquidity provider’s position. While we have shown that these conditions are necessary, we will also show that they are sufficient in the remainder of this section.

2.1 Solution method and equivalence

The method presented here can be seen as a special case of Fenchel conjugacy, with some slight modifications. Though not necessary, since we will introduce the tools required in this note and give self-contained proofs, the results here are essentially corollaries of well-known theorems in convex analysis, with the most notable being strong duality. We refer the reader to, e.g., Boyd (2004, section 5) for further reading.

Given a consistent payoff function V, we will first find a set of reserves S corresponding to the payoff function V. We will then show that the set S will also have V as its payoff function, as defined in (1). We then find an explicit trading function, \(\psi _V\), whose 0-superlevel set is equal to S and therefore has the desired payoff function, V.

Feasible reserve set Given some concave payoff function \(V: {{\textbf {R}}}^n_+ \rightarrow {{\textbf {R}}}\), we will define its feasible reserve set \(S \subseteq {{\textbf {R}}}^n_+\) as

$$\begin{aligned} S = \{R \in {{\textbf {R}}}^n_+ \mid V(q) \le q^{\textrm{T}}R,\ \text{for all}\ q \in {{\textbf {R}}}^n\}. \end{aligned}$$
(2)

In other words, S is the set of reserves for which the portfolio value of the reserves, at any cost vector q, is always no smaller than V(q). Note that the set S is convex as it is the intersection of a family of hyperplanes parametrized by q.

2.1.1 Equivalence

We will show that, if V is a nonnegative, concave, 1-homogeneous payoff function with feasible reserve set S, then S has payoff, as defined in (1), given by V.

Using the definition of S in (2), we can rewrite problem (1) in extended form

$$\begin{aligned}{} & {} \text{minimize}\quad c^{\textrm{T}}R \\{} & {} \text{subject to}\quad V(q) \le q^{\textrm{T}}R, \quad \text{for all}\ q \in {{\textbf {R}}}^n, \end{aligned}$$
(3)

with variable \(R \in {{\textbf {R}}}^n\). We will write the optimal value of (3) for fixed c as \(V^\star (c)\). We now need to show that \(V^\star (c)\), i.e., the portfolio value given by S after arbitrage, when the coin price is equal to c, is equal to the desired portfolio value at c, namely V(c).

Lower bound Clearly, we know that

$$\begin{aligned} V^\star (c) \ge V(c), \end{aligned}$$

since, if \(R^\star \) is optimal for c, then

$$\begin{aligned} V^\star (c) = c^{\textrm{T}}R^\star \ge V(c), \end{aligned}$$

where the inequality follows from the fact that \(R^\star \) is a feasible point for problem (3).

Upper bound It will suffice to show that there exist some reserves \(R \in S\), such that \(c^{\textrm{T}}R = V(c)\); i.e., R is feasible for problem (3) with objective value equal to V(c). Because R is feasible for (3), then, by definition of optimality, we will have that \(c^{\textrm{T}}R \ge V^\star (c)\), as required.

First, pick any \(R \in \partial V(c)\); i.e., R is a supergradient of V at c, such that, for any \(q \in {{\textbf {R}}}^n\), we have

$$\begin{aligned} V(q) \le V(c) + R^{\textrm{T}}(q - c). \end{aligned}$$
(4)

Such an R exists, because V is a concave function and is nonnegative, because V is nondecreasing. [As a side note, R is equal to \(\nabla V(c)\) when the function V is differentiable at c. See, e.g., Rockafellar (1970, Thm. 25.1).] Now, let \(q = 0\) in (4) to get

$$\begin{aligned} c^{\textrm{T}}R \le V(c), \end{aligned}$$

where \(V(0) = 0\) by the homogeneity of V. On the other hand, let \(q = 2c\) in (4) to get

$$\begin{aligned} V(2 c) \le V(c) + c^{\textrm{T}}R. \end{aligned}$$

Since \(V(2c) = 2V(c)\), because V is 1-homogeneous, we have

$$\begin{aligned} V(c) \le c^{\textrm{T}}R, \end{aligned}$$

so \(V(c) = c^{\textrm{T}}R\). We can now rearrange (4) to get

$$\begin{aligned} V(q) - q^{\textrm{T}}R \le V(c) - c^{\textrm{T}}R = 0, \end{aligned}$$

for any q, which means that \(R \in S\) by the definition of S in (2). From before, this means that R is feasible for (3) and, because its objective value is \(c^{\textrm{T}}R = V(c)\), we must have that \(V(c) \ge V^\star (c)\).

Result Putting both statements together yields that \(V(c) = V^\star (c)\) for every c, and therefore, the set S has the desired payoff. In fact, the proof given above has a few simple but important consequences. For example, dropping the monotonicity requirement on V implies that there might exist reserves in S which are negative. One way to deal with such a problem is to take the intersection of S with the nonnegative reals, \(S \cap {{\textbf {R}}}_+^n\), but then V need not equal \(V^\star \) as defined above, and the proof above also gives a simple way of quantifying the gap. Similar results and extensions also hold for the nonnegativity requirement for V, the concavity of V, and so on, which we leave as open questions for future research.

2.1.2 Constructing a trading function

From the previous discussion, given a desired payoff function V, we can easily find a trading set S, such that S has payoff equal to V. While this may suffice for some applications, it is often easier to work with the functional form of a CFMM. More specifically, we will look for a concave trading function \(\psi _S\), such that some superlevel set of the function is equal to the set S.

One example of such a functional form (there are many equivalent ones) is given by

$$\begin{aligned} \psi _V(R) = \inf _c (c^{\textrm{T}}R - V(c)), \end{aligned}$$
(5)

where \(c \in {{\textbf {R}}}^n\) ranges over all real n-vectors. This function has the desired property, since

$$\begin{aligned} \psi _V(R) \ge 0, \ \text{if, and only if},\ c^{\textrm{T}}R \ge V(c)\ \text{for all}\ c \in {{\textbf {R}}}^n, \end{aligned}$$

and therefore, \(\psi _V(R) \ge 0\) if, and only if, \(R \in S\), so \(\psi _V\) can be used as the CFMM trading function, as required. We also note that \(\psi _V\) is the negative Fenchel conjugate of \(-V\), with negated arguments, that is

$$\begin{aligned} \psi _V(R) = -\sup _c (-c^{\textrm{T}}R - (-V)(c)) = -(-V)^*(-R). \end{aligned}$$

This equation, along with the portfolio value equation in Angeris (2020, section 2.5) implies, roughly speaking, that the portfolio value function and the trading function for a CFMM are essentially Fenchel conjugates of each other.

Discussion In general, unless certain conditions are satisfied, it is possible that applying Eq. (5) directly to any desired payoff function V need not yield a CFMM whose payoff function is equal to V at all prices. We only guarantee equality in the case that V is consistent, but find that this procedure is also useful in cases where V is not. (As discussed, the proof given in Sect. 2.1.1 gives a way of quantifying how much the payoff might differ in cases where V is not consistent.) Additionally, we note that the function (5) will always be a set-indicator function; i.e., \(\psi _V\) will always be either 0 or \(+\infty \) at every point, due to the 1-homogeneity of V. In some cases, the set-indicator description can be simplified, but this need not always be true.

3 Basic examples and properties

We show two basic examples, where the desired payoff is linear and, later, quadratic, and introduce some basic tools which help simplify derivations.

3.1 Linear payoffs and offsets

In this case, we will find a CFMM that produces a linear payoff function; i.e., what is a CFMM that corresponds to the payoff function

$$\begin{aligned} V(c) = a^{\textrm{T}}c, \end{aligned}$$

where \(c \in {{\textbf {R}}}_+^{n}\), \(a \in {{\textbf {R}}}_+^{n}\). It is not difficult to intuit what the behavior of the LP (and therefore, of the CFMM’s trading function) should be. To replicate this payoff, the LP should simply hold \(a_i\) of asset i, which would be equivalent to the CFMM disallowing any trades other than the null trade. We will apply the method to this example, where the solution is known, as a simple, but potentially useful exercise.

Linear payoff As before, we have that

$$\begin{aligned} \psi _V(R) = \inf _c(c^{\textrm{T}}R - a^{\textrm{T}}c) = \inf _c ((R - a)^{\textrm{T}}c) = \left\{ \begin{array}{ll} 0 &{}\quad R = a\\ -\infty &{}\quad \text{otherwise}, \end{array}\right. \end{aligned}$$

which is exactly the CFMM we expect from the intuitive result: the CFMM can only allow trading if a trade leaves the reserves at a.

Linear offsets A useful and general tool used in the previous derivation is that a linear offset of the payoff function V results in a linear offset of the arguments of the trading function. More specifically, given a payoff function V, with trading function \(\psi _V\), the trading function corresponding to the ‘linearly offset’ payoff

$$\begin{aligned} V'(c) = V(c) + a^{\textrm{T}}c \end{aligned}$$
(6)

where \(a \in {{\textbf {R}}}_+^n\), is

$$\begin{aligned} \psi _{V'}(R) = \psi _V(R - a). \end{aligned}$$

This follows immediately from (5) and has an obvious economic interpretation: any linear offset in the value function is simply equivalent to adding that quantity of coins to the reserves. This may help in simplifying derivations, since a number of payoffs are simply linear offsets of other, potentially well-known payoff functions.

3.2 Perspective transform and quadratic payoffs

It is also sometimes easier in practice to specify the payoff with respect to a numéraire, rather than with respect to a general price vector. For example, if we assume that the nth coin is the numéraire, and \(c'\) is the price vector for the first \(n-1\) coins with respect to the nth coin, then this is equivalent to specifying the ‘reduced payoff function’ \(U(c')\) for each \(c' \in {{\textbf {R}}}^{n-1}\), which depends only on the first \(n-1\) coins.

Perspective transform A simple approach to constructing an n coin, 1-homogeneous payoff function that is concave, nonnegative whenever U is also concave, nonnegative is by the use of the perspective transform of U, which we define here as the function \(V: {{\textbf {R}}}^n \rightarrow {{\textbf {R}}}\), such that

$$\begin{aligned} V(c', c_n) = \left\{ \begin{array}{ll} c_n U(c'/c_n) &{}\quad c_n > 0\\ -\infty &{}\quad \text{otherwise}, \end{array}\right. \end{aligned}$$
(7)

where \(c' \in {{\textbf {R}}}^{n-1}_+\) is the price of the first \(n-1\) coins while \(c_n \in {{\textbf {R}}}_+\) is the price of the numéraire. The concavity of V, given the concavity of U, follows from a basic argument (see, e.g., Boyd, 2004, section 3.2.6), while positivity is immediate from the definition. The fact that V is 1-homogeneous is easy to see as well, since, if \(c_n > 0\) and \(\eta > 0\), we have

$$\begin{aligned} V(\eta c', \eta c_n) = (\eta c_n) U(\eta c' / \eta c_n) = \eta (c_n U(c'/c_n)) = \eta V(c', c_n), \end{aligned}$$

while the case where \(c_n = 0\) is obvious. Additionally, it is worth noting that

$$\begin{aligned} V(c', 1) = U(c'), \end{aligned}$$

so this recovers the original payoff when the numéraire’s value, \(c_n\), is set to 1, as expected.

Quadratic payoff Given the affine case, the next natural question is, can we find the CFMMs corresponding to more complicated payoff functions? For this case, we will consider a CFMM whose payoff is a concave quadratic. To our knowledge, a CFMM of this form is not known in the literature, but the procedure above gives a simple derivation. In particular, we want a CFMM that yields a payoff of

$$\begin{aligned} U(c') = -\frac{1}{2} (c') ^{\textrm{T}}A c' + b^{\textrm{T}}c' + d, \end{aligned}$$

where A is a strictly positive definite matrix (the case of positive semidefinite matrices is also easy to identify, but requires some additional conditions on b and the nullspace of A, which we leave as a simple extension). Note that this is not positive everywhere, so the payoff of this CFMM cannot match that of \(V'\) everywhere. On the other hand, we will see that both are equal within some specific set of cost vectors \(c'\).

To start, we will first consider the perspective transformation (7) of \(V'\) to get

$$\begin{aligned} V(c', c_n) = \frac{1}{2c_n}(c')^{\textrm{T}}Ac' + b^{\textrm{T}}c' + dc_n. \end{aligned}$$

Using (6), it suffices to consider the simpler function

$$\begin{aligned} V(c', c_n) = -\frac{1}{2c_n} (c')^{\textrm{T}}A c', \end{aligned}$$

as the rest is simply a linear offset of this function, which follows from the previous discussion. From (5), we have

$$\begin{aligned} \psi _V(R', R_n) = \inf _{c_n > 0, c'} ((R')^{\textrm{T}}c' + R_nc_n - V(c', c_n)), \end{aligned}$$

where \(R' \in {{\textbf {R}}}^{n-1}_+\) are the reserves of the first \(n-1\) coins, while \(R_n \in {{\textbf {R}}}_+\) is the reserve of the numéraire. To find \(\psi _V\), we will first partially minimize over \(c'\), using the first-order optimality conditions, to get

$$\begin{aligned} \psi _V(R', R_n) = \inf _{c_n > 0} \left( R_nc_n - \frac{c_n}{2} (R')^{\textrm{T}}A^{-1}R'\right) , \end{aligned}$$

so

$$\begin{aligned} \psi _V(R', R_n) = \left\{ \begin{array}{ll} 0 &{} \quad \frac{1}{2} (R')^{\textrm{T}}A^{-1}R' \le R_n\\ -\infty &{}\quad \text{otherwise}. \end{array}\right. \end{aligned}$$

Finally, adding the linear offset \(V(c', c_n) \rightarrow V(c', c_n) + a^{\textrm{T}}c' + bc_n\), using (6) gives

$$\begin{aligned} \psi _V(R', R_n) = \left\{ \begin{array}{ll} 0 &{}\quad \frac{1}{2} (R'-a)^{\textrm{T}}A^{-1}(R'-a) \le R_n - b\\ -\infty &{}\quad \text{otherwise}, \end{array}\right. \end{aligned}$$

as required. Note that, because \(U(c')\) is negative and decreasing for large enough \(c'\), the payoff may not be correctly replicated at all possible price vectors \(c'\). In fact, it is not hard to show that once \(c'\) is outside of some compact set, the resulting payoff is always 0, and we leave this as a simple, but interesting, exercise for the reader.

4 Practical applications

In this section, we outline several practical applications of this general solution method in the more specific case where we have two coins, a traded coin and the numéraire. The first example gives a simple way of reconstructing the well-known constant-mean market makers, such as those created and implemented by Balancer, by attempting to replicate an intuitive payoff function.

We then proceed with a realistic financial product, the covered call. We present both static replication of the asset payoff at expiry and of the option price using the Black–Scholes model. In Evans et al. (2020), it was shown that the covered call can be statically replicated by a constant-mean market maker with dynamic weights. The replication methodology used here does not require one to update the trading function using an external price oracle. We expect that this will reduce the cost and complexity of implementing these CFMMs in practice. Finally, we present the example of a perpetual American put option. In this subsection, unlike in the previous subsections, we have that \(c_1 \in {{\textbf {R}}}_+\), \(R_1 \in {{\textbf {R}}}_+\), and \(R_2 \in {{\textbf {R}}}_+\) are all scalar quantities, where \(c_1\) is the price of the asset in question.

4.1 Balancer

We can recover some known payoff functions in a few important cases. For example, we can ask: what is a CFMM trading function whose payoff is a (concave) power of the price? In other words, can we find a CFMM whose payoff is

$$\begin{aligned} U(c_1) = c_1^w, \end{aligned}$$

for some \(0< w < 1\)? As is known in the literature (see, e.g., Angeris & Chitra, 2020; Evans et al., 2020; Martinelli & Mushegian, 2019), we will see that the trading function for Balancer, or that of a constant-mean market, is one such trading function (and, in fact, will be the trading function we recover).

Taking the perspective of U as in (7), where \(c_2\) is the new variable (the ‘price of the numéraire’), we have

$$\begin{aligned} V(c_1, c_2) = c_1^wc_2^{1-w}. \end{aligned}$$

(Note that V is then the weighted geometric mean of \(c_1\) and \(c_2\) with weights \((w, 1-w)\).) Therefore, we can recover the trading function using (5)

$$\begin{aligned} \psi _V(R_1,R_2) = \inf _{c} (c_1R_1 + c_2R_2 - V(c_1, c_2)). \end{aligned}$$

This implies that

$$\begin{aligned} \psi _V(R_1, R_2) = \left\{ \begin{array}{ll} 0 &{}\quad \left( \frac{R_1}{w}\right) ^{w}\left( \frac{R_2}{1-w}\right) ^{1-w} \ge 1\\ -\infty &{}\quad \text{otherwise}. \end{array}\right. \end{aligned}$$
(8)

It is also easy to show that

$$\begin{aligned} \psi (R_1, R_2) = \left( \frac{R_1}{w}\right) ^{w}\left( \frac{R_2}{1-w}\right) ^{1-w} \end{aligned}$$

is equivalent to \(\psi _V\), when the reserves R lie on the boundary of reserves R for which (8) is satisfied. [This is always true for rational trades, since the trader would otherwise have received less, or paid more than they should, and is certainly true for any solution to (1), since, by definition of optimality, no solution can be dominated by another; cf., Angeris and Chitra (2020) for further discussion.] We can of course simplify this further by dropping the constant multiplier \(w^{-w}(1-w)^{-(1-w)}\), which yields the usual form for constant mean markets, that is

$$\begin{aligned} \psi (R_1, R_2) = R_1^{w}R_2^{1-w}. \end{aligned}$$

To show (8), we consider three separate cases. First, \(R_1, R_2 \ge 0\), otherwise \(\psi _V\) is unbounded from below. On the other hand, if

$$\begin{aligned} \left( \frac{R_1}{w}\right) ^{w}\left( \frac{R_2}{1-w}\right) ^{1-w} < 1, \end{aligned}$$

then picking \(c_1 = tw/R_1\) and \(c_2 = t(1-w)/R_2\) for \(t \in {{\textbf {R}}}\) with \(t \ge 0\) means that

$$\begin{aligned} \psi _V(R_1, R_2) \le c_1R_1 + c_2R_2 - V(c_1, c_2) = t \underbrace{\left( 1 - \left( \frac{R_1}{w}\right) ^{-w}\left( \frac{R_2}{1-w}\right) ^{-(1-w)}\right) }_{< 0} \rightarrow -\infty , \end{aligned}$$

as \(t \rightarrow \infty \). Finally, if

$$\begin{aligned} \left( \frac{R_1}{w}\right) ^{w}\left( \frac{R_2}{1-w}\right) ^{1-w} \ge 1, \end{aligned}$$

then, using the weighted AM-GM inequality, we find for any \(c_1, c_2 > 0\)

$$\begin{aligned} c_1R_1 + c_2R_2 = wc_1\frac{R_1}{w}+ (1-w)c_2\frac{R_2}{1-w} \ge \left( c_1\frac{R_1}{w}\right) ^w\left( c_2\frac{R_2}{1-w}\right) ^{1-w} \ge c_1^{w}c_2^{1-w}, \end{aligned}$$

which means that \(\psi _V(R_1, R_2) \ge 0\). Clearly, equality is achievable by choosing \(c_1, c_2 \downarrow 0\), yielding (8).

This proof easily generalizes to the case where \(c \in {{\textbf {R}}}_+^n\) and

$$\begin{aligned} V(c) = \prod _{i=1}^n c_i^{w_i}, \end{aligned}$$

where \({\textbf{1}}^{\textrm{T}}w = 1\) and \(w_i > 0\) for \(i=1, \dots , n\), with equivalent trading function, for \(R \in {{\textbf {R}}}_+^n\),

$$\begin{aligned} \psi (R) = \prod _{i=1}^n \left( \frac{R_i}{w_i}\right) ^{w_i}. \end{aligned}$$

(This is just the n coin constant-mean market maker, e.g., Balancer, as is used in practice.)

4.2 Covered call at expiry

In the following examples, we assume that we have a ‘risky’ asset with reserve amount \(R_1\) and a ‘risk-free’ asset with reserve amount \(R_2\). We seek to find the trading function that corresponds to certain derivative securities. We will restrict our attention to ‘covered’ instruments whose replication does not require short positions in either asset (negative reserve quantities). We note that lending markets and offsetting positions have been proposed as solutions for replicating these types of instruments (Evans et al., 2020), but we do not explore this further in this work.

In this first application, we consider the terminal payoff of a covered call. This strategy involves combining a long position in the risky asset with a short position in a call option on the risky asset. A covered call allows the writer to generate additional income from a long position in exchange for giving up upside for prices above the strike. At expiry, the payoff of a covered call with strike K at expiry is

$$\begin{aligned} U(c) = c_1 - \max (c_1-K,0). \end{aligned}$$

We take the perspective transform to get

$$\begin{aligned} V(c_1,c_2) = \left\{ \begin{array}{ll} c_1 &{}\quad c_1 < c_2K \\ c_2K &{}\quad c_1 \ge c_2K. \end{array}\right. \end{aligned}$$

For \((R_1,R_2) \in {{\textbf {R}}}^{2}_+\), we have the trading function

$$\begin{aligned}{} & {} \psi _V(R_1,R_2) = \inf _{c} (c_1R_1 + c_2R_2 - V(c_1, c_2))\\{} & {} \quad =\max \{f_1(R_1,R_2),f_2(R_1,R_2)\}, \end{aligned}$$

where

$$\begin{aligned} f_1(R_1,R_2) = \inf _{c_1\ge K, c_2 > 0} (c_1R_1 + c_2R_2 - c_1) = \left\{ \begin{array}{ll} 0 &{}\quad (R_1,R_2)=(1,0) \\ -\infty &{}\quad \text{otherwise} \end{array}\right. \end{aligned}$$

and

$$\begin{aligned} f_2(R_1,R_2) = \inf _{c_1 < K, c_2 > 0} (c_1R_1 + c_2R_2 - c_2K) = \left\{ \begin{array}{ll} 0 &{}\quad (R_1,R_2)=(0,K) \\ -\infty &{}\quad \text{otherwise}. \end{array}\right. \end{aligned}$$

Putting these two together yields the trading function

$$\begin{aligned} \psi _V(R_1,R_2) =\left\{ \begin{array}{ll} 0 &{}\quad (R_1,R_2)=(1,0) \\ 0 &{}\quad (R_1,R_2)=(0,K) \\ -\infty &{}\quad \text{otherwise}. \end{array}\right. \end{aligned}$$

In other words, the CFMM only will either hold one unit of the underlying asset or K units of the risk-free asset. When the option is out of the money, \(c_1<K\), the CFMM will hold only one unit of the risky asset \((R_1,R_2)=(1,0)\). The CFMM will function equivalently to a limit order to sell one unit of the underlying at K. When the option is in the money, the CFMM will therefore hold only K units of the risk-free asset, i.e., \((R_1,R_2)=(0,K)\). In either case, the arbitrageur will ensure that the CFMM holds the whichever of (0, 1) and (0, K) has lowest total value. This implies that the constant affine curve

$$\begin{aligned} \psi _V(R_1,R_2) = K-KR_1-R_2 = 0 \end{aligned}$$

will yield the same payoff by allowing the arbitrageur to trade between the underlying and the risk-free asset. This is analogous to the trading rule used in the stop-loss start-gain strategy for replicating an option position (Carr & Jarrow, 1990), but requires full collateralization.

4.3 Black–Scholes covered call price

While the previous example gives the terminal payoff of a covered call, it requires full collateralization, which we expect will not be particularly useful in practice. In this example, we instead replicate the price of the covered call under the Black–Scholes model. We chose this model as a standard example, because it is well studied, but note that our approach could accommodate different pricing models and assumptions. The replication in this section will require less initial capital and apply to the price of the instrument at any time prior to expiry. In this case, given a price \(c_1 \ge 0\), we can create a two-coin CFMM whose portfolio value function replicates the Black–Scholes price of a covered call, given by

$$\begin{aligned} U(c_1) = c_1(1-\Phi (d_1))+K\Phi (d_2), \end{aligned}$$

where \(\tau >0\) is the time to maturity, \(K \ge 0\) is the strike price, \(\Phi (\cdot )\) is the standard normal CDF, and

$$\begin{aligned} d_1 = \frac{\log (c_1/K)+ (\sigma ^2/2)\tau }{\sigma \sqrt{\tau }}, \qquad d_2 = d_1 - \sigma \sqrt{\tau }, \end{aligned}$$

where \(\sigma \ge 0\) is the implied volatility. Here, we assume zero risk-free rate, i.e., \(r=0\), but the extension to the case of a positive risk-free rate is immediate. Taking the perspective of U

$$\begin{aligned} V(c_1, c_2) = c_1-c_1\Phi (d'_1)+Kc_2\Phi (d'_2), \end{aligned}$$

where we have modified the constants to satisfy

$$\begin{aligned} d'_1 = \frac{\log (\frac{c_1}{c_2 K})+ (\sigma ^2/2)\tau }{\sigma \sqrt{\tau }}, \quad d'_2 = d'_1 - \sigma \sqrt{\tau }. \end{aligned}$$

Using (5), we write, for \(R, R' \ge 0\), Therefore, we can recover the trading function using (5)

$$\begin{aligned} \psi _V(R_1,R_2) = \inf _{c_2 > 0, c_1} (c_1R_1 + c_2R_2 - V(c_1, c_2)). \end{aligned}$$

Partially minimizing over c, we have the first-order conditions

$$\begin{aligned} R_1-1+\Phi (d'_1)=0, \quad d'_1=\Phi ^{-1}(1-R_1),\quad c_1=c_2 K h(R_1), \end{aligned}$$

where h is defined as

$$\begin{aligned} h(R_1) = e^{\sigma \sqrt{\tau }\Phi ^{-1}(1-R_1)-\tau \sigma ^2/2}, \end{aligned}$$

for convenience. We can substitute this result back, and, after cancellations, find that

$$\begin{aligned} \psi _V(R_1,R_2) = \inf _{c_2 > 0} \left( c_2(K\Phi (\Phi ^{-1}(1-R_1)-\sigma \sqrt{\tau } - R_2) \right) . \end{aligned}$$

This then easily reduces to

$$\begin{aligned} \psi _V(R_1, R_2) = \left\{ \begin{array}{ll} 0 &{}\quad K\Phi (\Phi ^{-1}(1-R_1)-\sigma \sqrt{\tau }) \ge R_2\\ -\infty &{}\quad \text{otherwise}. \end{array}\right. \end{aligned}$$

We plot some examples in Fig. 1. When the price of the risky asset and the time to maturity are both strictly positive, the covered call payoff will require more capital to replicate a covered call closer to maturity. This can be seen in both the formula for \(V'(c)\) and visually in Fig. 1. If one were to update the trading function over time as the option neared maturity, each update would require additional capital. The difference over time is determined by ‘theta’ which captures the time-decay of the option’s price. The no-fee CFMM will not capture gains from theta decay and as such will fail to offer self-financing replication. We conjecture that fees may restore the ability of the LP to profit from theta decay when replicating such positions, as demonstrated in a simpler case in Evans et al. (2021). We discuss theta decay further in Appendix, but do not resolve this question directly in this work.

4.4 Perpetual American put option price

We consider a payoff of \(K-P(c)\), where P(c) is the Black–Scholes price of a perpetual put option struck at K. From Shreve (2004, Chapter 6), this payoff is

Fig. 1
figure 1

The left figure plots the trading function of the replicating CFMM for a covered call with \(\tau =10\) for different values of implied volatility. The right figure shows how the trading function changes with time to maturity for \(\sigma =0.1\)

$$\begin{aligned} U(c_1) = \left\{ \begin{array}{ll} c_1 &{}\quad c_1 \le L \\ K - (K-L)\left( \frac{c_1}{L}\right) ^{-\frac{2r}{\sigma ^2}} &{}\quad c_1>L. \end{array}\right. \end{aligned}$$

where \(L=\frac{2r}{2r+\sigma ^2}K\), \(\sigma \) is the volatility of the risky-asset and r is the risk-free rate. Taking the perspective

$$\begin{aligned} V(c_1,c_2) = \left\{ \begin{array}{ll} c_1 &{}\quad c_1 \le L \\ c_2K - c_2^{\frac{2r+\sigma ^2}{\sigma ^2}}(K-L)\left( \frac{c_1}{L}\right) ^{-\frac{2r}{\sigma ^2}} &{}\quad c_1>L. \end{array}\right. \end{aligned}$$

We have the trading function

$$\begin{aligned} \psi _V(R_1,R_2) = \inf _{c_2 > 0, c_1} (c_1R_1 + c_2R_2 - V(c_1, c_2))=\max \{f_1(R_1,R_2),f_2(R_1,R_2)\}, \end{aligned}$$

where

$$\begin{aligned} f_1(R_1,R_2) = \inf _{c_1 \le L, c_2>0} (c_1R_1 + c_2R_2 - c_1) = \left\{ \begin{array}{ll} 0 &{}\quad (R_1,R_2)=(1,0) \\ -\infty &{}\quad \text{otherwise} \end{array}\right. \end{aligned}$$

and

$$\begin{aligned} f_2(R_1,R_2) = \inf _{c_1>L, c_2 > 0} \left( c_1R_1 + c_2R_2 - c_2K + c_2^{\frac{2r+\sigma ^2}{\sigma ^2}}(K-L)\left( \frac{c_1}{L}\right) ^{-\frac{2r}{\sigma ^2}}\right) . \end{aligned}$$

The first-order optimality condition applied to \(c_1\) implies that

$$\begin{aligned} c_1=c_2 \left( \frac{R_1\sigma ^2}{2r}\frac{L^{-\frac{2r}{\sigma ^2}}}{K-L} \right) ^{-\frac{\sigma ^2}{2r+\sigma ^2}}. \end{aligned}$$

Substituting this back and after some cancellations, we get

$$\begin{aligned} \psi _2(R_1,R_2) = \inf _{c_2 > 0} (c_2(R_2 + KR_1^{\frac{2r}{2r+\sigma ^2}} - K)) = \left\{ \begin{array}{ll} 0 &{}\quad R_2 + KR_1^{\frac{2r}{2r+\sigma ^2}} - K \ge 0\\ -\infty &{}\quad \text{otherwise}. \end{array}\right. \end{aligned}$$

Noting that \(f_1(1,0)=f_2(1,0)=0\) means we can simply use \(f_2\) as our trading function. Unlike the previous example, the perpetual American put does not require one to update the curve or contribute additional capital to continue the replication.

Fig. 2
figure 2

The left figure plots the trading function of the replicating CFMM for a perpetual American put with \(r=0.1\) for different values of implied volatility. The right figure plots the trading function for different values of r when \(\sigma =0.25\)

5 Conclusion

We demonstrated an equivalence between CFMM trading functions and consistent (i.e., concave, nonnegative, nondecreasing, and 1-homogeneous) payoff functions. Our methodology relies only on basic tools from convex analysis and can produce the appropriate trading function for replicating a number of theoretically and practically interesting payoffs. However, we also point to cases where replication requires additional initial capital due to arbitrage costs. Finally, the results presented in this article may have implications for the design of existing CFMMs and indeed qualitatively matches some results in the previous work. In particular, the result of Angeris et al. (2020) that lower curvature CFMMs are more suitable to lower volatility assets appears to be confirmed in the discussion of options in Sect. 4, wherein the trading functions have lower curvature for lower implied volatility (for a visual illustration, see Figs. 1 and 2).

Future work There are several interesting directions for future research. For example, determining whether fees can mitigate arbitrage losses, allowing replication without additional capital, would be a very useful result. We conjecture that such a result would generalize the framework of Evans et al. (2021) from constant-mean marker makers to arbitrary CFMMs. As previously discussed, another possibility is, when the replication of a given payoff is impossible, how closely one can approximate the payoff with a CFMM. Another area for research involves extending the results to include convex payoffs as well as positions that require leverage to replicate. Convex instruments may require the ability to establish short positions in CFMMs shares. Similarly, levered instruments require one to facilitate lending secured by the value of CFMM shares. A model for secure lending and borrowing of CFMM shares would therefore expand the range of payoffs one can replicate with a CFMM.