Swifter is a revolutionary swap aggregator platform that leverages MetaMask smart accounts with advanced delegation technology, built on the Monad network. The platform delivers a secure, gas-efficient, and flexible automated trading experience with five main swap modes: direct, scheduled, price-targeted, batch convert, and auto-subscription.
- Real-time swap execution at current market prices
- Direct integration with Monorail Swap Aggregator
- Customizable slippage tolerance
- Accurate gas fee estimates
- Schedule swaps for specific future times
- Intuitive date and time picker interface
- Countdown timer for upcoming swaps
- Automated execution without user intervention
- Automated limit orders with specific price targets
- Flexible expiration periods (1 day to 1 year)
- Automatic calculation of minimum received amount
- Automated execution without user intervention
- Multi-token Conversion: Convert multiple ERC20 tokens to a single target token in one transaction
- Smart Token Detection: Automatic detection of all ERC20 tokens in smart account with balance filtering
- Quote Optimization: Real-time price quotes for all selected tokens with automatic failed quote handling
- Gas-Efficient Batching: Single transaction execution for multiple token conversions
- Priority Selection: Smart token selection with verified token prioritization
- Recursive Trading: Set up automatic recurring swaps at customizable intervals
- Flexible Scheduling: Multiple frequency options (hourly, daily, weekly, monthly, custom intervals)
- Duration Control: Configurable subscription periods (1 day to indefinite)
- Smart Balance Management: Automatic execution with balance verification
- Progress Tracking: Real-time monitoring of subscription executions and remaining swaps
Purpose: Create a delegation signature to grant authority to the backend for swap execution
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β DELEGATION CREATION β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
Step 1: Initialization
ββββββββββββββββββββββββββββββββββββββββββββββββ
β β’ Validate smart account address β
β β’ Check wallet connection β
β β’ Initialize swap parameters: β
β - Source token & amount β
β - Target token β
β - Slippage tolerance β
ββββββββββββββββββββββββββββββββββββββββββββββββ
β
Step 2: Quote Fetching
ββββββββββββββββββββββββββββββββββββββββββββββββ
β β’ Call Monorail API for best price β
β β’ Support batch or single quote β
β β’ Calculate expected output amount β
β β’ Get optimal swap route β
β β’ Display price impact to user β
ββββββββββββββββββββββββββββββββββββββββββββββββ
β
Step 3: Delegation Creation
ββββββββββββββββββββββββββββββββββββββββββββββββ
β β’ Generate delegation object with: β
β - Delegate address (backend executor) β
β - Caveats (restrictions): β
β β’ Token allowances β
β β’ Execution limits β
β β’ Time constraints β
β - Nonce & expiry β
β β’ User signs delegation via wallet β
ββββββββββββββββββββββββββββββββββββββββββββββββ
β
Step 4: Approval Handling
ββββββββββββββββββββββββββββββββββββββββββββββββ
β IF token is NOT native (ETH/MATIC): β
β β’ Create ERC20 approval delegation β
β β’ Set allowance for swap contract β
β β’ Sign approval delegation β
β β’ Include in delegation package β
ββββββββββββββββββββββββββββββββββββββββββββββββ
β
Step 5: Submission
ββββββββββββββββββββββββββββββββββββββββββββββββ
β β’ Bundle all delegations β
β β’ Send to backend API: β
β POST /api/delegations β
β { β
β swap_delegation, β
β approval_delegation, β
β metadata β
β } β
β β’ Receive confirmation & tracking ID β
ββββββββββββββββββββββββββββββββββββββββββββββββ
β
β
Success
Purpose: Convert multiple tokens to a single target token in one efficient transaction
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β BATCH CONVERSION β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
Step 1: Token Detection
ββββββββββββββββββββββββββββββββββββββββββββββββ
β β’ Scan smart account for all ERC20 balances β
β β’ Filter tokens with balance > 0 β
β β’ Fetch token metadata (symbol, decimals) β
β β’ Display total portfolio value β
ββββββββββββββββββββββββββββββββββββββββββββββββ
β
Step 2: Target Selection
ββββββββββββββββββββββββββββββββββββββββββββββββ
β β’ User selects target conversion token β
β (e.g., USDC, ETH, USDT) β
β β’ System auto-excludes target token from β
β source token list β
β β’ Show available tokens for conversion β
ββββββββββββββββββββββββββββββββββββββββββββββββ
β
Step 3: Quote Aggregation
ββββββββββββββββββββββββββββββββββββββββββββββββ
β β’ Fetch quotes for ALL selected tokens β
β simultaneously via Monorail batch API β
β β’ For each token pair: β
β - Get best swap route β
β - Calculate output amount β
β - Estimate gas cost β
β β’ Display total expected output β
ββββββββββββββββββββββββββββββββββββββββββββββββ
β
Step 4: Validation
ββββββββββββββββββββββββββββββββββββββββββββββββ
β β’ Check quote results: β
β β
Success: Include in batch β
β β Failed: Auto-deselect & notify user β
β β’ Validate total gas estimate β
β β’ Check for price impact warnings β
β β’ Require user confirmation β
ββββββββββββββββββββββββββββββββββββββββββββββββ
β
Step 5: Batch Execution
ββββββββββββββββββββββββββββββββββββββββββββββββ
β β’ Create batch delegation with: β
β - Multiple swap operations β
β - Shared caveats & restrictions β
β - Optimized execution order β
β β’ Generate approval delegations for each β
β source token β
β β’ User signs batch delegation β
β β’ Submit to backend for execution β
ββββββββββββββββββββββββββββββββββββββββββββββββ
β
Step 6: Confirmation
ββββββββββββββββββββββββββββββββββββββββββββββββ
β β’ Display conversion summary: β
β - Total tokens converted: X β
β - Total output amount: Y target tokens β
β - Transaction hash β
β - Gas cost used β
β - Success/failure per token β
β β’ Update portfolio balance β
ββββββββββββββββββββββββββββββββββββββββββββββββ
β
β
Complete
Purpose: Automatic recurring swap with certain time intervals (DCA strategy)
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β AUTO SUBSCRIPTION β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
Step 1: Configuration
ββββββββββββββββββββββββββββββββββββββββββββββββ
β User Input: β
β β’ Frequency (Daily/Weekly/Monthly) β
β β’ Duration (1 month / 3 months / 1 year) β
β β’ Token pair (e.g., USDC β ETH) β
β β’ Amount per swap β
β β’ Slippage tolerance β
β β
β System Calculates: β
β β’ Total executions = duration / frequency β
β β’ Total cost = amount Γ executions β
β β’ Next execution time β
ββββββββββββββββββββββββββββββββββββββββββββββββ
β
Step 2: Validation
ββββββββββββββββββββββββββββββββββββββββββββββββ
β β’ Check for duplicate pair subscriptions β
β β’ Validate sufficient token balance: β
β Required = amount Γ total_executions β
β β’ Verify gas fee coverage β
β β’ Confirm subscription limit not exceeded β
ββββββββββββββββββββββββββββββββββββββββββββββββ
β
Step 3: Delegation Setup
ββββββββββββββββββββββββββββββββββββββββββββββββ
β β’ Create time-bound delegation with: β
β - Start time: Now β
β - End time: Now + duration β
β - Execution limit: total_executions β
β - Amount per execution: specified amount β
β - Frequency caveat: time interval β
β β
β β’ Generate recurring approval delegation β
β β’ User signs subscription delegation β
ββββββββββββββββββββββββββββββββββββββββββββββββ
β
Step 4: Monitoring
ββββββββββββββββββββββββββββββββββββββββββββββββ
β Backend System Tracks: β
β β’ Execution count: X / total β
β β’ Next run time: timestamp β
β β’ Remaining balance check β
β β’ Subscription status: ACTIVE/PAUSED/ENDED β
β β
β User Dashboard Shows: β
β β’ Progress bar β
β β’ Execution history β
β β’ Average price achieved β
β β’ Total tokens accumulated β
ββββββββββββββββββββββββββββββββββββββββββββββββ
β
Step 5: Automatic Execution
ββββββββββββββββββββββββββββββββββββββββββββββββ
β When Next Run Time Reached: β
β β’ Validate delegation still valid β
β β’ Check balance sufficient β
β β’ Fetch current market quote β
β β’ Execute swap via delegation β
β β’ Update execution counter β
β β’ Calculate next execution time β
β β’ Send notification to user β
ββββββββββββββββββββββββββββββββββββββββββββββββ
β
Step 6: Progress Tracking
ββββββββββββββββββββββββββββββββββββββββββββββββ
β Real-time Updates: β
β β’ Email/Push notification after each swap β
β β’ In-app execution log β
β β’ Performance metrics: β
β - Average buy price β
β - Total accumulated β
β - ROI vs lump sum β
β β
β Completion: β
β β’ Final summary report β
β β’ Option to renew subscription β
ββββββββββββββββββββββββββββββββββββββββββββββββ
β
β
Active
Purpose: Backend service that monitors and executes delegations
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β BACKEND EXECUTION β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
Step 1: Validation
ββββββββββββββββββββββββββββββββββββββββββββββββ
β On Delegation Received: β
β β’ Verify signature validity β
β β’ Check delegation not expired β
β β’ Validate all caveats satisfied β
β β’ Confirm nonce not used β
β β’ Store in execution queue β
ββββββββββββββββββββββββββββββββββββββββββββββββ
β
Step 2: Monitoring
ββββββββββββββββββββββββββββββββββββββββββββββββ
β Continuous Monitoring For: β
β β
β A. Market Conditions: β
β β’ Price thresholds met β
β β’ Liquidity availability β
β β’ Gas price optimal β
β β
β B. Time-Based: β
β β’ Scheduled execution time reached β
β β’ Subscription interval completed β
β β
β C. Subscription Schedules: β
β β’ Next run time for each subscription β
β β’ Execution count not exceeded β
β β’ Balance still sufficient β
ββββββββββββββββββββββββββββββββββββββββββββββββ
β
Step 3: Execution
ββββββββββββββββββββββββββββββββββββββββββββββββ
β When Conditions Met: β
β 1. Fetch latest market quote β
β 2. Validate quote within slippage β
β 3. Execute approval if needed β
β 4. Execute swap via delegation: β
β β’ Call smart account with delegation β
β β’ Submit transaction to network β
β 5. Wait for confirmation β
β 6. Update execution status β
ββββββββββββββββββββββββββββββββββββββββββββββββ
β
Step 4: Confirmation
ββββββββββββββββββββββββββββββββββββββββββββββββ
β Post-Execution: β
β β’ Store transaction hash β
β β’ Update delegation status: COMPLETED β
β β’ Calculate actual vs expected output β
β β’ Compute gas cost β
ββββββββββββββββββββββββββββββββββββββββββββββββ
β
β
Completed
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β SYSTEM ARCHITECTURE β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
Frontend (User Interface)
ββββββββββββββββββββββββββββββββββββββββββββββββ
β β’ Wallet connection (WalletConnect, Metamask)β
β β’ Delegation signing interface β
β β’ Portfolio management dashboard β
β β’ Subscription configuration panel β
β β’ Real-time execution tracking β
ββββββββββββββββββββββββββββββββββββββββββββββββ
β API Calls
Backend Services
ββββββββββββββββββββββββββββββββββββββββββββββββ
β β’ Delegation validation service β
β β’ Execution scheduler (cron jobs) β
β β’ Market monitoring engine β
β β’ Notification service β
β β’ Transaction management β
ββββββββββββββββββββββββββββββββββββββββββββββββ
β RPC Calls
Blockchain Layer
ββββββββββββββββββββββββββββββββββββββββββββββββ
β β’ Smart Account contracts β
β β’ ERC20 tokens β
β β’ Swap router contracts (Monorail) β
β β’ Event logs & transaction tracking β
ββββββββββββββββββββββββββββββββββββββββββββββββ
User Action β Frontend β Backend β Blockchain
β β β β
Sign Validate Execute Confirm
β β β β
Store Monitor Update Notify User
// Hybrid implementation with MetaMask Delegation Toolkit
const smartAccount = await toMetaMaskSmartAccount({
implementation: Implementation.Hybrid,
deployParams: [ownerAddress, [], [], []],
deploySalt: salt,
signer: { walletClient }
});Utilizes @metamask/delegation-toolkit to create limited permissions:
- Restricted Scope: Only the MONORAIL_AGREGATE function is allowed
- Smart Caveats: Time, amount, and balance change restrictions
- Multi-layer Security: Signature verification for each delegation
- Subscription Support: Recurring execution permissions with frequency limits
- Multi-call Aggregation: Combine multiple token approvals and swaps into single transactions
- Gas Optimization: Reduced gas costs through batch processing
- Quote Validation: Pre-execution quote verification and fallback handling
- Token Whitelisting: Verified token prioritization for enhanced security
- Integration with Pimlico for gas sponsorship
- Bundler client for user operation handling
- Paymaster integration for gasless transactions
- Batch gas savings for multiple operations
Delegation Caveats:
limitedCalls: Limits the number of executions (crucial for subscriptions)allowedTargets: Only the Monorail contract is allowedtimestamp: Time-based execution restrictionsbalanceChange: Verification of balance changes
Smart Account Protection:
- Fund isolation through separate smart accounts
- Salt-based account generation
- Deployment verification
- Subscription limit enforcement (max 5 per account)
Batch Convert Security:
- Token verification and whitelisting
- Maximum value limits per batch
- Quote validation before execution
- Automatic failed token deselection
Transaction Safety:
- Slippage protection
- Minimum output guarantee
- Deadline enforcement
- Duplicate subscription prevention
// Enhanced caveats for subscription security
const caveats = [
{
type: "erc20BalanceChange",
tokenAddress: toToken.address,
recipient: smartAccount.address,
balance: BigInt(quote.min_output),
changeType: BalanceChangeType.Increase,
},
{
type: "limitedCalls",
limit: subscriptionData.totalExecutions, // Fixed execution count
}
];1. Insufficient Balance
Detection: Before delegation creation
Action: Show error, suggest amount adjustment
Recovery: User can reduce amount or cancel
2. Quote Failure
Detection: During quote fetching
Action: Retry 3x with exponential backoff
Recovery: Show error, allow manual retry
3. Signature Rejection
Detection: During wallet signing
Action: Clear pending state
Recovery: User can retry signing
4. Execution Failure
Detection: During on-chain execution
Action: Mark delegation as FAILED
Recovery: Refund gas, notify user, allow retry
5. Slippage Exceeded
Detection: Before execution
Action: Skip execution, mark as SKIPPED
Recovery: Notify user, wait for next interval
6. Network Congestion
Detection: High gas prices
Action: Queue for later execution
Recovery: Execute when gas drops below threshold
CREATED β PENDING β EXECUTING β EXECUTED
β β β β
REJECTED QUEUED FAILED COMPLETED
CONFIGURING β ACTIVE β PAUSED β ENDED
β β β
EXECUTING RESUMED COMPLETED
- SwapBox: Main swap interface with intuitive token selection
- SmartWallet: Smart account management with deposit/withdraw
- Task Management: Monitoring and control for all active swaps and subscriptions
- Batch Convert: Unified view for multi-token conversions
- Subscription Manager: Comprehensive control panel for recurring swaps
- Popup System: Elegant confirmation, success, and error handling
- Balance Tracking: Real-time balance updates across all features
- Token Search: Filtering and token verification with batch selection
- Percentage Quick-select: 25%, 50%, 75%, 100% amount selection
- Responsive Design: Mobile-friendly interface
- Progress Indicators: Real-time status for batch and subscription operations
- Smart Defaults: Auto-selection of optimal parameters
- MetaMask Delegation Integration: First in the Monad ecosystem
- Hybrid Smart Accounts: Combines EOA and smart contract benefits
- Gasless Operations: Seamless user experience without gas fees
- Batch Processing Engine: Multi-token operations in single transactions
- Recursive Delegation System: Time-based automatic execution permissions
- Multi-mode Swaps: One platform for all trading needs
- Time-based Automation: Scheduled swaps without manual intervention
- Price Automation: More flexible limit orders
- Portfolio Consolidation: Batch convert scattered tokens into preferred assets
- DCA Strategy Support: Automated dollar-cost averaging through subscriptions
- Smart Account Management: Multiple wallet support with guaranteed security
- Quote Caching: Reduces unnecessary API calls
- Batch Operations: Multi-account and multi-token management
- Gas Price Optimization: Dynamic gas pricing via Pimlico
- Error Recovery: Robust error handling and retry mechanisms
- Parallel Processing: Simultaneous quote fetching for batch operations
- Real-time task tracking for all swap types
- Subscription execution history and progress
- Batch conversion success rates and gas savings
- Transaction history with explorer links
- Comprehensive status updates
- Error reporting and resolution guidance
- Monorail: Swap aggregation engine
- Pimlico: Account abstraction services
- Monad Testnet: Blockchain infrastructure
- MetaMask: Wallet provider and delegation framework
// Core contract addresses
MONORAIL_CONTRACT = "0x525b929fcd6a64aff834f4eecc6e860486ced700"; // Swap aggregation
DELEGATOR_ADDRESS = "0x22f4b7Bca137cF91AE3d08B393167FADdA220eee"; // Scheduled swap Executor
DELEGATOR_ADDRESS_PRICE = "0x82eC492530cAef73fec8512054b070a0a35E0000"; // Price-based swap Executor
DELEGATOR_ADDRESS_AUTOBUY = "0xc14e57e4ba2a86652f362c459c0dc048331f4444"; // Auto-subscription Executor- Multi-chain deployment preparation
- Advanced order types (TWAP, VWAP)
- Portfolio management features
- Mobile app development
- Enhanced batch conversion strategies
- DeFi protocol integrations
- Cross-chain swap capabilities
- Institutional features
- DAO governance model
- Advanced subscription analytics
- Technical Depth: Implements delegation technology not widely adopted
- User-Centric Design: Complex functionality with a simple interface
- Monad Ecosystem Contribution: Building on a new network with specific optimizations
- Production Ready: Mature code quality and security considerations
- β¨ First MetaMask delegation implementation on Monad
- β‘ Gasless scheduled and limit orders
- π Multi-mode swap in a single interface
- π‘οΈ Enhanced security through smart account isolation
- π¦ Batch token conversion for portfolio management
- π Auto-subscription for recurring investment strategies
- Reduced gas costs by up to 80% through sponsorship and batching
- 100% automation rate for scheduled swaps and subscriptions
- Sub-5 second execution for price target swaps
- 99.9% success rate on delegation executions
- 70% gas savings on batch conversions vs individual swaps
- 5x user efficiency improvement through automated recurring swaps
- Time Savings: Automated execution eliminates manual monitoring
- Cost Efficiency: Batch operations reduce overall gas costs
- Portfolio Optimization: Easy consolidation of scattered tokens
- Strategy Implementation: Support for DCA and recurring investment strategies
- Risk Reduction: Automated execution at optimal conditions