dexbot 1.6.6 → 1.6.7

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 (110) hide show
  1. package/CHANGELOG.md +41 -1
  2. package/README.md +5 -2
  3. package/analysis/trend_detection/package.json +1 -1
  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/claw/tests/test_claw_mcp_transport.ts +2 -2
  8. package/dist/dexbot.d.ts.map +1 -1
  9. package/dist/dexbot.js +22 -9
  10. package/dist/dexbot.js.map +1 -1
  11. package/dist/modules/account_bots.d.ts.map +1 -1
  12. package/dist/modules/account_bots.js +10 -9
  13. package/dist/modules/account_bots.js.map +1 -1
  14. package/dist/modules/account_orders.d.ts +20 -2
  15. package/dist/modules/account_orders.d.ts.map +1 -1
  16. package/dist/modules/account_orders.js +63 -3
  17. package/dist/modules/account_orders.js.map +1 -1
  18. package/dist/modules/bitshares-native/chain_client.d.ts +10 -0
  19. package/dist/modules/bitshares-native/chain_client.d.ts.map +1 -1
  20. package/dist/modules/bitshares-native/chain_client.js +197 -28
  21. package/dist/modules/bitshares-native/chain_client.js.map +1 -1
  22. package/dist/modules/bitshares-native/subscriptions.d.ts.map +1 -1
  23. package/dist/modules/bitshares-native/subscriptions.js +312 -10
  24. package/dist/modules/bitshares-native/subscriptions.js.map +1 -1
  25. package/dist/modules/bitshares-native/transport.d.ts +1 -0
  26. package/dist/modules/bitshares-native/transport.d.ts.map +1 -1
  27. package/dist/modules/bitshares-native/transport.js +97 -3
  28. package/dist/modules/bitshares-native/transport.js.map +1 -1
  29. package/dist/modules/bitshares_client.d.ts +20 -0
  30. package/dist/modules/bitshares_client.d.ts.map +1 -1
  31. package/dist/modules/bitshares_client.js +29 -0
  32. package/dist/modules/bitshares_client.js.map +1 -1
  33. package/dist/modules/chain_keys.d.ts +37 -22
  34. package/dist/modules/chain_keys.d.ts.map +1 -1
  35. package/dist/modules/chain_keys.js +145 -44
  36. package/dist/modules/chain_keys.js.map +1 -1
  37. package/dist/modules/cli_start_onboarding.d.ts +10 -0
  38. package/dist/modules/cli_start_onboarding.d.ts.map +1 -0
  39. package/dist/modules/cli_start_onboarding.js +15 -0
  40. package/dist/modules/cli_start_onboarding.js.map +1 -0
  41. package/dist/modules/cli_start_output.d.ts +6 -0
  42. package/dist/modules/cli_start_output.d.ts.map +1 -0
  43. package/dist/modules/cli_start_output.js +8 -0
  44. package/dist/modules/cli_start_output.js.map +1 -0
  45. package/dist/modules/constants.d.ts +13 -0
  46. package/dist/modules/constants.d.ts.map +1 -1
  47. package/dist/modules/constants.js +103 -1
  48. package/dist/modules/constants.js.map +1 -1
  49. package/dist/modules/dexbot_cow_runtime.d.ts.map +1 -1
  50. package/dist/modules/dexbot_cow_runtime.js +49 -9
  51. package/dist/modules/dexbot_cow_runtime.js.map +1 -1
  52. package/dist/modules/dexbot_fill_runtime.d.ts +6 -1
  53. package/dist/modules/dexbot_fill_runtime.d.ts.map +1 -1
  54. package/dist/modules/dexbot_fill_runtime.js +22 -3
  55. package/dist/modules/dexbot_fill_runtime.js.map +1 -1
  56. package/dist/modules/dexbot_maintenance_runtime.d.ts +24 -1
  57. package/dist/modules/dexbot_maintenance_runtime.d.ts.map +1 -1
  58. package/dist/modules/dexbot_maintenance_runtime.js +45 -1
  59. package/dist/modules/dexbot_maintenance_runtime.js.map +1 -1
  60. package/dist/modules/dexbot_state_recovery.d.ts.map +1 -1
  61. package/dist/modules/dexbot_state_recovery.js +13 -1
  62. package/dist/modules/dexbot_state_recovery.js.map +1 -1
  63. package/dist/modules/order/grid.d.ts.map +1 -1
  64. package/dist/modules/order/grid.js +33 -1
  65. package/dist/modules/order/grid.js.map +1 -1
  66. package/dist/modules/order/grid_reconcile_internal.d.ts.map +1 -1
  67. package/dist/modules/order/grid_reconcile_internal.js +11 -0
  68. package/dist/modules/order/grid_reconcile_internal.js.map +1 -1
  69. package/dist/modules/order/logger.d.ts +12 -2
  70. package/dist/modules/order/logger.d.ts.map +1 -1
  71. package/dist/modules/order/logger.js +29 -7
  72. package/dist/modules/order/logger.js.map +1 -1
  73. package/dist/modules/order/manager.d.ts +49 -0
  74. package/dist/modules/order/manager.d.ts.map +1 -1
  75. package/dist/modules/order/manager.js +72 -24
  76. package/dist/modules/order/manager.js.map +1 -1
  77. package/dist/modules/order/utils/order.d.ts.map +1 -1
  78. package/dist/modules/order/utils/order.js +97 -12
  79. package/dist/modules/order/utils/order.js.map +1 -1
  80. package/dist/modules/order/utils/system.d.ts +97 -0
  81. package/dist/modules/order/utils/system.d.ts.map +1 -1
  82. package/dist/modules/order/utils/system.js +274 -2
  83. package/dist/modules/order/utils/system.js.map +1 -1
  84. package/dist/modules/paths.d.ts +7 -1
  85. package/dist/modules/paths.d.ts.map +1 -1
  86. package/dist/modules/paths.js +10 -3
  87. package/dist/modules/paths.js.map +1 -1
  88. package/dist/modules/utils/text_width.d.ts +19 -0
  89. package/dist/modules/utils/text_width.d.ts.map +1 -0
  90. package/dist/modules/utils/text_width.js +97 -0
  91. package/dist/modules/utils/text_width.js.map +1 -0
  92. package/dist/pm2.d.ts.map +1 -1
  93. package/dist/pm2.js +95 -18
  94. package/dist/pm2.js.map +1 -1
  95. package/dist/scripts/update.js +62 -13
  96. package/dist/scripts/update.js.map +1 -1
  97. package/dist/unlock.d.ts +14 -2
  98. package/dist/unlock.d.ts.map +1 -1
  99. package/dist/unlock.js +73 -4
  100. package/dist/unlock.js.map +1 -1
  101. package/docs/COW_INVARIANTS.md +8 -0
  102. package/docs/CREDENTIAL_SECURITY.md +26 -0
  103. package/docs/DEXBOT_COMPARISON.md +3 -3
  104. package/docs/EVOLUTION.md +6 -5
  105. package/docs/FUND_MOVEMENT_AND_ACCOUNTING.md +1 -1
  106. package/docs/GRID_PRICE_INVARIANT.md +56 -1
  107. package/docs/LOGGING.md +17 -2
  108. package/docs/ORDER_ENGINE_POST_1.0_RETROSPECTIVE.md +6 -7
  109. package/docs/README.md +1 -1
  110. package/package.json +2 -2
