All you need to know about the Automated Market Maker (AMM)

Susu Pu
9 min readFeb 5, 2021

--

I am Susu, Partner of Research at Sperax. This is my first research blog. Hope you like it.

With the outburst of decentralized financial applications available on Ethereum and other smart contract platforms, individuals started taking advantage of a global, permissionless, transparent, and interoperable network to develop new products and services.

These include borrowing and lending, decentralized exchanges, and prediction markets. In particular, we are interested in analyzing how Automated Market Maker (AMM) protocols can help decentralized exchanges to stabilize the price with sufficient token supply.

An AMM protocol is a type of decentralized exchange protocol that prices assets based on a predefined mathematical formula.

It replaces the traditional limit order book with automatic assets trading on the pool’s latest price.

The Major Types of Rebalancing Models Include:

  • Constant Product Market Maker
  • X * Y= K

The plot results in a hyperbola where liquidity is always available, but at increasingly higher prices that approach infinity at both ends.

  • Constant Sum Market Maker (CSMM)
  • X + Y =K

The plot results in a straight line and CSMMs are ideal in no slippage circumstances but do not provide infinite liquidity.

  • Constant Mean Market Maker (CMMM)

The plot results in multidimensional. It guarantees that the weighted geometric mean of the reserves remains constant, and involves multi-token exposures.

  • Advanced Hybrid CFMMs

The plot results in a “zoom-in hyperbola”. Functions are combined to achieve lower slippage or impermanent loss.

The Key Benefits of Utilizing AMM:

  • Faster transaction process
  • Bootstrapping liquidity
  • Path independence
  • On-chain price oracle

The Key Challenges of Utilizing AMM:

  • Impermanent Loss
  • Forced Multi-Token Exposure
  • Slippage Cost

*Impermanent loss happens no matter the direction of the price change. The only thing impermanent loss considers is the price ratio relative to the time of deposit.

* By construction, the larger the order size, the larger the slippage. Similarly, the longer the trade, the larger the slippage.

In the following sections, we first summarize the available AMM protocols on the market and then compare their performance in order from most basic to most sophisticated. Finally, we introduce the innovative design underlying the Sperax stablecoin protocol.

Uniswap V1 & V2

Uniswap is the most classic AMM protocol. It utilizes a constant product market model to maintain price stability.

The advantage of Uniswap:

  1. It charges no listing fee, so it costs significantly fewer gas fees.
  2. The fees are distributed proportionally.
  3. Anyone can participate with no capital requirements.

However, non-direct pairs will incur double the trading fees (0.6%), as the liquidity needs to come from two different pools. Also, the LPs are subjected to substantial impermanent loss.

Uniswap V.2 addresses the issues in V.1 and added following features:

  1. ERC20/ERC20 Pair: This enables the pool of any ERC20 token directly with any other ERC20 token.
  2. Price oracles: The oracle system in Uniswap V2 is highly decentralized and manipulation-resistant.
  3. Flash Swaps: A user can withdraw any amount of any ERC20 token at no upfront cost.

Kyber Network

The liquidity pool in the Kyber Network is not open to anyone.

The price of the tokens in the liquidity pool can be set by external oracles or be automatically determined by the smart contract parameters during setup. Both of these allow market makers to have greater control of the pool in times of high volatility.

The Kyber Network liquidity pool has three reserves to control the token supply:

  1. Fed Price Reserve is similar to traditional markets that have greater control over when they want to offer liquidity.
  2. Automated Price Reserves creates liquidity pools with predefined algorithms that automatically adjust and set the price.
  3. Bridge Reserves aggregates liquidity from other on-chain sources like 0x and Uniswap.

However, the initialization of liquidity requires large capital. Each liquidity pool needs to be approved by the system, which makes it less decentralized. Additionally, fees paid cannot be accurately predicted after trading due to the aggregated liquidity pool.

SushiSwap

SushiSwap is a fork of Uniswap with some key differences — most notably, the SUSHI token. The tokens distributed through these liquidity incentives then grant governance rights to token holders.

The token has two functions at launch:

  1. Entitling holders to governance rights
  2. Issuing a portion of the fees paid to the protocol by traders.

PancakeSwap

Similar to SushiSwap, Binance exchange also introduces a new decentralized exchange on Binance smart chain. PancakeSwap is a decentralized exchange for swapping BEP20 tokens. It uses a hybrid CFMM function to maintain its token supply:

Balancer V1 & V2

More than a liquidity pool, Balancer implements the following features:

  1. Multi-token pool
  2. Dynamic pool fees
  3. Private pools
  4. Custom pool ratios.

Pools can be created that include up to eight tokens in a single liquidity pool. This feature opens up the potential for various use cases, the most prominent being an automated portfolio manager that can act as an index. It uses Constant Mean Market Maker (CMMM) to adjust its token supply.

Balancer’s dynamic features allow it to be used as more than just a liquidity pool. Its asset managers can create private pools that act more like an index basket of assets, which automatically adjusts based on the percentage ratio set.

However, competing pools in the protocol can create fragmentation of the assets. Slippage may have a higher impact on large trade orders. Pool participants are subject to (higher) impermanent loss due to trading volatility.

Key updates in the V2 features:

  • In V2 all deposited assets go into a single vault. This new design enables the protocol to save users a ton in gas fees as well since only net token amounts are transferred to and from the vault.
  • Customizable AMM logic and the three types of Balancer pools that anyone can create using the protocol. This includes weighted pools, stable pools, and smart pools. Weighted pools are great for constant weight index products. The new stable pools take inspiration from Curve and enable greater trading efficiency for assets that are soft-pegged to each other. Finally, the smart pools will allow for ongoing parameter changes. All three of these pools co-exist and provide a shared bucket of liquidity for the Balancer trade router.
  • Introduction of asset managers in the Balancer ecosystem. Asset managers would even be able to lend underlying tokens to another lending protocol to achieve yield for pool participants.

