Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,15 @@ 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**

As mentioned earlier, 0x API works with specific market makers who participate in the RFQ system. Each maker is identified by an HTTP endpoint URL, and each endpoint has an associated list of asset pairs for which that endpoint will provide quotes. For the instance at `api.0x.org`, the 0x team is maintaining a list of trusted market makers.

## 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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ Example 2: Both buy (SMI) and sell tokens (FLOKI) have buy and sell taxes, respe

<Accordion title="Step 2: Utilize API Response Parameters">

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:

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand All @@ -37,15 +37,15 @@ In API v2, **allowance management** and **swap execution** are handled by **diff

This separation enhances security by isolating allowance management from swap execution.

<Note>
<Warning>

- 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`.

</Note>
</Warning>

Example response from `/swap/permit2/quote` will return back the contract address if an allowance needs to be set:

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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:

Expand Down Expand Up @@ -135,7 +135,7 @@ Firm quotes are fetched later in QuoteView.

#### Token Allowances & Approvals

<Note>
<Warning>

Important: Read Before Using 0x API

Expand All @@ -145,7 +145,7 @@ Important: Read Before Using 0x API

- The correct allowance target is returned in `issues.allowance.spender` or `allowanceTarget`.

</Note>
</Warning>

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.

Expand Down Expand Up @@ -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:

Expand Down Expand Up @@ -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).

<sup>1</sup> Trade surplus is available only to select integrators on a custom plan.
Contact support for access.
<sup>1</sup> Trade surplus is available only to select integrators on a custom
plan. Contact support for access.

## Conclusion

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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:

Expand Down Expand Up @@ -125,7 +125,7 @@ Firm quotes are fetched later in QuoteView.

#### Token Allowances & Approvals

<Note>
<Warning>

Important: Read Before Using 0x API

Expand All @@ -135,7 +135,7 @@ Important: Read Before Using 0x API

- The correct allowance target is returned in `issues.allowance.spender` or `allowanceTarget`.

</Note>
</Warning>

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.

Expand Down Expand Up @@ -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:

Expand Down Expand Up @@ -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).

<sup>1</sup> Trade surplus is available only to select integrators on a custom plan.
Contact support for access.
<sup>1</sup> Trade surplus is available only to select integrators on a custom
plan. Contact support for access.

## Conclusion

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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%).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand All @@ -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());
Expand Down Expand Up @@ -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).

<Note>
<Warning>
- 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`.

</Note>
</Warning>

<Tip>
When setting the token allowance, make sure to provide enough allowance for
Expand Down Expand Up @@ -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);
Expand All @@ -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.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.

<Note>
{" "}
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){" "}
</Note>

## Playground
Expand Down Expand Up @@ -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.

Expand Down Expand Up @@ -84,7 +85,7 @@ const priceResponse = await fetch(
"https://api.0x.org/swap/allowance-holder/price?" + priceParams.toString(),
{
headers,
}
},
);

console.log(await priceResponse.json());
Expand Down Expand Up @@ -245,15 +246,15 @@ 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).

<Note>
<Warning>

- 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`.

</Note>
</NWarningote>

<Tip>
When setting the token allowance, make sure to provide enough allowance for
Expand Down Expand Up @@ -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);
Expand All @@ -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.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.

<Note>
<Warning>
- 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`.

</Note>
</Warning>
## 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.
Expand Down
Loading