{"sources":[{"url":"https://raw.githubusercontent.com/gtmcknight/amm-sim/66604b3426d8e97a73e2c39940b9b4dece51cc73/research/tell/README.md","quote":"- **Retail** (`market/router.rs`). A leg's paid amount is `numerator / denominator`, or the whole order, or the order less the other leg: a double of no particular grid, whose own last bit is hundreds of times finer than the reserve's.\n\nSo: the amount paid (Y when the pool sold X, X when it bought X"},{"url":"https://raw.githubusercontent.com/gtmcknight/amm-sim/66604b3426d8e97a73e2c39940b9b4dece51cc73/research/solved/README.md","quote":"- **The rival's spot is known from our own trades.** After an order that splits, both pools sit at the same marginal price: rival spot = own spot x 0.997 / (1 - own fee) on a buy, own spot x (1 - own fee) / 0.997 on a sell. Tracking it that way costs 0.19.\n- **Run parameters need no adaptation.** Ta"},{"url":"https://raw.githubusercontent.com/gtmcknight/amm-sim/66604b3426d8e97a73e2c39940b9b4dece51cc73/research/tell/fetch.sh","quote":"#!/bin/sh\n# Fetch ../solved and this folder into ONE directory and check every file's sha256.\n# usage: sh fetch.sh <raw URL of research/ at a commit> [dir]        default dir: test/scratch/amm\n# This folder's README.md lands as TELL.md and its fetch.sh as fetch-tell.sh; ../solved keeps its names.\nse"},{"url":"https://raw.githubusercontent.com/gtmcknight/amm-sim/66604b3426d8e97a73e2c39940b9b4dece51cc73/research/tell/tellpol.py","quote":"    def on_grid(self, is_buy, ax, ay, x, y):\n        \"\"\"(whether the amount paid is fl(n * grid / gamma) for a whole n, the chance a retail amount is)\"\"\"\n        if is_buy: paid, gamma, grid = ax, 1.0 - self.fb, min(math.ulp(self.px), math.ulp(x))   # the pool bought X: X was paid\n        else:     "},{"url":"https://raw.githubusercontent.com/gtmcknight/amm-sim/66604b3426d8e97a73e2c39940b9b4dece51cc73/research/tell/tellref.py","quote":"def is_arb(is_buy, amount_x_w, amount_y_w, reserve_x_w, reserve_y_w, prev_reserve_x_w, prev_reserve_y_w, bid_fee_w, ask_fee_w):\n    \"\"\"True when the amount the trader paid is one the arbitrageur's arithmetic produces.\n\n    is_buy as afterSwap has it: true when the pool bought X.  The fees are the on"},{"url":"https://raw.githubusercontent.com/gtmcknight/amm-sim/66604b3426d8e97a73e2c39940b9b4dece51cc73/research/tell/mirror.py","quote":"def split_buy(a1, a2, total_y):\n    g1 = 1.0 - fee_f64(a1.ask_w); g2 = 1.0 - fee_f64(a2.ask_w)\n    A1 = math.sqrt(a1.rx * g1 * a1.ry); A2 = math.sqrt(a2.rx * g2 * a2.ry)\n    if A2 == 0.0: return (total_y, 0.0)\n    r = A1 / A2\n    num = r * (a2.ry + g2 * total_y) - a1.ry\n    den = g1 + r * g2\n    y1 "},{"url":"https://raw.githubusercontent.com/gtmcknight/amm-sim/66604b3426d8e97a73e2c39940b9b4dece51cc73/research/solved/real.py","quote":"        if not is_arb:\n            if is_buy:\n                cand = s * (1.0 - self.fb) / G2\n                if cand < self.s2h: self.s2h = cand; self.synced = True\n            else:\n                cand = s * G2 / (1.0 - self.fa)\n                if cand > self.s2h: self.s2h = cand; self.synced = T"},{"url":"https://raw.githubusercontent.com/gtmcknight/amm-sim/66604b3426d8e97a73e2c39940b9b4dece51cc73/research/solved/replica2.py","quote":"                u1 = (r * (y2 + g2 * size) - y1) / d if d != 0 else size / 2\n                u1 = 0.0 if u1 < 0 else (size if u1 > size else u1)\n                u2 = size - u1\n                if u2 > 1e-4:\n                    nry = y2 + u2 * g2; nrx = K / nry; xo = x2 - nrx\n                    if xo"},{"url":"https://raw.githubusercontent.com/gtmcknight/amm-sim/66604b3426d8e97a73e2c39940b9b4dece51cc73/research/solved/run.py","quote":"        if getattr(inner, 'needs_flag', False): out = inner.on_trade(is_buy, ax, ay, t, x, y, arb)   # diagnostic policies only\n        else: out = inner.on_trade(is_buy, ax, ay, t, x, y)\n        if getattr(inner, 'first', False):\n            self.nfirst += 1\n            if bool(getattr(inner, 'is_a"},{"url":"https://raw.githubusercontent.com/gtmcknight/amm-sim/66604b3426d8e97a73e2c39940b9b4dece51cc73/research/solved/par.py","quote":"\"\"\"Run tasks across processes; fall back to one process where a pool cannot start.\nPROCS=<n> sets the process count (default: every CPU; 1 = no pool).\"\"\"\nimport os\n\n\ndef pmap(fn, tasks):\n    tasks = list(tasks)\n    n = int(os.environ.get('PROCS', '0') or 0) or (os.cpu_count() or 1)\n    if n <= 1 or "},{"url":"https://raw.githubusercontent.com/gtmcknight/amm-sim/66604b3426d8e97a73e2c39940b9b4dece51cc73/research/solved/evalpol.py","quote":"\"\"\"Run a solved (dp.py) perfect-information policy on the pure-Python replica.\nusage: python3 -I evalpol.py <pol.json>[,<pol2.json>...] hold        seeds 10000..12047, paired vs the stored HA / old oracle table rows\n       python3 -I evalpol.py <pol.json> mid [n]                      midpoint parame"},{"url":"https://raw.githubusercontent.com/gtmcknight/amm-sim/66604b3426d8e97a73e2c39940b9b4dece51cc73/research/solved/pair.py","quote":"\"\"\"Pair two sets of run.py results on their common seeds.\n\nusage: python3 -I pair.py <candidate.json[,more parts]> <reference.json[,more parts]>\nPrints paired{n, mean_diff, se, worst5} and each side's own line (with vs HA where HA rows exist: seeds 10000..12047).\n\"\"\"\nimport sys, os, json\nHERE = os.p"},{"url":"https://raw.githubusercontent.com/gtmcknight/amm-sim/66604b3426d8e97a73e2c39940b9b4dece51cc73/research/tell/tell_qm.json","quote":"{\"policy\": \"tellpol:TellPolicy\", \"opt\": {\"soft\": 1.0, \"qm\": \"qm_k1e-5.json\"}, \"rows\": [{\"seed\": 10000, \"edge\": 446.7525003520403, \"retail\": 466.45478501028487, \"arb\": -19.702284658243357, \"rv\": 64472.74497516746, \"av\": 20711.24608942138, \"first\": 6271, \"misread\": 1, \"se\": 450090.42467588634, \"nse\": "},{"url":"https://raw.githubusercontent.com/gtmcknight/amm-sim/66604b3426d8e97a73e2c39940b9b4dece51cc73/research/tell/SHA256SUMS","quote":"ad382c07e6c2b3a5a8055ea767e140b7461105f29dafee69b7c1766c90d0634f  tell_qm.json\n6e62a0e070d9778537e746438f03ea7a4b44cb1d9652ae13702b801997db5f6d  tellpol.py\n72679df55e2ba46a903075543654b685e7b2bf86dfbef3d5122dff6368d4a4f2  tellref.py\n7483623d551bd6334547b6b1fcd621b4d721dd2082011b6c113f083421396947  v"},{"url":"https://raw.githubusercontent.com/gtmcknight/amm-sim/66604b3426d8e97a73e2c39940b9b4dece51cc73/research/solved/SHA256SUMS","quote":"5ff53e42ca87390e5f65d1caa3f7a480e67a8212fb0670274dfd562b05ba1afd  qm_k1e-5.json\n63b8c35048718c37eb0a5dae9e70849fa3af257c335e4a2e3a625c833f1dc1eb  qmdp.py\nb8159b7a7235e3a2b137c95fec27b27fc804aa33eb5e79ec46aef7a32cb96030  README.md\n7fc9f4bdf9a9af094ec2eb0e9a8e8eec8b343c5226bf0ebaa30c798785cb7c58  real"},{"url":"https://raw.githubusercontent.com/ethereum/EIPs/master/EIPS/eip-2929.md","quote":"| `COLD_SLOAD_COST` | 2100 |"},{"url":"https://raw.githubusercontent.com/ethereum/EIPs/master/EIPS/eip-2929.md","quote":"| `SSTORE_RESET_GAS` | 5000 | `5000 - COLD_SLOAD_COST` |"}]}
