dexbot 1.7.1 → 1.7.2

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 (51) hide show
  1. package/CHANGELOG.md +28 -0
  2. package/claw/package.json +1 -1
  3. package/claw/runtimes/openclaw-plugin/openclaw.plugin.json +1 -1
  4. package/claw/runtimes/openclaw-plugin/package.json +1 -1
  5. package/dist/modules/account_bots.d.ts +1 -0
  6. package/dist/modules/account_bots.js +7 -5
  7. package/dist/modules/constants.d.ts +2 -0
  8. package/dist/modules/constants.js +16 -2
  9. package/dist/modules/dexbot_class.d.ts +22 -0
  10. package/dist/modules/dexbot_class.js +30 -0
  11. package/dist/modules/dexbot_cow_runtime.d.ts +31 -1
  12. package/dist/modules/dexbot_cow_runtime.js +68 -56
  13. package/dist/modules/dexbot_maintenance_runtime.d.ts +1 -1
  14. package/dist/modules/dexbot_maintenance_runtime.js +33 -6
  15. package/dist/modules/node_flap_score.d.ts +6 -6
  16. package/dist/modules/node_flap_score.js +6 -6
  17. package/dist/modules/order/accounting.d.ts +9 -4
  18. package/dist/modules/order/accounting.js +89 -26
  19. package/dist/modules/order/async_lock.d.ts +7 -1
  20. package/dist/modules/order/async_lock.js +7 -1
  21. package/dist/modules/order/export.js +25 -18
  22. package/dist/modules/order/fill_ledger.d.ts +99 -0
  23. package/dist/modules/order/fill_ledger.js +103 -0
  24. package/dist/modules/order/grid.d.ts +75 -18
  25. package/dist/modules/order/grid.js +207 -61
  26. package/dist/modules/order/grid_reconcile_internal.js +16 -4
  27. package/dist/modules/order/index.d.ts +14 -5
  28. package/dist/modules/order/index.js +5 -5
  29. package/dist/modules/order/lifecycle.js +3 -3
  30. package/dist/modules/order/manager.d.ts +15 -24
  31. package/dist/modules/order/manager.js +40 -27
  32. package/dist/modules/order/sync_engine.d.ts +66 -118
  33. package/dist/modules/order/sync_engine.js +118 -162
  34. package/dist/modules/order/utils/math.d.ts +7 -3
  35. package/dist/modules/order/utils/math.js +7 -3
  36. package/dist/modules/order/utils/order.d.ts +40 -41
  37. package/dist/modules/order/utils/order.js +110 -84
  38. package/dist/modules/order/utils/system.d.ts +81 -6
  39. package/dist/modules/order/utils/system.js +167 -29
  40. package/dist/modules/timing_policy.js +2 -2
  41. package/dist/modules/types.d.ts +22 -27
  42. package/docs/COW_INVARIANTS.md +5 -1
  43. package/docs/DEXBOT_COMPARISON.md +4 -4
  44. package/docs/EVOLUTION.md +6 -5
  45. package/docs/FUND_MOVEMENT_AND_ACCOUNTING.md +1 -1
  46. package/docs/GRID_RECONCILE.md +3 -3
  47. package/docs/ORDER_ENGINE_POST_1.0_RETROSPECTIVE.md +38 -30
  48. package/docs/README.md +1 -1
  49. package/docs/architecture.md +26 -8
  50. package/modules/README.md +3 -0
  51. package/package.json +3 -3
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.7.1 (released).
5
+ **Version context:** v1.7.2 (released).
6
6
 
7
7
  ---
8
8
 
@@ -513,14 +513,18 @@ The correction path is fund-only and never manufactures budget by shrinking a re
513
513
  member); the walk steps over it and promotes only the next empty slot, so a
514
514
  placed edge never becomes a duplicate CREATE target.
515
515
  5. If free funds cannot cover every target, place the affordable prefix, then
516
- **rotate a resting same-side order** into each unfunded promoted gap slot
517
- (same booked size, never a new commitment). A fully allocated rail has ~0
518
- free forever, so create-only repair can never close the spread; the rotation
519
- is the repair path and is bounded by the same promotion, crossing, last-fill,
520
- dedupe/duplicate-price and edge-order guards as a create. It never shrinks or
521
- grows the moved order. Exactly-zero free on both sides is covered by a
522
- rotation-only fallback around side selection (an unavailable market price is
523
- still a hard skip: cross-asset comparison is unsafe).
516
+ **rotate a resting same-side order** into each unfunded tightening slot —
517
+ whether it is a promoted gap slot or an orphaned rail slot left by a
518
+ fill-anchored boundary move (same booked size, never a new commitment). A
519
+ fully allocated rail has ~0 free forever, so create-only repair can never
520
+ close the spread. A virtual tail that reserves the whole free balance is not
521
+ a hard stop: moving a far resting order into the window edge frees no new
522
+ inventory but tightens the spread. The rotation is bounded by the same
523
+ promotion, crossing, last-fill, dedupe/duplicate-price and edge-order guards
524
+ as a create. It never shrinks or grows the moved order. Exactly-zero free on
525
+ both sides is covered by a rotation-only fallback around side selection (an
526
+ unavailable market price is still a hard skip: cross-asset comparison is
527
+ unsafe).
524
528
  6. If neither side places an effective order, `checkSpreadCondition` reports a
