{
  "axon_version": "1.0.0",
  "protocol": {
    "name": "0x / Matcha",
    "slug": "zerox-ethereum",
    "version": "v2",
    "description": "Professional-grade DEX aggregator powering Matcha and hundreds of integrations. The 0x Swap API v2 uses Permit2 for gasless approvals and sources liquidity across all major DEXs, RFQ market makers, and proprietary liquidity.",
    "category": "dex",
    "chain": {
      "id": 1,
      "name": "ethereum",
      "network": "mainnet"
    },
    "contracts": {
      "exchange_proxy": {
        "address": "0xDef1C0ded9bec7F1a1670819833240f027b25EfF",
        "label": "0x Exchange Proxy (Settler)",
        "verified": true
      },
      "permit2": {
        "address": "0x000000000022D473030F116dDEE9F6B43aC78BA3",
        "label": "Permit2 (Uniswap Canonical)",
        "verified": true
      },
      "allowance_holder": {
        "address": "0x0000000000001fF3684f28c67538d4D072C22734",
        "label": "AllowanceHolder",
        "verified": true
      }
    },
    "links": {
      "website": "https://matcha.xyz",
      "docs": "https://0x.org/docs",
      "github": "https://github.com/0xProject"
    },
    "off_chain_api": {
      "description": "0x Swap API v2 provides off-chain route optimization with RFQ liquidity and Permit2-based gasless approvals. Requires an API key.",
      "base_url": "https://api.0x.org",
      "authentication": {
        "type": "api_key_header",
        "header": "0x-api-key",
        "description": "Requires a 0x API key from the 0x Dashboard (dashboard.0x.org)"
      },
      "endpoints": {
        "price": {
          "method": "GET",
          "path": "/swap/permit2/price",
          "description": "Get an indicative price quote without commitment. Faster than /quote, useful for displaying prices.",
          "parameters": {
            "chainId": "Chain ID (1 for Ethereum)",
            "sellToken": "Address of the token to sell",
            "buyToken": "Address of the token to buy",
            "sellAmount": "(optional) Amount of sellToken in wei (use either sellAmount or buyAmount)",
            "buyAmount": "(optional) Desired amount of buyToken in wei",
            "taker": "Address of the taker/sender",
            "slippageBps": "(optional) Slippage tolerance in basis points (default: 100 = 1%)",
            "excludedSources": "(optional) Comma-separated list of liquidity sources to exclude"
          }
        },
        "quote": {
          "method": "GET",
          "path": "/swap/permit2/quote",
          "description": "Get a firm quote with full transaction data for execution. Includes Permit2 signature data.",
          "parameters": {
            "chainId": "Chain ID (1 for Ethereum)",
            "sellToken": "Address of the token to sell",
            "buyToken": "Address of the token to buy",
            "sellAmount": "(optional) Amount of sellToken in wei",
            "buyAmount": "(optional) Desired amount of buyToken in wei",
            "taker": "Address of the taker/sender",
            "slippageBps": "(optional) Slippage in basis points",
            "excludedSources": "(optional) Sources to exclude"
          }
        }
      },
      "rate_limits": {
        "requests_per_second": 5,
        "requests_per_minute": 100
      }
    }
  },
  "actions": [
    {
      "id": "get_quote",
      "name": "Get Swap Quote",
      "description": "Fetches the optimal swap route from 0x's off-chain routing engine, including RFQ (Request for Quote) liquidity from professional market makers. Returns indicative pricing via /price or firm quotes via /quote. The /price endpoint is faster and suitable for displaying rates; /quote returns executable transaction data.",
      "type": "swap",
      "parameters": [
        {
          "name": "sellToken",
          "type": "address",
          "required": true,
          "description": "Contract address of the token to sell"
        },
        {
          "name": "buyToken",
          "type": "address",
          "required": true,
          "description": "Contract address of the token to buy"
        },
        {
          "name": "sellAmount",
          "type": "uint256",
          "required": false,
          "description": "Amount of sellToken to sell, in wei. Mutually exclusive with buyAmount."
        },
        {
          "name": "buyAmount",
          "type": "uint256",
          "required": false,
          "description": "Desired amount of buyToken, in wei. Mutually exclusive with sellAmount."
        },
        {
          "name": "taker",
          "type": "address",
          "required": true,
          "description": "Address of the wallet that will execute the swap"
        },
        {
          "name": "slippageBps",
          "type": "uint256",
          "required": false,
          "description": "Maximum acceptable slippage in basis points (e.g. 100 = 1%)",
          "default": "100"
        },
        {
          "name": "excludedSources",
          "type": "string",
          "required": false,
          "description": "Comma-separated list of liquidity sources to exclude"
        }
      ],
      "constraints": {
        "min_amount": "1",
        "max_slippage_bps": 5000,
        "deadline_required": false,
        "supported_tokens": "any_erc20_or_native"
      },
      "approvals": [],
      "transaction_flow": [
        {
          "step": 1,
          "action": "off_chain_quote",
          "description": "Call 0x Price API for an indicative quote (no commitment), or Quote API for a firm quote with tx data",
          "contract": "off_chain",
          "method": "GET /swap/permit2/price?chainId=1&sellToken={sellToken}&buyToken={buyToken}&sellAmount={sellAmount}&taker={taker}",
          "conditional": "always",
          "returns": ["buyAmount", "sellAmount", "price", "sources", "gas", "route"]
        }
      ],
      "risk_warnings": [
        "Indicative prices from /price may differ from executable /quote prices",
        "RFQ quotes have short expiry windows (typically 30-60 seconds)",
        "Either sellAmount or buyAmount must be specified, not both"
      ]
    },
    {
      "id": "swap",
      "name": "Execute Swap",
      "description": "Executes a token swap via the 0x Exchange Proxy using Permit2 for token approvals. The flow is: (1) approve tokens to Permit2 contract, (2) fetch quote from 0x API, (3) sign Permit2 message, (4) submit transaction. This provides gasless approval benefits.",
      "type": "swap",
      "parameters": [
        {
          "name": "sellToken",
          "type": "address",
          "required": true,
          "description": "Contract address of the token to sell"
        },
        {
          "name": "buyToken",
          "type": "address",
          "required": true,
          "description": "Contract address of the token to buy"
        },
        {
          "name": "sellAmount",
          "type": "uint256",
          "required": false,
          "description": "Exact amount of sellToken to sell, in wei"
        },
        {
          "name": "buyAmount",
          "type": "uint256",
          "required": false,
          "description": "Desired exact amount of buyToken, in wei"
        },
        {
          "name": "taker",
          "type": "address",
          "required": true,
          "description": "Address of the wallet executing the swap"
        },
        {
          "name": "slippageBps",
          "type": "uint256",
          "required": false,
          "description": "Maximum slippage in basis points",
          "default": "100"
        }
      ],
      "constraints": {
        "min_amount": "1",
        "max_slippage_bps": 5000,
        "deadline_required": false,
        "supported_tokens": "any_erc20_or_native"
      },
      "approvals": [
        {
          "type": "erc20_approve",
          "token": "sellToken",
          "spender": "permit2",
          "amount": "exact_or_max"
        },
        {
          "type": "permit2",
          "token": "sellToken",
          "spender": "allowance_holder",
          "amount": "exact"
        }
      ],
      "transaction_flow": [
        {
          "step": 1,
          "action": "check_allowance",
          "description": "Check if Permit2 contract has sufficient ERC-20 allowance for the sell token",
          "contract": "sellToken",
          "method": "allowance(address,address)",
          "conditional": "if_not_native_token"
        },
        {
          "step": 2,
          "action": "approve_permit2",
          "description": "Approve the Permit2 contract to spend sell tokens (one-time per token). This is a standard ERC-20 approve.",
          "contract": "sellToken",
          "method": "approve(address,uint256)",
          "conditional": "if_allowance_insufficient"
        },
        {
          "step": 3,
          "action": "off_chain_build_tx",
          "description": "Call 0x Quote API to get firm quote with transaction data and Permit2 signature parameters",
          "contract": "off_chain",
          "method": "GET /swap/permit2/quote?chainId=1&sellToken={sellToken}&buyToken={buyToken}&sellAmount={sellAmount}&taker={taker}&slippageBps={slippageBps}",
          "conditional": "always",
          "returns": ["transaction.to", "transaction.data", "transaction.value", "transaction.gas", "permit2.eip712"]
        },
        {
          "step": 4,
          "action": "sign_permit2",
          "description": "Sign the Permit2 EIP-712 typed data message to authorize the AllowanceHolder to spend tokens for this specific swap",
          "contract": "off_chain",
          "method": "eth_signTypedData_v4(permit2.eip712)",
          "conditional": "if_not_native_token",
          "returns": ["signature"]
        },
        {
          "step": 5,
          "action": "execute",
          "description": "Submit the swap transaction with Permit2 signature. The Exchange Proxy handles routing through optimal DEX path.",
          "contract": "exchange_proxy",
          "method": "executeMetaTransaction(bytes,bytes)",
          "returns": ["buyAmount", "sellAmount"]
        }
      ],
      "risk_warnings": [
        "Permit2 approval is a one-time gas cost per token — subsequent swaps for the same token skip step 2",
        "Always verify the Permit2 EIP-712 message details before signing",
        "RFQ quotes may expire — execute promptly after receiving quote",
        "The 0x API may include a protocol fee (0x Swap Surplus) on certain routes"
      ]
    }
  ],
  "risk": {
    "audit_status": {
      "audited": true,
      "auditors": ["Trail of Bits", "Consensys Diligence", "Certora"],
      "last_audit_date": "2024-06-01",
      "audit_reports": [
        "https://github.com/0xProject/protocol/tree/main/audits"
      ]
    },
    "tvl": {
      "current_usd": 0,
      "source": "defillama",
      "last_updated": "2026-03-07T00:00:00Z"
    },
    "incidents": [
      {
        "date": "2022-01-05",
        "severity": "medium",
        "title": "AllowanceTarget exploit",
        "description": "A vulnerability was found in the legacy AllowanceTarget contract allowing unauthorized token transfers for users who had granted unlimited approvals. Patched immediately.",
        "resolved": true,
        "post_mortem": "https://blog.0xproject.com"
      }
    ],
    "risk_score": {
      "overall": "A",
      "smart_contract": "A",
      "centralization": "B",
      "oracle_dependence": "A+",
      "liquidity": "A+"
    }
  },
  "fees": {
    "model": "per_trade",
    "tiers": [
      {
        "name": "zero_protocol_fee",
        "fee_bps": 0,
        "description": "0% — No explicit protocol fee on most routes",
        "conditions": "Standard DEX aggregation routes"
      },
      {
        "name": "swap_surplus",
        "fee_bps": null,
        "description": "0x collects positive slippage (swap surplus) on applicable routes. This is the difference between quoted and executed price when favorable.",
        "conditions": "Routes with positive price movement"
      },
      {
        "name": "integrator_fee",
        "fee_bps": null,
        "description": "Optional integrator/affiliate fee, configurable via API",
        "conditions": "When buy/sellTokenFeeAddress is set"
      }
    ],
    "gas_estimates": {
      "swap_simple": "160000",
      "swap_complex_route": "300000",
      "approve_permit2": "46000",
      "sign_permit2": "0"
    }
  }
}