dexbot 1.6.12 → 1.6.13
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.
- package/CHANGELOG.md +33 -1
- package/analysis/README.md +9 -11
- package/analysis/ama_fitting/README.md +5 -3
- package/claw/README.md +1 -0
- package/claw/docs/AI_BOT_LIBRARY_API.md +2 -0
- package/claw/modules/claw_bridge.ts +0 -3
- package/claw/modules/claw_skill_md.ts +1 -0
- package/claw/package.json +3 -3
- package/claw/runtimes/openclaw-plugin/openclaw.plugin.json +1 -1
- package/claw/runtimes/openclaw-plugin/package.json +1 -1
- package/claw/tsconfig.json +2 -2
- package/dist/analysis/ama_fitting/analyze_lambda_vs_slow.js +1 -14
- package/dist/analysis/ama_fitting/fetch_lp_candles.js +51 -41
- package/dist/analysis/ama_fitting/generate_unified_comparison_chart.d.ts +1 -24
- package/dist/analysis/ama_fitting/generate_unified_comparison_chart.js +36 -18
- package/dist/analysis/ama_fitting/optimizer_high_resolution.js +18 -66
- package/dist/analysis/analyze_args.d.ts +12 -0
- package/dist/analysis/analyze_args.js +20 -0
- package/dist/analysis/bot_fitting/backtest_ama_sweep.d.ts +1 -16
- package/dist/analysis/bot_fitting/backtest_ama_sweep.js +20 -101
- package/dist/analysis/bot_fitting/backtest_bot_fitting.js +26 -92
- package/dist/analysis/bot_fitting/backtest_lookback_drawdown.js +19 -34
- package/dist/analysis/bot_fitting/shared_utils.d.ts +71 -3
- package/dist/analysis/bot_fitting/shared_utils.js +124 -8
- package/dist/analysis/chart_ui.d.ts +30 -1
- package/dist/analysis/chart_ui.js +37 -1
- package/dist/analysis/fills_cache.d.ts +3 -23
- package/dist/analysis/fills_cache.js +3 -84
- package/dist/analysis/fills_source.d.ts +31 -1
- package/dist/analysis/fills_source.js +69 -1
- package/dist/analysis/grid_correction_check.d.ts +1 -23
- package/dist/analysis/grid_correction_check.js +15 -58
- package/dist/analysis/math_utils.d.ts +85 -1
- package/dist/analysis/math_utils.js +116 -1
- package/dist/analysis/price_sources.d.ts +22 -1
- package/dist/analysis/price_sources.js +23 -0
- package/dist/analysis/resolve_source.js +31 -10
- package/dist/analysis/trade_profitability.d.ts +6 -0
- package/dist/analysis/trade_profitability.js +23 -97
- package/dist/analysis/tradingview/analyze_tradingview.d.ts +1 -17
- package/dist/analysis/tradingview/analyze_tradingview.js +1 -1
- package/dist/analysis/tradingview/tradingview_uplot_chart_generator.js +2 -15
- package/dist/analysis/trend_detection/backtest_ama_slope_huber.d.ts +1 -101
- package/dist/analysis/trend_detection/backtest_ama_slope_huber.js +22 -80
- package/dist/analysis/trend_detection/dynamic_weight_chart_generator.js +11 -37
- package/dist/analysis/trend_detection/volatility_chart_generator.js +9 -10
- package/dist/analysis/worker_pool.d.ts +38 -0
- package/dist/analysis/worker_pool.js +67 -0
- package/dist/dexbot.js +67 -48
- package/dist/market_adapter/ama_signal_runner.js +21 -54
- package/dist/market_adapter/candle_utils.d.ts +7 -1
- package/dist/market_adapter/candle_utils.js +11 -1
- package/dist/market_adapter/cli_args.d.ts +22 -0
- package/dist/market_adapter/cli_args.js +30 -0
- package/dist/market_adapter/core/config_normalizers.js +11 -6
- package/dist/market_adapter/core/kibana_candles.d.ts +3 -1
- package/dist/market_adapter/core/kibana_candles.js +3 -2
- package/dist/market_adapter/core/market_adapter_service.d.ts +85 -85
- package/dist/market_adapter/core/market_adapter_service.js +93 -158
- package/dist/market_adapter/core/signals/hurst_analyzer.d.ts +1 -6
- package/dist/market_adapter/core/signals/hurst_analyzer.js +1 -1
- package/dist/market_adapter/core/signals/permutation_entropy_analyzer.d.ts +1 -11
- package/dist/market_adapter/core/signals/permutation_entropy_analyzer.js +1 -1
- package/dist/market_adapter/inputs/fetch_book_data.js +0 -1
- package/dist/market_adapter/inputs/fetch_cex_synthetic_data.js +63 -107
- package/dist/market_adapter/inputs/fetch_lp_data.d.ts +8 -1
- package/dist/market_adapter/inputs/fetch_lp_data.js +25 -7
- package/dist/market_adapter/inputs/kibana_feed_source.js +4 -26
- package/dist/market_adapter/inputs/window_cache.d.ts +4 -72
- package/dist/market_adapter/inputs/window_cache.js +52 -177
- package/dist/market_adapter/interval_utils.d.ts +11 -1
- package/dist/market_adapter/interval_utils.js +16 -1
- package/dist/market_adapter/lp_chart_runner.d.ts +3 -0
- package/dist/market_adapter/lp_chart_runner.js +37 -19
- package/dist/market_adapter/market_adapter.js +27 -72
- package/dist/market_adapter/utils/data_discovery.d.ts +45 -1
- package/dist/market_adapter/utils/data_discovery.js +220 -27
- package/dist/market_adapter/utils/month_shards.d.ts +84 -0
- package/dist/market_adapter/utils/month_shards.js +237 -0
- package/dist/modules/account_bots.d.ts +1 -0
- package/dist/modules/account_bots.js +102 -121
- package/dist/modules/account_orders.d.ts +13 -0
- package/dist/modules/account_orders.js +38 -44
- package/dist/modules/bitshares-native/chain_client.d.ts +1 -1
- package/dist/modules/bitshares-native/chain_client.js +14 -13
- package/dist/modules/bitshares-native/resolvers.js +22 -25
- package/dist/modules/bitshares-native/serial/types.js +22 -50
- package/dist/modules/bitshares-native/signing_client.d.ts +1 -1
- package/dist/modules/bot_defaults.d.ts +2 -1
- package/dist/modules/bot_settings.d.ts +1 -1
- package/dist/modules/broadcast_failure.d.ts +2 -1
- package/dist/modules/chain_orders.d.ts +1 -1
- package/dist/modules/chain_orders.js +51 -96
- package/dist/modules/cli_start_onboarding.d.ts +2 -1
- package/dist/modules/constants.d.ts +7 -1
- package/dist/modules/constants.js +20 -1
- package/dist/modules/cr_planner.d.ts +1 -1
- package/dist/modules/cr_planner.js +1 -5
- package/dist/modules/credit_pricing.d.ts +2 -1
- package/dist/modules/credit_pricing.js +36 -40
- package/dist/modules/credit_runtime.d.ts +7 -0
- package/dist/modules/credit_runtime.js +45 -73
- package/dist/modules/daemon_node_health.d.ts +4 -3
- package/dist/modules/dexbot_class.d.ts +28 -17
- package/dist/modules/dexbot_class.js +105 -58
- package/dist/modules/dexbot_cow_runtime.d.ts +0 -7
- package/dist/modules/dexbot_cow_runtime.js +54 -28
- package/dist/modules/dexbot_credential_client.d.ts +0 -7
- package/dist/modules/dexbot_credential_client.js +1 -2
- package/dist/modules/dexbot_fill_runtime.d.ts +1 -2
- package/dist/modules/dexbot_fill_runtime.js +5 -6
- package/dist/modules/dexbot_maintenance_runtime.d.ts +20 -3
- package/dist/modules/dexbot_maintenance_runtime.js +84 -69
- package/dist/modules/dexbot_startup_runtime.d.ts +0 -1
- package/dist/modules/dexbot_startup_runtime.js +13 -14
- package/dist/modules/general_settings.d.ts +1 -1
- package/dist/modules/graceful_shutdown.js +17 -11
- package/dist/modules/key_store.js +0 -1
- package/dist/modules/lazy_shim.d.ts +11 -0
- package/dist/modules/lazy_shim.js +16 -0
- package/dist/modules/node_connect_policy.d.ts +3 -2
- package/dist/modules/node_failure_ledger.d.ts +6 -5
- package/dist/modules/order/format.d.ts +12 -3
- package/dist/modules/order/format.js +15 -3
- package/dist/modules/order/genesis_policy.d.ts +3 -3
- package/dist/modules/order/genesis_policy.js +5 -2
- package/dist/modules/order/grid.d.ts +4 -2
- package/dist/modules/order/grid.js +91 -35
- package/dist/modules/order/index.d.ts +1 -0
- package/dist/modules/order/logger.d.ts +1 -8
- package/dist/modules/order/logger.js +0 -9
- package/dist/modules/order/manager.d.ts +9 -13
- package/dist/modules/order/manager.js +33 -50
- package/dist/modules/order/utils/order.js +39 -35
- package/dist/modules/order/utils/system.d.ts +9 -29
- package/dist/modules/order/utils/system.js +17 -2
- package/dist/modules/order/utils/validate.js +2 -2
- package/dist/modules/order/utils/withPoolRef.d.ts +2 -1
- package/dist/modules/paths.js +32 -34
- package/dist/modules/runtime_settings.d.ts +2 -4
- package/dist/modules/settings_merge.d.ts +2 -2
- package/dist/modules/socket_json_client.d.ts +2 -1
- package/dist/modules/types.d.ts +42 -27
- package/dist/modules/utils/errors.js +1 -3
- package/dist/modules/version_notice.d.ts +11 -10
- package/dist/pm2.d.ts +0 -1
- package/dist/pm2.js +56 -35
- package/dist/scripts/analyze-git.js +2 -15
- package/dist/scripts/chart_command.js +2 -2
- package/dist/scripts/check_any.d.ts +4 -0
- package/dist/scripts/check_any.js +53 -21
- package/dist/scripts/diagnose-pool-history.js +1 -6
- package/dist/scripts/run-tests.js +0 -1
- package/dist/scripts/sync-version.js +0 -10
- package/docs/BITSHARES_ONBOARDING.md +8 -12
- package/docs/COPY_ON_WRITE_MASTER_PLAN.md +1 -1
- package/docs/DEXBOT_COMPARISON.md +6 -6
- package/docs/EVOLUTION.md +9 -8
- package/docs/FUND_MOVEMENT_AND_ACCOUNTING.md +1 -1
- package/docs/README.md +1 -1
- package/docs/WORKFLOW.md +1 -0
- package/docs/architecture.md +19 -10
- package/market_adapter/README.md +6 -4
- package/package.json +6 -9
- package/scripts/README.md +43 -38
- package/tests/README.md +25 -10
- package/dist/scripts/diagnose-kibana-candles.d.ts +0 -3
- package/dist/scripts/diagnose-kibana-candles.js +0 -82
- package/scripts/git-viewer.sh +0 -489
- package/scripts/postinstall.js +0 -16
package/market_adapter/README.md
CHANGED
|
@@ -581,7 +581,7 @@ market_adapter/
|
|
|
581
581
|
|-- market_adapter.ts main adapter daemon
|
|
582
582
|
|-- ama_signal_runner.ts one-cycle JSON signal CLI
|
|
583
583
|
|-- candle_utils.ts candle transforms, gap detection, pruning
|
|
584
|
-
|-- interval_utils.ts shared interval label helpers
|
|
584
|
+
|-- interval_utils.ts shared interval label + chain-time helpers
|
|
585
585
|
|-- lp_chart_core.ts chart HTML renderer
|
|
586
586
|
|-- lp_chart_strategy_loader.ts AMA strategy/profile resolver for charts
|
|
587
587
|
|-- lp_chart_runner.ts LP chart orchestration
|
|
@@ -592,7 +592,7 @@ market_adapter/
|
|
|
592
592
|
| |-- market_adapter_service.ts full signal pipeline service
|
|
593
593
|
| |-- config_normalizers.ts shared config normalization
|
|
594
594
|
| |-- kibana_client.ts low-level Kibana/ES query client
|
|
595
|
-
| |-- kibana_candles.ts
|
|
595
|
+
| |-- kibana_candles.ts generic Kibana candle fetch engine (LP/book/feed)
|
|
596
596
|
| |-- kibana_market_candles.ts book candle fetch and transform
|
|
597
597
|
| |-- signals/
|
|
598
598
|
| | |-- hurst_analyzer.ts Hurst Exponent analysis
|
|
@@ -614,14 +614,16 @@ market_adapter/
|
|
|
614
614
|
| |-- fetch_book_data.ts order-book candle exporter
|
|
615
615
|
| |-- kibana_feed_source.ts MPA feed candle source
|
|
616
616
|
| |-- window_cache.ts shared month-shard candle cache
|
|
617
|
-
|
|
|
617
|
+
| |-- fetch_cex_synthetic_data.ts public CEX synthetic-candle seed importer
|
|
618
|
+
| `-- cex_candle_parsing.ts CEX OHLC row layouts and parsing
|
|
618
619
|
|-- utils/
|
|
619
620
|
| |-- chain.ts blockchain query helpers
|
|
620
621
|
| |-- adapter_client.ts inter-process credential daemon client
|
|
621
622
|
| |-- native_history.ts native BitShares market history fetch
|
|
622
623
|
| |-- file_lock.ts single-instance file lock
|
|
623
624
|
| |-- file_json_cache.ts write-through JSON read cache
|
|
624
|
-
| |--
|
|
625
|
+
| |-- month_shards.ts calendar-month shard naming + coverage-span primitives (shared by candle and fills caches)
|
|
626
|
+
| |-- data_discovery.ts data directory auto-discovery + shard-family assembly
|
|
625
627
|
| |-- atomic_write.ts atomic file write utility
|
|
626
628
|
| |-- dynamic_grid_snapshot.ts dynamic grid snapshot helpers
|
|
627
629
|
|-- data/ runtime candle caches and exports
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dexbot",
|
|
3
|
-
"version": "1.6.
|
|
3
|
+
"version": "1.6.13",
|
|
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": {
|
|
@@ -26,13 +26,11 @@
|
|
|
26
26
|
"scripts/clear-orders.sh",
|
|
27
27
|
"scripts/create-bot-symlinks.sh",
|
|
28
28
|
"scripts/dexbot",
|
|
29
|
-
"scripts/git-viewer.sh",
|
|
30
29
|
"scripts/keys",
|
|
31
30
|
"scripts/lib/dexbot-paths.sh",
|
|
32
31
|
"scripts/pdev.sh",
|
|
33
32
|
"scripts/pm2",
|
|
34
33
|
"scripts/pmain.sh",
|
|
35
|
-
"scripts/postinstall.js",
|
|
36
34
|
"scripts/ptest.sh",
|
|
37
35
|
"scripts/README.md",
|
|
38
36
|
"scripts/reset-settings.sh",
|
|
@@ -88,8 +86,8 @@
|
|
|
88
86
|
"unlock:start": "npm run unlock",
|
|
89
87
|
"claw:unlock": "npm run build && node dist/unlock.js --claw-only",
|
|
90
88
|
"claw:start": "npm run claw:unlock",
|
|
91
|
-
"pm2:start": "
|
|
92
|
-
"pm2:stop": "
|
|
89
|
+
"pm2:start": "npm run pm2:unlock",
|
|
90
|
+
"pm2:stop": "node dist/pm2.js stop all",
|
|
93
91
|
"pmain": "bash scripts/pmain.sh",
|
|
94
92
|
"pdev": "bash scripts/pdev.sh",
|
|
95
93
|
"ptest": "bash scripts/ptest.sh",
|
|
@@ -105,7 +103,6 @@
|
|
|
105
103
|
"native:ecc-invariants": "npm run build && npm run build:tests && node dist/tests/test_native_ecc.js",
|
|
106
104
|
"native:corpus": "npm run build && node dist/scripts/generate_mainnet_corpus_report.js",
|
|
107
105
|
"test:credit-renewal": "npm run build && node dist/scripts/test-credit-renewal.js",
|
|
108
|
-
"test:legacy": "npm run build && npm run build:tests && node dist/analysis/legacy/tests/test_derivative_chart.js && node dist/analysis/legacy/tests/test_derivative_entry_bias.js && node dist/analysis/legacy/tests/test_derivative_momentum_gate.js && node dist/analysis/legacy/tests/test_derivative_signal_trap_regression.js && node dist/analysis/legacy/tests/test_kalman_trend.js && node dist/analysis/legacy/tests/test_kalman_velocity_smoothing.js",
|
|
109
106
|
"version:sync": "npm run build && node dist/scripts/sync-version.js",
|
|
110
107
|
"version:check": "npm run build && node dist/scripts/sync-version.js --check",
|
|
111
108
|
"verify:browser-bundle": "npm run build && node dist/scripts/verify-browser-bundle.js",
|
|
@@ -114,7 +111,7 @@
|
|
|
114
111
|
"clean": "node scripts/clean-dist.js",
|
|
115
112
|
"build": "echo \"tsc is compiling ...\" && tsc && chmod +x dist/dexbot.js dist/bot.js dist/unlock.js dist/pm2.js dist/credential-daemon.js",
|
|
116
113
|
"build:clean": "npm run clean && npm run build",
|
|
117
|
-
"build:tests": "tsc -p tsconfig.tests.json && cp tests/package.json dist/tests/package.json && cp tests/helpers/esm_mock_hooks.mjs tests/helpers/esm_mock_loader.mjs dist/tests/helpers/
|
|
114
|
+
"build:tests": "tsc -p tsconfig.tests.json && cp tests/package.json dist/tests/package.json && cp tests/helpers/esm_mock_hooks.mjs tests/helpers/esm_mock_loader.mjs dist/tests/helpers/",
|
|
118
115
|
"typecheck": "tsc --noEmit",
|
|
119
116
|
"check:any": "npm run build && node dist/scripts/check_any.js",
|
|
120
117
|
"check:any:update": "npm run build && node dist/scripts/check_any.js --update",
|
|
@@ -124,8 +121,7 @@
|
|
|
124
121
|
"version": "npm run version:sync && npm run build:clean",
|
|
125
122
|
"postversion": "npm run build:clean",
|
|
126
123
|
"prepack": "npm run build:clean",
|
|
127
|
-
"prepare": "npm run build:clean"
|
|
128
|
-
"postinstall": "node scripts/postinstall.js"
|
|
124
|
+
"prepare": "npm run build:clean"
|
|
129
125
|
},
|
|
130
126
|
"repository": {
|
|
131
127
|
"type": "git",
|
|
@@ -170,6 +166,7 @@
|
|
|
170
166
|
"./dist/modules/dexbot_state_recovery.js": false,
|
|
171
167
|
"./dist/modules/dexbot_startup_runtime.js": false,
|
|
172
168
|
"./dist/modules/dexbot_class.js": false,
|
|
169
|
+
"./dist/modules/lazy_shim.js": false,
|
|
173
170
|
"./dist/modules/graceful_shutdown.js": false,
|
|
174
171
|
"./dist/modules/process_discovery.js": false,
|
|
175
172
|
"./dist/modules/credential_runtime.js": false,
|
package/scripts/README.md
CHANGED
|
@@ -7,7 +7,7 @@ This guide provides a terminal-focused reference for the maintenance and diagnos
|
|
|
7
7
|
## 🛠️ CORE MAINTENANCE
|
|
8
8
|
|
|
9
9
|
### Update DEXBot2
|
|
10
|
-
**File:** `update.ts` (shim: `update.js`)
|
|
10
|
+
**File:** `update.ts` (shim: `update.js`), install-layout detection in `update_layout.ts`
|
|
11
11
|
**Purpose:** Perform a safe, production-ready update.
|
|
12
12
|
```bash
|
|
13
13
|
# Pull latest code, install deps, and restart PM2
|
|
@@ -143,12 +143,17 @@ shows live weights with color: higher = red (losing), lower = green (winning),
|
|
|
143
143
|
static = grey. Stale snapshot appends a red `(adapter offline)` alert to the
|
|
144
144
|
static weights.
|
|
145
145
|
|
|
146
|
-
###
|
|
147
|
-
**File:** `
|
|
148
|
-
**Purpose:**
|
|
146
|
+
### Credit Analysis
|
|
147
|
+
**File:** `analyze-credit.ts` (CLI: `dexbot credit`)
|
|
148
|
+
**Purpose:** Live-chain overview of active MPA (margin) and credit (borrowed-deal) positions, summed per asset per bot — the credit counterpart to `analyze-orders.ts` / `dexbot order`.
|
|
149
149
|
```bash
|
|
150
|
-
|
|
150
|
+
# Credit-enabled bots only
|
|
151
|
+
node dist/scripts/analyze-credit.js
|
|
152
|
+
|
|
153
|
+
# Single bot (name or key)
|
|
154
|
+
node dist/scripts/analyze-credit.js <bot>
|
|
151
155
|
```
|
|
156
|
+
Credit deals report per-pair and average CR, but only for pairs whitelisted in `bots.json` (`debtPolicy.lending`) and listed on the current credit offer; everything else is shown as ignored/unpriced and excluded from the average. A borrow-now preview per configured pair shows today's rate.
|
|
152
157
|
|
|
153
158
|
### Pool History Diagnostics
|
|
154
159
|
**File:** `diagnose-pool-history.ts`
|
|
@@ -195,36 +200,6 @@ The corpus report lands in `<profiles>/native_validation/mainnet_corpus_report.j
|
|
|
195
200
|
|
|
196
201
|
---
|
|
197
202
|
|
|
198
|
-
## 🔍 GIT & DEVELOPMENT WORKFLOW
|
|
199
|
-
|
|
200
|
-
### Interactive Git Changes Monitor
|
|
201
|
-
**File:** `git-viewer.sh`
|
|
202
|
-
**Purpose:** Interactive monitor for uncommitted, committed, and pushed changes.
|
|
203
|
-
```bash
|
|
204
|
-
# Launch interactive git changes viewer with fzf search
|
|
205
|
-
bash scripts/git-viewer.sh
|
|
206
|
-
```
|
|
207
|
-
|
|
208
|
-
**Features**:
|
|
209
|
-
- View uncommitted (working tree) changes
|
|
210
|
-
- View committed (staged) changes
|
|
211
|
-
- View pushed vs. remote-tracking changes
|
|
212
|
-
- Smart auto-refresh (1s for local, 15s for remote)
|
|
213
|
-
- Fuzzy search with `fzf` for finding files
|
|
214
|
-
- Toggle between full file view and diff-only view
|
|
215
|
-
|
|
216
|
-
**Usage**:
|
|
217
|
-
```bash
|
|
218
|
-
# Press '1' to view all changes
|
|
219
|
-
# Press '2' to search uncommitted files (with fzf)
|
|
220
|
-
# Press '3' to search unpushed commits (with fzf)
|
|
221
|
-
# Press '4' to search pushed commits (with fzf)
|
|
222
|
-
# Press 'q' to quit
|
|
223
|
-
```
|
|
224
|
-
Inside file viewer: `f` full file, `d` diff view, `q` back to search, `b` main menu.
|
|
225
|
-
|
|
226
|
-
---
|
|
227
|
-
|
|
228
203
|
## 💻 DEVELOPMENT UTILITIES
|
|
229
204
|
|
|
230
205
|
### Test Suite Setup
|
|
@@ -234,11 +209,31 @@ through `dist/scripts/run-tests.js` (with a per-test watchdog and diagnostics
|
|
|
234
209
|
summary). See [tests/README.md](../tests/README.md) for details.
|
|
235
210
|
|
|
236
211
|
### Repository Statistics Analyzer
|
|
237
|
-
**File:** `analyze-git.ts`
|
|
212
|
+
**File:** `analyze-git.ts` (CLI: `dexbot git`)
|
|
238
213
|
**Purpose:** Analyze git history and generate a chart of lines added vs deleted by file.
|
|
214
|
+
**Git-only:** Requires a source checkout (`.git` directory); it does not work with global npm installs.
|
|
239
215
|
```bash
|
|
216
|
+
# Preferred CLI entry point
|
|
217
|
+
dexbot git
|
|
218
|
+
|
|
219
|
+
# Direct invocation
|
|
240
220
|
node dist/scripts/analyze-git.js
|
|
241
221
|
```
|
|
222
|
+
The report is written to `analysis/charts/repo-stats.html`.
|
|
223
|
+
|
|
224
|
+
### Explicit-`any` Budget Ratchet
|
|
225
|
+
**File:** `check_any.ts`
|
|
226
|
+
**Purpose:** Count explicit `any` tokens on code lines (comments/JSDoc excluded) and fail when the count rises above the committed budget in `any-budget.json`, keeping `any` removal monotonic. Two scopes are tracked independently: `root` (`modules/`, `market_adapter/`, `analysis/`, `scripts/`, plus root-level `*.ts`) and `claw` (the experimental `claw/` subtree, tests excluded), so the clean root count is not inflated by claw.
|
|
227
|
+
```bash
|
|
228
|
+
# Compare against any-budget.json
|
|
229
|
+
npm run check:any
|
|
230
|
+
|
|
231
|
+
# Print per-file counts
|
|
232
|
+
npm run check:any:list
|
|
233
|
+
|
|
234
|
+
# Write the current count as the new budget
|
|
235
|
+
npm run check:any:update
|
|
236
|
+
```
|
|
242
237
|
|
|
243
238
|
### Credit Renewal Test
|
|
244
239
|
**File:** `test-credit-renewal.ts`
|
|
@@ -271,6 +266,7 @@ npm run version:check
|
|
|
271
266
|
# Rewrite aligned manifests from root package.json
|
|
272
267
|
npm run version:sync
|
|
273
268
|
```
|
|
269
|
+
|
|
274
270
|
---
|
|
275
271
|
|
|
276
272
|
## 🌳 BRANCH SYNCHRONIZATION
|
|
@@ -340,6 +336,13 @@ The following scripts allow you to call `dexbot` commands directly from the `scr
|
|
|
340
336
|
| `npm test` | Build + compile tests + run full suite (excludes live-chain tests) |
|
|
341
337
|
| `npm run test:live` | Build + compile tests + run full suite including live-chain tests |
|
|
342
338
|
|
|
339
|
+
### Code Quality
|
|
340
|
+
| Command | Purpose |
|
|
341
|
+
|:---|:---|
|
|
342
|
+
| `npm run check:any` | Fail if the explicit-`any` count rises above `any-budget.json` |
|
|
343
|
+
| `npm run check:any:list` | Print per-file explicit-`any` counts |
|
|
344
|
+
| `npm run check:any:update` | Write the current explicit-`any` count as the new budget |
|
|
345
|
+
|
|
343
346
|
### Runtime
|
|
344
347
|
| Command | Purpose |
|
|
345
348
|
|:---|:---|
|
|
@@ -347,8 +350,8 @@ The following scripts allow you to call `dexbot` commands directly from the `scr
|
|
|
347
350
|
| `npm run claw:unlock` | Build + single-prompt unlock (claw-only mode) |
|
|
348
351
|
| `npm run pm2:unlock` | Build + launch full bot via PM2 ecosystem |
|
|
349
352
|
| `npm run pm2:claw-only` | Build + launch claw-only PM2 process |
|
|
350
|
-
| `npm run pm2:start` |
|
|
351
|
-
| `npm run pm2:stop` | Stop PM2 processes
|
|
353
|
+
| `npm run pm2:start` | Unlock + start bots via PM2 (alias of `pm2:unlock`) |
|
|
354
|
+
| `npm run pm2:stop` | Stop all dexbot PM2 processes via the launcher |
|
|
352
355
|
|
|
353
356
|
### Branch Sync *(git checkout only)*
|
|
354
357
|
| Command | Purpose |
|
|
@@ -369,6 +372,8 @@ The following scripts allow you to call `dexbot` commands directly from the `scr
|
|
|
369
372
|
| `npm run market-adapter:fetch-cex-synthetic` | Fetch CEX synthetic data for market adapter |
|
|
370
373
|
| `npm run analysis:tradingview` | TradingView-style chart export |
|
|
371
374
|
| `npm run analysis:trade-pnl` | Trade PnL analysis from fill data |
|
|
375
|
+
| `npm run analysis:grid-check` | Last-fill-guard check (`grid_correction_check.ts`) |
|
|
376
|
+
| `npm run analysis:resolve-accounts` | Batch-resolve on-chain bot accounts (`resolve_bot_accounts.ts`) |
|
|
372
377
|
| `npm run ama:chart:lp-local` | Generate local LP comparison chart |
|
|
373
378
|
| `npm run lp:chart` | Generate uPlot LP chart |
|
|
374
379
|
| `npm run test:credit-renewal` | Test credit offer renewal for a specific bot |
|
package/tests/README.md
CHANGED
|
@@ -1,19 +1,21 @@
|
|
|
1
1
|
# DEXBot2 Test Suite
|
|
2
2
|
|
|
3
|
-
Tests live as standalone `.ts` files
|
|
3
|
+
Tests live as standalone `.ts` files under `tests/` (plus `claw/tests/` for the Claw integration). They are compiled to `dist/tests/` and `dist/claw/tests/` by the build and run from there with plain `node` — no test framework, no TypeScript loader. The suite uses Node's native `assert`.
|
|
4
|
+
|
|
5
|
+
`scripts/run-tests.ts` discovers every compiled `test_*.js` and runs them sequentially, echoing output and appending a timestamped log to `tests/tmp/`. Live-blockchain tests are opt-in via `RUN_LIVE_BITSHARES_TESTS=1` (see *Runner & environment* below).
|
|
4
6
|
|
|
5
7
|
## Quick Start
|
|
6
8
|
|
|
7
9
|
```bash
|
|
8
|
-
# Run all tests (builds production code + tests first)
|
|
10
|
+
# Run all offline tests (builds production code + tests first)
|
|
9
11
|
npm test
|
|
10
12
|
|
|
13
|
+
# Run including live-blockchain tests
|
|
14
|
+
npm run test:live
|
|
15
|
+
|
|
11
16
|
# Run a single test file
|
|
12
17
|
npm run build:tests
|
|
13
18
|
node dist/tests/<file>.js
|
|
14
|
-
|
|
15
|
-
# Run the archived legacy suites (excluded from `npm test`)
|
|
16
|
-
npm run test:legacy
|
|
17
19
|
```
|
|
18
20
|
|
|
19
21
|
## Directory Layout
|
|
@@ -21,22 +23,35 @@ npm run test:legacy
|
|
|
21
23
|
```
|
|
22
24
|
tests/
|
|
23
25
|
helpers/ # Shared test infrastructure (stubs, mocks, utilities)
|
|
24
|
-
tmp/ # Scratch space
|
|
26
|
+
tmp/ # Scratch space + per-run logs (gitignored)
|
|
25
27
|
tsconfig.json # Test-specific TS config (extends root)
|
|
26
28
|
<name>.ts # Test files (one file per module or concern)
|
|
29
|
+
claw/tests/ # Claw integration tests (same conventions, run by npm test)
|
|
27
30
|
```
|
|
28
31
|
|
|
29
32
|
`helpers/` contains reusable test support:
|
|
30
33
|
- `bitshares_client_stub.ts` — mock blockchain client
|
|
31
|
-
- `bitshares_native_stub.ts` — mock native chain client
|
|
32
|
-
- `chain_keys_stub.ts` — key derivation test doubles
|
|
33
34
|
- `chain_orders_stub.ts` — order lifecycle test doubles
|
|
34
35
|
- `fee_cache_init.ts` — fee cache seeding for tests
|
|
35
36
|
- `order_test_helpers.ts` — order construction utilities
|
|
36
37
|
- `silent_logger.ts` — suppresses log output during tests
|
|
37
38
|
- `module_cache_stub.ts` — isolates module state per test
|
|
39
|
+
- `vault_fixture.ts` — chain-key vault fixtures
|
|
40
|
+
- `pm2_path_shim.ts` — PM2 path isolation for `pm2.ts` tests
|
|
41
|
+
- `esm_mocks.ts` + `esm_mock_hooks.mjs` / `esm_mock_loader.mjs` — loader-hook harness for stubbing compiled ESM named exports
|
|
38
42
|
- `unlock_test_helpers.ts`, `foreign_cred_stub.js`, `dynamic_weight_files.ts` — domain-specific helpers
|
|
39
43
|
|
|
44
|
+
## Runner & environment
|
|
45
|
+
|
|
46
|
+
`scripts/run-tests.ts` runs each compiled `test_*.js` file as its own `node` process (no shared state between tests). Knobs:
|
|
47
|
+
|
|
48
|
+
- `RUN_LIVE_BITSHARES_TESTS=1` — also run the live-chain tests; without it they are skipped and counted as `skippedLive`. The live set is the `liveTestFiles` allow-list in `scripts/run-tests.ts`.
|
|
49
|
+
- `DEXBOT_TEST_CONCURRENCY=N` — run N files in parallel (default `1`; several tests share `tests/tmp` paths, so parallelism must be requested deliberately).
|
|
50
|
+
- `DEXBOT_TEST_TIMEOUT_MS=N` — per-file watchdog (default `240000`); on expiry the child is `SIGTERM`/`SIGKILL`ed and marked `TIMEOUT`.
|
|
51
|
+
- `DEXBOT_SUPPRESS_WARNINGS=1` — add `--no-warnings` to children (hides the warnings the diagnostics summary is meant to surface).
|
|
52
|
+
|
|
53
|
+
Every run appends to `tests/tmp/test-run-<timestamp>.log` and prints an aggregate summary (per-test pass/fail, slowest tests, and a diagnostics scan for warn/error/circular-dependency/deprecation/leak patterns).
|
|
54
|
+
|
|
40
55
|
## Test Categories
|
|
41
56
|
|
|
42
57
|
Tests are organized by concern, **not** by directory — patterns like `test_<area>*.ts` indicate the focus area. Below is a thematic guide with representative files (run `ls tests/*.ts` for the full list).
|
|
@@ -47,7 +62,7 @@ Connection, subscriptions, node management, native chain client.
|
|
|
47
62
|
|
|
48
63
|
### Account & Authentication
|
|
49
64
|
Key validation, balance queries, account selection.
|
|
50
|
-
*Examples:* `test_key_validation.ts`, `test_account_totals.ts`, `
|
|
65
|
+
*Examples:* `test_key_validation.ts`, `test_account_totals.ts`, `test_chain_keys_vault.ts`
|
|
51
66
|
|
|
52
67
|
### Market Data & Pricing
|
|
53
68
|
Price derivation, orderbook inspection, tolerance checks.
|
|
@@ -150,4 +165,4 @@ Shared utility functions, precision handling, chain helpers.
|
|
|
150
165
|
|
|
151
166
|
---
|
|
152
167
|
|
|
153
|
-
**Note:** Interactive/diagnostic scripts (`connection_test.ts`, `diag_
|
|
168
|
+
**Note:** Interactive/diagnostic scripts (`connection_test.ts`, `diag_*`, `benchmark_cow.ts`, `sim_batching.ts`, `repro_phantom_orders.ts`) require network access or real state and are **not** run by `npm test` — the runner only globs `test_*.js`. Run these manually when debugging.
|
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import { createRequire } from 'node:module';
|
|
3
|
-
const require = createRequire(import.meta.url);
|
|
4
|
-
'use strict';
|
|
5
|
-
/**
|
|
6
|
-
* Diagnostic: Fetch raw Kibana LP candles for pool 1.19.133
|
|
7
|
-
* to verify whether the pool actually had trading activity.
|
|
8
|
-
*/
|
|
9
|
-
const kibanaSource = require('../market_adapter/inputs/kibana_source');
|
|
10
|
-
async function main() {
|
|
11
|
-
const assetA = { id: '1.3.5537', precision: 4, symbol: 'IOB.XRP' };
|
|
12
|
-
const assetB = { id: '1.3.0', precision: 5, symbol: 'BTS' };
|
|
13
|
-
console.log('Fetching Kibana LP candles for pool 1.19.133...');
|
|
14
|
-
console.log('Lookback: 720h (30 days), interval: 1h');
|
|
15
|
-
console.log('');
|
|
16
|
-
const candles = await kibanaSource.getLpCandlesForPool('1.19.133', assetA, assetB, {
|
|
17
|
-
intervalSeconds: 3600,
|
|
18
|
-
lookbackHours: 720,
|
|
19
|
-
apiKey: null,
|
|
20
|
-
});
|
|
21
|
-
console.log(`Total candles returned: ${candles.length}`);
|
|
22
|
-
if (candles.length === 0) {
|
|
23
|
-
console.log('NO candles returned from Kibana.');
|
|
24
|
-
return;
|
|
25
|
-
}
|
|
26
|
-
// Count unique close prices
|
|
27
|
-
const uniqueCloses = new Set(candles.map((c) => c[4]));
|
|
28
|
-
console.log(`Unique close prices: ${uniqueCloses.size}`);
|
|
29
|
-
// Show first and last
|
|
30
|
-
const first = candles[0];
|
|
31
|
-
const last = candles[candles.length - 1];
|
|
32
|
-
console.log(`\nFirst candle: ${new Date(first[0]).toISOString()} O=${first[1]} H=${first[2]} L=${first[3]} C=${first[4]} vol=${first[5]}`);
|
|
33
|
-
console.log(`Last candle: ${new Date(last[0]).toISOString()} O=${last[1]} H=${last[2]} L=${last[3]} C=${last[4]} vol=${last[5]}`);
|
|
34
|
-
// Find runs of identical prices
|
|
35
|
-
let maxRun = 0;
|
|
36
|
-
let currentRun = 1;
|
|
37
|
-
let maxRunPrice = null;
|
|
38
|
-
for (let i = 1; i < candles.length; i++) {
|
|
39
|
-
if (candles[i][4] === candles[i - 1][4]) {
|
|
40
|
-
currentRun++;
|
|
41
|
-
if (currentRun > maxRun) {
|
|
42
|
-
maxRun = currentRun;
|
|
43
|
-
maxRunPrice = candles[i][4];
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
else {
|
|
47
|
-
currentRun = 1;
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
console.log(`\nLongest run of identical closes: ${maxRun} candles @ ${maxRunPrice}`);
|
|
51
|
-
// Show candles with non-zero volume
|
|
52
|
-
const withVolume = candles.filter((c) => c[5] > 0);
|
|
53
|
-
console.log(`Candles with volume > 0: ${withVolume.length}`);
|
|
54
|
-
const trueOhlc = candles.filter((c) => c[5] > 0 && (c[1] !== c[2] || c[1] !== c[3] || c[1] !== c[4]));
|
|
55
|
-
console.log(`Candles with non-flat OHLC: ${trueOhlc.length}`);
|
|
56
|
-
// Show a few recent candles
|
|
57
|
-
console.log('\nLast 10 candles:');
|
|
58
|
-
candles.slice(-10).forEach((c, i) => {
|
|
59
|
-
const idx = candles.length - 10 + i;
|
|
60
|
-
console.log(` [${idx}] ${new Date(c[0]).toISOString()} O=${c[1].toFixed(6)} H=${c[2].toFixed(6)} L=${c[3].toFixed(6)} C=${c[4].toFixed(6)} vol=${c[5].toFixed(2)}`);
|
|
61
|
-
});
|
|
62
|
-
if (trueOhlc.length > 0) {
|
|
63
|
-
console.log('\nRecent non-flat OHLC candles:');
|
|
64
|
-
trueOhlc.slice(-10).forEach((c) => {
|
|
65
|
-
console.log(` ${new Date(c[0]).toISOString()} O=${c[1].toFixed(6)} H=${c[2].toFixed(6)} L=${c[3].toFixed(6)} C=${c[4].toFixed(6)} vol=${c[5].toFixed(2)}`);
|
|
66
|
-
});
|
|
67
|
-
}
|
|
68
|
-
// Show where price changes happened
|
|
69
|
-
console.log('\nPrice changes (first 20):');
|
|
70
|
-
let changes = 0;
|
|
71
|
-
for (let i = 1; i < candles.length && changes < 20; i++) {
|
|
72
|
-
if (candles[i][4] !== candles[i - 1][4]) {
|
|
73
|
-
changes++;
|
|
74
|
-
console.log(` [${i}] ${new Date(candles[i][0]).toISOString()} ${candles[i - 1][4].toFixed(6)} -> ${candles[i][4].toFixed(6)}`);
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
main().catch(err => {
|
|
79
|
-
console.error('Fatal:', err);
|
|
80
|
-
process.exit(1);
|
|
81
|
-
});
|
|
82
|
-
//# sourceMappingURL=diagnose-kibana-candles.js.map
|