# Task: DEX CHECK/USDC capacity-aware fast NPZ tuner v3

## Context

Pool: `base_CHECK_USDC_AERODROME_2PCT` on Base.

Data:

```text
DEX_DATA/fast_npz/base_CHECK_USDC_2PCT_2026_02_05_fee_replay_v2.npz
DEX_DATA/fast_npz/base_CHECK_USDC_2PCT_2026_02_05_fee_replay_v2.meta.json
```

Known metadata:

```text
fee_rate = 0.002515
period = 2026-02-01 → 2026-05-01
swap rows = 133474
```

## Problem

The v2 tuner used fixed `$1000` capital. For this pool that is too large. April v2 runs show avg liquidity share around 5–7% and max share around 70–82%, so the high-return `$1000` runs are not deployable.

## Goal

Use `dex_platform/backtest/cl_fee_replay_fast_npz_v3.py` to tune range and position size together.

## Required commands

April capacity tune:

```bash
bash dex_platform/scripts/tune_check_2pct_capacity_v3.sh
```

Walk-forward/monthly tune:

```bash
bash dex_platform/scripts/run_check_2pct_capacity_walkforward_v3.sh
```

## Capacity constraints

Use these as default live-deployability constraints:

```text
avg_share <= 3%
p95_share <= 5%
p99_share <= 10%
max_share is diagnostic, not the primary hard cap
```

Do not select a champion only because it has the highest return. Select by capacity-aware score.

## Scoring

```text
score =
  return_pct
  - w_mdd * max(0, abs(mdd_pct) - target_mdd_pct)
  - w_avg_share * max(0, avg_share - max_avg_share)
  - w_p95_share * max(0, p95_share - max_p95_share)
  - w_p99_share * max(0, p99_share - max_p99_share)
  - w_max_share * max(0, max_share - max_max_share)
  - w_rebalance * rebalances
```

Defaults:

```text
target_mdd_pct = 25
w_mdd = 2
w_avg_share = 5
w_p95_share = 10
w_p99_share = 3
w_max_share = 0.5
w_rebalance = 0.02
```

## Outputs

Each run must produce:

```text
summary.csv
summary.json
best_by_score.csv
best_by_return.csv
best_capacity_by_strategy.csv
```

Walk-forward must additionally produce:

```text
walkforward.csv
monthly_breakdown.csv
```

## Decision rule

For live/paper test, prefer configs that:

1. pass avg/p95/p99 capacity constraints;
2. do not depend only on April hindsight;
3. keep MDD under or near 25%;
4. use small capital first: `$25–50` for this pool until real fills/fee accounting are validated.

## Do not edit

```text
DEX_DATA/
DEX_REPORTS/
.venv*
.env
old CEX backtest files
```
