{"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 = 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        uint256 anchorPacked = slots[16];\n        uint256 anchorMean = uint128(anchorPacked);\n        uint256 anchorCount = anchorPacked >> 128;\n        if (anchorCount < 403) anchorCount++;\n        if (toxEma >= anchorMean) anchorMean += (toxEma-anchorMean)/anchorCount;\n        else anchorMean -= (anchorMean-toxEma)/anchorCount;\n        slots[16] = anchorMean | (anchorCount << 128);\n        uint256 anchorLinear = _anchorMix(anchorMean, toxEma, 472972331820306432);\n        uint256 anchorQuad = _anchorMix(anchorMean, toxEma, 1265762939134584320);\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, anchorLinear) + wmul(TOX_QUAD_COEF, wmul(anchorQuad, anchorQuad)) + wmul(ACT_COEF, actEma);\n        fMid = fMid + wmul(SIGMA_TOX_COEF, wmul(sigmaHat, anchorLinear));\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 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    function _anchorMix(uint256 mean, uint256 value, uint256 k) internal pure returns (uint256) {\n        if (value >= mean) return mean + wmul(value-mean,k);\n        uint256 reduction = wmul(mean-value,k);\n        return reduction < mean ? mean-reduction : 0;\n    }\n}\n","sha256":"c7df70f20f8914d4d6f2893959d5eb710c0dd64a318b480a53b15ca3b0c58cd3","params":{"k_linear":0.4729723318203064,"k_quadratic":1.2657629391345844,"N":403,"target":"toxEma","TOX_DECAY":"910000000000000000","cma_seed":46,"copy":"b"},"log":[{"params":[1.238194127941733,1.4929611698248608,3113],"n":64,"mean_diff":-1.377810714342604,"se":0.4069960842912683,"start":955000,"valid":true},{"params":[0.6153472392615967,1.1604270440910613,784],"n":64,"mean_diff":0.19025981931371216,"se":0.0486876597226577,"start":955064,"valid":true},{"params":[0.9420726136636428,0.7204458822222118,879],"n":64,"mean_diff":-0.5087247838776898,"se":0.07132000294470031,"start":955128,"valid":true},{"params":[1.360785487338115,0.5869930544767012,1023],"n":64,"mean_diff":-0.5997759319818936,"se":0.08175708242035225,"start":955192,"valid":true},{"params":[1.4637383734829381,0.7638924475010669,582],"n":64,"mean_diff":-0.16156463514340214,"se":0.0687951245201904,"start":955256,"valid":true},{"params":[1.3425001496174365,1.0093694543106193,871],"n":64,"mean_diff":0.020243101548461873,"se":0.04458766905060623,"start":955320,"valid":true},{"params":[0.46367267580733984,0.8063995041914334,228],"n":64,"mean_diff":-0.5970911503225089,"se":0.08695585581458344,"start":955384,"valid":true},{"params":[0.5885804034932709,1.4659237679751096,240],"n":64,"mean_diff":-0.26396775595483213,"se":0.23364219429608518,"start":955448,"valid":true},{"params":[0.4729723318203064,1.2657629391345844,403],"n":64,"mean_diff":0.22260142695683705,"se":0.07931855613159597,"start":955512,"valid":true},{"params":[1.1619159670362793,1.0186306290655398,1681],"n":64,"mean_diff":0.03378694250025838,"se":0.0332076671845066,"start":955576,"valid":true},{"params":[0.9567752759201715,1.1526098065837078,527],"n":64,"mean_diff":0.07572317288774588,"se":0.09939425477387315,"start":955640,"valid":true},{"params":[1.0944054702214498,1.3167995835204296,406],"n":64,"mean_diff":0.2573622385904546,"se":0.12157951285086945,"start":955704,"valid":true},{"params":[0.913875990126007,1.4902764899388632,1128],"n":64,"mean_diff":-0.30975196506940605,"se":0.2043906990756205,"start":955768,"valid":true},{"params":[0.30485889878569955,1.3053002959080733,702],"n":64,"mean_diff":0.283971472752226,"se":0.08102591671477276,"start":955832,"valid":true}],"recheck":[{"params":[0.30485889878569955,1.3053002959080733,702],"n":256,"mean_diff":0.29879506576398174,"se":0.04132650051849246,"worst":[{"seed":958004,"d":-2.5561662377722314},{"seed":958155,"d":-2.170329764647988},{"seed":958188,"d":-1.9460036126948808},{"seed":958139,"d":-1.8169954718520103},{"seed":958021,"d":-1.721924434178618}],"valid":true},{"params":[1.0944054702214498,1.3167995835204296,406],"n":256,"mean_diff":0.09149979702423505,"se":0.06384964187878969,"worst":[{"seed":958155,"d":-4.677026073858883},{"seed":958213,"d":-4.092407637379949},{"seed":958091,"d":-3.522612599252966},{"seed":958156,"d":-3.2544975357199064},{"seed":958188,"d":-3.1683692862078487}],"valid":true},{"params":[0.4729723318203064,1.2657629391345844,403],"n":256,"mean_diff":0.30283712994011647,"se":0.036816584325614195,"worst":[{"seed":958004,"d":-2.3664346066485678},{"seed":958155,"d":-2.186627443320731},{"seed":958237,"d":-1.600195861569432},{"seed":958055,"d":-1.261195835989838},{"seed":958046,"d":-1.2501906988443352}],"valid":true}],"held_out":{"vs_rs2":{"n":512,"mean_diff":0.22743129815066498,"se":0.029138446294552398,"worst":[{"seed":959312,"d":-5.207447317714809},{"seed":959175,"d":-3.3438029281713852},{"seed":959117,"d":-2.4344875843106593},{"seed":959203,"d":-2.273348153825623},{"seed":959133,"d":-1.7133313882769698}]},"retail_edge_delta":{"mean":-0.21262643685636973,"se":0.03273157722748534},"arb_edge_delta":{"mean":0.44005773500703543,"se":0.016655862486365237},"reconciliation_max_abs":1.0302869668521453e-13,"valid":true,"start":959000,"end":959511,"gas_raw":{"candidate":[{"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":5502403,"ok":5502403,"max_ok_gas":22592,"sum_ok_gas":124150467428,"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":243115,"sum_ok_gas":124474880,"oog":0,"revert":0,"other_halt":0,"tx_error":0,"bad_return":0},{"role":"Submission","callback":"afterSwap","calls":5284817,"ok":5284817,"max_ok_gas":223339,"sum_ok_gas":654253526820,"oog":0,"revert":0,"other_halt":0,"tx_error":0,"bad_return":0},{"role":"Submission","callback":"getName","calls":512,"ok":512,"max_ok_gas":21623,"sum_ok_gas":11070976,"oog":0,"revert":0,"other_halt":0,"tx_error":0,"bad_return":0}],"rs2":[{"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":5481576,"ok":5481576,"max_ok_gas":22592,"sum_ok_gas":123680543208,"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":5304581,"ok":5304581,"max_ok_gas":200268,"sum_ok_gas":624768875351,"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}]}},"gas":{"max_ok":225559,"init_max_ok":243115,"oog":0,"other_halts":0,"scope":"All candidate search, recheck, held-out and overlay-off parity calls; includes Vanilla baseline counters for halt totals."},"parity":{"n":32,"start":959600,"end":959631,"identical_source":true,"all_rows_equal":true,"vs_rs2":{"n":32,"mean_diff":0.0,"se":0.0,"worst":[{"seed":959600,"d":0.0},{"seed":959601,"d":0.0},{"seed":959602,"d":0.0},{"seed":959603,"d":0.0},{"seed":959604,"d":0.0}]}},"generator_source":"def generate(base,p,enabled=True):\n    kl,kq,cap=p\n    cap=int(round(cap)); kl=int(round(kl*10**18));kq=int(round(kq*10**18))\n    if not enabled:return base\n    old='        uint256 toxSignal = toxEma;'\n    new=f'''        uint256 toxSignal = toxEma;\n        uint256 anchorPacked = slots[16];\n        uint256 anchorMean = uint128(anchorPacked);\n        uint256 anchorCount = anchorPacked >> 128;\n        if (anchorCount < {cap}) anchorCount++;\n        if (toxEma >= anchorMean) anchorMean += (toxEma-anchorMean)/anchorCount;\n        else anchorMean -= (anchorMean-toxEma)/anchorCount;\n        slots[16] = anchorMean | (anchorCount << 128);\n        uint256 anchorLinear = _anchorMix(anchorMean, toxEma, {kl});\n        uint256 anchorQuad = _anchorMix(anchorMean, toxEma, {kq});'''\n    assert old in base\n    s=base.replace(old,new)\n    s=s.replace('wmul(TOX_COEF, toxSignal)','wmul(TOX_COEF, anchorLinear)').replace('wmul(TOX_QUAD_COEF, wmul(toxSignal, toxSignal))','wmul(TOX_QUAD_COEF, wmul(anchorQuad, anchorQuad))').replace('wmul(SIGMA_TOX_COEF, wmul(sigmaHat, toxSignal))','wmul(SIGMA_TOX_COEF, wmul(sigmaHat, anchorLinear))')\n    helper='''\n    function _anchorMix(uint256 mean, uint256 value, uint256 k) internal pure returns (uint256) {\n        if (value >= mean) return mean + wmul(value-mean,k);\n        uint256 reduction = wmul(mean-value,k);\n        return reduction < mean ? mean-reduction : 0;\n    }\n'''\n    at=s.rfind('}');return s[:at]+helper+s[at:]\n","harness_source":"\"\"\"Run from the pinned amm-challenge checkout, with the brief's environment active.\npython harness.py --start 5000000 --n 2000 --out measured.json candidate.sol STACK.sol\nDo not use confirmation seeds to choose or change a strategy.\n\"\"\"\nimport argparse,hashlib,json,math\nfrom pathlib import Path\nimport numpy as np\nimport amm_sim_rs as sim\nfrom amm_competition.evm.compiler import SolidityCompiler\n\n\ndef configs(start,n):\n    configs=[]\n    for seed in range(start,start+n):\n        rng=np.random.default_rng(seed)\n        size=rng.uniform(19.,21.)\n        rate=rng.uniform(.6,1.)\n        sigma=rng.uniform(.000882,.001008)\n        configs.append(sim.SimulationConfig(n_steps=10000,initial_price=100.,\n            initial_x=100.,initial_y=10000.,gbm_mu=0.,gbm_sigma=sigma,gbm_dt=1.,\n            retail_arrival_rate=rate,retail_mean_size=size,retail_size_sigma=1.2,\n            retail_buy_prob=.5,seed=seed))\n    return configs\n\n\ndef decomposition(r,initial_fee=.0004):\n    # Fees are outside reserves, so k stays fixed up to floating-point roundoff.\n    # The arb acts before retail, using the preceding step's final spot and fees.\n    steps=r.steps\n    fair=np.array([s.fair_price for s in steps])\n    spots=np.array([r.initial_fair_price]+[s.spot_prices['submission'] for s in steps[:-1]])\n    bids=np.array([initial_fee]+[s.fees['submission'][0] for s in steps[:-1]])\n    asks=np.array([initial_fee]+[s.fees['submission'][1] for s in steps[:-1]])\n    x0,y0=r.initial_reserves['submission'];k=x0*y0\n    x=np.sqrt(k/spots);y=np.sqrt(k*spots)\n    ga=1-asks;gb=1-bids\n    out=np.minimum(np.maximum(x-np.sqrt(k/(ga*fair)),0),.99*x)\n    paid=(k/(x-out)-y)/ga\n    buyprofit=np.where(out>0,np.maximum(out*fair-paid,0),0)\n    gross=np.maximum((np.sqrt(k*gb/fair)-x)/gb,0)\n    received=y-k/(x+gb*gross)\n    sellprofit=np.where(gross>0,np.maximum(received-gross*fair,0),0)\n    arb=-float(np.sum(np.where(spots<fair,buyprofit,sellprofit)))\n    return arb,r.edges['submission']-arb\n\n\ndef aggregate(chunks):\n    out={}\n    for chunk in chunks:\n        for row in chunk['raw']:\n            key=(row['role'],row['callback'])\n            dest=out.setdefault(key,{'role':row['role'],'callback':row['callback']})\n            for k,v in row.items():\n                if k in ['role','callback']:continue\n                dest[k]=max(dest.get(k,0),v) if k=='max_ok_gas' else dest.get(k,0)+v\n    return list(out.values())\n\n\ndef run(source,start,n,vanilla,compiler):\n    compiled=compiler.compile(source)\n    assert compiled.success,compiled.errors\n    rows=[];chunks=[]\n    for first in range(start,start+n,20):\n        count=min(20,start+n-first)\n        sim.gas_stats_reset()\n        batch=sim.run_batch(list(compiled.bytecode),list(vanilla),configs(first,count),8)\n        results=batch.results\n        assert sorted(r.seed for r in results)==list(range(first,first+count))\n        for r in results:\n            arb,retail=decomposition(r)\n            rows.append({'seed':r.seed,'edge':r.edges['submission'],'arb':arb,'retail':retail})\n        chunks.append({'start':first,'raw':sim.gas_stats()})\n        del results,batch\n    return {'sha256':hashlib.sha256(source.encode()).hexdigest(),'rows':rows,\n            'raw_counters':aggregate(chunks),'chunks':chunks}\n\n\ndef stats(d):\n    d=np.asarray(d,dtype=float)\n    return {'mean':float(d.mean()),'se':float(d.std(ddof=1)/np.sqrt(len(d)))}\n\n\ndef compare(candidate,stack):\n    a={r['seed']:r for r in candidate['rows']};b={r['seed']:r for r in stack['rows']}\n    assert a.keys()==b.keys()\n    seeds=sorted(a)\n    d=np.array([a[s]['edge']-b[s]['edge'] for s in seeds])\n    arb=np.array([a[s]['arb']-b[s]['arb'] for s in seeds])\n    retail=np.array([a[s]['retail']-b[s]['retail'] for s in seeds])\n    assert np.max(np.abs(d-arb-retail))<1e-8\n    summary=stats(d)\n    return {'paired':{'n':len(d),'mean_diff':summary['mean'],'se':summary['se'],\n                'worst':[{'seed':seeds[i],'d':float(d[i])} for i in np.argsort(d)[:5]]},\n            'retail_edge_delta':stats(retail),'arb_edge_delta':stats(arb),\n            'reconciliation_max_abs':float(np.max(np.abs(d-arb-retail)))}\n\n\nif __name__=='__main__':\n    p=argparse.ArgumentParser()\n    p.add_argument('--start',type=int,required=True);p.add_argument('--n',type=int,required=True)\n    p.add_argument('--out',required=True);p.add_argument('candidate');p.add_argument('stack')\n    args=p.parse_args()\n    compiler=SolidityCompiler()\n    vanilla=compiler.compile(Path('contracts/src/VanillaStrategy.sol').read_text(),'VanillaStrategy')\n    assert vanilla.success,vanilla.errors\n    candidate=run(Path(args.candidate).read_text(),args.start,args.n,vanilla.bytecode,compiler)\n    stack=run(Path(args.stack).read_text(),args.start,args.n,vanilla.bytecode,compiler)\n    out=compare(candidate,stack);out.update(candidate=candidate,stack=stack)\n    errors=['oog','revert','other_halt','tx_error','bad_return']\n    out['valid']=all(not any(row.get(e,0) for e in errors)\n        for arm in [candidate,stack] for row in arm['raw_counters'])\n    Path(args.out).write_text(json.dumps(out,allow_nan=False))\n    print(json.dumps({k:v for k,v in out.items() if k not in ['candidate','stack']}))\n","experiment_source":"import sys,time,json,hashlib,math\nfrom pathlib import Path\nimport numpy as np\nimport cma\nsys.path.insert(0,'scratch')\nimport harness as h\nfrom generator import generate\nroot=Path('scratch'); base=(root/'rs2_code.txt').read_text()\nassert hashlib.sha256(base.encode()).hexdigest()=='f24b6ca198b744c380842c3a17964a6dc21f311bb04984b26733afa3fee8eaf2'\nc=h.SolidityCompiler();v=c.compile(Path('contracts/src/VanillaStrategy.sol').read_text(),'VanillaStrategy');assert v.success\n\ndef run(source,start,n,decomp=False):\n t=time.time();compiled=c.compile(source);assert compiled.success,compiled.errors\n rows=[]; counters=[]\n for first in range(start,start+n,16):\n  h.sim.gas_stats_reset();b=h.sim.run_batch(list(compiled.bytecode),list(v.bytecode),h.configs(first,min(16,start+n-first)),8)\n  for r in b.results:\n   arb,retail=h.decomposition(r) if decomp else (0,0)\n   rows.append(dict(seed=r.seed,edge=r.edges['submission'],arb=arb,retail=retail))\n  counters.append({'raw':h.sim.gas_stats()});del b\n result={'rows':rows,'raw_counters':h.aggregate(counters)}\n print(json.dumps(dict(event='arm',start=start,n=n,seconds=time.time()-t,mean=np.mean([r['edge'] for r in rows]),gas=result['raw_counters'])),flush=True)\n return result\n\ndef valid(r):\n return all(not any(z.get(e,0) for e in ['oog','revert','other_halt','tx_error','bad_return']) and (z['role']!='Submission' or z['max_ok_gas'] < (235000 if z['callback']=='afterSwap' else 245000)) for z in r['raw_counters'])\ndef paired(a,b):\n aa={r['seed']:r['edge'] for r in a['rows']};bb={r['seed']:r['edge'] for r in b['rows']};assert aa.keys()==bb.keys()\n seeds=sorted(aa);d=np.array([aa[z]-bb[z] for z in seeds]);st=h.stats(d)\n return dict(n=len(d),mean_diff=st['mean'],se=st['se'],worst=[dict(seed=seeds[i],d=float(d[i])) for i in np.argsort(d)[:5]])\ndef save(name,x):\n (root/(name+'.json')).write_text(json.dumps(x,allow_nan=False))\n\ncal=run((root/'CH.sol').read_text(),0,1000)\ncalmean=float(np.mean([r['edge'] for r in cal['rows']]))\nsave('calibration',dict(n=1000,mean=calmean,expected=525.5258821780834,difference=calmean-525.5258821780834,gas=cal['raw_counters']))\nassert abs(calmean-525.5258821780834)<1e-8,(calmean,'calibration failed')\n\nstarttime=time.monotonic();logs=[];es=cma.CMAEvolutionStrategy([.65,.65,.5],.30,{'bounds':[0,1],'seed':46,'popsize':6,'verbose':-9})\nseed=955000\n# One fresh 64-seed block per candidate, capped at the item search window.\nwhile time.monotonic()-starttime<1200 and seed+64<=958000:\n xs=es.ask();ys=[]\n for x in xs:\n  if time.monotonic()-starttime>=1200:break\n  p=[float(x[0]*1.5),float(x[1]*1.5),int(round(100*(100**float(x[2]))))]\n  a=run(generate(base,p),seed,64);b=run(base,seed,64)\n  ps=paired(a,b);ok=valid(a) and valid(b)\n  log=dict(params=p,n=64,mean_diff=ps['mean_diff'],se=ps['se'],start=seed,valid=ok,gas=a['raw_counters']);logs.append(log);ys.append(-ps['mean_diff'] if ok else 1000)\n  save('search',logs);print(json.dumps(dict(event='trial',**log)),flush=True);seed+=64\n if len(ys)!=len(xs):break\n es.tell(xs,ys)\n# rank exactly the top three valid search candidates\nbest=sorted([x for x in logs if x['valid']],key=lambda x:x['mean_diff'],reverse=True)[:3]\nassert len(best)==3\nb=run(base,958000,256)\nrecheck=[]\nfor z in best:\n a=run(generate(base,z['params']),958000,256)\n recheck.append(dict(params=z['params'],**paired(a,b),valid=valid(a) and valid(b),gas=a['raw_counters']))\n save('recheck',recheck)\nwinner=max([z for z in recheck if z['valid']],key=lambda z:z['mean_diff'])\np=winner['params'];code=generate(base,p);(root/'frozen.sol').write_text(code);save('freeze',dict(params=p,sha256=hashlib.sha256(code.encode()).hexdigest()))\na=run(code,959000,512,True);b=run(base,959000,512,True)\ncomparison=h.compare(a,b);save('heldout',dict(comparison=comparison,candidate=a,rs2=b,valid=valid(a) and valid(b)))\na=run(generate(base,p,False),959600,32,True);b=run(base,959600,32,True)\nsave('parity',dict(comparison=h.compare(a,b),identical_source=generate(base,p,False)==base,all_rows_equal=a['rows']==b['rows'],candidate=a,rs2=b))\nprint('COMPLETE',flush=True)\n","calibration":{"n":1000,"mean":525.5258821780834,"expected":525.5258821780834,"difference":0.0,"gas":[{"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}]},"notes":["Pinned amm-challenge checkout 6b6921f8d463314aa7c96234e1be25a25245f704; supplied setup.sh ran successfully. Simulator wheel SHA256 verified as aedb68280aca34c110968f00148387c95885207913fb2cf19a1ab4c5cfd6887a. Python 3.12, numpy 2.5.4, cma 4.5.0, solc 0.8.24, viaIR, optimizer 200, paris.","RS2 source SHA256 verified as f24b6ca198b744c380842c3a17964a6dc21f311bb04984b26733afa3fee8eaf2 before any search. generator_source accepts that exact source as base.","Run mean updates once per afterSwap using the post-update toxEma. Count starts at zero (unset), increments to N, then stays N, giving exact integer running mean up to N and 1/N exponential updates thereafter. Mean and count are packed into slot 16; no write added to afterInitialize. Integer division rounds toward zero.","Mixing is mean + k*(toxEma-mean), independently for linear/sigma-tox and quadratic terms. Negative extrapolated signals at k>1 are clamped to zero. Only TOX_COEF, TOX_QUAD_COEF and SIGMA_TOX_COEF operands change. DIR_TOX_COEF remains on original toxSignal; price, stale-shift and posterior unchanged.","CMA-ES seed 46, population 6, initial normalized mean [.65,.65,.5], sigma .30, bounds [0,1]. k=1.5*x; N=round(100*100**x). Fitness is paired candidate minus RS2; any halt or gas-limit failure scores -1000. Each candidate uses a fresh disjoint 64-seed block from 955000. Search clock starts after calibration; stop checked before each trial after 1200 seconds, allowing headroom under 25 minutes. Incomplete last generation is evaluated but not told to CMA.","Top three valid search candidates rechecked on shared 958000..958255. Largest valid paired recheck mean frozen before held-out 959000..959511. Held-out evaluated exactly once per arm, no tuning afterward. All item seeds are below 5000000; no STACK or board comparison was performed.","Each strategy alone versus VanillaStrategy, run_batch(candidate,Vanilla,configs,8), in 16-seed chunks with gas_stats_reset/gas_stats per chunk. Configs exactly from supplied harness (default_rng(seed): size, rate, sigma). No seeds dropped. Paired SE is sample standard deviation/sqrt(n); worst lists five smallest paired deltas.","Retail/arb decomposition uses supplied harness reconstruction, initial fee .0004. Retail edge is total edge minus reconstructed arb edge; reconciliation checked numerically. This is a reconstruction, not a separate simulator event-label measurement.","A preflight ran RS2 on parity seeds 959600..959601 to inspect simulator counters; it did not evaluate a candidate or inform parameter selection. Overlay off is generator enabled=False, which returns original RS2 source byte for byte. It was simulated on all 32 parity seeds; equality checks include edge and reconstructed retail/arb per seed.","An initial calibration attempt was interrupted before producing a completed result to correct a local harness issue. The reported full calibration and all completed search/recheck/held-out/parity runs use the repaired harness."],"search_summary":{"evaluations":14,"seeds_per_trial":64,"start":955000,"end":955895,"summed_arm_wall_seconds":1228.2685368061066,"complete_cma_generations":2},"params_exact":{"k_linear_wad":"472972331820306432","k_quadratic_wad":"1265762939134584320","N":403},"interpretation":"Held-out measurement against RS2 only. No STACK-relative confirmation or board/top-10 claim. This item did not use any seed >=5000000.","input_sources":{"rs2":"https://api.imdnotdead.fun/artifacts/19f2ec857df536e8ab62ab1da89ec6623332521ce46849f15bccff402c63e1e5","method":"https://api.imdnotdead.fun/artifacts/33f54e81f3372088e9eced52c0174f310ac348af98ef5727b73785c088679194","calibration_strategy":"https://raw.githubusercontent.com/ChengHua926/amm-challenge/d34a5199c59a4c44d5336a25f1436b4ae1f21104/contracts/src/Strategy.sol","simulator_repository":"https://github.com/benedictbrady/amm-challenge/tree/6b6921f8d463314aa7c96234e1be25a25245f704"}}