From 71a635215cbfb3ef5392270aeea27b4b42650c3a Mon Sep 17 00:00:00 2001 From: Jessica Lin Date: Wed, 4 Mar 2026 16:13:41 -0800 Subject: [PATCH] misc doc updates - chains, callluts, etc --- .../about-the-rfq-system.mdx | 4 +- .../buy-sell-tax-support.mdx | 2 +- .../how-to-set-your-token-allowances.mdx | 12 ++-- .../build-token-swap-dapp-nextjs-permit2.mdx | 12 ++-- .../guides/build-token-swap-dapp-nextjs.mdx | 12 ++-- .../guides/monetize-your-app-using-swap.mdx | 2 +- .../swap-tokens-with-0x-swap-api-permit2.mdx | 12 ++-- .../guides/swap-tokens-with-0x-swap-api.mdx | 17 ++--- .../guides/troubleshooting-swap-api.mdx | 4 +- fern/docs/pages/0x-swap-api/introduction.mdx | 28 ++------ fern/docs/pages/api-reference-overview.mdx | 8 +-- .../pages/core-concepts/0x-cheat-sheet.mdx | 38 +++------- fern/docs/pages/core-concepts/contracts.mdx | 13 ++-- .../guides/gasless-api-technical-appendix.mdx | 2 +- .../guides/get-started-with-gasless-api.mdx | 21 +++--- fern/docs/pages/gasless-api/introduction.mdx | 23 +----- fern/docs/pages/introduction/api-issues.mdx | 2 +- fern/docs/pages/introduction/faq.mdx | 43 ++++++------ .../pages/introduction/supported-chains.mdx | 2 +- .../trade-analytics-api/introduction.mdx | 2 +- .../upgrading/upgrading-to-gasless-v2.mdx | 8 +-- .../pages/upgrading/upgrading-to-swap-v2.mdx | 70 +++++++++---------- 22 files changed, 135 insertions(+), 202 deletions(-) diff --git a/fern/docs/pages/0x-swap-api/additional-topics/about-the-rfq-system.mdx b/fern/docs/pages/0x-swap-api/additional-topics/about-the-rfq-system.mdx index feef67dd..5a1b0b49 100644 --- a/fern/docs/pages/0x-swap-api/additional-topics/about-the-rfq-system.mdx +++ b/fern/docs/pages/0x-swap-api/additional-topics/about-the-rfq-system.mdx @@ -34,7 +34,7 @@ If integrators request a standard quote from the Swap API, part or all of their **Takers** -Takers fill 0x orders by agreeing to trade their asset for the Maker's asset; in other words, consume the 0x liquidity. When making a Swap API request, the RFQ orders must contain the [`taker`](/api-reference/openapi-yaml/swap/permit-2-getquote) request parameter. When an order containing this parameter gets hashed and signed by two counterparties, it is exclusive to those two counterparties. This means that the order can only be filled by the taker address specified in the order. This is a security feature that prevents front-running and other types of attacks. +Takers fill 0x orders by agreeing to trade their asset for the Maker's asset; in other words, consume the 0x liquidity. When making a Swap API request, the RFQ orders must contain the [`taker`](/api-reference/openapi-json/swap/permit-2-getquote) request parameter. When an order containing this parameter gets hashed and signed by two counterparties, it is exclusive to those two counterparties. This means that the order can only be filled by the taker address specified in the order. This is a security feature that prevents front-running and other types of attacks. **Market Makers** @@ -42,7 +42,7 @@ As mentioned earlier, 0x API works with specific market makers who participate i ## Integrating RFQ Liquidity -RFQ liquidity is included in a quote when `taker` is included in a [`/quote` request](/api-reference/openapi-yaml/swap/allowanceholder-getquote). +RFQ liquidity is included in a quote when `taker` is included in a [`/quote` request](/api-reference/openapi-json/swap/allowanceholder-getquote). ## Learn More diff --git a/fern/docs/pages/0x-swap-api/additional-topics/buy-sell-tax-support.mdx b/fern/docs/pages/0x-swap-api/additional-topics/buy-sell-tax-support.mdx index 1e4d7ae7..34dbeadb 100644 --- a/fern/docs/pages/0x-swap-api/additional-topics/buy-sell-tax-support.mdx +++ b/fern/docs/pages/0x-swap-api/additional-topics/buy-sell-tax-support.mdx @@ -71,7 +71,7 @@ Example 2: Both buy (SMI) and sell tokens (FLOKI) have buy and sell taxes, respe -Use the `tokenMetadata` object returned in the `/price` and `/quote` endpoints for both [Swap and Gasless API calls](/api-reference/openapi-yaml/swap/allowanceholder-getprice). This object contains the buy/sell tax information for the tokens involved in the swap. +Use the `tokenMetadata` object returned in the `/price` and `/quote` endpoints for both [Swap and Gasless API calls](/api-reference/openapi-json/swap/allowanceholder-getprice). This object contains the buy/sell tax information for the tokens involved in the swap. Example response: diff --git a/fern/docs/pages/0x-swap-api/additional-topics/how-to-set-your-token-allowances.mdx b/fern/docs/pages/0x-swap-api/additional-topics/how-to-set-your-token-allowances.mdx index 62a33b49..a8187052 100644 --- a/fern/docs/pages/0x-swap-api/additional-topics/how-to-set-your-token-allowances.mdx +++ b/fern/docs/pages/0x-swap-api/additional-topics/how-to-set-your-token-allowances.mdx @@ -7,10 +7,10 @@ To allow a third-party service—such as the 0x API—to move your ERC-20 tokens Which contract to approve depends on the API endpoint you're using: -| API Endpoint | Allowance Target Contract | -| ------------------------------------------------------------------------- | ------------------------- | -| [`/swap/allowance-holder`](/api-reference/openapi-yaml/swap/allowanceholder-getquote) | AllowanceHolder | -| [`/swap/permit2`](/api-reference/openapi-yaml/swap/permit-2-getquote) | Permit2 | +| API Endpoint | Allowance Target Contract | +| ------------------------------------------------------------------------------------- | ------------------------- | +| [`/swap/allowance-holder`](/api-reference/openapi-json/swap/allowanceholder-getquote) | AllowanceHolder | +| [`/swap/permit2`](/api-reference/openapi-json/swap/permit-2-getquote) | Permit2 | The wallet holding the tokens (`taker`) must approve the contract address returned in `issues.allowance.spender` or `allowanceTarget` from the `/price` or `/quote` response. @@ -37,7 +37,7 @@ In API v2, **allowance management** and **swap execution** are handled by **diff This separation enhances security by isolating allowance management from swap execution. - + - NEVER set an allowance on the [Settler contract](/docs/core-concepts/contracts#0x-settler-contract). Doing so may result in unintended consequences, including potential loss of tokens or exposure to security risks. The Settler contract does not support or require token allowances for its operation. Setting an allowance on the Settler contract will lead to misuse by other parties. @@ -45,7 +45,7 @@ This separation enhances security by isolating allowance management from swap ex - The correct allowance target is returned in `issues.allowance.spender` or `allowanceTarget`. - + Example response from `/swap/permit2/quote` will return back the contract address if an allowance needs to be set: diff --git a/fern/docs/pages/0x-swap-api/guides/build-token-swap-dapp-nextjs-permit2.mdx b/fern/docs/pages/0x-swap-api/guides/build-token-swap-dapp-nextjs-permit2.mdx index c16e282a..4b0fc24a 100644 --- a/fern/docs/pages/0x-swap-api/guides/build-token-swap-dapp-nextjs-permit2.mdx +++ b/fern/docs/pages/0x-swap-api/guides/build-token-swap-dapp-nextjs-permit2.mdx @@ -102,7 +102,7 @@ const projectId = process.env.NEXT_PUBLIC_WALLET_CONNECT_PROJECT_ID as string; / ### What is it? -PriceView displays indicative pricing using[/swap/allowance-holder/price](/api-reference/openapi-yaml/swap/permit-2-getprice). Indicative pricing is for users to browse for a price without committing to a trade. +PriceView displays indicative pricing using[/swap/allowance-holder/price](/api-reference/openapi-json/swap/permit-2-getprice). Indicative pricing is for users to browse for a price without committing to a trade. Indicative prices: @@ -135,7 +135,7 @@ Firm quotes are fetched later in QuoteView. #### Token Allowances & Approvals - + Important: Read Before Using 0x API @@ -145,7 +145,7 @@ Important: Read Before Using 0x API - The correct allowance target is returned in `issues.allowance.spender` or `allowanceTarget`. - + Before placing a trade on the PageView, users must set allowances on all tokens involved. A token allowance lets a third party move funds on your behalf. Essentially, you permit them to move your tokens. @@ -174,7 +174,7 @@ The logic to check if the user has approved a token allowance the selected sell ### What is it? -QuoteView displays a firm, executable quote returned from [/swap/allowance-holder/quote](/api-reference/openapi-yaml/swap/permit-2-getquote). +QuoteView displays a firm, executable quote returned from [/swap/allowance-holder/quote](/api-reference/openapi-json/swap/permit-2-getquote). Firm quotes: @@ -289,8 +289,8 @@ Swap API provides two built-in ways to monetize your swap integration—availabl For implementation details and pricing considerations, see the [how to monetize your app using 0x Swap API](/docs/0x-swap-api/guides/monetize-your-app-using-swap). -1 Trade surplus is available only to select integrators on a custom plan. -Contact support for access. +1 Trade surplus is available only to select integrators on a custom +plan. Contact support for access. ## Conclusion diff --git a/fern/docs/pages/0x-swap-api/guides/build-token-swap-dapp-nextjs.mdx b/fern/docs/pages/0x-swap-api/guides/build-token-swap-dapp-nextjs.mdx index b35b49b0..8036cfdb 100644 --- a/fern/docs/pages/0x-swap-api/guides/build-token-swap-dapp-nextjs.mdx +++ b/fern/docs/pages/0x-swap-api/guides/build-token-swap-dapp-nextjs.mdx @@ -92,7 +92,7 @@ const projectId = process.env.NEXT_PUBLIC_WALLET_CONNECT_PROJECT_ID as string; / ### What is it? -PriceView displays indicative pricing using[/swap/allowance-holder/price](/api-reference/openapi-yaml/swap/allowanceholder-getprice). Indicative pricing is for users to browse for a price without committing to a trade. +PriceView displays indicative pricing using[/swap/allowance-holder/price](/api-reference/openapi-json/swap/allowanceholder-getprice). Indicative pricing is for users to browse for a price without committing to a trade. Indicative prices: @@ -125,7 +125,7 @@ Firm quotes are fetched later in QuoteView. #### Token Allowances & Approvals - + Important: Read Before Using 0x API @@ -135,7 +135,7 @@ Important: Read Before Using 0x API - The correct allowance target is returned in `issues.allowance.spender` or `allowanceTarget`. - + Before placing a trade on the PageView, users must set allowances on all tokens involved. A token allowance lets a third party move funds on your behalf. Essentially, you permit them to move your tokens. @@ -164,7 +164,7 @@ The logic to check if the user has approved a token allowance the selected sell ### What is it? -QuoteView displays a firm, executable quote returned from [/swap/allowance-holder/quote](/api-reference/openapi-yaml/swap/allowanceholder-getquote). +QuoteView displays a firm, executable quote returned from [/swap/allowance-holder/quote](/api-reference/openapi-json/swap/allowanceholder-getquote). Firm quotes: @@ -245,8 +245,8 @@ Swap API provides two built-in ways to monetize your swap integration—availabl For implementation details and pricing considerations, see the [how to monetize your app using 0x Swap API](./monetize-your-app-using-swap). -1 Trade surplus is available only to select integrators on a custom plan. -Contact support for access. +1 Trade surplus is available only to select integrators on a custom +plan. Contact support for access. ## Conclusion diff --git a/fern/docs/pages/0x-swap-api/guides/monetize-your-app-using-swap.mdx b/fern/docs/pages/0x-swap-api/guides/monetize-your-app-using-swap.mdx index 863fdef6..1795b4a8 100644 --- a/fern/docs/pages/0x-swap-api/guides/monetize-your-app-using-swap.mdx +++ b/fern/docs/pages/0x-swap-api/guides/monetize-your-app-using-swap.mdx @@ -31,7 +31,7 @@ Out-of-the-box, 0x Swap API offers two monetization options: 0x supports multiple affiliate fee (trading fees/commissions) within a single swap request. This allows you to route fees to multiple recipients with independently specified fee amounts — perfect for multi-product apps, partner revenue-share setups, or flexible monetization strategies. -To apply affiliate fees, include the following parameters in your [Swap API request](/api-reference/openapi-yaml/swap/allowanceholder-getprice): +To apply affiliate fees, include the following parameters in your [Swap API request](/api-reference/openapi-json/swap/allowanceholder-getprice): - `swapFeeRecipient` - The wallet address to receive the specified trading fees (supports single or multiple comma-separated values). - `swapFeeBps` - The fee amount(s), in basis points, to send to each corresponding `swapFeeRecipient`. Denoted in basis points (0–1000 Bps = 0–10%). diff --git a/fern/docs/pages/0x-swap-api/guides/swap-tokens-with-0x-swap-api-permit2.mdx b/fern/docs/pages/0x-swap-api/guides/swap-tokens-with-0x-swap-api-permit2.mdx index f0bb5df0..55afb4c5 100644 --- a/fern/docs/pages/0x-swap-api/guides/swap-tokens-with-0x-swap-api-permit2.mdx +++ b/fern/docs/pages/0x-swap-api/guides/swap-tokens-with-0x-swap-api-permit2.mdx @@ -69,7 +69,7 @@ Every 0x API call requires an API key. [Create a 0x account](https://dashboard.0 Let's find the best price! -Use the [`/swap/permit2/price`](/api-reference/openapi-yaml/swap/permit-2-getprice) endpoint to get an indicative price for an asset pair. This returns pricing information without creating a full order or transaction, allowing the user to browse potential prices before committing. +Use the [`/swap/permit2/price`](/api-reference/openapi-json/swap/permit-2-getprice) endpoint to get an indicative price for an asset pair. This returns pricing information without creating a full order or transaction, allowing the user to browse potential prices before committing. Think of `/price` as the "read-only" version of `/quote`, which you'll use in step 3. @@ -95,7 +95,7 @@ const headers = { const priceResponse = await fetch( "https://api.0x.org/swap/permit2/price?" + priceParams.toString(), - { headers } + { headers }, ); console.log(await priceResponse.json()); @@ -268,14 +268,14 @@ Specify the amount of ERC20 tokens the contract can move. For implementation details, see [how to set your token allowances](/docs/0x-swap-api/additional-topics/how-to-set-your-token-allowances). - + - NEVER set an allowance on the [Settler contract](/docs/core-concepts/0x-cheat-sheet#0x-settler-contracts). Doing so may result in unintended consequences, including potential loss of tokens or exposure to security risks. The Settler contract does not support or require token allowances for its operation. Setting an allowance on the Settler contract will lead to misuse by other parties. - ONLY set allowances on [AllowanceHolder](/docs/core-concepts/0x-cheat-sheet#allowanceholder-contract) or [Permit2](/docs/core-concepts/0x-cheat-sheet#permit2-contract) contracts, as indicated by the API responses. - The correct allowance target is returned in `issues.allowance.spender` or `allowanceTarget`. - + When setting the token allowance, make sure to provide enough allowance for @@ -309,7 +309,7 @@ if (sellToken.address === CONTRACTS.ETH) { const hash = await sellToken.write.approve(request.args); console.log( "Approved Permit2 to spend sellToken.", - await client.waitForTransactionReceipt({ hash }) + await client.waitForTransactionReceipt({ hash }), ); } catch (error) { console.log("Error approving Permit2:", error); @@ -322,7 +322,7 @@ if (sellToken.address === CONTRACTS.ETH) { ## 3. Fetch a Firm Quote -When you're ready to execute a trade, request a firm quote from the Swap API using [`/swap/permit2/quote`](/api-reference/openapi-yaml/swap/permit-2-getquote). This signals a soft commitment to complete the trade. +When you're ready to execute a trade, request a firm quote from the Swap API using [`/swap/permit2/quote`](/api-reference/openapi-json/swap/permit-2-getquote). This signals a soft commitment to complete the trade. The response includes a full 0x order, ready for submission to the network. The Market Maker is expected to have reserved the necessary assets, reducing the likelihood of order reversion. diff --git a/fern/docs/pages/0x-swap-api/guides/swap-tokens-with-0x-swap-api.mdx b/fern/docs/pages/0x-swap-api/guides/swap-tokens-with-0x-swap-api.mdx index b51aa84a..988797c3 100644 --- a/fern/docs/pages/0x-swap-api/guides/swap-tokens-with-0x-swap-api.mdx +++ b/fern/docs/pages/0x-swap-api/guides/swap-tokens-with-0x-swap-api.mdx @@ -17,11 +17,12 @@ The API handles three key tasks: ## What You Will Learn -This guide will cover the core steps to using Swap API, specifically using the [Swap AllowanceHolder](/api-reference/openapi-yaml/swap/allowanceholder-getprice) endpoint. +This guide will cover the core steps to using Swap API, specifically using the [Swap AllowanceHolder](/api-reference/openapi-json/swap/allowanceholder-getprice) endpoint. {" "} - Learn about the [difference between AllowanceHolder and Permit2 in Swap API](/docs/introduction/faq#allowanceholder-and-permit2){" "} + Learn about the [difference between AllowanceHolder and Permit2 in Swap + API](/docs/introduction/faq#allowanceholder-and-permit2){" "} ## Playground @@ -56,7 +57,7 @@ Every 0x API call requires an API key. [Create a 0x account](https://dashboard.0 Let's find the best price! -Use the [`/swap/allowance-holder/price`](/api-reference/openapi-yaml/swap/allowanceholder-getprice) endpoint to get an indicative price for an asset pair. This returns pricing information without creating a full order or transaction, allowing the user to browse potential prices before committing. +Use the [`/swap/allowance-holder/price`](/api-reference/openapi-json/swap/allowanceholder-getprice) endpoint to get an indicative price for an asset pair. This returns pricing information without creating a full order or transaction, allowing the user to browse potential prices before committing. Think of `/price` as the "read-only" version of `/quote`, which you'll use in step 3. @@ -84,7 +85,7 @@ const priceResponse = await fetch( "https://api.0x.org/swap/allowance-holder/price?" + priceParams.toString(), { headers, - } + }, ); console.log(await priceResponse.json()); @@ -245,7 +246,7 @@ Specify the amount of ERC20 tokens the contract can use. For detailed instructions, see [how to set your token allowances](/docs/0x-swap-api/additional-topics/how-to-set-your-token-allowances). - + - NEVER set an allowance on the [Settler contract](/docs/core-concepts/contracts#0x-settler-contract). Doing so may result in unintended consequences, including potential loss of tokens or exposure to security risks. The Settler contract does not support or require token allowances for its operation. Setting an allowance on the Settler contract will lead to misuse by other parties. @@ -253,7 +254,7 @@ For detailed instructions, see [how to set your token allowances](/docs/0x-swap- - The correct allowance target is returned in `issues.allowance.spender` or `allowanceTarget`. - + When setting the token allowance, make sure to provide enough allowance for @@ -282,7 +283,7 @@ if (price.issues.allowance !== null) { const hash = await usdc.write.approve(request.args); console.log( "Approved AllowanceHolder to spend USDC.", - await client.waitForTransactionReceipt({ hash }) + await client.waitForTransactionReceipt({ hash }), ); } catch (error) { console.log("Error approving AllowanceHolder:", error); @@ -294,7 +295,7 @@ if (price.issues.allowance !== null) { ## 3. Fetch a Firm Quote -When you're ready to execute a trade, request a firm quote from the Swap API using [`/swap/allowance-holder/quote`](/api-reference/openapi-yaml/swap/allowanceholder-getquote). This signals a soft commitment to complete the trade. +When you're ready to execute a trade, request a firm quote from the Swap API using [`/swap/allowance-holder/quote`](/api-reference/openapi-json/swap/allowanceholder-getquote). This signals a soft commitment to complete the trade. The response includes a full 0x order, ready for submission to the network. The Market Maker is expected to have reserved the necessary assets, reducing the likelihood of order reversion. diff --git a/fern/docs/pages/0x-swap-api/guides/troubleshooting-swap-api.mdx b/fern/docs/pages/0x-swap-api/guides/troubleshooting-swap-api.mdx index 9f171332..69a40c3e 100644 --- a/fern/docs/pages/0x-swap-api/guides/troubleshooting-swap-api.mdx +++ b/fern/docs/pages/0x-swap-api/guides/troubleshooting-swap-api.mdx @@ -19,14 +19,14 @@ Check the value returned by the `liquidityAvailable` field that validates the av The taker (the address which holds the `sellToken` balance and is executing the swap transaction) should hold at _least_ the `sellAmount` of `sellToken`. The taker also should approve the `issues.allowance.spender` (AllowanceHolder or Permit2 contracts) to spend at least the same amount for that token. - + - NEVER set an allowance on the [Settler contract](/docs/core-concepts/contracts#0x-settler-contract). Doing so may result in unintended consequences, including potential loss of tokens or exposure to security risks. The Settler contract does not support or require token allowances for its operation. Setting an allowance on the Settler contract will lead to misuse by other parties. - ONLY set allowances on [AllowanceHolder](/docs/core-concepts/contracts#allowanceholder-recommended) or [Permit2](/docs/core-concepts/contracts#permit2-advanced-use-only) contracts, as indicated by the API responses. - The correct allowance target is returned in `issues.allowance.spender` or `allowanceTarget`. - + ## Gas Limits The transaction needs to be submitted with enough gas. Due to the nondeterministic nature of the on-chain settlement process, the swap may require more than what an `eth_estimateGas` RPC call returns. The quoted response will return `transacation.gas` which is the estimated limit that should be used to send the transaction to guarntee settlement. Any unused gas will be refunded to the transaction submitter. diff --git a/fern/docs/pages/0x-swap-api/introduction.mdx b/fern/docs/pages/0x-swap-api/introduction.mdx index ed23e7c1..6877901f 100644 --- a/fern/docs/pages/0x-swap-api/introduction.mdx +++ b/fern/docs/pages/0x-swap-api/introduction.mdx @@ -45,7 +45,7 @@ curl --request GET \ ``` You’ll receive an unsigned Ethereum transaction that can be [signed and submitted](/docs/introduction/quickstart/getting-started#4-submit-the-transaction) directly to a node. -Learn more about the response parameters in the [API docs](/api-reference/openapi-yaml/swap/allowanceholder-getprice). +Learn more about the response parameters in the [API docs](/api-reference/openapi-json/swap/allowanceholder-getprice). ```bash @@ -360,7 +360,8 @@ Below is a high-level diagram showing how Swap API works under the hood: 0x. -For more details about how 0x orders are executed, check out [How does 0x work?](/docs/core-concepts/introduction-to-0x#how-does-0x-work) +For more details about how 0x orders are executed, check out [How does 0x +work?](/docs/core-concepts/introduction-to-0x#how-does-0x-work) Under the hood, Swap API performs a series of tasks: @@ -370,28 +371,7 @@ Under the hood, Swap API performs a series of tasks: ## Supported Chains -Swap and Gasless v2 APIs are currently supported on the following chains. Select the chain in your request by providing the corresponding `chainId` request parameter. To request support for a new chain, please submit a request [here](https://0x.canny.io/request-features). - -| Chain | Chain ID | Swap API | Gasless API | -| :----------------- | :------- | :------- | :---------- | -| Ethereum (Mainnet) | 1 | ✅ | ✅ | -| Abstract | 2741 | ✅ | | -| Arbitrum | 42161 | ✅ | ✅ | -| Avalanche | 43114 | ✅ | ✅ | -| Base | 8453 | ✅ | ✅ | -| Berachain | 80094 | ✅ | | -| Blast | 81457 | ✅ | ✅ | -| BSC | 56 | ✅ | ✅ | -| Ink | 57073 | ✅ | | -| Linea | 59144 | ✅ | | -| Mantle | 5000 | ✅ | ✅ | -| Mode | 34443 | ✅ | ✅ | -| Monad | 10143 | ✅ | | -| Optimism | 10 | ✅ | ✅ | -| Polygon | 137 | ✅ | ✅ | -| Scroll | 534352 | ✅ | ✅ | -| Unichain | 130 | ✅ | | -| World Chain | 480 | ✅ | | +Swap API supports multiple blockchain networks. Refer to the [Supported Chains](/docs/introduction/supported-chains) page for the full list of currently supported networks and chain IDs. ## Get Started diff --git a/fern/docs/pages/api-reference-overview.mdx b/fern/docs/pages/api-reference-overview.mdx index 45245e8c..49f195b3 100644 --- a/fern/docs/pages/api-reference-overview.mdx +++ b/fern/docs/pages/api-reference-overview.mdx @@ -9,10 +9,10 @@ The 0x API provides a unified interface for liquidity aggregation, token swap pr The 0x API exposes endpoints for the following core capabilities: -- **[Swap](/api-reference/openapi-yaml/swap/allowanceholder-getprice)**: Generate executable quotes and calldata for token swaps using either the AllowanceHolder (recommended) or Permit2 approval models. Learn more in the [FAQ](/docs/introduction/faq#allowanceholder-and-permit2). -- **[Gasless](/api-reference/openapi-yaml/gasless/getprice)**: Enable gasless swaps by sponsoring transaction fees on behalf of users, improving UX for end-user applications. -- **[Sources](/api-reference/openapi-yaml/sources/getsources)**: Retrieve supported liquidity sources, chains, and token metadata used by the 0x routing engine. -- **[Trade Analytics](/api-reference/openapi-yaml/trade-analytics/trade-analytics-swap)**: Query historical trade data, volumes, and execution details for monitoring and analytics use cases. +- **[Swap](/api-reference/openapi-json/swap/allowanceholder-getprice)**: Generate executable quotes and calldata for token swaps using either the AllowanceHolder (recommended) or Permit2 approval models. Learn more in the [FAQ](/docs/introduction/faq#allowanceholder-and-permit2). +- **[Gasless](/api-reference/openapi-json/gasless/getprice)**: Enable gasless swaps by sponsoring transaction fees on behalf of users, improving UX for end-user applications. +- **[Sources](/api-reference/openapi-json/sources/getsources)**: Retrieve supported liquidity sources, chains, and token metadata used by the 0x routing engine. +- **[Trade Analytics](/api-reference/openapi-json/trade-analytics/trade-analytics-swap)**: Query historical trade data, volumes, and execution details for monitoring and analytics use cases. Each API surface is documented in detail in the sections below. diff --git a/fern/docs/pages/core-concepts/0x-cheat-sheet.mdx b/fern/docs/pages/core-concepts/0x-cheat-sheet.mdx index b08a9b9e..110b0e6d 100644 --- a/fern/docs/pages/core-concepts/0x-cheat-sheet.mdx +++ b/fern/docs/pages/core-concepts/0x-cheat-sheet.mdx @@ -5,30 +5,7 @@ description: A resource for supported chains, example calls, contracts, and orde ## Supported Chains -Swap and Gasless v2 APIs are currently supported on the following chains. Select the chain in your request by providing the corresponding `chainId` request parameter. To request support for a new chain, please submit a request [here](https://0x.canny.io/request-features). - -| Chain | Chain ID | Swap API | Gasless API | -| ------------------ | -------- | -------- | ----------- | -| Ethereum (Mainnet) | 1 | ✅ | ✅ | -| Abstract | 2741 | ✅ | | -| Arbitrum | 42161 | ✅ | ✅ | -| Avalanche | 43114 | ✅ | ✅ | -| Base | 8453 | ✅ | ✅ | -| Berachain | 80094 | ✅ | | -| Blast | 81457 | ✅ | ✅ | -| BSC | 56 | ✅ | ✅ | -| Ink | 57073 | ✅ | | -| Linea | 59144 | ✅ | | -| Mantle | 5000 | ✅ | ✅ | -| Mode | 34443 | ✅ | ✅ | -| Monad | 10143 | ✅ | | -| Optimism | 10 | ✅ | ✅ | -| Plasma | 9745 | ✅ | ✅ | -| Polygon | 137 | ✅ | ✅ | -| Scroll | 534352 | ✅ | ✅ | -| Sonic | 146 | ✅ | ✅ | -| Unichain | 130 | ✅ | | -| World Chain | 480 | ✅ | | +Swap and Gasless APIs support multiple blockchain networks. Refer to the [Supported Chains](/docs/introduction/supported-chains) page for the full list of currently supported networks and chain IDs. ## Swap API v2 @@ -679,14 +656,15 @@ This section provides an overview of the three main contracts developers need to ### A Note About Setting Token Allowances - + + - NEVER set an allowance on the [Settler contract](/docs/core-concepts/contracts#0x-settler-contract). Doing so may result in unintended consequences, including potential loss of tokens or exposure to security risks. The Settler contract does not support or require token allowances for its operation. Setting an allowance on the Settler contract will lead to misuse by other parties. - ONLY set allowances on [AllowanceHolder](/docs/core-concepts/0x-cheat-sheet#allowanceholder-recommended) or [Permit2](/docs/core-concepts/0x-cheat-sheet#permit2-advanced-use-only) contracts, as indicated by the API responses. - The correct allowance target is returned in `issues.allowance.spender` or `allowanceTarget`. - + ### 0x Settler @@ -720,8 +698,8 @@ AllowanceHolder is recommended for most integrators, and it is especially well-s Endpoints: -- [/swap/allowance-holder/price](/api-reference/openapi-yaml/swap/allowanceholder-getprice) -- [/swap/allowance-holder/quote](/api-reference/openapi-yaml/swap/allowanceholder-getquote) +- [/swap/allowance-holder/price](/api-reference/openapi-json/swap/allowanceholder-getprice) +- [/swap/allowance-holder/quote](/api-reference/openapi-json/swap/allowanceholder-getquote) Key Points: @@ -748,8 +726,8 @@ When to use Permit2: Endpoints: -- [/swap/permit2/price](/api-reference/openapi-yaml/swap/permit-2-getprice) -- [/swap/permit2/quote](/api-reference/openapi-yaml/swap/permit-2-getquote) +- [/swap/permit2/price](/api-reference/openapi-json/swap/permit-2-getprice) +- [/swap/permit2/quote](/api-reference/openapi-json/swap/permit-2-getquote) Key Points: diff --git a/fern/docs/pages/core-concepts/contracts.mdx b/fern/docs/pages/core-concepts/contracts.mdx index 38005eb4..e7bc84cc 100644 --- a/fern/docs/pages/core-concepts/contracts.mdx +++ b/fern/docs/pages/core-concepts/contracts.mdx @@ -7,7 +7,7 @@ description: Learn about 0x Settler, AllowanceHolder, and Permit2 contracts. ## A Note about Setting Token Allowances - + - NEVER set an allowance on the [Settler contract](/docs/core-concepts/contracts#0x-settler-contract). Doing so may result in unintended consequences, including potential loss of tokens or exposure to security risks. The Settler contract does not support or require token allowances for its operation. Setting an allowance on the Settler contract will lead to misuse by other parties. @@ -15,7 +15,7 @@ description: Learn about 0x Settler, AllowanceHolder, and Permit2 contracts. - The correct allowance target is returned in `issues.allowance.spender` or `allowanceTarget`. - + ## Allowance Target vs. Entry Point @@ -75,7 +75,6 @@ For v2, we strongly advise **against hardcoding** any entry point contract addre - For a comprehensive list of all Settler addresses (past, current, and predicted next hundred), [download the settler_predictions.tar.xz file here](https://github.com/0xProject/0x-examples/blob/main/settler_predictions.tar.xz). - In the list, each chain includes the following address types: - - **Taker Address (tokenId = 2)** — Used by users or smart contracts submitting swaps or trades. This is the address used when the taker (caller or end user) submits the transaction. - **Metatransaction Address (tokenId = 3)** — Used when transactions are relayed or batched—e.g., for Gasless API flows. This is the address used by the meta-tx relayer - **Ignore (tokenId = 4)** - Ignore this address type. Not used for integrations. @@ -98,8 +97,8 @@ For v2, we strongly advise **against hardcoding** any entry point contract addre ### Endpoints -- [/swap/allowance-holder/price](/api-reference/openapi-yaml/swap/allowanceholder-getprice) -- [/swap/allowance-holder/quote](/api-reference/openapi-yaml/swap/allowanceholder-getquote) +- [/swap/allowance-holder/price](/api-reference/openapi-json/swap/allowanceholder-getprice) +- [/swap/allowance-holder/quote](/api-reference/openapi-json/swap/allowanceholder-getquote) ### Who Should Use AllowanceHolder? @@ -152,8 +151,8 @@ Permit2 offers flexible approvals with features like time-limited and granular a ### Endpoints -- [/swap/permit2/price](/api-reference/openapi-yaml/swap/permit-2-getprice) -- [/swap/permit2/quote](/api-reference/openapi-yaml/swap/permit-2-getquote) +- [/swap/permit2/price](/api-reference/openapi-json/swap/permit-2-getprice) +- [/swap/permit2/quote](/api-reference/openapi-json/swap/permit-2-getquote) ### Who Should Use Permit2? diff --git a/fern/docs/pages/gasless-api/guides/gasless-api-technical-appendix.mdx b/fern/docs/pages/gasless-api/guides/gasless-api-technical-appendix.mdx index 1496191f..e124d7e6 100644 --- a/fern/docs/pages/gasless-api/guides/gasless-api-technical-appendix.mdx +++ b/fern/docs/pages/gasless-api/guides/gasless-api-technical-appendix.mdx @@ -24,7 +24,7 @@ Checkout the [Gasless API Runnable Headless Example](https://github.com/0xProjec ## Signing objects -To take advantage of gaslesses approvals and gasless trades, user must sign the `approval.eip712` and the `trade.eip712` objects returned by [`/quote`](/api-reference/openapi-yaml/gasless/getquote). These objects contain everything (domain, types, primaryType, message) needed when signing these objects . +To take advantage of gaslesses approvals and gasless trades, user must sign the `approval.eip712` and the `trade.eip712` objects returned by [`/quote`](/api-reference/openapi-json/gasless/getquote). These objects contain everything (domain, types, primaryType, message) needed when signing these objects . There are different EIP-712 signing strategies if you are user facing wallet that shows the users the details of what they are signing. Some commonly used tools for this include: diff --git a/fern/docs/pages/gasless-api/guides/get-started-with-gasless-api.mdx b/fern/docs/pages/gasless-api/guides/get-started-with-gasless-api.mdx index 620f15b6..f8acc7dd 100644 --- a/fern/docs/pages/gasless-api/guides/get-started-with-gasless-api.mdx +++ b/fern/docs/pages/gasless-api/guides/get-started-with-gasless-api.mdx @@ -71,9 +71,9 @@ You will be able to enable Gasless API in your app from "App Settings" in your [ ## 1. Fetch Price -Use [`/gasless/price`](/api-reference/openapi-yaml/gasless/getprice) to get the indicative price. This is used when the user is just _browsing_ for the price they could receive on the specified asset pair, but they are not ready to submit the quote yet. +Use [`/gasless/price`](/api-reference/openapi-json/gasless/getprice) to get the indicative price. This is used when the user is just _browsing_ for the price they could receive on the specified asset pair, but they are not ready to submit the quote yet. -This endpoint responds with pricing information, but the response does not contain a full 0x order, so it does not constitute a full transaction that can be submitted to the Ethereum network (you must use [`/gasless/quote`](/api-reference/openapi-yaml/gasless/getquote) for this). Think of `/price` as the the "read-only" version of `/quote`. +This endpoint responds with pricing information, but the response does not contain a full 0x order, so it does not constitute a full transaction that can be submitted to the Ethereum network (you must use [`/gasless/quote`](/api-reference/openapi-json/gasless/getquote) for this). Think of `/price` as the the "read-only" version of `/quote`. ### Example Request @@ -160,7 +160,7 @@ curl --request GET \ ## 2. Fetch Quote -When the user has found a price they are happy with and are ready to fill a quote, they should request a firm quote from Gasless API using the [`/gasless/quote`](/api-reference/openapi-yaml/gasless/getquote) endpoint. At this point, the taker is making a soft commitment to fill the suggested orders, and understands they may be penalized by the [Market Maker](/docs/core-concepts/glossary#maker) if they do not. +When the user has found a price they are happy with and are ready to fill a quote, they should request a firm quote from Gasless API using the [`/gasless/quote`](/api-reference/openapi-json/gasless/getquote) endpoint. At this point, the taker is making a soft commitment to fill the suggested orders, and understands they may be penalized by the [Market Maker](/docs/core-concepts/glossary#maker) if they do not. Quotes expire in ~ 30s in order to ensure freshness. Make sure to take this @@ -458,17 +458,16 @@ https://api.0x.org/gasless/quote?chainId=137&buyToken=0x0d500B1d8E8eF31E21C99d1D If liquidity is available, 2 objects may be returned: -- `approval`: This is the “approval” object which contains the necessary information to process a gasless approval. See the [quote response](/api-reference/openapi-yaml/gasless/getquote#option-1) for an example. - +- `approval`: This is the “approval” object which contains the necessary information to process a gasless approval. See the [quote response](/api-reference/openapi-json/gasless/getquote#option-1) for an example. - If a gasless approval is possible, this object includes all the required information to process it. - If a gasless approval is **not** possible, this object will be `null`, and you must use the [standard approval flow](/docs/gasless-api/guides/understanding-gasless-api#technical-flow-charts) to [set a token allowance](/docs/0x-swap-api/additional-topics/how-to-set-your-token-allowances). NEVER SET AN ALLOWANCE ON THE SETTLER CONTRACT. - - You can also see all the token addresses that support gasless approvals with the [`/gasless-approval-tokens`](/api-reference/openapi-yaml/gasless/getgaslessapprovaltokens) endpoint. + - You can also see all the token addresses that support gasless approvals with the [`/gasless-approval-tokens`](/api-reference/openapi-json/gasless/getgaslessapprovaltokens) endpoint. - `trade`: This is the "trade" object which contains the necessary information to process a gasless trade. See the quote response [here](/api-reference#tag/Gasless/operation/gasless::getQuote). ## 3. Submit Transaction -When user accepts the quote and wants to submit the trade, use [`/gasless/submit`](/api-reference/openapi-yaml/gasless/submit) to send both signatures back along with the payload from `/gasless/quote`. +When user accepts the quote and wants to submit the trade, use [`/gasless/submit`](/api-reference/openapi-json/gasless/submit) to send both signatures back along with the payload from `/gasless/quote`. In order to submit the trade, we must complete the following: @@ -516,7 +515,7 @@ curl -X POST '' --header '0x-api-key: - Use the getChains{" "} + Use the getChains{" "} endpoint to get a list of supported chains for Swap. We offer two transparent, flexible tiers for Web3 businesses of all sizes. You can get started here. If you are a high-volume app or have a unique business model, please contact us to discuss a custom plan. - 0x takes an on-chain fee on swaps for select tokens for teams on the Standard tier. This fee is charged on-chain to your users during the transaction. In cases where we charge a fee, we return the value in the API response as zeroExFee. See the Swap API reference for details. + 0x takes an on-chain fee on swaps for select tokens for teams on the Standard tier. This fee is charged on-chain to your users during the transaction. In cases where we charge a fee, we return the value in the API response as zeroExFee. See the Swap API reference for details. @@ -219,8 +219,8 @@ amount = (swapFeeBps / 10000) * sellAmount // in sellToken base units Endpoints: Allowance target is returned in issues.allowance.spender or allowanceTarget. @@ -410,7 +410,7 @@ Read more about the contracts [here](/docs/core-concepts/contracts). Use the{" "} - getSources{" "} + getSources{" "} endpoint. @@ -425,13 +425,13 @@ Read more about the contracts [here](/docs/core-concepts/contracts). Gasless API provides a gasless experience at two points of the trade flow where users normally pay gas: **What doesn’t work:** - You can’t use Gasless API to sell a chain’s native coin (e.g., ETH on Mainnet, POL on Polygon). Native coins aren’t ERC-20s, so they lack transferFrom which the relay system uses. Use the Swap API instead (user pays gas in the native token) or have users wrap the coin (e.g., ETH → WETH). + You can’t use Gasless API to sell a chain’s native coin (e.g., ETH on Mainnet, POL on Polygon). Native coins aren’t ERC-20s, so they lack transferFrom which the relay system uses. Use the Swap API instead (user pays gas in the native token) or have users wrap the coin (e.g., ETH → WETH). **Work-arounds for tokens not supported by Gasless API:** @@ -444,7 +444,7 @@ Read more about the contracts [here](/docs/core-concepts/contracts). Use the{" "} - + Swap API {" "} (user pays gas in the native token), or have users wrap the native coin first @@ -461,16 +461,18 @@ Read more about the contracts [here](/docs/core-concepts/contracts). Both enable gasless-like UX, but they serve different purposes.

