> ## Documentation Index
> Fetch the complete documentation index at: https://docs.trails.build/llms.txt
> Use this file to discover all available pages before exploring further.

# Route Providers

> Configure and optimize route providers for cross-chain interactions

## Route Providers

Trails integrates with multiple liquidity sources and bridge providers to find the best routes for your cross-chain transactions. You can specify preferred providers for swapping and bridging, or let Trails automatically select the optimal ones.

## Available Providers

* **`AUTO`** (recommended): Automatically selects the best provider based on the route
* **`RELAY`**: Uses Relay for fast bridging operations
* **`CCTP`**: Uses Circle's Cross-Chain Transfer Protocol for USDC transfers
* **`SUSHI`**: Uses SushiSwap for on-chain swaps
* **`ZEROX`**: Uses 0x protocol for DEX aggregation
* **`LIFI`**: Uses LI.FI for cross-chain routing
* **`LZ_OFT`**: Uses LayerZero Omnichain Fungible Token bridge
* **`LZ_TRANSFER`**: Uses LayerZero's Value Transfer API for direct cross-chain value transfers
* **`HYPERLANE`**: Uses Hyperlane warp routes for cross-chain messaging
* **`OIF`**: Uses the Open Intents Framework for solver-filled cross-chain intents
* **`GASZIP`**: Uses Gas.zip for gas-optimized routing
* **`WETH`**: Wrap/unwrap ETH ↔ WETH on the same chain
* **`SOMNIA_EXCHANGE`**: Uses Somnia Exchange for swaps on Somnia
* **`SOMNIA_SWAP`**: Uses Somnia Swap for swaps on Somnia

## Configuration

### Widget-level configuration

Specify route providers on any focused component:

```tsx theme={null}
import { Swap } from '0xtrails/widget'

<Swap
  apiKey="YOUR_API_KEY"
  swapProvider="SUSHI"    // Provider for on-chain swaps
  bridgeProvider="RELAY"  // Provider for cross-chain bridging
  from={{ token: "USDC", chain: "ethereum" }}
  to={{ token: "USDC", chain: "base" }}
/>
```

### Hook-level configuration

When using the `useQuote` hook, you can specify both swap and bridge providers:

```tsx theme={null}
import { useQuote, RouteProvider } from '0xtrails'

const { quote, send } = useQuote({
  walletClient,
  from: {
    token: 'USDC',
    chain: 'ethereum',
    amount: '1', // human-readable USDC amount
  },
  to: {
    token: 'USDC',
    chain: 'base',
  },
  swapProvider: 'AUTO',    // Optional: defaults to AUTO
  bridgeProvider: 'RELAY', // Optional: specify preferred bridge
})
```

## Provider Details

### AUTO (recommended)

The `AUTO` setting lets Trails intelligently select the best provider for each transaction based on cost, speed, liquidity, and reliability. Use this unless you have a specific reason to lock to a particular provider.

```tsx theme={null}
<Swap
  apiKey="YOUR_API_KEY"
  swapProvider="AUTO"    // Default
  bridgeProvider="AUTO"  // Default
/>
```

### Relay

Relay provides fast cross-chain transfers through an intent-based filler network. Fillers front the destination execution and settle asynchronously.

* Fast finality on most routes
* Competitive fees
* Good coverage across major EVM chains

```tsx theme={null}
<Swap apiKey="YOUR_API_KEY" bridgeProvider="RELAY" />
```

### CCTP

Circle's Cross-Chain Transfer Protocol enables native USDC bridging without wrapped tokens. There is no slippage — 1 USDC in equals 1 USDC out.

* Available on Ethereum, Base, Arbitrum, Optimism, Polygon, Avalanche
* No wrapped USDC; transfers use Circle's burn-and-mint mechanism
* Best choice when users need exact USDC amounts at destination

```tsx theme={null}
<Swap
  apiKey="YOUR_API_KEY"
  bridgeProvider="CCTP"
  to={{ token: "USDC" }}
/>
```

