{"item":"normalizer-state","blocked":null,"code":"// SPDX-License-Identifier: MIT\npragma solidity ^0.8.24;\n\nimport {AMMStrategyBase} from \"./AMMStrategyBase.sol\";\nimport {TradeInfo} from \"./IAMMStrategy.sol\";\n\ncontract Strategy is AMMStrategyBase {\n    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[13] = 902500000000; slots[14] = slots[5]; \n        slots[16] = (slots[5] << 128) | 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            uncertainty += wmul(sigmaForFast, sigmaForFast) * elapsedRaw;\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        {\n            uint256 ret = fastHat > 0 ? wdiv(absDiff(pImplied, fastHat), fastHat) : 0;\n            uint256 alpha;\n            if (firstInStep) {\n                uint256 processSigma = sigmaForFast;\n                uint256 obsVar = uncertainty + wmul(processSigma, processSigma);\n                uint256 probArb;\n                uint256 z2 = wdiv(wmul(ret, ret), obsVar);\n                uint256 density = _powWad(wdiv(WAD, WAD + z2 / 16), 8);\n                uint256 sigmaObs = _isqrt(obsVar * WAD);\n                uint256 odds = wmul(density, wdiv(6700000000000000, sigmaObs));\n                bool arbFlag = ret <= wmul(sigmaForFast, 1220000000000000000);\n                uint256 prior = arbFlag ? 650000000000000000 : 400000000000000000;\n                uint256 tr = trade.reserveY > 0 ? wdiv(trade.amountY, trade.reserveY) : 0;\n                if (tr > 3000000000000000) prior = wmul(prior, 6 * WAD / 10);\n                if (silent > 1) prior = wmul(prior, 8 * WAD / 10);\n                odds = wmul(odds, wdiv(prior, WAD - prior));\n                probArb = wdiv(odds, WAD + odds);\n                alpha = wmul(probArb, 600000000000000000) + wmul(WAD - probArb, 80000000000000000);\n                slots[15] = pImplied >= fastHat ? 1 : 2;\n                uncertainty = wmul(uncertainty, WAD - alpha);\n            } else {\n                if ((slots[15] == 1) == (pImplied >= fastHat)) alpha = PHAT_ALPHA_RETAIL;\n            }\n            uint256 gate = wmul(sigmaHat, GATE_SIGMA_MULT);\n            if (gate < MIN_GATE) gate = MIN_GATE;\n            if (ret <= gate) fastHat = wmul(fastHat, WAD - alpha) + wmul(pImplied, alpha);\n            slots[13] = uncertainty;\n        }\n\n\n        uint256 nLow;\n        uint256 nHigh;\n        uint256 nEst;\n        {\n            uint256 packed = slots[16];\n            nLow = packed >> 128;\n            nHigh = uint128(packed);\n            nEst = slots[17];\n            if (firstInStep || nLow == 0 || nHigh == 0) {\n                nLow = wmul(pHat, WAD - 30 * BPS);\n                nHigh = wdiv(pHat, WAD - 30 * BPS);\n                nEst = pHat;\n            }\n            if (!firstInStep && gamma > 0) {\n                uint256 obs = trade.isBuy\n                    ? wdiv(wmul(spot, gamma), WAD - 30 * BPS)\n                    : wdiv(wmul(spot, WAD - 30 * BPS), gamma);\n                // Corner observations are one-sided constraints, not exact prices.\n                // Allow unobserved normalizer flow before applying each constraint.\n                uint256 normalDepthY = _isqrt(wmul(trade.reserveX, trade.reserveY) * nEst);\n                uint256 movement = wmul(nEst, wdiv(trade.amountY, normalDepthY)) / 2;\n                nLow = nLow > movement ? nLow - movement : 1;\n                nHigh += movement;\n                if (trade.isBuy) { if (obs < nHigh) nHigh = obs; }\n                else { if (obs > nLow) nLow = obs; }\n                if (nLow > nHigh) { nLow = obs; nHigh = obs; }\n                if (nEst < nLow) nEst = nLow;\n                if (nEst > nHigh) nEst = nHigh;\n                // Keep the original observation blend unless an opposing constraint\n                // makes a narrow interval. Bounds alone need not identify a split.\n                if (feeUsed > 30 * BPS) {\n                    pHat = wmul(pHat, 9 * WAD / 10) + wmul(obs, WAD / 10);\n                    if ((slots[15] == 1) == (obs >= fastHat))\n                        fastHat = wmul(fastHat, 9 * WAD / 10) + wmul(obs, WAD / 10);\n                }\n                if (nHigh > nLow && nHigh - nLow < nEst / 1000) {\n                    uint256 midpoint = (nHigh + nLow) / 2;\n                    pHat = (pHat + midpoint) / 2;\n                    fastHat = wmul(fastHat, 8 * WAD / 10) + wmul(midpoint, 2 * WAD / 10);\n                }\n            }\n            slots[16] = (nLow << 128) | nHigh;\n            slots[17] = nEst;\n        }\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 flowSize = wmul(lambdaHat, sizeHat);\n        uint256 fBase = BASE_FEE + wmul(SIGMA_COEF, sigmaHat) + wmul(LAMBDA_COEF, lambdaHat) + wmul(FLOW_SIZE_COEF, flowSize);\n        uint256 fMid = fBase + wmul(TOX_COEF, toxSignal) + wmul(TOX_QUAD_COEF, wmul(toxSignal, toxSignal)) + wmul(ACT_COEF, actEma);\n        fMid = fMid + wmul(SIGMA_TOX_COEF, wmul(sigmaHat, toxSignal));\n\n        uint256 dirDev; bool sellPressure;\n        if (dirState >= WAD) { dirDev = dirState - WAD; sellPressure = true; }\n        else { dirDev = WAD - dirState; sellPressure = false; }\n\n        uint256 skew = wmul(DIR_COEF, dirDev) + wmul(DIR_TOX_COEF, wmul(dirDev, toxSignal));\n        uint256 bidFee; uint256 askFee;\n        if (sellPressure) {\n            bidFee = fMid + skew;\n            askFee = fMid > skew ? fMid - skew : 0;\n        } else {\n            askFee = fMid + skew;\n            bidFee = fMid > skew ? fMid - skew : 0;\n        }\n\n        {\n            uint256 staleHat = wmul(pHat, 700000000000000000) + wmul(fastHat, 300000000000000000);\n            uint256 staleTox = wdiv(absDiff(spot, staleHat), staleHat);\n            if (staleTox > TOX_CAP) staleTox = TOX_CAP;\n            uint256 staleShift = wmul(STALE_DIR_COEF, staleTox);\n            uint256 attractShift = wmul(staleShift, STALE_ATTRACT_FRAC);\n            if (spot >= staleHat) {\n                bidFee = bidFee + staleShift;\n                askFee = askFee > attractShift ? askFee - attractShift : 0;\n            } else {\n                askFee = askFee + staleShift;\n                bidFee = bidFee > attractShift ? bidFee - attractShift : 0;\n            }\n        }\n\n        {\n            bool tradeAligned = (trade.isBuy && spot >= pHat) || (!trade.isBuy && spot < pHat);\n            if (tradeAligned) {\n                uint256 tradeBoost = wmul(TRADE_TOX_BOOST, tradeRatio);\n                if (!firstInStep && tradeBoost > 16 * BPS) tradeBoost = 16 * BPS;\n                if (trade.isBuy) { bidFee = bidFee + tradeBoost; }\n                else { askFee = askFee + tradeBoost; }\n            }\n        }\n\n        if (sellPressure) {\n            bidFee = clampFee(_compressTailWithSlope(bidFee, TAIL_SLOPE_PROTECT));\n            askFee = clampFee(_compressTailWithSlope(askFee, TAIL_SLOPE_ATTRACT));\n        } else {\n            askFee = clampFee(_compressTailWithSlope(askFee, TAIL_SLOPE_PROTECT));\n            bidFee = clampFee(_compressTailWithSlope(bidFee, TAIL_SLOPE_ATTRACT));\n        }\n\n        if (firstInStep) {\n            if (askFee > bidFee && bidFee > 30 * BPS) bidFee = 30 * BPS;\n            else if (bidFee > askFee && askFee > 30 * BPS) askFee = 30 * BPS;\n        }\n\n        if (bidFee > askFee && askFee > 36 * BPS) askFee = 36 * BPS;\n        else if (askFee > bidFee && bidFee > 36 * BPS) bidFee = 36 * BPS;\n\n        slots[0] = bidFee; slots[1] = askFee; slots[2] = (spot << 64) | trade.timestamp;\n        slots[3] = dirState; slots[4] = actEma; slots[5] = pHat;\n        slots[6] = sigmaHat; slots[7] = lambdaHat; slots[8] = sizeHat;\n        slots[9] = toxEma; slots[10] = stepTradeCount;\n\n        return (bidFee, askFee);\n    }\n\n    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 \"no_cubic\"; }\n}\n","sha256":"ce7e02d29699d5b55794e9abf57ff3d3e4833af24534a412b9387fda0f43d2ff","harness_source":"import json,sys,time,hashlib\nfrom pathlib import Path\nimport numpy as np\nimport amm_sim_rs as sim\nfrom amm_competition.evm.compiler import SolidityCompiler\nfrom amm_competition.competition.config import build_config\n\ndef configs(start,n):\n out=[]\n for s in range(start,start+n):\n  r=np.random.default_rng(s);size=r.uniform(19,21);rate=r.uniform(.6,1);sigma=r.uniform(.000882,.001008)\n  out.append(build_config(seed=s,gbm_sigma=sigma,retail_arrival_rate=rate,retail_mean_size=size))\n return out\n\ndef compile_file(path,name='Strategy'):\n c=SolidityCompiler().compile(Path(path).read_text(),name)\n if not c.success: raise RuntimeError(c.errors)\n return list(c.bytecode)\n\ndef run(path,start,n,out):\n a=compile_file(path);b=compile_file('contracts/src/VanillaStrategy.sol','VanillaStrategy');rows=[];gas=[];t=time.time()\n for k in range(0,n,20):\n  sim.gas_stats_reset();rr=sim.run_batch(a,b,configs(start+k,min(20,n-k)),8);gas.append(sim.gas_stats())\n  for x in rr.results:\n   if not rows: print('FIELDS',dir(x),flush=True)\n   arb=0.;arb_volume=0.;prev_spot=100.;bid=ask=.0004\n   for step in x.steps:\n    price=step.fair_price;rx=(1000000./prev_spot)**.5;ry=1000000./rx\n    if prev_spot < price:\n     gamma=1.-ask;nx=(1000000./(gamma*price))**.5;dx=min(rx-nx,rx*.99)\n     if dx>0:\n      paid=(1000000./(rx-dx)-ry)/gamma;profit=dx*price-paid\n      if paid>0 and profit>0:arb-=profit;arb_volume+=paid\n    elif prev_spot > price:\n     gamma=1.-bid;dx=((1000000.*gamma/price)**.5-rx)/gamma\n     if dx>0:\n      paid=ry-1000000./(rx+gamma*dx);profit=paid-dx*price\n      if paid>0 and profit>0:arb-=profit;arb_volume+=paid\n    prev_spot=step.spot_prices['submission'];bid,ask=step.fees['submission']\n   row={'seed':x.seed,'edge':x.edges['submission'],'arb_edge':arb,'retail_edge':x.edges['submission']-arb,'arb_volume_reconstruction_error':arb_volume-x.arb_volume_y['submission']}\n   for attr in dir(x):\n    if ('edge' in attr or 'halt' in attr) and attr!='edges':\n     z=getattr(x,attr)\n     try: json.dumps(z);row[attr]=z\n     except:pass\n   rows.append(row)\n  Path(out).write_text(json.dumps({'rows':rows,'gas':gas,'sha256':hashlib.sha256(Path(path).read_bytes()).hexdigest(),'seconds':time.time()-t}))\n  print(path,len(rows),np.mean([x['edge'] for x in rows]),time.time()-t,flush=True)\nif __name__=='__main__': run(sys.argv[1],int(sys.argv[2]),int(sys.argv[3]),sys.argv[4])\n","holdout_driver_source":"import json,hashlib,contextlib\nfrom pathlib import Path\nfrom harness import run\nfreeze=json.loads(Path('scratch/freeze.json').read_text())\narm=freeze['variant'];assert arm in ['C','D']\nassert hashlib.sha256(Path('scratch/'+arm+'.sol').read_bytes()).hexdigest()==freeze['sha256']\nfor name in ['STACK',arm]:\n out=Path('scratch/holdout-'+name+'.json');assert not out.exists(), 'Holdout must never be retried'\n with open('scratch/holdout-'+name+'.log','w') as log,contextlib.redirect_stdout(log):\n  run('scratch/'+name+'.sol',5004000,2000,str(out))\n assert len(json.loads(out.read_text())['rows'])==2000\n","variant_generator_source":"from pathlib import Path\ns=Path('scratch/STACK.sol').read_text()\na=s.index('        // Interior retail routing')\nb=s.index('        {\\n            uint256 ret = fastHat',a)\ns=s[:a]+s[b:]\na=s.index('        if (!firstInStep && feeUsed > 30 * BPS && gamma > 0)')\nb=s.index('        slots[14] = fastHat;',a)\ns=s[:a]+s[b:]\n# A projected interval estimate; B interior likelihood with depth correction; C direct quotes from interval.\ncommon='''\n        uint256 nLow;\n        uint256 nHigh;\n        uint256 nEst;\n        {\n            uint256 packed = slots[16];\n            nLow = packed >> 128;\n            nHigh = uint128(packed);\n            nEst = slots[17];\n            if (firstInStep || nLow == 0 || nHigh == 0) {\n                nLow = wmul(pHat, WAD - 30 * BPS);\n                nHigh = wdiv(pHat, WAD - 30 * BPS);\n                nEst = pHat;\n            }\n            if (!firstInStep && gamma > 0) {\n                uint256 obs = trade.isBuy\n                    ? wdiv(wmul(spot, gamma), WAD - 30 * BPS)\n                    : wdiv(wmul(spot, WAD - 30 * BPS), gamma);\n                // Corner observations are one-sided constraints, not exact prices.\n                // Allow unobserved normalizer flow before applying each constraint.\n                uint256 movement = wmul(nEst, wdiv(trade.amountY, trade.reserveY)) / 2;\n                nLow = nLow > movement ? nLow - movement : 1;\n                nHigh += movement;\n                if (trade.isBuy) { if (obs < nHigh) nHigh = obs; }\n                else { if (obs > nLow) nLow = obs; }\n                if (nLow > nHigh) { nLow = obs; nHigh = obs; }\n                if (nEst < nLow) nEst = nLow;\n                if (nEst > nHigh) nEst = nHigh;\n                VARIANT_UPDATE\n            }\n            slots[16] = (nLow << 128) | nHigh;\n            slots[17] = nEst;\n        }\n'''\ninit='        slots[16] = (slots[5] << 128) | slots[5];\\n'\ns=s.replace('        return (BASE_FEE, BASE_FEE);',init+'        return (BASE_FEE, BASE_FEE);')\nupdates={\n'A':'''pHat = wmul(pHat, 6 * WAD / 10) + wmul(nEst, 4 * WAD / 10);\n                fastHat = wmul(fastHat, 8 * WAD / 10) + wmul(nEst, 2 * WAD / 10);''',\n'B':'''// Use the distance to the latent price and observed size to score a split.\n                uint256 normalDepthY = _isqrt(wmul(trade.reserveX, trade.reserveY) * nEst);\n                uint256 width = wdiv(trade.amountY, normalDepthY);\n                uint256 gap = wdiv(absDiff(obs, nEst), nEst);\n                uint256 confidence = wdiv(width, width + gap + BPS);\n                if (feeUsed < 30 * BPS) confidence /= 4;\n                nEst = wmul(nEst, WAD - confidence) + wmul(obs, confidence);\n                pHat = wmul(pHat, WAD / 2) + wmul(nEst, WAD / 2);\n                fastHat = wmul(fastHat, 7 * WAD / 10) + wmul(nEst, 3 * WAD / 10);''',\n'C':'''// Preserve STACK's estimator; use interval only in the quote stage.\n                pHat = wmul(pHat, 9 * WAD / 10) + wmul(obs, WAD / 10);\n                if ((slots[15] == 1) == (obs >= fastHat))\n                    fastHat = wmul(fastHat, 9 * WAD / 10) + wmul(obs, WAD / 10);'''\n}\nfor name,upd in updates.items():\n v=s.replace('        slots[14] = fastHat;',common.replace('VARIANT_UPDATE',upd)+'        slots[14] = fastHat;')\n if name=='C':\n  quote='''\n        if (!firstInStep && nLow > 0 && nHigh >= nLow) {\n            // Quote against the favorable edge of the inferred competitor interval.\n            uint256 targetBid = spot > nHigh ? WAD - wdiv(wmul(nHigh, WAD - 30 * BPS), spot) : 0;\n            uint256 targetAsk = spot < nLow ? WAD - wdiv(wmul(spot, WAD - 30 * BPS), nLow) : 0;\n            if (targetBid > bidFee) bidFee = (bidFee + targetBid) / 2;\n            if (targetAsk > askFee) askFee = (askFee + targetAsk) / 2;\n        }\n'''\n  v=v.replace('        if (sellPressure) {\\n            bidFee = clampFee',quote+'        if (sellPressure) {\\n            bidFee = clampFee')\n Path('scratch/'+name+'.sol').write_text(v)\n\ns=Path('scratch/A.sol').read_text()\na=s.index('                pHat = wmul(pHat, 6 * WAD / 10)');b=s.index('\\n            }\\n            slots[16]',a)\ns=s[:a]+'''                // Keep the original observation blend unless an opposing constraint\n                // makes a narrow interval. Bounds alone need not identify a split.\n                if (feeUsed > 30 * BPS) {\n                    pHat = wmul(pHat, 9 * WAD / 10) + wmul(obs, WAD / 10);\n                    if ((slots[15] == 1) == (obs >= fastHat))\n                        fastHat = wmul(fastHat, 9 * WAD / 10) + wmul(obs, WAD / 10);\n                }\n                if (nHigh > nLow && nHigh - nLow < nEst / 1000) {\n                    uint256 midpoint = (nHigh + nLow) / 2;\n                    pHat = (pHat + midpoint) / 2;\n                    fastHat = wmul(fastHat, 8 * WAD / 10) + wmul(midpoint, 2 * WAD / 10);\n                }'''+s[b:]\ns=s.replace('uint256 movement = wmul(nEst, wdiv(trade.amountY, trade.reserveY)) / 2;', 'uint256 normalDepthY = _isqrt(wmul(trade.reserveX, trade.reserveY) * nEst);\\n                uint256 movement = wmul(nEst, wdiv(trade.amountY, normalDepthY)) / 2;')\nPath('scratch/D.sol').write_text(s)\n","setup_source":"set -eu;R=$PWD/scratch;mkdir -p $R/tmp $R/bin $R/solcx\necho \"export TMPDIR=$R/tmp XDG_CACHE_HOME=$R/xc UV_CACHE_DIR=$R/uvc UV_PYTHON_INSTALL_DIR=$R/uvpy SOLCX_BINARY_PATH=$R/solcx VIRTUAL_ENV=$PWD/.venv PATH=$PWD/.venv/bin:$R/bin:\\$PATH\" >$R/env.sh;. $R/env.sh\ncommand -v uv >/dev/null||{ curl -LsSf https://github.com/astral-sh/uv/releases/latest/download/uv-x86_64-unknown-linux-gnu.tar.gz|tar --no-same-owner -xz -C $R/tmp;cp $R/tmp/uv-*/uv $R/bin/;}\nW=amm_sim_rs-0.1.0.post1-cp310-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl;curl -LsSf https://github.com/gtmcknight/amm-sim/releases/download/sim-6b6921f8/$W -o $R/$W\necho \"aedb68280aca34c110968f00148387c95885207913fb2cf19a1ab4c5cfd6887a  $R/$W\"|sha256sum -c -\nuv venv --python 3.12 .venv;uv pip install $R/$W numpy py-solc-x==2.1.0 pyrevm==0.3.7;uv pip install --no-deps -e .\npython -c \"import solcx;solcx.install_solc('0.8.24')\"\namm-match validate contracts/src/StarterStrategy.sol\n","source_bundle":{"encoding":"base64(zlib.compress(UTF-8 JSON mapping relative paths to full source strings))","data":"eNrtPQtXGzezf0XlnPTYiQHbPAIYnGvAJJzyuthpk1tyOWtbhr1d77q7ax5t+e93Rq+VtFrbkKT36/3Mac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Vg=="},"provenance":{"repository":"https://github.com/benedictbrady/amm-challenge","commit":"6b6921f8d463314aa7c96234e1be25a25245f704","STACK_url":"https://api.imdnotdead.fun/artifacts/c33720874aa1285e9dc766540b8a90410118a8e8b840d949ea0dcc211bdb27c1","STACK_sha256":"2eaafc7960e520b8a7fd322ec8afaff8fa677c730228a961efb509cc30b25719","evidence":"Remote source passages in sources.json; numerical measurements from the included harness on the pinned wheel. Board figures in the brief were not independently checked."},"calibration":{"source_url":"https://raw.githubusercontent.com/ChengHua926/amm-challenge/d34a5199c59a4c44d5336a25f1436b4ae1f21104/contracts/src/Strategy.sol","sha256":"6dd68f77a70900319460215374143dbd5d924198450a46d9f5f91f6b1e3d35c3","seeds":[0,1000],"n":1000,"expected_mean_edge":525.5258821780834,"observed_mean_edge":525.5258821780834,"absolute_error":0.0,"tolerance":1e-06,"pass":true,"gas":{"max_ok":151647,"oog":0,"halts":0,"raw_counters":[{"role":"Baseline","callback":"afterInitialize","calls":1000,"ok":1000,"max_ok_gas":21796,"sum_ok_gas":21796000,"oog":0,"revert":0,"other_halt":0,"tx_error":0,"bad_return":0},{"role":"Baseline","callback":"afterSwap","calls":10741746,"ok":10741746,"max_ok_gas":22592,"sum_ok_gas":242365461576,"oog":0,"revert":0,"other_halt":0,"tx_error":0,"bad_return":0},{"role":"Baseline","callback":"getName","calls":1000,"ok":1000,"max_ok_gas":21526,"sum_ok_gas":21526000,"oog":0,"revert":0,"other_halt":0,"tx_error":0,"bad_return":0},{"role":"Submission","callback":"afterInitialize","calls":1000,"ok":1000,"max_ok_gas":185532,"sum_ok_gas":185532000,"oog":0,"revert":0,"other_halt":0,"tx_error":0,"bad_return":0},{"role":"Submission","callback":"afterSwap","calls":10445223,"ok":10445223,"max_ok_gas":151647,"sum_ok_gas":811927105393,"oog":0,"revert":0,"other_halt":0,"tx_error":0,"bad_return":0},{"role":"Submission","callback":"getName","calls":1000,"ok":1000,"max_ok_gas":21530,"sum_ok_gas":21530000,"oog":0,"revert":0,"other_halt":0,"tx_error":0,"bad_return":0}],"chunk_size":20,"chunks":50}},"method":{"market":"Each submitted arm alone against VanillaStrategy; never candidate vs STACK in one market. run_batch(submission_bytecode, vanilla_bytecode, configs, 8).","steps":10000,"screen_seeds":[10000,10120],"shortlist_seeds":[20000,20200],"holdout_seeds":[5004000,5006000],"seed_intervals":"Half-open, contiguous, no dropping; holdout run once per arm after freeze.","config":{"initial_price":100.0,"initial_x":100.0,"initial_y":10000.0,"gbm_mu":0.0,"gbm_dt":1.0,"retail_buy_prob":0.5,"retail_size_sigma":1.2,"draws":"np.random.default_rng(seed), in order uniform(19,21) mean size, uniform(0.6,1.0) arrival rate, uniform(0.000882,0.001008) sigma; seed=seed, price seed=seed, retail seed=seed+1"},"compiler":{"solc":"0.8.24","optimizer":true,"runs":200,"viaIR":true,"evmVersion":"paris","entry":"Strategy","checks":"Pinned SolidityCompiler enforces opcode and 32-slot storage policy."},"runtime":{"wheel":"amm_sim_rs-0.1.0.post1-cp310-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl","sha256":"aedb68280aca34c110968f00148387c95885207913fb2cf19a1ab4c5cfd6887a","numpy":"2.5.4","python":"3.12.3","py-solc-x":"2.1.0","pyrevm":"0.3.7"},"statistics":"d=edge(candidate)-edge(STACK); SE=sample sd(ddof=1)/sqrt(n). Gas stats reset before each isolated arm/chunk; raw counters below sum counts and sum gas, and retain maxima across chunks."},"structures":{"A":"One-sided soft interval projection into a latent Vanilla spot, replacing the two STACK routing blends; stronger slow/fast estimator updates.","B":"Censored interval plus split-likelihood weight using observed size, price gap and inferred Vanilla Y depth sqrt(k*spot).","C":"Soft interval endpoints set competitive protective quote targets; retains a 10% routing update also on low-fee observations, unlike STACK.","D":"Retains STACK routing updates and applies an extra midpoint update only for narrow opposing constraints. Vanilla depth inferred from shared initial k; bounds widened using observed size/depth."},"limitations":["A routed print cannot identify an interior split with certainty because the total retail order and Vanilla-only trades are hidden. Buy observations give lower bounds and sell observations upper bounds on the post-route Vanilla spot. The propagated intervals use heuristic priors and widening, not certified bounds.","Fee buckets leave k constant, and both pools start with identical k. Vanilla depth is inferred conditional on the latent spot, not observed directly.","Retail/arb edge attribution is reconstructed from per-step data; retail is total edge minus reconstructed arb edge. The native wheel does not expose separate edge counters. The holdout volume cross-check failed its predeclared absolute tolerance, so these component estimates are unvalidated; the cause is unresolved. Native total-edge differences are unaffected. No holdout replay or tolerance change was made.","Harness reproduction needs the pinned simulator/runtime installed by setup; binaries are not embedded in this JSON. The delivered Solidity imports the challenge-standard base/interface; these and STACK, CH, and Vanilla source inputs are embedded in source_bundle. No board submission was performed."],"freeze":{"variant":"D","sha256":"ce7e02d29699d5b55794e9abf57ff3d3e4833af24534a412b9387fda0f43d2ff","frozen_at_utc":"2026-11-08T18:32:03.640211+00:00","shortlist_arms":["C","D"],"selection_rule":"Among novel C and D hashes with no halts in either tuning block, select the larger mean paired gain on second tuning block [20000,20200). Holdout has not been opened. Selection is for reporting the best pilot; adoption separately requires positive evidence.","second_block_paired":{"n":200,"mean_diff":-1.5334296493028046,"se":0.16997084065763401,"worst":[{"seed":20096,"d":-16.012256501473757},{"seed":20199,"d":-14.786950790341848},{"seed":20197,"d":-13.441683765074231},{"seed":20114,"d":-12.567115039715077},{"seed":20031,"d":-10.420273683915866}]},"recommendation_before_holdout":"Retain STACK fallback; all shortlisted mechanisms lost on the second tuning block. The frozen novel candidate is confirmed for reporting, not adopted.","ranked_shortlist":[{"variant":"D","sha256":"ce7e02d29699d5b55794e9abf57ff3d3e4833af24534a412b9387fda0f43d2ff","paired":{"n":200,"mean_diff":-1.5334296493028046,"se":0.16997084065763401,"worst":[{"seed":20096,"d":-16.012256501473757},{"seed":20199,"d":-14.786950790341848},{"seed":20197,"d":-13.441683765074231},{"seed":20114,"d":-12.567115039715077},{"seed":20031,"d":-10.420273683915866}]}},{"variant":"C","sha256":"91d1db739291d62f57d37b3cd01f3bead9ede28219f6714d210e732edd37cf7c","paired":{"n":200,"mean_diff":-1.751862882173036,"se":0.06752382757671126,"worst":[{"seed":20089,"d":-4.705670438643438},{"seed":20153,"d":-4.271189904920675},{"seed":20183,"d":-4.262769470686067},{"seed":20172,"d":-4.010552951099953},{"seed":20152,"d":-3.927229947347996}]}}]},"variant_tuning_log":[{"stage":"screen","STACK":{"sha256":"2eaafc7960e520b8a7fd322ec8afaff8fa677c730228a961efb509cc30b25719","n":120,"mean_edge":519.4049147878003,"gas":{"max_ok":211576,"oog":0,"halts":0,"raw_counters":[{"role":"Baseline","callback":"afterInitialize","calls":120,"ok":120,"max_ok_gas":21796,"sum_ok_gas":2615520,"oog":0,"revert":0,"other_halt":0,"tx_error":0,"bad_return":0},{"role":"Baseline","callback":"afterSwap","calls":1276168,"ok":1276168,"max_ok_gas":22592,"sum_ok_gas":28794111728,"oog":0,"revert":0,"other_halt":0,"tx_error":0,"bad_return":0},{"role":"Baseline","callback":"getName","calls":120,"ok":120,"max_ok_gas":21526,"sum_ok_gas":2583120,"oog":0,"revert":0,"other_halt":0,"tx_error":0,"bad_return":0},{"role":"Submission","callback":"afterInitialize","calls":120,"ok":120,"max_ok_gas":220962,"sum_ok_gas":26515440,"oog":0,"revert":0,"other_halt":0,"tx_error":0,"bad_return":0},{"role":"Submission","callback":"afterSwap","calls":1232702,"ok":1232702,"max_ok_gas":211576,"sum_ok_gas":121392723996,"oog":0,"revert":0,"other_halt":0,"tx_error":0,"bad_return":0},{"role":"Submission","callback":"getName","calls":120,"ok":120,"max_ok_gas":21576,"sum_ok_gas":2589120,"oog":0,"revert":0,"other_halt":0,"tx_error":0,"bad_return":0}],"chunk_size":20,"chunks":6}},"variants":[{"variant":"A","sha256":"537aec51e5fa6377995154441913a9fa1e4cd4bc55c2a52a5a4602685c48f350","paired":{"n":120,"mean_diff":-17.34930027361266,"se":0.5915777292355843,"worst":[{"seed":10085,"d":-38.7133282963548},{"seed":10028,"d":-35.313083692980854},{"seed":10110,"d":-31.646899647492774},{"seed":10078,"d":-30.90998638915471},{"seed":10111,"d":-30.538812059340557}]},"gas":{"max_ok":238781,"oog":0,"halts":0,"raw_counters":[{"role":"Baseline","callback":"afterInitialize","calls":120,"ok":120,"max_ok_gas":21796,"sum_ok_gas":2615520,"oog":0,"revert":0,"other_halt":0,"tx_error":0,"bad_return":0},{"role":"Baseline","callback":"afterSwap","calls":1278920,"ok":1278920,"max_ok_gas":22592,"sum_ok_gas":28855977844,"oog":0,"revert":0,"other_halt":0,"tx_error":0,"bad_return":0},{"role":"Baseline","callback":"getName","calls":120,"ok":120,"max_ok_gas":21526,"sum_ok_gas":2583120,"oog":0,"revert":0,"other_halt":0,"tx_error":0,"bad_return":0},{"role":"Submission","callback":"afterInitialize","calls":120,"ok":120,"max_ok_gas":243065,"sum_ok_gas":29167800,"oog":0,"revert":0,"other_halt":0,"tx_error":0,"bad_return":0},{"role":"Submission","callback":"afterSwap","calls":1274743,"ok":1274743,"max_ok_gas":238781,"sum_ok_gas":139507003954,"oog":0,"revert":0,"other_halt":0,"tx_error":0,"bad_return":0},{"role":"Submission","callback":"getName","calls":120,"ok":120,"max_ok_gas":21560,"sum_ok_gas":2587200,"oog":0,"revert":0,"other_halt":0,"tx_error":0,"bad_return":0}],"chunk_size":20,"chunks":6},"retail_edge_delta":{"mean":8.92843783691549,"se":0.23034745538054865},"arb_edge_delta":{"mean":-26.277738110528155,"se":0.7219646957664607}},{"variant":"B","sha256":"0154700c5f44a60d0d25e09822813d0d3f97bb2adfd4b6da0fbb391d263382f7","paired":{"n":120,"mean_diff":-28.77672598474418,"se":0.8759949089289745,"worst":[{"seed":10085,"d":-54.11109599373901},{"seed":10028,"d":-52.15073715935682},{"seed":10078,"d":-51.58826698342159},{"seed":10111,"d":-49.3436800292352},{"seed":10011,"d":-47.9516229058961}]},"gas":{"max_ok":238968,"oog":0,"halts":0,"raw_counters":[{"role":"Baseline","callback":"afterInitialize","calls":120,"ok":120,"max_ok_gas":21796,"sum_ok_gas":2615520,"oog":0,"revert":0,"other_halt":0,"tx_error":0,"bad_return":0},{"role":"Baseline","callback":"afterSwap","calls":1282068,"ok":1282068,"max_ok_gas":22592,"sum_ok_gas":28926991188,"oog":0,"revert":0,"other_halt":0,"tx_error":0,"bad_return":0},{"role":"Baseline","callback":"getName","calls":120,"ok":120,"max_ok_gas":21526,"sum_ok_gas":2583120,"oog":0,"revert":0,"other_halt":0,"tx_error":0,"bad_return":0},{"role":"Submission","callback":"afterInitialize","calls":120,"ok":120,"max_ok_gas":243074,"sum_ok_gas":29168880,"oog":0,"revert":0,"other_halt":0,"tx_error":0,"bad_return":0},{"role":"Submission","callback":"afterSwap","calls":1276392,"ok":1276392,"max_ok_gas":238968,"sum_ok_gas":141041042794,"oog":0,"revert":0,"other_halt":0,"tx_error":0,"bad_return":0},{"role":"Submission","callback":"getName","calls":120,"ok":120,"max_ok_gas":21570,"sum_ok_gas":2588400,"oog":0,"revert":0,"other_halt":0,"tx_error":0,"bad_return":0}],"chunk_size":20,"chunks":6},"retail_edge_delta":{"mean":9.308825060763724,"se":0.24612523585022344},"arb_edge_delta":{"mean":-38.08555104550791,"se":1.0130991219920953}},{"variant":"C","sha256":"91d1db739291d62f57d37b3cd01f3bead9ede28219f6714d210e732edd37cf7c","paired":{"n":120,"mean_diff":-1.7099022201156535,"se":0.08624643818887999,"worst":[{"seed":10115,"d":-4.000157102923595},{"seed":10045,"d":-3.800703686517295},{"seed":10110,"d":-3.748710144376787},{"seed":10085,"d":-3.6858812739577616},{"seed":10111,"d":-3.60506243953148}]},"gas":{"max_ok":238978,"oog":0,"halts":0,"raw_counters":[{"role":"Baseline","callback":"afterInitialize","calls":120,"ok":120,"max_ok_gas":21796,"sum_ok_gas":2615520,"oog":0,"revert":0,"other_halt":0,"tx_error":0,"bad_return":0},{"role":"Baseline","callback":"afterSwap","calls":1288078,"ok":1288078,"max_ok_gas":22592,"sum_ok_gas":29062801832,"oog":0,"revert":0,"other_halt":0,"tx_error":0,"bad_return":0},{"role":"Baseline","callback":"getName","calls":120,"ok":120,"max_ok_gas":21526,"sum_ok_gas":2583120,"oog":0,"revert":0,"other_halt":0,"tx_error":0,"bad_return":0},{"role":"Submission","callback":"afterInitialize","calls":120,"ok":120,"max_ok_gas":243087,"sum_ok_gas":29170440,"oog":0,"revert":0,"other_halt":0,"tx_error":0,"bad_return":0},{"role":"Submission","callback":"afterSwap","calls":1221287,"ok":1221287,"max_ok_gas":238978,"sum_ok_gas":133248586282,"oog":0,"revert":0,"other_halt":0,"tx_error":0,"bad_return":0},{"role":"Submission","callback":"getName","calls":120,"ok":120,"max_ok_gas":21582,"sum_ok_gas":2589840,"oog":0,"revert":0,"other_halt":0,"tx_error":0,"bad_return":0}],"chunk_size":20,"chunks":6},"retail_edge_delta":{"mean":1.6975029925770595,"se":0.07925129637793793},"arb_edge_delta":{"mean":-3.4074052126927197,"se":0.09324179516005901}},{"variant":"D","sha256":"ce7e02d29699d5b55794e9abf57ff3d3e4833af24534a412b9387fda0f43d2ff","paired":{"n":120,"mean_diff":-1.480752068556618,"se":0.24004535280983302,"worst":[{"seed":10085,"d":-25.999969681460243},{"seed":10032,"d":-9.617894151706764},{"seed":10110,"d":-5.815426125760837},{"seed":10072,"d":-4.673889648876525},{"seed":10015,"d":-4.55124471408368}]},"gas":{"max_ok":238905,"oog":0,"halts":0,"raw_counters":[{"role":"Baseline","callback":"afterInitialize","calls":120,"ok":120,"max_ok_gas":21796,"sum_ok_gas":2615520,"oog":0,"revert":0,"other_halt":0,"tx_error":0,"bad_return":0},{"role":"Baseline","callback":"afterSwap","calls":1276812,"ok":1276812,"max_ok_gas":22592,"sum_ok_gas":28808598204,"oog":0,"revert":0,"other_halt":0,"tx_error":0,"bad_return":0},{"role":"Baseline","callback":"getName","calls":120,"ok":120,"max_ok_gas":21526,"sum_ok_gas":2583120,"oog":0,"revert":0,"other_halt":0,"tx_error":0,"bad_return":0},{"role":"Submission","callback":"afterInitialize","calls":120,"ok":120,"max_ok_gas":243077,"sum_ok_gas":29169240,"oog":0,"revert":0,"other_halt":0,"tx_error":0,"bad_return":0},{"role":"Submission","callback":"afterSwap","calls":1240574,"ok":1240574,"max_ok_gas":238905,"sum_ok_gas":135444295025,"oog":0,"revert":0,"other_halt":0,"tx_error":0,"bad_return":0},{"role":"Submission","callback":"getName","calls":120,"ok":120,"max_ok_gas":21573,"sum_ok_gas":2588760,"oog":0,"revert":0,"other_halt":0,"tx_error":0,"bad_return":0}],"chunk_size":20,"chunks":6},"retail_edge_delta":{"mean":0.9664689101409659,"se":0.05353199748525321},"arb_edge_delta":{"mean":-2.4472209786975907,"se":0.23954167095719706}}]},{"stage":"shortlist","STACK":{"sha256":"2eaafc7960e520b8a7fd322ec8afaff8fa677c730228a961efb509cc30b25719","n":200,"mean_edge":527.4975190490292,"gas":{"max_ok":211564,"oog":0,"halts":0,"raw_counters":[{"role":"Baseline","callback":"afterInitialize","calls":200,"ok":200,"max_ok_gas":21796,"sum_ok_gas":4359200,"oog":0,"revert":0,"other_halt":0,"tx_error":0,"bad_return":0},{"role":"Baseline","callback":"afterSwap","calls":2143961,"ok":2143961,"max_ok_gas":22592,"sum_ok_gas":48374030956,"oog":0,"revert":0,"other_halt":0,"tx_error":0,"bad_return":0},{"role":"Baseline","callback":"getName","calls":200,"ok":200,"max_ok_gas":21526,"sum_ok_gas":4305200,"oog":0,"revert":0,"other_halt":0,"tx_error":0,"bad_return":0},{"role":"Submission","callback":"afterInitialize","calls":200,"ok":200,"max_ok_gas":220962,"sum_ok_gas":44192400,"oog":0,"revert":0,"other_halt":0,"tx_error":0,"bad_return":0},{"role":"Submission","callback":"afterSwap","calls":2068411,"ok":2068411,"max_ok_gas":211564,"sum_ok_gas":203560680355,"oog":0,"revert":0,"other_halt":0,"tx_error":0,"bad_return":0},{"role":"Submission","callback":"getName","calls":200,"ok":200,"max_ok_gas":21576,"sum_ok_gas":4315200,"oog":0,"revert":0,"other_halt":0,"tx_error":0,"bad_return":0}],"chunk_size":20,"chunks":10}},"variants":[{"variant":"C","sha256":"91d1db739291d62f57d37b3cd01f3bead9ede28219f6714d210e732edd37cf7c","paired":{"n":200,"mean_diff":-1.751862882173036,"se":0.06752382757671126,"worst":[{"seed":20089,"d":-4.705670438643438},{"seed":20153,"d":-4.271189904920675},{"seed":20183,"d":-4.262769470686067},{"seed":20172,"d":-4.010552951099953},{"seed":20152,"d":-3.927229947347996}]},"gas":{"max_ok":238966,"oog":0,"halts":0,"raw_counters":[{"role":"Baseline","callback":"afterInitialize","calls":200,"ok":200,"max_ok_gas":21796,"sum_ok_gas":4359200,"oog":0,"revert":0,"other_halt":0,"tx_error":0,"bad_return":0},{"role":"Baseline","callback":"afterSwap","calls":2164191,"ok":2164191,"max_ok_gas":22592,"sum_ok_gas":48830386320,"oog":0,"revert":0,"other_halt":0,"tx_error":0,"bad_return":0},{"role":"Baseline","callback":"getName","calls":200,"ok":200,"max_ok_gas":21526,"sum_ok_gas":4305200,"oog":0,"revert":0,"other_halt":0,"tx_error":0,"bad_return":0},{"role":"Submission","callback":"afterInitialize","calls":200,"ok":200,"max_ok_gas":243087,"sum_ok_gas":48617400,"oog":0,"revert":0,"other_halt":0,"tx_error":0,"bad_return":0},{"role":"Submission","callback":"afterSwap","calls":2048921,"ok":2048921,"max_ok_gas":238966,"sum_ok_gas":223414883193,"oog":0,"revert":0,"other_halt":0,"tx_error":0,"bad_return":0},{"role":"Submission","callback":"getName","calls":200,"ok":200,"max_ok_gas":21582,"sum_ok_gas":4316400,"oog":0,"revert":0,"other_halt":0,"tx_error":0,"bad_return":0}],"chunk_size":20,"chunks":10},"retail_edge_delta":{"mean":1.6725103510459707,"se":0.070708230363741},"arb_edge_delta":{"mean":-3.4243732332190073,"se":0.07090388288124766}},{"variant":"D","sha256":"ce7e02d29699d5b55794e9abf57ff3d3e4833af24534a412b9387fda0f43d2ff","paired":{"n":200,"mean_diff":-1.5334296493028046,"se":0.16997084065763401,"worst":[{"seed":20096,"d":-16.012256501473757},{"seed":20199,"d":-14.786950790341848},{"seed":20197,"d":-13.441683765074231},{"seed":20114,"d":-12.567115039715077},{"seed":20031,"d":-10.420273683915866}]},"gas":{"max_ok":238893,"oog":0,"halts":0,"raw_counters":[{"role":"Baseline","callback":"afterInitialize","calls":200,"ok":200,"max_ok_gas":21796,"sum_ok_gas":4359200,"oog":0,"revert":0,"other_halt":0,"tx_error":0,"bad_return":0},{"role":"Baseline","callback":"afterSwap","calls":2145131,"ok":2145131,"max_ok_gas":22592,"sum_ok_gas":48400349284,"oog":0,"revert":0,"other_halt":0,"tx_error":0,"bad_return":0},{"role":"Baseline","callback":"getName","calls":200,"ok":200,"max_ok_gas":21526,"sum_ok_gas":4305200,"oog":0,"revert":0,"other_halt":0,"tx_error":0,"bad_return":0},{"role":"Submission","callback":"afterInitialize","calls":200,"ok":200,"max_ok_gas":243077,"sum_ok_gas":48615400,"oog":0,"revert":0,"other_halt":0,"tx_error":0,"bad_return":0},{"role":"Submission","callback":"afterSwap","calls":2081138,"ok":2081138,"max_ok_gas":238893,"sum_ok_gas":227111657467,"oog":0,"revert":0,"other_halt":0,"tx_error":0,"bad_return":0},{"role":"Submission","callback":"getName","calls":200,"ok":200,"max_ok_gas":21573,"sum_ok_gas":4314600,"oog":0,"revert":0,"other_halt":0,"tx_error":0,"bad_return":0}],"chunk_size":20,"chunks":10},"retail_edge_delta":{"mean":1.013534540414112,"se":0.04483757503387742},"arb_edge_delta":{"mean":-2.5469641897169173,"se":0.1668446737502116}}]}],"n":2000,"paired":{"n":2000,"mean_diff":-1.3756328776753344,"se":0.04581777642932667,"worst":[{"seed":5005166,"d":-38.527588753941245},{"seed":5005368,"d":-32.549609779313414},{"seed":5004789,"d":-26.414205874116533},{"seed":5005609,"d":-17.444157245530278},{"seed":5005522,"d":-16.670492759688386}]},"candidate_mean_edge":524.2014888693757,"STACK_mean_edge":525.5771217470509,"retail_edge_delta":{"mean":0.9901206884883873,"se":0.015004238905845327,"estimated":true,"validated":false},"arb_edge_delta":{"mean":-2.365753566163721,"se":0.044013453624143405,"estimated":true,"validated":false},"attribution_check":{"pass":false,"absolute_volume_tolerance":1e-06,"max_absolute_arb_volume_error":0.00011530283882166259,"mean_reconciliation_error":6.661338147750939e-16,"source":"Pinned engine executes one arbitrage per pool before retail each step. Reconstruct reserves as sqrt(k/spot), sqrt(k*spot) using previous step spot, then use current fair price and previous bid/ask fees with the pinned closed-form arbitrage equations. Native arb_volume_y is independently compared per seed."},"gas":{"candidate":{"max_ok":240832,"oog":0,"halts":0,"raw_counters":[{"role":"Baseline","callback":"afterInitialize","calls":2000,"ok":2000,"max_ok_gas":21796,"sum_ok_gas":43592000,"oog":0,"revert":0,"other_halt":0,"tx_error":0,"bad_return":0},{"role":"Baseline","callback":"afterSwap","calls":21496456,"ok":21496456,"max_ok_gas":22592,"sum_ok_gas":485022776132,"oog":0,"revert":0,"other_halt":0,"tx_error":0,"bad_return":0},{"role":"Baseline","callback":"getName","calls":2000,"ok":2000,"max_ok_gas":21526,"sum_ok_gas":43052000,"oog":0,"revert":0,"other_halt":0,"tx_error":0,"bad_return":0},{"role":"Submission","callback":"afterInitialize","calls":2000,"ok":2000,"max_ok_gas":243077,"sum_ok_gas":486154000,"oog":0,"revert":0,"other_halt":0,"tx_error":0,"bad_return":0},{"role":"Submission","callback":"afterSwap","calls":20835158,"ok":20835158,"max_ok_gas":240832,"sum_ok_gas":2273614258043,"oog":0,"revert":0,"other_halt":0,"tx_error":0,"bad_return":0},{"role":"Submission","callback":"getName","calls":2000,"ok":2000,"max_ok_gas":21573,"sum_ok_gas":43146000,"oog":0,"revert":0,"other_halt":0,"tx_error":0,"bad_return":0}],"chunk_size":20,"chunks":100},"STACK":{"max_ok":213500,"oog":0,"halts":0,"raw_counters":[{"role":"Baseline","callback":"afterInitialize","calls":2000,"ok":2000,"max_ok_gas":21796,"sum_ok_gas":43592000,"oog":0,"revert":0,"other_halt":0,"tx_error":0,"bad_return":0},{"role":"Baseline","callback":"afterSwap","calls":21486383,"ok":21486383,"max_ok_gas":22592,"sum_ok_gas":484795911904,"oog":0,"revert":0,"other_halt":0,"tx_error":0,"bad_return":0},{"role":"Baseline","callback":"getName","calls":2000,"ok":2000,"max_ok_gas":21526,"sum_ok_gas":43052000,"oog":0,"revert":0,"other_halt":0,"tx_error":0,"bad_return":0},{"role":"Submission","callback":"afterInitialize","calls":2000,"ok":2000,"max_ok_gas":220962,"sum_ok_gas":441924000,"oog":0,"revert":0,"other_halt":0,"tx_error":0,"bad_return":0},{"role":"Submission","callback":"afterSwap","calls":20701304,"ok":20701304,"max_ok_gas":213500,"sum_ok_gas":2037340243295,"oog":0,"revert":0,"other_halt":0,"tx_error":0,"bad_return":0},{"role":"Submission","callback":"getName","calls":2000,"ok":2000,"max_ok_gas":21576,"sum_ok_gas":43152000,"oog":0,"revert":0,"other_halt":0,"tx_error":0,"bad_return":0}],"chunk_size":20,"chunks":100}},"valid":false,"paired_valid":true,"attribution_valid":false,"reasons":["Arbitrage-volume reconstruction disagreement exceeds 1e-6."],"recommendation":"Retain STACK fallback; all shortlisted mechanisms lost on the second tuning block. The frozen novel candidate is confirmed for reporting, not adopted.","adopt":false,"fallback_sha256":"2eaafc7960e520b8a7fd322ec8afaff8fa677c730228a961efb509cc30b25719","validity_scope":"valid requires both native paired evaluation and reconstructed attribution to pass declared checks. Native total edge and gas can be valid while component attribution remains unvalidated. No claim of improvement is implied.","source_verification":{"n":12,"all_quotes_exact":true,"verified_at_utc":"2026-11-08T18:36:04.896373+00:00"},"execution_notes":["The screen wrapper returned exit 127 after its four requested arm runs finished: it was edited while executing, leaving a trailing shell token e. STACK/A/B/C each completed all 120 seeds, as verified in their output files; no simulation chunk was rerun. D was run separately. No effect on arm bytecode, simulation data, or gas counters."],"commands":{"checkout":["git clone https://github.com/benedictbrady/amm-challenge test/scratch/amm-challenge","git -C test/scratch/amm-challenge checkout 6b6921f8d463314aa7c96234e1be25a25245f704"],"working_directory":"test/scratch/amm-challenge under the workspace; scratch and installed runtime are temporary and not delivered","setup":"sh scratch/setup.sh (once; exact source in setup_source)","fetch":[". scratch/env.sh && curl -fLsS https://api.imdnotdead.fun/artifacts/c33720874aa1285e9dc766540b8a90410118a8e8b840d949ea0dcc211bdb27c1 -o scratch/stack.json",". scratch/env.sh && curl -fLsS https://raw.githubusercontent.com/ChengHua926/amm-challenge/d34a5199c59a4c44d5336a25f1436b4ae1f21104/contracts/src/Strategy.sol -o scratch/CH.sol"],"STACK_extract":"json.load(open(\"scratch/stack.json\"))[\"code\"] written as UTF-8 to scratch/STACK.sol; SHA256 checked before testing","calibration":". scratch/env.sh && python scratch/harness.py scratch/CH.sol 0 1000 scratch/calibration.json > scratch/calibration.log 2>&1","generate":". scratch/env.sh && python scratch/variants.py (embedded final generator reproduces the four tested hashes)","screen":[". scratch/env.sh && python scratch/harness.py scratch/STACK.sol 10000 120 scratch/screen-STACK.json > scratch/screen-STACK.log 2>&1",". scratch/env.sh && python scratch/harness.py scratch/A.sol 10000 120 scratch/screen-A.json > scratch/screen-A.log 2>&1",". scratch/env.sh && python scratch/harness.py scratch/B.sol 10000 120 scratch/screen-B.json > scratch/screen-B.log 2>&1",". scratch/env.sh && python scratch/harness.py scratch/C.sol 10000 120 scratch/screen-C.json > scratch/screen-C.log 2>&1",". scratch/env.sh && python scratch/harness.py scratch/D.sol 10000 120 scratch/screen-D.json > scratch/screen-D.log 2>&1"],"shortlist":[". scratch/env.sh && python scratch/harness.py scratch/STACK.sol 20000 200 scratch/shortlist-STACK.json > scratch/shortlist-STACK.log 2>&1",". scratch/env.sh && python scratch/harness.py scratch/C.sol 20000 200 scratch/shortlist-C.json > scratch/shortlist-C.log 2>&1",". scratch/env.sh && python scratch/harness.py scratch/D.sol 20000 200 scratch/shortlist-D.json > scratch/shortlist-D.log 2>&1"],"freeze":". scratch/env.sh && python scratch/freeze.py > scratch/freeze.log","holdout":". scratch/env.sh && python scratch/run_holdout.py > scratch/holdout-driver.log 2>&1","report":". scratch/env.sh && python scratch/report.py","offline_inputs":"Decode source_bundle with json.loads(zlib.decompress(base64.b64decode(data))). The result maps relative file paths to their exact UTF-8 source strings. Write harness_source and variant_generator_source to scratch/harness.py and scratch/variants.py. Runtime and compiler versions must already be installed for offline replay."},"checks":{"json_parse":true,"code_and_bundle_hashes":true,"python_sources_parse":true,"paired_n_and_seed_range":true,"edge_delta_reconciliation":true,"all_final_callbacks_ok":true,"attribution_volume_check":false,"validity_flags_consistent":true,"sources_exact_passages_rechecked":12,"size_limit_bytes":64000}}