@@ -155,7 +155,7 @@ plans, `LANDED`/`REVERTED`/`SUPERSEDED` statuses, commit hashes, and verificatio
155
155
  - **P3** — landed `f94d6ec4` (`validateBoundaryAgainstChainEvidence` + reconcile phase-1 gate + `placementsAllowed` adoption-only mode); amended `3713c496` (anchor demoted to non-authoritative hint, can never veto); extended `a54863ca` (NO_FEASIBLE escalates a straddle-cancel ladder instead of freezing). **REVERTED `e7231534`** — `validateBoundaryAgainstChainEvidence` (`grid_reconcile.ts:359`) and `placementsAllowed` (`grid_reconcile_internal.ts:1601`) removed; **current** boundary derives from `calculateIdealBoundary` (`order/utils/order.ts:1216` via `grid.ts:160`) + `LAST-FILL-GUARD` (`manager.ts:1679`/`dexbot_cow_runtime.ts:1624`), not a P3 chain-evidence gate.
156
156
  - **P4** — landed `f94d6ec4` (`dexbot_state_recovery.ts:581 rejectCorruptedGridSnapshot` clears in-memory + persisted boundary on reject). Live.
157
157
  - **P5** — landed `f94d6ec4` (skip/defer logging + `STRUCTURAL_RESYNC_MAX_DEFER_MS` force, `dexbot_maintenance_runtime.ts:2242-2266`). Live.
