SmartRouter
SIP Protocol API Reference v0.7.0
SIP Protocol API Reference / SmartRouter
Class: SmartRouter
Section titled “Class: 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)
Example
Section titled “Example”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 routeconst best = routes[0]console.log(`Best backend: ${best.backend}`)console.log(`Cost: ${best.quote.fees.totalFeeUSD} USD`)console.log(`Time: ${best.quote.estimatedTime}s`)Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new SmartRouter(
registry):SmartRouter
Defined in: @sip-protocol/sdk/dist/index-BYZbDjal.d.ts:4751
Parameters
Section titled “Parameters”registry
Section titled “registry”Returns
Section titled “Returns”SmartRouter
Methods
Section titled “Methods”findBestRoute()
Section titled “findBestRoute()”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.
Parameters
Section titled “Parameters”params
Section titled “params”Route finding parameters
Returns
Section titled “Returns”Promise<RouteWithQuote[]>
Sorted routes (best first)
Throws
Section titled “Throws”If no backends support the route
compareQuotes()
Section titled “compareQuotes()”compareQuotes(
routes):QuoteComparison
Defined in: @sip-protocol/sdk/dist/index-BYZbDjal.d.ts:4768
Compare quotes from multiple routes side-by-side
Parameters
Section titled “Parameters”routes
Section titled “routes”Routes to compare (from findBestRoute)
Returns
Section titled “Returns”Comparison with best routes by different criteria