# 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;


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://impossible.gitbook.io/impossible-finance-faq/impossible-swap/swap-math.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
