Ask what the response authorizes the application to do. A price can populate a comparison table. A route describes how funds might move. A transaction contains the call a wallet can submit. A signable order belongs to another execution path entirely.
Use a discriminated response model
A useful application model has separate variants such as indicative, needsBuild, transaction and order. Each variant exposes only the actions it supports. This is a proposed client design, not a standardized provider schema.
| Variant | Permitted next action | Missing evidence |
|---|---|---|
| Indicative price | Display estimate | Executable call |
| Route description | Request encoding | Final recipient-bound payload |
| Transaction | Validate and simulate | Wallet consent and receipt |
| Order | Validate signing request | Signature, acceptance and fill |
0x separates indicative price from firm quote. PancakeSwap distinguishes an agg route from a pcsx signable order. Both examples demonstrate why a single optional calldata field is an inadequate execution contract.
Handle missing payloads deliberately
Do not enable a wallet button merely because outputAmount exists. Require the fields for the selected variant, check their units and bind them to the input request. If a build call fails, preserve the displayed estimate with an explicit unavailable-execution state rather than fabricating a transaction from route details.
During an adapter migration, save response fixtures for every variant. A fixture containing an excellent price but no transaction should never reach sendTransaction. A new unknown execution type should stop at the adapter boundary until its lifecycle is implemented.
Sources & verification (2)
Source-check date is recorded in the article details. URLs are provided for manual verification. Use Copy to keep this page open.
- Get Started with Swap API
AllowanceHolder sequence, request parameters and transaction payload
https://docs.0x.org/docs/introduction/quickstart/swap-tokens-with-0x-swap-api - Response payloads
Candidate response shapes
https://developer.pancakeswap.finance/contracts/unified-swap-api/payloads