{"key": "retune-a", "blocked": null, "gates": {"A": {"pass": true, "max_fee_diff_bps": 1.2216616607219066e-09, "sequences": 50, "callbacks_per_seq": 2000}, "B": {"pass": true, "paired_mean": 0.2420270811033297, "se": 0.01692058854320023, "markets": [31000000, 31004095]}, "C": {"pass": true, "max_fee_diff_bps": 2.479093319518455e-09, "sequences": 20}}, "sim_markets_per_s": 101.77958628851238, "curve": [[10, -0.008635751536087588, 0.024551249079141316], [20, -0.012068036431501922, 0.022983246683410917]], "generations": 20, "gen_log_[gen,max_gain,mean_gain,sigma]": [[1, -0.3511421273616351, -12.177120619279, 0.14186758105843936], [2, -0.4292116124380405, -6.338205042888351, 0.13688708743819117], [3, -0.3830877683885996, -8.650195538762691, 0.13588980700000636], [4, -0.08264571462537718, -3.5703495542468815, 0.13357219137885654], [5, -0.42183213976883027, -3.7328944147263408, 0.13116763585771796], [6, -0.4542425486263182, -8.186207571580994, 0.13005708301014687], [7, -0.028857523284236075, -10.256643891582726, 0.12879552590188206], [8, -0.4499821038392777, -5.681251027253866, 0.13022783626047923], [9, -0.1721668417303519, -7.0723512305995095, 0.1312918707115377], [10, -0.542293039584252, -7.422447103363821, 0.13165539026029222], [11, -0.5073879056842172, -5.378918327796894, 0.13095917520586633], [12, 0.061935580309088856, -5.390420049905337, 0.12967307788353666], [13, -0.47334099919022576, -2.8922355477623727, 0.12787565097113782], [14, -0.7979186779004066, -7.768330573716322, 0.12546936165857095], [15, -0.74251942610952, -3.1014203619947525, 0.1245750420413485], [16, -1.258991431279669, -5.297764787291226, 0.12289026667974308], [17, -0.7673882697321228, -6.942149100506277, 0.12233589599816258], [18, -0.8326314450184311, -4.2259497897452, 0.12018574442587728], [19, -0.3580092501126255, -1.9253036155919612, 0.11824464372273184], [20, -0.6211859845275403, -3.7037572997508588, 0.11705316346325297]], "best_monitor": {"gain": -0.008635751536087588, "se": 0.024551249079141316, "generation": 10}, "params": {"ELAPSED_CAP": 8.0, "SIGNAL_THRESHOLD": 0.001110309776249723, "DIR_DECAY": 0.7543405584078315, "ACT_DECAY": 0.43776316326306297, "SIZE_DECAY": 0.5016357322558402, "TOX_DECAY": 0.9169270153039681, "SIGMA_DECAY": 0.6941046365882269, "LAMBDA_DECAY": 0.9932783444915417, "SIZE_BLEND_DECAY": 0.8641677112102482, "TOX_BLEND_DECAY": 0.04337020033540061, "ACT_BLEND_DECAY": 0.9831874214560741, "PHAT_ALPHA": 0.27698033520531656, "PHAT_ALPHA_RETAIL": 0.07148811217564217, "PHAT_ALPHA_SAME": 0.10983787450867533, "DIR_IMPACT_MULT": 4.0, "GATE_SIGMA_MULT": 8.131169937234002, "MIN_GATE": 0.022945033481023887, "TRADE_TOX_BOOST": 0.4548649798676035, "STALE_ATTRACT_FRAC": 0.9302627782207123, "RET_CAP": 0.0337699139662417, "TOX_CAP": 0.2766410922133626, "TRADE_RATIO_CAP": 0.18431123765423765, "LAMBDA_CAP": 1.8583180876420395, "STEP_COUNT_CAP": 99.0, "BASE_FEE": 0.0005706148226598419, "SIGMA_COEF": 0.15335077112651724, "LAMBDA_COEF": 0.0012477232262952994, "FLOW_SIZE_COEF": 0.4331901295804766, "TOX_COEF": 0.027179828182240524, "TOX_QUAD_COEF": 1.5204908926914822, "ACT_COEF": 7.023851769222014, "DIR_COEF": 0.0018259369537716238, "DIR_TOX_COEF": 0.006851367455649063, "STALE_DIR_COEF": 0.673249874407551, "SIGMA_TOX_COEF": 0.04318938094654643, "TAIL_KNEE": 0.050902855446683375, "TAIL_SLOPE_PROTECT": 0.9370747674416148, "TAIL_SLOPE_ATTRACT": 0.8731935380069101, "ANCHOR_N": 646.0, "ANCHOR_K_LIN": 0.7216449416825431, "ANCHOR_K_QUAD": 1.291307037888252}, "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 = 1110309776249723;\n    uint256 constant DIR_DECAY = 754340558407831552;\n    uint256 constant ACT_DECAY = 437763163263062976;\n    uint256 constant SIZE_DECAY = 501635732255840256;\n    uint256 constant TOX_DECAY = 916927015303968128;\n    uint256 constant SIGMA_DECAY = 694104636588226816;\n    uint256 constant LAMBDA_DECAY = 993278344491541760;\n    uint256 constant SIZE_BLEND_DECAY = 864167711210248192;\n    uint256 constant TOX_BLEND_DECAY = 43370200335400608;\n    uint256 constant ACT_BLEND_DECAY = 983187421456074112;\n    uint256 constant PHAT_ALPHA = 276980335205316576;\n    uint256 constant PHAT_ALPHA_RETAIL = 71488112175642176;\n    uint256 constant PHAT_ALPHA_SAME = 109837874508675328;\n    uint256 constant REVERT_U = 0;\n    uint256 constant DIR_IMPACT_MULT = 4;\n    uint256 constant GATE_SIGMA_MULT = 8131169937234001920;\n    uint256 constant MIN_GATE = 22945033481023888;\n    uint256 constant TRADE_TOX_BOOST = 454864979867603520;\n    uint256 constant STALE_ATTRACT_FRAC = 930262778220712320;\n    uint256 constant RET_CAP = 33769913966241704;\n    uint256 constant TOX_CAP = 276641092213362592;\n    uint256 constant TRADE_RATIO_CAP = 184311237654237664;\n    uint256 constant LAMBDA_CAP = 1858318087642039552;\n    uint256 constant STEP_COUNT_CAP = 99;\n    uint256 constant BASE_FEE = 570614822659842;\n    uint256 constant SIGMA_COEF = 153350771126517248;\n    uint256 constant LAMBDA_COEF = 1247723226295300;\n    uint256 constant FLOW_SIZE_COEF = 433190129580476608;\n    uint256 constant TOX_COEF = 27179828182240524;\n    uint256 constant TOX_QUAD_COEF = 1520490892691482112;\n    uint256 constant ACT_COEF = 7023851769222013952;\n    uint256 constant DIR_COEF = 1825936953771624;\n    uint256 constant DIR_TOX_COEF = 6851367455649063;\n    uint256 constant STALE_DIR_COEF = 673249874407550976;\n    uint256 constant SIGMA_TOX_COEF = 43189380946546432;\n    uint256 constant TAIL_KNEE = 50902855446683376;\n    uint256 constant TAIL_SLOPE_PROTECT = 937074767441614720;\n    uint256 constant TAIL_SLOPE_ATTRACT = 873193538006910080;\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 toxLinear;\n        uint256 toxQuadratic;\n        {\n            uint256 packedAnchor = slots[16];\n            uint256 runMean = uint64(packedAnchor);\n            uint256 sampleCount = packedAnchor >> 64;\n            if (sampleCount < 646) sampleCount++;\n            if (toxEma >= runMean) runMean += (toxEma-runMean)/sampleCount;\n            else runMean -= (runMean-toxEma)/sampleCount;\n            slots[16] = runMean | (sampleCount << 64);\n            toxLinear = _anchorBlend(runMean, toxEma, 721644941682543104);\n            toxQuadratic = _anchorBlend(runMean, toxEma, 1291307037888252160);\n        }\n\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, toxLinear) + wmul(TOX_QUAD_COEF, wmul(toxQuadratic, toxQuadratic)) + wmul(ACT_COEF, actEma);\n        fMid = fMid + wmul(SIGMA_TOX_COEF, wmul(sigmaHat, toxLinear));\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\n    function _anchorBlend(uint256 mean, uint256 value, uint256 k) internal pure returns (uint256) {\n        if (k == WAD) return value;\n        if (value >= mean) return mean + wmul(value-mean,k);\n        uint256 delta = wmul(mean-value,k);\n        return delta < mean ? mean-delta : 0;\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": "d6cd642806e704f1b074c0145736b637c9c7a29a6b8d9b88348ac8f9758a3323", "real": {"n": 192, "seeds": [6000000, 6000191], "mean_diff": -0.16933399447411132, "se": 0.08068952222009237, "worst5": [{"seed": 6000120, "d": -3.467865605323027}, {"seed": 6000062, "d": -3.0924612795982966}, {"seed": 6000081, "d": -2.6979502378990787}, {"seed": 6000021, "d": -2.6305324285541474}, {"seed": 6000029, "d": -2.581887100246149}], "retail_delta": {"mean": 2.4774396198574777, "se": 0.08255941862807}, "arb_delta": {"mean": -2.646773614331593, "se": 0.057438201321678005}, "note": "run once, in order, 64-seed chunks; stopped by the run time limit before 512"}, "gas": {"max_ok": 223298, "init_max_ok": 243115, "oog": 0, "other_errors": 0, "raw_counters": [{"role": "baseline", "callback": "after_initialize", "calls": 192, "ok": 192, "max_ok_gas": 21796, "sum_ok_gas": 4184832, "oog": 0, "revert": 0, "other_halt": 0, "tx_error": 0, "bad_return": 0}, {"role": "baseline", "callback": "after_swap", "calls": 2083465, "ok": 2083465, "max_ok_gas": 22592, "sum_ok_gas": 47009048384, "oog": 0, "revert": 0, "other_halt": 0, "tx_error": 0, "bad_return": 0}, {"role": "baseline", "callback": "getName", "calls": 192, "ok": 192, "max_ok_gas": 21526, "sum_ok_gas": 4132992, "oog": 0, "revert": 0, "other_halt": 0, "tx_error": 0, "bad_return": 0}, {"role": "submission", "callback": "after_initialize", "calls": 192, "ok": 192, "max_ok_gas": 243115, "sum_ok_gas": 46678080, "oog": 0, "revert": 0, "other_halt": 0, "tx_error": 0, "bad_return": 0}, {"role": "submission", "callback": "after_swap", "calls": 1995345, "ok": 1995345, "max_ok_gas": 223298, "sum_ok_gas": 247943027519, "oog": 0, "revert": 0, "other_halt": 0, "tx_error": 0, "bad_return": 0}, {"role": "submission", "callback": "getName", "calls": 192, "ok": 192, "max_ok_gas": 21623, "sum_ok_gas": 4151616, "oog": 0, "revert": 0, "other_halt": 0, "tx_error": 0, "bad_return": 0}], "limit_ok": true}, "minutes": {"search": 14.253021844228108, "real": 11.999442195892334}, "notes": ["Machine cgroup limits CPU to 1 core (cpu.max 100000 100000), so the replica ran ~100 markets/s; the search was stopped at 20 generations (~14 min) to leave time for the real run.", "Search space: the 38 declared constants of T (lines 8-46 except REVERT_U=0, an off switch) plus anchor N, k_lin, k_quad = 41 dims. Inline named literals the port exposes (posterior, silence, flow, route, stale weights, caps) were NOT searched: deviation from the brief, for time.", "No CMA candidate beat T-port: best generation objective +0.062 (gen 12, 256 markets, noise); monitor scores -0.0086 (gen 10) and -0.0121 (gen 20). The frozen candidate is the gen-10 best and is statistically indistinguishable from T on the replica.", "CH check on seeds 0..999 was NOT run (about 14 min at 1 CPU); a 20-seed CH smoke run (seeds 0..19) ran on the real engine, mean 561.15. Gates A and B show the setup matches T and RS2.", "Conclusion: with sigma0 0.15 over 41 dims, 256-market blocks and 20 generations, the search does not beat T; most samples lose 2-12 points."]}