Skip to content

SmartRouter

SIP Protocol API Reference v0.7.0


SIP Protocol API Reference / SmartRouter

Defined in: @sip-protocol/sdk/dist/index-BYZbDjal.d.ts:4749

Smart Router for finding optimal settlement routes

Queries all compatible backends in parallel and ranks routes by:

  • Total cost (network + protocol fees)
  • Execution speed (estimated time)
  • Privacy support (shielded vs transparent)
const registry = new SettlementRegistry()
registry.register(nearIntentsBackend)
registry.register(zcashBackend)
const router = new SmartRouter(registry)
const routes = await router.findBestRoute({
from: { chain: 'ethereum', token: 'USDC' },
to: { chain: 'solana', token: 'SOL' },
amount: 100_000000n,
privacyLevel: PrivacyLevel.SHIELDED,
preferLowFees: true
})
// Get best route
const best = routes[0]
console.log(`Best backend: ${best.backend}`)
console.log(`Cost: ${best.quote.fees.totalFeeUSD} USD`)
console.log(`Time: ${best.quote.estimatedTime}s`)

new SmartRouter(registry): SmartRouter

Defined in: @sip-protocol/sdk/dist/index-BYZbDjal.d.ts:4751

SettlementRegistry

SmartRouter

findBestRoute(params): Promise<RouteWithQuote[]>

Defined in: @sip-protocol/sdk/dist/index-BYZbDjal.d.ts:4761

Find best routes for a swap

Queries all compatible backends in parallel and returns sorted routes.

FindBestRouteParams

Route finding parameters

Promise<RouteWithQuote[]>

Sorted routes (best first)

If no backends support the route


compareQuotes(routes): QuoteComparison

Defined in: @sip-protocol/sdk/dist/index-BYZbDjal.d.ts:4768

Compare quotes from multiple routes side-by-side

RouteWithQuote[]

Routes to compare (from findBestRoute)

QuoteComparison

Comparison with best routes by different criteria