{
  "credit": "Taylor (gtmcknight), github.com/gtmcknight/amm-sim@4812a6382311624e1506aca131ca35c378f930d9 research/solved: original replica, Gaussian filter, fee rule, qm tables and exact-arithmetic arb/retail tell. Share-feedback experiment built on his policy.",
  "mech": "share-feedback: slow symmetric fee-level feedback from observed own retail fills and normalized paid volume; no improvement found, do not promote.",
  "already_present": {
    "present": false,
    "where": "Inspected leanbase.py, stalerival.py, real.py and tellpol.py from the pinned reference bundle. real.RealPolicy.on_trade has cnt (within-step retail count) and phase selection; stalerival.Policy.on_trade has router age and a rival pull. Neither accumulates cross-step count/volume against a target to control fee level. leanbase and tellpol change the arb/retail classification only. Existing per-step count is reused only through the existing retail label; the cross-step controller is new.",
    "source": "https://api.imd.fun/artifacts/efb8e653f8fd061cecf3e92b186470c9c96c5188523364b60ed101e9672869aa"
  },
  "definition": {
    "formula": "Let dt = timestamp - prior callback timestamp, r = 1 when the existing LEAN classifier says non-arb, otherwise 0. With callback amounts/reserves reconstructed from integer wads, v = min(100, 10000*(amountX/reserveX if pool bought X else amountY/reserveY)), in bps of post-trade paid-side reserve. Maintain z, initialized to 1: z <- z*T/(T+dt); if r=1, z <- z + (0.5/T)*(1/C + v/V). Then d_bps = clamp(g*(z-1), -cap, cap); add d_bps*1e-4 to both final table fees before the existing fee_round clamp and Vanilla-gamma exclusion. The actual corrected fees remain in policy state for its next tell/filter update.",
    "parameters": {
      "g": "gain in bps per unit normalized flow excess",
      "T": "smoothing time constant in timestamp steps",
      "C": "target own classified-retail fills per step",
      "V": "target sum of clipped normalized own classified-retail paid volume per step, in bps",
      "cap_bps": 2.0,
      "per_fill_volume_cap_bps": 100.0
    },
    "state_kept": "One additional scalar z in sf[9]; initialized to target 1. Existing si[0] supplies prior callback timestamp. No new timestamp, step accumulator, per-run market parameter or opponent state is required.",
    "observability": "Only afterSwap side, amounts, timestamp, own reserves, existing classifier output and own prior state. Zero-fill intervals are accounted for at the next callback via dt. Fees cannot update when there is no callback. The total market order count and rival-only fills are unobservable: this is own flow intensity feedback, not measured fractional market share, and it does not infer per-run arrival rate or sigma.",
    "timing": "Rational decay T/(T+dt), not exact exponential decay. Multiple fills at a timestamp have dt=0. The current retail fill increments z before fees for the next trade are returned. Classified arb callbacks decay z but add no count or volume. Initial fees remain LEAN/AGE initial fees.",
    "selection_protocol": {
      "seeds": "64000..65023 inclusive",
      "round_size": 128,
      "max_settings": 12,
      "grid": {
        "gain_bps": [
          0.5,
          1.5
        ],
        "time_constant_steps": [
          128,
          512
        ],
        "paired_count_volume_targets": [
          [
            0.45,
            6
          ],
          [
            0.6,
            8
          ],
          [
            0.75,
            10
          ]
        ]
      },
      "baseline": {
        "a0": 0.35,
        "ainf": 0.35,
        "tau": 2.0
      },
      "drop": "Immediately after each cumulative 128-seed round, drop if mean_diff + 3*se < 0.",
      "selection": "Highest cumulative paired mean among survivors at n=1024, ties lower grid index. Ten dropped and two completed. Grid and selection rule frozen before search results.",
      "se": "sample standard deviation of per-seed candidate-minus-baseline differences, ddof=1, divided by sqrt(n)",
      "n_steps_per_seed": 10000
    },
    "provenance": {
      "replica": "https://api.imd.fun/artifacts/a88ff982eba7e078bc6ccb1555b90a211c00c9fd76ec90a62ab13a4074f2c3d0",
      "reference": "https://api.imd.fun/artifacts/efb8e653f8fd061cecf3e92b186470c9c96c5188523364b60ed101e9672869aa",
      "original_fastlean_sha256": "d9c758bb280fe24e09c039496f84ab0804173ff70cec24c332f8683f28efa582",
      "patched_fastlean_sha256": "5a1ad5c327f7db5b7d41fb5df657917e07a84475cff1ad163822e172f800cf80",
      "patch_sha256": "0ecda429c950a30e854001e6794ded88ef4566e93f2a4fbf4e66b5ddf4d11ae6",
      "tables": {
        "pol_mid.json": "efbb5ee102db4d312f64565d9bf7232b6becbe02b624164f744a402bbbf2983b",
        "qm_k1e-5.json": "5ff53e42ca87390e5f65d1caa3f7a480e67a8212fb0670274dfd562b05ba1afd"
      },
      "policy_sha256": {
        "leanbase.py": "ba015769f7981d7798acbbc9aff8c0e0c59825bb1541d55bcdef49311d7a04bc",
        "stalerival.py": "d124a171d35b024daed840e5449d352b2b5e50a68ce98c8a9aaafaf3419d23da",
        "real.py": "6a4a0f0e7f8b43d38e5eaa9d8b2e847a0771aee7f89551b122fe89bfe7969b5f",
        "tellpol.py": "7d5961c45bec56292533e65607245ad119b8733c760a5bf28f76a2e07bc3960b"
      },
      "dependency_verification": "All ten imported packed reference modules checked against frozen.dependency_sha256; both tables checked against setup.table_sha256. Original fastlean checked against its artifact source_sha256."
    },
    "checks": {
      "disabled_controller": "Original versus patched disabled, and patched explicit zero gain: bit-identical seed edges for 64000..64007.",
      "python_oracle": "Independent subclass of packed leanbase.Policy applies controller in round_fees before rounding. Shadow fast on_trade receives identical callback values. Full independent Python replica edge also compared with compiled simulator.",
      "oracle_seeds": "64000..64007 on LEAN and AGE, for initial grid setting and chosen setting; selection seeds only, no report seed reuse.",
      "chosen_seed_runs": 16,
      "chosen_callbacks": 176853,
      "initial_setting_callbacks": 175600,
      "edge_max_abs_diff": 0.0,
      "label_mismatches": 0,
      "max_fee_diff_bps": 0.0,
      "patch": "Unified diff applied cleanly to original fastlean.py and reproduced patched SHA256.",
      "statistics": "Independently recomputed both report summaries from saved paired rows; checked every setting stopping decision against cumulative history.",
      "scope": "Local sampled reference/label/fee checks; not certification of all engine gates."
    },
    "reproduce": "Decode artifact code_zb64 as base64(zlib(tar)), materialize its pinned reference/tables, apply decoded patch_zb64 with patch -p1 beside fastlean.py. Use Python 3.12.3, numpy 2.2.6, llvmlite 0.44.0, numba 0.61.2. Call fastlean.load(amm_dir, a0=.35, ainf=.35, tau=2, share=(.5,512,.75,10,2)) and run_batch(tabs, range(10000,12048)); compare with share=None. AGE uses a0=0, ainf=.7, tau=1 for both sides of its comparison. Selection enumerates gain, then T, then paired C/V targets in the listed order and uses consecutive 128-seed rounds. No learned-hook weights. No fastmath changes.",
    "local_evidence": "Scores and checks are locally computed experiments, not claims quoted from an external page. Report hashes cover little-endian float64 differences in ascending seed order."
  },
  "settings_tried": [
    {
      "parameters": {
        "gain_bps": 0.5,
        "time_constant_steps": 128.0,
        "count_target": 0.45,
        "volume_target_bps": 6.0,
        "cap_bps": 2.0
      },
      "n": 128,
      "mean_diff": -0.08975464830598812,
      "se": 0.017038132351788474,
      "seeds_positive": 39,
      "dropped_early": true
    },
    {
      "parameters": {
        "gain_bps": 0.5,
        "time_constant_steps": 128.0,
        "count_target": 0.6,
        "volume_target_bps": 8.0,
        "cap_bps": 2.0
      },
      "n": 384,
      "mean_diff": -0.028063654945895244,
      "se": 0.0069222980737315126,
      "seeds_positive": 153,
      "dropped_early": true
    },
    {
      "parameters": {
        "gain_bps": 0.5,
        "time_constant_steps": 128.0,
        "count_target": 0.75,
        "volume_target_bps": 10.0,
        "cap_bps": 2.0
      },
      "n": 1024,
      "mean_diff": -0.006430534204347249,
      "se": 0.003925781485296574,
      "seeds_positive": 482,
      "dropped_early": false
    },
    {
      "parameters": {
        "gain_bps": 0.5,
        "time_constant_steps": 512.0,
        "count_target": 0.45,
        "volume_target_bps": 6.0,
        "cap_bps": 2.0
      },
      "n": 128,
      "mean_diff": -0.07762657432105913,
      "se": 0.015292052340016998,
      "seeds_positive": 36,
      "dropped_early": true
    },
    {
      "parameters": {
        "gain_bps": 0.5,
        "time_constant_steps": 512.0,
        "count_target": 0.6,
        "volume_target_bps": 8.0,
        "cap_bps": 2.0
      },
      "n": 256,
      "mean_diff": -0.024182396190727484,
      "se": 0.007665350998574814,
      "seeds_positive": 102,
      "dropped_early": true
    },
    {
      "parameters": {
        "gain_bps": 0.5,
        "time_constant_steps": 512.0,
        "count_target": 0.75,
        "volume_target_bps": 10.0,
        "cap_bps": 2.0
      },
      "n": 1024,
      "mean_diff": -0.005493219484855372,
      "se": 0.003779579743069829,
      "seeds_positive": 464,
      "dropped_early": false
    },
    {
      "parameters": {
        "gain_bps": 1.5,
        "time_constant_steps": 128.0,
        "count_target": 0.45,
        "volume_target_bps": 6.0,
        "cap_bps": 2.0
      },
      "n": 128,
      "mean_diff": -0.39358310614251435,
      "se": 0.033499655677813316,
      "seeds_positive": 16,
      "dropped_early": true
    },
    {
      "parameters": {
        "gain_bps": 1.5,
        "time_constant_steps": 128.0,
        "count_target": 0.6,
        "volume_target_bps": 8.0,
        "cap_bps": 2.0
      },
      "n": 128,
      "mean_diff": -0.07630209756475104,
      "se": 0.017650327953110816,
      "seeds_positive": 50,
      "dropped_early": true
    },
    {
      "parameters": {
        "gain_bps": 1.5,
        "time_constant_steps": 128.0,
        "count_target": 0.75,
        "volume_target_bps": 10.0,
        "cap_bps": 2.0
      },
      "n": 128,
      "mean_diff": -0.04770254854803202,
      "se": 0.01558840573462792,
      "seeds_positive": 51,
      "dropped_early": true
    },
    {
      "parameters": {
        "gain_bps": 1.5,
        "time_constant_steps": 512.0,
        "count_target": 0.45,
        "volume_target_bps": 6.0,
        "cap_bps": 2.0
      },
      "n": 128,
      "mean_diff": -0.3532645493668509,
      "se": 0.03067569299862201,
      "seeds_positive": 15,
      "dropped_early": true
    },
    {
      "parameters": {
        "gain_bps": 1.5,
        "time_constant_steps": 512.0,
        "count_target": 0.6,
        "volume_target_bps": 8.0,
        "cap_bps": 2.0
      },
      "n": 128,
      "mean_diff": -0.05735222507678639,
      "se": 0.014640859842768552,
      "seeds_positive": 48,
      "dropped_early": true
    },
    {
      "parameters": {
        "gain_bps": 1.5,
        "time_constant_steps": 512.0,
        "count_target": 0.75,
        "volume_target_bps": 10.0,
        "cap_bps": 2.0
      },
      "n": 256,
      "mean_diff": -0.04346261401743012,
      "se": 0.011743647531610045,
      "seeds_positive": 108,
      "dropped_early": true
    }
  ],
  "chosen": {
    "index_zero_based": 5,
    "parameters": {
      "gain_bps": 0.5,
      "time_constant_steps": 512.0,
      "count_target": 0.75,
      "volume_target_bps": 10.0,
      "cap_bps": 2.0
    },
    "selection_n": 1024,
    "selection_mean_diff": -0.005493219484855372,
    "selection_se": 0.003779579743069829,
    "frozen_before_report": true
  },
  "report": {
    "vs_lean": {
      "n": 2048,
      "mean_diff": -0.0015907482784406624,
      "se": 0.0028472614476621892,
      "seeds_positive": 996,
      "seed_start": 10000,
      "seed_end": 12047,
      "baseline_mean": 536.603390956178,
      "candidate_mean": 536.6018002078997,
      "paired_differences_sha256": "c6000fa16b977e1ae948fc7e15ea9186ab3c242280a5d0abb687b20e7e19ea34"
    },
    "on_age": {
      "n": 2048,
      "mean_diff": -0.006530390919671475,
      "se": 0.0028038291574551885,
      "seeds_positive": 972,
      "seed_start": 10000,
      "seed_end": 12047,
      "baseline_mean": 536.6231002985178,
      "candidate_mean": 536.6165699075981,
      "paired_differences_sha256": "03ee0e329e48a34f0427188403323e827842e849096d9d19bd2b3c0faf01cd8e"
    },
    "protocol": "Each chosen candidate and paired baseline evaluated once per report seed 10000..12047. AGE means a0=0, ainf=0.7, tau=1; candidate controller identical to LEAN test. Report outcomes did not alter parameters."
  },
  "promote": false,
  "contract_cost": {
    "storage_words": 1,
    "gas": {
      "measured": null,
      "estimated_incremental_afterSwap_range": [
        6000,
        10000
      ],
      "estimate_basis": "Engineering estimate for one read/modify/write of a nonzero fixed-point flow state, reuse of existing timestamp and retail label, a few fixed-point divisions/multiplies and clamps. Initialize z in afterInitialize. No added loops, logs, exponentials or tables. Not measured or a guaranteed upper bound.",
      "brief_baseline_peak": 208000,
      "brief_peak_limit": 245000,
      "estimated_total_peak_range": [
        214000,
        218000
      ]
    },
    "characters": {
      "measured": null,
      "estimated_added_solidity_range": [
        700,
        1400
      ],
      "brief_current": 47230,
      "brief_limit": 50000,
      "remaining_before_change": 2770
    },
    "runtime_bytes": {
      "measured": null,
      "estimated_added_range": [
        250,
        800
      ],
      "brief_current": 22440,
      "brief_limit": 24576,
      "remaining_before_change": 2136
    },
    "qualification": "All Solidity gas/source/runtime additions are planning estimates, not compiled measurements. Storage count follows the one-scalar design. Existing resource figures come from the assignment, not this experiment. A real port must check fixed-point precision, source size, deployed size, peak gas and OOG. This negative replica result does not justify that port."
  },
  "patch_zb64": "eNq1Vktv4zYQvudXTLMHS7G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ZQVTNvmQgGhowJBF5eWEyIIPW8hPVV8cUmDz4ngaHy2Cv3wzfOAHnnBklQFCxl/74t5deK31H924STfSmnMRTj0by1LwOQBsCicbOxwvcWN4JMo/EqfcBCoFHZ/XlmdD8s2cs4IGgnanjni1IoajVeNjeWV7dsQB5WvWew97aPQGG6F/1SF2wMOyO1J8zQR1yTcAmwtPw0XibjtGQm02hG3exJ9r3GUXi/Ed77mLoT6Z1ktKmaVgX9TCh64pcbjSjRDDBPdNr0Rl5LtA7RYevTZWloyspc/1aZdakazVIWrdOVtF8DT/SxnK/W4sCC9pzf+o3wmchuHB6Nk7BXhuCqgRr1+x9s55z3ghCmKR3+BuDPQqsmGJC9i6ibntJRUtRsZr+HWfZDssJmO0yoJ8FBI2vXtd73fT4t976H+pifxuZTfE3+8211Q==",
  "not_done": [
    "No Solidity contract produced, no QLX5 or qt1 comparison, no fresh engine seeds, no engine-faithfulness changes, no gas/runtime-byte measurement, no OOG certification and no leaderboard submission.",
    "Replica uses the supplied LEANBASE constant-product arithmetic, including its known engine reserve-rounding mismatch. Do not infer an engine/board gain from these results.",
    "No table refit/compression, price-belief variant, per-run sigma/arrival-rate fit, exact rival carry, learned residual head or kappa tested.",
    "No claim to measure true market share: all-market denominator and completely rival-routed orders are unavailable to afterSwap.",
    "Smoothing uses callback-sampled rational decay, and its normalized-flow statistic has small discretization bias; target matching is approximate.",
    "Only the specified 12 settings were searched. Sampled parity checks are not an exhaustive proof of classifier or fixed-point contract equivalence."
  ]
}
