Rubic Documents
  • RUBIC
    • Overview
    • Rubic's Ecosystem
    • Security
    • Tokenomics
    • Roadmap
    • Rubic Discord Roles
    • “Swap to Earn” Program on Rubic
    • MEV-bot Protection
    • B2B Cross-Chain Toolkit
      • Use Cases
      • Why Rubic?
    • Refund Guidelines for Stuck Transactions
  • ⚒️Integrate SDK
    • SDK Overview
    • SDK Architecture
    • SDK Advantages
    • SDK Integration
    • 1️⃣Install SDK
    • 2️⃣Set up SDK
    • 3️⃣Trade calculation
    • 4️⃣Swap Execution
    • 📜Advanced documentation
    • Migration from V2 to V3
    • Contact Us
  • Integrate Widget
    • Widget Overview
    • Instruction
    • White Label Widget Integration Instruction
    • Partners
    • Listing of tokens
  • Rubic API
    • 🔐Tokens API
    • Referrer And Rate Limits
    • Rubic API
      • Supported chains
      • Supported providers
      • Request Quote
      • Request Data
      • Get Cross-Chain Status
      • Integration example
        • Swaps from EVM
        • Swaps from Solana
        • Swaps from TON
        • Swaps from Tron
        • Swaps from Bitcoin
        • Swaps VIA deposit
      • Swagger
      • Models
        • OnChainTradeType
        • CrossChainTradeType
        • FeesDto
        • RoutingDto
        • TransactionDto
        • ErrorDto
      • Errors
    • Monetization And Fees
  • FAQ
    • What is Rubic?
    • How to start using Rubic?
    • Who can use our service?
    • Is KYC required?
    • What are the minimum and maximum trade sizes?
    • Should I list my token before using your service?
    • How to create a Swap?
    • How long does it take to complete a transaction?
    • How is the privacy and security of the transaction ensured?
    • How does Rubic unite different DEX platforms?
    • Why does Rubic offer a choice between different providers?
    • How do I add the BNB Smart Chain and Polygon networks to MetaMask?
    • What should I do when I see the message: “Trading on Uniswap is not available?”
    • What should I do if Uniswap doesn’t display any rates?
    • How can we integrate the Rubic Relay widget?
    • How do we get listed on Rubic?
    • How to Complete swaps to/from TON network using Rubic
  • Contacts
    • Community
    • PR Marketing
    • Business Development
    • Support
    • Influencers Collaboration Requests
  • Legal Documentation
    • Privacy Policy
    • Terms of Use
    • Third-Party Software
  • Audits
    • MixBytes Audit
  • Pitch Deck
Powered by GitBook
On this page
  • Description
  • Error domains
  • Error codes
  • Example API error responses
  • PARAMS_ERROR example
  • Common error example
  • Error with additional "data" field example

Was this helpful?

  1. Rubic API
  2. Rubic API

Errors

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

PreviousErrorDtoNextMonetization And Fees

Last updated 29 days ago

Was this helpful?

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 Telegram .

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

{
    errors: [
        {
            code: 1999,
            reason: "fromAddress with value 0x12esa isn't a correct wallet address for ETH network"
        },
        {
            code: 1999,
            reason: "receiver with value 0x12esa isn't a correct address in POLYGON"
        }
    ]
}

Common error example

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

{
    error: {
        code: number,
        reason: string,
        // Error specific data
        data?: object
    },
    id: string
}

NO_ROUTES

{
    error: {
        code: 2001,
        reason:"No routes found. Try to use other tokens" 
    },
    // used to fetch status of successfull cross-chain transaction in destinatio chain
    id: "0367294f-2866-43b6-a937-5e928e8350b7" 
}

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

{
    error: {
        code: 3001,
        reason: "Trade can not be executed. You have not enough allowance for 0x3335733c454805df6a77f825f266e136FB4a3333 spender address",
        data: {
            contractAddress: "0x3335733c454805df6a77f825f266e136FB4a3333"        
        }
    },
    // used to fetch status of successfull cross-chain transaction in destination chain
    id: "0367294f-2866-43b6-a937-5e928e8350b7" 
}

NOT_ENOUGH_NATIVE_BALANCE (EVM chains)

{
    error: {
        code: 3004,
        reason: "Transaction simulation failed. You probably have not enough native currency to pay for transaction on 0x7E1FdF03Eb3aC35BF0256694D7fBe6B6d7b3E0c8 wallet address. You can find approximate gas data for tx in "data".",
        data: {
            gasLimit: "562800",
            gasPrice: "2285283281",
            //tx value
            value: "1050000000000000000"      
        }
    },
    // used to fetch status of successfull cross-chain transaction in destination chain
    id: "0367294f-2866-43b6-a937-5e928e8350b7" 
}

NOT_ENOUGH_NATIVE_BALANCE (TON)

{
    error: {
        code: 3004,
        reason: "Transaction simulation failed. You probably have not enough native currency to pay for transaction on EQBsSItDkR-1_2CiAMxl7MDraJuEopRcw0qQZjso9pAhaVbF wallet address. You can find approximate gas data for tx in "data".",
        data: {
            gas: "200000000",
            value: "1050000000000000000"      
        }
    },
    // used to fetch status of successfull cross-chain transaction in destination chain
    id: "0367294f-2866-43b6-a937-5e928e8350b7" 
}
https://t.me/IlyaRubic
Page cover image