“I want to understand liquidity provision” → Experience concentrated liquidity in 10 minutes
While swaps move tokens, liquidity provision is where the real DeFi magic happens. This guide walks you through adding and removing liquidity using Saros DLMM (concentrated liquidity), giving you hands-on experience with the technology that makes swaps possible.
Prerequisites: Complete your first swap successfully. You need devnet SOL and basic environment validation.
Traditional AMM Problem: Your $1000 liquidity is spread across ALL possible prices (0 to infinity). Only ~0.1% is actually used for trading.DLMM Solution: Your $1000 liquidity concentrates in specific price ranges (bins) where trading actually happens. ~90% actively earns fees.Result: 10x to 100x better capital efficiency = more fees for you.Step-by-step liquidity provision process - this shows the complete workflow you’ll experience
// explore-pool.tsimport { Connection, PublicKey } from '@solana/web3.js';async function explorePool() { console.log('🔍 Exploring DLMM Pool Structure...'); const connection = new Connection('https://api.devnet.solana.com'); // USDC/SOL DLMM pool on devnet const poolAddress = '2wUvdZA8ZsY714Y5wUL9fkFmupJGGwzui2N74zqJWgty'; try { // 1. Get basic pool info const accountInfo = await connection.getAccountInfo(new PublicKey(poolAddress)); if (accountInfo) { console.log('✅ Pool found on-chain'); console.log(`📊 Pool size: ${accountInfo.data.length} bytes`); console.log('🎯 This pool uses DLMM concentrated liquidity'); } else { console.log('❌ Pool not found - check network/address'); return; } // 2. Understand what we found console.log('\n💡 What this means:'); console.log('• Traditional AMM: Liquidity spread across all prices'); console.log('• DLMM: Liquidity concentrated in specific price ranges (bins)'); console.log('• Result: Your liquidity earns more fees'); // 3. Next steps explanation console.log('\n🚀 Ready to add liquidity to this pool!'); console.log('📚 Next: Install DLMM SDK and interact with bins'); } catch (error) { console.error('❌ Pool exploration failed:', error); }}explorePool();
// understand-bins.tsasync function understandBins() { console.log('🧠 Understanding DLMM Liquidity Bins...\n'); // Simulate current price and bins const currentPrice = 100; // Example: 100 USDC per SOL console.log('📊 Traditional AMM Liquidity Distribution:'); console.log('Price Range: $0.01 to $10,000+ per SOL'); console.log('Your $1000: Spread across ALL prices'); console.log('Active liquidity: ~$1 (0.1%)'); console.log('Earning fees: Almost none\n'); console.log('🎯 DLMM Liquidity Distribution:'); console.log(`Current SOL Price: $${currentPrice}`); console.log('Your choice: Focus on $90-110 range (where trades happen)'); console.log('Your $1000: Concentrated in active range'); console.log('Active liquidity: ~$900 (90%)'); console.log('Earning fees: 10-100x more\n'); console.log('🔥 Bins Explanation:'); console.log('• Bin 1: $95-98 per SOL'); console.log('• Bin 2: $98-101 per SOL ← Current price'); console.log('• Bin 3: $101-104 per SOL'); console.log('• Bin 4: $104-107 per SOL'); console.log('• You choose which bins to provide liquidity to!'); console.log('\n✨ This is why DLMM is revolutionary for DeFi');}understandBins();
# Install DLMM SDK for liquidity operationsnpm install @saros-finance/dlmm-sdk# Create wallet configurationcat > wallet-config.ts << 'EOF'import { Connection, Keypair } from '@solana/web3.js';export const connection = new Connection('https://api.devnet.solana.com');// For demo purposes - in real apps, load from secure locationexport function loadWallet(): Keypair { console.log('⚠️ Demo wallet loading'); console.log('🔐 In production, use secure wallet management'); // This would load your actual devnet wallet // return Keypair.fromSecretKey(...) // For now, we'll simulate throw new Error('Load your actual devnet wallet here');}EOF
// prepare-liquidity.tsimport { Connection, PublicKey } from '@solana/web3.js';async function prepareLiquidity() { console.log('🛠️ Preparing for Real Liquidity Operations...\n'); const connection = new Connection('https://api.devnet.solana.com'); // Check requirements console.log('✅ Requirements Check:'); // 1. Network connection try { const version = await connection.getVersion(); console.log(`✅ Connected to Solana (${version['solana-core']})`); } catch (error) { console.log('❌ Network connection failed'); return; } // 2. Wallet setup reminder console.log('📋 Wallet Requirements:'); console.log('• Devnet SOL for transaction fees (~0.1 SOL)'); console.log('• Devnet USDC and SOL tokens for liquidity'); console.log('• Wallet configured in Solana CLI'); // 3. Token requirements console.log('\n🪙 Token Requirements:'); console.log('• Some devnet USDC'); console.log('• Some devnet SOL'); console.log('• Equal value of both (for balanced liquidity)'); // 4. Next steps console.log('\n🚀 Next Steps:'); console.log('1. Get devnet tokens from faucets'); console.log('2. Follow a full DLMM tutorial'); console.log('3. Execute real add/remove liquidity'); console.log('4. Monitor position performance'); console.log('\n📚 Ready for full DLMM tutorial!'); console.log('🔗 Continue to: /dlmm-ts/liquidity-tutorial');}prepareLiquidity();
Capital Efficiency: DLMM concentrates your liquidity where trades actually happen, earning 10-100x more fees than traditional AMMs spreading liquidity across all prices.
Bin Strategy: Choose specific price ranges (bins) for your liquidity. Active bins earn more fees but require more management.
Risk vs Reward: Concentrated liquidity earns more fees but faces higher impermanent loss risk. Balance is key.