RouterOptions
Defined in: protocol-swap2-router/src/router.ts:23
@anywalletkit/protocol-swap2-router — the OPTIONAL swap2 aggregator.
Every swap2 provider module runs on its own (install only
@anywalletkit/protocol-swap2-lifi and use LifiSwap2Protocol). Install
this package when you want one protocol that auctions a route across several
providers: pass the providers you installed and it quotes them in parallel,
validates every quote, scores them and executes the winner.
import {RouterSwap2Protocol} from "@anywalletkit/protocol-swap2-router";import {lifiProvider} from "@anywalletkit/protocol-swap2-lifi/provider";import {nearIntentsProvider} from "@anywalletkit/protocol-swap2-near-intents/provider";
const swap2 = new RouterSwap2Protocol(account, { fromChain: "eip155:1", providers: [lifiProvider({}), nearIntentsProvider({})],});Providers reached through a backend use remoteProvider (re-exported from
the core package); give it supportsChain/supportsChainPair — e.g. from
the provider package’s config export — so discovery knows its coverage.
Properties
Section titled “Properties”tieBand?
Section titled “tieBand?”
optionaltieBand?:number
Defined in: protocol-swap2-router/src/router.ts:37
Fraction of the best net value inside which quotes tie on price (default 0.002).
valueUsd?
Section titled “valueUsd?”
optionalvalueUsd?: (quote,params) =>number|null
Defined in: protocol-swap2-router/src/router.ts:35
What a quote is worth to the user in USD: its guaranteed output minus what
the route charges on top (a native bridge fee, the source gas). Return null
when it cannot be priced — the auction then compares guaranteed outputs.
usdValue(prices) builds one from a symbol → USD price map.
Parameters
Section titled “Parameters”params
Section titled “params”Returns
Section titled “Returns”number | null
weights?
Section titled “weights?”
optionalweights?:string
Defined in: protocol-swap2-router/src/router.ts:28
“price:0.6,speed:0.3,reliability:0.1” — how quotes inside the tie band
(same price, within tieBand) are ordered. Price itself always leads.