BID-ASK Distribution
Create weighted liquidity that increases farther from the current price. Ideal for market making and volatility harvesting strategies. Visit the Shapes and Strategy section for more details.
Quick Implementation
import { DistributionUtils } from '@ferra-labs/dlmm';
// Create BID-ASK distribution
const bidAskParams = DistributionUtils.createParams(
DistributionUtils.BID_ASK,
{
activeId: pair.parameters.active_id,
binRange: [activeId - 15, activeId + 15],
parsedAmounts: [
new Decimal(1000), // token X
new Decimal(1000) // token Y
]
}
);
// Add liquidity
const tx = await sdk.Pair.openPositionAndAddLiquidity(pair, {
amountX: 1000000000n,
amountY: 1000000000n,
...bidAskParams
});
How It Works
Liquidity weight increases with distance from active bin:
Bin ±1: Weight = 2
Bin ±2: Weight = 3
Bin ±3: Weight = 4
And so on...
// Manual implementation
const range = 10;
const deltaIds = Array.from({length: range * 2 + 1}, (_, i) => i - range);
const distribution = deltaIds.map(id => {
const weight = Math.abs(id) + 1;
return id === 0 ? weight / 2 : weight; // Half weight at active
});
// Normalize to 100
const normalized = distribution.map(v => (v / sum) * 100);
Best Use Cases
✅ Ideal for:
Market making strategies
Mean reversion trading
Volatility harvesting
Large price swings
❌ Not suitable for:
Stable pairs
Trending markets
Passive strategies
Strategy Benefits
Volatility Capture
Profits from price swings
Better fills at extremes
Natural buy low/sell high
Risk Management
Less IL at current price
Protected from small moves
Captures large deviations
Configuration Tips
Volatile pairs: 20-30 bin range
Standard pairs: 15-20 bin range
Adjust range: Based on historical volatility
Example Scenarios
// High volatility pair
const volatileParams = {
binRange: [activeId - 25, activeId + 25], // Wide range
// More capital for larger swings
};
// Moderate volatility
const standardParams = {
binRange: [activeId - 15, activeId + 15], // Standard range
// Balanced approach
};
Key Advantages
Captures volatility premium
Reduces impermanent loss risk
Better pricing at extremes
Automated mean reversion
Related Topics
SPOT Distribution - Uniform approach
CURVE Distribution - Concentrated liquidity
Liquidity Strategies - Advanced tactics
Last updated