Skip to main content
The Flashnet SDK provides a comprehensive error system with typed error codes, automatic fund recovery, and clear guidance on how to handle each type of failure.

Error Codes

All Flashnet AMM Gateway errors follow the format FSAG-XXXX and are categorized by their numeric range:

Recovery Strategies

Each error has an associated recovery strategy that tells you how to handle fund recovery:

Automatic Clawback

The SDK automatically attempts to clawback your funds when an operation fails with a clawbackable error. You don’t need to manually handle fund recovery in most cases.
When you execute operations like executeSwap, executeRouteSwap, addLiquidity, or createSingleSidedPool, the SDK:
  1. Sends your funds to the pool
  2. Executes the operation
  3. If the operation fails with a clawbackable error, automatically attempts to recover your funds
  4. Returns a FlashnetError with details about what happened and the recovery status

Example: Handling Auto-Clawback

Complete Error Code Reference

Validation Errors (1000-1999)

These errors indicate invalid request parameters. Recovery: Clawback Required

Security Errors (2000-2999)

Authentication and authorization failures. Recovery: Clawback Required (except auth token errors)

Infrastructure Errors (3000-3999)

External service and network issues. Recovery: Clawback Recommended

Business Errors (4000-4999)

AMM logic and pool state errors. Recovery: Auto Refund (funds return automatically)

System Errors (5000-5999)

Internal service errors. Recovery: Clawback Required

FlashnetError Properties

The FlashnetError class provides rich error information:

FlashnetError Methods

Best Practices

1. Always Use Type Guards

2. Handle Business Errors Gracefully

Business errors (4000-4999) indicate conditions like slippage or insufficient liquidity. These are auto-refunded and often retryable:

3. Log Request IDs for Debugging

4. Implement Retry Logic for Retryable Errors

Next Steps