dexbot 1.6.17 → 1.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (156) hide show
  1. package/CHANGELOG.md +58 -0
  2. package/README.md +24 -18
  3. package/analysis/README.md +105 -12
  4. package/analysis/ama_fitting/README.md +2 -2
  5. package/analysis/bot_fitting/README.md +3 -3
  6. package/claw/package.json +1 -1
  7. package/claw/runtimes/openclaw-plugin/openclaw.plugin.json +1 -1
  8. package/claw/runtimes/openclaw-plugin/package.json +1 -1
  9. package/dist/analysis/analyze_args.d.ts +2 -1
  10. package/dist/analysis/analyze_dynamic_weight.js +2 -1
  11. package/dist/analysis/analyze_kalman.js +3 -2
  12. package/dist/analysis/analyze_liquidity.d.ts +17 -0
  13. package/dist/analysis/analyze_liquidity.js +325 -0
  14. package/dist/analysis/analyze_regime.js +3 -2
  15. package/dist/analysis/analyze_regime_windows.js +3 -2
  16. package/dist/analysis/analyze_volatility.js +3 -2
  17. package/dist/analysis/fills_source.d.ts +1 -8
  18. package/dist/analysis/fills_source.js +1 -1
  19. package/dist/analysis/grid_correction_check.d.ts +9 -6
  20. package/dist/analysis/grid_correction_check.js +56 -64
  21. package/dist/analysis/liquidity/liquidity_chain.d.ts +66 -0
  22. package/dist/analysis/liquidity/liquidity_chain.js +178 -0
  23. package/dist/analysis/liquidity/liquidity_chart_generator.d.ts +19 -0
  24. package/dist/analysis/liquidity/liquidity_chart_generator.js +523 -0
  25. package/dist/analysis/liquidity/liquidity_depth_model.d.ts +141 -0
  26. package/dist/analysis/liquidity/liquidity_depth_model.js +230 -0
  27. package/dist/analysis/liquidity/liquidity_view.d.ts +38 -0
  28. package/dist/analysis/liquidity/liquidity_view.js +55 -0
  29. package/dist/analysis/math_utils.d.ts +1 -1
  30. package/dist/analysis/trade_profitability.d.ts +1 -1
  31. package/dist/analysis/trade_profitability.js +2 -1
  32. package/dist/analysis/tradingview/analyze_tradingview.js +2 -1
  33. package/dist/analysis/tradingview/tradingview_uplot_chart_generator.js +3 -3
  34. package/dist/analysis/trend_detection/huber_scale_variants.d.ts +4 -3
  35. package/dist/dexbot.js +74 -169
  36. package/dist/market_adapter/cli_args.d.ts +6 -1
  37. package/dist/market_adapter/cli_args.js +16 -2
  38. package/dist/market_adapter/core/kibana_candles.d.ts +5 -1
  39. package/dist/market_adapter/core/kibana_candles.js +3 -1
  40. package/dist/market_adapter/core/strategies/regime_gate.d.ts +7 -1
  41. package/dist/market_adapter/core/strategies/regime_gate.js +3 -1
  42. package/dist/market_adapter/inputs/cex_candle_parsing.d.ts +7 -2
  43. package/dist/market_adapter/inputs/cex_candle_parsing.js +3 -1
  44. package/dist/market_adapter/inputs/fetch_book_data.d.ts +7 -1
  45. package/dist/market_adapter/inputs/fetch_book_data.js +3 -1
  46. package/dist/market_adapter/inputs/fetch_cex_synthetic_data.js +2 -11
  47. package/dist/market_adapter/inputs/fetch_lp_data.d.ts +26 -1
  48. package/dist/market_adapter/inputs/fetch_lp_data.js +62 -52
  49. package/dist/market_adapter/inputs/kibana_feed_source.d.ts +14 -2
  50. package/dist/market_adapter/inputs/kibana_feed_source.js +14 -1
  51. package/dist/market_adapter/inputs/window_cache.d.ts +14 -3
  52. package/dist/market_adapter/inputs/window_cache.js +14 -1
  53. package/dist/market_adapter/lp_chart_runner.d.ts +12 -9
  54. package/dist/market_adapter/lp_chart_runner.js +3 -1
  55. package/dist/market_adapter/lp_chart_strategy_loader.d.ts +5 -1
  56. package/dist/market_adapter/lp_chart_strategy_loader.js +3 -1
  57. package/dist/market_adapter/market_adapter.d.ts +10 -2
  58. package/dist/market_adapter/market_adapter.js +10 -11
  59. package/dist/market_adapter/utils/chain.d.ts +2 -3
  60. package/dist/market_adapter/utils/file_json_cache.d.ts +5 -1
  61. package/dist/market_adapter/utils/file_json_cache.js +3 -1
  62. package/dist/market_adapter/utils/file_lock.js +1 -1
  63. package/dist/market_adapter/utils/native_history.d.ts +7 -3
  64. package/dist/market_adapter/utils/native_history.js +3 -1
  65. package/dist/market_adapter/utils/pair_orientation.d.ts +2 -2
  66. package/dist/modules/asset_lookup.d.ts +25 -0
  67. package/dist/modules/asset_lookup.js +75 -0
  68. package/dist/modules/bots_file_lock.d.ts +2 -2
  69. package/dist/modules/bots_file_lock.js +2 -2
  70. package/dist/modules/chain_scan.d.ts +64 -0
  71. package/dist/modules/chain_scan.js +80 -0
  72. package/dist/modules/cli_colors.d.ts +5 -0
  73. package/dist/modules/cli_colors.js +7 -0
  74. package/dist/modules/cli_progress.d.ts +51 -0
  75. package/dist/modules/cli_progress.js +113 -0
  76. package/dist/modules/constants.js +6 -3
  77. package/dist/modules/dexbot_class.d.ts +8 -0
  78. package/dist/modules/dexbot_class.js +10 -0
  79. package/dist/modules/dexbot_cow_runtime.d.ts +62 -1
  80. package/dist/modules/dexbot_cow_runtime.js +475 -47
  81. package/dist/modules/dexbot_credential_client.d.ts +5 -0
  82. package/dist/modules/dexbot_fill_runtime.js +20 -0
  83. package/dist/modules/dexbot_maintenance_runtime.js +71 -9
  84. package/dist/modules/dexbot_startup_runtime.js +7 -1
  85. package/dist/modules/graceful_shutdown.d.ts +2 -2
  86. package/dist/modules/graceful_shutdown.js +2 -2
  87. package/dist/modules/launcher/runtime_entry.d.ts +21 -1
  88. package/dist/modules/launcher/runtime_entry.js +36 -1
  89. package/dist/modules/launcher/runtime_mode.d.ts +4 -3
  90. package/dist/modules/liquidity_pool_ref.d.ts +32 -0
  91. package/dist/modules/liquidity_pool_ref.js +116 -0
  92. package/dist/modules/node_manager.d.ts +1 -1
  93. package/dist/modules/node_manager.js +1 -1
  94. package/dist/modules/order/accounting.js +2 -1
  95. package/dist/modules/order/export.d.ts +2 -2
  96. package/dist/modules/order/export.js +2 -2
  97. package/dist/modules/order/grid.d.ts +19 -14
  98. package/dist/modules/order/grid.js +269 -61
  99. package/dist/modules/order/grid_reconcile.js +27 -2
  100. package/dist/modules/order/grid_reconcile_internal.js +94 -15
  101. package/dist/modules/order/index.d.ts +24 -4
  102. package/dist/modules/order/manager.d.ts +12 -0
  103. package/dist/modules/order/manager.js +44 -11
  104. package/dist/modules/order/strategy.js +22 -2
  105. package/dist/modules/order/sync_engine.d.ts +32 -1
  106. package/dist/modules/order/sync_engine.js +209 -26
  107. package/dist/modules/order/utils/math.d.ts +26 -10
  108. package/dist/modules/order/utils/math.js +54 -14
  109. package/dist/modules/order/utils/order.d.ts +158 -11
  110. package/dist/modules/order/utils/order.js +434 -21
  111. package/dist/modules/order/utils/system.d.ts +136 -30
  112. package/dist/modules/order/utils/system.js +465 -63
  113. package/dist/modules/order/utils/validate.d.ts +1 -0
  114. package/dist/modules/order/utils/validate.js +37 -3
  115. package/dist/modules/storage/index.d.ts +3 -2
  116. package/dist/modules/storage/index.js +3 -2
  117. package/dist/modules/types.d.ts +14 -0
  118. package/dist/modules/utils/asset_symbols.d.ts +13 -2
  119. package/dist/modules/utils/asset_symbols.js +21 -2
  120. package/dist/scripts/analysis_runner.d.ts +10 -0
  121. package/dist/scripts/analysis_runner.js +33 -0
  122. package/dist/scripts/analyze-orders.js +2 -1
  123. package/dist/scripts/asset.d.ts +26 -0
  124. package/dist/scripts/asset.js +165 -0
  125. package/dist/scripts/bts_distribution.d.ts +1 -0
  126. package/dist/scripts/bts_distribution.js +194 -142
  127. package/dist/scripts/chart_command.d.ts +1 -1
  128. package/dist/scripts/chart_command.js +60 -86
  129. package/dist/scripts/chart_targets.d.ts +18 -0
  130. package/dist/scripts/chart_targets.js +52 -0
  131. package/dist/scripts/dw.js +1 -1
  132. package/dist/scripts/liquid.d.ts +24 -0
  133. package/dist/scripts/liquid.js +134 -0
  134. package/dist/scripts/rich_list.js +12 -16
  135. package/dist/scripts/token_distribution.d.ts +2 -0
  136. package/dist/scripts/token_distribution.js +132 -108
  137. package/dist/scripts/tv.js +1 -1
  138. package/dist/scripts/verify-browser-bundle.js +18 -0
  139. package/docs/COPY_ON_WRITE_MASTER_PLAN.md +1 -1
  140. package/docs/COW_INVARIANTS.md +21 -11
  141. package/docs/DEXBOT_COMPARISON.md +6 -6
  142. package/docs/EVOLUTION.md +10 -8
  143. package/docs/FUND_MOVEMENT_AND_ACCOUNTING.md +11 -11
  144. package/docs/GRID_PRICE_INVARIANT.md +28 -5
  145. package/docs/GRID_RECONCILE.md +25 -5
  146. package/docs/LIFECYCLE.md +11 -11
  147. package/docs/LOGGING.md +37 -2
  148. package/docs/ORDER_ENGINE_POST_1.0_RETROSPECTIVE.md +124 -36
  149. package/docs/README.md +1 -1
  150. package/docs/WORKFLOW.md +3 -1
  151. package/docs/architecture.md +115 -13
  152. package/docs/developer_guide.md +12 -0
  153. package/market_adapter/README.md +9 -4
  154. package/modules/README.md +23 -15
  155. package/package.json +6 -3
  156. package/scripts/README.md +23 -7
