{"blocked":null,"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 = uint8(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] = (slots[12] & ~uint256(255)) | (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\n        // Dual anchor: later own prints are retail; high fees ensure interior routing.\n        // Packed slot 12: low 8 bits retain RS2 direction, next 128 price, next 64 time.\n        uint256 anchorState = slots[12];\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            anchorState = uint8(anchorState) | (uint256(uint128(normalSpot)) << 8)\n                | (uint256(uint64(trade.timestamp)) << 136);\n            slots[12] = anchorState;\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 (342406799193418304 > 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, 366383424913407168);\n            uint256 retailSize = 2 == 0 ? sizeHat : wmul(meanSize,1883296158119298304);\n            lambdaHat = _blend(lambdaHat,retailRate,342406799193418304);\n            sizeHat = _blend(sizeHat,retailSize,342406799193418304);\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            staleHat = _dualClamp(staleHat, anchorState, trade.timestamp, sigmaHat);\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\n    function _dualClamp(uint256 estimate, uint256 state, uint256 nowTs, uint256 sigma)\n        internal pure returns (uint256) {\n        uint256 center = uint128(state >> 8);\n        if (center == 0) return estimate;\n        uint256 age = nowTs - uint64(state >> 136);\n        uint256 width = 30 * BPS + wmul(2000000000000000000, sigma) * age;\n        if (width >= WAD) return estimate;\n        uint256 lo = wmul(center, WAD - width);\n        uint256 hi = wdiv(center, WAD - width);\n        uint256 target = estimate < lo ? lo : (estimate > hi ? hi : estimate);\n        return _blend(estimate, target, 125000000000000000);\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 pure 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        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":"9faa3bed57343f00c5bde9f0baf59e0f9edc41bfe50a2bd66760a0a22989c511","params":{"w":0.125,"k":2.0,"variant":"stale"},"mechanism":"Infer Vanilla's post-retail spot by equating fee-adjusted marginal prices on identifiable later own fills with fee above 30 bps, and retain that anchor in packed slot 12. Pull the selected RS2 estimate toward its 30 bp interval with weight w, widening the relative band by k*sigmaHat for each elapsed step; w=0 emits unmodified RS2.","source":{"url":"https://benedict.dev/optimization-arena-learnings","quote":"EMA, dual anchor, or virtual reserves"},"baseline_sources":{"RS2":{"url":"https://api.imdnotdead.fun/artifacts/19f2ec857df536e8ab62ab1da89ec6623332521ce46849f15bccff402c63e1e5","sha256":"f24b6ca198b744c380842c3a17964a6dc21f311bb04984b26733afa3fee8eaf2"},"harness":"https://api.imdnotdead.fun/artifacts/33f54e81f3372088e9eced52c0174f310ac348af98ef5727b73785c088679194","STACK":"https://api.imdnotdead.fun/artifacts/c33720874aa1285e9dc766540b8a90410118a8e8b840d949ea0dcc211bdb27c1"},"search":{"evaluations":33,"neutral_evaluations":1,"seconds":1528.4274330860935,"budget_seconds":1500,"seed":84,"method":"Shuffled discrete grid with fixed warm-up, default_rng(84), w={0.125,0.25,0.5,0.75,1}, k={0,0.25,0.5,1,2,4,8}, variant={fast,slow,stale}; first warm-up (w,k)=(1,1),(0.5,0),(1,0), each across all variants. Neutral w=0 is source-identical RS2 and is checked separately. Timer includes compilation and paired-baseline costs, stops between whole 64-seed evaluations.","blocks":"975000+64*floor((evaluation-1)/15); RS2 cached once per block, candidates run separately versus VanillaStrategy, never against RS2 in one market.","best":{"evaluation":33,"params":{"w":0.125,"k":2.0,"variant":"stale"},"start":975128,"n":64,"paired":{"n":64,"mean_diff":-0.2784419719485358,"se":0.054839829357068944,"worst":[{"seed":975154,"d":-2.372513540471118},{"seed":975183,"d":-1.5751402196248705},{"seed":975149,"d":-1.0197702489961102},{"seed":975162,"d":-0.950963702540605},{"seed":975160,"d":-0.8585026382733076}]},"gas":{"max_ok":200261,"init_max_ok":243106,"oog":0,"other_halts":0},"valid":true,"seconds":1528.4227832520846,"sha256":"9faa3bed57343f00c5bde9f0baf59e0f9edc41bfe50a2bd66760a0a22989c511"},"best_including_neutral":{"params":{"w":0,"k":0,"variant":"fast"},"mean_diff":0.0,"se":0.0,"code":"unchanged RS2"},"neutral":{"w":0,"mean_diff":0.0,"se":0.0},"variant_best":{"fast":{"evaluation":27,"params":{"w":0.25,"k":4.0,"variant":"fast"},"start":975064,"n":64,"paired":{"n":64,"mean_diff":-0.8326810334257457,"se":0.12573551206063707,"worst":[{"seed":975109,"d":-3.8305729314583914},{"seed":975117,"d":-3.5374313469620233},{"seed":975107,"d":-3.17665661355295},{"seed":975086,"d":-3.1663137549420526},{"seed":975126,"d":-3.037205058981499}]},"gas":{"max_ok":203404,"init_max_ok":243090,"oog":0,"other_halts":0},"valid":true,"seconds":1245.696750447154,"sha256":"a93c4d475ec1c3fe5e492c1b6dc13d68e52d50203980b2fa8ed9a6b585661f1e"},"slow":{"evaluation":32,"params":{"w":0.125,"k":4.0,"variant":"slow"},"start":975128,"n":64,"paired":{"n":64,"mean_diff":-0.4249502161764207,"se":0.08432199954127918,"worst":[{"seed":975185,"d":-3.8884999090922747},{"seed":975183,"d":-2.326025048442034},{"seed":975154,"d":-2.091108319196451},{"seed":975149,"d":-1.3036615025197307},{"seed":975136,"d":-1.2562834779099603}]},"gas":{"max_ok":200092,"init_max_ok":243081,"oog":0,"other_halts":0},"valid":true,"seconds":1485.9776309451554,"sha256":"38b13b6ecccf672020f82ccefbf9ba72672a006dc8fdf41b73ce363191d23e67"},"stale":{"evaluation":33,"params":{"w":0.125,"k":2.0,"variant":"stale"},"start":975128,"n":64,"paired":{"n":64,"mean_diff":-0.2784419719485358,"se":0.054839829357068944,"worst":[{"seed":975154,"d":-2.372513540471118},{"seed":975183,"d":-1.5751402196248705},{"seed":975149,"d":-1.0197702489961102},{"seed":975162,"d":-0.950963702540605},{"seed":975160,"d":-0.8585026382733076}]},"gas":{"max_ok":200261,"init_max_ok":243106,"oog":0,"other_halts":0},"valid":true,"seconds":1528.4227832520846,"sha256":"9faa3bed57343f00c5bde9f0baf59e0f9edc41bfe50a2bd66760a0a22989c511"}},"evaluated":[{"evaluation":1,"params":{"w":1.0,"k":1.0,"variant":"fast"},"start":975000,"n":64,"mean_diff":-3.4274298526133915,"se":0.364084247390478,"valid":true,"gas":{"max_ok":192664,"init_max_ok":243090,"oog":0,"other_halts":0}},{"evaluation":2,"params":{"w":1.0,"k":1.0,"variant":"slow"},"start":975000,"n":64,"mean_diff":-14.371824368751508,"se":1.4484481305013375,"valid":true,"gas":{"max_ok":192606,"init_max_ok":243081,"oog":0,"other_halts":0}},{"evaluation":3,"params":{"w":1.0,"k":1.0,"variant":"stale"},"start":975000,"n":64,"mean_diff":-22.673636262575755,"se":2.1519586389301706,"valid":true,"gas":{"max_ok":192769,"init_max_ok":243106,"oog":0,"other_halts":0}},{"evaluation":4,"params":{"w":0.5,"k":0.0,"variant":"fast"},"start":975000,"n":64,"mean_diff":-3.9132329565611554,"se":0.49104875547001503,"valid":true,"gas":{"max_ok":192664,"init_max_ok":243090,"oog":0,"other_halts":0}},{"evaluation":5,"params":{"w":0.5,"k":0.0,"variant":"slow"},"start":975000,"n":64,"mean_diff":-53.4252485450205,"se":5.592176898958883,"valid":true,"gas":{"max_ok":200189,"init_max_ok":243081,"oog":0,"other_halts":0}},{"evaluation":6,"params":{"w":0.5,"k":0.0,"variant":"stale"},"start":975000,"n":64,"mean_diff":-23.42837643935948,"se":3.1838446593088823,"valid":true,"gas":{"max_ok":192769,"init_max_ok":243106,"oog":0,"other_halts":0}},{"evaluation":7,"params":{"w":1.0,"k":0.0,"variant":"fast"},"start":975000,"n":64,"mean_diff":-6.251091218287972,"se":0.6836151657321801,"valid":true,"gas":{"max_ok":192664,"init_max_ok":243090,"oog":0,"other_halts":0}},{"evaluation":8,"params":{"w":1.0,"k":0.0,"variant":"slow"},"start":975000,"n":64,"mean_diff":-132.40743712684537,"se":9.348081554137313,"valid":true,"gas":{"max_ok":201767,"init_max_ok":243081,"oog":0,"other_halts":0}},{"evaluation":9,"params":{"w":1.0,"k":0.0,"variant":"stale"},"start":975000,"n":64,"mean_diff":-149.2350595619765,"se":8.855022270587774,"valid":true,"gas":{"max_ok":202248,"init_max_ok":243106,"oog":0,"other_halts":0}},{"evaluation":10,"params":{"w":0.5,"k":1.0,"variant":"fast"},"start":975000,"n":64,"mean_diff":-2.023515222356407,"se":0.2607015036654593,"valid":true,"gas":{"max_ok":192664,"init_max_ok":243090,"oog":0,"other_halts":0}},{"evaluation":11,"params":{"w":0.5,"k":0.25,"variant":"slow"},"start":975000,"n":64,"mean_diff":-8.874454250331059,"se":1.0279915687865473,"valid":true,"gas":{"max_ok":192606,"init_max_ok":243081,"oog":0,"other_halts":0}},{"evaluation":12,"params":{"w":0.75,"k":0.5,"variant":"stale"},"start":975000,"n":64,"mean_diff":-14.707968213260218,"se":1.2899657287578847,"valid":true,"gas":{"max_ok":192769,"init_max_ok":243106,"oog":0,"other_halts":0}},{"evaluation":13,"params":{"w":0.75,"k":2.0,"variant":"stale"},"start":975000,"n":64,"mean_diff":-11.64564096579213,"se":1.1525007012033968,"valid":true,"gas":{"max_ok":192769,"init_max_ok":243106,"oog":0,"other_halts":0}},{"evaluation":14,"params":{"w":1.0,"k":4.0,"variant":"fast"},"start":975000,"n":64,"mean_diff":-3.4136215246993507,"se":0.3638633292779144,"valid":true,"gas":{"max_ok":192664,"init_max_ok":243090,"oog":0,"other_halts":0}},{"evaluation":15,"params":{"w":0.75,"k":8.0,"variant":"fast"},"start":975000,"n":64,"mean_diff":-2.4881752111739397,"se":0.33519681164619897,"valid":true,"gas":{"max_ok":192664,"init_max_ok":243090,"oog":0,"other_halts":0}},{"evaluation":16,"params":{"w":0.75,"k":0.0,"variant":"fast"},"start":975064,"n":64,"mean_diff":-4.546296788006464,"se":0.4085627617383423,"valid":true,"gas":{"max_ok":203142,"init_max_ok":243090,"oog":0,"other_halts":0}},{"evaluation":17,"params":{"w":0.5,"k":4.0,"variant":"stale"},"start":975064,"n":64,"mean_diff":-3.832900316722748,"se":0.31237434938377256,"valid":true,"gas":{"max_ok":203553,"init_max_ok":243106,"oog":0,"other_halts":0}},{"evaluation":18,"params":{"w":1.0,"k":0.25,"variant":"slow"},"start":975064,"n":64,"mean_diff":-15.522674382918792,"se":1.3406666797310607,"valid":true,"gas":{"max_ok":203373,"init_max_ok":243081,"oog":0,"other_halts":0}},{"evaluation":19,"params":{"w":1.0,"k":0.5,"variant":"fast"},"start":975064,"n":64,"mean_diff":-3.617613538380696,"se":0.3781636047170099,"valid":true,"gas":{"max_ok":203437,"init_max_ok":243090,"oog":0,"other_halts":0}},{"evaluation":20,"params":{"w":0.75,"k":0.0,"variant":"stale"},"start":975064,"n":64,"mean_diff":-80.10945122421158,"se":6.678237886154585,"valid":true,"gas":{"max_ok":198005,"init_max_ok":243106,"oog":0,"other_halts":0}},{"evaluation":21,"params":{"w":1.0,"k":2.0,"variant":"stale"},"start":975064,"n":64,"mean_diff":-22.843180370604774,"se":2.504276598982365,"valid":true,"gas":{"max_ok":203518,"init_max_ok":243106,"oog":0,"other_halts":0}},{"evaluation":22,"params":{"w":0.25,"k":2.0,"variant":"fast"},"start":975064,"n":64,"mean_diff":-1.0494762622056593,"se":0.14295381516053676,"valid":true,"gas":{"max_ok":203424,"init_max_ok":243090,"oog":0,"other_halts":0}},{"evaluation":23,"params":{"w":0.25,"k":0.25,"variant":"fast"},"start":975064,"n":64,"mean_diff":-1.50124838691415,"se":0.15696714407034046,"valid":true,"gas":{"max_ok":203452,"init_max_ok":243090,"oog":0,"other_halts":0}},{"evaluation":24,"params":{"w":0.5,"k":0.5,"variant":"fast"},"start":975064,"n":64,"mean_diff":-2.3935980607893788,"se":0.24328273309039208,"valid":true,"gas":{"max_ok":203440,"init_max_ok":243090,"oog":0,"other_halts":0}},{"evaluation":25,"params":{"w":0.75,"k":0.25,"variant":"slow"},"start":975064,"n":64,"mean_diff":-12.721736872398761,"se":1.1538418344666834,"valid":true,"gas":{"max_ok":203372,"init_max_ok":243081,"oog":0,"other_halts":0}},{"evaluation":26,"params":{"w":0.75,"k":0.5,"variant":"slow"},"start":975064,"n":64,"mean_diff":-11.011070572833116,"se":1.0922999462822995,"valid":true,"gas":{"max_ok":203364,"init_max_ok":243081,"oog":0,"other_halts":0}},{"evaluation":27,"params":{"w":0.25,"k":4.0,"variant":"fast"},"start":975064,"n":64,"mean_diff":-0.8326810334257457,"se":0.12573551206063707,"valid":true,"gas":{"max_ok":203404,"init_max_ok":243090,"oog":0,"other_halts":0}},{"evaluation":28,"params":{"w":0.75,"k":4.0,"variant":"stale"},"start":975064,"n":64,"mean_diff":-10.602240373006081,"se":0.9911554452419221,"valid":true,"gas":{"max_ok":203545,"init_max_ok":243106,"oog":0,"other_halts":0}},{"evaluation":29,"params":{"w":0.75,"k":1.0,"variant":"fast"},"start":975064,"n":64,"mean_diff":-2.564472361320222,"se":0.25826412150623296,"valid":true,"gas":{"max_ok":203432,"init_max_ok":243090,"oog":0,"other_halts":0}},{"evaluation":30,"params":{"w":0.125,"k":0.5,"variant":"stale"},"start":975064,"n":64,"mean_diff":-0.3923598507120145,"se":0.05600199295462436,"valid":true,"gas":{"max_ok":203553,"init_max_ok":243106,"oog":0,"other_halts":0}},{"evaluation":31,"params":{"w":0.125,"k":1.0,"variant":"slow"},"start":975128,"n":64,"mean_diff":-0.7496826192639414,"se":0.12839900064541107,"valid":true,"gas":{"max_ok":200112,"init_max_ok":243081,"oog":0,"other_halts":0}},{"evaluation":32,"params":{"w":0.125,"k":4.0,"variant":"slow"},"start":975128,"n":64,"mean_diff":-0.4249502161764207,"se":0.08432199954127918,"valid":true,"gas":{"max_ok":200092,"init_max_ok":243081,"oog":0,"other_halts":0}},{"evaluation":33,"params":{"w":0.125,"k":2.0,"variant":"stale"},"start":975128,"n":64,"mean_diff":-0.2784419719485358,"se":0.054839829357068944,"valid":true,"gas":{"max_ok":200261,"init_max_ok":243106,"oog":0,"other_halts":0}}]},"recheck":{"start":978000,"n":256,"candidates":[{"paired":{"n":256,"mean_diff":-0.31378014788908226,"se":0.08338106048783332,"worst":[{"seed":978254,"d":-20.81206271164274},{"seed":978074,"d":-2.538976512792715},{"seed":978077,"d":-1.6727291291856545},{"seed":978125,"d":-1.5526154491858506},{"seed":978193,"d":-1.1296204904075466}]},"retail_edge_delta":{"mean":0.37166462482584306,"se":0.016667916516349836},"arb_edge_delta":{"mean":-0.6854447727149263,"se":0.08451562490176841},"reconciliation_max_abs":2.2737367544323206e-13,"params":{"w":0.125,"k":2.0,"variant":"stale"},"gas":{"max_ok":202770,"init_max_ok":243106,"oog":0,"other_halts":0},"search_evaluation":33,"sha256":"9faa3bed57343f00c5bde9f0baf59e0f9edc41bfe50a2bd66760a0a22989c511","valid":true},{"paired":{"n":256,"mean_diff":-0.4477880069190756,"se":0.08930813878179826,"worst":[{"seed":978254,"d":-21.918607493269633},{"seed":978074,"d":-4.0270692955450045},{"seed":978125,"d":-2.0783928728212686},{"seed":978077,"d":-1.9025251934720018},{"seed":978186,"d":-1.5996338962263508}]},"retail_edge_delta":{"mean":0.45803529143031163,"se":0.019639780008482037},"arb_edge_delta":{"mean":-0.9058232983493875,"se":0.08693530992521556},"reconciliation_max_abs":2.2737367544323206e-13,"params":{"w":0.125,"k":0.5,"variant":"stale"},"gas":{"max_ok":202770,"init_max_ok":243106,"oog":0,"other_halts":0},"search_evaluation":30,"sha256":"efa55451f7bfad7495318d514c60d3ab20bb3b975609b171bbe1c8d2a6b21571","valid":true},{"paired":{"n":256,"mean_diff":-0.4765469659974424,"se":0.09863697545234948,"worst":[{"seed":978254,"d":-22.974268310959587},{"seed":978130,"d":-5.451276930757899},{"seed":978074,"d":-4.408909498031335},{"seed":978003,"d":-3.608191268078258},{"seed":978015,"d":-2.6816246216521904}]},"retail_edge_delta":{"mean":0.43143077538002905,"se":0.021052698635720207},"arb_edge_delta":{"mean":-0.9079777413774686,"se":0.09784180382201786},"reconciliation_max_abs":2.2737367544323206e-13,"params":{"w":0.125,"k":4.0,"variant":"slow"},"gas":{"max_ok":202617,"init_max_ok":243081,"oog":0,"other_halts":0},"search_evaluation":32,"sha256":"38b13b6ecccf672020f82ccefbf9ba72672a006dc8fdf41b73ce363191d23e67","valid":true}],"selection":"Top three valid non-neutral search candidates; freeze highest valid recheck mean before held-out; retain RS2 if the tested mechanism loses."},"freeze":{"sha256":"9faa3bed57343f00c5bde9f0baf59e0f9edc41bfe50a2bd66760a0a22989c511","params":{"w":0.125,"k":2.0,"variant":"stale"},"before_held_out":true},"held_out":{"baseline":"RS2","start":979000,"candidate_mean":518.8103099025597,"baseline_mean":519.0819328988373,"n":512,"mean_diff":-0.27162299627774633,"se":0.01829723438768289,"worst":[{"seed":979438,"d":-2.0116644163967408},{"seed":979511,"d":-1.9348671849007815},{"seed":979091,"d":-1.7343920682906173},{"seed":979352,"d":-1.7318582335908559},{"seed":979220,"d":-1.675043574781057}]},"retail_edge_delta":{"mean":0.3932410455751616,"se":0.013320492883108912},"arb_edge_delta":{"mean":-0.6648640418529073,"se":0.01706246459583475},"gas":{"max_ok":203598,"init_max_ok":243106,"oog":0,"other_halts":0,"limits":{"afterSwap_lt":235000,"afterInitialize_lt":245000},"scope":"Frozen strategy, 512 RS2-held-out plus 2000 fresh STACK-confirmation seeds; gas_stats reset/read per <=20-seed chunk.","search_and_recheck":{"max_ok":203553,"init_max_ok":243106,"oog":0,"other_halts":0}},"stack_confirmation":{"start":6840000,"baseline_sha256":"2eaafc7960e520b8a7fd322ec8afaff8fa677c730228a961efb509cc30b25719","paired":{"n":2000,"mean_diff":0.027966466474600424,"se":0.01688668136107633,"worst":[{"seed":6841840,"d":-4.8105832379596905},{"seed":6841066,"d":-4.097061379016395},{"seed":6841929,"d":-3.704932749166403},{"seed":6840515,"d":-3.547576721022665},{"seed":6840092,"d":-3.2132574234873346}]},"retail_edge_delta":{"mean":0.7441394476814044,"se":0.014836170649963577},"arb_edge_delta":{"mean":-0.716172981206804,"se":0.01103237707198562},"reconciliation_max_abs":1.1368683772161603e-13,"gas":{"max_ok":203598,"init_max_ok":243106,"oog":0,"other_halts":0},"baseline_gas":{"max_ok":213557,"init_max_ok":220962,"oog":0,"other_halts":0},"valid":true},"checks":{"calibration_CH":{"n":1000,"start":0,"mean":525.5258821780834,"expected":525.5258821780834,"exact_match":true},"neutral_parity":{"n":32,"start":979600,"end":979631,"exact_equal_edges":true,"sha256":"f24b6ca198b744c380842c3a17964a6dc21f311bb04984b26733afa3fee8eaf2"},"valid_held_out":true,"valid_stack_confirmation":true,"frozen_amm_match_validate":true,"json_size_limit_bytes":60000,"source_quotes_checked":true},"protocol":{"repository":"https://github.com/benedictbrady/amm-challenge","commit":"6b6921f8d463314aa7c96234e1be25a25245f704","simulator":"amm_sim_rs 0.1.0.post1 (sim-6b6921f8)","wheel_sha256":"aedb68280aca34c110968f00148387c95885207913fb2cf19a1ab4c5cfd6887a","compiler":"solc 0.8.24, optimizer runs 200, viaIR, paris","n_workers":8,"gas_chunk_max_n":20,"config":{"n_steps":10000,"initial_price":100,"initial_x":100,"initial_y":10000,"gbm_mu":0,"gbm_dt":1,"retail_size_sigma":1.2,"retail_buy_prob":0.5,"randomization":"default_rng(seed), draw size U(19,21), rate U(0.6,1), sigma U(0.000882,0.001008), in that order; SimulationConfig.seed=seed"}},"generator_source":"def generate(BASE, w=0., k=0., variant='fast'):\n    if w==0:return BASE\n    assert variant in ('fast','slow','stale') and 0<w<=1 and 0<=k<=32\n    s=BASE.replace('uint256 d1 = slots[12];','uint256 d1 = uint8(slots[12]);')\n    s=s.replace('slots[12] = pImplied >= pHat ? 1 : 2;', 'slots[12] = (slots[12] & ~uint256(255)) | (pImplied >= pHat ? 1 : 2);')\n    # One slot packs last anchor, its timestamp, and existing direction bits.\n    block='''\n        // Dual anchor: later own prints are retail; high fees ensure interior routing.\n        // Packed slot 12: low 8 bits retain RS2 direction, next 128 price, next 64 time.\n        uint256 anchorState = slots[12];\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            anchorState = uint8(anchorState) | (uint256(uint128(normalSpot)) << 8)\n                | (uint256(uint64(trade.timestamp)) << 136);\n            slots[12] = anchorState;\n        }\n'''\n    if variant=='fast':block+='        fastHat = _dualClamp(fastHat, anchorState, trade.timestamp, sigmaHat);\\n'\n    if variant=='slow':block+='        pHat = _dualClamp(pHat, anchorState, trade.timestamp, sigmaHat);\\n'\n    s=s.replace('        slots[13] = uncertainty;',block+'        slots[13] = uncertainty;')\n    if variant=='stale':\n        s=s.replace('            uint256 staleTox =', '            staleHat = _dualClamp(staleHat, anchorState, trade.timestamp, sigmaHat);\\n            uint256 staleTox =')\n    helper=f'''\n    function _dualClamp(uint256 estimate, uint256 state, uint256 nowTs, uint256 sigma)\n        internal pure returns (uint256) {{\n        uint256 center = uint128(state >> 8);\n        if (center == 0) return estimate;\n        uint256 age = nowTs - uint64(state >> 136);\n        uint256 width = 30 * BPS + wmul({int(round(k*1e18))}, sigma) * age;\n        if (width >= WAD) return estimate;\n        uint256 lo = wmul(center, WAD - width);\n        uint256 hi = wdiv(center, WAD - width);\n        uint256 target = estimate < lo ? lo : (estimate > hi ? hi : estimate);\n        return _blend(estimate, target, {int(round(w*1e18))});\n    }}\n'''\n    s=s.replace('    struct PosteriorInput {',helper+'\\n    struct PosteriorInput {')\n    return s\n","notes":["All numbers here are local measurements, not leaderboard submissions. Paired differences are candidate minus named baseline; se=sample SD/sqrt(n), worst lists five smallest differences without dropping seeds.","Retail and arb edge decomposition uses the supplied harness reconstruction from per-step pre-retail reserves/fees and fair prices; deltas reconcile to total edge within floating point tolerance. These are derived components, not explicit trade labels emitted by Rust.","Identifiable retail means !firstInStep, because the first own fill might be arbitrage or retail. Requiring own fee>30bps follows RS2's interior-route proxy; it does not prove that both pools received a positive fill. The inferred Vanilla post-trade price and 30bps fair band are consequently heuristic observations.","Vanilla's post-retail spot need not remain inside its pre-retail arbitrage band: a large retail order can move it further. The brief's proposed 30bps interval is implemented as requested, with elapsed-step widening; this limitation is a plausible explanation for losses, not a measured causal conclusion.","The lower bound is center*(1-width), upper center/(1-width), width=0.003+k*sigmaHat*age. Widening has no effect on a fresh anchor at age zero. Width>=1 disables the clamp. The anchor refreshes on eligible later fills; otherwise its age grows by simulation steps. Fast and slow variants persist adjusted estimates, stale variant changes only the local stale-decision estimate.","No initialization slot added: source of afterInitialize is unchanged. Packed slot12 preserves low8 direction bits, uses next128 bits for anchor price and next64 for timestamp. Only second-print direction reads are narrowed to uint8.","Neutral w=0 returns RS2 byte-for-byte. The best three non-neutral candidates were rechecked to quantify mechanism performance even if zero weight was better; negative candidates are reported as losses, not promoted as improvements.","Frozen source imports the pinned challenge AMMStrategyBase.sol and IAMMStrategy.sol. The included pure Python generator accepts the exact RS2 code from its cited artifact as BASE; no runtime Python dependency is needed to use the frozen Solidity.","No held-out seeds were used to select parameters. The 2000-seed STACK confirmation is a separate fresh block evaluated only after freezing; it was not used to revise the candidate.","The cited harness artifact already used 5000000..5001999. Before any freezing, held-out run or confirmation, a baseline-only recheck launch was interrupted and restarted to move this confirmation to 6840000..6841999, disjoint from the known prior block.","Held-out verdict: measured loss; keep RS2."]}