๐ŸŽฏ Auto Slippage

Auto Slippage

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 TypeModeSlippage
Directauto10 bps (0.1%)
Directaggressive5 bps (0.05%)
Directsafe50 bps (0.5%)
Syntheticautomax(priceImpact ร— 200, 30) ร— 1.5
Syntheticaggressivemax(priceImpact ร— 200, 30) ร— 1.0
Syntheticsafemax(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.