# wavg-fees: two-part posterior fee averaging Credit: Taylor (gtmcknight) for the Gaussian filter, solved tables, and replica; qt1's reference and qm-spline decoding are retained from [Q](https://api.imdnotdead.fun/artifacts/8a6e303b662e1a5ea9bb47f31acedd3988ef65b3ddb66d074517aa59ad41ca40). ## Design Changed only quoting when `dt >= 1` and `0.005 < pi < 0.995`. Each hypothetical branch starts from the rival estimate before the callback's clip. Arb: clip rival around `exp(lp)`, phase 0, sd 0. Retail: clip around `exp(mt)`, apply qt1's directional rival update using the incoming fee, phase 1, sd `sqrt(vt)`; select the synced table exactly when that update replaces the estimate. Convert each branch's offsets to fees through the unchanged `lookup`, then return the per-side convex combination `pi * fee_arb + (1-pi) * fee_ret`. No constants tuned. No collapsed lookup runs on this path. Temporary table selection is restored before qt1's original state update. The mixture mean/variance, rival estimate, synced flag, count and timestamp follow qt1's original equations. Outgoing fees become the weighted fees; subsequent trajectories naturally differ. Other callback paths use the original lookup. `new_path_calls` is diagnostic only. The filter and table semantics come from [Taylor's pinned description](https://raw.githubusercontent.com/gtmcknight/amm-sim/4812a6382311624e1506aca131ca35c378f930d9/research/solved/README.md) and [Q](https://api.imdnotdead.fun/artifacts/8a6e303b662e1a5ea9bb47f31acedd3988ef65b3ddb66d074517aa59ad41ca40). ## Screen Observed paired gain: **+0.278205 edge, SE 0.021560**, across all 512 requested seeds. Full requested screen, not a partial prefix. Every seed 60000..60511 was evaluated exactly once per policy with `multiprocessing.Pool(4)`, `python3 -I`, stdlib only, default 10,000-step [replica runs](https://raw.githubusercontent.com/gtmcknight/amm-sim/4812a6382311624e1506aca131ca35c378f930d9/research/solved/replica2.py). Pilot 60000..60015 was retained, then 60016..60263 and 60264..60511 appended. Paired differences are variant minus base. SE uses sample SD (`n-1`) divided by `sqrt(n)`. The five lowest observed differences are listed, including their seeds. Counts are the variant's own trajectory. One paired lookup returns both bid and ask, including interpolation between two sd levels. ```json { "variant": "wavg-fees", "base": "qt1-ref", "seeds": { "first": 60000, "last": 60511, "inclusive": true }, "n": 512, "mean_diff": 0.27820510575416324, "se": 0.021560114887340238, "worst5": [ [ 60496, -1.8162365453899838 ], [ 60210, -1.3556876186893305 ], [ 60128, -1.3042045648450085 ], [ 60144, -1.1196900546161714 ], [ 60199, -1.091086605867531 ] ], "mean_edge_variant": 529.5541111712446, "mean_edge_base": 529.2759060654904, "new_path_calls_per_run": 5824.8046875, "lookups_per_first_trade": { "mixture_paired_bid_ask": 2, "other_paired_bid_ask": 1, "mixture_scalar_sides": 4, "other_scalar_sides": 2 } } ``` Local timing: pilot 12.368677 s; remaining chunks 59.063380 and 58.425196 s. Pilot extrapolation was 395.798 s for 512 pairs, below 40 minutes. Each command stayed below 8 minutes. Gate P ran before modifying the reference and reproduced all printed digits of [Taylor's gates](https://raw.githubusercontent.com/gtmcknight/amm-sim/4812a6382311624e1506aca131ca35c378f930d9/research/solved/gates.py): ```text seed perfect-info gaussian+plain gaussian+qm lattice+qm 10000 448.261189 443.455598 443.522608 443.663520 10001 576.779199 571.463409 571.623551 571.977293 10002 531.886497 525.168028 525.865859 526.411631 ``` Extracted qt1 reference independently reproduced 443.1017411146794 / 571.454483381923 / 525.908441161234 on seeds 10000..10002, agreeing with [Q's checks](https://api.imdnotdead.fun/artifacts/8a6e303b662e1a5ea9bb47f31acedd3988ef65b3ddb66d074517aa59ad41ca40) to six decimals. Locally verified Q's extracted Solidity SHA-256 `c68887cff61180e12ba2b1ceb333edf76a830f91f63b5d775a8806fb9ec08aca` and [blob](https://api.imdnotdead.fun/artifacts/17d249ab0c33fc44931d9b105cf3f9e3846a560bd518b67310c2a56defacdecc) length 10,167 / SHA-256 `3ac7cb8811ecfb6a17f499aa4e9b70dd55f7fb6432b3aec3b904e11a3dece38e`. Same-input callback checks on three baseline replica trajectories: 31,521 callbacks, including 17,015 mixture callbacks; all checks passed. For each callback a shadow variant starts with exactly qt1's incoming state; the test asserts exact equality of updated `m,v,tlast,cnt,s2h,sp,synced`, exact returned-fee equality on every unchanged path, finite returned fees and bounded stored fees. This verifies callback-local preservation, not equal states across different policy trajectories. ## Code Complete `scratch/mix.py` (temporary work lived under the permitted `test/scratch/scratch/`). Save this block as `mix.py` alongside the decoded `blob.bin` from [Data](https://api.imdnotdead.fun/artifacts/17d249ab0c33fc44931d9b105cf3f9e3846a560bd518b67310c2a56defacdecc), then use `replica2.run(seed, mix.QMRef('blob.bin'))` with the pinned replica. No installed dependencies were needed. ```python """wavg-fees variant of qt1; credit Taylor (gtmcknight). qt1 reference: Taylor's (gtmcknight) Gaussian filter (as port-3's standalone.Coarse / trim-2) + real.py's qm fee rule over the DECODED qm-spline tables (QMS1 blob, sha256 3ac7cb88...). Standard library only. usage: from qmref import QMRef; QMRef('blob.bin') is a replica2 policy (wants_j). Init fees = real.py's init: the full plain pol_mid table at (0,0,0) = 0.002823606104386589 each. """ import math, struct SIG2 = .000945 ** 2 LD_M, LD_S = math.log(11.12e-4), 1.176 INIT = 0.002823606104386589 MAXF = 0.1 def phi(x): return math.exp(-.5 * x * x) / 2.5066282746310002 def Phi(x): return .5 * (1 + math.erf(x / 1.4142135623730951)) def trunc(m, v, lo, hi): if v <= 0: return float(lo <= m <= hi), m, 0. sd = math.sqrt(v); a = (lo - m) / sd; b = (hi - m) / sd; z = Phi(b) - Phi(a) if z < 1e-12: return z, lo if m < lo else hi, v * .25 pa, pb = phi(a), phi(b); r = (pa - pb) / z return z, m + sd * r, max(0, v * (1 + (a * pa - b * pb) / z - r * r)) def parse(blob): o = [0] def rd(fmt): v = struct.unpack_from('<' + fmt, blob, o[0]); o[0] += struct.calcsize('<' + fmt); return v assert blob[:4] == b'QMS1'; o[0] = 4 form, ntab, nw, w0, h, ns = rd('BBHHBB'); assert form == 3 S = list(rd('%dB' % ns)); n2 = rd('B')[0]; W2L = list(rd('%dh' % n2)); fb = rd('B')[0] tabs = [] for _ in range(ntab): nr, nc, nk = rd('BBB') kr = list(rd('%dH' % (nr - 4))); kc = list(rd('%dH' % (nc - 4))); ks = list(rd('%dH' % (nk - 4))) assert nk == 4 and not ks tabs.append([nr, nc, nk, kr, kc]) for t in tabs: t.append(list(rd('%dh' % (t[0] * t[1] * t[2])))) assert o[0] == len(blob) return dict(NW=nw, W0=w0, H=float(h), S=[float(s) for s in S], W2L=[float(v) for v in W2L], FB=fb, tabs=tabs) def basis(knots, x): """all cubic B-spline basis values at x (Cox-de Boor recursion), right end included""" t = knots; n = len(t) - 4 B = [1.0 if t[m] <= x < t[m + 1] else 0.0 for m in range(len(t) - 1)] if x >= t[-1]: last = max(m for m in range(len(t) - 1) if t[m] < t[m + 1]); B = [0.0] * (len(t) - 1); B[last] = 1.0 for d in range(1, 4): Bn = [0.0] * (len(t) - 1 - d) for m in range(len(t) - 1 - d): a = t[m + d] - t[m]; b = t[m + d + 1] - t[m + 1] if a > 0: Bn[m] += (x - t[m]) / a * B[m] if b > 0: Bn[m] += (t[m + d + 1] - x) / b * B[m + 1] B = Bn return B[:n] def surfaces(P): """F[t][level][row][col] = max(0, spline) at the grid nodes, in bps""" out = [] for ti, (nr, nc, nk, kr, kc, C) in enumerate(P['tabs']): ncol = 2 * P['FB'] + 1 if ti == 0 else len(P['W2L']) Kr = [0.0] * 4 + [v / 64 for v in kr] + [P['NW'] - 1.0] * 4 Kc = [0.0] * 4 + [v / 64 for v in kc] + [ncol - 1.0] * 4 Ks = [0.0] * 4 + [len(P['S']) - 1.0] * 4 Br = [basis(Kr, i) for i in range(P['NW'])]; Bc = [basis(Kc, j) for j in range(ncol)] Bs = [basis(Ks, l) for l in range(len(P['S']))] F = [] for l in range(len(P['S'])): D = [[sum(Bs[l][s] * C[(s * nr + r) * nc + c] for s in range(nk)) / 8.0 for c in range(nc)] for r in range(nr)] E = [[sum(D[r][c] * Bc[j][c] for c in range(nc)) for j in range(ncol)] for r in range(nr)] F.append([[max(0.0, sum(Br[i][r] * E[r][j] for r in range(nr))) for j in range(ncol)] for i in range(P['NW'])]) out.append(F) return out class Tables: """A/B exactly as qms_decode.to_qm writes them (rounded to 6 decimals)""" def __init__(self, blob): P = parse(blob); self.P = P NW = P['NW']; w = [(i - P['W0']) * P['H'] for i in range(NW)] self.A = {}; self.B = {} for tag, F in zip(['0c', '1s', '1c', '2s', '2c'], surfaces(P)): A = [[[round(F[l][i][j] + w[i], 6) for j in range(len(F[l][i]))] for i in range(NW)] for l in range(len(F))] self.A[tag] = A self.B[tag] = [[row[::-1] for row in A[l][::-1]] for l in range(len(A))] class QMRef: wants_j = True _cache = {} def __init__(self, blob_path): if blob_path not in QMRef._cache: QMRef._cache[blob_path] = Tables(open(blob_path, 'rb').read()) self.T = QMRef._cache[blob_path]; P = self.T.P self.S = P['S']; self.W0 = P['W0']; self.NW = P['NW']; self.h = P['H']; self.FB = P['FB']; self.W2L = P['W2L'] self.m = math.log(100); self.v = 0.; self.tlast = 0; self.cnt = 0; self.s2h = 100.; self.fb = self.fa = .003 self.sp = 100.; self.synced = False; self.new_path_calls = 0 def _pos2(self, v): W = self.W2L; n = len(W) if v <= W[0]: return 0.0 if v >= W[n - 1]: return float(n - 1) lo, hi = 0, n - 1 while hi - lo > 1: mid = (lo + hi) // 2 if W[mid] <= v: lo = mid else: hi = mid return lo + (v - W[lo]) / (W[hi] - W[lo]) def lookup(self, w, w2, phs, sd): # real.py RealPolicy.lookup S = self.S; k = 0 while k < len(S) - 2 and sd >= S[k + 1]: k += 1 tt = min(1.0, max(0.0, (sd - S[k]) / (S[k + 1] - S[k]))) tag = '0c' if phs == 0 else (str(phs) + ('s' if self.synced else 'c')) A, B = self.T.A[tag], self.T.B[tag] pw = min(self.NW - 1.0, max(0.0, w / self.h + self.W0)) l2 = w2 / self.h if phs == 0: l2 = min(self.FB, max(-self.FB, l2)); p2 = l2 + self.FB; n2 = 2 * self.FB + 1 else: p2 = self._pos2(l2); n2 = len(self.W2L) i = min(int(pw), self.NW - 2); j = min(int(p2), n2 - 2); f = pw - i; g = p2 - j def bl(Tb): return (Tb[i][j] * (1 - f) + Tb[i + 1][j] * f) * (1 - g) + (Tb[i][j + 1] * (1 - f) + Tb[i + 1][j + 1] * f) * g a = bl(A[k]) * (1 - tt) + bl(A[k + 1]) * tt b = bl(B[k]) * (1 - tt) + bl(B[k + 1]) * tt fa = 1.0 - math.exp(-(a - w) * 1e-4) if a > w else 0.0 fb = 1.0 - math.exp(-(b + w) * 1e-4) if b > -w else 0.0 return fb, fa def init(self, *args): self.fb = self.fa = INIT; return INIT, INIT def on_trade(self, is_buy, ax, ay, t, x, y, arb=False, p=100., s2=100., j=0): s = y / x; dt = t - self.tlast; is_arb = False mix_fees = None if dt >= 1: self.cnt = 0; lo = math.log(self.sp * (1 - self.fb)); hi = math.log(self.sp / (1 - self.fa)); m, v = self.m, self.v for _ in range(min(dt - 1, 12)): v += SIG2; _, m, v = trunc(m, v, lo, hi) v += SIG2 lp = math.log(s * (1 - self.fb)) if is_buy else math.log(s / (1 - self.fa)); sd = math.sqrt(v) la = phi((lp - m) / sd) / sd; Z, mt, vt = trunc(m, v, lo, hi); d = max(abs(math.log(s / self.sp)), 1e-9) lr = Z * .26 * phi((math.log(d) - LD_M) / LD_S) / (d * LD_S) pi = la / (la + lr) if la + lr > 0 else 0.; is_arb = pi > .5 if .005 < pi < .995: # Hypothetical branches affect quotes only, never the carried filter/rival. old_synced = self.synced pa = math.exp(lp) ra = max(pa * .997, min(pa / .997, self.s2h)) self.synced = False fba, faa = self.lookup((math.log(s) - lp) * 1e4, (math.log(ra) - lp) * 1e4, 0, 0.) pr = math.exp(mt) rr = max(pr * .997, min(pr / .997, self.s2h)) cand = s * (1 - self.fb) / .997 if is_buy else s * .997 / (1 - self.fa) if (cand < rr) if is_buy else (cand > rr): rr = cand; self.synced = True fbr, far = self.lookup((math.log(s) - mt) * 1e4, (math.log(rr) - mt) * 1e4, 1, math.sqrt(vt) * 1e4) self.synced = old_synced mix_fees = (pi * fba + (1 - pi) * fbr, pi * faa + (1 - pi) * far) self.new_path_calls += 1 m2 = pi * lp + (1 - pi) * mt; self.m, self.v = m2, pi * (lp - m2) ** 2 + (1 - pi) * (vt + (mt - m2) ** 2) elif is_arb: self.m, self.v = lp, 0. else: self.m, self.v = mt, vt pe = math.exp(self.m); self.s2h = max(pe * .997, min(pe / .997, self.s2h)); self.synced = False if not is_arb: cand = s * (1 - self.fb) / .997 if is_buy else s * .997 / (1 - self.fa) if (cand < self.s2h) if is_buy else (cand > self.s2h): self.s2h = cand; self.synced = True self.cnt += 1; ph = 1 if self.cnt == 1 else 2 else: ph = 0 self.tlast = t; self.sp = s if mix_fees is None: fb, fa = self.lookup((math.log(s) - self.m) * 1e4, (math.log(self.s2h) - self.m) * 1e4, ph, math.sqrt(self.v) * 1e4) else: fb, fa = mix_fees self.fb, self.fa = min(MAXF, max(0.0, fb)), min(MAXF, max(0.0, fa)) return fb, fa ``` ## Commands All shell commands were issued from the repository root; file writes via shell heredocs are specified below with their complete helper contents. No engine setup or engine commands were needed for this bounded Python-reference item. Tool polling only retrieved command completion. Web tool opens also checked the three URLs Q, Data, and the pinned raw README; Q and Data returned web-tool errors but succeeded via curl. ````sh mkdir -p test/scratch/scratch artifacts/goal/batches/e1-lead-mix/items/mix-wavg-fees curl -fLsS https://api.imdnotdead.fun/artifacts/8a6e303b662e1a5ea9bb47f31acedd3988ef65b3ddb66d074517aa59ad41ca40 -o test/scratch/scratch/q.md curl -fLsS https://api.imdnotdead.fun/artifacts/17d249ab0c33fc44931d9b105cf3f9e3846a560bd518b67310c2a56defacdecc -o test/scratch/scratch/data.md git clone https://github.com/gtmcknight/amm-sim test/scratch/taylor git -C test/scratch/taylor checkout 4812a6382311624e1506aca131ca35c378f930d9 cat test/scratch/taylor/research/solved/README.md rg -n '^##|sha256|```' test/scratch/scratch/q.md test/scratch/scratch/data.md rg --files test/scratch/taylor/research/solved sed -n '350,515p' test/scratch/scratch/q.md cat test/scratch/taylor/research/solved/gates.py sed -n '1,100p' test/scratch/taylor/research/solved/real.py python3 -I test/scratch/taylor/research/solved/gates.py sed -n '1,65p' test/scratch/taylor/research/solved/replica2.py sed -n '31,44p' test/scratch/scratch/q.md # cat > test/scratch/scratch/extract.py <<'PY' (contents below) python3 -I test/scratch/scratch/extract.py # cat > test/scratch/scratch/build.py <<'PY' (contents below) python3 -I test/scratch/scratch/build.py # cat > test/scratch/scratch/screen.py <<'PY' (contents below) python3 -I test/scratch/scratch/screen.py baseline python3 -I test/scratch/scratch/screen.py pilot 60000 60016 sed -n '143,205p' test/scratch/scratch/mix.py git status --short git diff --stat rg -n 'def on_trade|mix_fees|new_path_calls' test/scratch/scratch/mix.py python3 -I test/scratch/scratch/screen.py chunk1 60016 60264 # cat > test/scratch/scratch/check.py <<'PY' (final contents below) python3 -I test/scratch/scratch/check.py # python3 -I - <<'PY': corrected the check assertion as documented in Problems python3 -I test/scratch/scratch/check.py python3 -I test/scratch/scratch/screen.py chunk2 60264 60512 # cat > test/scratch/scratch/check-result.txt <<'EOF': saved the reported successful callback check counts # cat > test/scratch/scratch/report.py <<'PY': assembled this report and sources from measured rows # python3 -I - <<'PY': adjusted report shell fencing and restored the original rg command text python3 -I test/scratch/scratch/report.py # python3 -I - <<'PY': final JSON, byte-size, code and source-quote checks as documented below # git status --short # python3 -I - <<'PY': added the observed screen conclusion; checked final outputs remain untracked ```` The script creation commands used `cat > test/scratch/scratch/NAME <<'PY'`, the following contents, and terminating `PY`: ### extract.py ```python from pathlib import Path import re,base64,hashlib p=Path(__file__).resolve().parent q=(p/'q.md').read_text() sol=q.split('```solidity\n')[1].split('```')[0] assert hashlib.sha256(sol.encode()).hexdigest()=='c68887cff61180e12ba2b1ceb333edf76a830f91f63b5d775a8806fb9ec08aca' ref=q.split('## Python reference')[1].split('```python\n')[1].split('```')[0] (p/'qmref.py').write_text(ref) b=base64.b64decode((p/'data.md').read_text().split('## Data:')[1].split('```')[1]) assert len(b)==10167 assert hashlib.sha256(b).hexdigest()=='3ac7cb8811ecfb6a17f499aa4e9b70dd55f7fb6432b3aec3b904e11a3dece38e' (p/'blob.bin').write_bytes(b) print('Verified Solidity and blob hashes; extracted reference.') ``` ### build.py ```python from pathlib import Path p=Path(__file__).resolve().parent s=(p/'qmref.py').read_text() s=s.replace('"""qt1 reference:', '"""wavg-fees variant of qt1; credit Taylor (gtmcknight).\nqt1 reference:',1) s=s.replace('self.sp = 100.; self.synced = False','self.sp = 100.; self.synced = False; self.new_path_calls = 0') s=s.replace('s = y / x; dt = t - self.tlast; is_arb = False','s = y / x; dt = t - self.tlast; is_arb = False\n mix_fees = None') s=s.replace(' if .005 < pi < .995:\n', ''' if .005 < pi < .995: # Hypothetical branches affect quotes only, never the carried filter/rival. old_synced = self.synced pa = math.exp(lp) ra = max(pa * .997, min(pa / .997, self.s2h)) self.synced = False fba, faa = self.lookup((math.log(s) - lp) * 1e4, (math.log(ra) - lp) * 1e4, 0, 0.) pr = math.exp(mt) rr = max(pr * .997, min(pr / .997, self.s2h)) cand = s * (1 - self.fb) / .997 if is_buy else s * .997 / (1 - self.fa) if (cand < rr) if is_buy else (cand > rr): rr = cand; self.synced = True fbr, far = self.lookup((math.log(s) - mt) * 1e4, (math.log(rr) - mt) * 1e4, 1, math.sqrt(vt) * 1e4) self.synced = old_synced mix_fees = (pi * fba + (1 - pi) * fbr, pi * faa + (1 - pi) * far) self.new_path_calls += 1 ''') old=' fb, fa = self.lookup((math.log(s) - self.m) * 1e4, (math.log(self.s2h) - self.m) * 1e4, ph, math.sqrt(self.v) * 1e4)' s=s.replace(old,' if mix_fees is None:\n '+old+'\n else:\n fb, fa = mix_fees') (p/'mix.py').write_text(s) ``` ### screen.py ```python """Paired stdlib replica screen; Taylor (gtmcknight) supplies replica and qt1 base.""" import sys, os, json, time, math, statistics from pathlib import Path from multiprocessing import Pool HERE=Path(__file__).resolve().parent sys.path.insert(0,str(HERE)) sys.path.insert(0,str(HERE.parent/'taylor/research/solved')) import replica2 import qmref, mix BLOB=str(HERE/'blob.bin') def init(): qmref.QMRef(BLOB); mix.QMRef(BLOB) def pair(seed): base=replica2.run(seed,qmref.QMRef(BLOB))['edge'] policy=mix.QMRef(BLOB) variant=replica2.run(seed,policy)['edge'] return [seed,variant-base,variant,base,policy.new_path_calls] if __name__=='__main__': mode=sys.argv[1] if mode=='baseline': init() values=[replica2.run(seed,qmref.QMRef(BLOB))['edge'] for seed in range(10000,10003)] assert [round(v,6) for v in values]==[443.101741,571.454483,525.908441] print(json.dumps(values),flush=True) else: start,end=map(int,sys.argv[2:4]); t=time.monotonic() # Four workers avoids dependence on a large reported virtual CPU count. with Pool(4,initializer=init) as pool: rows=list(pool.imap(pair,range(start,end))) elapsed=time.monotonic()-t (HERE/(mode+'.json')).write_text(json.dumps({'seconds':elapsed,'rows':rows})) d=[r[1] for r in rows]; n=len(d) result=dict(variant='wavg-fees',base='qt1-ref',seeds=[start,end-1],n=n, mean_diff=statistics.mean(d),se=statistics.stdev(d)/math.sqrt(n), worst5=[[r[0],r[1]] for r in sorted(rows,key=lambda r:r[1])[:5]], mean_edge_variant=statistics.mean(r[2] for r in rows), mean_edge_base=statistics.mean(r[3] for r in rows), new_path_calls_per_run=statistics.mean(r[4] for r in rows), lookups_per_first_trade={'mixture':2,'other':1}) (HERE/(mode+'-summary.json')).write_text(json.dumps(result,indent=2)) print(json.dumps({'seconds':elapsed,'result':result}),flush=True) ``` ### check.py ```python """Same-input callback checks; credit Taylor (gtmcknight) for baseline and replica.""" import sys, math from pathlib import Path H=Path(__file__).resolve().parent sys.path.insert(0,str(H));sys.path.insert(0,str(H.parent/'taylor/research/solved')) import qmref,mix,replica2 class Check(qmref.QMRef): calls=0; changed=0 def on_trade(self,*args,**kwargs): other=mix.QMRef(str(H/'blob.bin')) other.__dict__.update(self.__dict__); other.new_path_calls=0 a=super().on_trade(*args,**kwargs) b=other.on_trade(*args,**kwargs) for key in ('m','v','tlast','cnt','s2h','sp','synced'): assert self.__dict__[key]==other.__dict__[key],key assert all(math.isfinite(f) for f in b) assert 0 <= other.fb <= .1 and 0 <= other.fa <= .1 if not other.new_path_calls: assert a==b,(a,b) Check.calls+=1;Check.changed+=other.new_path_calls return a for seed in range(10000,10003): replica2.run(seed,Check(str(H/'blob.bin'))) print({'callbacks':Check.calls,'mixture_callbacks':Check.changed,'checks':'state equality; unchanged-path exact fee equality; finite returned fees; bounded stored fees'}) ``` ## Problems The first callback test incorrectly required raw returned fees to be at most 10%; it failed. qt1 returns raw fees while clamping its stored fees, and the replica clamps returns. The check was repaired to assert finite returns and bounded stored fees. Policy code and screened constants were not changed. No screen seed was rerun. This item is a replica screen only. No holdout 10000..12047 score, Solidity port, contract/reference parity Gate F, engine scores, deployed size or gas measurements were performed. The broader goal's engine/contract acceptance remains unestablished. Replica edge cannot be reported as a board score ([Taylor](https://raw.githubusercontent.com/gtmcknight/amm-sim/4812a6382311624e1506aca131ca35c378f930d9/research/solved/README.md)). The supplied blob remains a required external input from the cited artifact; the complete policy is embedded above. No network access is required once the pinned replica and blob are present. Final local verification parses `sources.json`, checks every quote against its downloaded source text, parses the embedded Python, confirms contiguous unique 512 paired seeds and finite summary values, and enforces the 48,000-byte report cap. Only the two named output files are delivered; temporary scripts and measurements are not submitted.