## Prerequisites

An understanding of Constant Function Market Makers, StableSwap, impermanent loss, and homotopy is useful for this post.

## Introduction

The rise of Automated Market Makers (AMMs) in the decentralized finance setting is indicative of the value of such markets. Two popular forms of AMMs are Constant Sum Market Markers and Constant Product Market Makers (CSMMs and CPMMs respectively). Some platforms, such as that presented in the StableSwap whitepaper (see here), attempt to take the best of these two methods and combine them in a new type of market. Our work in “Mixing Constant Sum and Constant Product Market Makers” recontextualizes the blending of these markets and opens new doors to easy methods for market design.

## Basics of AMMs

The equations of a CSMM and CPMM in the case of two assets are typically written in the following ways:

In this presentation, x and y represent the quantities of the two respective assets in the market; traders in the market may exchange one asset for another as long as the initial and final quantity values satisfy the same equations. For example, suppose there was a CPMM where the initial quantities were 60 and 20 respectively. This would mean that the curve defining the valid states of the market is given implicitly by xy = 1200. It is possible for a trader to withdraw 30 of the first asset and deposit 20 of the second asset because doing so would move the quantities to 60–30 = 30 and 20 + 20 = 40; this point is on the same curve because 30 times 40 is also equal to 1200.

It is important to establish the notion of “exchange rate” in a market such as the ones above. One might say that 30 of asset 1 is the same value as 20 of asset 2 in the above example and therefore the exchange rate is always 3 : 2. However, we see that the point (57, 22) is not a valid state because 57 times 22 is 1254 (i.e. not 1200). This demonstrates that a more sophisticated model for exchange rate is needed.

A more general notion of a AMM for two assets is the following. The function defining the AMM is usually denoted by A. Note that this function must satisfy several important conditions that need not be covered here. The “instantaneous exchange rate” or “spot price” of this AMM is defined to be the negative of the slope of the tangent line at the given state, i.e.

## Important Features of AMMs

There are many types of AMM platforms in existence today and each claims to have its own set of benefits. The following list encapsulates the important features of AMMs that we keep in mind when designing behaviors in our work:

Existence of a parametrization for the implicitly defined AMM

Ability to provide liquidity at all exchange rates

Whether or not the AMM is Exchange Rate Level Independent (see here)

The amount of stability in exchange rates as quantities in the AMM change

These features help to ensure that the market is stable, functioning at all prices, easy to analyze in the context of impermanent loss, and able to maintain small levels of slippage.

## Mixings of CSMMs and CPMMs

Our first method for mixing CSMM and CPMM behavior follows that of StableSwap; our others are more novel. As an example, let’s write generalizations of the above two asset equations in the following way:

Note that the notion of CPMM given here is broader than the usual sense of the term and is closer to the equations used in Balancer (see here).

This presentation of the equations has the advantage that both are defined with a constant of 1 on the right hand side; mixing these two equations is now very natural. Our work focuses on the classical “arithmetic” mixing and introduces the novel “geometric” and “homotopy” mixings.

The parameter t controls the relative strengths of the two types of behavior; if t = 0 then the curve is a CSMM and if t = 1 then it is a CPMM. For values of t in between 0 and 1, this blending for all three mixings is visually presented below for different values of t:

The most notable difference between these mixings is that arithmetic only supports a finite range of exchange rates while the other two support all exchange rates.

These mixings might seem abstract, but as an example of the applicability of this framework, one can describe the StableSwap system using this arithmetic mixing format. In short, StableSwap has a “leverage parameter”, denoted ꭓ, which serves a similar role to t. We show that the equation to convert between the two parameters is as follows:

## Uses of Homotopy Mixing

The primary focus of our paper is expanding the notion of the homotopy mixing presented above. The idea of the homotopy mixing stems from the concept of the same name in topology. Roughly speaking, a common example of a homotopy between two vector valued functions f(s) and g(s) is

In other words, the point H(s, t) is exactly 100t% of the way along the line segment connecting the points f(s) and g(s) for each s. As such, a point on the homotopy mixing curve will be exactly 100t% percent of the way along the line segment connecting two corresponding points on the CSMM and CPMM curves.

The images below demonstrate an example of the convenience of this homotopy construction. Taking t = 0.5 and examining the line y = 0.25x shows that the homotopy mixing intersects the line exactly 50% of the way between the points (1.6, 0.4) and (2, 0.5); in contrast, the arithmetic and geometric mixings intersect approximately 44.4% and 47.2% of the way between them.

The above definition of the homotopy mixing takes t to be a constant, but a more general approach in 2D would be to take t(s) to be a function. Doing so and rearranging the terms yields

There are many interesting and novel directions one could go with this approach. Two examples we present are (1) a family of symmetric AMMs with very high levels of price stability and (2) a family of asymmetric AMMs with higher levels of stability for one asset than for the other (i.e. the orange curve is more stable when Currency 1 is more abundant and the light blue curve is the opposite).

Note that not all equations are valid choices for t(s); it is possible for the resulting curve to not be convex. We find an easy-to-check condition that ensures convexity holds. Define the following constants and functions:

We show that the following is the convexity condition for markets with two assets:

## Simulations of Stability

An important component of our work was testing the stability of the homotopy curves. Our interest specifically lay in describing how the stability parameter of the mixing (1) affected the ability of arbitrageurs to match the internal exchange rate of the market with an externally driven exchange rate and (2) how the stability parameter correlated with slippage in both the short and long term. A summary of our results is shown below.

### In short, we found the following results:

Arbitrageurs find it more difficult to match the internal and external exchange rates when the stability parameter is high

In the short term, slippage is small when stability is high. Ultimately this phenomenon is due to the fact that the external exchange rate remains in the stable region near the initial state in a short time frame.

In the long term, the amount of slippage is higher when the stability parameter is high. In other words, the cost of having a larger stable region is much lower stability outside the stable region

These results suggest that dynamically updating the curve to keep the current exchange rate in a stable region might be beneficial for the market. Experimenting with such dynamics is a future goal of our work.

### Conclusion

The work we present in “Mixing Constant Sum and Constant Product Market Makers” creates a novel framework for the mixing of constant sum and constant product market makers, presents examples of novel designs made with the framework, and demonstrates a preliminary analysis of how the design choices of these markets affect arbitrageurs and slippage. We hope to expand on this work by (1) more thoroughly examining the homotopy mixing in markets with more than two assets and (2) to create more powerful simulations of dynamically balanced homotopy curves.

## Comments