Core Concepts

Rebasing Assets

Although ButtonSwap can handle non-rebasing pairs, its value-add comes from the way it treats rebasing assets relative to existing AMMs. Rebasing assets shift the volatility of an asset from price to supply. Token balances “rebase” and change based on predetermined rules or external factors. Rebasing assets present new opportunities for use as a unit of account (AMPL), interest-bearing asset (aTokens), or for use as staking positions (stETH).

But rebasing assets also present some challenges. One of those challenges is how rebasing events are handled in AMMs. As stated in the Uniswap docs, LPs bear the loss for negative rebases.

Liquidity Pools and LPs

Like Uniswap, ButtonSwap doesn’t use an order book to derive the price of an asset or to match buyers and sellers of tokens. Instead, it uses what is called Liquidity Pools, which allow autonomous execution in a permissionless environment.

Traders interact with the pool by calling ‘swap’,which exchanges one unique token for another. Liquidity Providers (LPs) add liquidity to pools by calling ‘deposit'. ButtonSwap relies on the constant product invariant (x * y = k),where x and y are the pool’s reserves of the two assets.

LPs receive minted LP shares for providing liquidity. Each share token represents a portion of the pool’s liquidity and trading fees generated by swaps. LPs can withdraw liquidity and redeem shares for the underlying assets at any time.

Reservoirs

In addition to having a liquidity pool for Token X (pool_x) and Token Y (pool_y) as in Uniswap v2, ButtonSwap adds two additional token balances called ‘reservoirs’ for each token (reservoir_x and reservoir_y). This allows ButtonSwap to properly deal with rebasing and value-accruing assets.

Liquidity pools are the 'active' liquidity that gives you the swap ratio between unique tokens. Reservoirs hold 'excess' tokens, that represent 'inactive' liquidity. There will always be one empty reservoir.

When there is a positive rebase, new tokens don’t immediately flow into the active liquidity pool, but instead go into the reservoirs.

After a negative rebase, the excess tokens from the reservoir are used to balance out the pool. If there is a negative rebase to token_x, and reservoir_x is empty, then tokens from pool_y are withdrawn from active liquidity, and flow to reservoir_y.

The diagram below shows how Button Swap treats rebasing assets differently than Uniswap v2. The key thing to consider is that Button Swap maintains the same marginal price (swap ratio) regardless of a positive or negative rebase:

As shown in the user guide, LPs can fully or partially balance out pools by depositing the asset with less liquidity. If reservoir_x is partially filled, LPs can mint shares by depositing Token Y. The deposits of Token Y and the equivalent amount of Token X then flow into the active pool.

The active liquidity pools dictate the swap ratio. The added reservoirs allow for:

  • ButtonSwap to learn when a rebase event has occurred

  • Swap ratio (marginal price) to be maintained despite a rebase event

  • Tokens to be preserved for LPs that otherwise would be lost to arbitrage or impermanent loss

Last updated