{"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\n    int256 constant VQ_GAIN = 150000000000000000;\n    uint256 constant VQ_CAP = 800000000000000;\n    int256 constant VQ_MARGIN = 400000000000000;\n    uint256 constant ELAPSED_CAP = 8;\n    uint256 constant SIGNAL_THRESHOLD = WAD / 650;\n    uint256 constant DIR_DECAY = 750000000000000000;\n    uint256 constant ACT_DECAY = 530000000000000000;\n    uint256 constant SIZE_DECAY = 530000000000000000;\n    uint256 constant TOX_DECAY = 910000000000000000;\n    uint256 constant SIGMA_DECAY = 690000000000000000;\n    uint256 constant LAMBDA_DECAY = 990000000000000000;\n    uint256 constant SIZE_BLEND_DECAY = 828000000000000000;\n    uint256 constant TOX_BLEND_DECAY = 51000000000000000;\n    uint256 constant ACT_BLEND_DECAY = 985000000000000000;\n    uint256 constant PHAT_ALPHA = 270000000000000000;\n    uint256 constant PHAT_ALPHA_RETAIL = 60000000000000000;\n    uint256 constant PHAT_ALPHA_SAME = 120000000000000000;\n    uint256 constant REVERT_U = 0;\n    uint256 constant DIR_IMPACT_MULT = 4;\n    uint256 constant GATE_SIGMA_MULT = 7200000000000000000;\n    uint256 constant MIN_GATE = 30000000000000000;\n    uint256 constant TRADE_TOX_BOOST = 3500 * BPS;\n    uint256 constant STALE_ATTRACT_FRAC = 1050000000000000000;\n    uint256 constant RET_CAP = WAD / 35;\n    uint256 constant TOX_CAP = WAD / 5;\n    uint256 constant TRADE_RATIO_CAP = WAD / 5;\n    uint256 constant LAMBDA_CAP = 1820000000000000000;\n    uint256 constant STEP_COUNT_CAP = 64;\n    uint256 constant BASE_FEE = 4 * BPS;\n    uint256 constant SIGMA_COEF = 200000000000000000;\n    uint256 constant LAMBDA_COEF = 12 * BPS;\n    uint256 constant FLOW_SIZE_COEF = 4842 * BPS;\n    uint256 constant TOX_COEF = 300 * BPS;\n    uint256 constant TOX_QUAD_COEF = 15000 * BPS;\n    uint256 constant ACT_COEF = 91843 * BPS;\n    uint256 constant DIR_COEF = 20 * BPS;\n    uint256 constant DIR_TOX_COEF = 100 * BPS;\n    uint256 constant STALE_DIR_COEF = 6850 * BPS;\n    uint256 constant SIGMA_TOX_COEF = 500 * BPS;\n    uint256 constant TAIL_KNEE = 600 * BPS;\n    uint256 constant TAIL_SLOPE_PROTECT = 930000000000000000;\n    uint256 constant TAIL_SLOPE_ATTRACT = 850000000000000000;\n\n    function afterInitialize(uint256 initialX, uint256 initialY) external override returns (uint256, uint256) {\n        slots[0] = BASE_FEE; slots[1] = BASE_FEE; slots[3] = WAD; \n        slots[5] = initialX > 0 ? wdiv(initialY, initialX) : 100 * WAD;\n        slots[6] = 950000000000000; slots[7] = 800000000000000000; slots[8] = 2000000000000000;\n        slots[15] = 400000000000000000 | (uint256(2000000000000000) << 160); slots[13] = 902500000000; slots[14] = slots[5]; \n        return (BASE_FEE, BASE_FEE);\n    }\n\n    function afterSwap(TradeInfo calldata trade) external override returns (uint256, uint256) {\n        uint256 prevBidFee = slots[0]; uint256 prevAskFee = slots[1]; uint256 lastTs = uint64(slots[2]);\n        uint256 dirState = slots[3]; uint256 actEma = slots[4]; uint256 pHat = slots[5];\n        uint256 sigmaHat = slots[6]; uint256 lambdaHat = slots[7]; uint256 sizeHat = slots[8];\n        uint256 toxEma = slots[9]; uint256 stepTradeCount = slots[10];\n\n        uint256 sigmaForFast = sigmaHat;\n        uint256 fastHat = slots[14];\n        uint256 uncertainty = slots[13];\n        uint256 silent = trade.timestamp > lastTs ? trade.timestamp - lastTs : 0;\n        bool isNewStep = trade.timestamp > lastTs;\n        if (isNewStep) {\n            uint256 elapsedRaw = trade.timestamp - lastTs;\n            uint256 elapsed = elapsedRaw > ELAPSED_CAP ? ELAPSED_CAP : elapsedRaw;\n            dirState = _decayCentered(dirState, DIR_DECAY, elapsed);\n            actEma = wmul(actEma, _powWad(ACT_DECAY, elapsed));\n            sizeHat = wmul(sizeHat, _powWad(SIZE_DECAY, elapsed));\n            toxEma = wmul(toxEma, _powWad(TOX_DECAY, elapsed));\n            if (stepTradeCount > 0 && elapsedRaw > 0) {\n                uint256 lambdaInst = (stepTradeCount * WAD) / elapsedRaw;\n                if (lambdaInst > LAMBDA_CAP) lambdaInst = LAMBDA_CAP;\n                lambdaHat = wmul(lambdaHat, LAMBDA_DECAY) + wmul(lambdaInst, WAD - LAMBDA_DECAY);\n            }\n            // Process variance is propagated inside the censored update.\n            if (uncertainty > 100000000000000) uncertainty = 100000000000000;\n            stepTradeCount = 0;\n        }\n\n        bool firstInStep = stepTradeCount == 0;\n        uint256 spot = trade.reserveX > 0 ? wdiv(trade.reserveY, trade.reserveX) : pHat;\n        if (pHat == 0) pHat = spot;\n\n        uint256 feeUsed = trade.isBuy ? prevBidFee : prevAskFee;\n        uint256 gamma = feeUsed < WAD ? WAD - feeUsed : 0;\n        uint256 pImplied;\n        if (gamma == 0) { pImplied = spot; }\n        else { pImplied = trade.isBuy ? wmul(spot, gamma) : wdiv(spot, gamma); }\n\n        // S: infer a no-trade interval center from the last post-trade spot.\n        uint256 silenceScale = WAD;\n        if (firstInStep && silent > 1) {\n            uint256 g = silent - 1;\n            if (g > 1) g = 1;\n            uint256 w = WAD - _powWad(800000000000000000, g);\n            uint256 s = slots[2] >> 64;\n            if (s == 0) s = pHat;\n            uint256 c = (wmul(s, WAD - prevBidFee) + wdiv(s, WAD - prevAskFee)) / 2;\n            if (c >= pHat) pHat += wmul(w, c - pHat);\n            else pHat -= wmul(w, pHat - c);\n            silenceScale = WAD - wmul(300000000000000000, w);\n        }\n\n        {\n            uint256 ret = pHat > 0 ? wdiv(absDiff(pImplied, pHat), pHat) : 0;\n            uint256 alpha = firstInStep ? PHAT_ALPHA : PHAT_ALPHA_RETAIL;\n            uint256 prePhat = pHat;\n            bool secondPrint = !firstInStep && stepTradeCount == 1;\n            bool sameDir = false; bool oppDir = false;\n            if (secondPrint) {\n                bool up2 = pImplied >= pHat;\n                uint256 d1 = slots[12];\n                if (d1 != 0) { sameDir = (d1 == 1) == up2; oppDir = !sameDir; }\n                if (sameDir) alpha = PHAT_ALPHA_SAME;\n            }\n            if (firstInStep) { slots[12] = pImplied >= pHat ? 1 : 2; }\n            uint256 adaptiveGate = wmul(sigmaHat, GATE_SIGMA_MULT);\n            if (adaptiveGate < MIN_GATE) adaptiveGate = MIN_GATE;\n            alpha = wmul(alpha, silenceScale);\n            adaptiveGate = wmul(adaptiveGate, silenceScale);\n            if (ret <= adaptiveGate) { pHat = wmul(pHat, WAD - alpha) + wmul(pImplied, alpha); }\n            if (oppDir && REVERT_U > 0) {\n                uint256 pre = slots[11];\n                if (pre > pHat) pHat = pHat + wmul(pre - pHat, REVERT_U);\n                else pHat = pHat - wmul(pHat - pre, REVERT_U);\n            }\n            if (firstInStep) {\n                if (ret > RET_CAP) ret = RET_CAP;\n                sigmaHat = wmul(sigmaHat, SIGMA_DECAY) + wmul(ret, WAD - SIGMA_DECAY);\n            }\n        }\n\n        // Interior retail routing equalizes fee-adjusted marginal prices.\n        // Subsequent trades in a step cannot be the initial arbitrage trade.\n        if (!firstInStep && feeUsed > 30 * BPS && gamma > 0) {\n            uint256 normalSpot = trade.isBuy\n                ? wdiv(wmul(spot, gamma), WAD - 30 * BPS)\n                : wdiv(wmul(spot, WAD - 30 * BPS), gamma);\n            pHat = wmul(pHat, 90 * WAD / 100) + wmul(normalSpot, 10 * WAD / 100);\n        }\n\n        // Censored assumed-density posterior. No external or future inputs.\n        uint256 arbProbability;\n        (fastHat, uncertainty, arbProbability) = _posterior(PosteriorInput(\n            fastHat, uncertainty, pImplied, spot, slots[2] >> 64,\n            prevBidFee, prevAskFee, firstInStep, silent, trade.isBuy,\n            trade.reserveY > 0 ? wdiv(trade.amountY, trade.reserveY) : 0\n        ));\n        slots[13] = uncertainty;\n        slots[14] = fastHat;\n        uint256 tradeRatio = trade.reserveY > 0 ? wdiv(trade.amountY, trade.reserveY) : 0;\n        if (tradeRatio > TRADE_RATIO_CAP) tradeRatio = TRADE_RATIO_CAP;\n\n        if (tradeRatio > SIGNAL_THRESHOLD) {\n            uint256 push = tradeRatio * DIR_IMPACT_MULT;\n            if (push > WAD / 4) push = WAD / 4;\n            if (trade.isBuy) {\n                dirState = dirState + push;\n                if (dirState > 2 * WAD) dirState = 2 * WAD;\n            } else {\n                dirState = dirState > push ? dirState - push : 0;\n            }\n            actEma = wmul(actEma, ACT_BLEND_DECAY) + wmul(tradeRatio, WAD - ACT_BLEND_DECAY);\n            sizeHat = wmul(sizeHat, SIZE_BLEND_DECAY) + wmul(tradeRatio, WAD - SIZE_BLEND_DECAY);\n            if (sizeHat > WAD) sizeHat = WAD;\n        }\n\n        uint256 tox = pHat > 0 ? wdiv(absDiff(spot, pHat), pHat) : 0;\n        if (tox > TOX_CAP) tox = TOX_CAP;\n        toxEma = wmul(toxEma, TOX_BLEND_DECAY) + wmul(tox, WAD - TOX_BLEND_DECAY);\n        uint256 toxSignal = toxEma;\n\n        stepTradeCount = stepTradeCount + 1;\n        if (stepTradeCount > STEP_COUNT_CAP) stepTradeCount = STEP_COUNT_CAP;\n\n        uint256 originalLambda = lambdaHat; uint256 originalSize = sizeHat;\n\n        if (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            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        if (VQ_GAIN != 0) {\n            (bidFee,askFee)=_vanillaQuote(trade,\n                wmul(pHat,700000000000000000)+wmul(fastHat,300000000000000000),\n                spot,feeUsed,!firstInStep || arbProbability<WAD/2,bidFee,askFee);\n        }\n\n        slots[0] = bidFee; slots[1] = askFee; slots[2] = (spot << 64) | trade.timestamp;\n        slots[3] = dirState; slots[4] = actEma; slots[5] = pHat;\n        slots[6] = sigmaHat; slots[7] = lambdaHat; slots[8] = sizeHat;\n        slots[9] = toxEma; slots[10] = stepTradeCount;\n\n        return (bidFee, askFee);\n    }\n\n\n\n    // Two lazy virtual-reserve slots; initialization callback is unchanged.\n    function _vanillaQuote(TradeInfo calldata t, uint256 estimate, uint256 ownSpot,\n        uint256 usedFee, bool retail, uint256 bid, uint256 ask)\n        internal returns (uint256, uint256)\n    {\n        uint256 vx=slots[16]; uint256 vy=slots[17];\n        uint256 k;\n        bool firstModel = vx==0;\n        if (vy==0) {\n            k=wmul(t.reserveX,t.reserveY);\n            if (firstModel) vx=_isqrt(wdiv(k,slots[5])*WAD);\n            vy=wdiv(k,vx);\n        } else { k=wmul(vx,vy); }\n        uint256 vg=WAD-30*BPS;\n        uint256 vs=wdiv(vy,vx);\n        // Project to the closest edge only if outside Vanilla's no-arb band.\n        if (wmul(vs,vg)>estimate) vs=wdiv(estimate,vg);\n        else if (wdiv(vs,vg)<estimate) vs=wmul(estimate,vg);\n        if (retail && usedFee<WAD) {\n            uint256 routed=t.isBuy ? wdiv(wmul(ownSpot,WAD-usedFee),vg)\n                : wdiv(wmul(ownSpot,vg),WAD-usedFee);\n            // A corner route cannot move the competitor against the order.\n            if ((t.isBuy && routed<vs) || (!t.isBuy && routed>vs)) vs=routed;\n        }\n        vx=_isqrt(wdiv(k,vs)*WAD);\n        vy=wdiv(k,vx);\n        slots[16]=vx;\n        // Stagger zero-to-nonzero writes; recover missing Y from invariant.\n        if (!firstModel) slots[17]=vy;\n        bool attractAsk=ownSpot>=estimate;\n        // Fee-adjusted marginal quote of the virtual Vanilla pool.\n        uint256 ratio=attractAsk ? wdiv(wmul(ownSpot,vg),vs)\n            : wdiv(wmul(vs,vg),ownSpot);\n        int256 target=int256(WAD)-int256(ratio)-VQ_MARGIN;\n        uint256 old=attractAsk?ask:bid;\n        int256 delta=(target-int256(old))*VQ_GAIN/int256(WAD);\n        int256 cap=int256(VQ_CAP);\n        if (delta>cap) delta=cap;\n        if (delta < -cap) delta= -cap;\n        int256 next=int256(old)+delta;\n        uint256 fee=next>0?clampFee(uint256(next)):0;\n        if (attractAsk) ask=fee; else bid=fee;\n        return (bid,ask);\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":"f61c0f28d8a55c3030e811777cf451549a075ddf23e1de453edd10309d4a1452","params":{"g":0.15,"c_bps":8.0,"m_bps":4.0},"mechanism":"Two lazily populated slots track constant-product virtual reserves for the 30 bps Vanilla pool; each own callback projects its spot into the RS2 price estimate's arbitrage band and inferred retail fills update it toward the router's equal-marginal-price condition. The attracting fee moves by g times the difference from the fee matching Vanilla's modelled marginal quote minus m, with the adjustment clipped to plus or minus c bps and the resulting fee clamped to the strategy's allowed range.","source":{"url":"https://benedict.dev/optimization-arena-learnings","quote":"fully model the competitor AMM"},"generator_source":"def generate(template, g=0.0, c_bps=10.0, m_bps=0.0):\n    import re\n    values = {\"VQ_GAIN\": round(g * 10**18),\n              \"VQ_CAP\": round(c_bps * 10**14),\n              \"VQ_MARGIN\": round(m_bps * 10**14)}\n    assert c_bps >= 0\n    for name, value in values.items():\n        template, count = re.subn(r\"(constant \" + name + r\" = )-?\\d+;\",\n                                  lambda match: match.group(1) + str(value) + \";\",\n                                  template)\n        assert count == 1\n    return template\n","generator_usage":"generate(result[\"code\"], g, c_bps, m_bps); g=0 is neutral. Parameters are compiled constants, not additional storage.","search":{"seed":82,"method":"seeded shuffled partial grid","evaluations":55,"elapsed_seconds":1516.1074982080027,"budget_seconds":1500,"block_n":64,"seed_range":[965000,967999],"common_block_for_each_eight_trials":true,"blocks":[965375,965663,966349,966510,966644,966763,966781],"gain_grid":[-0.15,-0.5,-1,0.15,0.5,1,2],"cap_bps_grid":[2,8,24],"margin_bps_grid":[-4,0,4,12],"neutral_control":[0,0,0],"best":{"index":9,"params":{"g":0.15,"c_bps":8.0,"m_bps":4.0},"start":966510,"n":64,"mean_diff":0.1914065259852471,"se":0.05619301660257274,"valid":true,"gas":{"max_ok":225557,"init_max_ok":243118,"oog":0,"errors":0}},"invalid_trials":0,"oog_across_search":0,"top_ten_valid":[{"index":9,"params":{"g":0.15,"c_bps":8.0,"m_bps":4.0},"start":966510,"n":64,"mean_diff":0.1914065259852471,"se":0.05619301660257274,"valid":true,"gas":{"max_ok":225557,"init_max_ok":243118,"oog":0,"errors":0}},{"index":38,"params":{"g":0.15,"c_bps":8.0,"m_bps":0.0},"start":966349,"n":64,"mean_diff":0.11577213844142076,"se":0.04286838886312181,"valid":true,"gas":{"max_ok":225517,"init_max_ok":243118,"oog":0,"errors":0}},{"index":12,"params":{"g":0.15,"c_bps":2.0,"m_bps":0.0},"start":966510,"n":64,"mean_diff":0.11531294102906653,"se":0.043303521270969245,"valid":true,"gas":{"max_ok":229173,"init_max_ok":243118,"oog":0,"errors":0}},{"index":17,"params":{"g":0.15,"c_bps":24.0,"m_bps":4.0},"start":966644,"n":64,"mean_diff":0.11522188887701645,"se":0.05605623347535182,"valid":true,"gas":{"max_ok":225553,"init_max_ok":243118,"oog":0,"errors":0}},{"index":31,"params":{"g":2.0,"c_bps":2.0,"m_bps":4.0},"start":966781,"n":64,"mean_diff":0.10749240278247463,"se":0.050367052416410464,"valid":true,"gas":{"max_ok":225584,"init_max_ok":243118,"oog":0,"errors":0}},{"index":25,"params":{"g":1.0,"c_bps":2.0,"m_bps":4.0},"start":966781,"n":64,"mean_diff":0.1026896228824743,"se":0.044047925489505466,"valid":true,"gas":{"max_ok":225581,"init_max_ok":243118,"oog":0,"errors":0}},{"index":21,"params":{"g":0.15,"c_bps":2.0,"m_bps":4.0},"start":966644,"n":64,"mean_diff":0.09694650497323742,"se":0.04101610064460102,"valid":true,"gas":{"max_ok":228584,"init_max_ok":243118,"oog":0,"errors":0}},{"index":34,"params":{"g":0.15,"c_bps":2.0,"m_bps":12.0},"start":966349,"n":64,"mean_diff":0.06812801957444314,"se":0.03716303131245892,"valid":true,"gas":{"max_ok":225573,"init_max_ok":243118,"oog":0,"errors":0}},{"index":37,"params":{"g":0.5,"c_bps":2.0,"m_bps":12.0},"start":966349,"n":64,"mean_diff":0.03352903076647262,"se":0.04209691886869642,"valid":true,"gas":{"max_ok":225573,"init_max_ok":243118,"oog":0,"errors":0}},{"index":18,"params":{"g":0.15,"c_bps":24.0,"m_bps":0.0},"start":966644,"n":64,"mean_diff":0.008871130088823342,"se":0.054764127673337784,"valid":true,"gas":{"max_ok":225516,"init_max_ok":243118,"oog":0,"errors":0}}],"evaluations_summary":[{"index":0,"params":{"g":0.0,"c_bps":0.0,"m_bps":0.0},"start":965663,"n":64,"mean_diff":0.0,"se":0.0,"valid":true,"gas":{"max_ok":200152,"init_max_ok":243099,"oog":0,"errors":0}},{"index":1,"params":{"g":-1.0,"c_bps":2.0,"m_bps":4.0},"start":965663,"n":64,"mean_diff":-1.4081367549985098,"se":0.060180174686634114,"valid":true,"gas":{"max_ok":228517,"init_max_ok":243118,"oog":0,"errors":0}},{"index":2,"params":{"g":-0.5,"c_bps":8.0,"m_bps":12.0},"start":965663,"n":64,"mean_diff":-4.077301162991102,"se":0.09343257351328502,"valid":true,"gas":{"max_ok":228517,"init_max_ok":243118,"oog":0,"errors":0}},{"index":3,"params":{"g":1.0,"c_bps":8.0,"m_bps":-4.0},"start":965663,"n":64,"mean_diff":-3.2249193580514115,"se":0.11201203790378582,"valid":true,"gas":{"max_ok":228429,"init_max_ok":243106,"oog":0,"errors":0}},{"index":4,"params":{"g":0.15,"c_bps":8.0,"m_bps":-4.0},"start":965663,"n":64,"mean_diff":-0.021952282358864927,"se":0.04755518251412776,"valid":true,"gas":{"max_ok":228413,"init_max_ok":243106,"oog":0,"errors":0}},{"index":5,"params":{"g":-0.5,"c_bps":8.0,"m_bps":4.0},"start":965663,"n":64,"mean_diff":-3.4606716716506423,"se":0.07876272642182004,"valid":true,"gas":{"max_ok":228517,"init_max_ok":243118,"oog":0,"errors":0}},{"index":6,"params":{"g":-0.15,"c_bps":8.0,"m_bps":-4.0},"start":965663,"n":64,"mean_diff":-1.4520581930128245,"se":0.054675137396757945,"valid":true,"gas":{"max_ok":228416,"init_max_ok":243106,"oog":0,"errors":0}},{"index":7,"params":{"g":-0.15,"c_bps":24.0,"m_bps":12.0},"start":965663,"n":64,"mean_diff":-2.053582594698841,"se":0.07223899332470123,"valid":true,"gas":{"max_ok":228498,"init_max_ok":243118,"oog":0,"errors":0}},{"index":8,"params":{"g":-0.5,"c_bps":24.0,"m_bps":12.0},"start":966510,"n":64,"mean_diff":-6.830336599430206,"se":0.17567591352784265,"valid":true,"gas":{"max_ok":229038,"init_max_ok":243118,"oog":0,"errors":0}},{"index":9,"params":{"g":0.15,"c_bps":8.0,"m_bps":4.0},"start":966510,"n":64,"mean_diff":0.1914065259852471,"se":0.05619301660257274,"valid":true,"gas":{"max_ok":225557,"init_max_ok":243118,"oog":0,"errors":0}},{"index":10,"params":{"g":1.0,"c_bps":8.0,"m_bps":0.0},"start":966510,"n":64,"mean_diff":-1.9169946284674557,"se":0.09127476941694819,"valid":true,"gas":{"max_ok":228998,"init_max_ok":243118,"oog":0,"errors":0}},{"index":11,"params":{"g":-0.15,"c_bps":2.0,"m_bps":12.0},"start":966510,"n":64,"mean_diff":-1.115806073854122,"se":0.04673518771564263,"valid":true,"gas":{"max_ok":229213,"init_max_ok":243118,"oog":0,"errors":0}},{"index":12,"params":{"g":0.15,"c_bps":2.0,"m_bps":0.0},"start":966510,"n":64,"mean_diff":0.11531294102906653,"se":0.043303521270969245,"valid":true,"gas":{"max_ok":229173,"init_max_ok":243118,"oog":0,"errors":0}},{"index":13,"params":{"g":0.5,"c_bps":2.0,"m_bps":-4.0},"start":966510,"n":64,"mean_diff":-0.49989751263279025,"se":0.05402015698416182,"valid":true,"gas":{"max_ok":229166,"init_max_ok":243106,"oog":0,"errors":0}},{"index":14,"params":{"g":2.0,"c_bps":2.0,"m_bps":12.0},"start":966510,"n":64,"mean_diff":0.003761351163547033,"se":0.044048139095512646,"valid":true,"gas":{"max_ok":225576,"init_max_ok":243118,"oog":0,"errors":0}},{"index":15,"params":{"g":-1.0,"c_bps":8.0,"m_bps":0.0},"start":966510,"n":64,"mean_diff":-4.084213580951419,"se":0.0951124850821832,"valid":true,"gas":{"max_ok":225542,"init_max_ok":243118,"oog":0,"errors":0}},{"index":16,"params":{"g":-1.0,"c_bps":2.0,"m_bps":12.0},"start":966644,"n":64,"mean_diff":-1.337662696867822,"se":0.06902010590656238,"valid":true,"gas":{"max_ok":228587,"init_max_ok":243118,"oog":0,"errors":0}},{"index":17,"params":{"g":0.15,"c_bps":24.0,"m_bps":4.0},"start":966644,"n":64,"mean_diff":0.11522188887701645,"se":0.05605623347535182,"valid":true,"gas":{"max_ok":225553,"init_max_ok":243118,"oog":0,"errors":0}},{"index":18,"params":{"g":0.15,"c_bps":24.0,"m_bps":0.0},"start":966644,"n":64,"mean_diff":0.008871130088823342,"se":0.054764127673337784,"valid":true,"gas":{"max_ok":225516,"init_max_ok":243118,"oog":0,"errors":0}},{"index":19,"params":{"g":-0.5,"c_bps":24.0,"m_bps":4.0},"start":966644,"n":64,"mean_diff":-5.608843456384931,"se":0.17789187956706898,"valid":true,"gas":{"max_ok":228568,"init_max_ok":243118,"oog":0,"errors":0}},{"index":20,"params":{"g":-0.15,"c_bps":24.0,"m_bps":4.0},"start":966644,"n":64,"mean_diff":-1.6259683343934643,"se":0.08183893837149296,"valid":true,"gas":{"max_ok":228568,"init_max_ok":243118,"oog":0,"errors":0}},{"index":21,"params":{"g":0.15,"c_bps":2.0,"m_bps":4.0},"start":966644,"n":64,"mean_diff":0.09694650497323742,"se":0.04101610064460102,"valid":true,"gas":{"max_ok":228584,"init_max_ok":243118,"oog":0,"errors":0}},{"index":22,"params":{"g":0.5,"c_bps":8.0,"m_bps":-4.0},"start":966644,"n":64,"mean_diff":-2.07572622704929,"se":0.09832653997198713,"valid":true,"gas":{"max_ok":225530,"init_max_ok":243106,"oog":0,"errors":0}},{"index":23,"params":{"g":-1.0,"c_bps":8.0,"m_bps":4.0},"start":966644,"n":64,"mean_diff":-4.435205888125314,"se":0.11498937094990268,"valid":true,"gas":{"max_ok":228587,"init_max_ok":243118,"oog":0,"errors":0}},{"index":24,"params":{"g":-0.5,"c_bps":2.0,"m_bps":12.0},"start":966781,"n":64,"mean_diff":-1.2708141711484044,"se":0.060410371220614746,"valid":true,"gas":{"max_ok":225587,"init_max_ok":243118,"oog":0,"errors":0}},{"index":25,"params":{"g":1.0,"c_bps":2.0,"m_bps":4.0},"start":966781,"n":64,"mean_diff":0.1026896228824743,"se":0.044047925489505466,"valid":true,"gas":{"max_ok":225581,"init_max_ok":243118,"oog":0,"errors":0}},{"index":26,"params":{"g":2.0,"c_bps":24.0,"m_bps":0.0},"start":966781,"n":64,"mean_diff":-13.644551427468635,"se":0.2543036594837525,"valid":true,"gas":{"max_ok":220707,"init_max_ok":243118,"oog":0,"errors":0}},{"index":27,"params":{"g":-1.0,"c_bps":2.0,"m_bps":0.0},"start":966781,"n":64,"mean_diff":-0.90377435504133,"se":0.04507935951989537,"valid":true,"gas":{"max_ok":225550,"init_max_ok":243118,"oog":0,"errors":0}},{"index":28,"params":{"g":1.0,"c_bps":24.0,"m_bps":0.0},"start":966781,"n":64,"mean_diff":-8.49564126691914,"se":0.17131044596940373,"valid":true,"gas":{"max_ok":220688,"init_max_ok":243118,"oog":0,"errors":0}},{"index":29,"params":{"g":-0.5,"c_bps":2.0,"m_bps":4.0},"start":966781,"n":64,"mean_diff":-1.215282912303361,"se":0.05121957469881138,"valid":true,"gas":{"max_ok":225587,"init_max_ok":243118,"oog":0,"errors":0}},{"index":30,"params":{"g":-0.15,"c_bps":24.0,"m_bps":0.0},"start":966781,"n":64,"mean_diff":-1.6689348641051103,"se":0.0644090484748145,"valid":true,"gas":{"max_ok":225531,"init_max_ok":243118,"oog":0,"errors":0}},{"index":31,"params":{"g":2.0,"c_bps":2.0,"m_bps":4.0},"start":966781,"n":64,"mean_diff":0.10749240278247463,"se":0.050367052416410464,"valid":true,"gas":{"max_ok":225584,"init_max_ok":243118,"oog":0,"errors":0}},{"index":32,"params":{"g":0.5,"c_bps":24.0,"m_bps":0.0},"start":966349,"n":64,"mean_diff":-2.0560524129618587,"se":0.07725500085227861,"valid":true,"gas":{"max_ok":225517,"init_max_ok":243118,"oog":0,"errors":0}},{"index":33,"params":{"g":-0.5,"c_bps":8.0,"m_bps":-4.0},"start":966349,"n":64,"mean_diff":-3.4560939653236114,"se":0.0833472234899332,"valid":true,"gas":{"max_ok":225515,"init_max_ok":243106,"oog":0,"errors":0}},{"index":34,"params":{"g":0.15,"c_bps":2.0,"m_bps":12.0},"start":966349,"n":64,"mean_diff":0.06812801957444314,"se":0.03716303131245892,"valid":true,"gas":{"max_ok":225573,"init_max_ok":243118,"oog":0,"errors":0}},{"index":35,"params":{"g":-0.15,"c_bps":2.0,"m_bps":-4.0},"start":966349,"n":64,"mean_diff":-0.7383022469846248,"se":0.0354493596979857,"valid":true,"gas":{"max_ok":225515,"init_max_ok":243106,"oog":0,"errors":0}},{"index":36,"params":{"g":-1.0,"c_bps":24.0,"m_bps":0.0},"start":966349,"n":64,"mean_diff":-9.826750520149481,"se":0.2182247890334297,"valid":true,"gas":{"max_ok":225520,"init_max_ok":243118,"oog":0,"errors":0}},{"index":37,"params":{"g":0.5,"c_bps":2.0,"m_bps":12.0},"start":966349,"n":64,"mean_diff":0.03352903076647262,"se":0.04209691886869642,"valid":true,"gas":{"max_ok":225573,"init_max_ok":243118,"oog":0,"errors":0}},{"index":38,"params":{"g":0.15,"c_bps":8.0,"m_bps":0.0},"start":966349,"n":64,"mean_diff":0.11577213844142076,"se":0.04286838886312181,"valid":true,"gas":{"max_ok":225517,"init_max_ok":243118,"oog":0,"errors":0}},{"index":39,"params":{"g":2.0,"c_bps":8.0,"m_bps":-4.0},"start":966349,"n":64,"mean_diff":-3.778180350734093,"se":0.13169592240183076,"valid":true,"gas":{"max_ok":225531,"init_max_ok":243106,"oog":0,"errors":0}},{"index":40,"params":{"g":-0.5,"c_bps":24.0,"m_bps":0.0},"start":965375,"n":64,"mean_diff":-5.724232857563404,"se":0.13961780343029737,"valid":true,"gas":{"max_ok":224161,"init_max_ok":243118,"oog":0,"errors":0}},{"index":41,"params":{"g":2.0,"c_bps":8.0,"m_bps":12.0},"start":965375,"n":64,"mean_diff":-1.4528401876474657,"se":0.08917340496265323,"valid":true,"gas":{"max_ok":224214,"init_max_ok":243118,"oog":0,"errors":0}},{"index":42,"params":{"g":-0.15,"c_bps":2.0,"m_bps":4.0},"start":965375,"n":64,"mean_diff":-0.8215573357290173,"se":0.045243451497318316,"valid":true,"gas":{"max_ok":224198,"init_max_ok":243118,"oog":0,"errors":0}},{"index":43,"params":{"g":-0.15,"c_bps":8.0,"m_bps":0.0},"start":965375,"n":64,"mean_diff":-1.4589307156150984,"se":0.051538076351379004,"valid":true,"gas":{"max_ok":224161,"init_max_ok":243118,"oog":0,"errors":0}},{"index":44,"params":{"g":-1.0,"c_bps":8.0,"m_bps":12.0},"start":965375,"n":64,"mean_diff":-5.391957413293153,"se":0.1201608064152998,"valid":true,"gas":{"max_ok":229038,"init_max_ok":243118,"oog":0,"errors":0}},{"index":45,"params":{"g":0.5,"c_bps":8.0,"m_bps":0.0},"start":965375,"n":64,"mean_diff":-0.940375870537129,"se":0.07388793556907215,"valid":true,"gas":{"max_ok":228998,"init_max_ok":243118,"oog":0,"errors":0}},{"index":46,"params":{"g":-1.0,"c_bps":8.0,"m_bps":-4.0},"start":965375,"n":64,"mean_diff":-4.000160012785694,"se":0.09877196463862033,"valid":true,"gas":{"max_ok":224148,"init_max_ok":243106,"oog":0,"errors":0}},{"index":47,"params":{"g":-0.5,"c_bps":8.0,"m_bps":0.0},"start":965375,"n":64,"mean_diff":-3.354009361096945,"se":0.07860201170817328,"valid":true,"gas":{"max_ok":224161,"init_max_ok":243118,"oog":0,"errors":0}},{"index":48,"params":{"g":-0.15,"c_bps":24.0,"m_bps":-4.0},"start":966763,"n":64,"mean_diff":-1.7692484072306103,"se":0.06627335108573107,"valid":true,"gas":{"max_ok":228424,"init_max_ok":243106,"oog":0,"errors":0}},{"index":49,"params":{"g":-1.0,"c_bps":2.0,"m_bps":-4.0},"start":966763,"n":64,"mean_diff":-0.8234488088896175,"se":0.06014892565287359,"valid":true,"gas":{"max_ok":228443,"init_max_ok":243106,"oog":0,"errors":0}},{"index":50,"params":{"g":-0.5,"c_bps":2.0,"m_bps":-4.0},"start":966763,"n":64,"mean_diff":-0.7800081310903888,"se":0.05762111603142331,"valid":true,"gas":{"max_ok":228443,"init_max_ok":243106,"oog":0,"errors":0}},{"index":51,"params":{"g":0.5,"c_bps":24.0,"m_bps":12.0},"start":966763,"n":64,"mean_diff":-1.4251880375235144,"se":0.10120941638284499,"valid":true,"gas":{"max_ok":223663,"init_max_ok":243118,"oog":0,"errors":0}},{"index":52,"params":{"g":0.5,"c_bps":8.0,"m_bps":12.0},"start":966763,"n":64,"mean_diff":-0.5177213215625134,"se":0.08176040015282826,"valid":true,"gas":{"max_ok":228522,"init_max_ok":243118,"oog":0,"errors":0}},{"index":53,"params":{"g":0.5,"c_bps":24.0,"m_bps":-4.0},"start":966763,"n":64,"mean_diff":-3.597377097822198,"se":0.1318699166258731,"valid":true,"gas":{"max_ok":228421,"init_max_ok":243106,"oog":0,"errors":0}},{"index":54,"params":{"g":1.0,"c_bps":24.0,"m_bps":4.0},"start":966763,"n":64,"mean_diff":-5.969850122489162,"se":0.14396968583716627,"valid":true,"gas":{"max_ok":223660,"init_max_ok":243118,"oog":0,"errors":0}}]},"recheck":{"seeds":[968000,968255],"n":256,"results":[{"params":{"g":0.15,"c_bps":8.0,"m_bps":4.0},"valid":true,"gas":{"max_ok":231403,"init_max_ok":243118,"oog":0,"errors":0},"paired":{"n":256,"mean_diff":0.21750591046678536,"se":0.02739007609650152,"worst":[{"seed":968191,"d":-0.9520414303683538},{"seed":968100,"d":-0.6777092589163658},{"seed":968089,"d":-0.6376246318044991},{"seed":968002,"d":-0.6298349294811487},{"seed":968099,"d":-0.6084813615573239}]},"retail_edge_delta":{"mean":0.1676703202312526,"se":0.02636144920416429},"arb_edge_delta":{"mean":0.049835590235535895,"se":0.014369679326542109},"reconciliation_max_abs":2.2737367544323206e-13},{"params":{"g":0.15,"c_bps":8.0,"m_bps":0.0},"valid":true,"gas":{"max_ok":231366,"init_max_ok":243118,"oog":0,"errors":0},"paired":{"n":256,"mean_diff":0.16320545601025316,"se":0.027488230030163742,"worst":[{"seed":968045,"d":-1.485741983873595},{"seed":968191,"d":-1.1096580069005313},{"seed":968193,"d":-0.7947140193732594},{"seed":968180,"d":-0.69327054866136},{"seed":968050,"d":-0.6480464035674913}]},"retail_edge_delta":{"mean":0.052721186927969566,"se":0.026394143873716514},"arb_edge_delta":{"mean":0.11048426908228419,"se":0.01479066918223861},"reconciliation_max_abs":2.2737367544323206e-13},{"params":{"g":0.15,"c_bps":2.0,"m_bps":0.0},"valid":true,"gas":{"max_ok":231385,"init_max_ok":243118,"oog":0,"errors":0},"paired":{"n":256,"mean_diff":0.08437273939788059,"se":0.020824744761921102,"worst":[{"seed":968045,"d":-1.253074011839999},{"seed":968191,"d":-1.0250350874646301},{"seed":968181,"d":-0.6139336794119572},{"seed":968100,"d":-0.6132300984928634},{"seed":968032,"d":-0.6045252134862267}]},"retail_edge_delta":{"mean":0.006164783272660346,"se":0.022204721295343056},"arb_edge_delta":{"mean":0.0782079561252214,"se":0.008704272927421621},"reconciliation_max_abs":1.1368683772161603e-13}],"selection":"Highest paired mean among valid rechecked candidates; frozen before held-out evaluation."},"held_out":{"comparator":"RS2","rs2_sha256":"f24b6ca198b744c380842c3a17964a6dc21f311bb04984b26733afa3fee8eaf2","seeds":[969000,969511],"n":512,"mean_diff":0.22302213597420917,"se":0.018347855427829837,"worst":[{"seed":969388,"d":-2.5931706138052846},{"seed":969456,"d":-1.272216527805199},{"seed":969487,"d":-1.0385307588909427},{"seed":969495,"d":-1.0157713943274302},{"seed":969105,"d":-0.6869833850482223}],"candidate_mean":528.6040810191898,"rs2_mean":528.3810588832155,"valid":true,"reconciliation_max_abs":1.0658141036401503e-13},"retail_edge_delta":{"mean":0.1792315797774614,"se":0.018748483322800748},"arb_edge_delta":{"mean":0.04379055619674558,"se":0.0060582486649508206},"gas":{"max_ok":231403,"init_max_ok":243118,"oog":0,"other_errors":0,"valid":true,"scope":"Frozen source on search/recheck blocks where identical parameters were used, held-out 969000..969511, and independent STACK confirmation 5820000..5821999; gas counters reset every <=20 seeds."},"neutral_check":{"seeds":[969600,969631],"params":{"g":0,"c_bps":10,"m_bps":0},"paired":{"n":32,"mean_diff":0.0,"se":0.0,"worst":[{"seed":969600,"d":0.0},{"seed":969601,"d":0.0},{"seed":969602,"d":0.0},{"seed":969603,"d":0.0},{"seed":969604,"d":0.0}]},"retail_edge_delta":{"mean":0.0,"se":0.0},"arb_edge_delta":{"mean":0.0,"se":0.0},"reconciliation_max_abs":0.0,"gas":{"max_ok":199748,"init_max_ok":243099,"oog":0,"errors":0},"sha256":"f40a0011eb3bcc14f98aa40fed71d23475cf68fd53848f84e51e238a03ee1f5f","all_edges_equal":true},"calibration":{"n":1000,"mean_edge":525.5258821780834,"expected":525.5258821780834,"difference":0.0,"gas":{"max_ok":151647,"init_max_ok":185532,"oog":0,"errors":0}},"stack_confirmation":{"seeds":[5820000,5821999],"comparator_sha256":"2eaafc7960e520b8a7fd322ec8afaff8fa677c730228a961efb509cc30b25719","paired":{"n":2000,"mean_diff":0.5514277421227615,"se":0.013811303616272655,"worst":[{"seed":5820440,"d":-2.7035756105987048},{"seed":5820200,"d":-2.121250971171662},{"seed":5821076,"d":-1.4619161492168473},{"seed":5820236,"d":-1.3331411452205657},{"seed":5820229,"d":-1.25186424229463}]},"retail_edge_delta":{"mean":0.5417309461804739,"se":0.013698115720490553},"arb_edge_delta":{"mean":0.009696795942287522,"se":0.006235123968165564},"reconciliation_max_abs":1.1368683772161603e-13,"gas":{"max_ok":230790,"init_max_ok":243118,"oog":0,"errors":0},"valid":true,"candidate_mean":529.0510425830435,"stack_mean":528.4996148409207},"protocol":{"checkout_commit":"6b6921f8d463314aa7c96234e1be25a25245f704","simulator_wheel_sha256":"aedb68280aca34c110968f00148387c95885207913fb2cf19a1ab4c5cfd6887a","n_steps":10000,"workers":8,"market":"Each strategy alone versus VanillaStrategy; never RS2 and candidate together.","config":"numpy.default_rng(seed) draws size Uniform(19,21), rate Uniform(0.6,1), sigma Uniform(0.000882,0.001008), in that order. Config seed=seed gives price seed=seed and retail seed+1 in the pinned simulator. Initial reserves (100,10000), price 100, dt 1, mu 0, retail size sigma 1.2 and buy probability 0.5.","se":"Sample standard deviation (ddof=1) of paired seed differences divided by sqrt(n).","decomposition":"Supplied harness reconstructs the negative arbitrage profit from preceding spot and fees at each fair price; retail=edge-arb, initial RS2 fee 4 bps. Reported component SEs are paired across seeds."},"notes":["All numeric results are local measurements, not leaderboard submissions or a claim of top-10 performance.","The quote target uses the marginal (infinitesimal) quote, not a finite-order average quote. Positive m undercuts that fee-equivalent target; negative g repels the target.","The price estimate is RS2's existing 70% slow / 30% fast blend. It is also used to identify the attracting side.","Retail classification: all later prints in a step are retail; a first print is classified retail when the existing posterior arbitrage probability is below 0.5. Own callbacks cannot observe competitor-only retail trades; the model is approximate.","On a corner route, virtual spot moves only in the retail order's direction toward the equality condition; it is not moved backward.","Virtual k is recovered from own constant-product reserves before both virtual slots exist; initial competitor reserves equal own initial reserves in this simulator. The first own callback writes X only; the next recovers Y from k and X and begins storing both. No new initialization slot is written.","The first STACK baseline launch on 5000000..5001999 was interrupted before returning results after detecting that the supplied harness artifact had already used that block. No candidate was evaluated there and no results were saved or inspected; the completed confirmation instead uses fresh 5820000..5821999.","A preliminary unstaggered-slot implementation reached 248547 swap gas and was rejected. The timed search was restarted after the storage repair; preliminary trials are excluded from search counts.","Gas limits are strict: reject any halt or bad return, swap max >=235000, or initialization max >=245000. Invalid trials cannot be selected.","Neutral behavior is verified seed by seed, with exact edge, retail and arbitrage equality, on the prescribed 32 seeds.","Calibration and verification scaffolding lived in disposable test/scratch; only the two requested JSON outputs are delivered.","Held-out candidate gained 0.22302213597420917 edge per seed versus RS2; selection did not use these seeds."]}
