dexbot 1.6.4 → 1.6.6

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 (240) hide show
  1. package/CHANGELOG.md +75 -3
  2. package/README.md +109 -40
  3. package/analysis/README.md +19 -17
  4. package/analysis/account_resolver.ts +1 -11
  5. package/analysis/analyze_dynamic_weight.ts +9 -3
  6. package/analysis/bot_usage/kibana_bot_queries.ts +1 -1
  7. package/analysis/chain_pool.ts +1 -1
  8. package/analysis/fills_source.ts +0 -6
  9. package/analysis/grid_correction_check.ts +20 -26
  10. package/analysis/resolve_source.ts +1 -1
  11. package/analysis/trade_profitability.ts +2 -5
  12. package/analysis/tradingview/analyze_tradingview.ts +5 -0
  13. package/analysis/tradingview/tradingview_uplot_chart_generator.ts +2 -2
  14. package/analysis/trend_detection/DYNAMIC_WEIGHT_RESEARCH.md +35 -2
  15. package/analysis/trend_detection/README.md +1 -3
  16. package/analysis/trend_detection/dynamic_weight_chart_generator.ts +82 -10
  17. package/analysis/trend_detection/package.json +1 -1
  18. package/claw/modules/dexbot_profiles.ts +4 -3
  19. package/claw/package.json +1 -1
  20. package/claw/runtimes/openclaw-plugin/openclaw.plugin.json +1 -1
  21. package/claw/runtimes/openclaw-plugin/package.json +1 -1
  22. package/claw/tests/test_claw_mcp_transport.ts +2 -2
  23. package/claw/tests/test_dexbot_profiles.ts +18 -1
  24. package/dist/analysis/account_resolver.d.ts +1 -4
  25. package/dist/analysis/account_resolver.d.ts.map +1 -1
  26. package/dist/analysis/account_resolver.js +1 -1
  27. package/dist/analysis/account_resolver.js.map +1 -1
  28. package/dist/analysis/analyze_dynamic_weight.js +9 -3
  29. package/dist/analysis/analyze_dynamic_weight.js.map +1 -1
  30. package/dist/analysis/bot_usage/kibana_bot_queries.d.ts +1 -2
  31. package/dist/analysis/bot_usage/kibana_bot_queries.d.ts.map +1 -1
  32. package/dist/analysis/bot_usage/kibana_bot_queries.js +1 -1
  33. package/dist/analysis/bot_usage/kibana_bot_queries.js.map +1 -1
  34. package/dist/analysis/chain_pool.d.ts +1 -3
  35. package/dist/analysis/chain_pool.d.ts.map +1 -1
  36. package/dist/analysis/chain_pool.js +1 -1
  37. package/dist/analysis/chain_pool.js.map +1 -1
  38. package/dist/analysis/fills_source.d.ts +1 -51
  39. package/dist/analysis/fills_source.d.ts.map +1 -1
  40. package/dist/analysis/fills_source.js +1 -1
  41. package/dist/analysis/fills_source.js.map +1 -1
  42. package/dist/analysis/grid_correction_check.d.ts +2 -3
  43. package/dist/analysis/grid_correction_check.d.ts.map +1 -1
  44. package/dist/analysis/grid_correction_check.js +18 -26
  45. package/dist/analysis/grid_correction_check.js.map +1 -1
  46. package/dist/analysis/resolve_source.d.ts +1 -1
  47. package/dist/analysis/resolve_source.d.ts.map +1 -1
  48. package/dist/analysis/trade_profitability.d.ts.map +1 -1
  49. package/dist/analysis/trade_profitability.js +2 -7
  50. package/dist/analysis/trade_profitability.js.map +1 -1
  51. package/dist/analysis/tradingview/analyze_tradingview.d.ts.map +1 -1
  52. package/dist/analysis/tradingview/analyze_tradingview.js +5 -0
  53. package/dist/analysis/tradingview/analyze_tradingview.js.map +1 -1
  54. package/dist/analysis/tradingview/tradingview_uplot_chart_generator.js +2 -2
  55. package/dist/analysis/trend_detection/dynamic_weight_chart_generator.d.ts.map +1 -1
  56. package/dist/analysis/trend_detection/dynamic_weight_chart_generator.js +82 -10
  57. package/dist/analysis/trend_detection/dynamic_weight_chart_generator.js.map +1 -1
  58. package/dist/dexbot.d.ts.map +1 -1
  59. package/dist/dexbot.js +85 -140
  60. package/dist/dexbot.js.map +1 -1
  61. package/dist/market_adapter/core/asymmetric_bounds.d.ts +2 -2
  62. package/dist/market_adapter/core/asymmetric_bounds.d.ts.map +1 -1
  63. package/dist/market_adapter/core/asymmetric_bounds.js +15 -12
  64. package/dist/market_adapter/core/asymmetric_bounds.js.map +1 -1
  65. package/dist/market_adapter/core/kibana_candles.d.ts +1 -15
  66. package/dist/market_adapter/core/kibana_candles.d.ts.map +1 -1
  67. package/dist/market_adapter/core/kibana_candles.js +1 -1
  68. package/dist/market_adapter/core/kibana_candles.js.map +1 -1
  69. package/dist/market_adapter/inputs/fetch_lp_data.d.ts +1 -35
  70. package/dist/market_adapter/inputs/fetch_lp_data.d.ts.map +1 -1
  71. package/dist/market_adapter/inputs/fetch_lp_data.js +10 -54
  72. package/dist/market_adapter/inputs/fetch_lp_data.js.map +1 -1
  73. package/dist/market_adapter/inputs/kibana_feed_source.d.ts +1 -8
  74. package/dist/market_adapter/inputs/kibana_feed_source.d.ts.map +1 -1
  75. package/dist/market_adapter/inputs/kibana_feed_source.js +1 -1
  76. package/dist/market_adapter/inputs/kibana_feed_source.js.map +1 -1
  77. package/dist/market_adapter/inputs/window_cache.d.ts +2 -63
  78. package/dist/market_adapter/inputs/window_cache.d.ts.map +1 -1
  79. package/dist/market_adapter/inputs/window_cache.js +22 -102
  80. package/dist/market_adapter/inputs/window_cache.js.map +1 -1
  81. package/dist/market_adapter/interval_utils.d.ts +1 -1
  82. package/dist/market_adapter/interval_utils.js +1 -1
  83. package/dist/modules/account_bots.d.ts +70 -6
  84. package/dist/modules/account_bots.d.ts.map +1 -1
  85. package/dist/modules/account_bots.js +353 -149
  86. package/dist/modules/account_bots.js.map +1 -1
  87. package/dist/modules/bitshares-native/crypto/ecc.browser.d.ts.map +1 -1
  88. package/dist/modules/bitshares-native/crypto/ecc.browser.js +0 -31
  89. package/dist/modules/bitshares-native/crypto/ecc.browser.js.map +1 -1
  90. package/dist/modules/bot_defaults.d.ts +98 -0
  91. package/dist/modules/bot_defaults.d.ts.map +1 -0
  92. package/dist/modules/bot_defaults.js +169 -0
  93. package/dist/modules/bot_defaults.js.map +1 -0
  94. package/dist/modules/bot_settings.d.ts.map +1 -1
  95. package/dist/modules/bot_settings.js +4 -1
  96. package/dist/modules/bot_settings.js.map +1 -1
  97. package/dist/modules/config.d.ts +1 -0
  98. package/dist/modules/config.d.ts.map +1 -1
  99. package/dist/modules/config.js +1 -0
  100. package/dist/modules/config.js.map +1 -1
  101. package/dist/modules/constants.d.ts +11 -2
  102. package/dist/modules/constants.d.ts.map +1 -1
  103. package/dist/modules/constants.js +40 -27
  104. package/dist/modules/constants.js.map +1 -1
  105. package/dist/modules/credit_runtime.d.ts +0 -2
  106. package/dist/modules/credit_runtime.d.ts.map +1 -1
  107. package/dist/modules/credit_runtime.js +1 -10
  108. package/dist/modules/credit_runtime.js.map +1 -1
  109. package/dist/modules/dexbot_class.d.ts +13 -10
  110. package/dist/modules/dexbot_class.d.ts.map +1 -1
  111. package/dist/modules/dexbot_class.js +0 -9
  112. package/dist/modules/dexbot_class.js.map +1 -1
  113. package/dist/modules/dexbot_cow_runtime.d.ts +13 -0
  114. package/dist/modules/dexbot_cow_runtime.d.ts.map +1 -1
  115. package/dist/modules/dexbot_cow_runtime.js +13 -1
  116. package/dist/modules/dexbot_cow_runtime.js.map +1 -1
  117. package/dist/modules/dexbot_maintenance_runtime.d.ts +1 -1
  118. package/dist/modules/dexbot_maintenance_runtime.d.ts.map +1 -1
  119. package/dist/modules/dexbot_maintenance_runtime.js +9 -4
  120. package/dist/modules/dexbot_maintenance_runtime.js.map +1 -1
  121. package/dist/modules/launcher/adapter_requirement.js +1 -1
  122. package/dist/modules/launcher/launch_modes.d.ts +17 -1
  123. package/dist/modules/launcher/launch_modes.d.ts.map +1 -1
  124. package/dist/modules/launcher/launch_modes.js +18 -1
  125. package/dist/modules/launcher/launch_modes.js.map +1 -1
  126. package/dist/modules/launcher/monolithic_runtime.d.ts.map +1 -1
  127. package/dist/modules/launcher/monolithic_runtime.js +8 -1
  128. package/dist/modules/launcher/monolithic_runtime.js.map +1 -1
  129. package/dist/modules/market_adapter_whitelist.d.ts +40 -1
  130. package/dist/modules/market_adapter_whitelist.d.ts.map +1 -1
  131. package/dist/modules/market_adapter_whitelist.js +161 -11
  132. package/dist/modules/market_adapter_whitelist.js.map +1 -1
  133. package/dist/modules/order/accounting.d.ts +4 -18
  134. package/dist/modules/order/accounting.d.ts.map +1 -1
  135. package/dist/modules/order/accounting.js +4 -34
  136. package/dist/modules/order/accounting.js.map +1 -1
  137. package/dist/modules/order/export.d.ts +9 -12
  138. package/dist/modules/order/export.d.ts.map +1 -1
  139. package/dist/modules/order/export.js +9 -12
  140. package/dist/modules/order/export.js.map +1 -1
  141. package/dist/modules/order/grid.d.ts +44 -40
  142. package/dist/modules/order/grid.d.ts.map +1 -1
  143. package/dist/modules/order/grid.js +66 -48
  144. package/dist/modules/order/grid.js.map +1 -1
  145. package/dist/modules/order/grid_reconcile.d.ts.map +1 -1
  146. package/dist/modules/order/grid_reconcile.js +111 -20
  147. package/dist/modules/order/grid_reconcile.js.map +1 -1
  148. package/dist/modules/order/grid_reconcile_internal.d.ts +5 -3
  149. package/dist/modules/order/grid_reconcile_internal.d.ts.map +1 -1
  150. package/dist/modules/order/grid_reconcile_internal.js +18 -3
  151. package/dist/modules/order/grid_reconcile_internal.js.map +1 -1
  152. package/dist/modules/order/manager.d.ts +0 -8
  153. package/dist/modules/order/manager.d.ts.map +1 -1
  154. package/dist/modules/order/manager.js +3 -12
  155. package/dist/modules/order/manager.js.map +1 -1
  156. package/dist/modules/order/utils/order.d.ts +22 -7
  157. package/dist/modules/order/utils/order.d.ts.map +1 -1
  158. package/dist/modules/order/utils/order.js +103 -21
  159. package/dist/modules/order/utils/order.js.map +1 -1
  160. package/dist/modules/order/utils/system.d.ts +5 -1
  161. package/dist/modules/order/utils/system.d.ts.map +1 -1
  162. package/dist/modules/order/utils/system.js +5 -2
  163. package/dist/modules/order/utils/system.js.map +1 -1
  164. package/dist/modules/order/utils/withPoolRef.d.ts +12 -0
  165. package/dist/modules/order/utils/withPoolRef.d.ts.map +1 -1
  166. package/dist/modules/order/utils/withPoolRef.js +17 -0
  167. package/dist/modules/order/utils/withPoolRef.js.map +1 -1
  168. package/dist/modules/order/working_grid.d.ts +8 -13
  169. package/dist/modules/order/working_grid.d.ts.map +1 -1
  170. package/dist/modules/order/working_grid.js +8 -29
  171. package/dist/modules/order/working_grid.js.map +1 -1
  172. package/dist/modules/settings_merge.d.ts +10 -1
  173. package/dist/modules/settings_merge.d.ts.map +1 -1
  174. package/dist/modules/settings_merge.js +27 -17
  175. package/dist/modules/settings_merge.js.map +1 -1
  176. package/dist/modules/validate_profiles.d.ts.map +1 -1
  177. package/dist/modules/validate_profiles.js +4 -3
  178. package/dist/modules/validate_profiles.js.map +1 -1
  179. package/dist/scripts/chart_command.d.ts +48 -0
  180. package/dist/scripts/chart_command.d.ts.map +1 -0
  181. package/dist/scripts/chart_command.js +504 -0
  182. package/dist/scripts/chart_command.js.map +1 -0
  183. package/dist/scripts/dw.d.ts +3 -0
  184. package/dist/scripts/dw.d.ts.map +1 -0
  185. package/dist/scripts/dw.js +30 -0
  186. package/dist/scripts/dw.js.map +1 -0
  187. package/dist/scripts/sync-version.js +0 -22
  188. package/dist/scripts/sync-version.js.map +1 -1
  189. package/dist/scripts/tv.d.ts +1 -31
  190. package/dist/scripts/tv.d.ts.map +1 -1
  191. package/dist/scripts/tv.js +10 -463
  192. package/dist/scripts/tv.js.map +1 -1
  193. package/dist/scripts/update.js +99 -62
  194. package/dist/scripts/update.js.map +1 -1
  195. package/dist/scripts/update_dist_freshness.d.ts +58 -0
  196. package/dist/scripts/update_dist_freshness.d.ts.map +1 -0
  197. package/dist/scripts/update_dist_freshness.js +144 -0
  198. package/dist/scripts/update_dist_freshness.js.map +1 -0
  199. package/dist/unlock.js +1 -1
  200. package/dist/unlock.js.map +1 -1
  201. package/docs/BITSHARES_ONBOARDING.md +16 -10
  202. package/docs/COW_INVARIANTS.md +1 -0
  203. package/docs/DEXBOT_COMPARISON.md +11 -11
  204. package/docs/EVOLUTION.md +9 -7
  205. package/docs/FUND_MOVEMENT_AND_ACCOUNTING.md +4 -4
  206. package/docs/GRID_PRICE_INVARIANT.md +518 -0
  207. package/docs/GRID_RECALCULATION.md +20 -24
  208. package/docs/GRID_RECONCILE.md +62 -41
  209. package/docs/LOGGING.md +1 -0
  210. package/docs/ORDER_ENGINE_POST_1.0_RETROSPECTIVE.md +556 -0
  211. package/docs/README.md +18 -18
  212. package/docs/WORKFLOW.md +13 -8
  213. package/docs/architecture.md +42 -40
  214. package/docs/developer_guide.md +5 -8
  215. package/market_adapter/README.md +45 -65
  216. package/modules/README.md +3 -2
  217. package/package.json +7 -4
  218. package/scripts/README.md +18 -34
  219. package/scripts/reset-settings.sh +1 -1
  220. package/analysis/ama_fitting/package.json +0 -12
  221. package/analysis/analyze_derivatives.ts +0 -320
  222. package/analysis/derivative_chart_generator.ts +0 -874
  223. package/analysis/trend_detection/SIGNAL_DOCUMENTATION.md +0 -403
  224. package/analysis/trend_detection/derivative_analyzer.ts +0 -1059
  225. package/dist/analysis/analyze_derivatives.d.ts +0 -68
  226. package/dist/analysis/analyze_derivatives.d.ts.map +0 -1
  227. package/dist/analysis/analyze_derivatives.js +0 -287
  228. package/dist/analysis/analyze_derivatives.js.map +0 -1
  229. package/dist/analysis/derivative_chart_generator.d.ts +0 -12
  230. package/dist/analysis/derivative_chart_generator.d.ts.map +0 -1
  231. package/dist/analysis/derivative_chart_generator.js +0 -891
  232. package/dist/analysis/derivative_chart_generator.js.map +0 -1
  233. package/dist/analysis/trend_detection/derivative_analyzer.d.ts +0 -248
  234. package/dist/analysis/trend_detection/derivative_analyzer.d.ts.map +0 -1
  235. package/dist/analysis/trend_detection/derivative_analyzer.js +0 -910
  236. package/dist/analysis/trend_detection/derivative_analyzer.js.map +0 -1
  237. package/dist/scripts/generate_market_adapter_whitelist.d.ts +0 -15
  238. package/dist/scripts/generate_market_adapter_whitelist.d.ts.map +0 -1
  239. package/dist/scripts/generate_market_adapter_whitelist.js +0 -191
  240. package/dist/scripts/generate_market_adapter_whitelist.js.map +0 -1
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.4 (released).
5
+ **Version context:** v1.6.6 (released).
6
6
 
