From 9def3dae5e0213168a34cb94c2e6f54fcdcb572c Mon Sep 17 00:00:00 2001 From: gravermistakes Date: Mon, 19 Oct 2026 19:42:33 -0700 Subject: [PATCH] docs: add M3c V1 runtime contract --- core/src/economy/sims/amm/README.md | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 core/src/economy/sims/amm/README.md diff --git a/core/src/economy/sims/amm/README.md b/core/src/economy/sims/amm/README.md new file mode 100644 index 0000000..4e6f46b --- /dev/null +++ b/core/src/economy/sims/amm/README.md @@ -0,0 +1,27 @@ +# M3c — AMM & liquidity simulator + +M3c V1 is the Solidity-native AMM simulator behind the stomach's `amm_liquidity` prediction type. + +Implemented mechanics: fee-adjusted constant-product swaps; exact fixed-point impermanent loss; nonlinear slippage; IL-derived withdrawal thresholds; active LP rebalance; just-in-time liquidity fee economics; deterministic backrun and sandwich simulation; concentrated-liquidity position amounts and volatility/horizon range forecasts; deterministic exact-input splitting across two pools. + +The five public prediction types are `impermanent_loss`, `pool_return`, `optimal_range`, `slippage_estimate`, and `lp_withdrawal_threshold`. Every publication remains a numeric `BoundedPrediction` with explicit lower/value/upper bounds. + +Calibration consumes normalized M2 `dex_pool_state` and `price_tick` histories. Source confidence sets the uncertainty width; recent literal pool-state history supplies a retrospective correctness score. + +The live simulation boundary is: + +`M2 → AMMRunner (Tcl) → AMMQuery (read-only eth_call) → AMMSim → SimsHub → Marketplace` + +`AMMQuery.sol` is stateless and exposes only pure query methods. It has no transfer, approval, swap, signer, broadcaster, or privileged function. CI deploys it only to a fresh ephemeral local Anvil instance. + +V1 concentrated liquidity covers position/range accounting, not full initialized-tick traversal. V1 multi-pool routing optimizes across two pools; N-way routing is a scaling extension. + +Verification: + +```sh +cd core/src/economy/sims/amm +forge test -vv +tclsh integration.test +``` + +The dedicated M3c workflow enforces both the native Foundry suite and the Tcl M2→M3c→Hub summary.