Skip to content
docs

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.

new CrossChainRouter(providers, options?): CrossChainRouter

Defined in: protocol-swap2-router/src/router.ts:112

CrossChainProvider[]

string | RouterOptions

CrossChainRouter

get lastRejections(): readonly string[]

Defined in: protocol-swap2-router/src/router.ts:104

Why providers sat out the last auction, one line each.

readonly string[]

close(): void

Defined in: protocol-swap2-router/src/router.ts:350

Release every provider’s resources.

void


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).

ChainTx

DescribeActivityContext

ActivityItem | null


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".

QuoteParams

"best" | "fastest"

boolean

Promise<RoutedQuote | null>


getProvider(name): CrossChainProvider | undefined

Defined in: protocol-swap2-router/src/router.ts:180

A provider by name.

string

CrossChainProvider | undefined


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).

QuoteParams

(set) => void

boolean

Promise<RouteSet | null>


hasEnabledProvider(name): boolean

Defined in: protocol-swap2-router/src/router.ts:190

True when that provider is installed and enabled.

string

boolean


hasProvider(name): boolean

Defined in: protocol-swap2-router/src/router.ts:185

True when a provider of that name is installed.

string

boolean


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.

string

string

string

Promise<void>


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.

string

CrossChainRouter


supportsChain(caip2): boolean

Defined in: protocol-swap2-router/src/router.ts:197

True when any enabled provider declares the chain.

string

boolean


supportsChainPair(fromChain, toChain): boolean

Defined in: protocol-swap2-router/src/router.ts:204

True when any enabled provider declares the chain pair.

string

string

boolean


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.

string

IntentRef

Promise<IntentStatus>