7
7
  ---
8
8
 
@@ -17,7 +17,7 @@ This directory contains the comprehensive technical documentation for the DEXBot
17
17
 
18
18
  ### 📡 [Market Adapter](../market_adapter/README.md)
19
19
  *Live AMA pricing, dynamic weights, and recalc trigger orchestration.*
20
- - **Quick Start**: Enable AMA, generate the whitelist, and start DEXBot2
20
+ - **Quick Start**: Enable AMA, set the per-bot adapter flags in `dexbot bot`, and start DEXBot2
21
21
  - **Settings**: Global, pair, and bot-specific adapter overrides
22
22
  - **Dynamic Weights**: How adapter signals write live weight snapshots
23
23
  - **Troubleshooting**: Common adapter startup and trigger issues
@@ -32,7 +32,7 @@ This directory contains the comprehensive technical documentation for the DEXBot
32
32
 
33
33
  ### 📈 [Analysis](../analysis/README.md)
34
34
  *Research runners, chart generators, and tuning helpers.*
35
- - **Trend Detection**: SMA, MACD, RSI, Hurst, Kalman, and regime analysis tools
35
+ - **Trend Detection**: Hurst, Kalman, and regime analysis tools
36
36
  - **AMA Fitting**: Parameter fitting, comparison charts, and LP data workflows
