Multi-Fee Support

View as Markdown

The Swap and Gasless APIs support collecting fees for multiple recipients in a single transaction. This is useful for use cases like revenue sharing between a protocol and a frontend, splitting fees between partners, or distributing fees across multiple treasury addresses — all without requiring multiple transactions or custom contracts.

Overview

Fee splitting is controlled by three query parameters that work together:

  • swapFeeRecipient — one or more wallet addresses (comma-separated) that receive fees at settlement
  • swapFeeBps — one or more fee amounts in basis points (comma-separated), defining how much each recipient earns
  • swapFeeToken(optional) — the token fees are collected in; can be omitted or set to either the address of buyToken or sellToken

swapFeeRecipient and swapFeeBps are positionally matched and co-dependent. The first value in swapFeeBps applies to the first address in swapFeeRecipient, the second to the second, and so on. Both must be present and the same length.

Use swapFeeToken to specify which token fees are collected in — either the buyToken or sellToken. If omitted, 0x defaults to the buy token, unless the sell token has higher priority (e.g., stablecoins or a more liquid asset) or the buy token is ineligible.

Parameters

swapFeeRecipient
string

The wallet address(es) to receive trading fees. Accepts a single address or multiple comma-separated addresses.

Example: 0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045,0xfb6916095ca1df60bb79ce92ce3ea74c37c5d359

When providing multiple values, the list must be the same length as swapFeeBps. You must also specify swapFeeBps to use this parameter.

swapFeeBps
string

The fee amount(s) in basis points (Bps) to charge per recipient. Accepts a single value or multiple comma-separated values.

Example: 5,10

When providing multiple values, the list must be the same length as swapFeeRecipient. The default maximum is 1000 Bps per recipient. Contact us if your integration requires a higher limit.

swapFeeToken
string

The contract address of the token to collect trading fees in. Accepts a single address or multiple comma-separated addresses.

Format: ^\s*0x(?!0{40})[a-fA-F0-9]{40}(\s*,\s*0x(?!0{40})[a-fA-F0-9]{40})*\s*$

Each value must be set to either the address of the buyToken or the sellToken. When multiple values are provided, the list must be the same length as swapFeeBps.

If omitted, 0x selects the fee token from the trade. The buy token is used by default unless the sell token has higher priority (e.g., stablecoins or more liquid assets) or the buy token is ineligible.

You must also specify swapFeeRecipient and swapFeeBps to use this parameter.

swapFeeRecipient and swapFeeBps are co-dependent — you must specify both together. When using multiple fees, both lists must be the same length and positionally matched (index 0 of swapFeeBps applies to index 0 of swapFeeRecipient, and so on). swapFeeToken must also match this length when multiple values are provided.

Example Request

The following example splits fees between two recipients on a USDC → USDT swap — 5 Bps to the platform and 10 Bps to a distribution partner. swapFeeToken is omitted, so fees default to the buy token (USDT).

$curl "https://api.0x.org/swap/allowance-holder/price\
>?chainId=1\
>&buyToken=0xdac17f958d2ee523a2206206994597c13d831ec7\
>&sellToken=0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2\
>&sellAmount=100000000\
>&taker=0x70a9f34f9b34c64957b9c401a97bfed35b95049e\
>&swapFeeRecipient=0xPLATFORM_ADDRESS,0xPARTNER_ADDRESS\
>&swapFeeBps=5,10" \
>-H "0x-api-key: <YOUR_API_KEY>"

Example Response

When multiple fees are configured, the response includes both the legacy integratorFee field (containing the first fee, for backwards compatibility) and the new integratorFees array (containing all fees):

1{
2 "fees": {
3 "integratorFee": {
4 "amount": "49989",
5 "token": "0xdac17f958d2ee523a2206206994597c13d831ec7",
6 "type": "volume"
7 },
8 "integratorFees": [
9 {
10 "amount": "49989",
11 "token": "0xdac17f958d2ee523a2206206994597c13d831ec7",
12 "type": "volume"
13 },
14 {
15 "amount": "99978",
16 "token": "0xdac17f958d2ee523a2206206994597c13d831ec7",
17 "type": "volume"
18 }
19 ],
20 "zeroExFee": {
21 "amount": "149968",
22 "token": "0xdac17f958d2ee523a2206206994597c13d831ec7",
23 "type": "volume"
24 },
25 "gasFee": null
26 }
27}

fees.integratorFee is retained for backwards compatibility and always reflects the first fee in the list. Use fees.integratorFees to access the full breakdown of all fees.

Each entry in integratorFees corresponds positionally to the swapFeeRecipient and swapFeeBps values in your request:

IndexRecipientFee (Bps)Amount (in buy token)
00xPLATFORM_ADDRESS549,989
10xPARTNER_ADDRESS1099,978