Minswap Stableswap Part 1: introduction to Stableswaps and Cardano Stablecoins
TLDR: this article written in collaboration with Cardano Spot and part of the Stableswap Education campaign delves into the problems that Stableswaps solve. It also describes the current Stablecoins on Cardano, demonstrating how the Minswap Stableswap will strongly benefit Cardano DeFi.
Exchanges form the bedrock of any financial stack and are crucial to the efficient flow of value. Decentralized Exchanges (DEXs) take the functionality of an exchange and add to it properties of censorship resistance, decentralization, permissionless nature, and security by allowing the trading of tokens without any intermediaries.
In Traditional Finance, Order Books are commonly used for trading. A vital drawback is that they require matching buyers and sellers. In a market with low liquidity and volume, they depend highly on specialized market makers or suffer from high wait times. Automated Market Makers introduce a Liquidity Pool concept, allowing users to add assets to a Smart Contract against which traders can trade. This turns holders into passive market makers, allowing communities and projects to bootstrap markets in a permissionless way.
Liquidity Pools don’t necessarily require providers to set prices like order books; these prices are found internally based on an algorithm. Automated Market Makers (AMMs) have an algorithm to find prices to quote to traders and discover prices internally. There are various types, the most famous being the Constant Product Market Maker (CPMM) formula popularized by Uniswap and used by Minswap V1. It follows the equation: x * y = k, where x represents the amount of one asset in the Liquidity Pool, y represents the amount of the other asset, and k is a constant value.
Due to the fact that CPMMs provide a price for the entire price curve, they are not ideal for the trading of stable pairs (i.e. where both assets are similar in price, mostly pegged to an external asset like BTC or USD), since these are always supposed to be pegged to a certain other asset and shouldn’t vary much from it. The lack of liquidity concentration in CPMMs results in higher Slippage (the impact of a trade against the pool causes the price to deviate from the stable price) and the price curve creates high Impermanent Loss (IL) for stable assets. This is why stablecoins require a different algorithm.
Below, we delve deeper into Stableswaps, Cardano Stablecoins and the Minswap Stableswap. This will give us the information needed to understand why the Minswap open-source Aiken Stableswap is so essential for Cardano DeFi and how it will make on-chain trading of stable assets on Cardano more efficient.
Curve Finance introduced a new algorithm known as the Stableswap Invariant. To understand it, one must first understand another concept: Constant Sum Market Makers (CSMM). They work on the simple formula of x + y = C. This results in all liquidity being concentrated around the 1:1 price, which makes them much more efficient for stable assets.
Here are the Key Benefits of the CSMM:
- Low impermanent Loss: Assets don’t imbalance, resulting in less Impermanent Loss. IL occurs when the original ratios of the assets deposited in a Liquidity Pool change, and the total value of the assets held by the user in the pool are less than compared to what they would be had they been simply held. However, this could lead to a scenario where there is no liquidity for one of the pairs. That is why you need a mechanism to counteract this.
- High Capital Efficiency: The concentration in the Liquidity Pool allows the use of all liquidity.
- Low Fees: Due to the lack of IL and high efficiency, low fees are required from traders (generally 0.04% vs. 0.3% for other asset pairs).
- Low Slippage: Traders can trade one stablecoin to another with low slippage.
- High Liquidity: Stablecoins are reliable assets and are highly used in DeFi. They have much higher liquidity compared to most pairs in crypto.
2.1 Stableswap Invariant
The Stableswap Invariant combines CPMM and CSMM. It allows the curve to be flat around the middle, but also to adjust quickly to be more like a CPMM. Concentrated liquidity with 1:1 trade in the middle, but as soon as you deviate high, it will act more like a CPMM. This offers good liquidity with guardrails around a depeg.
The CSMM invariant has the benefit of keeping a constant price regardless of how many of each of the underlying tokens are in the liquidity pool (the pool can be unbalanced and still keep a constant price). The downside of CSMM is it can literally run out of liquidity and be left with only 1 token in the pool. The CPMM invariant has the opposite problem. It will never run out of tokens as it is forced to keep a 50/50 value split between the tokens. However, the CPMM always has a volatile price and can have very high slippage for traders.
The Stableswap Invariant combines both the CSMM and CPMM into 1 invariant, with a small twist. The reason one can’t just combine the 2 together and see the magic is due to the fact the CPMM overwhelms the CSMM. One ends up with something that looks very similar to the CPMM by itself.
There is a need to ‘amplify’ the effects of the CSMM in the Stableswap, and that is done through the Amplification Parameter (amp). A high amp allows one to create a Stableswap pool that has a constant price across very imbalanced liquidity (imagine something like 90% of the liquidity pool in 1 token, but you can still swap in the 90% token for the 10% token close to 1 to 1). A low amp does the opposite, the price deviates from 1 quicker (it could deviate from 1 well below being 90% in 1 token). The trade-off of a high amp is that even though it stays close to 1 at extreme liquidity imbalances, when that imbalance reaches its threshold, it breaks the peg really quickly.
The closer the amp is to 0, the closer the Stableswap acts like a CPMM. The image below shows 4 curves, the CSMM in purple, the CPMM in green, a Stableswap with an amp of 0.1 (blue), and a Stableswap with an amp of 10 (red). You can see going from 0.1 to 10 amp makes the Stableswap react much closer to the CSMM function.
Amp is extremely important, and should be parameterized specifically for each Liquidity Pool. Each token in a Liquidity Pool will exhibit unique characteristics given their different peg stability mechanisms and collateralization to the underlying asset. The depth of liquidity is just as important. The deeper the Liquidity Pool, the more trades can happen with lower slippage and better price execution. If the amp is set too high and the liquidity is too low, you could see massive volatility beyond that of a CPMM! Curve solved this issue by allowing their amp factor to evolve through ‘ramping’. This allows the amp to slowly (or quickly) change over time from a starting amp to an ending amp. This is something Minswap will heavily consider using as we build out more and more Stableswap pools.
2.2 Why do we need Stableswaps?
Here are several of the reasons why Stableswaps are needed:
- Efficient Trading — Stableswaps solve a major problem in DeFi — routing. Assets are generally fragmented under base pairs like BTC, ADA, USDC, or USDT. Stableswaps allow efficient routing and address fragmentation inside the market. This enhances the overall efficiency of the market.
- Peg Stability — Another important aspect is that it provides a venue to arbitrage between various stablecoins and tightly peg them. Stablecoins on Cardano, like iUSD or DJED, have been off their $1 peg for months! With incentivized liquidity on Stableswaps, this could bring these coins back to their peg.
- Yield Farming — Stableswap pools have low Slippage and low Impermanent Loss. This gives users one of the best risk/reward ratios to earn yield in crypto, as stablecoins have no price risk.
- Novel Applications — Synthetic protocols are heavy users of stablecoins and Stableswaps. Synthetic protocols like Synthetix allow slippage-free swaps between stable and volatile pairs. A synthetic trading protocol would allow USD to ADA by converting USD to SUSD to SADA to ADA. This requires two stable asset swaps, USD to SUSD and ADA and SADA; this form of trading can still be more efficient since stableswaps just charge approximately 0.04% fees compared to 0.3% for normal AMMs.
In conclusion, Stableswaps improve the overall efficiency of the ecosystem while providing stability and liquidity for stablecoins. Retail users, whales, and even institutional players love them all over crypto.
3. Stablecoins on Cardano
Stablecoins are known as crypto’s “Killer App” due to their significant adoption and widespread application. They are widely used for payments, DeFi, trading, and storing wealth. The stablecoin market cap has witnessed remarkable growth, surging from a modest $10 billion to a staggering $125 billion within the last two years.
Stablecoins differ based on the underlying collateral and their price stability mechanism. Cardano has 3 main types of stablecoins on its mainnet as of October 2023: iUSD by Indigo, DJED by Coti and wrapped stablecoins by Wanchain. Let’s look into how they work:
iUSD is a synthetic USD from Indigo Protocol where users can deposit $ADA in order to issue it. Once $ADA is deposited in a vault, the protocol utilizes an oracle to determine the dollar value of the collateral. The iUSD can be minted based on the permitted loan-to-value, currently at 83%.
For example, you deposit 1000 ADA:
Step 1: Indigo determines that 1000 Ada = $250
Step 2: Mint up to 80% of LTV -> $200 iUSD
If your collateral falls under the minimum collateral required, the vaults can be liquidated with a liquidation penalty. If you want to repay the loan, you can receive your $ADA back by burning the iUSD. Indigo uses a Stability Pool that allows immediate liquidation of iAssets. The Indigo community pools their iAssets in the Stability Pool, assuring a buyback when the price of $ADA falls below the liquidation threshold. In return, these users receive $INDY rewards and rewards from the liquidation penalties.
These vaults are overcollateralized, so users must deposit more $ADA than USD they can mint. This assures that the coins can always be redeemed for $1. However, this acts as a soft peg, and the value could fluctuate above or below due to market conditions. We have observed this with iUSD, which has remained off-peg for months.
iUSD is highly concentrated, with ~75% of the supply owned by the top 25 users. It is mainly used across its Stability Pool and Liqwid Finance to earn a yield on these assets.
DJED relies on algorithmic design to maintain the stability of its peg. It’s the first formally verified, crypto-backed, overcollateralized stablecoin. It can maintain its price stability by using a Smart Contract that continuously buys and sells DJED. Users can deposit $1 worth of ADA and mint $1 worth of DJED. To keep the price stable under any volatility, DJED requires a reserve known as SHEN.
DJED doesn’t have liquidations like iUSD, but this means it requires a high collateral target of 400%-800% instead of 110% for iUSD. This means that for every dollar to be minted, DJED requires 4–8x collateral which is hard to achieve. However, its unique liquidation-free design can be appealing to ADA holders who want to earn passive rewards.
DJED cannot be minted when collateralization is below 400%. This means that the effective peg is something like 0.99$ to infinity. Meanwhile the effective iUSD peg is 0$–1.2$ (since iUSD redemptions are not possible).
3.3 Wanchain bridged Stablecoins
Wanchain, according to their website, is a decentralised, non-custodial, bi-directional cross-chain bridge. Wanchain recently launched its Cardano Bridges to enable greater interoperability between networks and offer a huge influx of new assets and liquidity. Wanchain’s Cardano Bridges enable numerous assets including USDC, USDT and DAI.
Bridged assets have received plenty of criticism after the recent hacks such as Nomad. However, proponents of these wrapped stablecoins argue that current Cardano stablecoins are closed loop stablecoins that exist only in Cardano with low liquidity and poor peg mechanisms and without any fiat offramps. Bridged assets enable open loop stablecoins with orders of magnitude more liquidity, stronger pegs and ones that users can exit directly to their bank account within a two step process (bridge back to a chain Wanchain supports and then send funds to centralized exchange of choice from said chain).
Despite bridge risk, observing the data makes it clear that there is strong demand for this. This is the data from Liqwid (one of the largest lendign protocols on Cardano):
4. Minswap Stableswap
Stablecoins are currently behind as far as adoption in Cardano is concerned with low TVL and usage. In order to build more sustainable use cases, liquidity and utility of these stablecoins must improve. Stableswaps play a major role in improving this usage in trading.
The Minswap Stableswap has the following aims:
- Increased DeFi usage: Cardano will become a more attractive ecosystem for users looking to trade and obtain yield on their stable assets in an efficient manner.
- Higher Liquidity across the ecosystem: stablecoins are essential for many DeFi participants. An efficient, open sourced Stableswap will give DeFi participants a high assurance and more incentives to provide stable assets as liquidity.
- Minimal Slippage on trading Stablecoins: the Stableswap Invariant has been proven to be the most efficient model for a DEX to enable stable asset trading with minimal slippage.
- Open Source Stableswap: there is currently no open source Stableswap on Cardano. Open sourcing a major DeFi Smart Contract based on Aiken and audited by TxPipe (which developed the Aiken language) will majorly benefit the Cardano developer community. It will provide an example of what a productionized DeFi contract looks like built on Aiken.