Curve

Curve utilizes a combination of constant sum and constant product formulas based on the extent to which the pool is imbalanced at the moment of a query.

The function assumes that if the underlying assets are relatively stable-priced (e.g. two USD-pegged stablecoins), the slippage can be eliminated following the equation above.

In this formula,

  • X: the reserves for each asset
  • n: the number of assets
  • D: an invariant that represents the value in the reserve
  • A: amplification coefficient, which is a tunable constant that provides an effect similar to leverage and influences the range of asset prices that will be profitable for LPs (i.e. the higher the asset volatility, the higher A should be).

This function acts as a constant sum when the portfolio is balanced and shifts towards a constant product as the portfolio becomes increasingly imbalanced. In effect, the function looks like a “zoomed-in hyperbola.”

The key advantage is that it reduces slippage and impermanent loss, but Curve’s unique focus on stablecoins restricts their market to a specific niche.

Bancor V.2

V.1 has many limitations, so we will only introduce V.2 here. Following is an improved dynamic AMM that helps Bancor protocol to lower slippage and impermanent loss.

  1. Single side exposure: allowing LPs to contribute and maintain 100% exposure in a single token when they add or remove liquidity, the pool’s weights automatically adjust to account for the change in reserve value.
  2. Stake balance and current balance: to mitigate impermanent loss. V.2 pools are designed to mitigate this risk by incentivizing market participants to always equalize the total held in the reserves (“current balance”) with the amounts staked by LPs (“staked balance”).
  3. Dynamic Weights: The arbitrage incentive is always to convert BNTs to XYZs or vice-versa, such that the following conditions are met: BNT/XYZ pool price= BNT/XYZ market price or XYZ current balance = XYZ staked balance
  4. Price Feeds: with external and internal oracles, Bancor V.2 protocol captures significant movements in the prices of reserve assets and micro-changes in market conditions. On each update from the external oracle, the internal price feed re-anchors to the external oracle, and the Continuous Smoothed Moving Average calculation restarts.

However, one notable disadvantage of Bancor V.2 is that the floating weights solution for mitigating impermanent losses requires a smooth flow of price feeds from oracles that operate externally to the protocol.

Shell

Shell liquidity pool has five unique features:

  1. Deep stablecoin liquidity: It facilitates large stablecoin-to-stablecoin trades with minimal slippage.
  2. Reserve weights: The maiden pool has target weights of 30% DAI, 30% USDC, 30% USDT, and 10% SUSD.
  3. Protections against a broken peg: It has a minimum and maximum allocations for each stablecoin.
  4. Dynamic fees: adjusted to incentivize participants and maintain price dynamics.
  5. Interoperability with aTokens and cTokens: Shell facilitates trades between other platforms, i.e. Aave and Compound.

Shell Protocol has similar goals of reducing slippage but takes a different approach. It’s like Curve in that the slippage is optimized for stablecoins and is similar to Balancer in that pool tokens are a weighted basket of assets. But, it differs from both in that it uses a variety of tunable parameters. It uses the following functions:

Where U(x) could be interpreted as a utility function composed of a gain function, G(x), and a loss function, F(x); and x is the reserves of each asset. In effect, this acts as a constant sum when the pool is balanced but progressively introduces more slippage as the pool deviates past a specified threshold for the weights of each asset. This design ensures that the pool remains balanced according to its pre-set weights for each asset.

Mooniswap

1Inch launched Mooniswap in late 2020 aiming to enable LPs to catch a portion of price slippage profits.

All AMMs maximize profits in one of the two ways: maximizing trading fees or minimizing arbitrage profits. Mooniswap seeks the latter strategy with a virtual balance.

When a swap happens, a market maker does not automatically apply the invariant algorithm and displays the new prices for upcoming trades. The AMM improves exchange rates for arbitrage traders slowly, over approximately a five minute time period.

As a result, they will be able to collect only a portion of slippage, while the rest will remain in the pool shared among LPs.

Mooniswap was able to generate from 50% to 200% more income for LPs than Uniswap V2 due to redirection of price slippage profits. Mooniswap (1Inch) also introduces on-chain volume-weighted average price oracles.

Saddle

Saddle Finance was launched as an automated market maker in 2021 that focuses on preventing slippage in value between different types of pegged-value assets like stablecoins and tokenized bitcoin. Its ultimate goal is to unlock deep on-chain liquidity for pegged value crypto assets

Saddle plans to use Synthetix’s virtual synths to fix composability issues by introducing a new token that basically represents a claim on that unsettled trade. While the product and the underlying math is not all that different from Curve Finance at the moment, the Saddle team has made it clear that they have plans to go in a different direction compared to Curve and provide unique value to users.

Saddle’s first liquidity pool enables trades between different flavors of wrapped Bitcoin like wBTC , tBTC, renBTC, and sBTC. The project is launching a guarded mainnet which will restrict usage and cap deposits at 150 BTC. This maximum cap was reached just a few hours after the initial product launch.

Sperax AMM

Aimed to solve the issues in existing AMM protocols, Sperax strives to implement an efficient and robust AMM.

Our native AMM will mitigate impermanent loss and slippage costs while improving capital efficiency. We will include a hybrid CFMM model that is compatible with our stablecoin, a dynamic weights and pricing model that is up-to-date with the real market, a dual-balance sheet, and single-token exposure that maintains the value of the LP wallet.

More are under the construction to guarantee the best user experience and interoperability with other protocols.

Stay tuned for the updates!

--

--

Susu Pu

Sperax Partner of Research | Cornell University M.S. Financial Engineering 2020