# Root merge 3: Gaussian/plain confirmation, qm ports, gas repair and posterior quoting This is a synthesis of the 17 supplied results, not a new contract implementation or a new engine run. **The unchanged qm-2 is disqualified by observed OutOfGas callbacks and peaks above 245,000. qt1 and qtr2 are promising distinct repairs/ports with measured gas headroom; qtr2 has no direct t03 comparison in this input set.** The plain port-2 confirmations remain positive against t03. P/Q/F evidence must be attached to the precise implementation, and the qm ports' F claims require the applied-fee qualification below. These conclusions follow from the item-level measurements retained below, not from validator success alone. ## Scope, provenance and evidence strength The requester's goal figures are context, not new measurements here: Taylor's replica Gaussian + plain +2.83 vs HA; qm +3.77; lattice + qm +4.26; t03 about +1.45. The task requires `contract Strategy is AMMStrategyBase`, Taylor (gtmcknight) credit, runtime ≤24,576 bytes, engine afterSwap peak ≤245,000 and zero OutOfGas; P before changes, Q choose 60000..61023/report 10000..12047, and F within 0.01 bps on 50×2,000 replica callbacks. Replica gains against HA are not real-engine gains against t03. All 17 inputs were present and nonempty. Source labels below mean the supplied result itself: its worker's local observations are retained as reported, not independently reproduced. The manifest gives its original artifact path and SHA-256. Linked upstream artifacts identify implementation ancestry; they do not independently verify local measurements. No source sidecars or archived scratch records were supplied here. Complete Solidity, Python, CSV and per-chunk material in the input reports is deliberately condensed rather than silently treated as delivered executable code. The retained tables preserve paired scores, SEs, extremes, aggregate gas and coverage; repeated setup prose and granular chunk records are compressed into the common method and caveats. The requester explicitly flags failed source rechecks for the following inputs (number of sources): pb2 1; pb4 2; p3-b3 2; spl-128 1; qm-1 2; qm-2 2; qt1 2; qa1 1; qa2 2; qa4 1; qb1 1; qb2 3; qb3 1; qb4 1; qtr2 2; pb1r 1. No such flag was supplied for ar3. Which precise URL/passage failed is not provided. Consequently all affected upstream provenance/quoted-source assertions remain qualified; none is promoted to a verified fact merely because another report repeats it. Their internally supplied scores and gas observations remain evidence attributed to the reporting worker, with no independent certification. ar3's absence from that list does not constitute independent certification either. ## Reconciliation and decision implications - **Plain ports:** pb1r, pb2 and pb4 score the same port-2 source hash, on disjoint seed blocks, and each reports a positive mean against t03 with no callback failures. p3-b3 is a different coarse contract; its smaller +0.634034204 gain and lower gas do not contradict port-2. spl-128 is another source, with +1.277814626 vs t03. Those confirmations do not rerun P/Q/F. (Sources: b27-pb1r, b20-pb2, b20-pb4, b21-p3-b3, b21-spl-128.) - **qm-2:** the initial 128-seed run already reports a 245,140 successful-call peak, exceeding the requested ceiling by 140 despite zero OOG. Later qa/qb samples retain positive edges but each supplied block has OOG. Engine acceptance of a callback above 245,000 does not waive the goal's stated ceiling. The initial report's suggestion of a gas-accounting scale difference, and qb3's inference of a higher engine cap, are hypotheses, not proof of the engine's exact limit. The qm-2 narrative also says '29,000 more' than t03, but its published peaks differ by 9,684 (245,140−235,456); 29,000 corresponds approximately to its engine/pyrevm discrepancy, not the t03 peak gap. (Sources: b22-qm-2 and b24/b25 confirmations.) - **Independent qm implementations:** qm-1 uses packed Q23 contraction; qm-2 uses WAD bases and extended-precision lane sums; qt1 moves qm lookup into trim-2's 3-slot shell; qtr2 optimizes qm-2 with scalar accumulators, shared geometry and 4 packed slots. Same tables do not imply same gas or bytecode. qt1's 208,775 and qtr2's 191,661 observed engine peaks give headroom on their own 128-seed blocks, not a global upper bound. qtr2's +0.837560422 is versus trim-1, so it cannot be reported as a measured t03 advantage or combined with another block's trim-1 score. (Sources: b22-qm-1, b22-qm-2, b23-qt1, b26-qtr2.) - **Gate F is qualified:** unchanged Python can return a fee above its stored/pool-applied cap. qm-1, qm-2 and qtr2 explicitly fail a literal raw-Python-return comparison at one callback (70026, index 1702), with about 200.079335847 bps error; they pass against applied fees. qt1's reference clamps fees and its small F error must be read in that same effective-fee sense, not as evidence that uncapped returns match. qtr2's raw ABI bit identity is between two contracts, not between Solidity and raw Python. A strict reading of the goal's raw fee equality therefore remains unresolved, not an unconditional P/Q/F completion. (Sources: b22-qm-1, b22-qm-2, b23-qt1 reference/code, b26-qtr2.) - **Trace provenance:** qtr2 regenerates a different input digest and slightly different baseline mean gas from qm-2's historical report. It discloses this and establishes same-input contract identity locally; it does not reproduce the historical input bytes. The 316a54… digest coincides with qm-1's reported trace set. Shared maxima and table hashes do not establish identical historical traces. (Sources: b22-qm-1, b22-qm-2, b26-qtr2.) - **Wording corrections:** pb4's 'on all 256 seeds ... beats both' means positive aggregate means, not 256 individual wins (215 vs t03, 241 vs IB). qb2/qb3's 'beats every other arm on these seeds' likewise describes paired means; their own worst-five lists include losses. qb3 claims five chunks above 245,000, but its table has four: 9614944, 9614976, 9615040, 9615072. Preserve the table over that count. pb4 discloses overlapping arm/chunk execution, so its rough timing is not a controlled serial benchmark. (Sources: b20-pb4, b25-qb2, b25-qb3.) - **Setup source disagreement:** pb2/p3-b3/spl-128 and some port reports attribute the eight-line script to port-3; pb4 specifically says that section contains a steps table, not the script, and used port-2's explicit `setup.sh` block. Later confirmations use port-2. Successful local setup reports can be retained, but the script's claimed location in port-3 is disputed and also subject to the source flags. (Sources: corresponding setup sections.) - **Unported research:** ar3 adds posterior-aware plain-table quoting and gains +0.5662 (SE 0.0125) on the replica holdout; no Rust-engine, Solidity, gas, compression-Q or contract-F result accompanies it. It is a follow-up idea, not a shippable improvement over qt1/qtr2 or proof that gains add to qm/lattice. (Source: b28-ar3.) ## Common reported engine protocol Unless specifically qualified, workers report the pinned challenge `6b6921f8d463314aa7c96234e1be25a25245f704`, Linux-compatible checksum-verified `amm_sim_rs-0.1.0.post1` wheel (`aedb68280aca34c110968f00148387c95885207913fb2cf19a1ab4c5cfd6887a`), setup once, and later commands sourcing scratch/env.sh. Compilation: solc 0.8.24, optimizer 200, viaIR, Paris. Every arm is separately matched against fixed 30-bps Vanilla using `run_batch(X, VanillaStrategy, configs, 8)`, not directly against the comparator. Configs use default_rng(assigned seed), drawing size [19,21], rate [0.6,1.0], sigma [0.000882,0.001008] in that order; seed also drives simulation. Baseline is 10,000 steps, price 100, X/Y 100/10,000, mu 0, dt 1, size sigma 1.2, buy probability 0.5. Source links for the reported method: [MatchRunner](https://raw.githubusercontent.com/benedictbrady/amm-challenge/6b6921f8d463314aa7c96234e1be25a25245f704/amm_competition/competition/match.py), [config](https://raw.githubusercontent.com/benedictbrady/amm-challenge/6b6921f8d463314aa7c96234e1be25a25245f704/amm_competition/competition/config.py), [compiler](https://raw.githubusercontent.com/benedictbrady/amm-challenge/6b6921f8d463314aa7c96234e1be25a25245f704/amm_competition/evm/compiler.py), [Vanilla](https://raw.githubusercontent.com/benedictbrady/amm-challenge/6b6921f8d463314aa7c96234e1be25a25245f704/contracts/src/VanillaStrategy.sol). These links are inherited references, not newly fetched here. Scores are submission edge; differences pair the same seed/config, SE is sample SD (ddof=1)/√n. Gas counters reset/read around each 32-seed chunk; only Submission/afterSwap is aggregated unless stated. Peak is max successful-call `max_ok_gas`, not failed-call consumption; mean is total successful gas/total successful calls. Returned scores from chunks with OOG remain included. Chunk counters generally cannot locate individual failing seeds. Timings measure run_batch wall throughput with eight workers, exclude setup/compile/startup and are machine/load dependent. Workers report each assigned seed once per arm, all assigned arms complete and no commands over eight minutes; cross-worker freshness cannot be independently established. No supplied seed blocks overlap each other. Confirmation items do not independently establish P/Q/F. (Sources: all engine items; qa2 expressly limits freshness claims.) ## Candidate identity register All below are worker-reported exact-source SHA-256 and deployed runtime, with validation PASS. t03 and IB come from decoded `code_zb64`; candidate blocks include final LF. Policy credit belongs to Taylor (gtmcknight), pinned amm-sim `4812a6382311624e1506aca131ca35c378f930d9`, research/solved. The contracts report preserving that header credit. | Candidate | Name; runtime bytes | Solidity SHA-256 | Measurement sources | |---|---|---|---| | port-2 | TaylorGaussianPlain2; 18,484 | 7e2d9c157a7725c2875eea31e5741938fb9eafef5a3442710573f1b1a87faf17 | pb2, pb4, pb1r | | port-3 | TaylorGaussianPlainCoarse; 18,466 | 62930b8e68277c69fc1acfba18de781e684d7fc6daac8dc562b8210dc3932ac1 | p3-b3 | | spline-1 | TaylorGaussianPlainSpline; 21,106 | 27ad2a5f3d2b218138a95f8d4ab616227ca7dfd855a9c60577f86fea09c6caed | spl-128 | | qm-1 | TaylorGaussianQmSpline; 20,135 | c96e646d5c76ebcdf1e57aecbfe207b3a0e92e71281ac437eeb3046babb94883 | qm-1 | | qm-2 | TaylorGaussianQmSpline; 19,346 | 50a741b97a7ed79237ecbd34a4bc20b5c70b7872d8916f31dc3fe3f72b4fe859 | qm-2, qa1/qa2/qa4, qb1..qb4 | | qt1 | TaylorGaussianQMSpline; 20,605 | c68887cff61180e12ba2b1ceb333edf76a830f91f63b5d775a8806fb9ec08aca | qt1 | | qtr2 | TaylorGaussianQmTrim2; 19,945 | 7b99afae570ef1627b0163fb21411f14c496b005a07c3966cc7323906dee664f | qtr2 | | trim-1 | TaylorGaussianPlainNet2; 16,077 | d849c5f15d69499560b5c3ea08f55ad27153b393eba7abb7dd186f451ad46a24 | qm-1/qm-2, qa/qb, qtr2 | | trim-2 | 11,680 | 6157028022f7f2151781ea3a772e4a99956ab9c38c8fbabf4995887d05564b27 | qt1 | | t03 | censored_10; 14,654 | cb6d945511e1e10af78baa64c2a6cb25806f0998403ce6440654bfc3c70092d9 | all relevant engine items | | IB | inputs_b; 14,528 | 301941829a44bb60977bb28181a5e4bfa6544f3696763f987054789b2611d686 | all relevant engine items | Input links: [port-2](https://api.imd.fun/artifacts/e8c967d6358da0fd53117891357f19a1d684225bd71a5e302b6e299c85f1286c), [port-3](https://api.imd.fun/artifacts/0dbcc10af41b3c3467ff0d9b9cb64c81328fcf18295f9be06b2d81bb98874067), [spline-1](https://api.imd.fun/artifacts/2e73bea9c6c8fadd34bb31cb788591821df10e601321bbeeb0cba7c4a9d0be8a), [trim-1](https://api.imd.fun/artifacts/fce772b9057867b241350b8e44c05298c6c877871a26b58702a5af431726f6c5), [trim-2](https://api.imd.fun/artifacts/22560aac69c88188ffee4c1dfa7c58685ae83fd4b415fef626ed7258a12e7542), [qm-spline](https://api.imd.fun/artifacts/17d249ab0c33fc44931d9b105cf3f9e3846a560bd518b67310c2a56defacdecc), [t03](https://api.imd.fun/artifacts/2333ecf28d4356bd232b85c1e55842e94e1ada05e1cd067830b5625dfdbc5336), [IB](https://api.imd.fun/artifacts/afd5183e9ff3235334e041c00b0cd19079599a2c6464db95f8c1586712105557). qm-1, qm-2 and qt1 implementation artifacts are the corresponding input hashes in the manifest below. These upstream source attributions inherit the recheck caveat. ## Compression, implementation and gate evidence The qm ports use qm-spline QMS1: 4,896 int16 coefficients (9,792 coefficient bytes), blob 10,167 bytes SHA-256 `3ac7cb8811ecfb6a17f499aa4e9b70dd55f7fb6432b3aec3b904e11a3dece38e`; expanded JSON 10,639,373 bytes SHA-256 `4d97c205783ddff731fecd9dbdaea09c295954d2d2e96fbf25eec1320a5c22fa`. Axes are W0=160/NW=321/N2=49/FB=6/H=5/W2L; sd levels 0,4,8,12,16,20,26,34 bps. Lookup selects 0c or phase/synced 1s/1c/2s/2c, evaluates cubic splines at grid nodes, clamps F≥0 before bilinear and sd interpolation, and uses the point mirror for bids. Init comes from the plain-table center, 0.002823606104386589, not qm. qm-1 encodes 2823606104386590 WAD; qt1 encodes 2823606104386589. Contracts need no installed payload, external table/library, external call or assembly at runtime. (Sources: b22-qm-1, b22-qm-2, b23-qt1, b26-qtr2.) **qm-1:** replaces trim-1 Net2 with 306 PUSH32 coefficient immediates; knots are 1/64 grid units. Keeps Gaussian update, 12 separate silent-step truncations, timing and math/mixture thresholds; sync flag uses bit 256 of cnt, low count saturates at 2. Runtime Cox–de Boor bases use Q23, complementary weights preserve unity, two bases fit in 24-bit fields; coefficients biased by 32768 pack four 64-bit sd lanes, with <2^62 lane bound and 46 fractional contraction bits. Integer Bernstein weights at k/7 sum to 343. Decoder rounds A/B to six decimals; Solidity retains more precision. QMS1 mirror exception and approximation loss are inherited. Its contract-derived decoder reconstructs the expanded JSON byte-identically. No real.py/replica2.py policy formula changed. (Source: b22-qm-1.) **Q, qm-1 rerun:** choose n=1024 full 530.026094510303, decoded 529.971156871193, full−decoded loss 0.054937639110, SE 0.010295841019; report n=2048 full 533.326027337992, decoded 533.262830666503, loss 0.063196671489, SE 0.007194431268. Worst holdout losses: (10522,1.457596829663), (10711,1.359835282954), (12015,1.341616684156), (10268,1.171751677564), (10203,1.091629293394). Frozen profile sizes (24,10,4)/(24,14,4)/(18,12,4)/(24,14,4)/(12,8,4), no new fitting or holdout selection; loss <0.2 target met on this sample. qm-2/qt1 cite inherited loss 0.0632 SE 0.0072, about +3.71 vs HA; not new measurements. qt1's stdlib decoder matches all ten numpy-decoded tables exactly and reproduces compressed-reference check scores 443.101741 / 571.454483 / 525.908441. (Sources: b22-qm-1, b22-qm-2, b23-qt1.) **qm-2:** keeps trim-1 math/filter and eight slots; sync bit is slot 7 bit 0 with count above it. Five fill functions store 321 words with knots and coefficient lanes; WAD Cox–de Boor bases and extended U^3/8 sums divide once, clamp each node then interpolate. Phase-0 R/5 clips at ±6; other phases binary-search W2L. Python integer model matches decoded lookup within 4.8e-7 bps on 3,000 random points. Source 40,606 bytes, creation 19,374, runtime hash `3f522028749a4e88cffc0778411b13adcbf71a9b2e2d811a23972ccea4840991`. pyrevm 190,000 target missed. Lookup ablation on seed 70022 first 1,000 callbacks: no-lookup mean/peak 45,987/95,820 versus production 118,642/191,638 at callback 996; lookup about 72,700 mean/95,800 there. Basis/loop skeleton about 34,000 and lane arithmetic about 76,000 at that peak; alternate accumulators/row sums gave 200,114/205,707 and were rejected. Recommendation to save 25–30k by restructuring loops is a diagnosis, not a delivered optimization. (Source: b22-qm-2.) **qt1:** uses trim-2's three-slot Coarse filter shell and fee conversion; sync bit 255 of slot 2, count masked to 32 bits above bit 192. Encodes 306 coefficient words via 20 small binary-tree dispatch functions, runtime WAD bases and integer Bernstein weights; scalar/fixed-index contraction replaces costly dynamic arrays. A single 306-leaf tree segfaulted solc viaIR at default stack; splitting functions fixed default-stack compilation. Earlier dynamic-array build had pyrevm peak 288,854 (about 72–100k per surface); shipped lookup about 34–43k/surface. Source 42,990 bytes. Forty surface tests (20 grid/20 random) max error 1.9e-11 bps. It retains trim-2 functions byte-identically except initialization constant and adds synced tracking. Reference combines Coarse filter and real.py qm lookup; it is not simply an unchanged real.py source file. Generator and test/engine harnesses were omitted in the item due to its 64KB limit; complete contract/reference were included. (Source: b23-qt1.) **qtr2:** scalarizes eight node sums without changing accumulation/division order; shares mirrored knot scans while preserving original rounded Cox–de Boor order (does not reverse rounded basis weights). Rows are symmetric; column sharing only 1s/2s/2c, since 0c asymmetric and 1c has integer interior knots. Packs eight slots into four: signed mean/unsigned variance 128-bit halves; fees; own/rival spots; timestamp 128 bits/count 127 bits/sync. int256 arithmetic remains. Equivalence assumes packed ranges; arbitrary out-of-domain state is not established. Source comparison reports identical mul/divi/ab/clip/ln/exp/root/pdf/cdf/trunc/truncSD/update/bl/pos2/w2l/S and all five table-fill bodies, no table/filter-step changes or combined silent steps. On old peak trace, scalar/geometry changes reduce 215,414→206,649; packing to 166,183, while suite peak moves to seed 70002/index 587 at 173,599. (Source: b26-qtr2.) **F evidence (all 70000..70049, first 2,000 own callbacks/run):** fresh deployments initialize 100/10,000, amounts/reserves int(float×1e18), gas 245,000/call; 200,000 fee comparisons. qm-1: max applied error 0.000988148793866495 bps, mean 2.53279836910865e-05; init 8.673617379884035e-15; 100,000 successes, no failures, peak/mean gas 186205/94774.55865000, sum 9477455865. Peak seed 70016/index 911, max error seed 70012. Raw mean error 0.00102572466292363; one raw error 200.079335846508. Instrumented ask+bid lookup gas at w=R=0: phase0/sd0 72890; 1s/sd4 82153; 1c/sd12 74802; 2s/sd20 82321; 2c/sd34 73321 (ABI/table init/conversion included, filter/storage excluded; wrapper +39 runtime bytes). (Source: b22-qm-1.) qm-2 F: max/mean applied error 5.826114e-06/1.689195e-07 bps, init 0, all 100,000 callbacks succeed; peak 215414 at 70016/index911, mean 118244.01706; raw max 200.0793 bps. qt1 F: max/mean 5.826e-06/1.689e-07 bps, init 0; 100,050 calls including initializations succeed; peak 194051 (70032), mean 124776.9, per-run peaks 157420..194051, ≤200000 target met. qtr2 vs locally replayed qm-2: 0/100000 callbacks differ in raw returned 64-byte payloads; both 100000 succeed, init identical; qtr2 mean109292.64352 vs baseline118243.96559; peak173599 vs215414, reduction41815. Both applied errors5.8261143826e-06, raw Python errors200.079335847. Single clip is Python bid0.12000793358465078 vs contract0.1 at 70026/index1702. Thus literal raw reference F fails; applied-fee F passes. (Sources: b22-qm-2, b23-qt1, b26-qtr2.) Trace SHA-256: qm-1 inputs `316a54e2e52ff8373bc5a61ea353c24db71bc1a1cabc2e69898352acfd6f0f4d`; qm-2 historical `fe975d4705b71425c0ab0a20acd2bc164dafd455f5b64f89d0df0b4b71f4dc1e`; qt1 `66c1d374a625da5ece27dbe777beff17320fa124ff195d8da2dbf8fa46a5a7dc`; qtr2 regenerated inputs same316a54…, identical qtr2/qm-2 returned-fee digest `5da30a8850396a3077855ea28a0303d3651dfc0abe1c9d1bcc7210f3ef3b98cf`. Input sets hash concatenated seed-ordered compact-JSON per-run hex digests; returned-fee digest hashes per-run concatenated raw64-byte callback returns, excluding initialization. No archived historical input bytes provided to qtr2. (Sources: respective reports.) ### P reproduction and Q interpretation qm-1, qm-2, qt1 and qtr2 report unmodified gates.py before edits. The three seed rows (10000/10001/10002) are Gaussian plain 443.455598 / 571.463409 / 525.168028; Gaussian qm 443.522608 / 571.623551 / 525.865859; lattice qm 443.663520 / 571.977293 / 526.411631; perfect information 448.261189 / 576.779199 / 531.886497. ar3 also reports reproducing all four columns. (Sources: b22-qm-1, b22-qm-2, b23-qt1, b26-qtr2, b28-ar3.) Only qm-1 in this group independently reruns the complete choose/report Q scoring. qm-2, qt1 and qtr2 inherit qm-spline's Q result through identical decoded tables; table identity supports reuse but is not a fresh paired experiment. qt1 additionally changes the reference filter ancestry to Coarse and gives three check values; three seeds alone do not independently establish 2,048-seed Q equivalence. No plain-port P/Q/F recheck is supplied by these confirmation items. ## Real-engine measurements by source The following excerpts retain the reporting worker’s figures; first-person statements refer to that worker. Seed ranges are supplied in each source label below. General caveats above apply to every excerpt. ### Source b20-pb2 — seeds 9610496..9610751 #### Paired scores | Pair | n | mean_diff | se | Candidate mean | Comparator mean | |---|---:|---:|---:|---:|---:| | Candidate − t03 | 256 | 1.243568224 | 0.137356640 | 528.872438816 | 527.628870592 | | Candidate − IB | 256 | 2.019434259 | 0.135048537 | 528.872438816 | 526.853004556 | Candidate − t03: | Rank | Worst (seed, diff) | Best (seed, diff) | |---:|---|---| | 1 | (9610732, -2.563646496) | (9610561, 28.032542105) | | 2 | (9610622, -2.012068806) | (9610684, 5.182176343) | | 3 | (9610633, -1.871396420) | (9610715, 4.842776591) | | 4 | (9610722, -1.756881210) | (9610575, 4.727131619) | | 5 | (9610618, -1.523515251) | (9610638, 4.542092219) | Candidate − IB: | Rank | Worst (seed, diff) | Best (seed, diff) | |---:|---|---| | 1 | (9610732, -2.305052459) | (9610561, 27.132271960) | | 2 | (9610701, -1.642944739) | (9610677, 6.182409272) | | 3 | (9610593, -1.051324896) | (9610684, 5.873600737) | | 4 | (9610722, -1.049180613) | (9610575, 5.777347379) | | 5 | (9610618, -0.946340084) | (9610638, 5.528871933) | #### afterSwap gas | Arm | Calls | Successful | OutOfGas | Reverts | Peak gas | Mean successful gas | |---|---:|---:|---:|---:|---:|---:| | candidate | 2758920 | 2758920 | 0 | 0 | 226059 | 126655.656803024 | | t03 | 2777786 | 2777786 | 0 | 0 | 238235 | 135563.449946108 | | IB | 2755846 | 2755846 | 0 | 0 | 237651 | 135233.182994260 | All afterSwap OutOfGas, revert, other_halt, tx_error, and bad_return counters were zero in every arm/chunk. Candidate peak stayed below 245,000 gas. #### Timing and coverage | Arm | Seeds completed | Engine seconds | Seconds per seed | Minimum chunk seconds | Maximum chunk seconds | |---|---:|---:|---:|---:|---:| | candidate | 256 | 132.460287 | 0.517422995 | 16.245049 | 17.124210 | | t03 | 256 | 94.524294 | 0.369235524 | 11.353690 | 12.777290 | | IB | 256 | 92.452210 | 0.361141446 | 11.083161 | 12.628665 | Seeds not run (candidate): **none** (0). Seeds not run (t03): **none** (0). Seeds not run (IB): **none** (0). ### Source b20-pb4 — seeds 9611008..9611263 #### (2) Paired results (n = 256, seeds 9611008..9611263) | pair | n | mean_diff | se (sd/√n) | candidate mean | comparator mean | seeds candidate better | |---|---|---|---|---|---|---| | candidate − t03 | 256 | **+1.375215243** | 0.090799255 | 531.727327985 | 530.352112741 | 215 | | candidate − IB | 256 | **+2.153790987** | 0.098374976 | 531.727327985 | 529.573536998 | 241 | **Worst and best 5 seeds by (seed, diff):** - **candidate − t03, worst5:** (9611157, −2.105636941), (9611209, −1.585973712), (9611095, −1.389872768), (9611253, −1.383951033), (9611039, −1.320242032) - **candidate − t03, best5:** (9611133, 7.831381496), (9611009, 6.436529329), (9611176, 5.834157623), (9611066, 5.209898181), (9611134, 4.305190371) - **candidate − IB, worst5:** (9611199, −1.615528007), (9611257, −1.177882015), (9611157, −0.978696364), (9611105, −0.496021289), (9611117, −0.451435571) - **candidate − IB, best5:** (9611009, 8.639062544), (9611133, 8.387396345), (9611207, 7.920231484), (9611187, 6.987816097), (9611066, 6.469412373) #### (3) Gas (Submission role, from `amm_sim_rs.gas_stats()`) | arm | afterSwap calls | ok | OutOfGas | revert | other_halt / tx_error / bad_return | peak | mean (ok) | |---|---|---|---|---|---|---|---| | candidate | 2,763,520 | 2,763,520 | **0** | **0** | 0 / 0 / 0 | **226,071** | 126,638.6 | | t03 | 2,781,220 | 2,781,220 | **0** | 0 | 0 / 0 / 0 | **235,556** | 135,558.9 | | IB | 2,759,818 | 2,759,818 | 0 | 0 | 0 / 0 / 0 | 234,852 | 135,226.2 | Candidate afterSwap per chunk (calls, peak, OOG, revert): - The candidate's other callbacks (`afterInitialize`, peak 72,760; `getName`) recorded 0 failures of any kind in every chunk. - The candidate's peak is 18,929 gas under the 245,000 limit. - t03 per-chunk afterSwap peaks: 235,556, 232,399, 232,431, 232,498, 232,506, 232,588, 232,494, 235,394. OOG was 0 in every chunk. - IB per-chunk afterSwap peaks: 234,852, 231,893, 231,929, 231,840, 231,941, 232,014, 211,365, 234,805. OOG was 0 in every chunk. #### (5) Timing and coverage Seconds per seed are `run_batch` wall time (8 workers) divided by seeds: | arm | total run_batch seconds | seconds per seed | |---|---|---| | candidate | 191.9 | 0.750 | | t03 | 170.6 | 0.666 | | IB | 139.7 | 0.546 | - Candidate chunks 5–8 took 28–31 s each versus 18 s for chunks 1–4. Some runs also overlapped, as noted under Method. These timings are rough. - **Seeds not run: none.** All three arms ran all 256 seeds. ### Source b21-p3-b3 — seeds 9601536..9601791 #### 2. Paired results (diff = candidate − comparator, per seed) Arm means over all 256 seeds: candidate **528.825462975**, t03 **528.191428771**, IB **527.459746389**. cand-t03: n=256 mean_diff=0.634034204 se=0.091375516 sd=1.462008251 wins=164 worst5: (9601734, -3.022759519), (9601560, -2.732704485), (9601677, -2.011663823), (9601683, -1.985385973), (9601707, -1.979273664) best5: (9601611, +5.889910066), (9601610, +4.932596079), (9601600, +4.417588895), (9601676, +4.274538283), (9601592, +4.269747505) cand-IB: n=256 mean_diff=1.365716587 se=0.093565726 sd=1.497051622 wins=212 worst5: (9601734, -2.398700956), (9601598, -1.598856731), (9601683, -1.588940033), (9601728, -1.553048039), (9601742, -1.394149555) best5: (9601676, +7.109739745), (9601551, +6.179751587), (9601610, +5.761923759), (9601611, +5.586310894), (9601717, +5.394622013) se = sample sd / sqrt(n). "wins" = seeds with diff > 0. #### 3. Gas (Submission afterSwap, summed over the 8 chunks) cand afterSwap: calls=2722943 ok=2722943 oog=0 revert=0 other_halt=0 tx_error=0 bad_return=0 peak=205385 mean_ok=95544.3 t03 afterSwap: calls=2762500 ok=2762500 oog=0 revert=0 other_halt=0 tx_error=0 bad_return=0 peak=235588 mean_ok=135655.5 IB afterSwap: calls=2741649 ok=2741649 oog=0 revert=0 other_halt=0 tx_error=0 bad_return=0 peak=234977 mean_ok=135324.0 Candidate totals: 2,722,943 afterSwap calls, 0 OutOfGas, 0 reverts, peak 205,385, mean 95,544.3 gas per ok call. afterInitialize peak 141,957 (first chunk). t03: peak 235,588, OutOfGas 0. IB: peak 234,977, OutOfGas 0. #### 5. Timing and coverage Seconds per seed is engine wall time inside run_batch (8 workers, 6-core machine), excluding compilation: - cand: n=256 mean=528.825462975 engine_seconds=43.49 s/seed=0.1699 - t03: n=256 mean=528.191428771 engine_seconds=60.53 s/seed=0.2364 - IB: n=256 mean=527.459746389 engine_seconds=57.72 s/seed=0.2255 Seeds not run: **none**. All 256 seeds 9601536..9601791 were run exactly once for each of candidate, t03 and IB. No other engine seeds were used. #### Caveats These are local measurements on one machine. Nothing here independently certifies behaviour on other seeds. Gates P, Q and F were not part of this item and were not re-checked here. ### Source b21-spl-128 — seeds 9532000..9532127 #### Paired results | Comparator | n | Candidate mean | Comparator mean | Mean diff | SE | |---|---:|---:|---:|---:|---:| | t03 | 128 | 518.702976330 | 517.425161704 | +1.277814626 | 0.129421943 | | IB | 128 | 518.702976330 | 516.619544566 | +2.083431764 | 0.124979558 | ##### Candidate − t03 worst5: (9532097, -1.369926934), (9532103, -1.359320047), (9532125, -1.293848345), (9532102, -1.216913725), (9532089, -1.182937609). best5: (9532001, +5.741704788), (9532054, +5.459646524), (9532064, +4.940568873), (9532123, +4.382290138), (9532084, +4.374832075). ##### Candidate − IB worst5: (9532103, -1.407631552), (9532102, -0.598349188), (9532089, -0.444201047), (9532110, -0.220599450), (9532091, -0.205386646). best5: (9532001, +6.037982202), (9532126, +5.672369161), (9532123, +5.383975113), (9532012, +4.987129508), (9532108, +4.936291439). #### afterSwap gas | Arm | Calls / successful calls | OutOfGas | Reverts | Peak gas | Mean gas | Total successful gas | |---|---:|---:|---:|---:|---:|---:| | candidate | 1,360,202 / 1,360,202 | 0 | 0 | 231,131 | 132203.413707670 | 179823347732 | | t03 | 1,369,905 / 1,369,905 | 0 | 0 | 235,406 | 135785.788167793 | 186013630140 | | IB | 1,359,602 / 1,359,602 | 0 | 0 | 234,892 | 135452.346525674 | 184161281241 | Candidate observed peak **231,131 gas** is within the 245,000 limit; runtime **21,106 bytes** is within the 24,576-byte limit. All arms also recorded zero other_halt, tx_error and bad_return for afterSwap. These limits were checked on this sample. #### Timing and completeness | Arm | Seeds completed | Batch seconds total | Seconds/seed | Seeds not run | |---|---:|---:|---:|---| | candidate | 128 | 280.794490 | 2.193707 | None | | t03 | 128 | 201.051378 | 1.570714 | None | | IB | 128 | 198.059724 | 1.547342 | None | Every seed 9532000–9532127 completed for each arm. No missing or imputed observations. IB n=128. ### Source b22-qm-1 — seeds 9533000..9533127 Paired submission-edge difference = port minus comparator; SE = sample SD / sqrt(n). worst5 is the five smallest differences, not their average. | Pair | n | mean_diff | se | worst5 (seed,difference) | |---|---:|---:|---:|---| | port - t03 | 128 | +2.207150660219 | 0.096224495554 | (9533052,-0.645451157990), (9533075,-0.311969954956), (9533003,-0.060601735768), (9533092,-0.027096654046), (9533024,+0.001551155035) | | port - IB | 128 | +2.975182830869 | 0.111932600425 | (9533088,-0.167590112162), (9533003,-0.037214513990), (9533117,+0.436349983036), (9533124,+0.532900507788), (9533092,+0.589756646450) | | Strategy | Mean submission edge | afterSwap calls | Peak gas | Mean gas | OOG | sum_ok_gas | |---|---:|---:|---:|---:|---:|---:| | port | 537.151367842100 | 1404904 | 229132 | 131282.35640585 | 0 | 184439107644 | | t03 | 534.944217181881 | 1393477 | 235406 | 135500.18926900 | 0 | 188816397242 | | IB | 534.176185011231 | 1382304 | 232014 | 135172.51164722 | 0 | 186849503540 | All calls succeeded; revert, other_halt, tx_error and bad_return are zero for all strategies. Port afterInitialize: 128 calls, peak/mean 140367; getName: 128 calls, peak/mean 21568; no failures. Engine gas is measured independently of pyrevm, not estimated by adding an overhead. ### Source b22-qm-2 — seeds 9534000..9534127 | Pair | n | mean_diff | se | wins | worst5 (seed, diff) | |---|---:|---:|---:|---:|---| | port - t03 | 128 | +2.137129915 | 0.113017454 | 124 | (9534024, -0.526433), (9534018, -0.470212), (9534100, -0.129994), (9534015, -0.128967), (9534071, +0.067457) | | port - IB | 128 | +2.911653450 | 0.123620669 | 126 | (9534096, -1.505829), (9534071, -0.681756), (9534100, +0.091754), (9534008, +0.123777), (9534020, +0.475773) | | t03 - IB | 128 | +0.774523535 | 0.082867464 | 110 | (9534096, -3.272258), (9534051, -2.754364), (9534009, -1.322586), (9534020, -1.257404), (9534071, -0.749213) | Mean submission edges: port 546.243653746, t03 544.106523831, IB 543.332000296. SE = sample SD of differences / sqrt(n). Submission afterSwap gas (engine accounting, all chunks; revert, other_halt, tx_error, bad_return all zero): | Strategy | Calls | OOG | Peak | Mean | |---|---:|---:|---:|---:| | port | 1,408,559 | 0 | 245,140 | 155,143.08 | | t03 | 1,397,792 | 0 | 235,456 | 135,469.86 | | IB | 1,386,857 | 0 | 234,853 | 135,139.06 | Per chunk (first seed: calls, peak): port 9534000: 356,623, 245,140; 9534032: 350,091, 240,220; 9534064: 355,217, 239,631; 9534096: 346,628, 244,809. afterInitialize peak: port 140,543; t03 243,234; IB 243,227 (128 calls each, none failed). **Caveat on gas.** The engine peak 245,140 exceeds the 245,000 figure while every call succeeded, so the engine's reported gas and its limit are not on the same scale as the nominal cap (trim-1 recorded the same accounting). The margin is nevertheless thin: on these 128 seeds the heaviest callback used 29,000 more than the heaviest t03 callback (its engine peak 235,456 is 9,700 under the port's), and a different seed set could produce an OutOfGas. To make this robust the lookup needs roughly 25,000-30,000 gas less: the measured costs say the 8 Cox-de Boor evaluations (about 34,000 with the loop skeleton) and the lane arithmetic (about 76,000 at the peak) are both far above their opcode counts, so the next step is restructuring those loops (fewer live variables, fewer memory-array bounds checks, or precomputed per-span basis weights) rather than changing the tables; the fee logic itself is verified. ### Source b23-qt1 — seeds 9535000..9535127 Mean submission edge: candidate 533.054377388, t03 530.894385770, trim-2 532.235737688. | Pair | n | mean_diff | se | worst5 (seed, diff) | ahead | |---|---:|---:|---:|---|---:| | candidate − t03 | 128 | **+2.159991618** | 0.110379644 | (9535096, −0.878549878), (9535060, −0.290820903), (9535073, −0.159565111), (9535100, +0.003834528), (9535078, +0.238640550) | 125/128 | | candidate − trim-2 | 128 | **+0.818639700** | 0.054576749 | (9535096, −0.683208388), (9535125, −0.499936775), (9535054, −0.365720343), (9535055, −0.289423148), (9535052, −0.201705272) | 117/128 | | trim-2 − t03 (for reference) | 128 | +1.341351918 | 0.117145832 | (9535060, −1.637289022), (9535064, −1.477667845), (9535016, −1.330706926), (9535057, −0.885600959), (9535100, −0.776676298) | 111/128 | ##### gas_stats (Submission role) Sums are over the 4 chunks. Peak is the max over chunks. Mean = sum_ok_gas / ok. | Strategy | Callback | Calls | OutOfGas | Peak | Mean | |---|---|---:|---:|---:|---:| | candidate | afterSwap | 1,402,238 | 0 | **208,775** | 137,940.08 | | candidate | afterInitialize | 128 | 0 | 90,858 | 90,858.00 | | t03 | afterSwap | 1,391,456 | 0 | 235,394 | 135,537.53 | | t03 | afterInitialize | 128 | 0 | 243,234 | 243,234.00 | | trim-2 | afterSwap | 1,390,179 | 0 | 130,574 | 71,232.83 | | trim-2 | afterInitialize | 128 | 0 | 90,800 | 90,800.00 | - revert, other_halt, tx_error and bad_return were 0 in every row. - Candidate afterSwap peaks per chunk: 201,777, 206,279, 208,161, 208,775. - The engine peak minus the pyrevm peak is 14,724, consistent with trim-2's ~15,000. That leaves 36,225 gas of margin under the 245,000 limit. - Wall time per 32-seed chunk: candidate about 51 s, t03 about 30 s, trim-2 about 15 s. #### Notes and limits - **Engine headroom:** the contract costs about twice trim-2's gas, because each callback evaluates two spline surfaces at about 35–43k each. More headroom would come from two cheaper steps: binary search for knot spans (about 2.3k per basis evaluation, 4 evaluations per surface) and the coefficient dispatch (about 360 gas per word). I did neither, because both targets were already met. - **Fee error:** spline values carry fixed-point rounding (WAD bases, integer divisions in Cox–de Boor). Against the Python decoder at 40 test points (20 grid nodes and 20 random interior points with random sd fraction, across the 5 tables), the max |diff| of the surface is 1.9e-11 bps. Gate F measures the combined error at 5.8e-6 bps. - **Scope of the engine figures:** only seeds 9535000..9535127 were used on the engine, once per strategy. Replica results do not convert to board scores. - **Not included here because of the 64 KB limit:** the generator `gen.py`, the Gate F harness (`check.py`, port-3's `check.py` with the reference swapped in and traces cached), the engine harness (port-3's `engine.py` with the seed range changed) and the unit-test scaffolding. The contract and reference below are complete. ### Source b24-qa1 — seeds 9613312..9613567 #### Paired edge differences | Comparator | n | Mean difference | SE | qm-2 wins | Ties | |---|---:|---:|---:|---:|---:| | trim-1 | 256 | 0.866638991 | 0.041147212 | 234 | 0 | | t03 | 256 | 2.240918837 | 0.086525651 | 248 | 0 | | IB | 256 | 3.013187361 | 0.090941492 | 253 | 0 | **qm-2 minus trim-1** Worst five: (9613349, -1.023661363), (9613433, -0.786152295), (9613397, -0.774009200), (9613359, -0.700737292), (9613413, -0.694652715). Best five: (9613335, 3.259840699), (9613404, 2.457884132), (9613446, 2.375621218), (9613352, 2.281217581), (9613467, 2.226298398). **qm-2 minus t03** Worst five: (9613399, -2.487329752), (9613493, -2.406796667), (9613540, -2.042139197), (9613379, -0.799495997), (9613361, -0.704994310). Best five: (9613468, 7.090572799), (9613550, 6.186935438), (9613471, 6.176666947), (9613315, 5.515248097), (9613323, 5.047095028). **qm-2 minus IB** Worst five: (9613493, -1.604972285), (9613399, -0.795442046), (9613540, -0.124878662), (9613379, 0.113010545), (9613361, 0.158737540). Best five: (9613538, 7.405559536), (9613440, 7.193460661), (9613468, 7.072677029), (9613471, 6.581964668), (9613553, 6.297438285). #### Submission afterSwap gas and timing Other afterSwap failures (`other_halt`, `tx_error`, `bad_return`): qm-2 = 0; trim-1 = 0; t03 = 0; IB = 0. ### Source b24-qa2 — seeds 9613568..9613823 Mean submission edge per arm: qm-2 525.894063457, trim-1 524.986402196, t03 523.698461245, IB 522.912729961. #### Paired edge: qm-2 minus comparator | Comparator | n | mean_diff | se | wins | ties | losses | | --- | ---: | ---: | ---: | ---: | ---: | ---: | | trim-1 | 256 | 0.907661261 | 0.045032765 | 234 | 0 | 22 | | t03 | 256 | 2.195602212 | 0.075094836 | 246 | 0 | 10 | | IB | 256 | 2.981333496 | 0.083992722 | 254 | 0 | 2 | **qm-2 minus trim-1** worst5: (9613816, -1.250259505), (9613629, -0.744837887), (9613716, -0.643986563), (9613765, -0.598611713), (9613583, -0.558530412) best5: (9613711, 4.220731326), (9613776, 2.689320294), (9613623, 2.656708539), (9613787, 2.542520030), (9613756, 2.521051091) **qm-2 minus t03** worst5: (9613714, -0.965515787), (9613672, -0.693347810), (9613716, -0.622382709), (9613571, -0.584380819), (9613582, -0.499081653) best5: (9613793, 5.830522196), (9613700, 5.824200432), (9613641, 5.417934463), (9613711, 5.123045628), (9613674, 5.008544427) **qm-2 minus IB** worst5: (9613672, -0.186769740), (9613716, -0.038583137), (9613728, 0.089178462), (9613714, 0.206652079), (9613817, 0.401451243) best5: (9613793, 8.168308467), (9613641, 7.482411690), (9613700, 7.099043491), (9613770, 6.266075514), (9613572, 6.127428791) #### Submission afterSwap gas totals | Arm | Calls | Successful | OutOfGas | Reverts | Peak | Mean successful gas | | --- | ---: | ---: | ---: | ---: | ---: | ---: | | qm-2 | 2781622 | 2781617 | 5 | 0 | 248814 | 155283.298552 | | trim-1 | 2756739 | 2756739 | 0 | 0 | 233405 | 131562.534247 | | t03 | 2763438 | 2763438 | 0 | 0 | 235515 | 135656.107164 | | IB | 2742028 | 2742028 | 0 | 0 | 234958 | 135321.832885 | Other halts, transaction errors, and bad returns: zero for all four arms. ##### Per chunk #### Timing and completeness | Arm | Engine seconds | Seconds/seed | Seeds not run | | --- | ---: | ---: | --- | | qm-2 | 123.993744 | 0.484351 | none | | trim-1 | 85.198646 | 0.332807 | none | | t03 | 71.939834 | 0.281015 | none | | IB | 71.828239 | 0.280579 | none | ### Source b24-qa4 — seeds 9614080..9614335 #### Paired results | qm-2 minus | n | Mean diff | SE | Wins | Ties | |---|---:|---:|---:|---:|---:| | trim-1 | 256 | +0.896127730 | 0.043137566 | 228 | 0 | | t03 | 256 | +2.371015670 | 0.082774428 | 253 | 0 | | IB | 256 | +3.147306850 | 0.102535957 | 256 | 0 | **qm-2 minus trim-1** Worst5: (9614312, -0.807380144), (9614288, -0.761389734), (9614219, -0.731798137), (9614283, -0.560938161), (9614095, -0.503355329). Best5 (largest first): (9614302, +2.783957385), (9614184, +2.614867255), (9614327, +2.604217357), (9614237, +2.490304720), (9614170, +2.462299031). **qm-2 minus t03** Worst5: (9614136, -0.696299030), (9614105, -0.256864835), (9614239, -0.094270994), (9614108, +0.042090107), (9614285, +0.073990571). Best5 (largest first): (9614327, +6.751643383), (9614199, +6.541758577), (9614321, +5.990761956), (9614097, +5.900935980), (9614117, +5.900655132). **qm-2 minus IB** Worst5: (9614094, +0.047076953), (9614285, +0.147712146), (9614101, +0.273940594), (9614089, +0.342999523), (9614215, +0.658589580). Best5 (largest first): (9614140, +13.978909195), (9614199, +9.012626250), (9614203, +8.352728779), (9614327, +8.240316087), (9614244, +7.550792442). #### Submission afterSwap gas and timing | Arm | Calls | Successful | OutOfGas | Reverts | Peak | Mean successful gas | Batch seconds | Seconds/seed | |---|---:|---:|---:|---:|---:|---:|---:|---:| | qm-2 | 2777463 | 2777453 | 10 | 0 | 249376 | 155278.651741 | 183.000412 | 0.714845 | | trim-1 | 2753489 | 2753489 | 0 | 0 | 235450 | 131562.988903 | 134.279066 | 0.524528 | | t03 | 2759742 | 2759742 | 0 | 0 | 235406 | 135670.983492 | 108.949087 | 0.425582 | | IB | 2738263 | 2738263 | 0 | 0 | 234763 | 135337.403895 | 110.365533 | 0.431115 | Other afterSwap failure totals (other_halt / tx_error / bad_return): qm-2 0/0/0; trim-1 0/0/0; t03 0/0/0; IB 0/0/0. ### Source b25-qb1 — seeds 9614336..9614591 #### Paired submission-edge differences Difference = qm-2 submission edge minus comparator submission edge on the same seed. SE is sample standard deviation divided by √n; wins count strictly positive differences. The ordered extreme tuples are `(seed, difference)` in edge units. | Comparator | n | Mean difference | SE | Wins | Worst five | Best five | |---|---:|---:|---:|---:|---|---| | trim-1 | 256 | +0.820368731 | 0.041729824 | 230 | (9614347, -0.922929118), (9614537, -0.859347532), (9614427, -0.706002973), (9614378, -0.563547649), (9614363, -0.558792301) | (9614411, +2.766117612), (9614490, +2.702835918), (9614462, +2.357008874), (9614518, +2.351596517), (9614566, +2.200009357) | | t03 | 256 | +2.361278791 | 0.078007582 | 253 | (9614395, -0.220230582), (9614371, -0.084532358), (9614421, -0.023138088), (9614362, +0.028221384), (9614443, +0.096796331) | (9614373, +6.144904240), (9614407, +5.569209597), (9614463, +5.333057699), (9614570, +5.242238711), (9614569, +5.103409752) | | IB | 256 | +3.122030261 | 0.096770760 | 255 | (9614509, -0.045165230), (9614443, +0.156615013), (9614421, +0.353164232), (9614396, +0.635475007), (9614575, +0.734413799) | (9614349, +14.934074216), (9614354, +8.136838526), (9614407, +7.108471215), (9614437, +6.104928307), (9614423, +5.998095568) | #### Submission `afterSwap` gas | Arm | Calls | OutOfGas | Reverts | Peak gas | Mean gas (successful) | Engine seconds/seed | |---|---:|---:|---:|---:|---:|---:| | qm-2 | 2,813,060 | 5 | 0 | 247,997 | 155,174.727 | 0.337576 | | trim-1 | 2,788,392 | 0 | 0 | 235,703 | 131,478.222 | 0.237090 | | t03 | 2,792,576 | 0 | 0 | 235,406 | 135,473.015 | 0.214038 | | IB | 2,770,007 | 0 | 0 | 232,022 | 135,140.593 | 0.205237 | Per-chunk gas (`calls`, successful-call `peak`, `OutOfGas`): **Seeds not run:** none. All 256 seeds have a returned submission edge for every arm. Validation passed for all four sources. `qm-2` had five OutOfGas calls; the other arms recorded zero OutOfGas and zero reverts. ### Source b25-qb2 — seeds 9614592..9614847 ##### Paired differences (score = edges['submission'], each arm alone vs 30 bps VanillaStrategy) Means over the 256 seeds: qm-2 526.567232, trim-1 525.679788, t03 524.444849, IB 523.604610. **qm-2 minus trim-1**: n=256, mean_diff=0.887444, se=0.040107 (sample sd 0.641708), wins=231/256 (ties 0) worst5: (9614759, -1.107829), (9614771, -0.904445), (9614660, -0.730634), (9614760, -0.651627), (9614630, -0.593939) best5: (9614808, 2.445114), (9614711, 2.388288), (9614826, 2.232997), (9614730, 2.114943), (9614693, 2.098085) **qm-2 minus t03**: n=256, mean_diff=2.122383, se=0.082415 (sample sd 1.318634), wins=247/256 (ties 0) worst5: (9614831, -1.593833), (9614809, -1.330061), (9614768, -0.916535), (9614843, -0.590108), (9614817, -0.551999) best5: (9614808, 5.647306), (9614606, 5.546051), (9614755, 5.338741), (9614841, 5.292944), (9614682, 5.186336) **qm-2 minus IB**: n=256, mean_diff=2.962622, se=0.087940 (sample sd 1.407046), wins=255/256 (ties 0) worst5: (9614598, -0.196556), (9614817, 0.010097), (9614843, 0.076954), (9614608, 0.107824), (9614831, 0.170145) best5: (9614726, 6.778259), (9614808, 6.630811), (9614794, 6.431179), (9614750, 6.308604), (9614700, 6.232255) ##### Gas: Submission afterSwap (amm_sim_rs.gas_stats(), reset before each 32-seed chunk) | arm | calls | ok | OutOfGas | reverts | other halts/tx errors/bad returns | peak (max_ok_gas) | mean (sum_ok_gas/ok) | |---|---|---|---|---|---|---|---| | qm-2 | 2,768,247 | 2,768,246 | 1 | 0 | 0 | 249,885 | 155307.5 | | trim-1 | 2,741,373 | 2,741,373 | 0 | 0 | 0 | 233,101 | 131589.4 | | t03 | 2,750,236 | 2,750,236 | 0 | 0 | 0 | 237,473 | 135731.7 | | IB | 2,730,070 | 2,730,070 | 0 | 0 | 0 | 236,928 | 135393.5 | Per chunk (start seed; calls / peak / OutOfGas): ##### Timing Seconds per seed (run_batch wall time / seeds, 8 workers on a 6-core x86_64 Linux machine): qm-2 0.562, trim-1 0.363, t03 0.356, IB 0.330. Seeds not run: none (every seed 9614592..9614847 ran exactly once per arm). ### Source b25-qb3 — seeds 9614848..9615103 #### Paired differences (qm-2 minus other arm, per-seed engine edge) | vs | n | mean_diff | se | wins (qm-2 > other) | worst5 (seed, diff) | best5 (seed, diff) | |---|---|---|---|---|---|---| | trim1 | 256 | +0.876741 | 0.041058 | 231/256 | (9615035, -1.008864), (9614866, -0.864811), (9614985, -0.703647), (9615062, -0.669831), (9614940, -0.546504) | (9615052, +2.681863), (9614857, +2.531151), (9614896, +2.480524), (9614909, +2.313989), (9614974, +2.229976) | | t03 | 256 | +2.343042 | 0.080718 | 251/256 | (9614919, -0.835861), (9614927, -0.671203), (9615075, -0.520478), (9614910, -0.256337), (9614856, -0.051170) | (9614955, +7.098287), (9615084, +5.596358), (9614922, +5.594635), (9614999, +5.335091), (9614876, +4.957010) | | IB | 256 | +3.118800 | 0.084729 | 256/256 | (9614953, +0.263788), (9614927, +0.345239), (9614877, +0.417802), (9615083, +0.444122), (9614992, +0.458227) | (9614966, +7.676049), (9614955, +6.991411), (9615040, +6.686775), (9614982, +6.381661), (9614855, +5.915112) | Arm means over the 256 seeds: qm2 524.971753, trim1 524.095012, t03 522.628711, IB 521.852953. #### Submission afterSwap gas (amm_sim_rs.gas_stats) Totals over all 8 chunks: | arm | calls | OutOfGas | reverts | other_halt | tx_error | bad_return | peak (max_ok_gas) | mean (sum_ok_gas/ok) | |---|---|---|---|---|---|---|---|---| | qm2 | 2,796,482 | 6 | 0 | 0 | 0 | 0 | 248,782 | 155,219.0 | | trim1 | 2,771,654 | 0 | 0 | 0 | 0 | 0 | 228,546 | 131,511.7 | | t03 | 2,776,807 | 0 | 0 | 0 | 0 | 0 | 235,556 | 135,557.7 | | IB | 2,755,274 | 0 | 0 | 0 | 0 | 0 | 234,864 | 135,229.3 | Per chunk of 32 seeds (calls / peak / OutOfGas): #### Time Wall seconds of run_batch per seed (8 workers; sum over chunks / 256): qm2 0.4651 s, trim1 0.3411 s, t03 0.2875 s, IB 0.2894 s. Seeds not run: none. Every seed 9614848..9615103 was run exactly once per arm; IB was not dropped. ### Source b25-qb4 — seeds 9615104..9615359 #### Paired results | Difference | n | mean_diff | se | Wins | Ties | |---|---:|---:|---:|---:|---:| | qm-2 − trim-1 | 256 | +0.873261120 | 0.039622764 | 237 | 0 | | qm-2 − t03 | 256 | +2.272860568 | 0.077423323 | 253 | 0 | | qm-2 − IB | 256 | +3.031685977 | 0.081582969 | 256 | 0 | **qm-2 − trim-1** worst5: (9615246, -0.785516243), (9615124, -0.602641527), (9615194, -0.597424450), (9615156, -0.568808138), (9615303, -0.475947576). best5: (9615236, +2.618824871), (9615242, +2.478550077), (9615146, +2.465681446), (9615310, +2.407624780), (9615302, +2.331915474). **qm-2 − t03** worst5: (9615112, -0.133945373), (9615195, -0.064409839), (9615257, -0.056081353), (9615139, +0.062497673), (9615254, +0.095225666). best5: (9615278, +6.302232448), (9615321, +6.118429548), (9615188, +5.471923115), (9615251, +5.438385783), (9615359, +5.398824782). **qm-2 − IB** worst5: (9615254, +0.457826358), (9615257, +0.558039915), (9615195, +0.594922739), (9615139, +0.598548039), (9615280, +0.801814873). best5: (9615120, +6.793870451), (9615278, +6.644807964), (9615281, +6.579258798), (9615127, +6.391152766), (9615328, +6.131420003). #### Submission afterSwap gas and speed | Arm | Calls | Successful | OutOfGas | Reverts | Peak | Mean | sum_ok_gas | run_batch seconds | Seconds/seed | Mean edge | |---|---:|---:|---:|---:|---:|---:|---:|---:|---:|---:| | qm-2 | 2807105 | 2807101 | 4 | 0 | 249895 | 155173.940398653 | 435588923267 | 124.933500 | 0.488021485 | 534.877186954 | | trim-1 | 2781640 | 2781640 | 0 | 0 | 226410 | 131493.793990595 | 365768397116 | 84.925456 | 0.331740064 | 534.003925834 | | t03 | 2785652 | 2785652 | 0 | 0 | 235406 | 135513.862990783 | 377494463468 | 78.623822 | 0.307124306 | 532.604326386 | | IB | 2764032 | 2764032 | 0 | 0 | 234856 | 135174.223407688 | 373625879074 | 75.600911 | 0.295316060 | 531.845500977 | Other afterSwap failures (other_halt / tx_error / bad_return): qm-2 0 / 0 / 0; trim-1 0 / 0 / 0; t03 0 / 0 / 0; IB 0 / 0 / 0. **Seeds not run: none**, for each of qm-2, trim-1, t03 and IB. IB was retained. All requested comparisons have n=256. ### Source b26-qtr2 — seeds 9538000..9538127 #### Engine — assigned fresh seeds only Each arm ran alone against the 30 bps VanillaStrategy using `amm_sim_rs.run_batch(X, VanillaStrategy, configs, 8)`. Configs directly transcribe [MatchRunner._build_configs](https://raw.githubusercontent.com/benedictbrady/amm-challenge/6b6921f8d463314aa7c96234e1be25a25245f704/amm_competition/competition/match.py): `np.random.default_rng(seed)`, draws in size/rate/sigma order, remaining fields from the base config. qtr2 ran first, then trim-1. Each used seeds **9538000..9538127 once**, in four chunks of 32. A seed-reservation file was written before every invocation; gas stats were reset before and read after each chunk. Contract source was frozen before the first engine invocation. | Pair | n | mean_diff | se | worst5 (seed, yours − trim-1) | |---|---:|---:|---:|---| | qtr2 − trim-1 | 128 | +0.837560422 | 0.053444952 | (9538012, -0.959624959); (9538048, -0.669209022); (9538031, -0.450489526); (9538058, -0.277966519); (9538022, -0.231088189) | Submission afterSwap, combined chunks: | Arm | Calls | OutOfGas | Peak | Mean | |---|---:|---:|---:|---:| | qtr2 | 1,413,391 | 0 | 191,661 | 127157.94031 | | trim-1 | 1,402,142 | 0 | 223,347 | 131434.97545 | Revert, other_halt, tx_error, and bad_return counts are all zero for both arms. Gas figures are engine-reported; they are not interchangeable with the pyrevm numbers. ### Source b27-pb1r — seeds 9610240..9610495 #### Paired scores | Difference | n | mean_diff | se | wins | ties | |---|---:|---:|---:|---:|---:| | candidate − t03 | 256 | 1.327510001 | 0.088075259 | 213 | 0 | | candidate − IB | 256 | 2.029791756 | 0.091640459 | 241 | 0 | Candidate − t03: worst5: (9610397, -1.552673012), (9610272, -1.531993236), (9610271, -1.480311569), (9610413, -1.306498883), (9610403, -1.270333781). best5: (9610455, 11.247048738), (9610274, 6.276161357), (9610378, 5.245192619), (9610471, 4.836196624), (9610434, 4.320514463). Candidate − IB: worst5: (9610271, -1.284880686), (9610316, -1.147041378), (9610343, -0.801396145), (9610272, -0.663107279), (9610416, -0.591603158). best5: (9610455, 8.760192537), (9610434, 6.775223928), (9610274, 6.342688615), (9610378, 6.301833917), (9610368, 5.995190431). #### Submission afterSwap gas | Arm | Calls | OutOfGas | Reverts | Peak gas | Mean gas | Sum gas | |---|---:|---:|---:|---:|---:|---:| | candidate | 2,756,970 | 0 | 0 | 225,947 | 126700.387421 | 349309167107 | | t03 | 2,775,676 | 0 | 0 | 235,418 | 135582.198509 | 376332254428 | | IB | 2,754,525 | 0 | 0 | 234,825 | 135244.520566 | 372534413013 | All arms also had zero other_halt, tx_error, and bad_return events in Submission/afterSwap. Candidate peak is below 245,000 gas. These are observed limits on this seed block, not guarantees for other seeds. #### Timing | Arm | Total engine seconds | Seconds per seed | |---|---:|---:| | candidate | 139.349728 | 0.544334875 | | t03 | 96.919269 | 0.378590894 | | IB | 96.378373 | 0.376478020 | ## Replica-only posterior-quoting research — source b28-ar3 ### ar3: quote against the whole posterior instead of its collapsed mean Credit: the solved policy, replica, tables, Gaussian filter (`real.py`) and the list of open ideas all come from Taylor (gtmcknight), github.com/gtmcknight/amm-sim at commit 4812a6382311624e1506aca131ca35c378f930d9, folder `research/solved`. Everything below was run on that replica under plain `python3 -I`. ## Gate P: PASS Unmodified `python3 -I gates.py` printed (3.6 s): [Implementation or raw-data block not reproduced; see source item.] This matches the README's gate block digit for digit, gaussian+plain 443.455598 / 571.463409 / 525.168028 included. My BASE arm, run through my harness, gives 443.4555976 / 571.4634094 / 525.1680278 on those seeds. Across all of 10000..12047 it scores +2.828 se 0.041 vs HA, which is the README's +2.828. ## Which idea, and why README Open item 3 lists three untried ideas: (a) "choosing quotes against the whole lattice posterior instead of its mean and sd", (b) per-run sigma and order rate inside the classifier, and (c) the router likelihood per price hypothesis. Earlier items already covered (b) (+0.024) and (c) (+0.049). Size-to-gap and arrival-pattern are excluded. That leaves **(a)**, and it is also the one I would have picked on merit. The README says the classifier error "is near what those features allow" (table classifier 18.8% vs the lattice's 16.2%), and the two earlier items confirm it: both moved the result by less than 0.05. So a better *classifier* has little room left. What can still be recovered is the *cost* of each misclassification. Right now `real.py` collapses an ambiguous first trade into one Gaussian (m, v) by moment matching. With plain tables v is then ignored, so the quote is set at one price that may be far from both hypotheses. Quoting against the whole posterior hedges both cases. Adapting (a) to the Gaussian filter (the brief requires a copy of `real.py`, so I used the Gaussian version rather than the lattice): the belief update is unchanged. The filter state m, v, the classification `pi > 0.5`, the rival tracking and the phase logic are all exactly as in BASE. The only change is how the plain-table quote is chosen. ## What the TEST arm computes At the first own trade of a step, the filter already builds a two-part posterior: an arb point mass at `lp_arb` with weight pi, and a retail part N(m, v) truncated to the no-arb interval, with mass 1 - pi, mean mt and variance vt. TEST stores this as a list of price nodes `mix`: - arb branch (pi >= 0.995): one node at `lp_arb`; - retail branch (pi <= 0.005): 3-point Gauss-Hermite nodes mt - h, mt, mt + h with weights 1/6, 2/3, 1/6, where h = qs * sqrt(3 vt); - soft branch: weight qa = pi^k / (pi^k + (1-pi)^k) on `lp_arb`, plus the three retail nodes sharing weight 1 - qa. At every callback in that step (the filter does not update m within a step, so the posterior stays valid), each node x gives its own table lookup: own displacement w_x = ln s - x, rival displacement ln s2 - x, same phase. That gives offsets (a_x, b_x). The quoted log ask is the weighted mean of x + a_x and the quoted log bid is the weighted mean of x - b_x. The fees follow from the spot exactly as in BASE (ask fee = 1 - exp(-(LA - ln s)) if LA > ln s, else 0; bid likewise). With a single node this reduces exactly to BASE's `_fees`. Before the first step, or with `qm` tables, behavior is unchanged. Parameters: qs (quadrature width scale) and qk (power sharpening of pi). I tuned them on 60000..61023 only: | setting (choose set, TEST - BASE, n=1024) | mean_diff | se | |---|---|---| | qs=0 (arb point + retail mean only, 2 lookups) | +0.4907 | 0.0164 | | qs=0.5 | +0.5430 | 0.0175 | | **qs=1, qk=1 (chosen = file defaults)** | **+0.5667** | 0.0182 | | qs=1.5 | +0.5405 | 0.0191 | | qs=2 | +0.4286 | 0.0196 | | qk=0.5 | +0.2278 | 0.0197 | | qk=2 | +0.4286 | 0.0195 | ## Results, TEST minus BASE (paired, same seeds; se = sample sd / sqrt(n)) | set | n | mean_diff | se | wins | worst5 (seed, diff) | |---|---|---|---|---|---| | choose 60000..61023 | 1024 | +0.5667 | 0.0182 | 876 | (60773, -2.1817), (60225, -1.7215), (60210, -1.5763), (60204, -1.3188), (60084, -1.2056) | | **report 10000..12047** | 2048 | **+0.5662** | **0.0125** | 1746 | (10212, -1.5005), (11022, -1.2620), (11179, -1.2197), (11074, -1.1872), (12034, -1.1469) | The report seeds were scored once per arm, with no tuning on them. Means on the report set: BASE 532.3857, TEST 532.9519, true flag 536.1083. Against Taylor's stored HA rows: BASE +2.828 se 0.041, **TEST +3.394 se 0.040**, true flag +6.551 se 0.046. **True-flag gap.** BASE with the true arb/retail flag (`oraclearb=1`, plain tables, soft=1) minus BASE: n=2048, +3.7226, se 0.0237, wins 2044. TEST closes 0.566 of that 3.72, about 15%. (The README's "worth 2.7" and +6.985 refer to the qm tables. With plain tables the flag is worth 3.72 on this replica.) ## Confusion matrix (report seeds, first own trade of each step, all 2048 seeds summed) | arm | arb called arb | arb called retail | retail called arb | retail called retail | misclassified | |---|---|---|---|---|---| | BASE | 6,301,005 | 1,309,754 | 1,048,181 | 5,566,964 | 16.57% | | TEST | 6,394,351 | 1,244,969 | 1,128,646 | 5,470,053 | 16.67% | | true flag | 7,385,296 | 0 | 0 | 6,708,520 | 0.00% | The classifier itself is unchanged, so the error rate stays at about 16.6%. The gain comes from making each error cheaper, not from fewer errors. That is consistent with the README's finding that these features cap the classifier near 16%. (A trade counts as called arb when the policy ended the callback in phase 0. The truth is the replica's `arb` argument.) ## Cost Seconds per seed (one core, replica): BASE 0.098, TEST 0.157, flag 0.088. The choose set ran in 12 s (BASE) and 21 s (TEST) on 8 processes. Each callback needs up to 4 table lookups instead of 1 (2 with qs=0, which keeps +0.49 of the +0.57). That matters for the 245k gas budget in the Solidity port. ## Verdict: worth porting +0.566 with se 0.0125 on the untouched report set clears the bar (> +0.3, se < 0.1). The choose and report sets agree (+0.567 / +0.566), TEST wins 85% of report seeds, and the worst seed loses only 1.5. It is about 10x the gain of either earlier item. Caveats: - The extra lookups cost gas. qs=0 is a cheaper fallback (2 lookups, +0.49 on the choose set; not scored on the report set). - I tested it only with the plain tables. Whether it adds on top of the `qm` tables or the lattice filter (which already use sd) is untested. - Replica gaps have so far tracked the engine, per the README, but nothing here ran on the Rust engine. The source includes the complete realpq.py, SHA-256 `488ad8a89884ed22713ebc38031cbc71ea98dc78e759e65a790bc478247c32e1`, a copy of real.py with this idea added. Defaults are qs=1/qk=1; the wrapper counts confusion cells on first callbacks of steps and pairs replica outcomes per seed using eight processes. This merge preserves its algorithm and measurements, not a replacement Python file. Earlier +0.024/+0.049 ideas and README classifier claims are contextual citations made by ar3, not experiments independently supplied in this root. Additional bounded-process details: qm-1 reports an initial invocation at the wrong directory could not open scratch/setup.sh and ran no setup steps; the actual script then ran once successfully, adding three curl retries spaced two seconds. Other reported setups succeeded without final download failure. pb4 saved setup hash `f3abb169ae32d5b1c3d8604d693fa1c646dcbda1a527aab6cc6c8402724f392b`; its candidate source length was29,482 bytes. p3-b3/spl-128/pb2 source-location assertions remain qualified by the explicit script-location disagreement. (Sources: b22-qm-1, b20-pb4 and named setup sections.) ## Source manifest and coverage ledger Each label above refers to the exact input bytes listed here. All 17 inputs are represented. Hashes are locally checked against the assignment by the merge process. Original result paths are provenance identifiers, not assertions that those files exist in this checkout. | Label | Original result path | SHA-256 | |---|---|---| | b20-pb2 | artifacts/goal/batches/r4-confirm-p2-b/items/pb2/result.md | `079f9d26b4e06097d2a3150d1df4dc80063cf997dfbfd5ae00abe975207b33b5` | | b20-pb4 | artifacts/goal/batches/r4-confirm-p2-b/items/pb4/result.md | `36825dcecce7f94011b8ec4e6e531c71d01431644c5c15b13446ff48ddf1cf83` | | b21-p3-b3 | artifacts/goal/batches/r4-confirm-misc/items/p3-b3/result.md | `450e88d79a1233df110b4e7e309d4e34928c7e0cdce518f9e213e4d71c416663` | | b21-spl-128 | artifacts/goal/batches/r4-confirm-misc/items/spl-128/result.md | `c37e7f1dbfe1032608c8e4193dd88d63c6d60bfce44e0b67e76d445a28f41dd7` | | b22-qm-1 | artifacts/goal/batches/r4-qm-port/items/qm-1/result.md | `e631c005505076970c29cf8a4fae2a9eb5943252a7d00d72370b5443d0222e91` | | b22-qm-2 | artifacts/goal/batches/r4-qm-port/items/qm-2/result.md | `e50ab7b92163d8589bb2f75c49d6cda2a1012bb96a0f4a52620b887668f63264` | | b23-qt1 | artifacts/goal/batches/r5-qm-t2/items/qt1/result.md | `8a6e303b662e1a5ea9bb47f31acedd3988ef65b3ddb66d074517aa59ad41ca40` | | b24-qa1 | artifacts/goal/batches/r6-confirm-qm-a/items/qa1/result.md | `00a96f4d9c5bf0a4e6118b2063dd779e4ab7e24c60bc840f74fd8778a09b73ee` | | b24-qa2 | artifacts/goal/batches/r6-confirm-qm-a/items/qa2/result.md | `ecd38e4f7da4b2e3a4cfa3c6915a2a5d0ba0bd8555845451d6679ddcdb2b88e8` | | b24-qa4 | artifacts/goal/batches/r6-confirm-qm-a/items/qa4/result.md | `1eaa69c34be73ccf0213acb2d978df143e432f7b25b3053796440ad1c85f68b0` | | b25-qb1 | artifacts/goal/batches/r6-confirm-qm-b/items/qb1/result.md | `41bd2bdbf8385ece615d29f7c60d75660d558db2cacba08d1ac748bae3819659` | | b25-qb2 | artifacts/goal/batches/r6-confirm-qm-b/items/qb2/result.md | `c7ffa22abd281ff01e5a36492b45a6abf5e6ae4bdeac726a3e85d44966cbb4bd` | | b25-qb3 | artifacts/goal/batches/r6-confirm-qm-b/items/qb3/result.md | `adfc9c08dbcf72ae954475e8617a99dab32506db0a64060cf11387f07be7aae4` | | b25-qb4 | artifacts/goal/batches/r6-confirm-qm-b/items/qb4/result.md | `bc47490ac83e2bbb54ab590b1c6ffe6c762ee3660e0eceddbb773424ac4f4de8` | | b26-qtr2 | artifacts/goal/batches/r6-qm-trim/items/qtr2/result.md | `18ca35cb47390b8e8c289b240d7836804692998ad64f84ef248c43d61e199f0b` | | b27-pb1r | artifacts/goal/batches/r6-rerun-blocks/items/pb1r/result.md | `994660cf36b4ec18c58e70eea8ec58910b3f0fef724638d90734207c25150682` | | b28-ar3 | artifacts/goal/batches/r6-arb/items/ar3/result.md | `7d68707ac5f44c85e8821a490566120f76e232763efa290ba8b565c3d3ca486b` |