Remove Liquidity Overview
Understand how to withdraw liquidity from DLMM positions, collect accumulated fees, and manage partial or complete exits from pools.
What is Removing Liquidity?
In DLMM, removing liquidity means:
Withdrawing tokens from specific bins
Collecting accumulated trading fees
Reducing or closing your position
Receiving tokens based on current bin reserves
Core Concepts
Partial vs Complete Removal
Partial: Remove from selected bins only
Complete: Withdraw all liquidity and fees
Close Position: Complete removal + burn NFT
Token Returns
You receive tokens based on:
Your share of each bin's reserves
Accumulated fees in those bins
Current price (may differ from entry)
Fee Collection
Fees are automatically included in removal
No separate claim transaction needed
Proportional to your liquidity share
The Workflow
1. Check Position Status
const bins = await sdk.Position.getPositionBins(pair, positionId);
const amounts = await sdk.Position.getPositionBinsAmount(pair, positionId);
2. Calculate Expected Output
Preview what you'll receive:
// Check each bin's value
amounts.forEach(bin => {
console.log(`Bin ${bin.id}: ${bin.amountX} X, ${bin.amountY} Y`);
});
3. Execute Removal
Two main options:
Remove from specific bins
Remove all and close position
Removal Strategies
Range Exit
Remove liquidity outside active range:
Before: ████ ████ ████ ████ ████
After: ████ ████ [active]
(removed) (removed)
Profit Taking
Remove from bins with accumulated fees:
Fees: Low Low HIGH Low Low
Action: Keep Keep REMOVE Keep Keep
Rebalancing
Remove and re-add with new distribution:
Remove from current bins
Calculate new optimal range
Add with updated strategy
What You Receive
For each bin removed:
Your tokens = (Your liquidity / Total liquidity) × (Reserves + Fees)
Example:
Your liquidity: 1000
Total in bin: 10000
Bin reserves: 50000 X, 100000 Y
Your share: 10% of everything
Important Considerations
Price Impact
Current price may differ from entry
Can result in more of one token
This is impermanent loss realized
Gas Optimization
Removing many bins costs more gas
Consider batching operations
Complete removal is gas-efficient
Timing
No lock periods in DLMM
Remove anytime markets are open
Consider fee accumulation rates
Common Patterns
Emergency Exit
// Quick complete withdrawal
await sdk.Pair.removeAndClosePosition(pair, positionId);
Selective Removal
// Remove only profitable bins
const profitableBins = bins.filter(b => b.fees > threshold);
await sdk.Pair.removeLiquidity(pair, {
positionId,
binIds: profitableBins.map(b => b.id)
});
Fee Harvesting
// Remove and re-add to collect fees
// 1. Remove all
// 2. Add back immediately
Next Steps
Choose your removal approach:
Partial Removal: Remove from Specific Bins
Complete Exit: Remove All Liquidity
Preview First: Calculate Output Amounts
Related Topics
Position Management - Check bins
Close Position - Remove and burn
Calculate Position Fees - Track earnings
Last updated