API status codes

API status code is the code returned by the server like 200, 404, 429, 500, 502.

API error codes

API returns the following set of error codes:

  • DefaultError = 1000,
  • FailedToBuildTransactionError = 1001,
  • NoQuoteError = 1002,
  • NotFoundError = 1003,
  • NotProcessableError = 1004,
  • RateLimitError = 1005,
  • ServerError = 1006,
  • SlippageError = 1007,
  • ThirdPartyError = 1008,
  • TimeoutError = 1009,
  • UnauthorizedError = 1010,
  • ValidationError = 1011,
  • RpcFailure = 1012,
  • MalformedSchema = 1013,

Tool errors

In addition to returning status and error codes, API may return error messages for underlying tools, describing an issue with specific tools. This can be caused by many reasons, from the tool simply not supporting the requested token pair or insufficient liquidity.

To better explain failure cases, we try to return errors in a predictable format. The ToolError interface looks like the following:

type ToolErrorType = 'NO_QUOTE'

interface ToolError {
  errorType: ToolErrorType
  code: string
  action: Action
  tool: string
  message: string
}

Possible codes:

NO_POSSIBLE_ROUTE: No route was found for this action.

INSUFFICIENT_LIQUIDITY: The tool’s liquidity is insufficient.

TOOL_TIMEOUT: The third-party tool timed out.

UNKNOWN_ERROR: An unknown error occurred.

RPC_ERROR: There was a problem getting on-chain data. Please try again later.

AMOUNT_TOO_LOW:The initial amount is too low to transfer using this tool.

AMOUNT_TOO_HIGH: The initial amount is too high to transfer using this tool.

FEES_HGHER_THAN_AMOUNT: The fees are higher than the initial amount — this would result in negative resulting token.

DIFFERENT_RECIPIENT_NOT_SUPPORTED: This tool does not support different recipient addresses.

TOOL_SPECIFIC_ERROR: The third-party tool returned an error.

CANNOT_GUARANTEE_MIN_AMOUNT: The tool cannot guarantee that the minimum amount will be met.

Example response:

{
    "message": "Unable to find a quote for the requested transfer.",
    "errors": [
        {
            "errorType": "NO_QUOTE",
            "code": "INSUFFICIENT_LIQUIDITY",
            "action": {
                "fromChainId": 100,
                "toChainId": 100,
                "fromToken": {
                    "address": "0x4ecaba5870353805a9f068101a40e0f32ed605c6",
                    "decimals": 6,
                    "symbol": "USDT",
                    "chainId": 100,
                    "coinKey": "USDT",
                    "name": "USDT",
                    "logoURI": "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/ethereum/assets/0xdAC17F958D2ee523a2206206994597C13D831ec7/logo.png",
                    "priceUSD": "0.99872"
                },
                "toToken": {
                    "address": "0xddafbb505ad214d7b80b1f830fccc89b60fb7a83",
                    "decimals": 6,
                    "symbol": "USDC",
                    "chainId": 100,
                    "coinKey": "USDC",
                    "name": "USDC",
                    "logoURI": "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/ethereum/assets/0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48/logo.png"
                },
                "fromAmount": "1",
                "slippage": 0.03,
                "fromAddress": "0x552008c0f6870c2f77e5cC1d2eb9bdff03e30Ea0",
                "toAddress": "0x552008c0f6870c2f77e5cC1d2eb9bdff03e30Ea0"
            },
            "tool": "1inch",
            "message": "The tool's liquidity is insufficient."
        },
        {
            "errorType": "NO_QUOTE",
            "code": "TOOL_TIMEOUT",
            "action": {
                "fromChainId": 100,
                "toChainId": 100,
                "fromToken": {
                    "address": "0x4ecaba5870353805a9f068101a40e0f32ed605c6",
                    "decimals": 6,
                    "symbol": "USDT",
                    "chainId": 100,
                    "coinKey": "USDT",
                    "name": "USDT",
                    "logoURI": "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/ethereum/assets/0xdAC17F958D2ee523a2206206994597C13D831ec7/logo.png",
                    "priceUSD": "0.99872"
                },
                "toToken": {
                    "address": "0xddafbb505ad214d7b80b1f830fccc89b60fb7a83",
                    "decimals": 6,
                    "symbol": "USDC",
                    "chainId": 100,
                    "coinKey": "USDC",
                    "name": "USDC",
                    "logoURI": "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/ethereum/assets/0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48/logo.png"
                },
                "fromAmount": "1",
                "slippage": 0.03,
                "fromAddress": "0x552008c0f6870c2f77e5cC1d2eb9bdff03e30Ea0",
                "toAddress": "0x552008c0f6870c2f77e5cC1d2eb9bdff03e30Ea0"
            },
            "tool": "openocean",
            "message": "The third party tool timed out."
        },
        {
            "errorType": "NO_QUOTE",
            "code": "NO_POSSIBLE_ROUTE",
            "action": {
                "fromChainId": 100,
                "toChainId": 100,
                "fromToken": {
                    "address": "0x4ecaba5870353805a9f068101a40e0f32ed605c6",
                    "decimals": 6,
                    "symbol": "USDT",
                    "chainId": 100,
                    "coinKey": "USDT",
                    "name": "USDT",
                    "logoURI": "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/ethereum/assets/0xdAC17F958D2ee523a2206206994597C13D831ec7/logo.png",
                    "priceUSD": "0.99872"
                },
                "toToken": {
                    "address": "0xddafbb505ad214d7b80b1f830fccc89b60fb7a83",
                    "decimals": 6,
                    "symbol": "USDC",
                    "chainId": 100,
                    "coinKey": "USDC",
                    "name": "USDC",
                    "logoURI": "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/ethereum/assets/0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48/logo.png"
                },
                "fromAmount": "1",
                "slippage": 0.03,
                "fromAddress": "0x552008c0f6870c2f77e5cC1d2eb9bdff03e30Ea0",
                "toAddress": "0x552008c0f6870c2f77e5cC1d2eb9bdff03e30Ea0"
            },
            "tool": "superfluid",
            "message": "No route was found for this action."
        }
    ]
}