circle-exclamationErrors

Page contains info about specific errors returned in specific cases by rubic-api server

Description

Error code consists of two parts - Number(error domain + error code). For instance if you'll try to fetch not supported pair of tokens - you get an error with code "2001", because Number(''002" + "001") equals 2001. Every error is related with particular stage of interaction with API (ex. making quote request, making swap request, interaction with Rubic smart contracts).

Error domains

const ERROR_DOMAINS = {
    PARAMS_ERRORS: '001',
    CALCULATION_ERRORS: '002',
    SWAP_ERRORS: '003',
    RUBIC_CONTRACT_ERRORS: '004',
    UNKNOWN_ERRORS: '999'
}

Error codes

Currently errors list contains 5 main issues like invalid params, calculation restrictions etc. In future this list will grow as we develop and scale our API. To receive all actual data or mention any discrepency or incorrectness in errors list - contact our BD via Telegramarrow-up-right.

const SPECIFIC_ERROR_CODES = {
    // 001
    [ERROR_DOMAINS.PARAMS_ERRORS]: {
        REQUIRED_RECEIVER: '001',
        EQUAL_TOKENS: '002',
        DIFFERENT_QUOTES: '003',
        MISS_ID: '004',
        NO_REQUIRED_FIELD: '005',
        NOT_CORRECT_WALLET_ADDRESS: '006',

        WRONG_OR_MISSED_FIELD: '999'
    },
    // 002
    [ERROR_DOMAINS.CALCULATION_ERRORS]: {
        NO_ROUTES: '001',
        BLOCKCHAIN_TEMPORARILY_DOWN: '002',
        PROVIDER_RATE_LIMIT: '003',
        MAX_AMOUNT: '004',
        MIN_AMOUNT: '005',
        MAX_DECIMALS: '006',
        NO_AUTH_WALLET: '007',

        UNKNOWN: '999'
    },
    // 003
    [ERROR_DOMAINS.SWAP_ERRORS]: {
        NEED_APPROVE: '001',
        NEED_PERMIT2_APPROVE: '002',
        NOT_ENOUGH_BALANCE: '003',
        NOT_ENOUGH_NATIVE_BALANCE: '004',
        SIMULATION_FAILED: '005',
        UNSUPPORTED_RECEIVER: '006',
        NO_DATA: '007',

        WRONG_ARB_BRIDGE_HASH: '100',

        UNKNOWN: '999'
    },
    //004
    [ERROR_DOMAINS.RUBIC_CONTRACT_ERRORS]: {
        NO_DIRECT_ROUTES: '001',
        NO_SELECTOR: '002',
        NO_CONTRACT: '003',
        UNLISTED: '004'
    },
    // 999
    [ERROR_DOMAINS.UNKNOWN_ERRORS]: {
        UNKNOWN: '999'
    }
}

Example API error responses

Errors may have different structures. PARAMS_ERRORS is an array of errors(it's related with NestJS exceptions of validation pipes)

PARAMS_ERROR example

Common error example

A usual(except PARAMS_ERRORS) error body has a type like

NO_ROUTES

Error with additional "data" field example

Errors can have optional field "data" (object), this field contains additional useful data and details about error cause.

NEED_APPROVE

NOT_ENOUGH_NATIVE_BALANCE (EVM chains)

NOT_ENOUGH_NATIVE_BALANCE (TON)

Last updated