Skip to content
docs

BaseSwap2Protocol

Defined in: protocol-swap2-core/src/swap2/base.ts:716

Abstract swap2 protocol backed by the engine. Concrete subclasses bind either a single provider (contribution-shaped) or the router (aggregator).

  • Swap2Protocol

new BaseSwap2Protocol(account, config): BaseSwap2Protocol

Defined in: protocol-swap2-core/src/swap2/base.ts:719

unknown

Swap2EngineConfig

BaseSwap2Protocol

Swap2Protocol.constructor

protected readonly _account: IWalletAccountReadOnly | IWalletAccount

Defined in: core/dist/index-QWdcwE6y.d.ts:309

SingleProviderSwap2._account


protected readonly _config: Swap2ProtocolConfig

Defined in: core/dist/index-QWdcwE6y.d.ts:310

Swap2Protocol._config


protected readonly fromChain: string

Defined in: protocol-swap2-core/src/swap2/base.ts:717

protected assertFeeCaps(fees, sourceAmount, sourceToken, config?): void

Defined in: protocol-swap2-core/src/swap2/base.ts:851

readonly Swap2Fee[] | undefined

bigint

string

Swap2ProtocolConfig

void


protected assertFeeConfig(config?): void

Defined in: protocol-swap2-core/src/swap2/base.ts:842

Swap2ProtocolConfig

void


protected assertQuoteFeeCaps(q, options, config?): void

Defined in: protocol-swap2-core/src/swap2/base.ts:880

Quote

Swap2Options

Swap2ProtocolConfig

void


bridge(options): Promise<BridgeResult>

Defined in: protocol-swap2-core/src/swap2/base.ts:1675

The inherited bridge() has no floor field: quote first, then bind execution to that quote’s minimum so the inherited convenience API stays safe.

BridgeOptions

Promise<BridgeResult>

Swap2Protocol.bridge


abstract protected chainSupported(caip2): boolean

Defined in: protocol-swap2-core/src/swap2/base.ts:739

Whether this protocol can route a chain at all (for support discovery).

string

boolean


claimSwap2(id, account): Promise<{ chain: string; hash: string; id: string; }>

Defined in: protocol-swap2-core/src/swap2/base.ts:1609

Two-phase routes (CCTP-style burn-and-mint): once getSwap2Status reports “action-required”, the delivery needs a second transaction on the DESTINATION chain, signed there and paid in that chain’s gas. account is the destination-chain account (the bound source account is not reused: the chains differ). The provider builds the claim from the attestation; it is refused when not ready, when it names another chain than the account, or when it is anything but plain EVM calldata. Returns the claim hash and the status id to keep polling with.

string

unknown

Promise<{ chain: string; hash: string; id: string; }>


describeActivity(_tx, _ctx): ActivityItem | null

Defined in: core/dist/index-QWdcwE6y.d.ts:320

Recognize one of this protocol’s own transactions in an address’s history and describe it for the wallet’s activity feed (“Supplied 100 USDC · Aave v3”). Return null when the transaction is not this protocol’s: the kit then asks the next module and finally falls back to send / receive / approve / contract call. Must be pure and synchronous: no network, no account state. The conformance suite feeds every module its recorded fixtures through this method.

ChainTx

DescribeActivityContext

ActivityItem | null

Swap2Protocol.describeActivity


protected emitPhase(phase, detail?): void

Defined in: protocol-swap2-core/src/swap2/base.ts:742

Report an execution phase; an observer that throws is ignored.

Swap2ExecutionPhase

Swap2ExecutionPhaseDetail

void


getSupportedChains(): Promise<Swap2SupportedChain[]>

Defined in: protocol-swap2-core/src/swap2/base.ts:1713

Source chains this protocol can swap from.

Promise<Swap2SupportedChain[]>

Swap2Protocol.getSupportedChains


getSupportedTokens(options?): Promise<Swap2SupportedToken[]>

Defined in: protocol-swap2-core/src/swap2/base.ts:1724

Tokens of the asset catalog on the supported chains, optionally narrowed.

Swap2SupportedTokensOptions

Promise<Swap2SupportedToken[]>

Swap2Protocol.getSupportedTokens


getSwap2Status(id, _options?): Promise<Swap2StatusResult>

Defined in: protocol-swap2-core/src/swap2/base.ts:1592

Status of a swap by the id swap2() returned, asked from the provider that executed it.

string

Swap2StatusOptions

Promise<Swap2StatusResult>

Swap2Protocol.getSwap2Status


protected noRouteDetail(): string

Defined in: protocol-swap2-core/src/swap2/base.ts:733