37
37
  - **Bot Fitting**: Grid parameter sweep backtests for AMA winners
38
38
  - **TradingView Exports**: Chart export utilities for visual analysis
@@ -44,7 +44,7 @@ This directory contains the comprehensive technical documentation for the DEXBot
44
44
  - **Purpose**: Exposes BitShares capabilities and DEXBot2 infrastructure through JSON/CLI bridges, MCP, and runtime-native skill packaging for OpenClaw and compatible runtimes (see [claw/README.md](../claw/README.md) for the full list).
45
45
  - **API Boundary**: Responsibility split between the AI decision layer and the DEXBot2 execution substrate ([AI_BOT_LIBRARY_API.md](../claw/docs/AI_BOT_LIBRARY_API.md))
46
46
  - **Tuning Reference**: Practical grid-tuning baselines ([DEXBOT2_TUNING_CHEAT_SHEET.md](../claw/docs/DEXBOT2_TUNING_CHEAT_SHEET.md))
47
- - **Position Management**: Health monitoring, margin planner, and dynamic weight policy
47
+ - **Position Management**: Short-position tracking, position health monitoring (3-zone CR model), and shared CR planning via `cr_planner.ts`
48
48
  - **Skills**: Presentation-only, concept-reference, and launcher-orchestration skill packs for bitshares-guide, margin-trading, launcher-ops, and shared references
