{"item": "e04-retail-state/a", "blocked": null, "status": "incomplete", "summary": "I implemented a latent retail flow state. Weights: 1 for later prints, 1 minus V10's posterior arb probability for first prints. It feeds only the fee-flow inputs (lambda and flow size), and the V10 price/stale updates are unchanged. Zero mix reproduces V10 bit-for-bit. Three structures were searched: weighted counts only (A), counts plus size moments (B), and plus a bounded fee-dependent missing-flow correction (C). No structure showed a significant gain. The best (C) is +0.033 +/- 0.072 on a 64-seed partial recheck. Time ran out before the 256-seed recheck and the 512-seed held-out run, so this hash is a provisional pick, not a frozen confirmed one.", "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 MIX_L = 97208736839318288;\n    uint256 constant MIX_S = 365976343805026688;\n    uint256 constant R_DECAY = 954763670217833728;\n    uint256 constant S_DECAY = 885902719308659712;\n    uint256 constant R_SCALE = 773303862660854400;\n    uint256 constant S_SCALE = 722010222045784832;\n    uint256 constant V_COEF = 212519832015945536;\n    uint256 constant CORR_C = 533672291176834816;\n    uint256 constant CORR_B = 350185795573288896;\n    uint256 constant FIRST_W = 800657826587715200;\n    uint256 constant SIGNAL_THRESHOLD = WAD / 650;\n    uint256 constant DIR_DECAY = 750000000000000000;\n    uint256 constant ACT_DECAY = 530000000000000000;\n    uint256 constant SIZE_DECAY = 530000000000000000;\n    uint256 constant TOX_DECAY = 910000000000000000;\n    uint256 constant SIGMA_DECAY = 690000000000000000;\n    uint256 constant LAMBDA_DECAY = 990000000000000000;\n    uint256 constant SIZE_BLEND_DECAY = 828000000000000000;\n    uint256 constant TOX_BLEND_DECAY = 51000000000000000;\n    uint256 constant ACT_BLEND_DECAY = 985000000000000000;\n    uint256 constant PHAT_ALPHA = 270000000000000000;\n    uint256 constant PHAT_ALPHA_RETAIL = 60000000000000000;\n    uint256 constant PHAT_ALPHA_SAME = 120000000000000000;\n    uint256 constant REVERT_U = 0;\n    uint256 constant DIR_IMPACT_MULT = 4;\n    uint256 constant GATE_SIGMA_MULT = 7200000000000000000;\n    uint256 constant MIN_GATE = 30000000000000000;\n    uint256 constant TRADE_TOX_BOOST = 3500 * BPS;\n    uint256 constant STALE_ATTRACT_FRAC = 1050000000000000000;\n    uint256 constant RET_CAP = WAD / 35;\n    uint256 constant TOX_CAP = WAD / 5;\n    uint256 constant TRADE_RATIO_CAP = WAD / 5;\n    uint256 constant LAMBDA_CAP = 1820000000000000000;\n    uint256 constant STEP_COUNT_CAP = 64;\n    uint256 constant BASE_FEE = 4 * BPS;\n    uint256 constant SIGMA_COEF = 200000000000000000;\n    uint256 constant LAMBDA_COEF = 12 * BPS;\n    uint256 constant FLOW_SIZE_COEF = 4842 * BPS;\n    uint256 constant TOX_COEF = 300 * BPS;\n    uint256 constant TOX_QUAD_COEF = 15000 * BPS;\n    uint256 constant ACT_COEF = 91843 * BPS;\n    uint256 constant DIR_COEF = 20 * BPS;\n    uint256 constant DIR_TOX_COEF = 100 * BPS;\n    uint256 constant STALE_DIR_COEF = 6850 * BPS;\n    uint256 constant SIGMA_TOX_COEF = 500 * BPS;\n    uint256 constant TAIL_KNEE = 600 * BPS;\n    uint256 constant TAIL_SLOPE_PROTECT = 930000000000000000;\n    uint256 constant TAIL_SLOPE_ATTRACT = 850000000000000000;\n\n    function afterInitialize(uint256 initialX, uint256 initialY) external override returns (uint256, uint256) {\n        slots[0] = BASE_FEE; slots[1] = BASE_FEE; slots[3] = WAD; \n        slots[5] = initialX > 0 ? wdiv(initialY, initialX) : 100 * WAD;\n        slots[6] = 950000000000000; slots[7] = 800000000000000000; slots[8] = 2000000000000000;\n        slots[13] = 902500000000; slots[14] = slots[5];\n        return (BASE_FEE, BASE_FEE);\n    }\n\n    function afterSwap(TradeInfo calldata trade) external override returns (uint256, uint256) {\n        uint256 prevBidFee = slots[0]; uint256 prevAskFee = slots[1]; uint256 lastTs = uint64(slots[2]);\n        uint256 dirState = slots[3]; uint256 actEma = slots[4]; uint256 pHat = slots[5];\n        uint256 sigmaHat = slots[6]; uint256 lambdaHat = slots[7]; uint256 sizeHat = slots[8];\n        uint256 toxEma = slots[9]; uint256 stepTradeCount = slots[10];\n\n        uint256 sigmaForFast = sigmaHat;\n        uint256 fastHat = slots[14];\n        uint256 uncertainty = slots[13];\n        uint256 silent = trade.timestamp > lastTs ? trade.timestamp - lastTs : 0;\n        bool isNewStep = trade.timestamp > lastTs;\n        if (isNewStep) {\n            uint256 elapsedRaw = trade.timestamp - lastTs;\n            uint256 elapsed = elapsedRaw > ELAPSED_CAP ? ELAPSED_CAP : elapsedRaw;\n            dirState = _decayCentered(dirState, DIR_DECAY, elapsed);\n            actEma = wmul(actEma, _powWad(ACT_DECAY, elapsed));\n            sizeHat = wmul(sizeHat, _powWad(SIZE_DECAY, elapsed));\n            toxEma = wmul(toxEma, _powWad(TOX_DECAY, elapsed));\n            if (stepTradeCount > 0 && elapsedRaw > 0) {\n                uint256 lambdaInst = (stepTradeCount * WAD) / elapsedRaw;\n                if (lambdaInst > LAMBDA_CAP) lambdaInst = LAMBDA_CAP;\n                lambdaHat = wmul(lambdaHat, LAMBDA_DECAY) + wmul(lambdaInst, WAD - LAMBDA_DECAY);\n            }\n            // Process variance is propagated inside the censored update.\n            if (uncertainty > 100000000000000) uncertainty = 100000000000000;\n            stepTradeCount = 0;\n            if (MIX_L + MIX_S > 0) _flowStep(elapsedRaw);\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 arbProb;\n        (fastHat, uncertainty, arbProb) = _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 fBaseLambda;\n        uint256 tradeRatio = trade.reserveY > 0 ? wdiv(trade.amountY, trade.reserveY) : 0;\n        if (tradeRatio > TRADE_RATIO_CAP) tradeRatio = TRADE_RATIO_CAP;\n\n        if (tradeRatio > SIGNAL_THRESHOLD) {\n            uint256 push = tradeRatio * DIR_IMPACT_MULT;\n            if (push > WAD / 4) push = WAD / 4;\n            if (trade.isBuy) {\n                dirState = dirState + push;\n                if (dirState > 2 * WAD) dirState = 2 * WAD;\n            } else {\n                dirState = dirState > push ? dirState - push : 0;\n            }\n            actEma = wmul(actEma, ACT_BLEND_DECAY) + wmul(tradeRatio, WAD - ACT_BLEND_DECAY);\n            sizeHat = wmul(sizeHat, SIZE_BLEND_DECAY) + wmul(tradeRatio, WAD - SIZE_BLEND_DECAY);\n            if (sizeHat > WAD) sizeHat = WAD;\n        }\n\n        uint256 tox = pHat > 0 ? wdiv(absDiff(spot, pHat), pHat) : 0;\n        if (tox > TOX_CAP) tox = TOX_CAP;\n        toxEma = wmul(toxEma, TOX_BLEND_DECAY) + wmul(tox, WAD - TOX_BLEND_DECAY);\n        uint256 toxSignal = toxEma;\n\n        stepTradeCount = stepTradeCount + 1;\n        if (stepTradeCount > STEP_COUNT_CAP) stepTradeCount = STEP_COUNT_CAP;\n\n        uint256 flowSize;\n        if (MIX_L + MIX_S > 0) {\n            (uint256 lEff, uint256 sEff) = _flowPrint(firstInStep ? WAD - arbProb : WAD, tradeRatio, feeUsed, firstInStep, lambdaHat, sizeHat);\n            flowSize = wmul(lEff, sEff);\n            fBaseLambda = lEff;\n        } else { flowSize = wmul(lambdaHat, sizeHat); fBaseLambda = lambdaHat; }\n        uint256 fBase = BASE_FEE + wmul(SIGMA_COEF, sigmaHat) + wmul(LAMBDA_COEF, fBaseLambda) + wmul(FLOW_SIZE_COEF, flowSize);\n        uint256 fMid = fBase + wmul(TOX_COEF, toxSignal) + wmul(TOX_QUAD_COEF, wmul(toxSignal, toxSignal)) + wmul(ACT_COEF, actEma);\n        fMid = fMid + wmul(SIGMA_TOX_COEF, wmul(sigmaHat, toxSignal));\n\n        uint256 dirDev; bool sellPressure;\n        if (dirState >= WAD) { dirDev = dirState - WAD; sellPressure = true; }\n        else { dirDev = WAD - dirState; sellPressure = false; }\n\n        uint256 skew = wmul(DIR_COEF, dirDev) + wmul(DIR_TOX_COEF, wmul(dirDev, toxSignal));\n        uint256 bidFee; uint256 askFee;\n        if (sellPressure) {\n            bidFee = fMid + skew;\n            askFee = fMid > skew ? fMid - skew : 0;\n        } else {\n            askFee = fMid + skew;\n            bidFee = fMid > skew ? fMid - skew : 0;\n        }\n\n        {\n            uint256 staleHat = wmul(pHat, 700000000000000000) + wmul(fastHat, 300000000000000000);\n            uint256 staleTox = wdiv(absDiff(spot, staleHat), staleHat);\n            if (staleTox > TOX_CAP) staleTox = TOX_CAP;\n            uint256 staleShift = wmul(STALE_DIR_COEF, staleTox);\n            uint256 attractShift = wmul(staleShift, STALE_ATTRACT_FRAC);\n            if (spot >= staleHat) {\n                bidFee = bidFee + staleShift;\n                askFee = askFee > attractShift ? askFee - attractShift : 0;\n            } else {\n                askFee = askFee + staleShift;\n                bidFee = bidFee > attractShift ? bidFee - attractShift : 0;\n            }\n        }\n\n        {\n            bool tradeAligned = (trade.isBuy && spot >= pHat) || (!trade.isBuy && spot < pHat);\n            if (tradeAligned) {\n                uint256 tradeBoost = wmul(TRADE_TOX_BOOST, tradeRatio);\n                if (!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\n    // Latent retail flow state, packed in slot15 (never zero after first write):\n    // bits 0-63 weighted retail count in step, 64-127 rate, 128-191 size mean, 192-254 size 2nd moment, bit 255 marker.\n    uint256 constant M64 = 0xFFFFFFFFFFFFFFFF;\n    function _unpack() internal view returns (uint256 c, uint256 r, uint256 s, uint256 m2) {\n        uint256 v = slots[15];\n        if (v == 0) return (0, 800000000000000000, 2000000000000000, 4000000000000);\n        c = v & M64; r = (v >> 64) & M64; s = (v >> 128) & M64; m2 = (v >> 192) & 0x7FFFFFFFFFFFFFFF;\n    }\n    function _pack(uint256 c, uint256 r, uint256 s, uint256 m2) internal {\n        slots[15] = (1 << 255) | (m2 << 192) | (s << 128) | (r << 64) | c;\n    }\n    function _flowStep(uint256 elapsedRaw) internal {\n        (uint256 c, uint256 r, uint256 s, uint256 m2) = _unpack();\n        uint256 inst = elapsedRaw > 0 ? c / elapsedRaw : 0;\n        if (inst > LAMBDA_CAP) inst = LAMBDA_CAP;\n        uint256 e = elapsedRaw > ELAPSED_CAP ? ELAPSED_CAP : elapsedRaw;\n        uint256 d = _powWad(R_DECAY, e);\n        r = wmul(r, d) + wmul(inst, WAD - d);\n        _pack(0, r, s, m2);\n    }\n    function _flowPrint(uint256 w, uint256 ratio, uint256 feeUsed, bool first, uint256 lambdaHat, uint256 sizeHat) internal returns (uint256, uint256) {\n        (uint256 cnt, uint256 r, uint256 s, uint256 m2) = _unpack();\n        if (first) w = wmul(w, FIRST_W);\n        // bounded correction for quote-dependent missing flow: c = 1 + C*(fee/30bps - 1), clamped to [1-B, 1+B]\n        if (CORR_C > 0 && w > 0) {\n            uint256 c = WAD + wmul(CORR_C, wdiv(feeUsed, 30 * BPS));\n            c = c > CORR_C ? c - CORR_C : 0;\n            if (c > WAD + CORR_B) c = WAD + CORR_B;\n            if (c + CORR_B < WAD) c = WAD - CORR_B;\n            w = wmul(w, c);\n        }\n        cnt += w; if (cnt > 16 * WAD) cnt = 16 * WAD;\n        if (w > 0) {\n            uint256 a = wmul(w, WAD - S_DECAY);\n            if (a > WAD) a = WAD;\n            if (ratio > TRADE_RATIO_CAP) ratio = TRADE_RATIO_CAP;\n            s = _blend(s, ratio, a);\n            m2 = _blend(m2, wmul(ratio, ratio), a);\n        }\n        _pack(cnt, r, s, m2);\n        uint256 sEff = wmul(s, S_SCALE);\n        if (V_COEF > 0 && s > 0) {\n            uint256 ss = wmul(s, s);\n            sEff += wmul(V_COEF, wdiv(m2 > ss ? m2 - ss : 0, s));\n        }\n        return (_blend(lambdaHat, wmul(r, R_SCALE), MIX_L), _blend(sizeHat, sEff, MIX_S));\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": "de391f5ce8120b6bc6cdbb4a5b398b25da1d901cb22afd3931928ba9af1617d5", "v10_sha256": "cd9bdb45ab0537ad25c4fd90ca8618898cef6386de3df65f192eaef65fbca245", "v10_sha256_expected": "cd9bdb45ab0537ad25c4fd90ca8618898cef6386de3df65f192eaef65fbca245", "zero_mix_identity": {"template_zero_sha256": "d361c214d8563b803daa777370e75fe59fd4a9b156b0a0174a0fc5e322d6601c", "seeds": [640000, 640019], "max_abs_edge_diff_vs_V10": 0.0, "gas_afterSwap_max": 190639, "v10_afterSwap_max": 190636}, "params": {"MIX_L": "97208736839318288", "MIX_S": "365976343805026688", "R_DECAY": "954763670217833728", "S_DECAY": "885902719308659712", "R_SCALE": "773303862660854400", "S_SCALE": "722010222045784832", "V_COEF": "212519832015945536", "CORR_C": "533672291176834816", "CORR_B": "350185795573288896", "FIRST_W": "800657826587715200"}, "params_note": "WAD-scaled uint256. MIX_L/MIX_S blend V10 lambdaHat/sizeHat toward the latent rate/size. R_DECAY/S_DECAY are EMA decays. R_SCALE/S_SCALE are scales. V_COEF is a size-variance (size-biased) term. CORR_C/CORR_B: own-fill weight multiplied by clamp(1+C*(fee/30bps-1),1-B,1+B). FIRST_W multiplies first-print weight. The state is packed into slot 15 to stay under gas (an unpacked first version OOG'd in afterInitialize and afterSwap and was discarded).", "harness_source": "import json,time,sys,hashlib\nfrom pathlib import Path\nimport numpy as np\nimport amm_sim_rs as sim\nfrom amm_competition.evm.compiler import SolidityCompiler\nfrom amm_competition.competition.config import build_config\nC=SolidityCompiler()\nVAN=C.compile(Path('contracts/src/VanillaStrategy.sol').read_text(),'VanillaStrategy'); assert VAN.success\ndef configs(start,n):\n    out=[]\n    for s in range(start,start+n):\n        r=np.random.default_rng(s)\n        size=r.uniform(19,21);rate=r.uniform(.6,1);sigma=r.uniform(.000882,.001008)\n        out.append(build_config(seed=s,gbm_sigma=sigma,retail_arrival_rate=rate,retail_mean_size=size))\n    return out\ndef decomposition(r, initial_fee=0.0004):\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.maximum(out*fair-paid,0)\n    gross=np.maximum((np.sqrt(k*gb/fair)-x)/gb,0)\n    received=y-k/(x+gb*gross)\n    sellprofit=np.maximum(received-gross*fair,0)\n    arb=-float(np.sum(np.where(spots<fair,buyprofit,sellprofit)))\n    return arb,r.edges['submission']-arb\n_cache={}\ndef compile_(src):\n    h=hashlib.sha256(src.encode()).hexdigest()\n    if h not in _cache:\n        a=C.compile(src); assert a.success,a.errors; _cache[h]=a\n    return h,_cache[h]\ndef run(src,seeds,decomp=False):\n    h,a=compile_(src)\n    seeds=list(seeds); edges={};arb={};ret={};gas={'max_ok':0,'oog':0,'halts':0,'init_max':0}\n    for i in range(0,len(seeds),20):\n        ch=seeds[i:i+20]\n        sim.gas_stats_reset()\n        res=sim.run_batch(list(a.bytecode),list(VAN.bytecode),[c for s in ch for c in configs(s,1)],8)\n        g=sim.gas_stats()\n        for c in g:\n            if c['role']=='Submission':\n                gas['oog']+=c['oog']; gas['halts']+=c['oog']+c['revert']+c['other_halt']+c['tx_error']+c['bad_return']\n                if c['callback']=='afterSwap': gas['max_ok']=max(gas['max_ok'],c['max_ok_gas'])\n                if c['callback']=='afterInitialize': gas['init_max']=max(gas['init_max'],c['max_ok_gas'])\n        for r in res.results:\n            edges[r.seed]=r.edges['submission']\n            if decomp: arb[r.seed],ret[r.seed]=decomposition(r)\n        del res\n    return h,edges,arb,ret,gas\ndef paired(ea,eb):\n    ks=sorted(ea); d=np.array([ea[k]-eb[k] for k in ks])\n    o=np.argsort(d)[:5]\n    return {'n':len(d),'mean_diff':float(d.mean()),'se':float(d.std(ddof=1)/np.sqrt(len(d))),'worst':[{'seed':ks[i],'d':float(d[i])} for i in o]}\n", "generator_source": "import sys,time,json;sys.path.insert(0,'scratch')\nimport numpy as np\nfrom multiprocessing import Pool\nW=10**18\nKEYS=['MIX_L','MIX_S','R_DECAY','S_DECAY','R_SCALE','S_SCALE','V_COEF','CORR_C','CORR_B','FIRST_W']\ndef sig(x): return 1/(1+np.exp(-x))\ndef decode(st,x):\n    p=dict(MIX_L=0,MIX_S=0,R_DECAY=0,S_DECAY=0,R_SCALE=W,S_SCALE=W,V_COEF=0,CORR_C=0,CORR_B=0,FIRST_W=W)\n    p['MIX_L']=int(sig(x[0])*W); p['R_DECAY']=int((0.9+0.099*sig(x[1]))*W); p['R_SCALE']=int(np.exp(0.3*x[2])*W); p['FIRST_W']=int(sig(x[3]+2)*W)\n    if st in 'BC':\n        p['MIX_S']=int(sig(x[4])*W); p['S_DECAY']=int((0.8+0.199*sig(x[5]))*W); p['S_SCALE']=int(np.exp(0.5*x[6])*W); p['V_COEF']=int(sig(x[7]-2)*W)\n    if st=='C':\n        p['CORR_C']=int(sig(x[8])*W); p['CORR_B']=int(0.5*sig(x[9])*W)\n    return p\nDIM={'A':4,'B':8,'C':10}\ndef ev(args):\n    from h import run\n    src,seeds=args; h,e,_,_,g=run(src,seeds); return h,e,g\nif __name__=='__main__':\n    T=open('scratch/tmpl.sol').read(); V=open('scratch/V10.sol').read()\n    rng=np.random.default_rng(401+int(sys.argv[2])); t0=time.time(); pool=Pool(4)\n    base={}\n    def block(i): return list(range(640000+32*i,640032+32*i))\n    best={}\n    plan=json.load(open(sys.argv[1])); blk=int(sys.argv[2]); log=json.load(open('scratch/searchlog.json'))\n    for st,gens,m0 in plan:\n        m=np.array(m0,float); s=0.8\n        for g in range(gens):\n            seeds=block(blk); blk+=1\n            X=[m+s*rng.standard_normal(DIM[st]) for _ in range(3)]\n            jobs=[(V,seeds)]+[(T.format(**decode(st,x)),seeds) for x in X]\n            R=pool.map(ev,jobs)\n            eb=R[0][1]; scores=[]\n            for x,(h,e,gs) in zip(X,R[1:]):\n                d=np.array([e[k]-eb[k] for k in seeds]); ok=gs['oog']==0 and gs['halts']==0\n                sc=float(d.mean()) if ok else -1e9\n                scores.append(sc)\n                log.append(dict(structure=st,gen=g,seeds=[seeds[0],seeds[-1]],sha256=h,params={k:str(v) for k,v in decode(st,x).items()},mean_diff=float(d.mean()),se=float(d.std(ddof=1)/np.sqrt(len(d))),gas=gs,valid=ok,x=[float(v) for v in x]))\n                print(st,g,round(sc,4),gs['max_ok'],gs['oog'],round(time.time()-t0),flush=True)\n            o=np.argsort(scores)[::-1]\n            m=0.7*X[o[0]]+0.3*X[o[1]]; s*=0.7\n            if st not in best or scores[o[0]]>best[st][1]: best[st]=(X[o[0]],scores[o[0]])\n        json.dump(log,open('scratch/searchlog.json','w'))\n    print('elapsed',time.time()-t0)\n", "recheck_source": "import sys,json,time;sys.path.insert(0,'scratch')\nimport numpy as np\nfrom multiprocessing import Pool\nfrom search import decode,ev\nL=json.load(open('scratch/searchlog.json'))\ntop=sorted([r for r in L if r['valid']],key=lambda r:-r['mean_diff'])[:2]\nT=open('scratch/tmpl.sol').read();V=open('scratch/V10.sol').read()\nseeds=list(range(644000,644064))\nsrcs=[V]+[T.format(**{k:int(v) for k,v in r['params'].items()}) for r in top]\nt=time.time()\ndef evd(a):\n    from h import run\n    h,e,arb,ret,g=run(a,seeds,decomp=True);return h,e,arb,ret,g\nR=Pool(3).map(evd,srcs)\nout=[]\n_,e0,a0,r0,g0=R[0]\nfor r,(h,e,a,rt,g) in zip(top,R[1:]):\n    d=np.array([e[k]-e0[k] for k in seeds]);da=np.array([a[k]-a0[k] for k in seeds]);dr=np.array([rt[k]-r0[k] for k in seeds])\n    o=np.argsort(d)[:5]\n    out.append(dict(sha256=h,structure=r['structure'],params=r['params'],paired=dict(n=len(d),mean_diff=float(d.mean()),se=float(d.std(ddof=1)/8),worst=[{'seed':seeds[i],'d':float(d[i])} for i in o]),\n      arb_delta=dict(mean=float(da.mean()),se=float(da.std(ddof=1)/8)),retail_delta=dict(mean=float(dr.mean()),se=float(dr.std(ddof=1)/8)),\n      reconciliation_max_abs=float(np.max(np.abs(d-da-dr))),gas=g))\njson.dump(dict(seeds=[644000,644063],v10_sha=R[0][0],v10_gas=g0,v10_mean=float(np.mean([e0[k] for k in seeds])),arms=out,elapsed=time.time()-t),open('scratch/recheck.json','w'),indent=1)\nprint(json.dumps(out,indent=0)[:3000],time.time()-t)\n", "search": {"method": "Seeded ES (CMA-like, numpy default_rng 401+block_index, 3 candidates/gen, mean update 0.7/0.3 of top-2). Each gen used a fresh rotating 32-seed CRN block, with V10 rerun on the same block.", "blocks_used": [[640000, 640031], [640032, 640063], [640064, 640095], [640096, 640127]], "search_wall_minutes": "about 25 (exceeds the 20-min target; one 10-min run was killed by the tool timeout after A completed, and its A log was kept)", "log": [{"structure": "A", "gen": 0, "seeds": [640000, 640031], "sha256": "8f8d170273caf197d7da3bb76559690c793acbe2ab44298875b2bf092148ac2f", "params": {"MIX_L": "299992172463184576", "MIX_S": "0", "R_DECAY": "951989332826660864", "S_DECAY": "0", "R_SCALE": "1312974629270082048", "S_SCALE": "1000000000000000000", "V_COEF": "0", "CORR_C": "0", "CORR_B": "0", "FIRST_W": "733178562821324288"}, "mean_diff": -0.4484540511232069, "se": 0.08497462683486354, "gas": {"max_ok": 214728, "oog": 0, "halts": 0, "init_max": 220984}, "valid": true}, {"structure": "A", "gen": 0, "seeds": [640000, 640031], "sha256": "36d89c3ca39d7ccf7a3b1c8ce322ed862142bd1fc3159ba62bda194daf63f3cf", "params": {"MIX_L": "386771127391573824", "MIX_S": "0", "R_DECAY": "916077155606990336", "S_DECAY": "0", "R_SCALE": "1279122878678658304", "S_SCALE": "1000000000000000000", "V_COEF": "0", "CORR_C": "0", "CORR_B": "0", "FIRST_W": "959515768856584576"}, "mean_diff": -0.6136985449577654, "se": 0.10121812221097093, "gas": {"max_ok": 214728, "oog": 0, "halts": 0, "init_max": 220984}, "valid": true}, {"structure": "A", "gen": 0, "seeds": [640000, 640031], "sha256": "4409ddc3053017327ae82e11a9355dbba28819857f95d863879ac5b9b6eddbd8", "params": {"MIX_L": "624638750515499264", "MIX_S": "0", "R_DECAY": "949363373300631296", "S_DECAY": "0", "R_SCALE": "1622964572865582336", "S_SCALE": "1000000000000000000", "V_COEF": "0", "CORR_C": "0", "CORR_B": "0", "FIRST_W": "907415689696612992"}, "mean_diff": -0.5889809678614331, "se": 0.1127971390009709, "gas": {"max_ok": 214728, "oog": 0, "halts": 0, "init_max": 220984}, "valid": true}, {"structure": "A", "gen": 1, "seeds": [640032, 640063], "sha256": "efd9f485a8d002e5cdd30599bbd106dbc113ef2a54de4b189fe31c7121b6247c", "params": {"MIX_L": "306134662258387392", "MIX_S": "0", "R_DECAY": "953316174179562240", "S_DECAY": "0", "R_SCALE": "1227886893888040192", "S_SCALE": "1000000000000000000", "V_COEF": "0", "CORR_C": "0", "CORR_B": "0", "FIRST_W": "840842894745907072"}, "mean_diff": -0.35735458531224573, "se": 0.0958657581819635, "gas": {"max_ok": 218026, "oog": 0, "halts": 0, "init_max": 220984}, "valid": true}, {"structure": "A", "gen": 1, "seeds": [640032, 640063], "sha256": "4b9561c8905dc5a4b93f778856b7e5fb2c089ad1b34066596cd5b9cd6dafdb75", "params": {"MIX_L": "390136357137319040", "MIX_S": "0", "R_DECAY": "927795226127938432", "S_DECAY": "0", "R_SCALE": "1585511183358941952", "S_SCALE": "1000000000000000000", "V_COEF": "0", "CORR_C": "0", "CORR_B": "0", "FIRST_W": "568544127561791616"}, "mean_diff": -0.5279682524870939, "se": 0.09841170602320536, "gas": {"max_ok": 218026, "oog": 0, "halts": 0, "init_max": 220984}, "valid": true}, {"structure": "A", "gen": 1, "seeds": [640032, 640063], "sha256": "dfb98a30fce792a09605acbf2b1ac67e52caaec7a5a7ad797c911b01120b6221", "params": {"MIX_L": "381949359178020224", "MIX_S": "0", "R_DECAY": "957699481793291776", "S_DECAY": "0", "R_SCALE": "2010310064055017216", "S_SCALE": "1000000000000000000", "V_COEF": "0", "CORR_C": "0", "CORR_B": "0", "FIRST_W": "797371815457598336"}, "mean_diff": -0.2694902681621709, "se": 0.06398712046883596, "gas": {"max_ok": 218026, "oog": 0, "halts": 0, "init_max": 220984}, "valid": true}, {"structure": "B", "gen": 0, "seeds": [640064, 640095], "sha256": "070a47a37f719be048b6430033147bb30a74ed9cd20b32da3b203e7964ba779e", "params": {"MIX_L": "186349261235137888", "MIX_S": "428512360071654016", "R_DECAY": "963689378715390720", "S_DECAY": "929611795520724096", "R_SCALE": "918043821488097792", "S_SCALE": "667945247497110144", "V_COEF": "121400828774491328", "CORR_C": "0", "CORR_B": "0", "FIRST_W": "901688963534363904"}, "mean_diff": 0.017863841477325337, "se": 0.11654680645410553, "gas": {"max_ok": 215105, "oog": 0, "halts": 0, "init_max": 220984}, "valid": true}, {"structure": "B", "gen": 0, "seeds": [640064, 640095], "sha256": "513bd771211d61e04ca6da978e7342d1f312b17f391dd52392d6a26407af6f85", "params": {"MIX_L": "126061509740241968", "MIX_S": "666935065825003264", "R_DECAY": "943933788170298368", "S_DECAY": "921673701815706752", "R_SCALE": "1406074841340061952", "S_SCALE": "978317081160498304", "V_COEF": "120714274244158864", "CORR_C": "0", "CORR_B": "0", "FIRST_W": "589301109294855296"}, "mean_diff": -1.2411185346010534, "se": 0.21243425116837764, "gas": {"max_ok": 215096, "oog": 0, "halts": 0, "init_max": 220984}, "valid": true}, {"structure": "B", "gen": 0, "seeds": [640064, 640095], "sha256": "849c49abe8d3d26392aed99c558825296f4ddef8d79b7abcd833b90442745281", "params": {"MIX_L": "89737842970979840", "MIX_S": "116220560629027776", "R_DECAY": "929220746427945216", "S_DECAY": "871597924832832384", "R_SCALE": "1560233863206666496", "S_SCALE": "1533397036457766144", "V_COEF": "89572637695860368", "CORR_C": "0", "CORR_B": "0", "FIRST_W": "868957136231940736"}, "mean_diff": -0.06496960877435498, "se": 0.09673259559824103, "gas": {"max_ok": 215086, "oog": 0, "halts": 0, "init_max": 220984}, "valid": true}, {"structure": "C", "gen": 0, "seeds": [640096, 640127], "sha256": "2443191a879d2c0753cb269f8a60e3477b52fafd24f92b6d39dd01ace06834af", "params": {"MIX_L": "589398249591421440", "MIX_S": "96530433690107168", "R_DECAY": "967593384523785216", "S_DECAY": "853271724176320768", "R_SCALE": "1010295525684984832", "S_SCALE": "1077081989820423168", "V_COEF": "69599109450575600", "CORR_C": "654553423927973248", "CORR_B": "78897433398259120", "FIRST_W": "945958347576469504"}, "mean_diff": -1.6953890279263035, "se": 0.1899344375849989, "gas": {"max_ok": 215530, "oog": 0, "halts": 0, "init_max": 220987}, "valid": true}, {"structure": "C", "gen": 0, "seeds": [640096, 640127], "sha256": "c2ad30238d7fbdf65a5bb0727c0dd93cf284973271662641b32613cd63c6bd72", "params": {"MIX_L": "63938288418202744", "MIX_S": "381185224395575104", "R_DECAY": "934699941485532672", "S_DECAY": "871012479342621952", "R_SCALE": "1529975279658772480", "S_SCALE": "637550198832780416", "V_COEF": "198835715522965120", "CORR_C": "498001037856964480", "CORR_B": "349690011097014656", "FIRST_W": "932729020075724800"}, "mean_diff": 0.03229193667968211, "se": 0.13286718532097863, "gas": {"max_ok": 215540, "oog": 0, "halts": 0, "init_max": 220987}, "valid": true}, {"structure": "C", "gen": 0, "seeds": [640096, 640127], "sha256": "de391f5ce8120b6bc6cdbb4a5b398b25da1d901cb22afd3931928ba9af1617d5", "params": {"MIX_L": "97208736839318288", "MIX_S": "365976343805026688", "R_DECAY": "954763670217833728", "S_DECAY": "885902719308659712", "R_SCALE": "773303862660854400", "S_SCALE": "722010222045784832", "V_COEF": "212519832015945536", "CORR_C": "533672291176834816", "CORR_B": "350185795573288896", "FIRST_W": "800657826587715200"}, "mean_diff": 0.17134318857727493, "se": 0.11424700048366934, "gas": {"max_ok": 215549, "oog": 0, "halts": 0, "init_max": 220987}, "valid": true}]}, "seed_ledger": {"search": [[640000, 640127]], "recheck_partial": [[644000, 644063]], "recheck_planned_not_run": [[644064, 644255]], "heldout_planned_not_run": [[645000, 645511]], "confirmation_ge_5000000": "none used", "seeds_dropped": 0}, "recheck_partial": {"seeds": [644000, 644063], "v10_sha": "cd9bdb45ab0537ad25c4fd90ca8618898cef6386de3df65f192eaef65fbca245", "v10_gas": {"max_ok": 188238, "oog": 0, "halts": 0, "init_max": 220981}, "v10_mean": 510.01304277044426, "arms": [{"sha256": "de391f5ce8120b6bc6cdbb4a5b398b25da1d901cb22afd3931928ba9af1617d5", "structure": "C", "params": {"MIX_L": "97208736839318288", "MIX_S": "365976343805026688", "R_DECAY": "954763670217833728", "S_DECAY": "885902719308659712", "R_SCALE": "773303862660854400", "S_SCALE": "722010222045784832", "V_COEF": "212519832015945536", "CORR_C": "533672291176834816", "CORR_B": "350185795573288896", "FIRST_W": "800657826587715200"}, "paired": {"n": 64, "mean_diff": 0.03312445117171414, "se": 0.07237888017058114, "worst": [{"seed": 644025, "d": -1.3008942021191388}, {"seed": 644021, "d": -1.2797118644144803}, {"seed": 644010, "d": -1.20081691886503}, {"seed": 644059, "d": -1.0195917419219995}, {"seed": 644054, "d": -0.8078690932482004}]}, "arb_delta": {"mean": 1.4794094948523184, "se": 0.055811695707639025}, "retail_delta": {"mean": -1.4462850436806054, "se": 0.08568381348589892}, "reconciliation_max_abs": 9.947598300641403e-14, "gas": {"max_ok": 210819, "oog": 0, "halts": 0, "init_max": 220987}}, {"sha256": "c2ad30238d7fbdf65a5bb0727c0dd93cf284973271662641b32613cd63c6bd72", "structure": "C", "params": {"MIX_L": "63938288418202744", "MIX_S": "381185224395575104", "R_DECAY": "934699941485532672", "S_DECAY": "871012479342621952", "R_SCALE": "1529975279658772480", "S_SCALE": "637550198832780416", "V_COEF": "198835715522965120", "CORR_C": "498001037856964480", "CORR_B": "349690011097014656", "FIRST_W": "932729020075724800"}, "paired": {"n": 64, "mean_diff": -0.11681762245460536, "se": 0.09388048973471058, "worst": [{"seed": 644010, "d": -2.069414362350699}, {"seed": 644025, "d": -1.8751703003923694}, {"seed": 644021, "d": -1.4727625196221084}, {"seed": 644059, "d": -1.3814497925884552}, {"seed": 644048, "d": -1.3701269407598602}]}, "arb_delta": {"mean": 2.124804276646458, "se": 0.06075354942050605}, "retail_delta": {"mean": -2.241621899101058, "se": 0.10320199169407478}, "reconciliation_max_abs": 1.1368683772161603e-13, "gas": {"max_ok": 210810, "oog": 0, "halts": 0, "init_max": 220987}}], "elapsed": 420.47535967826843}, "paired": {"n": 64, "mean_diff": 0.03312445117171414, "se": 0.07237888017058114, "worst": [{"seed": 644025, "d": -1.3008942021191388}, {"seed": 644021, "d": -1.2797118644144803}, {"seed": 644010, "d": -1.20081691886503}, {"seed": 644059, "d": -1.0195917419219995}, {"seed": 644054, "d": -0.8078690932482004}], "block": "644000..644063 partial recheck (not held-out)", "vs": "V10", "se_kind": "sample SE (ddof=1)"}, "retail_edge_delta": {"mean": -1.4462850436806054, "se": 0.08568381348589892}, "arb_edge_delta": {"mean": 1.4794094948523184, "se": 0.055811695707639025}, "reconciliation": {"max_abs": 9.947598300641403e-14, "method": "V10 harness decomposition: reconstructed arb from fair price, previous spot and fees; retail = total - arb"}, "gas": {"candidate": {"afterSwap_max_ok": 210819, "oog": 0, "all_halts": 0, "afterInitialize_max": 220987}, "V10": {"afterSwap_max_ok": 188238, "oog": 0, "all_halts": 0, "afterInitialize_max": 220981}, "note": "Every searched arm had 0 OOG and 0 halts. The maximum afterSwap across the search was 218026 (<235k)."}, "validation": "amm-match validate contracts/src/C1.sol: Strategy 'censored_10' validated successfully. getName is unchanged from V10.", "findings": ["A (weighted counts alone, mix about 0.5) lost on all 6 candidates, -0.27 to -0.61 vs V10 on 32 seeds.", "B (counts plus size moments) ranged from -1.24 to +0.018; only small mixes were near neutral.", "C (plus bounded missing-flow correction) ranged from -1.70 to +0.17 on 32 seeds, but the top 2 regressed to +0.033 +/- 0.072 and -0.117 +/- 0.094 on the 64-seed recheck.", "The mechanism moves edge from retail (-1.45) to arb (+1.48): higher flow-driven fees protect against arb and lose retail. No net gain is resolved."], "limitations": ["Incomplete. The 256-seed recheck was cut to 64 seeds, the 512-seed held-out run 645000..645511 was not run, and no hash was frozen by protocol.", "Only 4 ES generations and 12 candidates in total, far short of a converged search.", "Paired gain vs V10 is not significant; the +5 goal is not approached.", "Missing-flow correction is a heuristic fee-ratio clamp, not a derived routing likelihood."], "seeds_kind": "tuning", "board_claim": null}