Skip to content
docs

ZeroExSwap2Protocol

Defined in: protocol-swap2-0x/src/protocol.ts:8

0x as a standalone swap2 protocol (same-chain swaps on one account).

  • SingleProviderSwap2

new ZeroExSwap2Protocol(account, config): ZeroExSwap2Protocol

Defined in: protocol-swap2-0x/src/protocol.ts:10

unknown

ZeroExSwap2Config

ZeroExSwap2Protocol

SingleProviderSwap2.constructor

protected readonly _account: IWalletAccountReadOnly | IWalletAccount

Defined in: core/dist/index-i6xtgDlq.d.ts:317

SingleProviderSwap2._account


protected readonly _config: Swap2ProtocolConfig

Defined in: core/dist/index-i6xtgDlq.d.ts:318

SingleProviderSwap2._config


protected readonly fromChain: string

Defined in: protocol-swap2-core/dist/base-6gRdyyWr.d.ts:469

SingleProviderSwap2.fromChain


protected readonly provider: ZeroExProvider

Defined in: protocol-swap2-0x/src/protocol.ts:9

SingleProviderSwap2.provider

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

Defined in: protocol-swap2-core/dist/base-6gRdyyWr.d.ts:513

Hold itemized fees to maxNetworkFeeBps / maxProtocolFeeBps of the input. Every fee of a capped type must be in the source token (sourceToken, compared case-insensitively); with sourceNative (the source is the chain’s native coin) a fee in a provider’s native spelling — “native”, the zero address, 0xEeee…EEeE — counts as the source too.

readonly Swap2Fee[] | undefined

bigint

string

Swap2ProtocolConfig

boolean

void

SingleProviderSwap2.assertFeeCaps


protected assertFeeConfig(config?): void

Defined in: protocol-swap2-core/dist/base-6gRdyyWr.d.ts:507

Swap2ProtocolConfig

void

SingleProviderSwap2.assertFeeConfig


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

Defined in: protocol-swap2-core/dist/base-6gRdyyWr.d.ts:514

Quote

Swap2Options

Swap2ProtocolConfig

void

SingleProviderSwap2.assertQuoteFeeCaps


bridge(options): Promise<BridgeResult>

Defined in: protocol-swap2-core/dist/base-6gRdyyWr.d.ts:634

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>

SingleProviderSwap2.bridge


cancelSwap2(id, account, options?): Promise<{ id: string; mode: "offchain"; } | { chain: string; hash: string; id: string; mode: "onchain"; }>

Defined in: protocol-swap2-core/dist/base-6gRdyyWr.d.ts:621

Cancel an order that rests before it settles (CoW Protocol), by the id swap2() returned.

Default: the free off-chain cancellation — the account signs an EIP-712 OrderCancellations message for its own order and the provider hands it to the orderbook. It is best effort: an order a solver already picked up may still settle, so keep polling the status. {onchain: true} sends the transaction that invalidates the order in the contract instead (costs gas, final once mined); an order placed by an on-chain transaction (a native-coin sell) can only be cancelled this way, and the same transaction refunds it after it expired.

The engine signs nothing but a cancellation of orders this account owns, for GPv2Settlement on the account’s chain, and sends nothing but plain calldata to a contract the provider declares (cancelTargets). Cancelling stays available when the provider is switched off.

string

unknown

boolean

Promise<{ id: string; mode: "offchain"; } | { chain: string; hash: string; id: string; mode: "onchain"; }>

SingleProviderSwap2.cancelSwap2


protected chainSupported(caip2): boolean

Defined in: protocol-swap2-0x/src/protocol.ts:14

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

string

boolean

SingleProviderSwap2.chainSupported


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

Defined in: protocol-swap2-core/dist/base-6gRdyyWr.d.ts:602

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; }>

SingleProviderSwap2.claimSwap2


close(): void

Defined in: protocol-swap2-core/dist/swap2/single.d.ts:25

void

SingleProviderSwap2.close


describeActivity(tx, ctx): ActivityItem | null

Defined in: protocol-swap2-core/dist/swap2/single.d.ts:23

Activity recognition lives on the provider (shared with the router); null when it has none.

ChainTx

DescribeActivityContext

ActivityItem | null

SingleProviderSwap2.describeActivity


protected emitPhase(phase, detail?): void

Defined in: protocol-swap2-core/dist/base-6gRdyyWr.d.ts:489

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

Swap2ExecutionPhase

Swap2ExecutionPhaseDetail

void

SingleProviderSwap2.emitPhase


getSupportedChains(): Promise<Swap2SupportedChain[]>

Defined in: protocol-swap2-core/dist/base-6gRdyyWr.d.ts:638

Source chains this protocol can swap from.

Promise<Swap2SupportedChain[]>

SingleProviderSwap2.getSupportedChains


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

Defined in: protocol-swap2-core/dist/base-6gRdyyWr.d.ts:640

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

Swap2SupportedTokensOptions

Promise<Swap2SupportedToken[]>

SingleProviderSwap2.getSupportedTokens


getSwap2RecoveryQuotes(id): Promise<readonly RecoveryQuote[]>

Defined in: protocol-swap2-core/dist/base-6gRdyyWr.d.ts:583

Recovery discovery. Execution refreshes the selected offer and requires an explicit review.

string

Promise<readonly RecoveryQuote[]>

SingleProviderSwap2.getSwap2RecoveryQuotes


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

Defined in: protocol-swap2-core/dist/base-6gRdyyWr.d.ts:591

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