49
49
 
50
50
  ## Operational & Security
@@ -65,19 +65,19 @@ This directory contains the comprehensive technical documentation for the DEXBot
65
65
  ### 🔁 [Grid Reconciliation](GRID_RECONCILE.md)
66
66
  *How the bot re-aligns its intended grid with on-chain reality at startup.*
67
67
  - **3-Phase Plan-then-Execute**: Phase 1 pure in-memory planning under `_gridLock`, Phase 2 blockchain execution outside the lock, Phase 3 fresh re-read and stale surplus cleanup
68
- - **Safety Guardrails**: Fresh-grid `matchedOnGrid > 0` guard, 5× duplicate tolerance, freshly-assigned deferral, and truncated-read ambiguity handling
68
+ - **Safety Guardrails**: Fresh-grid `matchedOnGrid > 0` guard, exact slot-price duplicate cancel, freshly-assigned deferral, and truncated-read ambiguity handling
69
69
  - **Partial Failure State**: No rollback on partial Phase 2 success; remaining mismatches caught by the next maintenance or startup cycle
70
70
  - **Lock Hierarchy**: Canonical `_syncLock`/`_gridLock` level reference and the 1.4.6 ABBA deadlock correction
71
71
 
72
72
  ### 📝 [Logging System](LOGGING.md)
73
73
  *Configuration reference for log levels, rotation, JSON output, and categories.*
74
74
  - **5 Severity Levels**: `debug`, `info`, `warn`, `error`, `critical`.
75
- - **Rotation**: Size-based (1GB default), auto-prune (5 files).
75
+ - **Rotation**: Size-based (1.1GB total budget default), auto-prune (10 rotated files).
76
76
  - **JSON Output**: Structured lines for log aggregators (opt-in).
77
77
  - **Categories**: 6 independently enablable category groups.
78
78
  - **Change Detection**: Skips redundant logs (40-50% reduction).
79
79
  - **Batch Processing Logs**: Fill batching, recovery retry, and orphan-fill deduplication messages.
80
- - **Fill History Scans**: The `Subscriptions` logger emits `fetchFillHistoryEntries: maxPages (X) reached` at `info` level when the history scan hits its page cap — normal on busy accounts; see LOGGING.md for the `--partial-operations` diagnostic.
80
+ - **Fill History Scans**: The `Subscriptions` logger emits `fetchFillHistoryEntries: maxPages (X) reached` at `debug` level when the history scan hits its page cap — normal on busy accounts; see LOGGING.md for the `--partial-operations` diagnostic.
81
81
 
82
82
  ### 🐳 [Docker](docker.md)
83
83
  *Container build, release images, and secure startup.*
@@ -88,8 +88,8 @@ This directory contains the comprehensive technical documentation for the DEXBot
88
88
  ### 🛠️ [Scripts](../scripts/README.md)
89
89
  *CLI maintenance and diagnostic utilities.*
90
90
  - **Update**: Safe production update via `dexbot update`
91
- - **Reset & Cleanup**: Log wiping, setting resets, PM2 ecosystem regeneration
92
- - **Analysis Helpers**: Diagnostic connection tests and health probes
91
+ - **Reset & Cleanup**: Log/order wipes, settings resets, and market-adapter/claw state cleanup
92
+ - **Diagnostics**: Configuration audit, grid divergence/trading analysis, and candle/pool history checks
93
93
 
94
94
  ## Reference Docs
95
95
 
@@ -97,9 +97,9 @@ This directory contains the comprehensive technical documentation for the DEXBot
97
97
  *The blueprint of the system.*
98
98
  - **Design Philosophy**: Simplicity, constant spread, minimal blockchain interaction, and closed-loop market dynamics.
99
99
  - **System Design**: High-level overview of how the bot components interact.
100
- - **Module Responsibilities**: Detailed breakdown of the **Manager**, **Accountant**, **Strategy**, **Grid**, **FillRuntime**, and **MaintenanceRuntime** modules.
100
+ - **Module Responsibilities**: Detailed breakdown of the **Manager**, **Accountant**, **Strategy**, **SyncEngine**, **Grid**, **FillRuntime**, and **MaintenanceRuntime** modules.
101
101
  - **Copy-on-Write Pattern**: Safe concurrent rebalancing with isolated working grids (see [COPY_ON_WRITE_MASTER_PLAN.md](COPY_ON_WRITE_MASTER_PLAN.md))
102
- - **Fill Processing Pipeline**: Fixed-cap batch fill processing (1-4 fills per broadcast; documented Feb 7 29-fill scenario: ~24s)
102
+ - **Fill Processing Pipeline**: Fixed-cap batch fill processing (`gapSlots+1` fills per broadcast; documented Feb 7 29-fill scenario: ~24s)
103
103
  - **Spread Correction**: Conservative, fund-aware maintenance of constant spread width
104
104
  - **Periodic Market Price Refresh**: Background 4-hour price updates
105
105
  - **Pipeline Safety & Diagnostics**: 5-minute timeout safeguard and health monitoring
@@ -119,14 +119,14 @@ This directory contains the comprehensive technical documentation for the DEXBot
119
119
  ### 🧩 [Copy-on-Write Master Plan](COPY_ON_WRITE_MASTER_PLAN.md)
120
120
  *COW design, phases, and state machine details.*
121
121
  - **Architecture**: Master-grid projection model and rebalance flow
122
- - **Lifecycle**: Implementation phases, commit boundaries, and test coverage
122
+ - **Lifecycle**: State machine, rebalance/fill data flows, fill handling strategy, and operational rules
123
123
  - **Safety**: Invariants and guardrails for concurrent updates
124
124
 
125
125
  ### 🔒 [COW Invariants](COW_INVARIANTS.md)
126
126
  *Stable theory contract for COW pipeline.*
127
127
  - **Non-negotiable invariants**: Master immutability, commit atomicity, projection rules, accounting separation
