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.
Extends
Section titled “Extends”ProtocolBase<TConfig>
Type Parameters
Section titled “Type Parameters”TConfig
Section titled “TConfig”TConfig extends Swap2ProtocolConfig = Swap2ProtocolConfig
Implements
Section titled “Implements”Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new Swap2Protocol<
TConfig>(account,config?):Swap2Protocol<TConfig>
Defined in: protocols/swap2.ts:189
Parameters
Section titled “Parameters”account
Section titled “account”IWalletAccountReadOnly | IWalletAccount
config?
Section titled “config?”TConfig = ...
Returns
Section titled “Returns”Swap2Protocol<TConfig>
Overrides
Section titled “Overrides”Properties
Section titled “Properties”_account
Section titled “_account”
protectedreadonly_account:IWalletAccountReadOnly|IWalletAccount
Defined in: protocols/base.ts:8
Inherited from
Section titled “Inherited from”_config
Section titled “_config”
protectedreadonly_config:TConfig
Defined in: protocols/base.ts:9
Inherited from
Section titled “Inherited from”Methods
Section titled “Methods”bridge()
Section titled “bridge()”bridge(
options):Promise<BridgeResult>
Defined in: protocols/swap2.ts:204
The older bridge, run through swap2 with the same token on both chains.
Parameters
Section titled “Parameters”options
Section titled “options”Returns
Section titled “Returns”Promise<BridgeResult>
Implementation of
Section titled “Implementation of”describeActivity()
Section titled “describeActivity()”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.
Parameters
Section titled “Parameters”Returns
Section titled “Returns”ActivityItem | null
Inherited from
Section titled “Inherited from”getSupportedChains()
Section titled “getSupportedChains()”getSupportedChains():
Promise<Swap2SupportedChain[]>
Defined in: protocols/swap2.ts:217
Chains this provider can swap on or to.
Returns
Section titled “Returns”Promise<Swap2SupportedChain[]>
Implementation of
Section titled “Implementation of”ISwap2Protocol.getSupportedChains
getSupportedTokens()
Section titled “getSupportedTokens()”getSupportedTokens(
_options?):Promise<Swap2SupportedToken[]>
Defined in: protocols/swap2.ts:218
Tokens this provider can swap, optionally narrowed by Swap2SupportedTokensOptions.
Parameters
Section titled “Parameters”_options?
Section titled “_options?”Returns
Section titled “Returns”Promise<Swap2SupportedToken[]>
Implementation of
Section titled “Implementation of”ISwap2Protocol.getSupportedTokens
getSwap2Status()
Section titled “getSwap2Status()”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.
Parameters
Section titled “Parameters”string
_options?
Section titled “_options?”Returns
Section titled “Returns”Promise<Swap2StatusResult>
Implementation of
Section titled “Implementation of”quoteBridge()
Section titled “quoteBridge()”quoteBridge(
options):Promise<BridgeQuote>
Defined in: protocols/swap2.ts:209
The older quoteBridge, run through quoteSwap2.
Parameters
Section titled “Parameters”options
Section titled “options”Returns
Section titled “Returns”Promise<BridgeQuote>
Implementation of
Section titled “Implementation of”quoteSwap()
Section titled “quoteSwap()”quoteSwap(
options):Promise<SwapQuote>
Defined in: protocols/swap2.ts:199
The older quoteSwap, run through quoteSwap2.
Parameters
Section titled “Parameters”options
Section titled “options”Returns
Section titled “Returns”Promise<SwapQuote>
Implementation of
Section titled “Implementation of”quoteSwap2()
Section titled “quoteSwap2()”quoteSwap2(
_options):Promise<Swap2Quote>
Defined in: protocols/swap2.ts:214
Price a swap. Signs nothing and works on a read-only account.
Parameters
Section titled “Parameters”_options
Section titled “_options”Returns
Section titled “Returns”Promise<Swap2Quote>
Throws
Section titled “Throws”Swap2QuoteError (from protocol-swap2-core) with a named reason when there is no
route.
Implementation of
Section titled “Implementation of”requireSigningAccount()
Section titled “requireSigningAccount()”
protectedrequireSigningAccount(methodName):IWalletAccount
Defined in: protocols/base.ts:29
The account, narrowed to a signing one, or a ReadOnlyAccountError naming the caller.
Parameters
Section titled “Parameters”methodName
Section titled “methodName”string
Returns
Section titled “Returns”Inherited from
Section titled “Inherited from”ProtocolBase.requireSigningAccount
swap()
Section titled “swap()”swap(
options):Promise<SwapResult>
Defined in: protocols/swap2.ts:194
The older same-chain swap, run through Swap2Protocol.swap2.
Parameters
Section titled “Parameters”options
Section titled “options”Returns
Section titled “Returns”Promise<SwapResult>
Implementation of
Section titled “Implementation of”swap2()
Section titled “swap2()”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).
Parameters
Section titled “Parameters”_options
Section titled “_options”_config?
Section titled “_config?”Returns
Section titled “Returns”Promise<Swap2Result>