# ep3-mech merge 1 The supplied results support retaining **next-mix-a as the sole qualifying candidate**, not claiming the goal is reached. It reports a fresh paired gain of **0.16998543167515265**, SE **0.00735759405356205**, n **4000** (t **23.103399078243136**), exceeding the requested mean_diff >= 2*se filter. Its decoded delta, SHA-256 and full code are copied verbatim below. The other three confirmed candidates lose to NP2; EV-fee is unconfirmed. Sources: the supplied item results, specifically `paired`, `tune`, `delta`, `sha256`, and `code`; exact input paths and hashes appear in `item_evidence`. The task supplies the leaderboard context: NP2 **518.83 (39th)**, 10th **524.66**, first **528.40**, with target paired gains **+5.8** and **+9.6**. These are requester-provided context, not rechecked leaderboard observations. Next-mix's reported gain is much smaller than either target. No combined strategy performance is inferred by adding mechanism gains. All five named inputs were found and parsed. Their byte hashes match the five hashes supplied in the assignment; each embedded code string also hashes to its reported SHA-256. These are integrity checks, not independent reproduction of simulation results. This merge does not rerun setup, tuning, confirmation, gas tests, or leaderboard submission. Every worker-reported metric below is attributed to its exact local input; its external URLs do not independently certify those measurements. The requester flags external-source failures for step-exact (1), Kalman (2), next-mix (2), and router (1). The supplied result files do not identify which specific URL or passage failed; the separate `sources.json` referenced by next-mix is not among the five supplied inputs. Consequently external descriptions of baseline provenance, trade semantics, simulator behavior and fee constraints remain unverified here. In particular, next-mix's statistical selection rests on its worker-reported experiment, not verified external support for its Poisson/actor model. Router's expected normalizer spot=fair is explicitly its modeling assumption; first-print-as-arbitrage is a fallible proxy in the workers' own accounts. These warnings reduce confidence in source-backed explanations and reproducibility; they neither independently validate nor disprove the reported local scores. EV-fee has no source warning reported by the requester, which is not a certification. Four workers report the required CH calibration at 525.5258821780834 and NP2 at 526.1155722459862 on seeds 0..999; EV-fee reports only NP2 calibration and explicitly did not run CH. Sources: each item's `np2_check`. Confirmed workers report paired separate markets against the same 30-bps normalizer using the pinned simulator, with held-out blocks of at least 2,000 seeds, and sample SE; their detailed method claims and block bounds are retained below. Different blocks prevent a direct shared-seed comparison between mechanisms. No raw per-seed arrays or executable harnesses were supplied with these JSON inputs, so the means and SEs cannot be independently recomputed from them. The requested literal disagreement rule (confirm mean below half tuning mean) flags **step-exact-a, kalman-a, router-a**. Each was already negative in tuning and remains negative in confirmation: these are not lost positive gains. **Next-mix-a is not flagged**; its positive gain persists. **EV-fee cannot be assessed**. Exact arithmetic and original tuning values are included per item below. All inputs have `blocked: null`, so no worker-reported blocked step/error exists. EV-fee's missing confirmation is separately marked incomplete, with its stated reason. Its single-seed volume anecdotes are not comparable to confirmation-block averages, and its flat gas counter is explicitly unreliable. Other gas maxima are reported finite stress-test observations, not universal bounds. No candidate should be called safe for every input from those maxima alone. Sources: item `paired`, `gas`, `methodology`, and `notes` where present. The JSON below is the merged table and evidence record. Redundant tuning sweeps are omitted with counts; selected tuning results, all confirmation results (including worst-seed lists), deltas and hashes, reported checks, next ideas, and material limitations are retained. Losing and unconfirmed code is not copied because it does not meet the requested inclusion filter. ```json { "schema_note": "Merged evidence, not a new simulator run. Rows ranked descending by signed confirm t=mean_diff/se; unconfirmed items last. worst is minimum per-seed paired edge difference. All volume metrics retain original units and aggregation. Numerical values retain the supplied precision.", "rows": [ { "key": "next-mix-a", "mechanism_name": "Next-trade Poisson mixture", "n": 4000, "mean_diff": 0.16998543167515265, "se": 0.00735759405356205, "worst": -5.942457080101121, "arb_volume": { "unit": "Y per 10000-step simulation", "n": 4000, "candidate_mean": 23439.897395402422, "np2_mean": 24112.36330017476, "mean_diff": -672.465904772335, "se": 1.4675659770591707, "relative_diff_percent": -2.7888842599160024 }, "retail_volume": { "unit": "Y per 10000-step simulation", "n": 4000, "candidate_mean": 76816.70218368016, "np2_mean": 77286.78958463413, "mean_diff": -470.08740095397167, "se": 1.5922849711752762, "relative_diff_percent": -0.6082377123961091 }, "gas": { "n_calls": 6050, "randomized_calls": 6000, "fresh_first_calls": 50, "initialization_gas": 189944, "max_after_swap_gas": 179704, "max_by_type": { "same_step": 155285, "new_step": 117985, "fresh_first_call": 179704 }, "gas_limit": 250000, "all_success": true, "method": "pyrevm EVM.result.gas_used; direct hooks, randomized constant-product trades, long same-step runs, both directions, time gaps, large reserve shocks, and fresh first-call cases; synthetic test, not a formal all-input bound" }, "blocked_step": null, "t": 23.103399078243136, "source": "item_evidence.next-mix-a" }, { "key": "router-a", "mechanism_name": "Guarded router undercut", "n": 2000, "mean_diff": -26.726126100689385, "se": 0.3506906569088013, "worst": -166.9545351751368, "arb_volume": { "unit": "Y per 10000-step simulation", "candidate_mean": 17620.865548703536, "np2_mean": 24160.909026845355, "mean_diff": -6540.043478141816, "relative_change": -0.27068697915608764 }, "retail_volume": { "unit": "Y per 10000-step simulation", "candidate_mean": 65415.11075070301, "np2_mean": 77519.10077123897, "mean_diff": -12103.990020535963, "relative_change": -0.15614203338419996 }, "gas": { "init_gas": 189971, "max_swap_gas": 155077, "calls": 2000, "limit": 249999, "all_succeeded": true, "fee_bounds_and_guarded_edge_floor": true }, "blocked_step": null, "t": -76.20997472892365, "source": "item_evidence.router-a" }, { "key": "kalman-a", "mechanism_name": "Log-price Kalman estimator", "n": 2000, "mean_diff": -13.64338049411491, "se": 0.0675452328927238, "worst": -30.536359201850132, "arb_volume": { "unit": "Y notional per simulation", "n": 2000, "candidate_mean": 24805.560312813966, "np2_mean": 24137.31254204684, "mean_diff": 668.2477707671262, "paired_se": 14.180364054135135, "relative_change_fraction": 0.02768525988976811 }, "retail_volume": { "unit": "Y notional per simulation", "n": 2000, "candidate_mean": 71929.55188839229, "np2_mean": 77227.81056475846, "mean_diff": -5298.258676366178, "paired_se": 11.014646265756271, "relative_change_fraction": -0.06860557922878541 }, "gas": { "source_sha256": "fe6122f90473052272296d9ef7e4603ccc9501d30d955d283e2b5e58a1a2a460", "init": 237433, "max_after_swap": 145118, "calls": 3000, "all_success": true, "limit": 250000, "scope": "Observed pyrevm EVM.result.gas_used, initialization and 3000 synthetic constant-product swaps, both sides and timestamp gaps 0/1/2/8/25. Finite stress test, not a formal worst-case bound.", "validate_pass": true }, "blocked_step": null, "t": -201.9887993544045, "source": "item_evidence.kalman-a" }, { "key": "step-exact-a", "mechanism_name": "First-print step-exact tracker", "n": 2000, "mean_diff": -54.97857710114733, "se": 0.21258710896579427, "worst": -95.73721933173158, "arb_volume": { "units": "Y", "aggregation": "Mean cumulative volume per 10000-step simulation", "n": 2000, "candidate": 21192.951074082503, "np2": 24125.490624771206, "mean_diff": -2932.539550688712, "se": 19.113652664541636, "relative_change": -0.12155357154385404 }, "retail_volume": { "units": "Y", "aggregation": "Mean cumulative volume per 10000-step simulation", "n": 2000, "candidate": 59935.439361150784, "np2": 77261.75091452763, "mean_diff": -17326.311553376836, "se": 62.349320871912596, "relative_change": -0.2242547101028609 }, "gas": { "source_sha256": "7ebe1a489eab8b4aef49425b1c6f9b4eae6835ade11810278836a954ded741e6", "success": true, "n_calls": 3352, "initialization_gas": 185532, "max_after_swap_gas": 119831, "mean_after_swap_gas": 36270.05727923628, "gas_limit": 250000, "method": "pyrevm ExecutionResult.gas_used, not executor placeholder estimate", "cases": { "retail_sell": 541, "clamp_lower": 386, "later_frozen": 1386, "arb_sell": 429, "clamp_upper": 492, "clamp_inside": 268, "retail_buy": 605, "arb_buy": 391 }, "reserve_reconstruction_max_error_wad": 0, "model": "Independent Decimal natural log; exact integer reserve/fee equations; state assertions after every call", "validate_pass": true, "validate_stdout": "Validating strategy...\nCompiling strategy...\nStrategy 'step_exact_a' validated successfully!", "qualification": "Observed gas in controlled boundary cases and randomized valid constant-product swaps; not a formal all-input bound.", "source": "https://raw.githubusercontent.com/benedictbrady/amm-challenge/6b6921f8d463314aa7c96234e1be25a25245f704/amm_sim_rs/src/evm/strategy.rs" }, "blocked_step": null, "t": -258.61670243605175, "source": "item_evidence.step-exact-a" }, { "key": "ev-fee-a", "mechanism_name": "Expected-value grid fee", "n": 0, "mean_diff": null, "se": null, "worst": null, "arb_volume": "not measured vs NP2 beyond one seed (10000): C=0,W=1 arb 28.9k vs NP2 24.5k; retail 80.1k vs 75.3k (single seed, Y units)", "retail_volume": "see arb_volume", "gas": "validate passes; harness gas counter reports flat 125000 (<250k), unreliable; grid loop is 8 sqrt-newton x 5 iters + 80 loss terms", "blocked_step": null, "t": null, "source": "item_evidence.ev-fee-a" } ], "qualifying_items": [ { "key": "next-mix-a", "source": "item-next-mix-a: delta, sha256, code (verbatim decoded strings)", "delta": "Added only NEXT-TRADE MIX to exact NP2. All existing estimator and fee constants remain unchanged. After TWO's fee compression, k=stepTradeCount-1 uses the first observed print as the existing arb proxy. Compute q=P(Poisson(lambdaHat)>k)/P(Poisson(lambdaHat)>=k); k=0 gives 1-exp(-lambdaHat). Blend the exposed side as q^e*TWO+(1-q^e)*min(10%,abs(ln(spot/pHat))+m*sigmaHat); leave the other side unchanged. Poisson tails use a 24-term positive series; capped log uses five atanh terms; q^e uses square roots and integer powers. Final m=0.625, e=0.125 (MIX_M=625000000000000000, MIX_E_SIXTEENTHS=2). No added state or external dependency.", "sha256": "1e8a7601c5c0622e870e80308f2ab7aa5a58361358e7926f96735c31f6321a5b", "code": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.24;\n\nimport {AMMStrategyBase} from \"./AMMStrategyBase.sol\";\nimport {TradeInfo} from \"./IAMMStrategy.sol\";\n\ncontract Strategy is AMMStrategyBase {\n uint256 constant MIX_M = 625000000000000000;\n uint256 constant MIX_E_SIXTEENTHS = 2;\n uint256 constant ELAPSED_CAP = 8;\n uint256 constant SIGNAL_THRESHOLD = WAD / 650;\n uint256 constant DIR_DECAY = 750000000000000000;\n uint256 constant ACT_DECAY = 530000000000000000;\n uint256 constant SIZE_DECAY = 530000000000000000;\n uint256 constant TOX_DECAY = 910000000000000000;\n uint256 constant SIGMA_DECAY = 690000000000000000;\n uint256 constant LAMBDA_DECAY = 990000000000000000;\n uint256 constant SIZE_BLEND_DECAY = 828000000000000000;\n uint256 constant TOX_BLEND_DECAY = 51000000000000000;\n uint256 constant ACT_BLEND_DECAY = 985000000000000000;\n uint256 constant PHAT_ALPHA = 270000000000000000;\n uint256 constant PHAT_ALPHA_RETAIL = 60000000000000000;\n uint256 constant PHAT_ALPHA_SAME = 120000000000000000;\n uint256 constant REVERT_U = 0;\n uint256 constant DIR_IMPACT_MULT = 4;\n uint256 constant GATE_SIGMA_MULT = 7200000000000000000;\n uint256 constant MIN_GATE = 30000000000000000;\n uint256 constant TRADE_TOX_BOOST = 3500 * BPS;\n uint256 constant STALE_ATTRACT_FRAC = 1050000000000000000;\n uint256 constant RET_CAP = WAD / 35;\n uint256 constant TOX_CAP = WAD / 5;\n uint256 constant TRADE_RATIO_CAP = WAD / 5;\n uint256 constant LAMBDA_CAP = 1820000000000000000;\n uint256 constant STEP_COUNT_CAP = 64;\n uint256 constant BASE_FEE = 4 * BPS;\n uint256 constant SIGMA_COEF = 200000000000000000;\n uint256 constant LAMBDA_COEF = 12 * BPS;\n uint256 constant FLOW_SIZE_COEF = 4842 * BPS;\n uint256 constant TOX_COEF = 300 * BPS;\n uint256 constant TOX_QUAD_COEF = 15000 * BPS;\n uint256 constant ACT_COEF = 91843 * BPS;\n uint256 constant DIR_COEF = 20 * BPS;\n uint256 constant DIR_TOX_COEF = 100 * BPS;\n uint256 constant STALE_DIR_COEF = 6850 * BPS;\n uint256 constant SIGMA_TOX_COEF = 500 * BPS;\n uint256 constant TAIL_KNEE = 600 * BPS;\n uint256 constant TAIL_SLOPE_PROTECT = 930000000000000000;\n uint256 constant TAIL_SLOPE_ATTRACT = 850000000000000000;\n\n function afterInitialize(uint256 initialX, uint256 initialY) external override returns (uint256, uint256) {\n slots[0] = BASE_FEE; slots[1] = BASE_FEE; slots[2] = 0; slots[3] = WAD; slots[4] = 0;\n slots[5] = initialX > 0 ? wdiv(initialY, initialX) : 100 * WAD;\n slots[6] = 950000000000000; slots[7] = 800000000000000000; slots[8] = 2000000000000000;\n slots[9] = 0; slots[10] = 0; slots[11] = 0; slots[12] = 0;\n return (BASE_FEE, BASE_FEE);\n }\n\n function afterSwap(TradeInfo calldata trade) external override returns (uint256, uint256) {\n uint256 prevBidFee = slots[0]; uint256 prevAskFee = slots[1]; uint256 lastTs = slots[2];\n uint256 dirState = slots[3]; uint256 actEma = slots[4]; uint256 pHat = slots[5];\n uint256 sigmaHat = slots[6]; uint256 lambdaHat = slots[7]; uint256 sizeHat = slots[8];\n uint256 toxEma = slots[9]; uint256 stepTradeCount = slots[10];\n\n bool isNewStep = trade.timestamp > lastTs;\n if (isNewStep) {\n uint256 elapsedRaw = trade.timestamp - lastTs;\n uint256 elapsed = elapsedRaw > ELAPSED_CAP ? ELAPSED_CAP : elapsedRaw;\n dirState = _decayCentered(dirState, DIR_DECAY, elapsed);\n actEma = wmul(actEma, _powWad(ACT_DECAY, elapsed));\n sizeHat = wmul(sizeHat, _powWad(SIZE_DECAY, elapsed));\n toxEma = wmul(toxEma, _powWad(TOX_DECAY, elapsed));\n if (stepTradeCount > 0 && elapsedRaw > 0) {\n uint256 lambdaInst = (stepTradeCount * WAD) / elapsedRaw;\n if (lambdaInst > LAMBDA_CAP) lambdaInst = LAMBDA_CAP;\n lambdaHat = wmul(lambdaHat, LAMBDA_DECAY) + wmul(lambdaInst, WAD - LAMBDA_DECAY);\n }\n stepTradeCount = 0;\n }\n\n bool firstInStep = stepTradeCount == 0;\n uint256 spot = trade.reserveX > 0 ? wdiv(trade.reserveY, trade.reserveX) : pHat;\n if (pHat == 0) pHat = spot;\n\n uint256 feeUsed = trade.isBuy ? prevBidFee : prevAskFee;\n uint256 gamma = feeUsed < WAD ? WAD - feeUsed : 0;\n uint256 pImplied;\n if (gamma == 0) { pImplied = spot; }\n else { pImplied = trade.isBuy ? wmul(spot, gamma) : wdiv(spot, gamma); }\n\n {\n uint256 ret = pHat > 0 ? wdiv(absDiff(pImplied, pHat), pHat) : 0;\n uint256 alpha = firstInStep ? PHAT_ALPHA : PHAT_ALPHA_RETAIL;\n uint256 prePhat = pHat;\n bool secondPrint = !firstInStep && stepTradeCount == 1;\n bool sameDir = false; bool oppDir = false;\n if (secondPrint) {\n bool up2 = pImplied >= pHat;\n uint256 d1 = slots[12];\n if (d1 != 0) { sameDir = (d1 == 1) == up2; oppDir = !sameDir; }\n if (sameDir) alpha = PHAT_ALPHA_SAME;\n }\n if (firstInStep) { slots[11] = pHat; slots[12] = pImplied >= pHat ? 1 : 2; }\n uint256 adaptiveGate = wmul(sigmaHat, GATE_SIGMA_MULT);\n if (adaptiveGate < MIN_GATE) adaptiveGate = MIN_GATE;\n if (ret <= adaptiveGate) { pHat = wmul(pHat, WAD - alpha) + wmul(pImplied, alpha); }\n if (oppDir && REVERT_U > 0) {\n uint256 pre = slots[11];\n if (pre > pHat) pHat = pHat + wmul(pre - pHat, REVERT_U);\n else pHat = pHat - wmul(pHat - pre, REVERT_U);\n }\n if (firstInStep) {\n if (ret > RET_CAP) ret = RET_CAP;\n sigmaHat = wmul(sigmaHat, SIGMA_DECAY) + wmul(ret, WAD - SIGMA_DECAY);\n }\n }\n\n // Interior retail routing equalizes fee-adjusted marginal prices.\n // Subsequent trades in a step cannot be the initial arbitrage trade.\n if (!firstInStep && feeUsed > 30 * BPS && gamma > 0) {\n uint256 normalSpot = trade.isBuy\n ? wdiv(wmul(spot, gamma), WAD - 30 * BPS)\n : wdiv(wmul(spot, WAD - 30 * BPS), gamma);\n pHat = wmul(pHat, 90 * WAD / 100) + wmul(normalSpot, 10 * WAD / 100);\n }\n\n uint256 tradeRatio = trade.reserveY > 0 ? wdiv(trade.amountY, trade.reserveY) : 0;\n if (tradeRatio > TRADE_RATIO_CAP) tradeRatio = TRADE_RATIO_CAP;\n\n if (tradeRatio > SIGNAL_THRESHOLD) {\n uint256 push = tradeRatio * DIR_IMPACT_MULT;\n if (push > WAD / 4) push = WAD / 4;\n if (trade.isBuy) {\n dirState = dirState + push;\n if (dirState > 2 * WAD) dirState = 2 * WAD;\n } else {\n dirState = dirState > push ? dirState - push : 0;\n }\n actEma = wmul(actEma, ACT_BLEND_DECAY) + wmul(tradeRatio, WAD - ACT_BLEND_DECAY);\n sizeHat = wmul(sizeHat, SIZE_BLEND_DECAY) + wmul(tradeRatio, WAD - SIZE_BLEND_DECAY);\n if (sizeHat > WAD) sizeHat = WAD;\n }\n\n uint256 tox = pHat > 0 ? wdiv(absDiff(spot, pHat), pHat) : 0;\n if (tox > TOX_CAP) tox = TOX_CAP;\n toxEma = wmul(toxEma, TOX_BLEND_DECAY) + wmul(tox, WAD - TOX_BLEND_DECAY);\n uint256 toxSignal = toxEma;\n\n stepTradeCount = stepTradeCount + 1;\n if (stepTradeCount > STEP_COUNT_CAP) stepTradeCount = STEP_COUNT_CAP;\n\n uint256 flowSize = wmul(lambdaHat, sizeHat);\n uint256 fBase = BASE_FEE + wmul(SIGMA_COEF, sigmaHat) + wmul(LAMBDA_COEF, lambdaHat) + wmul(FLOW_SIZE_COEF, flowSize);\n uint256 fMid = fBase + wmul(TOX_COEF, toxSignal) + wmul(TOX_QUAD_COEF, wmul(toxSignal, toxSignal)) + wmul(ACT_COEF, actEma);\n fMid = fMid + wmul(SIGMA_TOX_COEF, wmul(sigmaHat, toxSignal));\n\n uint256 dirDev; bool sellPressure;\n if (dirState >= WAD) { dirDev = dirState - WAD; sellPressure = true; }\n else { dirDev = WAD - dirState; sellPressure = false; }\n\n uint256 skew = wmul(DIR_COEF, dirDev) + wmul(DIR_TOX_COEF, wmul(dirDev, toxSignal));\n uint256 bidFee; uint256 askFee;\n if (sellPressure) {\n bidFee = fMid + skew;\n askFee = fMid > skew ? fMid - skew : 0;\n } else {\n askFee = fMid + skew;\n bidFee = fMid > skew ? fMid - skew : 0;\n }\n\n {\n uint256 staleShift = wmul(STALE_DIR_COEF, toxSignal);\n uint256 attractShift = wmul(staleShift, STALE_ATTRACT_FRAC);\n if (spot >= pHat) {\n bidFee = bidFee + staleShift;\n askFee = askFee > attractShift ? askFee - attractShift : 0;\n } else {\n askFee = askFee + staleShift;\n bidFee = bidFee > attractShift ? bidFee - attractShift : 0;\n }\n }\n\n {\n bool tradeAligned = (trade.isBuy && spot >= pHat) || (!trade.isBuy && spot < pHat);\n if (tradeAligned) {\n uint256 tradeBoost = wmul(TRADE_TOX_BOOST, tradeRatio);\n if (trade.isBuy) { bidFee = bidFee + tradeBoost; }\n else { askFee = askFee + tradeBoost; }\n }\n }\n\n if (sellPressure) {\n bidFee = clampFee(_compressTailWithSlope(bidFee, TAIL_SLOPE_PROTECT));\n askFee = clampFee(_compressTailWithSlope(askFee, TAIL_SLOPE_ATTRACT));\n } else {\n askFee = clampFee(_compressTailWithSlope(askFee, TAIL_SLOPE_PROTECT));\n bidFee = clampFee(_compressTailWithSlope(bidFee, TAIL_SLOPE_ATTRACT));\n }\n\n // Mix the next retail quote with a defence against next-step arbitrage.\n // The first observed print is our existing proxy for the step's arb;\n // after it, k counts the subsequent observed retail prints.\n {\n uint256 q = _nextRetailProbability(lambdaHat, stepTradeCount - 1);\n uint256 weight = _mixWeight(q);\n uint256 defence = clampFee(_absLogRatio(spot, pHat) + wmul(MIX_M, sigmaHat));\n if (spot >= pHat) {\n bidFee = wmul(weight, bidFee) + wmul(WAD - weight, defence);\n } else {\n askFee = wmul(weight, askFee) + wmul(WAD - weight, defence);\n }\n }\n\n slots[0] = bidFee; slots[1] = askFee; slots[2] = trade.timestamp;\n slots[3] = dirState; slots[4] = actEma; slots[5] = pHat;\n slots[6] = sigmaHat; slots[7] = lambdaHat; slots[8] = sizeHat;\n slots[9] = toxEma; slots[10] = stepTradeCount;\n\n return (bidFee, askFee);\n }\n\n // Poisson survival ratio P(N > k) / P(N >= k). Dividing both\n // tails by P(N=k) avoids cancellation for large k. For k=0 this\n // is exactly 1-exp(-lambda), up to fixed-point/series rounding.\n function _nextRetailProbability(uint256 lambda, uint256 k) internal pure returns (uint256) {\n uint256 term = WAD;\n uint256 tail;\n for (uint256 j = 1; j <= 24; ++j) {\n term = wmul(term, lambda) / (k + j);\n tail += term;\n if (term == 0) break;\n }\n return wdiv(tail, WAD + tail);\n }\n\n // e is an exact multiple of 1/16. Successive square roots implement\n // the fractional bits without an external fixed-point math library.\n function _mixWeight(uint256 q) internal pure returns (uint256 weight) {\n weight = _powWad(q, MIX_E_SIXTEENTHS / 16);\n uint256 fraction = MIX_E_SIXTEENTHS % 16;\n uint256 root = q;\n for (uint256 bit = 8; bit > 0 && fraction > 0; bit >>= 1) {\n root = sqrt(root * WAD);\n if ((fraction & bit) != 0) {\n weight = wmul(weight, root);\n fraction -= bit;\n }\n }\n }\n\n // 2*atanh((a-b)/(a+b)) = abs(ln(a/b)). Once z >= .05,\n // the logarithm exceeds the 10% fee cap. In the remaining domain\n // five positive terms give <1e-15 absolute truncation error.\n function _absLogRatio(uint256 a, uint256 b) internal pure returns (uint256) {\n if (a == b) return 0;\n if (a == 0 || b == 0) return MAX_FEE;\n uint256 z = wdiv(absDiff(a, b), a + b);\n if (z >= WAD / 20) return MAX_FEE;\n uint256 z2 = wmul(z, z);\n uint256 power = z;\n uint256 series = z;\n for (uint256 j = 3; j <= 9; j += 2) {\n power = wmul(power, z2);\n series += power / j;\n }\n return 2 * series;\n }\n\n function _compressTailWithSlope(uint256 fee, uint256 slope) internal pure returns (uint256) {\n if (fee <= TAIL_KNEE) return fee;\n return TAIL_KNEE + wmul(fee - TAIL_KNEE, slope);\n }\n\n function _powWad(uint256 factor, uint256 exp) internal pure returns (uint256 result) {\n result = WAD;\n while (exp > 0) {\n if (exp & 1 == 1) result = wmul(result, factor);\n factor = wmul(factor, factor);\n exp >>= 1;\n }\n }\n\n function _decayCentered(uint256 centered, uint256 decayFactor, uint256 elapsed) internal pure returns (uint256) {\n uint256 mul = _powWad(decayFactor, elapsed);\n if (centered >= WAD) { return WAD + wmul(centered - WAD, mul); }\n uint256 below = wmul(WAD - centered, mul);\n return below < WAD ? WAD - below : 0;\n }\n\n function getName() external pure override returns (string memory) { return \"NP2_next_mix_a\"; }\n}\n" } ], "blocked_items": [], "incomplete_items": [ { "key": "ev-fee-a", "step": "confirmation", "error": "Confirm block 2320000+ NOT run: no tuned config beat NP2, and time was short. Delivered code is not shown to improve on NP2.", "reported_blocked": null, "additional_gaps": "CH not separately run; no aggregate confirmation volumes; flat 125000 gas counter explicitly unreliable. No measured confirmation gas bound." } ], "next_ideas": [ { "key": "step-exact-a", "source": "item-step-exact-a#/next", "idea": "Do not promote: the frozen step-exact tracker loses to NP2. A separate experiment should test a stronger first-print arb/retail classifier or a volatility estimate insulated from retail; no post-confirmation tuning was performed." }, { "key": "kalman-a", "source": "item-kalman-a#/next", "idea": "Do not promote: the frozen Kalman estimator loses to NP2 on fresh paired seeds. Preserve NP2. Investigate a likelihood that distinguishes retail from arbitrage before another independently reserved confirmation block." }, { "key": "ev-fee-a", "source": "item-ev-fee-a#/next", "idea": "EV fee as specified does not help: loss term is mis-scaled vs sim (any C>0 hurts sharply); TWO's tox/shift terms already price stale flow. Try EV only to modulate fBase by +-few bps, or fit C via regression of realized arb loss." }, { "key": "next-mix-a", "source": "item-next-mix-a#/next", "idea": "Evaluate a separate variant with a retail-only arrival estimate and an explicit uncertainty model for the first observed print; preserve these untouched confirmation results. This mix alone does not establish a leaderboard gain of +5.8 or +9.6." }, { "key": "router-a", "source": "item-router-a#/next", "idea": "Do not promote: reserved confirmation loses 26.7261 edge per seed vs NP2. First print can be retail; test reliable arb classification before further router tuning. High edge thresholds suppress most overrides." } ], "item_evidence": { "step-exact-a": { "delta": "Replace NP2's smoothed pHat, second-print update and normalizer blend with first-print-only step-exact tracking; no later print updates pHat. Reconstruct pre-trade X/Y reserves by reversing net input (gross amount*(1-fee)) and output; s0=preY/preX. pA=postSpot*(1-bidFee) when AMM buys X, postSpot/(1-askFee) when it sells X. Set pHat=pA iff abs(ln(pA/pHat)) <= k*sigmaHat*sqrt(1+gap); otherwise clamp into [s0*(1-bidFee),s0/(1-askFee)]. gap=timestamp-lastTs (0 at timestamp 0); gate uses pre-update sigmaHat and an equivalent squared comparison. Final k=1.1 (WAD STEP_K); range-reduced WAD log series through z^39/39. Keep NP2's sigma update and all fee/state coefficients; remove unused smoothing constants and slots 11/12; name step_exact_a.", "sha256": "7ebe1a489eab8b4aef49425b1c6f9b4eae6835ade11810278836a954ded741e6", "np2_check": { "seeds": "0..999", "n": 1000, "CH": 525.5258821780834, "CH_expected": 525.525882178, "NP2": 526.1155722459862, "NP2_expected": 526.1156, "pass": true, "np2_sha256": "51f1c1a9d4999ee460eb8bbc66880da8074b173399a4f5d71f96671482e18ac0", "config_draws_match": true, "method": "Measured locally with the pinned unmodified simulator; required scores reproduced before tuning.", "source_urls": [ "https://api.imdnotdead.fun/artifacts/528a6da78583c6142644a552c86670f9d25c20e39e92f4de44deae05ddc8cecd", "https://api.imdnotdead.fun/artifacts/da313379a2e69e9286668865e06b18dfcae25732c82b934b0fd9c2ef0d8c2ff5", "https://raw.githubusercontent.com/ChengHua926/amm-challenge/d34a5199c59a4c44d5336a25f1436b4ae1f21104/contracts/src/Strategy.sol" ] }, "tune": { "seeds": [ "10000..10249", "20000..20999" ], "best_mean_diff": -55.172618628615865, "selected_k": "1.1", "selection_seeds": "20000..20999", "selection_n": 1000, "selection_se": 0.3342720434119169, "selection_rule": "Highest paired mean on the final tuning comparison block; only k varied.", "method": { "simulator_commit": "6b6921f8d463314aa7c96234e1be25a25245f704", "simulator_url": "https://github.com/benedictbrady/amm-challenge/tree/6b6921f8d463314aa7c96234e1be25a25245f704", "backend": "amm_sim_rs.run_batch; 8 workers; chunks of 32; source files unmodified", "comparison": "Each candidate and NP2 separately versus VanillaStrategy (30bps), identical configs per seed.", "draws": "numpy.default_rng(s): size uniform(19,21), rate uniform(0.6,1.0), sigma uniform(0.000882,0.001008), in this order; cfg.seed=s.", "config": "10000 steps; initial price=100, X=100, Y=10000; mu=0, dt=1, retail_size_sigma=1.2, buy_prob=0.5; price seed=s, retail seed=s+1.", "statistics": "diff=candidate edge minus NP2 edge per seed; se=sample std(ddof=1)/sqrt(n); worst=five smallest differences.", "sources": [ "https://raw.githubusercontent.com/benedictbrady/amm-challenge/6b6921f8d463314aa7c96234e1be25a25245f704/amm_competition/competition/match.py", "https://raw.githubusercontent.com/benedictbrady/amm-challenge/6b6921f8d463314aa7c96234e1be25a25245f704/amm_competition/competition/config.py", "https://raw.githubusercontent.com/benedictbrady/amm-challenge/6b6921f8d463314aa7c96234e1be25a25245f704/amm_sim_rs/src/simulation/engine.rs" ] }, "trials_omitted_count": 19, "freeze_omitted_count": null }, "paired": { "n": 2000, "mean_diff": -54.97857710114733, "se": 0.21258710896579427, "candidate_mean": 469.20752348822555, "np2_mean": 524.1861005893729, "worst": [ { "seed": 2301168, "diff": -95.73721933173158, "candidate_edge": 454.4537875924767, "np2_edge": 550.1910069242083 }, { "seed": 2300162, "diff": -93.62417465872693, "candidate_edge": 459.9724303906537, "np2_edge": 553.5966050493806 }, { "seed": 2301696, "diff": -85.20055118602056, "candidate_edge": 552.8518464574979, "np2_edge": 638.0523976435185 }, { "seed": 2301874, "diff": -84.52321436099061, "candidate_edge": 510.1803479961731, "np2_edge": 594.7035623571637 }, { "seed": 2301862, "diff": -84.46787087727193, "candidate_edge": 625.5342079634817, "np2_edge": 710.0020788407536 } ], "seeds": "2300000..2301999", "definition": "Candidate submission edge minus NP2 submission edge; separate markets with the same 30bps normalizer and identical seed/config draws.", "run_once": true, "candidate_frozen_before_confirmation": true, "measurement": "Local simulation result, not an independently verified leaderboard score." }, "blocked": null, "next": "Do not promote: the frozen step-exact tracker loses to NP2. A separate experiment should test a stronger first-print arb/retail classifier or a volatility estimate insulated from retail; no post-confirmation tuning was performed.", "source": { "read_path": ".imd/reads/artifacts/item-step-exact-a", "original_result_path": "artifacts/goal/batches/ep3-mech/items/step-exact-a/result.json", "input_sha256": "9dc856ee8380caa57325dd6a88995e5d5510b2b493f0ba35a99647ab66be8580", "json_fields": "Original result fields unless explicitly marked derived or omitted. Gas and volume fields are preserved in rows." }, "code_sha256_checked_by_merge": true, "external_source_warning_count": 1, "tune_confirm_comparison_derived": { "tuning_mean_diff": -55.172618628615865, "half_tuning_mean_diff": -27.586309314307933, "confirm_mean_diff": -54.97857710114733, "literal_below_half_tuning_flag": true, "positive_tuning_gain": false, "interpretation": "Both tuning and confirmation are negative; literal flag is not evidence of a positive gain collapsing." } }, "kalman-a": { "delta": "Replace NP2's EWMA/second-print pHat update with a log-price Kalman estimator. slots[5]=lnP, [11]=P, [12]=previous postSpot (preSpot on next call). First print predicts P += sigmaHat^2*uncapped timestamp gap. Each print uses arb-implied log price if innovation <= c*sqrt(P); otherwise log pre-trade fee-band midpoint, R=log-band-width^2/12. Apply K=P/(P+R), lnP+=K*(z-lnP), P*=1-K. Retain NP2 process sigma EMA and 10% interior-retail recentering, synchronizing lnP afterward. Both sigma-dependent fee terms use sqrt(P); all other fee constants/rules unchanged. Initial P=(0.00095)^2; numerical noise floor=1e-18. Final Ra=0.0001 (WAD 100000000000000), c=2 (WAD 2000000000000000000).", "sha256": "fe6122f90473052272296d9ef7e4603ccc9501d30d955d283e2b5e58a1a2a460", "np2_check": { "seed_start": 0, "n": 1000, "mean_edge": 526.1155722459862, "expected_rounded": 526.1156, "pass": true, "sha256": "51f1c1a9d4999ee460eb8bbc66880da8074b173399a4f5d71f96671482e18ac0", "CH_mean_edge": 525.5258821780834, "CH_expected": 525.525882178, "CH_pass": true, "CH_sha256": "6dd68f77a70900319460215374143dbd5d924198450a46d9f5f91f6b1e3d35c3" }, "tune": { "seeds": { "screen": "10000..10099", "tight_gate_screen": "10000..10029", "finalist_selection": "10000..10499" }, "best_mean_diff": -13.646362055829721, "best_se": 0.13683200381645474, "final_Ra": 0.0001, "final_c": 2.0, "finalists": [ { "path": "scratch/g-100000000000000-2.sol", "n": 500, "mean_diff": -13.646362055829721, "se": 0.13683200381645474, "worst": -24.130644209520597 }, { "path": "scratch/k-300000000000000-3.sol", "n": 500, "mean_diff": -16.37544595613936, "se": 0.12174998401182698, "worst": -26.425913420986603 }, { "path": "scratch/k-100000000000000-3.sol", "n": 500, "mean_diff": -16.401150447677075, "se": 0.1605896734953754, "worst": -28.234662515563855 } ], "selection": "Highest paired mean over 500 tuning seeds among finalists; frozen before any confirmation run.", "screened_omitted_count": 31 }, "paired": { "n": 2000, "seed_start": 2310000, "seed_end": 2311999, "mean_diff": -13.64338049411491, "se": 0.0675452328927238, "worst": [ { "seed": 2310445, "diff": -30.536359201850132, "candidate_edge": 519.6567120423781, "np2_edge": 550.1930712442282 }, { "seed": 2311085, "diff": -26.992669113837792, "candidate_edge": 599.965857648871, "np2_edge": 626.9585267627087 }, { "seed": 2310171, "diff": -23.459192084430924, "candidate_edge": 649.0057894329269, "np2_edge": 672.4649815173578 }, { "seed": 2310535, "diff": -23.356974182203885, "candidate_edge": 664.6229316321741, "np2_edge": 687.979905814378 }, { "seed": 2311881, "diff": -22.74528651746573, "candidate_edge": 557.5634360583073, "np2_edge": 580.308722575773 } ], "candidate_mean_edge": 512.0246669477377, "np2_mean_edge": 525.6680474418525, "confirmation_runs_per_strategy_per_seed": 1 }, "blocked": null, "next": "Do not promote: the frozen Kalman estimator loses to NP2 on fresh paired seeds. Preserve NP2. Investigate a likelihood that distinguishes retail from arbitrage before another independently reserved confirmation block.", "methodology": { "evidence": "All numerical performance, volume, gas and check values are local measurements; source URLs document source code and simulator semantics, not independent certification.", "simulator_commit": "6b6921f8d463314aa7c96234e1be25a25245f704", "setup": "Requester item setup script run once; StarterStrategy validation passed.", "pairing": "Separate amm_sim_rs.run_batch runs: candidate vs VanillaStrategy(30bps), NP2 vs same VanillaStrategy. Difference is candidate submission edge minus NP2 submission edge for the same seed. Never candidate vs NP2 in a shared market.", "draws": "numpy.random.default_rng(seed): size U(19,21), rate U(0.6,1.0), sigma U(0.000882,0.001008), in that order. cfg.seed=seed; retail seed=seed+1.", "fixed_config": "10000 steps; initial_price=100, initial_x=100, initial_y=10000; gbm_mu=0; gbm_dt=1; retail_size_sigma=1.2; retail_buy_prob=0.5. Eight workers; chunks of 50.", "statistics": "Arithmetic mean of per-seed differences; SE=sample std(ddof=1)/sqrt(n). Worst lists five most negative paired differences. Confirmation uses the first 2000 seeds within the specified 2310000..2319999 block, once after freeze; no tuning afterward.", "band": "Band endpoints converted to log prices before midpoint and width calculations so measurement and variance have consistent units. Stored prior postSpot equals pre-trade spot because reserves change only on our swaps. NP2 routing correction recenters lnP without an extra variance update.", "tests": { "math_roundtrip": { "source_sha256": "fe6122f90473052272296d9ef7e4603ccc9501d30d955d283e2b5e58a1a2a460", "input_price_min": 1e-12, "input_price_max": 1999000000000.0, "cases": 100, "max_relative_roundtrip_error": 1.4285714285306002e-06 }, "kalman_update_oracle": { "source_sha256": "fe6122f90473052272296d9ef7e4603ccc9501d30d955d283e2b5e58a1a2a460", "cases": 300, "arb_updates": 271, "band_updates": 29, "max_abs_log_price_error": 8.881784197001252e-16, "oracle": "double-precision specified Kalman update, reading prior EVM state" } } }, "source": { "read_path": ".imd/reads/artifacts/item-kalman-a", "original_result_path": "artifacts/goal/batches/ep3-mech/items/kalman-a/result.json", "input_sha256": "b8700c506a75b70cf8475c7249c20e9f6b140b8fd64ef8b45e6b9f0c02f58ca9", "json_fields": "Original result fields unless explicitly marked derived or omitted. Gas and volume fields are preserved in rows." }, "code_sha256_checked_by_merge": true, "external_source_warning_count": 2, "tune_confirm_comparison_derived": { "tuning_mean_diff": -13.646362055829721, "half_tuning_mean_diff": -6.823181027914861, "confirm_mean_diff": -13.64338049411491, "literal_below_half_tuning_flag": true, "positive_tuning_gain": false, "interpretation": "Both tuning and confirmation are negative; literal flag is not evidence of a positive gain collapsing." } }, "ev-fee-a": { "delta": "NP2 + EV fee. Slots/shifts/skew unchanged. fBase replaced per side by mix (1-W)*fBase+W*f*, f*=argmax over grid {2,6,11,16,22,30,50,120}bps of f*share(f)*T - C*0.5*E[max(s*d+z*sigmaHat-f,0)^2]; share per brief with R=1 (reserve-normalised), T=flowSize*TS, 997bps-normalizer r=sqrt((1-f)/.997); 5pt Gauss-Hermite; d=spot/pHat-1 signed per side (bid +d, ask -d), one-sided arb. Tox/act/sigma-tox extras kept. Final (best found, ~null): C=0, W=0.2, TS=1.", "sha256": "6b8fcb6fa7dc3865a874e85cf9a47c05122824f48422b6aacf97e689e40ddcb4", "np2_check": "NP2 rebuilt sha256 51f1c1a9d4999ee460eb8bbc66880da8074b173399a4f5d71f96671482e18ac0; seeds 0..999 mean 526.1155722 (matches 526.1156). CH not separately run.", "tune": { "seeds": "10000..10239 (240 paired seeds, NP2 mean 522.853)", "best_mean_diff": -0.053, "grid": "(C,W,TS)->diff: C=0.01..100,W=1: -112..-133; C=1e-3,W=1:-59.7; 1e-4:-38; 1e-5:-24; C=0,W=1:-3.44; C=1e-7,W=.5:-3.47; C=0,W=.5:-0.75; C=0,W=.2:-0.053(se .034). Not positive anywhere; any C>0 hurts." }, "paired": { "n": 0, "mean_diff": null, "se": null, "worst": null, "note": "Confirm block 2320000+ NOT run: no tuned config beat NP2, and time was short. Delivered code is not shown to improve on NP2." }, "blocked": null, "next": "EV fee as specified does not help: loss term is mis-scaled vs sim (any C>0 hurts sharply); TWO's tox/shift terms already price stale flow. Try EV only to modulate fBase by +-few bps, or fit C via regression of realized arb loss.", "source": { "read_path": ".imd/reads/artifacts/item-ev-fee-a", "original_result_path": "artifacts/goal/batches/ep3-mech/items/ev-fee-a/result.json", "input_sha256": "0fce302fe05d75a6dc43d42afc3ebb9390834a4ed4e4d310327b3c2b6c53b7b3", "json_fields": "Original result fields unless explicitly marked derived or omitted. Gas and volume fields are preserved in rows." }, "code_sha256_checked_by_merge": true, "external_source_warning_count": 0, "tune_confirm_comparison_derived": { "tuning_mean_diff": -0.053, "half_tuning_mean_diff": -0.0265, "confirm_mean_diff": null, "literal_below_half_tuning_flag": null, "positive_tuning_gain": false, "interpretation": "Not assessable: confirmation absent." } }, "next-mix-a": { "delta": "Added only NEXT-TRADE MIX to exact NP2. All existing estimator and fee constants remain unchanged. After TWO's fee compression, k=stepTradeCount-1 uses the first observed print as the existing arb proxy. Compute q=P(Poisson(lambdaHat)>k)/P(Poisson(lambdaHat)>=k); k=0 gives 1-exp(-lambdaHat). Blend the exposed side as q^e*TWO+(1-q^e)*min(10%,abs(ln(spot/pHat))+m*sigmaHat); leave the other side unchanged. Poisson tails use a 24-term positive series; capped log uses five atanh terms; q^e uses square roots and integer powers. Final m=0.625, e=0.125 (MIX_M=625000000000000000, MIX_E_SIXTEENTHS=2). No added state or external dependency.", "sha256": "1e8a7601c5c0622e870e80308f2ab7aa5a58361358e7926f96735c31f6321a5b", "np2_check": { "seeds": "0..999", "n": 1000, "mean": 526.1155722459862, "expected": 526.1156, "tolerance": 5e-05, "pass": true, "sha256": "51f1c1a9d4999ee460eb8bbc66880da8074b173399a4f5d71f96671482e18ac0", "CH": { "seeds": "0..999", "n": 1000, "mean": 525.5258821780834, "expected": 525.525882178, "tolerance": 1e-06, "pass": true } }, "tune": { "seeds": "10000..10399; 11000..11999 (128-seed broad sweep uses 10000..10127)", "best_mean_diff": 0.16325352468175702, "selected": { "tag": "selection2-m0.625-e2", "m": 0.625, "e": 0.125, "e16": 2, "seeds": "11000..11999", "sha256": "1e8a7601c5c0622e870e80308f2ab7aa5a58361358e7926f96735c31f6321a5b", "stats": { "n": 1000, "mean_diff": 0.16325352468175702, "se": 0.015470357318619938, "worst": [ { "seed": 11819, "diff": -4.237044944269883, "candidate_edge": 402.8958725929875, "np2_edge": 407.13291753725736 }, { "seed": 11682, "diff": -2.503183923295694, "candidate_edge": 485.113170737034, "np2_edge": 487.6163546603297 }, { "seed": 11891, "diff": -2.4931272208190194, "candidate_edge": 610.0113360251112, "np2_edge": 612.5044632459302 }, { "seed": 11692, "diff": -2.2409641959126247, "candidate_edge": 553.0126161735953, "np2_edge": 555.253580369508 }, { "seed": 11316, "diff": -2.026694486631243, "candidate_edge": 495.14275462734867, "np2_edge": 497.1694491139799 } ], "candidate_mean": 521.3792616902196, "np2_mean": 521.2160081655378 }, "seconds": 220.86118193692528 }, "selection_rule": "Broad sweep of 20 variants on 10000..10127; 16 neighboring variants on 10000..10399. Finalists: early leader (m=.5,e=.125), positive small-exponent variant (m=.375,e=.0625), and the highest-mean remaining 400-seed variant. Choose the highest mean paired gain among these three on the common independent tuning block 11000..11999. Holdout excluded throughout.", "holdout_seen_before_freeze": false, "trials_omitted_count": 39 }, "paired": { "n": 4000, "mean_diff": 0.16998543167515265, "se": 0.00735759405356205, "worst": [ { "seed": 2331615, "diff": -5.942457080101121, "candidate_edge": 729.2696059862673, "np2_edge": 735.2120630663684 }, { "seed": 2333135, "diff": -4.1636455746398155, "candidate_edge": 407.44937496282165, "np2_edge": 411.61302053746147 }, { "seed": 2330603, "diff": -3.085442827850841, "candidate_edge": 474.69833968380254, "np2_edge": 477.7837825116534 }, { "seed": 2330294, "diff": -2.6696437351916984, "candidate_edge": 472.52214309509566, "np2_edge": 475.19178683028736 }, { "seed": 2331305, "diff": -2.558624668452353, "candidate_edge": 374.7404411424912, "np2_edge": 377.29906581094355 } ], "candidate_mean": 524.8129484806834, "np2_mean": 524.6429630490082, "seeds": "2330000..2333999", "worst_definition": "Five most negative per-seed candidate-minus-NP2 edges.", "confirmation_runs": 1 }, "blocked": null, "next": "Evaluate a separate variant with a retail-only arrival estimate and an explicit uncertainty model for the first observed print; preserve these untouched confirmation results. This mix alone does not establish a leaderboard gain of +5.8 or +9.6.", "methodology": { "simulator_commit": "6b6921f8d463314aa7c96234e1be25a25245f704", "frozen_at_utc": "2026-11-07T18:50:48.238761+00:00", "setup": "Ran the item-specific scratch/setup.sh verbatim once from the simulator checkout under test/scratch; setup and StarterStrategy validation succeeded.", "comparison": "Each strategy independently faces the 30-bps VanillaStrategy. Candidate and NP2 share seeds and market draws. Subtract submission edge per seed; never pit candidate against NP2 in one market.", "configuration": "For every seed s, numpy.random.default_rng(s) draws retail_mean_size U(19,21), retail_arrival_rate U(0.6,1.0), gbm_sigma U(0.000882,0.001008), in that order. cfg.seed=s; Rust price seed=s and retail seed=s+1. n_steps=10000, initial_price=100, initial_x=100, initial_y=10000, gbm_mu=0, gbm_dt=1, retail_size_sigma=1.2, retail_buy_prob=0.5. Configuration builder was checked field-by-field against MatchRunner._build_configs on seeds 0..999.", "execution": "Unmodified pinned simulator; amm_sim_rs.run_batch, 8 workers, chunks of 24. Each confirmation seed evaluated once per strategy. All confirmation seeds were held out from tuning; source hash and constants were frozen before starting confirmation.", "statistics": "Arithmetic mean of per-seed differences; SE = sample standard deviation (ddof=1)/sqrt(n). Metrics are local experimental measurements, not independently certified or a leaderboard submission.", "compiler": "Solidity 0.8.24, optimizer enabled with 200 runs, viaIR=true, evmVersion=paris; official SolidityCompiler and amm-match validate.", "source_map_note": "Zero-based indices into sources.json.", "source_map": { "NP2_inputs": [ 0, 1 ], "CH": [ 2 ], "configuration": [ 3, 4 ], "trade_model": [ 5, 6, 7 ], "fee_constraints": [ 8, 9, 10 ], "compiler": [ 11 ], "hook_error_behavior": [ 12 ] }, "limitations": "TradeInfo has no arb/retail label. A first observed print can be retail when no arb fills, and some retail orders do not reach this pool. The original lambdaHat estimates capped total observed prints per elapsed step and is retained unchanged. Hence the requested Poisson mix is a model based on observed-print proxies, not an oracle of the next trade type." }, "checks": { "validate_passed": true, "validate_stdout": "Validating strategy...\nCompiling strategy...\nStrategy 'NP2_next_mix_a' validated successfully!\n", "identity_control": { "pass": true, "n": 8, "seeds": "10000..10007", "check": "e=0 reproduces NP2 edge, arb volume and retail volume exactly per seed" }, "math": { "poisson": { "cases": 1792, "max_abs_error": "9.5510720758052753906836146884862626363649193700296557263028708364239274554E-18" }, "log": { "cases": 505, "max_abs_error_after_fee_cap": "8.86E-16" }, "weight": { "cases": 1177, "max_abs_error": "4.727302184275615136438441867918164971014620419005429827525167160627980673696E-16" } }, "math_method": "Direct EVM calls to the exact helper implementations versus 90-digit Decimal references. Probability covers k=0..63 and lambda=0..1.82; log covers both directions and clipping; weights cover all tuned dyadic exponents and endpoints.", "simulator_tracked_files_modified": false, "confirmation_code_sha256": "1e8a7601c5c0622e870e80308f2ab7aa5a58361358e7926f96735c31f6321a5b" }, "source": { "read_path": ".imd/reads/artifacts/item-next-mix-a", "original_result_path": "artifacts/goal/batches/ep3-mech/items/next-mix-a/result.json", "input_sha256": "2e6360771b7716c442e48f0832082c895b3d4c88b439b719f4566cc0a11fd9f8", "json_fields": "Original result fields unless explicitly marked derived or omitted. Gas and volume fields are preserved in rows." }, "code_sha256_checked_by_merge": true, "external_source_warning_count": 2, "tune_confirm_comparison_derived": { "tuning_mean_diff": 0.16325352468175702, "half_tuning_mean_diff": 0.08162676234087851, "confirm_mean_diff": 0.16998543167515265, "literal_below_half_tuning_flag": false, "positive_tuning_gain": true, "interpretation": "Positive tuning gain retained." } }, "router-a": { "delta": "NP2 plus one guarded router-undercut override after first print of each step (arb proxy). Recover fair from post-spot and feeUsed; expected normalizer spot=fair. After AMM sells X, target bid=1-(0.997+m)*fair/spot; mirror target ask=1-spot/(fair/0.997-m*fair). Targets floored at zero. Apply only if target+feeUsed>=emin; otherwise retain NP2 favored-side fee. Opposite side is at least feeUsed. Later prints use existing NP2/TWO logic. Final m=1 bps, emin=500 bps. No other baseline constants changed.", "sha256": "4d621ce5ffdc091b139442cfa3cc5c00c7c11dd66e3aa3467796b9799f63af60", "np2_check": { "n": 1000, "seeds": [ 0, 999 ], "expected_rounded": 526.1156, "mean": 526.1155722459862, "pass": true, "sha256": "51f1c1a9d4999ee460eb8bbc66880da8074b173399a4f5d71f96671482e18ac0", "ch": { "n": 1000, "mean": 525.5258821780834, "expected": 525.525882178, "pass": true, "sha256": "6dd68f77a70900319460215374143dbd5d924198450a46d9f5f91f6b1e3d35c3" } }, "tune": { "seeds": [ [ 12000, 12159 ], [ 13000, 13399 ] ], "best_mean_diff": -25.748065425046402, "final_constants_bps": { "m": 1, "emin": 500 }, "selection": "Top three coarse settings re-evaluated on 400 tuning seeds; choose largest refined paired mean, then lower emin and m. Frozen before reserved holdout. Earlier discarded implementations used tuning seeds 10000..10599 and 11000..11399 only; none used confirmation seeds.", "coarse_omitted_count": 15, "refined_omitted_count": 3 }, "paired": { "n": 2000, "mean_diff": -26.726126100689385, "se": 0.3506906569088013, "worst": -166.9545351751368, "seeds": [ 2340000, 2341999 ], "candidate_mean": 500.409850089316, "np2_mean": 527.1359761900054, "worst5": [ { "seed": 2340264, "diff": -166.9545351751368 }, { "seed": 2340438, "diff": -147.45064783215304 }, { "seed": 2341194, "diff": -125.09380437414632 }, { "seed": 2341812, "diff": -123.32947187388856 }, { "seed": 2340008, "diff": -120.76992082829327 } ] }, "blocked": null, "next": "Do not promote: reserved confirmation loses 26.7261 edge per seed vs NP2. First print can be retail; test reliable arb classification before further router tuning. High edge thresholds suppress most overrides.", "methodology": { "simulator_commit": "6b6921f8d463314aa7c96234e1be25a25245f704", "pairing": "Separate candidate-vs-Vanilla and NP2-vs-Vanilla markets for identical seeds; subtract submission edges per seed. amm_sim_rs.run_batch, 8 workers, chunks of 16. Sample SE uses ddof=1. Worst is minimum per-seed difference.", "draws": "numpy.default_rng(s): size U(19,21), rate U(0.6,1), sigma U(0.000882,0.001008), in that order; config.seed=s, Rust price seed=s, retail seed=s+1. 10000 steps; initial price=100, x=100, y=10000, mu=0, dt=1, retail buy probability=.5, size sigma=1.2.", "confirmation": "Exactly one frozen candidate on seeds 2340000..2341999, an unused 2000-seed subset of the specified reserved block; no tuning afterward.", "validate": "amm-match validate scratch/router.sol passed after freeze.", "gas": "Actual pyrevm EVM.result.gas_used from 2000 synthetic swap calls using tuning-domain random seed 12345; both sides, timestamp gaps, varied reserves and sizes. Includes fee bounds, nonfavored fee minimum, and exact guarded target checks. Measured maximum, not proof of a global worst-case bound." }, "notes": [ "No measurements or source values were fabricated; all required evaluation fields are measured locally.", "Fair recovery is exact up to WAD rounding only for a true optimal arb print. There is no actor flag, so first-in-step is a fallible proxy and can classify retail as arb.", "Expected normalizer spot=fair is a modeling assumption (center of its symmetric multiplicative no-arb band), not an observed normalizer price. Fee+feeUsed is the requested bps edge approximation.", "Floor-zero saturation may be unable to beat the expected normalizer price when our post-arb spot is outside its competitive range. If minimum edge conflicts with target, skip the favored-side override; opposite-side minimum still applies.", "Higher emin can make this mechanism effectively inactive. A negative paired result is evidence against promotion, not a claimed improvement.", "Baseline scoring is not evidence of hook success because the pinned simulator can retain fees after a hook failure; gas and formula stress checks are reported separately." ], "source": { "read_path": ".imd/reads/artifacts/item-router-a", "original_result_path": "artifacts/goal/batches/ep3-mech/items/router-a/result.json", "input_sha256": "fcd11d752dbdea7a48dca6a2c7695fa420d2e518ef73c4dc3e591a867b25a6c7", "json_fields": "Original result fields unless explicitly marked derived or omitted. Gas and volume fields are preserved in rows." }, "code_sha256_checked_by_merge": true, "external_source_warning_count": 1, "tune_confirm_comparison_derived": { "tuning_mean_diff": -25.748065425046402, "half_tuning_mean_diff": -12.874032712523201, "confirm_mean_diff": -26.726126100689385, "literal_below_half_tuning_flag": true, "positive_tuning_gain": false, "interpretation": "Both tuning and confirmation are negative; literal flag is not evidence of a positive gain collapsing." } } } } ```