dexbot 1.6.18 → 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 (89) hide show
  1. package/CHANGELOG.md +26 -0
  2. package/README.md +24 -18
  3. package/analysis/README.md +95 -3
  4. package/claw/package.json +1 -1
  5. package/claw/runtimes/openclaw-plugin/openclaw.plugin.json +1 -1
  6. package/claw/runtimes/openclaw-plugin/package.json +1 -1
  7. package/dist/analysis/analyze_dynamic_weight.js +2 -1
  8. package/dist/analysis/analyze_kalman.js +3 -2
  9. package/dist/analysis/analyze_liquidity.d.ts +17 -0
  10. package/dist/analysis/analyze_liquidity.js +325 -0
  11. package/dist/analysis/analyze_regime.js +3 -2
  12. package/dist/analysis/analyze_regime_windows.js +3 -2
  13. package/dist/analysis/analyze_volatility.js +3 -2
  14. package/dist/analysis/liquidity/liquidity_chain.d.ts +66 -0
  15. package/dist/analysis/liquidity/liquidity_chain.js +178 -0
  16. package/dist/analysis/liquidity/liquidity_chart_generator.d.ts +19 -0
  17. package/dist/analysis/liquidity/liquidity_chart_generator.js +523 -0
  18. package/dist/analysis/liquidity/liquidity_depth_model.d.ts +141 -0
  19. package/dist/analysis/liquidity/liquidity_depth_model.js +230 -0
  20. package/dist/analysis/liquidity/liquidity_view.d.ts +38 -0
  21. package/dist/analysis/liquidity/liquidity_view.js +55 -0
  22. package/dist/analysis/trade_profitability.js +2 -1
  23. package/dist/analysis/tradingview/analyze_tradingview.js +2 -1
  24. package/dist/dexbot.js +74 -169
  25. package/dist/modules/asset_lookup.d.ts +25 -0
  26. package/dist/modules/asset_lookup.js +75 -0
  27. package/dist/modules/chain_scan.d.ts +64 -0
  28. package/dist/modules/chain_scan.js +80 -0
  29. package/dist/modules/cli_colors.d.ts +5 -0
  30. package/dist/modules/cli_colors.js +7 -0
  31. package/dist/modules/cli_progress.d.ts +51 -0
  32. package/dist/modules/cli_progress.js +113 -0
  33. package/dist/modules/dexbot_cow_runtime.js +14 -4
  34. package/dist/modules/dexbot_fill_runtime.js +20 -0
  35. package/dist/modules/dexbot_maintenance_runtime.js +16 -1
  36. package/dist/modules/launcher/runtime_entry.d.ts +21 -1
  37. package/dist/modules/launcher/runtime_entry.js +36 -1
  38. package/dist/modules/liquidity_pool_ref.d.ts +32 -0
  39. package/dist/modules/liquidity_pool_ref.js +116 -0
  40. package/dist/modules/order/grid.js +9 -2
  41. package/dist/modules/order/grid_reconcile.js +22 -1
  42. package/dist/modules/order/grid_reconcile_internal.js +92 -14
  43. package/dist/modules/order/index.d.ts +15 -1
  44. package/dist/modules/order/manager.d.ts +2 -0
  45. package/dist/modules/order/manager.js +3 -0
  46. package/dist/modules/order/sync_engine.d.ts +20 -0
  47. package/dist/modules/order/sync_engine.js +101 -33
  48. package/dist/modules/order/utils/math.d.ts +18 -1
  49. package/dist/modules/order/utils/math.js +30 -1
  50. package/dist/modules/order/utils/order.d.ts +107 -1
  51. package/dist/modules/order/utils/order.js +298 -1
  52. package/dist/modules/order/utils/system.d.ts +63 -1
  53. package/dist/modules/order/utils/system.js +247 -36
  54. package/dist/modules/order/utils/validate.js +33 -2
  55. package/dist/modules/types.d.ts +5 -0
  56. package/dist/modules/utils/asset_symbols.d.ts +13 -2
  57. package/dist/modules/utils/asset_symbols.js +21 -2
  58. package/dist/scripts/analysis_runner.d.ts +10 -0
  59. package/dist/scripts/analysis_runner.js +33 -0
  60. package/dist/scripts/analyze-orders.js +2 -1
  61. package/dist/scripts/asset.d.ts +26 -0
  62. package/dist/scripts/asset.js +165 -0
  63. package/dist/scripts/bts_distribution.d.ts +1 -0
  64. package/dist/scripts/bts_distribution.js +194 -142
  65. package/dist/scripts/chart_command.d.ts +1 -1
  66. package/dist/scripts/chart_command.js +60 -86
  67. package/dist/scripts/chart_targets.d.ts +18 -0
  68. package/dist/scripts/chart_targets.js +52 -0
  69. package/dist/scripts/dw.js +1 -1
  70. package/dist/scripts/liquid.d.ts +24 -0
  71. package/dist/scripts/liquid.js +134 -0
  72. package/dist/scripts/rich_list.js +12 -16
  73. package/dist/scripts/token_distribution.d.ts +2 -0
  74. package/dist/scripts/token_distribution.js +132 -108
  75. package/dist/scripts/tv.js +1 -1
  76. package/dist/scripts/verify-browser-bundle.js +18 -0
  77. package/docs/COW_INVARIANTS.md +2 -2
  78. package/docs/DEXBOT_COMPARISON.md +6 -6
  79. package/docs/EVOLUTION.md +9 -8
  80. package/docs/FUND_MOVEMENT_AND_ACCOUNTING.md +1 -1
  81. package/docs/GRID_PRICE_INVARIANT.md +4 -1
  82. package/docs/GRID_RECONCILE.md +20 -0
  83. package/docs/LOGGING.md +25 -3
  84. package/docs/ORDER_ENGINE_POST_1.0_RETROSPECTIVE.md +2 -1
  85. package/docs/README.md +1 -1
  86. package/docs/WORKFLOW.md +3 -1
  87. package/modules/README.md +5 -1
  88. package/package.json +3 -1
  89. package/scripts/README.md +23 -7
