Swop.fi pricing

Swop.fi
Swop.fi
Published in
4 min readNov 24, 2020

Swop.fi is an automated market maker (AMM), meaning that exchange rates for token pairs depend only on token amounts in the underlying liquidity pool. Swop.fi smart contracts do not use oracles or any other external data sources to determine exchange rates.

Swop.fi offers different pricing formulas that are most suitable for each specific token pair:

  1. Constant Product Market Maker (CPMM).
  2. Flat.

Below, we describe how both formulas work and why the Flat formula reduces slippage and provides better swap rates for stablecoins.

CPMM

Most Swop.fi pools are based on a well-known formula used by Uniswap and many other AMM projects. This formula states that trades must not change the product of token amounts:

where

x is the amount of token X,

y is amount of token Y,

k is a constant.

If a user sends amount a of token X, the equivalent amount b of token Y satisfies the ratio:

In fact, what the user receives is not b, but 0.997b, due to a 0.3% fee charged by the smart contract.

Suppose x = 1000 and y = 200. Let’s see how the swap amount affects the price.

For small trades, the price is close to x/y. The greater the swap amount relative to the total amount of the token in the pool, the more the price moves. This effect is called slippage. The hyperbola price curve causes high slippage on large trades.

Flat: reducing slippage

The CPMM formula does not work well for a pair of tokens with a very similar price, such as stable coins pegged to the same fiat currency. When exchanging small amounts, the price should be as close as possible to the constant price described by the formula

Curve reduced slippage for stablecoin pools by implementing a formula that combines product (1) and sum (2) of the token amount. Inspired by Curve’s approach, we designed our own original formula, which is currently applied to the USDT/USDN pair:

Here s is the skewness of token amounts. The greater the skewness, the greater the impact of the product is, as in formula (1). If the amounts are close to equilibrium, the impact of the sum is greater, as in formula (2).

Our simulations have shown that the values α = 0.5 and β = 0.46 result in the least slippage at a balance ratio close to equilibrium. The price curve in this case looks like this:

Suppose the smart contract stores 1,000 X tokens and 1,000 Y tokens. According to the CPMM formula (1), the swap result would be as follows:

The amplified Flat formula (3) gives the price that deviates substantially less from 1:

In fact, what the user receives is not b, but 0.9995b, due to a 0.05% fee charged by the smart contract.

Sign up to our Twitter not to miss out our regular updates! Join our support group on Telegram for questions related to our service.

--

--

Swop.fi
Swop.fi

Swop.fi is an instant, AMM-type crypto exchange that offers the most profitable swap formulas for each token pair.