{"key":"head-a","blocked":null,"gates":{"A":{"passed":true,"sequences":50,"swap_callbacks":100000,"max_fee_diff_bps":1.2216616607219066e-09,"threshold_bps":0.01,"seeds":[310000,310049]},"B":{"passed":true,"n":4096,"seeds":[31000000,31004095],"gain":0.2420270811033297,"se":0.01692058854320023,"required_interval":[0.17,0.37]},"C":{"passed":true,"sequences":20,"swap_callbacks":40000,"max_fee_diff_bps":7.60422131512728e-05,"threshold_bps":0.1,"seeds":[310000,310019]}},"ch_check":{"n":1000,"mean_edge":525.5258821780834,"expected":525.5258821780834,"absolute_error":0.0},"sim_markets_per_s":759.1412111345176,"sim_speed":{"T_port":759.1412111345176,"RS2_port":613.1953761776955,"scope":"4096 10000-step markets, 8 processes, warmed Numba, compilation excluded"},"curve":[[10,0.31355753224057425,0.01502250591389228],[20,0.5132338563411899,0.016883688859638774],[30,0.6700794904732756,0.020478208120545367],[40,0.716303441439913,0.01835632355119158],[50,0.6210749220057433,0.017996482970904358],[60,0.6210749220057433,0.017996482970904358],[70,0.6210749220057433,0.017996482970904358],[80,0.6210749220057433,0.017996482970904358],[90,0.6210749220057433,0.017996482970904358],[100,0.6210749220057433,0.017996482970904358],[110,0.6210749220057433,0.017996482970904358],[120,0.7486130116689275,0.019694618816517434],[130,0.7486130116689275,0.019694618816517434],[140,0.7486130116689275,0.019694618816517434],[150,0.7486130116689275,0.019694618816517434],[160,0.8093951784823651,0.021151234703818543],[170,0.8093951784823651,0.021151234703818543],[180,0.888571111087092,0.02176165980692271],[190,0.9286374272602482,0.019246795253669097],[200,0.9087666677243054,0.01971201494052476],[210,0.95540730056382,0.02129135843776028],[220,1.0402963127674938,0.021301914537894946],[230,1.0402963127674938,0.021301914537894946],[240,1.0402963127674938,0.021301914537894946],[250,1.0402963127674938,0.021301914537894946],[260,1.0402963127674938,0.021301914537894946],[270,1.0402963127674938,0.021301914537894946],[280,1.0402963127674938,0.021301914537894946],[290,1.0379081764057307,0.020856166486377146],[300,1.0379081764057307,0.020856166486377146],[310,1.0379081764057307,0.020856166486377146],[320,1.0360368999470593,0.020520805393056753],[330,1.0360368999470593,0.020520805393056753],[340,1.0360368999470593,0.020520805393056753],[350,1.0360368999470593,0.020520805393056753],[360,1.0360368999470593,0.020520805393056753],[370,1.0966772622519825,0.020878532501852298],[380,1.0966772622519825,0.020878532501852298],[390,1.0966772622519825,0.020878532501852298],[400,1.0966772622519825,0.020878532501852298],[410,1.1515186909142017,0.021420238492560275]],"best_monitor":{"gain":1.1515186909142017,"se":0.021420238492560275},"params":{"hidden_units":8,"W1":[[-0.042655,1.389981,-0.435022,2.131939,-2.307678,-0.134711,-1.563002,0.838218,-3.867643,-0.287527,-0.014871,0.138925,0.547082],[0.840878,1.015656,1.905167,4.344855,1.49152,0.813268,0.140392,-0.166508,-0.344279,0.280778,-0.262185,-0.623571,0.543047],[2.339559,1.927192,-1.149669,0.419394,2.422033,2.797237,-0.184718,2.200018,2.191446,-1.193034,-0.027589,-1.571561,-1.126364],[-1.436015,-0.245775,0.519839,0.840096,-1.06768,0.941901,-0.447013,1.415013,-1.647625,0.825277,0.681432,-1.416949,-1.754078],[1.014618,-1.515656,3.692017,-0.716903,-2.472535,-0.750627,-1.234693,-1.457361,0.437293,0.064478,-0.154363,-3.496125,0.238174],[1.237463,-0.770777,0.793692,-1.766367,2.499688,1.239927,0.842836,-0.357134,-2.299169,0.131642,0.337489,3.91456,0.554438],[-2.559287,0.779086,-0.480982,-2.426775,2.235989,0.776522,-0.2552,-0.074918,1.361255,-0.489339,0.456458,1.516253,-0.226631],[-3.164297,-1.575901,2.530196,3.744943,-1.077146,-1.736719,-0.508633,1.762971,0.752575,-0.725826,2.462294,-2.054677,1.028772]],"b1":[1.446428,-2.846664,-3.039159,-0.668153,-0.67968,-1.68127,-2.09327,-0.152766],"W2":[[0.532461,-1.789106,-0.079941,-0.398251,-3.782992,-0.373606,-1.339628,0.932635],[0.237721,-1.524133,-0.899179,0.243723,0.796095,-0.493254,-0.436366,0.913103]],"b2":[0.654604,1.544139],"weight_fixed_point_scale":1000000,"feature_fixed_point_scale":1000000,"output_unit_fee":0.0001,"feature_order":["sigmaHat","lambdaHat","sizeHat","toxEma","actEma","direction","(spot-staleHat)/staleHat","signed_trade_ratio","arb_probability","first_in_step","uncertainty","min(silent,8)/8","anchor_mean"],"feature_multipliers":[1000,2,500,500,500,1,500,500,2,2,1000000,1,500],"feature_offsets":[-1,-1,-1,-1,-1,-1,0,0,-1,-1,-1,0,-1],"feature_clip":[-4,4],"hidden_relu_clip":[0,4],"toxicity_anchor":{"count_cap":674,"linear_k_wad":712696014807650816,"quadratic_k_wad":1295240753826310656},"cma":{"seed":21,"population":16,"dimension":130,"initial_sigma":0.2,"W1_initial_rng":"numpy.default_rng(21).normal(0,0.35,104)","other_initial_values":0,"generations":413,"train_seeds":[22000000,22105727],"train_markets_per_generation":256,"monitor_seeds":[30000000,30002047],"monitor_every_generations":10,"selection":"best historical training-block proposal rescored on monitor; retain maximum monitor gain"}},"valid":true,"code":"// SPDX-License-Identifier: MIT\npragma solidity ^0.8.24;\n\nimport {AMMStrategyBase} from \"./AMMStrategyBase.sol\";\nimport {TradeInfo} from \"./IAMMStrategy.sol\";\n\ncontract Strategy is AMMStrategyBase {\n    uint256 constant ELAPSED_CAP = 8;\n    uint256 constant SIGNAL_THRESHOLD = WAD / 650;\n    uint256 constant DIR_DECAY = 750000000000000000;\n    uint256 constant ACT_DECAY = 530000000000000000;\n    uint256 constant SIZE_DECAY = 530000000000000000;\n    uint256 constant TOX_DECAY = 910000000000000000;\n    uint256 constant SIGMA_DECAY = 690000000000000000;\n    uint256 constant LAMBDA_DECAY = 990000000000000000;\n    uint256 constant SIZE_BLEND_DECAY = 828000000000000000;\n    uint256 constant TOX_BLEND_DECAY = 51000000000000000;\n    uint256 constant ACT_BLEND_DECAY = 985000000000000000;\n    uint256 constant PHAT_ALPHA = 270000000000000000;\n    uint256 constant PHAT_ALPHA_RETAIL = 60000000000000000;\n    uint256 constant PHAT_ALPHA_SAME = 120000000000000000;\n    uint256 constant REVERT_U = 0;\n    uint256 constant DIR_IMPACT_MULT = 4;\n    uint256 constant GATE_SIGMA_MULT = 7200000000000000000;\n    uint256 constant MIN_GATE = 30000000000000000;\n    uint256 constant TRADE_TOX_BOOST = 3500 * BPS;\n    uint256 constant STALE_ATTRACT_FRAC = 1050000000000000000;\n    uint256 constant RET_CAP = WAD / 35;\n    uint256 constant TOX_CAP = WAD / 5;\n    uint256 constant TRADE_RATIO_CAP = WAD / 5;\n    uint256 constant LAMBDA_CAP = 1820000000000000000;\n    uint256 constant STEP_COUNT_CAP = 64;\n    uint256 constant BASE_FEE = 4 * BPS;\n    uint256 constant SIGMA_COEF = 200000000000000000;\n    uint256 constant LAMBDA_COEF = 12 * BPS;\n    uint256 constant FLOW_SIZE_COEF = 4842 * BPS;\n    uint256 constant TOX_COEF = 300 * BPS;\n    uint256 constant TOX_QUAD_COEF = 15000 * BPS;\n    uint256 constant ACT_COEF = 91843 * BPS;\n    uint256 constant DIR_COEF = 20 * BPS;\n    uint256 constant DIR_TOX_COEF = 100 * BPS;\n    uint256 constant STALE_DIR_COEF = 6850 * BPS;\n    uint256 constant SIGMA_TOX_COEF = 500 * BPS;\n    uint256 constant TAIL_KNEE = 600 * BPS;\n    uint256 constant TAIL_SLOPE_PROTECT = 930000000000000000;\n    uint256 constant TAIL_SLOPE_ATTRACT = 850000000000000000;\n\n    function afterInitialize(uint256 initialX, uint256 initialY) external override returns (uint256, uint256) {\n        slots[0] = BASE_FEE; slots[1] = BASE_FEE; slots[3] = WAD; \n        slots[5] = initialX > 0 ? wdiv(initialY, initialX) : 100 * WAD;\n        slots[6] = 950000000000000; slots[7] = 800000000000000000; slots[8] = 2000000000000000;\n        slots[15] = 400000000000000000 | (uint256(2000000000000000) << 160); slots[13] = 902500000000; slots[14] = slots[5]; \n        return (BASE_FEE, BASE_FEE);\n    }\n\n    function afterSwap(TradeInfo calldata trade) external override returns (uint256, uint256) {\n        uint256 prevBidFee = slots[0]; uint256 prevAskFee = slots[1]; uint256 lastTs = uint64(slots[2]);\n        uint256 dirState = slots[3]; uint256 actEma = slots[4]; uint256 pHat = slots[5];\n        uint256 sigmaHat = slots[6]; uint256 lambdaHat = slots[7]; uint256 sizeHat = slots[8];\n        uint256 toxEma = slots[9]; uint256 stepTradeCount = slots[10];\n\n        uint256 sigmaForFast = sigmaHat;\n        uint256 fastHat = slots[14];\n        uint256 uncertainty = slots[13];\n        uint256 silent = trade.timestamp > lastTs ? trade.timestamp - lastTs : 0;\n        bool isNewStep = trade.timestamp > lastTs;\n        if (isNewStep) {\n            uint256 elapsedRaw = trade.timestamp - lastTs;\n            uint256 elapsed = elapsedRaw > ELAPSED_CAP ? ELAPSED_CAP : elapsedRaw;\n            dirState = _decayCentered(dirState, DIR_DECAY, elapsed);\n            actEma = wmul(actEma, _powWad(ACT_DECAY, elapsed));\n            sizeHat = wmul(sizeHat, _powWad(SIZE_DECAY, elapsed));\n            toxEma = wmul(toxEma, _powWad(TOX_DECAY, elapsed));\n            if (stepTradeCount > 0 && elapsedRaw > 0) {\n                uint256 lambdaInst = (stepTradeCount * WAD) / elapsedRaw;\n                if (lambdaInst > LAMBDA_CAP) lambdaInst = LAMBDA_CAP;\n                lambdaHat = wmul(lambdaHat, LAMBDA_DECAY) + wmul(lambdaInst, WAD - LAMBDA_DECAY);\n            }\n            // Process variance is propagated inside the censored update.\n            if (uncertainty > 100000000000000) uncertainty = 100000000000000;\n            stepTradeCount = 0;\n        }\n\n        bool firstInStep = stepTradeCount == 0;\n        uint256 spot = trade.reserveX > 0 ? wdiv(trade.reserveY, trade.reserveX) : pHat;\n        if (pHat == 0) pHat = spot;\n\n        uint256 feeUsed = trade.isBuy ? prevBidFee : prevAskFee;\n        uint256 gamma = feeUsed < WAD ? WAD - feeUsed : 0;\n        uint256 pImplied;\n        if (gamma == 0) { pImplied = spot; }\n        else { pImplied = trade.isBuy ? wmul(spot, gamma) : wdiv(spot, gamma); }\n\n        // S: infer a no-trade interval center from the last post-trade spot.\n        uint256 silenceScale = WAD;\n        if (firstInStep && silent > 1) {\n            uint256 g = silent - 1;\n            if (g > 1) g = 1;\n            uint256 w = WAD - _powWad(800000000000000000, g);\n            uint256 s = slots[2] >> 64;\n            if (s == 0) s = pHat;\n            uint256 c = (wmul(s, WAD - prevBidFee) + wdiv(s, WAD - prevAskFee)) / 2;\n            if (c >= pHat) pHat += wmul(w, c - pHat);\n            else pHat -= wmul(w, pHat - c);\n            silenceScale = WAD - wmul(300000000000000000, w);\n        }\n\n        {\n            uint256 ret = pHat > 0 ? wdiv(absDiff(pImplied, pHat), pHat) : 0;\n            uint256 alpha = firstInStep ? PHAT_ALPHA : PHAT_ALPHA_RETAIL;\n            uint256 prePhat = pHat;\n            bool secondPrint = !firstInStep && stepTradeCount == 1;\n            bool sameDir = false; bool oppDir = false;\n            if (secondPrint) {\n                bool up2 = pImplied >= pHat;\n                uint256 d1 = slots[12];\n                if (d1 != 0) { sameDir = (d1 == 1) == up2; oppDir = !sameDir; }\n                if (sameDir) alpha = PHAT_ALPHA_SAME;\n            }\n            if (firstInStep) { slots[12] = pImplied >= pHat ? 1 : 2; }\n            uint256 adaptiveGate = wmul(sigmaHat, GATE_SIGMA_MULT);\n            if (adaptiveGate < MIN_GATE) adaptiveGate = MIN_GATE;\n            alpha = wmul(alpha, silenceScale);\n            adaptiveGate = wmul(adaptiveGate, silenceScale);\n            if (ret <= adaptiveGate) { pHat = wmul(pHat, WAD - alpha) + wmul(pImplied, alpha); }\n            if (oppDir && REVERT_U > 0) {\n                uint256 pre = slots[11];\n                if (pre > pHat) pHat = pHat + wmul(pre - pHat, REVERT_U);\n                else pHat = pHat - wmul(pHat - pre, REVERT_U);\n            }\n            if (firstInStep) {\n                if (ret > RET_CAP) ret = RET_CAP;\n                sigmaHat = wmul(sigmaHat, SIGMA_DECAY) + wmul(ret, WAD - SIGMA_DECAY);\n            }\n        }\n\n        // Interior retail routing equalizes fee-adjusted marginal prices.\n        // Subsequent trades in a step cannot be the initial arbitrage trade.\n        if (!firstInStep && feeUsed > 30 * BPS && gamma > 0) {\n            uint256 normalSpot = trade.isBuy\n                ? wdiv(wmul(spot, gamma), WAD - 30 * BPS)\n                : wdiv(wmul(spot, WAD - 30 * BPS), gamma);\n            pHat = wmul(pHat, 90 * WAD / 100) + wmul(normalSpot, 10 * WAD / 100);\n        }\n\n        // Censored assumed-density posterior. No external or future inputs.\n        uint256 arbProbability;\n        (fastHat, uncertainty, arbProbability) = _posterior(PosteriorInput(\n            fastHat, uncertainty, pImplied, spot, slots[2] >> 64,\n            prevBidFee, prevAskFee, firstInStep, silent, trade.isBuy,\n            trade.reserveY > 0 ? wdiv(trade.amountY, trade.reserveY) : 0\n        ));\n        slots[13] = uncertainty;\n        slots[14] = fastHat;\n        uint256 tradeRatio = trade.reserveY > 0 ? wdiv(trade.amountY, trade.reserveY) : 0;\n        if (tradeRatio > TRADE_RATIO_CAP) tradeRatio = TRADE_RATIO_CAP;\n\n        if (tradeRatio > SIGNAL_THRESHOLD) {\n            uint256 push = tradeRatio * DIR_IMPACT_MULT;\n            if (push > WAD / 4) push = WAD / 4;\n            if (trade.isBuy) {\n                dirState = dirState + push;\n                if (dirState > 2 * WAD) dirState = 2 * WAD;\n            } else {\n                dirState = dirState > push ? dirState - push : 0;\n            }\n            actEma = wmul(actEma, ACT_BLEND_DECAY) + wmul(tradeRatio, WAD - ACT_BLEND_DECAY);\n            sizeHat = wmul(sizeHat, SIZE_BLEND_DECAY) + wmul(tradeRatio, WAD - SIZE_BLEND_DECAY);\n            if (sizeHat > WAD) sizeHat = WAD;\n        }\n\n        uint256 tox = pHat > 0 ? wdiv(absDiff(spot, pHat), pHat) : 0;\n        if (tox > TOX_CAP) tox = TOX_CAP;\n        toxEma = wmul(toxEma, TOX_BLEND_DECAY) + wmul(tox, WAD - TOX_BLEND_DECAY);\n        uint256 toxSignal = toxEma;\n        uint256 toxLinear;\n        uint256 toxQuadratic;\n        {\n            uint256 packedAnchor = slots[16];\n            uint256 runMean = uint64(packedAnchor);\n            uint256 sampleCount = packedAnchor >> 64;\n            if (sampleCount < 674) 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, 712696014807650816);\n            toxQuadratic = _anchorBlend(runMean, toxEma, 1295240753826310656);\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        {\n            int256[13] memory nx;\n            unchecked {\n                nx[0] = int256(sigmaHat)*1000/1e12-1000000;\n                nx[1] = int256(lambdaHat)*2/1e12-1000000;\n                nx[2] = int256(sizeHat)*500/1e12-1000000;\n                nx[3] = int256(toxEma)*500/1e12-1000000;\n                nx[4] = int256(actEma)*500/1e12-1000000;\n                nx[5] = int256(dirState)/1e12-1000000;\n                uint256 nh = wmul(pHat,700000000000000000)+wmul(fastHat,300000000000000000);\n                nx[6] = (int256(spot)-int256(nh))*500000000/int256(nh);\n                nx[7] = int256(tradeRatio)*500/1e12;\n                if (!trade.isBuy) nx[7] = -nx[7];\n                nx[8] = int256(arbProbability)*2/1e12-1000000;\n                nx[9] = firstInStep ? int256(1000000) : -int256(1000000);\n                nx[10] = int256(uncertainty)/1e6-1000000;\n                nx[11] = int256(silent>8 ? 8 : silent)*1000000/8;\n                nx[12] = int256(uint256(uint64(slots[16])))*500/1e12-1000000;\n                for (uint256 ni=0;ni<13;ni++) {\n                    if(nx[ni]>4000000) nx[ni]=4000000;\n                    if(nx[ni]<-4000000) nx[ni]=-4000000;\n                }\n                (int256 hb,int256 ha) = _head(nx);\n                int256 nb = int256(bidFee)+hb*100000000;\n                int256 na = int256(askFee)+ha*100000000;\n                bidFee = nb<0 ? 0 : (nb>int256(MAX_FEE) ? MAX_FEE : uint256(nb));\n                askFee = na<0 ? 0 : (na>int256(MAX_FEE) ? MAX_FEE : uint256(na));\n            }\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    function _head(int256[13] memory x) internal pure returns (int256 b,int256 a) {\n        unchecked {\n            b = 654604000000; a = 1544139000000;\n            int256 z;\n            z = 1446428 + ((-42655 * x[0]) + (1389981 * x[1]) + (-435022 * x[2]) + (2131939 * x[3]) + (-2307678 * x[4]) + (-134711 * x[5]) + (-1563002 * x[6]) + (838218 * x[7]) + (-3867643 * x[8]) + (-287527 * x[9]) + (-14871 * x[10]) + (138925 * x[11]) + (547082 * x[12]))/1000000;\n            if(z<0) z=0; else if(z>4000000) z=4000000;\n            b += (532461 * z); a += (237721 * z);\n            z = -2846664 + ((840878 * x[0]) + (1015656 * x[1]) + (1905167 * x[2]) + (4344855 * x[3]) + (1491520 * x[4]) + (813268 * x[5]) + (140392 * x[6]) + (-166508 * x[7]) + (-344279 * x[8]) + (280778 * x[9]) + (-262185 * x[10]) + (-623571 * x[11]) + (543047 * x[12]))/1000000;\n            if(z<0) z=0; else if(z>4000000) z=4000000;\n            b += (-1789106 * z); a += (-1524133 * z);\n            z = -3039159 + ((2339559 * x[0]) + (1927192 * x[1]) + (-1149669 * x[2]) + (419394 * x[3]) + (2422033 * x[4]) + (2797237 * x[5]) + (-184718 * x[6]) + (2200018 * x[7]) + (2191446 * x[8]) + (-1193034 * x[9]) + (-27589 * x[10]) + (-1571561 * x[11]) + (-1126364 * x[12]))/1000000;\n            if(z<0) z=0; else if(z>4000000) z=4000000;\n            b += (-79941 * z); a += (-899179 * z);\n            z = -668153 + ((-1436015 * x[0]) + (-245775 * x[1]) + (519839 * x[2]) + (840096 * x[3]) + (-1067680 * x[4]) + (941901 * x[5]) + (-447013 * x[6]) + (1415013 * x[7]) + (-1647625 * x[8]) + (825277 * x[9]) + (681432 * x[10]) + (-1416949 * x[11]) + (-1754078 * x[12]))/1000000;\n            if(z<0) z=0; else if(z>4000000) z=4000000;\n            b += (-398251 * z); a += (243723 * z);\n            z = -679680 + ((1014618 * x[0]) + (-1515656 * x[1]) + (3692017 * x[2]) + (-716903 * x[3]) + (-2472535 * x[4]) + (-750627 * x[5]) + (-1234693 * x[6]) + (-1457361 * x[7]) + (437293 * x[8]) + (64478 * x[9]) + (-154363 * x[10]) + (-3496125 * x[11]) + (238174 * x[12]))/1000000;\n            if(z<0) z=0; else if(z>4000000) z=4000000;\n            b += (-3782992 * z); a += (796095 * z);\n            z = -1681270 + ((1237463 * x[0]) + (-770777 * x[1]) + (793692 * x[2]) + (-1766367 * x[3]) + (2499688 * x[4]) + (1239927 * x[5]) + (842836 * x[6]) + (-357134 * x[7]) + (-2299169 * x[8]) + (131642 * x[9]) + (337489 * x[10]) + (3914560 * x[11]) + (554438 * x[12]))/1000000;\n            if(z<0) z=0; else if(z>4000000) z=4000000;\n            b += (-373606 * z); a += (-493254 * z);\n            z = -2093270 + ((-2559287 * x[0]) + (779086 * x[1]) + (-480982 * x[2]) + (-2426775 * x[3]) + (2235989 * x[4]) + (776522 * x[5]) + (-255200 * x[6]) + (-74918 * x[7]) + (1361255 * x[8]) + (-489339 * x[9]) + (456458 * x[10]) + (1516253 * x[11]) + (-226631 * x[12]))/1000000;\n            if(z<0) z=0; else if(z>4000000) z=4000000;\n            b += (-1339628 * z); a += (-436366 * z);\n            z = -152766 + ((-3164297 * x[0]) + (-1575901 * x[1]) + (2530196 * x[2]) + (3744943 * x[3]) + (-1077146 * x[4]) + (-1736719 * x[5]) + (-508633 * x[6]) + (1762971 * x[7]) + (752575 * x[8]) + (-725826 * x[9]) + (2462294 * x[10]) + (-2054677 * x[11]) + (1028772 * x[12]))/1000000;\n            if(z<0) z=0; else if(z>4000000) z=4000000;\n            b += (932635 * z); a += (913103 * z);\n            b /= 1000000; a /= 1000000;\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":"99e3a2eceae0e5543d27473859e10b005d0ce0aa7067f2e1a24d1e0e4a7390fe","real":{"chunks":[{"start":6020000,"n":64,"mean_diff":1.1425077821720162},{"start":6020064,"n":64,"mean_diff":1.2991317911389402},{"start":6020128,"n":64,"mean_diff":1.540802036087534},{"start":6020192,"n":64,"mean_diff":0.9597960607904676},{"start":6020256,"n":64,"mean_diff":1.213708554548524},{"start":6020320,"n":64,"mean_diff":1.1967016961108339},{"start":6020384,"n":64,"mean_diff":1.3237257467981998},{"start":6020448,"n":64,"mean_diff":1.3821629127731399}],"n":512,"mean_diff":1.257317072552457,"se":0.06203879579203182,"worst5":[{"seed":6020246,"diff":-2.1792053779995513},{"seed":6020336,"diff":-2.022197550879696},{"seed":6020180,"diff":-1.6446567069602906},{"seed":6020487,"diff":-1.2791665313936846},{"seed":6020342,"diff":-1.2665776793586474}],"retail_delta":4.1956951263987365,"arb_delta":-2.9383780538462787,"retail_delta_se":0.06932533531280473,"arb_delta_se":0.025664455981920496,"reconciliation_max_abs":1.1013412404281553e-13,"seeds":[6020000,6020511],"chunk_size":64,"runs_per_seed_per_arm":1},"gas":{"max_ok":231381,"init_max_ok":243147,"oog":0,"other_failures":0,"valid":true,"raw_counters":[{"role":"Baseline","callback":"afterInitialize","calls":512,"ok":512,"max_ok_gas":21796,"sum_ok_gas":11159552,"oog":0,"revert":0,"other_halt":0,"tx_error":0,"bad_return":0},{"role":"Baseline","callback":"afterSwap","calls":5491757,"ok":5491757,"max_ok_gas":22592,"sum_ok_gas":123909450832,"oog":0,"revert":0,"other_halt":0,"tx_error":0,"bad_return":0},{"role":"Baseline","callback":"getName","calls":512,"ok":512,"max_ok_gas":21526,"sum_ok_gas":11021312,"oog":0,"revert":0,"other_halt":0,"tx_error":0,"bad_return":0},{"role":"Submission","callback":"afterInitialize","calls":512,"ok":512,"max_ok_gas":243147,"sum_ok_gas":124491264,"oog":0,"revert":0,"other_halt":0,"tx_error":0,"bad_return":0},{"role":"Submission","callback":"afterSwap","calls":5439483,"ok":5439483,"max_ok_gas":231381,"sum_ok_gas":716419648957,"oog":0,"revert":0,"other_halt":0,"tx_error":0,"bad_return":0},{"role":"Submission","callback":"getName","calls":512,"ok":512,"max_ok_gas":21654,"sum_ok_gas":11086848,"oog":0,"revert":0,"other_halt":0,"tx_error":0,"bad_return":0}],"T_raw_counters":[{"role":"Baseline","callback":"afterInitialize","calls":512,"ok":512,"max_ok_gas":21796,"sum_ok_gas":11159552,"oog":0,"revert":0,"other_halt":0,"tx_error":0,"bad_return":0},{"role":"Baseline","callback":"afterSwap","calls":5480326,"ok":5480326,"max_ok_gas":22592,"sum_ok_gas":123652301636,"oog":0,"revert":0,"other_halt":0,"tx_error":0,"bad_return":0},{"role":"Baseline","callback":"getName","calls":512,"ok":512,"max_ok_gas":21526,"sum_ok_gas":11021312,"oog":0,"revert":0,"other_halt":0,"tx_error":0,"bad_return":0},{"role":"Submission","callback":"afterInitialize","calls":512,"ok":512,"max_ok_gas":243115,"sum_ok_gas":124474880,"oog":0,"revert":0,"other_halt":0,"tx_error":0,"bad_return":0},{"role":"Submission","callback":"afterSwap","calls":5280593,"ok":5280593,"max_ok_gas":223251,"sum_ok_gas":653608940785,"oog":0,"revert":0,"other_halt":0,"tx_error":0,"bad_return":0},{"role":"Submission","callback":"getName","calls":512,"ok":512,"max_ok_gas":21623,"sum_ok_gas":11070976,"oog":0,"revert":0,"other_halt":0,"tx_error":0,"bad_return":0}]},"minutes":{"search":44.34849602381389,"search_evaluation":44.06290984832837,"real":5.227979198641454},"notes":["All four required input SHA256s verified. Pinned setup completed and CH check matched exactly.","Both strategies run separately against Vanilla with 8 workers; confirmation seeds processed once, ascending, in 64-seed chunks. Retail/arb decomposition uses the supplied harness.","All 130 network parameters searched; W2 and both biases start at zero, so the initial policy equals T. Every proposal rounds weights to 1e-6. Solidity features and network use signed 1e6 fixed point; floating port uses the same rounded weights. Gate C bounds arithmetic differences.","The signed trade ratio is positive for trade.isBuy and negative otherwise, after the T ratio cap. Features use the updated state immediately before storing the final fees. First-in-step encodes true as +1 and false as -1. Silent is measured before updating timestamp.","Solidity uses unrolled network literals and adds no afterInitialize writes. The 8-unit design passed the preliminary gas probe; final gas is measured on the frozen candidate in confirmation markets.","Search minutes sum execution time of all search segments, including Numba warm-up and process startup; setup and idle gaps between segments are excluded. Search_evaluation is generation and monitor evaluation only. Real minutes include both arms and decomposition; exclude compilation.","Monitor results select proposals, not acceptance. Only the real engine result estimates candidate minus T on confirmation seeds. The 512-seed estimate does not establish top-10 leaderboard placement."],"evidence":{"T":"https://api.imdnotdead.fun/artifacts/6ac5e013b7b1fb4c5e7bdcdfec0aba28b16824e18ccf39500f258533879faffe","RS2":"https://api.imdnotdead.fun/artifacts/19f2ec857df536e8ab62ab1da89ec6623332521ce46849f15bccff402c63e1e5","replica":"https://api.imdnotdead.fun/artifacts/e8a7a2af9039c24b8bb2d3b5fa1c9113606cbf5a480ac07d02ca26750f1752ea","port":"https://api.imdnotdead.fun/artifacts/d845a4b94eab87f23956fd1939c0135d955df212d1f3037f2a761c178cef7a0e","real_decomposition":"https://api.imdnotdead.fun/artifacts/33f54e81f3372088e9eced52c0174f310ac348af98ef5727b73785c088679194","measurements":"Locally measured in this run; gates and confirmation are not copied from upstream artifacts."},"input_sha256":{"T":"ebd9de9bf6af6e55d5e308fd15dbb88edec11fd684891d02a30aec185acd19b3","RS2":"f24b6ca198b744c380842c3a17964a6dc21f311bb04984b26733afa3fee8eaf2","replica":"1e4c44b4bffbdeed65872ee15d46dbde209bf5aa11014329d13d100507b4040c","port":"9eac3553357528b06eeae3ed8d18283d83401e1968145ceba16be356a147e271"},"conclusion":"The frozen 8-unit policy improved over T on the specified 512 confirmation seeds by 1.257317072552457 (paired SE 0.06203879579203182). This is below the approximately +4.3 over T cited in the brief as needed for top 10; no leaderboard placement is established."}
