Constant Product

The constant product function is based on the following equation.

xy=kx * y = k

The x here represents the amount of one asset, and y is the amount of the other asset. As the name of the functions hints, the principle is that the product of the asset amounts remains constant - the k in the formula. So if you want to swap asset one for asset two, x will increase, and y will decrease so that k is kept constant.

Constant product AMM is suitable for volatile token pairs because they enable trading at all possible prices. That means it can facilitate trading even during market fluctuation. It is also beneficial for primary markets, where traders are more likely to guess and act based on information from outside the market, despite higher slippage.

Following is the resulting price curve of the constant product AMM function. As you can see, large trades relative to the size of the pool move prices further along the curve in both directions. It is an elegant solution well-suited to most crypto assets that behave more like traditional stocks.

However, while the constant product market maker model is a great leap forward for DeFi, it is not ideal for trading pairs of USD stablecoins or any other two same-valued assets. For such trading pairs, it is desirable to exchange in a 1:1 ratio between them. In a constant product AMM world, it requires high liquidity to ensure low slippage, and even then, it can fall short of the set expectations.

This is where StableSwap comes in.

Last updated