128
- - **Test mapping**: Links each invariant to regression tests
129
- - **Review checklist**: Quick-use verification for COW/accounting changes
128
+ - **Subsystem Scope**: 13 `INV-*` prefix groups mapping each invariant to its runtime subsystem
129
+ - **Change Policy**: Required steps for an intentional invariant change — same-PR doc update, rationale, and regression tests
130
130
 
131
131
  ### 📐 [Grid-Price Invariant](GRID_PRICE_INVARIANT.md)
132
132
  *Why a slot's emitted price must equal its genesis level — and how that failed.*
@@ -140,7 +140,7 @@ This directory contains the comprehensive technical documentation for the DEXBot
140
140
  *The most critical part of the bot: safe capital management.*
141
141
  - **Single Source of Truth**: How the bot avoids double-spending and out-of-sync balances.
142
142
  - **Optimistic ChainFree**: The mechanism that allows the bot to trade with fill proceeds before they are finalized on-chain.
143
- - **Fill Batch Processing**: Fixed-cap batching for efficient fill processing (`<=4` unified, `>4` chunked)
143
+ - **Fill Batch Processing**: Fixed-cap batching for efficient fill processing (`1..gapSlots+1` unified, deeper queues chunked at `gapSlots+1`)
144
144
  - **Partial Order Consolidation**: Simplified, direct consolidation through grid rebuilding (no merge/split mechanics)
145
145
  - **Dust Detection & Management**: Partials below the dust threshold are cancelled on-chain immediately on detection (no delay, no timer)
146
146
  - **BTS Fee Object Structure**: `netProceeds` field for accounting precision
@@ -158,9 +158,9 @@ This directory contains the comprehensive technical documentation for the DEXBot
158
158
  - **Configurable startPrice & gridPrice**: Fixed numeric, pool, book-derived, or AMA keyword pricing modes
159
159
  - **Pool ID Caching**: Optimization for price derivation
160
160
  - **Order State Helper Functions**: Centralized predicate functions for state checking
161
- - **Signal Concepts**: Dynamic weights, regime detection, derivative signals, and market adapter integration
161
+ - **Signal Concepts**: Dynamic weights, regime detection, and market adapter integration
162
162
  - **Debt Policy**: Native MPA and credit offer configuration and runtime rules
163
- - **Common Tasks**: Practical "how-to" guides for adding features or fixing bugs.
163
+ - **Practical How-Tos**: Adding features step by step, common pitfalls to avoid, and useful debugging commands.
164
164
  - **Glossary**: Definitions of project-specific terminology (e.g., "Virtual Orders", "Rotation", "Pipeline Safety", "WorkingGrid", "COW Commit", "Dynamic Weight", "Regime Detection").
165
165
 
166
166
  ### 🔄 [Workflow](WORKFLOW.md)
@@ -172,7 +172,7 @@ This directory contains the comprehensive technical documentation for the DEXBot
172
172
  *Test organization, categories, and key architectural patterns tested.*
173
173
  - **Test Layout**: Directory structure, helpers, and quick-start commands
174
174
  - **Categories**: Core infrastructure, order management, COW rebalancing, fees/accounting, integration, edge cases, and more
175
- - **Architectural Patterns**: COW rebalancing, RMS divergence, and fund invariants with doc cross-references
175
+ - **Architectural Patterns**: COW rebalancing, RMS divergence, fund invariants, and the grid-price invariant with doc cross-references
176
176
 
177
177
  ### 🧭 [Evolution Report](EVOLUTION.md)
178
178
  *Project timeline and major architecture phases.*
package/docs/WORKFLOW.md CHANGED
@@ -238,28 +238,33 @@ the canonical name is preferred in scripts and docs.
238
238
 
239
239
  | Command (canonical) | Aliases | Purpose |
240
240
  |---------|---------|---------|
241
- | `dexbot test <bot>` | — | Test-run a single bot (one-shot, live trading) |
241
+ | `dexbot test <bot>` | — | Run a single bot in live mode (one-shot; not a dry run) |
242
242
  | `dexbot drystart <bot>` | — | Same as `test` but forces dry-run execution |
243
- | `dexbot reset <bot>` | — | Trigger a grid reset (applies live or on next start) |
243
+ | `dexbot reset <bot>` | — | Trigger a grid reset (applies live or on next start; `reset all` for all) |
244
244
  | `dexbot default` | `defaults` | Reset settings to defaults (deletes generated settings files) |
245
245
  | `dexbot disable <bot>` | — | Mark a bot inactive in config (`disable all` for all) |
246
246
  | `dexbot enable <bot>` | — | Mark a bot active in config (`enable all` for all) |
247
- | `dexbot key` | `key` | Launch the chain key helper (`modules/chain_keys.ts`) |
248
- | `dexbot bot` | `bot` | Launch the interactive bot configurator |
247
+ | `dexbot key` | `keys` | Launch the chain key helper (`modules/chain_keys.ts`) |
248
+ | `dexbot bot` | `bots` | Launch the interactive bot configurator |
249
249
  | `dexbot pm2` | — | Start all active bots via PM2 |
250
250
  | `dexbot update` | — | Update DEXBot2 from the repository and restart active bots |
251
251
  | `dexbot export <bot>` | — | Export bot trades/settings to CSV/JSON for local analysis/ |
252
- | `dexbot order` | `orders` | Analyze persisted order grids (spread, increment, funds) |
252
+ | `dexbot order` | `orders` | Analyze persisted order grids (spread, increment, funds); `--export` for HTML |
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
- | `dexbot status` | `stat` | Unified runtime health — daemon, adapter, bots |
255
+ | `dexbot tv <target>` | — | TradingView 1h chart for `<bot|pool-id|AssetA/AssetB>` over `--month N` (default 3) |
256
+ | `dexbot dw <target>` | — | Dynamic-weight research chart: same targets/flags as `tv` |
257
+ | `dexbot status` | `stat`, `stats` | Unified runtime health — daemon, adapter, bots |
256
258
  | `dexbot start` | `unlock` | Run credential daemon + bot (equivalent to running the `unlock` runtime, `dist/unlock.js`) |
257
- | `dexbot stop` / `dexbot start` | `stp`, `stopall` | Stop/start the monolithic runtime (unlock mode) |
259
+ | `dexbot stop` | `stp`, `stopall` | Stop the monolithic runtime (unlock mode) |
258
260
  | `dexbot reload` | `reloadall` | Reload the monolithic runtime without touching the credential daemon (unlock mode) |
259
261
  | `dexbot restart` | `restartall` | Restart the monolithic runtime (unlock mode, re-unlocks credential daemon) |
