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
@@ -18,8 +18,8 @@
18
18
  * Methods:
19
19
  * syncMeta(botConfig), storeMasterGrid(orders, btsFeesOwed, boundaryIdx, assets, debugInputs, recentFillKeys, genesis, gapEvacStreaks, pendingFillCrawls, lastFillPivot)
20
20
  * loadGrid(forceReload), loadRecentFillKeys(forceReload), loadPersistedAssets(forceReload), loadPendingFillCrawls(forceReload)
21
- * loadBoundaryIdx(forceReload), loadBtsBalance(forceReload), loadBtsFeesOwed(forceReload), loadGapEvacStreaks(forceReload), loadGenesis(forceReload)
22
- * clearGrid()
21
+ * loadBoundaryIdx(forceReload), loadBtsBalance(forceReload), loadBtsFeesOwed(forceReload), loadGapEvacStreaks(forceReload), loadGenesis(forceReload), loadLastFillPivot(forceReload)
22
+ * clearGrid(), clearPersistedBoundary(), clearPersistedLastFillPivot()
23
23
  * loadProcessedFills(options), updateProcessedFillsBatch(fills), cleanOldProcessedFills(olderThanMs)
24
24
  * getAssetBalances(forceReload)
25
25
  *
@@ -64,6 +64,7 @@ import { ORDER_TYPES, ORDER_STATES } from './constants.js';
64
64
  import { PATHS } from './paths.js';
65
65
  import AsyncLock from './order/async_lock.js';
66
66
  import { isPhantomOrder } from './order/utils/order.js';
67
+ import { hasGenesisLadder } from './order/genesis_policy.js';
67
68
  import * as Format from './order/format.js';
68
69
  import { ensureDir, nowIso, normalizeLastFillPivot } from './order/utils/system.js';
69
70
  import Logger from './order/logger.js';
@@ -478,15 +479,51 @@ class AccountOrders {
478
479
  }
479
480
  return (this.data && Array.isArray(this.data.grid)) ? this.data.grid : null;
480
481
  }