string

Swap2StatusOptions

Promise<Swap2StatusResult>

SingleProviderSwap2.getSwap2Status


protected noRouteDetail(params?): string

Defined in: protocol-swap2-core/dist/swap2/single.d.ts:19

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.

QuoteParams

string

SingleProviderSwap2.noRouteDetail


protected noRouteRefusals(params?): readonly Swap2Refusal[]

Defined in: protocol-swap2-core/dist/swap2/single.d.ts:20

Each venue’s refusal behind the empty resolveQuote for params (the object it was given), classified where the venue could (Swap2RefusalReason). Per call: overlapping quotes on one instance must not read each other’s.

QuoteParams

readonly Swap2Refusal[]

SingleProviderSwap2.noRouteRefusals


protected pairSupported(fromChain, toChain): boolean

Defined in: protocol-swap2-0x/src/protocol.ts:17

Pair-level capability used when discovery specifies both endpoints.

string

string

boolean

SingleProviderSwap2.pairSupported


protected prepareOptions(options): Promise<Swap2Options>

Defined in: protocol-swap2-core/dist/base-6gRdyyWr.d.ts:503

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>

SingleProviderSwap2.prepareOptions


protected protocolEnabled(): boolean

Defined in: protocol-swap2-core/dist/swap2/single.d.ts:24

Runtime availability used by the public discovery methods.

boolean

SingleProviderSwap2.protocolEnabled


protected providerFor(name): CrossChainProvider | undefined

Defined in: protocol-swap2-core/dist/swap2/single.d.ts:21

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

string

CrossChainProvider | undefined

SingleProviderSwap2.providerFor


quoteBridge(options): Promise<BridgeQuote>

Defined in: core/dist/index-i6xtgDlq.d.ts:630

The older quoteBridge, run through quoteSwap2.

BridgeOptions

Promise<BridgeQuote>

SingleProviderSwap2.quoteBridge


quoteSwap(options): Promise<SwapQuote>

Defined in: core/dist/index-i6xtgDlq.d.ts:626

The older quoteSwap, run through quoteSwap2.

SwapOptions

Promise<SwapQuote>

SingleProviderSwap2.quoteSwap


quoteSwap2(options): Promise<Swap2Quote>

Defined in: protocol-swap2-core/dist/base-6gRdyyWr.d.ts:527

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.

SingleProviderSwap2.quoteSwap2


recoverSwap2(id, actionId, account, options): Promise<{ chain: string; hash: string; operationId: string; }>

Defined in: protocol-swap2-core/dist/base-6gRdyyWr.d.ts:585

A separately reviewed, bounded EVM recovery. Legacy claimSwap2 remains zero-value.

string

string

unknown

Swap2RecoveryOptions

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

SingleProviderSwap2.recoverSwap2


protected requireSigningAccount(methodName): IWalletAccount

Defined in: core/dist/index-i6xtgDlq.d.ts:330

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

string

IWalletAccount

SingleProviderSwap2.requireSigningAccount


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

Defined in: protocol-swap2-core/dist/swap2/single.d.ts:18

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

QuoteParams

Promise<Quote | null>

SingleProviderSwap2.resolveQuote


resumeSwap2(operationId): Promise<Swap2ResumeResult>

Defined in: protocol-swap2-core/dist/base-6gRdyyWr.d.ts:581

Read-only reconciliation. Never signs, re-quotes, repeats an approval or re-sends funds.

string

Promise<Swap2ResumeResult>

SingleProviderSwap2.resumeSwap2


protected routeQuote(q, options): Swap2Quote | null

Defined in: protocol-swap2-core/dist/base-6gRdyyWr.d.ts:519

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

SingleProviderSwap2.routeQuote


protected snapshotOf(options): Swap2Options

Defined in: protocol-swap2-core/dist/base-6gRdyyWr.d.ts:517

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

Swap2Options

Swap2Options

SingleProviderSwap2.snapshotOf


protected sourceAsset(options): CcAsset | undefined

Defined in: protocol-swap2-core/dist/base-6gRdyyWr.d.ts:496

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

Swap2Options

CcAsset | undefined

SingleProviderSwap2.sourceAsset


swap(options): Promise<SwapResult>

Defined in: protocol-swap2-core/dist/base-6gRdyyWr.d.ts:636

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

SwapOptions

Promise<SwapResult>

SingleProviderSwap2.swap


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

Defined in: protocol-swap2-core/dist/base-6gRdyyWr.d.ts:541

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.

config takes the fee ceilings and this execution’s approval policy (allowanceReuse, revokeUnspentApproval), which overrides the engine’s.

Swap2Options

Swap2ExecutionConfig

Promise<Swap2EngineResult>

Swap2ExecutionError for a read-only account, Swap2InFlightError for a double tap, Swap2MaybeSentError when the broadcast outcome is unknown (do not retry; track hash). With revokeUnspentApproval: false, an error after an approval this execution granted and did not spend carries it as leftAllowance (leftAllowanceOf).

SingleProviderSwap2.swap2


protected toParams(given, dry): QuoteParams

Defined in: protocol-swap2-core/dist/base-6gRdyyWr.d.ts:505

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

Swap2Options

boolean

QuoteParams

SingleProviderSwap2.toParams


protected toQuote(q, options): Swap2Quote

Defined in: protocol-swap2-core/dist/base-6gRdyyWr.d.ts:515

Quote

Swap2Options

Swap2Quote

SingleProviderSwap2.toQuote