Can one hear the shape of a CFMM? (Part 1)

Apparently, it is hard to hear the shape of a drum (Marc Kac, 1966), but what about a CFMM?

Apparently, it is hard to hear the shape of a drum (Marc Kac, 1966), but what about a CFMM?

The rise of Uniswap in 2019 was a watershed moment for DeFi trading. Uniswap’s simplicity, gas efficiency, and expert-defying performance quickly made it the dominant venue for on-chain exchange. The launch of Curve in the early part of this year demonstrated that even small changes in the design of constant-function market makers (CFMMs) can lead to drastic improvements in capital efficiency and performance. In particular, Curve pioneered a locally flatter curve that offered lower slippage for stablecoin-to-stablecoin trading. This tweak allowed Curve to capture significant trading volumes while routinely outcompeting established exchanges and OTC desks. As a result of Curve’s success, curvature is increasingly recognized as an integral component of the design space of CFMMs. Nonetheless, the precise effects of the choice of curvature on the behavior of the market have not been studied in depth.

In this series of posts, we set out to make the concept of CFMM curvature concrete. We discuss the effects of curvature choice on equilibrium prices, stability, liquidity provider returns, and market microstructure. These posts will draw from the research we conducted for our upcoming paper: “When does the tail wag the dog? Curvature and market making.” The paper will be published concurrently with the third post in this series. In this first post, we will provide a working definition of curvature and discuss its implications on liquidity and price stability.

The summer of 2020 changed the landscape of CFMMs. Owing in large part to yield farming, CFMMs are increasingly the most liquid markets for a wide variety of pairs. This necessitates a new analytical framework for studying these markets. We show that curvature provides the missing link for studying CFMM-dominated markets. When a CFMM becomes the most liquid trading venue, other venues mostly adjust to the price of the CFMM. The first step in our framework is understanding how venues with finite liquidity interact with one another.

A two-market model

Suppose there are two venues for trading a given pair of assets. One of the two venues is more liquid than the other. How do we model the difference in liquidity? A simple exercise is to look at the effects of a fixed-size trade. If the same-size trade induces a larger price change on one market than the other, we could roughly say that the former is less liquid. In the case of CFMMs, this simple model is surprisingly descriptive. CFMMs implement a specific curve for each pair, allowing us to precisely describe the impact of a given trade. This is where curvature comes in. Informally, curvature describes the absolute change in the price reported by a CFMM after a small trade. All else being equal, a CFMM with higher reserves will exhibit lower curvature. However, some CFMMs will have lower curvature than others for a given value of reserves. The difference can be seen by comparing Uniswap and Curve. Starting from the point where reserves are equal, we can see from the plot below that Uniswap has higher curvature than Curve around the point x=y=5.

0_RiQFW-1Q04XQGNMd.png

As we can see, curvature provides an elegant model for the liquidity of a given market. The lower the curvature of the market, the lower the price impact of a given trade.

Most models of CFMMs assume a CFMM with finite liquidity and a “reference” market with unlimited liquidity. These models show that under fairly general conditions, the price of the CFMM will be adjusted by an arbitrageur to reflect that of the reference market (this is formalized in the original CFMMs paper). These models perform quite well in practice. Because the arbitrage problem for Uniswap and friends is typically convex, arbitrageurs can easily figure out how to adjust reserves to reflect prevailing market prices. This theory underpins the use of CFMMs as price oracles in a variety of on-chain applications (for example, the Uniswap v2 oracle). However, after the boom of CFMMs in the summer 2020, we need a model that can better capture the reality of CFMM-driven markets.

To do that, let’s flip the script. Assume we have a highly liquid (low curvature) CFMM and a less liquid (high curvature) reference market. The reference market could be based on a CFMM, a limit order book, a request-for-quote system, an auction, or any combination. The choice of market doesn’t affect the model, as long as it has non-zero curvature (finite liquidity). If the prices of the two markets differ, an arbitrageur can make a profit by making offsetting trades in each market until the prices reported by the two markets agree. If the two markets are equally liquid, we expect that the resulting no-arbitrage price would be somewhere in between the pre-trade prices of the two markets. If the CFMM is more liquid, however, the final price would be closer to the CFMM’s pre-arbitrage reported price. In other words, if the CFMM is significantly more liquid than the reference market, then changes in the price on the reference market would have a smaller effect on the no-arbitrage price.

