# Cross-DEX

We use native cross-DEX swaps whenever possible, relying on original liquidity provider smart contracts. If that's not an option, we use the **Rainbow Routing Wallet**.

## Rainbow Routing Wallet

This smart contract acts as a middleman, allowing seamless swaps between different DEXes in a single transaction. It also lets users withdraw TON or jettons, just like a Jetton Wallet contract, to ensure asset security (no losses have occurred).

Events diagram:\ <br>

<figure><img src="/files/SKGeOJPF3z5AygiUks0N" alt=""><figcaption></figcaption></figure>

Smart contract are written using [FunC](https://docs.ton.org/develop/func/overview) language.\
All code could be found in [contracts](https://github.com/0xblackbot/rainbow-swap/blob/main/contracts) folder.

To build the **Rainbow Routing Wallet** smart contract you need to clone the [repository](https://github.com/0xblackbot/rainbow-swap) and run

```
yarn build:contract
```


---

# 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/technical/cross-dex.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.