### SushiSwap

SushiSwap provides on-chain swap routing using its V3 concentrated liquidity pools across multiple EVM chains.

* Available on most major chains
* Works well when deep Sushi liquidity exists for the token pair

```tsx theme={null}
<Swap apiKey="YOUR_API_KEY" swapProvider="SUSHI" />
```

### 0x Protocol

0x aggregates liquidity across multiple DEXs to find optimal swap rates. It optimizes for both price and gas.

```tsx theme={null}
<Swap apiKey="YOUR_API_KEY" swapProvider="ZEROX" />
```

### LayerZero (LZ\_OFT / LZ\_TRANSFER)

LayerZero is an omnichain messaging protocol that powers two distinct bridge providers:

**LZ\_OFT** — Omnichain Fungible Token bridge. Used for tokens that have native OFT deployments across chains (no wrapping, direct cross-chain transfers).

**LZ\_TRANSFER** — LayerZero's Value Transfer API. Direct cross-chain value transfers for supported tokens; requires explicit `bridgeProvider="LZ_TRANSFER"` selection (not currently picked by AUTO).

* LZ\_OFT expands coverage to chains and tokens not served by Relay or CCTP
* AUTO will select LZ\_OFT when it is optimal

```tsx theme={null}
<Swap apiKey="YOUR_API_KEY" bridgeProvider="LZ_OFT" />      // For OFT-enabled tokens
<Swap apiKey="YOUR_API_KEY" bridgeProvider="LZ_TRANSFER" /> // For Value Transfer routes
```

### Hyperlane

Hyperlane is a permissionless interchain messaging protocol used for warp routes between chains. Trails uses Hyperlane for token pairs covered by deployed warp routes, with on-chain gas estimation for the interchain gas payment.

* Included in AUTO routing — Hyperlane is considered alongside other bridges when scoring routes
* AUTO will only select Hyperlane when a warp route exists for the token pair

```tsx theme={null}
<Swap apiKey="YOUR_API_KEY" bridgeProvider="HYPERLANE" />
```

### OIF (Open Intents Framework)

The Open Intents Framework is a permissionless solver network for cross-chain intents. Trails supports OIF for explicit selection, with refund handling for expired or unfilled orders.

* Available on `v1_5` only — Trails does not route OIF for `v1` quotes
* Requires explicit `bridgeProvider="OIF"`; not currently selected by AUTO

```tsx theme={null}
<Swap apiKey="YOUR_API_KEY" bridgeProvider="OIF" />
```

### Gas.zip

Gas.zip is a gas-optimized routing provider that reduces the total gas cost of cross-chain transactions.

* Useful when minimizing gas costs is the priority over speed
* AUTO will select Gas.zip when it provides the best cost efficiency

```tsx theme={null}
<Swap apiKey="YOUR_API_KEY" bridgeProvider="GASZIP" />
```

### Somnia (SOMNIA\_EXCHANGE / SOMNIA\_SWAP)

Native swap providers on Somnia (chain id `5031`). Used for on-chain swaps within Somnia.

```tsx theme={null}
<Swap apiKey="YOUR_API_KEY" swapProvider="SOMNIA_EXCHANGE" />
<Swap apiKey="YOUR_API_KEY" swapProvider="SOMNIA_SWAP" />
```

## Best Practices

1. **Use `AUTO` by default**: Let Trails optimize the route for you.
2. **USDC transfers**: Use `CCTP` for guaranteed 1:1 native USDC bridging.
3. **Fast bridging**: Use `RELAY` when speed is the priority.
4. **Gas-sensitive routes**: Use `GASZIP` or leave as `AUTO` to minimize fees.
5. **Separate swap and bridge**: `swapProvider` controls same-chain DEX routing; `bridgeProvider` controls the cross-chain transport layer.
6. **Fallback support**: Set `swapProviderFallback: true` or `bridgeProviderFallback: true` to automatically fall back to another provider if your preferred one is unavailable.
