Skip links

Automated Market Making Mechanisms and Issues in Uniswap, Balancer, and Curve

Introduction

Early decentralized exchange (DEX) proposals took their inspiration from classical exchange markets and made use of order books to match sell and buy orders. Although these proposals achieved to be non-custodial exchanges, they turned out to be not very good in practice. The main reason for this is that an order book has a linear increase in storage and often even polynomial increase in computation with respect to the number of orders (see [1] , p. 2). This in turn — when implemented as smart contracts — caused far too high costs in fees making these solutions infeasible. Several approaches came up which run the order book offchain to reduce costs. This line of research continues to grow further using for example advanced cryptography (StarkDex) or exploiting batch ring trades (Gnosis).

A complementary approach to offchain order books for decentralized exchanges uses the concept of automated market makers (AMMs). The great advantage of such protocols are that they only require constant space and time interactions – unlike order books –, making non-custodial exchanges feasible.

In this post we look at the basics of the following three AMM projects: Uniswap, Balancer, and Curve. We shed some light on what they have in common, and try to understand in which aspects they are different from each other. The exposition takes a simplified view considering only trading markets with two tokens. This demonstrates already the essential points without getting lost in greater complexity. For those who want to understand the general case we provide links to further literature discussing the general case in even more depth.

The Formulas Behind Uniswap, Balancer, and Curve

 

Trading Functions and Marginal Prices

In this section we present the trading functions of Uniswap, Balancer and Curve, and their price impact functions. After passing through some mathematical formulas, we demonstrate in an example, how these different choices can be interpreted.

UNISWAP: The trading function of Uniswap is the product of the updated reserves

and the constraint (1) takes the form of

BALANCER: The trading function of Balancer is the weighted product of the updated reserves

CURVE: The trading function of Curve is a linear combination of the sum and the product of the updated reserves

Figure 2: Curvature  in dependency of portfolio value PV for Uniswap, Balancer, and Curve (Source: [1], p. 14)

Trading Functions with Fees

BALANCER:

CURVE:

Liquidity Provider Return and Other Topics

LIQUIDITY PROVIDER RETURN: Whenever a liquidity provider deposits into a pool, she receives liquidity tokens in return. These tokens represent her contribution to the actual pool size. In order to withdraw, the liquidity provider must burn the liquidity tokens which gives her back the proportion of the reserve pool. Assuming a fixed market price, the liquidity provider will collect the same amount plus a return from fees which increased the pool size. (Some minor fees for withdrawing from reserves may apply!)

There is an empirical evidence that the shape of the price impact function and the liquidity provider’s return are correlated. As shown in Figure 1, Curve’s price impact function is flat around the “mean” (i.e. when R1 = R2 in the stable coin example) while the price impact function of Uniswap increases more rapidly. This invites stable coin traders to change higher amounts between stable coins in the Curve platform, which creates a higher trading volume. Therefore, a higher return is paid to liquidity providers in Curve, which, in fact, has the highest token volume locked (see here)! See [1], section 2, for a more general discussion. In the above scenario the market price of the tokens are supposed to be constant which can be assumed for stable coin pairs in Curve. For other coins, this is usually not the case, since slippage (see below) changes the token price. Until prices are not moved back to the “original” price, this may cause an impermanent loss. This loss becomes permanent when the liquidity provider withdraws before the price moves back. For more details see here.

References

[1] G. Angeris, A. Evans, T. Chitra; When does the tail wag the dog? Curvature and market making, 2020.

[2] G. Angeris et al.; An analysis of Uniswap markets, 2020.

[3] G. Angeris, T. Chitra; Improved Price Oracles: Constant Function Market Makers, 2020.

[4] F. Martinelli, N. Mushegian; Balancer white paper. 2019