I hope you liked the first article in the series about cross-chain swap technology where I talked about the feature of interoperability between different blockchains. In this second article of this series I’ll be talking about another decentralised exchange called Curve, formerly called Stableswap. Just like the previous article this one also is about a challenge, a problem whose better solution was provided by an exchange other than Uniswap which in this case is Curve.

And just to clarify, the purpose of these articles is not to criticize Uniswap in any way, it is arguably the best decentralized exchange in the world and its highest trading volumes speaks for itself. Through these articles I just want to put forward my opinion regarding various problems currently there in the defi world and how it is not always the best exchange which is providing all the solutions.

Now coming back to the original topic, Curve is a decentralised exchange that facilitates the trade of stablecoins in a much more efficient manner than any other exchange. To understand how curve does it, it is important first to understand what stablecoins are and why they are not just any tokens.

One of the major demerits of cryptocurrency is their price instability, because of the high volatility of this digital money, it is not really possible to use it as widely as fiat currencies in daily transactions. So to mitigate this issue the concept or rather a new form of cryptocurrency was introduced which is stablecoin. Stablecoin as the name goes is a form of cryptocurrency which unlike other currencies like BTC or ETH is not volatile in terms of price and just like its fiat equivalent remains stable. Now to explain how this stability is maintained requires a different article altogether but just to give a brief idea, the stability of Stablecoins is ensured by pegging them to an another stable asset like gold or some other fiat currency. What the organisation behind the stablecoin will do is that it will set up a reserve where it stores the asset backing the stablecoin for example 1 million$ for 1 million stablecoins. But the point that is relevant to our discussion here is that these stablecoins have been on the rise. The supply of stablecoins took 5 years to reach the 6 billion mark and from thereon it just took 4 months to reach 12 billion from 6 billion. A part of that can also be attributed to the Bitcoin crash which also underlines the fact that at times even the price of stablecoins can become unstable if the demand is very high which was indeed the case when the price of bitcoin plummeted but the larger picture tells us that these stablecoins today are in more demand than ever and thus there is a need to have an efficient decentralised exchange that smoothly facilitates their trade and one such exchange, Curve, we are going to discuss in the next section.

The first question that comes to find is why we are seeking a special kind of exchange for the trade of stablecoins, why cant they just be traded like other hundreds of coins and why Uniswap comes second to Curve when it comes to exchange of stablecoins only. The answer here is price slippage. Price slippage, as discussed in previous blog also, is the difference between the price of asset at the time of placing and executing the order and this price slippage is high in AMMs like Uniswap, basically in all of the AMMS which come under the category of Constant Product Market Maker(CPMM).

Let’s understand slippage through an example. Suppose in a Uniswap Liquidity pool there are two tokens **A and B**, total number being **5000 and 10 respectively**.

So according to the **xy = k** formula the value of constant** k is 50000 **and price of token B in terms of token **A is 500** (according to formula x/y).

Now suppose a trader wants to **buy 5 tokens of B**, so **now total no of B = 5 **and according to **AMM total no. of A is now 10000**, so **effectively** the trader was able to **buy 5 tokens of B by putting in 5000 tokens of A** making the effective price of trade to be **1000 A per B**, so this difference of initial price** 500 and the final price 1000** is the price slippage and now the price of token B is** 10000/5 = 2000**.

As the size of the trade in proportion to the pool size increases bigger will be the price slippage and more the price of the token bought will increase in the pool and this problem of price slippage occurs in all those AMMs which are of the type CPMM or CMMM. Balancer is another example for the same.

Now since the price of stablecoins have to be stable trading them on exchanges like balancer or Uniswap leads to the deviation of price from their pegged value(which is mostly the price at which they are traded in the reference market i.e. centralized exchanges).

This deviation would give rise to arbitrage, a phenomenon discussed before in the balancer blog, which would incur impermanent loss to the liquidity providers. So now there are two problems at hand : Price slippage and Impermanent loss due to arbitrage and both of these problems arise because of the type of AMM used.

Potential solutions to the problems would be to increase the trading fees which would reduce the possibility of arbitrage because the profit earned by arbitrageurs if the difference in price of the same asset in two different markets minus the trading fees, so increase the trading fees would naturally reduce the arbitrage and hence the impermanent loss and also high trading fees means more profits for liquidity providers. But the problem with this approach is that when the trading fees is increased to shoo away the arbitrageurs you are also simultaneously making trading activity on the exchange unattractive because of high trading fees. Another solution would be to have an AMM which incurs zero to little price slippage and keeps the price of both the assets in the pool relatively stable.

But this seemingly perfect approach has a seemingly obvious inherent problem and the problem is that because of this constant sum formula there is a chance that the no. of tokens of one of the asset shoot to zero which was impossible in a CPMM like Uniswap or Balancer because as the reserve would approach to zero the price will shoot to infinity. But in a CSMM suppose if the market price of one of the stablecoin is different from the exchange then the arbitrageurs will keep flushing one of the assets out of the pool and since the price on a CSMM is always constant it won’t become equal to the market price, unlike a CPMM, no matter how much trading activity occur and finally the ultimate result would be that one of the assets is completely depleted and the pool isn’t of any use anymore.

So the need is to find a middle ground between CSMM and CPMM, a weighted average of both, an AMM which can keep shifting between the two types according to circumstances and that’s precisely what Curve has implemented.

The AMM that Curve uses is essentially a weighted average of CSMM and CPMM and in simple terms can be expressed as

Now ideally we wouldn’t want f to be a constant because we would like our AMM to behave more like CSMM when both the stablecoin tokens are in sufficient amount and like CPMM when the balance of one of the tokens is running to zero. Now how this f is dynamically varied, to get an idea I would personally advise reading DeFi Primer April 2021 by Vijay Mohan where the concept is beautifully explained instead of the whitepaper of the Curve where I feel it hasn’t been elaborated that well.

So to conclude, Curve, also popularly known as “Uniswap for Stablecoins” is the best in the business when it comes to stablecoins, with its unique kind of AMM it makes sure that it takes care of several challenges faced by exchanges like Uniswap or Balancer in terms of stablecoins and thus making trading for this emerging and promising type of currency more attractive and lucrative both for traders and liquidity providers by mitigating issues like price slippage, arbitrage and also trading fees(0.04% only vs 0.3% of Uniswap V2).

**References**

*Defi Primer 2021 by Vijay Mohan**Curve Whitepaper**Coinmonks*