Error Codes
All Flashnet AMM Gateway errors follow the formatFSAG-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.
executeSwap, executeRouteSwap, addLiquidity, or createSingleSidedPool, the SDK:
- Sends your funds to the pool
- Executes the operation
- If the operation fails with a clawbackable error, automatically attempts to recover your funds
- Returns a
FlashnetErrorwith 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 RequiredSecurity 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 RecommendedBusiness Errors (4000-4999)
AMM logic and pool state errors. Recovery: Auto Refund (funds return automatically)System Errors (5000-5999)
Internal service errors. Recovery: Clawback RequiredFlashnetError Properties
TheFlashnetError 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
- Learn about the Clawback Monitor for background recovery
- See Advanced Topics for manual clawback and recovery tools