Error Codes

API error codes and their meanings

DexAggregator uses standard HTTP status codes along with custom error codes for more specific error handling.

HTTP Status Codes

Status Code
Meaning

200

Success

400

Bad Request - Invalid parameters

404

Not Found - Endpoint doesn't exist

500

Internal Server Error

503

Service Unavailable

Custom Error Codes

General Errors (1000-1099)

Code
Message
Description
Solution

1000

Invalid chain

Chain identifier not supported

Use bsc or ethereum

1001

Invalid token address

Token address format invalid

Use checksummed 42-char address

1002

Invalid amount

Amount must be positive

Provide amount > 0 in wei

1003

Invalid slippage

Slippage out of range

Use 1-10000 basis points

1004

Invalid deadline

Deadline in the past

Use future Unix timestamp

Routing Errors (1100-1199)

Code
Message
Description
Solution

1100

No route found

No swap path available

Check token pair availability

1101

KyberSwap API error

Failed to fetch from KyberSwap

Retry or check KyberSwap status

1102

Insufficient liquidity

Not enough liquidity for swap

Reduce swap amount

1103

No supported adapters

No DEX adapters match route

Check includedSources parameter

1104

Route transformation failed

Error processing route data

Report issue with request details

Encoding Errors (1200-1299)

Code
Message
Description
Solution

1200

Encoding failed

Failed to encode calldata

Check swap parameters

1201

Invalid swap type

Swap type not recognized

Report issue

1202

Missing adapter address

Adapter contract not configured

Check chain configuration

Gas Estimation Errors (1300-1399)

Code
Message
Description
Solution

1300

Gas estimation failed

On-chain gas simulation failed

Check RPC endpoint

1301

RPC connection error

Cannot connect to blockchain RPC

Verify RPC URL

Error Response Format

All errors follow this structure:

Handling Errors

JavaScript Example

Python Example

Common Issues and Solutions

Issue: "No route found"

Possible causes:

  • Token pair not supported

  • Insufficient liquidity

  • DEX sources filtered out

Solutions:

  1. Verify both tokens exist on the chain

  2. Check token pair liquidity on DEX

  3. Remove includedSources filter

  4. Reduce swap amount

Issue: "KyberSwap API error"

Possible causes:

  • KyberSwap API temporarily down

  • Rate limiting

  • Network connectivity

Solutions:

  1. Implement exponential backoff retry

  2. Check KyberSwap status page

  3. Verify internet connectivity

Issue: "Invalid token address"

Possible causes:

  • Wrong address format

  • Missing 0x prefix

  • Incorrect checksum

Solutions:

Issue: "Gas estimation failed"

Possible causes:

  • RPC endpoint down

  • Contract execution would revert

  • Insufficient balance

Solutions:

  1. Verify RPC endpoint is responsive

  2. Check wallet has sufficient balance

  3. Verify token approval if needed

Debugging Tips

Enable Debug Mode

Set DEBUG=true environment variable for detailed logs:

This will output:

  • Request/response details

  • Route transformation steps

  • Encoding process

  • Timing information

Reporting Issues

When reporting errors, please include:

  1. Error code and message

  2. Full request payload (remove private keys!)

  3. Chain and token addresses

  4. Timestamp

  5. Server logs (if available)

Report issues on GitHub.

Need Help?

Last updated