Skip to content

Errors

Each rejection is a SmartRecipeError. It contains a code, a message, and a requestId (from the server's x-request-id header). Include the requestId in a bug report. Each code has a bound subclass, so you can branch with instanceof:

import { SmartRecipeError, QuoteExpiredError } from "@zerodev/smart-recipes";
 
try {
  await sr.aave.deposit({ /* … */ });
} catch (e) {
  if (e instanceof QuoteExpiredError) {
    // request a new quote
  } else if (e instanceof SmartRecipeError) {
    console.error(`[${e.code}] ${e.message} (request ${e.requestId})`);
  }
}

Error codes

HTTPCodeWhen
400INVALID_REQUESTA parameter is missing or malformed
400UNSUPPORTED_TOKENThe token does not resolve
400UNKNOWN_PROTOCOLThe protocol has no registered adapter
400VAULT_TYPE_MISMATCHThe target is not the expected vault kind (on-chain probe)
400ASSET_MISMATCHThe vault asset is not the expected token
400CHAIN_NOT_SUPPORTEDThe chain is not configured on the server
400VAULT_DEPOSITS_DISABLEDThe vault's on-chain maxDeposit is 0. It accepts no deposits.
403SANCTIONED_ADDRESSThe owner is on the OFAC SDN list
403VAULT_BLOCKEDThe vault is on the server blocklist
403FEATURE_DISABLEDSwap-leg routes are disabled on the server
403ACCESS_DENIEDThe origin or IP is not on the project's allowlist
409VAULT_CAP_EXCEEDEDThe amount is over the vault's remaining capacity
410QUOTE_EXPIREDThe quote is past its TTL. Request a new quote.
413PAYLOAD_TOO_LARGEThe request body is over the size cap
422INSUFFICIENT_AMOUNTThe amount is below the vault minimum after fees
422SWAP_ROUTE_NOT_FOUNDNo swap route was found
429RATE_LIMITEDToo many requests. Idempotent GETs retry with backoff.
500INTERNAL_ERRORAn unexpected server error
502SRA_UNAVAILABLE / QUOTER_UNAVAILABLE / RPC_UNAVAILABLEAn upstream service failed

Codes that need special handling

VAULT_CAP_EXCEEDED and VAULT_DEPOSITS_DISABLED are different conditions. For VAULT_CAP_EXCEEDED, try a smaller amount. For VAULT_DEPOSITS_DISABLED, the vault accepts no deposits at all. Select a different vault. preflight shows both conditions before you quote.

FEATURE_DISABLED means the route needs a swap leg, and the server has swaps disabled. Same-token routes are not affected. This includes same-chain deposits and plain cross-chain bridges. A retry with different parameters does not help.

QUOTE_EXPIRED occurs because a quote lives for about 60 seconds. Request a new quote.

Retry behavior

The SDK does not retry quote-building POST requests. Each POST can create a new SRA on the server. The SDK retries idempotent GET requests on 429, 502, 503, and network failures, with backoff, up to the client's maxRetries.