- In short: Permit (EIP-2612) is an ERC-20 extension - enabling gasless approvals via an EIP-712 signature — no on-chain tx — - but only for tokens that implement EIP-2612. Many older tokens (e.g., WETH) don’t, - so they still need a regular approve().
+ In short: Permit (EIP-2612) is an ERC-20 + extension enabling gasless approvals via an EIP-712 signature —{" "} + no on-chain tx — but only for tokens that implement EIP-2612. Many + older tokens (e.g., WETH) don’t, so they still need a regular{" "} + approve().

- Permit2 (by Uniswap Labs) is a universal approval contract for - any ERC-20. Users first do a standard gasful approve() to Permit2, - then future moves can be authorized via EIP-712 signatures (gasless for subsequent - swaps). This is useful when tokens don’t support permit() but you - want a consistent meta-tx flow. Permit2 is deployed at + Permit2 (by Uniswap Labs) is a universal approval contract + for any ERC-20. Users first do a standard gasful approve() to + Permit2, then future moves can be authorized via EIP-712 signatures (gasless + for subsequent swaps). This is useful when tokens don’t support{" "} + permit() but you want a consistent meta-tx flow. Permit2 is + deployed at 0x000000000022D473030F116dDEE9F6B43aC78BA3 on major chains.
@@ -489,7 +491,7 @@ Read more about the contracts [here](/docs/core-concepts/contracts). You have full flexibility on the fees you collect on trades.

