# What is LST Stable Swap?

## Overview

Bifrost Stable Pool is designed to facilitate related exchanges between vToken and Token that are expected to have similar values, such as vDOT-DOT, vETH-ETH, vKSM-KSM, etc. The Bifrost Stable Pool uses [Stable Math](#invariant) (based on StableSwap, widely promoted by Curve), which allows for large-scale exchanges to take place before encountering significant price impact, greatly improving the capital efficiency of vToken-Token exchanges.

### Why Bifrost Stable Swap is unique?

As vToken is a yield-bearing token, its value will gradually increase over time compared to the corresponding Token value. Therefore, the liquidity supply anchor of vToken and Token in AMM should change with the vToken exchange rate to avoid loss for liquidity providers. The following is a comparison between pegged stable swap and correllated stable swap.

* Pegged Stable Swap

Tokens that swap near 1:1, such as two stablecoins of the same currency

* <mark style="color:purple;">**Correllated stable swap**</mark>

Tokens that swap near 1: ***R*** with some slowly changing exchange rate ***R***, like vToken (eg: vDOT, DOT)

### Liquidity Efficiency Statement

In Stableswap, the size of function A determines the range of stable exchange rates supported in the Stable Curve. The larger the A value, the more liquidity is available to support constant prices. Conversely, the smaller the A value, the less liquidity is available to support constant prices. For mathematical details about the A value, please refer to Invariant.

<figure><img src="https://757947912-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FJFtVsA5N3spWTWKvFvv0%2Fuploads%2FJp5vmbZaSSfRIPHhbrX0%2Fimage.png?alt=media&#x26;token=7393c230-d48c-4a56-b04f-017b80ca876d" alt=""><figcaption><p>Stable Curve Coefficient: from Understanding Stable Swap (Curve)</p></figcaption></figure>

<figure><img src="https://757947912-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FJFtVsA5N3spWTWKvFvv0%2Fuploads%2FJQtpQ50nzxQtSfpXAP2k%2Fimage.png?alt=media&#x26;token=c0ce8f81-f394-4d36-bc2e-1223e2bc9b27" alt=""><figcaption><p>Bifrost Stable Swap</p></figcaption></figure>

To facilitate user understanding, we express the value of ***A*** in Stable Swap as an improvement in liquidity efficiency compared to Uniswap V2.

As shown in the above figure, **100 times** liquidity efficiency means:

> *"Exchanging 100 BNC in the stable pool with the same liquidity is equivalent to exchanging 1 BNC in the Uniswap V2 pool."*

***

Let's take an example. Suppose a liquidity pool has the following liquidity (assuming the exchange rate between vDOT and DOT is 1:1):

| vDOT | 501.1872 |
| ---- | -------- |
| DOT  | 501.1872 |

When a user exchanges 100 vDOT for DOT, the following results will be presented:

#### Uniswap V2

| Input         | 100 vDOT    |
| ------------- | ----------- |
| Output        | 90.8539 DOT |
| Swapped Price | 0.90854     |
| Slippage      | 9.146%      |

#### <mark style="color:purple;">Bifrost Stable Pool (with</mark> <mark style="color:purple;"></mark>*<mark style="color:purple;">A</mark>* <mark style="color:purple;"></mark><mark style="color:purple;">coefficient 5,000)</mark>

| Input         | 100 vDOT    |   |
| ------------- | ----------- | - |
| Output        | 99.9958 DOT |   |
| Swapped Price | 0.99996     |   |
| Slippage      | 0.004%      |   |

#### **Conclusion**

| Input         | 100 vDOT                                                         |
| ------------- | ---------------------------------------------------------------- |
| Output        | 90.8539 DOT ⇒ <mark style="color:purple;">**99.9958 DOT**</mark> |
| Swapped Price | 0.90854 ⇒ <mark style="color:purple;">**0.99996**</mark>         |
| Slippage      | 9.146% ⇒ <mark style="color:purple;">**0.004%**</mark>           |

### **Invariant**

Since the Stable Math equation is quite complex, determining the invariant, ***D*** is typically done iteratively. For an example of how to do this, please refer to: <https://miguelmota.com/blog/understanding-stableswap-curve/>

<figure><img src="https://757947912-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FJFtVsA5N3spWTWKvFvv0%2Fuploads%2FsnRT5CqZq6r9QO3wLj25%2Fimage.png?alt=media&#x26;token=ddc4fd77-54e3-4b17-9727-b47b3466b79f" alt=""><figcaption><p>Curve's StableSwap Invariant</p></figcaption></figure>

This invariant has the following properties:

* When the token prices are closed to equilibrium(1 to 1), it’s performing close to a constant sum curve;
* When the token prices are shifted away from the equilibrium, it’s performing close to a constant product curve.
* The further the token prices are shifted away, the more slippage the invariant produces. This ensures that the pool can always provide liquidity even at extreme prices.

<figure><img src="https://757947912-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FJFtVsA5N3spWTWKvFvv0%2Fuploads%2FV0ZO6poWHDFwxpdKYotL%2Fimage.png?alt=media&#x26;token=c3a675de-6cd5-4600-8f4e-a144d79e19a1" alt=""><figcaption><p>StableSwap's Curve, from StableSwap whitepaper</p></figcaption></figure>

## How to Swap

#### Basic Swap

1. Enter [bifrost.app](https://bifrost.app) and click "**Swap**" on the left main navigation menu to enter the swap page
2. Switch the token to the desired token through the token dropdown menu on the token name

<figure><img src="https://757947912-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FJFtVsA5N3spWTWKvFvv0%2Fuploads%2FWd0YZO3lEg7u9vEYPLKs%2FCapture%20d%E2%80%99e%CC%81cran%202024-01-01%20a%CC%80%2011.31.26.png?alt=media&#x26;token=305f81bc-e7b0-4bb5-952e-be84e65ae453" alt=""><figcaption><p>Swap page</p></figcaption></figure>

3. Enter the number of tokens that need to be swapped, and verify the output of the transaction (price impact).
4. Click the "**Swap**" button to confirm the transaction and complete the signature


---

# 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://docs.bifrost.io/faq/what-is-lst-stable-swap.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.