@@ -695,7 +695,8 @@ required is no longer reachable at runtime.
695
695
  - **A rail clamp only cites its own evidence:** the batch's op destinations and the master
696
696
  orders on their own side of the planned boundary; strays are ignored and named (§9.10/P3).
697
697
  - **The pivot has a lifetime:** re-armed explicitly after a rebuild from the last real fill,
698
- bounded by the same 24h TTL, and a re-center is requested at most once per pivot because a
698
+ bounded by the same 24h TTL (enforced at restore and at read time, so a stale row can neither
699
+ arm the guard nor be re-armed), and a re-center is requested at most once per pivot because a
699
700
  re-center cannot move it (§9.10/P2).
700
701
 
701
702
  #### 9.7 The guard was a band, not an economic rule (`c86b4b0e`)
package/docs/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  This directory contains the comprehensive technical documentation for the DEXBot2 trading bot. It is designed to guide developers from high-level architecture down to the nuances of fund accounting and state management.
4
4
 
5
- **Version context:** v1.6.18 (released).
5
+ **Version context:** v1.7.0 (released).
6
6
 
7
7
  ---
8
8
 
package/docs/WORKFLOW.md CHANGED
@@ -253,9 +253,11 @@ the canonical name is preferred in scripts and docs.
253
253
  | `dexbot order [<bot>]` | — | Analyze only the specified bot's order grid |
254
254
  | `dexbot credit` | — | Live summed MPA + borrowed-credit positions per asset per bot (`[<bot>]`) |
255
255
  | `dexbot rich <asset...>` | — | Top holder(s) per asset via the chain asset-holders API (`--top N`, `--json`/`--csv`) |
256
- | `dexbot tv <target>` | — | TradingView 1h chart for `<bot|pool-id|AssetA/AssetB>` over `--month N` (default 3) |
256
+ | `dexbot tv <target>` | — | TradingView 1h chart for `<bot|pool|AssetA/AssetB>` over `--month N` (default 3); pool = id (133 / 1.19.133) or pool token (LP share-asset symbol) |
257
257
  | `dexbot dw <target>` | — | Dynamic-weight research chart: same targets/flags as `tv` |
258
+ | `dexbot liquid <target>` | `liq` (default shorthand), `liqu`, `liquidity` | Blended order-book + AMM pool liquidity depth chart for `<bot|pool|AssetA/AssetB>` (`--range`, `--depth`, `--steps`); a pool target (id or pool token) derives both legs |
258
259
  | `dexbot pnl <account>` | — | HTML PnL report for a bot/account over `--month N`, optional `--pair BASE/QUOTE` filter |
260
+ | `dexbot asset <bts\|symbol\|1.3.x>` | `a` | Supply distribution: `bts` for the core asset (collateral, pools, locks, residual), a bare symbol/id for an issued asset; `--json`, `--html`/`--no-html`, `--detail`, `--holders` |
259
261
  | `dexbot git` | — | Analyze repository git history and write an added/deleted-lines HTML chart (`repo-stats.html`; source checkouts only) |
260
262
  | `dexbot status` | `stat`, `stats` | Unified runtime health — daemon, adapter, bots. Whole-runtime: an optional bot name is validated, then ignored |
