Monorail is our DeFi optimal routing system developed at Gambit Labs. It specializes in finding trade paths across thousands of DeFi contracts to get the best rates when converting tokens. It supports,
- Path splitting of arbitrary size and at any level in the path to minimize slippage.
- Capturing fragmented liquidity via intermediary tokens which is especially useful when trading low liquidity tokens.
- Trading tokens with transfer fees.
- Incorporating inner cycles to collect pre-existing arbitrage in the form of the destination token.
- Tunable path complexity (number of basic swaps) to lower gas cost (can be determined automatically) and express other execution preferences.
Example Trading USDT to WETH
Below is a common real-life example (not-cherry picked) to demonstrate converting 132588.70 USDT to 66.77 WETH. This solution would have found an additional 0.14 WETH compared to pushing the same amount of USDT split via the top two USDT/WETH Uniswap pools.
51933.75 USDT ─[v3 0x48DA]─▸ 51947.70 DAI
├─[v2 0x517F]─▸ 19.49 MKR ─[v3 0xe8c6]─▸ 14.17 WETH
└─[v3 0x6059]─▸ 11.98 WETH
49604.08 USDT ─[v3 0xc7bB]─▸ 24.98 WETH
18654.18 USDT ─[v3 0xfA6e]─┬─▸ 31060.88 USDC ─┬─[v2 0xB4e1]─▸ 9.11 WETH
12396.67 USDT ─[v3 0x3416]─┘ └─[v3 0x2322]─▸ 74714.52 RLB ─[v3 0x5101]─▸ 6.52 WETH
TOTAL: 132588.70 USDT ─▸ 66.77 WETH
Capturing Inner Cycles
When trading between tokens, pre-existing arbitrage (aka " inner cycles") can be captured to further increase the trade's amount out. Below are real-life examples (with amounts removed). In the first example, the backwards path (eg. TOAD to USDC, former being a tax token), picked up on a price discrepency with TOAD/WETH and TOAD/USDC pairs, allowing more USDC to be squeezed out and routed through the path obtaining additional WETH. There could be an arbitrary number of backward paths found.
┌─────────────────┐ ┌────▸WBTC──────┐ ┌──────────────────────┐ ┌──────┐
│ ┌────TOAD◂────┐ │ │ ┌───TOAD◂───┐ │ │ ┌─────┐ │ ┌───▸DAI───┐ │
│ ▾ │ ▾ │ ▾ │ ▾ │ ▾ │ ▾ │ ▾ ▾
USDC───▸WBTC───▸WETH USDC─────────▸WETH WETH───▸DAI───▸USDC───▸UNI USDT───────▸WETH
▴ | │ ▴ │ ▴ ▴ │
└─────LMWR◂─────┘ └─────▸DAI──────┘ └──────────────┘ └───RENQ◂───┘
Comparing to Direct Swaps
Below we demonstrate how more complex routing using intermediary swaps increases the amount out one would get over using direct swaps only. For a given token out, direct swaps includes any available pool that trades directly from WETH to the given token out (eg. USDT). We split optimally amongst the pairs to maximize the amount out. This is a generous baseline as most solutions would entail just using the single most-liquid or lowest fee-tier pool. Meanwhile intermediary swaps allow us to access fragmented liquidity in indirect pairs to maximize the amount out.
The first row is the absolute increase in amount out when using intermediary swaps across a grid of amounts in (forming a pricing curve), and the second row expresses this increase as a percent improvement. The data is gathered from a random week period (November 18 - 25, 2023; randomly selected).
As the amount in for the trade (eg. converting WETH to USDT) increases we can reach into all accessible liquidity via these intermediary tokens (eg. routing from WETH/FRAX to FRAX/USDT). This has a big impact especially on low liquidity tokens (notice the upward curve in increased amount out starts early with small amounts in on DAI and BLUR which have less total liquidity than USDT).
Reach Out for Access
If you're interested in using Monorail, reach out to us to discuss specific integration needs or use cases. We'd love to learn more about your project and how we can help.