{
 "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 = 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        // After the first print, cap only the lower of the final V2 quotes.\n        if (firstInStep) {\n            if (bidFee < askFee && bidFee > 30 * BPS) bidFee = 30 * BPS;\n            else if (askFee < bidFee && askFee > 30 * BPS) askFee = 30 * BPS;\n        }\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": "e98d8a0ff00f19785d801b00220eba9864fb3e44cbc1d591745c1d976f7df941",
 "base_sha256": "610c1905e7dd5559b84e40a3b2d6f8e0b53a7b0ac7574ae33b6c1770a28367cb",
 "variants": [
  {
   "id": "cap30",
   "stage": "screen",
   "params": {
    "kind": "cap",
    "first_cap_bps": 30,
    "second_print": false,
    "sha256": "e98d8a0ff00f19785d801b00220eba9864fb3e44cbc1d591745c1d976f7df941"
   },
   "n": 256,
   "mean_diff": 0.029018252824711377,
   "se": 0.008197850436636445,
   "oog": 0,
   "v2_oog": 3,
   "valid": true,
   "invalid_reasons": []
  },
  {
   "id": "cap32",
   "stage": "screen",
   "params": {
    "kind": "cap",
    "first_cap_bps": 32,
    "second_print": false,
    "sha256": "42ea25eff63c54bfdc63b18a1c2b736998691bb2787d08d3cea10628ac0a56b1"
   },
   "n": 256,
   "mean_diff": 0.011492935751284294,
   "se": 0.0056113451792400605,
   "oog": 0,
   "v2_oog": 3,
   "valid": true,
   "invalid_reasons": []
  },
  {
   "id": "cap34",
   "stage": "screen",
   "params": {
    "kind": "cap",
    "first_cap_bps": 34,
    "second_print": false,
    "sha256": "530e134e5846564e2570de927af6cc98b9202ee4fe1e2432ddaeaa6057d243cb"
   },
   "n": 256,
   "mean_diff": 0.009441198141797447,
   "se": 0.004503461776534016,
   "oog": 0,
   "v2_oog": 3,
   "valid": true,
   "invalid_reasons": []
  },
  {
   "id": "cap36",
   "stage": "screen",
   "params": {
    "kind": "cap",
    "first_cap_bps": 36,
    "second_print": false,
    "sha256": "82b6be1e372d86ca31c6a1026f4d3cd1e7d809042172cca2e67e1e0716229e7f"
   },
   "n": 256,
   "mean_diff": 0.008369690433386534,
   "se": 0.0039730226531709285,
   "oog": 0,
   "v2_oog": 3,
   "valid": true,
   "invalid_reasons": []
  },
  {
   "id": "cut2",
   "stage": "screen",
   "params": {
    "kind": "cut",
    "first_cut_bps": 2,
    "floor_bps": 20,
    "second_print": false,
    "never_raise": true,
    "sha256": "529df80063082f8dabc9b4453619a02df3cd03d5a28d8862a04097b16e6702ec"
   },
   "n": 256,
   "mean_diff": -0.0015607494044331816,
   "se": 0.012258270799134281,
   "oog": 0,
   "v2_oog": 3,
   "valid": true,
   "invalid_reasons": []
  },
  {
   "id": "cut4",
   "stage": "screen",
   "params": {
    "kind": "cut",
    "first_cut_bps": 4,
    "floor_bps": 20,
    "second_print": false,
    "never_raise": true,
    "sha256": "0ab15790595cbf7ace4a16a6e9886f4696fe90ae9f32c8b493481ef05d4bbded"
   },
   "n": 256,
   "mean_diff": -0.05738003986405049,
   "se": 0.015465200687473596,
   "oog": 0,
   "v2_oog": 3,
   "valid": true,
   "invalid_reasons": []
  },
  {
   "id": "cut4_second2",
   "stage": "screen",
   "params": {
    "kind": "cut",
    "first_cut_bps": 4,
    "second_cut_bps": 2,
    "floor_bps": 20,
    "second_print": true,
    "never_raise": true,
    "sha256": "6bba215fc1c06f46f5d537f8ea801d5bba9c9701f86d6a88d7c9a28b6929ee40"
   },
   "n": 256,
   "mean_diff": -0.07585579938938913,
   "se": 0.01685942576121411,
   "oog": 0,
   "v2_oog": 3,
   "valid": true,
   "invalid_reasons": []
  },
  {
   "id": "cap30",
   "stage": "selection",
   "params": {
    "kind": "cap",
    "first_cap_bps": 30,
    "second_print": false,
    "sha256": "e98d8a0ff00f19785d801b00220eba9864fb3e44cbc1d591745c1d976f7df941"
   },
   "n": 512,
   "mean_diff": 0.017645233273910543,
   "se": 0.006187911124991828,
   "oog": 0,
   "v2_oog": 8,
   "valid": true,
   "invalid_reasons": []
  },
  {
   "id": "cap32",
   "stage": "selection",
   "params": {
    "kind": "cap",
    "first_cap_bps": 32,
    "second_print": false,
    "sha256": "42ea25eff63c54bfdc63b18a1c2b736998691bb2787d08d3cea10628ac0a56b1"
   },
   "n": 512,
   "mean_diff": 0.010804080761265489,
   "se": 0.004321781688027867,
   "oog": 0,
   "v2_oog": 8,
   "valid": true,
   "invalid_reasons": []
  }
 ],
 "paired": {
  "label": "candidate_minus_V2",
  "n": 2000,
  "mean_diff": 0.014869864900261064,
  "se": 0.0031976705708119486,
  "sd": 0.14300417531972145,
  "n_nonzero": 2000,
  "max_abs_diff": 2.2347890698141555,
  "worst": [
   {
    "seed": 4311810,
    "diff": -2.2347890698141555,
    "edge_a": 673.8160357819206,
    "edge_b": 676.0508248517348
   },
   {
    "seed": 4310610,
    "diff": -0.9207298039505076,
    "edge_a": 572.1818354596641,
    "edge_b": 573.1025652636146
   },
   {
    "seed": 4311919,
    "diff": -0.8910825118451839,
    "edge_a": 633.642428143315,
    "edge_b": 634.5335106551602
   },
   {
    "seed": 4310440,
    "diff": -0.7798964679591336,
    "edge_a": 553.3510980698128,
    "edge_b": 554.1309945377719
   },
   {
    "seed": 4311052,
    "diff": -0.7795245074568129,
    "edge_a": 811.9736561136199,
    "edge_b": 812.7531806210767
   }
  ]
 },
 "split": {
  "cand": {
   "retail": 553.5745497911757,
   "arb": -27.2729158270307
  },
  "v2": {
   "retail": 553.56146437894,
   "arb": -27.274700279695193
  },
  "terciles": [
   {
    "label": "low",
    "n": 667,
    "mean_diff": 0.008973496572046703,
    "se": 0.003577827306611125,
    "v2_retail_volume_min": 54210.286315007696,
    "v2_retail_volume_max": 70880.81451280744
   },
   {
    "label": "middle",
    "n": 667,
    "mean_diff": 0.014888542770864708,
    "se": 0.004844463762893868,
    "v2_retail_volume_min": 70920.36927682077,
    "v2_retail_volume_max": 82037.2796292882
   },
   {
    "label": "high",
    "n": 666,
    "mean_diff": 0.020756380718919245,
    "se": 0.00747124239823535,
    "v2_retail_volume_min": 82090.47498113324,
    "v2_retail_volume_max": 101262.5553413265
   }
  ]
 },
 "gas": {
  "max_ok": 213474,
  "oog": 0,
  "reverts": 0,
  "other_halts": 0,
  "init_max": 220962,
  "tx_errors": 0,
  "bad_returns": 0,
  "by_callback": {
   "afterInitialize": {
    "calls": 2000,
    "ok": 2000,
    "max_ok_gas": 220962,
    "sum_ok_gas": 441924000,
    "oog": 0,
    "revert": 0,
    "other_halt": 0,
    "tx_error": 0,
    "bad_return": 0
   },
   "afterSwap": {
    "calls": 20699162,
    "ok": 20699162,
    "max_ok_gas": 213474,
    "sum_ok_gas": 2033946044900,
    "oog": 0,
    "revert": 0,
    "other_halt": 0,
    "tx_error": 0,
    "bad_return": 0
   },
   "getName": {
    "calls": 2000,
    "ok": 2000,
    "max_ok_gas": 21576,
    "sum_ok_gas": 43152000,
    "oog": 0,
    "revert": 0,
    "other_halt": 0,
    "tx_error": 0,
    "bad_return": 0
   }
  }
 },
 "v2_gas": {
  "max_ok": 243713,
  "oog": 33,
  "reverts": 0,
  "other_halts": 0,
  "init_max": 236377,
  "tx_errors": 0,
  "bad_returns": 0,
  "by_callback": {
   "afterInitialize": {
    "calls": 2000,
    "ok": 2000,
    "max_ok_gas": 236377,
    "sum_ok_gas": 472754000,
    "oog": 0,
    "revert": 0,
    "other_halt": 0,
    "tx_error": 0,
    "bad_return": 0
   },
   "afterSwap": {
    "calls": 20691410,
    "ok": 20691377,
    "max_ok_gas": 243713,
    "sum_ok_gas": 2304977081042,
    "oog": 33,
    "revert": 0,
    "other_halt": 0,
    "tx_error": 0,
    "bad_return": 0
   },
   "getName": {
    "calls": 2000,
    "ok": 2000,
    "max_ok_gas": 21545,
    "sum_ok_gas": 43090000,
    "oog": 0,
    "revert": 0,
    "other_halt": 0,
    "tx_error": 0,
    "bad_return": 0
   }
  }
 },
 "seeds": {
  "screen": {
   "start": 30000,
   "end_inclusive": 30255,
   "n": 256
  },
  "selection": {
   "start": 32000,
   "end_inclusive": 32511,
   "n": 512
  },
  "holdout": {
   "start": 4310000,
   "end_inclusive": 4311999,
   "n": 2000
  }
 },
 "valid": true,
 "blocked": null,
 "invalid_reasons": [],
 "selected_id": "cap30",
 "frozen_at_utc": "2026-11-08T03:48:54.670887+00:00",
 "v2_sha256": "28417e116f57f1029fdd1803832e852574902c1ae7253c05657f317db76da4ab",
 "method": {
  "simulator_commit": "6b6921f8d463314aa7c96234e1be25a25245f704",
  "steps": 10000,
  "gas_cap": 250000,
  "workers": 8,
  "chunk_size": 8,
  "market": "Each strategy separately against VanillaStrategy; one V2 run per seed block reused as paired reference.",
  "configs": "MatchRunner._build_configs: default_rng(seed) draws size, rate, sigma in that order; price seed=seed and retail seed=seed+1.",
  "selection": "Highest valid mean_diff on 256 screen seeds advances two; highest valid mean_diff on 512 selection seeds is frozen before any holdout run.",
  "floor": "Fixed cuts never raise a fee already below 20 bps; equal quotes are unchanged.",
  "terciles": "Holdout seeds sorted by V2 submission retail_volume_y, then seed; numpy.array_split into three groups.",
  "standard_error": "Sample standard deviation of per-seed paired differences divided by sqrt(n).",
  "gas_scope": "Final gas fields cover holdout only; max_ok is successful afterSwap maximum, init_max is successful afterInitialize maximum.",
  "base": "Exact reconstructed G hash matched the required gas-trimmed V2 base; no fallback.",
  "rule": "On firstInStep, cap only the smaller final V2 quote at 30 bps; equal quotes and later prints receive no direct adjustment."
 },
 "checks": {
  "validation_passed": [
   "V2",
   "cap30",
   "cap32",
   "cap34",
   "cap36",
   "cut2",
   "cut4",
   "cut4_second2"
  ],
  "holdout_gas_counters_match": true,
  "max_edge_reconciliation_error": 9.094947017729282e-12,
  "vanilla_candidate": {
   "by_callback": {
    "afterInitialize": {
     "calls": 2000,
     "ok": 2000,
     "max_ok_gas": 21796,
     "sum_ok_gas": 43592000,
     "oog": 0,
     "revert": 0,
     "other_halt": 0,
     "tx_error": 0,
     "bad_return": 0
    },
    "afterSwap": {
     "calls": 21522584,
     "ok": 21522584,
     "max_ok_gas": 22592,
     "sum_ok_gas": 485613256816,
     "oog": 0,
     "revert": 0,
     "other_halt": 0,
     "tx_error": 0,
     "bad_return": 0
    },
    "getName": {
     "calls": 2000,
     "ok": 2000,
     "max_ok_gas": 21526,
     "sum_ok_gas": 43052000,
     "oog": 0,
     "revert": 0,
     "other_halt": 0,
     "tx_error": 0,
     "bad_return": 0
    }
   },
   "max_ok": 22592,
   "oog": 0,
   "other_errors": 0,
   "oog_seeds": []
  },
  "vanilla_v2": {
   "by_callback": {
    "afterInitialize": {
     "calls": 2000,
     "ok": 2000,
     "max_ok_gas": 21796,
     "sum_ok_gas": 43592000,
     "oog": 0,
     "revert": 0,
     "other_halt": 0,
     "tx_error": 0,
     "bad_return": 0
    },
    "afterSwap": {
     "calls": 21525283,
     "ok": 21525283,
     "max_ok_gas": 22592,
     "sum_ok_gas": 485674215416,
     "oog": 0,
     "revert": 0,
     "other_halt": 0,
     "tx_error": 0,
     "bad_return": 0
    },
    "getName": {
     "calls": 2000,
     "ok": 2000,
     "max_ok_gas": 21526,
     "sum_ok_gas": 43052000,
     "oog": 0,
     "revert": 0,
     "other_halt": 0,
     "tx_error": 0,
     "bad_return": 0
    }
   },
   "max_ok": 22592,
   "oog": 0,
   "other_errors": 0,
   "oog_seeds": []
  },
  "independent_recomputation_passed": true,
  "configuration_and_validity_selftests_passed": true
 },
 "provenance": {
  "v2_code_and_harness": "https://api.imd.fun/artifacts/db62deadd0a3ec885ad69bd3917fee793a924ead522776d73cc09110923e1e86",
  "gas_trimmed_base": "https://api.imd.fun/artifacts/f09f39f5092e5b1e56f156df10f397e5df0e194afa630ab24fc699adfd980d31",
  "simulation_market_order": "https://raw.githubusercontent.com/benedictbrady/amm-challenge/6b6921f8d463314aa7c96234e1be25a25245f704/amm_sim_rs/src/simulation/engine.rs",
  "configuration_builder": "https://raw.githubusercontent.com/benedictbrady/amm-challenge/6b6921f8d463314aa7c96234e1be25a25245f704/amm_competition/competition/match.py",
  "callback_gas_limits": "https://raw.githubusercontent.com/benedictbrady/amm-challenge/6b6921f8d463314aa7c96234e1be25a25245f704/amm_sim_rs/src/evm/strategy.rs"
 }
}
