{"item":"first","batch":"e08-protect-hinge","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 (firstInStep) {\n                uint256 hingeK = 150 * BPS;\n                uint256 low = staleTox < hingeK ? staleTox : hingeK;\n                staleShift = wmul(STALE_DIR_COEF, low) + wmul(500000000000000000, wmul(STALE_DIR_COEF, staleTox - low));\n            }\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        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":"e3de387bdc9d154c765ae4aba4b5fb405f45c11872053ecc8207c14cf2e1a493","base_sha256":"610c1905e7dd5559b84e40a3b2d6f8e0b53a7b0ac7574ae33b6c1770a28367cb","v2_sha256":"28417e116f57f1029fdd1803832e852574902c1ae7253c05657f317db76da4ab","simulator_commit":"6b6921f8d463314aa7c96234e1be25a25245f704","variant":{"name":"H150_5","K_bps":150,"m_wad":"500000000000000000","sha256":"e3de387bdc9d154c765ae4aba4b5fb405f45c11872053ecc8207c14cf2e1a493"},"variants":[{"name":"H50_5","K_bps":50,"m_wad":"500000000000000000","sha256":"06fb8089a5ced98039cc63e1dc67cf1dcd579dac90d01acdf69b7e69a6e85f83"},{"name":"H50_15","K_bps":50,"m_wad":"1500000000000000000","sha256":"b3d0e8d807ed6c51fede4b5879d6237f18ffe7040e2a536fc5f11d92d7b32a9a"},{"name":"H150_5","K_bps":150,"m_wad":"500000000000000000","sha256":"e3de387bdc9d154c765ae4aba4b5fb405f45c11872053ecc8207c14cf2e1a493"},{"name":"H150_15","K_bps":150,"m_wad":"1500000000000000000","sha256":"8eae610d5a545510a00d2447e8ae54a02802943d481b7e900042b44d8304a8f4"}],"paired":{"label":"candidate_minus_V2","n":512,"mean_diff":-6.19593630721322,"se":0.12584156211813644,"sd":2.847469501722958,"n_nonzero":512,"max_abs_diff":16.422978748168134,"worst":[{"seed":12359,"diff":-16.422978748168134,"edge_a":735.6677632542579,"edge_b":752.090742002426},{"seed":12012,"diff":-16.351945332737387,"edge_a":838.1620013140225,"edge_b":854.5139466467599},{"seed":12089,"diff":-15.210120322050784,"edge_a":507.20708392539814,"edge_b":522.4172042474489},{"seed":12390,"diff":-14.174894653694764,"edge_a":743.5429360928692,"edge_b":757.717830746564},{"seed":12256,"diff":-14.0370517660308,"edge_a":710.4055860681002,"edge_b":724.442637834131}],"stage":"tuning"},"seeds":{"screen":[10000,10255],"selected_training":[12000,12511],"intervals":"inclusive","confirmation":null},"selection":{"rule":"Maximum screen mean_diff among valid hinge variants, excluding G control. All four variants measured once.","selected":"H150_5","G_control_better_than_selected":true,"recommendation":"Reject this hinge family: all four screening variants lose edge versus V2. Retain G; no board claim."},"freeze":{"name":"H150_5","sha256":"e3de387bdc9d154c765ae4aba4b5fb405f45c11872053ecc8207c14cf2e1a493"},"gas":{"max_ok":213681,"init_max":220962,"oog":0,"other_errors":0},"v2_gas":{"max_ok":243733,"init_max":236377,"oog":10,"other_errors":0},"G-control":{"name":"G","seeds":{"start":10000,"end_inclusive":10255},"valid":true,"invalid_reasons":[],"paired":{"label":"candidate_minus_V2","n":256,"mean_diff":0.002904894772038702,"se":0.002857312170046356,"sd":0.0457169947207417,"n_nonzero":5,"max_abs_diff":0.7304987692035638,"worst":[{"seed":10044,"diff":-0.023879557265217954,"edge_a":581.4479025749735,"edge_b":581.4717821322387},{"seed":10057,"diff":-0.0020430751104640876,"edge_a":441.40959048771265,"edge_b":441.4116335628231},{"seed":10000,"diff":0.0,"edge_a":489.4875846678468,"edge_b":489.4875846678468},{"seed":10001,"diff":0.0,"edge_a":552.3376592263003,"edge_b":552.3376592263003},{"seed":10002,"diff":0.0,"edge_a":443.04632640588295,"edge_b":443.04632640588295}],"stage":"tuning"},"gas":{"max_ok":211186,"init_max":220944,"oog":0,"other_errors":0},"v2_gas":{"max_ok":243554,"init_max":236377,"oog":7,"other_errors":0},"edge_deltas":{"total":{"n":256,"mean":0.002904894772038702,"se":0.002857312170046356,"sd":0.0457169947207417},"retail":{"n":256,"mean":-0.00032599031636637577,"se":0.0002866995092404792,"sd":0.004587192147847668},"arb":{"n":256,"mean":0.0032308850883991103,"se":0.0031205864312076224,"sd":0.04992938289932196}},"v2_volume_terciles":[{"n":86,"volume_min":57146.525064967944,"volume_max":70606.56468501159,"deltas":{"total":{"n":86,"mean":-2.3756687330977762e-05,"se":2.3756687330977762e-05,"sd":0.00022031045502426383},"retail":{"n":86,"mean":-5.148402973524097e-05,"se":5.1484029735240966e-05,"sd":0.00047744325037538143},"arb":{"n":86,"mean":2.7727342379807323e-05,"se":2.7727342379807323e-05,"sd":0.0002571327951243231}}},{"n":85,"volume_min":70782.87220107234,"volume_max":82121.65976706463,"deltas":{"total":{"n":85,"mean":0.00892753401864518,"se":0.008596601552777522,"sd":0.07925675019746543},"retail":{"n":85,"mean":-0.000738577467102593,"se":0.0008049542706652925,"sd":0.007421311684486435},"arb":{"n":85,"mean":0.009666111485738912,"se":0.009396495422076196,"sd":0.08663140728658059}}},{"n":85,"volume_min":82281.64874642732,"volume_max":98205.47208725398,"deltas":{"total":{"n":85,"mean":-0.0001546382921466883,"se":0.00030938797640195863,"sd":0.00285241620298974},"retail":{"n":85,"mean":-0.00019113893798636554,"se":0.0003125637904288027,"sd":0.002881695761598323},"arb":{"n":85,"mean":3.6500645855309195e-05,"se":2.6715397682507955e-05,"sd":0.00024630379662814145}}}],"checks":{"candidate":{"complete":true,"n_returned":256,"error":null,"counters_per_seed_match_global":true,"max_abs_reconciliation_error":7.673861546209082e-12,"normalizer":{"by_callback":{"afterInitialize":{"calls":256,"ok":256,"max_ok_gas":21796,"sum_ok_gas":5579776,"oog":0,"revert":0,"other_halt":0,"tx_error":0,"bad_return":0},"afterSwap":{"calls":2749682,"ok":2749682,"max_ok_gas":22592,"sum_ok_gas":62040909928,"oog":0,"revert":0,"other_halt":0,"tx_error":0,"bad_return":0},"getName":{"calls":256,"ok":256,"max_ok_gas":21526,"sum_ok_gas":5510656,"oog":0,"revert":0,"other_halt":0,"tx_error":0,"bad_return":0}},"max_ok":22592,"oog":0,"other_errors":0,"oog_seeds":[]},"submission":{"by_callback":{"afterInitialize":{"calls":256,"ok":256,"max_ok_gas":220944,"sum_ok_gas":56561664,"oog":0,"revert":0,"other_halt":0,"tx_error":0,"bad_return":0},"afterSwap":{"calls":2644186,"ok":2644186,"max_ok_gas":211186,"sum_ok_gas":259299555384,"oog":0,"revert":0,"other_halt":0,"tx_error":0,"bad_return":0},"getName":{"calls":256,"ok":256,"max_ok_gas":21557,"sum_ok_gas":5518592,"oog":0,"revert":0,"other_halt":0,"tx_error":0,"bad_return":0}},"max_ok":220944,"oog":0,"other_errors":0,"oog_seeds":[]}},"reference":{"complete":true,"n_returned":256,"error":null,"counters_per_seed_match_global":true,"max_abs_reconciliation_error":7.673861546209082e-12,"normalizer":{"by_callback":{"afterInitialize":{"calls":256,"ok":256,"max_ok_gas":21796,"sum_ok_gas":5579776,"oog":0,"revert":0,"other_halt":0,"tx_error":0,"bad_return":0},"afterSwap":{"calls":2749671,"ok":2749671,"max_ok_gas":22592,"sum_ok_gas":62040662676,"oog":0,"revert":0,"other_halt":0,"tx_error":0,"bad_return":0},"getName":{"calls":256,"ok":256,"max_ok_gas":21526,"sum_ok_gas":5510656,"oog":0,"revert":0,"other_halt":0,"tx_error":0,"bad_return":0}},"max_ok":22592,"oog":0,"other_errors":0,"oog_seeds":[]},"submission":{"by_callback":{"afterInitialize":{"calls":256,"ok":256,"max_ok_gas":236377,"sum_ok_gas":60512512,"oog":0,"revert":0,"other_halt":0,"tx_error":0,"bad_return":0},"afterSwap":{"calls":2644187,"ok":2644180,"max_ok_gas":243554,"sum_ok_gas":294618218760,"oog":7,"revert":0,"other_halt":0,"tx_error":0,"bad_return":0},"getName":{"calls":256,"ok":256,"max_ok_gas":21545,"sum_ok_gas":5515520,"oog":0,"revert":0,"other_halt":0,"tx_error":0,"bad_return":0}},"max_ok":243554,"oog":7,"other_errors":0,"oog_seeds":[[10043,2],[10044,1],[10057,1],[10150,2],[10231,1]]}}},"stage":"tuning","training_block":"screen"},"stages":[{"name":"H50_5","seeds":{"start":10000,"end_inclusive":10255},"valid":true,"invalid_reasons":[],"paired":{"label":"candidate_minus_V2","n":256,"mean_diff":-14.76785254578808,"se":0.27737471945400105,"sd":4.437995511264017,"n_nonzero":256,"max_abs_diff":28.256602794598848,"worst":[{"seed":10237,"diff":-28.256602794598848,"edge_a":724.9629934166585,"edge_b":753.2195962112573},{"seed":10199,"diff":-26.14572390436058,"edge_a":721.8776780081485,"edge_b":748.023401912509},{"seed":10025,"diff":-25.54385203793197,"edge_a":670.2348462218902,"edge_b":695.7786982598221},{"seed":10121,"diff":-25.026931877124866,"edge_a":670.1681227221108,"edge_b":695.1950545992356},{"seed":10144,"diff":-24.417640523551768,"edge_a":612.7669700365034,"edge_b":637.1846105600551}],"stage":"tuning"},"gas":{"max_ok":211708,"init_max":220962,"oog":0,"other_errors":0},"v2_gas":{"max_ok":243554,"init_max":236377,"oog":7,"other_errors":0},"edge_deltas":{"total":{"n":256,"mean":-14.76785254578808,"se":0.27737471945400105,"sd":4.437995511264017},"retail":{"n":256,"mean":4.5988641380129724,"se":0.10934600417866047,"sd":1.7495360668585676},"arb":{"n":256,"mean":-19.366716683801265,"se":0.28587553519479,"sd":4.57400856311664}},"v2_volume_terciles":[{"n":86,"volume_min":57146.525064967944,"volume_max":70606.56468501159,"deltas":{"total":{"n":86,"mean":-11.559804664873246,"se":0.35828963810205844,"sd":3.3226414146477112},"retail":{"n":86,"mean":4.0770148496708645,"se":0.14008812982864022,"sd":1.2991238717782814},"arb":{"n":86,"mean":-15.636819514544387,"se":0.35177068124933214,"sd":3.2621870958069303}}},{"n":85,"volume_min":70782.87220107234,"volume_max":82121.65976706463,"deltas":{"total":{"n":85,"mean":-15.072180438450449,"se":0.360520508713791,"sd":3.3238348578526438},"retail":{"n":85,"mean":4.631550399083174,"se":0.1738381564038813,"sd":1.602708611339418},"arb":{"n":85,"mean":-19.703730837533744,"se":0.35673339105373614,"sd":3.288919358220769}}},{"n":85,"volume_min":82281.64874642732,"volume_max":98205.47208725398,"deltas":{"total":{"n":85,"mean":-17.709314273816013,"se":0.46255118507419063,"sd":4.264511214565011},"retail":{"n":85,"mean":5.094166568677137,"se":0.22976509517574947,"sd":2.1183295097069537},"arb":{"n":85,"mean":-22.803480842493396,"se":0.4286236980226418,"sd":3.9517152393690274}}}],"checks":{"candidate":{"complete":true,"n_returned":256,"error":null,"counters_per_seed_match_global":true,"max_abs_reconciliation_error":5.5138116294983774e-12,"normalizer":{"by_callback":{"afterInitialize":{"calls":256,"ok":256,"max_ok_gas":21796,"sum_ok_gas":5579776,"oog":0,"revert":0,"other_halt":0,"tx_error":0,"bad_return":0},"afterSwap":{"calls":2741857,"ok":2741857,"max_ok_gas":22592,"sum_ok_gas":61864054940,"oog":0,"revert":0,"other_halt":0,"tx_error":0,"bad_return":0},"getName":{"calls":256,"ok":256,"max_ok_gas":21526,"sum_ok_gas":5510656,"oog":0,"revert":0,"other_halt":0,"tx_error":0,"bad_return":0}},"max_ok":22592,"oog":0,"other_errors":0,"oog_seeds":[]},"submission":{"by_callback":{"afterInitialize":{"calls":256,"ok":256,"max_ok_gas":220962,"sum_ok_gas":56566272,"oog":0,"revert":0,"other_halt":0,"tx_error":0,"bad_return":0},"afterSwap":{"calls":2697785,"ok":2697785,"max_ok_gas":211708,"sum_ok_gas":265726246232,"oog":0,"revert":0,"other_halt":0,"tx_error":0,"bad_return":0},"getName":{"calls":256,"ok":256,"max_ok_gas":21576,"sum_ok_gas":5523456,"oog":0,"revert":0,"other_halt":0,"tx_error":0,"bad_return":0}},"max_ok":220962,"oog":0,"other_errors":0,"oog_seeds":[]}},"reference":{"complete":true,"n_returned":256,"error":null,"counters_per_seed_match_global":true,"max_abs_reconciliation_error":7.673861546209082e-12,"normalizer":{"by_callback":{"afterInitialize":{"calls":256,"ok":256,"max_ok_gas":21796,"sum_ok_gas":5579776,"oog":0,"revert":0,"other_halt":0,"tx_error":0,"bad_return":0},"afterSwap":{"calls":2749671,"ok":2749671,"max_ok_gas":22592,"sum_ok_gas":62040662676,"oog":0,"revert":0,"other_halt":0,"tx_error":0,"bad_return":0},"getName":{"calls":256,"ok":256,"max_ok_gas":21526,"sum_ok_gas":5510656,"oog":0,"revert":0,"other_halt":0,"tx_error":0,"bad_return":0}},"max_ok":22592,"oog":0,"other_errors":0,"oog_seeds":[]},"submission":{"by_callback":{"afterInitialize":{"calls":256,"ok":256,"max_ok_gas":236377,"sum_ok_gas":60512512,"oog":0,"revert":0,"other_halt":0,"tx_error":0,"bad_return":0},"afterSwap":{"calls":2644187,"ok":2644180,"max_ok_gas":243554,"sum_ok_gas":294618218760,"oog":7,"revert":0,"other_halt":0,"tx_error":0,"bad_return":0},"getName":{"calls":256,"ok":256,"max_ok_gas":21545,"sum_ok_gas":5515520,"oog":0,"revert":0,"other_halt":0,"tx_error":0,"bad_return":0}},"max_ok":243554,"oog":7,"other_errors":0,"oog_seeds":[[10043,2],[10044,1],[10057,1],[10150,2],[10231,1]]}}},"stage":"tuning","training_block":"screen"},{"name":"H50_15","seeds":{"start":10000,"end_inclusive":10255},"valid":true,"invalid_reasons":[],"paired":{"label":"candidate_minus_V2","n":256,"mean_diff":-60.72867063387651,"se":1.8671094712209988,"sd":29.87375153953598,"n_nonzero":256,"max_abs_diff":159.01950786794106,"worst":[{"seed":10165,"diff":-159.01950786794106,"edge_a":507.69487504926354,"edge_b":666.7143829172046},{"seed":10089,"diff":-152.87109821636056,"edge_a":554.9808472542044,"edge_b":707.8519454705649},{"seed":10217,"diff":-150.76015437360638,"edge_a":324.13796418429314,"edge_b":474.8981185578995},{"seed":10078,"diff":-147.77344872655942,"edge_a":506.5415901464287,"edge_b":654.3150388729881},{"seed":10226,"diff":-138.72422369846572,"edge_a":436.2288322995323,"edge_b":574.953055997998}],"stage":"tuning"},"gas":{"max_ok":211707,"init_max":220962,"oog":0,"other_errors":0},"v2_gas":{"max_ok":243554,"init_max":236377,"oog":7,"other_errors":0},"edge_deltas":{"total":{"n":256,"mean":-60.72867063387651,"se":1.8671094712209988,"sd":29.87375153953598},"retail":{"n":256,"mean":-70.83589340860428,"se":1.999868170494075,"sd":31.9978907279052},"arb":{"n":256,"mean":10.107222774727711,"se":0.1776726591818501,"sd":2.8427625469096016}},"v2_volume_terciles":[{"n":86,"volume_min":57146.525064967944,"volume_max":70606.56468501159,"deltas":{"total":{"n":86,"mean":-50.48001574039857,"se":3.0701952432134103,"sd":28.471819392246815},"retail":{"n":86,"mean":-59.31105583377258,"se":3.256991738082626,"sd":30.20409882195974},"arb":{"n":86,"mean":8.831040093373893,"se":0.2524983781316729,"sd":2.34157362952455}}},{"n":85,"volume_min":70782.87220107234,"volume_max":82121.65976706463,"deltas":{"total":{"n":85,"mean":-60.436536165256356,"se":2.7196947562041247,"sd":25.074346715090268},"retail":{"n":85,"mean":-70.83721831092292,"se":2.914674201994957,"sd":26.871968383817173},"arb":{"n":85,"mean":10.400682145666442,"se":0.2570479839951891,"sd":2.3698653161011562}}},{"n":85,"volume_min":82281.64874642732,"volume_max":98205.47208725398,"deltas":{"total":{"n":85,"mean":-71.3900324064861,"se":3.4937560979870037,"sd":32.21083966832931},"retail":{"n":85,"mean":-82.49499240552711,"se":3.740672535777401,"sd":34.487296743774266},"arb":{"n":85,"mean":11.104959999041078,"se":0.35323910991894897,"sd":3.256703677952319}}}],"checks":{"candidate":{"complete":true,"n_returned":256,"error":null,"counters_per_seed_match_global":true,"max_abs_reconciliation_error":6.366462912410498e-12,"normalizer":{"by_callback":{"afterInitialize":{"calls":256,"ok":256,"max_ok_gas":21796,"sum_ok_gas":5579776,"oog":0,"revert":0,"other_halt":0,"tx_error":0,"bad_return":0},"afterSwap":{"calls":2881243,"ok":2881243,"max_ok_gas":22592,"sum_ok_gas":65011534844,"oog":0,"revert":0,"other_halt":0,"tx_error":0,"bad_return":0},"getName":{"calls":256,"ok":256,"max_ok_gas":21526,"sum_ok_gas":5510656,"oog":0,"revert":0,"other_halt":0,"tx_error":0,"bad_return":0}},"max_ok":22592,"oog":0,"other_errors":0,"oog_seeds":[]},"submission":{"by_callback":{"afterInitialize":{"calls":256,"ok":256,"max_ok_gas":220962,"sum_ok_gas":56566272,"oog":0,"revert":0,"other_halt":0,"tx_error":0,"bad_return":0},"afterSwap":{"calls":1733681,"ok":1733681,"max_ok_gas":211707,"sum_ok_gas":171519832964,"oog":0,"revert":0,"other_halt":0,"tx_error":0,"bad_return":0},"getName":{"calls":256,"ok":256,"max_ok_gas":21576,"sum_ok_gas":5523456,"oog":0,"revert":0,"other_halt":0,"tx_error":0,"bad_return":0}},"max_ok":220962,"oog":0,"other_errors":0,"oog_seeds":[]}},"reference":{"complete":true,"n_returned":256,"error":null,"counters_per_seed_match_global":true,"max_abs_reconciliation_error":7.673861546209082e-12,"normalizer":{"by_callback":{"afterInitialize":{"calls":256,"ok":256,"max_ok_gas":21796,"sum_ok_gas":5579776,"oog":0,"revert":0,"other_halt":0,"tx_error":0,"bad_return":0},"afterSwap":{"calls":2749671,"ok":2749671,"max_ok_gas":22592,"sum_ok_gas":62040662676,"oog":0,"revert":0,"other_halt":0,"tx_error":0,"bad_return":0},"getName":{"calls":256,"ok":256,"max_ok_gas":21526,"sum_ok_gas":5510656,"oog":0,"revert":0,"other_halt":0,"tx_error":0,"bad_return":0}},"max_ok":22592,"oog":0,"other_errors":0,"oog_seeds":[]},"submission":{"by_callback":{"afterInitialize":{"calls":256,"ok":256,"max_ok_gas":236377,"sum_ok_gas":60512512,"oog":0,"revert":0,"other_halt":0,"tx_error":0,"bad_return":0},"afterSwap":{"calls":2644187,"ok":2644180,"max_ok_gas":243554,"sum_ok_gas":294618218760,"oog":7,"revert":0,"other_halt":0,"tx_error":0,"bad_return":0},"getName":{"calls":256,"ok":256,"max_ok_gas":21545,"sum_ok_gas":5515520,"oog":0,"revert":0,"other_halt":0,"tx_error":0,"bad_return":0}},"max_ok":243554,"oog":7,"other_errors":0,"oog_seeds":[[10043,2],[10044,1],[10057,1],[10150,2],[10231,1]]}}},"stage":"tuning","training_block":"screen"},{"name":"H150_5","seeds":{"start":10000,"end_inclusive":10255},"valid":true,"invalid_reasons":[],"paired":{"label":"candidate_minus_V2","n":256,"mean_diff":-6.19416443231107,"se":0.16546214390540906,"sd":2.647394302486545,"n_nonzero":256,"max_abs_diff":14.18673651059089,"worst":[{"seed":10237,"diff":-14.18673651059089,"edge_a":739.0328597006664,"edge_b":753.2195962112573},{"seed":10144,"diff":-12.922178212510403,"edge_a":624.2624323475447,"edge_b":637.1846105600551},{"seed":10081,"diff":-12.902478069865538,"edge_a":651.3983793182067,"edge_b":664.3008573880722},{"seed":10025,"diff":-12.20002120850279,"edge_a":683.5786770513193,"edge_b":695.7786982598221},{"seed":10166,"diff":-12.024517303278458,"edge_a":707.2004212008914,"edge_b":719.2249385041698}],"stage":"tuning"},"gas":{"max_ok":211708,"init_max":220962,"oog":0,"other_errors":0},"v2_gas":{"max_ok":243554,"init_max":236377,"oog":7,"other_errors":0},"edge_deltas":{"total":{"n":256,"mean":-6.19416443231107,"se":0.16546214390540906,"sd":2.647394302486545},"retail":{"n":256,"mean":0.8999194025910262,"se":0.06504597012135524,"sd":1.0407355219416838},"arb":{"n":256,"mean":-7.09408383490215,"se":0.1646045781954622,"sd":2.6336732511273953}},"v2_volume_terciles":[{"n":86,"volume_min":57146.525064967944,"volume_max":70606.56468501159,"deltas":{"total":{"n":86,"mean":-4.773464024592819,"se":0.23067349886267483,"sd":2.1391780254736084},"retail":{"n":86,"mean":0.7480189242961681,"se":0.08480341197782715,"sd":0.7864344897987198},"arb":{"n":86,"mean":-5.521482948889116,"se":0.23542902975435342,"sd":2.18327900470658}}},{"n":85,"volume_min":70782.87220107234,"volume_max":82121.65976706463,"deltas":{"total":{"n":85,"mean":-6.3728699360306855,"se":0.24716555260285458,"sd":2.2787538005333814},"retail":{"n":85,"mean":0.8922013473311414,"se":0.10076178685065862,"sd":0.928977773465917},"arb":{"n":85,"mean":-7.265071283362056,"se":0.2362714175443656,"sd":2.178314838037889}}},{"n":85,"volume_min":82281.64874642732,"volume_max":98205.47208725398,"deltas":{"total":{"n":85,"mean":-7.45287345875345,"se":0.3019768124460242,"sd":2.784088647417716},"retail":{"n":85,"mean":1.0613250005962969,"se":0.14345269506293953,"sd":1.3225684996512508},"arb":{"n":85,"mean":-8.514198459349549,"se":0.2846182705493083,"sd":2.624050798687163}}}],"checks":{"candidate":{"complete":true,"n_returned":256,"error":null,"counters_per_seed_match_global":true,"max_abs_reconciliation_error":7.617018127348274e-12,"normalizer":{"by_callback":{"afterInitialize":{"calls":256,"ok":256,"max_ok_gas":21796,"sum_ok_gas":5579776,"oog":0,"revert":0,"other_halt":0,"tx_error":0,"bad_return":0},"afterSwap":{"calls":2750699,"ok":2750699,"max_ok_gas":22592,"sum_ok_gas":62063869420,"oog":0,"revert":0,"other_halt":0,"tx_error":0,"bad_return":0},"getName":{"calls":256,"ok":256,"max_ok_gas":21526,"sum_ok_gas":5510656,"oog":0,"revert":0,"other_halt":0,"tx_error":0,"bad_return":0}},"max_ok":22592,"oog":0,"other_errors":0,"oog_seeds":[]},"submission":{"by_callback":{"afterInitialize":{"calls":256,"ok":256,"max_ok_gas":220962,"sum_ok_gas":56566272,"oog":0,"revert":0,"other_halt":0,"tx_error":0,"bad_return":0},"afterSwap":{"calls":2643233,"ok":2643233,"max_ok_gas":211708,"sum_ok_gas":260230114536,"oog":0,"revert":0,"other_halt":0,"tx_error":0,"bad_return":0},"getName":{"calls":256,"ok":256,"max_ok_gas":21576,"sum_ok_gas":5523456,"oog":0,"revert":0,"other_halt":0,"tx_error":0,"bad_return":0}},"max_ok":220962,"oog":0,"other_errors":0,"oog_seeds":[]}},"reference":{"complete":true,"n_returned":256,"error":null,"counters_per_seed_match_global":true,"max_abs_reconciliation_error":7.673861546209082e-12,"normalizer":{"by_callback":{"afterInitialize":{"calls":256,"ok":256,"max_ok_gas":21796,"sum_ok_gas":5579776,"oog":0,"revert":0,"other_halt":0,"tx_error":0,"bad_return":0},"afterSwap":{"calls":2749671,"ok":2749671,"max_ok_gas":22592,"sum_ok_gas":62040662676,"oog":0,"revert":0,"other_halt":0,"tx_error":0,"bad_return":0},"getName":{"calls":256,"ok":256,"max_ok_gas":21526,"sum_ok_gas":5510656,"oog":0,"revert":0,"other_halt":0,"tx_error":0,"bad_return":0}},"max_ok":22592,"oog":0,"other_errors":0,"oog_seeds":[]},"submission":{"by_callback":{"afterInitialize":{"calls":256,"ok":256,"max_ok_gas":236377,"sum_ok_gas":60512512,"oog":0,"revert":0,"other_halt":0,"tx_error":0,"bad_return":0},"afterSwap":{"calls":2644187,"ok":2644180,"max_ok_gas":243554,"sum_ok_gas":294618218760,"oog":7,"revert":0,"other_halt":0,"tx_error":0,"bad_return":0},"getName":{"calls":256,"ok":256,"max_ok_gas":21545,"sum_ok_gas":5515520,"oog":0,"revert":0,"other_halt":0,"tx_error":0,"bad_return":0}},"max_ok":243554,"oog":7,"other_errors":0,"oog_seeds":[[10043,2],[10044,1],[10057,1],[10150,2],[10231,1]]}}},"stage":"tuning","training_block":"screen"},{"name":"H150_15","seeds":{"start":10000,"end_inclusive":10255},"valid":true,"invalid_reasons":[],"paired":{"label":"candidate_minus_V2","n":256,"mean_diff":-23.80505816187647,"se":1.2782731623166184,"sd":20.452370597065894,"n_nonzero":256,"max_abs_diff":121.15913789667013,"worst":[{"seed":10165,"diff":-121.15913789667013,"edge_a":545.5552450205345,"edge_b":666.7143829172046},{"seed":10089,"diff":-114.78391520720379,"edge_a":593.0680302633612,"edge_b":707.8519454705649},{"seed":10226,"diff":-110.09089274802898,"edge_a":464.86216324996906,"edge_b":574.953055997998},{"seed":10166,"diff":-102.28803708190924,"edge_a":616.9369014222606,"edge_b":719.2249385041698},{"seed":10091,"diff":-102.10098488261616,"edge_a":307.1036686677078,"edge_b":409.20465355032394}],"stage":"tuning"},"gas":{"max_ok":211707,"init_max":220962,"oog":0,"other_errors":0},"v2_gas":{"max_ok":243554,"init_max":236377,"oog":7,"other_errors":0},"edge_deltas":{"total":{"n":256,"mean":-23.80505816187647,"se":1.2782731623166184,"sd":20.452370597065894},"retail":{"n":256,"mean":-28.079520090742502,"se":1.371630211864469,"sd":21.946083389831504},"arb":{"n":256,"mean":4.274461928865823,"se":0.13039592838909486,"sd":2.086334854225518}},"v2_volume_terciles":[{"n":86,"volume_min":57146.525064967944,"volume_max":70606.56468501159,"deltas":{"total":{"n":86,"mean":-18.10260941482976,"se":1.8628873311739484,"sd":17.27570640939936},"retail":{"n":86,"mean":-21.32493967440619,"se":1.987278134520068,"sd":18.429259263979503},"arb":{"n":86,"mean":3.222330259576342,"se":0.1733628195472526,"sd":1.607700649784686}}},{"n":85,"volume_min":70782.87220107234,"volume_max":82121.65976706463,"deltas":{"total":{"n":85,"mean":-23.792239575449116,"se":2.187112469023148,"sd":20.164180641258522},"retail":{"n":85,"mean":-28.270635006633587,"se":2.343155487834643,"sd":21.60282619044129},"arb":{"n":85,"mean":4.478395431184008,"se":0.19406092973006836,"sd":1.7891533690699561}}},{"n":85,"volume_min":82281.64874642732,"volume_max":98205.47208725398,"deltas":{"total":{"n":85,"mean":-29.58741312766874,"se":2.411039487416697,"sd":22.228685742526892},"retail":{"n":85,"mean":-34.72245124314463,"se":2.567508141414341,"sd":23.67125545423095},"arb":{"n":85,"mean":5.135038115475819,"se":0.25373597208771625,"sd":2.339330075077127}}}],"checks":{"candidate":{"complete":true,"n_returned":256,"error":null,"counters_per_seed_match_global":true,"max_abs_reconciliation_error":5.9117155615240335e-12,"normalizer":{"by_callback":{"afterInitialize":{"calls":256,"ok":256,"max_ok_gas":21796,"sum_ok_gas":5579776,"oog":0,"revert":0,"other_halt":0,"tx_error":0,"bad_return":0},"afterSwap":{"calls":2789767,"ok":2789767,"max_ok_gas":22592,"sum_ok_gas":62946078068,"oog":0,"revert":0,"other_halt":0,"tx_error":0,"bad_return":0},"getName":{"calls":256,"ok":256,"max_ok_gas":21526,"sum_ok_gas":5510656,"oog":0,"revert":0,"other_halt":0,"tx_error":0,"bad_return":0}},"max_ok":22592,"oog":0,"other_errors":0,"oog_seeds":[]},"submission":{"by_callback":{"afterInitialize":{"calls":256,"ok":256,"max_ok_gas":220962,"sum_ok_gas":56566272,"oog":0,"revert":0,"other_halt":0,"tx_error":0,"bad_return":0},"afterSwap":{"calls":2360503,"ok":2360503,"max_ok_gas":211707,"sum_ok_gas":232494280434,"oog":0,"revert":0,"other_halt":0,"tx_error":0,"bad_return":0},"getName":{"calls":256,"ok":256,"max_ok_gas":21576,"sum_ok_gas":5523456,"oog":0,"revert":0,"other_halt":0,"tx_error":0,"bad_return":0}},"max_ok":220962,"oog":0,"other_errors":0,"oog_seeds":[]}},"reference":{"complete":true,"n_returned":256,"error":null,"counters_per_seed_match_global":true,"max_abs_reconciliation_error":7.673861546209082e-12,"normalizer":{"by_callback":{"afterInitialize":{"calls":256,"ok":256,"max_ok_gas":21796,"sum_ok_gas":5579776,"oog":0,"revert":0,"other_halt":0,"tx_error":0,"bad_return":0},"afterSwap":{"calls":2749671,"ok":2749671,"max_ok_gas":22592,"sum_ok_gas":62040662676,"oog":0,"revert":0,"other_halt":0,"tx_error":0,"bad_return":0},"getName":{"calls":256,"ok":256,"max_ok_gas":21526,"sum_ok_gas":5510656,"oog":0,"revert":0,"other_halt":0,"tx_error":0,"bad_return":0}},"max_ok":22592,"oog":0,"other_errors":0,"oog_seeds":[]},"submission":{"by_callback":{"afterInitialize":{"calls":256,"ok":256,"max_ok_gas":236377,"sum_ok_gas":60512512,"oog":0,"revert":0,"other_halt":0,"tx_error":0,"bad_return":0},"afterSwap":{"calls":2644187,"ok":2644180,"max_ok_gas":243554,"sum_ok_gas":294618218760,"oog":7,"revert":0,"other_halt":0,"tx_error":0,"bad_return":0},"getName":{"calls":256,"ok":256,"max_ok_gas":21545,"sum_ok_gas":5515520,"oog":0,"revert":0,"other_halt":0,"tx_error":0,"bad_return":0}},"max_ok":243554,"oog":7,"other_errors":0,"oog_seeds":[[10043,2],[10044,1],[10057,1],[10150,2],[10231,1]]}}},"stage":"tuning","training_block":"screen"},{"name":"H150_5","seeds":{"start":12000,"end_inclusive":12511},"valid":true,"invalid_reasons":[],"paired":{"label":"candidate_minus_V2","n":512,"mean_diff":-6.19593630721322,"se":0.12584156211813644,"sd":2.847469501722958,"n_nonzero":512,"max_abs_diff":16.422978748168134,"worst":[{"seed":12359,"diff":-16.422978748168134,"edge_a":735.6677632542579,"edge_b":752.090742002426},{"seed":12012,"diff":-16.351945332737387,"edge_a":838.1620013140225,"edge_b":854.5139466467599},{"seed":12089,"diff":-15.210120322050784,"edge_a":507.20708392539814,"edge_b":522.4172042474489},{"seed":12390,"diff":-14.174894653694764,"edge_a":743.5429360928692,"edge_b":757.717830746564},{"seed":12256,"diff":-14.0370517660308,"edge_a":710.4055860681002,"edge_b":724.442637834131}],"stage":"tuning"},"gas":{"max_ok":213681,"init_max":220962,"oog":0,"other_errors":0},"v2_gas":{"max_ok":243733,"init_max":236377,"oog":10,"other_errors":0},"edge_deltas":{"total":{"n":512,"mean":-6.19593630721322,"se":0.12584156211813644,"sd":2.847469501722958},"retail":{"n":512,"mean":0.7838517740887051,"se":0.04603491974545147,"sd":1.0416513255483915},"arb":{"n":512,"mean":-6.979788081301977,"se":0.12656843526471764,"sd":2.863916763515277}},"v2_volume_terciles":[{"n":171,"volume_min":56609.85690614511,"volume_max":69299.74772823698,"deltas":{"total":{"n":171,"mean":-4.952025885798064,"se":0.1860878833863765,"sd":2.43341483489579},"retail":{"n":171,"mean":0.7478829793207249,"se":0.07411429430182954,"sd":0.9691701574005221},"arb":{"n":171,"mean":-5.699908865118803,"se":0.1821920944960004,"sd":2.3824707846602364}}},{"n":171,"volume_min":69452.7064391168,"volume_max":80118.62548945099,"deltas":{"total":{"n":171,"mean":-6.234587669010798,"se":0.1974118767874755,"sd":2.5814952635139257},"retail":{"n":171,"mean":0.7885838019736078,"se":0.07240642261618707,"sd":0.9468368371417721},"arb":{"n":171,"mean":-7.023171470984481,"se":0.2081133281385403,"sd":2.7214348984794507}}},{"n":170,"volume_min":80181.79091172446,"volume_max":97575.07091417206,"deltas":{"total":{"n":170,"mean":-7.408285126005017,"se":0.22765344505032922,"sd":2.968237773049551},"retail":{"n":170,"mean":0.8152722866593302,"se":0.09177387628931158,"sd":1.196584950080101},"arb":{"n":170,"mean":-8.223557412664412,"se":0.22261687223491514,"sd":2.902568897825099}}}],"checks":{"candidate":{"complete":true,"n_returned":512,"error":null,"counters_per_seed_match_global":true,"max_abs_reconciliation_error":6.59383658785373e-12,"normalizer":{"by_callback":{"afterInitialize":{"calls":512,"ok":512,"max_ok_gas":21796,"sum_ok_gas":11159552,"oog":0,"revert":0,"other_halt":0,"tx_error":0,"bad_return":0},"afterSwap":{"calls":5437875,"ok":5437875,"max_ok_gas":22592,"sum_ok_gas":122694411360,"oog":0,"revert":0,"other_halt":0,"tx_error":0,"bad_return":0},"getName":{"calls":512,"ok":512,"max_ok_gas":21526,"sum_ok_gas":11021312,"oog":0,"revert":0,"other_halt":0,"tx_error":0,"bad_return":0}},"max_ok":22592,"oog":0,"other_errors":0,"oog_seeds":[]},"submission":{"by_callback":{"afterInitialize":{"calls":512,"ok":512,"max_ok_gas":220962,"sum_ok_gas":113132544,"oog":0,"revert":0,"other_halt":0,"tx_error":0,"bad_return":0},"afterSwap":{"calls":5251280,"ok":5251280,"max_ok_gas":213681,"sum_ok_gas":517267621244,"oog":0,"revert":0,"other_halt":0,"tx_error":0,"bad_return":0},"getName":{"calls":512,"ok":512,"max_ok_gas":21576,"sum_ok_gas":11046912,"oog":0,"revert":0,"other_halt":0,"tx_error":0,"bad_return":0}},"max_ok":220962,"oog":0,"other_errors":0,"oog_seeds":[]}},"reference":{"complete":true,"n_returned":512,"error":null,"counters_per_seed_match_global":true,"max_abs_reconciliation_error":6.821210263296962e-12,"normalizer":{"by_callback":{"afterInitialize":{"calls":512,"ok":512,"max_ok_gas":21796,"sum_ok_gas":11159552,"oog":0,"revert":0,"other_halt":0,"tx_error":0,"bad_return":0},"afterSwap":{"calls":5435418,"ok":5435418,"max_ok_gas":22592,"sum_ok_gas":122639036868,"oog":0,"revert":0,"other_halt":0,"tx_error":0,"bad_return":0},"getName":{"calls":512,"ok":512,"max_ok_gas":21526,"sum_ok_gas":11021312,"oog":0,"revert":0,"other_halt":0,"tx_error":0,"bad_return":0}},"max_ok":22592,"oog":0,"other_errors":0,"oog_seeds":[]},"submission":{"by_callback":{"afterInitialize":{"calls":512,"ok":512,"max_ok_gas":236377,"sum_ok_gas":121025024,"oog":0,"revert":0,"other_halt":0,"tx_error":0,"bad_return":0},"afterSwap":{"calls":5254411,"ok":5254401,"max_ok_gas":243733,"sum_ok_gas":585894701021,"oog":10,"revert":0,"other_halt":0,"tx_error":0,"bad_return":0},"getName":{"calls":512,"ok":512,"max_ok_gas":21545,"sum_ok_gas":11031040,"oog":0,"revert":0,"other_halt":0,"tx_error":0,"bad_return":0}},"max_ok":243733,"oog":10,"other_errors":0,"oog_seeds":[[12120,1],[12129,1],[12138,1],[12221,2],[12286,3],[12288,1],[12505,1]]}}},"stage":"tuning","training_block":"selected_variant_training"}],"edge_deltas":{"total":{"n":512,"mean":-6.19593630721322,"se":0.12584156211813644,"sd":2.847469501722958},"retail":{"n":512,"mean":0.7838517740887051,"se":0.04603491974545147,"sd":1.0416513255483915},"arb":{"n":512,"mean":-6.979788081301977,"se":0.12656843526471764,"sd":2.863916763515277}},"v2_volume_terciles":[{"n":171,"volume_min":56609.85690614511,"volume_max":69299.74772823698,"deltas":{"total":{"n":171,"mean":-4.952025885798064,"se":0.1860878833863765,"sd":2.43341483489579},"retail":{"n":171,"mean":0.7478829793207249,"se":0.07411429430182954,"sd":0.9691701574005221},"arb":{"n":171,"mean":-5.699908865118803,"se":0.1821920944960004,"sd":2.3824707846602364}}},{"n":171,"volume_min":69452.7064391168,"volume_max":80118.62548945099,"deltas":{"total":{"n":171,"mean":-6.234587669010798,"se":0.1974118767874755,"sd":2.5814952635139257},"retail":{"n":171,"mean":0.7885838019736078,"se":0.07240642261618707,"sd":0.9468368371417721},"arb":{"n":171,"mean":-7.023171470984481,"se":0.2081133281385403,"sd":2.7214348984794507}}},{"n":170,"volume_min":80181.79091172446,"volume_max":97575.07091417206,"deltas":{"total":{"n":170,"mean":-7.408285126005017,"se":0.22765344505032922,"sd":2.968237773049551},"retail":{"n":170,"mean":0.8152722866593302,"se":0.09177387628931158,"sd":1.196584950080101},"arb":{"n":170,"mean":-8.223557412664412,"se":0.22261687223491514,"sd":2.902568897825099}}}],"checks":{"source_hashes_match":true,"harness_tests":{"matchrunner_equal_10000_10031":true,"far_block_len":4,"far_block_seconds":0.0002,"allocation_scales_with_n":true,"far_seed_equals_single":true,"validity_cases":{"cand_oog_equal_v2_valid":true,"cand_oog_less_valid":true,"cand_oog_more_invalid":true,"v2_oog_alone_not_invalid":true,"revert_invalid":true,"ref_revert_invalid":true,"vanilla_oog_invalid":true,"vanilla_other_invalid":true,"incomplete_invalid":true,"counter_mismatch_invalid":true,"reconciliation_threshold_invalid":true,"control_oog_match_valid":true,"control_oog_mismatch_invalid":true},"all_pass":true},"setup":"passed; setup.sh executed once","instrumentation":"supplied patch applied; release rebuilt","validation":"Validating strategy...\nCompiling strategy...\nStrategy 'no_cubic' validated successfully!\nValidating strategy...\nCompiling strategy...\nStrategy 'no_cubic' validated successfully!\nValidating strategy...\nCompiling strategy...\nStrategy 'no_cubic' validated successfully!\nValidating strategy...\nCompiling strategy...\nStrategy 'no_cubic' validated successfully!\nValidating strategy...\nCompiling strategy...\nStrategy 'no_cubic' validated successfully!\n","source_only_changes":"Protecting staleShift assignment after original attractShift computation; gate uses pre-increment firstInStep. No estimator, side selection, boost, clamp, or other fee term changes.","all_training_stages_valid":true,"chunk_max":32,"workers":8,"n_steps":10000,"gas_limit_afterSwap":250000,"runs":"Each strategy separately against Vanilla; V2 screen rows reused. No confirmation runs or seed >=4000000 simulations."},"method":{"paired":"Per-seed candidate total edge minus V2 total edge. Mean and sample-standard-deviation/sqrt(n). Worst lists five smallest paired differences.","decomposition":"Actual engine-exported retail and arb edge deltas; total reconciled to retail+arb for every seed and both roles.","terciles":"Sort by V2 submission retail_volume_y, split with numpy.array_split into three groups. Report paired deltas within each group.","OOG":"Candidate OOG <= V2 OOG; no other submission errors or any Vanilla errors allowed; counters per-seed and global must agree; abs(total-retail-arb)<1e-8.","state":"Only existing observable G state; d is capped staleTox. Attract shift computed before hinge overwrite from original x.","timing":"All stages completed in less than 60 minutes including setup."},"reproducibility":{"generator_python":"from pathlib import Path\nimport sys\n# Usage: python generator.py G.sol K_bps m_wad output.sol\nsrc=Path(sys.argv[1]).read_text(); k=int(sys.argv[2]);m=int(sys.argv[3])\nassert k in (50,150) and m in (500000000000000000,1500000000000000000)\nneedle='            uint256 attractShift = wmul(staleShift, STALE_ATTRACT_FRAC);\\n'\nassert src.count(needle)==1\naddition=f'''            if (firstInStep) {{\n                uint256 hingeK = {k} * BPS;\n                uint256 low = staleTox < hingeK ? staleTox : hingeK;\n                staleShift = wmul(STALE_DIR_COEF, low) + wmul({m}, wmul(STALE_DIR_COEF, staleTox - low));\n            }}\n'''\nPath(sys.argv[4]).write_text(src.replace(needle,needle+addition))\n","generator_usage":"python generator.py G.sol 150 500000000000000000 output.sol","variant_patch":"--- G.sol\n+++ H150_5.sol\n@@ -232,6 +232,11 @@\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 (firstInStep) {\n+                uint256 hingeK = 150 * BPS;\n+                uint256 low = staleTox < hingeK ? staleTox : hingeK;\n+                staleShift = wmul(STALE_DIR_COEF, low) + wmul(500000000000000000, wmul(STALE_DIR_COEF, staleTox - low));\n+            }\n             if (spot >= staleHat) {\n                 bidFee = bidFee + staleShift;\n                 askFee = askFee > attractShift ? askFee - attractShift : 0;\n","training_runner_python":"import json,time,hashlib\nfrom pathlib import Path\nimport harness as h\nfrom amm_competition.evm.baseline import get_vanilla_bytecode_and_abi\nstart=time.time(); vanilla=list(get_vanilla_bytecode_and_abi()[0]); cache={};out={'stages':[]}\ndef measure(name,s0,s1):\n src,bc=h.compile_src('contracts/src/'+name+'.sol')\n r,rows=h.run(name,bc,vanilla,h.build_configs(s0,s1),chunk=32)\n Path(f'scratch/rows_{name}_{s0}.json').write_text(json.dumps({'run':r,'rows':rows}))\n print('DONE',name,s0,r['seconds'],flush=True)\n return r,rows\ndef gas(r):\n g=r['gas']['submission'];return {'max_ok':g['by_callback']['afterSwap']['max_ok_gas'],'init_max':g['by_callback']['afterInitialize']['max_ok_gas'],'oog':g['oog'],'other_errors':g['other_errors']}\ndef compare(name,a,b,s0,s1):\n ra,ea=a;rb,eb=b;seeds=list(range(s0,s1));valid,reasons=h.validity(ra,rb,'ref')\n p=h.paired(ea,eb,seeds,'candidate_minus_V2');p['stage']='tuning'\n def parts(ss):return {k:h.summary([ea[s]['submission'][k]-eb[s]['submission'][k] for s in ss]) for k in ['total','retail','arb']}\n ordered=sorted(seeds,key=lambda s:eb[s]['submission']['retail_volume_y']); groups=[list(x) for x in __import__('numpy').array_split(ordered,3)]\n return {'name':name,'seeds':{'start':s0,'end_inclusive':s1-1},'valid':valid,'invalid_reasons':reasons,'paired':p,'gas':gas(ra),'v2_gas':gas(rb),'edge_deltas':parts(seeds),'v2_volume_terciles':[{'n':len(g),'volume_min':min(eb[s]['submission']['retail_volume_y'] for s in g),'volume_max':max(eb[s]['submission']['retail_volume_y'] for s in g),'deltas':parts(g)} for g in groups],'checks':{'candidate':ra,'reference':rb}}\ndef save():Path('scratch/experiment.json').write_text(json.dumps(out))\nb=measure('V2',10000,10256)\nfor name in ['G','H50_5','H50_15','H150_5','H150_15']:\n a=measure(name,10000,10256);out['stages'].append(compare(name,a,b,10000,10256));save()\nvalid=[s for s in out['stages'] if s['name']!='G' and s['valid']]\nif valid:\n best=max(valid,key=lambda s:s['paired']['mean_diff'])['name'];out['selection']=best;save()\n b=measure('V2',12000,12512);a=measure(best,12000,12512);out['stages'].append(compare(best,a,b,12000,12512));out['freeze']={'name':best,'sha256':hashlib.sha256(Path('contracts/src/'+best+'.sol').read_bytes()).hexdigest()};save()\nprint('FINISHED',time.time()-start,flush=True)\n","instructions":"Clone pinned simulator in scratch. Decode reusable_sources_bundle from source artifact into scratch and V2.sol into contracts/src; save artifact code as contracts/src/G.sol. Run supplied setup.sh once, git apply scratch/instrumentation.patch, then source scratch/env.sh for subsequent commands and rebuild maturin release. Change harness.CHUNK to 32. Run harness tests (replace their configuration-only seed 4000000..4000003 with 20000..20003). Generate the four sources with embedded generator, then run embedded training runner from checkout root. Compile/validate every variant. Sources and exact hashes given above."},"blocked":null,"confirmation":null}