Skip to main content
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

1

Import Module

Import the swap components and hooks:
2

Wallet Integration

Ensure Embedded Wallets are configured:
3

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

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

Core Hook: useSwapLogic

The primary hook for swap functionality:

TradeService Integration

Provider-agnostic service for executing swaps:
object
object
object

Quick Start Examples

Advanced Features

Real-time Price Monitoring

Slippage Protection

Multi-Route Comparison

Error Handling & Recovery

object

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

Embedded Wallets

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.