Dynamic slippage calculation for synthetic routes โ optimized per token category, liquidity depth, and trade size.
Usage
// Auto โ SDK calculates optimal slippage
await flash.executeLocal(params, { slippage: 'auto' });
// Manual override โ exact bps value
await flash.executeLocal(params, { slippage: 50 }); // 50 bps
// Modes: 'auto', 'aggressive', 'safe', or exact number
import { calculateSlippageBps } from '@vaea/flash';
const bps = calculateSlippageBps('auto', 'synthetic', 0.05);
// Returns 45 bps for a synthetic route with 0.05% price impact
Slippage by Token Category
Route Type
Mode
Slippage
Direct
auto
10 bps (0.1%)
Direct
aggressive
5 bps (0.05%)
Direct
safe
50 bps (0.5%)
Synthetic
auto
max(priceImpact ร 200, 30) ร 1.5
Synthetic
aggressive
max(priceImpact ร 200, 30) ร 1.0
Synthetic
safe
max(priceImpact ร 200, 30) ร 3.0
Calculate Manually
typescript
import { calculateSlippageBps } from '@vaea/flash';
// Modes: 'auto', 'aggressive', 'safe'
const bps = calculateSlippageBps('auto', 'synthetic', priceImpact);
// 'aggressive' โ minimal slippage (may fail on volatile markets)
// 'safe' โ wide margin (always lands but costs more)
// 'auto' โ balanced, recommended for most use cases
โน๏ธ Note
For direct routes, the slippage is minimal because no swap is involved. For synthetic routes, slippage scales with price impact โ the SDK uses 2ร the impact as a safety margin, with a minimum of 30 bps.