package/CHANGELOG.md CHANGED
@@ -2,6 +2,64 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file.
4
4
 
5
+ ## [1.7.0] - 2026-11-02 - Liquidity Depth Chart & `dexbot liquid`, Asset Distribution Shortcut, Pool-Ref Chart Targets, Case-Insensitive Asset Lookup, Orphan-Fill Attribution & Stale-Grid Re-Buy Discipline
6
+
7
+ ### 2026-11-02
8
+
9
+ - **Feat(liquidity)**: add a cumulative liquidity depth chart and the `dexbot liquid` command — a read-only analyzer (`analysis/analyze_liquidity.ts`, `analysis/liquidity/*`) blends a pair's live order book with its constant-product AMM pool using the vendored uPlot runtime. The curves stay separate rather than summed, support depth-asset switching and price inversion via axis clicks, reuse the shared 4-digit formatters, and keep the market centre centred when inverted. Depth is fetched through `get_limit_orders` (up to ~300 levels per side) with a `get_order_book` fallback, because the latter is commonly capped at 50 and silently truncated the curves; transport chatter is suppressed for the generator. Exposed as `dexbot liquid <bot|AssetA/AssetB>` with the same clickable `file://` trailer as `dexbot tv`, and the bot-target resolution plus analysis-script spawning is now shared between `tv`, `dw` and `liquid` instead of duplicated. Covered by new `tests/test_liquidity_depth.ts` and `tests/test_liquid_cli.ts` (pool invariant math, order-book side mapping, limit-order decoding and fallback, view inversion, HTML payload/formatting, offline CLI parsing).
10
+
11
+ - **Feat(cli)**: add `liq` and `liqu` as shortcuts for the liquidity depth chart — the command was only reachable as `liquid`/`liquidity`, which is cumbersome for something used repeatedly during research. Both aliases forward `--help` to the liquid script (alias resolution runs before the help-owning command check), and `--help`, `--cli-examples`, the README cheat sheet and the analysis/WORKFLOW docs all show `liq` while naming `liquid` canonical. Covered by new `tests/test_cli_aliases.ts`, which spawns the entrypoint to assert every spelling and the help listing.
12
+
13
+ - **Feat(cli)**: add `dexbot asset <bts|symbol>` (shorthand `a`) for supply distribution — the two analyzers were only reachable through `dist/scripts/*.js` or npm scripts, which sat awkwardly beside the other analysis commands. The router sends `bts` (or the core asset id) to the BTS report and any other symbol/id to the token report, with no `token` keyword: `asset token X` fails with a hint instead of a chain lookup. Forwarded flags are validated against the chosen analyzer (core asset: `--holders`/`--circulating`; issued asset: `--no-orders`/`--concurrency`) while the analyzers stay the single flag reference, and `asset` is help-owning so `--help` works offline. Both analyzers now log in the `[Liquidity]` style (`[Assets] Loading`, tagged transient progress, `Report saved` link, `[Assets] Error:`), and the `asset` npm script plus README/scripts README/WORKFLOW docs are added. Covered by new `tests/test_asset_cli.ts`.
14
+
15
+ - **Feat(cli)**: accept a pool id or pool token wherever `liq`/`tv`/`dw` take a target — `dexbot liq` resolved only bots and `AssetA/AssetB` pairs, and the shared chart pipeline behind `tv`/`dw` accepted numeric pool ids only. All three now take the same three target kinds (bot, pool, pair), where a pool is either its object id (`133` / `1.19.133`) or its pool token (the LP-share asset symbol, the same value a bot names in its `pool` setting). Parsing lives once in `modules/liquidity_pool_ref.ts` (`normalizePoolRef`, `isPoolIdRef`/`isPoolRefLike`, `poolAssetIds`, `resolvePoolRef`) with the chain read injected, so the module stays browser-safe and the commands cannot drift. `analysis/analyze_liquidity.ts --pool` accepts the same spellings and derives both legs when `--base`/`--quote` are omitted; a half-given pair beside `--pool`, a pool target combined with `--pool`, a valueless `--pool` and a pool/pair mismatch are all rejected with specific messages instead of silently charting something else, and a bare `--help` now prints usage rather than failing target validation. The CLI's child-process plumbing is centralized in `modules/launcher/runtime_entry.runRuntimeScript` (one `SCRIPT_COMMANDS` map, replacing nine copy-pasted spawn blocks plus the router copies in `scripts/analysis_runner.ts` and `scripts/asset.ts`), and `modules/cli_progress.ts` owns the `[Tag] …` progress/saved-line style. Behavioral impact: new accepted targets on read-only chart commands; existing targets, flags, reports and exit codes are unchanged, except a missing build or failed spawn now reports through the shared runner and `status` exits 1 rather than 0 when the unlock probe cannot be spawned. Covered by `tests/test_liquidity_pool_ref.ts`, `tests/test_cli_progress.ts` and the extended liquid/liquidity suites.
16
+
17
+ - **Fix(cli)**: resolve asset symbols case-insensitively through one lookup — every command that takes an asset from a human (`dexbot asset <symbol>`, `dexbot rich <asset...>`, `dexbot liq`/`tv`/`dw` pairs and pool tokens, `--base`/`--quote`) failed on any spelling that was not exactly the on-chain UPPERCASE symbol, because `get_assets`/`lookup_asset_symbols` are case-sensitive and a lowercase symbol resolved to null. `modules/asset_lookup.ts` is now the single resolver: refs are canonicalised with `normalizeAssetSymbol` (1.3.x ids pass through untouched), resolved in one batched `get_assets` call, and only an unresolved ref is retried once with the spelling as typed so a node holding a genuinely non-canonical symbol still resolves. The reader is injected, keeping the module browser-safe, and `assetSymbolCandidates` is the only place that decides the two spellings. Wired through `scripts/token_distribution.ts`, `scripts/rich_list.ts` (which keeps the caller's spelling in result rows and still applies the legacy `bit*` alias retry) and `analysis/liquidity/liquidity_chain.ts` (dropping its private id regex); `modules/liquidity_pool_ref.ts` resolves pool tokens through the same resolver. Behavioral impact: lowercase/mixed-case symbols now resolve instead of failing; `asset not found` still echoes the typed spelling, and already-correct input is unchanged. Covered by new `tests/test_asset_lookup.ts` plus reworked `test_liquidity_pool_ref` and `test_rich_list_symbol_normalization`.
18
+
19
+ - **Perf(cli)**: cut the asset reports' chain requests by an order of magnitude — both supply distribution commands only need per-asset metadata but asked the node for far more. The BTS report listed every asset (100 per page over thousands of assets) just to find the smart assets and sum fee pools, then fetched dynamic/bitasset data by id; it now derives smart assets from a dense walk of the 2.4.x implementation space plus one `get_assets` call (extended objects, so `total_in_collateral` stays available), sums fee pools from a 2.3.x walk, looks up symbols only for printed rows, uses the asset-scoped SameT/credit calls with `list_*` fallbacks on older nodes, and uses `list_htlcs` instead of probing the 1.16.0..1.16.99,999 range. The token report enumerates assets through the same dense 1.3.x walk (9 calls instead of 67 `list_assets` pages), fetches rich-list pages in parallel (with one sentinel page so a mid-scan rank shift cannot truncate the list), and raises the per-asset `get_limit_orders` sweep concurrency from 12 to 32 while keeping `--no-orders` as the fast path. The shared walks live in new `modules/chain_scan.ts`, which batches 1000 ids per call, halves the batch on nodes that refuse it, and defines `--gap` as exactly "gap consecutive missing ids" so results no longer depend on batch size; scans that hit their id limit now warn instead of silently shortening a bucket. Measured on mainnet: BTS ~92s → ~20s and token full runs ~50s → ~19s (~29s → ~12s with `--no-orders`), with outputs unchanged apart from chain drift. Covered by new `tests/test_chain_scan.ts` and pinned browser-safe in `scripts/verify-browser-bundle.ts`.
20
+
21
+ - **Refactor(cli)**: centralize report terminal output — the file-writing commands each re-implemented the same furniture: the section header (two copies), a warning block (`! ` in one report, `• ` in the other), the muted trailing summary, the `[Tag] Loading …` opener, and a saved-file trailer that had drifted into four spellings. `modules/cli_progress.ts` now owns all of them (`loadingLine`, `section`, `warningLines`/`warningsBlock`, `summaryLine`, `savedLine` with an optional `kind` so a mixed-case label still reads "Open report"), and `modules/cli_colors.ts` exports `colorize()`, the local `c(color, text)` wrapper scripts kept redeclaring; `CLI_TAGS` covers the remaining tags. Behavioral impact: every command that writes a file ends with the same clickable `file://` trailer (the research analyzers now get a link too), warnings render identically everywhere, and the BTS report no longer prints a duplicate plain `HTML report: <path>` plus `Collateral:` source line (provenance moved into the HTML footer). `--quiet`, `--json` and `--no-html` keep their behavior: no trailer when no file is written. Covered by the extended `tests/test_cli_progress.ts`.
22
+
23
+ - **Fix(order)**: stop stale-grid re-buys after a fill — a live incident had the bot buying at successively higher prices: a multi-minute stale broadcast region deferred the fill queue, then the post-fill targeted reconcile derived its window from a master that still held the filled slots as ACTIVE and re-created same-side orders at the top of the un-crawled rail, which filled within seconds. The root cause was upstream: fills whose order id no longer sat on an ACTIVE/PARTIAL slot were dropped ("order not found in active grid") after their accounting was booked, so neither the last-fill pivot nor the owed boundary crawl learned the real execution price, and every downstream geometry gate compared against a stale, higher pivot. Four gates now close it: (1) `hasUnsettledFills` defers the targeted reconcile and the window top-up while fills are queued, draining, in flight or owed a crawl, while 1:1 repairs (cancelled-slot replacement, vacated-rail refill) still run so a rail is never left un-repaired; (2) `SyncEngine._absorbUnmatchedFill` attributes such a fill to the slot that still owns the chain id and records the pivot plus owed crawl from the real execution price, without mutating the slot or already-booked accounting, and dry runs never grow the crawl ledger; (3) `isLastFillPlacementBlocked` applies the direction rule plus a same-grid-level refusal to every reconcile placement (both create paths and the re-pricing relocation), keeping a same-price relocation exempt as an adoption; (4) `_pickVirtualSlotsToActivate` uses the same predicate so the pick budget rolls to the next level instead of being spent on a level the create would refuse, restoring the documented rotate-to-bottom/counter-SELL behaviour. Behavioral impact: fail-closed during an unsettled fill window (a top-up waits one cycle, and a level on the wrong side of the last fill waits for the crawl); no new orders, sizes or boundary semantics. Docs: `GRID_RECONCILE` (fill discipline) and `LOGGING`. Covered by new `tests/test_grid_fill_discipline.ts` and `tests/test_fill_attribution_virtual_slot.ts`.
24
+
25
+ - **Fix(order)**: attribute orphan fills by price and repair dark levels — a follow-up audit of the stale-grid fix found six gaps of the same class, the first in the fix itself. Fill attribution looked the slot up by chain order id, but `virtualizeOrder()` nulls `orderId` on every virtualisation path, so the absorption never fired for the very fills it was written for (the re-delivered fills logged "order not found in active grid" and the reconcile re-created their levels); attribution now falls back to the genesis ladder level of the execution price (the same authority pass 2 uses for adoption), refuses prices outside the frozen rail so a shelf/manual order can never arm the pivot, and only owes a crawl for a hole the grid owns. A slot virtualised while its order stayed live on chain counted as inactive for window accounting while its order still counted in `chainCount`, so the side reported a shortfall it could never repair and the planner saw a free level that already held an order; `reviveVirtualSlotFromChain` now re-materialises such a slot in place (master-only, no broadcast) when the chain order rests at that slot's own level, wired into sync pass 1 and reconcile Phase 1, so a rotation alias whose cancel has not landed is never resurrected. Duplicate CREATEs are closed by keying slot occupancy on the id alone (any state) instead of `isOrderOnChain()`, with a soft reason that withholds only a possibly-landed CREATE rather than aborting the batch, and sync pass 1 clears a genuinely stale id on a non-placed slot without booking a fill (freshly assigned ids are deferred). The orphan-credit sweep now attributes before crediting through the same shared helper, the spread-correction planner uses the same ladder-snapped predicate as the broadcast guards instead of planning same-level creates that were refused, and the re-stamp leak counter uses the same same-level comparison its comment claims to detect. Behavioral impact: no new orders, sizes or boundary semantics; attribution and the revive are master-side only, the revive is level-gated, and everything stays fail-closed for one cycle while fills are unsettled. Docs: `GRID_RECONCILE` (identities, revive, occupancy) and `LOGGING`. Covered by extended fill-attribution, revive, occupancy, hole-gate and planner/guard-parity tests.
26
+
27
+ - **Fix(order)**: anchor-aware residual allow-list, pivot clock provenance and read-time TTL — three defects of the same shape (1) `reanchorBoundaryFromLastFill` derives the boundary from the fill batch's extremum, but the in-band allow-list that lets the fill's own PARTIAL residual survive was keyed on the last-processed pivot, so for every chunked sweep whose furthest fill was not the pivot the list matched nothing and the re-anchor was refused as `unsafe: placed_order_in_band` — exactly the shape the extremum resolution exists for; the list is now keyed on the anchor and stays narrow (one explicit slot, same side, same ladder level; REANCHOR-21 pins that a foreign in-band order still refuses). (2) `rearmLastFillPivotFromMarketFill` read `_lastFilledAt || _lastMarketFillAt` while the price came from the market-row resolver, so a market-row price could inherit a fresh book-seed timestamp and then re-stamp `_lastMarketFillAt` with it, refreshing the 24h lifetime on every rebuild until the row never expired; price, side and clock now travel as one row. (3) The pivot lifetime only existed at restore, so a long-lived process kept a >24h fill vetoing one side forever even though the geometry-bind watchdog reports that a fill or the pivot TTL restores the side; the TTL is now enforced where the reference is read, in both entry points, so that line is true with or without a restart, while an unknown age (legacy managers, the ambiguous two-sided book seed) never expires. `recordRestampBuyAboveAnchor` reads the same reference the guard does. Centralisation: one TTL reader and expiry predicate for all four sites (both restores and both read paths), one row reader with live/market adapters replacing four near-copies, and expiry logged once per expired value rather than per probe. Deliberately unchanged: the COW build lane keeps judging a ladder-snapped pivot (`resolveOnGridPivot`, tolerance one increment) rather than the raw placement predicate, pinned by PIVOT-004 and a `GRID_RECONCILE` note. Behavioral impact: a chunked sweep can now complete its re-anchor instead of stalling, and a side whose last fill is older than 24h is placeable again (the documented lifetime, already true across a restart); no new orders, sizes or boundary semantics, and no persistence-contract change. Docs: `COW_INVARIANTS`, `GRID_PRICE_INVARIANT`, `GRID_RECONCILE`, `LOGGING`, `ORDER_ENGINE_POST_1.0_RETROSPECTIVE`. Tests: REANCHOR-20/21, REARM-6/7/8, LFP-10, PIVOT-004, plus two fixtures corrected because they hard-coded a fill date.
28
+
29
+ - **Docs**: align the CLI reference and document the shared lookup, scan and trailer — `dexbot help` and the README "Bot Management" block disagreed on both order and naming: the block opened with the runtime-only `status` (spelled as its `stat` alias), taught the `liq` alias while the help called `liquid` canonical, and never listed `dw` or `rich`, so a reader could not know that `tv`/`dw` take the same targets or that `rich` exists. Both surfaces now use one investigation-order sequence (grid state and its data export, then market research, then accounting/chain context, then maintenance); the README moves `status` into the runtime block above and regroups the rest into those clusters, lists `liquid` instead of `liq`, corrects `asset <bts/token>` to `<bts|symbol>`, and the help Analysis group is reordered to match with `liq`/`liqu`/`liquidity` moved into the `liquid` description; `CLI_EXAMPLES` drops its alias-first snippet. `modules/README.md` lists the two new browser-safe modules (`asset_lookup`, `chain_scan`) and the widened `cli_colors`/`cli_progress` responsibilities, and `scripts/README.md` states the two cross-cutting rules (case-insensitive asset symbols through `modules/asset_lookup.ts`, one terminal trailer through `modules/cli_progress.ts`) and records how 1.13.x/1.15.x objects are enumerated now that no per-asset index exists. Docs and help text only: nothing is renamed, added or removed — `stat`, `liq`, `liqu`, `liquidity` and `a` still resolve. The CLI alias test's help-shape assertions are updated to match the new layout (`liquid` row plus `aliases: liq, liqu, liquidity`), since the previous `liq <target>` expectation no longer described the documented output. Full suite: 341/341 files (`npm test`, 14 live tests skipped); `typecheck`, `check:any`, `typecheck:analysis` and `verify:browser-bundle` clean.
30
+
31
+ ## [1.6.18] - 2026-11-01 - Partial-Fill Re-Anchor Recovery, Rail-Derived Boundary & Live Fill Prices, Edge-Fill Pivot Exclusion, Guard Arity Pinning, CLI `--flag=value`, Export-Surface Cleanup
32
+
33
+ ### 2026-11-01
34
+
35
+ - **Fix(spread)**: harden partial-fill re-anchor and recovery — a live market-pair bot stayed out of spread after a sell sweep even though the correction loop ran; four independent gaps combined. (1) A gap-evacuation plan built against an older boundary executed as a normal update once its live-geometry stamp went stale, moving valid in-rail buys off the bid edge and re-opening the spread: the build loop now skips a stale evacuation instead of falling through to the direction-only last-fill guard, and the final pre-broadcast gate drops a stamp whose live geometry went stale after op-building, including when the fill pivot itself did not change. (2) The fill anchor could not repair a window left behind a PARTIAL fill — the residual at the fill slot is inside the implied band by construction, so `validatePersistedBoundary` refused every re-anchor; the fill's own PARTIAL residual is now explicitly allow-listed (same side, same ladder level, exact anchor slot) while ACTIVE/foreign in-band orders still refuse, plus a post-clamp check that fails closed when the grid ceiling prevents the fill from leaving its window. (3) A re-anchor is absolute, but its plan carried only the derivation's consumed-crawl subset, so older owed deltas could be applied on top of the new boundary later: a successful re-anchor now snapshots and consumes the whole plan-time crawl ledger, and records recorded after plan build survive. (4) Create-only repair cannot close a fully allocated rail (free funds read 0 forever): when free funds cannot fund every promoted gap slot, a resting same-side ACTIVE order is rotated into the unfunded slot at its booked size (no new commitment, no growth/shrink; edge and PARTIAL sources excluded, crossing/last-fill/grid-price guards unchanged), rotation destinations come from the post-dedupe/post-duplicate-price candidate list so an already-occupied price cannot receive one, and rotation-only plans count as executable. Review hardening: startup and resume/reconcile load paths pass `tolerateTransientStranding` (the re-anchor deliberately leaves the fill's own PARTIAL residual in-band, so a strict load would rebuild the boundary away on the first restart); `reanchorBoundaryFromLastFill` requires `lastFillPivotSource === 'fill'`, because a one-sided book seed is a pricing hint for the guard, never an absolute geometry anchor (the bot-scoped last-market-fill row is the fallback); exactly-zero free funds now reach the rotation-only repair on the initial check, the TOCTOU re-plan and the fresh-master re-plan when the side decision carries the structured `no-free-funds` code (an unavailable market price stays a hard skip); and `plannedCount` includes rotation candidates so `checkSpreadCondition` reports the post-guard executed count rather than the plan count. Files: `order/grid_reconcile.ts`, `order/utils/system.ts`, `order/utils/math.ts`, `order/strategy.ts`, `order/grid.ts`, `dexbot_cow_runtime.ts`, `dexbot_startup_runtime.ts`; covered by `tests/test_stale_evac_build_skip.ts` and extended re-anchor, restore-validation, crawl-ledger, final-pivot-gate, spread-correction and pure-fund-driven tests.
36
+
37
+ - **Fix(order)**: keep the boundary on the placed rails and judge geometry by live fill prices — a sell sweep places counter BUYs on the promoted rail, but the refill hold kept the old committed boundary when the opposite-side refills were guard-skipped, so the next plan reclassified those counters as in-band and rotated SELLs onto their price, collapsing a 1.5% band to 0.3%; separately, a refused-commit adoption can leave a master slot keyed at an old generation price while its chain order trades elsewhere, and the fill pivot, GAP-EVAC and the crossing guard all trusted that stale price. `deriveRailBoundary` now clamps the committed boundary to the batch's resulting rails (`maxBuy <= boundary <= minSell-gap-1`, live master + kept op destinations) so counter orders win over empty refill holes, crossed or over-ceiling rails fail closed instead of self-legalizing, and `boundaryHeld` follows the value actually committed. Fill records now carry the chain execution price (history pays/receives, pass-1 chain price, pass-2 adoption, phantom cleanup) and the queued-fill pivot refresh prefers fill economics over the slot price without rewriting slot identity prices (GRID-PRICE-INVARIANT); `reanchorBoundaryFromLastFill` anchors on the fill batch's extremum for that side (max SELL/min BUY) rather than the mutable last-processed pivot, so a chunked sweep cannot leave its furthest counter in-band; new `resolveLiveOrderLadderPosition` maps the live chain price onto the ladder before falling back to the slot id for detection, drain-time validation and the eviction teeth, and a price mismatch whose live price is in-band queues a cancel-only `gapEvacuation` and drops any plain re-price for that chain order; the crossing candidate set uses the live chain price so an emission cannot print onto an opposite-side order adopted at a stale slot price. Risk: transient decisions follow the chain price while the grid slot identity stays frozen, and rail cross/ceiling failures keep the previous boundary and defer to GAP-EVAC. Covered by new `tests/test_rail_derived_boundary.ts` and `tests/test_live_geometry_provenance.ts` plus batch-extremum cases in `test_boundary_fill_reanchor`.
38
+
39
+ - **Fix(order)**: never arm the last-fill pivot from an edge-pinned fill — an edge order (grid floor/ceiling) is static fat-finger insurance, not market movement, yet `recordLastFilledPrices` armed the pivot on every fill and the pivot doubles as the absolute geometry anchor for `reanchorBoundaryFromLastFill`, so a wick that triggered a floor insurance BUY moved the window onto the grid edge (observed: boundary 29 -> 0 on a 60-slot ladder; mirrored at the ceiling). Eligibility now lives at the single pivot writer: fill ids are classified with `collectEdgePinnedFillIds` (`modules/order/utils/order.ts`), the same window/edge classifier the placement pickers use, so "edge" cannot mean two things; PARTIAL fills still arm the pivot (a partial at a far slot is a real trade and its residual is already allow-listed by the re-anchor). Behavioural impact: an edge fill no longer vetoes its own side of the book and can no longer drive an absolute boundary move — the guard and the anchor stay on the last WINDOW trade, so that side stays vetoed relative to it until a window fill or the 24h pivot TTL (the pre-fix alternative moved the whole window). The skip is logged (`[FILL-PIVOT] ... edge-skipped=K` plus a dedicated edge-only-batch line). Covered by new `tests/test_edge_fill_pivot.ts` and REANCHOR-18/19.
40
+
41
+ - **Fix(guard)**: pin the direction-only guard arity, re-arm the pivot explicitly, and stop self-legalizing the rail clamp — review follow-ups on the v1.6.12 -> v1.6.17 order-engine arc. `isLastFillGuardBlocked` still carried two dead parameters (`size`, `increment`) left over from the removed `pivot +/- increment/2` band, and keeping them made a band-rule reintroduction a compile-time non-event: the signature is now `(price, type, lastPrice, lastType)` at every call site (COW CREATE/rotation/fallback gates, planner predicate), and LFG-5 pins `.length === 4` plus "trailing arguments cannot resurrect a band". `initializeGrid` cleared the generation-bound pivot while its comment claimed the guard re-arms on the first real fill, and the read-time fallback silently kept an old-generation value, so after a rebuild in a market that had moved away one side read `last-fill-blocked` forever while the geometry clock rebuilt the generation every cooldown with no way to succeed: `rearmLastFillPivotFromMarketFill` now writes the re-arm explicitly through the one pivot writer (provenance `fill`, original fill timestamp, logged), and the geometry-bind escalation re-centers at most ONCE per pivot value (`_lastGeometryResyncPivotKey`) before reporting that only a fill or the 24h pivot TTL restores the side. `deriveRailBoundary` clamped onto EVERY live rail order, so one stray (refused-commit adoption, stranded hold, guard straggler) 18 slots off pulled the boundary 138 -> 115 and re-typed the whole window: rail membership is now the batch's own op destinations plus master orders on their own side of the planned boundary, strays are skipped and named in the log, rail indices come from the live chain price (`resolveLiveOrderLadderPosition`) instead of a possibly stale slot id, and the result passes the shared `validatePersistedBoundary` gate (cancel/rotation sources allow-listed, skipped on a sparse ladder whose array-derived ceiling would reject everything). Crossing CREATEs are observed rather than vetoed — a hard veto would re-open the counter-order deadlock after a gap — via `warnCrossingCreate`, logged once per batch from already-cached evidence (no chain call). Same pass: one pivot resolver (two verbatim copies merged), one boundary validator shared by the re-anchor and the rail clamp, and the batch-extremum logic extracted as the pure `resolveFillAnchorIndex`. Files: `order/utils/system.ts`, `order/utils/order.ts`, `order/grid.ts`, `order/grid_reconcile*.ts`, `dexbot_cow_runtime.ts`; covered by new `tests/test_last_fill_pivot_rearm.ts` plus RAIL-10..14, SLF-11/12 and arity updates in LFG-5, FG-9, GPI-WIRE-003 and SGP-1/4.
42
+
43
+ - **Fix(spread)**: count last-fill-excluded candidates per slot — the planner's "Excluded N candidate(s)" line counted pool visits, and a slot can legitimately appear in more than one candidate pool (an empty in-rail slot normalized to SPREAD satisfies both the SPREAD pool and the orphan pool, which the merge already dedupes), so every vetoed slot was reported twice and the over-count was worst exactly when the pools overlapped most. That number decides the `last-fill-blocked` stall and is the only signal for how much of a side the pivot blocked, so inflating it overstated the geometry bind. The counter now de-duplicates by slot id (an unidentified candidate still counts, since it cannot be matched); the plan itself is unchanged, the filter being a predicate and not a side effect. SLF-13 pins the overlap (`Excluded 2`, not `4`) and was verified failing on the pre-fix tree.
44
+
45
+ - **Refactor(analysis)**: judge fills by the direction-only guard — `analysis/grid_correction_check.ts` still implemented the old `pivot +/- increment/2` band while claiming to mirror `isLastFillGuardBlocked` 1:1, so it reported exactly the tightening placements the live guard allows. The predicate now matches the runtime rule (BUY < last fill, SELL > last fill, equal price blocked) with the same four arguments; the band fields are gone from the report header, violation table and JSON payload (per-row `halfInc` stays 0 so existing consumers keep their shape); `--increment` is documented as informational (default and configured value still reported); and the guard section of `analysis/README.md` documents the offline limits — edge-pinned fills cannot be reconstructed from the fill stream, so wick/insurance fills can appear as violations, and the spread-correction bypass is invisible per fill. Offline report only: no live behaviour change.
46
+
47
+ - **Feat(analysis)**: step SMA/VWMA period controls by 10 — the chart toolbar's period steppers moved one unit per click, making broad sweeps (e.g. 500 -> 600) tedious and hold-to-repeat slow. SMA and VWMA up/down buttons now step by 10 per click and per hold tick, the SMA arrow floor rises from 1 to 10 to match the 10-unit step, and the VWMA lower clamp/arrow floor drops from 24 to 10 so the 10-step sequence is reachable across the whole allowed range (manual entry unaffected apart from the lower clamp). AMA controls and chart rendering are unchanged.
48
+
49
+ - **Refactor(market_adapter)**: remove dead paths and narrow the test surface — the adapter still carried a native-history fallback that could never run (adapter_client exposes only db/history proxies, so `history.getMarketHistory` is always present and `BitShares.tradeHistory` never existed on the client shape), the CEX seeder's `typeof`/`||` guards re-checked helpers destructured from a `require` that would already have thrown, and seven types were exported although only used inside their defining modules. 41 test-only named exports became one explicit `__test` object per module: production callers keep the same public surface, tests still reach the internal seams, and future dead-export scans no longer need to special-case white-box helpers. The LP exporter CLI drift is fixed by routing it through the shared `walkCliArgs` walker (with `--help`, unknown flags rejected instead of silently ignored, and `--chunkMonths`, `--apiKey`, `--out` documented), the README no longer claims the adapter only handles 1h candles, and the file-lock default payload no longer writes an owner UUID into `pid` — it records `runtime.pid` while keeping the unique ownerId for release checks.
50
+
51
+ - **Fix(market_adapter)**: accept `--flag=value` and validate the LP export CLI — `walkCliArgs` rejected any value token starting with `--`, so a path or API key beginning with `--` could not be passed at all, and the LP exporter had drifted onto bare `parseInt`, silently storing `NaN` for `--chunkMonths abc`. The walker now understands `--flag=value` (the escape hatch for flag-shaped values), refuses an inline value on a flag/help that takes none, and reports an unknown token exactly as typed; the exporter routes its options through validating helpers (`--chunkMonths` an integer >= 1, `--precA`/`--precB` integers >= 0 with an empty inline value no longer read as 0, `--apiKey`/`--out` non-empty) and `--help` documents the `=` form. Behavioral impact for `fetch_lp_data`: unknown flags still fail, invalid numbers now fail naming the flag instead of producing `NaN`, and a flag-shaped value must use `--flag=value`. Covered by new `tests/test_cli_args_walker.ts` and extended `tests/test_fetch_lp_data_logic.ts`.
52
+
53
+ - **Fix(build)**: export the credential response type and pin the backtest slope test — the claw credential wrapper infers `Promise<CredentialDaemonResponse>` from the imported client, but declaration emit cannot name a module-private interface there, so `npm run build --prefix claw` failed with TS4058; the type is exported again (compile-time surface only, with a comment explaining why it must stay exported). `test_backtest_bot_fitting_logic` still hardcoded the old 0.09 AMA max-slope default and failed once the canonical constant moved to 0.1, so the full/half/sub-strength inputs are derived from `MARKET_ADAPTER.DYNAMIC_WEIGHT_AMA_MAX_SLOPE_PCT` and track the production knob instead of drifting on the next tune. Both restore a green `npm test` (331/331 files, 14 live tests skipped) and `build --prefix claw` on this branch.
54
+
55
+ - **Test(guards)**: enforce the `__test` seam and run the analysis typecheck in `npm test` — the `__test` convention replaced 41 named exports with one seam object per module, but nothing prevented production code from importing that object, so a future caller could quietly build on a test-only surface; and the standalone analysis tsconfig (stricter: `noUnusedLocals`/`noUnusedParameters`) was reachable only through `npm run typecheck:analysis`, so it could rot unnoticed. `tests/test_public_surface_guard.ts` scans every production `.ts` file (modules, market_adapter, analysis, scripts, claw and the root entrypoints) and fails if `__test` is referenced without defining a seam or if a seam is touched more than once inside its defining module, and `npm test` / `npm run test:live` now run `typecheck:analysis` before the suite.
56
+
57
+ - **Refactor(analysis)**: drop dead exports and correct stale docs — the analysis surface is aligned with its real callers and output locations: the README states that shared chart/bot-key helpers are imported by the production market adapter and that `--source market_adapter` prefers the bot candle cache before the centers file; the AMA optimizer/backtest docs point at `analysis/results/` (`PATHS.ANALYSIS.RESULTS_DIR`), not `analysis/ama_fitting/`; zero-consumer exports are narrowed back to internal types; the inert `analysis/.npmignore` is removed (the package `files` allowlist already ships only the analysis READMEs plus uplot); and `analysis/tsconfig.json` is wired into `typecheck:analysis` so the standalone config is actually used. **Removed CLI surface**: the deprecated `--tolerance` alias of `grid_correction_check` is gone — its band no longer exists and `--increment` already carries the report label.
58
+
59
+ - **Refactor(modules)**: remove dead exports, params and the slot-helper shim — an audit of `modules/` found no unreachable files or unused locals, but a layer of vestigial surface: ten symbols are de-exported (the remaining over-export candidates stay exported because declaration emit needs them named across modules, TS4023/TS4058), the `parseSlotIndex` forwarding wrapper and re-export in `order/utils/order.ts` are dropped so all callers import the canonical helper from `order/utils/slot.ts` and the two copies cannot drift again, the `calculateOrderCreationFees` JSDoc is corrected, and `lazy_shim.ts` / `launcher/runtime_mode.ts` are documented in `modules/README.md`. **Breaking for out-of-tree `dist/` consumers**: `allocateFundsByWeights`, `calculateOrderSizes` and `calculateRotationOrderSizes` lose their unused trailing `minSize`/`minSellSize`/`minBuySize` parameters (every in-repo caller passed 0, so behaviour is unchanged); in-tree call sites and tests are updated positionally.
60
+
61
+ - **Docs**: symbol-name citations and export-surface rules replace drifted line numbers, and the module map is corrected — 36 of 64 `file.ts:LINE` references in `docs/` no longer pointed at the code they described, so every one is now a symbol name plus filename, which also removed three outright-wrong claims (a deleted `computeOutOfToleranceDriftTag` listed as a live `priceForSlot` consumer, a non-existent `ANCHOR.PROJECTION_ENABLED` asserted dead three times, and a misnamed maintenance entry point); two documented symbols were corrected and deliberately removed ones keep only the filename. `modules/README.md` moves `runtime_mode.ts` into the `launcher/` block (it was the only tree entry resolving to nothing), fixes descriptions that sent readers to the wrong subsystem (`chain_keys` as the master-password vault plus signing-key retrieval, `credential_runtime` as socket/path helpers, `daemon_node_health` as a failure ledger with no health checking, `socket_json_client` as newline-delimited JSON rather than JSON-RPC, `storage/browser_adapter` as an IndexedDB-persisted Map), unwraps two markdown links that sat inside a fenced tree, names the real crypto split and fill wiring in the principles, and re-aligns three one-column-off rows; module-header usage snippets that used CommonJS `require()` in a `"type": "module"` package now use static imports with `.js` specifiers. `developer_guide` gains an "Export Surface & Test Seams" section (declaration emit is a real consumer, shipped `dist/` is a public API, test-only helpers live in one `__test` object enforced by `tests/test_public_surface_guard.ts`), and `ORDER_ENGINE_POST_1.0_RETROSPECTIVE` is reconciled with the code: §0/§6/§7 described the offline checker with old band semantics, §9.1/§9.7/§9.9 carried pre-fix statements, the header/TOC/snapshot/footer said v1.6.14, the §9.5 ledger gained rows for the whole 1.6.15/1.6.17 arc and the post-1.6.17 work, §9.6 gained four invariants (only a window trade may become the pivot, one boundary validator, a rail clamp cites only its own evidence, the pivot has a lifetime), and R2-R5 record the "one rule, several implementations" meta-pattern plus lessons 8-11. `COW_INVARIANTS`, `architecture`, `GRID_PRICE_INVARIANT` and `LOGGING` document the new rail-clamp membership, re-anchor eligibility, explicit re-arm, once-per-pivot re-center, `[COW-CROSS-GUARD]` line, capped re-center warning and the per-slot "Excluded N" count. Docs/comments only; `npm test` 331/331.
62
+
5
63
  ## [1.6.17] - 2026-10-30 - Last-Fill Direction Guard, Spread-Correction Stall Naming & Chain-Truth Funding, Owed-Crawl Consumption, Restart Auth-Before-Stop, Pool-Priced LP Collateral, Supply Distribution Analyzers
6
64
 
7
65
  ### 2026-10-30
package/README.md CHANGED
@@ -317,6 +317,7 @@ Defaults in [`modules/constants.ts`](modules/constants.ts) are overridable at gl
317
317
  `dexbot start` is the recommended production runtime (global install). Repo-root users can run `./unlock` instead. It runs the selected bot set as one monolithic bot process, with the credential daemon and market adapter in separate helper processes. Monolithic start/stop/reload/restart controls apply to the whole runtime, not to individual bots: a bot argument (e.g. `dexbot reload <bot>`) is validated and then folds into the whole-runtime action with a notice. Per-bot control needs `--isolated` (one supervisor process per bot, then `stop`/`reload`/`restart <bot>` acts on just that bot). `delete` and `status` are whole-runtime only. `dexbot help` detects which runtime is up (monolithic, isolated, or PM2) and lists the controls for that mode.
318
318
 
319
319
  ```bash
320
+ dexbot status # Runtime health: credential daemon, adapter, bots
320
321
  dexbot start/stop # Stop/start the monolithic runtime
321
322
  dexbot start --dryrun # Dry-run (no transactions broadcast)
322
323
  dexbot reload [<bot>] # Reload (monolithic: whole runtime; isolated: one bot)
@@ -329,24 +330,29 @@ First-run details and common mistakes are covered in the [BitShares Onboarding T
329
330
  ## 🛠️ Bot Management
330
331
 
331
332
  ```bash
332
- dexbot key # Master password/keyring
333
- dexbot bot # Interactive bot configurator
334
-
335
- dexbot reset {all|<bot>} # Regenerate grid
336
- dexbot disable {all|<bot>} # Disable bot in config
337
- dexbot enable {all|<bot>} # Enable bot in config
338
-
339
- dexbot stat # Runtime status (unlock or PM2)
340
- dexbot order [<bot>] # Analyze order grids (--export → HTML to analysis/charts/)
341
- dexbot tv <bot|pool|A/B> # TradingView 1h chart with AMA overlay (default: 3 months)
342
- dexbot pnl <bot|account> # HTML PnL report (--month N, optional --pair A/B)
343
- dexbot credit [<bot>] # Live summed MPA + borrowed-credit positions
344
- dexbot export <bot> # Export trades + settings (CSV/JSON) for analysis/
345
-
346
- dexbot update # Update DEXBot2
347
- dexbot clear # Delete log files in <profiles>/logs
348
- dexbot default # Reset settings to defaults
349
- dexbot help # Grouped command reference
333
+ dexbot key # Master password/keyring
334
+ dexbot bot # Interactive bot configurator
335
+
336
+ dexbot reset {all|<bot>} # Regenerate grid
337
+ dexbot disable {all|<bot>} # Disable bot in config
338
+ dexbot enable {all|<bot>} # Enable bot in config
339
+
340
+ dexbot order [<bot>] # Grid state: spread, increment, funds (--export → HTML)
341
+ dexbot export <bot> # Trades + settings → CSV/JSON for analysis/
342
+
343
+ dexbot tv <bot|pool|A/B> # TradingView 1h chart with AMA overlay (default: 3 months)
344
+ dexbot dw <bot|pool|A/B> # Dynamic-weight research chart (same targets/flags as tv)
345
+ dexbot liquid <bot|pool|A/B> # Liquidity depth: order book + AMM pool (aliases: liq, liqu)
346
+
347
+ dexbot pnl <bot|account> # HTML PnL report (--month N, optional --pair A/B)
348
+ dexbot credit [<bot>] # Live summed MPA + borrowed-credit positions
349
+ dexbot asset <bts|symbol> # Supply distribution + HTML report (short: dexbot a bts)
350
+ dexbot rich <asset...> # Top holders per asset
351
+
352
+ dexbot update # Update DEXBot2
353
+ dexbot clear # Delete log files in <profiles>/logs
354
+ dexbot default # Reset settings to defaults
355
+ dexbot help # Grouped command reference (runtime, trading, config, analysis, files)
350
356
  ```
351
357
 
352
358
  ## 🎯 PM2 Process Management
@@ -1,6 +1,6 @@
1
1
  # Analysis
2
2
 
3
- Tools that inspect DEXBot trading behavior and the market data it operates on. Output is interactive HTML charts written to `charts/` (regenerated on each run, not committed); none of this runs in production.
3
+ Tools that inspect DEXBot trading behavior and the market data it operates on. Output is mostly interactive HTML charts written to `charts/` (regenerated on each run, not committed) and JSON results under `results/`; the trade analyzers can also export CSV/JSON to a caller-supplied path. The runners are research-only, but their shared chart and bot-key helpers are imported by the production market adapter.
4
4
 
5
5
  ## Contents
6
6
 
@@ -22,10 +22,11 @@ Tools that inspect DEXBot trading behavior and the market data it operates on. O
22
22
  |------|----------------|------------------|
23
23
  | [`trade_profitability.ts`](#trade-profitability-analyzer-trade_profitabilityts) | "Is my bot making money?" — PnL, R-multiples, drawdown | `npm run analysis:trade-pnl -- <account-id>` |
24
24
  | [`dexbot pnl`](#pnl-html-report-dexbot-pnl) | "Give me a readable PnL report" — self-contained HTML with a lot table | `dexbot pnl <bot\|account> --month 3` |
25
- | [`grid_correction_check.ts`](#last-fill-guard-check-grid_correction_checkts) | "Are fills respecting the pivot ± half-increment guard?" | `npm run analysis:grid-check -- --bot-key <bot-key>` |
25
+ | [`grid_correction_check.ts`](#last-fill-guard-check-grid_correction_checkts) | "Are fills respecting the direction-only last-fill guard?" | `npm run analysis:grid-check -- --bot-key <bot-key>` |
26
26
  | [`analyze_risk_profile.ts`](#risk-profile-analyzer-analyze_risk_profilets) | "How wide should my Safe Range clamps be?" | `node dist/analysis/analyze_risk_profile.js --bot-key <bot-key>` |
27
27
  | [`analyze_trade_heatmap.ts`](#trade-heatmap-analyze_trade_heatmapts) | "Where did trade volume cluster vs the AMA?" | `node dist/analysis/analyze_trade_heatmap.js --bot-key <bot-key>` |
28
28
  | [`tradingview/analyze_tradingview.ts`](#tradingview-chart-tradingviewanalyze_tradingviewts) | "Just give me a candle chart" | `dexbot tv <bot-key>` |
29
+ | [`analyze_liquidity.ts`](#liquidity-depth-chart-analyze_liquidityts) | "Where is the pair's real liquidity — order book, AMM pool, or both?" | `npm run analysis:liquidity -- --pair TOKENA/TOKENB` |
29
30
  | [`analyze_dynamic_weight.ts`](#dynamic-weight-research-analyze_dynamic_weightts) | "Are buy/sell weights tuned for this regime?" | `dexbot dw <bot-key>` |
30
31
  | [`analyze_volatility.ts`](#volatility-analyze_volatilityts) | "Both weights clipped too hard / not enough?" | `node dist/analysis/analyze_volatility.js --bot-key <bot-key>` |
31
32
  | [`analyze_regime.ts`](#supporting-sub-signals) | "Is the trend/chaos gate too aggressive?" | `node dist/analysis/analyze_regime.js --bot-key <bot-key>` |
@@ -76,14 +77,14 @@ node dist/analysis/analyze_dynamic_weight.js --bot-key <bot-key>
76
77
  npm run analysis:trade-pnl -- 1.2.123456 --hours 168
77
78
  ```
78
79
 
79
- > The market adapter source reads from `market_adapter/state/market_adapter_centers.json` — run the bot first to populate state.
80
+ > The market adapter source prefers the bot's cached candle file and falls back to `market_adapter/state/market_adapter_centers.json` — run the bot first to populate state.
80
81
  > Prefer the `npm run analysis:*` shortcuts; they wrap the compiled runners with the same flags (see [npm Script Shortcuts](#npm-script-shortcuts) for the full mapping).
81
82
 
82
83
  ## Data Prerequisites
83
84
 
84
85
  Most runners expect candle data. Two paths to get it:
85
86
 
86
- **Market adapter source** (default for most runners) — reads from `market_adapter/state/market_adapter_centers.json`. No setup needed; just run the bot first to populate state.
87
+ **Market adapter source** (default for most runners) — resolves the bot's cached candle file first, then falls back to `market_adapter/state/market_adapter_centers.json`. No setup needed; just run the bot first to populate state.
87
88
 
88
89
  **LP candle files** — for deeper analysis with full OHLC data:
89
90
 
@@ -258,9 +259,11 @@ All amounts use the shared 4-significant-figure formatter (compact `K`/`M`, sign
258
259
 
259
260
  ### LAST-FILL-GUARD Check (`grid_correction_check.ts`)
260
261
 
261
- Validates LAST-FILL-GUARD discipline from the same Kibana fill pipeline as `trade_profitability.ts`. For a previous fill at price `x` and grid increment `i`, the next order must satisfy `BUY < x × (1 − i/2/100)` and `SELL > x × (1 + i/2/100)`, regardless of the previous fill's side. A violation is a buy or sell fill inside the prohibited half-increment band around its pivot.
262
+ Validates LAST-FILL-GUARD discipline from the same Kibana fill pipeline as `trade_profitability.ts`. The rule is **direction only** (v1.6.16+): with the previous fill at price `p`, the next order must satisfy `BUY < p` and `SELL > p` (equal price is blocked — a re-place at the just-filled level). There is no increment band: the older `pivot ± i/2` rule blocked a BUY below a SELL fill and a SELL one tick above our cost, i.e. it flagged the tightening placements the engine legitimately makes. A violation is a buy fill at/above its pivot or a sell fill at/below it.
262
263
 
263
- **Pipeline:** Kibana `fill_order` query (paginated `search_after`) → on-chain asset precision resolution → buy/sell classification → chronological sort → per-order/price-epoch aggregation (partial fills at one price collapsed to weighted-average; repriced order lifetimes kept separate) → consecutive pivot-band comparison → violation report with daily histogram.
264
+ **Offline limits:** the tool reconstructs pivots from consecutive fills, so it cannot see the runtime's edge-pinned-fill exclusion (no slot identity per fill) nor the spread-correction bypass — expect rare false positives on wick/insurance fills.
265
+
266
+ **Pipeline:** Kibana `fill_order` query (paginated `search_after`) → on-chain asset precision resolution → buy/sell classification → chronological sort → per-order/price-epoch aggregation (partial fills at one price collapsed to weighted-average; repriced order lifetimes kept separate) → consecutive direction comparison → violation report with daily histogram.
264
267
 
265
268
  ```bash
266
269
  # Per-order aggregated check (default), last 7 days
@@ -272,7 +275,7 @@ npm run analysis:grid-check -- --bot-key <bot-key> --hours 720 --json out.json -
272
275
  # Raw fill granularity instead of per-order aggregation
273
276
  npm run analysis:grid-check -- --bot-key <bot-key> --per-fill --hours 168
274
277
 
275
- # Override the bot's configured grid increment
278
+ # Override the bot's configured grid increment (informational: the guard has no band)
276
279
  npm run analysis:grid-check -- --bot-key <bot-key> --hours 168 --increment 0.5
277
280
  ```
278
281
 
@@ -287,10 +290,9 @@ Exit code `0` = pass, `2` = violations found, `1` = fatal error. Bot keys resolv
287
290
  | `--start <iso>` / `--end <iso>` | — | Absolute time window |
288
291
  | `--account <id>` | bot `preferredAccount` | Override account ID or name |
289
292
  | `--refresh-account` | off | Force re-resolution of `preferredAccount` and update the stored `accountId` when it changed |
290
- | `--increment <pct>` | bot config / `0.5` | Grid increment used to derive the half-increment guard band |
293
+ | `--increment <pct>` | bot config / `0.5` | Grid increment (informational only — the guard is direction-only and uses no band) |
291
294
  | `--per-fill` | off | Check at fill granularity instead of per-order aggregated |
292
295
  | `--include-cross-pair` | off | Also check consecutive fills across different pairs |
293
- | `--tolerance <pct>` | — | Deprecated compatibility alias for `--increment`; its value is doubled and a warning is emitted |
294
296
  | `--json <file>` / `--csv <file>` | — | Export violations |
295
297
  | `--verbose` | off | Print the fetched trade sequence before checking |
296
298
  | `--list-bots` | — | List available bot keys and exit |
@@ -301,6 +303,91 @@ Exit code `0` = pass, `2` = violations found, `1` = fatal error. Bot keys resolv
301
303
 
302
304
  ## Charts & Visualization
303
305
 
306
+ ### Liquidity Depth Chart (`analyze_liquidity.ts`)
307
+
308
+ Blends one pair's live limit-order book with its constant-product AMM pool into a
309
+ single cumulative-depth chart (the PoolTool depth view, rebuilt with the vendored
310
+ uPlot runtime). The chart plots **both** liquidity sources side by side as
311
+ independent curves — they are deliberately **not summed**, because an on-chain
312
+ order and an AMM reserve are different claims on liquidity. You can see which
313
+ source supplies the depth at a given price, where the pool price sits relative
314
+ to the book mid, and how far the two diverge.
315
+
316
+ - **Price axis**: quote per base (B/A), e.g. `QUOTE per BASE`
317
+ - **Depth axis**: cumulative quote liquidity (e.g. BTS) at or better than that price;
318
+ click the right y-axis to toggle the same curves into cumulative base units
319
+ (e.g. BASE) — both are precomputed server-side
320
+ - **Click the x-axis to invert price** (`1/p`, e.g. `BASE per QUOTE`). Inversion
321
+ also swaps bid/ask roles and flips the depth asset to the new quote, so the
322
+ chart stays a valid book view rather than a mirrored picture with the wrong sides
323
+ - **Bids**: order-book bids (`quote` of every bid at price >= p) drawn next to
324
+ the pool's `quoteReserve * (1 - sqrt(p / p0))` curve
325
+ - **Asks**: order-book asks (`quote` of every ask at price <= p) drawn next to
326
+ the pool's `quoteReserve * (sqrt(p / p0) - 1)` curve
327
+
328
+ The window is symmetric around the pool price (book mid when there is no pool),
329
+ so the whole `0.5x .. 1.5x` range is visible by default. The chain's
330
+ `get_order_book` side convention is handled by the tool. Pool depth is the exact
331
+ constant-product solution (verified against the `x*y = k` swap invariant); the
332
+ AMM taker fee is **not** applied to the curve — matching PoolTool — and is shown
333
+ in the header as metadata only. PoolTool's `depthchart.py` plots the same curves
334
+ with the reciprocal price convention (`amount_y * (sqrt(p_pool/p) - 1)` for buys
335
+ and `amount_y * (1 - sqrt(p_pool/p))` for sells).
336
+
337
+ Order-book depth prefers `get_limit_orders` (up to ~300 levels per side) over
338
+ `get_order_book`, which many nodes cap at 50 — otherwise thin far levels are
339
+ silently missing from the curves. If the wider call is unavailable the tool
340
+ falls back to the classic 50-level endpoint.
341
+
342
+ All displayed numbers use DEXBot's existing 4-active-digit formatters —
343
+ `formatCurrency` for prices/percentages and `formatFundsValue` for amounts
344
+ (`modules/order/format.ts`) — embedded into the generated page so it renders
345
+ identically offline.
346
+
347
+ ```bash
348
+ # Default example pair
349
+ npm run analysis:liquidity -- --pair TOKENA/TOKENB
350
+
351
+ # CLI wrapper: resolves a bot key, a pool (id or pool token) or a pair
352
+ dexbot liq TOKENA/TOKENB --range 0.25
353
+ dexbot liq <bot-key>
354
+ dexbot liq 1.19.123 # pool by id
355
+ dexbot liq <pool-token-symbol> # pool by its LP share-asset symbol
356
+ # Aliases: liqu, liquidity (canonical command: liquid)
357
+
358
+ # Tighter window, deeper book, explicit pool
359
+ node dist/analysis/analyze_liquidity.js \
360
+ --pair TOKENA/TOKENB --range 0.25 --depth 50 --pool 1.19.123 --json liquidity.json
361
+
362
+ # Any pair by symbol or asset id
363
+ node dist/analysis/analyze_liquidity.js --base 1.3.123 --quote TOKENB --chart /tmp/lp.html
364
+
365
+ # One pool by id or pool token (legs derived from the pool)
366
+ node dist/analysis/analyze_liquidity.js --pool 1.19.123 --chart /tmp/pool.html
367
+ node dist/analysis/analyze_liquidity.js --pool <pool-token-symbol> --json pool.json
368
+ ```
369
+
370
+ <details><summary><mark>Options (click to expand)</mark></summary>
371
+
372
+ | Flag | Default | Description |
373
+ |------|---------|-------------|
374
+ | `--base` / `--quote` | — | Assets by symbol or `1.3.x` id (required via `--pair` or `--base` + `--quote`) |
375
+ | `--pair <base>/<quote>` | — | Shorthand for `--base` + `--quote` (also accepts `:`) |
376
+ | `--pool` | deepest pool | One pool: id (`133` / `1.19.133`) or its pool token (LP share-asset symbol). With no `--base`/`--quote`, both legs come from the pool |
377
+ | `--depth` | `300` | Order-book levels per side; fetched via `get_limit_orders` (commonly capped at 300) with a `get_order_book` fallback |
378
+ | `--range` | `0.5` | Window half-width as a fraction of the center price |
379
+ | `--steps` | `400` | Price samples across the window (exact book levels are always added) |
380
+ | `--chart` | `analysis/charts/liquidity_<base>_<quote>.html` | HTML output path |
381
+ | `--json` | — | Optional JSON dump of the sampled series and summary |
382
+ | `--quiet` | off | Suppress the console summary |
383
+
384
+ </details>
385
+
386
+ Generation is read-only and uses an ephemeral chain connection (`analysis/chain_pool.ts`),
387
+ so it never disturbs a running bot. The output is a single self-contained HTML file
388
+ (uPlot inlined, no CDN or sibling assets); hovering shows book/pool depth at
389
+ the cursor price, scroll zooms, drag pans, double-click resets.
390
+
304
391
  ### Trade Heatmap (`analyze_trade_heatmap.ts`)
305
392
 
306
393
  Generates a 2D heatmap + summed histogram showing where trade volume concentrates relative to AMA deviation. Time-slice rows show how the distribution evolved; the bottom histogram shows the aggregate bell-curve shape with threshold annotations.
@@ -346,9 +433,10 @@ Generates a standalone TradingView-style HTML chart with candle OHLC, SMA, AMA,
346
433
 
347
434
  # Recommended one-step: bot, pool, or pair (fetches candles + renders, default 3 months)
348
435
  dexbot tv <bot-key>
349
- dexbot tv 133
436
+ dexbot tv 133 # pool by id
437
+ dexbot tv <pool-token-symbol> # pool by its LP share-asset symbol
350
438
  dexbot tv TOKENA/TOKENB
351
- dexbot tv BTS/HONEST.USD --feed # opt-in: MPA price-feed history instead of market candles
439
+ dexbot tv BTS/HONEST.USD --feed # opt-in: MPA price-feed history instead of market candles
352
440
  # Manual: bot-key (auto-resolves candle file and AMA settings)
353
441
  npm run analysis:tradingview -- --source market_adapter --bot-key <bot-key>
354
442
 
@@ -373,7 +461,8 @@ Interactive 4-panel chart for the asymmetric path: AMA slope plus Kalman confirm
373
461
  # Recommended one-step (advanced): bot, pool, or pair — fetches candles and renders,
374
462
  # same pipeline as `dexbot tv`, default 3 months
375
463
  dexbot dw <bot-key>
376
- dexbot dw 133 --month 6
464
+ dexbot dw 133 --month 6 # pool by id
465
+ dexbot dw <pool-token-symbol> --month 6
377
466
  dexbot dw TOKENA/TOKENB --month 1
378
467
 
379
468
  # Direct analyzer (own candle files, research knobs --alpha/--gain/--dw/--lb/--clip)
@@ -542,6 +631,7 @@ These npm scripts wrap common analysis runners:
542
631
  | `npm run analysis:tradingview` | `node dist/analysis/tradingview/analyze_tradingview.js` |
543
632
  | `npm run analysis:trade-pnl` | `node dist/analysis/trade_profitability.js` |
544
633
  | `npm run analysis:grid-check` | `node dist/analysis/grid_correction_check.js` |
634
+ | `npm run analysis:liquidity` | `node dist/analysis/analyze_liquidity.js` |
545
635
  | `npm run ama:chart:lp-local` | `node dist/analysis/ama_fitting/generate_unified_comparison_chart.js` (chart also auto-generated by optimizer) |
546
636
 
547
637
  All accept `--` forwarded flags.
@@ -553,6 +643,9 @@ npm run analysis:tradingview -- --source market_adapter --bot-key <bot-key>
553
643
  # Trade PnL
554
644
  npm run analysis:trade-pnl -- 1.2.123456 --hours 720
555
645
 
646
+ # Liquidity depth (order book + AMM pool)
647
+ npm run analysis:liquidity -- --pair TOKENA/TOKENB --range 0.5
648
+
556
649
  # LAST-FILL-GUARD check
557
650
  npm run analysis:grid-check -- --bot-key <bot-key> --hours 168
558
651
 
@@ -10,7 +10,7 @@ parameters into `profiles/market_profiles.json` for the market adapter.
10
10
 
11
11
  ```
12
12
  1. fetch_lp_candles.ts → market_adapter/data/lp/<pairFolder>/lp_pool_<poolShort>_<interval>.json
13
- 2. optimizer_high_resolution.ts → optimization_results_*.json
13
+ 2. optimizer_high_resolution.ts → analysis/results/optimization_results_*.json
14
14
  → profiles/market_profiles.json (only with --write-profiles)
15
15
  3. scripts/generate_lp_chart.ts → market chart + comparison chart (visual review)
16
16
  - LP chart: `npm run lp:chart -- --data <lp-export.json>`
@@ -156,7 +156,7 @@ Source: pool 133 `IOB.XRP/BTS`, 1h candles, 2023-04-12 00:00 UTC through
156
156
  2026-04-11 23:00 UTC (the working-tree dataset `analysis/ama_fitting/data/lp_pool_133_iob.xrp_bts_1h.json`, regenerated by a local `fetch_lp_candles.ts` run).
157
157
 
158
158
  **Outputs:**
159
- - `analysis/ama_fitting/optimization_results_<datafile>_w<λ1>_<λ2>_<λ3>_<λ4>.json` — full results (e.g. `_w0_0031_0_0025_0_00185_0_0013`)
159
+ - `analysis/results/optimization_results_<datafile>_w<λ1>_<λ2>_<λ3>_<λ4>.json` — full results (e.g. `_w0_0031_0_0025_0_00185_0_0013`)
160
160
  - `analysis/charts/optimization_chart_<datafile>_w<λ1>_<λ2>_<λ3>_<λ4>.html` — interactive AMA overlay chart (auto-generated)
161
161
  - `profiles/market_profiles.json` — updated with new AMA parameters per pair only when `--write-profiles` is used
162
162
 
@@ -1,6 +1,6 @@
1
1
  ## Bot Fitting Backtest
2
2
 
3
- This folder contains parameter sweep backtests that simulate grid fills for the four AMA winners from `analysis/ama_fitting`.
3
+ This folder contains parameter sweep backtests that simulate grid fills for the four AMA winners produced by the optimizer in `analysis/ama_fitting/` (results land in `analysis/results/`).
4
4
 
5
5
  ### What it optimizes
6
6
 
@@ -74,7 +74,7 @@ microstructure, and no consolidation/dust-cancel/COW/collision mechanics.
74
74
  Both scripts require:
75
75
 
76
76
  - **LP candles JSON** (recommended 1h), from `market_adapter/data/lp/` — pass via `--data`
77
- - **AMA optimization winners JSON**, from `analysis/ama_fitting/` — for `backtest_ama_sweep.ts`, pass via `--results`
77
+ - **AMA optimization winners JSON**, from `analysis/results/` — for `backtest_ama_sweep.ts`, pass via `--results`
78
78
 
79
79
  ### Run
80
80
 
@@ -99,7 +99,7 @@ node dist/analysis/bot_fitting/backtest_lookback_drawdown.js \
99
99
  > builds on it and reports the paired per-lookback deltas.
100
100
 
101
101
  > `backtest_bot_fitting.ts` auto-derives `--results` from the `--data` filename
102
- > (`analysis/ama_fitting/optimization_results_<base>_w<λ1>_<λ2>_<λ3>_<λ4>.json`,
102
+ > (`analysis/results/optimization_results_<base>_w<λ1>_<λ2>_<λ3>_<λ4>.json`,
103
103
  > newest `_w*` file matching the base name; falls back to the legacy
104
104
  > `optimization_results_<base>.json`) when omitted.
105
105
  > `backtest_ama_sweep.ts` requires `--results` explicitly.
package/claw/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dexbot2-claw",
3
- "version": "1.6.17",
3
+ "version": "1.7.0",
4
4
  "private": true,
5
5
  "description": "Claw bridge and runtime integration layer for BitShares and DEXBot2.",
6
6
  "type": "module",
@@ -2,7 +2,7 @@
2
2
  "id": "bitshares-claw",
3
3
  "name": "BitShares Claw",
4
4
  "description": "Native BitShares and DEXBot2 tools from the DEXBot2 claw integration",
5
- "version": "1.6.17",
5
+ "version": "1.7.0",
6
6
  "skills": [
7
7
  "skills"
8
8
  ],
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "bitshares-claw-openclaw-plugin",
3
3
  "private": true,
4
- "version": "1.6.17",
4
+ "version": "1.7.0",
5
5
  "type": "module",
6
6
  "main": "index.js"
7
7
  }
@@ -8,7 +8,7 @@
8
8
  */
9
9
  import type { SourceConfig } from './resolve_source.js';
10
10
  /** Fields every analysis CLI config shares. */
11
- export interface AnalysisBaseConfig {
11
+ interface AnalysisBaseConfig {
12
12
  source: {
13
13
  type: string;
14
14
  config: SourceConfig;
@@ -40,4 +40,5 @@ export declare function printHelpHeader(title: string, usagePath: string): void;
40
40
  * `width` is per-tool so adopting this helper keeps the original column.
41
41
  */
42
42
  export declare function helpRow(flag: string, description: string, width: number): string;
43
+ export {};
43
44
  //# sourceMappingURL=analyze_args.d.ts.map
@@ -22,6 +22,7 @@ import { computeAmaSlopeWeights, createAmaSlopeClipTracker } from '../market_ada
22
22
  import { MARKET_ADAPTER } from '../modules/constants.js';
23
23
  import { PATHS } from '../modules/paths.js';
24
24
  import { writeChartFile, toFileUrl } from './chart_utils.js';
25
+ import { CLI_TAGS, savedLine } from '../modules/cli_progress.js';
25
26
  import { getCandleClose } from './math_utils.js';
26
27
  import { resolveSource, listAvailableBots } from './resolve_source.js';
27
28
  import { baseAnalysisConfig, consumeCommonAnalysisArg } from './analyze_args.js';
@@ -195,7 +196,7 @@ async function main() {
195
196
  }, config.title || 'Dynamic Weight Research Tool');
196
197
  writeChartFile(config.chartFile, html);
197
198
  if (!config.quiet)
198
- console.log(`\n[DynamicWeight] ✓ Chart saved. Open chart: (${toFileUrl(config.chartFile)})`);
199
+ console.log(savedLine(CLI_TAGS.dynamicWeight, 'Chart', toFileUrl(config.chartFile)));
199
200
  }
200
201
  catch (err) {
201
202
  console.error(`[DynamicWeight] Error: ${getErrorMessage(err)}`);
@@ -18,7 +18,8 @@ import { calculateAMA } from '../market_adapter/core/strategies/ama.js';
18
18
  import { computeAmaSlopeWeights, createAmaSlopeClipTracker } from '../market_adapter/core/strategies/ama_slope_model.js';
19
19
  import { MARKET_ADAPTER } from '../modules/constants.js';
20
20
  import { getCandleClose } from './math_utils.js';
21
- import { writeChartFile } from './chart_utils.js';
21
+ import { writeChartFile, toFileUrl } from './chart_utils.js';
22
+ import { CLI_TAGS, savedLine } from '../modules/cli_progress.js';
22
23
  import { PATHS } from '../modules/paths.js';
23
24
  import { resolveSource, listAvailableBots } from './resolve_source.js';
24
25
  import { baseAnalysisConfig, consumeCommonAnalysisArg } from './analyze_args.js';
@@ -124,7 +125,7 @@ async function main() {
124
125
  const html = generateHTML({ allResults, amaConfig, clipPct: MARKET_ADAPTER.DYNAMIC_WEIGHT_CLIP_PERCENTILE }, 'Kalman Trend Analysis');
125
126
  writeChartFile(config.chartFile, html);
126
127
  if (!config.quiet)
127
- console.log(`[Kalman] ✓ Chart saved to ${config.chartFile}`);
128
+ console.log(savedLine(CLI_TAGS.kalman, 'Chart', toFileUrl(config.chartFile)));
128
129
  }
129
130
  catch (err) {
130
131
  console.error(`[Kalman] Error: ${getErrorMessage(err)}`);
@@ -0,0 +1,17 @@
1
+ #!/usr/bin/env node
2
+ interface LiquidityConfig {
3
+ base: string;
4
+ quote: string;
5
+ poolId: string | null;
6
+ depth: number;
7
+ range: number;
8
+ steps: number;
9
+ chartFile: string | null;
10
+ jsonFile: string | null;
11
+ quiet: boolean;
12
+ help: boolean;
13
+ }
14
+ declare function parseArgs(argv: string[]): LiquidityConfig;
15
+ export { parseArgs };
16
+ export type { LiquidityConfig };
17
+ //# sourceMappingURL=analyze_liquidity.d.ts.map