Minswap Stableswap Part 2: setting amp and Pool strategy
Introduction
The Minswap Stableswap is coming next week! After a successful Bug Bounty period (you can see the result here), and open sourcing all the code and the audit report, we are now ready for deployment. But before that, we want to publish a research piece covering some important decision making around the Stableswap launch. First, regarding how to set the amp parameter on the Liquidity Pools, and secondly the strategy around which Pools are to be seeded and incentivized.
This post is a continuation of the previous article: Minswap Stableswap Part 1: introduction to Stableswaps and Cardano Stablecoins. As a reminder, the Stableswap Invariant combines both the Constant Sum Market Maker (CSMM) and Constant Product Market Maker (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). We will spend a large part of time in this paper learning about the effects of a changing amp on simulated pools and back tested pools.
We would like to thank community volunteer and DeFi maven Marco for authoring the vast majority of this article and conducting all the research and financial modeling work. Minswap would not be where it’s at if it weren’t for community members like Marco.
The Importance of amp
To determine how to set the amp parameter, we had to conduct extensive research first. For this, we decided to start analyzing the effects of the amp by simulating a bunch of different examples, views and surfaces of different simulated stableswap pools in different states over time. All simulations start with 100,000 of token X and 100,000 of token Y, with variable amplification factors (amps). We ignored fees for the time being, especially given that many stable swap pools charge extremely small fees.
The first thing we looked at, which is also the most complicated, was a view of what a stable swap pool would look like with different amps versus the ratio of tokens y to tokens x in the pool. We also looked at this view to see what the effective price of the pool would be.
For example, when the ratio of tokens Y to X is 2.9 (like 140,000 Y to 48,300 X) and the…
- amp = 10, the effective price you could swap 1 X for is 0.871 Y.
- amp = 100, the effective price you could swap 1 X for is 0.984 Y.
- amp = 500, the effective price you could swap 1 X for is 0.9967 Y.
For example, when the ratio of tokens Y to X is 0.1 and the…
- amp = 10, the effective price you could swap 1 X for is 2.051 Y.
- amp = 100, the effective price you could swap 1 X for is 1.143 Y.
- amp = 500, the effective price you could swap 1 X for is 1.03 Y.
We can see that amp really affects the effective swap price in unbalanced pools. In the 2nd example, increasing the amp from 10 to 100 increases the ability to swap closer to 1:1 drastically even though the pool has 10 times the amount of tokens X to Y.
This confirmed our suspicion that high amps can cause extremely imbalanced pools. These pools lead to arbitrageurs draining liquidity out of the pool, leading to higher impermanent loss for LPs, all at the expense of trying to keep the price pegged. So there needs to be a balance between a good trading experience (keep the peg tight across an imbalanced pool) versus a good LP experience (less toxic flow and Impermanent Loss). This is especially prevalent during times of low liquidity in the pool, such as when the pool launches and is ramping up liquidity.
We had a feeling that we may want to ‘ramp’ the amp (Curve has a function to increase the amplification factor slowly or quickly over time) manually depending on the pool, so we wanted to view some lower amps in isolation. It is also extremely important to understand the peg mechanisms of the tokens that are in the stableswap pool, their economic rationale for staying close to a peg and how protocols allow arbitrage to get token price back to the peg when they deviate.
We looked at the effect of varying the Y to X supply of the pool on the price of Y to X you could get for a small trade in that pool. We looked at amps of both 10 and 100 to compare. The peak price of the 10 amp is above 6 when the X supply is at the lowest simulated value of 10,000 and the Y supply is at the highest simulated value of 290,000. That same peak price is roughly 2 when you increase the amp to 100.
The easiest way to look at it may be the view below. This shows the price of the pair relative to the supply ratio of the pair. You can see that the 100 amp line stays very close to 1:1 even when the pool is extremely imbalanced (like 6:1 imbalanced is still very close to 1:1 swap rate while the 10 amp pool is closer to 1.5:1). What is quite interesting about this graph is what happens at the beginning. If you look at the 10 amp line, it has a more gradual decrease from 1 towards 0. When you look at the 100 amp line, you can see the line tries to stay near to ‘1:1’ peg as much as possible, but when it drops, it drops drastically. High amp pools tend to keep their peg even when the pool is relatively unbalanced; however, once the high amp pool starts to break the peg, it breaks quickly and with force.
To summarize, all of this simulating was to tell us that amp has an extremely important effect on the price users can swap in unbalanced pools. So the question becomes, for a specific pair of assets, how unbalanced do we want to allow the pool to become while still having the assets trade 1:1?
Curve (the largest stableswap protocol on Ethereum) allows people to permissionlessly create stableswap pools, but the Curve DAO can propose and adjust the amp parameter after the fact. This becomes a slightly subjective decision that will need to be made on a case by case basis, looking at each of the tokens independently, understanding what they are pegged to, and what their peg mechanisms are. Do they have hard peg mechanisms, soft peg mechanisms, do they rely on arbitrageurs to enforce that peg, how do they enforce the peg, do they rely on 3rd party DeFi protocols to help (like AMMs)? These are all important questions that need to be asked on a case by case basis. So let’s start with the first case, DJED and iUSD.
iUSD/DJED Modeling
iUSD price, and to a lesser extent the DJED price, has been volatile relative to USD. Below is a graph, sourced from Coin Gecko’s API, showing the price of iUSD and DJED over time. There are 2 bad data points for iUSD we can ignore.
We decided to set up a fake iUSD/DJED pool and backtest different stableswap pools by simulating the trades that would occur in that pool to set the effective price of the DJED/iUSD to the Coin Gecko prices we pulled, ratio’d to each other. So this is like saying, pretend there is a DJED/iUSD stableswap pool that is arbitraged to the Coin Gecko prices. We started with a pool that had 100,000 DJED and 100,000 iUSD, with an effective price of 1 to 1. Then each day there was anywhere from 0 to 10,000 swaps of 100 units of either DJED or iUSD trying to get the relative price to within a threshold of 0.0001. There are a couple days when the algorithm didn’t converge but we can ignore those days.
First we started with an amp of 5. Below you can see the value of the pool in percentage terms. iUSD is the blue area and djed is the red area. On 1/17/24 the ratio of DJED/iUSD was 1.3322, the percent of iUSD in the pool was 71% and the percent of DJED in the pool was 29%.
Then we looked at amps of 10, 25, and 50. Here is the 50 amp. On 1/17/24 the ratio of DJED/iUSD was 1.3322, the percent of iUSD in the pool was 89% and the percent of DJED in the pool was 11%.
Then we looked at amps of 75, and 100. Here is the 100 amp. On 1/17/24 the ratio of DJED/iUSD was 1.3322, the percent of iUSD in the pool was 92.25% and the percent of DJED in the pool was 7.25%.
So we can see that even though the ratio of DJED to iUSD was 1.33 (1 DJED / 0.751 iUSD), the percentage breakdown in the pools varied from the 50%/50% many of us are familiar with in a 50/50 CPMM pool to 71%/29% — 92.25%/7.25%. And that was only an amp going up to 100. Can you imagine the 2000 amp that Curve 3pool uses!
Overall this leads us to believe that for this specific use case, a DJED/iUSD pool needs to be carefully parameterized and monitored. It would make sense to start with a low amp like 5 and ramp the amp over time as the tokens become more stable. Indigo V2 will help with the stability of iUSD (see below). We will want to adjust the amp upwards once we see more stability in this pair.
USDC/DJED Modeling
Another important asset to consider for modeling was USDC bridged from Wanchain. Wanchain bridged stablecoins have gained steady adoption on Cardano. However, their Liquidity is almost non-existent on DEXs for pairs such as USDC/ADA or USDT/ADA. This is why a Stableswap can come in handy to generate more liquidity as well as benefit from those volumes. The other stablecoin of choice would be DJED, due to the strong peg of both stablecoins since their launch.
DJED price has been volatile relative to USD for a Stablecoin, though less volatile than iUSD as seen above. Below is a graph, sourced from Coin Gecko’s API, showing the price of USDC and DJED over time. Note that this is the USDC price from Coin Gecko, not the WanChain bridged USDC price on Cardano.
We decided to set up a fake USDC/DJED pool and backtest different stableswap pools by simulating the trades that would occur in that pool to set the effective price of the DJED/USDC to the Coin Gecko prices we pulled, ratio’d to each other. So this is like saying, pretend there is a DJED/USDC stableswap pool that is arbitraged to the Coin Gecko prices. We started with a pool that had 100,000 DJED and 100,000 USDC, with an effective price of 1 to 1. Then each day there was anywhere from 0 to 10,000 swaps of 100 units of either DJED or USDC trying to get the relative price to within a threshold of 0.0001. There are a couple days when the algorithm didn’t converge but we can ignore those days
Below is a view of the asset percentages if the pool was set to 5 amp.
On 6/30/2023 when 1 DJED = 1.105 USDC, the pool had 61% in USDC and 39% in DJED
Below is a view of the asset percentages if the pool was set to 50 amp.
On 6/30/2023 when 1 DJED = 1.105 USDC, the pool had 84% in USDC and 16% in DJED.
Below is a view of the asset percentages if the pool was set to 100 amp.
On 6/30/2023 when 1 DJED = 1.105 USDC, the pool had 88.5% in USDC and 10.5% in DJED
Below is a view of the asset percentages if the pool was set to 500 amp.
On 6/30/2023 when 1 DJED = 1.105 USDC DJED, the pool had 95.5% in USDC and 5.5% in DJED
Note that this analysis on DJED / USDC makes a huge assumption that the USDC bridged from WanChain has no bridge risk premium associated with it and should trade at parity with USDC on other chains and CEXs. This is a big and unrealistic assumption. It’s quite likely that the volatility of USDC bridged to Cardano will have more volatility than the USDC on Coinbase or Ethereum.
We also conclude here that the volatilty of DJED/USDC is likely much lower than the volatilty of DJED/iUSD, so the amp on the DJED/USDC pool can be set higher, maybe up to 50–100. We would still want to start with a lower amp of something like 10 then ramp the amp as liquidity in the pool grows.
Pool Strategy
There are currently 4 main Stablecoins on Cardano, which we covered in our previous article.
- iUSD: from Indigo Protocol. Whole it has been struggling with a depeg for several months now, Indigo V2 is set to feature a series of mechanisms (such as Redemptions) aimed at addressing this issue. You can read more about it here.
- DJED: currently there is 3mn DJED circulating while 2.1mn DJED are mintable.
- Wanchain bridged Stablecoins: the liquidity on DEX is currently almost non-existent. However around 1mn USD worth of bridged USDT and USDC is deposited on Liqwid.
- USDM which was very recently launched. This is the first fiat stablecoin to come to Cardano. We hope USDM, which has been a community bootstrapped endeavor, will get significant adoption and liquidity. USDM could make a very good stable coin pair with an asset such as DJED given they both have strong pegs. However, more time is needed for USDM to start trading to be able to assess it. Marco did so recently in his USDM risk report which you can read here.
Admittedly, the Stablecoin landscape currently on Cardano is in its infant stages. However, as Waffle Capital wrote recently in their article “the introduction of stablecoins like iUSD, DJED, and upcoming projects like USDM indicates the growing interest in stablecoin offerings on Cardano”.
We expect a rather slow and steady start to the Minswap Stableswap. Only 2 Pools will be seeded with some capital and actively monitored at the start: DJED/iUSD and DJED/USDC (bridged from Wachain). Incentives will start slowly and ramp up with adoption.
Conclusion
After extensive analysis, we have come to the conclusion that Stableswap pools are powerful DeFi primitives that need to be handled and parameterized carefully. Setting too high an amp too early, when liquidity is low, could lead to even more volatile prices; while keeping the amp too low allows arbitrageurs to extract liquidity and profits from liquidity providers when in reality assets should be trading 1:1. There needs to be balance, and the ability to scale the amp as liquidity scales in the pool. The last thing we want is to deploy a power tool into Cardano’s growing DeFi ecosystem that will just be used for value extraction. We want to contribute to the growth of the ecosystem, and a well designed and parameterized stableswap pool is extremely important. Curve’s 3pool is extremely important in the Ethereum DeFi landscape as Curve itself has seen over 100bn USD in cumulative volume.
Each stableswap pool should have its own analysis run. The hard and soft pegs of each asset need to be analyzed, on top of the additional risks. A well defined and thought out stablecoin may be able to keep its peg extremely well, but a poorly designed set of smart contracts could be the flaw, not the economic logic behind the stablecoin design. A stableswap pool paired with that poorly designed smart contract coin and a separate stablecoin could easily be drained of the 2nd stablecoin in the event of a hack. This is all to say that it is not just the design of the tokens themselves, but broader risk management needs to be conducted as well when thinking through setting the amp.
Additionally, low liquidity could be the cause of massive price volatility. An amp should increase over time as the liquidity increases, hardening the peg between assets even further. Our suggestion would be for teams to reach out and collaborate on parameterizing different stableswap pools. We can work through a thoughtful path towards liquidity growth, increasing amp, and deepening the peg between stable assets.