{"credit":"Taylor (gtmcknight), github.com/gtmcknight/amm-sim@4812a6382311624e1506aca131ca35c378f930d9 research/solved: replica, Gaussian filter, fee rule, qm tables and exact-arithmetic arb/retail tell.","mech":"size-run: callback-only per-run estimate of full retail order size shifts LEAN fee levels.","already_present":{"value":false,"where":"Inspected leanbase.py, stalerival.py, real.py and tellpol.py in the LEANBASE reference bundle. real.py uses a fixed retail-size likelihood; none keeps a running size estimate or conditions the returned fees on it. See sources.json for the reference bundle and real.py."},"definition":{"formula":"For each fill read as retail, convert own fill to quote units q: ay for a buy-X order, ax*(y/x) for a sell-X order. Reconstruct pre-trade own reserves from callback amounts and fee in force. Infer a rival reserve from prior rival spot s2h and pre-trade own k; invert the replica router split formula for full size z. Clamp z to [q,4q]. Starting M=20 and N=32, update N <- N+1 and M <- M+(z-M)/N. Each callback uses r=clip(M/20-1,-0.5,0.5) and delta=c*r*1e-4. Mode 0 adds delta to both fees, mode 1 to the traded side, mode 2 to the other side, before wad rounding.","parameters":"c: fee bps per unit relative size; mode: 0/1/2; prior mean 20 quote units; prior pseudo-count 32; split cap 4; relative-size cap 0.5.","state_kept":"Two per-run values: estimated size mean M and effective count N. Existing policy state supplies prior rival spot and fees in force. Inputs are callback side, amounts, timestamp and own reserves only.","source_refs":["https://api.imd.fun/artifacts/a88ff982eba7e078bc6ccb1555b90a211c00c9fd76ec90a62ab13a4074f2c3d0","https://api.imd.fun/artifacts/efb8e653f8fd061cecf3e92b186470c9c96c5188523364b60ed101e9672869aa","https://raw.githubusercontent.com/gtmcknight/amm-sim/66604b3426d8e97a73e2c39940b9b4dece51cc73/research/solved/real.py","https://raw.githubusercontent.com/gtmcknight/amm-sim/66604b3426d8e97a73e2c39940b9b4dece51cc73/research/solved/replica2.py"]},"settings_tried":[{"parameters":{"coefficient_bps_per_rel":2.0,"side_mode":0,"prior_mean":20.0,"prior_count":32.0,"split_cap":4.0},"n":256,"mean_diff":-0.03682596735132693,"se":0.009508428004685066,"dropped_early":true},{"parameters":{"coefficient_bps_per_rel":-2.0,"side_mode":0,"prior_mean":20.0,"prior_count":32.0,"split_cap":4.0},"n":128,"mean_diff":-0.045910988125525076,"se":0.013550294362974589,"dropped_early":true},{"parameters":{"coefficient_bps_per_rel":5.0,"side_mode":0,"prior_mean":20.0,"prior_count":32.0,"split_cap":4.0},"n":128,"mean_diff":-0.15029612885375432,"se":0.021936316158419972,"dropped_early":true},{"parameters":{"coefficient_bps_per_rel":-5.0,"side_mode":0,"prior_mean":20.0,"prior_count":32.0,"split_cap":4.0},"n":128,"mean_diff":-0.10861698173828538,"se":0.021136490970899823,"dropped_early":true},{"parameters":{"coefficient_bps_per_rel":10.0,"side_mode":0,"prior_mean":20.0,"prior_count":32.0,"split_cap":4.0},"n":128,"mean_diff":-0.4767879139073159,"se":0.04061008499522567,"dropped_early":true},{"parameters":{"coefficient_bps_per_rel":-10.0,"side_mode":0,"prior_mean":20.0,"prior_count":32.0,"split_cap":4.0},"n":128,"mean_diff":-0.29248455618771896,"se":0.03944478263559245,"dropped_early":true},{"parameters":{"coefficient_bps_per_rel":20.0,"side_mode":0,"prior_mean":20.0,"prior_count":32.0,"split_cap":4.0},"n":128,"mean_diff":-1.74303185448837,"se":0.14289792552750102,"dropped_early":true},{"parameters":{"coefficient_bps_per_rel":-20.0,"side_mode":0,"prior_mean":20.0,"prior_count":32.0,"split_cap":4.0},"n":128,"mean_diff":-0.7240537345374891,"se":0.08031722616892283,"dropped_early":true},{"parameters":{"coefficient_bps_per_rel":10.0,"side_mode":2,"prior_mean":20.0,"prior_count":32.0,"split_cap":4.0},"n":128,"mean_diff":-0.1886939048406786,"se":0.02294183051002697,"dropped_early":true},{"parameters":{"coefficient_bps_per_rel":-10.0,"side_mode":2,"prior_mean":20.0,"prior_count":32.0,"split_cap":4.0},"n":128,"mean_diff":-0.14087475664950455,"se":0.022686888929696638,"dropped_early":true},{"parameters":{"coefficient_bps_per_rel":10.0,"side_mode":1,"prior_mean":20.0,"prior_count":32.0,"split_cap":4.0},"n":128,"mean_diff":-0.2333647823623295,"se":0.028654144548005116,"dropped_early":true},{"parameters":{"coefficient_bps_per_rel":-10.0,"side_mode":1,"prior_mean":20.0,"prior_count":32.0,"split_cap":4.0},"n":128,"mean_diff":-0.13778586031837836,"se":0.03384001590595578,"dropped_early":true}],"chosen":{"coefficient_bps_per_rel":2.0,"side_mode":0,"prior_mean":20.0,"prior_count":32.0,"split_cap":4.0},"report":{"vs_lean":{"n":2048,"mean_diff":-0.04992351261329561,"se":0.003577958126681876,"seeds_positive":732},"on_age":{"n":2048,"mean_diff":-0.053940194276585585,"se":0.0037164126133699647,"seeds_positive":729}},"promote":false,"contract_cost":{"storage_words":2,"gas":{"additional_measured":null,"current_peak_given":208000,"limit":245000,"headroom":37000,"work":"Per retail callback: two square roots, reserve reconstruction, split inversion, clamp, mean update; per callback: fee adjustment. Solidity gas not measured."},"characters":{"additional_measured":null,"current_given":47230,"limit":50000,"headroom":2770,"status":"No Solidity port; fit not measured."},"runtime_bytes":{"additional_measured":null,"current_given":22440,"limit":24576,"headroom":2136}},"patch_zb64":"eNqNVm1P4zgQ/s6vGGmFiNukpGlpF/ZYsSsttyud7suhuw8IIadxqG9DktoObe7X34wd8tIWtEGinvfHM2OPgyAAfp5ybTLB80lZn4zHY4gHnJsbCObRzF/AmH6WcHNzAvTp9D58gGt45mY9yYonbxqGk5B9IsGUBEhZIiLCCi05I/L2/uLBUnNHLRx1MVRdWHIStgGXliEiJ/7YUFEjlw4QCWUDwS6jbjnrlvNuacP+QD1LLRw1c5QNGZ6MGwSXREavAKc24CyahAAf4I7XWaFgpUQiDfC4eBHk4j8BpZIokDlsqsIIqHJptA+lFlVSwKqocnMC9HeT/yuNt+Krtbi+U5VgNv0X4QLzPr4Il730Z7qfe80cN419SDlKsqL4WZXeFx+++vCXD/9Ef/i4qfCB/k/x/61d39q1h84CV1AGI0zpHHmdbyoh21dw8fa/co37spZ6o4xnW6F12ZQCa8ZOAtKWKayLHDA1SaHNlUsyMh3VOtVPuesD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dcSLxKFFFeJnPBFUMoCr6PTpNxBN53wJqs3bOVnVFUfIDsIfShQ8JO/gf+wy1Z","not_done":["All 12 settings met the mean_diff + 3*se < 0 early-stop rule; the least negative was still run on report seeds.","No Solidity port, gas measurement, engine evaluation or leaderboard submission. The chosen replica mechanism loses to both LEAN and AGE."]}
