Handle errors
Every API error has the same shape:
{ "error": { "code": "INSUFFICIENT_LIQUIDITY", "message": "Not enough free liquidity for that amount" } }
Act on code; show message to users. The full list is in Errors.
By kind
| Kind | Codes | What to do |
|---|---|---|
| Fix the request | INVALID_REQUEST, INVALID_CAP, INVALID_STRIKE, STRIKE_TOO_CLOSE, INVALID_TENOR, DIRECTION_NOT_OFFERED, STRUCTURE_NOT_OFFERED | Change terms and retry |
| Market conditions | INSUFFICIENT_LIQUIDITY, TENOR_DISABLED, POOL_NOT_ACCEPTING | Offer smaller size, another tenor or later |
| Timing | QUOTE_EXPIRED, QUOTE_USED, SLIPPAGE_EXCEEDED | Request a new quote |
| Data | ORACLE_NOT_READY, ORACLE_PRICE_REJECTED | Retry later |
| Auth | UNAUTHORIZED (401) | Sign in again |
| Service | CHAIN_NOT_ENABLED (503), CHAIN_DRAINING (409), PAUSED, UNKNOWN (500) | Retry with backoff |
Retrying safely
- Quotes are single-use. Never resend a signed transaction built from a quote that failed with
QUOTE_EXPIREDorQUOTE_USED; request a new quote. - Relaying the same signed transaction twice cannot buy twice: the quote nonce is consumed on the first success.
- Read
GET /api/v2/transactions/:chain/:hashbefore retrying a relay that timed out.