*Note: This article is not financial advice. Hubble Protocol does not endorse any of the tokens or platforms mentioned in this article.*

### Key Takeaways

- Stable swap AMMs increase the capital efficiency of swapping stable assets, like stablecoins and pegged derivatives.
- Capital efficiency is increased using a different invariant from other AMMs.
- Adjusting the A-Factor of a stable swap can affect the rate at which slippage occurs for swapping two assets.

The stable swap is a kind of automated market maker (AMM) dedicated to swapping tokens with stable values. Its goal is to facilitate swaps as efficiently as possible and allow users to trade stablecoins with minimal loss.

Although stable swaps seem like a simple enough concept, they're actually quite complex under the hood. Although complex, their efficiency has made stable swaps one of the most important tools in decentralized finance (DeFi) today.

This article will look at how stable swaps function. As a special focus, the A-Factor (also known as A parameter or A param) will receive extra attention as an important part of how stable swaps work.

## From *x*y=k* To an Invariant That Doesn't Fit in a Subheading

The invention of the automated market maker (AMM) was a game-changer for DeFi. AMMs gave users the opportunity to swap tokens at any time, and they could do so without having to wait for a counterparty to pick up a bid or an ask.

The AMM was first mentioned in a Reddit post by Vitalik Buterin six years ago, and by early 2018, the idea had been further fleshed out with input from Martin Köppelmann, Co-Founder of Gnosis. Buterin wrote:

The idea is that you have a contract that holds x coins of token A and y coins of token B, and always maintains the invariant that x∗y=k for some constant k . Anyone can buy or sell coins by essentially shifting the market maker’s position on the x∗y=k curve; if they shift the point to the right, then the amount by which they move it right is the amount of token A they have to put in, and the amount by which they shift the point down corresponds to how much of token B they get out.

The launch of Uniswap in November of 2018 put the invariant *x*y=k* to work, and the curve it described has since facilitated millions of trades.

The deployment of *x*y=k* made AMMs a useful tool for price discovery, since moving away from the apex of the curve in either direction would affect the price of each asset. However, this price curve made it difficult to swap stablecoins, which should theoretically be swapped without affecting each other's price.

When a swap moves along the curve described by *x*y=k*, slippage can occur, meaning that fewer tokens are received than expected due to a change in price that happens as the swap is executed.

When it comes to swapping stablecoins, the effects of *x*y=k*'s price discovery are especially less than desirable.

## Curve Introduced a Revolutionary New Variant

A year after the launch of Uniswap, Curve's whitepaper appeared, detailing an invariant for swapping tokens with a stable price.

As can be seen, this invariant is a bit more complicated than *x*y=k*, and* *its added complexity allows for various parameters to be changed in order to deliver more optimal swaps for users.

In order for an AMM to facilitate swaps without affecting the price of either token, it needs to complete the swap at the apex of the price curve. Additionally, liquidity (how many tokens are available for swapping) affects how quickly a swap moves along the price curve.

With the stable swap invariant, the curve is flattened, creating a range where prices remain constant. This flattened curve allows for swaps to occur with minimal slippage, even as larger trades affect a token's liquidity.

## The Effect of the Amplification Parameter or A-Factor

The A at the beginning of the stable swap invariant plays a huge role in how flattened the curve will be. This A stands for the "amplification parameter," otherwise known as the A-Factor, A parameter, or "A param."

If the A-Factor is set to zero, then the curve describes a similar path as *x*y=k*, and slippage increases. The illustration below graphs the stable swap invariant with the A-Factor set to zero. Notice the green line:

The higher the A-Factor is set, the more flattened the curve becomes. Notice how the green line's curve has begun to flatten when the A-Factor is set to 10:

When the A-Factor is increased even further, then the curve flattens accordingly. Here is an A-Factor set to 250:

A higher A-Factor can allow for larger quantities of tokens to be swapped with minimal slippage. On the other hand, a higher A-Factor can also wreak havoc on liquidity if one token doesn't hold its peg.

For example, once upon a time, the A-Factor was set to 2,000 on a Curve pool that held DAI. When DAI rose above its peg, the DAI in the pool was automatically reduced to 2-3% of the pool volume.

Setting the A-Factor correctly can take some trial and error. Curve deployed many tests trying to find the "sweet spot" for setting the A-Factor, and their results showed that:

In the case of 3pool, raising A generally increases profits with few directly observable negative side effects. Raising A to even quite high values (>1000) did not radically reduce the pool’s balance or generate additional susceptibility to slippage. Also, interestingly, increasing A reduced volatility in the pool’s value (in USD), presumably because larger arbitrage trades offset volatility produced by short-term variability in individual coin prices.

Curve goes on to report that these results do not take into account the risks of imbalancing a pool due to a high A-Factor, and the pool being studied is one with some of the deepest liquidity in all of DeFi, so results may be skewed.

## The Allure of Stable Swaps Against the Complexity of Parameters

The A-Factor isn't the only part of a stable swap AMM that can be tweaked to change the outcome of a swap (and its effect on attracting users). There are a host of parameters that can be adjusted on an AMM like Curve these days.

Getting these parameters within optimal ranges is a large undertaking. Being able to swap large quantities of stablecoins with minimal slippage is a major draw for institutional users as well as retail users in DeFi.

The multi-chain landscape these days seems to demand highly efficient swaps between stable assets, since many bridges do not port over assets that can be used natively on a target chain. No one wants to incur capital inefficiencies when switching chains, so stable swaps are becoming even more important as the DeFi ecosystem expands.

In addition to increasing the efficiency of stablecoin swaps, much of the DeFi community uses Curve like a savings account. Hubble's next piece on stablecoins will look at the "savings account" phenomenon that has made Curve a protocol that now holds tens of billions in TVL due to stablecoin liquidity.

**Keep in Touch**