> ## Documentation Index
> Fetch the complete documentation index at: https://optimism-373f39ad-feat-swap-documentation.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Swap Documentation

> API reference for Actions SDK swap operations, functions, and parameters.

{/*
⚠️ WARNING: DO NOT EDIT THIS FILE DIRECTLY ⚠️

This file is auto-generated from the Actions SDK source code.

To update this documentation:
1. Bump the SDK version in package.json: pnpm add @eth-optimism/actions-sdk@latest
2. Run the generation script: pnpm prebuild

Any manual edits will be overwritten on the next generation.
*/}

## WalletSwapNamespace

Wallet swap namespace (full operations with signing)

### Methods

| Function                                      | Description                                      |
| --------------------------------------------- | ------------------------------------------------ |
| **[price()](#price)**                         | Get a price quote for a swap                     |
| **[getMarket()](#getmarket)**                 | Get a specific swap market                       |
| **[getMarkets()](#getmarkets)**               | Get available swap markets across all providers  |
| **[supportedChainIds()](#supportedchainids)** | Get all supported chain IDs across all providers |
| **[execute()](#execute)**                     | Execute a token swap                             |

#### `price()`

Get a price quote for a swap

| Parameter          | Type               | Description                                                                      |
| ------------------ | ------------------ | -------------------------------------------------------------------------------- |
| `params`           | `SwapPriceParams`  | Price quote parameters                                                           |
| `params.assetIn`   | `Asset`            | Token to get price for (required)                                                |
| `params.assetOut`  | `Asset`            | Token to price against. Defaults to USDC if not provided.                        |
| `params.amountIn`  | `number`           | Amount of input token (human-readable). Defaults to 1 unit. For exact-in quotes. |
| `params.amountOut` | `number`           | Amount of output token (human-readable). For exact-out quotes.                   |
| `params.chainId`   | `SupportedChainId` | Chain to get price on                                                            |

**Returns:** Promise resolving to `SwapPrice` with exchange rate, amounts, price impact, route, and gas estimate

<sub>[<Icon icon="github" /> Source ↗](https://github.com/ethereum-optimism/actions/blob/main/packages/sdk/src/swap/namespaces/BaseSwapNamespace.ts)</sub>

***

#### `getMarket()`

Get a specific swap market

| Parameter        | Type                  | Description                                 |
| ---------------- | --------------------- | ------------------------------------------- |
| `params`         | `GetSwapMarketParams` | Market identifier                           |
| `params.poolId`  | `string`              | Pool identifier (keccak256 hash of PoolKey) |
| `params.chainId` | `SupportedChainId`    | Chain ID where this market exists           |

**Returns:** Promise resolving to `SwapMarket` information

<sub>[<Icon icon="github" /> Source ↗](https://github.com/ethereum-optimism/actions/blob/main/packages/sdk/src/swap/namespaces/BaseSwapNamespace.ts)</sub>

***

#### `getMarkets()`

Get available swap markets across all providers

| Parameter        | Type                   | Description                                             |
| ---------------- | ---------------------- | ------------------------------------------------------- |
| `params`         | `GetSwapMarketsParams` | Optional filtering parameters                           |
| `params.chainId` | `SupportedChainId`     | Filter by chain ID                                      |
| `params.asset`   | `Asset`                | Filter by asset (returns markets containing this asset) |

**Returns:** Promise resolving to array of `SwapMarket` from all providers

<sub>[<Icon icon="github" /> Source ↗](https://github.com/ethereum-optimism/actions/blob/main/packages/sdk/src/swap/namespaces/BaseSwapNamespace.ts)</sub>

***

#### `supportedChainIds()`

Get all supported chain IDs across all providers

**Returns:** Array of unique `SupportedChainId` values supported by any configured provider

<sub>[<Icon icon="github" /> Source ↗](https://github.com/ethereum-optimism/actions/blob/main/packages/sdk/src/swap/namespaces/BaseSwapNamespace.ts)</sub>

***

#### `execute()`

Execute a token swap

| Parameter          | Type               | Description                                                                                       |
| ------------------ | ------------------ | ------------------------------------------------------------------------------------------------- |
| `params`           | `WalletSwapParams` | Swap parameters                                                                                   |
| `params.assetIn`   | `Asset`            | Token to sell                                                                                     |
| `params.assetOut`  | `Asset`            | Token to buy                                                                                      |
| `params.chainId`   | `SupportedChainId` | Chain to execute swap on                                                                          |
| `params.amountIn`  | `number`           | Amount of input token (human-readable). For exact-in swaps. Mutually exclusive with `amountOut`.  |
| `params.amountOut` | `number`           | Amount of output token (human-readable). For exact-out swaps. Mutually exclusive with `amountIn`. |
| `params.slippage`  | `number`           | Slippage tolerance override (e.g., `0.01` for 1%). Overrides provider and config defaults.        |
| `params.deadline`  | `number`           | Transaction deadline as Unix timestamp. Defaults to now + 1 minute.                               |
| `params.recipient` | `Address`          | Recipient address. Defaults to wallet address.                                                    |

**Returns:** Promise resolving to `SwapReceipt` with transaction receipt, amounts, assets, price, and price impact

<sub>[<Icon icon="github" /> Source ↗](https://github.com/ethereum-optimism/actions/blob/main/packages/sdk/src/swap/namespaces/WalletSwapNamespace.ts)</sub>

***
