> 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="https://565861027-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FSD7ZvlWdfwvnrQF0DH1F%2Fuploads%2FseVti7J3TxhrRuGel1JT%2Fsmart-contract-events-diagram.svg?alt=media&amp;token=6cc287e9-6830-4815-afac-88db97cf6b37" 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
```
