{
 "item": "s2",
 "batch": "e07-hyb-floor",
 "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 NE_CAP = 35 * BPS;\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 = uint64(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[2] >> 64;\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[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 = _isqrt(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        // Hybrid: keep V2's exposed (higher) side; cap the other side at NE_CAP.\n        if (bidFee > askFee) { if (askFee > NE_CAP) askFee = NE_CAP; }\n        else if (askFee > bidFee) { if (bidFee > NE_CAP) bidFee = NE_CAP; }\n\n        slots[0] = bidFee; slots[1] = askFee; slots[2] = (spot << 64) | 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    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    // Floor square root: bit-length seed and seven Newton steps (all uint256).\n    function _isqrt(uint256 x) internal pure returns (uint256 r) {\n        if (x == 0) return 0;\n        unchecked {\n            uint256 y = x;\n            r = 1;\n            if (y >> 128 != 0) { y >>= 128; r <<= 64; }\n            if (y >> 64 != 0) { y >>= 64; r <<= 32; }\n            if (y >> 32 != 0) { y >>= 32; r <<= 16; }\n            if (y >> 16 != 0) { y >>= 16; r <<= 8; }\n            if (y >> 8 != 0) { y >>= 8; r <<= 4; }\n            if (y >> 4 != 0) { y >>= 4; r <<= 2; }\n            if (y >> 2 != 0) { r <<= 1; }\n            r = (r + x / r) >> 1;\n            r = (r + x / r) >> 1;\n            r = (r + x / r) >> 1;\n            r = (r + x / r) >> 1;\n            r = (r + x / r) >> 1;\n            r = (r + x / r) >> 1;\n            r = (r + x / r) >> 1;\n            uint256 t = x / r;\n            return r < t ? r : t;\n        }\n    }\n\n    function getName() external pure override returns (string memory) { return \"no_cubic\"; }\n}\n",
 "sha256": "07dd9817d003b39dbed871af065d8c77bc5f8a165e14ad8c12a693409022ddad",
 "frozen_variant": "C29",
 "base_sha256": "610c1905e7dd5559b84e40a3b2d6f8e0b53a7b0ac7574ae33b6c1770a28367cb",
 "base": "G (reconstructed from code_GN per brief; sha256 matched 610c1905...)",
 "v2_sha256": "28417e116f57f1029fdd1803832e852574902c1ae7253c05657f317db76da4ab",
 "variants": [
  {
   "id": "A26",
   "params": {
    "family": "non-exposed = max(no-stale-shift fee, F0), always",
    "F0_bps": 26
   },
   "seeds": [
    80000,
    80255
   ],
   "n": 256,
   "mean_diff": -23.8927,
   "se": 0.3189,
   "oog": 0,
   "v2_oog": 3,
   "max_ok_gas": 220962,
   "sha256": "b3af46f34a48ac8a5b3016cc7134e577aa1a12e0889524ac07ed8e1e15b81523"
  },
  {
   "id": "B29",
   "params": {
    "family": "non-exposed = max(no-stale-shift fee, F0) only while silent>1 or staleShift>0, else V2",
    "F0_bps": 29
   },
   "seeds": [
    80000,
    80063
   ],
   "n": 64,
   "mean_diff": -25.8288,
   "se": 0.6404,
   "oog": 0,
   "v2_oog": 3,
   "max_ok_gas": 220969,
   "sha256": "698244ef3a01204d3705b6b8beed66d1fb25139ec2d5865608cd7151ef95c4d3"
  },
  {
   "id": "A32",
   "params": {
    "family": "non-exposed = max(no-stale-shift fee, F0), always",
    "F0_bps": 32
   },
   "seeds": [
    80000,
    80063
   ],
   "n": 64,
   "mean_diff": -27.5648,
   "se": 0.6364,
   "oog": 0,
   "v2_oog": 3,
   "max_ok_gas": 220962,
   "sha256": "b34f5be4f8471a89867e4b93e0d69d569dd0149a634859ff1b213efa1c751832"
  },
  {
   "id": "C29",
   "params": {
    "family": "keep V2 stale shift, cap non-exposed at F0+6bps",
    "F0_bps": 29
   },
   "seeds": [
    80000,
    80063
   ],
   "n": 64,
   "mean_diff": 0.0142,
   "se": 0.0123,
   "oog": 0,
   "v2_oog": 3,
   "max_ok_gas": 220944,
   "sha256": "07dd9817d003b39dbed871af065d8c77bc5f8a165e14ad8c12a693409022ddad"
  },
  {
   "id": "A29",
   "params": {
    "family": "non-exposed = max(no-stale-shift fee, F0), always",
    "F0_bps": 29
   },
   "n": 0,
   "mean_diff": null,
   "se": null,
   "oog": null,
   "v2_oog": null,
   "note": "generated and passed amm-match validate; not simulated (machine throughput ~1.5 sims/s left no time before holdout)",
   "sha256": "4ef124b2204e61985c9df45e20e1e53315289a6663f791c589e6b1a35a216e96"
  },
  {
   "id": "A35",
   "params": {
    "family": "non-exposed = max(no-stale-shift fee, F0), always",
    "F0_bps": 35
   },
   "n": 0,
   "mean_diff": null,
   "se": null,
   "oog": null,
   "v2_oog": null,
   "note": "generated and passed amm-match validate; not simulated (machine throughput ~1.5 sims/s left no time before holdout)",
   "sha256": "9602bbbf5d5d3b93f8effde4ae62f2fa2fd21019d573cdb7f9951ca9f6f7b71c"
  },
  {
   "id": "B26",
   "params": {
    "family": "non-exposed = max(no-stale-shift fee, F0) only while silent>1 or staleShift>0, else V2",
    "F0_bps": 26
   },
   "n": 0,
   "mean_diff": null,
   "se": null,
   "oog": null,
   "v2_oog": null,
   "note": "generated and passed amm-match validate; not simulated (machine throughput ~1.5 sims/s left no time before holdout)",
   "sha256": "23696b9575c05042cc4b842f479ecc05f5eb3b163574785ad1b6ccd456de8a3a"
  },
  {
   "id": "B32",
   "params": {
    "family": "non-exposed = max(no-stale-shift fee, F0) only while silent>1 or staleShift>0, else V2",
    "F0_bps": 32
   },
   "n": 0,
   "mean_diff": null,
   "se": null,
   "oog": null,
   "v2_oog": null,
   "note": "generated and passed amm-match validate; not simulated (machine throughput ~1.5 sims/s left no time before holdout)",
   "sha256": "d88d361aecd251bdecf6893b7fc6d0ec8fe0097347f968fd89a0d346b9c56ea6"
  },
  {
   "id": "B35",
   "params": {
    "family": "non-exposed = max(no-stale-shift fee, F0) only while silent>1 or staleShift>0, else V2",
    "F0_bps": 35
   },
   "n": 0,
   "mean_diff": null,
   "se": null,
   "oog": null,
   "v2_oog": null,
   "note": "generated and passed amm-match validate; not simulated (machine throughput ~1.5 sims/s left no time before holdout)",
   "sha256": "3615665bbe65ec267620bdb185a097f665518c71d107ba45ea80636cfe48c6be"
  },
  {
   "id": "C32",
   "params": {
    "family": "keep V2 stale shift, cap non-exposed at F0+6bps",
    "F0_bps": 32
   },
   "n": 0,
   "mean_diff": null,
   "se": null,
   "oog": null,
   "v2_oog": null,
   "note": "generated and passed amm-match validate; not simulated (machine throughput ~1.5 sims/s left no time before holdout)",
   "sha256": "454be57994f35faaeb6d23f830b612e0e6f6b22e940a418a8dbc4044f7b0ad76"
  }
 ],
 "paired": {
  "n": 2000,
  "mean_diff": 0.0141,
  "se": 0.0024,
  "worst": [
   {
    "seed": 4360639,
    "diff": -1.0366,
    "cand": 524.4312,
    "v2": 525.4679
   },
   {
    "seed": 4360180,
    "diff": -0.6075,
    "cand": 617.6332,
    "v2": 618.2407
   },
   {
    "seed": 4361972,
    "diff": -0.5858,
    "cand": 509.7454,
    "v2": 510.3311
   },
   {
    "seed": 4361865,
    "diff": -0.4724,
    "cand": 732.7792,
    "v2": 733.2516
   },
   {
    "seed": 4361314,
    "diff": -0.424,
    "cand": 489.5594,
    "v2": 489.9834
   }
  ]
 },
 "split": {
  "cand": {
   "retail": 553.704,
   "arb": -28.1716,
   "total": 525.5323
  },
  "v2": {
   "retail": 553.6846,
   "arb": -28.1665,
   "total": 525.5182
  },
  "terciles": [
   {
    "tercile": 1,
    "v2_retail_volume_range": [
     54402.6,
     70579.7
    ],
    "n": 666,
    "mean_diff": 0.0122,
    "se": 0.0025
   },
   {
    "tercile": 2,
    "v2_retail_volume_range": [
     70593.4,
     81210.8
    ],
    "n": 666,
    "mean_diff": 0.0102,
    "se": 0.004
   },
   {
    "tercile": 3,
    "v2_retail_volume_range": [
     81233.5,
     97608.8
    ],
    "n": 668,
    "mean_diff": 0.02,
    "se": 0.0056
   }
  ],
  "tercile_basis": "per-seed V2 retail_volume_y (sum of routed retail trade.amount_y for V2), sorted ascending"
 },
 "gas": {
  "max_ok": 211248,
  "oog": 0,
  "reverts": 0,
  "other_halts": 0,
  "tx_error": 0,
  "bad_return": 0,
  "init_max": 220944,
  "swap_calls": 20652072,
  "complete": true,
  "vanilla_failures": 0,
  "oog_seeds": []
 },
 "v2_gas": {
  "max_ok": 243722,
  "oog": 20,
  "reverts": 0,
  "other_halts": 0,
  "tx_error": 0,
  "bad_return": 0,
  "init_max": 236377,
  "swap_calls": 20644803,
  "complete": true,
  "vanilla_failures": 0,
  "oog_seeds": [
   [
    4360456,
    4
   ],
   [
    4360781,
    1
   ],
   [
    4360973,
    2
   ],
   [
    4361182,
    2
   ],
   [
    4361348,
    1
   ],
   [
    4361437,
    1
   ],
   [
    4361507,
    2
   ],
   [
    4361728,
    1
   ],
   [
    4361771,
    2
   ],
   [
    4361817,
    2
   ],
   [
    4361828,
    2
   ]
  ]
 },
 "seeds": {
  "screen": "80000..80255 (A26) and 80000..80063 (B29,A32,C29); paired vs V2 on same seeds",
  "second_stage": "not run (82000..82511 skipped for time)",
  "holdout": [
   4360000,
   4361999
  ]
 },
 "valid": true,
 "blocked": null,
 "notes": [
  "Hybrid families: A = non-exposed side recomputed without the STALE_DIR_COEF/STALE_ATTRACT_FRAC shift (trade boost and tail compression kept) and floored at F0; B = same but only while silent>1 or staleShift>0, else V2 value; C = keep V2 non-exposed value, cap at F0+6 bps. Exposed = side with higher final V2 fee; equal fees unchanged. The silence logic is an estimator update of pHat shared by both sides, so it was kept and used only as the activity condition in B.",
  "Screen was shortened by machine throughput (~1.3-3 sims/s): A26 on 256 seeds, B29/A32/C29 on 64 seeds (80000..80063), V2 rows from the same seeds; 6 variants validated but not simulated; the 512-seed second stage (82000..82511) was not run. C29 was frozen (sha256 recorded before the holdout) as the only non-losing family; all floor variants lost ~24-28 per seed.",
  "Holdout 4360000..4361999 was run once in 4 chunks (each chunk: candidate then V2, each run_batch(X, Vanilla, cfgs, 8), chunk size 64). A first holdout attempt launched in background processes was killed by the sandbox before producing any output; no results were seen from it.",
  "Engine instrumented with scratch/instrumentation.patch from the V2 control artifact; retail_volume_y is the engine native per-AMM sum of routed retail trade.amount_y."
 ]
}