dexbot 1.6.7 → 1.6.8

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 (613) hide show
  1. package/CHANGELOG.md +49 -1
  2. package/README.md +3 -3
  3. package/analysis/README.md +2 -3
  4. package/analysis/tradingview/README.md +78 -1
  5. package/analysis/trend_detection/DYNAMIC_WEIGHT_RESEARCH.md +1 -1
  6. package/claw/package.json +1 -1
  7. package/claw/runtimes/openclaw-plugin/openclaw.plugin.json +1 -1
  8. package/claw/runtimes/openclaw-plugin/package.json +1 -1
  9. package/dist/analysis/tradingview/analyze_tradingview.d.ts +4 -0
  10. package/dist/analysis/tradingview/analyze_tradingview.js +55 -0
  11. package/dist/analysis/tradingview/grid_reset_config.d.ts +61 -0
  12. package/dist/analysis/tradingview/grid_reset_config.js +235 -0
  13. package/dist/analysis/tradingview/grid_reset_sim.d.ts +67 -0
  14. package/dist/analysis/tradingview/grid_reset_sim.js +307 -0
  15. package/dist/analysis/tradingview/tradingview_uplot_chart_generator.js +419 -3
  16. package/dist/dexbot.js +22 -6
  17. package/dist/market_adapter/core/market_adapter_service.js +14 -2
  18. package/dist/market_adapter/core/strategies/dynamic_weight_series.d.ts +8 -1
  19. package/dist/market_adapter/core/strategies/dynamic_weight_series.js +5 -1
  20. package/dist/market_adapter/inputs/window_cache.d.ts +97 -19
  21. package/dist/market_adapter/inputs/window_cache.js +302 -48
  22. package/dist/market_adapter/market_adapter.d.ts +8 -1
  23. package/dist/market_adapter/market_adapter.js +22 -4
  24. package/dist/modules/account_bots.js +10 -0
  25. package/dist/modules/account_orders.d.ts +24 -2
  26. package/dist/modules/account_orders.js +41 -4
  27. package/dist/modules/bot_settings.js +10 -1
  28. package/dist/modules/config.d.ts +1 -0
  29. package/dist/modules/config.js +1 -0
  30. package/dist/modules/constants.d.ts +11 -3
  31. package/dist/modules/constants.js +116 -37
  32. package/dist/modules/dexbot_class.d.ts +6 -76
  33. package/dist/modules/dexbot_class.js +0 -32
  34. package/dist/modules/dexbot_cow_runtime.d.ts +3 -58
  35. package/dist/modules/dexbot_cow_runtime.js +4 -87
  36. package/dist/modules/dexbot_maintenance_runtime.d.ts +15 -1
  37. package/dist/modules/dexbot_maintenance_runtime.js +59 -11
  38. package/dist/modules/dexbot_startup_runtime.js +73 -20
  39. package/dist/modules/dexbot_state_recovery.d.ts +6 -0
  40. package/dist/modules/dexbot_state_recovery.js +21 -0
  41. package/dist/modules/order/async_lock.d.ts +8 -0
  42. package/dist/modules/order/async_lock.js +15 -0
  43. package/dist/modules/order/genesis_policy.d.ts +162 -0
  44. package/dist/modules/order/genesis_policy.js +267 -0
  45. package/dist/modules/order/grid.js +76 -134
  46. package/dist/modules/order/grid_reconcile.d.ts +9 -0
  47. package/dist/modules/order/grid_reconcile.js +13 -4
  48. package/dist/modules/order/grid_reconcile_internal.js +2 -2
  49. package/dist/modules/order/manager.d.ts +4 -0
  50. package/dist/modules/order/manager.js +14 -1
  51. package/dist/modules/order/sync_engine.d.ts +19 -0
  52. package/dist/modules/order/sync_engine.js +284 -344
  53. package/dist/modules/order/utils/math.d.ts +22 -1
  54. package/dist/modules/order/utils/math.js +64 -1
  55. package/dist/modules/order/utils/order.d.ts +43 -58
  56. package/dist/modules/order/utils/order.js +220 -197
  57. package/dist/modules/order/utils/system.js +8 -1
  58. package/dist/modules/paths.d.ts +1 -0
  59. package/dist/modules/paths.js +1 -0
  60. package/dist/modules/version_notice.d.ts +165 -0
  61. package/dist/modules/version_notice.js +364 -0
  62. package/dist/pm2.js +9 -0
  63. package/dist/unlock.js +28 -0
  64. package/docs/BITSHARES_ONBOARDING.md +8 -1
  65. package/docs/COW_INVARIANTS.md +3 -2
  66. package/docs/DEXBOT_COMPARISON.md +4 -4
  67. package/docs/EVOLUTION.md +20 -19
  68. package/docs/FUND_MOVEMENT_AND_ACCOUNTING.md +1 -1
  69. package/docs/GRID_PRICE_INVARIANT.md +149 -31
  70. package/docs/GRID_RECALCULATION.md +12 -0
  71. package/docs/README.md +3 -1
  72. package/docs/WORKFLOW.md +16 -5
  73. package/market_adapter/README.md +1 -1
  74. package/modules/README.md +18 -1
  75. package/package.json +13 -5
  76. package/scripts/README.md +28 -2
  77. package/scripts/clear-all.sh +13 -4
  78. package/scripts/clear-logs.sh +13 -4
  79. package/scripts/clear-market-adapter.sh +6 -0
  80. package/scripts/clear-orders.sh +5 -0
  81. package/scripts/lib/dexbot-paths.sh +108 -0
  82. package/tests/README.md +11 -3
  83. package/analysis/account_resolver.ts +0 -161
  84. package/analysis/ama_fitting/analyze_ama_price_changes.ts +0 -155
  85. package/analysis/ama_fitting/analyze_lambda_vs_slow.ts +0 -404
  86. package/analysis/ama_fitting/calibrate_convergence_er.ts +0 -201
  87. package/analysis/ama_fitting/fetch_lp_candles.ts +0 -184
  88. package/analysis/ama_fitting/generate_unified_comparison_chart.ts +0 -232
  89. package/analysis/ama_fitting/optimizer_high_resolution.ts +0 -802
  90. package/analysis/analyze_dynamic_weight.ts +0 -243
  91. package/analysis/analyze_kalman.ts +0 -157
  92. package/analysis/analyze_regime.ts +0 -158
  93. package/analysis/analyze_regime_windows.ts +0 -470
  94. package/analysis/analyze_risk_profile.ts +0 -199
  95. package/analysis/analyze_trade_heatmap.ts +0 -362
  96. package/analysis/analyze_volatility.ts +0 -182
  97. package/analysis/bot_fitting/backtest_ama_sweep.ts +0 -934
  98. package/analysis/bot_fitting/backtest_bot_fitting.ts +0 -861
  99. package/analysis/bot_fitting/shared_utils.ts +0 -52
  100. package/analysis/bot_key_utils.ts +0 -426
  101. package/analysis/bot_usage/discover_bot_accounts.ts +0 -635
  102. package/analysis/bot_usage/kibana_bot_queries.ts +0 -211
  103. package/analysis/chain_pool.ts +0 -47
  104. package/analysis/chart_css.ts +0 -62
  105. package/analysis/chart_ui.ts +0 -105
  106. package/analysis/chart_utils.ts +0 -210
  107. package/analysis/fills_source.ts +0 -228
  108. package/analysis/grid_correction_check.ts +0 -786
  109. package/analysis/math_utils.ts +0 -53
  110. package/analysis/price_sources.ts +0 -136
  111. package/analysis/resolve_bot_accounts.ts +0 -199
  112. package/analysis/resolve_source.ts +0 -99
  113. package/analysis/results/ama_sweep_results_lp_pool_133_1h.json +0 -2455
  114. package/analysis/results/bot_fitting_results_lp_pool_133_1h.json +0 -218
  115. package/analysis/trade_profitability.ts +0 -1335
  116. package/analysis/tradingview/analyze_tradingview.ts +0 -280
  117. package/analysis/tradingview/h-bts_tradingview.html +0 -1570
  118. package/analysis/tradingview/t-bts_tradingview.html +0 -1570
  119. package/analysis/tradingview/tradingview_uplot_chart_generator.ts +0 -3268
  120. package/analysis/trend_detection/dynamic_weight_chart_generator.ts +0 -1481
  121. package/analysis/trend_detection/hurst_analyzer.ts +0 -7
  122. package/analysis/trend_detection/kalman_chart_generator.ts +0 -398
  123. package/analysis/trend_detection/kalman_trend_analyzer.ts +0 -9
  124. package/analysis/trend_detection/kalman_velocity_smoothing.ts +0 -7
  125. package/analysis/trend_detection/package.json +0 -23
  126. package/analysis/trend_detection/permutation_entropy_analyzer.ts +0 -7
  127. package/analysis/trend_detection/regime_chart_generator.ts +0 -338
  128. package/analysis/trend_detection/tests/test_kalman_trend.ts +0 -153
  129. package/analysis/trend_detection/tests/test_kalman_velocity_smoothing.ts +0 -64
  130. package/analysis/trend_detection/volatility_chart_generator.ts +0 -654
  131. package/analysis/tsconfig.json +0 -29
  132. package/claw/tests/package.json +0 -3
  133. package/claw/tests/test_claw_bridge.ts +0 -570
  134. package/claw/tests/test_claw_catalog_and_credentials.ts +0 -156
  135. package/claw/tests/test_claw_chain_layer.ts +0 -739
  136. package/claw/tests/test_claw_data_flow.ts +0 -525
  137. package/claw/tests/test_claw_domain_logic.ts +0 -471
  138. package/claw/tests/test_claw_manifest_and_matrix.ts +0 -222
  139. package/claw/tests/test_claw_mcp_transport.ts +0 -243
  140. package/claw/tests/test_claw_regressions.ts +0 -711
  141. package/claw/tests/test_claw_skill_generation.ts +0 -103
  142. package/claw/tests/test_claw_state_store.ts +0 -44
  143. package/claw/tests/test_dexbot_profiles.ts +0 -654
  144. package/claw/tests/test_memu_bridge.ts +0 -189
  145. package/claw/tests/test_nullclaw_tmp_integration.ts +0 -57
  146. package/claw/tests/test_position_health.ts +0 -343
  147. package/claw/tests/test_position_manager.ts +0 -429
  148. package/claw/tests/test_position_manager_watch_health.ts +0 -100
  149. package/claw/tests/test_short_mpa_strategy.ts +0 -232
  150. package/dist/analysis/account_resolver.d.ts.map +0 -1
  151. package/dist/analysis/account_resolver.js.map +0 -1
  152. package/dist/analysis/ama_fitting/analyze_ama_price_changes.d.ts.map +0 -1
  153. package/dist/analysis/ama_fitting/analyze_ama_price_changes.js.map +0 -1
  154. package/dist/analysis/ama_fitting/analyze_lambda_vs_slow.d.ts.map +0 -1
  155. package/dist/analysis/ama_fitting/analyze_lambda_vs_slow.js.map +0 -1
  156. package/dist/analysis/ama_fitting/calibrate_convergence_er.d.ts.map +0 -1
  157. package/dist/analysis/ama_fitting/calibrate_convergence_er.js.map +0 -1
  158. package/dist/analysis/ama_fitting/fetch_lp_candles.d.ts.map +0 -1
  159. package/dist/analysis/ama_fitting/fetch_lp_candles.js.map +0 -1
  160. package/dist/analysis/ama_fitting/generate_unified_comparison_chart.d.ts.map +0 -1
  161. package/dist/analysis/ama_fitting/generate_unified_comparison_chart.js.map +0 -1
  162. package/dist/analysis/ama_fitting/optimizer_high_resolution.d.ts.map +0 -1
  163. package/dist/analysis/ama_fitting/optimizer_high_resolution.js.map +0 -1
  164. package/dist/analysis/analyze_dynamic_weight.d.ts.map +0 -1
  165. package/dist/analysis/analyze_dynamic_weight.js.map +0 -1
  166. package/dist/analysis/analyze_kalman.d.ts.map +0 -1
  167. package/dist/analysis/analyze_kalman.js.map +0 -1
  168. package/dist/analysis/analyze_regime.d.ts.map +0 -1
  169. package/dist/analysis/analyze_regime.js.map +0 -1
  170. package/dist/analysis/analyze_regime_windows.d.ts.map +0 -1
  171. package/dist/analysis/analyze_regime_windows.js.map +0 -1
  172. package/dist/analysis/analyze_risk_profile.d.ts.map +0 -1
  173. package/dist/analysis/analyze_risk_profile.js.map +0 -1
  174. package/dist/analysis/analyze_trade_heatmap.d.ts.map +0 -1
  175. package/dist/analysis/analyze_trade_heatmap.js.map +0 -1
  176. package/dist/analysis/analyze_volatility.d.ts.map +0 -1
  177. package/dist/analysis/analyze_volatility.js.map +0 -1
  178. package/dist/analysis/bot_fitting/backtest_ama_sweep.d.ts.map +0 -1
  179. package/dist/analysis/bot_fitting/backtest_ama_sweep.js.map +0 -1
  180. package/dist/analysis/bot_fitting/backtest_bot_fitting.d.ts.map +0 -1
  181. package/dist/analysis/bot_fitting/backtest_bot_fitting.js.map +0 -1
  182. package/dist/analysis/bot_fitting/shared_utils.d.ts.map +0 -1
  183. package/dist/analysis/bot_fitting/shared_utils.js.map +0 -1
  184. package/dist/analysis/bot_key_utils.d.ts.map +0 -1
  185. package/dist/analysis/bot_key_utils.js.map +0 -1
  186. package/dist/analysis/bot_usage/discover_bot_accounts.d.ts.map +0 -1
  187. package/dist/analysis/bot_usage/discover_bot_accounts.js.map +0 -1
  188. package/dist/analysis/bot_usage/kibana_bot_queries.d.ts.map +0 -1
  189. package/dist/analysis/bot_usage/kibana_bot_queries.js.map +0 -1
  190. package/dist/analysis/chain_pool.d.ts.map +0 -1
  191. package/dist/analysis/chain_pool.js.map +0 -1
  192. package/dist/analysis/chart_css.d.ts.map +0 -1
  193. package/dist/analysis/chart_css.js.map +0 -1
  194. package/dist/analysis/chart_ui.d.ts.map +0 -1
  195. package/dist/analysis/chart_ui.js.map +0 -1
  196. package/dist/analysis/chart_utils.d.ts.map +0 -1
  197. package/dist/analysis/chart_utils.js.map +0 -1
  198. package/dist/analysis/fills_source.d.ts.map +0 -1
  199. package/dist/analysis/fills_source.js.map +0 -1
  200. package/dist/analysis/grid_correction_check.d.ts.map +0 -1
  201. package/dist/analysis/grid_correction_check.js.map +0 -1
  202. package/dist/analysis/math_utils.d.ts.map +0 -1
  203. package/dist/analysis/math_utils.js.map +0 -1
  204. package/dist/analysis/price_sources.d.ts.map +0 -1
  205. package/dist/analysis/price_sources.js.map +0 -1
  206. package/dist/analysis/resolve_bot_accounts.d.ts.map +0 -1
  207. package/dist/analysis/resolve_bot_accounts.js.map +0 -1
  208. package/dist/analysis/resolve_source.d.ts.map +0 -1
  209. package/dist/analysis/resolve_source.js.map +0 -1
  210. package/dist/analysis/trade_profitability.d.ts.map +0 -1
  211. package/dist/analysis/trade_profitability.js.map +0 -1
  212. package/dist/analysis/tradingview/analyze_tradingview.d.ts.map +0 -1
  213. package/dist/analysis/tradingview/analyze_tradingview.js.map +0 -1
  214. package/dist/analysis/tradingview/tradingview_uplot_chart_generator.d.ts.map +0 -1
  215. package/dist/analysis/tradingview/tradingview_uplot_chart_generator.js.map +0 -1
  216. package/dist/analysis/trend_detection/dynamic_weight_chart_generator.d.ts.map +0 -1
  217. package/dist/analysis/trend_detection/dynamic_weight_chart_generator.js.map +0 -1
  218. package/dist/analysis/trend_detection/hurst_analyzer.d.ts.map +0 -1
  219. package/dist/analysis/trend_detection/hurst_analyzer.js.map +0 -1
  220. package/dist/analysis/trend_detection/kalman_chart_generator.d.ts.map +0 -1
  221. package/dist/analysis/trend_detection/kalman_chart_generator.js.map +0 -1
  222. package/dist/analysis/trend_detection/kalman_trend_analyzer.d.ts.map +0 -1
  223. package/dist/analysis/trend_detection/kalman_trend_analyzer.js.map +0 -1
  224. package/dist/analysis/trend_detection/kalman_velocity_smoothing.d.ts.map +0 -1
  225. package/dist/analysis/trend_detection/kalman_velocity_smoothing.js.map +0 -1
  226. package/dist/analysis/trend_detection/permutation_entropy_analyzer.d.ts.map +0 -1
  227. package/dist/analysis/trend_detection/permutation_entropy_analyzer.js.map +0 -1
  228. package/dist/analysis/trend_detection/regime_chart_generator.d.ts.map +0 -1
  229. package/dist/analysis/trend_detection/regime_chart_generator.js.map +0 -1
  230. package/dist/analysis/trend_detection/tests/test_kalman_trend.d.ts +0 -2
  231. package/dist/analysis/trend_detection/tests/test_kalman_trend.d.ts.map +0 -1
  232. package/dist/analysis/trend_detection/tests/test_kalman_trend.js +0 -128
  233. package/dist/analysis/trend_detection/tests/test_kalman_trend.js.map +0 -1
  234. package/dist/analysis/trend_detection/tests/test_kalman_velocity_smoothing.d.ts +0 -2
  235. package/dist/analysis/trend_detection/tests/test_kalman_velocity_smoothing.d.ts.map +0 -1
  236. package/dist/analysis/trend_detection/tests/test_kalman_velocity_smoothing.js +0 -37
  237. package/dist/analysis/trend_detection/tests/test_kalman_velocity_smoothing.js.map +0 -1
  238. package/dist/analysis/trend_detection/volatility_chart_generator.d.ts.map +0 -1
  239. package/dist/analysis/trend_detection/volatility_chart_generator.js.map +0 -1
  240. package/dist/bot.d.ts.map +0 -1
  241. package/dist/bot.js.map +0 -1
  242. package/dist/credential-daemon.d.ts.map +0 -1
  243. package/dist/credential-daemon.js.map +0 -1
  244. package/dist/dexbot.d.ts.map +0 -1
  245. package/dist/dexbot.js.map +0 -1
  246. package/dist/market_adapter/ama_signal_runner.d.ts.map +0 -1
  247. package/dist/market_adapter/ama_signal_runner.js.map +0 -1
  248. package/dist/market_adapter/candle_utils.d.ts.map +0 -1
  249. package/dist/market_adapter/candle_utils.js.map +0 -1
  250. package/dist/market_adapter/core/asymmetric_bounds.d.ts.map +0 -1
  251. package/dist/market_adapter/core/asymmetric_bounds.js.map +0 -1
  252. package/dist/market_adapter/core/config_normalizers.d.ts.map +0 -1
  253. package/dist/market_adapter/core/config_normalizers.js.map +0 -1
  254. package/dist/market_adapter/core/kibana_candles.d.ts.map +0 -1
  255. package/dist/market_adapter/core/kibana_candles.js.map +0 -1
  256. package/dist/market_adapter/core/kibana_client.d.ts.map +0 -1
  257. package/dist/market_adapter/core/kibana_client.js.map +0 -1
  258. package/dist/market_adapter/core/kibana_market_candles.d.ts.map +0 -1
  259. package/dist/market_adapter/core/kibana_market_candles.js.map +0 -1
  260. package/dist/market_adapter/core/market_adapter_service.d.ts.map +0 -1
  261. package/dist/market_adapter/core/market_adapter_service.js.map +0 -1
  262. package/dist/market_adapter/core/signals/hurst_analyzer.d.ts.map +0 -1
  263. package/dist/market_adapter/core/signals/hurst_analyzer.js.map +0 -1
  264. package/dist/market_adapter/core/signals/kalman_trend_analyzer.d.ts.map +0 -1
  265. package/dist/market_adapter/core/signals/kalman_trend_analyzer.js.map +0 -1
  266. package/dist/market_adapter/core/signals/kalman_velocity_smoothing.d.ts.map +0 -1
  267. package/dist/market_adapter/core/signals/kalman_velocity_smoothing.js.map +0 -1
  268. package/dist/market_adapter/core/signals/permutation_entropy_analyzer.d.ts.map +0 -1
  269. package/dist/market_adapter/core/signals/permutation_entropy_analyzer.js.map +0 -1
  270. package/dist/market_adapter/core/strategies/ama.d.ts.map +0 -1
  271. package/dist/market_adapter/core/strategies/ama.js.map +0 -1
  272. package/dist/market_adapter/core/strategies/ama_slope_model.d.ts.map +0 -1
  273. package/dist/market_adapter/core/strategies/ama_slope_model.js.map +0 -1
  274. package/dist/market_adapter/core/strategies/atr/calculator.d.ts.map +0 -1
  275. package/dist/market_adapter/core/strategies/atr/calculator.js.map +0 -1
  276. package/dist/market_adapter/core/strategies/collateral_manager.d.ts.map +0 -1
  277. package/dist/market_adapter/core/strategies/collateral_manager.js.map +0 -1
  278. package/dist/market_adapter/core/strategies/dynamic_weight_series.d.ts.map +0 -1
  279. package/dist/market_adapter/core/strategies/dynamic_weight_series.js.map +0 -1
  280. package/dist/market_adapter/core/strategies/regime_gate.d.ts.map +0 -1
  281. package/dist/market_adapter/core/strategies/regime_gate.js.map +0 -1
  282. package/dist/market_adapter/core/strategies/regime_interp.d.ts.map +0 -1
  283. package/dist/market_adapter/core/strategies/regime_interp.js.map +0 -1
  284. package/dist/market_adapter/core/strategies/volatility_shift.d.ts.map +0 -1
  285. package/dist/market_adapter/core/strategies/volatility_shift.js.map +0 -1
  286. package/dist/market_adapter/inputs/fetch_book_data.d.ts.map +0 -1
  287. package/dist/market_adapter/inputs/fetch_book_data.js.map +0 -1
  288. package/dist/market_adapter/inputs/fetch_cex_synthetic_data.d.ts.map +0 -1
  289. package/dist/market_adapter/inputs/fetch_cex_synthetic_data.js.map +0 -1
  290. package/dist/market_adapter/inputs/fetch_lp_data.d.ts.map +0 -1
  291. package/dist/market_adapter/inputs/fetch_lp_data.js.map +0 -1
  292. package/dist/market_adapter/inputs/kibana_feed_source.d.ts.map +0 -1
  293. package/dist/market_adapter/inputs/kibana_feed_source.js.map +0 -1
  294. package/dist/market_adapter/inputs/kibana_source.d.ts.map +0 -1
  295. package/dist/market_adapter/inputs/kibana_source.js.map +0 -1
  296. package/dist/market_adapter/inputs/window_cache.d.ts.map +0 -1
  297. package/dist/market_adapter/inputs/window_cache.js.map +0 -1
  298. package/dist/market_adapter/interval_utils.d.ts.map +0 -1
  299. package/dist/market_adapter/interval_utils.js.map +0 -1
  300. package/dist/market_adapter/log_format.d.ts.map +0 -1
  301. package/dist/market_adapter/log_format.js.map +0 -1
  302. package/dist/market_adapter/lp_chart_core.d.ts.map +0 -1
  303. package/dist/market_adapter/lp_chart_core.js.map +0 -1
  304. package/dist/market_adapter/lp_chart_runner.d.ts.map +0 -1
  305. package/dist/market_adapter/lp_chart_runner.js.map +0 -1
  306. package/dist/market_adapter/lp_chart_strategy_loader.d.ts.map +0 -1
  307. package/dist/market_adapter/lp_chart_strategy_loader.js.map +0 -1
  308. package/dist/market_adapter/market_adapter.d.ts.map +0 -1
  309. package/dist/market_adapter/market_adapter.js.map +0 -1
  310. package/dist/market_adapter/test_helpers.d.ts.map +0 -1
  311. package/dist/market_adapter/test_helpers.js.map +0 -1
  312. package/dist/market_adapter/utils/adapter_client.d.ts.map +0 -1
  313. package/dist/market_adapter/utils/adapter_client.js.map +0 -1
  314. package/dist/market_adapter/utils/atomic_write.d.ts.map +0 -1
  315. package/dist/market_adapter/utils/atomic_write.js.map +0 -1
  316. package/dist/market_adapter/utils/chain.d.ts.map +0 -1
  317. package/dist/market_adapter/utils/chain.js.map +0 -1
  318. package/dist/market_adapter/utils/data_discovery.d.ts.map +0 -1
  319. package/dist/market_adapter/utils/data_discovery.js.map +0 -1
  320. package/dist/market_adapter/utils/dynamic_grid_snapshot.d.ts.map +0 -1
  321. package/dist/market_adapter/utils/dynamic_grid_snapshot.js.map +0 -1
  322. package/dist/market_adapter/utils/file_lock.d.ts.map +0 -1
  323. package/dist/market_adapter/utils/file_lock.js.map +0 -1
  324. package/dist/market_adapter/utils/native_history.d.ts.map +0 -1
  325. package/dist/market_adapter/utils/native_history.js.map +0 -1
  326. package/dist/modules/account_bots.d.ts.map +0 -1
  327. package/dist/modules/account_bots.js.map +0 -1
  328. package/dist/modules/account_orders.d.ts.map +0 -1
  329. package/dist/modules/account_orders.js.map +0 -1
  330. package/dist/modules/authority_resolver.d.ts.map +0 -1
  331. package/dist/modules/authority_resolver.js.map +0 -1
  332. package/dist/modules/bitshares-native/chain_client.d.ts.map +0 -1
  333. package/dist/modules/bitshares-native/chain_client.js.map +0 -1
  334. package/dist/modules/bitshares-native/crypto/ecc.browser.d.ts.map +0 -1
  335. package/dist/modules/bitshares-native/crypto/ecc.browser.js.map +0 -1
  336. package/dist/modules/bitshares-native/crypto/ecc.d.ts.map +0 -1
  337. package/dist/modules/bitshares-native/crypto/ecc.js.map +0 -1
  338. package/dist/modules/bitshares-native/crypto/ecc_selector.d.ts.map +0 -1
  339. package/dist/modules/bitshares-native/crypto/ecc_selector.js.map +0 -1
  340. package/dist/modules/bitshares-native/index.d.ts.map +0 -1
  341. package/dist/modules/bitshares-native/index.js.map +0 -1
  342. package/dist/modules/bitshares-native/lru_cache.d.ts.map +0 -1
  343. package/dist/modules/bitshares-native/lru_cache.js.map +0 -1
  344. package/dist/modules/bitshares-native/resolvers.d.ts.map +0 -1
  345. package/dist/modules/bitshares-native/resolvers.js.map +0 -1
  346. package/dist/modules/bitshares-native/serial/chain_constants.d.ts.map +0 -1
  347. package/dist/modules/bitshares-native/serial/chain_constants.js.map +0 -1
  348. package/dist/modules/bitshares-native/serial/index.d.ts.map +0 -1
  349. package/dist/modules/bitshares-native/serial/index.js.map +0 -1
  350. package/dist/modules/bitshares-native/serial/operations.d.ts.map +0 -1
  351. package/dist/modules/bitshares-native/serial/operations.js.map +0 -1
  352. package/dist/modules/bitshares-native/serial/serializer.d.ts.map +0 -1
  353. package/dist/modules/bitshares-native/serial/serializer.js.map +0 -1
  354. package/dist/modules/bitshares-native/serial/types.d.ts.map +0 -1
  355. package/dist/modules/bitshares-native/serial/types.js.map +0 -1
  356. package/dist/modules/bitshares-native/signing_client.d.ts.map +0 -1
  357. package/dist/modules/bitshares-native/signing_client.js.map +0 -1
  358. package/dist/modules/bitshares-native/subscriptions.d.ts.map +0 -1
  359. package/dist/modules/bitshares-native/subscriptions.js.map +0 -1
  360. package/dist/modules/bitshares-native/transport.d.ts.map +0 -1
  361. package/dist/modules/bitshares-native/transport.js.map +0 -1
  362. package/dist/modules/bitshares-native/tx/builder.d.ts.map +0 -1
  363. package/dist/modules/bitshares-native/tx/builder.js.map +0 -1
  364. package/dist/modules/bitshares-native/tx/tx_cache.d.ts.map +0 -1
  365. package/dist/modules/bitshares-native/tx/tx_cache.js.map +0 -1
  366. package/dist/modules/bitshares_client.d.ts.map +0 -1
  367. package/dist/modules/bitshares_client.js.map +0 -1
  368. package/dist/modules/bot_defaults.d.ts.map +0 -1
  369. package/dist/modules/bot_defaults.js.map +0 -1
  370. package/dist/modules/bot_settings.d.ts.map +0 -1
  371. package/dist/modules/bot_settings.js.map +0 -1
  372. package/dist/modules/bots_file_lock.d.ts.map +0 -1
  373. package/dist/modules/bots_file_lock.js.map +0 -1
  374. package/dist/modules/broadcast_failure.d.ts.map +0 -1
  375. package/dist/modules/broadcast_failure.js.map +0 -1
  376. package/dist/modules/chain_keys.d.ts.map +0 -1
  377. package/dist/modules/chain_keys.js.map +0 -1
  378. package/dist/modules/chain_orders.d.ts.map +0 -1
  379. package/dist/modules/chain_orders.js.map +0 -1
  380. package/dist/modules/cli_colors.d.ts.map +0 -1
  381. package/dist/modules/cli_colors.js.map +0 -1
  382. package/dist/modules/cli_start_onboarding.d.ts.map +0 -1
  383. package/dist/modules/cli_start_onboarding.js.map +0 -1
  384. package/dist/modules/cli_start_output.d.ts.map +0 -1
  385. package/dist/modules/cli_start_output.js.map +0 -1
  386. package/dist/modules/config.d.ts.map +0 -1
  387. package/dist/modules/config.js.map +0 -1
  388. package/dist/modules/constants.d.ts.map +0 -1
  389. package/dist/modules/constants.js.map +0 -1
  390. package/dist/modules/cr_planner.d.ts.map +0 -1
  391. package/dist/modules/cr_planner.js.map +0 -1
  392. package/dist/modules/credential_policy.d.ts.map +0 -1
  393. package/dist/modules/credential_policy.js.map +0 -1
  394. package/dist/modules/credential_runtime.d.ts.map +0 -1
  395. package/dist/modules/credential_runtime.js.map +0 -1
  396. package/dist/modules/credential_session_cache.d.ts.map +0 -1
  397. package/dist/modules/credential_session_cache.js.map +0 -1
  398. package/dist/modules/credit_pricing.d.ts.map +0 -1
  399. package/dist/modules/credit_pricing.js.map +0 -1
  400. package/dist/modules/credit_runtime.d.ts.map +0 -1
  401. package/dist/modules/credit_runtime.js.map +0 -1
  402. package/dist/modules/crypto/browser_provider.d.ts.map +0 -1
  403. package/dist/modules/crypto/browser_provider.js.map +0 -1
  404. package/dist/modules/crypto/index.d.ts.map +0 -1
  405. package/dist/modules/crypto/index.js.map +0 -1
  406. package/dist/modules/crypto/node_provider.d.ts.map +0 -1
  407. package/dist/modules/crypto/node_provider.js.map +0 -1
  408. package/dist/modules/crypto/provider.d.ts.map +0 -1
  409. package/dist/modules/crypto/provider.js.map +0 -1
  410. package/dist/modules/crypto/pure_ripemd160.d.ts.map +0 -1
  411. package/dist/modules/crypto/pure_ripemd160.js.map +0 -1
  412. package/dist/modules/crypto/pure_scrypt.d.ts.map +0 -1
  413. package/dist/modules/crypto/pure_scrypt.js.map +0 -1
  414. package/dist/modules/crypto/pure_secp256k1.d.ts.map +0 -1
  415. package/dist/modules/crypto/pure_secp256k1.js.map +0 -1
  416. package/dist/modules/crypto/sync.d.ts.map +0 -1
  417. package/dist/modules/crypto/sync.js.map +0 -1
  418. package/dist/modules/daemon_node_health.d.ts.map +0 -1
  419. package/dist/modules/daemon_node_health.js.map +0 -1
  420. package/dist/modules/dexbot_class.d.ts.map +0 -1
  421. package/dist/modules/dexbot_class.js.map +0 -1
  422. package/dist/modules/dexbot_cow_runtime.d.ts.map +0 -1
  423. package/dist/modules/dexbot_cow_runtime.js.map +0 -1
  424. package/dist/modules/dexbot_credential_client.d.ts.map +0 -1
  425. package/dist/modules/dexbot_credential_client.js.map +0 -1
  426. package/dist/modules/dexbot_fill_runtime.d.ts.map +0 -1
  427. package/dist/modules/dexbot_fill_runtime.js.map +0 -1
  428. package/dist/modules/dexbot_maintenance_runtime.d.ts.map +0 -1
  429. package/dist/modules/dexbot_maintenance_runtime.js.map +0 -1
  430. package/dist/modules/dexbot_startup_runtime.d.ts.map +0 -1
  431. package/dist/modules/dexbot_startup_runtime.js.map +0 -1
  432. package/dist/modules/dexbot_state_recovery.d.ts.map +0 -1
  433. package/dist/modules/dexbot_state_recovery.js.map +0 -1
  434. package/dist/modules/env.d.ts.map +0 -1
  435. package/dist/modules/env.js.map +0 -1
  436. package/dist/modules/fund_registry.d.ts.map +0 -1
  437. package/dist/modules/fund_registry.js.map +0 -1
  438. package/dist/modules/general_settings.d.ts.map +0 -1
  439. package/dist/modules/general_settings.js.map +0 -1
  440. package/dist/modules/graceful_shutdown.d.ts.map +0 -1
  441. package/dist/modules/graceful_shutdown.js.map +0 -1
  442. package/dist/modules/grid_price_source.d.ts.map +0 -1
  443. package/dist/modules/grid_price_source.js.map +0 -1
  444. package/dist/modules/key_store.d.ts.map +0 -1
  445. package/dist/modules/key_store.js.map +0 -1
  446. package/dist/modules/launcher/adapter_requirement.d.ts.map +0 -1
  447. package/dist/modules/launcher/adapter_requirement.js.map +0 -1
  448. package/dist/modules/launcher/bot_supervisor.d.ts.map +0 -1
  449. package/dist/modules/launcher/bot_supervisor.js.map +0 -1
  450. package/dist/modules/launcher/child_env.d.ts.map +0 -1
  451. package/dist/modules/launcher/child_env.js.map +0 -1
  452. package/dist/modules/launcher/credential_bootstrap.d.ts.map +0 -1
  453. package/dist/modules/launcher/credential_bootstrap.js.map +0 -1
  454. package/dist/modules/launcher/credential_daemon.d.ts.map +0 -1
  455. package/dist/modules/launcher/credential_daemon.js.map +0 -1
  456. package/dist/modules/launcher/credential_secret.d.ts.map +0 -1
  457. package/dist/modules/launcher/credential_secret.js.map +0 -1
  458. package/dist/modules/launcher/foreign_cred_daemon.d.ts.map +0 -1
  459. package/dist/modules/launcher/foreign_cred_daemon.js.map +0 -1
  460. package/dist/modules/launcher/headless_password.d.ts.map +0 -1
  461. package/dist/modules/launcher/headless_password.js.map +0 -1
  462. package/dist/modules/launcher/launch_modes.d.ts.map +0 -1
  463. package/dist/modules/launcher/launch_modes.js.map +0 -1
  464. package/dist/modules/launcher/market_adapter_runtime.d.ts.map +0 -1
  465. package/dist/modules/launcher/market_adapter_runtime.js.map +0 -1
  466. package/dist/modules/launcher/market_adapter_watchdog.d.ts.map +0 -1
  467. package/dist/modules/launcher/market_adapter_watchdog.js.map +0 -1
  468. package/dist/modules/launcher/monolithic_runtime.d.ts.map +0 -1
  469. package/dist/modules/launcher/monolithic_runtime.js.map +0 -1
  470. package/dist/modules/launcher/runtime_entry.d.ts.map +0 -1
  471. package/dist/modules/launcher/runtime_entry.js.map +0 -1
  472. package/dist/modules/launcher/status_reporting.d.ts.map +0 -1
  473. package/dist/modules/launcher/status_reporting.js.map +0 -1
  474. package/dist/modules/launcher/supervisor_control.d.ts.map +0 -1
  475. package/dist/modules/launcher/supervisor_control.js.map +0 -1
  476. package/dist/modules/market_adapter_whitelist.d.ts.map +0 -1
  477. package/dist/modules/market_adapter_whitelist.js.map +0 -1
  478. package/dist/modules/node_connect_policy.d.ts.map +0 -1
  479. package/dist/modules/node_connect_policy.js.map +0 -1
  480. package/dist/modules/node_failure_ledger.d.ts.map +0 -1
  481. package/dist/modules/node_failure_ledger.js.map +0 -1
  482. package/dist/modules/node_health_cache.d.ts.map +0 -1
  483. package/dist/modules/node_health_cache.js.map +0 -1
  484. package/dist/modules/node_manager.d.ts.map +0 -1
  485. package/dist/modules/node_manager.js.map +0 -1
  486. package/dist/modules/order/accounting.d.ts.map +0 -1
  487. package/dist/modules/order/accounting.js.map +0 -1
  488. package/dist/modules/order/async_lock.d.ts.map +0 -1
  489. package/dist/modules/order/async_lock.js.map +0 -1
  490. package/dist/modules/order/export.d.ts.map +0 -1
  491. package/dist/modules/order/export.js.map +0 -1
  492. package/dist/modules/order/format.d.ts.map +0 -1
  493. package/dist/modules/order/format.js.map +0 -1
  494. package/dist/modules/order/grid.d.ts.map +0 -1
  495. package/dist/modules/order/grid.js.map +0 -1
  496. package/dist/modules/order/grid_reconcile.d.ts.map +0 -1
  497. package/dist/modules/order/grid_reconcile.js.map +0 -1
  498. package/dist/modules/order/grid_reconcile_internal.d.ts.map +0 -1
  499. package/dist/modules/order/grid_reconcile_internal.js.map +0 -1
  500. package/dist/modules/order/index.d.ts.map +0 -1
  501. package/dist/modules/order/index.js.map +0 -1
  502. package/dist/modules/order/logger.d.ts.map +0 -1
  503. package/dist/modules/order/logger.js.map +0 -1
  504. package/dist/modules/order/logger_state.d.ts.map +0 -1
  505. package/dist/modules/order/logger_state.js.map +0 -1
  506. package/dist/modules/order/manager.d.ts.map +0 -1
  507. package/dist/modules/order/manager.js.map +0 -1
  508. package/dist/modules/order/processed_fill_store.d.ts.map +0 -1
  509. package/dist/modules/order/processed_fill_store.js.map +0 -1
  510. package/dist/modules/order/strategy.d.ts.map +0 -1
  511. package/dist/modules/order/strategy.js.map +0 -1
  512. package/dist/modules/order/sync_engine.d.ts.map +0 -1
  513. package/dist/modules/order/sync_engine.js.map +0 -1
  514. package/dist/modules/order/utils/math.d.ts.map +0 -1
  515. package/dist/modules/order/utils/math.js.map +0 -1
  516. package/dist/modules/order/utils/order.d.ts.map +0 -1
  517. package/dist/modules/order/utils/order.js.map +0 -1
  518. package/dist/modules/order/utils/slot.d.ts.map +0 -1
  519. package/dist/modules/order/utils/slot.js.map +0 -1
  520. package/dist/modules/order/utils/system.d.ts.map +0 -1
  521. package/dist/modules/order/utils/system.js.map +0 -1
  522. package/dist/modules/order/utils/timeout.d.ts.map +0 -1
  523. package/dist/modules/order/utils/timeout.js.map +0 -1
  524. package/dist/modules/order/utils/validate.d.ts.map +0 -1
  525. package/dist/modules/order/utils/validate.js.map +0 -1
  526. package/dist/modules/order/utils/withPoolRef.d.ts.map +0 -1
  527. package/dist/modules/order/utils/withPoolRef.js.map +0 -1
  528. package/dist/modules/order/working_grid.d.ts.map +0 -1
  529. package/dist/modules/order/working_grid.js.map +0 -1
  530. package/dist/modules/path_api.d.ts.map +0 -1
  531. package/dist/modules/path_api.js.map +0 -1
  532. package/dist/modules/paths.d.ts.map +0 -1
  533. package/dist/modules/paths.js.map +0 -1
  534. package/dist/modules/process_discovery.d.ts.map +0 -1
  535. package/dist/modules/process_discovery.js.map +0 -1
  536. package/dist/modules/runtime.d.ts.map +0 -1
  537. package/dist/modules/runtime.js.map +0 -1
  538. package/dist/modules/runtime_settings.d.ts.map +0 -1
  539. package/dist/modules/runtime_settings.js.map +0 -1
  540. package/dist/modules/settings_merge.d.ts.map +0 -1
  541. package/dist/modules/settings_merge.js.map +0 -1
  542. package/dist/modules/socket_json_client.d.ts.map +0 -1
  543. package/dist/modules/socket_json_client.js.map +0 -1
  544. package/dist/modules/storage/browser_adapter.d.ts.map +0 -1
  545. package/dist/modules/storage/browser_adapter.js.map +0 -1
  546. package/dist/modules/storage/index.d.ts.map +0 -1
  547. package/dist/modules/storage/index.js.map +0 -1
  548. package/dist/modules/storage/node_adapter.d.ts.map +0 -1
  549. package/dist/modules/storage/node_adapter.js.map +0 -1
  550. package/dist/modules/storage/types.d.ts.map +0 -1
  551. package/dist/modules/storage/types.js.map +0 -1
  552. package/dist/modules/types.d.ts.map +0 -1
  553. package/dist/modules/types.js.map +0 -1
  554. package/dist/modules/utils/base58check.d.ts.map +0 -1
  555. package/dist/modules/utils/base58check.js.map +0 -1
  556. package/dist/modules/utils/build_dir.d.ts.map +0 -1
  557. package/dist/modules/utils/build_dir.js.map +0 -1
  558. package/dist/modules/utils/chain_logs.d.ts.map +0 -1
  559. package/dist/modules/utils/chain_logs.js.map +0 -1
  560. package/dist/modules/utils/errors.d.ts.map +0 -1
  561. package/dist/modules/utils/errors.js.map +0 -1
  562. package/dist/modules/utils/sanitize_key.d.ts.map +0 -1
  563. package/dist/modules/utils/sanitize_key.js.map +0 -1
  564. package/dist/modules/utils/text_width.d.ts.map +0 -1
  565. package/dist/modules/utils/text_width.js.map +0 -1
  566. package/dist/modules/validate_profiles.d.ts.map +0 -1
  567. package/dist/modules/validate_profiles.js.map +0 -1
  568. package/dist/pm2.d.ts.map +0 -1
  569. package/dist/pm2.js.map +0 -1
  570. package/dist/scripts/analyze-credit.d.ts.map +0 -1
  571. package/dist/scripts/analyze-credit.js.map +0 -1
  572. package/dist/scripts/analyze-git.d.ts.map +0 -1
  573. package/dist/scripts/analyze-git.js.map +0 -1
  574. package/dist/scripts/analyze-orders.d.ts.map +0 -1
  575. package/dist/scripts/analyze-orders.js.map +0 -1
  576. package/dist/scripts/chart_command.d.ts.map +0 -1
  577. package/dist/scripts/chart_command.js.map +0 -1
  578. package/dist/scripts/diagnose-kibana-candles.d.ts.map +0 -1
  579. package/dist/scripts/diagnose-kibana-candles.js.map +0 -1
  580. package/dist/scripts/diagnose-pool-history.d.ts.map +0 -1
  581. package/dist/scripts/diagnose-pool-history.js.map +0 -1
  582. package/dist/scripts/divergence-calc.d.ts.map +0 -1
  583. package/dist/scripts/divergence-calc.js.map +0 -1
  584. package/dist/scripts/dw.d.ts.map +0 -1
  585. package/dist/scripts/dw.js.map +0 -1
  586. package/dist/scripts/generate_lp_chart.d.ts.map +0 -1
  587. package/dist/scripts/generate_lp_chart.js.map +0 -1
  588. package/dist/scripts/generate_mainnet_corpus_report.d.ts.map +0 -1
  589. package/dist/scripts/generate_mainnet_corpus_report.js.map +0 -1
  590. package/dist/scripts/native_release_gates.d.ts.map +0 -1
  591. package/dist/scripts/native_release_gates.js.map +0 -1
  592. package/dist/scripts/print_grid.d.ts.map +0 -1
  593. package/dist/scripts/print_grid.js.map +0 -1
  594. package/dist/scripts/run-tests.d.ts.map +0 -1
  595. package/dist/scripts/run-tests.js.map +0 -1
  596. package/dist/scripts/runner.d.ts.map +0 -1
  597. package/dist/scripts/runner.js.map +0 -1
  598. package/dist/scripts/sync-version.d.ts.map +0 -1
  599. package/dist/scripts/sync-version.js.map +0 -1
  600. package/dist/scripts/test-credit-renewal.d.ts.map +0 -1
  601. package/dist/scripts/test-credit-renewal.js.map +0 -1
  602. package/dist/scripts/tv.d.ts.map +0 -1
  603. package/dist/scripts/tv.js.map +0 -1
  604. package/dist/scripts/update.d.ts.map +0 -1
  605. package/dist/scripts/update.js.map +0 -1
  606. package/dist/scripts/update_dist_freshness.d.ts.map +0 -1
  607. package/dist/scripts/update_dist_freshness.js.map +0 -1
  608. package/dist/scripts/validate_bots.d.ts.map +0 -1
  609. package/dist/scripts/validate_bots.js.map +0 -1
  610. package/dist/scripts/verify-browser-bundle.d.ts.map +0 -1
  611. package/dist/scripts/verify-browser-bundle.js.map +0 -1
  612. package/dist/unlock.d.ts.map +0 -1
  613. package/dist/unlock.js.map +0 -1