260
262
  | `dexbot delete` | — | Shut down and clean up the monolithic runtime (unlock mode) |
261
- | `dexbot whitelist` | `white` | Generate market adapter whitelist from AMA bot configs |
262
263
  | `dexbot clear` | — | Remove all log files from the logs directory (`<profiles>/logs`) |
264
+ | `dexbot clear-orders` | — | Remove all persisted order files (`<profiles>/orders`) |
265
+ | `dexbot clear-market-adapter` | — | Remove market adapter data, state, and logs |
266
+ | `dexbot clear-all` | — | Remove orders, logs, market adapter, and claw files (all of the above) |
267
+ | `dexbot help` | — | Print the full CLI reference (grouped by Runtime/Trading/Config/Analysis/Files) |
263
268
 
264
269
  ## NPM Scripts for Branch Synchronization
265
270
 
@@ -22,7 +22,7 @@ DEXBot2 is a grid trading bot for the BitShares blockchain. It maintains a geome
22
22
  DEXBot2 prioritizes **simplicity and operational efficiency** over complex partial-handling mechanics:
23
23
 
24
24
  1. **Constant Spread**: The spread zone width remains fixed at `targetSpreadPercent`, eliminating dynamic inflation triggers.
25
- 2. **Direct Consolidation**: Dust partials are absorbed into the next grid rebuild cycle, not handled by complex merge/split logic.
25
+ 2. **Immediate Dust Cancellation**: Sub-threshold partials are cancelled on-chain as soon as detection runs; surviving non-dust partials are handled by ordinary fund-driven rebalancing without complex merge/split logic.
26
26
  3. **Minimal Blockchain Interaction**: Fund-driven rebalancing occurs once per fill batch, not per-partial. Grid generation uses only available funds—no forced allocations.
27
27
  4. **Closed-Loop Market Dynamics**: The boundary-crawl mechanism naturally handles price movement and fill flows without special-case logic.
28
28
  5. **Powerful Maintenance Tools**: Periodic grid regeneration, recovery retries, and fund invariant verification keep the system healthy over long operations.
@@ -56,10 +56,10 @@ graph TB
56
56
  MASTERGRID[Master Grid - immutable/frozen<br/>slot-id, price, size, state<br/>orderId, blockchain, grid, proceeds]
57
57
  TWOPASS[SyncEngine<br/>2-pass: grid-to-chain then chain-to-grid<br/>match orderId, detect partials, flag stale]
58
58
  FUNDS["Accounting - SSOT for funds<br/>available, virtual, committed<br/>btsFeesOwed<br/>Avail = max 0 ChainFree minus Virtual minus Fees"]
59
- TARGET[Strategy Engine<br/>calculateTargetGrid<br/>boundary-crawl pivot<br/>partial-fill consolidation, rotation]
59
+ TARGET[Strategy Engine<br/>calculateTargetGrid<br/>boundary-crawl pivot<br/>partial correction, rotation]
60
60
  WORKGRID[WorkingGrid - COW copy<br/>all mutations here only<br/>commit to Master on confirmation]
61
61
  FILLQUEUE[Fill Queue<br/>AsyncLock + dedup 5-60 min]
62
- BATCHER[Fixed-Cap Batcher<br/>queue within cap: unified batch<br/>queue above cap: chunk at cap size<br/>default cap: 4]
62
+ BATCHER[Fixed-Cap Batcher<br/>queue within cap: unified batch<br/>queue above cap: chunk at cap size<br/>cap = gapSlots + 1]
63
63
  end
64
64
 
65
65
  subgraph "OUTPUTS"
@@ -107,7 +107,7 @@ graph TB
107
107
  | **Immutability** | Master Grid is frozen; all changes go through a disposable WorkingGrid (Copy-on-Write) |
108
108
  | **Single Source of Truth** | Accounting engine owns all fund data; everything reads from it |
109
109
  | **Event-driven + Polling** | Fill Events (real-time) and Open-Order polling feed the same queue |
110
- | **Fixed-Cap Batching** | Deterministic batching with hard cap per broadcast (default 4 fills) |
110
+ | **Fixed-Cap Batching** | Deterministic batching with hard cap per broadcast (cap = gapSlots + 1 fills) |
111
111
  | **Persistence** | Grid snapshot written after every confirmed blockchain commit |
112
112
 
113
113
  ---
@@ -443,7 +443,7 @@ The fill pipeline handles incoming filled orders efficiently through fixed-cap b
443
443
 
444
444
  Scenario source: 29-fill burst during the Feb 7 market crash, modeled at
445
445
  roughly 3 seconds per broadcast; see
