Skip to main content
This section covers advanced features of the Flashnet AMM SDK including fund recovery mechanisms, background monitoring, and manual clawback operations.

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:
  1. Transfers your funds to the pool
  2. Executes the operation (signing intents, calling the API)
  3. If the operation fails, checks if the error requires clawback
  4. Automatically claws back your funds if needed
  5. 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:
  1. Auto-clawback partially failed - Check error.getUnrecoveredTransferIds() and retry manually
  2. Application crashed mid-operation - Use the monitor or listClawbackableTransfers to find stuck funds
  3. Debugging - Investigate specific transfers before recovery
  4. 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)
Transfers become ineligible after the time limit expires. Use the clawback monitor for continuous recovery.

Error Recovery Decision Tree

Next Steps