{"item":"b","batch":"e09-head-gas","blocked":null,"n":512,"scope":"Gas envelope only. n is seeds per arm; 2560 arm-seeds plus the separate 1000-seed calibration. No performance-gain, leaderboard, paired edge, retail-edge or arbitrage-edge claim; no confirmation seeds used.","protocol":{"repository":"https://github.com/benedictbrady/amm-challenge","commit":"6b6921f8d463314aa7c96234e1be25a25245f704","rs2_source":"https://api.imd.fun/artifacts/19f2ec857df536e8ab62ab1da89ec6623332521ce46849f15bccff402c63e1e5","harness_source":"https://api.imd.fun/artifacts/26cb8e86f05170308de2a4b24821ac7fad2a17077f8d94af6e0f31985343fe89","calibration_source":"https://raw.githubusercontent.com/ChengHua926/amm-challenge/d34a5199c59a4c44d5336a25f1436b4ae1f21104/contracts/src/Strategy.sol","rs2_sha256":"f24b6ca198b744c380842c3a17964a6dc21f311bb04984b26733afa3fee8eaf2","wheel_version":"amm_sim_rs 0.1.0.post1","wheel_sha256":"aedb68280aca34c110968f00148387c95885207913fb2cf19a1ab4c5cfd6887a","solc":"0.8.24","optimizer_runs":200,"viaIR":true,"evmVersion":"paris","workers":8,"chunk_max":20,"tuning_seeds_inclusive":[736100,736611],"steps":10000,"config_source":"Exact configs() excerpt of H.harness_source; size then rate then sigma from default_rng(seed). Simulator price seed=s, retail seed=s+1.","arms":"Each source alone against VanillaStrategy; run_batch(candidate,vanilla,configs,8); gas_stats_reset() before and gas_stats() after every arm/chunk.","measurement_source":"Local execution of embedded harness_source; compact chunk evidence below. No simulator source changes."},"calibration":{"n":1000,"seeds_inclusive":[0,999],"expected_mean":525.5258821780834,"observed_mean":525.5258821780834,"absolute_error":0.0,"tolerance":1e-06,"passed":true,"gas":{"max_ok":151647,"init_max_ok":185532,"oog":0,"other_halts":0},"seconds":100.31894182786345,"source_sha256":"6dd68f77a70900319460215374143dbd5d924198450a46d9f5f91f6b1e3d35c3"},"architecture_rows":[{"name":"RS2","inputs":null,"hidden":null,"outputs":2,"weights":0,"biases":0,"MACs":0,"source_sha256":"f24b6ca198b744c380842c3a17964a6dc21f311bb04984b26733afa3fee8eaf2","creation_bytes":9850,"deployed_bytes":9822,"gas":{"max_ok":202492,"init_max_ok":243099,"oog":0,"other_halts":0},"n":512,"valid":true,"static_policy_valid":true,"state_test_max_ok":147398,"zero_prior_fee_stress_max_ok":169745,"runtime_opcode_counts":{"MUL":70,"SLOAD":17,"SSTORE":25}},{"name":"skeleton","inputs":null,"hidden":null,"outputs":2,"weights":0,"biases":0,"MACs":0,"source_sha256":"943ef987638a5f55a3cf11a03288cc3f850ac71d022fecb973ac832fe9d7ebe1","creation_bytes":8150,"deployed_bytes":8122,"gas":{"max_ok":193572,"init_max_ok":243084,"oog":0,"other_halts":0},"n":512,"valid":true,"static_policy_valid":true,"state_test_max_ok":140811,"zero_prior_fee_stress_max_ok":183407,"runtime_opcode_counts":{"MUL":48,"SLOAD":17,"SSTORE":25}},{"name":"head_8_8_2","inputs":8,"hidden":8,"outputs":2,"weights":80,"biases":10,"MACs":80,"source_sha256":"53f7f3676fcc39f9b107d81d0b080035d81b36852f7547d34fcc0732c8a1134a","creation_bytes":9809,"deployed_bytes":9781,"gas":{"max_ok":203826,"init_max_ok":243099,"oog":0,"other_halts":0},"n":512,"parameters":90,"valid":true,"static_policy_valid":true,"state_test_max_ok":148113,"zero_prior_fee_stress_max_ok":188010,"runtime_opcode_counts":{"MUL":131,"SLOAD":17,"SSTORE":25}},{"name":"head_10_12_2","inputs":10,"hidden":12,"outputs":2,"weights":144,"biases":14,"MACs":144,"source_sha256":"04bf7d616e0c6839dcdeab3801361cd28d0f3c9edab1452dc432e93db9b55897","creation_bytes":10728,"deployed_bytes":10700,"gas":{"max_ok":206326,"init_max_ok":243106,"oog":0,"other_halts":0},"n":512,"parameters":158,"valid":true,"static_policy_valid":true,"state_test_max_ok":150734,"zero_prior_fee_stress_max_ok":190597,"runtime_opcode_counts":{"MUL":197,"SLOAD":17,"SSTORE":25}},{"name":"head_12_16_2","inputs":12,"hidden":16,"outputs":2,"weights":224,"biases":18,"MACs":224,"source_sha256":"4e678577ad9d2e0b2dc6b2b8eb0753ed79d3f31c7873c3817db1b950967b7dd7","creation_bytes":12494,"deployed_bytes":12466,"gas":{"max_ok":209891,"init_max_ok":243143,"oog":0,"other_halts":0},"n":512,"parameters":242,"valid":true,"static_policy_valid":true,"state_test_max_ok":154381,"zero_prior_fee_stress_max_ok":194202,"runtime_opcode_counts":{"MUL":277,"SLOAD":17,"SSTORE":25}}],"recommended":{"name":"head_12_16_2","reason":"Largest of the three tested heads meeting afterSwap <235000, init <245000, and zero architecture halts in both market and directed callback tests. No shrinking needed.","MACs":224,"weights":224,"parameters_including_bias":242,"deployed_bytes":12466,"afterSwap_margin_to_235000":25109,"init_margin_to_245000":1857,"limitations":["Observed maxima are not a proof of worst-case safety.","Recommendation applies to this exact compiler, source, signed weight fixture, normalization and 5-to-105-bps fee range. Retrain or alter weights, features or fee scaling only with a fresh gas check.","Different fee policies produce different trade paths and callback counts; subtraction of market maxima is not a marginal MAC-cost estimate.","Synthetic legal-slot stress includes zero prior fees, which are not reachable from this head's own positive-fee initialization/outputs."]},"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 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\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        int256[12] memory nnX;\n        nnX[0] = _nnNorm(sigmaHat, 1000000000000000); // sigma\n        nnX[1] = _nnNorm(lambdaHat, WAD); // retail_blended_rate\n        nnX[2] = _nnNorm(sizeHat, 2000000000000000); // retail_blended_size\n        nnX[3] = _nnNorm(toxEma, 10000000000000000); // toxicity\n        nnX[4] = _nnNorm(actEma, 2000000000000000); // activity\n        nnX[5] = _nnNorm(dirState, WAD) - 1024; // centered_direction\n        nnX[6] = _nnGap(spot, pHat); // signed_slow_price_gap\n        nnX[7] = _nnNorm(arbProbability, WAD); // arb_probability\n        nnX[8] = _nnGap(spot, fastHat); // signed_fast_price_gap\n        nnX[9] = _nnNorm(silent, 2); // silence\n        nnX[10] = firstInStep ? int256(1024) : -int256(1024); // first_print\n        nnX[11] = trade.isBuy ? _nnNorm(tradeRatio, 5000000000000000) : -_nnNorm(tradeRatio, 5000000000000000); // signed_trade_size\n        (uint256 bidFee, uint256 askFee) = _nnHead(nnX);\n        lambdaHat = originalLambda; sizeHat = originalSize;\n        slots[0] = bidFee; slots[1] = askFee; slots[2] = (spot << 64) | trade.timestamp;\n        slots[3] = dirState; slots[4] = actEma; slots[5] = pHat;\n        slots[6] = sigmaHat; slots[7] = lambdaHat; slots[8] = sizeHat;\n        slots[9] = toxEma; slots[10] = stepTradeCount;\n\n        return (bidFee, askFee);\n    }\n\n\n    struct PosteriorInput {\n        uint256 mu; uint256 v; uint256 obs; uint256 spot; uint256 preSpot;\n        uint256 bid; uint256 ask; bool first; uint256 silent; bool buy; uint256 size;\n    }\n    function _posterior(PosteriorInput memory x) internal pure returns (uint256, uint256, uint256) {\n        if (x.mu == 0) x.mu = x.spot;\n        if (x.v < 10000000000) x.v = 10000000000;\n        uint256 lo = wmul(x.preSpot, WAD-x.bid);\n        uint256 hi = wdiv(x.preSpot, WAD-x.ask);\n        if (x.first) {\n            if (x.silent>1 && x.preSpot>0) {\n                uint256 elapsed=x.silent>8?8:x.silent;\n                x.v += 902500000000*(elapsed-1);\n                (x.mu,x.v)=_band(x.mu,x.v,lo,hi);\n            }\n            x.v+=902500000000;\n        }\n        uint256 mRetail = x.mu;\n        uint256 vRetail = x.v;\n        // A missing own-pool trade is a censored price observation.\n        if (x.first && x.preSpot > 0) {\n            (mRetail, vRetail) = _band(x.mu, x.v, lo, hi);\n        }\n        if (!x.first) {\n            // A later print is retail. Only an interior route is an observation\n            // of the other pool, with explicit observation uncertainty.\n            uint256 fee = x.buy ? x.bid : x.ask;\n            if (fee > 30 * BPS) {\n                uint256 normal = x.buy ? wdiv(wmul(x.spot, WAD-fee), WAD-30*BPS)\n                    : wdiv(wmul(x.spot, WAD-30*BPS), WAD-fee);\n                uint256 residual = wdiv(absDiff(normal, x.mu),x.mu);\n                uint256 noise = 9000000000000 + wmul(residual,residual);\n                uint256 k = wdiv(x.v,x.v+noise);\n                return (_blend(x.mu,normal,k),wmul(x.v,WAD-k),0);\n            }\n            return (x.mu,x.v,0);\n        }\n        uint256 e = wdiv(absDiff(x.obs,x.mu),x.mu);\n        uint256 totalV = x.v + 22500000000;\n        uint256 z = wdiv(wmul(e,e),totalV);\n        uint256 density = _powWad(wdiv(WAD,WAD+z/8),4);\n        uint256 odds = wmul(density,wdiv(4000000000000000,_isqrt(totalV*WAD)));\n        if (x.size > 3000000000000000) odds = wmul(odds,4*WAD/10);\n        if (x.silent > 1) odds = wmul(odds,8*WAD/10);\n        uint256 sd = _isqrt(x.v*WAD);\n        uint256 width = wdiv(hi-lo,x.mu);\n        uint256 distance = x.mu<lo?lo-x.mu:(x.mu>hi?x.mu-hi:0);\n        uint256 zBand = wdiv(wdiv(distance,x.mu),sd);\n        uint256 mass = wmul(wdiv(width,width+2*sd),wdiv(WAD,WAD+wmul(zBand,zBand)));\n        if (mass < WAD/100) mass = WAD/100;\n        odds = wdiv(odds,mass);\n        uint256 prob = wdiv(odds,WAD+odds);\n        uint256 kArb = wdiv(x.v,totalV);\n        uint256 mArb = _blend(x.mu,x.obs,kArb);\n        uint256 mean = _blend(mRetail,mArb,prob);\n        uint256 between = wdiv(absDiff(mArb,mRetail),x.mu);\n        uint256 variance = wmul(prob,wmul(x.v,WAD-kArb)) + wmul(WAD-prob,vRetail)\n            + wmul(wmul(prob,WAD-prob),wmul(between,between));\n        if (variance > 100000000000000) variance = 100000000000000;\n        return (mean,variance,prob);\n    }\n    function _blend(uint256 a,uint256 b,uint256 w) internal pure returns(uint256) {\n        return b>=a ? a+wmul(b-a,w) : a-wmul(a-b,w);\n    }\n    function _band(uint256 mu,uint256 v,uint256 lo,uint256 hi) internal pure returns(uint256,uint256) {\n        // Soft interval likelihood avoids discontinuities at quadrature nodes.\n        uint256 sd=wmul(mu,_isqrt(v*WAD));\n        uint256[3] memory acc;\n        for(uint256 j=0;j<7;j++) {\n            uint256 p=j<3 ? (mu>(3-j)*sd?mu-(3-j)*sd:1) : mu+(j-3)*sd;\n            uint256 w=j==3?72:(j==2||j==4?45:(j==1||j==5?10:1));\n            uint256 distance=p<lo?lo-p:(p>hi?p-hi:0);\n            uint256 z=sd>0?wdiv(distance,sd):0;\n            uint256 likelihood=wdiv(WAD,WAD+4*wmul(z,z));\n            w=wmul(w*WAD,likelihood);\n            acc[0]+=w;acc[1]+=wmul(w,p);\n            uint256 d=wdiv(absDiff(p,mu),mu);\n            acc[2]+=wmul(w,wmul(d,d));\n        }\n        uint256 m=wdiv(acc[1],acc[0]);\n        uint256 d=wdiv(absDiff(m,mu),mu);\n        uint256 second=wdiv(acc[2],acc[0]);\n        return(m,second>wmul(d,d)?second-wmul(d,d):10000000000);\n    }\n\n\n    // NN_BEGIN: no persistent state or initialization writes.\n    // Q10 features/weights; saturate BEFORE multiplication and signed conversion.\n    function _nnNorm(uint256 v, uint256 unit) internal pure returns (int256) {\n        if (v >= 4 * unit) return 4096;\n        return int256(v * 1024 / unit);\n    }\n    function _nnGap(uint256 a, uint256 b) internal pure returns (int256) {\n        if (b == 0) return 0;\n        uint256 d = a >= b ? a - b : b - a;\n        // Denominator is at least one; its cap keeps unit*4 and v*1024 safe.\n        uint256 unit = b / 100;\n        if (unit == 0) unit = 1;\n        if (unit > type(uint256).max / 4096) unit = type(uint256).max / 4096;\n        int256 z = _nnNorm(d, unit);\n        return a >= b ? z : -z;\n    }\n    function _nnRelu(int256 accumulator) internal pure returns (int256) {\n        if (accumulator <= 0) return 0;\n        if (accumulator >= 4194304) return 4096;\n        return accumulator / 1024;\n    }\n\n    function _nnHead(int256[12] memory x) internal pure returns (uint256 bid, uint256 ask) {\n        int256[16] memory h;\n        unchecked {\n            h[0] = _nnRelu(-538624 + (-344 * x[0]) + (521 * x[1]) + (-482 * x[2]) + (419 * x[3]) + (140 * x[4]) + (-221 * x[5]) + (342 * x[6]) + (-439 * x[7]) + (-448 * x[8]) + (-689 * x[9]) + (-458 * x[10]) + (-203 * x[11]));\n            h[1] = _nnRelu(552960 + (-500 * x[0]) + (261 * x[1]) + (446 * x[2]) + (-479 * x[3]) + (424 * x[4]) + (-345 * x[5]) + (-434 * x[6]) + (-627 * x[7]) + (-732 * x[8]) + (301 * x[9]) + (422 * x[10]) + (263 * x[11]));\n            h[2] = _nnRelu(690176 + (400 * x[0]) + (641 * x[1]) + (-154 * x[2]) + (-283 * x[3]) + (580 * x[4]) + (597 * x[5]) + (-654 * x[6]) + (-687 * x[7]) + (504 * x[8]) + (553 * x[9]) + (642 * x[10]) + (451 * x[11]));\n            h[3] = _nnRelu(731136 + (300 * x[0]) + (-765 * x[1]) + (-374 * x[2]) + (-599 * x[3]) + (224 * x[4]) + (-209 * x[5]) + (490 * x[6]) + (-363 * x[7]) + (-660 * x[8]) + (-549 * x[9]) + (222 * x[10]) + (-639 * x[11]));\n            h[4] = _nnRelu(946176 + (584 * x[0]) + (761 * x[1]) + (594 * x[2]) + (531 * x[3]) + (-636 * x[4]) + (-205 * x[5]) + (-326 * x[6]) + (295 * x[7]) + (-688 * x[8]) + (161 * x[9]) + (698 * x[10]) + (699 * x[11]));\n            h[5] = _nnRelu(-956416 + (612 * x[0]) + (757 * x[1]) + (302 * x[2]) + (-719 * x[3]) + (152 * x[4]) + (-713 * x[5]) + (674 * x[6]) + (611 * x[7]) + (460 * x[8]) + (-541 * x[9]) + (150 * x[10]) + (631 * x[11]));\n            h[6] = _nnRelu(327680 + (384 * x[0]) + (497 * x[1]) + (138 * x[2]) + (-651 * x[3]) + (-308 * x[4]) + (197 * x[5]) + (638 * x[6]) + (-671 * x[7]) + (-488 * x[8]) + (665 * x[9]) + (498 * x[10]) + (-435 * x[11]));\n            h[7] = _nnRelu(271360 + (-668 * x[0]) + (365 * x[1]) + (614 * x[2]) + (-455 * x[3]) + (-208 * x[4]) + (449 * x[5]) + (218 * x[6]) + (-475 * x[7]) + (132 * x[8]) + (277 * x[9]) + (718 * x[10]) + (-239 * x[11]));\n            h[8] = _nnRelu(726016 + (-184 * x[0]) + (-745 * x[1]) + (706 * x[2]) + (131 * x[3]) + (-236 * x[4]) + (445 * x[5]) + (-566 * x[6]) + (663 * x[7]) + (544 * x[8]) + (401 * x[9]) + (298 * x[10]) + (-299 * x[11]));\n            h[9] = _nnRelu(723968 + (212 * x[0]) + (-485 * x[1]) + (414 * x[2]) + (575 * x[3]) + (136 * x[4]) + (313 * x[5]) + (-146 * x[6]) + (-211 * x[7]) + (188 * x[8]) + (525 * x[9]) + (-262 * x[10]) + (-359 * x[11]));\n            h[10] = _nnRelu(-483328 + (-368 * x[0]) + (481 * x[1]) + (762 * x[2]) + (763 * x[3]) + (-164 * x[4]) + (693 * x[5]) + (-622 * x[6]) + (655 * x[7]) + (216 * x[8]) + (137 * x[9]) + (354 * x[10]) + (-675 * x[11]));\n            h[11] = _nnRelu(700416 + (-524 * x[0]) + (221 * x[1]) + (598 * x[2]) + (-439 * x[3]) + (448 * x[4]) + (-177 * x[5]) + (-458 * x[6]) + (-715 * x[7]) + (500 * x[8]) + (645 * x[9]) + (702 * x[10]) + (351 * x[11]));\n            h[12] = _nnRelu(703488 + (680 * x[0]) + (217 * x[1]) + (-306 * x[2]) + (-627 * x[3]) + (-604 * x[4]) + (685 * x[5]) + (166 * x[6]) + (-135 * x[7]) + (-144 * x[8]) + (-513 * x[9]) + (-410 * x[10]) + (-283 * x[11]));\n            h[13] = _nnRelu(280576 + (324 * x[0]) + (213 * x[1]) + (-398 * x[2]) + (431 * x[3]) + (376 * x[4]) + (-425 * x[5]) + (-514 * x[6]) + (323 * x[7]) + (428 * x[8]) + (-381 * x[9]) + (374 * x[10]) + (-471 * x[11]));\n            h[14] = _nnRelu(865280 + (-608 * x[0]) + (-465 * x[1]) + (-490 * x[2]) + (-747 * x[3]) + (-276 * x[4]) + (-293 * x[5]) + (-606 * x[6]) + (-255 * x[7]) + (712 * x[8]) + (633 * x[9]) + (722 * x[10]) + (-531 * x[11]));\n            h[15] = _nnRelu(-661504 + (380 * x[0]) + (333 * x[1]) + (198 * x[2]) + (551 * x[3]) + (560 * x[4]) + (289 * x[5]) + (-314 * x[6]) + (-315 * x[7]) + (-612 * x[8]) + (-629 * x[9]) + (430 * x[10]) + (591 * x[11]));\n            bid = 5 * BPS + uint256(_nnRelu(1572864 + (-384 * h[0]) + (-497 * h[1]) + (650 * h[2]) + (267 * h[3]) + (-180 * h[4]) + (-197 * h[5]) + (254 * h[6]) + (543 * h[7]) + (-744 * h[8]) + (537 * h[9]) + (498 * h[10]) + (-307 * h[11]) + (-540 * h[12]) + (493 * h[13]) + (742 * h[14]) + (711 * h[15]))) * (100 * BPS) / 4096;\n            ask = 5 * BPS + uint256(_nnRelu(1835008 + (-464 * h[0]) + (-193 * h[1]) + (-602 * h[2]) + (-603 * h[3]) + (644 * h[4]) + (405 * h[5]) + (-590 * h[6]) + (495 * h[7]) + (312 * h[8]) + (-489 * h[9]) + (-194 * h[10]) + (259 * h[11]) + (-620 * h[12]) + (445 * h[13]) + (438 * h[14]) + (279 * h[15]))) * (100 * BPS) / 4096;\n        }\n    }\n    // NN_END\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 \"rs2_nn_12_16_2\"; }\n}\n","sha256":"4e678577ad9d2e0b2dc6b2b8eb0753ed79d3f31c7873c3817db1b950967b7dd7","head_design":{"fixed_point_Q":1024,"input_abs_bound":4096,"hidden_activation_range":[0,4096],"output_activation_range":[0,4096],"fee_formula":"5*BPS + clamped_output*(100*BPS)/4096; initial fees remain RS2 4*BPS","weights":"Dense, unrolled, nonzero signed literal coefficients in bytecode; biases nonzero. weights counts matrix entries; MACs excludes biases. No coefficient storage, constructor or additional init writes.","features":[{"index":0,"name":"sigma","expression":"_nnNorm(sigmaHat, 1000000000000000)"},{"index":1,"name":"retail_blended_rate","expression":"_nnNorm(lambdaHat, WAD)"},{"index":2,"name":"retail_blended_size","expression":"_nnNorm(sizeHat, 2000000000000000)"},{"index":3,"name":"toxicity","expression":"_nnNorm(toxEma, 10000000000000000)"},{"index":4,"name":"activity","expression":"_nnNorm(actEma, 2000000000000000)"},{"index":5,"name":"centered_direction","expression":"_nnNorm(dirState, WAD) - 1024"},{"index":6,"name":"signed_slow_price_gap","expression":"_nnGap(spot, pHat)"},{"index":7,"name":"arb_probability","expression":"_nnNorm(arbProbability, WAD)"},{"index":8,"name":"signed_fast_price_gap","expression":"_nnGap(spot, fastHat)"},{"index":9,"name":"silence","expression":"_nnNorm(silent, 2)"},{"index":10,"name":"first_print","expression":"firstInStep ? int256(1024) : -int256(1024)"},{"index":11,"name":"signed_trade_size","expression":"trade.isBuy ? _nnNorm(tradeRatio, 5000000000000000) : -_nnNorm(tradeRatio, 5000000000000000)"}],"feature_prefixes":"8-8-2 uses first 8; 10-12-2 first 10; 12-16-2 all 12.","liveness":"All input features come from current/past trade and retained RS2 estimators. Every dense row feeds both live fees, stored in slots 0/1. Perturbation witnesses for every input changed fees; all hidden units reached both clamp limits in kernel tests. Runtime MUL counts include estimators, so logical MAC counts are reported separately."},"preservation_checks":{"initializer_source_identical":true,"estimator_prefix_source_identical":true,"original_fee_mapping_removed":true,"estimator_state_restoration_preserved":true,"slot_access":"Only inherited uint256[32] slots. Original estimator code reads/writes slots 0..15; no new storage, slots 16..31 remain zero in tests.","static_validation":"All five pass SolidityValidator and SolidityCompiler forbidden-opcode and storage-layout checks.","compiler_source":"https://raw.githubusercontent.com/benedictbrady/amm-challenge/6b6921f8d463314aa7c96234e1be25a25245f704/amm_competition/evm/compiler.py","storage_definition":"https://raw.githubusercontent.com/benedictbrady/amm-challenge/6b6921f8d463314aa7c96234e1be25a25245f704/contracts/src/AMMStrategyBase.sol"},"arithmetic_tests":{"passed":true,"kernel":[{"inputs":8,"hidden":8,"cases":787,"corner_vectors":256,"random_vectors":512,"exact_integer_parity":true,"all_inputs_live":true,"hidden_min":[0,0,0,0,0,0,0,0],"hidden_max":[4096,4096,4096,4096,4096,4096,4096,4096],"distinct_fee_pairs":521,"signed_weights":{"negative":38,"positive":42,"zero":0},"hidden_accumulator_abs_bound":18149376,"output_accumulator_abs_bound":18399232},{"inputs":10,"hidden":12,"cases":1559,"corner_vectors":1024,"random_vectors":512,"exact_integer_parity":true,"all_inputs_live":true,"hidden_min":[0,0,0,0,0,0,0,0,0,0,0,0],"hidden_max":[4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096],"distinct_fee_pairs":797,"signed_weights":{"negative":74,"positive":70,"zero":0},"hidden_accumulator_abs_bound":24082432,"output_accumulator_abs_bound":23945216},{"inputs":12,"hidden":16,"cases":4635,"corner_vectors":4096,"random_vectors":512,"exact_integer_parity":true,"all_inputs_live":true,"hidden_min":[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],"hidden_max":[4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096],"distinct_fee_pairs":2784,"signed_weights":{"negative":103,"positive":121,"zero":0},"hidden_accumulator_abs_bound":26851328,"output_accumulator_abs_bound":32473088}],"helpers":{"cases":143,"exact_integer_parity":true,"includes":"negative/zero/positive accumulator, clamp-1/clamp/clamp+1, signed int256 extrema, denominator zero, uint256-max gap operands","overflow_or_halt":false},"state":[{"name":"RS2","cases":134,"initial_state_equal":true,"init_nonzero_slots":10,"estimator_slots_2_through_31_equal":true,"slots_0_1_match_return":true,"slots_16_through_31_zero":true,"step_counter_cap_test":64,"branch_gas":{"first_no_silence":{"calls":24,"max_ok":147398,"min_ok":64472},"later_no_silence":{"calls":16,"max_ok":42990,"min_ok":39371},"first_silence":{"calls":24,"max_ok":85564,"min_ok":81269}},"oog":0,"other_halts":0},{"name":"skeleton","cases":134,"initial_state_equal":true,"init_nonzero_slots":10,"estimator_slots_2_through_31_equal":true,"slots_0_1_match_return":true,"slots_16_through_31_zero":true,"step_counter_cap_test":64,"branch_gas":{"first_no_silence":{"calls":24,"max_ok":140811,"min_ok":58441},"later_no_silence":{"calls":16,"max_ok":34366,"min_ok":33429},"first_silence":{"calls":24,"max_ok":79544,"min_ok":77213}},"oog":0,"other_halts":0},{"name":"head_8_8_2","cases":134,"initial_state_equal":true,"init_nonzero_slots":10,"estimator_slots_2_through_31_equal":true,"slots_0_1_match_return":true,"slots_16_through_31_zero":true,"step_counter_cap_test":64,"branch_gas":{"first_no_silence":{"calls":24,"max_ok":148113,"min_ok":62994},"later_no_silence":{"calls":16,"max_ok":43683,"min_ok":38007},"first_silence":{"calls":24,"max_ok":86525,"min_ok":81775}},"oog":0,"other_halts":0},{"name":"head_10_12_2","cases":134,"initial_state_equal":true,"init_nonzero_slots":10,"estimator_slots_2_through_31_equal":true,"slots_0_1_match_return":true,"slots_16_through_31_zero":true,"step_counter_cap_test":64,"branch_gas":{"first_no_silence":{"calls":24,"max_ok":150734,"min_ok":65488},"later_no_silence":{"calls":16,"max_ok":46131,"min_ok":40517},"first_silence":{"calls":24,"max_ok":89290,"min_ok":84331}},"oog":0,"other_halts":0},{"name":"head_12_16_2","cases":134,"initial_state_equal":true,"init_nonzero_slots":10,"estimator_slots_2_through_31_equal":true,"slots_0_1_match_return":true,"slots_16_through_31_zero":true,"step_counter_cap_test":64,"branch_gas":{"first_no_silence":{"calls":24,"max_ok":154381,"min_ok":70396},"later_no_silence":{"calls":16,"max_ok":49777,"min_ok":46456},"first_silence":{"calls":24,"max_ok":92486,"min_ok":88360}},"oog":0,"other_halts":0}],"zero_prior_fee_stress":[{"name":"RS2","n":162,"oog":0,"other_halts":0,"max_ok":169745,"worst":{"bid":10500000000000000,"ask":0,"kind":"first","buy":true,"spot_offset_percent":0},"branches":{"first":169745,"later":101946,"silence":145345}},{"name":"skeleton","n":162,"oog":0,"other_halts":0,"max_ok":183407,"worst":{"bid":0,"ask":0,"kind":"first","buy":false,"spot_offset_percent":-1},"branches":{"first":183407,"later":113950,"silence":159035}},{"name":"head_8_8_2","n":162,"oog":0,"other_halts":0,"max_ok":188010,"worst":{"bid":0,"ask":0,"kind":"first","buy":false,"spot_offset_percent":1},"branches":{"first":188010,"later":118596,"silence":163654}},{"name":"head_10_12_2","n":162,"oog":0,"other_halts":0,"max_ok":190597,"worst":{"bid":0,"ask":0,"kind":"first","buy":false,"spot_offset_percent":-1},"branches":{"first":190597,"later":121220,"silence":166128}},{"name":"head_12_16_2","n":162,"oog":0,"other_halts":0,"max_ok":194202,"worst":{"bid":0,"ask":0,"kind":"first","buy":false,"spot_offset_percent":-1},"branches":{"first":194202,"later":124729,"silence":169731}}],"state_test_method":"pyrevm 0.3.7: fresh EVM with installed runtime and restored slots per callback. Match prior fees in RS2 for estimator parity. Directed trades include timestamp 0, first/later prints, both sides, silence to 1000, and the 64-trade counter cap.","bounds":["Inputs normalized/clamped before multiplication and int256 conversion. Normalizer units are positive constants or bounded to floor((2^256-1)/4096); the product v*1024 is safe because v<4*unit on the multiplying branch.","With |x|<=4096, |weight|<=768 and |bias|<=1792, every accumulator has magnitude <2^26. Exact per-matrix triangle bounds are in kernel rows. Only bounded dense MAC arithmetic is unchecked.","ReLU clamps accumulator before division; nonnegative conversion is safe. Fee output is 5..105 BPS, below MAX_FEE=1000 BPS.","These bounds cover the added head and normalization. Existing RS2 estimator arithmetic/domain assumptions are unchanged; arbitrary malicious reserves are not a proven-safe input domain."]},"throughput":{"workers":8,"note":"Elapsed wall time includes run_batch, result extraction, gas collection, JSON checkpoint writing and collection overhead; excludes compilation. Architecture tests use different market paths.","arms":[{"name":"RS2","seconds":113.5623005121015,"seeds_per_second":4.508538464712062,"afterSwap_calls":5258400,"afterSwap_calls_per_second":46304.09895086311,"mean_afterSwap_gas":117918.21524075765},{"name":"skeleton","seconds":128.05650719394907,"seeds_per_second":3.998234929401487,"afterSwap_calls":8155091,"afterSwap_calls_per_second":63683.53454814004,"mean_afterSwap_gas":102629.27462293186},{"name":"head_8_8_2","seconds":126.92550160293467,"seeds_per_second":4.033862332895929,"afterSwap_calls":6298856,"afterSwap_calls_per_second":49626.40226315531,"mean_afterSwap_gas":115412.4178908043},{"name":"head_10_12_2","seconds":141.77981849201024,"seeds_per_second":3.6112332872598008,"afterSwap_calls":6680659,"afterSwap_calls_per_second":47119.95734693706,"mean_afterSwap_gas":115119.11628358818},{"name":"head_12_16_2","seconds":85.86747819418088,"seeds_per_second":5.962676565884027,"afterSwap_calls":2851242,"afterSwap_calls_per_second":33205.144252078724,"mean_afterSwap_gas":132457.97792821514}]},"gas_evidence":{"fields":["seed_start","chunk_n","submission_afterSwap_calls","submission_afterSwap_max_ok","submission_init_max_ok","all_roles_oog","all_roles_other_errors"],"chunks":{"encoding":"zlib+base64","bytes":4880,"sha256":"5bc9b0b44823eadc5f8a1165d82c14c2d8e088dca84eaa5bc2deef1054e32042","data":"eNp9WM3OXTUMfJeu7yL+ix0eA5ZVVSFRCQkEC9gh3h07iQ/czwlqpUr9ps54Mvbk9K9P3/+An777/FmpQ2svjN9NSF6gxgYvZGpjvNqrfXlNEG6Q6egvGIqqFcQbxBiVhoJiBfUN6mg9TkXpFWQbpB3pVgnbv5zYQSjxFx9BSRwamf+BPA6Vkrgwru64SoAP8dFnJfKfFlASl0bByeggJiXx7n05aBBUTpTESWYlV7zqRI/ixhxighwqJXFEnt3BkApK4qwILzA/tx7HSdydMqbiB+K8iUNDi0pArR7HSbz1ycn6qDpxEjdCX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/HlmgLvW4PdIQ3+PByfccVVASR+LVHXMFJXEPTpuV1offOyiJ+/daZGv0V0CUxGM1z0/gphWUxA3ipeXdrY/2d9BDHOOnHnVyAG3ivkPH0skOoIf4iF00mnIlzkncv41xuaAS57TKNL1/EDSox+2RDtPN/5VpCNUFnIrPz1rvTrHeHSdxH2Wa3WnlJI9VALcEB1AqPuba9+MOnCSJ+/N+ObNbBSVxmT896yT2+CkeH353Vv20R7qLr5BZSN8offn7HzM76V0="},"counter_note":"other_errors sums revert, other_halt, tx_error and bad_return. All baseline and submission errors were zero. Full aggregate counters include getName and initialization. Full aggregate rows omitted to meet size; chunk errors cover every callback and both roles."},"failed_architecture_probes":[],"excluded_harness_diagnostics":[{"probe":"pyrevm.commit() API experiment on original RS2","error":"Halt { reason: CallTooDeep, gas_used: 22192 }","classification":"Invalid harness setup, not a run_batch architecture observation. Discarded; directed tests use a fresh EVM with installed runtime. No head candidate was run in this diagnostic."}],"generator_source":"\"\"\"Generate RS2 estimator skeleton and deterministic clamped-ReLU gas probes.\nUsage: python generator.py RS2.sol output_directory\nThe matrices are gas fixtures, not trained fee policies. All weights are nonzero.\n\"\"\"\nimport argparse, hashlib, json, re\nfrom pathlib import Path\nQ=1024\nCAP=4096\nARCHS=[(8,8),(10,12),(12,16)]\nSTART='        uint256 flowSize = wmul(lambdaHat, sizeHat);'\nEND='        slots[0] = bidFee; slots[1] = askFee;'\nFEATURES=[\n ('sigma','_nnNorm(sigmaHat, 1000000000000000)'),\n ('retail_blended_rate','_nnNorm(lambdaHat, WAD)'),\n ('retail_blended_size','_nnNorm(sizeHat, 2000000000000000)'),\n ('toxicity','_nnNorm(toxEma, 10000000000000000)'),\n ('activity','_nnNorm(actEma, 2000000000000000)'),\n ('centered_direction','_nnNorm(dirState, WAD) - 1024'),\n ('signed_slow_price_gap','_nnGap(spot, pHat)'),\n ('arb_probability','_nnNorm(arbProbability, WAD)'),\n ('signed_fast_price_gap','_nnGap(spot, fastHat)'),\n ('silence','_nnNorm(silent, 2)'),\n ('first_print','firstInStep ? int256(1024) : -int256(1024)'),\n ('signed_trade_size','trade.isBuy ? _nnNorm(tradeRatio, 5000000000000000) : -_nnNorm(tradeRatio, 5000000000000000)'),\n]\nHELPERS='''\n    // NN_BEGIN: no persistent state or initialization writes.\n    // Q10 features/weights; saturate BEFORE multiplication and signed conversion.\n    function _nnNorm(uint256 v, uint256 unit) internal pure returns (int256) {\n        if (v >= 4 * unit) return 4096;\n        return int256(v * 1024 / unit);\n    }\n    function _nnGap(uint256 a, uint256 b) internal pure returns (int256) {\n        if (b == 0) return 0;\n        uint256 d = a >= b ? a - b : b - a;\n        // Denominator is at least one; its cap keeps unit*4 and v*1024 safe.\n        uint256 unit = b / 100;\n        if (unit == 0) unit = 1;\n        if (unit > type(uint256).max / 4096) unit = type(uint256).max / 4096;\n        int256 z = _nnNorm(d, unit);\n        return a >= b ? z : -z;\n    }\n    function _nnRelu(int256 accumulator) internal pure returns (int256) {\n        if (accumulator <= 0) return 0;\n        if (accumulator >= 4194304) return 4096;\n        return accumulator / 1024;\n    }\n'''\n\ndef parameters(inputs,hidden):\n    # Integer deterministic PRNG independent of Python/numpy versions.\n    state=0xB736100 + inputs*65537 + hidden\n    def word():\n        nonlocal state\n        state=(1664525*state+1013904223)&0xffffffff\n        return state\n    def weight():\n        v=word();return (129+((v>>1)%640))*(1 if v&1 else -1)\n    # Step twice for a sign sequence with both signs in every dense row.\n    def draw():\n        v=word();w=weight();return abs(w)*(1 if v&(1<<16) else -1)\n    w1=[[draw() for _ in range(inputs)] for _ in range(hidden)]\n    b1=[(256+word()%769)*(-1 if j%5==0 else 1) for j in range(hidden)]\n    w2=[[draw() for _ in range(hidden)] for _ in range(2)]\n    b2=[1536,1792]\n    return dict(w1=w1,b1=b1,w2=w2,b2=b2)\n\ndef network(inputs,hidden,p):\n    lines=[HELPERS,f'    function _nnHead(int256[{inputs}] memory x) internal pure returns (uint256 bid, uint256 ask) {{',f'        int256[{hidden}] memory h;','        unchecked {']\n    for j in range(hidden):\n        terms=[str(p['b1'][j]*Q)]+[f'({w} * x[{i}])' for i,w in enumerate(p['w1'][j])]\n        lines.append(f'            h[{j}] = _nnRelu('+ ' + '.join(terms)+');')\n    for o,name in enumerate(['bid','ask']):\n        terms=[str(p['b2'][o]*Q)]+[f'({w} * h[{j}])' for j,w in enumerate(p['w2'][o])]\n        lines.append(f'            {name} = 5 * BPS + uint256(_nnRelu('+' + '.join(terms)+')) * (100 * BPS) / 4096;')\n    lines+=['        }','    }','    // NN_END\\n']\n    return '\\n'.join(lines)\n\ndef generate(rs2,inputs=0,hidden=0):\n    assert hashlib.sha256(rs2.encode()).hexdigest()=='f24b6ca198b744c380842c3a17964a6dc21f311bb04984b26733afa3fee8eaf2'\n    left,right=rs2.split(START,1);_,right=right.split(END,1)\n    if inputs:\n        p=parameters(inputs,hidden)\n        mapping=[f'        int256[{inputs}] memory nnX;']\n        mapping += [f'        nnX[{i}] = {expr}; // {name}' for i,(name,expr) in enumerate(FEATURES[:inputs])]\n        mapping+=['        (uint256 bidFee, uint256 askFee) = _nnHead(nnX);']\n        helpers=network(inputs,hidden,p)\n    else:\n        mapping=['        uint256 bidFee = BASE_FEE; uint256 askFee = BASE_FEE;'];helpers=''\n    mapping+=['        lambdaHat = originalLambda; sizeHat = originalSize;','']\n    source=left+'\\n'.join(mapping)+END+right\n    # Delete only constants exclusively used by removed mapping (BASE_FEE stays for init).\n    dead=['STALE_ATTRACT_FRAC','TRADE_TOX_BOOST','SIGMA_COEF','LAMBDA_COEF','FLOW_SIZE_COEF','TOX_COEF','TOX_QUAD_COEF','ACT_COEF','DIR_COEF','DIR_TOX_COEF','STALE_DIR_COEF','SIGMA_TOX_COEF','TAIL_KNEE','TAIL_SLOPE_PROTECT','TAIL_SLOPE_ATTRACT']\n    for name in dead:\n        source=re.sub(r'    uint256 constant '+name+r' = [^;]+;\\n','',source)\n    a=source.index('    function _compressTailWithSlope(');b=source.index('    function _powWad(',a)\n    source=source[:a]+helpers+'\\n'+source[b:]\n    name=f'rs2_nn_{inputs}_{hidden}_2' if inputs else 'rs2_estimators'\n    source=source.replace('return \"censored_10\";',f'return \"{name}\";')\n    return source\n\ndef manifest(inputs,hidden):\n    p=parameters(inputs,hidden)\n    return dict(inputs=inputs,hidden=hidden,outputs=2,weights=inputs*hidden+hidden*2,biases=hidden+2,parameters=inputs*hidden+hidden*2+hidden+2,MACs=inputs*hidden+hidden*2,Q=Q,activation_cap=CAP,features=[name for name,_ in FEATURES[:inputs]],matrix=p)\n\nif __name__=='__main__':\n    a=argparse.ArgumentParser();a.add_argument('rs2');a.add_argument('out');args=a.parse_args();rs2=Path(args.rs2).read_text();out=Path(args.out);out.mkdir(exist_ok=True,parents=True)\n    (out/'skeleton.sol').write_text(generate(rs2))\n    for n,h in ARCHS:\n        (out/f'head_{n}_{h}_2.sol').write_text(generate(rs2,n,h))\n        (out/f'head_{n}_{h}_2.weights.json').write_text(json.dumps(manifest(n,h),indent=2))\n","harness_source":"import argparse,hashlib,json,time,gc\nfrom pathlib import Path\nimport numpy as np\nimport amm_sim_rs as sim\nfrom amm_competition.evm.compiler import SolidityCompiler\ndef configs(start,n):\n    configs=[]\n    for seed in range(start,start+n):\n        rng=np.random.default_rng(seed)\n        size=rng.uniform(19.,21.)\n        rate=rng.uniform(.6,1.)\n        sigma=rng.uniform(.000882,.001008)\n        configs.append(sim.SimulationConfig(n_steps=10000,initial_price=100.,\n            initial_x=100.,initial_y=10000.,gbm_mu=0.,gbm_sigma=sigma,gbm_dt=1.,\n            retail_arrival_rate=rate,retail_mean_size=size,retail_size_sigma=1.2,\n            retail_buy_prob=.5,seed=seed))\n    return configs\n\n\ndef aggregate(chunks):\n    out={}\n    for chunk in chunks:\n        for row in chunk['raw']:\n            key=(row['role'],row['callback'])\n            dest=out.setdefault(key,{'role':row['role'],'callback':row['callback']})\n            for k,v in row.items():\n                if k in ['role','callback']:continue\n                dest[k]=max(dest.get(k,0),v) if k=='max_ok_gas' else dest.get(k,0)+v\n    return list(out.values())\n\nERRORS=['oog','revert','other_halt','tx_error','bad_return']\ndef measure(path,start,n,out):\n    compiler=SolidityCompiler();source=Path(path).read_text();t0=time.monotonic()\n    c=compiler.compile(source);assert c.success,c.errors\n    v=compiler.compile(Path('contracts/src/VanillaStrategy.sol').read_text(),'VanillaStrategy');assert v.success,v.errors\n    compiled_seconds=time.monotonic()-t0\n    chunks=[];edges=[];t0=time.monotonic()\n    for first in range(start,start+n,20):\n        count=min(20,start+n-first);t=time.monotonic();sim.gas_stats_reset()\n        batch=sim.run_batch(list(c.bytecode),list(v.bytecode),configs(first,count),8)\n        raw=sim.gas_stats();results=batch.results\n        assert sorted(r.seed for r in results)==list(range(first,first+count))\n        edges.extend([{'seed':r.seed,'edge':r.edges['submission']} for r in results])\n        chunk={'start':first,'n':count,'seconds':time.monotonic()-t,'raw':raw};chunks.append(chunk)\n        del results,batch;gc.collect()\n        outdata={'source_sha256':hashlib.sha256(source.encode()).hexdigest(),'creation_bytes':len(c.bytecode),'deployed_bytes':len(c.deployed_bytecode),'compile_seconds':compiled_seconds,'seconds':time.monotonic()-t0,'n':len(edges),'mean_edge':float(np.mean([x['edge'] for x in edges])),'raw_counters':aggregate(chunks),'chunks':chunks,'edges':edges}\n        Path(out).write_text(json.dumps(outdata,allow_nan=False))\n        submission=[r for r in raw if r['role']=='Submission']\n        print(json.dumps({'arm':Path(path).stem,'start':first,'n':len(edges),'seconds':outdata['seconds'],'gas':submission}),flush=True)\n        if any(r.get(e,0) for r in raw for e in ERRORS):\n            print('HALT: architecture invalid; stopping arm',flush=True);break\n    return outdata\nif __name__=='__main__':\n p=argparse.ArgumentParser();p.add_argument('source');p.add_argument('--start',type=int,required=True);p.add_argument('--n',type=int,required=True);p.add_argument('--out',required=True);a=p.parse_args()\n assert (a.start==0 and a.n==1000) or (736100<=a.start<=736611 and a.start+a.n<=736612)\n r=measure(a.source,a.start,a.n,a.out)\n if a.start==0:\n  assert r['n']==1000\n  assert abs(r['mean_edge']-525.5258821780834)<1e-6,r['mean_edge']\n  print('CALIBRATION_PASS',r['mean_edge'],flush=True)\n","reproduction":{"sources":{"RS2.sol":{"encoding":"zlib+base64; dictionary=result.code UTF-8","sha256":"f24b6ca198b744c380842c3a17964a6dc21f311bb04984b26733afa3fee8eaf2","bytes":19703,"data":"ePkyXNxp7Z1NbxoxEIbv+Re9NcqiEhEQUUMimsCltEsLVY4rEoESlQokaE/98fXHeDxeez/a9NBK7yWBxR6Pd23v2B4/8wYAXABwAcAFAPffAeDaI/rmGef5QhfX6zt7upI9O55NivFSZVXVmaq/xsOpD+RuDXK3ZhS4zSfTxOncpkGAspn5V3UR01l+X5juT+kvhhf1Ocxtt2l7DS1BJ/30ZXzHuug2UJtDtxhKfHk+NJPy6sS60/DNaUwp9D5v1YKF+MGw323xpEQRTZ1Ejz7F+4+mEQzapF3M8vmkmH/Ol5Nb3Q0vW/dgn5v6pB7dE70R1GdQn0F9BvUZ1GdQn0F9BvUZ1GdQn0F9BvUZ1GdQn0F9BvUZ1GdQn0F9BvUZ1GdQn0F9BvUZ1GdQn0F9BvUZ1GdQn0F9BvX5P6I+8/q9GmmppuX9GRKeeL9ujJujd0tww4T31sl4As5jiHDKyfwt4Z9DN5yMFUsV/8GcobFaUHbneJL5l/+p/I2dcDK2J2wqmYFzOCecjExBoYQrXP8Lqu01KC04CPni7f0SkK/Y0L9b/3jrFlK327manxzUFDQ0YLw9zK7/Nqe0lTvWn0RKMfOJ7+vEnglntxaZgP6G2Wk5NmFlHr6u+QCBczPKSC4/Bum0RLfVpijd1AQ316CMQ6hyyaoTmpZfCw/OG4OeslY2OnwkUlzb6tzYbx37LTCLk9OWUEiqmFCRFsU0bRMcjqvtOlo0ibxH/cIJryXEOxRVuzu6iKWx+RMzB6fAqfiY2v4mGWIaIeRGc4mo/MXT84YrGTqzZSypogKro3HxDkR4oVnCuzNVA4OmHflKpnYY3NOlD2dC99ge4NZCH65DRW/c9U54PZ7qVs2gywXUq1NWPlKHrjeq09x4HxgXPN5aNtYoWIswG0V0v+2U9KcyFl6lUlyltvB4aYPE11mJJt273e7ATaPkHyxNnQorsbwsK2SaYzV0VC8oyl1OSwwXZhINy8tK7SLRqB43gOpsycfWelx9VG+/vfr4unjcfdvr1Etlv9w/H58W291+zSD22O+z7CzDOjeJXNESZuwMGiDsasfpPyijQu2X3ImU2icnLXdTzC6bG0BIC9UEuRN7EDSr2Oummp65T4bPxv3filXSuAAvje9hLK2kfK28QSwv6hisWW09B3E9WRIiJiBiAiImIGICIiYgYgIiJiBiAiImIGICIiYgYgIiJiBiAiImIGICIiaEERPC/pteyBKmtj84fdA//Q7+ytnfVyN/fpx5TBu5x0PX/CnzM97X1z5E7nJGOlTUBeQzkM9APgP5DOQzkM/+GvnMLd4V513Cnv0CLhYUKw=="},"CH.sol":{"encoding":"zlib+base64; dictionary=result.code UTF-8","sha256":"6dd68f77a70900319460215374143dbd5d924198450a46d9f5f91f6b1e3d35c3","bytes":9399,"data":"ePkyXNxp7V3dT9swEH/fX7G9MZFqIChqxQbqoH2hI91axGNEq1RUC6Ra6Xjhj58/zuezc/kYm1g7/AJpcmefz76zfb788iEA4AYA3ACAu5EAuBsLUatfole9EMdjWd1B26x4S9Fhe8N+0psIVtGcgfircpDaARS3AhS3wk7P4v6AeX+2zkyBTe2QyqsYDOPrRBko0B92Dqs5lNo17UHNSJCkX6965yiLHAOVHHLEAHF3v6O2zeXE0mhQObWURO79RiOYFH/Uae816ClSRZ2RSP+QXFyqQXDUhHY8jEf9ZPQtnvTPpBl2G1uw5QablP6XscatwWVWoda9IkozeSuqAIW8LZDNXadt+lSAydj8D5GVTd8GROUARByAiAMQcR0QcQD8fS2Av9uFxfpv0TlfBDFza3EkAzhdAKcL4HQBnG4DwOnmWf4I4Ef+Sgk6imnVXMXA7Y7YqMYGiiL0pag3Eg+K7AoNH7sRoAgF46r/ohIstBTAbmIekVX5e/oM4z8R9qKmogzIYeI/ERggEcJULv85zbYSeHMHKZ/pAOEQztOfxwYfPctGwrOv1j9St+utJ8GzXc1JvUwLAhCkFOWJ1ymzMkJ2PZYJqovLDijrjH2uvqd4QmyiVBGUi6qkMS9QjabwFMMAoyisGhc1x7MHIqk/DUxNKAB6SgpbyC4hFCe6Oaf6V0v/chwK6/DdQrhqXEEaVFO34hQb5Cwd3y7m6LjdQCFVbMna8EGdcDll2FIjJnTOuXWFzGE+oMBA6pt2w8UuEbw4C6Me4eLEFfLU3G+594vTZ9ms7FdQLY4vfEEcuF8rTn23ThEppZfp1wI/Oesb9WUER9dPT2933nEUH7lvVuByCYqv2sArus95vsJh4R28UGy/ElhEd2nGDANbCfeRA/BOxe4qZ2OV3Ng/zMRctBSXO8ksv1tK6snNIrtePNyOs3yZImJUMfzth1BQ5roibwBhuxgTd961rfQ3z6ijROw/0QQn9pvno5G9WvgxN4uJVz8JythTj5V89DvZZQYQSOzM8fAH053mdIaFe/aIaBfBUuXa19yOQIaStoTEwpBY+GKJhX8zeek+T2br6WIGaUu/AIQiVnU="},"arithmetic_tests.py":{"encoding":"zlib+base64; dictionary=result.code UTF-8","sha256":"c9d7bdc0b3549bdc6ee06ef5449b42516308e4c8819f9050ff16c03054cf0c8a","bytes":9703,"data":"ePkyXNxp3V1tb9tGEv6uX6Gm6C1pr2VReZfCAkaQQwukvSQOrgfoBIKSaIu2RAqkZEsx/N/veWZ3ScqWE+cO7YdrUJvcnX2bnZ15dnY5fvLkyT/OzuZplrTjIl3NFskqnej2JF6XcrCNBZ+UpbZncEvSbEUXjIsYS7B9HkuYpzHP4T6tbdA+9DZLCh4UdJaGepIvlrAzEbQFk6owPMs0k6M3ruV8vRLd02GnWkKyjFezeTpu26i5H/DqIujO4pJZ+qLMM52i0VWez0uNXk3zheadaVvFtkiuFq6Gd//8TZ9M5OMWxhM0JPFiEbGDGLpcgQR9x3a4cAVPbQTgtzbdlKzG6chOPr395VSDTZgr9KnUWbK6zotL/VG/PfnQghoOg+7BQfBqAHBgHp8N3p68f//uU6i6m/txRff+11OtX3//9XM43vL8kz2ZJRtPvXr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gbxH/AwoxM="},"storage_stress.py":{"encoding":"zlib+base64; dictionary=result.code UTF-8","sha256":"879bc710795c2140c8b3391e091d37bb62e713a6999804dfb5d6a6e7843e0f2f","bytes":1960,"data":"ePkyXNxpfVxRb9s2EH7Xr/DyQinhVMtIi0GpBhRFt5d2HZpiDzMEg5YpW7UtCqKUxMvy3/d9J7lxO28JYIsi73h3vDvS4EdeXFy8dfWIdbuzcsHe0hRbgXFYP6DiGoHWlRblv2zr9KTj4evGeTu5vf3MXbWuNUQGQVIfB3+izSkNk8rOriEywcGTO7PrreflC93G9euNIPGku8nGmpXyPOZdiTTEypXMTcHebMEJLfcI/daaYmOWmLfkPh9uJbn7+nl7EFkBAn2xTM8HOSq+N+3WdpLJ/KRHso6p+fE23i/e1dofvK5g2s65nQ+EcWO6za5aTsZmv6M4Vhxae7c/vn/3xwf9ppATM7ykMACnmKRxRcN24VQrX7SmKzYv7l27VdHAxLSw7d52VbHorIcOI7uVbXbuoJ+10bIBqgW/qTlA+u2b9+/ffeLutcYiI2jdvc/meVDC4jW8hFcXzNWn25lCz1u7s8jXeKR1Fz/hf3YsJFO6w3NxcA2Vp8HEapMNkoTUO/xGhRfqiv1cqXhZ1SqKW1IvD1AjxPL7WfIQXKIbn4kCUggmLcxU7W32f1zHNme430DX7FGxnUr5qVWtUljYufXwTUjnYgPn8lLem4eF28oj+vCdSn9zNaiW8FhMIWj0+ISQo+m4+YRFrt5W9Uov+4N2ZektcR6Tr44Rw1FXfdGF86m+JnJSJ9OX/M71mTdKAK0wr8BXORrDQQuFul94NY7+3PYWhR8TPdVYf8LwjA9YLC5cc4C+LGEZnRGaLs9JnkHIQLIvJf0hG3tJpXqWZ1x+ErLw+vWr6+jvZCQDj+Mj2iRg0HlYcqRNjjLy6Shl+ur6ac4+8psSK71NBk+HSGa1ajM1ffjXIZ7zf4lCX0I/BsTCDMGyqBAtIbmdhk9YO0JBEl24lc1GT4BX/TeHMRpOeSzNTgAlyfTycpZEBFhxhCt9x9G0db+3BAWEtEeUnmXtkTzM2g7ygZA8TLumzTAWKqW3KIyESukzimZSqbiOgu+gHg6kiLNdDG60aGzLNZtKhzLzfNceOOKSJvU6Y2yHIoyWXiXiQzLqvOaoXg2kkQBSZpfULnkp2vGqDEg/YCVOeETzFKOdsYNgmLHXPyOE5se4yNNvStn6RspDqMDToDDp5OXXkMkHp8hAFX5XE2OiCsUK00ivKZl9KGyDJClfArnweCdq7/0aqaHFL4xoFE597LuP5a/GK44T6gfxGNz5lTitXEIwvj0J9WMtKmJYaGVLgx8moSpNtSMgROl5HsWmaYhVe1TUCwOHT60wgTr4PTp7ohjCuh4ZMrMeqVqewBYEesgJI171+8bLW13uekQHYzkKzuS10ZXgUpDEx6RGWhP4ClL/w/f8vIYfuPtFbepMsgRG+B825JL6"}},"compile_source":"from pathlib import Path\nimport hashlib,json,time\nfrom amm_competition.evm.compiler import SolidityCompiler\nfrom amm_competition.evm.validator import SolidityValidator\nc=SolidityCompiler();v=SolidityValidator();out={}\nfor name in ['RS2','skeleton','head_8_8_2','head_10_12_2','head_12_16_2']:\n s=Path('scratch/work/'+name+'.sol').read_text();t=time.monotonic()\n legal=v.validate(s);r=c.compile(s)\n row={'name':name,'source_sha256':hashlib.sha256(s.encode()).hexdigest(),'source_bytes':len(s.encode()),'validation':legal.__dict__,'success':r.success,'errors':r.errors,'seconds':time.monotonic()-t}\n if r.success:\n  row.update(creation_bytes=len(r.bytecode),deployed_bytes=len(r.deployed_bytecode))\n  Path('scratch/work/'+name+'.bin').write_bytes(r.bytecode)\n  Path('scratch/work/'+name+'.runtime.bin').write_bytes(r.deployed_bytecode)\n print(json.dumps(row),flush=True);out[name]=row\nPath('scratch/work/compilation.json').write_text(json.dumps(out,indent=2))\n","decode":"For each sources entry: d=zlib.decompressobj(zdict=result[\"code\"].encode()); b=d.decompress(base64.b64decode(entry[\"data\"]))+d.flush(); assert sha256(b)==entry[\"sha256\"]. For gas_evidence.chunks use plain zlib.decompress after base64 decoding, then JSON parse. Embedded files are JSON payloads, not submodules. Run using the prescribed pinned toolchain checkout.","commands":["Decode inputs/tests into scratch/work, save generator_source as scratch/work/generator.py, harness_source as scratch/work/harness.py and compile_source as scratch/work/compile_all.py.",". scratch/env.sh && python scratch/work/generator.py scratch/work/RS2.sol scratch/work",". scratch/env.sh && python scratch/work/compile_all.py",". scratch/env.sh && python scratch/work/harness.py scratch/work/CH.sol --start 0 --n 1000 --out scratch/work/calibration.json",". scratch/env.sh && python scratch/work/harness.py scratch/work/NAME.sol --start 736100 --n 512 --out scratch/work/NAME.measured.json  # repeat for each architecture_rows name",". scratch/env.sh && python scratch/work/arithmetic_tests.py",". scratch/env.sh && python scratch/work/storage_stress.py"]}}