525
529
  `stall` cause (`no-free-funds` / `unfunded` / `no-candidates` / `cold-book` /
526
530
  `unmatched-orders` / `readiness-gate` / `last-fill-blocked` /
@@ -664,6 +668,20 @@ anchoring on it leaves the furthest fill's counter order inside the implied
664
668
  band. `calculateTargetGrid` passes the batch into
665
669
  `reanchorBoundaryFromLastFill`.
666
670
 
671
+ **Rebuild and load apply the same anchor.** A fresh generation derives its band
672
+ from the current market center, but the last fill is still geometry fact. If
673
+ that center puts the pivot inside the band, the startup picker correctly skips
674
+ the levels at/through the fill (LAST-FILL-GUARD), fills the same-side window
675
+ lower, and the first ask stays at the old `sellStart` — a realized spread two
676
+ steps wider than target with no fill reason for the extra width (live
677
+ 2026‑11‑04: boundary 159 after a BUY at new-ladder slot 158, realized 2.123% vs
678
+ the 1.5% target). `initializeGrid` and `loadGrid` therefore call
679
+ `anchorRebuildBoundaryToLastFill` after the pivot is re-armed/restored and
680
+ before reconcile/re-type; `applyRebuildFillAnchor` moves the boundary and
681
+ re-types the rails atomically (`BUY fill at 158 => boundary 157`, counter SELL
682
+ at 162). A cold/off-ladder/unsafe fill keeps the derived boundary, so this is a
683
+ no-op on a healthy restart.
684
+
667
685
  ### Rail-Derived Commit Boundary (counter orders are the fact)
668
686
 
669
687
  A plan built at a re-anchored boundary places **counter orders** on the promoted
package/modules/README.md CHANGED
@@ -74,6 +74,8 @@ modules/
74
74
  ├── node_health_cache.ts shared node-health cache file I/O + ordering
75
75
  ├── socket_json_client.ts newline-delimited JSON Unix-socket client
76
76
  ├── market_adapter_whitelist.ts adapter whitelist I/O
77
+ ├── outcome.ts three-valued Outcome construction (applied/rejected/unknown)
78
+ ├── timing_policy.ts timing-window audit: EXTERNAL/BOUND/POLICY/SELF_HEALING classification
77
79
  ├── types.ts shared type definitions
78
80
  │
79
81
  ├── crypto/ cross-environment crypto providers
@@ -100,6 +102,7 @@ modules/
100
102
  │ ├── accounting.ts fund tracking, fee accounting
101
103
  │ ├── sync_engine.ts blockchain sync, fill detection, reconciliation
102
104
  │ ├── lifecycle.ts one record per slot: chain existence, phase, evidence, clocks (docs/ORDER_LIFECYCLE.md)
105
+ │ ├── fill_ledger.ts fill identity, traded-side resolution, booked membership (docs/FILL_PIPELINE.md)
103
106
  │ ├── genesis_policy.ts missing-ladder refusal + rebuild policy (docs/GRID_PRICE_INVARIANT.md)
104
107
  │ ├── grid_reconcile.ts startup grid reconciliation (docs/GRID_RECONCILE.md)
105
108
  │ ├── grid_reconcile_internal.ts internal grid reconciliation helpers
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dexbot",
3
- "version": "1.7.1",
3
+ "version": "1.7.2",
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": {
@@ -112,12 +112,12 @@
112
112
  "version:check": "npm run build && node dist/scripts/sync-version.js --check",
113
113
  "verify:browser-bundle": "npm run build && node dist/scripts/verify-browser-bundle.js",
114
114
  "test": "npm run build && npm run build:tests && npm run build --prefix claw && npm run typecheck:analysis && node dist/scripts/run-tests.js",
115
- "test:live": "RUN_LIVE_BITSHARES_TESTS=1 npm run build && npm run build:tests && npm run build --prefix claw && npm run typecheck:analysis && node dist/scripts/run-tests.js",
115
+ "test:live": "npm run build && npm run build:tests && npm run build --prefix claw && npm run typecheck:analysis && RUN_LIVE_BITSHARES_TESTS=1 node dist/scripts/run-tests.js",
116
116
  "test:playwright": "npm run build && NODE_PATH=\"$(npm root -g)\" playwright test --config tests/playwright/playwright.config.mjs",
117
117
  "clean": "node scripts/clean-dist.js",
118
118
  "build": "echo \"tsc is compiling ...\" && tsc && chmod +x dist/dexbot.js dist/bot.js dist/unlock.js dist/pm2.js dist/credential-daemon.js",
119
119
  "build:clean": "npm run clean && npm run build",
120
- "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/",
120
+ "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 tests/helpers/foreign_cred_stub.js dist/tests/helpers/",
121
121
  "typecheck": "tsc --noEmit",
122
122
  "typecheck:analysis": "tsc -p analysis/tsconfig.json",
123
123
  "check:any": "npm run build && node dist/scripts/check_any.js",