Why Cleanups Matter
Single-chain flows are atomic: all succeed or all fail. Cross-chain flows aren’t—a bridge might succeed but the destination swap fails, leaving tokens stranded. Cleanups automatically return leftover tokens to the user.Fusion Mode
For external wallets (MetaMask, Rabby):dependsOn needed—Fusion batches everything automatically.
EIP-7702 / Smart Account Mode
For embedded wallets or SCAs:dependsOn when cleanup should wait for specific instructions.
Multi-Token Cleanup
Return multiple tokens:How It Works
- Cleanup instructions are added to the transaction
- They wait until dependent operations complete
- Transfer any remaining balance back to user
- If balance is 0, cleanup harmlessly reverts
Cleanups always run last and only transfer tokens that remain in the smart account.
When to Use
| Scenario | Use Cleanup? |
|---|---|
| Cross-chain bridge + swap | ✅ Yes |
| Multi-step DeFi flow | ✅ Yes |
| Simple single-chain transfer | ❌ Not needed |
| Atomic single-chain batch | ❌ Not needed |
Tips
- Fusion: Skip
dependsOn—handled automatically - EIP-7702/SCA: Use
dependsOnfor non-sequential flows - Always set
recipientAddressto the user’s EOA - Cleanups prevent funds from being stuck in intermediate accounts