To see this, consider the following example. We have a 60–40 Balancer pool and a Uniswap pool. For the same value of reserves, the Uniswap pool has slightly lower curvature. To emphasize the difference, we assume the Uniswap pool is slightly larger. In the following graphic, the prices reported on Balancer and Uniswap begin at different points (the slopes of their tangent lines differ). An arbitrageur buys in one market and sells on the other, until the slopes of the two tangent lines are equal. Notice that the Balancer price moves more than the Uniswap price, but the difference isn’t that significant. This is because the curvature of the two markets is in fact quite close, despite the Uniswap market having higher reserves and slightly more even weights.

Arbitrage between Uniswap and Balancer

Arbitrage between Uniswap and Balancer

Consider instead a Uniswap pool and a Curve pool with roughly equal reserves. In this case, the Curve price barely moves at all, while the bulk of the adjustment comes from Uniswap.

Arbitrage between Uniswap and Curve

Arbitrage between Uniswap and Curve

Curve has much lower curvature than Uniswap when the coins traded have roughly equal price. That means, that even if the price on the less liquid venue is quite volatile, the final price will not deviate much from the price reported by Curve. Note that this type of arbitrage is extremely common in practice. Arbitrage bots on Ethereum continually align prices across Balancer, Uniwap, and Curve pools as well as order-book-based exchanges. In our forthcoming paper, we establish this effect mathematically. If the CFMM is highly liquid relative to the reference market, then even large deviations in price on the reference market will have a minimal effect on the no-arbitrage price. We show that this holds as long as the price jumps are bounded by some (potentially large) constant. This assumption precludes extreme scenarios such as a complete collapse of the peg of a stablecoin. Finally, in footnotes 0 and 1, we sketch some of the more technical and mathematical considerations that one needs to consider when describing curvature formally.

The curious case of sUSD

We’ve seen that low-curvature CFMMs can “impose their will” on the broader market. This also helps explain another phenomenon: price stability. Beginning in March 2020, Synthetix announced that it would incentivize liquidity for sUSD on Curve with the intent of better supporting the sUSD peg. The creation of this sUSD pool on Curve had a near-immediate impact on the peg: sUSD began to track other stablecoins much more closely in price. Below, we show the implied price of sUSD on Uniswap from late 2019 to September 2020. The sUSD pool was officially launched in mid-March 2020 (and rebooted shortly following a security incident). Over the period from late March to early June 2020, sUSD was remarkably faithful to its peg on Uniswap. We expect that arbitrage between Curve and Uniswap contributed to this effect: As long as the price fluctuations of sUSD around the peg were bounded, arbitrageurs were incentivized to align the price on Uniswap with that of Curve. Note that sUSD was illiquid on every other venue but Curve, leading to a very large curvature differential between Curve and all other markets. More recently, projects such as Pickle Finance have directly tied rewards to how close the CFMM is to parity for a given stablecoin.

1_nWgF6rcOQpLieqlID7mQ8A.png

At the same time, this data shows the limitations of our simple two-market model. In the second week of June, sUSD started depegging more frequently. The new regime coincides almost perfectly with the advent of yield farming in June 2020. In early-to-mid June 2020, Compound and Balancer launched the first liquidity mining programs. The price of SNX (the primary collateral for sUSD) began to inflect, more than tripling over the month of June and continuing its rally through the summer. Other DeFi projects launched liquidity mining and stablecoins were central to most liquidity mining strategies. As a result, nearly all stablecoins experienced increased volatility due to demand from yield farming. Clearly, these factors are not captured by our two-market model. As a result, we need to extend the model to include yield farming and its interaction with curvature. We will discuss this extension later in this series.

Cost of curvature

