# pb4: port-2 (TaylorGaussianPlain2) on fresh real-engine seeds 9611008..9611263 On all 256 seeds the candidate beats both comparators: **+1.375215243 edge vs t03** (SE 0.090799255, 215/256 seeds better) and **+2.153790987 vs IB** (SE 0.098374976, 241/256 seeds better). afterSwap peak was **226,071 gas**, with **0 OutOfGas** and **0 reverts** in 2,763,520 calls. Every arm ran every seed exactly once, so no seed is missing. The policy is Taylor's (gtmcknight) dynamic-programming solution: github.com/gtmcknight/amm-sim at commit 4812a6382311624e1506aca131ca35c378f930d9, `research/solved` (Gaussian filter + plain tables). The contract header credits Taylor. Port-2 is the Solidity port of that policy. ## Setup - Platform: Linux x86_64. - I cloned `benedictbrady/amm-challenge` at `6b6921f8d463314aa7c96234e1be25a25245f704` inside the workspace's `test/scratch/`. - **setup.sh source.** The brief says the 8-line script is in the Setup section of port-3's result (artifact `0dbcc10a…`). That section has only a table of steps, not the script. I used the 8-line script from the `### setup.sh` block of the port-2 artifact (`e8c967d6…`). It matches the script in the goal brief line for line. Saved file sha256: `f3abb169ae32d5b1c3d8604d693fa1c646dcbda1a527aab6cc6c8402724f392b`. - I ran the script once with `sh scratch/setup.sh`. It exited 0, the wheel sha256 check passed (`aedb6828…887a`), and it ended with `Strategy 'StarterStrategy' validated successfully!` ## (1) Candidate - **Source block:** the only ```` ```solidity ```` block in https://api.imdnotdead.fun/artifacts/e8c967d6358da0fd53117891357f19a1d684225bd71a5e302b6e299c85f1286c, under `## Code` / `### Strategy.sol` (artifact lines 80–279, without the fences). I saved it byte for byte, with one trailing newline, as `contracts/src/Strategy.sol` (29,482 bytes). - **sha256 (my own computation; none was published):** `7e2d9c157a7725c2875eea31e5741938fb9eafef5a3442710573f1b1a87faf17` - **Validation:** `amm-match validate contracts/src/Strategy.sol` **passed**, printing `Strategy 'TaylorGaussianPlain2' validated successfully!` - **getName():** `TaylorGaussianPlain2` - **Runtime (deployed) bytes:** **18,484**, matching the expected figure and within the 24,576 limit. - **Comparators:** sources decoded from `code_zb64` (base64, then zlib). - t03: sha256 `cb6d945511e1e10af78baa64c2a6cb25806f0998403ce6440654bfc3c70092d9` (matches), getName `censored_10`, 14,654 runtime bytes. - IB: sha256 `301941829a44bb60977bb28181a5e4bfa6544f3696763f987054789b2611d686` (matches), getName `inputs_b`, 14,528 runtime bytes. ## Method - Each arm ran alone against `VanillaStrategy` (30 bps) through `amm_sim_rs.run_batch(X, VanillaStrategy, configs, 8)`. - Configs follow `MatchRunner._build_configs` with config index i = seed: - `rng = np.random.default_rng(seed)`, then three uniform draws in this order: retail_mean_size [19, 21], retail_arrival_rate [0.6, 1.0], gbm_sigma [0.000882, 0.001008] (`BASELINE_VARIANCE`). - All other fields come from `build_base_config`: 10,000 steps, price 100, x 100, y 10,000. - `SimulationConfig.seed` = the seed. - Score = `edges['submission']`. - Each run covered 32 seeds, giving 8 chunks per arm and 24 runs in total, each well under 8 minutes. - I called `gas_stats_reset()` before each chunk and `gas_stats()` after it. Per-chunk JSON is kept under `scratch/res/`. - Order: candidate on all seeds first, then t03. - **Order deviation:** the tool harness overlapped some runs. t03 chunks 1–3 ran at the same time as t03 chunks 4–6. IB chunks 1–4 ran at the same time as t03 chunks 7–8. Results are deterministic per seed, so this only affects the wall-clock timings. No seed was run twice. ## (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): | chunk start | calls | peak | OOG | revert | |---|---|---|---|---| | 9611008 | 341,556 | 224,573 | 0 | 0 | | 9611040 | 349,968 | 225,150 | 0 | 0 | | 9611072 | 351,737 | 224,656 | 0 | 0 | | 9611104 | 350,074 | 226,059 | 0 | 0 | | 9611136 | 343,154 | 226,071 | 0 | 0 | | 9611168 | 344,071 | 226,059 | 0 | 0 | | 9611200 | 341,715 | 224,526 | 0 | 0 | | 9611232 | 341,245 | 224,693 | 0 | 0 | - 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. ## (4) Per-seed edges (CSV, 9 decimals) ```csv seed,candidate,t03,IB 9611008,403.104023264,403.207043067,401.923038857 9611009,577.284418009,570.847888680,568.645355465 9611010,504.298715256,504.293296508,503.074053952 9611011,432.335801404,432.042753741,431.975930846 9611012,573.632764532,569.394361423,568.332220077 9611013,502.487226193,501.803799213,501.245925985 9611014,435.766084333,434.727177103,434.646234628 9611015,577.614617428,576.201448938,576.317153369 9611016,609.418329647,608.937352231,605.980842527 9611017,482.270606603,481.884480921,481.155064613 9611018,391.850622610,391.382516329,390.569586224 9611019,642.453549455,640.417026435,639.521353212 9611020,484.417060468,483.801111515,483.285454861 9611021,647.409003416,644.882136333,643.886383196 9611022,432.056860601,431.368431637,430.047341736 9611023,629.702301283,626.418860964,625.485426018 9611024,514.587143249,514.819550445,513.905332295 9611025,592.127853712,589.568638171,589.493519259 9611026,553.014760836,549.717228193,550.128015394 9611027,592.465731154,589.943359999,590.770524829 9611028,522.082626169,521.437848894,520.467416094 9611029,595.823162506,592.488310833,593.271699741 9611030,618.975012732,616.838737679,616.217385787 9611031,480.924735302,481.808886733,480.641662877 9611032,527.156697292,526.964826146,522.389294214 9611033,428.346440149,427.834409244,427.258837053 9611034,497.825944502,497.121252084,496.087254524 9611035,452.546926944,450.697043131,449.977685323 9611036,473.016607222,470.573805480,469.396655933 9611037,398.310991367,398.339452289,397.466931549 9611038,423.355087280,422.848994512,422.382995737 9611039,509.139154573,510.459396606,509.021503222 9611040,526.104691372,526.133179501,524.406762535 9611041,528.247821180,526.676952659,525.565473983 9611042,500.598049223,500.864367019,499.677353881 9611043,569.231853652,567.980435816,567.618422124 9611044,486.166124774,486.346497952,483.088315060 9611045,517.115148863,516.516987910,515.648024664 9611046,600.048117401,596.853250016,597.537023332 9611047,627.465753907,626.269951858,626.389101533 9611048,443.706575319,442.365819136,441.248014510 9611049,711.259061744,709.070950981,705.777011893 9611050,543.183522715,540.235920035,539.345109050 9611051,634.208202427,634.797809014,632.493420864 9611052,584.616274618,583.981759064,582.888064187 9611053,588.795529377,586.903939510,587.192078845 9611054,417.285777805,417.514742817,416.697798882 9611055,443.090641699,439.902434073,439.982049892 9611056,589.197501355,587.185834018,586.875675233 9611057,596.954731344,595.536784327,595.066679694 9611058,616.265306882,613.563852943,612.974745810 9611059,372.762818425,373.637480203,372.800234501 9611060,402.156469383,402.033594065,400.500268334 9611061,545.150257787,544.577682450,544.380895783 9611062,513.411981317,511.897801181,509.583518242 9611063,626.787253597,627.090860163,627.195127495 9611064,679.530431671,677.094280377,675.076616597 9611065,447.781069311,447.475114871,445.745171276 9611066,731.758309906,726.548411726,725.288897533 9611067,646.457317194,642.782865690,641.764654808 9611068,449.539829126,448.312421656,446.414517997 9611069,714.425769616,712.178564765,711.997393179 9611070,475.112837230,473.828268613,472.700256254 9611071,467.495028702,466.893745382,465.181622525 9611072,524.942383649,523.130100642,523.244156806 9611073,643.878075091,642.409218857,642.816241076 9611074,593.914083514,590.869166302,590.888385375 9611075,607.245584228,606.864095318,606.676133576 9611076,537.040340376,536.295250220,535.380266066 9611077,589.368030035,586.637440501,586.754330119 9611078,658.711281036,655.608428476,653.866451581 9611079,483.645362924,484.257116757,483.286788627 9611080,525.126183504,523.015583404,522.836069508 9611081,472.011080634,471.067326231,470.310908660 9611082,677.896746564,677.827790869,677.817020853 9611083,481.406454213,480.050397972,479.426894845 9611084,471.273281236,468.537164305,468.305079296 9611085,605.452388870,602.438907573,601.704747032 9611086,513.204592440,513.009721432,513.057772538 9611087,675.186487647,672.345386648,671.563812201 9611088,595.446936143,592.748590043,590.552305717 9611089,475.577708086,475.141065927,474.019387373 9611090,483.088983695,482.987062295,483.400096441 9611091,489.041831765,487.739251902,486.579814263 9611092,503.990588627,502.982811672,502.410543228 9611093,386.023916488,385.499650729,384.877757967 9611094,655.029627541,651.584289113,651.339285241 9611095,343.410361698,344.800234466,343.858555630 9611096,513.177718709,513.405108428,512.383304649 9611097,559.630894703,558.170381847,556.718585249 9611098,424.559667898,424.696696628,424.191094570 9611099,590.673181495,590.055206573,589.147714682 9611100,374.862832498,374.608536698,373.975640326 9611101,638.595512595,639.333368835,638.198508810 9611102,661.882439734,659.391822177,658.614997848 9611103,615.281349860,612.354970353,612.039245072 9611104,668.684442697,669.101855030,667.299834136 9611105,561.714436472,562.797806783,562.210457760 9611106,408.326154636,406.924979342,406.163505999 9611107,468.346148113,466.227071688,466.356114912 9611108,489.913594939,489.481114763,488.478496797 9611109,518.777995888,518.274609089,516.187767412 9611110,575.161140948,572.903895398,571.981627386 9611111,510.824668494,510.590219465,509.658101334 9611112,615.401030559,614.927655178,612.230842560 9611113,633.175371048,630.197540728,629.552740993 9611114,407.296173929,406.357010688,404.429182183 9611115,554.195416529,551.693387649,551.867155195 9611116,601.633810079,602.090207922,600.970924825 9611117,580.006961762,579.648089862,580.458397333 9611118,650.480682510,647.214330958,646.025166410 9611119,486.310314212,486.059921200,485.399302070 9611120,409.086577223,409.808148080,409.192340014 9611121,544.120463193,541.177802692,541.003847451 9611122,525.659314307,524.555861382,523.560205765 9611123,539.864101855,537.762414272,536.410475110 9611124,484.741276223,484.167849105,483.378465312 9611125,434.967687735,434.233829880,432.982451210 9611126,554.774634315,554.568188674,553.983193471 9611127,625.633801850,625.567956763,624.838838959 9611128,628.195239862,624.051263357,625.475762107 9611129,548.906047490,545.930033760,545.598750134 9611130,479.254070334,478.026960147,477.726352854 9611131,417.664365271,415.164571751,414.735288458 9611132,604.516484184,600.998892120,600.219883398 9611133,635.037324214,627.205942718,626.649927869 9611134,626.325656051,622.020465680,622.273820809 9611135,618.350128060,614.673669544,613.873362823 9611136,573.726795763,574.353596175,573.831036068 9611137,599.541869111,596.662725387,596.638712414 9611138,586.886851512,583.594162195,583.667202313 9611139,595.549982096,591.854004465,590.686245990 9611140,649.209582548,646.571568242,646.653553974 9611141,684.380202483,680.774211248,680.899558536 9611142,431.759269790,432.517775541,431.440451358 9611143,578.788950428,577.230660863,577.219166999 9611144,553.320139003,553.089576998,553.215106430 9611145,413.089827351,413.190723317,412.319845084 9611146,474.229643786,473.634911122,473.340151383 9611147,425.294345314,424.927148566,424.555410513 9611148,587.955553656,584.133304705,583.607838320 9611149,441.739465013,439.926326307,437.918965730 9611150,591.124571847,590.047836461,589.732181905 9611151,620.449143622,617.178475488,615.288077713 9611152,336.962865655,336.573585223,336.742375613 9611153,572.348913892,571.096156062,570.343423698 9611154,568.337874106,566.979800896,566.911755755 9611155,549.548274393,546.186539169,545.449423107 9611156,562.639713150,559.582877004,558.509461656 9611157,465.269978758,467.375615699,466.248675122 9611158,605.227920023,603.114177190,602.114251717 9611159,371.218298257,370.900195198,369.861880584 9611160,637.107937341,635.635820905,635.649459958 9611161,496.356275568,496.467320853,495.864304124 9611162,669.055697767,667.186896164,666.111015230 9611163,432.472262484,430.814814607,429.743814253 9611164,361.550228831,361.903165194,361.443725527 9611165,454.479940051,454.791056392,454.865829537 9611166,432.146060848,431.598294013,430.313841935 9611167,502.146264203,501.162715694,500.369440503 9611168,613.945146641,610.345062380,609.773006182 9611169,428.393128164,428.423147421,427.381555081 9611170,577.897888411,577.727796683,576.768825082 9611171,440.012231025,438.621273329,438.357906839 9611172,357.084928596,356.529193889,356.272153877 9611173,612.177843279,611.447228640,611.252184523 9611174,459.174275490,458.173585138,457.641553639 9611175,448.160314363,448.650001539,448.245085087 9611176,724.363802540,718.529644917,718.318380333 9611177,487.703275169,486.329383878,485.573112707 9611178,424.324379005,423.141493786,422.455115416 9611179,671.991585246,670.418241269,670.071451380 9611180,563.938272107,564.013404480,563.099795947 9611181,566.985307004,564.649217197,564.194386604 9611182,658.769866157,655.267610419,655.962586372 9611183,535.381569265,533.913297294,532.363394054 9611184,440.668641040,439.053308243,438.423940952 9611185,434.591728930,433.264332183,432.577396063 9611186,535.812988986,534.780080812,535.742748320 9611187,593.342304757,591.798259784,586.354488660 9611188,595.768812176,594.625442637,594.694589957 9611189,539.658371638,539.653177953,538.773543129 9611190,348.535134250,349.618890616,348.483398955 9611191,562.983371236,560.461881584,560.188444368 9611192,488.344764350,488.982472413,487.689706775 9611193,603.360395579,601.546902637,601.180897770 9611194,562.284616179,560.870941906,561.337263533 9611195,429.370011343,427.869981199,427.672705172 9611196,459.708099556,458.615498702,458.547102573 9611197,627.394826694,627.498417145,626.370405835 9611198,584.924580242,583.779961523,583.083768966 9611199,494.314765132,495.626151946,495.930293139 9611200,466.199929675,465.281931375,464.886971935 9611201,708.690256916,706.118705982,704.710728002 9611202,521.818625939,521.020741941,521.867369016 9611203,400.588838815,400.211987208,399.672966437 9611204,557.059995377,555.498764172,554.809858474 9611205,597.400043451,593.505223454,593.470127176 9611206,490.307267068,487.113243273,486.917397805 9611207,610.350067147,608.921738357,602.429835663 9611208,389.750562361,389.311149556,387.679911637 9611209,584.558215005,586.144188716,584.051707598 9611210,629.609076723,627.529078530,626.336767771 9611211,478.420895612,476.266739561,475.293785426 9611212,646.961059391,642.988704927,642.305640036 9611213,516.968688141,515.558344293,515.456619703 9611214,415.913135351,413.931764913,413.638818296 9611215,485.630095089,482.005300628,481.077326316 9611216,450.285970422,448.787884072,448.666930844 9611217,355.385231796,355.402970242,354.410326202 9611218,581.385194153,580.140995486,580.064435235 9611219,593.506640421,591.319688479,589.750381539 9611220,472.180099464,472.909479223,471.757605741 9611221,463.780512515,461.480426389,461.450625210 9611222,539.800663441,538.561011443,538.165159121 9611223,449.442267001,449.034145216,448.393844208 9611224,528.564159654,528.092466940,526.263098517 9611225,387.709162589,387.336593446,384.878598637 9611226,601.995123484,599.095654157,598.144319056 9611227,599.841950890,598.247274154,596.896880764 9611228,460.744508598,460.267778472,459.291178884 9611229,578.317638889,576.548340787,576.154095114 9611230,578.941114098,577.818174603,577.461624596 9611231,704.353775949,702.514071606,702.793117389 9611232,589.889392887,587.463650654,586.704362366 9611233,405.155173109,403.472643105,403.046018728 9611234,450.814600975,449.076148912,447.633007811 9611235,608.573019816,604.962384151,604.122122868 9611236,663.028332347,660.699824004,661.011715080 9611237,420.368854642,419.512965192,418.528380431 9611238,404.461267425,402.951677628,402.143201054 9611239,608.672307069,606.747683545,605.502561353 9611240,603.782969546,603.249177875,601.630078247 9611241,578.040209540,576.266573426,576.260200813 9611242,557.214003446,555.726848697,555.397789413 9611243,490.630689608,488.642343377,487.695616576 9611244,403.167977470,403.492133216,402.477200138 9611245,455.808647951,455.434243900,454.173757612 9611246,486.299900798,485.896883666,483.262429895 9611247,473.824761239,471.852264280,471.810784884 9611248,410.702142240,409.223549715,408.566113854 9611249,483.954196114,483.074291778,482.493456603 9611250,563.980748640,561.582949008,560.130304586 9611251,397.460670429,396.756414636,395.594741953 9611252,414.074526851,413.111175218,412.974737562 9611253,416.028327610,417.412278643,416.236016507 9611254,546.212606207,543.153874849,542.790959914 9611255,585.945638320,584.401463406,583.486980238 9611256,710.384237289,706.586907521,707.526853792 9611257,401.674220181,402.762271142,402.852102195 9611258,566.359188259,565.304581740,564.213738932 9611259,531.952854968,531.117068520,529.093251077 9611260,689.650204890,687.484385246,685.818654223 9611261,675.889038367,674.430504060,673.924926877 9611262,417.232691507,417.014339337,416.675324299 9611263,689.587534791,686.641804737,686.079800729 ```