harb/onchain/analysis/PARAMETER_SEARCH_RESULTS.md
openhands 21857ae8ca feat: protocol stats display + parameter sweep fuzzing infrastructure (#106)
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-13 18:09:11 +00:00

15 KiB

KRAIKEN Parameter Search Results

Objective

Find optimizer parameters where the LiquidityManager NEVER loses ETH regardless of trade sequence.

Methodology

  • Mode: boundary
  • Runs per parameter combination: 5
  • Trades per run: 30
  • Uncapped swaps: true (trades push through position boundaries)
  • Trade size range: 20-80 ETH (vs 100 ETH LM balance)
  • VWAP accumulation: Environment reused across runs per combo
  • Buy biases tested: 80%
  • Total combinations tested: 252
  • Elapsed time: 64s

Parameters Searched

Parameter Values Description
capitalInefficiency 0%, 30%, 50%, 80% Capital buffer (0=aggressive, 1e18=conservative)
anchorShare 10.0%, 20.0%, 30.0%, 40.0%, 50.0%, 70.0%, 100.0% ETH allocation to anchor vs floor
anchorWidth 30,50,80 Anchor position width (1-100)
discoveryDepth 20%, 50%, 100% Discovery liquidity density
buyBias 80% Adversarial trade mix (80=buy-heavy, 100=buy-only)

Key Metrics

  • Trader PnL < 0: LM gained ETH (SAFE). Trader lost money.
  • Trader PnL > 0: LM lost ETH (UNSAFE). Trader extracted ETH.

Results Summary

  • Safe combinations: 1 / 252
  • Unsafe combinations: 251 / 252

UNSAFE Parameters (Trader Profited = LM Lost ETH)

CI AnchorShare AnchorWidth DiscoveryDepth BuyBias Worst Trader PnL (ETH)
0% 10.0% 30 20% 80 +44.4865
0% 10.0% 30 50% 80 +167.0544
0% 10.0% 30 100% 80 +173.8168
0% 10.0% 50 20% 80 +195.4837
0% 10.0% 50 50% 80 +151.0647
0% 10.0% 50 100% 80 +32.3425
0% 10.0% 80 50% 80 +194.9101
0% 10.0% 80 100% 80 +142.8975
0% 20.0% 30 20% 80 +155.1874
0% 20.0% 30 50% 80 +163.5719
0% 20.0% 30 100% 80 +165.1913
0% 20.0% 50 20% 80 +160.7820
0% 20.0% 50 50% 80 +45.7948
0% 20.0% 50 100% 80 +158.7578
0% 20.0% 80 20% 80 +194.8064
0% 20.0% 80 50% 80 +195.2834
0% 20.0% 80 100% 80 +111.9274
0% 30.0% 30 20% 80 +151.7137
0% 30.0% 30 50% 80 +159.1207
0% 30.0% 30 100% 80 +171.0853
0% 30.0% 50 20% 80 +129.2839
0% 30.0% 50 50% 80 +141.0922
0% 30.0% 50 100% 80 +153.9969
0% 30.0% 80 20% 80 +194.9104
0% 30.0% 80 50% 80 +167.4619
0% 30.0% 80 100% 80 +98.0605
0% 40.0% 30 20% 80 +150.5747
0% 40.0% 30 50% 80 +156.1247
0% 40.0% 30 100% 80 +164.0883
0% 40.0% 50 20% 80 +101.9849
0% 40.0% 50 50% 80 +93.0508
0% 40.0% 50 100% 80 +146.2112
0% 40.0% 80 20% 80 +195.2850
0% 40.0% 80 50% 80 +126.8223
0% 40.0% 80 100% 80 +103.2776
0% 50.0% 30 20% 80 +160.1651
0% 50.0% 30 50% 80 +165.6169
0% 50.0% 30 100% 80 +167.6367
0% 50.0% 50 20% 80 +137.2574
0% 50.0% 50 50% 80 +150.7772
0% 50.0% 50 100% 80 +154.5785
0% 50.0% 80 20% 80 +195.4837
0% 50.0% 80 50% 80 +181.7083
0% 50.0% 80 100% 80 +147.8093
0% 70.0% 30 20% 80 +172.0906
0% 70.0% 30 50% 80 +170.8340
0% 70.0% 30 100% 80 +167.3951
0% 70.0% 50 20% 80 +156.1362
0% 70.0% 50 50% 80 +163.3642
0% 70.0% 50 100% 80 +169.0484
0% 70.0% 80 20% 80 +120.1484
0% 70.0% 80 50% 80 +127.5211
0% 70.0% 80 100% 80 +142.2562
0% 100.0% 30 20% 80 +159.4093
0% 100.0% 30 50% 80 +162.4528
0% 100.0% 30 100% 80 +159.8911
0% 100.0% 50 20% 80 +164.0498
0% 100.0% 50 50% 80 +166.4621
0% 100.0% 50 100% 80 +163.1331
0% 100.0% 80 20% 80 +139.6734
0% 100.0% 80 50% 80 +142.3217
0% 100.0% 80 100% 80 +147.6998
30% 10.0% 30 20% 80 +90.1073
30% 10.0% 30 50% 80 +115.8428
30% 10.0% 30 100% 80 +119.9304
30% 10.0% 50 20% 80 +126.4138
30% 10.0% 50 50% 80 +121.1845
30% 10.0% 50 100% 80 +103.7924
30% 10.0% 80 20% 80 +71.6892
30% 10.0% 80 50% 80 +113.3565
30% 10.0% 80 100% 80 +110.1272
30% 20.0% 30 20% 80 +99.5726
30% 20.0% 30 50% 80 +109.5590
30% 20.0% 30 100% 80 +102.5265
30% 20.0% 50 20% 80 +120.0764
30% 20.0% 50 50% 80 +88.3542
30% 20.0% 50 100% 80 +105.7466
30% 20.0% 80 20% 80 +115.8770
30% 20.0% 80 50% 80 +112.3954
30% 20.0% 80 100% 80 +102.0245
30% 30.0% 30 20% 80 +88.9205
30% 30.0% 30 50% 80 +97.1584
30% 30.0% 30 100% 80 +102.9767
30% 30.0% 50 20% 80 +113.3466
30% 30.0% 50 50% 80 +81.5380
30% 30.0% 50 100% 80 +91.2719
30% 30.0% 80 20% 80 +113.7442
30% 30.0% 80 50% 80 +105.2492
30% 30.0% 80 100% 80 +98.0605
30% 40.0% 30 20% 80 +80.5371
30% 40.0% 30 50% 80 +87.1861
30% 40.0% 30 100% 80 +89.2654
30% 40.0% 50 20% 80 +101.9849
30% 40.0% 50 50% 80 +93.0508
30% 40.0% 50 100% 80 +82.1692
30% 40.0% 80 20% 80 +112.1467
30% 40.0% 80 50% 80 +98.4444
30% 40.0% 80 100% 80 +81.6585
30% 50.0% 30 20% 80 +81.1150
30% 50.0% 30 50% 80 +87.9297
30% 50.0% 30 100% 80 +85.4227
30% 50.0% 50 20% 80 +64.9790
30% 50.0% 50 50% 80 +82.5178
30% 50.0% 50 100% 80 +85.9601
30% 50.0% 80 20% 80 +106.5547
30% 50.0% 80 50% 80 +104.7799
30% 50.0% 80 100% 80 +99.1856
30% 70.0% 30 20% 80 +81.5207
30% 70.0% 30 50% 80 +79.0134
30% 70.0% 30 100% 80 +72.5387
30% 70.0% 50 20% 80 +69.8455
30% 70.0% 50 50% 80 +80.6623
30% 70.0% 50 100% 80 +86.1583
30% 70.0% 80 20% 80 +65.6840
30% 70.0% 80 50% 80 +58.3039
30% 70.0% 80 100% 80 +65.6792
30% 100.0% 30 20% 80 +48.0308
30% 100.0% 30 50% 80 +46.0619
30% 100.0% 30 100% 80 +45.0256
30% 100.0% 50 20% 80 +61.2679
30% 100.0% 50 50% 80 +64.0892
30% 100.0% 50 100% 80 +54.6580
30% 100.0% 80 20% 80 +59.1616
30% 100.0% 80 50% 80 +54.4745
30% 100.0% 80 100% 80 +58.5477
50% 10.0% 30 20% 80 +44.4865
50% 10.0% 30 50% 80 +36.2061
50% 10.0% 30 100% 80 +39.7368
50% 10.0% 50 20% 80 +78.7116
50% 10.0% 50 50% 80 +74.2340
50% 10.0% 50 100% 80 +32.3425
50% 10.0% 80 20% 80 +72.2638
50% 10.0% 80 50% 80 +72.8687
50% 10.0% 80 100% 80 +63.3909
50% 20.0% 30 20% 80 +31.0651
50% 20.0% 30 50% 80 +30.5473
50% 20.0% 30 100% 80 +29.6514
50% 20.0% 50 20% 80 +75.2892
50% 20.0% 50 50% 80 +45.7948
50% 20.0% 50 100% 80 +27.4948
50% 20.0% 80 20% 80 +72.8613
50% 20.0% 80 50% 80 +67.6330
50% 20.0% 80 100% 80 +61.9827
50% 30.0% 30 20% 80 +34.5388
50% 30.0% 30 50% 80 +27.1038
50% 30.0% 30 100% 80 +35.0315
50% 30.0% 50 20% 80 +70.7938
50% 30.0% 50 50% 80 +45.1601
50% 30.0% 50 100% 80 +32.2557
50% 30.0% 80 20% 80 +70.9767
50% 30.0% 80 50% 80 +62.9839
50% 30.0% 80 100% 80 +60.1060
50% 40.0% 30 20% 80 +35.6779
50% 40.0% 30 50% 80 +30.1036
50% 40.0% 30 100% 80 +22.1643
50% 40.0% 50 20% 80 +66.2748
50% 40.0% 50 50% 80 +62.6375
50% 40.0% 50 100% 80 +40.0414
50% 40.0% 80 20% 80 +67.5835
50% 40.0% 80 50% 80 +61.6885
50% 40.0% 80 100% 80 +54.1124
50% 50.0% 30 20% 80 +26.0875
50% 50.0% 30 50% 80 +20.6095
50% 50.0% 30 100% 80 +18.6159
50% 50.0% 50 20% 80 +48.9952
50% 50.0% 50 50% 80 +35.4577
50% 50.0% 50 100% 80 +31.6740
50% 50.0% 80 20% 80 +70.3513
50% 50.0% 80 50% 80 +68.3633
50% 50.0% 80 100% 80 +62.8821
50% 70.0% 30 20% 80 +14.6729
50% 70.0% 30 50% 80 +15.8832
50% 70.0% 30 100% 80 +19.7497
50% 70.0% 50 20% 80 +30.1163
50% 70.0% 50 50% 80 +22.8615
50% 70.0% 50 100% 80 +17.2041
50% 70.0% 80 20% 80 +56.9112
50% 70.0% 80 50% 80 +55.4916
50% 70.0% 80 100% 80 +43.9963
50% 100.0% 30 20% 80 +14.4888
50% 100.0% 30 50% 80 +17.3528
50% 100.0% 30 100% 80 +20.0627
50% 100.0% 50 20% 80 +22.2027
50% 100.0% 50 50% 80 +19.7685
50% 100.0% 50 100% 80 +23.5007
50% 100.0% 80 20% 80 +44.1949
50% 100.0% 80 50% 80 +41.6010
50% 100.0% 80 100% 80 +38.5527
80% 10.0% 30 20% 80 +36.9053
80% 10.0% 30 50% 80 +19.1955
80% 10.0% 30 100% 80 +13.3382
80% 10.0% 50 20% 80 +38.0580
80% 10.0% 50 50% 80 +36.8523
80% 10.0% 50 100% 80 +32.3425
80% 10.0% 80 20% 80 +22.1459
80% 10.0% 80 50% 80 +22.4193
80% 10.0% 80 100% 80 +17.4677
80% 20.0% 30 20% 80 +31.0651
80% 20.0% 30 50% 80 +22.6756
80% 20.0% 30 100% 80 +21.0613
80% 20.0% 50 20% 80 +32.2943
80% 20.0% 50 50% 80 +31.7863
80% 20.0% 50 100% 80 +27.4948
80% 20.0% 80 20% 80 +23.7564
80% 20.0% 80 50% 80 +22.6200
80% 20.0% 80 100% 80 +18.4964
80% 30.0% 30 20% 80 +27.9013
80% 30.0% 30 50% 80 +27.1038
80% 30.0% 30 100% 80 +15.1672
80% 30.0% 50 20% 80 +31.9832
80% 30.0% 50 50% 80 +28.1646
80% 30.0% 50 100% 80 +25.4829
80% 30.0% 80 20% 80 +23.0357
80% 30.0% 80 50% 80 +29.0780
80% 30.0% 80 100% 80 +18.5361
80% 40.0% 30 20% 80 +26.2602
80% 40.0% 30 50% 80 +23.8902
80% 40.0% 30 100% 80 +22.1643
80% 40.0% 50 20% 80 +28.8204
80% 40.0% 50 50% 80 +24.2234
80% 40.0% 50 100% 80 +23.4347
80% 40.0% 80 20% 80 +31.4300
80% 40.0% 80 50% 80 +28.4225
80% 40.0% 80 100% 80 +26.1570
80% 50.0% 30 20% 80 +20.1297
80% 50.0% 30 50% 80 +17.7192
80% 50.0% 30 100% 80 +18.6159
80% 50.0% 50 20% 80 +21.8346
80% 50.0% 50 50% 80 +20.5705
80% 50.0% 50 100% 80 +19.6272
80% 50.0% 80 20% 80 +30.2614
80% 50.0% 80 50% 80 +25.7402
80% 50.0% 80 100% 80 +24.5946
80% 70.0% 30 20% 80 +9.4713
80% 70.0% 30 50% 80 +10.6575
80% 70.0% 30 100% 80 +19.7497
80% 70.0% 50 20% 80 +14.8283
80% 70.0% 50 50% 80 +12.9254
80% 70.0% 50 100% 80 +12.3710
80% 70.0% 80 20% 80 +23.0548
80% 70.0% 80 50% 80 +21.2336
80% 70.0% 80 100% 80 +18.9539
80% 100.0% 30 20% 80 +12.7994
80% 100.0% 30 50% 80 +13.8975
80% 100.0% 30 100% 80 +16.5736
80% 100.0% 50 20% 80 +7.8091
80% 100.0% 50 50% 80 +7.6161
80% 100.0% 50 100% 80 +18.5219
80% 100.0% 80 20% 80 +18.8946
80% 100.0% 80 50% 80 +18.7205
80% 100.0% 80 100% 80 +16.0340

SAFE Parameters

All tested parameter combinations where the LM never lost ETH:

Safe Ranges by Buy Bias

  • BuyBias=80%: 1/252 safe

Top 20 Safest Combinations (most negative trader PnL = hardest to exploit)

CI AnchorShare AnchorWidth DiscoveryDepth BuyBias Worst Trader PnL (ETH)
0% 10.0% 80 20% 80 -114.4822

Exploitation Mechanism

Where Trader Profit ETH Comes From

The trader's profit WETH is extracted from the Uniswap pool's liquidity, which is backed by the LM's positions. Since the LM is the sole liquidity provider:

  1. Trader buys KRAIKEN: sends WETH to pool, receives KRAIKEN from LM's positions
  2. Recenter fires: LM scrapes positions, repositions at new price, mints fresh KRAIKEN
  3. Trader sells KRAIKEN: receives WETH from pool (from LM's repositioned liquidity)
  4. Net: trader extracts WETH from LM's position value

This is impermanent loss (IL) from dynamic liquidity management. Each recenter repositions liquidity at the current price, "absorbing" the price impact. The trader exploits this by pushing price, triggering recenter, then reversing.

VWAP is NOT the Attack Vector

VWAP tracks historical anchor prices weighted by ETH fee volume. getAdjustedVWAP(CI) returns (70% * VWAP) + (CI * VWAP), which places the floor BELOW average prices when CI is low (bull) and ABOVE when CI is high (bear). VWAP anchors the floor to history — it is a safety mechanism that prevents the floor from chasing price up, not an exploitation surface.

Measurement Notes

  • Trader PnL is the reliable safety metric: WETH balance before vs after trading+liquidation
  • lm_eth_delta in the CSV uses lm_balance + pool_WETH as a rough proxy for total LM ETH. This metric is noisy because pool WETH mixes LM position ETH with trader buy WETH in transit. It is informational only — trader PnL is the authoritative signal.

Confirmed: Capped Swaps Prevent Exploitation

With LiquidityBoundaryHelper caps enabled (production behavior): trader ALWAYS loses money. Capped swaps prevent the trader from pushing through position boundaries, eliminating the IL-based extraction. The question is whether caps restrict legitimate large trades.

Recommendations

251 of 252 tested parameter combinations are UNSAFE with uncapped swaps.

The exploitation stems from the LM acting as a repositioning market maker: each recenter resets position geometry around the current price, allowing a trader to repeatedly extract IL by moving the price and triggering repositioning.

capitalInefficiency Effect

CI Unsafe Rate Avg Trader Profit
0% (bull) 98% ~100+ ETH
30% 100% ~85 ETH
50% 100% ~40 ETH
80% (bear) 100% ~22 ETH

CI reduces exploitation magnitude but does not eliminate it.

Mitigation Directions (Require Code Changes)

  1. Keep swap caps: LiquidityBoundaryHelper prevents exploitation entirely
  2. Recenter cooldown: Prevent rapid buy→recenter→sell→recenter cycles
  3. Price impact detection: Detect when recenter is triggered by a single actor's trades
  4. Position geometry hardening: Widen positions to increase slippage cost of round-trips

Generated: 2026-02-07