{
  "credit": "Taylor (gtmcknight), github.com/gtmcknight/amm-sim@4812a6382311624e1506aca131ca35c378f930d9 research/solved: original replica, Gaussian filter, fee rule, qm tables and arb/retail tell.",
  "mech": "undercut: explicit synced, symmetric fee-space band snap below the estimated rival marginal quote",
  "already_present": {
    "value": false,
    "where": "Read leanbase.py, stalerival.py, real.py and tellpol.py from reference_zb64 at https://api.imd.fun/artifacts/efb8e653f8fd061cecf3e92b186470c9c96c5188523364b60ed101e9672869aa. leanbase.Policy changes the tell; tellpol.TellPolicy changes the first-trade posterior; real.RealPolicy updates the rival estimate and selects/interpolates synced qm tables; stalerival.Policy pulls the stale estimate then repeats lookup. None applies this explicit post-table fee-band snap. Tables already account for rival competition, so the economic idea of competing with the rival is not itself new."
  },
  "definition": {
    "formula": "Let s=reserveY/reserveX after wad reconstruction, r=the existing estimated rival spot after its bind/pull, g=0.997. Bid indifference B=1-g*r/s from s*(1-f_bid)=g*r; ask indifference A=1-g*s/r from s/(1-f_ask)=r/g. Independently on each side, if synced and 0<=point<=0.1 and abs(table_fee-point)<=band_bps*1e-4, replace that fee with max(0,point-margin_bps*1e-4). Otherwise retain it. Apply before existing fee_round, preserving its clamp and Vanilla-gamma collision avoidance.",
    "interpretation": "Marginal (zero-size) router indifference; no prediction of the next order size. A symmetric band may increase a table fee already below the point. A negative indifference fee is ineligible: a zero floor cannot truly undercut it. No edits to price beliefs, tables, tell or market loop.",
    "parameters": {
      "margin_bps": [
        0.01,
        0.1,
        0.5
      ],
      "band_bps": [
        0.5,
        2.0,
        5.0,
        10.0
      ],
      "synced_required": true,
      "both_sides": true
    },
    "state_kept": "No new persistent state; uses current own reserves, existing s2h estimate and synced flag. These already derive only from callback side, amounts, timestamp, own reserves and prior state. Constants are immutable; patch parameters use the existing weights argument.",
    "patch_api": "Apply unified diff to fastlean/fastlean.py. load(amm_dir) and run_batch(tabs,seeds,weights=[margin_bps,band_bps]); weights=None remains baseline, and the existing neural-hook array lengths retain their old meanings. No neural hook is used in this experiment.",
    "method": "Predeclared 3x4 grid, 12 settings. Sequential rounds of 128 seeds, 64000..65023 inclusive, each active candidate paired against LEAN on identical seeds. Drop immediately at a round boundary if cumulative mean_diff+3*se<0. Choose maximum cumulative mean among surviving full-1024 candidates, before report evaluation. Then exactly one full run per report seed of chosen+LEAN and LEAN, and chosen+AGE and AGE, on 10000..12047 inclusive; 10000 steps/run. se=sample sd of paired differences (ddof=1)/sqrt(n); seeds_positive counts strict positive paired differences. Report chunks of 128 only provide progress, with no report stopping or reselection.",
    "baselines": {
      "LEAN": {
        "a0": 0.35,
        "ainf": 0.35,
        "tau": 2.0
      },
      "AGE": {
        "a0": 0.0,
        "ainf": 0.7,
        "tau": 1.0
      }
    },
    "provenance": {
      "replica": "https://api.imd.fun/artifacts/a88ff982eba7e078bc6ccb1555b90a211c00c9fd76ec90a62ab13a4074f2c3d0",
      "reference": "https://api.imd.fun/artifacts/efb8e653f8fd061cecf3e92b186470c9c96c5188523364b60ed101e9672869aa",
      "kit": "https://raw.githubusercontent.com/identity-md-launches/goal-3178-build-shared-evaluation-kit/45e7563d1a29ffca9d608fdf60c90bf2624d2d01/README.md",
      "original_fastlean_sha256": "d9c758bb280fe24e09c039496f84ab0804173ff70cec24c332f8683f28efa582",
      "patched_fastlean_sha256": "a4dd1e3990fa5d4fcf08cd2a9696b164b2fe2285cce65aa216c25bd46076dda6",
      "patch_sha256": "bc5ee0bc55341b5c09ead50d1791fdc9611cc917c9ccb115bc8df1e5e51411de",
      "table_sha256": {
        "pol_mid.json": "efbb5ee102db4d312f64565d9bf7232b6becbe02b624164f744a402bbbf2983b",
        "qm_k1e-5.json": "5ff53e42ca87390e5f65d1caa3f7a480e67a8212fb0670274dfd562b05ba1afd"
      },
      "runtime": "CPython 3.12; numpy 2.2.6, numba 0.61.2, llvmlite 0.44.0; standard supplied fast LEAN market loop retained"
    }
  },
  "settings_tried": [
    {
      "parameters": {
        "margin_bps": 0.01,
        "band_bps": 0.5
      },
      "dropped_early": false,
      "n": 1024,
      "mean_diff": -0.006213298236536546,
      "se": 0.003046913884433012,
      "seeds": [
        64000,
        65023
      ]
    },
    {
      "parameters": {
        "margin_bps": 0.01,
        "band_bps": 2.0
      },
      "dropped_early": true,
      "n": 128,
      "mean_diff": -0.07114872722169174,
      "se": 0.020687981306851465,
      "seeds": [
        64000,
        64127
      ]
    },
    {
      "parameters": {
        "margin_bps": 0.01,
        "band_bps": 5.0
      },
      "dropped_early": true,
      "n": 128,
      "mean_diff": -0.8148717663935368,
      "se": 0.038403892183247294,
      "seeds": [
        64000,
        64127
      ]
    },
    {
      "parameters": {
        "margin_bps": 0.01,
        "band_bps": 10.0
      },
      "dropped_early": true,
      "n": 128,
      "mean_diff": -2.4196979542939703,
      "se": 0.07864149233846525,
      "seeds": [
        64000,
        64127
      ]
    },
    {
      "parameters": {
        "margin_bps": 0.1,
        "band_bps": 0.5
      },
      "dropped_early": false,
      "n": 1024,
      "mean_diff": -0.0035008659169544765,
      "se": 0.002816481716747035,
      "seeds": [
        64000,
        65023
      ]
    },
    {
      "parameters": {
        "margin_bps": 0.1,
        "band_bps": 2.0
      },
      "dropped_early": true,
      "n": 128,
      "mean_diff": -0.06608115606978826,
      "se": 0.017600382034385027,
      "seeds": [
        64000,
        64127
      ]
    },
    {
      "parameters": {
        "margin_bps": 0.1,
        "band_bps": 5.0
      },
      "dropped_early": true,
      "n": 128,
      "mean_diff": -0.7952823793126562,
      "se": 0.0366507945122996,
      "seeds": [
        64000,
        64127
      ]
    },
    {
      "parameters": {
        "margin_bps": 0.1,
        "band_bps": 10.0
      },
      "dropped_early": true,
      "n": 128,
      "mean_diff": -2.370954807056956,
      "se": 0.07555826197699735,
      "seeds": [
        64000,
        64127
      ]
    },
    {
      "parameters": {
        "margin_bps": 0.5,
        "band_bps": 0.5
      },
      "dropped_early": false,
      "n": 1024,
      "mean_diff": -0.005467804396866394,
      "se": 0.0032811267592942357,
      "seeds": [
        64000,
        65023
      ]
    },
    {
      "parameters": {
        "margin_bps": 0.5,
        "band_bps": 2.0
      },
      "dropped_early": true,
      "n": 256,
      "mean_diff": -0.05204552444551336,
      "se": 0.012191012402346867,
      "seeds": [
        64000,
        64255
      ]
    },
    {
      "parameters": {
        "margin_bps": 0.5,
        "band_bps": 5.0
      },
      "dropped_early": true,
      "n": 128,
      "mean_diff": -0.6787730027384051,
      "se": 0.03419520547971747,
      "seeds": [
        64000,
        64127
      ]
    },
    {
      "parameters": {
        "margin_bps": 0.5,
        "band_bps": 10.0
      },
      "dropped_early": true,
      "n": 128,
      "mean_diff": -2.160989410607077,
      "se": 0.06999933819938856,
      "seeds": [
        64000,
        64127
      ]
    }
  ],
  "chosen": {
    "index_zero_based": 4,
    "parameters": {
      "margin_bps": 0.1,
      "band_bps": 0.5
    },
    "selection_n": 1024,
    "selection_mean_diff": -0.0035008659169544765,
    "selection_se": 0.002816481716747035,
    "reason": "Highest selection mean among non-dropped candidates; frozen before report seeds. All selection means were negative."
  },
  "report": {
    "vs_lean": {
      "n": 2048,
      "mean_diff": -0.004690568590842298,
      "se": 0.002193183321020636,
      "seeds_positive": 941,
      "seeds": [
        10000,
        12047
      ],
      "baseline_mean_edge": 536.603390956178,
      "candidate_mean_edge": 536.5987003875872,
      "paired_rows_sha256": "d72d51596b484001711ed07fdedcbc073b6c78d5727c9af02df847bfca417d27"
    },
    "on_age": {
      "n": 2048,
      "mean_diff": -0.009578699512042016,
      "se": 0.0022076424341107,
      "seeds_positive": 949,
      "seeds": [
        10000,
        12047
      ],
      "baseline_mean_edge": 536.6231002985178,
      "candidate_mean_edge": 536.6135215990057,
      "paired_rows_sha256": "2945900da2d59bc269c54bd6e8dadf5648ae35486f53e540a4241dd1ab57dfd6"
    },
    "validation": {
      "lean": {
        "seeds": [
          64000,
          64001,
          64002,
          64003,
          64004,
          64005,
          64006,
          64007
        ],
        "baseline_max_abs_diff": 0.0,
        "undercut_max_abs_diff": 0.0,
        "original_no_hook_bit_identical": true
      },
      "age": {
        "seeds": [
          64000,
          64001,
          64002,
          64003,
          64004,
          64005,
          64006,
          64007
        ],
        "baseline_max_abs_diff": 0.0,
        "undercut_max_abs_diff": 0.0,
        "original_no_hook_bit_identical": true
      },
      "credit": "Taylor (gtmcknight), github.com/gtmcknight/amm-sim@4812a6382311624e1506aca131ca35c378f930d9 research/solved: replica, Gaussian filter, fee rule, qm tables, arb/retail tell",
      "fee_callbacks": 176667,
      "max_fee_diff_bps": 0.0,
      "algebraic_checks": true,
      "tell_labels": {
        "recorded": 20313,
        "recorded_mismatch": 0,
        "perturbed": 25775,
        "perturbed_mismatch": 0,
        "seeds": [
          64000,
          64001
        ]
      }
    }
  },
  "promote": false,
  "contract_cost": {
    "storage_words": 0,
    "gas": {
      "measured_increment": null,
      "engineering_estimate_increment": [
        500,
        3000
      ],
      "basis": "Unmeasured planning range assuming existing fixed-point spot and rival values can be reused; two ratio calculations, two point calculations, bounds/band tests and subtractions. No new SLOAD/SSTORE or transcendental functions. A particular Solidity arithmetic library/compiler could change this; not a gas guarantee."
    },
    "characters": {
      "solidity_measured_increment": null,
      "engineering_estimate_increment": [
        700,
        1600
      ],
      "python_patch_net_increment": 1118
    },
    "runtime_bytes": {
      "measured_increment": null,
      "engineering_estimate_increment": [
        200,
        900
      ]
    },
    "supplied_baseline": {
      "peak_gas": 208000,
      "gas_limit": 245000,
      "runtime_bytes": 22440,
      "runtime_limit": 24576,
      "source_characters": 47230,
      "source_limit": 50000
    },
    "headroom": {
      "gas": 37000,
      "runtime_bytes": 2136,
      "source_characters": 2770
    },
    "assessment": "Likely fits the supplied headroom if implemented directly with existing fixed-point helpers and compile-time margin/band. Estimates are engineering judgment, not measurements; no Solidity contract was built. Source/gas/byte limits and 0 OOG require later compiled engine certification."
  },
  "patch_zb64": "eNqFVm1v4kYQ/s6vmEaKYoe1g18wLzmi3LWXXqW2XxK1lRCK1ngNbsya213C8e87s3YwAaIayZ7deX92ZhbP84Df5FybUnDpr3edbrcL6bud+3vwkoQl0MV3GMP9fQeOnsAfhQx6fo9BlPixfQe0E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yi5iu+DKnvQgHNKtPoiHLOi9O+mtoNuAOrOhplcNcTWrpbaH93XDQ3jNbi0muJ+XFTdJ7Pp4PxBajhc0kVKVl0I6W3ePrDwGkvZwJpP9snTwU+i8kIURqGV7hzgS/WIV4mxyj+aW4gX2zV+83IivSlXKuXg7kDFMz93CM1httMFbFmo39pxlJaVYcFO8iouD8dpMu23nMFKnToH68c+Hr5+foIuzgQJFxh3ukz0kPWr9y1Ymckmt57oHlXoS/BvyY4JtgffmZYbzAf8p4AUuFK2csqD/DS6GouDb9WXWDcH5hhepXGIpFka7V+QV++koQgZtJG7n/6Efd/4DfVaxEQ==",
  "not_done": [
    "No promotion: chosen report mean fails the +0.03 criterion versus LEAN. No engine pipeline was warranted by this replica screen.",
    "No QLX5 or qt1 comparison, no fresh engine seeds, no Solidity contract, no engine or leaderboard submission. Do not interpret LEAN replica deltas as certified QLX5/leaderboard gains.",
    "No engine-faithful k recomputation port: retained the requested original fast LEAN constant-K market loop. Its known engine arithmetic limitation remains.",
    "No formal or full engine P/Q/T/F/G/E certification. Local checks cover eight selection seeds per LEAN/AGE baseline and chosen variant against the CPython policy, fee-expression equality on their callbacks, and tell labels on two separate baseline traces plus perturbations. Report runs themselves were not rerun.",
    "Contract cost estimates are uncompiled and unmeasured. No runtime byte size, gas peak, source size or OOG assurance is claimed."
  ]
}
