> For the complete documentation index, see [llms.txt](https://docs.imperial.space/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.imperial.space/routing.md).

# Routing

Imperial isn't a single exchange — it's a router that sits on top of several perp venues (Jupiter, Flash, Phoenix, GMX, and more). When you place a trade, Imperial compares those venues in real time and sends your order to whichever one gives you the best all-in deal. You get one clean trading experience and never have to shop around yourself.

### What routing does

When you open or close a position, Imperial looks at every venue that can trade your asset and picks the single best one for **that specific trade**. The decision is based on what you're actually doing:

* The **asset** you're trading
* Your **direction** (long or short)
* Your **size**
* Your **leverage**

The same asset can route to different venues depending on these inputs — a small long might be cheapest on one venue while a large short is cheapest on another.

### How Imperial picks a venue

Imperial estimates the **total cost of the round trip** on each venue and chooses the cheapest. That estimate accounts for more than just the headline fee:

* **Open and close fees** — what the venue charges to enter and exit.
* **Price impact and slippage** — how much your size moves the price on that venue. A venue that can't fill your size at a good price is skipped.
* **Borrow and funding rates** — the ongoing cost of holding the position, based on how long you expect to hold it. Side-specific where a venue prices longs and shorts differently.
* **Liquidation risk** — how likely the position is to get liquidated at your chosen leverage, and how much you'd lose if it does. Venues with more forgiving liquidation mechanics score better here.

The venue with the lowest total estimated cost wins. In the trade screen, Imperial tells you *why* it chose a venue — usually either "lowest fees" or "tighter pricing / less slippage."

The estimate is a quote to help you choose. Your final execution price is always confirmed on-chain at the moment the trade lands.

### Staying on your position

If you already have an open position on an asset, Imperial keeps new orders for that asset on the **same venue**. Splitting a single position across venues would fragment it and usually costs you more, so once you're in, you stay put until you close.

### Choosing your own venue

Auto-routing is the default, but you're never locked into it. Imperial shows a side-by-side comparison of every eligible venue — fees, pricing, and max leverage — so you can override the router and pick one yourself. To avoid your route flickering between near-identical venues on every price tick, Imperial only switches venues when a challenger is meaningfully cheaper.

### Boosting leverage with the Imperial Lending Pool

Some trades want more leverage than a venue allows on its own. Imperial can attach a loan from the **Imperial Lending Pool** to the trade so you reach your target leverage even when the venue's own cap is lower. The loan and your own collateral fund the same single position on one venue — nothing is split across exchanges.

Loans are used in two situations:

* **Reaching higher leverage** — when you ask for more than the venue's cap, the loan bridges the gap.
* **Safer liquidations** — even within a venue's cap, borrowing can move your liquidation point to Imperial's more protective trigger. Imperial only does this when the reduced liquidation risk is worth the loan's carrying cost.

The size of the loan is chosen to hit your target leverage while keeping the position within the pool's safety limits. If the lending pool is paused or can't safely back the trade, Imperial simply routes the order without a loan.

### Venue limits

Not every venue can take every trade. Routing automatically respects each venue's:

* **Maximum leverage** for the asset
* **Available liquidity** — a venue is skipped if it can't fill your size well
* **Supported assets** — each venue lists its own markets
* **Live status** — paused or one-sided markets are excluded

If no venue can reach your requested leverage, Imperial routes to the highest available and clearly flags that your leverage was capped, rather than silently changing your trade or letting it fail.
