Configuration
Tuning the MNMX routing engine for different use cases and environments.
Router Configuration
typescript
1const router = new MnmxRouter({2 // Routing strategy3 strategy: 'minimax', // minimax | cheapest | fastest | safest4
5 // Tolerance6 slippageTolerance: 0.5, // Max acceptable slippage (%)7 timeout: 30_000, // Max total execution time (ms)8
9 // Path constraints10 maxHops: 3, // Maximum intermediate hops11 bridges: ['wormhole', 'debridge', 'layerzero', 'allbridge'],12
13 // Scoring weights (must sum to 1.0)14 weights: {15 fees: 0.25,16 slippage: 0.25,17 speed: 0.15,18 reliability: 0.20,19 mevExposure: 0.15,20 },21
22 // Worst-case multipliers23 adversarialModel: {24 slippageMultiplier: 2.0, // 2x quoted slippage25 gasMultiplier: 1.5, // 1.5x current gas26 bridgeDelayMultiplier: 3.0, // 3x median bridge time27 mevExtraction: 0.003, // 0.3% of value28 priceMovement: 0.005, // 0.5% adverse price change29 },30});Strategy Profiles
Preset configurations for common use cases:
| Strategy | Fees | Slippage | Speed | Reliability | MEV | Use Case |
|---|---|---|---|---|---|---|
| minimax | 0.25 | 0.25 | 0.15 | 0.20 | 0.15 | Best guaranteed outcome (default) |
| cheapest | 0.45 | 0.30 | 0.05 | 0.10 | 0.10 | Minimize total cost |
| fastest | 0.10 | 0.15 | 0.50 | 0.15 | 0.10 | Minimize transfer time |
| safest | 0.10 | 0.15 | 0.10 | 0.40 | 0.25 | Maximize security and reliability |
Adversarial Model Tuning
The adversarial model controls how the minimax engine estimates worst-case outcomes. Adjust based on your risk tolerance:
| Parameter | Default | Conservative | Aggressive |
|---|---|---|---|
slippageMultiplier | 2.0x | 3.0x | 1.5x |
gasMultiplier | 1.5x | 2.0x | 1.2x |
bridgeDelayMultiplier | 3.0x | 5.0x | 2.0x |
mevExtraction | 0.3% | 0.5% | 0.1% |
priceMovement | 0.5% | 1.0% | 0.2% |
Higher multipliers = more conservative routing. The engine will prefer routes with lower variance over routes with higher expected value. This is appropriate when protecting large transfers.
Bridge Configuration
Include or exclude specific bridges:
typescript
1// Only use specific bridges2const router = new MnmxRouter({3 bridges: ['wormhole', 'debridge'],4});5
6// Exclude specific bridges7const router = new MnmxRouter({8 excludeBridges: ['allbridge'],9});10
11// Per-route bridge exclusion12const route = await router.findRoute({13 from: { chain: 'ethereum', token: 'ETH', amount: '1.0' },14 to: { chain: 'solana', token: 'SOL' },15 options: { excludeBridges: ['layerzero'] },16});Chain Configuration
Configure RPC endpoints for each chain:
typescript
1const router = new MnmxRouter({2 chains: {3 ethereum: { rpc: 'https://eth-mainnet.g.alchemy.com/v2/YOUR_KEY' },4 solana: { rpc: 'https://mainnet.helius-rpc.com/?api-key=YOUR_KEY' },5 arbitrum: { rpc: 'https://arb-mainnet.g.alchemy.com/v2/YOUR_KEY' },6 },7});Environment Variables
| Variable | Description | Default |
|---|---|---|
MNMX_STRATEGY | Default routing strategy | minimax |
MNMX_MAX_HOPS | Maximum intermediate hops | 3 |
MNMX_TIMEOUT | Max execution time (ms) | 30000 |
MNMX_SLIPPAGE | Default slippage tolerance (%) | 0.5 |
MNMX_LOG_LEVEL | Logging level | info |
ETH_RPC_URL | Ethereum RPC endpoint | — |
SOL_RPC_URL | Solana RPC endpoint | — |
ARB_RPC_URL | Arbitrum RPC endpoint | — |