482
+ /**
483
+ * Load the persisted price-ladder (genesis) for this bot.
484
+ *
485
+ * SCHEMA GATE (docs/GRID_PRICE_INVARIANT.md, "Schema"): a usable ladder needs a
486
+ * NON-EMPTY `priceLevels` array. A row without one is not a ladder --
487
+ * accepting it would hand `loadGrid` a genesis it cannot validate against
488
+ * (and, for an empty array, silently disable every genesis-derived consumer).
489
+ * Refusing it here means the caller takes the missing-genesis path once, at
490
+ * the source, instead of at every consumer.
491
+ *
492
+ * The hash is deliberately NOT required here: a present-but-tampered hash is
493
+ * still returned, because the hash-mismatch warning belongs to `loadGrid`,
494
+ * which can say what it compared against (`hasGenesisLadder` in
495
+ * modules/order/genesis_policy.ts draws the same distinction).
496
+ * @param {boolean} forceReload - If true, reload from disk
497
+ * @returns {Object|null} The genesis object, or null when absent/invalid
498
+ */
481
499
  loadGenesis(forceReload = false) {
482
500
  if (forceReload) {
483
501
  this.data = this._loadData() || emptyData();
484
502
  }
485
- if (this.data && this.data.genesis && Array.isArray(this.data.genesis.priceLevels)) {
486
- return this.data.genesis;
503
+ const genesis = this.data?.genesis;
504
+ // Same predicate as loadGrid/genesis_policy: one definition of "usable
505
+ // ladder", so the schema gate cannot diverge from the load-time gate.
506
+ if (hasGenesisLadder(genesis)) {
507
+ return genesis;
508
+ }
509
+ if (genesis) {
510
+ this._noteRejectedGenesis(genesis);
487
511
  }
488
512
  return null;
489
513
  }
514
+ /**
515
+ * Record why a persisted genesis row was refused (observability for the
516
+ * schema gate above; loadGrid cannot report a row it never receives).
517
+ */
518
+ _noteRejectedGenesis(genesis) {
519
+ try {
520
+ const reason = !Array.isArray(genesis?.priceLevels)
521
+ ? 'priceLevels is not an array'
522
+ : (genesis?.priceLevels?.length === 0 ? 'priceLevels is empty' : 'malformed');
523
+ this._rejectedGenesis = { reason, at: Date.now() };
524
+ }
525
+ catch { /* never fail a load for telemetry */ }
526
+ }
490
527
  /**
491
528
  * Load the persisted gap-evacuation streaks (per-slot in-band cycle counts).
492
529
  * @param {boolean} forceReload - If true, reload from disk
@@ -85,8 +85,17 @@ function validateBotEntry(b, i, src) {
85
85
  }
86
86
  }
87
87
  if ('reserveOrders' in b && b.reserveOrders !== undefined && b.reserveOrders !== null) {
88
- if (typeof b.reserveOrders !== 'object' || Array.isArray(b.reserveOrders))
88
+ if (typeof b.reserveOrders === 'number') {
89
+ // Legacy numeric form migrates at read time (resolveReserveCount):
90
+ // { buy: n, sell: 0 }. Accept it here so a hand-edited bots.json
91
+ // that bypassed the editor is not rejected for a form the runtime
92
+ // still understands.
93
+ if (!Number.isInteger(b.reserveOrders) || b.reserveOrders < 0)
94
+ problems.push("'reserveOrders' numeric form must be a non-negative integer");
95
+ }
96
+ else if (typeof b.reserveOrders !== 'object' || Array.isArray(b.reserveOrders)) {
89
97
  problems.push("'reserveOrders' must be an object {buy, sell}");
98
+ }
90
99
  else {
91
100
  for (const side of ['buy', 'sell']) {
92
101
  const v = b.reserveOrders[side];
@@ -10,6 +10,7 @@ declare const Config: {
10
10
  DEXBOT_MONOLITHIC_BG: boolean;
11
11
  DEXBOT_LAUNCHER_WORKER: boolean;
12
12
  DEXBOT_UPDATE_SKIP_RELOAD: boolean;
13
+ DEXBOT_SKIP_VERSION_NOTICE: boolean;
13
14
  NO_COLOR: string | undefined;
14
15
  PM2_HOME: string | undefined;
15
16
  DEXBOT_SUPERVISOR_SOCKET: string | undefined;
@@ -53,6 +53,7 @@ const Config = {
53
53
  DEXBOT_MONOLITHIC_BG: bool('DEXBOT_MONOLITHIC_BG'),
54
54
  DEXBOT_LAUNCHER_WORKER: bool('DEXBOT_LAUNCHER_WORKER'),
55
55
  DEXBOT_UPDATE_SKIP_RELOAD: bool('DEXBOT_UPDATE_SKIP_RELOAD'),
56
+ DEXBOT_SKIP_VERSION_NOTICE: bool('DEXBOT_SKIP_VERSION_NOTICE'),
56
57
  NO_COLOR: str('NO_COLOR'),
57
58
  // ── Paths ───────────────────────────────────────────────────────
58
59
  PM2_HOME: str('PM2_HOME'),
@@ -213,6 +213,7 @@ declare let TIMING: {
213
213
  DUST_HEALTH_CHECK_INTERVAL_MS: number;
214
214
  DUST_CANCEL_TIMEOUT_MS: number;
215
215
  BROADCAST_STALE_CLEAR_MS: number;
216
+ BROADCAST_DEFER_SAFETY_MARGIN_MS: number;
216
217
  FILL_BROADCAST_DEFER_MAX_MS: number;
217
218
  FILL_TOTALS_RETRY_BASE_MS: number;
218
219
  FILL_TOTALS_RETRY_MAX_MS: number;
@@ -242,6 +243,7 @@ declare let TIMING: {
242
243
  TARGETED_DRIFT_SYNC_COOLDOWN_MS: number;
243
244
  LIGHTWEIGHT_SYNC_CHECK_INTERVAL_MS: number;
244
245
  SYNC_LOCK_FORCE_RELEASE_AGE_MS: number;
246
+ GRID_LOCK_HOLD_WARN_MS: number;
245
247
  GRID_BLOAT_RESYNC_GRACE_MS: number;
246
248
  MAX_ACCOUNT_TOTALS_AGE_MS: number;
247
249
  STALE_TOTALS_WARN_RATE_LIMIT_MS: number;
@@ -255,11 +257,12 @@ declare let TIMING: {
255
257
  CREDIT_RATE_MAX_AGE_MS: number;
256
258
  };
257
259
  declare let GRID_LIMITS: {
260
+ MISSING_GENESIS_POLICY: string;
261
+ MISSING_GENESIS_MISMATCH_RATIO: number;
258
262
  MIN_SPREAD_FACTOR: number;
259
263
  MIN_ORDER_SIZE_FACTOR: number;
260
264
  PRICE_TOLERANCE_MAX_PERCENT: number;
261
265
  PRICE_TOLERANCE_MIN_ABSOLUTE: number;
262
- ORPHAN_ADOPTION_TOLERANCE_MULTIPLIER: number;
263
266
  GRID_REGENERATION_PERCENTAGE: number;
264
267
  PARTIAL_DUST_THRESHOLD_PERCENTAGE: number;
265
268
  FUND_INVARIANT_PERCENT_TOLERANCE: number;
@@ -275,7 +278,6 @@ declare let GRID_LIMITS: {
275
278
  RMS_PERCENTAGE: number;
276
279
  };
277
280
  RELATIVE_ORDER_UPDATE_THRESHOLD_PERCENT: number;
278
- PRICE_DRIFT_TOLERANCE_MULTIPLIER: number;
279
281
  };
280
282
  declare let INCREMENT_BOUNDS: {
281
283
  MIN_PERCENT: number;
@@ -327,7 +329,8 @@ declare let FILL_PROCESSING: {
327
329
  MAX_CONSECUTIVE_CONSUMER_FAILURES: number;
328
330
  CONSUMER_BACKOFF_INITIAL_MS: number;
329
331
  CONSUMER_BACKOFF_MAX_MS: number;
330
- CORRECTION_MAX_UPDATES_PER_CYCLE: number;
332
+ CORRECTION_LOCK_HOLD_BUDGET_MS: number;
333
+ CORRECTION_MAX_UPDATES_PER_CYCLE: null;
331
334
  CORRECTION_QUEUE_WARN_THRESHOLD: number;
332
335
  CORRECTION_QUEUE_WARN_RATE_LIMIT_MS: number;
333
336
  };
@@ -569,6 +572,11 @@ declare let UPDATER: {
569
572
  REPOSITORY_URL: string;
570
573
  BRANCH: string;
571
574
  SCHEDULE: string;
575
+ NOTICE_ENABLED: boolean;
576
+ NOTICE_INTERVAL_MS: number;
577
+ NOTICE_TIMEOUT_MS: number;
578
+ NOTICE_STATUS_TIMEOUT_MS: number;
579
+ REGISTRY_URL: string;
572
580
  };
573
581
  declare let LAUNCHER: {
574
582
  MONOLITHIC: {
@@ -190,12 +190,12 @@ let DEFAULT_CONFIG = {
190
190
  };
191
191
  // Range quality zones for price bounds (minPrice/maxPrice multipliers).
192
192
  // Used for pre-entry legend in the bot editor (mountain-style).
193
- // Thresholds per user spec: green >=2x, yellow >=1.55x, orange 1.45x–1.55x, red <1.45x.
193
+ // Thresholds per user spec: green >=2x, yellow >=1.55x, orange 1.4x–1.55x, red <1.4x.
194
194
  let RANGE_QUALITY = {
195
195
  GREEN_MIN: 2.0, // >=2.0x → green (wide)
196
196
  YELLOW_MIN: 1.55, // >=1.55x → yellow (effeciant)
197
- ORANGE_MIN: 1.45, // >=1.45x → orange (tight)
198
- RED_MAX: 1.45, // <1.45x → red (suizidal) — exclusive upper bound for red
197
+ ORANGE_MIN: 1.4, // >=1.4x → orange (tight)
198
+ RED_MAX: 1.4, // <1.4x → red (suizidal) — exclusive upper bound for red
199
199
  };
200
200
  // Timing constants used by OrderManager and helpers
201
201
  let TIMING = {
@@ -263,20 +263,29 @@ let TIMING = {
263
263
  DUST_CANCEL_TIMEOUT_MS: 5 * 1000, // 5 seconds
264
264
  // BROADCAST_STALE_CLEAR_MS: a leaked/hung broadcast flag is hard-cleared
265
265
  // after this long so it cannot permanently block rebalancing
266
- // (see manager._clearStaleBroadcastFlag). Kept as a constant so the
267
- // fill-consumer deferral bound below can derive from it.
266
+ // (see manager._clearStaleBroadcastFlag). This is the SINGLE authority on
267
+ // "when is a broadcast region stale": both the maintenance-tick deferral
268
+ // (shouldDeferMaintenanceForBroadcast) and the fill-consumer deferral
269
+ // bound (FILL_BROADCAST_DEFER_MAX_MS, derived below) are expressed in
270
+ // terms of it, so they cannot be tuned out of agreement.
268
271
  BROADCAST_STALE_CLEAR_MS: 120000, // 120 seconds
272
+ // BROADCAST_DEFER_SAFETY_MARGIN_MS: headroom added to
273
+ // BROADCAST_STALE_CLEAR_MS when deriving FILL_BROADCAST_DEFER_MAX_MS, so a
274
+ // region that is still considered live by the stale-clear watchdog cannot
275
+ // first trip the fill-consumer deferral bound (which would drop the
276
+ // consumer into the in-lock wait the deferral exists to avoid).
277
+ BROADCAST_DEFER_SAFETY_MARGIN_MS: 30000, // 30 seconds
269
278
  // FILL_BROADCAST_DEFER_MAX_MS: Bound on fill-consumer deferral while a
270
279
  // broadcast region is active. The consumer defers (instead of acquiring
271
280
  // the fill lock and sleeping up to 30s inside it) so concurrent consumers
272
281
  // never queue as lock waiters and time out. Past this bound a stuck flag
273
282
  // falls through to the legacy in-lock wait, which still caps at 30s and
274
283
  // proceeds — a leaked flag can delay fills, never starve them.
275
- // MUST exceed BROADCAST_STALE_CLEAR_MS, or a legitimately long region
276
- // (e.g. startup reconcile Phase 2 with many create groups) trips the
277
- // bound and drops the consumer into the very in-lock wait the deferral
278
- // exists to avoid. The post-merge derivation enforces that relationship.
279
- FILL_BROADCAST_DEFER_MAX_MS: 120000, // 120 seconds (raised below to stale-clear + margin)
284
+ // Derived after override merge from BROADCAST_STALE_CLEAR_MS +
285
+ // BROADCAST_DEFER_SAFETY_MARGIN_MS (see end of this module), so the
286
+ // ordering invariant holds by construction. The value below is only a
287
+ // floor for that derivation.
288
+ FILL_BROADCAST_DEFER_MAX_MS: 120000, // 120 seconds (raised after merge to stale-clear + margin)
280
289
  // FILL_TOTALS_RETRY_BASE_MS / MAX_MS: Backoff for re-processing fills
281
290
  // parked when the accountTotals refresh failed (stale snapshot). The
282
291
  // deferred fills are held OUTSIDE the live queue and re-queued on a
@@ -432,6 +441,13 @@ let TIMING = {
432
441
  // is detached from it.
433
442
  // Derived as SYNC_LOCK_TIMEOUT_MS * 2 after override merge (see end of this module).
434
443
  SYNC_LOCK_FORCE_RELEASE_AGE_MS: 40000, // overridden by derivation after merge
444
+ // GRID_LOCK_HOLD_WARN_MS: observability threshold for _gridLock hold
445
+ // duration. That lock has no acquisition timeout and its callers cannot
446
+ // safely recover from a rejected acquire, so an over-long critical
447
+ // section is surfaced (warn + metric) by the maintenance tick rather than
448
+ // timed out or force-released. A hold crossing this threshold means a
449
+ // section is running unbounded and should be bounded at the source.
450
+ GRID_LOCK_HOLD_WARN_MS: 15000,
435
451
  // GRID_BLOAT_RESYNC_GRACE_MS: Grace period before the maintenance runtime
436
452
  // re-triggers a structural resync for a previously detected grid bloat.
437
453
  // Prevents immediate re-triggering when Grid.loadGrid already scheduled one
@@ -491,6 +507,36 @@ let TIMING = {
491
507
  };
492
508
  // Grid limits and scaling constants
493
509
  let GRID_LIMITS = {
510
+ // MISSING_GENESIS_POLICY: what to do when a persisted grid cannot be tied
511
+ // to a price ladder ("no genesis" -- the genesis-less state analysed in
512
+ // docs/GRID_PRICE_INVARIANT.md). A genesis-less grid is NOT repairable in
513
+ // place: every consumer (nearest-slot adoption, the materialize
514
+ // descriptor-price fallback, reserve-edge anchoring) has no authority for a
515
+ // slot's price, which is exactly how an off-grid price became grid evidence
516
+ // and was re-emitted. The load and sync gates refuse that state outright —
517
+ // no tolerance matcher remains.
518
+ // 'rebuild' (default) -- refuse the snapshot and rebuild a clean ladder
519
+ // through the existing resync machinery
520
+ // (initializeGrid/recalculateGrid, which re-derive
521
+ // prices and reconcile update-first, so only true
522
+ // surplus is cancelled). Deterministic, but the
523
+ // live orders are re-slotted -- the same net effect
524
+ // as a manual `dexbot reset`.
525
+ // 'halt' -- refuse to start and require the operator to run a
526
+ // manual grid reset. Strongest fund safety (nothing
527
+ // is cancelled without consent); the bot stays down
528
+ // until a human acts, so it is opt-in, not default.
529
+ // Read as `config.gridLimits.MISSING_GENESIS_POLICY` (see
530
+ // modules/order/genesis_policy.ts); any other value falls back to 'rebuild'.
531
+ MISSING_GENESIS_POLICY: 'rebuild',
532
+ // MISSING_GENESIS_MISMATCH_RATIO: share of persisted slots that must match
533
+ // the config-derived rail before a migrated (genesis-less) snapshot may
534
+ // adopt that rail as its genesis. Above it, the config was edited since the
535
+ // snapshot, so the config-derived ladder is a DIFFERENT generation:
536
+ // adopting it would mass-virtualize live order tracking in 'enforce' mode
537
+ // (or flood the log in 'log' mode) and persist a genesis the live grid does
538
+ // not match. Treated as a missing genesis instead -- refused, never adopted.
539
+ MISSING_GENESIS_MISMATCH_RATIO: 0.5,
494
540
  // MIN_SPREAD_FACTOR: Ensures spread is at least (incrementPercent × MIN_SPREAD_FACTOR) slots wide.
495
541
  // Rationale: Spread must be sufficiently wide to:
496
542
  // 1. Avoid order collision (orders too close get rejected by blockchain)
@@ -519,11 +565,6 @@ let GRID_LIMITS = {
519
565
  // PRICE_TOLERANCE_MIN_ABSOLUTE: Floor for the price tolerance cap in price units.
520
566
  // Ensures the cap is non-zero even for extremely cheap assets.
521
567
  PRICE_TOLERANCE_MIN_ABSOLUTE: 0.0001,
522
- // ORPHAN_ADOPTION_TOLERANCE_MULTIPLIER: Legacy fallback multiplier for calculatePriceTolerance
523
- // (sync_engine pass-2 before genesis). With genesis-frozen nearest-slot (slotIndexForPrice)
524
- // this multiplier is deprecated — deterministic slotId equality replaces widening. Kept for
525
- // migration fallback when genesis missing; otherwise unused.
526
- ORPHAN_ADOPTION_TOLERANCE_MULTIPLIER: 4,
527
568
  // GRID_REGENERATION_PERCENTAGE: Trigger threshold for automatic grid size recalculation.
528
569
  // Works in BOTH directions (bidirectional), sharing one threshold:
529
570
  // GROW: IF (availableFunds / allocatedCapital) x 100 >= threshold -> regenerate
@@ -648,10 +689,6 @@ let GRID_LIMITS = {
648
689
  // Example: 0.1 means two values are considered equal when diff < 0.1% of magnitude.
649
690
  // Note: Final blockchain update filtering still happens with integer precision checks.
650
691
  RELATIVE_ORDER_UPDATE_THRESHOLD_PERCENT: 0.1,
651
- // PRICE_DRIFT_TOLERANCE_MULTIPLIER: Legacy for price-drift-orphan tagging when genesis missing.
652
- // With genesis-frozen nearest-slot, drift is deterministic no-available-nearest-slot (gap/occupied)
653
- // not a tolerance band. Kept for diagnostics fallback only.
654
- PRICE_DRIFT_TOLERANCE_MULTIPLIER: 4,
655
692
  };
656
693
  // Increment percentage bounds for grid configuration
657
694
  let INCREMENT_BOUNDS = {
@@ -817,17 +854,27 @@ let FILL_PROCESSING = {
817
854
  // Reduced from 300s to 60s per tuning review: time-sensitive fills (e.g.,
818
855
  // credential daemon recovery) should not wait 5 minutes between retries.
819
856
  CONSUMER_BACKOFF_MAX_MS: 60000,
820
- // CORRECTION_MAX_UPDATES_PER_CYCLE: cap on sequential price-update
821
- // corrections drained per cycle. correctAllPriceMismatches holds _gridLock
822
- // (no acquisition timeout) and runs price updates sequentially with
823
- // SYNC_DELAY_MS between each, so an unbounded backlog can hold the lock
824
- // for minutes and starve every other waiter (the "Lock acquisition
825
- // timeout" cascade). Cancel-class entries (duplicate orphans / surplus /
826
- // type mismatch) are ALWAYS fully drained — they are batched with no
827
- // inter-op delay and are fund-safety-critical. Only the sequential
828
- // price-update loop is budgeted; the remainder stays queued durably and
829
- // re-drains on the next cycle.
830
- CORRECTION_MAX_UPDATES_PER_CYCLE: 5,
857
+ // CORRECTION_LOCK_HOLD_BUDGET_MS: wall-clock budget for the sequential
858
+ // price-update drain in correctAllPriceMismatches. That drain holds
859
+ // _gridLock (no acquisition timeout), so the invariant to protect is
860
+ // *lock-hold duration*, not update count: each update costs SYNC_DELAY_MS
861
+ // plus its RPC round-trip, and that round-trip grows with chain
862
+ // congestion. The drain stops pulling new updates once this much time has
863
+ // elapsed, so a slow chain drains fewer per cycle instead of holding the
864
+ // lock past the 20s fill-lock timeout (the "Lock acquisition timeout"
865
+ // cascade). Cancel-class entries (duplicate orphans / surplus / type
866
+ // mismatch) are ALWAYS fully drained — they are batched with no inter-op
867
+ // delay and are fund-safety-critical — and are never charged against this
868
+ // budget. Only the sequential price-update loop is budgeted; the
869
+ // remainder stays queued durably and re-drains on the next cycle.
870
+ CORRECTION_LOCK_HOLD_BUDGET_MS: 4000,
871
+ // CORRECTION_MAX_UPDATES_PER_CYCLE: optional hard cap on price updates
872
+ // drained per cycle, layered on top of CORRECTION_LOCK_HOLD_BUDGET_MS.
873
+ // Default null = no count cap (the hold-time budget alone governs, so the
874
+ // bound adapts to real RPC latency); a positive integer pins the count;
875
+ // 0 drains no price updates this cycle. Cancel-class entries are never
876
+ // budgeted by either knob.
877
+ CORRECTION_MAX_UPDATES_PER_CYCLE: null,
831
878
  // CORRECTION_QUEUE_WARN_THRESHOLD: emit a rate-limited warn when the
832
879
  // persisted correction queue reaches this size, so a growing backlog is
833
880
  // surfaced instead of silently starving placements.
@@ -1049,7 +1096,7 @@ let MARKET_ADAPTER = {
1049
1096
  // Lower values make the Kalman channel reach maximum influence more easily.
1050
1097
  // Higher values require a stronger move before the Kalman branch reaches full effect.
1051
1098
  // nob: kalS% (Kalman Max Slope %)
1052
- DYNAMIC_WEIGHT_KALMAN_MAX_SLOPE_PCT: 1.0,
1099
+ DYNAMIC_WEIGHT_KALMAN_MAX_SLOPE_PCT: 1.11,
1053
1100
  // DYNAMIC_WEIGHT_AMA_NEUTRAL_ZONE_PCT: Ignore small AMA moves around flat price action.
1054
1101
  // Higher values create a larger neutral zone and reduce small trend reactions.
1055
1102
  // Lower values make the AMA channel react to smaller moves.
@@ -1378,7 +1425,26 @@ let UPDATER = {
1378
1425
  // │ │ │ │ ┌────── day of week (0 - 6) (0 is Sunday)
1379
1426
  // │ │ │ │ │
1380
1427
  // 0 0 * * * (Default: Daily at midnight)
1381
- SCHEDULE: "0 0 * * *"
1428
+ SCHEDULE: "0 0 * * *",
1429
+ // ── Passive version NOTICE (modules/version_notice.ts) ──────────
1430
+ // Deliberately independent of ACTIVE: the notice never changes code, it
1431
+ // only tells the operator a newer release exists. Keeping it on a separate
1432
+ // switch means the default-off auto-updater does not also silence the
1433
+ // "you are running an outdated build" warning.
1434
+ NOTICE_ENABLED: true,
1435
+ // Minimum gap between registry probes (24h). Also throttles failures, so an
1436
+ // offline node pays the network timeout at most once a day, not per start.
1437
+ // Set 0 to probe on every launcher start (an explicit opt-in to always-check).
1438
+ NOTICE_INTERVAL_MS: 86_400_000,
1439
+ // Hard timeout for the registry request. The check never blocks startup,
1440
+ // but a hung socket must not keep the launcher alive either.
1441
+ NOTICE_TIMEOUT_MS: 2_000,
1442
+ // Shorter cap for `dexbot status`, which awaits the probe inline (no
1443
+ // startup work overlaps it), so a stale/offline probe cannot stall the
1444
+ // status output for the full NOTICE_TIMEOUT_MS.
1445
+ NOTICE_STATUS_TIMEOUT_MS: 750,
1446
+ // Registry document queried for the published `latest` version.
1447
+ REGISTRY_URL: "https://registry.npmjs.org/dexbot/latest"
1382
1448
  };
1383
1449
  let LAUNCHER = {
1384
1450
  MONOLITHIC: {
@@ -1840,11 +1906,24 @@ if (settings) {
1840
1906
  // Post-merge derivations: compute values from their documented relationships
1841
1907
  // so that user overrides to base constants propagate automatically.
1842
1908
  TIMING.SYNC_LOCK_FORCE_RELEASE_AGE_MS = TIMING.SYNC_LOCK_TIMEOUT_MS * 2;
1843
- // The fill-consumer deferral bound must outlast the stale-broadcast watchdog:
1844
- // a live region that runs longer than the bound would otherwise drop the
1845
- // consumer into the in-lock 30s wait (fill-lock acquisition timeout is 20s).
1846
- // Derive from the watchdog so overriding it propagates, keeping the margin.
1847
- TIMING.FILL_BROADCAST_DEFER_MAX_MS = Math.max(Number(TIMING.FILL_BROADCAST_DEFER_MAX_MS) > 0 ? Number(TIMING.FILL_BROADCAST_DEFER_MAX_MS) : 0, (Number(TIMING.BROADCAST_STALE_CLEAR_MS) > 0 ? Number(TIMING.BROADCAST_STALE_CLEAR_MS) : 120000) + 30000);
1909
+ // Broadcast deferral bounds are all expressed in terms of the single stale
1910
+ // authority (BROADCAST_STALE_CLEAR_MS): the maintenance-tick deferral uses it
1911
+ // directly (shouldDeferMaintenanceForBroadcast) and the fill-consumer bound is
1912
+ // staleClear + a named safety margin. Deriving rather than declaring keeps the
1913
+ // ordering invariant true by construction; the check below catches a future
1914
+ // edit or override that breaks it at load time instead of silently at runtime.
1915
+ const _broadcastStaleClearMs = Number(TIMING.BROADCAST_STALE_CLEAR_MS) > 0
1916
+ ? Number(TIMING.BROADCAST_STALE_CLEAR_MS)
1917
+ : 120000;
1918
+ const _broadcastDeferSafetyMarginMs = Number(TIMING.BROADCAST_DEFER_SAFETY_MARGIN_MS) > 0
1919
+ ? Number(TIMING.BROADCAST_DEFER_SAFETY_MARGIN_MS)
1920
+ : 30000;
1921
+ TIMING.FILL_BROADCAST_DEFER_MAX_MS = Math.max(Number(TIMING.FILL_BROADCAST_DEFER_MAX_MS) > 0 ? Number(TIMING.FILL_BROADCAST_DEFER_MAX_MS) : 0, _broadcastStaleClearMs + _broadcastDeferSafetyMarginMs);
1922
+ if (!(Number(TIMING.FILL_BROADCAST_DEFER_MAX_MS) > _broadcastStaleClearMs)) {
1923
+ throw new Error(`[constants] invariant violated: FILL_BROADCAST_DEFER_MAX_MS (${TIMING.FILL_BROADCAST_DEFER_MAX_MS}) ` +
1924
+ `must exceed BROADCAST_STALE_CLEAR_MS (${_broadcastStaleClearMs}) — the fill-consumer deferral bound ` +
1925
+ `must outlast the stale-broadcast watchdog.`);
1926
+ }
1848
1927
  // Freeze objects to prevent accidental runtime modifications
1849
1928
  Object.freeze(ORDER_TYPES);
1850
1929
  Object.freeze(ORDER_STATES);
@@ -125,8 +125,6 @@ declare class DEXBot {
125
125
  _maintenanceCooldownCycles: number;
126
126
  _lastGridActivityAt: number;
127
127
  _currentCycleId: number;
128
- _autoCancelOrphanCycleMarker: number | null;
129
- _autoCancelOrphanSubCount: number;
130
128
  _consecutiveConsumeFailures: number;
131
129
  _consumeFailureFirstAt: number;
132
130
  _reconnectUnregister: any;
@@ -275,9 +273,15 @@ declare class DEXBot {
275
273
  _recoverFromPersistedGrid(): Promise<{
276
274
  success: boolean;
277
275
  reason: string;
276
+ halt?: undefined;
278
277
  } | {
279
278
  success: boolean;
280
279
  reason?: undefined;
280
+ halt?: undefined;
281
+ } | {
282
+ success: boolean;
283
+ reason: string;
284
+ halt: boolean;
281
285
  }>;
282
286
  /**
283
287
  * Reject a corrupted grid snapshot when catastrophic fund drift is detected.
@@ -655,80 +659,6 @@ declare class DEXBot {
655
659
  * @returns {Promise<Object>} Result object compatible with batch return shape
656
660
  */
657
661
  _reconcileAfterUncertainBroadcast(err: any, opContexts: any, options?: Record<string, any>): Promise<any>;
658
- /**
659
- * Auto-cancel a price-drift orphan from the unmatched-order snapshot.
660
- *
661
- * Only cancels entries with reason === 'price-drift-orphan' — these are
662
- * surplus orders that drifted away from their slot price and have no
663
- * adoptable grid slot. All other unmatched orders (duplicate-price-level,
664
- * already-matched-slot, etc.) are adoptable positions that the structural
665
- * resync will integrate into the grid; cancelling them destroys capital.
666
- *
667
- * This is the post-recovery safety net: if, after
668
- * _reconcileAfterUncertainBroadcast runs, there are still price-drift
669
- * orphans, cancel ONE per cycle. Per-cycle cap = 1 (or 5 in recovery mode)
670
- * — the next cycle will pick up the next orphan if more remain.
671
- *
672
- * Safety conditions (ALL must hold):
673
- * 1. _pendingBroadcasts is empty (no in-flight recovery)
674
- * 2. _lastUnmatchedChainOrders contains at least one price-drift-orphan
675
- * 3. The current cycle has not already auto-cancelled an orphan
676
- * (tracked via this._autoCancelOrphanCycleMarker)
677
- *
678
- * Records the cancel via _recordOwnCancelOps so the fill consumer
679
- * doesn't trip the self-cancel guard.
680
- *
681
- * @returns {Promise<{cancelled: boolean, orderId?: string, reason?: string}>}
682
- */
683
- _autoCancelOneUnmatchedOrphan(): Promise<{
684
- cancelled: boolean;
685
- reason: string;
686
- subCount: any;
687
- message?: undefined;
688
- slotId?: undefined;
689
- orderId?: undefined;
690
- error?: undefined;
691
- } | {
692
- cancelled: boolean;
693
- reason: string;
694
- subCount?: undefined;
695
- message?: undefined;
696
- slotId?: undefined;
697
- orderId?: undefined;
698
- error?: undefined;
699
- } | {
700
- cancelled: boolean;
701
- reason: string;
702
- message: string;
703
- subCount?: undefined;
704
- slotId?: undefined;
705
- orderId?: undefined;
706
- error?: undefined;
707
- } | {
708
- cancelled: boolean;
709
- reason: string;
710
- slotId: any;
711
- subCount?: undefined;
712
- message?: undefined;
713
- orderId?: undefined;
714
- error?: undefined;
715
- } | {
716
- cancelled: boolean;
717
- orderId: any;
718
- reason?: undefined;
719
- subCount?: undefined;
720
- message?: undefined;
721
- slotId?: undefined;
722
- error?: undefined;
723
- } | {
724
- cancelled: boolean;
725
- reason: string;
726
- error: any;
727
- subCount?: undefined;
728
- message?: undefined;
729
- slotId?: undefined;
730
- orderId?: undefined;
731
- }>;
732
662
  /**
733
663
  * Execute operations with retry on BroadcastUncertainError.
734
664
  * The daemon already retries internally against a 25s deadline. If it
@@ -152,8 +152,6 @@ class DEXBot {
152
152
  _maintenanceCooldownCycles;
153
153
  _lastGridActivityAt;
154
154
  _currentCycleId;
155
- _autoCancelOrphanCycleMarker;
156
- _autoCancelOrphanSubCount;
157
155
  _consecutiveConsumeFailures;
158
156
  _consumeFailureFirstAt;
159
157
  _reconnectUnregister;
@@ -268,8 +266,6 @@ class DEXBot {
268
266
  this._lastGridActivityAt = 0;
269
267
  this._lastDeferredDustCount = 0;
270
268
  this._currentCycleId = 0;
271
- this._autoCancelOrphanCycleMarker = null;
272
- this._autoCancelOrphanSubCount = 0;
273
269
  // Dust cancellation is driven by the periodic dust health-check timer
274
270
  // (setupDustHealthCheckInterval) rather than per-dust state maps.
275
271
  this._dustHealthCheckTimer = null;
@@ -912,34 +908,6 @@ class DEXBot {
912
908
  async _reconcileAfterUncertainBroadcast(err, opContexts, options = {}) {
913
909
  return cowRuntime.reconcileAfterUncertainBroadcast(this, err, opContexts, options);
914
910
  }
915
- /**
916
- * Auto-cancel a price-drift orphan from the unmatched-order snapshot.
917
- *
918
- * Only cancels entries with reason === 'price-drift-orphan' — these are
919
- * surplus orders that drifted away from their slot price and have no
920
- * adoptable grid slot. All other unmatched orders (duplicate-price-level,
921
- * already-matched-slot, etc.) are adoptable positions that the structural
922
- * resync will integrate into the grid; cancelling them destroys capital.
923
- *
924
- * This is the post-recovery safety net: if, after
925
- * _reconcileAfterUncertainBroadcast runs, there are still price-drift
926
- * orphans, cancel ONE per cycle. Per-cycle cap = 1 (or 5 in recovery mode)
927
- * — the next cycle will pick up the next orphan if more remain.
928
- *
929
- * Safety conditions (ALL must hold):
930
- * 1. _pendingBroadcasts is empty (no in-flight recovery)
931
- * 2. _lastUnmatchedChainOrders contains at least one price-drift-orphan
932
- * 3. The current cycle has not already auto-cancelled an orphan
933
- * (tracked via this._autoCancelOrphanCycleMarker)
934
- *
935
- * Records the cancel via _recordOwnCancelOps so the fill consumer
936
- * doesn't trip the self-cancel guard.
937
- *
938
- * @returns {Promise<{cancelled: boolean, orderId?: string, reason?: string}>}
939
- */
940
- async _autoCancelOneUnmatchedOrphan() {
941
- return cowRuntime.autoCancelOneUnmatchedOrphan(this);
942
- }
943
911
  /**
944
912
  * Execute operations with retry on BroadcastUncertainError.
945
913
  * The daemon already retries internally against a 25s deadline. If it
@@ -164,60 +164,6 @@ declare function restoreDiscardedCreates(bot: any, discarded: any[], opContexts:
164
164
  * @returns {Promise<Object>}
165
165
  */
166
166
  declare function reconcileAfterUncertainBroadcastImpl(bot: any, err: any, opContexts: any, _options: any): Promise<any>;
167
- /**
168
- * Auto-cancel one unmatched orphan (price-drift orphan) per cycle.
169
- * @param {import('./dexbot_class.js').DEXBot} bot
170
- * @returns {Promise<{cancelled: boolean, reason?: string, orderId?: string}>}
171
- */
172
- declare function autoCancelOneUnmatchedOrphan(bot: any): Promise<{
173
- cancelled: boolean;
174
- reason: string;
175
- subCount: any;
176
- message?: undefined;
177
- slotId?: undefined;
178
- orderId?: undefined;
179
- error?: undefined;
180
- } | {
181
- cancelled: boolean;
182
- reason: string;
183
- subCount?: undefined;
184
- message?: undefined;
185
- slotId?: undefined;
186
- orderId?: undefined;
187
- error?: undefined;
188
- } | {
189
- cancelled: boolean;
190
- reason: string;
191
- message: string;
192
- subCount?: undefined;
193
- slotId?: undefined;
194
- orderId?: undefined;
195
- error?: undefined;
196
- } | {
197
- cancelled: boolean;
198
- reason: string;
199
- slotId: any;
200
- subCount?: undefined;
201
- message?: undefined;
202
- orderId?: undefined;
203
- error?: undefined;
204
- } | {
205
- cancelled: boolean;
206
- orderId: any;
207
- reason?: undefined;
208
- subCount?: undefined;
209
- message?: undefined;
210
- slotId?: undefined;
211
- error?: undefined;
212
- } | {
213
- cancelled: boolean;
214
- reason: string;
215
- error: any;
216
- subCount?: undefined;
217
- message?: undefined;
218
- slotId?: undefined;
219
- orderId?: undefined;
220
- }>;
221
167
  /**
222
168
  * Check whether to execute creates in outside-in pair mode.
223
169
  * @param {import('./dexbot_class.js').DEXBot} bot
@@ -354,11 +300,11 @@ declare function checkGridPriceInvariant(slotId: any, price: any, genesis: any):
354
300
  * copies from the destination hole's `order.price` and which is therefore only
355
301
  * as sound as whatever last wrote that object. Deriving the emitted price here
356
302
  * means a planner bug cannot produce a mis-priced UPDATE on its own; the
357
- * invariant check remains as the backstop for the no-genesis case.
303
+ * invariant check remains as the backstop.
358
304
  *
359
305
  * @returns {number} the destination's genesis level, or NaN when there is no
360
306
  * genesis ladder / no parseable destination index (caller falls back to the
361
- * planned price, which is the migration case the checker fails open on).
307
+ * planned price — an undefined grid, which the load and sync gates refuse).
362
308
  */
363
309
  declare function deriveRotationPrice(bot: any, newGridId: any): number;
364
310
  /**
@@ -621,7 +567,7 @@ declare function processBatchResults(bot: any, result: any, opContexts: any): Pr
621
567
  hadRotation: boolean;
622
568
  updateOperationCount: number;
623
569
  }>;
624
- export { isLastFillGuardBlocked, resolveOnGridPivot, checkGridPriceInvariant, deriveRotationPrice, refreshLastFillPivotFromQueue, runFinalPivotGate, buildOutsideInPairGroupsForOrders, buildOutsideInPairGroupsForCreateEntries, markMissingCreateResultsAsStructuralBlocker, formatUnmatchedChainOrderForLog, recordPendingBroadcast, clearPendingBroadcasts, popPushedWorkingGrid, findChainOrderForSlot, reconcileAfterUncertainBroadcast, reconcileAfterUncertainBroadcastImpl, autoCancelOneUnmatchedOrphan, executeWithRetryOnUncertain, executeChunkedWithRetryOnUncertain, formatPartialBroadcastSummary, executeOperationsWithStrategy, buildActionsFromPlan, buildCowResultFromPlan, applyRotationTransitionsToWorkingGrid, pollChainForConfirmation, updateOrdersOnChainBatchCOW, processBatchResults, adoptPlacedBatchFromChain, resolveRefillBoundaryHold, toRefillSlotIdSet, trackBoundaryHold };
570
+ export { isLastFillGuardBlocked, resolveOnGridPivot, checkGridPriceInvariant, deriveRotationPrice, refreshLastFillPivotFromQueue, runFinalPivotGate, buildOutsideInPairGroupsForOrders, buildOutsideInPairGroupsForCreateEntries, markMissingCreateResultsAsStructuralBlocker, formatUnmatchedChainOrderForLog, recordPendingBroadcast, clearPendingBroadcasts, popPushedWorkingGrid, findChainOrderForSlot, reconcileAfterUncertainBroadcast, reconcileAfterUncertainBroadcastImpl, executeWithRetryOnUncertain, executeChunkedWithRetryOnUncertain, formatPartialBroadcastSummary, executeOperationsWithStrategy, buildActionsFromPlan, buildCowResultFromPlan, applyRotationTransitionsToWorkingGrid, pollChainForConfirmation, updateOrdersOnChainBatchCOW, processBatchResults, adoptPlacedBatchFromChain, resolveRefillBoundaryHold, toRefillSlotIdSet, trackBoundaryHold };
625
571
  export { restoreDiscardedCreates };
626
572
  declare const _default: {
627
573
  buildOutsideInPairGroupsForOrders: typeof buildOutsideInPairGroupsForOrders;
@@ -639,7 +585,6 @@ declare const _default: {
639
585
  findChainOrderForSlot: typeof findChainOrderForSlot;
640
586
  reconcileAfterUncertainBroadcast: typeof reconcileAfterUncertainBroadcast;
641
587
  reconcileAfterUncertainBroadcastImpl: typeof reconcileAfterUncertainBroadcastImpl;
642
- autoCancelOneUnmatchedOrphan: typeof autoCancelOneUnmatchedOrphan;
643
588
  shouldExecuteCreatePairMode: typeof shouldExecuteCreatePairMode;
644
589
  executeWithRetryOnUncertain: typeof executeWithRetryOnUncertain;
645
590
  executeChunkedWithRetryOnUncertain: typeof executeChunkedWithRetryOnUncertain;