# How it Works

## Intro <a href="#f801" id="f801"></a>

TON DEXes have fragmented liquidity, each with its own set of liquid tokens. As the TON ecosystem grows, this uneven distribution worsens, leading to inefficient trades and arbitrage opportunities. Users often lose money due to the high price impact when swapping tokens on a single DEX.

## Problem <a href="#bf10" id="bf10"></a>

Imagine you want to swap 100 TON for a NOT token. To get the best price, you need to compare offers across different DEXes. First, you need to know which DEXes have the tokens you want to swap (new DEXes are constantly emerging, and we’ve already secured agreements to integrate them into our routing algorithms).

Let’s take a look at what the two biggest players in the market, DeDust.io and Ston.fi, offer:

<figure><img src="https://565861027-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FSD7ZvlWdfwvnrQF0DH1F%2Fuploads%2F6x3ytuXhiRZp4A7cxyKS%2Fimage.png?alt=media&#x26;token=8595ea3c-3c8e-4a78-807a-90aaa33ca6e3" alt=""><figcaption><p>Screenshot date: 7:50 UTC 16 Aug 2024</p></figcaption></figure>

In this case, Ston.fi offers a better amount of NOT. But what if I told you that we could get an even better price using their liquidity pools?

## Solution <a href="#id-2ab0" id="id-2ab0"></a>

Rainbow Swap distributes trade volume across optimal routes to minimize price impact and slippage. This ensures you get a better price in a single transaction.

<figure><img src="https://565861027-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FSD7ZvlWdfwvnrQF0DH1F%2Fuploads%2FwvLGy8l983kak4P29eae%2Fimage.png?alt=media&#x26;token=7710be0c-4fe1-4ca9-bfb8-dee9715416ae" alt="" width="375"><figcaption><p>Screenshot date: 7:50 UTC 16 Aug 2024</p></figcaption></figure>

Here, you will receive an extra 97 NOT (+0.16%) by splitting your trade into 2 parts: sending 61.6 TON to the Ston.fi pool and 38.4 TON to the DeDust.io pools.

Price improvement would depend on the tokens you want to swap and the amount of liquidity in DEXes pools. Here are a few price improvement examples:

<figure><img src="https://565861027-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FSD7ZvlWdfwvnrQF0DH1F%2Fuploads%2FSiHknzavU5p2TelwiSRU%2Fimage.png?alt=media&#x26;token=d6ae6223-3196-41a8-bc85-ed0c836a3b81" alt=""><figcaption></figcaption></figure>

<figure><img src="https://565861027-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FSD7ZvlWdfwvnrQF0DH1F%2Fuploads%2FTb0eG1mOwK8VtTwh9uEb%2Fimage.png?alt=media&#x26;token=d07d5a63-353e-4c0c-ba96-6d31d04b0f82" alt=""><figcaption></figcaption></figure>

## Conclusion <a href="#id-5898" id="id-5898"></a>

Earn more and forget about constantly tracking all DEXes simply by using Rainbow Swap. Our user-friendly interface allows seamless swaps with the most efficient routes, considering swap distribution and gas costs.


---

# 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://rainbow-ag.gitbook.io/docs/introduction/how-it-works.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.
