> For the complete documentation index, see [llms.txt](https://rainbow-ag.gitbook.io/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://rainbow-ag.gitbook.io/docs/technical/cross-dex.md).

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