package/dist/unlock.js CHANGED
@@ -51,6 +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, flushVersionStatus, printVersionStatusWhenReady } from './modules/version_notice.js';
54
55
  import { buildRuntimeScriptArgs } from './modules/launcher/runtime_entry.js';
55
56
  import { sendControlCommand } from './modules/launcher/supervisor_control.js';
56
57
  import { registerCleanup, setupGracefulShutdown } from './modules/graceful_shutdown.js';
@@ -134,6 +135,11 @@ function printLauncherSuccess({ botName = null, clawOnly = false, isolated = fal
134
135
  console.log('='.repeat(50));
135
136
  console.log();
136
137
  }
138
+ /**
139
+ * Print the pending "new version available" notice, if there is one.
140
+ * Awaited at every terminal launcher path because `process.exit()` would
141
+ * otherwise truncate the in-flight registry request.
142
+ */
137
143
  function makeFinishGuard(cleanup) {
138
144
  let settled = false;
139
145
  let timer = null;
@@ -463,6 +469,18 @@ async function main({ argv = process.argv, startupGraceMs = DEFAULT_STARTUP_GRAC
463
469
  }
464
470
  if (!isInternalChild)
465
471
  printRelocationNotices();
472
+ // Kick off the passive version check now and await it only at the terminal
473
+ // paths below. It reports the installed version against the published
474
+ // latest — green when current, orange when a newer release exists — and
475
+ // appends the one-time `dexbot update` hint. The password prompt and
476
+ // daemon startup that follow take seconds, which hides the registry
477
+ // round-trip entirely. The promise never rejects and resolves to null when
478
+ // the check is disabled.
479
+ // Internal children (detached supervisor, monolithic bg) stay silent: they
480
+ // would re-probe and re-print a notice the launcher already handled. A
481
+ // --dryrun is a side-effect-free validation, so it never probes or writes
482
+ // the cache either.
483
+ const versionStatus = (isInternalChild || dryrun) ? Promise.resolve(null) : startVersionStatusCheck();
466
484
  let effectiveBotName = botName;
467
485
  if (creditOnly && !effectiveBotName) {
468
486
  const creditBots = listConfiguredBots().filter((b) => b.creditOnly === true && b.active !== false);
@@ -487,6 +505,7 @@ async function main({ argv = process.argv, startupGraceMs = DEFAULT_STARTUP_GRAC
487
505
  printLauncherHeader({ botName: effectiveBotName || botName, clawOnly, creditOnly, isolated, dryrun, headless });
488
506
  console.log(`DEXBot2 already running in background (PID ${pid}).`);
489
507
  console.log('Use `dexbot stat` to inspect it, or `dexbot restart` to restart it.');
508
+ await flushVersionStatus(versionStatus);
490
509
  process.exitCode = 0;
491
510
  return;
492
511
  }
@@ -546,6 +565,7 @@ async function main({ argv = process.argv, startupGraceMs = DEFAULT_STARTUP_GRAC
546
565
  if (pid > 0) {
547
566
  console.log(`DEXBot2 already running in background (PID ${pid}).`);
548
567
  console.log('Use `dexbot stat` to inspect it, or `dexbot restart` to restart it.');
568
+ await flushVersionStatus(versionStatus);
549
569
  process.exitCode = 0;
550
570
  return;
551
571
  }
@@ -588,16 +608,22 @@ async function main({ argv = process.argv, startupGraceMs = DEFAULT_STARTUP_GRAC
588
608
  child.unref();
589
609
  storage.writeFile(MONOLITHIC_PID_FILE, String(child.pid), { mode: 0o600 });
590
610
  printLauncherStartupSummary({ botNames: launchedBotNames, mode: 'background' });
611
+ await flushVersionStatus(versionStatus);
591
612
  process.exit(0);
592
613
  }
593
614
  if (clawOnly) {
594
615
  printLauncherSuccess({ clawOnly });
616
+ await flushVersionStatus(versionStatus);
595
617
  const exitCode = await controller.waitForManagedDaemon();
596
618
  process.exitCode = exitCode || 0;
597
619
  return;
598
620
  }
599
621
  if (isolated) {
600
622
  if (isDetachedSupervisorChild || forceForegroundIsolated) {
623
+ // Never delay the bot launch on the probe: this branch stays
624
+ // resident for the bot's lifetime, so print when the probe
625
+ // settles instead of awaiting it before supervisor.start().
626
+ printVersionStatusWhenReady(versionStatus);
601
627
  process.exitCode = await runIsolated({
602
628
  botName: botName ?? undefined,
603
629
  botEntry: selectedBot,
@@ -616,6 +642,7 @@ async function main({ argv = process.argv, startupGraceMs = DEFAULT_STARTUP_GRAC
616
642
  console.log(`Supervisor PID: ${supervisorPid}`);
617
643
  console.log(`Control socket: ${Config.DEXBOT_SUPERVISOR_SOCKET || SOCKET_PATH}`);
618
644
  console.log(`Supervisor logs: ${SUPERVISOR_OUT_LOG}`);
645
+ await flushVersionStatus(versionStatus);
619
646
  process.exitCode = 0;
620
647
  return;
621
648
  }
@@ -688,6 +715,7 @@ async function main({ argv = process.argv, startupGraceMs = DEFAULT_STARTUP_GRAC
688
715
  if (!updater?.pendingRestart) {
689
716
  if (!isMonolithicBgChild) {
690
717
  printLauncherStartupSummary({ botNames: launchedBotNames, mode: 'foreground' });
718
+ await flushVersionStatus(versionStatus);
691
719
  }
692
720
  }
693
721
  const onSigint = () => forwardSignal(botProcess, 'SIGINT');
@@ -492,9 +492,16 @@ overrides the location entirely.
492
492
  | `dexbot-adapter.log` / `dexbot-adapter-error.log` | Market adapter managed by the runtime |
493
493
  | `market_adapter.log` | Standalone adapter mode |
494
494
  | `dexbot-update.log` / `dexbot-update-error.log` | Auto-updater |
495
+ | `daemon-audit.jsonl` | Credential daemon audit trail (`sign_denied` and friends) |
495
496
 
496
497
  See [LOGGING.md](LOGGING.md) for log levels, rotation, and JSON output.
497
- `dexbot clear` empties the logs directory wherever it resolves.
498
+ `dexbot clear` empties the logs directory wherever it resolves: every `*.log`, rotated
499
+ `*.log.N` and `*.jsonl*` — so the credential-daemon audit trail
500
+ (`daemon-audit.jsonl` and its rotated siblings) goes too; the preview names it.
501
+ Stop the runtime first (`dexbot stop`): a running daemon keeps writing to the
502
+ unlinked files, so the space is only freed on restart, and the scripts warn you
503
+ when they detect a live runtime. Siblings: `clear-orders`, `clear-market-adapter`,
504
+ `clear-all`.
498
505
 
499
506
  ### "I forgot the master password"
500
507
 
@@ -69,7 +69,7 @@ This document defines the non-negotiable behavioral invariants for the DEXBot2 s
69
69
  - A hold run carrying fresh fills (>= `TIMING.BOUNDARY_HOLD_RESYNC_THRESHOLD`) requests a guard-aware structural re-center (`requestStructuralGridResync`, cooldown `TIMING.BOUNDARY_HOLD_RESYNC_COOLDOWN_MS`) instead of holding forever — the heal path when the grid is trailing the market.
70
70
 
71
71
  - `INV-COW-008` Owed fill crawls survive unapplied commits
72
- - `order/strategy.ts` records a crawl per shift-eligible fill at intake (slot-level dedupe, capped at 500); `deriveTargetBoundary` folds still-owed `_pendingFillCrawls` into the next derivation, excluding the current batch's slots and reserve slots.
72
+ - `order/strategy.ts` records a crawl per shift-eligible fill at intake (slot-level dedupe, capped at 500); `deriveTargetBoundary` folds still-owed `_pendingFillCrawls` into the next derivation, excluding the current batch's slots, reserve slots, and window members — a window that reaches the grid edge is not a reserve, using the same window exclusion every placement picker and `countLiveReserveOrders` apply.
73
73
  - `_commitWorkingGrid` clears them only when the plan's boundary was actually applied — a held boundary (`boundaryHeld`), a gate-rejected boundary, and a null boundary all leave them owed.
74
74
  - `consumePendingFillCrawls` applies them onto a restored finite boundary; `applyPersistedPendingCrawls` is the shared startup/recovery wrapper used before sync/reconcile; `_clearPendingFillCrawls` drops them when the boundary is re-anchored (grid rebuild via `initializeGrid`, rejected snapshot via `rejectCorruptedGridSnapshot`, persisted snapshot wipe via `AccountOrders.clearGrid`).
75
75
 
@@ -208,7 +208,8 @@ This document defines the non-negotiable behavioral invariants for the DEXBot2 s
208
208
  - Enforced at all six emission sites (CREATE / UPDATE / CREATE-FALLBACK, RECONCILE-CREATE / RECONCILE-UPDATE, STARTUP-CREATE): an off-grid emission is blocked, never broadcast.
209
209
  - Range guards (`isChainPriceOutOfGrid`) are bounds checks, not membership checks — they cannot substitute for this invariant.
210
210
  - Adoption keeps the slot's own level (a fill/chain price is metadata, not the slot's price); `loadGrid` repairs a pre-existing off-grid slot price at load.
211
- - Tests: GPI-001..015 (`tests/test_grid_price_invariant_guard.ts`), GPI-WIRE-001..009 (`tests/test_grid_price_invariant_wiring.ts`), LEGACY-ADOPT/MATERIALIZE/ADOPT-NAME (`tests/test_sync_out_of_grid_defer.ts`).
211
+ - A snapshot carrying orders but no usable ladder is **refused** before any mutation (`loadGrid`, before the startup resume decision, and at the persisted-row schema), and the sync entry refuses to reconcile a ladder-less grid at all — without a ladder no consumer has authority for a slot's price, which is what this invariant exists to prevent. The tolerance matcher that used to cover that state has been removed. `config.gridLimits.MISSING_GENESIS_POLICY` picks the response: `'rebuild'` (default, structural resync) or `'halt'` (manual reset). One decision, one module: `modules/order/genesis_policy.ts`.
212
+ - Tests: GPI-001..015 (`tests/test_grid_price_invariant_guard.ts`), GPI-WIRE-001..009 (`tests/test_grid_price_invariant_wiring.ts`), LEGACY-ADOPT/MATERIALIZE/ADOPT-NAME (`tests/test_sync_out_of_grid_defer.ts`), GEN-01..21 (`tests/test_missing_genesis_policy.ts`).
212
213
 
213
214
  ---
214
215
 
@@ -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.7).
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.8).
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.7 |
39
+ | **Release Track** | 1.0.0 | v1.6.8 |
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.7 |
779
+ | **Release Track** | 1.0.0 | v1.6.8 |
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) |
@@ -882,7 +882,7 @@ The 500× figure is not theoretical: it materializes in production when higher o
882
882
  | **Security** | ★★★☆☆ | ★★★★★ (AES-256-GCM, credential daemon, authority resolution) | DEXBot2 |
883
883
  | **Ease of Setup** | ★★☆☆☆ (PyQt5/PyInstaller/Systemd dependency hell) | ★★★★★ (`npm i -g dexbot`, zero deps) | DEXBot2 |
884
884
  | **Accessibility** | ★★★★★ (GUI) | ★★☆☆☆ (CLI only) | DEXBot |
885
- | **Testing Depth** | ★★★☆☆ | ★★★★★ (256 test files; focused regressions) | DEXBot2 |
885
+ | **Testing Depth** | ★★★☆☆ | ★★★★★ (305 test files; focused regressions) | DEXBot2 |
886
886
  | **Documentation** | ★★★☆☆ | ★★★★★ (architecture/accounting/security/adapter docs) | DEXBot2 |
887
887
  | **Dependency Footprint** | ★★☆☆☆ (heavy) | ★★★★★ (0 runtime deps) | DEXBot2 |
888
888
  | **Extensibility** | ★★★★★ (plugins) | ★☆☆☆☆ | DEXBot |
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.7 stable release.
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.8 release.
6
6
 
7
7
  ### Key Milestones
8
8
  - **Project Inception**: December 2, 2025
9
- - **Growth Phase**: 2,277 commits over ~9 active months
9
+ - **Growth Phase**: 2,300 commits over ~9 active months
10
10
  - **Code Maturity**: Evolution from basic utilities to a ~100,000+ LoC intelligent TypeScript system
11
- - **Stability**: Progression from manual testing to a suite of 297 automated test files
12
- - **Releases**: 139 version entries in the changelog (v0.1.0 to v1.6.7)
11
+ - **Stability**: Progression from manual testing to a suite of 305 automated test files
12
+ - **Releases**: 140 version entries in the changelog (v0.1.0 to v1.6.8)
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,27 +149,28 @@ 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. 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).
152
+ Compact, era-level view; commit counts are `git rev-list --count <tag>..<tag>` over the current history (2026-09-28), so the column sums to 2,194 — the 106 commits before the `v0.1.0` tag are not attributed to an era (2,194 + 106 = 2,300). 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
  |-----|--------:|-------|
156
- | v0.1.0 → v0.6.0 | 1,217 | Foundation → COW architecture, strategy/sync engine, credential daemon, AMA prototype, credit/MPA runtime |
157
- | v0.6.0 → v1.0.0 | 309 | Zero-dependency & TS migration, native BitShares, fill-detection overhaul, first stable release |
158
- | v1.0.0 → v1.3.3 | 199 | Post-stable hardening, PnL analytics, auto-update, broadcast-deadlock fixes, AMA refits, credit-only mode, COW recovery hardening, runtime extraction |
159
- | v1.3.3 → v1.4.13 | 119 | CJS→ESM completion, concurrency correction, uncertain-broadcast & truncated-read safety, native ESM runtime, broadcast serialization, onboarding |
160
- | v1.4.13 → v1.4.25 | 101 | Profile-state centralization, consolidation, per-broadcast op cap, grid boundary/recovery hardening, tsx removal, genesis-frozen price-slots, self-trade & orphan fixes |
161
- | v1.4.25 → v1.5.3 | 40 | Credit overview + whitelist-scoped CR, TradingView tooling, daemon-safe reload, gap-evacuation/rail-hole hardening, sync adoption hardening, boundary ownership |
162
- | v1.5.3 → v1.6.0 | 37 | Node-failure ledger, grid regeneration, reserve ladder, live-config pickup, owed-crawl persistence, fill-anchored boundary recovery, TradingView overlay |
163
- | v1.6.0 → v1.6.3 | 12 | 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 | 18 | Fund-driven spread correction, gapSlots+1 batch cap, VIRTUAL RMS divergence, sync-lock log fix, invariant-doc contract, analysis shared modules, window-aware profitability annualisation, portable chart exports, range-threshold restore, dead-code purge, doc consolidation |
165
- | v1.6.4 → v1.6.5 | 15 | Editor-managed whitelist flags + legacy generator removal, centralized bot defaults/settings docs, log-symmetric range-scaling tilt, AMA gridPrice default + unset → startPrice normalization, Pool default/warn-color cues, Grid Health AMA-slope Δ knob, dynamic-weight chart CLI, update dist-freshness self-heal, launcher worker rename, RMS log tagging |
156
+ | v0.1.0 → v0.6.0 | 892 | Foundation → COW architecture, strategy/sync engine, credential daemon, AMA prototype, credit/MPA runtime |
157
+ | v0.6.0 → v1.0.0 | 650 | Zero-dependency & TS migration, native BitShares, fill-detection overhaul, first stable release |
158
+ | v1.0.0 → v1.3.3 | 210 | Post-stable hardening, PnL analytics, auto-update, broadcast-deadlock fixes, AMA refits, credit-only mode, COW recovery hardening, runtime extraction |
159
+ | v1.3.3 → v1.4.13 | 141 | CJS→ESM completion, concurrency correction, uncertain-broadcast & truncated-read safety, native ESM runtime, broadcast serialization, onboarding |
160
+ | v1.4.13 → v1.4.25 | 129 | Profile-state centralization, consolidation, per-broadcast op cap, grid boundary/recovery hardening, tsx removal, genesis-frozen price-slots, self-trade & orphan fixes |
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
+ | 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
+ | 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, gapSlots+1 batch cap, VIRTUAL RMS divergence, sync-lock log fix, invariant-doc contract, analysis shared modules, window-aware profitability annualisation, portable chart exports, range-threshold restore, dead-code purge, doc consolidation |
165
+ | v1.6.4 → v1.6.5 | 16 | Editor-managed whitelist flags + legacy generator removal, centralized bot defaults/settings docs, log-symmetric range-scaling tilt, AMA gridPrice default + unset → startPrice normalization, Pool default/warn-color cues, Grid Health AMA-slope Δ knob, dynamic-weight chart CLI, update dist-freshness self-heal, launcher worker rename, RMS log tagging |
166
166
  | v1.6.5 → v1.6.6 | 13 | Stale-cancellation guard hardening (live ownership, per-plan startup revalidation, COW orphan protection, settlement safety), editor label/menu realignment + colored bot list, grouped CLI help, poolRef aliases + startPrice priority, legacy SMA/MACD/RSI analyzer archived, run-relative candle-cache migration dropped, update dist-freshness tsconfig-exclude fix |
167
- | v1.6.6 → v1.6.7 | 10 | Native session/fill-channel recovery (dead-but-open forced reconnect, stale api_id self-heal, COW stale-plan recheck) + clean-process ecosystem regen, `dexbot start` onboarding redirect, key-manager cancellation + empty-vault onboarding link, LAST-FILL-GUARD pivot persistence (provenance-gated snapshot mirror, genesis-bound + TTL + on-grid restore with the boundary, centralized writer, generation invalidation mirroring the owed-crawl ledger), PM2 log-capture restore + `pm2-logrotate` enablement, correction-drain budget + broadcast-region timer/fill deferral (bounded `_gridLock` hold, backlog alarm, stale-flag-safe maintenance deferral, defer bound tied to the watchdog, per-group create yield) |
167
+ | v1.6.6 → v1.6.7 | 11 | Native session/fill-channel recovery (dead-but-open forced reconnect, stale api_id self-heal, COW stale-plan recheck) + clean-process ecosystem regen, `dexbot start` onboarding redirect, key-manager cancellation + empty-vault onboarding link, LAST-FILL-GUARD pivot persistence (provenance-gated snapshot mirror, genesis-bound + TTL + on-grid restore with the boundary, centralized writer, generation invalidation mirroring the owed-crawl ledger) |
168
+ | v1.6.7 → v1.6.8 | 12 | Correction-drain budget + broadcast-region timer/fill deferral (bounded `_gridLock` hold, backlog alarm, stale-flag-safe maintenance deferral, defer bound tied to the watchdog, per-group create yield) and its wall-clock follow-up, PM2 log-capture restore + `pm2-logrotate` enablement, passive new-version notice (bounded registry probe, notify-once latch committed only on display, install-kind hint, independent NOTICE kill switches) + review hardening (dryrun silence, status timeout, latch regression guard, terminal-path flushes, non-blocking print on the isolated-foreground launch path, AbortController-independent hard timeout backstop, centralized flush), changelog-gap close + stale-reference realignment, the genesis-less-snapshot refusal (ladder required at load; `MISSING_GENESIS_POLICY` rebuild/halt, sync-entry assert, persisted-row schema gate), and reserve window-exclusion classification (window members no longer read as reserves at any no-crawl/refill-wire site; legacy numeric `reserveOrders` read-time migration; retained-vs-dropped crawl log fix; shared rail-center helper), plus the legacy tolerance-matcher removal (frozen ladder the only price authority), the npm-tarball trim (explicit analysis asset list, sourcemaps dropped, test sources excluded, legacy Kalman suites rewired into `test:legacy`), the AMA grid-reset replay in the bot charts (with the slope-baseline, non-positive-threshold and config read-back runtime fixes), the `kalS%` default bump (1.0 → 1.11), the incremental/bounded Kibana tail refresh (timestamped coverage, per-gap settle horizon, gap merging, span cap, 48h ceiling), and the 1.4x range-threshold widening |
168
169
 
169
170
  ---
170
171
 
171
172
  **Report Originally Generated**: February 19, 2026
172
- **Last Updated**: September 26, 2026
173
- **Total Commits**: 2,287
174
- **Date Range**: December 2, 2025 – September 26, 2026
173
+ **Last Updated**: September 28, 2026
174
+ **Total Commits**: 2,300
175
+ **Date Range**: December 2, 2025 – September 28, 2026
175
176
  **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.7 release*
804
+ *Technical Reference for DEXBot2 v1.6.8 release*
@@ -232,26 +232,27 @@ adopt into `slot--17` (via `slotIndexForPrice`) and **let the slot keep
232
232
  placed*; it is not the slot's price, and it disappears on the next
233
233
  rotation/cancel.
234
234
 
235
- This is what the genesis path (`adoptChainOrderIntoSlot`) already did — it sets
236
- `orderId`, `state`, `size`, `rawOnChain` and **never touches `price`**. The
237
- legacy fallback was the only path that got it wrong; it now matches.
238
-
239
- **Both paths now state this explicitly, and warn when it is broken.** Keeping
240
- the slot's price by *not assigning it* is correct but invisible: nothing would
241
- catch a later edit that reintroduced `price: chainOrder.price`, and nothing
242
- would catch a slot whose price was **already** corrupted before it reached
243
- adoption — it would simply be re-adopted. `adoptedSlotKeepsItsOwnPrice` runs on
244
- both paths and warns, naming the path, slot, expected level and drift, when an
245
- adopted slot's price is not its genesis level.
235
+ This is what `adoptChainOrderIntoSlot` does — it sets `orderId`, `state`,
236
+ `size`, `rawOnChain` and **never touches `price`**. It used to be stated on two
237
+ paths (the no-genesis legacy fallback got it wrong); the legacy path is gone, so
238
+ there is now exactly one adoption path.
239
+
240
+ **The rule is stated explicitly, and warns when it is broken.** Keeping the
241
+ slot's price by *not assigning it* is correct but invisible: nothing would catch
242
+ a later edit that reintroduced `price: chainOrder.price`, and nothing would
243
+ catch a slot whose price was **already** corrupted before it reached adoption —
244
+ it would simply be re-adopted. `adoptedSlotKeepsItsOwnPrice` runs on adoption
245
+ and warns, naming the slot, expected level and drift, when an adopted slot's
246
+ price is not its genesis level. A manager with no ladder is a fault, not a
247
+ pass: the check reports it rather than waving the adoption through.
246
248
 
247
249
  That check is deliberately **non-blocking**: the chain order is real and must be
248
250
  tracked, so refusing the adoption would strand it untracked on the book —
249
251
  strictly worse than the corrupt slot it reports. It is a signal, not a gate.
250
252
 
251
- Note the two adoption paths are covered separately, because a fixture with a
252
- genesis takes the genesis path and a fixture without one takes the legacy
253
- fallback: LEGACY-ADOPT-001 covers the legacy path, ADOPT-NAME-001 the genesis
254
- path. Each is mutation-tested against its own path.
253
+ ADOPT-001 pins the rule on the nearest-slot path with a resting price that is
254
+ clearly off the level, and ADOPT-NAME-001 pins that a correct adoption does not
255
+ warn.
255
256
 
256
257
  ## Healing a pre-existing off-grid slot price
257
258
 
@@ -279,11 +280,11 @@ assertion.
279
280
  ### After a repair: expect one churn cycle
280
281
 
281
282
  A repair changes `slot.price`, so any *resting* order still sitting at the old
282
- corrupt price no longer matches its slot. It resolves on the next reconcile via
283
- price-drift auto-cancel, which means **one cycle of cancel/replace churn after a
284
- repair is expected, not a new fault**. Operators seeing a burst of cancels
285
- immediately following a `[GENESIS] Slot … price repaired from genesis` line are
286
- watching the repair settle.
283
+ corrupt price now maps to a different ladder level than its slot. Pass 1 queues
284
+ it as a price mismatch and the correction re-prices it onto the slot, so **one
285
+ cycle of churn after a repair is expected, not a new fault**. Operators seeing
286
+ a burst of corrections immediately following a `[GENESIS] Slot … price repaired
287
+ from genesis` line are watching the repair settle.
287
288
 
288
289
  ### Repair only runs at load — so a persistent rejection escalates
289
290
 
@@ -307,11 +308,11 @@ not "rejected N times ever".
307
308
 
308
309
  **Why not heal in place** (`slot.price = expected` at rejection time): the
309
310
  checker does compute the right value, but silently rewriting it destroys the
310
- diagnostic signal. The streak is what distinguishes the four corruption sources
311
- — legacy persisted state, migration fallback, genesis-identity mismatch, or an
312
- unknown live writer. Auto-heal makes all four look identical. Count first,
313
- escalate on persistence; consider an in-place fast path only after a soak shows
314
- in-process corruption is the common case.
311
+ diagnostic signal. The streak is what distinguishes the corruption sources —
312
+ a pre-ladder snapshot, the ladder-migration cross-check, a genesis-identity
313
+ mismatch, or an unknown live writer. Auto-heal makes them all look identical.
314
+ Count first, escalate on persistence; consider an in-place fast path only after a
315
+ soak shows in-process corruption is the common case.
315
316
 
316
317
  The streak is **bot-scoped**, not module-scoped: the monolithic runtime
317
318
  (`dexbot.ts`) runs every active bot in one process, so a shared count would pool
@@ -407,10 +408,115 @@ distinguishable from the hold record alone. The blast radius is bounded by
407
408
  the stranded-reasons allow-list above. The designated home for a real signal
408
409
  is divergence telemetry built on `calculateGridSideDivergenceMetric`.
409
410
 
411
+ ## The genesis-less state: refused at load, rebuilt or halted
412
+
413
+ **A grid with no price ladder is not a degraded grid — it is an undefined one.**
414
+ Every consumer of the invariant reads `priceForSlot(idx, genesis)`, and each one
415
+ silently degrades without it: nearest-slot adoption, `computeOutOfToleranceDriftTag`,
416
+ the materialize descriptor-price fallback, `resolveLiveReserveEdgeAnchorPrice`
417
+ tiers 3/4, and the `isSlotInRail` fail-open. That degradation is the tolerance
418
+ matcher, which is exactly the path on which an off-grid price becomes grid
419
+ evidence. So the ladder is treated as a **required** part of a snapshot, not a
420
+ nice-to-have.
421
+
422
+ The trigger is narrow: only a *pre-v1.4.25* snapshot (one persisted before the
423
+ genesis was written) can reach it. Given such a snapshot:
424
+
425
+ | Trigger | Condition | Verdict |
426
+ |---|---|---|
427
+ | T1 | config rail matches the persisted slots | migration ladder is adopted (unchanged) |
428
+ | T2 | > `MISSING_GENESIS_MISMATCH_RATIO` (50%) of slots mismatch the config rail | **refused** — the config was edited, so the derived rail is a different generation |
429
+ | T3 | rail config is not numeric yet (`startPrice: "pool"`, `minPrice: "2x"`) | **refused** — nothing can be built until `initializeGrid` derives them |
430
+ | T4 | the ladder build throws | **refused** |
431
+
432
+ ### The decision lives in one place
433
+
434
+ `modules/order/genesis_policy.ts` owns the single question "can this snapshot
435
+ have a ladder?" (`resolvePersistedGenesis`) and the policy
436
+ (`resolveOnMissingGenesisPolicy`). Three call sites, one verdict — they cannot
437
+ drift:
438
+
439
+ | Site | Mechanism | What it does on a refusal |
440
+ |---|---|---|
441
+ | `grid.loadGrid` | **E1**, source choke point | throws `MissingGenesisError` **before any mutation** (no asset init, no fund reset, no boundary restore) |
442
+ | `dexbot_startup_runtime` | **E3**, startup gate | regenerates the grid (`initializeGrid` re-derives prices, reconcile is update-first) or aborts startup |
443
+ | `order/sync_engine._assertGenesisInvariant` | **E2**, defence in depth | **refuses the sync** (empty result, nothing touched), reports once per generation, counts, and requests a structural resync — never throws |
444
+ | `AccountOrders.loadGenesis` | schema | a row with empty/absent `priceLevels` is not a ladder and is not returned |
445
+
446
+ ### Policy
447
+
448
+ `config.gridLimits.MISSING_GENESIS_POLICY`:
449
+
450
+ - **`'rebuild'` (default)** — refuse the snapshot and rebuild a clean ladder
451
+ through the existing resync machinery. Deterministic, no operator action, and
452
+ fund-safe in the same sense a manual reset is: reconcile is update-first, so
453
+ only true surplus is cancelled and out-of-grid orders are held per the
454
+ out-of-bounds policy. Live orders are re-slotted — the same net effect the
455
+ operator would get from `dexbot reset`, which is why `'halt'` exists.
456
+ - **`'halt'`** — refuse to start; a human must run a manual grid reset. Strongest
457
+ fund safety (nothing is cancelled without consent), but the bot stays down until
458
+ someone acts, which is why it is opt-in.
459
+
460
+ Anything other than `'halt'` falls back to `'rebuild'`.
461
+
462
+ ### Routing per caller
463
+
464
+ - **startup resume** — the E3 gate fires *before* the resume/regenerate decision,
465
+ so a ladder-less snapshot is regenerated rather than half-loaded.
466
+ - **price-match resume** (`attemptResumePersistedGridByPriceMatch`) — the throw is
467
+ caught and reported as "not resumed", which routes to regeneration.
468
+ - **recovery reload** — the throw is caught and logged with its reason. Under
469
+ `'rebuild'` it is returned as a failed reload, which is the existing signal for
470
+ "escalate to structural resync"; under `'halt'` the failure carries `halt: true`
471
+ so the maintenance resync path suppresses the automatic rebuild and waits for
472
+ the operator.
473
+ - **runtime E2 assert** — never fatal: it aborts the sync instead of reconciling a grid whose slots have no price authority, and it exists to make a future bypass loud.
474
+
475
+ Observability is part of the design, not an afterthought: the fault is recorded on
476
+ the manager as `_missingGenesis` (reason, detail, mismatch ratio, policy) and
477
+ cleared by the next successful load or grid build, so a log read tells an operator
478
+ whether T2-T4 ever fire in the wild.
479
+
480
+ ### The tolerance matcher is gone
481
+
482
+ The consumers listed above no longer degrade, because there is nothing left to
483
+ degrade *into*:
484
+
485
+ | Former legacy behaviour | Now |
486
+ |---|---|
487
+ | pass-2 tolerance adoption, incl. the widened `ORPHAN_ADOPTION_TOLERANCE_MULTIPLIER` spread-orphan band | nearest-slot only; no ladder means the orphan is reported as `no-genesis-deferred` and nothing is touched |
488
+ | pass-1 price-equality / duplicate-swap fallback to `calculatePriceTolerance` | level identity (`chainPriceOnSameLevel`: both prices map to the same slot), integer equality only when unjudgeable; a few-quanta rest-drift within one level is left in place (no re-price) until the order rotates |
489
+ | correction-queue staleness matched by tolerance | `priceSlotEqual` against the slot's own level, and a ladder-less entry is dropped |
490
+ | `computeOutOfToleranceDriftTag` + `price-drift-orphan` auto-cancel (`PRICE_DRIFT_TOLERANCE_MULTIPLIER`) | removed — an off-grid order is HELD (`out-of-grid-deferred`) and resolved structurally, never cancelled off a fuzzy price diff |
491
+ | `findMatchingGridOrderByOpenOrder` | removed (its last production caller was the pass-2 legacy block; the cancelOrder linkage matches by `orderId`) |
492
+ | `resolveLiveReserveEdgeAnchorPrice` tiers 2/3 (live slot extreme, config bound) | ladder extreme only; a ladder-less manager returns `null` (the live resolver no longer computes a config bound — consumers that want one, e.g. `reserveEdgeIdSet`, resolve it themselves) |
493
+ | materialize descriptor-price fallback for a `slot-N` id | kept only for an unparseable id; a `slot-N` id with no ladder logs `error` and requests a structural resync |
494
+
495
+ **E2 is fail-closed.** `syncFromOpenOrders` calls `_assertGenesisInvariant`
496
+ before anything else and, when slots exist without a ladder, returns an empty
497
+ result — no locks, no adoption, no correction queued — after logging at `error`
498
+ and requesting the structural resync that re-derives the ladder. It used to log
499
+ and continue *into* the tolerance matcher; that continuation is what made the
500
+ legacy path a live safety net, and it is what this removal gives up. The load
501
+ gates (E1/E3) own the fail-closed decision, so the state is unreachable through
502
+ a supported flow.
503
+
504
+ ### Rejected alternatives
505
+
506
+ - **Adopt the config-derived ladder despite a >50% mismatch** (mass-virtualizing
507
+ live tracking and persisting a mismatched genesis) — corruption risk, rejected.
508
+ - **Derive the ladder from the persisted slot prices** — a truncated persisted
509
+ array would permanently shrink it.
510
+ - **Keep loading "as-is without a ladder"** — this is the state that was removed.
511
+ - **Keep the tolerance matcher as the E2 fallback** — it is the corruption path
512
+ the invariant exists to close; E2 refuses instead.
513
+
410
514
  ## Key constants (`modules/constants.ts`, `TIMING`)
411
515
 
412
516
  | Constant | Value | Meaning |
413
517
  |---|---|---|
518
+ | `MISSING_GENESIS_POLICY` | `'rebuild'` | `'rebuild'` (auto) or `'halt'` (manual reset) when a snapshot has no usable ladder |
519
+ | `MISSING_GENESIS_MISMATCH_RATIO` | 0.5 | Share of slots that must match the config rail before a migrated ladder is adopted |
414
520
  | `GRID_PRICE_INVARIANT_RESYNC_THRESHOLD` | 3 | Consecutive rejecting batches per slot before a structural resync |
415
521
  | `GRID_PRICE_INVARIANT_RESYNC_COOLDOWN_MS` | 15 min | Bounds repeat resyncs for the same corruption |
416
522
  | `DEFERRED_HOLD_ESCALATE_MS` | 24 h | Age at which a stranded deferred hold escalates |
@@ -433,6 +539,8 @@ is divergence telemetry built on `calculateGridSideDivergenceMetric`.
433
539
  | `[HOLD]` enrichment + slow re-warn | **landed** |
434
540
  | Final pre-broadcast pivot gate re-checks BUILT ops on a refreshed pivot | **landed** |
435
541
  | Fill-guard pivot persisted with the grid snapshot (provenance: fills only) | **landed** |
542
+ | Snapshot without a usable ladder refused at load; rebuild by default, `halt` opt-in | **landed** |
543
+ | Legacy tolerance matcher removed; E2 fail-closed (refuse the sync) instead of warning and continuing | **landed** |
436
544
  | Pivot restored with the boundary (TTL → genesis → on-grid validation chain) | **landed** |
437
545
  | Pivot mutation behind one provenance-tagged writer (`setLastFillPivot`) | **landed** |
438
546
  | Grid generation invalidates the pivot (in-memory + persisted row) | **landed** |
@@ -452,12 +560,17 @@ reported.
452
560
  rotation price is derived from the destination's genesis level (GPI-013), and
453
561
  the derivation declines — rather than inventing a price — with no ladder
454
562
  (GPI-014) or an out-of-ladder index (GPI-015).
455
- - **Unit:** a legacy-path out-of-grid order is held, not adopted, and keeps its
456
- genesis price (LEGACY-ADOPT-001/002); the materialize path derives the slot
457
- price AND order type from genesis and warns when it cannot
458
- (MATERIALIZE-001/002/003); adoption
459
- keeps the slot's own level on the genesis path and does not warn when correct
460
- (ADOPT-NAME-001) (`tests/test_sync_out_of_grid_defer.ts`).
563
+ - **Unit:** an out-of-grid order is held, not adopted, and keeps its genesis
564
+ price (ADOPT-001/002); the materialize path derives the slot price AND order
565
+ type from genesis (MATERIALIZE-001/003) and, on a ladder-less grid, still
566
+ tracks the placed order but logs the undefined grid at `error` and requests a
567
+ structural resync (MATERIALIZE-002); adoption keeps the slot's own level and
568
+ does not warn when correct (ADOPT-NAME-001)
569
+ (`tests/test_sync_out_of_grid_defer.ts`).
570
+ - **Unit:** pass-2 orphan classification is nearest-slot only — out-of-grid is
571
+ held, an in-grid orphan adopts into the slot its price maps to and keeps that
572
+ slot's level, an occupied level is a cancel-only duplicate, and a ladder-less
573
+ grid refuses the whole sync (`tests/test_sync_excess_orphan.ts`).
461
574
  - **Unit:** pre-broadcast drift is reported at `warn` and the op is built from
462
575
  the *planned* price (`tests/test_cow_orchestration_fixes.ts`).
463
576
  - **Unit:** pivot snapping and off-ladder refusal
@@ -469,6 +582,11 @@ reported.
469
582
  - **Unit:** pivot snapshot round-trip and its restore validation chain
470
583
  (`tests/test_last_fill_pivot_persistence.ts`, LFP-1..8) — shape gates,
471
584
  provenance, TTL, genesis binding, off-ladder refusal, full-family reset.
585
+ - **Unit:** the missing-genesis policy — T1 adoption, T2/T3/T4 refusals, the
586
+ ratio boundary, policy resolution, `loadGrid` refusing before it mutates
587
+ anything (and honouring `'halt'`), the `loadGenesis` schema gate, and the E2
588
+ sync-entry assert and the `'halt'` suppression of the recovery resync
589
+ (`tests/test_missing_genesis_policy.ts`, GEN-01..21).
472
590
  - **External gate:** `analysis/grid_correction_check.ts` — target 0 sustained
473
591
  violations at 168h/720h. **The baseline is NOT clean:** 4 of 5 bots were
474
592
  non-zero over 7 days, so this is a live signal, not a historical one.
@@ -620,3 +620,15 @@ Removed trigger file.
620
620
  - `modules/market_adapter_whitelist.ts` — Whitelist storage/read helpers (the bot editor's `6) Adapter` reads and writes the same file)
621
621
  - `profiles/general.settings.json` — User-editable configuration
622
622
  - `profiles/bots.json` — Per-bot configuration including AMA
623
+
624
+ ## Visualizing the AMA Triggers (§3 and §4)
625
+
626
+ `dexbot tv <bot>` (and `analysis/tradingview/analyze_tradingview.js`) replays the
627
+ two market-adapter recentering triggers over the chart's candle history and draws
628
+ the accepted grid center, the range that center would own, and one marker per
629
+ reset (amber = AMA-price Δ, cyan = AMA-slope Δ, grey = first snapshot). The
630
+ thresholds are resolved through the same constants → `general.settings` →
631
+ `market_adapter_settings` chain the adapter uses, so the chart shows where the
632
+ grid would actually have moved — handy for tuning `AMA_DELTA_THRESHOLD_PERCENT`
633
+ and `AMA-Slope Δ` before changing them. Details:
634
+ [analysis/tradingview/README.md](../analysis/tradingview/README.md#grid-reset-simulation).
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.7 (released).
5
+ **Version context:** v1.6.8 (released).
6
6
 
7
7
  ---
8
8
 
@@ -210,6 +210,8 @@ While these docs explain the *why*, the *how* lives in the code. See the full [m
210
210
  - **`modules/order/processed_fill_store.ts`**: Processed fill dedupe tracker and persistence batching
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
+ - **`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`**: Passive installed-vs-published version probe and the single status-line renderer used by `start`/`pm2`/`status`
213
215
  - **`modules/credit_runtime.ts`**: Bot-scoped debt workflow executor (MPA and credit offer accept/repay/reborrow)
214
216
  - **`modules/cr_planner.ts`**: Shared collateral-ratio math layer for debt-first planning
215
217
  - **`modules/order/utils/math.ts`**: Precision conversions, RMS divergence calculation, fund allocation math
package/docs/WORKFLOW.md CHANGED
@@ -209,7 +209,7 @@ DEXBot2 runs as a **monolithic daemon** (`dexbot start`). This is the production
209
209
  recommended mode:
210
210
 
211
211
  - **Single process** — no PM2, no separate credential daemon management
212
- - **Auto-update** — detects new releases, builds, and restarts cleanly
212
+ - **Optional auto-update** — `dexbot update` (or `UPDATER.ACTIVE` in general settings, **default off**) pulls, builds and restarts cleanly; by default the bot only *reports* that a newer release exists
213
213
  - **Crash restart** — background mode re-spawns on failure
214
214
  - **Per-bot log files** — each bot logs to `<profiles>/logs/<bot>.log` (`~/.config/dexbot2/profiles/logs` by default)
215
215
  - **Built-in daemon** — the credential daemon is managed internally
@@ -260,12 +260,23 @@ the canonical name is preferred in scripts and docs.
260
260
  | `dexbot reload` | `reloadall` | Reload the monolithic runtime without touching the credential daemon (unlock mode) |
261
261
  | `dexbot restart` | `restartall` | Restart the monolithic runtime (unlock mode, re-unlocks credential daemon) |
262
262
  | `dexbot delete` | — | Shut down and clean up the monolithic runtime (unlock mode) |
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) |
263
+ | `dexbot clear` | — | Delete `*.log`, rotated `*.log.*` and `*.jsonl*` from the logs directory (`<profiles>/logs`) |
264
+ | `dexbot clear-orders` | — | Delete all persisted order files (`<profiles>/orders`); grids regenerate on next start |
265
+ | `dexbot clear-market-adapter` | — | Delete market adapter data, state (incl. `market_adapter.lock`), and adapter logs |
266
+ | `dexbot clear-all` | — | Delete orders, logs, market adapter, and claw data (all of the above) |
267
267
  | `dexbot help` | — | Print the full CLI reference (grouped by Runtime/Trading/Config/Analysis/Files) |
268
268
 
269
+ > ⚠️ **The `clear*` commands are offline-only** — stop the runtime first
270
+ > (`dexbot stop` / `dexbot pm2 stop all`). They detect a live runtime (pid files
271
+ > + this install's online PM2 apps) and warn, but the warning is advisory: the
272
+ > deletion still runs, a live bot re-creates the state within seconds, and open
273
+ > log FDs keep the disk space until it restarts.
274
+ >
275
+ > `clear*` never touches config — `bots.json`, `keys.json`, the settings files and
276
+ > `credit_runtime/` survive. `clear` / `clear-all` do delete the credential audit
277
+ > trail `logs/daemon-audit.jsonl` (and its rotated siblings) along with the rest
278
+ > of the logs; the preview names it explicitly.
279
+
269
280
  ## NPM Scripts for Branch Synchronization
270
281
 
271
282
  The following npm scripts provide safe, automated branch synchronization:
@@ -834,7 +834,7 @@ closed 1h candles.
834
834
 
835
835
  #### Shared Month-Shard Cache and Fetch Robustness
836
836
 
837
- Pool, book, and feed candle fetches share one cache entry point (`runCachedWindows` in `market_adapter/inputs/window_cache.ts`): candles live in fixed calendar-month shards (`<base>.shard_YYYY-MM.json`, UTC) whose names never shift, so a run loads only the shards overlapping its requested range, queries only genuinely missing buckets plus a bounded 48h tail refresh, and rewrites only shards that gained buckets or query coverage — pure-reuse runs perform zero writes and zero deletes. Shard metas record the ranges actually queried (`meta.queriedRanges`, monotonically unioned). A missing range is pruned only when recorded query coverage genuinely covers it — the absence of local buckets alone never certifies history as empty. Partial windows merge into the run output but are never persisted. Stable month shards are the only supported cache format; obsolete run-relative cache files are ignored. Every range fetch runs through `fetchRangeWithRetry` (per-range attempts + linear backoff + abort-signal timeout; the LP path keeps a 4-attempt budget), one-shot Kibana queries retry transient errors (3 attempts), paged fetchers cap at `kibanaMaxPages` (500), and bidirectional fetches tolerate a one-direction failure.
837
+ Pool, book, and feed candle fetches share one cache entry point (`runCachedWindows` in `market_adapter/inputs/window_cache.ts`): candles live in fixed calendar-month shards (`<base>.shard_YYYY-MM.json`, UTC) whose names never shift, so a run loads only the shards overlapping its requested range, queries only genuinely missing buckets plus a bounded tail refresh, and rewrites only shards that gained buckets or query coverage — pure-reuse runs perform zero writes and zero deletes. Shard metas record the ranges actually queried (`meta.queriedRanges`, monotonically unioned) together with `at`, the time each query ran; spans merge only when they assert the same verification time, so per-bucket freshness stays exact. A missing range is pruned only when recorded query coverage genuinely covers it — the absence of local buckets alone never certifies history as empty — and only once the range ended more than `GAP_SETTLE_HORIZON_MS` ago, judged per gap rather than per window (a month-old gap at the leading edge of the newest window is as settled as one in a fully past window). The tail window re-queries only buckets that no query has seen `TAIL_SETTLE_LAG_MS` after they closed (`settleCoverage`), so a rerun costs ~lag+elapsed hours instead of a fixed 48h, and the refresh never reaches back past `TAIL_REFRESH_HOURS` (an unsettled bucket must be refreshed because index lag is still open, but a coverage hole older than 48h is past any plausible lag and must not drag the boundary back weeks); caches without `at` fall back to that fixed window. Clusters of gaps within `GAP_MERGE_TOLERANCE_BUCKETS` collapse into one query, and the sub-range path is bounded by merged span hours rather than gap count, so one extra small hole can no longer escalate a run to a full-window fetch. Because spans merge only on an identical `at`, a shard gains one span per re-verifying run; the persisted list is capped at `MAX_COVERAGE_SPANS` by dropping the oldest spans, which can never invent emptiness (it can only make those buckets look unsettled, bounded by the same 48h ceiling). A run that re-verifies the tail therefore rewrites that shard even when the candles come back identical — the moved verification time is the news, and skipping the write would throw it away; pure-reuse runs still write nothing. Partial windows merge into the run output but are never persisted. Stable month shards are the only supported cache format; obsolete run-relative cache files are ignored. Every range fetch runs through `fetchRangeWithRetry` (per-range attempts + linear backoff + abort-signal timeout; the LP path keeps a 4-attempt budget), one-shot Kibana queries retry transient errors (3 attempts), paged fetchers cap at `kibanaMaxPages` (500), and bidirectional fetches tolerate a one-direction failure.
838
838
 
839
839
  #### AMA Warmup Window — Why Candle Length Matters
840
840