{"sources":[{"url":"https://api.imdnotdead.fun/artifacts/755f4fc0a7b028497ad9ddf23ea568071192341e192335cb7f31174d066d4df0","quote":"3a799de034a2482ff960dc0d89316a18a70ccff80b1d80af2e3b2d110977ec40"},{"url":"https://api.imdnotdead.fun/artifacts/ce5b4e6f21a08070df1df5e784c374eaf555f1540405c1c33864a710683fe8d8","quote":"830868f9b3e5ad162c4f2070e6faed0782c7b4cc308ab69044b2cf7306f68099"},{"url":"https://raw.githubusercontent.com/gtmcknight/amm-sim/66604b3426d8e97a73e2c39940b9b4dece51cc73/research/tell/README.md","quote":"A port's own gates: its `isArb` gives `expected` (the last field) on every vector of `vectors.json.gz`; the whole contract, driving the replica with its own fees and shadowed by `tellpol.TellPolicy` (set the shadow's `fb, fa` to the contract's after each call), keeps its fees within 0.01 bps; afterSwap peak at or under 245,000 gas with 0 OutOfGas; no revert; `amm-match validate` passes; 24,576 byt"},{"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 ones in force for the\n    trade: what the contract returned from its previous callback, clamped to 10%"},{"url":"https://raw.githubusercontent.com/gtmcknight/amm-sim/66604b3426d8e97a73e2c39940b9b4dece51cc73/research/tell/tellpol.py","quote":"class TellPolicy(real.RealPolicy):\n    def __init__(self, T, opt=None):\n        opt = dict(opt or {})\n        self.pin = bool(opt.pop('pin', 0))\n        real.RealPolicy.__init__(self, T, opt)\n        self.needs_flag = False                     # the harness tells it nothing\n        self.px, self.py = 100.0, 10000.0           # the reserves afterInitialize is handed\n\n    def on_grid(self, is_buy, a"},{"url":"https://raw.githubusercontent.com/gtmcknight/amm-sim/66604b3426d8e97a73e2c39940b9b4dece51cc73/research/solved/real.py","quote":"class RealPolicy(DPPolicy):\n    def __init__(self, T, opt=None):\n        DPPolicy.__init__(self, T)\n        self.o = opt or {}\n        self.Q = load(self.o['qm']) if 'qm' in self.o else None\n        self.synced = False\n        self.m = math.log(100.0); self.v = 0.0\n        self.tlast = 0; self.cnt = 0\n        self.s2h = 100.0\n        self.fb = self.fa = 0.003\n        self.sp = 100.0               "},{"url":"https://raw.githubusercontent.com/gtmcknight/amm-sim/66604b3426d8e97a73e2c39940b9b4dece51cc73/research/solved/replica2.py","quote":"def clampf(f):\n    return 0.0 if f < 0.0 else (MAXF if f > MAXF else f)\n\n\ndef run(seed, policy, n_steps=10000, cfg=None, qcap=None):\n    cr = random.Random(10_000_000 + seed)\n    size_mean = cr.uniform(19.0, 21.0)\n    lam = cr.uniform(0.6, 1.0)\n    sigma = cr.uniform(0.000882, 0.001008)\n    if cfg:\n        size_mean, lam, sigma = cfg\n    pr = random.Random(seed)\n    rr = random.Random(seed + 1)\n  "},{"url":"https://raw.githubusercontent.com/gtmcknight/amm-sim/66604b3426d8e97a73e2c39940b9b4dece51cc73/research/solved/evalpol.py","quote":"class DPPolicy:\n    wants_j = True\n    def __init__(self, T, use_rival=True, use_phase=True):\n        self.T = T; self.W0 = T['W0']; self.NW = T['NW']; self.N2 = T['N2']; self.FB = T['FB']; self.C2 = T['C2']\n        self.h = T['H_bps']; self.W2L = T['W2L']; self.use_rival = use_rival; self.use_phase = use_phase\n        self.tabs = [(T['A0'], T['B0']), (T['A1'], T['B1']), (T['A2'], T['B2'])]\n    de"},{"url":"https://raw.githubusercontent.com/benedictbrady/amm-challenge/6b6921f8d463314aa7c96234e1be25a25245f704/contracts/src/AMMStrategyBase.sol","quote":"abstract contract AMMStrategyBase is IAMMStrategy {\n    /*//////////////////////////////////////////////////////////////\n                               CONSTANTS\n    //////////////////////////////////////////////////////////////*/\n\n    /// @notice 1e18 - represents 100% in WAD precision\n    uint256 public constant WAD = 1e18;\n\n    /// @notice Maximum allowed fee: 10% (1e17)\n    uint256 public cons"},{"url":"https://raw.githubusercontent.com/benedictbrady/amm-challenge/6b6921f8d463314aa7c96234e1be25a25245f704/contracts/src/IAMMStrategy.sol","quote":"struct TradeInfo {\n    bool isBuy;          // true if AMM bought X (trader sold X)\n    uint256 amountX;     // Amount of X traded (WAD precision, 1e18)\n    uint256 amountY;     // Amount of Y traded (WAD precision, 1e18)\n    uint256 timestamp;   // Simulation step number\n    uint256 reserveX;    // Post-trade X reserves (WAD precision)\n    uint256 reserveY;    // Post-trade Y reserves (WAD precis"},{"url":"https://raw.githubusercontent.com/benedictbrady/amm-challenge/6b6921f8d463314aa7c96234e1be25a25245f704/contracts/src/VanillaStrategy.sol","quote":"contract VanillaStrategy is AMMStrategyBase {\n    /// @notice Fixed fee in WAD (30 bps = 0.30% = 30e14)\n    uint256 public constant FEE = 30 * BPS;\n\n    /// @inheritdoc IAMMStrategy\n    function afterInitialize(uint256, uint256) external pure override returns (uint256 bidFee, uint256 askFee) {\n        return (FEE, FEE);\n    }\n\n    /// @inheritdoc IAMMStrategy\n    function afterSwap(TradeInfo calld"},{"url":"https://raw.githubusercontent.com/benedictbrady/amm-challenge/6b6921f8d463314aa7c96234e1be25a25245f704/amm_competition/competition/match.py","quote":"    def _build_configs(self) -> list[amm_sim_rs.SimulationConfig]:\n        \"\"\"Build simulation configs with optional variance.\"\"\"\n        import numpy as np\n\n        configs = []\n        for i in range(self.n_simulations):\n            rng = np.random.default_rng(seed=i)\n\n            retail_mean_size = (\n                rng.uniform(self.variance.retail_mean_size_min, self.variance.retail_mean_size_"},{"url":"https://raw.githubusercontent.com/benedictbrady/amm-challenge/6b6921f8d463314aa7c96234e1be25a25245f704/amm_competition/competition/config.py","quote":"BASELINE_VARIANCE = HyperparameterVariance(\n    retail_mean_size_min=19.0,\n    retail_mean_size_max=21.0,\n    vary_retail_mean_size=True,\n    retail_arrival_rate_min=0.6,\n    retail_arrival_rate_max=1.0,\n    vary_retail_arrival_rate=True,\n    gbm_sigma_min=0.000882,\n    gbm_sigma_max=0.001008,\n    vary_gbm_sigma=True,\n)\n\ndef _midpoint(min_val: float, max_val: float) -> float:\n    return (min_val +"},{"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.\nset -eu\nB=$1; D=${2:-test/scratch/amm}\nmkdir -p \"$D/ref\"\nget() {\n  if command -v curl >/dev/null 2>&1;"},{"url":"https://raw.githubusercontent.com/gtmcknight/amm-sim/66604b3426d8e97a73e2c39940b9b4dece51cc73/research/tell/SHA256SUMS","quote":"tellref.py\n7483623d551bd6334547b6b1fcd621b4d721dd2082011b6c113f083421396947  vectors.json.gz\n"},{"url":"https://raw.githubusercontent.com/gtmcknight/amm-sim/66604b3426d8e97a73e2c39940b9b4dece51cc73/research/solved/SHA256SUMS","quote":"real.py\n6e37b4e61e1ffa5ffb1e43912ddb8659105989aa986eb48fcd1d7608f8dca685  replica2.py\n54d19a9194ebedee8b947dfaaf8626b1e4ef6f7d1b5aa12e738ec01a5ce401ac  run.py\n2b6ff558726b79d644b9bcaefcb16bf28d139345b8ec7652a409e64c95e0820a  stale.py\nec7aabb10732c180e91bd9b2caf31ef9ca87feb15b3a4867967b3ce93b5b75f1  trace.py\n898c1eb0b57bad36eb28d2c6db3208e2072f67587b12f4c9ec3314d17168a06f  track.py\naaaccadc2f20bf25"},{"url":"https://raw.githubusercontent.com/gtmcknight/amm-sim/main/research/setup.sh","quote":"#!/bin/sh\n# Setup block of IMD goals 282fbc03 and amm-filter-1: run once from the amm-challenge checkout root; then `. scratch/env.sh`.\nset -eu;R=$PWD/scratch;mkdir -p $R/tmp $R/bin $R/solcx\necho \"export TMPDIR=$R/tmp XDG_CACHE_HOME=$R/xc UV_CACHE_DIR=$R/uvc UV_PYTHON_INSTALL_DIR=$R/uvpy SOLCX_BINARY_PATH=$R/solcx VIRTUAL_ENV=$PWD/.venv PATH=$PWD/.venv/bin:$R/bin:\\$PATH\" >$R/env.sh;. $R/env.sh\ncom"},{"url":"https://raw.githubusercontent.com/benedictbrady/amm-challenge/6b6921f8d463314aa7c96234e1be25a25245f704/amm_competition/evm/compiler.py","quote":"class SolidityCompiler:\n    \"\"\"Compiles Solidity strategies using py-solc-x.\n\n    Uses inline sources to avoid filesystem dependencies.\n    \"\"\"\n\n    SOLC_VERSION = \"0.8.24\"\n\n    # Path to the contracts directory with base contracts\n    CONTRACTS_DIR = Path(__file__).parent.parent.parent / \"contracts\"\n    CONTRACTS_SRC_DIR = CONTRACTS_DIR / \"src\"\n\n    # Opcodes we never allow in user runtime byteco"},{"url":"https://raw.githubusercontent.com/benedictbrady/amm-challenge/6b6921f8d463314aa7c96234e1be25a25245f704/amm_competition/evm/executor.py","quote":"class EVMStrategyExecutor:\n    \"\"\"Executes Solidity AMM strategies using pyrevm.\n\n    Provides gas-limited execution and tracks storage usage.\n    \"\"\"\n\n    # Gas limits\n    GAS_LIMIT_DEPLOY = 10_000_000\n    GAS_LIMIT_INIT = 250_000\n    GAS_LIMIT_TRADE = 250_000\n\n    # Maximum storage slots (enforced by contract, but we track for reporting)\n    MAX_STORAGE_SLOTS = 32\n\n    # WAD precision (1e18)\n   "}]}