CrossChainRouter
Defined in: protocol-swap2-router/src/router.ts:99
Routes a cross-chain delivery over pluggable providers: queries all that
support the route in parallel (with a timeout so a slow provider can’t block),
normalizes their quotes, scores by configurable weights, and returns the best
tagged with routeScore. A failed/slow provider simply doesn’t participate.
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new CrossChainRouter(
providers,options?):CrossChainRouter
Defined in: protocol-swap2-router/src/router.ts:112
Parameters
Section titled “Parameters”providers
Section titled “providers”options?
Section titled “options?”string | RouterOptions
Returns
Section titled “Returns”CrossChainRouter
Accessors
Section titled “Accessors”lastRejections
Section titled “lastRejections”Get Signature
Section titled “Get Signature”get lastRejections(): readonly
string[]
Defined in: protocol-swap2-router/src/router.ts:104
Why providers sat out the last auction, one line each.
Returns
Section titled “Returns”readonly string[]
Methods
Section titled “Methods”close()
Section titled “close()”close():
void
Defined in: protocol-swap2-router/src/router.ts:350
Release every provider’s resources.
Returns
Section titled “Returns”void
describeActivity()
Section titled “describeActivity()”describeActivity(
tx,ctx):ActivityItem|null
Defined in: protocol-swap2-router/src/router.ts:171
Activity recognition across the installed providers: the first one that claims the transaction describes it. Null when none does (or none is held).
Parameters
Section titled “Parameters”ChainTx
DescribeActivityContext
Returns
Section titled “Returns”ActivityItem | null
getBestQuote()
Section titled “getBestQuote()”getBestQuote(
params,options?):Promise<RoutedQuote|null>
Defined in: protocol-swap2-router/src/router.ts:217
The auction’s pick: the best price (net of native fees and gas when
valueUsd is set; faster, then more reliable, among equal prices), or
the fastest route with prefer: "fastest".
Parameters
Section titled “Parameters”params
Section titled “params”options?
Section titled “options?”prefer?
Section titled “prefer?”"best" | "fastest"
requireImmediateExecution?
Section titled “requireImmediateExecution?”boolean
Returns
Section titled “Returns”Promise<RoutedQuote | null>
getProvider()
Section titled “getProvider()”getProvider(
name):CrossChainProvider|undefined
Defined in: protocol-swap2-router/src/router.ts:180
A provider by name.
Parameters
Section titled “Parameters”string
Returns
Section titled “Returns”CrossChainProvider | undefined
getQuotes()
Section titled “getQuotes()”getQuotes(
params,options?):Promise<RouteSet|null>
Defined in: protocol-swap2-router/src/router.ts:248
Every validated route, ranked — for a route picker that shows the best and
the fastest and lets the user choose. Providers run in parallel; with
onUpdate each one that answers re-publishes the ranked set at once (the
first price shows in the time of the fastest venue, not the slowest).
Parameters
Section titled “Parameters”params
Section titled “params”options?
Section titled “options?”onUpdate?
Section titled “onUpdate?”(set) => void
requireImmediateExecution?
Section titled “requireImmediateExecution?”boolean
Returns
Section titled “Returns”Promise<RouteSet | null>
hasEnabledProvider()
Section titled “hasEnabledProvider()”hasEnabledProvider(
name):boolean
Defined in: protocol-swap2-router/src/router.ts:190
True when that provider is installed and enabled.
Parameters
Section titled “Parameters”string
Returns
Section titled “Returns”boolean
hasProvider()
Section titled “hasProvider()”hasProvider(
name):boolean
Defined in: protocol-swap2-router/src/router.ts:185
True when a provider of that name is installed.
Parameters
Section titled “Parameters”string
Returns
Section titled “Returns”boolean
notifyDeposit()
Section titled “notifyDeposit()”notifyDeposit(
providerName,intentId,txHash):Promise<void>
Defined in: protocol-swap2-router/src/router.ts:345
Forward a source-broadcast notification to the intent’s provider.
Parameters
Section titled “Parameters”providerName
Section titled “providerName”string
intentId
Section titled “intentId”string
txHash
Section titled “txHash”string
Returns
Section titled “Returns”Promise<void>
only()
Section titled “only()”only(
name):CrossChainRouter
Defined in: protocol-swap2-router/src/router.ts:161
The same auction restricted to one provider — to execute the route a user picked.
Parameters
Section titled “Parameters”string
Returns
Section titled “Returns”CrossChainRouter
supportsChain()
Section titled “supportsChain()”supportsChain(
caip2):boolean
Defined in: protocol-swap2-router/src/router.ts:197
True when any enabled provider declares the chain.
Parameters
Section titled “Parameters”string
Returns
Section titled “Returns”boolean
supportsChainPair()
Section titled “supportsChainPair()”supportsChainPair(
fromChain,toChain):boolean
Defined in: protocol-swap2-router/src/router.ts:204
True when any enabled provider declares the chain pair.
Parameters
Section titled “Parameters”fromChain
Section titled “fromChain”string
toChain
Section titled “toChain”string
Returns
Section titled “Returns”boolean
trackIntent()
Section titled “trackIntent()”trackIntent(
providerName,ref):Promise<IntentStatus>
Defined in: protocol-swap2-router/src/router.ts:338
Status from the named provider; failed when it is not installed.
Parameters
Section titled “Parameters”providerName
Section titled “providerName”string
Returns
Section titled “Returns”Promise<IntentStatus>