There are trade-offs to low curvature. If a CFMM has zero curvature, the price reported by the CFMM doesn’t change, no matter how much is traded. As a result, constant-sum curves such as mStable set bounds on how much of each stablecoin the CFMM can hold in order to prevent LPs from exclusively holding the worst-performing asset.

Lower curvature CFMMs fare better when the assets are highly correlated and mean-reverting. In this environment, the CFMM is able to attract more trading volume and fees through lower curvature, while mean reversion modulates the effect of impermanent loss. Stablecoin-to-stablecoin CFMMs now largely adhere to this principle as do CFMMs for expiring assets such as bonds. We will discuss the trade-offs to curvature for LPs in the context of asymmetric information, mean reversion, and impermanent loss in the next post.

Footnotes

[0] One of the main differences between Curve and Uniswap is that Curve’s pricing function is ‘flatter’ within a certain region of the price-quantity space and ‘more curved’ in others. The economic intuition for why one would prefer such a morphological change to a pricing curve is the following:

  1. We have two assets whose price (relative to the other) are mean-reverting and low-variance (e.g. their prices are usually equal to each other).

  2. Trades that keep these assets near each other (e.g. ‘soft’ pegged to one another) should be cheap as they encourage arbitrageurs to enforce the peg. This is done by flattening the curve, which lowers the slippage and market impact that traders face.

  3. However, when the assets are ‘depegged’ (e.g. greater than some number of standard deviations from their common mean), traders should pay higher slippage. This effectively is to compensate liquidity providers for the deviation from the peg (they lose money via impermanent loss when the peg is broken) and ensure that they don’t pull their liquidity, freezing the market.

Unlike Uniswap, which has a more ‘uniform’ level of curvature for all prices, Curve is adapted to the price process (e.g. mean-reverting, bounded variance) that is expected to trade on it. This example shows that the choice of a CFMM pricing function is closely tied to the types of assets traded on it and the incentives needed to keep liquidity providers happy.

[1] Is there a way that we can formalize this beyond the vague hand-wavey notion of ‘flatter’ or ‘more curved’? The answer is yes, surprisingly thanks to Carl Friedrich Gauss. Mathematicians have spent much of the last few centuries quantifying and categorizing geometric intuitions via analysis and algebra. One of the main connections between analysis and algebra comes from the notion of intrinsic curvature. A surface’s intrinsic curvature represents the ratio of the area of small triangle on the surface to a triangle with the same perimeter on the plane. One key feature of intrinsic curvature is that it doesn’t depend on the orientation or parametrization of the surface. For instance, the intrinsic curvature of a beach ball doesn’t change when you rotate it by any amount in any direction. We can define the “intrinsic” property more generally as:

For any rotation matrix A and translation vector b, the surface defined by f(Ax+b) = k has the same curvature as the surface defined by f(x) = k

One of the key early results in differential geometry is Gauss’s Theorema Egregium, which says that the curvature of implicitly-defined surfaces, e.g. ones where f(x) = k, is intrinsic.

How does this relate to the intuitive notion of CFMM curvature? Recall that an equivalent way to define a CFMM is via its trading set, which is akin to the epigraph of its invariant function. The boundary of this set is a surface defined by the constant function invariant. It is this surface’s curvature that we refer to when we talk about Curve being flatter (lower curvature) than Uniswap.

But is there any economic content to requiring that the type of curvature related to liquidity needs to be intrinsic? Suppose that we represent the curve’s invariant in terms of new variables Z = (X+Y)/2 and W = (X-Y)/2. Z represents a long-only, half-sized portfolio of assets X and Y and W represents a half-sized long X, short Y portfolio. Gauss’s Theorema Egregium states that our intuitive statement that “a CFMM with flatter curvature requires more traded quantity to move the price” is invariant to our choice of asset representation. The LP’s returns and the trader’s market impact don’t change if the trades are made for X to Y or Z to W. We can view the “intrinsic” nature of curvature as equivalent to the financial claim that two portfolios with the same payoff are equivalent to a risk-neutral investor.

But how does this curvature related to the interaction between a CFMM, as a primary market, and other, secondary markets? To analyze this, we construct a game between two markets with different curvatures and compare the impact of a trade in the secondary market.