158
- - **P6** — landed `f94d6ec4` as `tests/test_gap_band_regression.ts` + `tests/test_boundary_chain_evidence.ts` (updated by `3713c496`/`e2898e51`/`a54863ca` to the amended behavior).
158
+ - **P6** — landed `f94d6ec4` (2026-08-29) as boundary chain-evidence regression coverage, since superseded by the boundary-geometry suite (`tests/test_boundary_anchor_recovery.ts`, `tests/test_boundary_restore_validation.ts`) and the slot-invariant guard tests.
159
159
 
160
160
  #### 1.1 Incident summary
161
161
 
@@ -200,7 +200,7 @@ Sequence `Restored boundary index: 131` *then* `[SNAPSHOT-REJECT] Deleting corru
200
200
 
201
201
  #### 1.7 P6 — Regression tests
202
202
 
203
- *Status: LANDED `f94d6ec4` as `test_gap_band_regression.ts` + `test_boundary_chain_evidence.ts`; **DELETED `e7231534`** — both files removed with P3 revert; no P6 tests remain at HEAD.*
203
+ *Status: LANDED, then superseded — the boundary chain-evidence and geometry assertions are now held by `tests/test_boundary_anchor_recovery.ts` (ANCHOR-001..004) and `tests/test_boundary_restore_validation.ts`.*
204
204
  - A (P1): stale boundary → startup updates into slot X → boundary snaps past X → assert cancel emitted same batch, no live in-band. (P1 later reverted `e2898e51`.)
205
205
  - B (P2): seed live orphan strictly inside gap with no duplicate price → sync/reconcile → assert `cancelOnly` within one cycle. (P2 reverted `3713c496`.)
206
206
  - C (P3/P4): corrupted snapshot stale vs fill evidence → rebuild → assert placements use re-derived boundary, rejected boundary not reused. **Both tests deleted `e7231534`** with P3 revert; P4 behavior now covered by `test_dexbot_state_recovery` + `test_periodic_sync_fill_rebalance`.
@@ -365,7 +365,7 @@ Still open: drift logging/alert >active window, re-stamp BUY above anchor metric
365
365
 
366
366
  ### 4. Price-First Alignment Plan
367
367
 
368
- > **Source:** `PRICE_FIRST_ALIGNMENT_PLAN.md` · **Status:** Phase 1 shipped and live as shadow telemetry; Phase 2 projection was enabled (`1bbf1a23`) then **removed** (`3713c496`) after a live-bot incident — the anchor veto overrode chain evidence and drove destructive gap-band cancels. The anchor is now observability-only; the boundary is chain-evidence-derived. Phase 3 is moot (no second write path to retire); Phase 4 golden tests landed (`tests/test_anchor_golden_geometry.ts`).
368
+ > **Source:** `PRICE_FIRST_ALIGNMENT_PLAN.md` · **Status:** Phase 1 shipped and live as shadow telemetry; Phase 2 projection was enabled (`1bbf1a23`) then **removed** (`3713c496`) after a live-bot incident — the anchor veto overrode chain evidence and drove destructive gap-band cancels. The anchor is now observability-only; the boundary is chain-evidence-derived. Phase 3 is moot (no second write path to retire); boundary geometry is pinned by `tests/test_boundary_anchor_recovery.ts` (ANCHOR-001..004) and `tests/test_grid_price_slot_invariant.ts`.
369
369
  > **Scope:** grid boundary state `modules/order/` · **Related:** three-layer crawl/anchor/guard fix.
370
370
 
371
371
  #### 4.1 Goal
@@ -389,7 +389,7 @@ Grid's "where is market" maintained two ways that disagree: boundary (discrete,
389
389
 
390
390
  #### 4.4 Invariants I1–I6
391
391
 
392
- I1 No order on wrong side of just-filled price (`sell ≤ maxFill, buy > minFill`) — `test_boundary_price_anchor.ts`; I2 Single eligible fill ±1 crawl — `test_multi_partial_consolidation.ts`; I3 Just-filled BUY refills as BUY at fill price — `test_multifill_opposite_partial.ts`; I4 Boundary never exceeds gap-aware ceiling / collapses on degenerate geometry — `test_boundary_restore_validation.ts`; I5 Price-less fills degrade conservatively — `test_boundary_price_anchor.ts #4`; I6 COW-commit-only writes (`_setBoundary`) — `test_cow_boundary_slot_replacement.ts`.
392
+ I1 No order on wrong side of just-filled price (`sell ≤ maxFill, buy > minFill`) — `test_last_fill_guard.ts` (LFG-1..7); I2 Single eligible fill ±1 crawl — `test_multi_partial_consolidation.ts`; I3 Just-filled BUY refills as BUY at fill price — `test_multifill_opposite_partial.ts`; I4 Boundary never exceeds gap-aware ceiling / collapses on degenerate geometry — `test_boundary_restore_validation.ts`; I5 Price-less fills degrade conservatively — `test_boundary_anchor_recovery.ts` ANCHOR-003; I6 COW-commit-only writes (`_setBoundary`) — `test_cow_boundary_slot_replacement.ts`.
393
393
 