- Include these parameters when making a Gasless API request: + Include these parameters when making a Gasless API request:
  • swapFeeRecipient — Wallet address to receive trading fees.
  • swapFeeBps — Fee in basis points (0–1000; 1000 Bps = 10%).
  • @@ -656,9 +658,8 @@ Read more about [accessing 0x transaction data here](/docs/core-concepts/transac audit reports - . Check out our - bounty program - . + . Check out our{" "} + bounty program. diff --git a/fern/docs/pages/introduction/supported-chains.mdx b/fern/docs/pages/introduction/supported-chains.mdx index e52d9ac1..44ee6b9e 100644 --- a/fern/docs/pages/introduction/supported-chains.mdx +++ b/fern/docs/pages/introduction/supported-chains.mdx @@ -3,7 +3,7 @@ title: Supported Chains description: This page provides a list of chains supported by 0x APIs. --- -Swap and Gasless APIs are currently supported on the following chains. Select the chain in your request by providing the corresponding `chainId` request parameter. To request support for a new chain, please submit a request [here](https://0x.canny.io/request-features). +Swap and Gasless APIs support the following chains. Select the chain in your request by providing the corresponding `chainId` request parameter. To request support for a new chain, please submit a request [here](https://0x.canny.io/request-features). | Chain | Chain ID | Swap API | Gasless API | | ------------------ | -------- | -------- | ----------- | diff --git a/fern/docs/pages/trade-analytics-api/introduction.mdx b/fern/docs/pages/trade-analytics-api/introduction.mdx index 5afc18af..f56919ac 100644 --- a/fern/docs/pages/trade-analytics-api/introduction.mdx +++ b/fern/docs/pages/trade-analytics-api/introduction.mdx @@ -34,7 +34,7 @@ Need real-time transaction parsing instead? ## Using Trade Analytics API -To start using the Trade Analytics API, use the [getSwapTrades](/api-reference/openapi-yaml/trade-analytics/trade-analytics-swap) and [getGaslessTrades](/api-reference/openapi-yaml/trade-analytics/trade-analytics-gasless) functions. Requests to the Trade Analytics APIs require a `0x-api-key`. Data will be returned for the app associated with API key in the request. +To start using the Trade Analytics API, use the [getSwapTrades](/api-reference/openapi-json/trade-analytics/trade-analytics-swap) and [getGaslessTrades](/api-reference/openapi-json/trade-analytics/trade-analytics-gasless) functions. Requests to the Trade Analytics APIs require a `0x-api-key`. Data will be returned for the app associated with API key in the request. ## Data diff --git a/fern/docs/pages/upgrading/upgrading-to-gasless-v2.mdx b/fern/docs/pages/upgrading/upgrading-to-gasless-v2.mdx index f368e447..62ab6087 100644 --- a/fern/docs/pages/upgrading/upgrading-to-gasless-v2.mdx +++ b/fern/docs/pages/upgrading/upgrading-to-gasless-v2.mdx @@ -428,13 +428,11 @@ To help provide developers a smooth build experience, 0x API v2 will do as much Note the following about the `issues` object for Price and Quote: - **Price** - - `allowance`: If this field is not `null`, prompt the user to set the allowance on `issues.allowance.spender` - `balance`: If this field is not `null`, do not proceed to get a `quote`. - `simulationIncomplete`: This field can be ignored for `price` since when calling price means aren't close to submitting a transaction (versus calling quote). Typically `simulationIncomplete: true` won't occur if the `taker` address is set and the `taker` has a sufficient balance of the sell token. - **Quote** - - `allowance`: This field should not appear if the `quote` is sent after the token allowance is set. - `balance`: This field will not be returned if the taker has sufficient balance when the `quote` request is sent. - `simulationIncomplete: true`: This field will not be returned if the taker has sufficient balance when the `quote` request is sent. @@ -451,9 +449,9 @@ With the introduction of the `issues.allowance` field in Gasless API v2, some fi ### Standard Token Approval Flow -In v2, for [tokens that do not support gasless approvals](/api-reference/openapi-yaml/gasless/getgaslessapprovaltokens), use the [standard token approval flow](/docs/0x-swap-api/additional-topics/how-to-set-your-token-allowances). +In v2, for [tokens that do not support gasless approvals](/api-reference/openapi-json/gasless/getgaslessapprovaltokens), use the [standard token approval flow](/docs/0x-swap-api/additional-topics/how-to-set-your-token-allowances). - + When using the [Standard Approval Flow](/docs/0x-swap-api/additional-topics/how-to-set-your-token-allowances) (aka Gasless Approvals are not supported) - NEVER set an allowance on the [Settler contract](/docs/core-concepts/0x-cheat-sheet#0x-settler-contracts). Doing so may result in unintended consequences, including potential loss of tokens or exposure to security risks. The Settler contract does not support or require token allowances for its operation. Setting an allowance on the Settler contract will lead to misuse by other parties. @@ -462,7 +460,7 @@ When using the [Standard Approval Flow](/docs/0x-swap-api/additional-topics/how- - The correct allowance target is returned in `issues.allowance.spender` or `allowanceTarget`. - + ## Detailed Migration Guide diff --git a/fern/docs/pages/upgrading/upgrading-to-swap-v2.mdx b/fern/docs/pages/upgrading/upgrading-to-swap-v2.mdx index c2308f96..cdd7e32a 100644 --- a/fern/docs/pages/upgrading/upgrading-to-swap-v2.mdx +++ b/fern/docs/pages/upgrading/upgrading-to-swap-v2.mdx @@ -333,7 +333,7 @@ This separation is a key architectural change from v1. This separation enhances security by isolating allowance management from swap execution. - + - NEVER set an allowance on the [Settler contract](/docs/core-concepts/0x-cheat-sheet#0x-settler). Doing so may result in unintended consequences, including potential loss of tokens or exposure to security risks. The Settler contract does not support or require token allowances for its operation. Setting an allowance on the Settler contract will lead to misuse by other parties. @@ -341,7 +341,7 @@ This separation enhances security by isolating allowance management from swap ex - The correct allowance target is returned in `issues.allowance.spender` or `allowanceTarget`. - + ### Updated URLs @@ -403,13 +403,11 @@ To help provide developers a smooth build experience, 0x API v2 will do as much Note the following about the `issues` object for Price and Quote: - **Price** - - `allowance`: If this field is not `null`, prompt the user to set the allowance on `issues.allowance.spender` - `balance`: If this field is not `null`, do not proceed to get a `quote`. - `simulationIncomplete`: This field can be ignored for `price` since when calling price means aren't close to submitting a transaction (versus calling quote). Typically `simulationIncomplete: true` won't occur if the `taker` address is set and the `taker` has a sufficient balance of the sell token. - **Quote** - - `allowance`: This field should not appear if the `quote` is sent after the token allowance is set. - `balance`: This field will not be returned if the taker has sufficient balance when the `quote` request is sent. - `simulationIncomplete: true`: This field will not be returned if the taker has sufficient balance when the `quote` request is sent. @@ -424,11 +422,11 @@ The following section overviews of how to update Swap API price and quote to han API?](/docs/introduction/faq#allowanceholder-and-permit2). -### Using Permit2 +### Using AllowanceHolder - ⚡️ See these steps in action in the [Permit2 headless - example](https://github.com/0xProject/0x-examples/tree/main/swap-v2-headless-example) +⚡️ See these steps in action in the [AllowanceHolder headless example](https://github.com/0xProject/0x-examples/tree/main/swap-v2-allowance-holder-headless-example) + #### Step 0. Get 0x API key @@ -437,7 +435,7 @@ The following section overviews of how to update Swap API price and quote to han #### Step 1. Get indicative price -- [ ] Call `/swap/permit2/price` ([code](https://github.com/0xProject/0x-examples/blob/main/swap-v2-headless-example/index.ts#L62-L83)) +- [ ] Call `/swap/allowance-holder/price` ([code](https://github.com/0xProject/0x-examples/blob/main/swap-v2-allowance-holder-headless-example/index.ts#L59-L79)) - [ ] Build required price params - [ ] Add `chainId` as new param - [ ] `takerAddress` has changed to `taker` @@ -445,39 +443,28 @@ The following section overviews of how to update Swap API price and quote to han #### Step 2. Set token allowance -- [ ] Check if `taker` needs to set an allowance for Permit2. If needed, set token allowance ([code](https://github.com/0xProject/0x-examples/blob/main/swap-v2-headless-example/index.ts#L85-L105)) +- [ ] Check if `taker` needs to set an allowance for AllowanceHolder. If needed, set token allowance ([code](https://github.com/0xProject/0x-examples/blob/main/swap-v2-allowance-holder-headless-example/index.ts#L81-L100)) - [ ] Use the info returned by `issues.allowance` returned by `/price` (if `taker` is set) and `/quote` which contains details of allowances that the `taker` must set for the order to execute successfully #### Step 3. Get firm quote -- [ ] Call `/swap/permit2/quote` ([code](https://github.com/0xProject/0x-examples/blob/main/swap-v2-headless-example/index.ts#L107-L122)) +- [ ] Call `/swap/allowance-holder/quote` ([code](https://github.com/0xProject/0x-examples/blob/main/swap-v2-allowance-holder-headless-example/index.ts#L102-L117)) - [ ] Build required quote params (price params + `taker` address) - [ ] Add `chainId` as new param - [ ] `takerAddress` has changed to `taker` - [ ] In the response: `sellTokenAddress` changed to `sellToken`, `buyTokenAddress` changed to `buyToken` ([code](https://github.com/0xProject/0x-examples/blob/main/swap-v2-headless-example/index.ts#L114-L131)) -#### Step 4. Sign Permit2 EIP-712 message - -- [ ] Sign the Permit2 EIP-712 message from `/quote` response - - [ ] `signature = await signTypedDataAsync(quote.permit2.eip712);` ([code](https://github.com/0xProject/0x-examples/blob/main/swap-v2-headless-example/index.ts#L124-L131)) - - [ ] Make sure `PriceResponse` and `QuoteResponse` types are up-to-date - -#### Step 5. Append signature length and signature data to transaction.data - -- [ ] Append the signature length and signature data to the `transaction.data`([code](https://github.com/0xProject/0x-examples/blob/main/swap-v2-headless-example/index.ts#L134-L149)) - -#### Step 6. Submit transaction with Permit2 signature - -- [ ] Submit the transaction with Permit2 signature - - [ ] Use `sendTransaction({account, gas, txOptions, data, value, chain)` ([code](https://github.com/0xProject/0x-examples/blob/main/swap-v2-headless-example/index.ts#L133-L166)) - - [ ] Note that the `/quote` response structure has changed from v1 to v2, specifically `to`, `gas` ,`data`, `value`, `gasPrice` → have moved under `quoteResponse.transaction.to`, `quoteResponse.transaction.gas`,`quoteResponse.transaction.data`, `quoteResponse.transaction.value`, `quoteResponse.transaction.gasPrice` ([code](https://github.com/0xProject/0x-examples/blob/main/swap-v2-headless-example/index.ts#L143-L154)) +#### Step 4. Submit transaction -### Using AllowanceHolder +- [ ] Submit the transaction using `sendTransaction()` ([code](https://github.com/0xProject/0x-examples/blob/main/swap-v2-allowance-holder-headless-example/index.ts#L119-L127)) + - [ ] Note that the `/quote` response structure has changed from v1 to v2, specifically `to`, `gas` ,`data`, `value`, `gasPrice` → have moved under `quoteResponse.transaction.to`, `quoteResponse.transaction.gas`,`quoteResponse.transaction.data`, `quoteResponse.transaction.value`, `quoteResponse.transaction.gasPrice` ([code](https://github.com/0xProject/0x-examples/blob/main/swap-v2-allowance-holder-headless-example/index.ts#L121-L122)) -:::tip -⚡️ See these steps in action in the [AllowanceHolder headless example](https://github.com/0xProject/0x-examples/tree/main/swap-v2-allowance-holder-headless-example) +### Using Permit2 -::: + + ⚡️ See these steps in action in the [Permit2 headless + example](https://github.com/0xProject/0x-examples/tree/main/swap-v2-permit2-headless-example) + #### Step 0. Get 0x API key @@ -485,7 +472,7 @@ The following section overviews of how to update Swap API price and quote to han #### Step 1. Get indicative price -- [ ] Call `/swap/allowance-holder/price` ([code](https://github.com/0xProject/0x-examples/blob/main/swap-v2-allowance-holder-headless-example/index.ts#L59-L79)) +- [ ] Call `/swap/permit2/price` ([code](https://github.com/0xProject/0x-examples/blob/main/swap-v2-permit2-headless-example/index.ts#L62-L83)) - [ ] Build required price params - [ ] Add `chainId` as new param - [ ] `takerAddress` has changed to `taker` @@ -493,21 +480,32 @@ The following section overviews of how to update Swap API price and quote to han #### Step 2. Set token allowance -- [ ] Check if `taker` needs to set an allowance for AllowanceHolder. If needed, set token allowance ([code](https://github.com/0xProject/0x-examples/blob/main/swap-v2-allowance-holder-headless-example/index.ts#L81-L100)) +- [ ] Check if `taker` needs to set an allowance for Permit2. If needed, set token allowance ([code](https://github.com/0xProject/0x-examples/blob/main/swap-v2-permit2-headless-example/index.ts#L85-L105)) - [ ] Use the info returned by `issues.allowance` returned by `/price` (if `taker` is set) and `/quote` which contains details of allowances that the `taker` must set for the order to execute successfully #### Step 3. Get firm quote -- [ ] Call `/swap/allowance-holder/quote` ([code](https://github.com/0xProject/0x-examples/blob/main/swap-v2-allowance-holder-headless-example/index.ts#L102-L117)) +- [ ] Call `/swap/permit2/quote` ([code](https://github.com/0xProject/0x-examples/blob/main/swap-v2-permit2-headless-example/index.ts#L107-L122)) - [ ] Build required quote params (price params + `taker` address) - [ ] Add `chainId` as new param - [ ] `takerAddress` has changed to `taker` - - [ ] In the response: `sellTokenAddress` changed to `sellToken`, `buyTokenAddress` changed to `buyToken` ([code](https://github.com/0xProject/0x-examples/blob/main/swap-v2-headless-example/index.ts#L114-L131)) + - [ ] In the response: `sellTokenAddress` changed to `sellToken`, `buyTokenAddress` changed to `buyToken` ([code](https://github.com/0xProject/0x-examples/blob/main/swap-v2-permit2-headless-example/index.ts#L114-L131)) -#### Step 4. Submit transaction +#### Step 4. Sign Permit2 EIP-712 message -- [ ] Submit the transaction using `sendTransaction()` ([code](https://github.com/0xProject/0x-examples/blob/main/swap-v2-allowance-holder-headless-example/index.ts#L119-L127)) - - [ ] Note that the `/quote` response structure has changed from v1 to v2, specifically `to`, `gas` ,`data`, `value`, `gasPrice` → have moved under `quoteResponse.transaction.to`, `quoteResponse.transaction.gas`,`quoteResponse.transaction.data`, `quoteResponse.transaction.value`, `quoteResponse.transaction.gasPrice` ([code](https://github.com/0xProject/0x-examples/blob/main/swap-v2-allowance-holder-headless-example/index.ts#L121-L122)) +- [ ] Sign the Permit2 EIP-712 message from `/quote` response + - [ ] `signature = await signTypedDataAsync(quote.permit2.eip712);` ([code](https://github.com/0xProject/0x-examples/blob/main/swap-v2-permit2-headless-example/index.ts#L124-L131)) + - [ ] Make sure `PriceResponse` and `QuoteResponse` types are up-to-date + +#### Step 5. Append signature length and signature data to transaction.data + +- [ ] Append the signature length and signature data to the `transaction.data`([code](https://github.com/0xProject/0x-examples/blob/main/swap-v2-permit2-headless-example/index.ts#L134-L149)) + +#### Step 6. Submit transaction with Permit2 signature + +- [ ] Submit the transaction with Permit2 signature + - [ ] Use `sendTransaction({account, gas, txOptions, data, value, chain)` ([code](https://github.com/0xProject/0x-examples/blob/main/swap-v2-permit2-headless-example/index.ts#L133-L166)) + - [ ] Note that the `/quote` response structure has changed from v1 to v2, specifically `to`, `gas` ,`data`, `value`, `gasPrice` → have moved under `quoteResponse.transaction.to`, `quoteResponse.transaction.gas`,`quoteResponse.transaction.data`, `quoteResponse.transaction.value`, `quoteResponse.transaction.gasPrice` ([code](https://github.com/0xProject/0x-examples/blob/main/swap-v2-headless-example/index.ts#L143-L154)) ## Migration FAQ