{
 "approach": "Warm-up deltas on NP. Trace of NP's mean quoted fee shows it starting near 23 bps and rising to about 36 bps over 200-400 steps; among NP's estimators only lambdaHat is slow (decay 0.99 per active step), and it is initialised at 0.8. Sigma, size and tox settle within a few steps. Tested fixed warm-up pairs, faster gains, initial values and fee floors. Fixed pairs lose at every grid point. The gain comes from starting lambdaHat at 1.15 instead of 0.8, with a small addition from opening at 25 bps instead of 4.",
 "tried": [
  {
   "variant": "lam=1.0",
   "seeds": "30000..31999",
   "n": 2000,
   "mean_diff": 0.02638,
   "se": 0.00169,
   "horizon_steps": 1000
  },
  {
   "variant": "lam=1.2",
   "seeds": "30000..31999",
   "n": 2000,
   "mean_diff": 0.03145,
   "se": 0.00287,
   "horizon_steps": 1000
  },
  {
   "variant": "lam=1.4",
   "seeds": "30000..31999",
   "n": 2000,
   "mean_diff": 0.02443,
   "se": 0.00355,
   "horizon_steps": 1000
  },
  {
   "variant": "lam=1.6",
   "seeds": "30000..31999",
   "n": 2000,
   "mean_diff": 0.00107,
   "se": 0.0043,
   "horizon_steps": 1000
  },
  {
   "variant": "lam=1.82",
   "seeds": "30000..31999",
   "n": 2000,
   "mean_diff": -0.03817,
   "se": 0.00524,
   "horizon_steps": 1000
  },
  {
   "variant": "size=0.0015",
   "seeds": "30000..31999",
   "n": 2000,
   "mean_diff": -0.00128,
   "se": 0.00015,
   "horizon_steps": 1000
  },
  {
   "variant": "size=0.003",
   "seeds": "30000..31999",
   "n": 2000,
   "mean_diff": 0.00155,
   "se": 0.00035,
   "horizon_steps": 1000
  },
  {
   "variant": "size=0.004",
   "seeds": "30000..31999",
   "n": 2000,
   "mean_diff": 0.00259,
   "se": 0.00051,
   "horizon_steps": 1000
  },
  {
   "variant": "sig=0.0005",
   "seeds": "30000..31999",
   "n": 2000,
   "mean_diff": -0.00075,
   "se": 0.00013,
   "horizon_steps": 1000
  },
  {
   "variant": "sig=0.0015",
   "seeds": "30000..31999",
   "n": 2000,
   "mean_diff": 0.00106,
   "se": 0.00021,
   "horizon_steps": 1000
  },
  {
   "variant": "sig=0.002",
   "seeds": "30000..31999",
   "n": 2000,
   "mean_diff": 0.00158,
   "se": 0.00031,
   "horizon_steps": 1000
  },
  {
   "variant": "open_=15",
   "seeds": "30000..31999",
   "n": 2000,
   "mean_diff": 0.00061,
   "se": 0.0005,
   "horizon_steps": 1000
  },
  {
   "variant": "open_=25",
   "seeds": "30000..31999",
   "n": 2000,
   "mean_diff": 0.00366,
   "se": 0.00053,
   "horizon_steps": 1000
  },
  {
   "variant": "open_=35",
   "seeds": "30000..31999",
   "n": 2000,
   "mean_diff": 0.00255,
   "se": 0.00074,
   "horizon_steps": 1000
  },
  {
   "variant": "open_=45",
   "seeds": "30000..31999",
   "n": 2000,
   "mean_diff": 0.0003,
   "se": 0.00115,
   "horizon_steps": 1000
  },
  {
   "variant": "lamN0=5",
   "seeds": "30000..31999",
   "n": 2000,
   "mean_diff": 0.02466,
   "se": 0.00249,
   "horizon_steps": 1000
  },
  {
   "variant": "lamN0=10",
   "seeds": "30000..31999",
   "n": 2000,
   "mean_diff": 0.02192,
   "se": 0.00237,
   "horizon_steps": 1000
  },
  {
   "variant": "lamN0=20",
   "seeds": "30000..31999",
   "n": 2000,
   "mean_diff": 0.0176,
   "se": 0.00192,
   "horizon_steps": 1000
  },
  {
   "variant": "lamN0=50",
   "seeds": "30000..31999",
   "n": 2000,
   "mean_diff": 0.00733,
   "se": 0.00091,
   "horizon_steps": 1000
  },
  {
   "variant": "fixN=5,fixF=30",
   "seeds": "30000..31999",
   "n": 2000,
   "mean_diff": -0.05475,
   "se": 0.00657,
   "horizon_steps": 1000
  },
  {
   "variant": "fixN=5,fixF=40",
   "seeds": "30000..31999",
   "n": 2000,
   "mean_diff": -0.07718,
   "se": 0.01583,
   "horizon_steps": 1000
  },
  {
   "variant": "fixN=5,fixF=50",
   "seeds": "30000..31999",
   "n": 2000,
   "mean_diff": -0.10734,
   "se": 0.01643,
   "horizon_steps": 1000
  },
  {
   "variant": "fixN=5,fixF=60",
   "seeds": "30000..31999",
   "n": 2000,
   "mean_diff": -0.13302,
   "se": 0.01584,
   "horizon_steps": 1000
  },
  {
   "variant": "fixN=20,fixF=30",
   "seeds": "30000..31999",
   "n": 2000,
   "mean_diff": -0.26123,
   "se": 0.02257,
   "horizon_steps": 1000
  },
  {
   "variant": "fixN=20,fixF=40",
   "seeds": "30000..31999",
   "n": 2000,
   "mean_diff": -0.35372,
   "se": 0.02655,
   "horizon_steps": 1000
  },
  {
   "variant": "fixN=20,fixF=50",
   "seeds": "30000..31999",
   "n": 2000,
   "mean_diff": -0.44275,
   "se": 0.03084,
   "horizon_steps": 1000
  },
  {
   "variant": "fixN=20,fixF=60",
   "seeds": "30000..31999",
   "n": 2000,
   "mean_diff": -0.58933,
   "se": 0.06661,
   "horizon_steps": 1000
  },
  {
   "variant": "fixN=80,fixF=30",
   "seeds": "30000..31999",
   "n": 2000,
   "mean_diff": -1.23868,
   "se": 0.08581,
   "horizon_steps": 1000
  },
  {
   "variant": "fixN=80,fixF=40",
   "seeds": "30000..31999",
   "n": 2000,
   "mean_diff": -1.55545,
   "se": 0.08936,
   "horizon_steps": 1000
  },
  {
   "variant": "fixN=80,fixF=50",
   "seeds": "30000..31999",
   "n": 2000,
   "mean_diff": -1.88302,
   "se": 0.0985,
   "horizon_steps": 1000
  },
  {
   "variant": "fixN=80,fixF=60",
   "seeds": "30000..31999",
   "n": 2000,
   "mean_diff": -2.27249,
   "se": 0.10289,
   "horizon_steps": 1000
  },
  {
   "variant": "lam=1.1",
   "seeds": "30000..31999",
   "n": 2000,
   "mean_diff": 0.03074,
   "se": 0.00236,
   "horizon_steps": 1000
  },
  {
   "variant": "lam=1.3",
   "seeds": "30000..31999",
   "n": 2000,
   "mean_diff": 0.03051,
   "se": 0.00323,
   "horizon_steps": 1000
  },
  {
   "variant": "lam=1.2,size=0.004",
   "seeds": "30000..31999",
   "n": 2000,
   "mean_diff": 0.02704,
   "se": 0.003,
   "horizon_steps": 1000
  },
  {
   "variant": "lam=1.2,size=0.004,sig=0.002",
   "seeds": "30000..31999",
   "n": 2000,
   "mean_diff": 0.02602,
   "se": 0.00303,
   "horizon_steps": 1000
  },
  {
   "variant": "lam=1.2,size=0.004,sig=0.002,open_=25",
   "seeds": "30000..31999",
   "n": 2000,
   "mean_diff": 0.02991,
   "se": 0.00298,
   "horizon_steps": 1000
  },
  {
   "variant": "lam=1.2,lamN0=20",
   "seeds": "30000..31999",
   "n": 2000,
   "mean_diff": 0.03046,
   "se": 0.00276,
   "horizon_steps": 1000
  },
  {
   "variant": "holdN=20,sigD=0.4",
   "seeds": "30000..31999",
   "n": 2000,
   "mean_diff": 0.00093,
   "se": 0.00058,
   "horizon_steps": 1000
  },
  {
   "variant": "holdN=80,sigD=0.4",
   "seeds": "30000..31999",
   "n": 2000,
   "mean_diff": -0.00064,
   "se": 0.001,
   "horizon_steps": 1000
  },
  {
   "variant": "holdN=20,sizeD=0.5",
   "seeds": "30000..31999",
   "n": 2000,
   "mean_diff": 0.00046,
   "se": 0.00077,
   "horizon_steps": 1000
  },
  {
   "variant": "holdN=80,sizeD=0.5",
   "seeds": "30000..31999",
   "n": 2000,
   "mean_diff": 0.0024,
   "se": 0.00165,
   "horizon_steps": 1000
  },
  {
   "variant": "holdN=80,sigD=0.4,sizeD=0.5",
   "seeds": "30000..31999",
   "n": 2000,
   "mean_diff": -0.00636,
   "se": 0.00228,
   "horizon_steps": 1000
  },
  {
   "variant": "act=0.00003",
   "seeds": "30000..31999",
   "n": 2000,
   "mean_diff": 0.00105,
   "se": 0.00032,
   "horizon_steps": 1000
  },
  {
   "variant": "act=0.00006",
   "seeds": "30000..31999",
   "n": 2000,
   "mean_diff": 0.00221,
   "se": 0.00044,
   "horizon_steps": 1000
  },
  {
   "variant": "floorN=5,floorF=25",
   "seeds": "30000..31999",
   "n": 2000,
   "mean_diff": -0.00148,
   "se": 0.00076,
   "horizon_steps": 1000
  },
  {
   "variant": "floorN=20,floorF=25",
   "seeds": "30000..31999",
   "n": 2000,
   "mean_diff": -0.01621,
   "se": 0.00139,
   "horizon_steps": 1000
  },
  {
   "variant": "floorN=20,floorF=15",
   "seeds": "30000..31999",
   "n": 2000,
   "mean_diff": -0.00787,
   "se": 0.00088,
   "horizon_steps": 1000
  },
  {
   "variant": "lam=1.15,open_=25",
   "seeds": "30000..31999",
   "n": 2000,
   "mean_diff": 0.03475,
   "se": 0.00262,
   "horizon_steps": 1000
  },
  {
   "variant": "lam=1.15,lamN0=10",
   "seeds": "30000..31999",
   "n": 2000,
   "mean_diff": 0.03124,
   "se": 0.00269,
   "horizon_steps": 1000
  },
  {
   "variant": "lam=1.15,act=0.00003",
   "seeds": "30000..31999",
   "n": 2000,
   "mean_diff": 0.03175,
   "se": 0.00265,
   "horizon_steps": 1000
  },
  {
   "variant": "lam=1.15",
   "seeds": "32000..33999",
   "n": 2000,
   "mean_diff": 0.0404,
   "se": 0.00316,
   "horizon_steps": 1000
  },
  {
   "variant": "lam=1.1,open_=25",
   "seeds": "32000..33999",
   "n": 2000,
   "mean_diff": 0.04058,
   "se": 0.00285,
   "horizon_steps": 1000
  },
  {
   "variant": "lam=1.15,open_=25",
   "seeds": "32000..33999",
   "n": 2000,
   "mean_diff": 0.04355,
   "se": 0.00321,
   "horizon_steps": 1000
  },
  {
   "variant": "lam=1.2,open_=25",
   "seeds": "32000..33999",
   "n": 2000,
   "mean_diff": 0.0438,
   "se": 0.00348,
   "horizon_steps": 1000
  },
  {
   "variant": "lam=1.15,open_=20",
   "seeds": "32000..33999",
   "n": 2000,
   "mean_diff": 0.04247,
   "se": 0.00322,
   "horizon_steps": 1000
  },
  {
   "variant": "lam=1.15,open_=30",
   "seeds": "32000..33999",
   "n": 2000,
   "mean_diff": 0.04371,
   "se": 0.00319,
   "horizon_steps": 1000
  },
  {
   "variant": "lam=1.15,open_=25,size=0.003",
   "seeds": "32000..33999",
   "n": 2000,
   "mean_diff": 0.04346,
   "se": 0.00324,
   "horizon_steps": 1000
  },
  {
   "variant": "lam=1.15,open_=25,sig=0.0015,act=0.00006",
   "seeds": "32000..33999",
   "n": 2000,
   "mean_diff": 0.04321,
   "se": 0.00326,
   "horizon_steps": 1000
  },
  {
   "variant": "lam=1.15,open_=25,lamN0=20",
   "seeds": "32000..33999",
   "n": 2000,
   "mean_diff": 0.04168,
   "se": 0.00302,
   "horizon_steps": 1000
  },
  {
   "variant": "FROZEN lam=1.15,open_=25 full-horizon check",
   "seeds": "34000..35499",
   "n": 1500,
   "mean_diff": 0.03502,
   "se": 0.00307,
   "horizon_steps": 10000,
   "note": "only 1500 of the planned 2000 seeds: the 10-minute tool limit cut the candidate run and time was kept for the fresh measurement"
  }
 ],
 "tried_note": "Rows with horizon_steps 1000 are a truncated screen: same seeds and same RNG prefix via amm_sim_rs.run_batch, n_steps=1000 instead of 10000, because a warm-up effect is confined to early steps and each cell costs about 20 s. These rows are not full-horizon measurements; the full-horizon check and the fresh measurement confirm the frozen candidate. Variant keys: lam=lambdaHat init; size=sizeHat init; sig=sigmaHat init; act=actEma init; open_=opening fee bps; fixN,fixF=fixed pair for first N callbacks; lamN0=running-mean lambda gain 1/(n0+k) floored at the EMA gain; holdN,sigD,sizeD=sigma/size decay override for first N callbacks; floorN,floorF=fee floor for first N callbacks. Screen rows used lam=1.15 as the float literal 1149999999999999872; the frozen file uses 1150000000000000000.",
 "findings": [
  "The brief's midpoint initialisation is already NP's state: lambdaHat 0.8, sizeHat 0.002 and sigmaHat 0.00095 are the parameter midpoints, so it adds nothing. The gain needs lambdaHat above the midpoint, because the estimator counts arbitrage trades too.",
  "All 12 fixed pairs tested (N 5/20/80, 30..60 bps) lose, from -0.055 to -2.27, with the loss growing in N and F.",
  "The optimum is flat: lambda init 1.1..1.2 and opening fee 20..30 bps all sit within one se (+0.041 to +0.044 on 32000..33999).",
  "The whole warm-up effect is about +0.04 edge. It is real but far smaller than the 0.08 gap between 1st and 2nd on the board."
 ],
 "next": "Warm-up is exhausted at about +0.04: take the two-constant delta and spend later items on steady-state mechanisms. Possibly retest lambdaHat init 1.15 if another item changes LAMBDA_DECAY or the lambda coefficients.",
 "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 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] = 25 * BPS; slots[1] = 25 * BPS; slots[2] = 0; slots[3] = WAD; slots[4] = 0;\n        slots[5] = initialX > 0 ? wdiv(initialY, initialX) : 100 * WAD;\n        slots[6] = 950000000000000; slots[7] = 1150000000000000000; slots[8] = 2000000000000000;\n        slots[9] = 0; slots[10] = 0;\n        return (25 * BPS, 25 * BPS);\n    }\n\n    function afterSwap(TradeInfo calldata trade) external override returns (uint256, uint256) {\n        uint256 prevBidFee = slots[0]; uint256 prevAskFee = slots[1]; uint256 lastTs = 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        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            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        {\n            uint256 ret = pHat > 0 ? wdiv(absDiff(pImplied, pHat), pHat) : 0;\n            uint256 alpha = firstInStep ? PHAT_ALPHA : PHAT_ALPHA_RETAIL;\n            uint256 adaptiveGate = wmul(sigmaHat, GATE_SIGMA_MULT);\n            if (adaptiveGate < MIN_GATE) adaptiveGate = MIN_GATE;\n            if (ret <= adaptiveGate) { pHat = wmul(pHat, WAD - alpha) + wmul(pImplied, alpha); }\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        if(!firstInStep&&feeUsed>30*BPS&&gamma>0){uint256 nS=trade.isBuy?wdiv(wmul(spot,gamma),WAD-30*BPS):wdiv(wmul(spot,WAD-30*BPS),gamma);pHat=wmul(pHat,9*WAD/10)+wmul(nS,WAD/10);}\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 staleShift = wmul(STALE_DIR_COEF, toxSignal);\n            uint256 attractShift = wmul(staleShift, STALE_ATTRACT_FRAC);\n            if (spot >= pHat) {\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 (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        slots[0] = bidFee; slots[1] = askFee; slots[2] = 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    function getName() external pure override returns (string memory) { return \"no_cubic\"; }\n}\n",
 "code_sha256": "ec91954763c189a97eb44e772ac79a00e49e622173194aa2070f2e7aadcb68ca",
 "delta": [
  "afterInitialize: slots[7] (lambdaHat init) 800000000000000000 -> 1150000000000000000",
  "afterInitialize: slots[0], slots[1] and the returned pair BASE_FEE (4 bps) -> 25 * BPS",
  "afterSwap unchanged from NP, so its gas use and slots 0..10 are unchanged"
 ],
 "reference_sha256": {
  "NP": "95d21646a5b6d293c86c36a184769477be7b1ff39ab2adde7668ed79fb22dd38",
  "CH": "6dd68f77a70900319460215374143dbd5d924198450a46d9f5f91f6b1e3d35c3"
 },
 "reproduction": {
  "seeds": "0..999",
  "CH": 525.5258821780834,
  "NP": 526.0337302497852,
  "matches_brief": true
 },
 "score": {
  "seed_start": 0,
  "n": 1000,
  "mean_edge": 526.0706568630395,
  "se": 2.791326698676339
 },
 "score_paired_vs_NP": {
  "seed_start": 0,
  "n": 1000,
  "mean_diff": 0.03692661325427315,
  "se": 0.0034662958086016816,
  "note": "seeds 0..999 were not used for tuning"
 },
 "paired": {
  "reference": "NP",
  "seed_start": 800000,
  "n": 2000,
  "n_covered": 2000,
  "chunk": 500,
  "mean_diff": 0.039169225890194295,
  "se": 0.0021874817073847383,
  "t": 17.9,
  "wins": 1366,
  "losses": 634,
  "candidate_mean": 522.124008116382,
  "reference_mean": 522.0848388904918,
  "worst": [
   {
    "seed": 801447,
    "diff": -0.7275559667642142
   },
   {
    "seed": 801776,
    "diff": -0.6539953914262355
   },
   {
    "seed": 800362,
    "diff": -0.5068685471196659
   },
   {
    "seed": 800115,
    "diff": -0.3623461670999859
   },
   {
    "seed": 801846,
    "diff": -0.3331941189768486
   }
  ],
  "clears_2se": true
 },
 "seconds_per_simulation": 0.2232,
 "seconds_per_simulation_note": "Wall time per full 10000-step simulation with 6 workers on 6 cores, measured on the first 1000 CH seeds; other full runs here took 0.18 to 0.36.",
 "validate_ok": true,
 "blocked": null,
 "process_notes": [
  "scratch/setup.sh first failed because this machine has no bzip2, which the micromamba tar step needs. Extracted the same micromamba archive with Python's tarfile into scratch, installed conda-forge gcc as the script does, then reran the script unchanged; it completed and validated StarterStrategy.",
  "The checkout is under test/scratch/amm-challenge in the workspace.",
  "The fresh block was measured once, for this one frozen candidate, but over several process runs: the 10-minute tool limit cut two runs, and per-chunk caching resumed them. Simulations are seeded, so the split does not affect the result.",
  "Seeds 900000..909999 were never used.",
  "gas was not measured separately: the delta adds no code to afterSwap and the runs completed under the engine's 250000 limit. The bounded while loop in _powWad is inherited from CH."
 ],
 "citations": [
  "https://raw.githubusercontent.com/benedictbrady/amm-challenge/6b6921f8d463314aa7c96234e1be25a25245f704/README.md",
  "https://raw.githubusercontent.com/benedictbrady/amm-challenge/6b6921f8d463314aa7c96234e1be25a25245f704/amm_competition/competition/match.py",
  "https://raw.githubusercontent.com/benedictbrady/amm-challenge/6b6921f8d463314aa7c96234e1be25a25245f704/amm_sim_rs/src/simulation/engine.rs",
  "https://raw.githubusercontent.com/ChengHua926/amm-challenge/d34a5199c59a4c44d5336a25f1436b4ae1f21104/contracts/src/Strategy.sol"
 ]
}