Skip to main content

WalletSwapNamespace

Wallet swap namespace (full operations with signing)

Methods

FunctionDescription
price()Get a price quote for a swap
getMarket()Get a specific swap market
getMarkets()Get available swap markets across all providers
supportedChainIds()Get all supported chain IDs across all providers
execute()Execute a token swap

price()

Get a price quote for a swap
ParameterTypeDescription
paramsSwapPriceParamsPrice quote parameters
params.assetInAssetToken to get price for (required)
params.assetOutAssetToken to price against. Defaults to USDC if not provided.
params.amountInnumberAmount of input token (human-readable). Defaults to 1 unit. For exact-in quotes.
params.amountOutnumberAmount of output token (human-readable). For exact-out quotes.
params.chainIdSupportedChainIdChain to get price on
Returns: Promise resolving to SwapPrice with exchange rate, amounts, price impact, route, and gas estimate Source ↗

getMarket()

Get a specific swap market
ParameterTypeDescription
paramsGetSwapMarketParamsMarket identifier
params.poolIdstringPool identifier (keccak256 hash of PoolKey)
params.chainIdSupportedChainIdChain ID where this market exists
Returns: Promise resolving to SwapMarket information Source ↗

getMarkets()

Get available swap markets across all providers
ParameterTypeDescription
paramsGetSwapMarketsParamsOptional filtering parameters
params.chainIdSupportedChainIdFilter by chain ID
params.assetAssetFilter by asset (returns markets containing this asset)
Returns: Promise resolving to array of SwapMarket from all providers Source ↗

supportedChainIds()

Get all supported chain IDs across all providers Returns: Array of unique SupportedChainId values supported by any configured provider Source ↗

execute()

Execute a token swap
ParameterTypeDescription
paramsWalletSwapParamsSwap parameters
params.assetInAssetToken to sell
params.assetOutAssetToken to buy
params.chainIdSupportedChainIdChain to execute swap on
params.amountInnumberAmount of input token (human-readable). For exact-in swaps. Mutually exclusive with amountOut.
params.amountOutnumberAmount of output token (human-readable). For exact-out swaps. Mutually exclusive with amountIn.
params.slippagenumberSlippage tolerance override (e.g., 0.01 for 1%). Overrides provider and config defaults.
params.deadlinenumberTransaction deadline as Unix timestamp. Defaults to now + 1 minute.
params.recipientAddressRecipient address. Defaults to wallet address.
Returns: Promise resolving to SwapReceipt with transaction receipt, amounts, assets, price, and price impact Source ↗