261
263
  | `dexbot start` | `unlock` | Run credential daemon + bot (equivalent to running the `unlock` runtime, `dist/unlock.js`) |
package/modules/README.md CHANGED
@@ -37,7 +37,11 @@ modules/
37
37
  ├── version_notice.ts passive npm-registry version check + status line
38
38
  ├── cli_start_onboarding.ts first-run setup routing for `dexbot start`
39
39
  ├── cli_start_output.ts launcher notice formatting
40
- ├── cli_colors.ts shared CLI color helpers
40
+ ├── cli_colors.ts shared CLI color palette + `colorize()`
41
+ ├── cli_progress.ts shared `[Tag]` lines: progress, section, warnings, summary, saved link
42
+ ├── liquidity_pool_ref.ts pool id / pool token resolution (shared by liq/tv/dw)
43
+ ├── chain_scan.ts batched object-id walk for list-less types (1.13/1.15)
44
+ ├── asset_lookup.ts case-insensitive asset refs (symbol/id) for every CLI
41
45
  ├── credential_runtime.ts daemon socket/path helpers + private-path security
42
46
  ├── credential_policy.ts signing policy validation
43
47
  ├── credential_session_cache.ts encrypted session cache
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dexbot",
3
- "version": "1.6.18",
3
+ "version": "1.7.0",
4
4
  "description": "The first open source trading bot with zero runtime dependencies and a fully adaptive market making strategy.",
5
5
  "main": "dist/modules/dexbot_class.js",
