{"item":"b","blocked":null,"valid":true,"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[15] = 400000000000000000 | (uint256(2000000000000000) << 160); 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            // Process variance is propagated inside the censored update.\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        // Censored assumed-density posterior. No external or future inputs.\n        uint256 arbProbability;\n        (fastHat, uncertainty, arbProbability) = _posterior(PosteriorInput(\n            fastHat, uncertainty, pImplied, spot, slots[2] >> 64,\n            prevBidFee, prevAskFee, firstInStep, silent, trade.isBuy,\n            trade.reserveY > 0 ? wdiv(trade.amountY, trade.reserveY) : 0\n        ));\n        slots[13] = uncertainty;\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 originalLambda = lambdaHat; uint256 originalSize = sizeHat;\n\n        if (293474674497324480 > 0) {\n            uint256 packedFlow = slots[15];\n            uint256 rate = uint80(packedFlow);\n            uint256 count = uint80(packedFlow >> 80);\n            uint256 meanSize = uint80(packedFlow >> 160);\n            if (rate == 0) rate = 400000000000000000;\n            if (meanSize == 0) meanSize = 2000000000000000;\n            if (isNewStep) {\n                uint256 inst = count / silent;\n                if (inst > 3 * WAD) inst = 3 * WAD;\n                uint256 retention = _powWad(999000000000000000, silent > 64 ? 64 : silent);\n                rate = wmul(rate, retention) + wmul(inst, WAD-retention);\n                count = 0;\n            }\n            uint256 weight = firstInStep ? WAD-arbProbability : WAD;\n            uint256 correctedWeight = weight;\n            if (2 == 2) {\n                uint256 missing = wmul(feeUsed, 196030880396139429888);\n                if (missing > 333333333333333376) missing = 333333333333333376;\n                correctedWeight = wdiv(weight, WAD-missing);\n            }\n            count += correctedWeight;\n            uint256 learning = wmul(WAD-999000000000000000, weight);\n            meanSize = _blend(meanSize, tradeRatio, learning);\n            slots[15]=rate | (count << 80) | (meanSize << 160);\n            uint256 retailRate = wmul(rate, 359074032908457728);\n            uint256 retailSize = 2 == 0 ? sizeHat : wmul(meanSize,1883296158119298304);\n            lambdaHat = _blend(lambdaHat,retailRate,293474674497324480);\n            sizeHat = _blend(sizeHat,retailSize,293474674497324480);\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        lambdaHat = originalLambda; sizeHat = originalSize;\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 (!firstInStep && tradeBoost > 16 * BPS) tradeBoost = 16 * BPS;\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        if (firstInStep) {\n            if (askFee > bidFee && bidFee > 30 * BPS) bidFee = 30 * BPS;\n            else if (bidFee > askFee && askFee > 30 * BPS) askFee = 30 * BPS;\n        }\n\n        if (bidFee > askFee && askFee > 36 * BPS) askFee = 36 * BPS;\n        else if (askFee > bidFee && bidFee > 36 * BPS) bidFee = 36 * BPS;\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\n    struct PosteriorInput {\n        uint256 mu; uint256 v; uint256 obs; uint256 spot; uint256 preSpot;\n        uint256 bid; uint256 ask; bool first; uint256 silent; bool buy; uint256 size;\n    }\n    function _posterior(PosteriorInput memory x) internal view returns (uint256, uint256, uint256) {\n        if (x.mu == 0) x.mu = x.spot;\n        if (x.v < 10000000000) x.v = 10000000000;\n        uint256 lo = wmul(x.preSpot, WAD-x.bid);\n        uint256 hi = wdiv(x.preSpot, WAD-x.ask);\n        if (x.first) {\n            if (x.silent>1 && x.preSpot>0) {\n                uint256 elapsed=x.silent>8?8:x.silent;\n                x.v += 902500000000*(elapsed-1);\n                (x.mu,x.v)=_band(x.mu,x.v,lo,hi);\n            }\n            x.v+=902500000000;\n        }\n        uint256 mRetail = x.mu;\n        uint256 vRetail = x.v;\n        // A missing own-pool trade is a censored price observation.\n        if (x.first && x.preSpot > 0) {\n            (mRetail, vRetail) = _band(x.mu, x.v, lo, hi);\n        }\n        if (!x.first) {\n            // A later print is retail. Only an interior route is an observation\n            // of the other pool, with explicit observation uncertainty.\n            uint256 fee = x.buy ? x.bid : x.ask;\n            if (fee > 30 * BPS) {\n                uint256 normal = x.buy ? wdiv(wmul(x.spot, WAD-fee), WAD-30*BPS)\n                    : wdiv(wmul(x.spot, WAD-30*BPS), WAD-fee);\n                uint256 residual = wdiv(absDiff(normal, x.mu),x.mu);\n                uint256 noise = 9000000000000 + wmul(residual,residual);\n                uint256 k = wdiv(x.v,x.v+noise);\n                return (_blend(x.mu,normal,k),wmul(x.v,WAD-k),0);\n            }\n            return (x.mu,x.v,0);\n        }\n        uint256 e = wdiv(absDiff(x.obs,x.mu),x.mu);\n        uint256 totalV = x.v + 22500000000;\n        uint256 z = wdiv(wmul(e,e),totalV);\n        uint256 density = _powWad(wdiv(WAD,WAD+z/8),4);\n        uint256 odds = wmul(density,wdiv(4000000000000000,_isqrt(totalV*WAD)));\n        if (x.size > 3000000000000000) odds = wmul(odds,4*WAD/10);\n        if (x.silent > 1) odds = wmul(odds,8*WAD/10);\n        uint256 sd = _isqrt(x.v*WAD);\n        uint256 width = wdiv(hi-lo,x.mu);\n        uint256 distance = x.mu<lo?lo-x.mu:(x.mu>hi?x.mu-hi:0);\n        uint256 zBand = wdiv(wdiv(distance,x.mu),sd);\n        uint256 mass = wmul(wdiv(width,width+2*sd),wdiv(WAD,WAD+wmul(zBand,zBand)));\n        if (mass < WAD/100) mass = WAD/100;\n        odds = wdiv(odds,mass);\n        odds = wmul(odds,787571886707185664);\n        uint256 cleanRate = uint80(slots[15]);\n        if (cleanRate == 0) cleanRate = 400000000000000000;\n        uint256 activityRate = slots[7];\n        if (activityRate < WAD/100) activityRate = WAD/100;\n        uint256 ratio = wdiv(activityRate,cleanRate);\n        if (ratio < WAD/100) ratio = WAD/100;\n        if (ratio > 100*WAD) ratio = 100*WAD;\n        uint256 root = _isqrt(_isqrt(ratio*WAD)*WAD);\n        uint256 factor = _powWad(root,1);\n        odds = wdiv(odds,factor);\n        uint256 prob = wdiv(odds,WAD+odds);\n        uint256 kArb = wdiv(x.v,totalV);\n        uint256 mArb = _blend(x.mu,x.obs,kArb);\n        uint256 mean = _blend(mRetail,mArb,prob);\n        uint256 between = wdiv(absDiff(mArb,mRetail),x.mu);\n        uint256 variance = wmul(prob,wmul(x.v,WAD-kArb)) + wmul(WAD-prob,vRetail)\n            + wmul(wmul(prob,WAD-prob),wmul(between,between));\n        if (variance > 100000000000000) variance = 100000000000000;\n        return (mean,variance,prob);\n    }\n    function _blend(uint256 a,uint256 b,uint256 w) internal pure returns(uint256) {\n        return b>=a ? a+wmul(b-a,w) : a-wmul(a-b,w);\n    }\n    function _band(uint256 mu,uint256 v,uint256 lo,uint256 hi) internal pure returns(uint256,uint256) {\n        // Soft interval likelihood avoids discontinuities at quadrature nodes.\n        uint256 sd=wmul(mu,_isqrt(v*WAD));\n        uint256[3] memory acc;\n        for(uint256 j=0;j<7;j++) {\n            uint256 p=j<3 ? (mu>(3-j)*sd?mu-(3-j)*sd:1) : mu+(j-3)*sd;\n            uint256 w=j==3?72:(j==2||j==4?45:(j==1||j==5?10:1));\n            uint256 distance=p<lo?lo-p:(p>hi?p-hi:0);\n            uint256 z=sd>0?wdiv(distance,sd):0;\n            uint256 likelihood=wdiv(WAD,WAD+4*wmul(z,z));\n            w=wmul(w*WAD,likelihood);\n            acc[0]+=w;acc[1]+=wmul(w,p);\n            uint256 d=wdiv(absDiff(p,mu),mu);\n            acc[2]+=wmul(w,wmul(d,d));\n        }\n        uint256 m=wdiv(acc[1],acc[0]);\n        uint256 d=wdiv(absDiff(m,mu),mu);\n        uint256 second=wdiv(acc[2],acc[0]);\n        return(m,second>wmul(d,d)?second-wmul(d,d):10000000000);\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 \"censored_10\"; }\n}\n","sha256":"39a911c2555cba0e91f1ba83476c41d232ae00933ff688f6e0407e4249ffdd1f","params":{"gamma":-0.25,"prior_scale":0.7875718867071857,"mix":0.29347467449732445,"rate_scale":0.35907403290845774,"rs2_baseline_params_exact":[2,0.3424067991934183,0.999,0.36638342491340714,1.8832961581192982,196.03088039613942,1.5],"effective_rs2_params_exact":[2,0.29347467449732445,0.999,0.35907403290845774,1.8832961581192982,196.03088039613942,1.5],"gamma_quantum":0.25},"mechanism":"V10 has no explicit activity-rate term in its posterior prior. Start from the RS2 seven-parameter generator, then multiply first-print posterior odds by prior_scale * (activity/cleaned_rate)^gamma. activity is the persisted slots[7] activity EMA; cleaned_rate is the persisted low 80-bit rate in RS2 slots[15], before fee rate_scale. Both are lagged estimates available before the current print. Clamp activity to at least 0.01 and the ratio to [0.01,100]; powers use two integer square roots and an integer power, with gamma quantized to quarters in [-2,2]. The adjustment applies where the first-print arb probability is computed, affecting both posterior price/uncertainty and subsequent probability-weighted retail counts. Prior scale 1 and gamma 0 with params_exact reproduce RS2 byte-for-byte.","log":[{"params":[0.25,0.6880047681278513,0.4774880144385807,0.9269599958825706],"sha256":"f46a180753a7c3e68f82e8406a804d429fcf3cde65b6e5edb1710e227c59276e","block":[890000,890063],"n":64,"mean_diff":-0.9470130277759035,"se":0.11249184950510158,"max_ok":203063,"init_max_ok":243099,"oog":0,"other_halts":0,"fitness":-0.9470130277759035},{"params":[-1.5,0.6093461479413045,0.3654180717635297,0.1779028398766321],"sha256":"fa915c61e298f08ada26983d9c3e4e1c98c5ec59725cf602d3997cf529affab1","block":[890000,890063],"n":64,"mean_diff":-0.18107367442917077,"se":0.1347127042202606,"max_ok":203626,"init_max_ok":243099,"oog":0,"other_halts":0,"fitness":-0.18107367442917077},{"params":[0.0,0.744086821727926,0.5006984346687274,0.8299474184290604],"sha256":"03afd456cb57b73f83564246a1896f0caa3fd367eba9268bd550db133b737690","block":[890000,890063],"n":64,"mean_diff":-0.5813004913430708,"se":0.0947112070906999,"max_ok":200234,"init_max_ok":243099,"oog":0,"other_halts":0,"fitness":-0.5813004913430708},{"params":[0.0,1.3381723620904098,0.42655848079878655,0.02],"sha256":"9ea197ee4b9abc5bd6ddb7dccd171ffc5a2531a8990a8ec5a02a85767371f78a","block":[890000,890063],"n":64,"mean_diff":-0.5795769595872686,"se":0.12998770691227718,"max_ok":200234,"init_max_ok":243099,"oog":0,"other_halts":0,"fitness":-0.5795769595872686},{"params":[0.25,0.7123352197513002,0.5005278534287274,0.3366275819656004],"sha256":"0e717dd12844cb07841beef4a2f48819491fd9219077a4f5a57ccaca592f3674","block":[890000,890063],"n":64,"mean_diff":0.11877992472702825,"se":0.11131775716144894,"max_ok":203063,"init_max_ok":243099,"oog":0,"other_halts":0,"fitness":0.11877992472702825},{"params":[-0.25,0.7957211366788175,0.5624642401547437,0.27428385360040103],"sha256":"9f085b0f47a412814a39d49ccf30022e75aed0509101e6e88313e8e7a0754b48","block":[890000,890063],"n":64,"mean_diff":-0.4512290197888804,"se":0.1499675912820562,"max_ok":203115,"init_max_ok":243099,"oog":0,"other_halts":0,"fitness":-0.4512290197888804},{"params":[-0.25,0.894359934853531,0.4382224525930211,0.5841880872743977],"sha256":"540dfe3ffdeca7926f82ef2cc0ca3ee57569bd36dd0239aeb420d882a1f6c314","block":[890000,890063],"n":64,"mean_diff":0.2251302536844486,"se":0.05755867707394384,"max_ok":203115,"init_max_ok":243099,"oog":0,"other_halts":0,"fitness":0.2251302536844486},{"params":[0.25,1.1292463009023648,0.7279033673501014,0.12416007514817623],"sha256":"85b75df3f5a0487e27bd19b3a10aff9fcd90f044932a31328c1a63c77cf2a24b","block":[890000,890063],"n":64,"mean_diff":-5.846813951858946,"se":0.1981249006513963,"max_ok":203063,"init_max_ok":243099,"oog":0,"other_halts":0,"fitness":-5.846813951858946},{"params":[-0.5,0.7558681815256366,0.4532830952570075,1.0392509113750585],"sha256":"0e7ff656e217b782cedee17d03689791b213767f853a0e38beaf468d74564a14","block":[890000,890063],"n":64,"mean_diff":-1.4615347858052186,"se":0.12094216964948072,"max_ok":203312,"init_max_ok":243099,"oog":0,"other_halts":0,"fitness":-1.4615347858052186},{"params":[0.0,0.7479530569112416,0.1940001803689952,0.754136726456929],"sha256":"d4f54be15f91879275c05c41a4c2437e676a5001b54848db31df34430961938f","block":[890000,890063],"n":64,"mean_diff":0.05978611158856495,"se":0.05401628790278742,"max_ok":200234,"init_max_ok":243099,"oog":0,"other_halts":0,"fitness":0.05978611158856495},{"params":[0.25,0.772722803681243,0.48915780793586533,0.9242752606156572],"sha256":"be4b22266146d08bad56d0116752595cf13ad347fd8e3d0bb37ec3e901c80521","block":[890064,890127],"n":64,"mean_diff":-0.7229291640092272,"se":0.1380187007264623,"max_ok":202742,"init_max_ok":243099,"oog":0,"other_halts":0,"fitness":-0.7229291640092272},{"params":[-0.5,0.7200997763487282,0.32346591954461007,0.6898346842974976],"sha256":"abe3bc00a54d12e866f4cdbe31283923fb27b67ccad45b540c6623a64fea4672","block":[890064,890127],"n":64,"mean_diff":0.07665990477156637,"se":0.07578390376935394,"max_ok":203147,"init_max_ok":243099,"oog":0,"other_halts":0,"fitness":0.07665990477156637},{"params":[-0.5,0.7187909030713286,0.449727017078387,0.9081195235926726],"sha256":"58e528c018ff529e17483c43001b6f91b25847704e79493cb0449033ff734131","block":[890064,890127],"n":64,"mean_diff":-0.6932512845797207,"se":0.1284995683347688,"max_ok":203151,"init_max_ok":243099,"oog":0,"other_halts":0,"fitness":-0.6932512845797207},{"params":[0.25,0.8192864717487212,0.3843897456262547,0.02],"sha256":"5ffc00edd9ab6b0be794b2ac41da384c09af3d928018f80c37b29c7f0d052f16","block":[890064,890127],"n":64,"mean_diff":-0.4447023366132763,"se":0.10976467847390291,"max_ok":200083,"init_max_ok":243099,"oog":0,"other_halts":0,"fitness":-0.4447023366132763},{"params":[0.5,0.5,0.45952650897961445,0.7609087819068202],"sha256":"37257313768b06188ee0b4962884a9adb1f844d0ba885cf221055523101acf1a","block":[890064,890127],"n":64,"mean_diff":-0.24321960981572488,"se":0.1019157168451566,"max_ok":203092,"init_max_ok":243099,"oog":0,"other_halts":0,"fitness":-0.24321960981572488},{"params":[-0.5,0.5208814036932271,0.40330798239442817,0.02],"sha256":"ae3bff878a0d2847feda8115da1295a207a2a2900cd733d7b0e2228de691de27","block":[890064,890127],"n":64,"mean_diff":-1.20098607838466,"se":0.13797049825168436,"max_ok":200332,"init_max_ok":243099,"oog":0,"other_halts":0,"fitness":-1.20098607838466},{"params":[0.25,0.8864596667614228,0.3815388876542414,0.9057076715820103],"sha256":"b26ed7fe9675cdaa0b9af439510417b7f187f20bff3214a1f0a40dd41b68f71d","block":[890064,890127],"n":64,"mean_diff":-0.42460618320900956,"se":0.10614718535110915,"max_ok":202774,"init_max_ok":243099,"oog":0,"other_halts":0,"fitness":-0.42460618320900956},{"params":[0.5,1.1750316769536213,0.5086083592925205,0.6087618772594627],"sha256":"6f598f70a6c7cfd91132092f29ed6c87cd484eead053981bd0528366ff0d7ab7","block":[890064,890127],"n":64,"mean_diff":0.13349872908922666,"se":0.07311582850099467,"max_ok":200274,"init_max_ok":243099,"oog":0,"other_halts":0,"fitness":0.13349872908922666},{"params":[-0.25,0.5,0.3796506968608451,0.3019020943106917],"sha256":"4cf9e845ecabb722fceff12439e4455954b59ad314492e2c644c5a4c026179f2","block":[890064,890127],"n":64,"mean_diff":0.030595501461472274,"se":0.09346923281562573,"max_ok":200135,"init_max_ok":243099,"oog":0,"other_halts":0,"fitness":0.030595501461472274},{"params":[-0.25,0.7875718867071857,0.29347467449732445,0.35907403290845774],"sha256":"39a911c2555cba0e91f1ba83476c41d232ae00933ff688f6e0407e4249ffdd1f","block":[890064,890127],"n":64,"mean_diff":0.2863394533462351,"se":0.06359892227820844,"max_ok":200135,"init_max_ok":243099,"oog":0,"other_halts":0,"fitness":0.2863394533462351},{"params":[-0.25,0.9946053418840726,0.4124334770288971,0.6298939726502235],"sha256":"5ca4553484d4c9b86236c55d46d1ba5c25637a005a6c5ecf5cd7f8c9068a9528","block":[890128,890191],"n":64,"mean_diff":0.04055105550882665,"se":0.05592784583567296,"max_ok":203103,"init_max_ok":243099,"oog":0,"other_halts":0,"fitness":0.04055105550882665},{"params":[0.25,0.7712242616399663,0.42232786520070476,0.11037181406411917],"sha256":"8f7af4992f4c952de046bb13f375a011892fa92e9f43787b40a02d7da4510082","block":[890128,890191],"n":64,"mean_diff":-0.8421643851554981,"se":0.10276298049737907,"max_ok":203051,"init_max_ok":243099,"oog":0,"other_halts":0,"fitness":-0.8421643851554981},{"params":[0.0,0.8348457392873792,0.26983570024529757,0.6184501475591607],"sha256":"0c962799adb487309eb549d119d6c8fcfa16139d8295aa4b57d7f6cfb3980120","block":[890128,890191],"n":64,"mean_diff":0.07484612321189221,"se":0.06017306658529837,"max_ok":200222,"init_max_ok":243099,"oog":0,"other_halts":0,"fitness":0.07484612321189221}],"recheck":{"seeds":[894000,894255],"selection":"Top three distinct valid search hashes by observed paired mean vs V10; frozen winner is highest valid recheck paired mean. No held-out data used for selection.","evaluations":[{"params":[-0.25,0.7875718867071857,0.29347467449732445,0.35907403290845774],"sha256":"39a911c2555cba0e91f1ba83476c41d232ae00933ff688f6e0407e4249ffdd1f","paired":{"n":256,"mean_diff":0.18545525775614968,"se":0.033267437801279776,"worst":[{"seed":894186,"d":-1.6047693533951133},{"seed":894167,"d":-1.2474800188429072},{"seed":894010,"d":-1.0650577558644727},{"seed":894035,"d":-1.0146892854947964},{"seed":894250,"d":-0.6459237510252365}]},"retail_edge_delta":{"mean":1.512996972827656,"se":0.03746199396459578},"arb_edge_delta":{"mean":-1.3275417150715003,"se":0.016131363646729763},"reconciliation_max_abs":1.0658141036401503e-13,"gas":{"max_ok":203196,"init_max_ok":243099,"oog":0,"other_halts":0},"valid":true},{"params":[-0.25,0.894359934853531,0.4382224525930211,0.5841880872743977],"sha256":"540dfe3ffdeca7926f82ef2cc0ca3ee57569bd36dd0239aeb420d882a1f6c314","paired":{"n":256,"mean_diff":0.1254297966666451,"se":0.033248223102395585,"worst":[{"seed":894010,"d":-1.208975388584122},{"seed":894035,"d":-1.0934206385525158},{"seed":894160,"d":-0.9865161467279222},{"seed":894206,"d":-0.9154834296087984},{"seed":894079,"d":-0.8824571240228352}]},"retail_edge_delta":{"mean":0.7708809622718058,"se":0.03517246680667249},"arb_edge_delta":{"mean":-0.6454511656051583,"se":0.015218907039153262},"reconciliation_max_abs":1.1368683772161603e-13,"gas":{"max_ok":203196,"init_max_ok":243099,"oog":0,"other_halts":0},"valid":true},{"params":[0.5,1.1750316769536213,0.5086083592925205,0.6087618772594627],"sha256":"6f598f70a6c7cfd91132092f29ed6c87cd484eead053981bd0528366ff0d7ab7","paired":{"n":256,"mean_diff":0.05286564492101875,"se":0.0392431454594157,"worst":[{"seed":894010,"d":-1.743139572184191},{"seed":894160,"d":-1.2860652733306779},{"seed":894149,"d":-1.2039809232928746},{"seed":894063,"d":-1.0927810924217738},{"seed":894251,"d":-0.9818968121201124}]},"retail_edge_delta":{"mean":0.6930219686217136,"se":0.04052888895478382},"arb_edge_delta":{"mean":-0.6401563237006922,"se":0.01682336036759612},"reconciliation_max_abs":9.947598300641403e-14,"gas":{"max_ok":203335,"init_max_ok":243099,"oog":0,"other_halts":0},"valid":true}]},"held_out":{"seeds":[895000,895511],"vs_v10":{"n":512,"mean_diff":0.17969227143652955,"se":0.025265042842170193,"worst":[{"seed":895504,"d":-2.2766503559948887},{"seed":895020,"d":-1.6513466589162817},{"seed":895225,"d":-1.5572032052335771},{"seed":895274,"d":-1.3950292224351415},{"seed":895375,"d":-1.245128742947145}]},"vs_rs2":{"n":512,"mean_diff":-0.010763191468042166,"se":0.014982506067758446,"worst":[{"seed":895197,"d":-1.3332915155755245},{"seed":895441,"d":-1.2667564856352556},{"seed":895164,"d":-1.2463102661506582},{"seed":895278,"d":-1.063844666790601},{"seed":895108,"d":-0.9911174085369794}]},"retail_edge_delta":{"vs_v10":{"mean":1.5270905599994906,"se":0.026392284191164298},"vs_rs2":{"mean":-0.0028066975566328756,"se":0.014796682850387719}},"arb_edge_delta":{"vs_v10":{"mean":-1.3473982885629627,"se":0.011292131659461758},"vs_rs2":{"mean":-0.007956493911409776,"se":0.0067096103888780526}},"arm_gas":{"frozen":{"max_ok":206066,"init_max_ok":243099,"oog":0,"other_halts":0,"raw":[{"role":"Baseline","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},{"role":"Baseline","callback":"afterSwap","calls":5525485,"ok":5525485,"max_ok_gas":22592,"sum_ok_gas":124671190568,"oog":0,"revert":0,"other_halt":0,"tx_error":0,"bad_return":0},{"role":"Baseline","callback":"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},{"role":"Submission","callback":"afterInitialize","calls":512,"ok":512,"max_ok_gas":243099,"sum_ok_gas":124466688,"oog":0,"revert":0,"other_halt":0,"tx_error":0,"bad_return":0},{"role":"Submission","callback":"afterSwap","calls":5338122,"ok":5338122,"max_ok_gas":206066,"sum_ok_gas":638711393826,"oog":0,"revert":0,"other_halt":0,"tx_error":0,"bad_return":0},{"role":"Submission","callback":"getName","calls":512,"ok":512,"max_ok_gas":21607,"sum_ok_gas":11062784,"oog":0,"revert":0,"other_halt":0,"tx_error":0,"bad_return":0}]},"rs2":{"max_ok":203115,"init_max_ok":243099,"oog":0,"other_halts":0,"raw":[{"role":"Baseline","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},{"role":"Baseline","callback":"afterSwap","calls":5525394,"ok":5525394,"max_ok_gas":22592,"sum_ok_gas":124669177284,"oog":0,"revert":0,"other_halt":0,"tx_error":0,"bad_return":0},{"role":"Baseline","callback":"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},{"role":"Submission","callback":"afterInitialize","calls":512,"ok":512,"max_ok_gas":243099,"sum_ok_gas":124466688,"oog":0,"revert":0,"other_halt":0,"tx_error":0,"bad_return":0},{"role":"Submission","callback":"afterSwap","calls":5337245,"ok":5337245,"max_ok_gas":203115,"sum_ok_gas":628057955811,"oog":0,"revert":0,"other_halt":0,"tx_error":0,"bad_return":0},{"role":"Submission","callback":"getName","calls":512,"ok":512,"max_ok_gas":21607,"sum_ok_gas":11062784,"oog":0,"revert":0,"other_halt":0,"tx_error":0,"bad_return":0}]},"v10":{"max_ok":195380,"init_max_ok":220981,"oog":0,"other_halts":0,"raw":[{"role":"Baseline","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},{"role":"Baseline","callback":"afterSwap","calls":5539917,"ok":5539917,"max_ok_gas":22592,"sum_ok_gas":124997072820,"oog":0,"revert":0,"other_halt":0,"tx_error":0,"bad_return":0},{"role":"Baseline","callback":"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},{"role":"Submission","callback":"afterInitialize","calls":512,"ok":512,"max_ok_gas":220981,"sum_ok_gas":113142272,"oog":0,"revert":0,"other_halt":0,"tx_error":0,"bad_return":0},{"role":"Submission","callback":"afterSwap","calls":5266129,"ok":5266129,"max_ok_gas":195380,"sum_ok_gas":582415813486,"oog":0,"revert":0,"other_halt":0,"tx_error":0,"bad_return":0},{"role":"Submission","callback":"getName","calls":512,"ok":512,"max_ok_gas":21594,"sum_ok_gas":11056128,"oog":0,"revert":0,"other_halt":0,"tx_error":0,"bad_return":0}]}}},"gas":{"max_ok":206066,"init_max_ok":243099,"oog":0,"other_halts":0,"scope":"Corrected search candidate evaluations, three candidate rechecks, and all three held-out arms; calibration and pre-search diagnostics excluded."},"generator_source":"def generate6(base,p):\n kind,mix,decay,scale,sscale,correction=p\n mix=int(mix*1e18);decay=int(decay*1e18)\n s=base.replace('(fastHat, uncertainty) = _posterior','uint256 arbProbability;\\n        (fastHat, uncertainty, arbProbability) = _posterior')\n s=s.replace('internal pure returns (uint256, uint256) {\\n        if (x.mu', 'internal pure returns (uint256, uint256, uint256) {\\n        if (x.mu')\n s=s.replace('wmul(x.v,WAD-k));','wmul(x.v,WAD-k),0);').replace('return (x.mu,x.v);','return (x.mu,x.v,0);').replace('return (mean,variance);','return (mean,variance,prob);')\n insert=f'''\n        if ({mix} > 0) {{\n            uint256 packedFlow = slots[15];\n            uint256 rate = uint80(packedFlow);\n            uint256 count = uint80(packedFlow >> 80);\n            uint256 meanSize = uint80(packedFlow >> 160);\n            if (rate == 0) rate = 400000000000000000;\n            if (meanSize == 0) meanSize = 2000000000000000;\n            if (isNewStep) {{\n                uint256 inst = count / silent;\n                if (inst > 3 * WAD) inst = 3 * WAD;\n                uint256 retention = _powWad({decay}, silent > 64 ? 64 : silent);\n                rate = wmul(rate, retention) + wmul(inst, WAD-retention);\n                count = 0;\n            }}\n            uint256 weight = firstInStep ? WAD-arbProbability : WAD;\n            uint256 correctedWeight = weight;\n            if ({kind} == 2) {{\n                uint256 missing = wmul(feeUsed, {int(correction*1e18)});\n                if (missing > WAD/2) missing = WAD/2;\n                correctedWeight = wdiv(weight, WAD-missing);\n            }}\n            count += correctedWeight;\n            uint256 learning = wmul(WAD-{decay}, weight);\n            meanSize = _blend(meanSize, tradeRatio, learning);\n            slots[15]=rate | (count << 80) | (meanSize << 160);\n            uint256 retailRate = wmul(rate, {int(scale*1e18)});\n            uint256 retailSize = {kind} == 0 ? sizeHat : wmul(meanSize,{int(sscale*1e18)});\n            lambdaHat = _blend(lambdaHat,retailRate,{mix});\n            sizeHat = _blend(sizeHat,retailSize,{mix});\n        }}\n'''\n s=s.replace('        uint256 flowSize =', '        uint256 originalLambda = lambdaHat; uint256 originalSize = sizeHat;\\n'+insert+'        uint256 flowSize =')\n s=s.replace('        uint256 dirDev;', '        lambdaHat = originalLambda; sizeHat = originalSize;\\n        uint256 dirDev;')\n s=s.replace(\"slots[13] = 902500000000;\", \"slots[15] = 400000000000000000 | (uint256(2000000000000000) << 160); slots[13] = 902500000000;\") if mix else s\n return s\n\n# --- cap extension (7th parameter); cap==2.0 reproduces RS1 byte-for-byte ---\ndef generate7(base,p):\n    p=list(p); kind=int(round(p[0])); cap=float(p[6]) if len(p)>6 else 2.0\n    s=generate6(base,[kind]+[float(x) for x in p[1:6]])\n    if cap!=2.0:\n        old='if (missing > WAD/2) missing = WAD/2;'\n        assert old in s or float(p[1])==0\n        m=int((1-1/cap)*1e18)\n        s=s.replace(old,f'if (missing > {m}) missing = {m};')\n    return s\n\nEXACT=[2, 0.3424067991934183, 0.999, 0.36638342491340714, 1.8832961581192982, 196.03088039613942, 1.5]\ndef generate(base,p):\n    # p = gamma, prior_scale, flow_mix, rate_scale. All remaining RS2 parameters fixed.\n    gamma,prior,mix,rate_scale=map(float,p)\n    q=EXACT.copy();q[1]=mix;q[3]=rate_scale\n    s=generate7(base,q)\n    if gamma==0 and prior==1:return s\n    s=s.replace('function _posterior(PosteriorInput memory x) internal pure','function _posterior(PosteriorInput memory x) internal view')\n    # Quarter-power quantization gives a deterministic bounded-cost power family.\n    ticks=int(round(abs(gamma)*4))\n    adjustment=f'        odds = wmul(odds,{int(prior*1e18)});\\n'\n    if ticks:\n        adjustment+='''        uint256 cleanRate = uint80(slots[15]);\n        if (cleanRate == 0) cleanRate = 400000000000000000;\n        uint256 activityRate = slots[7];\n        if (activityRate < WAD/100) activityRate = WAD/100;\n        uint256 ratio = wdiv(activityRate,cleanRate);\n        if (ratio < WAD/100) ratio = WAD/100;\n        if (ratio > 100*WAD) ratio = 100*WAD;\n        uint256 root = _isqrt(_isqrt(ratio*WAD)*WAD);\n'''\n        adjustment+=f'        uint256 factor = _powWad(root,{ticks});\\n'\n        adjustment+='        odds = '+('wmul' if gamma>0 else 'wdiv')+'(odds,factor);\\n'\n    s=s.replace('        uint256 prob = wdiv(odds,WAD+odds);',adjustment+'        uint256 prob = wdiv(odds,WAD+odds);')\n    return s\n","notes":{"protocol":"Each arm alone against VanillaStrategy; amm_sim_rs.run_batch(bytecode, VanillaStrategy, configs, 8), 10000 steps. Configs follow supplied V10 harness; numpy default_rng(seed) draws size U(19,21), rate U(.6,1), sigma U(.000882,.001008), with price seed=seed and retail seed=seed+1. Gas counters reset/captured in chunks of 20.","search":"Numpy CMA-ES default_rng(42), population 10, mu 5, sigma0 .2, unit-box clipping, initial normalized mean [0.5, 1/3, RS2_mix/0.9, (RS2_rate_scale-0.02)/2.98], four dimensions (gamma, prior_scale, mix, rate_scale), ranges [-2,2], [.5,2], [0,.9], [.02,3]. A fresh 64-seed block for each generation shared by all candidates and separately simulated V10; 25-minute wall-clock stop, allowing in-flight evaluation completion. Any halt or afterSwap >=235000 or afterInitialize >=245000 gives -1000.","calibration":{"source":"CH at d34a5199c59a4c44d5336a25f1436b4ae1f21104","seeds":[0,999],"n":1000,"mean_edge":525.5258821780834,"expected_mean":525.5258821780834,"gas":{"max_ok":151647,"init_max_ok":185532,"oog":0,"other_halts":0,"raw":[{"role":"Baseline","callback":"afterInitialize","calls":1000,"ok":1000,"max_ok_gas":21796,"sum_ok_gas":21796000,"oog":0,"revert":0,"other_halt":0,"tx_error":0,"bad_return":0},{"role":"Baseline","callback":"afterSwap","calls":10741746,"ok":10741746,"max_ok_gas":22592,"sum_ok_gas":242365461576,"oog":0,"revert":0,"other_halt":0,"tx_error":0,"bad_return":0},{"role":"Baseline","callback":"getName","calls":1000,"ok":1000,"max_ok_gas":21526,"sum_ok_gas":21526000,"oog":0,"revert":0,"other_halt":0,"tx_error":0,"bad_return":0},{"role":"Submission","callback":"afterInitialize","calls":1000,"ok":1000,"max_ok_gas":185532,"sum_ok_gas":185532000,"oog":0,"revert":0,"other_halt":0,"tx_error":0,"bad_return":0},{"role":"Submission","callback":"afterSwap","calls":10445223,"ok":10445223,"max_ok_gas":151647,"sum_ok_gas":811927105393,"oog":0,"revert":0,"other_halt":0,"tx_error":0,"bad_return":0},{"role":"Submission","callback":"getName","calls":1000,"ok":1000,"max_ok_gas":21530,"sum_ok_gas":21530000,"oog":0,"revert":0,"other_halt":0,"tx_error":0,"bad_return":0}]}},"hash_checks":{"RS2":"f24b6ca198b744c380842c3a17964a6dc21f311bb04984b26733afa3fee8eaf2","V10":"cd9bdb45ab0537ad25c4fd90ca8618898cef6386de3df65f192eaef65fbca245","neutral_reproduction":true},"uncertainty":"SE = sample standard deviation (ddof=1) divided by sqrt(n); worst contains the five smallest seed-paired edge differences.","decomposition":"Supplied V10 harness reconstructs arbitrage loss from preceding reserves and fees against current fair price; retail edge is total edge minus arb edge. Reconciliation checked per seed.","pre_search":"One unscored gas-schema diagnostic on seed 889999, plus an aborted search attempt on 890000..890063; the latter was restarted unchanged after fixing role capitalization in gas parsing. Only corrected scored evaluations appear in log. This replay is a disclosed departure from fresh-only initial search setup, with no parameter changes or selection based on the aborted attempt.","validation":{"command":"amm-match validate scratch/frozen.sol","exit_code":0,"output":"Validating strategy...\nCompiling strategy...\nStrategy 'censored_10' validated successfully!\n"},"interpretation":"Held-out results do not demonstrate an improvement over RS2. The frozen candidate is returned as the tested search winner; no board performance is inferred.","board_claim":false}}