Skip to main content

Documentation Index

Fetch the complete documentation index at: https://anypay-trails-api-docs.mintlify.app/llms.txt

Use this file to discover all available pages before exploring further.

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

Configuration

Widget-Level Configuration

Specify route providers when initializing the widget:
import { TrailsWidget } from '0xtrails/widget'

<TrailsWidget
  apiKey="YOUR_API_KEY"
  mode="swap"
  swapProvider="SUSHI"   // Provider for on-chain swaps
  bridgeProvider="RELAY" // Provider for cross-chain bridging
  toAddress="0x..."
  toChainId={8453}
  toToken="USDC"
/>

Hook-Level Configuration

When using the useQuote hook, you can specify both swap and bridge providers:
import { useQuote, TradeType, RouteProvider } from '0xtrails'

const { quote, swap } = useQuote({
  walletClient,
  fromTokenAddress: '0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
  fromChainId: 1,
  toTokenAddress: '0x833589fcd6edb6e08f4c7c32d4f71b54bda02913',
  toChainId: 8453,
  swapAmount: '1000000',
  tradeType: TradeType.EXACT_INPUT,
  swapProvider: 'AUTO',    // Optional: defaults to AUTO
  bridgeProvider: 'RELAY', // Optional: specify preferred bridge
})

Provider Characteristics

The AUTO setting allows Trails to intelligently select the best provider for each transaction based on:
  • Cost efficiency: Lowest fees and gas costs
  • Speed: Fastest execution time
  • Liquidity: Best rates for the token pair
  • Reliability: Provider uptime and success rates
<TrailsWidget
  swapProvider="AUTO"   // Default - recommended
  bridgeProvider="AUTO" // Default - recommended
  // ... other props
/>

Relay

Relay provides fast cross-chain transfers with competitive fees:
  • Fast execution: Optimized for speed
  • Native bridging: Direct chain-to-chain transfers
  • Lower complexity: Simple bridge operations
<TrailsWidget
  bridgeProvider="RELAY"
  // ... other props
/>

CCTP

Circle’s Cross-Chain Transfer Protocol for native USDC transfers:
  • Native USDC: No wrapped tokens
  • 1:1 transfers: No slippage for USDC
  • Official Circle: Secure and trusted
<TrailsWidget
  bridgeProvider="CCTP"
  toToken="USDC" // Best for USDC transfers
  // ... other props
/>

SushiSwap

SushiSwap provides on-chain swaps across multiple chains:
  • Multi-chain: Available on many EVM chains
  • DEX liquidity: Access to Sushi’s liquidity pools
<TrailsWidget
  swapProvider="SUSHI"
  // ... other props
/>

0x Protocol

0x provides DEX aggregation for optimal swap rates:
  • Aggregated liquidity: Sources from multiple DEXs
  • Best execution: Optimizes for price and gas
<TrailsWidget
  swapProvider="ZEROX"
  // ... other props
/>

Best Practices

  1. Use AUTO by default: Let Trails optimize the route for you
  2. Specify for USDC: Use CCTP bridge provider for USDC-specific transfers if you want guaranteed 1:1 transfers
  3. Consider your use case:
    • Fast bridging? Use RELAY as bridge provider
    • USDC transfers? Use CCTP for native transfers
  4. Separate concerns: Use swapProvider for same-chain swaps and bridgeProvider for cross-chain transfers