> For the complete documentation index, see [llms.txt](https://impossible.gitbook.io/impossible-finance-faq/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://impossible.gitbook.io/impossible-finance-faq/impossible-swap/swap-math.md).

# Swap Math

If you have not checked out our intro article on medium, [please start here](https://medium.com/impossiblefinance/the-impossible-v2-swap-4441b054ad17)

Our swap upgrade introduces two novel features:&#x20;

1. The xybk invariant
2. Asymmetrical tuning

## **New Invariant: xybk**

Our novel invariant, the xybk model, allows stablecoin swaps to be performed more efficiently through artificially inflating the TVL in pools by a multiple of b times. The invariant is as below:

![The xybk invariant. When b=1, this simplifies to Uniswap's x \* y = k](/files/-Mf9NVZktyjM-ZpXjX4G)

**Invariant Behavior**

In our medium article, we mentioned the simple example of a pool with *x*=token*0balance=100*, *y*=*token1balance=100*, *boost=10.* This pool has underlying assets of *(100, 100)* but **exhibits the same swap slippage as a&#x20;*****(1000, 1000)*****&#x20;v2 uniswap pool. This means swaps in both pools have the same slippage and will require the exact same amount of input to get the same output.**

For more complicated cases when the balances in the pool are not equal, we use a formula to calculate the K value for the pool. The value of K is bounded by the geometric mean sqrt(x\*y) when b = 1 (the uniswap invariant) to the arithmetic mean (x+y)/2 when b = infinity. Since (x+y)/2 > sqrt(x\*y) when x != y, the value of K in practice in an xybk pool will be greater than a uniswap pool with equivalent balances. We use the following formula, derived from rearranging the xybk equation, to compute the K value from the token balances in the pool (x, y):

![](/files/-Mf9T02oUWmA207mfl6V)

**Price Behavior**

Artificial token balances in the pool ranges from:

![](/files/-Mf9TwRKwV2u_U2CS-sj)

Since token prices in pools are calculated as a ratio of token balances, this means prices ranges from:

![Note: Price bounds purely depends on the pool boosts which is neat](/files/-Mf9UWHgQr4BoSHEkovI)

## New concept: Asymmetrical tuning

Asymmetrical tuning is a novel concept in the swap space.&#x20;
