How CloddsBot Integrates with Jupiter, Raydium, and Pump.fun on Solana
CloddsBot unifies Jupiter's aggregation engine, Raydium's concentrated liquidity markets, and Pump.fun's PumpSwap AMM through modular adapters in src/solana/jupiter.ts, raydium.ts, and pumpswap.ts, exposing quote generation, swap execution, and liquidity management through a consistent TypeScript API.
CloddsBot's Solana DeFi integration abstracts three major liquidity sources into a single execution layer. According to the alsk1992/CloddsBot source code, the bot implements dedicated modules for Jupiter, Raydium, and Pump.fun that handle everything from price discovery to transaction signing. Traders can route through the optimal venue without managing separate SDK implementations or manual transaction construction.
Jupiter Integration via src/solana/jupiter.ts
The Jupiter adapter in src/solana/jupiter.ts provides access to Solana's dominant swap aggregator, handling both simple swaps and advanced order types.
Quote Generation and Swap Execution
The module exposes getJupiterQuote for price discovery and executeJupiterSwap for transaction submission. All trade-skill commands (/jup, /sol) import these functions to build a JupiterSwapParams object from user requests, retrieve routing data, and submit signed transactions. The integration respects optional environment variables JUPITER_SWAP_BASE_URL and JUPITER_API_KEY for custom endpoints or authenticated API access.
Advanced Order Types
Beyond standard swaps, the Jupiter module supports:
- Limit orders – creation, cancellation, and listing
- Dollar-Cost Averaging (DCA) – create, close, deposit, withdraw, and history retrieval
- Batch and advanced-instruction APIs for complex trading strategies
import { Connection, Keypair } from '@solana/web3.js';
import {
getJupiterQuote,
executeJupiterSwap,
JupiterSwapParams,
} from './solana/jupiter';
// Build a connection & wallet
const conn = new Connection('https://api.mainnet-beta.solana.com');
const wallet = Keypair.fromSecretKey(/* Uint8Array secret */);
// Prepare swap parameters (USDC → SOL)
const params: JupiterSwapParams = {
inputMint: 'EPjFWdd5AufqSSqeM2qZ1T8Gd3bDgDEgG4wWg5d7x6a', // USDC
outputMint: 'So11111111111111111111111111111111111111112', // WSOL
amount: '5000000', // 5 USDC (6 decimals)
slippageBps: 50,
};
// Quote the trade
const quote = await getJupiterQuote(params);
console.log('Estimated out:', quote.outAmount);
// Execute the trade
const result = await executeJupiterSwap(conn, wallet, params);
console.log('Tx signature:', result.signature);
Raydium Integration via src/solana/raydium.ts
The Raydium adapter supports both legacy AMM pools and modern concentrated liquidity markets through a hybrid REST and SDK approach.
Legacy REST API and SDK Abstraction
For standard swaps, the module provides executeRaydiumSwap and getRaydiumQuote using the legacy REST API, alongside listRaydiumPools for pool enumeration. The newer executeRaydiumSwapSdk function internally forwards to the REST implementation for reliability while maintaining SDK compatibility. The @raydium-io/raydium-sdk-v2 package is loaded on demand to minimize cold-start latency. Environment variables RAYDIUM_SWAP_BASE_URL and RAYDIUM_POOL_LIST_URL allow overriding default API endpoints for testnet or private node configurations.
Concentrated Liquidity Management
For CLMM-specific operations, the module exposes functions to create positions, add or remove liquidity, and harvest rewards. Pool discovery implements resilience through a paginated API fallback to api-v3.raydium.io, avoiding the massive legacy dump that can overwhelm the connection.
import { Connection, Keypair } from '@solana/web3.js';
import {
createClmmPosition,
CreateClmmPositionParams,
} from './solana/raydium';
const conn = new Connection('https://api.mainnet-beta.solana.com');
const wallet = Keypair.fromSecretKey(/* secret */);
const clmmParams: CreateClmmPositionParams = {
poolId: 'CLMM_POOL_ID', // from listRaydiumPoolsSdk()
priceLower: 0.98,
priceUpper: 1.02,
baseAmount: '1000000', // 1 TOKEN (6 decimals)
slippage: 0.005,
};
const res = await createClmmPosition(conn, wallet, clmmParams);
console.log('Position NFT mint:', res.nftMint);
Pump.fun PumpSwap Integration via src/solana/pumpswap.ts
The PumpSwap adapter specifically targets Pump.fun's AMM, implementing custom pool discovery and fee-tier resolution logic.
Pool Discovery and Smart Routing
The module uses findPumpSwapPools to discover all pools for a mint pair, then selects the optimal venue via findBestPumpSwapState, which identifies the highest-liquidity pool. To prevent performance degradation, the lookup caps candidates at MAX_POOL_CANDIDATES = 10 and gracefully skips malformed accounts. The SDK @pump-fun/pump-swap-sdk is instantiated per RPC endpoint and cached in onlinePumpAmmSdkCache for reuse. Fee tiers are automatically resolved via the pool's creator field, ensuring accurate pricing calculations.
Quote Calculation and Priority Fee Execution
Quoting relies on pure functions buyQuoteInput and sellBaseInput that calculate prices using on-chain reserves. Execution via executePumpSwapTrade builds the complete instruction set, including Associated Token Account (ATA) creation, WSOL wrapping, and optional priority-fee compute budget instructions. The function accepts a priorityFeeLamports parameter to accelerate transaction inclusion during network congestion.
import { Connection, Keypair } from '@solana/web3.js';
import {
executePumpSwapTrade,
PumpSwapTradeParams,
} from './solana/pumpswap';
const conn = new Connection('https://api.mainnet-beta.solana.com');
const wallet = Keypair.fromSecretKey(/* secret */);
const trade: PumpSwapTradeParams = {
mint: 'PuMPiNkEy...123', // Pump.fun token
side: 'buy',
amountIn: '2000000', // 2 PUMP (6 decimals)
slippageBps: 30,
priorityFeeLamports: 5000, // optional compute-budget boost
};
const result = await executePumpSwapTrade(conn, wallet, trade);
if (result.success) {
console.log('Swap tx:', result.txHash);
} else {
console.error('Swap failed:', result.error);
}
Unified Trading Architecture
CloddsBot's DeFi layer follows a consistent architectural pattern across all three integrations.
Orchestration Flow
The src/trading/orchestrator.ts module coordinates the entire trading pipeline. When a user initiates a request (e.g., "swap 5 USDC for SOL"), the orchestrator:
- Determines the target DEX based on token pair or explicit flags
- Fetches quotes via
getJupiterQuote,getRaydiumQuote, orgetPumpSwapQuote - Presents the quote to the user
- Upon confirmation, executes via
executeJupiterSwap,executeRaydiumSwapSdk(forwarding to the REST implementation), orexecutePumpSwapTrade - Returns transaction signatures or error details
All three modules expose a uniform interface accepting a Solana Connection, a Keypair, and a typed parameter object, making them composable with the bot's command handlers.
Resilience and Configuration
The integration emphasizes operational flexibility through:
- Lazy SDK loading – Raydium and PumpSwap SDKs import only when needed, reducing cold-start latency
- Environment-driven endpoints – All modules read
process.envfor base URLs and API keys, enabling seamless testnet or private-node deployments without code changes - Robust error handling – Pool discovery includes fallback mechanisms and malformed account filtering
- Shared signing utilities –
src/solana/wallet.tsprovides genericsignAndSendTransactionandsignAndSendVersionedTransactionhelpers used uniformly across Jupiter, Raydium, and PumpSwap operations
Summary
- CloddsBot implements dedicated TypeScript modules in
src/solana/jupiter.ts,raydium.ts, andpumpswap.tsto abstract Jupiter, Raydium, and Pump.fun operations. - The Jupiter integration supports aggregation routing, limit orders, and DCA strategies with configurable base URLs via
JUPITER_SWAP_BASE_URL. - Raydium support combines legacy REST APIs with SDK-based CLMM position management, loading
@raydium-io/raydium-sdk-v2on demand. - PumpSwap integration handles pool discovery (capped at 10 candidates), creator-based fee resolution, and priority-fee execution through
@pump-fun/pump-swap-sdk. src/trading/orchestrator.tsunifies the three DEXs under a consistent quote-and-execute flow, whilesrc/solana/wallet.tsprovides shared transaction signing.
Frequently Asked Questions
Which DEX does CloddsBot prioritize for Solana swaps?
CloddsBot does not hardcode a single priority. Instead, src/trading/orchestrator.ts selects the optimal venue based on the specific token pair, user flags, or liquidity depth. Jupiter typically handles general aggregation, Raydium manages concentrated liquidity positions, and PumpSwap routes trades for Pump.fun launchpad tokens.
How does CloddsBot handle Raydium's concentrated liquidity positions?
The createClmmPosition function in src/solana/raydium.ts interacts with Raydium's CLMM pools using the v2 SDK. It accepts parameters for price bounds, token amounts, and slippage, then returns the NFT mint representing the position. The module also supports adding liquidity, removing liquidity, and harvesting rewards from existing positions.
Can I configure custom RPC endpoints for Jupiter?
Yes. The Jupiter module reads the optional environment variables JUPITER_SWAP_BASE_URL and JUPITER_API_KEY. Setting these allows you to redirect quote and swap requests to private Jupiter endpoints or authenticated infrastructure without modifying the TypeScript source code.
Does PumpSwap integration support priority fees?
Yes. The executePumpSwapTrade function in src/solana/pumpswap.ts accepts a priorityFeeLamports parameter. When provided, the function prepends compute-budget instructions to the transaction, increasing the likelihood of inclusion during periods of Solana network congestion.
Have a question about this repo?
These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:
curl -s "https://instagit.com/install.md" Maintain an open-source project? Get it listed too →