Automatic Fund Recovery
Good news: The SDK automatically handles fund recovery for most failures. When operations like swaps or liquidity additions fail, the SDK attempts to clawback your funds before throwing an error.
How Auto-Clawback Works
When you execute an operation that sends funds to a pool (swap, route swap, add liquidity, or confirm deposit), the SDK:- Transfers your funds to the pool
- Executes the operation (signing intents, calling the API)
- If the operation fails, checks if the error requires clawback
- Automatically claws back your funds if needed
- Returns a typed error with recovery status
Operations with Auto-Clawback
Clawback Monitor
For applications that need continuous fund recovery, the SDK provides a background monitor that automatically recovers any stuck transfers.Starting the Monitor
Monitor Options
Controlling the Monitor
Poll Result Structure
Manual Clawback
For cases where you need manual control over fund recovery.Check Clawback Eligibility
Before attempting clawback, verify a transfer is eligible:List Clawbackable Transfers
Get all your transfers that can be clawed back:Execute Single Clawback
Recover a specific stuck transfer:Batch Clawback
Recover multiple transfers at once:When to Use Manual Clawback
Manual clawback is useful when:- Auto-clawback partially failed - Check
error.getUnrecoveredTransferIds()and retry manually - Application crashed mid-operation - Use the monitor or
listClawbackableTransfersto find stuck funds - Debugging - Investigate specific transfers before recovery
- Custom recovery logic - Implement your own retry strategies
Clawback Eligibility Rules
A transfer is eligible for clawback if:- The authenticated user is the original sender
- The transfer was sent to an LP wallet
- The transfer is not already reserved or spent
- The transfer has not been claimed/settled
- The transfer is less than 23 hours old (for eligibility check) or 10 days old (for listing)
Error Recovery Decision Tree
Next Steps
- Learn about Error Codes and their meanings
- See Swaps for swap operations
- See Liquidity for liquidity operations