Swap Module
Unified token swapping interface with multi-DEX integration for optimal trading on Solana
The Swap Module provides a comprehensive token swapping solution that integrates multiple DEX providers into a unified interface for the Solana blockchain. It automatically finds the best routes and prices across different protocols to maximize trading efficiency.
Core Features
Multi-Provider Support
Integrated support for Jupiter aggregation, Raydium pools, and PumpSwap custom routing
Intelligent Routing
Automatic route optimization to find the best prices and lowest fees across all DEXs
Real-time Pricing
Live price updates, slippage calculations, and fee estimates for informed trading decisions
Advanced Controls
Customizable slippage, provider selection, and transaction parameters for power users
Installation & Setup
Import Module
Import the swap components and hooks:
Wallet Integration
Ensure wallet providers are configured:
DEX Configuration
Configure DEX provider settings (optional):
Module Architecture
The swap module is built with a modular, provider-agnostic architecture:
DEX Providers
Primary DEX Aggregator - Best price discovery across all Solana DEXs
Features:
- Route optimization across 20+ DEXs
- Price impact calculation
- Multi-hop swaps
- Minimal slippage
- Best execution prices
Primary DEX Aggregator - Best price discovery across all Solana DEXs
Features:
- Route optimization across 20+ DEXs
- Price impact calculation
- Multi-hop swaps
- Minimal slippage
- Best execution prices
Direct Pool Access - Concentrated liquidity and direct pool swaps
Features:
- Concentrated liquidity pools
- Direct pool swaps
- Fee sharing options
- Advanced pool analytics
- Custom liquidity provision
Custom Pool Support - Direct pool address specification with custom slippage
Features:
- Custom pool address input
- Configurable slippage (1-30%)
- High impact warnings
- Direct pool interaction
- Specialized token support
Core Components
SwapScreen
- Complete swap interface with all features
Features:
- Token selection with search
- Real-time price updates
- Provider selection interface
- Slippage controls
- Transaction status tracking
- Error handling and recovery
SwapScreen
- Complete swap interface with all features
Features:
- Token selection with search
- Real-time price updates
- Provider selection interface
- Slippage controls
- Transaction status tracking
- Error handling and recovery
SelectTokenModal
- Advanced token selection interface
Features:
- Search functionality with metadata
- Popular tokens list
- Real-time balance display
- Price information
- Custom token import
- Favorite tokens management
Granular UI Components - Building blocks for custom interfaces
Core Hook: useSwapLogic
The primary hook for swap functionality:
TradeService Integration
Provider-agnostic service for executing swaps:
Quick Start Examples
Advanced Features
Real-time Price Monitoring
Slippage Protection
Multi-Route Comparison
Error Handling & Recovery
Performance Optimization
Quote Caching: Implement intelligent quote caching to reduce API calls and improve response times.
Rate Limiting: Be mindful of DEX API rate limits when implementing real-time price updates.
Integration with Other Modules
Wallet Providers
Essential for transaction signing and balance checking
Data Module
Token metadata, prices, and portfolio integration
All DEX Modules
Works alongside Pump.fun, Raydium, and Meteora modules
AI Agent Kit
AI can execute swaps through natural language commands
API Reference
For detailed API documentation, see:
The Swap Module provides the foundation for all token trading activities in your Solana app, offering users the best possible prices through intelligent multi-DEX routing while maintaining a simple and intuitive interface.