Why the last resolveQuote came back empty (venue names + reasons), or “”. Rides inside the no-route error so execution failures are diagnosable from the surface that shows them.

string


protected pairSupported(fromChain, toChain): boolean

Defined in: protocol-swap2-core/src/swap2/base.ts:754

Pair-level capability used when discovery specifies both endpoints.

string

string

boolean


protected prepareOptions(options): Promise<Swap2Options>

Defined in: protocol-swap2-core/src/swap2/base.ts:778

Options ready to quote: with allowUnlistedTokens, an unlisted source token gets its decimals, read from the chain through the account (cached per token) — a caller’s fromTokenDecimals that disagrees is refused. Listed tokens and every option otherwise pass through unchanged.

Swap2Options

Promise<Swap2Options>


protected protocolEnabled(): boolean

Defined in: protocol-swap2-core/src/swap2/base.ts:752

Runtime availability used by the public discovery methods.

boolean


abstract protected providerFor(name): CrossChainProvider | undefined

Defined in: protocol-swap2-core/src/swap2/base.ts:737

Look up a provider by name to resume/track an in-flight swap2.

string

CrossChainProvider | undefined


quoteBridge(options): Promise<BridgeQuote>

Defined in: core/dist/index-QWdcwE6y.d.ts:609

The older quoteBridge, run through quoteSwap2.

BridgeOptions

Promise<BridgeQuote>

Swap2Protocol.quoteBridge


quoteSwap(options): Promise<SwapQuote>

Defined in: core/dist/index-QWdcwE6y.d.ts:605

The older quoteSwap, run through quoteSwap2.

SwapOptions

Promise<SwapQuote>

Swap2Protocol.quoteSwap


quoteSwap2(options): Promise<Swap2Quote>

Defined in: protocol-swap2-core/src/swap2/base.ts:932

Ask for a quote and check it against the request (amounts, slippage floor, fee ceilings in the protocol config). Works on a read-only account.

Swap2Options

Promise<Swap2Quote>

Swap2QuoteError when no route answers, with the provider’s own reason when it gave one.

Swap2Protocol.quoteSwap2


protected requireSigningAccount(methodName): IWalletAccount

Defined in: core/dist/index-QWdcwE6y.d.ts:322

The account, narrowed to a signing one, or a ReadOnlyAccountError naming the caller.

string

IWalletAccount

Swap2Protocol.requireSigningAccount


abstract protected resolveQuote(params): Promise<Quote | null>

Defined in: protocol-swap2-core/src/swap2/base.ts:728

Quote the route (single provider, or best across the router).

QuoteParams

Promise<Quote | null>


protected routeQuote(q, options): Swap2Quote | null

Defined in: protocol-swap2-core/src/swap2/base.ts:915

A dry route the auction already validated → the public quote, or null when the caller’s floor / fee caps refuse it.

Quote

Swap2Options

Swap2Quote | null


protected snapshotOf(options): Swap2Options

Defined in: protocol-swap2-core/src/swap2/base.ts:910

A frozen, validated copy of caller options (what every engine path works from).

Swap2Options

Swap2Options


protected sourceAsset(options): CcAsset | undefined

Defined in: protocol-swap2-core/src/swap2/base.ts:763

The source asset the options name: the catalog’s, or (allowUnlistedTokens) an unlisted one with its decimals.

Swap2Options

CcAsset | undefined


swap(options): Promise<SwapResult>

Defined in: protocol-swap2-core/src/swap2/base.ts:1692

Same protection for legacy exact-in swap() calls whose min is optional.

SwapOptions

Promise<SwapResult>

Swap2Protocol.swap


swap2(options, config?): Promise<Swap2Result>

Defined in: protocol-swap2-core/src/swap2/base.ts:953

Re-quote, check the quote, show it to reviewExecution when configured, send any approvals, then sign and broadcast the source leg. An identical call already in flight on the same account is refused.

Swap2Options

Swap2ProtocolConfig

Promise<Swap2Result>

Swap2ExecutionError for a read-only account, Swap2InFlightError for a double tap, Swap2MaybeSentError when the broadcast outcome is unknown (do not retry; track hash).

Swap2Protocol.swap2


protected toParams(given, dry): QuoteParams

Defined in: protocol-swap2-core/src/swap2/base.ts:802

Swap2Options → the engine’s QuoteParams (exact-in only).

Swap2Options

boolean

QuoteParams


protected toQuote(q, options): Swap2Quote

Defined in: protocol-swap2-core/src/swap2/base.ts:888

Quote

Swap2Options

Swap2Quote