{
  "approach": "Replace NP additive stale-price recentering with exact multiplicative bid/ask quote placement around pHat, with h=clamp(multiplier*fMid,0,10%). Preserve the NP normalizer-implied price estimator, all other estimators, directional skew, trade-aligned boost, tail compression and final fee clamp. Before skew/tail: bid=max(0,1-pHat*(1-h)/spot), ask=max(0,1-spot/(pHat*(1+h))).",
  "tried": [
    {
      "variant": "geo_1_2",
      "h_multiplier": 0.5,
      "code_sha256": "112c23a5d326bf5276352800705e791407d6ac68f897086cea3a59fdbc8b3c4f",
      "seeds": [
        30000,
        31999
      ],
      "n": 2000,
      "mean_diff": -89.05516067782683,
      "se": 0.8530493857502985,
      "mean_edge": 434.8256087413651,
      "worst": [
        {
          "seed": 30131,
          "diff": -267.58577928903145
        },
        {
          "seed": 31386,
          "diff": -247.14200119959014
        },
        {
          "seed": 31822,
          "diff": -246.53239246650685
        },
        {
          "seed": 31079,
          "diff": -245.44829558423265
        },
        {
          "seed": 31912,
          "diff": -241.18012808327848
        }
      ],
      "seconds_per_simulation": 0.14808468303689734
    },
    {
      "variant": "geo_3_4",
      "h_multiplier": 0.75,
      "code_sha256": "4631581a0d3eb86c144ab5fe9c4fbbbfcd1098dfbc1e2e59e7721c980520c955",
      "seeds": [
        30000,
        31999
      ],
      "n": 2000,
      "mean_diff": -111.6742399607698,
      "se": 1.0229269838751809,
      "mean_edge": 412.2065294584221,
      "worst": [
        {
          "seed": 31326,
          "diff": -313.2156774705211
        },
        {
          "seed": 30671,
          "diff": -289.03414844751785
        },
        {
          "seed": 31079,
          "diff": -278.951577097003
        },
        {
          "seed": 31255,
          "diff": -272.072284001858
        },
        {
          "seed": 30103,
          "diff": -270.70486544051306
        }
      ],
      "seconds_per_simulation": 0.12524245131970382
    },
    {
      "variant": "geo_1_1",
      "h_multiplier": 1.0,
      "code_sha256": "da76a93a4537347323b7e8420c6a308655adb85f0920046cf9b541fd369f9e4d",
      "seeds": [
        30000,
        31999
      ],
      "n": 2000,
      "mean_diff": -136.73497830024237,
      "se": 1.0958695371059448,
      "mean_edge": 387.1457911189496,
      "worst": [
        {
          "seed": 30286,
          "diff": -337.693556855174
        },
        {
          "seed": 31842,
          "diff": -303.9689620910989
        },
        {
          "seed": 31346,
          "diff": -300.25761876523717
        },
        {
          "seed": 31183,
          "diff": -298.8800671628056
        },
        {
          "seed": 30671,
          "diff": -296.57076810388645
        }
      ],
      "seconds_per_simulation": 0.10131872662855312
    },
    {
      "variant": "geo_5_4",
      "h_multiplier": 1.25,
      "code_sha256": "7b81f0e31cd22a5f3d4e2476db7dea03e669b42d0f18e3a29e9d53debb49acb8",
      "seeds": [
        30000,
        31999
      ],
      "n": 2000,
      "mean_diff": -166.64081255611728,
      "se": 1.15704048425541,
      "mean_edge": 357.23995686307467,
      "worst": [
        {
          "seed": 31784,
          "diff": -367.5175714986972
        },
        {
          "seed": 31309,
          "diff": -353.1652618623124
        },
        {
          "seed": 31022,
          "diff": -346.9083625959248
        },
        {
          "seed": 30504,
          "diff": -345.29490209866896
        },
        {
          "seed": 30192,
          "diff": -345.06355728654415
        }
      ],
      "seconds_per_simulation": 0.08534314857143908
    },
    {
      "variant": "geo_3_2",
      "h_multiplier": 1.5,
      "code_sha256": "e1a35bdb6a47fe275603bd0a569ac7ec163ffa694d14f222617b83e4bf765bc6",
      "seeds": [
        30000,
        31999
      ],
      "n": 2000,
      "mean_diff": -197.30630122153408,
      "se": 1.1871250646968041,
      "mean_edge": 326.57446819765784,
      "worst": [
        {
          "seed": 31784,
          "diff": -398.2985447798203
        },
        {
          "seed": 30649,
          "diff": -395.0644944209945
        },
        {
          "seed": 30192,
          "diff": -391.20215226616125
        },
        {
          "seed": 31435,
          "diff": -389.1492710182458
        },
        {
          "seed": 30700,
          "diff": -385.2900430919329
        }
      ],
      "seconds_per_simulation": 0.07396294833137654
    },
    {
      "variant": "geo_1_8",
      "h_multiplier": 0.125,
      "code_sha256": "fdd867ff823b8a041f467d505cc21b82c23378fd430710400befae552832bad6",
      "seeds": [
        30000,
        31999
      ],
      "n": 2000,
      "mean_diff": -59.431671364924476,
      "se": 0.30788773924741275,
      "mean_edge": 464.44909805426744,
      "worst": [
        {
          "seed": 31775,
          "diff": -162.4552268715031
        },
        {
          "seed": 31268,
          "diff": -155.10933933902095
        },
        {
          "seed": 31159,
          "diff": -141.93886720845683
        },
        {
          "seed": 30616,
          "diff": -133.2557278206969
        },
        {
          "seed": 31516,
          "diff": -128.29199331872462
        }
      ],
      "seconds_per_simulation": 0.20450439178128726
    },
    {
      "variant": "geo_1_4",
      "h_multiplier": 0.25,
      "code_sha256": "d64e1222ca08dddde2ab845faa493b7399d409b8f2bf92fd0eca351cf6fc094c",
      "seeds": [
        30000,
        31999
      ],
      "n": 2000,
      "mean_diff": -65.44198533257163,
      "se": 0.48984554068161495,
      "mean_edge": 458.43878408662033,
      "worst": [
        {
          "seed": 30131,
          "diff": -222.7636229439913
        },
        {
          "seed": 31188,
          "diff": -184.35114328448878
        },
        {
          "seed": 31159,
          "diff": -169.392870163535
        },
        {
          "seed": 31516,
          "diff": -160.5240929148609
        },
        {
          "seed": 31912,
          "diff": -158.46258268042243
        }
      ],
      "seconds_per_simulation": 0.1839476015714463
    },
    {
      "variant": "geo_3_8",
      "h_multiplier": 0.375,
      "code_sha256": "18593a0ec13a1d3401c638207db8c52ac0af64968752305b590e88f941f12dff",
      "seeds": [
        30000,
        31999
      ],
      "n": 2000,
      "mean_diff": -76.84190033052192,
      "se": 0.7176857284004695,
      "mean_edge": 447.03886908867,
      "worst": [
        {
          "seed": 30131,
          "diff": -238.92589517089598
        },
        {
          "seed": 31434,
          "diff": -234.42992663747464
        },
        {
          "seed": 31912,
          "diff": -230.2396958736441
        },
        {
          "seed": 31516,
          "diff": -217.61837392513723
        },
        {
          "seed": 31822,
          "diff": -217.5544988434766
        }
      ],
      "seconds_per_simulation": 0.16579169400362298
    }
  ],
  "next": "Do not promote this frozen geometric-recenter candidate. Retain NP. This completes the fresh mechanism experiment; any partial/interpolated recentering would be a new tuning experiment requiring separate fresh seeds. The best tested multiplier (0.125) is a grid boundary; the experiment does not establish the optimum outside the measured grid.",
  "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] = BASE_FEE; slots[1] = BASE_FEE; 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] = 800000000000000000; slots[8] = 2000000000000000;\n        slots[9] = 0; slots[10] = 0;\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 = 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\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        // Geometric quote band around the inferred fair price.\n        uint256 h = (fMid * 1) / 8;\n        if (h > WAD / 10) h = WAD / 10;\n        uint256 targetBid = wmul(pHat, WAD - h);\n        uint256 targetAsk = wmul(pHat, WAD + h);\n        uint256 bidFee = spot > targetBid ? WAD - wdiv(targetBid, spot) : 0;\n        uint256 askFee = targetAsk > spot ? WAD - wdiv(spot, targetAsk) : 0;\n        if (sellPressure) {\n            bidFee = bidFee + skew;\n            askFee = askFee > skew ? askFee - skew : 0;\n        } else {\n            askFee = askFee + skew;\n            bidFee = bidFee > skew ? bidFee - skew : 0;\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        // Every call uses elapsed <= ELAPSED_CAP (8): four bits suffice.\n        if (exp & 1 == 1) result = wmul(result, factor);\n        factor = wmul(factor, factor);\n        exp >>= 1;\n        if (exp & 1 == 1) result = wmul(result, factor);\n        factor = wmul(factor, factor);\n        exp >>= 1;\n        if (exp & 1 == 1) result = wmul(result, factor);\n        factor = wmul(factor, factor);\n        exp >>= 1;\n        if (exp & 1 == 1) result = wmul(result, factor);\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": "fdd867ff823b8a041f467d505cc21b82c23378fd430710400befae552832bad6",
  "delta": {
    "behavior": "Replace the fMid-centered bid/ask assignment and the entire additive staleShift/attractShift block with geometric recentering followed by the original skew. The width multiplier is the sole tuned parameter.",
    "mechanical": "Unroll the inherited _powWad exponent loop into four bit tests because every caller caps elapsed at 8. Exhaustive integer comparison over elapsed 0..8 for all three distinct decay factors confirms identical values. No loop remains in delivered Strategy.",
    "unified_diff": "--- NP.sol\n+++ Strategy.sol\n@@ -132,25 +132,19 @@\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+        // Geometric quote band around the inferred fair price.\n+        uint256 h = (fMid * 1) / 8;\n+        if (h > WAD / 10) h = WAD / 10;\n+        uint256 targetBid = wmul(pHat, WAD - h);\n+        uint256 targetAsk = wmul(pHat, WAD + h);\n+        uint256 bidFee = spot > targetBid ? WAD - wdiv(targetBid, spot) : 0;\n+        uint256 askFee = targetAsk > spot ? WAD - wdiv(spot, targetAsk) : 0;\n         if (sellPressure) {\n-            bidFee = fMid + skew;\n-            askFee = fMid > skew ? fMid - skew : 0;\n+            bidFee = bidFee + skew;\n+            askFee = askFee > skew ? askFee - 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+            askFee = askFee + skew;\n+            bidFee = bidFee > skew ? bidFee - skew : 0;\n         }\n \n         {\n@@ -185,11 +179,17 @@\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+        // Every call uses elapsed <= ELAPSED_CAP (8): four bits suffice.\n+        if (exp & 1 == 1) result = wmul(result, factor);\n+        factor = wmul(factor, factor);\n+        exp >>= 1;\n+        if (exp & 1 == 1) result = wmul(result, factor);\n+        factor = wmul(factor, factor);\n+        exp >>= 1;\n+        if (exp & 1 == 1) result = wmul(result, factor);\n+        factor = wmul(factor, factor);\n+        exp >>= 1;\n+        if (exp & 1 == 1) result = wmul(result, factor);\n     }\n \n     function _decayCentered(uint256 centered, uint256 decayFactor, uint256 elapsed) internal pure returns (uint256) {"
  },
  "score": {
    "seed_start": 0,
    "n": 1000,
    "mean_edge": 466.3044242843912,
    "se": 2.605610941897279
  },
  "paired": {
    "reference": "NP",
    "reference_code_sha256": "e93f6ea4b83679b7d7122532fde450fbf89a7f6e000fa79b91d0c194f88ae3f3",
    "seed_start": 800000,
    "n": 2000,
    "mean_diff": -59.57499193823926,
    "se": 0.3189748970067053,
    "worst": [
      {
        "seed": 801295,
        "diff": -157.99130623890392
      },
      {
        "seed": 800600,
        "diff": -147.0600978280595
      },
      {
        "seed": 801718,
        "diff": -139.1276210093377
      },
      {
        "seed": 800781,
        "diff": -137.4569155555867
      },
      {
        "seed": 800749,
        "diff": -137.01021114301926
      }
    ],
    "chunks": [
      {
        "seed_start": 800000,
        "n": 500,
        "n_covered": 500,
        "mean_diff": -59.72283932915378,
        "se": 0.6284959363483889
      },
      {
        "seed_start": 800500,
        "n": 500,
        "n_covered": 1000,
        "mean_diff": -60.30190371101734,
        "se": 0.6772707626291365
      },
      {
        "seed_start": 801000,
        "n": 500,
        "n_covered": 1500,
        "mean_diff": -59.2183617682214,
        "se": 0.6342314159741078
      },
      {
        "seed_start": 801500,
        "n": 500,
        "n_covered": 2000,
        "mean_diff": -59.05686294456449,
        "se": 0.6103430340188436
      }
    ]
  },
  "seconds_per_simulation": 0.20399192544515243,
  "validate_ok": true,
  "blocked": null,
  "citations": [
    {
      "url": "https://raw.githubusercontent.com/ChengHua926/amm-challenge/d34a5199c59a4c44d5336a25f1436b4ae1f21104/contracts/src/Strategy.sol",
      "supports": "CH base code and original stale-shift/skew/tail mechanism. NP injection is specified by the requester."
    },
    {
      "url": "https://raw.githubusercontent.com/benedictbrady/amm-challenge/6b6921f8d463314aa7c96234e1be25a25245f704/README.md",
      "supports": "Challenge simulator structure and 10,000-step horizon."
    },
    {
      "url": "https://raw.githubusercontent.com/benedictbrady/amm-challenge/6b6921f8d463314aa7c96234e1be25a25245f704/amm_competition/competition/match.py",
      "supports": "Canonical NumPy config draw order used by MatchRunner."
    },
    {
      "url": "https://raw.githubusercontent.com/benedictbrady/amm-challenge/6b6921f8d463314aa7c96234e1be25a25245f704/amm_competition/competition/config.py",
      "supports": "Canonical variance ranges and default simulation settings."
    },
    {
      "url": "https://raw.githubusercontent.com/benedictbrady/amm-challenge/6b6921f8d463314aa7c96234e1be25a25245f704/amm_sim_rs/src/simulation/engine.rs",
      "supports": "Distinct deterministic price and retail seeds."
    },
    {
      "url": "https://raw.githubusercontent.com/benedictbrady/amm-challenge/6b6921f8d463314aa7c96234e1be25a25245f704/amm_sim_rs/src/evm/strategy.rs",
      "supports": "250,000 gas limit per afterSwap callback."
    },
    {
      "url": "https://raw.githubusercontent.com/dipankar/amm-challenge/c588ae6c47fc9af2063c9bb1f2efbeb0dd276dab/ANALYSIS.md",
      "supports": "Public state-estimation post-mortem, read as background only; its reported scores were not used as measurements."
    },
    {
      "url": "https://raw.githubusercontent.com/benedictbrady/amm-challenge/6b6921f8d463314aa7c96234e1be25a25245f704/amm_competition/evm/compiler.py",
      "supports": "Canonical Solidity compilation settings and compiler/opcode/storage checks."
    },
    {
      "url": "https://raw.githubusercontent.com/benedictbrady/amm-challenge/6b6921f8d463314aa7c96234e1be25a25245f704/contracts/src/AMMStrategyBase.sol",
      "supports": "Inherited 32-slot storage bound and WAD helpers."
    },
    {
      "url": "https://raw.githubusercontent.com/benedictbrady/amm-challenge/6b6921f8d463314aa7c96234e1be25a25245f704/contracts/src/VanillaStrategy.sol",
      "supports": "Fixed 30 bps normalizer contract."
    },
    {
      "url": "https://raw.githubusercontent.com/benedictbrady/amm-challenge/6b6921f8d463314aa7c96234e1be25a25245f704/amm_sim_rs/src/lib.rs",
      "supports": "run_batch API and worker-count argument."
    },
    {
      "url": "https://raw.githubusercontent.com/benedictbrady/amm-challenge/6b6921f8d463314aa7c96234e1be25a25245f704/amm_sim_rs/src/types/result.rs",
      "supports": "Original result structure and chart-history getters; context for the output-only accessor patch."
    },
    {
      "url": "https://raw.githubusercontent.com/benedictbrady/amm-challenge/6b6921f8d463314aa7c96234e1be25a25245f704/amm_competition/evm/baseline.py",
      "supports": "Official normalizer bytecode compilation helper."
    },
    {
      "url": "https://raw.githubusercontent.com/benedictbrady/amm-challenge/6b6921f8d463314aa7c96234e1be25a25245f704/amm_sim_rs/src/simulation/runner.rs",
      "supports": "Per-config fresh EVM construction and deterministic parallel result collection."
    },
    {
      "url": "https://raw.githubusercontent.com/benedictbrady/amm-challenge/6b6921f8d463314aa7c96234e1be25a25245f704/amm_competition/evm/validator.py",
      "supports": "Official static strategy validation rules."
    },
    {
      "url": "https://raw.githubusercontent.com/benedictbrady/amm-challenge/6b6921f8d463314aa7c96234e1be25a25245f704/amm_sim_rs/src/types/config.rs",
      "supports": "Rust SimulationConfig fields and seed type."
    },
    {
      "url": "https://raw.githubusercontent.com/benedictbrady/amm-challenge/6b6921f8d463314aa7c96234e1be25a25245f704/amm_sim_rs/src/amm/cfmm.rs",
      "supports": "Bid/ask fee roles and callback propagation in the constant-product AMM."
    }
  ],
  "promotion": {
    "promoted": false,
    "rule": "fresh mean_diff > 2 * paired SE",
    "threshold": 0.6379497940134106,
    "frozen_variant": "geo_1_8",
    "frozen_sha256": "fdd867ff823b8a041f467d505cc21b82c23378fd430710400befae552832bad6",
    "retained_best_sha256": "e93f6ea4b83679b7d7122532fde450fbf89a7f6e000fa79b91d0c194f88ae3f3"
  },
  "scoreboard": {
    "incumbent": {
      "code_sha256": "e93f6ea4b83679b7d7122532fde450fbf89a7f6e000fa79b91d0c194f88ae3f3",
      "seed_start": 0,
      "n": 1000,
      "mean": 526.0337302497852,
      "se": 2.7912248204542776,
      "mean_edge": 526.0337302497852,
      "expected_mean_edge": 526.0337302497852,
      "difference_from_expected": 0.0,
      "seconds_per_simulation": 0.22922099797613918
    },
    "candidate": {
      "variant": "geo_1_8",
      "sha256": "fdd867ff823b8a041f467d505cc21b82c23378fd430710400befae552832bad6",
      "score": {
        "seed_start": 0,
        "n": 1000,
        "mean_edge": 466.3044242843912,
        "se": 2.605610941897279
      }
    },
    "ranked_promotions": []
  },
  "baseline_reproduction": {
    "CH": {
      "code_sha256": "6dd68f77a70900319460215374143dbd5d924198450a46d9f5f91f6b1e3d35c3",
      "seed_start": 0,
      "n": 1000,
      "mean": 525.5258821780834,
      "se": 2.7894264590251843,
      "mean_edge": 525.5258821780834,
      "expected_mean_edge": 525.525882178,
      "difference_from_expected": 8.344613888766617e-11,
      "seconds_per_simulation": 0.21409186653513462
    },
    "NP": {
      "code_sha256": "e93f6ea4b83679b7d7122532fde450fbf89a7f6e000fa79b91d0c194f88ae3f3",
      "seed_start": 0,
      "n": 1000,
      "mean": 526.0337302497852,
      "se": 2.7912248204542776,
      "mean_edge": 526.0337302497852,
      "expected_mean_edge": 526.0337302497852,
      "difference_from_expected": 0.0,
      "seconds_per_simulation": 0.22922099797613918
    }
  },
  "methodology": {
    "simulator_commit": "6b6921f8d463314aa7c96234e1be25a25245f704",
    "baseline": "Every strategy was run independently against the fixed 30 bps VanillaStrategy. Paired differences subtract NP submission edge on identical configs, never candidate-versus-NP direct AMM competition.",
    "draws": "For each seed s, numpy.random.default_rng(s), sequential uniform(19,21) mean size, uniform(0.6,1.0) arrival rate, uniform(0.000882,0.001008) sigma. Rust SimulationConfig.seed=s sets the price seed to s and retail seed to s+1.",
    "config": {
      "n_steps": 10000,
      "initial_price": 100,
      "initial_x": 100,
      "initial_y": 10000,
      "gbm_mu": 0,
      "gbm_dt": 1,
      "retail_size_sigma": 1.2,
      "retail_buy_prob": 0.5
    },
    "compiler": "SolidityCompiler: solc 0.8.24, optimizer 200, viaIR, evmVersion paris; no strategy/compiler setting overrides.",
    "se": "Sample standard deviation (ddof=1) of per-seed differences divided by sqrt(n). Score SE is computed from absolute per-seed candidate edges.",
    "selection": "All eight multiplier cells use exactly seeds 30000..31999. The initial five widths were 0.5, 0.75, 1, 1.25, 1.5; after observing wide-band training losses and before any fresh-seed measurement, an adaptive lower-width extension added 0.125, 0.25, 0.375. The first-stage selection was superseded using training data only. Freeze the maximum mean paired difference across all eight, then measure it once against NP on 800000..801999 in four chunks of 500 per strategy. Seeds 900000..909999 were never used. Score seeds 0..999 are not tuning data.",
    "output_only_engine_patch": "In amm_sim_rs/src/types/result.rs, inside #[pymethods] impl BatchSimulationResult, added:\nfn edge_rows(&self) -> Vec<(u64, f64)> {\n    self.results.iter().map(|r| (r.seed, r.edges.get(\"submission\").copied().unwrap_or(0.0))).collect()\n}\nThis borrows already-computed results and copies only seed/edge scalars. No simulation, RNG, math, gas limits, or strategies changed. Exact agreement checked with r.results and with the original pre-patch two-seed NP smoke run. The completed first 500-seed CH chunk uses the original result getter; remaining completed chunks use this accessor. The initial chart-retaining process was interrupted in its unfinished second CH chunk, which was rerun completely; no partial chunk is counted.",
    "setup": "Supplied setup script ran once successfully. The uname platform-inspection check was omitted under the task machine-inspection prohibition. Build, StarterStrategy validation, and subsequent validation succeeded.",
    "seconds_per_simulation_definition": "Wall time inside amm_sim_rs.run_batch divided by simulation count, with 8 Rust workers. Excludes compilation and Python result extraction; this is parallel throughput, not single-thread latency.",
    "measurement_harness": "import json,sys,time,hashlib\nfrom pathlib import Path\nimport numpy as np\nimport amm_sim_rs\nfrom amm_competition.evm.compiler import SolidityCompiler\nfrom amm_competition.evm.baseline import get_vanilla_bytecode_and_abi\nfrom amm_competition.competition.config import build_config\nP=Path('..'); C=SolidityCompiler()\ndef compile_file(name):\n    code=(P/f'{name}.sol').read_text()\n    cache=Path('scratch')/(hashlib.sha256(code.encode()).hexdigest()+'.hex')\n    if cache.exists(): return list(bytes.fromhex(cache.read_text()))\n    r=C.compile(code)\n    if not r.success: raise Exception(r.errors)\n    cache.write_text(r.bytecode.hex())\n    return list(r.bytecode)\nV=list(get_vanilla_bytecode_and_abi()[0])\ndef configs(start,n):\n    out=[]\n    for seed in range(start,start+n):\n        rng=np.random.default_rng(seed)\n        size=rng.uniform(19.,21.); rate=rng.uniform(.6,1.); sigma=rng.uniform(.000882,.001008)\n        out.append(build_config(seed=seed,gbm_sigma=sigma,retail_arrival_rate=rate,retail_mean_size=size))\n    return out\n\ndef run(name,start,n,chunk=500):\n    b=compile_file(name); vals=[]; elapsed=0\n    for s in range(start,start+n,chunk):\n        count=min(chunk,start+n-s); path=Path(f'scratch/{name}_{s}_{count}.json')\n        if path.exists():\n            j=json.loads(path.read_text())\n        else:\n            cfg=configs(s,count); t=time.perf_counter()\n            r=amm_sim_rs.run_batch(b,V,cfg,8)\n            dt=time.perf_counter()-t\n            rows=r.edge_rows()\n            j={'name':name,'start':s,'n':count,'elapsed':dt,'edges':[x[1] for x in rows], 'seeds':[x[0] for x in rows]}\n            del rows, r\n            assert j['seeds']==list(range(s,s+count))\n            path.write_text(json.dumps(j))\n        vals+=j['edges'];elapsed+=j['elapsed']\n        print(json.dumps({'progress':name,'covered':len(vals),'start':start,'through':s+count-1,'mean':float(np.mean(vals)),'elapsed':elapsed}),flush=True)\n    return np.array(vals),elapsed\n\ndef summary(x):\n    return {'n':len(x),'mean':float(np.mean(x)), 'se':float(np.std(x,ddof=1)/np.sqrt(len(x)))}\nif __name__=='__main__':\n    name,start,n=sys.argv[1],int(sys.argv[2]),int(sys.argv[3])\n    x,t=run(name,start,n)\n    print(json.dumps({'done':name,**summary(x),'seconds_per_simulation':t/n}),flush=True)\n"
  },
  "checks": {
    "validation_stdout": "Validating strategy...\nCompiling strategy...\nStrategy 'no_cubic' validated successfully!\n",
    "fixed_storage": "Only inherited slots[0..10] written; no other state storage.",
    "loop_free_strategy": true,
    "geometric_algebra": "Checked quote identities numerically on spots 90, 99, 100, 101, 110 at pHat=100, h=0.01, including zero-fee clamped sides.",
    "decay_unroll": "Exact fixed-point equality for all 27 combinations: three distinct decay factors x elapsed 0..8."
  }
}
