{
  "notes": "EPISODE 2 (goal: lift NP2 on Paradigm AMM fee challenge; need paired +5.8 for top 10, +9.6 for 1st vs NP2 526.1156 on seeds 0..999).\nSTATE AT START: nothing handed, nothing accepted, nothing failed. ep1-rules: 3 items (keys rules, decomp, harness) still waiting. ep1-mech: canary of 5 released (exact-block, arb-classifier, kalman-phat, ev-fee, third-print-alpha) still waiting, 18 held; merges merge-01..03 waiting. This episode woke on the 240-minute timer, not on results. Items used 26 of 400 before this episode; this episode adds 4 (total 30), 8 episodes left after this one.\nDECIDED: spend 4 items on the understanding work the requester's opening note asked for and episode 1 skipped, in two batches of 2 (<=5 items so no canary; two machines per important idea as the requester asked). No cancel, no pause: both ep1 batches are sound and simply have not run yet.\n(1) ep2-board (2 items, no simulator): mine the public per-run board files (GET www.paradigm.xyz/puzzles/api/v1/submissions/<id>, 1,000 runs, same runs in the same order for every entry; ids from /leaderboard?limit=100 with a browser User-Agent) of the top 20 against NP2 d5c8f6a9-febd-4cee-898e-3d81bc88038d. Item top20-regimes: per-run diff vs NP2 by terciles of baselineEdge, retailVolumeY, arbVolumeY; does the leader gain by more retail or less arb per regime. Item top20-families: regression of the diff on run features, correlation of each leader's per-run fee with NP2's fee and with baselineEdge, clustering of the top 20 into strategy families by their fee vectors. Both return a table plus <=5 testable mechanism ideas tied to a measured pattern.\n(2) ep2-oracle (2 items, simulator): the oracle bound. oracle-price = NP2 with pHat replaced by the true fair price each step (sigma still estimated): bounds what better estimation alone buys. oracle-full = knows price and sigma, fee per side = gap to fair on that side + grid-tuned retail fee: bounds what any strategy can earn. Both pair vs NP2 and report arb/retail edge decomposition and fee stats. If oracle-price shows << +9.6, estimation is not the whole story and side asymmetry / fee level per regime matters more; if oracle-full is near +9.6, the leader is near the bound and we need near-oracle tracking.\nCONFIRM SEED BLOCKS (never reuse): ep1-mech item i (0-based, exact-block=0 ... asym-tail=22) uses 2000000+i*10000 .. +9999 (2000000..2229999 in all); harness calibration 2900000..2909999; ep2-oracle oracle-price 2230000..2239999, oracle-full 2240000..2249999. NEXT FREE BLOCK: 2250000 (allocate 10000 per item; skip 2900000..2909999).\nBRIEF BUDGET (hard): a filled brief holds <=3000 chars. The ep2-oracle brief carries a short setup fallback instead of the requester's 1252-char script (workers are told to use the objective's script when they have it); the ep2-board brief needs no simulator. Keep mechanism texts <=297 chars when reusing the ep1-mech template.\nREADS REQUESTED for ep3: ep1-rules/rules, ep1-rules/decomp, ep1-rules/harness, ep1-mech/merge-01..03, ep2-board/top20-regimes, ep2-board/top20-families, ep2-oracle/oracle-price, ep2-oracle/oracle-full.\nEP3 PLAN: (a) read the ep1-mech merges: rank mechanisms by t=mean_diff/se on their confirm blocks; drop t<1 after one try; mechanisms with mean_diff>=2se are winners (their `code`+sha256 are in the item results; check `handed` for api.imd.fun/artifacts/<sha256> addresses to point later workers at them instead of re-deriving). (b) If the ep1-mech canary paused (3 of 5 failed), read `failures`, mend the brief (commonest causes expected: setup/platform blocked, sha256 check of NP2 failing, brief over 3000 chars) and re-run with itemsFrom both; if it released, let the rest run. (c) Use ep1-rules/rules (exact retail split formula: all-or-nothing vs smooth, exact arb rule, fee timing) plus ep2-board regimes/families plus the oracle bounds to write second-generation mechanisms: if the split is a share table, the lever is undercutting the 30 bps normalizer on the safe side when |spot-pHat| is small; if smooth, a closed-form EV-optimal fee per side (retail take vs next-step arb loss, using sigmaHat and the gap) is the lever; add censored-silence posterior update (no print in a step => price stayed within our band), inventory-aware skew, and asymmetric per-side fee from the leader's bid/ask pattern. (d) Stack: each combination item = NP2 + the winners' `delta` texts (or artifact URLs), confirm on a fresh block. (e) Keep ~100 items for ep7-9 stacking and a final 4,000-seed confirmation; the requester submits any file >= +1.0 over NP2 on 4,000 fresh seeds and reports the board score back as a note. Finish when a candidate shows paired mean_diff with mean-2se >= 5.8 vs NP2, or when the budget is near exhausted; the write-up gives final code, sha256, paired{n,mean_diff,se,worst}.",
  "spawn": [
    {
      "name": "ep2-board",
      "brief": "Evidence job, no simulator needed. Paradigm AMM fee challenge board (paradigm.xyz/puzzles/amm). Per-run data: GET https://www.paradigm.xyz/puzzles/api/v1/submissions/<id> returns 1,000 runs with fields submissionEdge, baselineEdge, arbVolumeY, retailVolumeY, averageBidFee, averageAskFee; the same runs in the same order for every entry, so entries compare run by run. Ids: https://www.paradigm.xyz/puzzles/api/v1/leaderboard?limit=100 (send a browser User-Agent). Ours: NP2 id d5c8f6a9-febd-4cee-898e-3d81bc88038d (score 518.829); TWO 666abc0e-bf5e-4f38-bb25-d1042e97821c (518.524); 1st @0xMai 52df1e42-4219-4931-b014-586d91720298 (528.40).\nDO: fetch the leaderboard and the per-run files of the top 20 entries and of NP2 into scratch/ (one JSON per id). Check all files have 1,000 runs with identical baselineEdge sequences; report any mismatch. For each top-20 entry compute per run d_i = submissionEdge_i(entry) - submissionEdge_i(NP2): mean, se (sd/sqrt(1000)), min, number of runs with d_i<0; and its means of retailVolumeY, arbVolumeY, averageBidFee, averageAskFee and of (averageBidFee-averageAskFee) next to NP2's. THEN: {{focus}}\nRESULT (markdown, <=16000 bytes, these sections in this order): `table`: one row per top-20 entry (rank, id, board score, mean d, se, worst d, runs lost, retail, arb, bid fee, ask fee) plus NP2's row; `analysis`: the THEN work with its numbers; `implications`: at most 5 concrete, testable mechanism ideas for a Solidity fee strategy that sees only its own swaps (fees it returned, trade size and direction, post-trade reserves, step timestamp), each tied to one measured pattern above with the number that motivates it; `fetch`: endpoints used, runs fetched per id, ids that failed, User-Agent used. If the API refuses, rate-limits or changes shape, retry with backoff a few times, then return a section `blocked` with the HTTP status and the first 300 chars of the body, with no invented numbers. Never fabricate or extrapolate a figure; every number must come from the fetched files.",
      "items": [
        {
          "key": "top20-regimes",
          "vars": {
            "focus": "cut the 1,000 runs into terciles by NP2's baselineEdge (say what baselineEdge measures per the challenge page; it is the volatility/arb-pressure proxy), by NP2's retailVolumeY and by NP2's arbVolumeY. For the 1st, 2nd, 3rd, 10th and 20th entries give mean d and se per tercile for each of the three cuts, and per tercile the entry's retailVolumeY and arbVolumeY minus NP2's. Say which regime carries the gap to 1st, and whether leaders gain by taking more retail volume or by giving less to arbs in each regime. Also list the 10 runs where 1st beats NP2 by most and the 10 where by least, with those runs' baselineEdge, retail and arb volumes."
          }
        },
        {
          "key": "top20-families",
          "vars": {
            "focus": "fit an OLS regression of d_i for the 1st entry and for the mean of the top 5 on NP2's run features (baselineEdge, retailVolumeY, arbVolumeY, averageBidFee, averageAskFee; standardize features), report coefficients, t-stats and R^2. For every top-20 entry report the correlation across runs of its averageBidFee with NP2's averageBidFee, of its mean fee with the run's baselineEdge (does it raise fees in high-pressure runs?), its fee asymmetry mean and sd, and the sd of its mean fee across runs. Cluster the top 20 (plus NP2) into strategy families by these fee statistics (state the method) and name which family leads, with the family's mean d. Say whether the leader's per-run fee moves with baselineEdge more or less than NP2's does."
          }
        }
      ],
      "output": { "format": "markdown", "maxBytes": 16000 }
    },
    {
      "name": "ep2-oracle",
      "brief": "Simulator github.com/benedictbrady/amm-challenge @6b6921f8d463314aa7c96234e1be25a25245f704. NP2 = `code` of https://api.imd.fun/artifacts/528a6da78583c6142644a552c86670f9d25c20e39e92f4de44deae05ddc8cecd plus the block of `code` of https://api.imd.fun/artifacts/da313379a2e69e9286668865e06b18dfcae25732c82b934b0fd9c2ef0d8c2ff5 from `// Interior retail routing` to (excl.) `uint256 tradeRatio =`, inserted before the former's `uint256 tradeRatio =`; sha256 starts 51f1c1a9. NP2 on seeds 0..999 scores 526.1156.\nSETUP (Linux x86_64): clone into your workspace (never /tmp). With the goal objective's setup script: save it as scratch/setup.sh, run `sh scratch/setup.sh` once from the checkout root, prefix later commands with `. scratch/env.sh && `. Without it: `uv venv --python 3.12 .venv && . .venv/bin/activate && uv pip install -e . maturin && maturin develop --release --uv --manifest-path amm_sim_rs/Cargo.toml`. First check NP2 on seeds 0..999 = 526.1156; if setup or the check fails return `blocked` {step, error} and n 0.\nTASK: measure an ORACLE BOUND: how much knowing the true fair price could earn. Change the simulator in your workspace (amm_sim_rs or the Python runner) so one strategy's bid/ask fees at start and after each trade are computed outside Solidity from the true GBM fair price p_t of the current step and the drawn sigma, while every draw, the arb rule, the retail split and the normalizer stay identical. The oracle strategy: {{oracle}} Pair vs unmodified NP2 with amm_sim_rs.run_batch using MatchRunner._build_configs's draws (default_rng(seed): size, rate, sigma; price seed=seed, retail seed+1), same seeds both sides. Tune on seeds 10000..10999 only; confirm ONCE on seeds {{block}} (fresh, never reused). Prove the baseline unchanged: NP2 through your modified path vs unmodified NP2 on 20 seeds must differ by exactly 0.\nRESULT (markdown, <=16000 bytes, sections in order): `method` (what the oracle knows and computes, where it is hooked in, the baseline proof); `paired` as JSON {n, mean_diff, se, worst} oracle minus NP2 on the confirm block (se = sd/sqrt(n)); `decomp`: arb edge and retail edge at fair price for oracle and NP2 on the confirm block (does the bound come from losing less to arbs or taking more retail); `fee_stats`: mean bid fee, ask fee, |bid-ask| for both; `tuning`: grids tried and values chosen; `lesson` (<=600 chars): what a Solidity strategy that sees only its own swaps could copy. Never invent a number; if the hour runs out, report what finished and mark the rest missing.",
      "items": [
        {
          "key": "oracle-price",
          "vars": {
            "oracle": "ESTIMATION ORACLE: NP2's logic and constants exactly (sigmaHat, skews, shifts, tail compress), but wherever NP2 reads its fair-price estimate pHat for the gap, shift and tox terms, use the true p_t of the current step instead (same units as spot; keep NP2's own pHat update running). Bounds what better fair-price estimation alone buys. Port NP2's fee formula to Rust/Python or pass p_t in as an extra argument; say which.",
            "block": "2230000..2239999"
          }
        },
        {
          "key": "oracle-full",
          "vars": {
            "oracle": "FULL ORACLE: knows p_t and the run's sigma. Per side, fee = the pool's mispricing against fair on that side (the fee at which an arb on that side just breaks even; 0 if the pool is favourable there) plus a retail fee f_side from a grid on seeds 10000..10999 (constants 5..60 bps step 5 per side, then a+b*sigma); clamp to [0, 10%]. Bounds what any strategy can earn. Also report the variant with f_side fixed at 30 bps, separating price knowledge from fee-level tuning.",
            "block": "2240000..2249999"
          }
        }
      ],
      "output": { "format": "markdown", "maxBytes": 16000 }
    }
  ],
  "read": [
    "ep1-rules/rules",
    "ep1-rules/decomp",
    "ep1-rules/harness",
    "ep1-mech/merge-01",
    "ep1-mech/merge-02",
    "ep1-mech/merge-03",
    "ep2-board/top20-regimes",
    "ep2-board/top20-families",
    "ep2-oracle/oracle-price",
    "ep2-oracle/oracle-full"
  ],
  "cancel": [],
  "wake": { "batches": ["ep1-rules", "ep1-mech", "ep2-board", "ep2-oracle"], "afterMinutes": 240 },
  "finish": false
}
