{
  "delta": "Added only NEXT-TRADE MIX to exact NP2. All existing estimator and fee constants remain unchanged. After TWO's fee compression, k=stepTradeCount-1 uses the first observed print as the existing arb proxy. Compute q=P(Poisson(lambdaHat)>k)/P(Poisson(lambdaHat)>=k); k=0 gives 1-exp(-lambdaHat). Blend the exposed side as q^e*TWO+(1-q^e)*min(10%,abs(ln(spot/pHat))+m*sigmaHat); leave the other side unchanged. Poisson tails use a 24-term positive series; capped log uses five atanh terms; q^e uses square roots and integer powers. Final m=0.625, e=0.125 (MIX_M=625000000000000000, MIX_E_SIXTEENTHS=2). No added state or external dependency.",
  "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 MIX_M = 625000000000000000;\n    uint256 constant MIX_E_SIXTEENTHS = 2;\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[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; slots[11] = 0; slots[12] = 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 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[11] = pHat; slots[12] = pImplied >= pHat ? 1 : 2; }\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 (oppDir && REVERT_U > 0) {\n                uint256 pre = slots[11];\n                if (pre > pHat) pHat = pHat + wmul(pre - pHat, REVERT_U);\n                else pHat = pHat - wmul(pHat - pre, REVERT_U);\n            }\n            if (firstInStep) {\n                if (ret > RET_CAP) ret = RET_CAP;\n                sigmaHat = wmul(sigmaHat, SIGMA_DECAY) + wmul(ret, WAD - SIGMA_DECAY);\n            }\n        }\n\n        // Interior retail routing equalizes fee-adjusted marginal prices.\n        // Subsequent trades in a step cannot be the initial arbitrage trade.\n        if (!firstInStep && feeUsed > 30 * BPS && gamma > 0) {\n            uint256 normalSpot = trade.isBuy\n                ? wdiv(wmul(spot, gamma), WAD - 30 * BPS)\n                : wdiv(wmul(spot, WAD - 30 * BPS), gamma);\n            pHat = wmul(pHat, 90 * WAD / 100) + wmul(normalSpot, 10 * WAD / 100);\n        }\n\n        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        // Mix the next retail quote with a defence against next-step arbitrage.\n        // The first observed print is our existing proxy for the step's arb;\n        // after it, k counts the subsequent observed retail prints.\n        {\n            uint256 q = _nextRetailProbability(lambdaHat, stepTradeCount - 1);\n            uint256 weight = _mixWeight(q);\n            uint256 defence = clampFee(_absLogRatio(spot, pHat) + wmul(MIX_M, sigmaHat));\n            if (spot >= pHat) {\n                bidFee = wmul(weight, bidFee) + wmul(WAD - weight, defence);\n            } else {\n                askFee = wmul(weight, askFee) + wmul(WAD - weight, defence);\n            }\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    // Poisson survival ratio P(N > k) / P(N >= k). Dividing both\n    // tails by P(N=k) avoids cancellation for large k. For k=0 this\n    // is exactly 1-exp(-lambda), up to fixed-point/series rounding.\n    function _nextRetailProbability(uint256 lambda, uint256 k) internal pure returns (uint256) {\n        uint256 term = WAD;\n        uint256 tail;\n        for (uint256 j = 1; j <= 24; ++j) {\n            term = wmul(term, lambda) / (k + j);\n            tail += term;\n            if (term == 0) break;\n        }\n        return wdiv(tail, WAD + tail);\n    }\n\n    // e is an exact multiple of 1/16. Successive square roots implement\n    // the fractional bits without an external fixed-point math library.\n    function _mixWeight(uint256 q) internal pure returns (uint256 weight) {\n        weight = _powWad(q, MIX_E_SIXTEENTHS / 16);\n        uint256 fraction = MIX_E_SIXTEENTHS % 16;\n        uint256 root = q;\n        for (uint256 bit = 8; bit > 0 && fraction > 0; bit >>= 1) {\n            root = sqrt(root * WAD);\n            if ((fraction & bit) != 0) {\n                weight = wmul(weight, root);\n                fraction -= bit;\n            }\n        }\n    }\n\n    // 2*atanh((a-b)/(a+b)) = abs(ln(a/b)). Once z >= .05,\n    // the logarithm exceeds the 10% fee cap. In the remaining domain\n    // five positive terms give <1e-15 absolute truncation error.\n    function _absLogRatio(uint256 a, uint256 b) internal pure returns (uint256) {\n        if (a == b) return 0;\n        if (a == 0 || b == 0) return MAX_FEE;\n        uint256 z = wdiv(absDiff(a, b), a + b);\n        if (z >= WAD / 20) return MAX_FEE;\n        uint256 z2 = wmul(z, z);\n        uint256 power = z;\n        uint256 series = z;\n        for (uint256 j = 3; j <= 9; j += 2) {\n            power = wmul(power, z2);\n            series += power / j;\n        }\n        return 2 * series;\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 \"NP2_next_mix_a\"; }\n}\n",
  "sha256": "1e8a7601c5c0622e870e80308f2ab7aa5a58361358e7926f96735c31f6321a5b",
  "np2_check": {
    "seeds": "0..999",
    "n": 1000,
    "mean": 526.1155722459862,
    "expected": 526.1156,
    "tolerance": 5e-05,
    "pass": true,
    "sha256": "51f1c1a9d4999ee460eb8bbc66880da8074b173399a4f5d71f96671482e18ac0",
    "CH": {
      "seeds": "0..999",
      "n": 1000,
      "mean": 525.5258821780834,
      "expected": 525.525882178,
      "tolerance": 1e-06,
      "pass": true
    }
  },
  "tune": {
    "seeds": "10000..10399; 11000..11999 (128-seed broad sweep uses 10000..10127)",
    "best_mean_diff": 0.16325352468175702,
    "selected": {
      "tag": "selection2-m0.625-e2",
      "m": 0.625,
      "e": 0.125,
      "e16": 2,
      "seeds": "11000..11999",
      "sha256": "1e8a7601c5c0622e870e80308f2ab7aa5a58361358e7926f96735c31f6321a5b",
      "stats": {
        "n": 1000,
        "mean_diff": 0.16325352468175702,
        "se": 0.015470357318619938,
        "worst": [
          {
            "seed": 11819,
            "diff": -4.237044944269883,
            "candidate_edge": 402.8958725929875,
            "np2_edge": 407.13291753725736
          },
          {
            "seed": 11682,
            "diff": -2.503183923295694,
            "candidate_edge": 485.113170737034,
            "np2_edge": 487.6163546603297
          },
          {
            "seed": 11891,
            "diff": -2.4931272208190194,
            "candidate_edge": 610.0113360251112,
            "np2_edge": 612.5044632459302
          },
          {
            "seed": 11692,
            "diff": -2.2409641959126247,
            "candidate_edge": 553.0126161735953,
            "np2_edge": 555.253580369508
          },
          {
            "seed": 11316,
            "diff": -2.026694486631243,
            "candidate_edge": 495.14275462734867,
            "np2_edge": 497.1694491139799
          }
        ],
        "candidate_mean": 521.3792616902196,
        "np2_mean": 521.2160081655378
      },
      "seconds": 220.86118193692528
    },
    "selection_rule": "Broad sweep of 20 variants on 10000..10127; 16 neighboring variants on 10000..10399. Finalists: early leader (m=.5,e=.125), positive small-exponent variant (m=.375,e=.0625), and the highest-mean remaining 400-seed variant. Choose the highest mean paired gain among these three on the common independent tuning block 11000..11999. Holdout excluded throughout.",
    "trials": [
      {
        "tag": "coarse-m0-e2",
        "m": 0.0,
        "e": 0.125,
        "seeds": "10000..10127",
        "n": 128,
        "mean_diff": -0.08696871391452543,
        "se": 0.04077413302972842
      },
      {
        "tag": "coarse-m0.5-e2",
        "m": 0.5,
        "e": 0.125,
        "seeds": "10000..10127",
        "n": 128,
        "mean_diff": 0.15883265835151938,
        "se": 0.05422498608316538
      },
      {
        "tag": "coarse-m1-e2",
        "m": 1.0,
        "e": 0.125,
        "seeds": "10000..10127",
        "n": 128,
        "mean_diff": -0.01628492793129066,
        "se": 0.07006204209220712
      },
      {
        "tag": "coarse-m2-e2",
        "m": 2.0,
        "e": 0.125,
        "seeds": "10000..10127",
        "n": 128,
        "mean_diff": -1.2423031840516017,
        "se": 0.10257948168781829
      },
      {
        "tag": "coarse-m4-e2",
        "m": 4.0,
        "e": 0.125,
        "seeds": "10000..10127",
        "n": 128,
        "mean_diff": -9.486565957591765,
        "se": 0.23438114995999995
      },
      {
        "tag": "coarse-m0-e8",
        "m": 0.0,
        "e": 0.5,
        "seeds": "10000..10127",
        "n": 128,
        "mean_diff": -2.317961746421302,
        "se": 0.1384258179018791
      },
      {
        "tag": "coarse-m0.5-e8",
        "m": 0.5,
        "e": 0.5,
        "seeds": "10000..10127",
        "n": 128,
        "mean_diff": -0.425780137128978,
        "se": 0.2021883610085444
      },
      {
        "tag": "coarse-m1-e8",
        "m": 1.0,
        "e": 0.5,
        "seeds": "10000..10127",
        "n": 128,
        "mean_diff": -4.0660593204369935,
        "se": 0.4143491008695759
      },
      {
        "tag": "coarse-m2-e8",
        "m": 2.0,
        "e": 0.5,
        "seeds": "10000..10127",
        "n": 128,
        "mean_diff": -184.39431403149172,
        "se": 4.725507781353178
      },
      {
        "tag": "coarse-m4-e8",
        "m": 4.0,
        "e": 0.5,
        "seeds": "10000..10127",
        "n": 128,
        "mean_diff": -285.13449651957103,
        "se": 3.870611012969136
      },
      {
        "tag": "coarse-m0-e16",
        "m": 0.0,
        "e": 1.0,
        "seeds": "10000..10127",
        "n": 128,
        "mean_diff": -7.32837642321574,
        "se": 0.20389544755130215
      },
      {
        "tag": "coarse-m0.5-e16",
        "m": 0.5,
        "e": 1.0,
        "seeds": "10000..10127",
        "n": 128,
        "mean_diff": -2.771901100453381,
        "se": 0.4421162405405522
      },
      {
        "tag": "coarse-m1-e16",
        "m": 1.0,
        "e": 1.0,
        "seeds": "10000..10127",
        "n": 128,
        "mean_diff": -31.758786169683923,
        "se": 1.158115501006376
      },
      {
        "tag": "coarse-m2-e16",
        "m": 2.0,
        "e": 1.0,
        "seeds": "10000..10127",
        "n": 128,
        "mean_diff": -310.485435199182,
        "se": 4.346947576565048
      },
      {
        "tag": "coarse-m4-e16",
        "m": 4.0,
        "e": 1.0,
        "seeds": "10000..10127",
        "n": 128,
        "mean_diff": -325.34903170393,
        "se": 4.533503655885097
      },
      {
        "tag": "coarse-m0-e32",
        "m": 0.0,
        "e": 2.0,
        "seeds": "10000..10127",
        "n": 128,
        "mean_diff": -20.187857100458196,
        "se": 0.5423635903187115
      },
      {
        "tag": "coarse-m0.5-e32",
        "m": 0.5,
        "e": 2.0,
        "seeds": "10000..10127",
        "n": 128,
        "mean_diff": -20.293511255745404,
        "se": 1.6750996622095151
      },
      {
        "tag": "coarse-m1-e32",
        "m": 1.0,
        "e": 2.0,
        "seeds": "10000..10127",
        "n": 128,
        "mean_diff": -272.1111645606561,
        "se": 4.399448648615903
      },
      {
        "tag": "coarse-m2-e32",
        "m": 2.0,
        "e": 2.0,
        "seeds": "10000..10127",
        "n": 128,
        "mean_diff": -335.6698231494639,
        "se": 4.730703470495697
      },
      {
        "tag": "coarse-m4-e32",
        "m": 4.0,
        "e": 2.0,
        "seeds": "10000..10127",
        "n": 128,
        "mean_diff": -349.69186167767754,
        "se": 4.8354972297605165
      },
      {
        "tag": "fine1-m0.25-e4",
        "m": 0.25,
        "e": 0.25,
        "seeds": "10000..10399",
        "n": 400,
        "mean_diff": -0.07987933438621084,
        "se": 0.04075290929322337
      },
      {
        "tag": "fine1-m0.75-e4",
        "m": 0.75,
        "e": 0.25,
        "seeds": "10000..10399",
        "n": 400,
        "mean_diff": -0.1208424632693992,
        "se": 0.06559515603228734
      },
      {
        "tag": "fine1-m0.25-e8",
        "m": 0.25,
        "e": 0.5,
        "seeds": "10000..10399",
        "n": 400,
        "mean_diff": -0.7328888889043487,
        "se": 0.07679135386267529
      },
      {
        "tag": "fine1-m0.75-e8",
        "m": 0.75,
        "e": 0.5,
        "seeds": "10000..10399",
        "n": 400,
        "mean_diff": -1.353715075054135,
        "se": 0.10338285402232414
      },
      {
        "tag": "fine1-m0.25-e16",
        "m": 0.25,
        "e": 1.0,
        "seeds": "10000..10399",
        "n": 400,
        "mean_diff": -3.2406684804725825,
        "se": 0.156279320298849
      },
      {
        "tag": "fine1-m0.75-e16",
        "m": 0.75,
        "e": 1.0,
        "seeds": "10000..10399",
        "n": 400,
        "mean_diff": -9.313462818491333,
        "se": 0.3851440917878296
      },
      {
        "tag": "fine2-m0.375-e1",
        "m": 0.375,
        "e": 0.0625,
        "seeds": "10000..10399",
        "n": 400,
        "mean_diff": 0.08939668318664915,
        "se": 0.013519545777319198
      },
      {
        "tag": "fine2-m0.5-e1",
        "m": 0.5,
        "e": 0.0625,
        "seeds": "10000..10399",
        "n": 400,
        "mean_diff": 0.09808067610791384,
        "se": 0.01556096181635242
      },
      {
        "tag": "fine2-m0.625-e1",
        "m": 0.625,
        "e": 0.0625,
        "seeds": "10000..10399",
        "n": 400,
        "mean_diff": 0.10659811734328258,
        "se": 0.016858158579138766
      },
      {
        "tag": "fine2-m0.375-e2",
        "m": 0.375,
        "e": 0.125,
        "seeds": "10000..10399",
        "n": 400,
        "mean_diff": 0.11796438714180951,
        "se": 0.025162456152446562
      },
      {
        "tag": "fine2-m0.5-e2",
        "m": 0.5,
        "e": 0.125,
        "seeds": "10000..10399",
        "n": 400,
        "mean_diff": 0.13107797660370524,
        "se": 0.025312923156541295
      },
      {
        "tag": "fine2-m0.625-e2",
        "m": 0.625,
        "e": 0.125,
        "seeds": "10000..10399",
        "n": 400,
        "mean_diff": 0.1508353274706333,
        "se": 0.026819907144414686
      },
      {
        "tag": "fine3-m0.375-e3",
        "m": 0.375,
        "e": 0.1875,
        "seeds": "10000..10399",
        "n": 400,
        "mean_diff": 0.10881666278566157,
        "se": 0.02873103899216987
      },
      {
        "tag": "fine3-m0.5-e3",
        "m": 0.5,
        "e": 0.1875,
        "seeds": "10000..10399",
        "n": 400,
        "mean_diff": 0.11865279501401872,
        "se": 0.04105732001625416
      },
      {
        "tag": "fine3-m0.375-e4",
        "m": 0.375,
        "e": 0.25,
        "seeds": "10000..10399",
        "n": 400,
        "mean_diff": 0.03138418603671255,
        "se": 0.05191637774762927
      },
      {
        "tag": "fine3-m0.5-e4",
        "m": 0.5,
        "e": 0.25,
        "seeds": "10000..10399",
        "n": 400,
        "mean_diff": 0.04991596009566223,
        "se": 0.0596642411603623
      },
      {
        "tag": "selection0-m0.5-e2",
        "m": 0.5,
        "e": 0.125,
        "seeds": "11000..11999",
        "n": 1000,
        "mean_diff": 0.1618352388178369,
        "se": 0.014047455496448336
      },
      {
        "tag": "selection1-m0.375-e1",
        "m": 0.375,
        "e": 0.0625,
        "seeds": "11000..11999",
        "n": 1000,
        "mean_diff": 0.08830816092404904,
        "se": 0.010365071786998654
      },
      {
        "tag": "selection2-m0.625-e2",
        "m": 0.625,
        "e": 0.125,
        "seeds": "11000..11999",
        "n": 1000,
        "mean_diff": 0.16325352468175702,
        "se": 0.015470357318619938
      }
    ],
    "holdout_seen_before_freeze": false
  },
  "paired": {
    "n": 4000,
    "mean_diff": 0.16998543167515265,
    "se": 0.00735759405356205,
    "worst": [
      {
        "seed": 2331615,
        "diff": -5.942457080101121,
        "candidate_edge": 729.2696059862673,
        "np2_edge": 735.2120630663684
      },
      {
        "seed": 2333135,
        "diff": -4.1636455746398155,
        "candidate_edge": 407.44937496282165,
        "np2_edge": 411.61302053746147
      },
      {
        "seed": 2330603,
        "diff": -3.085442827850841,
        "candidate_edge": 474.69833968380254,
        "np2_edge": 477.7837825116534
      },
      {
        "seed": 2330294,
        "diff": -2.6696437351916984,
        "candidate_edge": 472.52214309509566,
        "np2_edge": 475.19178683028736
      },
      {
        "seed": 2331305,
        "diff": -2.558624668452353,
        "candidate_edge": 374.7404411424912,
        "np2_edge": 377.29906581094355
      }
    ],
    "candidate_mean": 524.8129484806834,
    "np2_mean": 524.6429630490082,
    "seeds": "2330000..2333999",
    "worst_definition": "Five most negative per-seed candidate-minus-NP2 edges.",
    "confirmation_runs": 1
  },
  "arb_volume": {
    "unit": "Y per 10000-step simulation",
    "n": 4000,
    "candidate_mean": 23439.897395402422,
    "np2_mean": 24112.36330017476,
    "mean_diff": -672.465904772335,
    "se": 1.4675659770591707,
    "relative_diff_percent": -2.7888842599160024
  },
  "retail_volume": {
    "unit": "Y per 10000-step simulation",
    "n": 4000,
    "candidate_mean": 76816.70218368016,
    "np2_mean": 77286.78958463413,
    "mean_diff": -470.08740095397167,
    "se": 1.5922849711752762,
    "relative_diff_percent": -0.6082377123961091
  },
  "gas": {
    "n_calls": 6050,
    "randomized_calls": 6000,
    "fresh_first_calls": 50,
    "initialization_gas": 189944,
    "max_after_swap_gas": 179704,
    "max_by_type": {
      "same_step": 155285,
      "new_step": 117985,
      "fresh_first_call": 179704
    },
    "gas_limit": 250000,
    "all_success": true,
    "method": "pyrevm EVM.result.gas_used; direct hooks, randomized constant-product trades, long same-step runs, both directions, time gaps, large reserve shocks, and fresh first-call cases; synthetic test, not a formal all-input bound"
  },
  "blocked": null,
  "next": "Evaluate a separate variant with a retail-only arrival estimate and an explicit uncertainty model for the first observed print; preserve these untouched confirmation results. This mix alone does not establish a leaderboard gain of +5.8 or +9.6.",
  "methodology": {
    "simulator_commit": "6b6921f8d463314aa7c96234e1be25a25245f704",
    "frozen_at_utc": "2026-11-07T18:50:48.238761+00:00",
    "setup": "Ran the item-specific scratch/setup.sh verbatim once from the simulator checkout under test/scratch; setup and StarterStrategy validation succeeded.",
    "comparison": "Each strategy independently faces the 30-bps VanillaStrategy. Candidate and NP2 share seeds and market draws. Subtract submission edge per seed; never pit candidate against NP2 in one market.",
    "configuration": "For every seed s, numpy.random.default_rng(s) draws retail_mean_size U(19,21), retail_arrival_rate U(0.6,1.0), gbm_sigma U(0.000882,0.001008), in that order. cfg.seed=s; Rust price seed=s and retail seed=s+1. 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. Configuration builder was checked field-by-field against MatchRunner._build_configs on seeds 0..999.",
    "execution": "Unmodified pinned simulator; amm_sim_rs.run_batch, 8 workers, chunks of 24. Each confirmation seed evaluated once per strategy. All confirmation seeds were held out from tuning; source hash and constants were frozen before starting confirmation.",
    "statistics": "Arithmetic mean of per-seed differences; SE = sample standard deviation (ddof=1)/sqrt(n). Metrics are local experimental measurements, not independently certified or a leaderboard submission.",
    "compiler": "Solidity 0.8.24, optimizer enabled with 200 runs, viaIR=true, evmVersion=paris; official SolidityCompiler and amm-match validate.",
    "source_map_note": "Zero-based indices into sources.json.",
    "source_map": {
      "NP2_inputs": [
        0,
        1
      ],
      "CH": [
        2
      ],
      "configuration": [
        3,
        4
      ],
      "trade_model": [
        5,
        6,
        7
      ],
      "fee_constraints": [
        8,
        9,
        10
      ],
      "compiler": [
        11
      ],
      "hook_error_behavior": [
        12
      ]
    },
    "limitations": "TradeInfo has no arb/retail label. A first observed print can be retail when no arb fills, and some retail orders do not reach this pool. The original lambdaHat estimates capped total observed prints per elapsed step and is retained unchanged. Hence the requested Poisson mix is a model based on observed-print proxies, not an oracle of the next trade type."
  },
  "checks": {
    "validate_passed": true,
    "validate_stdout": "Validating strategy...\nCompiling strategy...\nStrategy 'NP2_next_mix_a' validated successfully!\n",
    "identity_control": {
      "pass": true,
      "n": 8,
      "seeds": "10000..10007",
      "check": "e=0 reproduces NP2 edge, arb volume and retail volume exactly per seed"
    },
    "math": {
      "poisson": {
        "cases": 1792,
        "max_abs_error": "9.5510720758052753906836146884862626363649193700296557263028708364239274554E-18"
      },
      "log": {
        "cases": 505,
        "max_abs_error_after_fee_cap": "8.86E-16"
      },
      "weight": {
        "cases": 1177,
        "max_abs_error": "4.727302184275615136438441867918164971014620419005429827525167160627980673696E-16"
      }
    },
    "math_method": "Direct EVM calls to the exact helper implementations versus 90-digit Decimal references. Probability covers k=0..63 and lambda=0..1.82; log covers both directions and clipping; weights cover all tuned dyadic exponents and endpoints.",
    "simulator_tracked_files_modified": false,
    "confirmation_code_sha256": "1e8a7601c5c0622e870e80308f2ab7aa5a58361358e7926f96735c31f6321a5b"
  }
}
