Skip to content
docs

Swap2Protocol

Defined in: protocols/swap2.ts:185

Swap + bridge in one. swap and bridge are derived from swap2, so a swap2 module is automatically a swap and a bridge module.

TConfig extends Swap2ProtocolConfig = Swap2ProtocolConfig

new Swap2Protocol<TConfig>(account, config?): Swap2Protocol<TConfig>

Defined in: protocols/swap2.ts:189

IWalletAccountReadOnly | IWalletAccount

TConfig = ...

Swap2Protocol<TConfig>

ProtocolBase.constructor

protected readonly _account: IWalletAccountReadOnly | IWalletAccount

Defined in: protocols/base.ts:8

ProtocolBase._account


protected readonly _config: TConfig

Defined in: protocols/base.ts:9

ProtocolBase._config

bridge(options): Promise<BridgeResult>

Defined in: protocols/swap2.ts:204

The older bridge, run through swap2 with the same token on both chains.

BridgeOptions

Promise<BridgeResult>

IBridgeProtocol.bridge


describeActivity(_tx, _ctx): ActivityItem | null

Defined in: protocols/base.ts:24

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

ProtocolBase.describeActivity


getSupportedChains(): Promise<Swap2SupportedChain[]>

Defined in: protocols/swap2.ts:217

Chains this provider can swap on or to.

Promise<Swap2SupportedChain[]>

ISwap2Protocol.getSupportedChains


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

Defined in: protocols/swap2.ts:218

Tokens this provider can swap, optionally narrowed by Swap2SupportedTokensOptions.

Swap2SupportedTokensOptions

Promise<Swap2SupportedToken[]>

ISwap2Protocol.getSupportedTokens


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

Defined in: protocols/swap2.ts:216

State of a swap by the id from Swap2Result. Poll it until a final status.

string

Swap2StatusOptions

Promise<Swap2StatusResult>

ISwap2Protocol.getSwap2Status


quoteBridge(options): Promise<BridgeQuote>

Defined in: protocols/swap2.ts:209

The older quoteBridge, run through quoteSwap2.

BridgeOptions

Promise<BridgeQuote>

IBridgeProtocol.quoteBridge


quoteSwap(options): Promise<SwapQuote>

Defined in: protocols/swap2.ts:199

The older quoteSwap, run through quoteSwap2.

SwapOptions

Promise<SwapQuote>

ISwapProtocol.quoteSwap


quoteSwap2(_options): Promise<Swap2Quote>

Defined in: protocols/swap2.ts:214

Price a swap. Signs nothing and works on a read-only account.

Swap2Options

Promise<Swap2Quote>

Swap2QuoteError (from protocol-swap2-core) with a named reason when there is no route.

ISwap2Protocol.quoteSwap2


protected requireSigningAccount(methodName): IWalletAccount

Defined in: protocols/base.ts:29

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

string

IWalletAccount

ProtocolBase.requireSigningAccount


swap(options): Promise<SwapResult>

Defined in: protocols/swap2.ts:194

The older same-chain swap, run through Swap2Protocol.swap2.

SwapOptions

Promise<SwapResult>

ISwapProtocol.swap


swap2(_options, _config?): Promise<Swap2Result>

Defined in: protocols/swap2.ts:215

Quote again, check the quote (amounts, recipient, refund address, fee ceilings in config), then sign and broadcast the source transaction (and an approval when one is needed).

Swap2Options

Swap2ProtocolConfig

Promise<Swap2Result>

ISwap2Protocol.swap2