6
6
  "exports": {
@@ -97,10 +97,12 @@
97
97
  "ama:chart:lp-local": "npm run build && node dist/analysis/ama_fitting/generate_unified_comparison_chart.js",
98
98
  "analysis:trade-pnl": "npm run build && node dist/analysis/trade_profitability.js",
99
99
  "analysis:grid-check": "npm run build && node dist/analysis/grid_correction_check.js",
100
+ "analysis:liquidity": "npm run build && node dist/analysis/analyze_liquidity.js",
100
101
  "analysis:resolve-accounts": "npm run build && node dist/analysis/resolve_bot_accounts.js",
101
102
  "richlist": "npm run build && node dist/scripts/rich_list.js",
102
103
  "distribution": "npm run build && node dist/scripts/bts_distribution.js",
103
104
  "token-distribution": "npm run build && node dist/scripts/token_distribution.js",
105
+ "asset": "npm run build && node dist/scripts/asset.js",
104
106
  "native:release-gates": "npm run build && npm run build:tests && node dist/scripts/native_release_gates.js",
105
107
  "native:serial-snapshots": "npm run build && npm run build:tests && node dist/tests/test_native_serial_ops.js",
106
108
  "native:ecc-invariants": "npm run build && npm run build:tests && node dist/tests/test_native_ecc.js",
package/scripts/README.md CHANGED
@@ -2,6 +2,15 @@
2
2
 
3
3
  This guide provides a terminal-focused reference for the maintenance and diagnostic utilities available in the `scripts/` directory.
4
4
 
5
+ Every command that writes a file prints the same trailer
6
+ (`[Tag] ✓ <kind> saved. Open <kind>: (file://…)`) plus the shared section/warning/summary
7
+ blocks, all from `modules/cli_progress.ts` (`savedLine`, `section`, `warningsBlock`, `summaryLine`).
8
+
9
+ Asset symbols are case-insensitive wherever a command takes one (`dexbot asset token.sym`,
10
+ `dexbot rich token.sym`, `dexbot liq A/B`, `dexbot tv <pool-token>`, `--base`/`--quote`): every
11
+ path resolves through `modules/asset_lookup.ts`, which looks the symbol up in its canonical UPPERCASE
12
+ form and keeps `1.3.x` ids untouched.
13
+
5
14
  ---
6
15
 
7
16
  ## 🛠️ CORE MAINTENANCE
@@ -104,7 +113,7 @@ the rename. Note:
104
113
  the `holders=` figure can be off by one.
105
114
 
106
115
  ### BTS Supply Distribution
107
- **File:** `bts_distribution.ts` (npm: `npm run distribution`)
116
+ **File:** `bts_distribution.ts` (CLI: `dexbot asset bts`; npm: `npm run distribution`)
108
117
  **Purpose:** Live-chain breakdown of where BTS sits: call-order collateral, global/individual
109
118
  settlement funds (plus force-settlement debt and parameters), governance tickets, vesting and
110
119
  legacy balances, liquidity pools, SameT/credit funds, HTLC escrow and asset fee pools. The
@@ -112,11 +121,17 @@ remainder is reported as a derived liquid residual and compared with total suppl
112
121
  circulating float. Also writes a self-contained HTML donut report to
113
122
  `analysis/charts/bts-distribution.html` (`--html PATH`, `--no-html`).
114
123
  ```bash
115
- npm run distribution # terminal + HTML
124
+ dexbot asset bts # terminal + HTML (shorthand: dexbot a bts)
125
+ npm run distribution # same, via npm
116
126
  node dist/scripts/bts_distribution.js --json # JSON (HTML still written)
117
127
  node dist/scripts/bts_distribution.js --circulating <reference-supply>
118
128
  node dist/scripts/bts_distribution.js --holders all # full rich list (~5 min)
119
129
  ```
130
+ Vesting (1.13.x) and legacy (1.15.x) objects have no list API, so both are enumerated by probing
131
+ ids with `get_objects` in 1000-id batches (`modules/chain_scan.ts`, halving on nodes that refuse
132
+ big batches) and filtered to BTS client-side — the walk covers every asset the node stores there,
133
+ because the chain exposes no per-asset index. `--gap N` controls how far past the last live object
134
+ the walk continues (default 20000); `--vesting-max` caps the 1.13.x probe.
120
135
  Call-order collateral uses `api_helper_indexes` `total_in_collateral` (falls back to summing
121
136
  `get_call_orders`). Top liquid holders come from `asset_api::get_asset_holders`, retrying on a
122
137
  node that exposes it; exchange tags are name heuristics, not verified identities. `--holders all`
@@ -124,7 +139,7 @@ also splits the residual into account balances, blinded balances and order books
124
139
  concentration plus balance bands. Read-only: no keys, no transactions.
125
140
 
126
141
  ### Token Distribution
127
- **File:** `token_distribution.ts` (npm: `npm run token-distribution`)
142
+ **File:** `token_distribution.ts` (CLI: `dexbot asset <symbol|1.3.x>`; npm: `npm run token-distribution`)
128
143
  **Purpose:** Per-asset companion to BTS Supply Distribution. Buckets a token into free account
129
144
  balances, limit orders, liquidity pools, vesting balances, P2P credit offers and deal collateral,
130
145
  SameT funds, HTLC escrow, accumulated market fees and blinded supply, then reconciles the total
@@ -134,13 +149,12 @@ token sellable (price −3%) and buyable (+3%), orderbook + pool combined per ma
134
149
  as a share of total supply. Writes the report to
135
150
  `analysis/charts/token-<SYMBOL>-distribution.html`.
136
151
  ```bash
152
+ dexbot asset <token> # terminal + HTML (shorthand: dexbot a <token>)
137
153
  npm run token-distribution -- <token>
138
154
  node dist/scripts/token_distribution.js <asset-id> --json
139
155
  node dist/scripts/token_distribution.js <token> --no-orders # skip the ~6k order queries
140
156
  ```
141
- Limit orders have no by-asset index in bitshares-core, so the exact scan queries every listed
142
- asset concurrently (~20s); vesting balances scan 1.13.x with a gap tolerance. Read-only: no keys,
143
- no transactions. BTS itself is rejected; use `npm run distribution`.
157
+ Read-only: no keys, no transactions. BTS itself is rejected; use `npm run distribution`.
144
158
 
145
159
  ### Configuration Audit
146
160
  **File:** `validate_bots.ts`
@@ -381,7 +395,8 @@ load `profiles/orders/<botKey>.json` automatically.
381
395
  **Output:** `tv_<bot|pool_<id>|<a>_<b>>_1h_<N>m.html` (`_feed` for feed charts)
382
396
  ```bash
383
397
  dexbot tv <bot> # bot, 3 months
384
- dexbot tv 133 --month 6 # pool
398
+ dexbot tv 133 --month 6 # pool by id
399
+ dexbot tv <pool-token-symbol> --month 6 # pool by its LP share-asset symbol
385
400
  dexbot tv TOKENA/TOKENB --month 1 --chart analysis/charts/custom.html
386
401
  dexbot tv TOKENA/BTS --feed --month 1 # MPA price feed
387
402
  ```
@@ -395,6 +410,7 @@ Same pipeline and flags as `tv`; renders the dynamic-weight research chart
395
410
  ```bash
396
411
  dexbot dw <bot>
397
412
  dexbot dw 133 --month 6
413
+ dexbot dw <pool-token-symbol> --month 6
398
414
  dexbot dw TOKENA/TOKENB --month 1 --chart analysis/charts/custom.html
399
415
  dexbot dw TOKENA/BTS --feed --month 1
400
416
  ```