394
394
  #### 4.5 Phase 1 — MarketAnchor + divergence telemetry (no behavior change)
395
395
 
@@ -407,10 +407,9 @@ Pure `projectAnchorToGrid(anchor, allSlots, gapSlots)` via `computePriceAnchored
407
407
  *Status: MOOT — Phase 2 was removed (`3713c496`), so there is no second write path to retire; the legacy machinery below is the live path. Original gate: 14-day zero rotations + flat divergence.*
408
408
  3a: `deriveTargetBoundary` collapses to initial-recovery + projection; delete `netShift`/cross-chunk budget/window-cap; delete `_boundaryShiftBudget/_boundaryShiftBudgetBase/_boundaryAnchor` (`dexbot_class.ts`) + re-plan restore (`dexbot_cow_runtime.ts`); fund sync now D1 floor only; spread-correction promotes via anchor; remaining readers projection-based; `manager._setBoundary` stays (I6). 3b: `account_orders.loadBoundaryIdx` (`validatePersistedBoundary` `dexbot_state_recovery.ts`) + `storeGrid` (`utils/system.ts`) stop persisting boundary; startup = load grid → book-seed → project. Gate: harness + fund-floor/recovery cases; kill-switch: corrupt/delete snapshot must converge from chain alone.
409
409
 
410
- #### 4.8 Phase 4 — Geometry golden tests (pin, don't refactor)
410
+ #### 4.8 Phase 4 — Boundary geometry coverage (pin, don't refactor)
411
411
 
412
- *Status: LANDED — `tests/test_anchor_golden_geometry.ts`.*
413
- Golden files canonical grid × gap `{0,1,2,3}` × price at/between slots × direction asserting `calculateIdealBoundary/getSellStartIdx/projectAnchorToGrid` agree. Gate: green.
412
+ *Status: LANDED with the projection, then superseded — boundary geometry is pinned by `tests/test_boundary_anchor_recovery.ts` (ANCHOR-001..004) and `tests/test_grid_price_slot_invariant.ts`.*
414
413
 
415
414
  #### 4.9 Sequencing & risk
416
415
 
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.6 (released).
5
+ **Version context:** v1.6.7 (released).
6
6
 
7
7
  ---
8
8
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dexbot",
3
- "version": "1.6.6",
3
+ "version": "1.6.7",
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": {
@@ -105,7 +105,7 @@
105
105
  "test": "npm run build && npm run build:tests && npm run build --prefix claw && node dist/scripts/run-tests.js",
106
106
  "test:live": "RUN_LIVE_BITSHARES_TESTS=1 npm run build && npm run build:tests && npm run build --prefix claw && node dist/scripts/run-tests.js",
107
107
  "clean": "node scripts/clean-dist.js",
108
- "build": "tsc && chmod +x dist/dexbot.js dist/bot.js dist/unlock.js dist/pm2.js dist/credential-daemon.js",
108
+ "build": "echo \"tsc is compiling ...\" && tsc && chmod +x dist/dexbot.js dist/bot.js dist/unlock.js dist/pm2.js dist/credential-daemon.js",
109
109
  "build:clean": "npm run clean && npm run build",
110
110
  "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/ && mkdir -p dist/analysis/legacy/tests && cp analysis/legacy/tests/package.json dist/analysis/legacy/tests/package.json",
111
111
  "typecheck": "tsc --noEmit",