{
  "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 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[3] = WAD; \n        slots[5] = initialX > 0 ? wdiv(initialY, initialX) : 100 * WAD;\n        slots[6] = 950000000000000; slots[7] = 800000000000000000; slots[8] = 2000000000000000;\n        slots[13] = 902500000000; slots[14] = slots[5]; \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        uint256 sigmaForFast = sigmaHat;\n        uint256 fastHat = slots[14];\n        uint256 uncertainty = slots[13];\n        uint256 silent = trade.timestamp > lastTs ? trade.timestamp - lastTs : 0;\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            uncertainty += wmul(sigmaForFast, sigmaForFast) * elapsedRaw;\n            if (uncertainty > 100000000000000) uncertainty = 100000000000000;\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        // S: infer a no-trade interval center from the last post-trade spot.\n        uint256 silenceScale = WAD;\n        if (firstInStep && silent > 1) {\n            uint256 g = silent - 1;\n            if (g > 1) g = 1;\n            uint256 w = WAD - _powWad(800000000000000000, g);\n            uint256 s = slots[16];\n            if (s == 0) s = pHat;\n            uint256 c = (wmul(s, WAD - prevBidFee) + wdiv(s, WAD - prevAskFee)) / 2;\n            if (c >= pHat) pHat += wmul(w, c - pHat);\n            else pHat -= wmul(w, pHat - c);\n            silenceScale = WAD - wmul(300000000000000000, w);\n        }\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            alpha = wmul(alpha, silenceScale);\n            adaptiveGate = wmul(adaptiveGate, silenceScale);\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        {\n            uint256 ret = fastHat > 0 ? wdiv(absDiff(pImplied, fastHat), fastHat) : 0;\n            uint256 alpha;\n            if (firstInStep) {\n                uint256 processSigma = sigmaForFast;\n                uint256 obsVar = uncertainty + wmul(processSigma, processSigma);\n                uint256 probArb;\n                uint256 z2 = wdiv(wmul(ret, ret), obsVar);\n                uint256 density = _powWad(wdiv(WAD, WAD + z2 / 16), 8);\n                uint256 sigmaObs = sqrt(obsVar * WAD);\n                uint256 odds = wmul(density, wdiv(6700000000000000, sigmaObs));\n                bool arbFlag = ret <= wmul(sigmaForFast, 1220000000000000000);\n                uint256 prior = arbFlag ? 650000000000000000 : 400000000000000000;\n                uint256 tr = trade.reserveY > 0 ? wdiv(trade.amountY, trade.reserveY) : 0;\n                if (tr > 3000000000000000) prior = wmul(prior, 6 * WAD / 10);\n                if (silent > 1) prior = wmul(prior, 8 * WAD / 10);\n                odds = wmul(odds, wdiv(prior, WAD - prior));\n                probArb = wdiv(odds, WAD + odds);\n                alpha = wmul(probArb, 600000000000000000) + wmul(WAD - probArb, 80000000000000000);\n                slots[15] = pImplied >= fastHat ? 1 : 2;\n                uncertainty = wmul(uncertainty, WAD - alpha);\n            } else {\n                if ((slots[15] == 1) == (pImplied >= fastHat)) alpha = PHAT_ALPHA_RETAIL;\n            }\n            uint256 gate = wmul(sigmaHat, GATE_SIGMA_MULT);\n            if (gate < MIN_GATE) gate = MIN_GATE;\n            if (ret <= gate) fastHat = wmul(fastHat, WAD - alpha) + wmul(pImplied, alpha);\n            slots[13] = uncertainty;\n        }\n\n        if (!firstInStep && feeUsed > 30 * BPS && gamma > 0) {\n            uint256 normalObs = trade.isBuy\n                ? wdiv(wmul(spot, gamma), WAD - 30 * BPS)\n                : wdiv(wmul(spot, WAD - 30 * BPS), gamma);\n            if ((slots[15] == 1) == (normalObs >= fastHat)) {\n                fastHat = wmul(fastHat, 9 * WAD / 10) + wmul(normalObs, WAD / 10);\n            }\n        }\n        slots[14] = fastHat;\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 staleHat = wmul(pHat, 700000000000000000) + wmul(fastHat, 300000000000000000);\n            uint256 staleTox = wdiv(absDiff(spot, staleHat), staleHat);\n            if (staleTox > TOX_CAP) staleTox = TOX_CAP;\n            uint256 staleShift = wmul(STALE_DIR_COEF, staleTox);\n            uint256 attractShift = wmul(staleShift, STALE_ATTRACT_FRAC);\n            if (spot >= staleHat) {\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        {\n            uint256 k = stepTradeCount;\n            uint256 term = WAD;\n            uint256 series = WAD;\n            for (uint256 j = 1; j <= 8; ++j) {\n                term = wmul(term, lambdaHat) / (k + j);\n                series += term;\n            }\n            uint256 ratio = wmul(lambdaHat / k, series);\n            uint256 probability = wdiv(ratio, WAD + ratio);\n            uint256 weight = probability * 1 / 2;\n            uint256 retailFee = 34 * BPS;\n            if (bidFee > retailFee) bidFee -= wmul(weight, bidFee - retailFee);\n            if (askFee > retailFee) askFee -= wmul(weight, askFee - retailFee);\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[16] = spot;\n        slots[9] = toxEma; slots[10] = stepTradeCount;\n\n        return (bidFee, askFee);\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 \"no_cubic\"; }\n}\n",
  "sha256": "86770c6fc51c9ab95c52bf028dfb69fa6c5d26bb5bad0a4f4e95d455bfd50692",
  "design": {
    "variant": "r34_s1of2",
    "retail_bps": 34,
    "scale": 0.5,
    "rule": "After V2 final fee clamps, lower each fee above R toward R with weight s * P(N >= k | N >= k-1), N ~ Poisson(lambdaHat), k = stepTradeCount after current print. First print is treated as the possible initial arbitrage print; subsequent prints are retail. No fee is raised. Remove only afterInitialize zero writes besides this insertion.",
    "probability": "Let S_k = 1 + sum(j=1..8) lambdaHat^j/((k+1)...(k+j)), a=lambdaHat*S_k/k. Use P=a/(1+a). Positive-tail series avoids cancellation. Fixed-point WAD arithmetic.",
    "limitations": [
      "First-print arbitrage is a modeling assumption; the first print may instead be retail.",
      "V2 lambdaHat estimates total observed prints, not a separately estimated retail-only Poisson rate.",
      "Tail-series truncation is an approximation.",
      "Local results do not establish a leaderboard score."
    ],
    "followup": "No attracting-side or R +/-2 follow-up: none of the 12 screen variants gained.",
    "decision": "Reject this two-sided position-in-step blend; retain V2."
  },
  "tuning": [
    {
      "variant": "r28_s1of1",
      "phase": "screen",
      "n": 256,
      "mean_diff": -69.50744536715253,
      "se": 1.4557215998280488,
      "valid": true,
      "sha256": "d15a84fc59619d97e6327c9cdd84de2409e84c6c2a948e281fcb7bb7e1bf564f",
      "gas": {
        "max_ok": 246164,
        "oog": 1,
        "reverts": 0,
        "other_halts": 0,
        "init_max": 220923,
        "swap_calls": 3058080,
        "init_calls": 256
      }
    },
    {
      "variant": "r28_s1of2",
      "phase": "screen",
      "n": 256,
      "mean_diff": -20.49277381982317,
      "se": 0.621713193432425,
      "valid": true,
      "sha256": "0385d0875ff6798fd1955bf629407208f1f6161f7a3e63b81360404c68d2695c",
      "gas": {
        "max_ok": 246164,
        "oog": 1,
        "reverts": 0,
        "other_halts": 0,
        "init_max": 220923,
        "swap_calls": 2962834,
        "init_calls": 256
      }
    },
    {
      "variant": "r28_s3of4",
      "phase": "screen",
      "n": 256,
      "mean_diff": -42.06318465775962,
      "se": 1.0286024543965007,
      "valid": true,
      "sha256": "704818d0c33cfd2faaf5c537a8ab79013d73d2300a776fa47f3442cc277f78d8",
      "gas": {
        "max_ok": 246194,
        "oog": 1,
        "reverts": 0,
        "other_halts": 0,
        "init_max": 220923,
        "swap_calls": 3025840,
        "init_calls": 256
      }
    },
    {
      "variant": "r30_s1of1",
      "phase": "screen",
      "n": 256,
      "mean_diff": -66.9370079781659,
      "se": 1.436862612942387,
      "valid": true,
      "sha256": "c0f7c33043aa47679360b543772810a2421244d27a18d425fc1932baabd25c31",
      "gas": {
        "max_ok": 246164,
        "oog": 1,
        "reverts": 0,
        "other_halts": 0,
        "init_max": 220923,
        "swap_calls": 3029115,
        "init_calls": 256
      }
    },
    {
      "variant": "r30_s1of2",
      "phase": "screen",
      "n": 256,
      "mean_diff": -19.726217175912232,
      "se": 0.6172192292206449,
      "valid": true,
      "sha256": "f789fd5531e5e385e62595baea3ece9ac2a1c31c0ecfbc99885d77e996a54918",
      "gas": {
        "max_ok": 246164,
        "oog": 1,
        "reverts": 0,
        "other_halts": 0,
        "init_max": 220923,
        "swap_calls": 2944839,
        "init_calls": 256
      }
    },
    {
      "variant": "r30_s3of4",
      "phase": "screen",
      "n": 256,
      "mean_diff": -40.42441062288236,
      "se": 1.0154855588907648,
      "valid": true,
      "sha256": "087fd4a38b35aa0ca8164d7f95affbe74441768d2f075d2d68081e4a0650d443",
      "gas": {
        "max_ok": 246194,
        "oog": 1,
        "reverts": 0,
        "other_halts": 0,
        "init_max": 220923,
        "swap_calls": 3002041,
        "init_calls": 256
      }
    },
    {
      "variant": "r32_s1of1",
      "phase": "screen",
      "n": 256,
      "mean_diff": -64.41825024961969,
      "se": 1.4120137418381518,
      "valid": true,
      "sha256": "6893a87aa51dd2e1d384dd7f1eec376611b26b490b2253d6afcc73eb08a8dc6f",
      "gas": {
        "max_ok": 246164,
        "oog": 1,
        "reverts": 0,
        "other_halts": 0,
        "init_max": 220923,
        "swap_calls": 3002214,
        "init_calls": 256
      }
    },
    {
      "variant": "r32_s1of2",
      "phase": "screen",
      "n": 256,
      "mean_diff": -18.952464459384824,
      "se": 0.6092677590676342,
      "valid": true,
      "sha256": "a4eff22686d6956cb306eca9b45b4a14181aa345619af63db919906a0b99d4ec",
      "gas": {
        "max_ok": 246164,
        "oog": 1,
        "reverts": 0,
        "other_halts": 0,
        "init_max": 220923,
        "swap_calls": 2927095,
        "init_calls": 256
      }
    },
    {
      "variant": "r32_s3of4",
      "phase": "screen",
      "n": 256,
      "mean_diff": -38.855824582790476,
      "se": 1.0035243374248346,
      "valid": true,
      "sha256": "91b3810388ffe04c3d6186c2906e7d8087dcde66da83f72576c19b735c8e32f1",
      "gas": {
        "max_ok": 246194,
        "oog": 1,
        "reverts": 0,
        "other_halts": 0,
        "init_max": 220923,
        "swap_calls": 2979857,
        "init_calls": 256
      }
    },
    {
      "variant": "r34_s1of1",
      "phase": "screen",
      "n": 256,
      "mean_diff": -62.20103015295323,
      "se": 1.4482531064537127,
      "valid": true,
      "sha256": "408b84c4d8911aa31c68072c438497d573dc81c28e17b58ef506974e7fe24066",
      "gas": {
        "max_ok": 246164,
        "oog": 1,
        "reverts": 0,
        "other_halts": 0,
        "init_max": 220923,
        "swap_calls": 2977704,
        "init_calls": 256
      }
    },
    {
      "variant": "r34_s1of2",
      "phase": "screen",
      "n": 256,
      "mean_diff": -18.286859852503603,
      "se": 0.6053902374119718,
      "valid": true,
      "sha256": "86770c6fc51c9ab95c52bf028dfb69fa6c5d26bb5bad0a4f4e95d455bfd50692",
      "gas": {
        "max_ok": 246164,
        "oog": 1,
        "reverts": 0,
        "other_halts": 0,
        "init_max": 220923,
        "swap_calls": 2910081,
        "init_calls": 256
      }
    },
    {
      "variant": "r34_s3of4",
      "phase": "screen",
      "n": 256,
      "mean_diff": -37.37997332256675,
      "se": 0.990668139325771,
      "valid": true,
      "sha256": "d25fe9233dd65bff62e448f7a318da0a93db9d9a06d8eba5403f882ed08fbe5c",
      "gas": {
        "max_ok": 246194,
        "oog": 1,
        "reverts": 0,
        "other_halts": 0,
        "init_max": 220923,
        "swap_calls": 2958530,
        "init_calls": 256
      }
    },
    {
      "variant": "r34_s1of2",
      "phase": "select",
      "n": 512,
      "mean_diff": -18.754554133314944,
      "se": 0.35227931489307385,
      "valid": true,
      "sha256": "86770c6fc51c9ab95c52bf028dfb69fa6c5d26bb5bad0a4f4e95d455bfd50692",
      "gas": {
        "max_ok": 247093,
        "oog": 8,
        "reverts": 0,
        "other_halts": 0,
        "init_max": 220923,
        "swap_calls": 5867948,
        "init_calls": 512
      }
    },
    {
      "variant": "r32_s1of2",
      "phase": "select",
      "n": 512,
      "mean_diff": -19.449453632916775,
      "se": 0.355728087445057,
      "valid": true,
      "sha256": "a4eff22686d6956cb306eca9b45b4a14181aa345619af63db919906a0b99d4ec",
      "gas": {
        "max_ok": 247093,
        "oog": 8,
        "reverts": 0,
        "other_halts": 0,
        "init_max": 220923,
        "swap_calls": 5902120,
        "init_calls": 512
      }
    }
  ],
  "paired": {
    "n": 2000,
    "mean_diff": -18.201638989072645,
    "se": 0.17822042179423234,
    "worst": [
      {
        "seed": 4251092,
        "diff": -65.45141099657883,
        "edge": 515.9679102749013,
        "v2_edge": 581.4193212714802
      },
      {
        "seed": 4251740,
        "diff": -64.00075569075034,
        "edge": 478.99938835557214,
        "v2_edge": 543.0001440463225
      },
      {
        "seed": 4250889,
        "diff": -62.448701004651525,
        "edge": 616.5737467768815,
        "v2_edge": 679.0224477815331
      },
      {
        "seed": 4251330,
        "diff": -61.90868917646003,
        "edge": 667.4085091072437,
        "v2_edge": 729.3171982837038
      },
      {
        "seed": 4251322,
        "diff": -59.96710416046358,
        "edge": 652.3264591778884,
        "v2_edge": 712.293563338352
      }
    ]
  },
  "gas": {
    "max_ok": 247489,
    "oog": 27,
    "reverts": 0,
    "other_halts": 0,
    "init_max": 220923,
    "swap_calls": 22832013,
    "init_calls": 2000
  },
  "v2_gas": {
    "max_ok": 244125,
    "oog": 27,
    "reverts": 0,
    "other_halts": 0,
    "init_max": 236377,
    "swap_calls": 20653396,
    "init_calls": 2000
  },
  "valid": true,
  "seeds": {
    "screen": {
      "start": 70000,
      "end_inclusive": 70255,
      "n": 256
    },
    "select": {
      "start": 72000,
      "end_inclusive": 72511,
      "n": 512
    },
    "holdout": {
      "start": 4250000,
      "end_inclusive": 4251999,
      "n": 2000,
      "runs_per_strategy": 1
    }
  },
  "freeze": {
    "variant": "r34_s1of2",
    "sha256": "86770c6fc51c9ab95c52bf028dfb69fa6c5d26bb5bad0a4f4e95d455bfd50692",
    "utc": "2026-11-08T04:31:59Z",
    "before_holdout": true
  },
  "methodology": {
    "checkout": "6b6921f8d463314aa7c96234e1be25a25245f704",
    "v2_sha256": "28417e116f57f1029fdd1803832e852574902c1ae7253c05657f317db76da4ab",
    "simulation": "Each strategy separately vs VanillaStrategy via amm_sim_rs.run_batch(bytecode, vanilla, configs, 8); 10000 steps, 250000 callback gas.",
    "configs": "Exact MatchRunner._build_configs draws, generated only for requested seed range: default_rng(seed) size, rate, sigma; engine price seed=seed and retail seed=seed+1.",
    "paired": "Per-seed candidate submission edge minus V2 submission edge; se=sample standard deviation / sqrt(n); worst=lowest five paired differences.",
    "validity": "OOG does not abort or remove seeds; valid iff complete paired measurements, candidate OOG <= V2 OOG, and neither has reverts or other halts.",
    "baseline_reuse": "One separate V2 baseline batch per phase reused for paired comparisons within that phase.",
    "gas_scope": "Submission callbacks only; max_ok is successful afterSwap gas, init_max is successful afterInitialize gas; error counts include all submission callbacks.",
    "evidence": "Numerical results are local simulator measurements, not external claims. External source URLs are in sources.json."
  },
  "phase_v2_gas": {
    "screen": {
      "max_ok": 242800,
      "oog": 1,
      "reverts": 0,
      "other_halts": 0,
      "init_max": 236377,
      "swap_calls": 2633056,
      "init_calls": 256
    },
    "select": {
      "max_ok": 243713,
      "oog": 8,
      "reverts": 0,
      "other_halts": 0,
      "init_max": 236377,
      "swap_calls": 5307763,
      "init_calls": 512
    }
  },
  "checks": {
    "setup": "passed; setup.sh run once with requested cargo fallback",
    "instrumentation": "supplied instrumentation.patch applied and extension rebuilt successfully",
    "source_scope": "all 12 variants equal exact V2 except final fee insertion and removal of afterInitialize zero writes",
    "poisson_numeric": "Compared 8-term vs 100-term floating-point tail series for lambda in {0.1,0.8,1.2,1.82}, k=1..64; maximum absolute probability difference 3.4462256083278575e-06",
    "holdout_source_hash": "frozen source sha256 verified"
  },
  "blocked": {
    "step": null,
    "error": null
  }
}
