0xprotocol connects settlement contracts with APIs for token trading
Updated on
0xprotocol is an open-source settlement protocol for exchanging tokenized assets. Native orders describe trades makers authorize, while the surrounding 0x APIs help applications find liquidity, arrange execution and analyze trading activity. These components address different needs: settlement enforces trade conditions, Swap API aggregates liquidity and Gasless API changes how eligible users handle transaction gas.
Wallet swaps need routing and transaction data, while market makers need order terms and settlement rules. App reporting adds another dependency because analytics data has its own scope and finalization window.
An order signature records trading terms; settlement also requires the balances, permissions and order conditions the relevant contract enforces.
Liquidity sources shape the trades applications can offer
0x connects liquidity suppliers with applications consuming that liquidity. Makers create orders and offer assets for exchange. Takers consume those offers through trading applications or agents.
Liquidity comes from onchain venues, including automated market makers such as Uniswap and Curve, and offchain suppliers such as professional market makers. The 0x introduction describes access to 150+ liquidity sources across 19+ EVM chains. An app can use that aggregation without integrating each venue separately. Available routes still depend on the requested assets and network, so those service-wide figures do not make every pair executable. Product support also has its own scope: a network available through one service does not establish identical support across the entire API suite.
The application categories extend beyond exchanges. Wallets can embed swaps, portfolio dashboards can add trading and DeFi applications can use liquidity within investment strategies. Supply-side integrations include AMMs, orderbooks and proprietary market-making systems.
Settlement contracts enforce the terms interfaces present
A signed order records a maker's authorized terms before a blockchain transaction attempts the exchange. Sharing that message allows potential takers to discover it. Settlement checks the signature and applicable trade conditions before atomically exchanging the assets. A native ERC20 order identifies both token contracts and the amounts each side offers. The maker amount describes what the maker sells; the taker amount describes what the taker supplies. Expiry places a time boundary on the offer. Optional taker or sender restrictions narrow who can fill it.
The 0x Protocol 4.1 architecture documentation describes the Exchange Proxy as the contract entry point. It delegates calls to Features implementing protocol functions. Transformers extend functionality, while the Flash Wallet provides a sandboxed escrow for their operations. The Governor controls trusted contracts within that architecture. The API documentation describes 0x Settler as the execution foundation for its professional APIs. A native V4 Exchange Proxy function and an API-generated Settler transaction therefore belong to distinct integration contexts. For native V4 ERC20 fills, maker and taker allowances target the Exchange Proxy. For EVM Swap API v2, allowances target AllowanceHolder or Permit2 as specified in the response.
0xprotocol: How Settlement and Trading APIs Work
- Liquidity sources shape the trades applications can offer
- Settlement contracts enforce the terms interfaces present
- Swap APIs combine routing with network-specific execution
The V4.1 documentation also describes native NFT orders exchanging ERC20 assets with ERC721 or ERC1155 assets. That contract capability has a different scope from the ERC20 trading described for EVM Swap API. Native asset support does not establish equivalent support in every API or interface.
Swap APIs combine routing with network-specific execution
EVM Swap API aggregates token liquidity on supported networks and can split trades across public sources and private market makers. The separate Solana Swap API aggregates liquidity and builds swap instructions for Solana Mainnet Beta. Its documentation identifies it as open beta, with interfaces subject to change. Cross-Chain API compares routes from bridge providers and liquidity sources across supported networks. Its status service tracks destination delivery or failure recovery; submitting an origin transaction does not establish completion.
EVM Swap API routing accounts for gas consumption and associated fees when evaluating available combinations. A source showing an attractive token price can produce a worse overall result once execution costs enter the calculation. The returned route reflects the available quote conditions; aggregation cannot guarantee an executable market for every request. EVM Swap API also lets apps collect affiliate fees on all pricing plans. Trade-surplus collection is limited to selected integrators on custom plans.
EVM Swap API returns transaction data for signing and submission. A quote is therefore a proposed execution, with completion depending on the subsequent onchain transaction. For API allowance handling, the integration must use the spender specified for its selected approval method. AllowanceHolder and Permit2 have different authorization arrangements. Never grant token allowances directly to Settler.
Can a native limit order fill for less than its full amount?
Yes, native V4 limit orders can fill partially when their terms and settlement checks permit.
The function
fillLimitOrder()
fills up to the requested taker-token amount. The alternative
fillOrKillLimitOrder()
requires that requested amount exactly or reverts. Neither function makes an expired, cancelled or otherwise invalid order executable.
Consider a hypothetical native V4 order with 34 taker-token units remaining and a hypothetical request to fill 74 units. Assume valid signatures, sufficient balances and allowances, payable fees and satisfied caller restrictions. The order remains unexpired and uncancelled.
Under those conditions,
fillLimitOrder()
can fill the remaining 34 units. The same 74-unit request through
fillOrKillLimitOrder()
reverts because the order cannot supply the requested fill. Reducing the hypothetical request to 34 units lets either function satisfy it under the same conditions.
Orderbook removal alone leaves onchain order status unchanged
An orderbook distributes signed messages offchain. Removing a listing affects discovery, while contract cancellation changes whether settlement accepts the order. A taker retaining a valid signed order may still fill it after the listing disappears, provided all other fill conditions remain satisfied.
The native contract exposes cancellation functions and order-status queries.
RFQ introduces market-maker quotes during aggregation
Request for quote, or RFQ, brings market-maker responses into quote construction as applications request liquidity. Market makers choose whether to respond with signed quotes. Those responses become candidates the aggregator can compare with other liquidity.
The native V4 RFQ order uses fewer fields than a standard limit order and has its own settlement function. Its structure includes a transaction-origin restriction, so possession of a signed quote does not automatically authorize every caller. Expiry and other encoded conditions still apply. This arrangement differs from distributing a standing limit order through an open orderbook.
Gasless execution separates approval support from swap support
Gasless API uses relayers to submit eligible swaps and pay blockchain gas upfront. Users authorize the relevant messages instead of directly funding that submission with the network's native token. The minimum trade size varies with chain and gas conditions; requests below it return an error with an estimated minimum.
Gas costs still exist. In the user-paid model, the trade covers those costs using the token being traded. If the application sponsors transactions, it pays 0x directly and users do not receive that onchain charge. These payment arrangements lead to different user costs despite sharing the gasless interface.
Gasless swaps and gasless approvals also have separate compatibility requirements. The documented swap path supports selling non-native tokens. Gasless approval requires a supported permit mechanism, such as EIP-2612 or a recognized related permit format. The quote's
approval
object identifies whether that option exists and which type applies.
Tokens without supported gasless approval may need a standard onchain approval first. WETH illustrates that distinction: its lack of EIP-2612 support does not exclude a later gasless swap. Selling a native coin requires a different path, such as ordinary Swap API execution or wrapping it first.
How does ZRX relate to protocol governance?
ZRX enables participation in protocol governance through votes on ZeroEx Improvement Proposals, known as ZEIPs. Governance addresses changes to shared protocol infrastructure, and the broader system also includes a community-owned treasury supporting ecosystem initiatives. These responsibilities differ from an application's choice of liquidity route or API execution method. A token's governance role does not establish a current staking return or entitlement to a particular trading fee.
App credentials require a server boundary
A 0x API key identifies an application's authenticated requests. The dashboard associates keys with an app and lets developers manage which API products the app can access. The key belongs in the
0x-api-key
request header.
Browser code exposes credentials to users inspecting the application. The API guidance recommends a backend server, serverless function or server-side framework route for requests carrying the key. Browser requests can also encounter cross-origin restrictions. Changing the frontend request does not provide a secure place to store a secret.
API authentication and trade authorization serve different purposes. An API key grants access to the enabled service; a wallet signature authorizes the relevant order or transaction. Keeping the credential on the server preserves that separation while allowing the interface to present trade information.
Trade Analytics adds reporting with a finalization window
Trade Analytics API provides historical records for an app's trades initiated through Swap API and Gasless API.
Trade Analytics returns data for the app associated with the request's API key.
Its records support reporting on trading volume and fees, while transaction hashes connect reported activity with onchain transactions. The methods
getSwapTrades
and
getGaslessTrades
provide access to the respective trade records.
The Trade Analytics introduction states that new settled trades appear roughly every 15 minutes. It considers reporting data final 48 hours after trade completion, allowing for latency from external providers such as token-price sources. This is an analytics finalization window, separate from the underlying transaction's execution. Recent reports can change as those inputs arrive.
Dollar-denominated volume and fee values are estimates based on token prices at trade time. They do not establish exact dollar settlement amounts. The documented refresh approach includes the preceding two days alongside the current day, allowing recent reporting inputs to update.
An app adding reporting must distinguish historical analytics from immediate transaction decoding. Trade Analytics serves the historical view; the separate
0x-parser
TypeScript library decodes onchain trade data.
Useful questions about 0xprotocol
-
Why can deleting an orderbook listing leave an order fillable?
- Deleting an offchain listing does not cancel the native order onchain. A taker holding the signed order can still attempt a fill while its contract conditions permit it. Exchange V4 provides explicit cancellation functions for individual orders and token pairs; expiry and previous fills also affect availability.
-
How does ZRX relate to protocol governance?
- ZRX provides voting power for protocol governance proposals. Its governance role concerns decisions about shared exchange infrastructure, while a maker's order signature authorizes a particular trade. Voting and filling an order are separate activities.
-
Are Trade Analytics dollar values exact settlement amounts?
- Trade Analytics dollar figures are estimates based on token prices at trade time. The trade records also carry token amounts, which describe the assets exchanged. Dollar estimates value those trades for reporting; they do not change the token quantities settled onchain. Reporting should keep each token amount and its denomination distinct from its estimated dollar value.