446
- [`FUND_MOVEMENT_AND_ACCOUNTING.md`](FUND_MOVEMENT_AND_ACCOUNTING.md#14-fill-batch-processing--cache-fund-timeline).
446
+ [`FUND_MOVEMENT_AND_ACCOUNTING.md`](FUND_MOVEMENT_AND_ACCOUNTING.md#15-fill-batch-processing--timeline).
447
447
 
448
448
  | Metric | Legacy (1-at-a-time) | Fixed-Cap Batching | Improvement |
449
449
  |--------|---------------------|-------------------|-------------|
@@ -464,46 +464,53 @@ Instead of complex partial handling, spread corrections are **conservative and f
464
464
  - Target spread width stays **constant** at `targetSpreadPercent`
465
465
  - Corrections scale with **actual available funds**, not arbitrary slot budgets
466
466
  - No dynamic spread inflation based on partial consolidation flags
467
- - Edge-first surplus selection ensures stable rotation candidates
467
+ - Safe window-contiguous candidate ordering (with an edge-first fallback) prevents cross-side placement
468
468
 
469
469
  ### Algorithm
470
470
 
471
- **Location**: `modules/order/strategy.ts::calculateTargetGrid()`
471
+ **Location**: `modules/order/grid.ts::prepareSpreadCorrectionOrders()`, selected by
472
+ `modules/order/grid.ts::determineOrderSideByFunds()`.
472
473
 
473
- The simplified approach prioritizes fund availability over aggressive corrections:
474
+ The correction path is fund-only and never manufactures budget by shrinking a resting order:
474
475
 
475
476
  ```
476
- 1. Detect that spread is wider than targetSpreadPercent
477
- 2. Calculate how many edge slots are missing
478
- 3. Attempt to place new edge orders with available funds
479
- 4. If insufficient funds for all edges:
480
- - Create what's affordable with available funds
481
- - Log shortfall (smooth over next rebalance cycle)
482
- 5. If a dust partial exists in the correction window:
483
- - Mark for consolidation in next grid rebuild
484
- - Don't create complex merge/split side effects
485
- 6. Maintain constant target spread—no inflation based on partial flags
477
+ 1. Detect that the live window is wider than targetSpreadPercent.
478
+ 2. Select up to `outOfSpread` eligible holes in safe window/gap order.
479
+ 3. If the funded edge holds a non-dust PARTIAL, optionally top it up, but only
480
+ when `ideal - current` is positive and free funds can cover the increase.
481
+ 4. Create replacements from free available/chainFree funds; contiguous gap-slot
482
+ promotion may extend the window while preserving MIN_SPREAD_ORDERS and the
483
+ opposite placed rail.
484
+ 5. If free funds cannot cover every target, place/top up the affordable prefix,
485
+ stop without shrinking inventory, and log the fund-constrained remainder.
486
+ 6. If neither side has free funds, skip correction and let the maintenance
487
+ runtime refresh balances and open orders rather than recycle stale inventory.
486
488
  ```
487
489
 
490
+ Detected dust partials never enter this path: `cancelDustOrders()` cancels them
491
+ on-chain immediately, and the five-minute health check is only a restart safety net.
492
+
488
493
  ### Fund-Safe Constraints
489
494
 
490
495
  Spread corrections respect these hard limits:
491
496
 
492
497
  ```javascript
493
498
  // In modules/constants.ts (GRID_LIMITS)
494
- MIN_SPREAD_ORDERS: 2, // Always maintain minimum gap
499
+ MIN_SPREAD_ORDERS: 2, // Preserve the minimum empty gap reserve
495
500
 
496
- // Spread width itself stays user-configured (`targetSpreadPercent`) — fixed, no inflation.
497
- // Correction count has no separate slot cap; it is bounded by the funds check below.
501
+ // `outOfSpread` supplies the requested slot count. Execution is bounded by
502
+ // safe candidate selection, healthy minimum sizes, and actual free funds.
503
+ const availableFund = Math.max(0, Math.min(
504
+ manager.funds.available[side],
505
+ manager.accountTotals[side === 'buy' ? 'buyFree' : 'sellFree']
506
+ ));
498
507
 
499
- // Each correction order must be healthy
500
- const minHealthySize = calculateMinOrderSize(side);
501
- const affordableOrderCount = Math.floor(availableFunds / minHealthySize);
502
- const correctionOrders = Math.min(missingSlots, affordableOrderCount);
508
+ // Each target is created or topped up only while remainingBudget covers it.
509
+ // No resting ACTIVE/PARTIAL order is shrunk to fund the correction.
503
510
  ```
504
511
 
505
512
  **Benefits**:
506
- - ✅ No "double-dust" fragmentation
513
+ - ✅ No inventory recycling from stale-size snapshots
507
514
  - ✅ Constant, predictable spread width
508
515
  - ✅ Funds always respected (no forced allocation)
509
516
  - ✅ Natural smoothing over multiple rebalance cycles
@@ -591,12 +598,11 @@ if (mgr.outOfSpread) {
591
598
  ### After (Numeric Distance)
592
599
 
593
600
  ```javascript
594
- // New approach: distance in steps
595
- mgr.outOfSpread = 3; // 3 steps beyond target spread
601
+ // New approach: requested missing slots derived from the live geometry
602
+ mgr.outOfSpread = 3; // three slots beyond the target spread
596
603
 
597
- // Use distance in correction logic
598
- const spreadDistance = mgr.outOfSpread;
599
- const replacementSlots = Math.min(spreadDistance, MAX_CORRECTION_SLOTS);
604
+ // The grid engine bounds actual work by eligible candidates, MIN_SPREAD_ORDERS,
605
+ // healthy sizes, and available free funds. There is no MAX_CORRECTION_SLOTS cap.
600
606
  ```
601
607
 
602
608
  **Benefit**: Enables scaled corrections based on actual severity.
@@ -706,7 +712,7 @@ stateDiagram-v2
706
712
 
707
713
  note right of PARTIAL
708
714
  Partially filled on-chain
709
- Waiting for consolidation
715
+ Dust is cancelled immediately; non-dust is corrected in rebalance
710
716
  end note
711
717
  ```
712
718
 
@@ -881,7 +887,7 @@ sequenceDiagram
881
887
  Strat-->>Mgr: target grid
882
888
  Mgr->>Mgr: Apply rotations via WorkingGrid
883
889
  Mgr->>Acct: Deduct BTS fees during recalculateFunds
884
- Mgr->>Mgr: Consolidate dust partials
890
+ Mgr->>Mgr: Cancel detected dust partials immediately
885
891
  ```
886
892
 
887
893
  ### 2. Order Rotation (Crawl Mechanism)
@@ -1059,7 +1065,7 @@ The system has been optimized to use a "memory-driven" model for order updates,
1059
1065
  - **Faster reaction time**: No waiting for blockchain queries during order updates
1060
1066
  - **Reduced API load**: Fewer fetches, less network congestion
1061
1067
  - **Mathematical precision**: Integer-based tracking prevents float precision errors
1062
- - *See [FUND_MOVEMENT_AND_ACCOUNTING.md § 5.5](FUND_MOVEMENT_AND_ACCOUNTING.md#55-precision--quantization-patch-14) for quantization utilities and best practices*
1068
+ - *See [FUND_MOVEMENT_AND_ACCOUNTING.md § 5.5](FUND_MOVEMENT_AND_ACCOUNTING.md#55-precision--quantization) for quantization utilities and best practices*
1063
1069
  - **Fallback safety**: Automatic recovery if memory state becomes inconsistent
1064
1070
 
1065
1071
  ### Performance Impact
@@ -1155,8 +1161,6 @@ graph LR
1155
1161
  B -->|Real-world Scenarios| B3["Fills/FEE Tests"]
1156
1162
 
1157
1163
  C -->|Dynamic Weight| C1["dynamic_weight"]
1158
- C -->|Derivative Trap| C2["derivative_signal"]
1159
- C -->|Momentum Gate| C3["momentum_gate"]
1160
1164
 
1161
1165
  D -->|CR Planner| D1["cr_planner"]
1162
1166
  D -->|Credit Runtime| D2["credit_runtime"]
@@ -1189,13 +1193,12 @@ node dist/tests/test_dexbot_credit_wiring.js
1189
1193
  - ✅ Edge cases covered (zero funds, max orders, etc.)
1190
1194
  - ✅ Concurrent operations tested with locks
1191
1195
  - ✅ State transitions validated end-to-end
1192
- - ✅ Signal pipelines tested (dynamic weight, derivative traps)
1196
+ - ✅ Signal pipelines tested (dynamic weight)
1193
1197
  - ✅ Credit/debt runtime tested (CR planner, MPA wiring)
1194
1198
 
1195
1199
  **Test Suite Evolution:**
1196
1200
  - 50+ test cases for signal intelligence and credit runtime
1197
1201
  - Dynamic weight override and market adapter signal gate tests
1198
- - Derivative momentum gate and signal trap regression tests
1199
1202
  - Credit/debt tests with CR planner and MPA wiring validation
1200
1203
 
1201
1204
  ### Testing Best Practices
@@ -1323,8 +1326,7 @@ The strategy engine has been significantly strengthened with improvements to fun
1323
1326
  **2. Dust Partial Handling**
1324
1327
  - Improved dust detection algorithm prevents false positives
1325
1328
  - Detects dust as `< 5% of ideal order size`
1326
- - Dust partials are absorbed into the next grid rebuild cycle (no merge/split mechanics)
1327
- - **Auto-Cancellation**: `_cancelDustOrders()` cancels dust partials on-chain immediately on detection — no delay, no timer maps, no retry budgets. Cancel is attempted post-fill (inside fill lock) and every 5-min health check (safety net).
1329
+ - **Immediate Cancellation**: `_cancelDustOrders()` cancels dust partials on-chain when detection runs — no delay, timer map, or consolidation cycle. Detection runs after fills/sync, and a 5-minute health check is the restart safety net.
1328
1330
 
1329
1331
  **3. Strict Order Size Constraints**
1330
1332
  - Orders validated to not exceed available funds
@@ -129,8 +129,6 @@ A **phantom order** is an order in ACTIVE/PARTIAL state WITHOUT a valid `orderId
129
129
  | **Kalman Confirmation** | Kalman-filtered trend signal blended with AMA slope for smoother weight transitions |
130
130
  | **Symmetric Shift** | Volatility-driven downward weight penalty applied equally to both sides (ATR-based) |
131
131
  | **Asymmetric Offset** | Directional weight shift (buy-heavy or sell-heavy) driven by AMA/Kalman trend |
132
- | **Derivative Signal** | SMA/MACD/RSI-based entry bias and momentum gate for optional strategy filtering |
133
- | **Momentum Gate** | N-bar commitment tracking that confirms derivative signals before acting |
134
132
  | **GridPrice** | Price anchor for grid math; can be numeric, `"pool"`, `"book"`, or AMA keyword (`"ama"`, `"ama1"`–`"ama4"`) |
135
133
 
136
134
  ### Grid Concepts
@@ -165,7 +163,7 @@ A **phantom order** is an order in ACTIVE/PARTIAL state WITHOUT a valid `orderId
165
163
  | Term | Meaning |
166
164
  |------|---------|
167
165
  | **Rotation** | Moving an order from one price level to another |
168
- | **Consolidation** | Absorbing dust partials into the next grid rebuild cycle. All slots are treated uniformly—no side-specific flags or bonuses. |
166
+ | **Consolidation** | Absorbing surviving non-dust partials into ordinary fund-driven rebalancing. Detected dust is cancelled immediately and never waits for a rebuild. |
169
167
  | **Rebalancing** | Adjusting order sizes based on current funds |
170
168
  | **Global Side Capping** | Scaling order sizes when insufficient funds |
171
169
  | **Atomic Check-and-Deduct** | Verify funds + deduct in single operation |
@@ -277,7 +275,7 @@ const correctedPrice = quantizeFloat(derivedPrice, 8);
277
275
  const normalized = normalizeInt(currentSizeInt, assetPrecision);
278
276
  ```
279
277
 
280
- **See [FUND_MOVEMENT_AND_ACCOUNTING.md § 5.5](FUND_MOVEMENT_AND_ACCOUNTING.md#55-precision--quantization-patch-14) for complete quantization guide and edge case handling.**
278
+ **See [FUND_MOVEMENT_AND_ACCOUNTING.md § 5.5](FUND_MOVEMENT_AND_ACCOUNTING.md#55-precision--quantization) for complete quantization guide and edge case handling.**
281
279
 
282
280
  ---
283
281
 
@@ -620,7 +618,7 @@ const minHealthySize = getMinOrderSize(ORDER_TYPES.BUY, assets, 1.0);
620
618
  if (isOrderHealthy(order, minHealthySize)) {
621
619
  // Order is valid for placement/rotation
622
620
  } else {
623
- // Order is dust - consolidate or skip
621
+ // Order is dust - skip it here; cancelDustOrders() handles it on-chain
624
622
  }
625
623
  ```
626
624
 
@@ -737,7 +735,7 @@ _verifyFundInvariants(...)
737
735
  - Process filled orders
738
736
  - Identify shortages and surpluses
739
737
  - Execute order rotations
740
- - Handle partial order consolidation
738
+ - Handle surviving non-dust partials during rebalance
741
739
 
742
740
  **Critical Methods**:
743
741
  ```javascript
@@ -1211,8 +1209,6 @@ Located in `tests/` (with `helpers/` subdirectory):
1211
1209
  - `test_bts_fee_logic.ts` - BTS fee deduction and settlement
1212
1210
  - `test_market_adapter_signal_gates.ts` - Market adapter signal validation
1213
1211
  - `test_dynamic_weight_override_wiring.ts` - Dynamic weight config wiring
1214
- - `test_derivative_signal_trap_regression.ts` - Derivative signal trap tests
1215
- - `test_derivative_momentum_gate.ts` - Momentum gate tests
1216
1212
  - `test_cr_planner.ts` - Collateral ratio planner tests
1217
1213
  - `test_dexbot_credit_wiring.ts` - Credit runtime integration tests
1218
1214
  - `test_credential_daemon.ts` / `test_credential_session_cache.ts` - Credential security tests
@@ -1559,6 +1555,7 @@ console.log('Locked?', manager.isOrderLocked(order.id));
1559
1555
  - `modules/node_manager.ts` - Multi-node health checking and failover
1560
1556
  - `modules/fund_registry.ts` - Shared-account fund registry with cross-bot invariants
1561
1557
  - `modules/settings_merge.ts` - Consolidated settings merge (single source of truth)
1558
+ - `modules/bot_defaults.ts` - Central bot-defaults seeder (draft/entry/runtime-config modes); single source for how `DEFAULT_CONFIG` is applied
1562
1559
  - `modules/chain_orders.ts` - Blockchain order operations
1563
1560
  - `modules/account_orders.ts` - Account order queries
1564
1561