This document provides detailed technical analysis and implementation details for the KRAIKEN protocol's core innovations. For a high-level overview, see AGENTS.md.
The three-position liquidity structure creates an "unfair advantage" against traditional arbitrageurs by forcing asymmetric costs on round-trip trades.
2.**Exploit**: Large trade → triggers recenter() → reverse trade at new configuration
3.**Expected Profit**: Trader profits from predictable liquidity movements
4.**Reality**: Asymmetric slippage makes this unprofitable
### Protection Mechanism
**Position Architecture:**
- **ANCHOR**: Shallow liquidity (~current price) = high slippage, fast price movement
- **DISCOVERY**: Medium liquidity (borders anchor) = fee capture zone
- **FLOOR**: Deep liquidity (VWAP-adjusted) = low slippage, price memory
**Attack Protection Logic:**
1.**First Trade**: Price moves quickly through shallow ANCHOR → hits deep DISCOVERY/FLOOR liquidity (high slippage cost)
2.**Recenter**: Rebalances all positions around new price
3.**Reverse Trade**: Price moves through new shallow ANCHOR → hits opposite deep liquidity (high slippage cost again)
4.**Result**: Attacker pays high slippage twice, making round-trip unprofitable
### Mathematical Foundation
The slippage differential between ANCHOR (shallow) and FLOOR (deep) positions ensures that any round-trip trade pays disproportionate costs, protecting the protocol's liquidity from exploitation.
## Dormant Whale Protection
### The Problem
**Dormant Whale Attack Pattern:**
1.**Accumulation**: Whale buys large amounts early at cheap prices
2.**Dormancy**: Waits extended periods while protocol accumulates volume and prices rise
3.**Exploitation**: Attempts to sell at inflated prices when market conditions are favorable
4.**Impact**: Can crash token price using historical price advantages
### VWAP-Based Solution
**Core Mechanism:**
- **Historical Price Memory**: VWAP tracker maintains volume-weighted average pricing across time
- **FLOOR Position Integration**: Only FLOOR position uses VWAP for price memory (ANCHOR/DISCOVERY use current tick)
- **Compression Algorithm**: Data compression (max 1000x) preserves historical significance while managing storage
### Double-Overflow Analysis
**Stress Testing Results:**
Double-overflow scenarios requiring >1000x compression would need:
- Single transactions >10,000 ETH (unrealistic for any individual)
- Token prices >$4.3 billion (exceeds global wealth)