StableSwap Invariant Market Maker (SIMM)

Pact offers the option of StableSwap liquidity pools, which leverage a more efficient mechanism optimised for swaps of pegged (or semi-pegged) assets (like ALGO/gALGO) and stablecoins.

Why StableSwap?

Why StableSwap? Stablecoins have proliferated and grown as decentralised finance (DeFi) has exploded since mid-2020. This has been reflected in total size, market capitalization, and variety. There now exist many popular cross-chain stablecoins, including USDT and USDC, as well as several emerging Algorand native stablecoins like XUSD, GARD, goUSD and STBL.

More recently, we have witnessed the rise in popularity of other pegged (and semi-pegged) assets like gALGO, a liquid staked Algo token which earns governance rewards. gALGO can be transferred freely, used as collateral, provided as liquidity in AMM pools, or held to passively accumulate Algorand Governance Rewards.

A common problem when swapping tokens via standard Automated Market Makers (AMM) mechanisms that utilise the Constant Product Function is that trades between one pegged asset to another are seldom as efficient as they could be. With Pact StableSwap:

  • Traders can swap between these pegged assets, solving for minimal possible slippage and price impact.

  • Liquidity providers can use StableSwap pools without the risks associated with impermanent loss, which could lead to benefits resulting from deeper liquidity, higher volumes, and an overall larger pool of fees.

How does StableSwap work?

AMM Mechanisms and Efficiencies

To understand AMM efficiency considerations, we can compare the mathematics between the below mechanics. Remember, a liquidity pool is simply a smart contract that holds reserves of two tokens and allows anyone to deposit and withdraw funds from them, but only according to particular rules:

Constant Product Market Maker (CPMM, as pioneered by Uniswap v2 AMM)

One such rule is the constant product formula x * y = k, where x and y are the reserves of two tokens, A and B. To withdraw some amount of token A, one must deposit a proportional amount of token B to maintain the constant k, before fees. This means that the price of token A is proportional to y / x, or the reserve of token B divided by the reserve of token A. The pool is self-regulating and automatically adjusts itself, making it expensive to bring it out of balance.

Constant Sum Market Maker (CSMM, also known as Linear Invariant)

To contrast, another rule is the constant sum formula x + y = k. In this case, to withdraw some amount of token A, one must deposit the same amount of token B to keep the sum constant. This means that the price of token A will remain constant with zero slippage. However, this is not ideal because the pool can run out of tokens or become significantly unbalanced.

Combining the best of both worlds

Popularised by Michael Egorov’s, a StableSwap algorithm is optimised by combining the two primitive mechanics above to find the “best of both worlds”. The algorithm's invariant combines the constant product and constant sum formulas. The algorithm consists of an Amplifier (A) variable used to set the 'hump' of the curve: the more significant the amplifier, the more it looks like a constant sum (more efficient) and vice-versa.

Pact’s implementation further optimises the algorithm for precision on the Algorand blockchain. In designing the implementation, StableSwap minimises the number of operations on the Algorand Virtual Machine (AVM) to reduce overall complexity. In addition, simulations of our implementation approach proved that swaps in healthy pools with deep liquidity can be efficiently achieved with minimal computing (no more than five iterations of Newton’s method) and that the algorithm also scales for unbalanced pools.

Pool parameters

Each StableSwap pool is configured with the following parameters:

Fee: 0.04% by default

Amplifier* to be determined by the Pact team

For exceptional cases only, please contact the Pact core team on Discord to request changes to pool parameters.

*Note: The amplifier is an input parameter to the StableSwap algorithm. The Pact team will aim to optimise the amplifier parameter to minimise slippage based on expected liquidity levels and usage patterns.

User interface

For traders, any trades between stablecoins will be seamlessly and automatically routed by default. Smart Router will calculate the most efficient route to fulfil the trade and will route it to the stableswap pool if applicable.

Last updated