dexbot 1.6.8 → 1.6.9
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 +24 -0
- package/claw/package.json +1 -1
- package/claw/runtimes/openclaw-plugin/openclaw.plugin.json +1 -1
- package/claw/runtimes/openclaw-plugin/package.json +1 -1
- package/dist/dexbot.js +44 -21
- package/dist/market_adapter/core/market_adapter_service.d.ts +81 -1
- package/dist/market_adapter/core/market_adapter_service.js +225 -18
- package/dist/market_adapter/core/signals/hurst_analyzer.d.ts +10 -1
- package/dist/market_adapter/core/signals/hurst_analyzer.js +40 -18
- package/dist/market_adapter/core/signals/permutation_entropy_analyzer.d.ts +26 -2
- package/dist/market_adapter/core/signals/permutation_entropy_analyzer.js +132 -29
- package/dist/market_adapter/core/strategies/regime_gate.d.ts +61 -3
- package/dist/market_adapter/core/strategies/regime_gate.js +207 -7
- package/dist/market_adapter/interval_utils.d.ts +18 -1
- package/dist/market_adapter/interval_utils.js +31 -1
- package/dist/market_adapter/market_adapter.d.ts +151 -2
- package/dist/market_adapter/market_adapter.js +378 -62
- package/dist/market_adapter/test_helpers.d.ts +2 -2
- package/dist/market_adapter/test_helpers.js +2 -2
- package/dist/market_adapter/utils/file_json_cache.d.ts +29 -0
- package/dist/market_adapter/utils/file_json_cache.js +106 -0
- package/dist/modules/config.d.ts +6 -0
- package/dist/modules/config.js +1 -0
- package/dist/modules/constants.d.ts +5 -1
- package/dist/modules/constants.js +41 -14
- package/dist/modules/order/grid.js +95 -25
- package/dist/modules/version_notice.d.ts +166 -20
- package/dist/modules/version_notice.js +401 -56
- package/dist/pm2.js +9 -2
- package/dist/unlock.js +7 -7
- package/docs/DEXBOT_COMPARISON.md +3 -3
- package/docs/EVOLUTION.md +13 -12
- package/docs/FUND_MOVEMENT_AND_ACCOUNTING.md +1 -1
- package/docs/GRID_RECALCULATION.md +6 -2
- package/docs/README.md +2 -2
- package/market_adapter/README.md +28 -0
- package/package.json +1 -1
package/dist/unlock.js
CHANGED
|
@@ -51,7 +51,7 @@ import { UPDATER, LAUNCHER } from './modules/constants.js';
|
|
|
51
51
|
import { formatStartupNotice } from './modules/cli_start_output.js';
|
|
52
52
|
import { runtime } from './modules/runtime.js';
|
|
53
53
|
import { PATHS, printRelocationNotices } from './modules/paths.js';
|
|
54
|
-
import { startVersionStatusCheck,
|
|
54
|
+
import { startVersionStatusCheck, flushVersionStatusOrHeader, printVersionStatusWhenReady } from './modules/version_notice.js';
|
|
55
55
|
import { buildRuntimeScriptArgs } from './modules/launcher/runtime_entry.js';
|
|
56
56
|
import { sendControlCommand } from './modules/launcher/supervisor_control.js';
|
|
57
57
|
import { registerCleanup, setupGracefulShutdown } from './modules/graceful_shutdown.js';
|
|
@@ -505,7 +505,7 @@ async function main({ argv = process.argv, startupGraceMs = DEFAULT_STARTUP_GRAC
|
|
|
505
505
|
printLauncherHeader({ botName: effectiveBotName || botName, clawOnly, creditOnly, isolated, dryrun, headless });
|
|
506
506
|
console.log(`DEXBot2 already running in background (PID ${pid}).`);
|
|
507
507
|
console.log('Use `dexbot stat` to inspect it, or `dexbot restart` to restart it.');
|
|
508
|
-
await
|
|
508
|
+
await flushVersionStatusOrHeader(versionStatus);
|
|
509
509
|
process.exitCode = 0;
|
|
510
510
|
return;
|
|
511
511
|
}
|
|
@@ -565,7 +565,7 @@ async function main({ argv = process.argv, startupGraceMs = DEFAULT_STARTUP_GRAC
|
|
|
565
565
|
if (pid > 0) {
|
|
566
566
|
console.log(`DEXBot2 already running in background (PID ${pid}).`);
|
|
567
567
|
console.log('Use `dexbot stat` to inspect it, or `dexbot restart` to restart it.');
|
|
568
|
-
await
|
|
568
|
+
await flushVersionStatusOrHeader(versionStatus);
|
|
569
569
|
process.exitCode = 0;
|
|
570
570
|
return;
|
|
571
571
|
}
|
|
@@ -608,12 +608,12 @@ async function main({ argv = process.argv, startupGraceMs = DEFAULT_STARTUP_GRAC
|
|
|
608
608
|
child.unref();
|
|
609
609
|
storage.writeFile(MONOLITHIC_PID_FILE, String(child.pid), { mode: 0o600 });
|
|
610
610
|
printLauncherStartupSummary({ botNames: launchedBotNames, mode: 'background' });
|
|
611
|
-
await
|
|
611
|
+
await flushVersionStatusOrHeader(versionStatus);
|
|
612
612
|
process.exit(0);
|
|
613
613
|
}
|
|
614
614
|
if (clawOnly) {
|
|
615
615
|
printLauncherSuccess({ clawOnly });
|
|
616
|
-
await
|
|
616
|
+
await flushVersionStatusOrHeader(versionStatus);
|
|
617
617
|
const exitCode = await controller.waitForManagedDaemon();
|
|
618
618
|
process.exitCode = exitCode || 0;
|
|
619
619
|
return;
|
|
@@ -642,7 +642,7 @@ async function main({ argv = process.argv, startupGraceMs = DEFAULT_STARTUP_GRAC
|
|
|
642
642
|
console.log(`Supervisor PID: ${supervisorPid}`);
|
|
643
643
|
console.log(`Control socket: ${Config.DEXBOT_SUPERVISOR_SOCKET || SOCKET_PATH}`);
|
|
644
644
|
console.log(`Supervisor logs: ${SUPERVISOR_OUT_LOG}`);
|
|
645
|
-
await
|
|
645
|
+
await flushVersionStatusOrHeader(versionStatus);
|
|
646
646
|
process.exitCode = 0;
|
|
647
647
|
return;
|
|
648
648
|
}
|
|
@@ -715,7 +715,7 @@ async function main({ argv = process.argv, startupGraceMs = DEFAULT_STARTUP_GRAC
|
|
|
715
715
|
if (!updater?.pendingRestart) {
|
|
716
716
|
if (!isMonolithicBgChild) {
|
|
717
717
|
printLauncherStartupSummary({ botNames: launchedBotNames, mode: 'foreground' });
|
|
718
|
-
await
|
|
718
|
+
await flushVersionStatusOrHeader(versionStatus);
|
|
719
719
|
}
|
|
720
720
|
}
|
|
721
721
|
const onSigint = () => forwardSignal(botProcess, 'SIGINT');
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# DEXBot vs DEXBot2 — Detailed Comparison Report
|
|
2
2
|
|
|
3
3
|
> **Date:** 2026-09-02 *(metrics refreshed against local source trees)*
|
|
4
|
-
> **Scope:** Full architectural, functional, and operational comparison between the original [DEXBot](https://github.com/Codaone/DEXBot) (Python, v1.0.0) and DEXBot2 (TypeScript, v1.6.
|
|
4
|
+
> **Scope:** Full architectural, functional, and operational comparison between the original [DEXBot](https://github.com/Codaone/DEXBot) (Python, v1.0.0) and DEXBot2 (TypeScript, v1.6.9).
|
|
5
5
|
> **Audience:** Developers, contributors, and operators evaluating or migrating between the two projects.
|
|
6
6
|
|
|
7
7
|
---
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
|
|
37
37
|
| Attribute | DEXBot (original) | DEXBot2 |
|
|
38
38
|
|---|---|---|
|
|
39
|
-
| **Release Track** | 1.0.0 | v1.6.
|
|
39
|
+
| **Release Track** | 1.0.0 | v1.6.9 |
|
|
40
40
|
| **Language** | Python 3.6+ | TypeScript 5.x |
|
|
41
41
|
| **Status** | Released 1.0.0, unmaintained | Active development |
|
|
42
42
|
| **Last Repo Activity** | May 23, 2020 | 2026-09-02 |
|
|
@@ -776,7 +776,7 @@ Where:
|
|
|
776
776
|
|
|
777
777
|
| Metric | DEXBot | DEXBot2 |
|
|
778
778
|
|---|---|---|
|
|
779
|
-
| **Release Track** | 1.0.0 | v1.6.
|
|
779
|
+
| **Release Track** | 1.0.0 | v1.6.9 |
|
|
780
780
|
| **Active Since** | ~2018 | December 2025 |
|
|
781
781
|
| **Last Commit** | May 23, 2020 | 2026-09-02 |
|
|
782
782
|
| **Total Commits** | 2281 | 2,125 (v1.4.25) |
|
package/docs/EVOLUTION.md
CHANGED
|
@@ -2,14 +2,14 @@
|
|
|
2
2
|
|
|
3
3
|
## Executive Summary
|
|
4
4
|
|
|
5
|
-
DEXBot2 is a sophisticated decentralized exchange trading bot for the BitShares blockchain. This report documents the complete evolution of the project from its inception in December 2025 through the current 1.6.
|
|
5
|
+
DEXBot2 is a sophisticated decentralized exchange trading bot for the BitShares blockchain. This report documents the complete evolution of the project from its inception in December 2025 through the current 1.6.9 release.
|
|
6
6
|
|
|
7
7
|
### Key Milestones
|
|
8
8
|
- **Project Inception**: December 2, 2025
|
|
9
|
-
- **Growth Phase**: 2,
|
|
9
|
+
- **Growth Phase**: 2,306 commits over ~9 active months
|
|
10
10
|
- **Code Maturity**: Evolution from basic utilities to a ~100,000+ LoC intelligent TypeScript system
|
|
11
11
|
- **Stability**: Progression from manual testing to a suite of 305 automated test files
|
|
12
|
-
- **Releases**:
|
|
12
|
+
- **Releases**: 141 version entries in the changelog (v0.1.0 to v1.6.9)
|
|
13
13
|
|
|
14
14
|
> **Post-1.0.0 "why":** the thematic story behind the hardening releases — root cause, recurring
|
|
15
15
|
> bug families, and lessons — lives in
|
|
@@ -149,7 +149,7 @@ Evolved from a basic README to a comprehensive framework (50+ docs entries, 80%+
|
|
|
149
149
|
|
|
150
150
|
## Version History
|
|
151
151
|
|
|
152
|
-
Compact, era-level view; commit counts are `git rev-list --count <tag>..<tag>` over the current history (2026-09-
|
|
152
|
+
Compact, era-level view; commit counts are `git rev-list --count <tag>..<tag>` over the current history (2026-09-30), so the column sums to 2,200 — the 106 commits before the `v0.1.0` tag are not attributed to an era (2,200 + 106 = 2,306). Per-release detail lives in [CHANGELOG.md](../CHANGELOG.md); the thematic post-1.0.0 story in [ORDER_ENGINE_POST_1.0_RETROSPECTIVE.md](ORDER_ENGINE_POST_1.0_RETROSPECTIVE.md).
|
|
153
153
|
|
|
154
154
|
| Era | Commits | Theme |
|
|
155
155
|
|-----|--------:|-------|
|
|
@@ -161,16 +161,17 @@ Compact, era-level view; commit counts are `git rev-list --count <tag>..<tag>` o
|
|
|
161
161
|
| v1.4.25 → v1.5.3 | 45 | Credit overview + whitelist-scoped CR, TradingView tooling, daemon-safe reload, gap-evacuation/rail-hole hardening, sync adoption hardening, boundary ownership |
|
|
162
162
|
| v1.5.3 → v1.6.0 | 39 | Node-failure ledger, grid regeneration, reserve ladder, live-config pickup, owed-crawl persistence, fill-anchored boundary recovery, TradingView overlay |
|
|
163
163
|
| v1.6.0 → v1.6.3 | 17 | Never-run-stale hardening, whitelist range-scaling opt-in, grid-price invariant, shard candle cache, correction-queue staleness, final pre-broadcast pivot gate |
|
|
164
|
-
| v1.6.3 → v1.6.4 | 19 | Fund-driven spread correction,
|
|
165
|
-
| v1.6.4 → v1.6.5 | 16 | Editor-managed whitelist flags
|
|
166
|
-
| v1.6.5 → v1.6.6 | 13 | Stale-cancellation guard hardening
|
|
167
|
-
| v1.6.6 → v1.6.7 | 11 |
|
|
168
|
-
| v1.6.7 → v1.6.8 | 12 | Correction-drain budget + broadcast-
|
|
164
|
+
| v1.6.3 → v1.6.4 | 19 | Fund-driven spread correction, batched correction cap, RMS divergence, invariant-doc contract, shared analysis modules, window-aware profitability, portable chart exports, range-threshold restore, dead-code purge |
|
|
165
|
+
| v1.6.4 → v1.6.5 | 16 | Editor-managed whitelist flags, centralized bot defaults/settings, log-symmetric range tilt, AMA gridPrice normalization, Pool/Health cues, AMA-slope Δ knob, dynamic-weight CLI, update self-heal, RMS log tagging |
|
|
166
|
+
| v1.6.5 → v1.6.6 | 13 | Stale-cancellation guard hardening, editor/CLI realignment, poolRef aliases + startPrice priority, legacy SMA/MACD/RSI analyzer archived, run-relative candle-cache migration dropped, dist-freshness exclude fix |
|
|
167
|
+
| v1.6.6 → v1.6.7 | 11 | Session/fill-channel recovery, clean-process ecosystem regen, onboarding redirect and key-manager link fixes, LAST-FILL-GUARD pivot persistence |
|
|
168
|
+
| v1.6.7 → v1.6.8 | 12 | Correction-drain budget + broadcast-deferral bounds, PM2 log capture + rotation, passive version notice, genesis-ladder refusal, reserve window exclusion, legacy tolerance-matcher removal, npm-tarball trim, TV grid-reset replay, bounded Kibana tail refresh, 1.4x range-threshold widening |
|
|
169
|
+
| v1.6.8 → v1.6.9 | 6 | Market-adapter cycle-CPU cuts, candle-boundary off-hour idle, spread-correction spread-tightening guard |
|
|
169
170
|
|
|
170
171
|
---
|
|
171
172
|
|
|
172
173
|
**Report Originally Generated**: February 19, 2026
|
|
173
|
-
**Last Updated**: September
|
|
174
|
-
**Total Commits**: 2,
|
|
175
|
-
**Date Range**: December 2, 2025 – September
|
|
174
|
+
**Last Updated**: September 30, 2026
|
|
175
|
+
**Total Commits**: 2,306
|
|
176
|
+
**Date Range**: December 2, 2025 – September 30, 2026
|
|
176
177
|
**Repository**: DEXBot2 (BitShares DEX Trading Bot)
|
|
@@ -801,4 +801,4 @@ To prevent "Time-of-Check to Time-of-Use" errors:
|
|
|
801
801
|
**TOCTOU protection in `processFillAccounting`.** `_buildBtsDeferredRefundAdjustment` reads `btsFeeState` from `mgr.orders` while the order lock is held — the lock is acquired before accounting runs, and the POST-RESET and BOOTSTRAP tracked-fill accounting paths follow the same locking pattern.
|
|
802
802
|
|
|
803
803
|
---
|
|
804
|
-
*Technical Reference for DEXBot2 v1.6.
|
|
804
|
+
*Technical Reference for DEXBot2 v1.6.9 release*
|
|
@@ -158,7 +158,6 @@ node dist/market_adapter/market_adapter.js --deltaPercent 2
|
|
|
158
158
|
```json
|
|
159
159
|
{
|
|
160
160
|
"ama": {
|
|
161
|
-
"enabled": true,
|
|
162
161
|
"erPeriod": 10, // Efficiency Ratio lookback period (candles)
|
|
163
162
|
"fastPeriod": 2, // Fast smoothing period for trending markets
|
|
164
163
|
"slowPeriod": 30, // Slow smoothing period for choppy markets
|
|
@@ -167,6 +166,12 @@ node dist/market_adapter/market_adapter.js --deltaPercent 2
|
|
|
167
166
|
}
|
|
168
167
|
```
|
|
169
168
|
|
|
169
|
+
> **`gridPrice` is the only switch.** A bot is AMA-driven when `gridPrice` says
|
|
170
|
+
> so — `usesAmaGridPrice()`, the source of truth shared by the bot, maintenance
|
|
171
|
+
> and launcher runtimes. There is deliberately no `ama.enabled`: a second switch
|
|
172
|
+
> could only disagree with them, freezing the center the bot still trades on. To
|
|
173
|
+
> park a bot, set a non-AMA `gridPrice` (`"fixed"`, a number, `"pool"`, `"book"`).
|
|
174
|
+
|
|
170
175
|
**Optional: `poolRef`** — pin a specific pool ID for price derivation when using `startPrice: "pool"`. Set in `bots.json` alongside the bot entry:
|
|
171
176
|
```json
|
|
172
177
|
{
|
|
@@ -184,7 +189,6 @@ The pool is fetched directly by ID, bypassing pool discovery. Useful when the tr
|
|
|
184
189
|
- If no pair profile matches, the bot's `ama` block is used as the fallback
|
|
185
190
|
|
|
186
191
|
**AMA Parameters:**
|
|
187
|
-
- `enabled`: Whether to track AMA and trigger grid resets (true/false)
|
|
188
192
|
- `erPeriod`: How many candles to look back for trend detection
|
|
189
193
|
- Higher values: More stable, slower response (e.g. `erPeriod=781` very stable)
|
|
190
194
|
- Lower values: More responsive, catches quick moves
|
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.
|
|
5
|
+
**Version context:** v1.6.9 (released).
|
|
6
6
|
|
|
7
7
|
---
|
|
8
8
|
|
|
@@ -211,7 +211,7 @@ While these docs explain the *why*, the *how* lives in the code. See the full [m
|
|
|
211
211
|
- **`modules/order/strategy.ts`**: Grid rebalancing, order activation, consolidation, rotation, and spread management
|
|
212
212
|
- **`modules/order/sync_engine.ts`**: Blockchain synchronization, fill detection, order reconciliation
|
|
213
213
|
- **`modules/order/genesis_policy.ts`**: Missing-ladder refusal and the `MISSING_GENESIS_POLICY` rebuild/halt decision ([GRID_PRICE_INVARIANT.md](GRID_PRICE_INVARIANT.md))
|
|
214
|
-
- **`modules/version_notice.ts`**:
|
|
214
|
+
- **`modules/version_notice.ts`**: The single version probe and status-line renderer for every entry point (`stat`/`pm2`/`start`/`restart`). Two sources (npm, then GitHub releases), a 12h cache for successes and a 15min backoff for failures, an explicit reason when it cannot answer, and a staged wait in `dexbot stat` ending in "no current version information" rather than silence
|
|
215
215
|
- **`modules/credit_runtime.ts`**: Bot-scoped debt workflow executor (MPA and credit offer accept/repay/reborrow)
|
|
216
216
|
- **`modules/cr_planner.ts`**: Shared collateral-ratio math layer for debt-first planning
|
|
217
217
|
- **`modules/order/utils/math.ts`**: Precision conversions, RMS divergence calculation, fund allocation math
|
package/market_adapter/README.md
CHANGED
|
@@ -292,6 +292,33 @@ Pair-specific AMA profiles live in `profiles/market_profiles.json`:
|
|
|
292
292
|
}
|
|
293
293
|
```
|
|
294
294
|
|
|
295
|
+
## Off-Hour Idle Behavior
|
|
296
|
+
|
|
297
|
+
The adapter only has work once per closed candle, so it stays quiet in between:
|
|
298
|
+
|
|
299
|
+
| Phase | Behavior |
|
|
300
|
+
|-------|----------|
|
|
301
|
+
| Startup | **Sleep-first, before any connection.** A respawned daemon checks whether every active AMA bot already consumed the newest closed candle; if so it sleeps to the next `pollSeconds` boundary (default 3600) without opening a socket, otherwise a catch-up cycle runs immediately. |
|
|
302
|
+
| Per bot, per cycle | **Closed-bucket gate before any fetch.** If the bot already consumed the newest closed bucket and its candle cache covers it (right source, no unresolved gaps, warmup target met), the bot is skipped before the native overlap fetch, the Kibana stale-tail check, and the candle re-serialize. |
|
|
303
|
+
| Between cycles | The BitShares socket is torn down after every cycle; the process sleeps with only an unref'd lock heartbeat. |
|
|
304
|
+
|
|
305
|
+
Both gates fail **open**: any input they cannot evaluate — fresh or unusable state, an interval that differs from the poll cadence (e.g. 2h candles polled hourly), a marker ahead of the clock (clock skew), an active bot with no row or no consumed marker (bootstrap owed), a bot whose last cycle left repair outstanding (`unresolvedGapCount > 0`, or `candleCount < rawKeepCount`, including an unknown count next to a known target) — runs the full cycle instead. Per-bot verdicts are never aggregated, so one lagging bot triggers a catch-up for everyone, and the veto is logged with its reason and bot keys:
|
|
306
|
+
|
|
307
|
+
```
|
|
308
|
+
Startup: running a catch-up cycle now — no_state_row [broken-bot].
|
|
309
|
+
```
|
|
310
|
+
|
|
311
|
+
Only bots the adapter would actually process are in scope, so a removed bot's leftover state row cannot keep the daemon awake. `kibanaBackfillCount`/`kibanaGapRepairCount` are deliberately ignored: they are action counts from a cycle that already applied its repair, not owed work.
|
|
312
|
+
|
|
313
|
+
Two deliberate trade-offs:
|
|
314
|
+
|
|
315
|
+
- An active bot that can *never* write state (unresolvable market, persistent pre-persist failure) disables the startup sleep for the whole daemon indefinitely — fail-safe by design, since healthy bots still take the per-bot skip; fixing or deactivating the bot restores the sleep.
|
|
316
|
+
- A config change made *after* the last cycle (e.g. a grown AMA window) waits for the next boundary. That backfill is bounded by one poll period, and no candle can close while the adapter sleeps, so no market value is ever late.
|
|
317
|
+
|
|
318
|
+
One-shot entry points (`--once`, and `runOnceForAma` behind `ama_signal_runner`) always run a full cycle — they exist to produce a computed AMA on demand, not a state-only "skipped" record with null prices.
|
|
319
|
+
|
|
320
|
+
Skipped work is visible in state: skipped bots record `lastCycleSource: "off-hour-skip"` with a fresh `lastCycleAt`, so monitoring can tell an idle-by-design adapter from a dead process. A skip record is a last-known snapshot, not an epoch reset: `amaPrice`, `amaCenterPrice`, `lastCandleTs` and the other data fields keep the values from the last full cycle, and only `lastCycleSource`/`lastCycleAt`/`pendingClosedCandle`/`lastTriggerSuppressedReason` are refreshed. Between-cycle consumers therefore read the most recent computed values rather than a hole.
|
|
321
|
+
|
|
295
322
|
## Live Writes and Dry-Run
|
|
296
323
|
|
|
297
324
|
The whitelist controls what the adapter may write. Non-whitelisted bots are
|
|
@@ -980,6 +1007,7 @@ Important fields in `market_adapter/state/market_adapter_state.json`:
|
|
|
980
1007
|
| Field | Meaning |
|
|
981
1008
|
|-------|---------|
|
|
982
1009
|
| `meta.updatedAt` | Last completed adapter cycle (ISO timestamp) |
|
|
1010
|
+
| `lastCycleSource` | How the last cycle ended the bot: a fetch source (`native-incremental-overlap`, `kibana-backfill`, …) or `off-hour-skip` when the closed-candle gate skipped the work |
|
|
983
1011
|
| `meta.metrics.processedBots` | Number of bots evaluated this cycle |
|
|
984
1012
|
| `meta.metrics.durationMs` | Cycle wall-clock duration in milliseconds |
|
|
985
1013
|
| `lastCycleAt` | Last cycle timestamp for a bot |
|
package/package.json
CHANGED