# Swap

## <mark style="color:blue;">Overview</mark>

Elys Network’s **Swap feature** allows users to exchange tokens seamlessly and with **minimal slippage**, facilitated by its [<mark style="color:blue;">Smart-shielded</mark>](earn/liquidity-mining) pools.

You just have to choose the currencies you’d like to swap, enter the amount you want to swap, and proceed by clicking on **Receive USDC (in this example)**.

<figure><img src="https://723411151-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FYSf8pZaRovewz0yJFl0a%2Fuploads%2FKwGaGzbikUAtZGKluHtW%2Fimage.png?alt=media&#x26;token=be28f937-7d93-4656-b2ad-287ffbaea2b1" alt=""><figcaption></figcaption></figure>

## <mark style="color:blue;">**How It Works**</mark>

In the unseen part of our swap function lies our liquidity pools, the engine that enables users to exchange their tokens independently and automatically.

These pools are characterized by:

* **Oracle-Powered Pricing**: Real-time oracles adjust pool weights to reflect accurate market values, ensuring fair pricing and minimizing risks of slippage.
* **Efficient Liquidity Utilization**: Through dynamic weighting, liquidity is distributed in a way that optimizes price stability and reduces slippage.

We aim to provide swaps that leverage our **SmartShielded Pools** to always ensure a price with a minimum slippage.

## <mark style="color:blue;">Benefits for Users</mark>

* Minimal slippage
* Fair and accurate pricing, maintained by our oracle.

## <mark style="color:blue;">Fee Mechanism</mark>

### <mark style="color:blue;">Swap fees</mark>

Swap fees are set at 0.1%

### <mark style="color:blue;">Membership Tier Discount</mark>

Based on portfolio balance over the past 7 days, users get a discount on swap fees.

* Platinium: 30% discount
* Gold: 20% discount
* Silver: 10% discount
* Bronze: 5% discount

<figure><img src="https://723411151-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FYSf8pZaRovewz0yJFl0a%2Fuploads%2F5yuizaVPtGyN2waCJgfd%2Fimage.png?alt=media&#x26;token=7d24829a-22f3-4adb-8a94-2ba0b0e6c7fc" alt=""><figcaption></figcaption></figure>

### <mark style="color:blue;">Pool Balancing - Dynamic Fee Mechanism</mark>

Elys Smart-Shielded pools incorporate a **dynamic fee mechanism** that continuously rebalances the pool back to its target weights, represented as a Pool Balance Reward (for bringing a pool closer to target weight) or a Pool Balance Fee (for taking a pool further away from target weight).&#x20;

This mechanism ensures that asset weights remain close to their target values, facilitating efficient trading and liquidity provision. Generally speaking, the target weight for a pool is 50:50.

### <mark style="color:blue;">Fee Calculation Formula</mark>

The Pool Balance F ees are determined by the following formula:

`Dynamic weight fees = 0.05% * (W1 / W2) ^ 2.5`

Where W1 is the weight of the asset being traded into, and W2 is the weight of the asset being traded out of.

### <mark style="color:blue;">Example</mark>

For example, let's assume that **token A is BTC** and **token B is USDC**.&#x20;

If the balance between A and B follows this trend in percentage represented in the pool: 50:50, 55:45, 60:40, 65:35, 70:30, 75:25, 80:20, 85:15, 90:10, 95:05

#### **To swap BTC (Token A) to USDC (Token B) for each scenario :**&#x20;

<figure><img src="https://723411151-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FYSf8pZaRovewz0yJFl0a%2Fuploads%2FBUYLdBbDD8mfPFWwnZmv%2F1.png?alt=media&#x26;token=62ad29ef-a1ca-45ac-9044-b9ba18c70b40" alt=""><figcaption><p>Pool Balance Fee Chart A/B</p></figcaption></figure>

#### **To swap USDC (Token B) to BTC (Token A) for each scenario :**&#x20;

<figure><img src="https://723411151-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FYSf8pZaRovewz0yJFl0a%2Fuploads%2F7YFwlz29bjKVxY2jSlJ6%2F2.png?alt=media&#x26;token=21420ad5-b1b6-45b0-be01-0f75c79a6d2e" alt=""><figcaption><p>Pool Balance Fee Chart B/A</p></figcaption></figure>

#### **Table summarizing all the scenario :**

| Token A / Token B Weight | Swap Token A to Token B | Swap Token B to Token A |
| ------------------------ | ----------------------- | ----------------------- |
| 50% / 50%                | 0.05%                   | 0.05000%                |
| 55% / 45%                | 0.08%                   | 0.03028%                |
| 60% / 40%                | 0.14%                   | 0.01814%                |
| 65% / 35%                | 0.24%                   | 0.01064%                |
| 70% / 30%                | 0.42%                   | 0.00601%                |
| 75% / 25%                | 0.78%                   | 0.00321%                |
| 80% / 20%                | 1.60%                   | 0.00156%                |
| 85% / 15%                | 3.82%                   | 0.00065%                |
| 90% / 10%                | 12.15%                  | 0.00021%                |
| 95% / 5%                 | 78.68%                  | 0.00003%                |

When a swap or a liquidity provider improves the weight and brings it closer to the target, both the swap fee and Pool Balance Fee are reduced to 0, along with an added incentive bonus (Pool Balance Reward).
