dexbot 1.6.6 → 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 (632) hide show
  1. package/CHANGELOG.md +89 -1
  2. package/README.md +8 -5
  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 +44 -15
  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 +20 -9
  25. package/dist/modules/account_orders.d.ts +44 -4
  26. package/dist/modules/account_orders.js +104 -7
  27. package/dist/modules/bitshares-native/chain_client.d.ts +10 -0
  28. package/dist/modules/bitshares-native/chain_client.js +197 -28
  29. package/dist/modules/bitshares-native/subscriptions.js +312 -10
  30. package/dist/modules/bitshares-native/transport.d.ts +1 -0
  31. package/dist/modules/bitshares-native/transport.js +97 -3
  32. package/dist/modules/bitshares_client.d.ts +20 -0
  33. package/dist/modules/bitshares_client.js +29 -0
  34. package/dist/modules/bot_settings.js +10 -1
  35. package/dist/modules/chain_keys.d.ts +37 -22
  36. package/dist/modules/chain_keys.js +145 -44
  37. package/dist/modules/cli_start_onboarding.d.ts +10 -0
  38. package/dist/modules/cli_start_onboarding.js +15 -0
  39. package/dist/modules/cli_start_output.d.ts +6 -0
  40. package/dist/modules/cli_start_output.js +8 -0
  41. package/dist/modules/config.d.ts +1 -0
  42. package/dist/modules/config.js +1 -0
  43. package/dist/modules/constants.d.ts +23 -2
  44. package/dist/modules/constants.js +196 -15
  45. package/dist/modules/dexbot_class.d.ts +6 -76
  46. package/dist/modules/dexbot_class.js +0 -32
  47. package/dist/modules/dexbot_cow_runtime.d.ts +3 -58
  48. package/dist/modules/dexbot_cow_runtime.js +53 -96
  49. package/dist/modules/dexbot_fill_runtime.d.ts +6 -1
  50. package/dist/modules/dexbot_fill_runtime.js +22 -3
  51. package/dist/modules/dexbot_maintenance_runtime.d.ts +38 -1
  52. package/dist/modules/dexbot_maintenance_runtime.js +103 -11
  53. package/dist/modules/dexbot_startup_runtime.js +73 -20
  54. package/dist/modules/dexbot_state_recovery.d.ts +6 -0
  55. package/dist/modules/dexbot_state_recovery.js +34 -1
  56. package/dist/modules/order/async_lock.d.ts +8 -0
  57. package/dist/modules/order/async_lock.js +15 -0
  58. package/dist/modules/order/genesis_policy.d.ts +162 -0
  59. package/dist/modules/order/genesis_policy.js +267 -0
  60. package/dist/modules/order/grid.js +109 -135
  61. package/dist/modules/order/grid_reconcile.d.ts +9 -0
  62. package/dist/modules/order/grid_reconcile.js +13 -4
  63. package/dist/modules/order/grid_reconcile_internal.js +13 -2
  64. package/dist/modules/order/logger.d.ts +12 -2
  65. package/dist/modules/order/logger.js +29 -7
  66. package/dist/modules/order/manager.d.ts +53 -0
  67. package/dist/modules/order/manager.js +86 -25
  68. package/dist/modules/order/sync_engine.d.ts +19 -0
  69. package/dist/modules/order/sync_engine.js +284 -344
  70. package/dist/modules/order/utils/math.d.ts +22 -1
  71. package/dist/modules/order/utils/math.js +64 -1
  72. package/dist/modules/order/utils/order.d.ts +43 -58
  73. package/dist/modules/order/utils/order.js +302 -194
  74. package/dist/modules/order/utils/system.d.ts +97 -0
  75. package/dist/modules/order/utils/system.js +282 -3
  76. package/dist/modules/paths.d.ts +8 -1
  77. package/dist/modules/paths.js +11 -3
  78. package/dist/modules/utils/text_width.d.ts +19 -0
  79. package/dist/modules/utils/text_width.js +97 -0
  80. package/dist/modules/version_notice.d.ts +165 -0
  81. package/dist/modules/version_notice.js +364 -0
  82. package/dist/pm2.js +104 -18
  83. package/dist/scripts/update.js +62 -13
  84. package/dist/unlock.d.ts +14 -2
  85. package/dist/unlock.js +101 -4
  86. package/docs/BITSHARES_ONBOARDING.md +8 -1
  87. package/docs/COW_INVARIANTS.md +11 -2
  88. package/docs/CREDENTIAL_SECURITY.md +26 -0
  89. package/docs/DEXBOT_COMPARISON.md +4 -4
  90. package/docs/EVOLUTION.md +20 -18
  91. package/docs/FUND_MOVEMENT_AND_ACCOUNTING.md +1 -1
  92. package/docs/GRID_PRICE_INVARIANT.md +204 -31
  93. package/docs/GRID_RECALCULATION.md +12 -0
  94. package/docs/LOGGING.md +17 -2
  95. package/docs/ORDER_ENGINE_POST_1.0_RETROSPECTIVE.md +6 -7
  96. package/docs/README.md +3 -1
  97. package/docs/WORKFLOW.md +16 -5
  98. package/market_adapter/README.md +1 -1
  99. package/modules/README.md +18 -1
  100. package/package.json +14 -6
  101. package/scripts/README.md +28 -2
  102. package/scripts/clear-all.sh +13 -4
  103. package/scripts/clear-logs.sh +13 -4
  104. package/scripts/clear-market-adapter.sh +6 -0
  105. package/scripts/clear-orders.sh +5 -0
  106. package/scripts/lib/dexbot-paths.sh +108 -0
  107. package/tests/README.md +11 -3
  108. package/analysis/account_resolver.ts +0 -161
  109. package/analysis/ama_fitting/analyze_ama_price_changes.ts +0 -155
  110. package/analysis/ama_fitting/analyze_lambda_vs_slow.ts +0 -404
  111. package/analysis/ama_fitting/calibrate_convergence_er.ts +0 -201
  112. package/analysis/ama_fitting/fetch_lp_candles.ts +0 -184
  113. package/analysis/ama_fitting/generate_unified_comparison_chart.ts +0 -232
  114. package/analysis/ama_fitting/optimizer_high_resolution.ts +0 -802
  115. package/analysis/analyze_dynamic_weight.ts +0 -243
  116. package/analysis/analyze_kalman.ts +0 -157
  117. package/analysis/analyze_regime.ts +0 -158
  118. package/analysis/analyze_regime_windows.ts +0 -470
  119. package/analysis/analyze_risk_profile.ts +0 -199
  120. package/analysis/analyze_trade_heatmap.ts +0 -362
  121. package/analysis/analyze_volatility.ts +0 -182
  122. package/analysis/bot_fitting/backtest_ama_sweep.ts +0 -934
  123. package/analysis/bot_fitting/backtest_bot_fitting.ts +0 -861
  124. package/analysis/bot_fitting/shared_utils.ts +0 -52
  125. package/analysis/bot_key_utils.ts +0 -426
  126. package/analysis/bot_usage/discover_bot_accounts.ts +0 -635
  127. package/analysis/bot_usage/kibana_bot_queries.ts +0 -211
  128. package/analysis/chain_pool.ts +0 -47
  129. package/analysis/chart_css.ts +0 -62
  130. package/analysis/chart_ui.ts +0 -105
  131. package/analysis/chart_utils.ts +0 -210
  132. package/analysis/fills_source.ts +0 -228
  133. package/analysis/grid_correction_check.ts +0 -786
  134. package/analysis/math_utils.ts +0 -53
  135. package/analysis/price_sources.ts +0 -136
  136. package/analysis/resolve_bot_accounts.ts +0 -199
  137. package/analysis/resolve_source.ts +0 -99
  138. package/analysis/results/ama_sweep_results_lp_pool_133_1h.json +0 -2455
  139. package/analysis/results/bot_fitting_results_lp_pool_133_1h.json +0 -218
  140. package/analysis/trade_profitability.ts +0 -1335
  141. package/analysis/tradingview/analyze_tradingview.ts +0 -280
  142. package/analysis/tradingview/h-bts_tradingview.html +0 -1570
  143. package/analysis/tradingview/t-bts_tradingview.html +0 -1570
  144. package/analysis/tradingview/tradingview_uplot_chart_generator.ts +0 -3268
  145. package/analysis/trend_detection/dynamic_weight_chart_generator.ts +0 -1481
  146. package/analysis/trend_detection/hurst_analyzer.ts +0 -7
  147. package/analysis/trend_detection/kalman_chart_generator.ts +0 -398
  148. package/analysis/trend_detection/kalman_trend_analyzer.ts +0 -9
  149. package/analysis/trend_detection/kalman_velocity_smoothing.ts +0 -7
  150. package/analysis/trend_detection/package.json +0 -23
  151. package/analysis/trend_detection/permutation_entropy_analyzer.ts +0 -7
  152. package/analysis/trend_detection/regime_chart_generator.ts +0 -338
  153. package/analysis/trend_detection/tests/test_kalman_trend.ts +0 -153
  154. package/analysis/trend_detection/tests/test_kalman_velocity_smoothing.ts +0 -64
  155. package/analysis/trend_detection/volatility_chart_generator.ts +0 -654
  156. package/analysis/tsconfig.json +0 -29
  157. package/claw/tests/package.json +0 -3
  158. package/claw/tests/test_claw_bridge.ts +0 -570
  159. package/claw/tests/test_claw_catalog_and_credentials.ts +0 -156
  160. package/claw/tests/test_claw_chain_layer.ts +0 -739
  161. package/claw/tests/test_claw_data_flow.ts +0 -525
  162. package/claw/tests/test_claw_domain_logic.ts +0 -471
  163. package/claw/tests/test_claw_manifest_and_matrix.ts +0 -222
  164. package/claw/tests/test_claw_mcp_transport.ts +0 -243
  165. package/claw/tests/test_claw_regressions.ts +0 -711
  166. package/claw/tests/test_claw_skill_generation.ts +0 -103
  167. package/claw/tests/test_claw_state_store.ts +0 -44
  168. package/claw/tests/test_dexbot_profiles.ts +0 -654
  169. package/claw/tests/test_memu_bridge.ts +0 -189
  170. package/claw/tests/test_nullclaw_tmp_integration.ts +0 -57
  171. package/claw/tests/test_position_health.ts +0 -343
  172. package/claw/tests/test_position_manager.ts +0 -429
  173. package/claw/tests/test_position_manager_watch_health.ts +0 -100
  174. package/claw/tests/test_short_mpa_strategy.ts +0 -232
  175. package/dist/analysis/account_resolver.d.ts.map +0 -1
  176. package/dist/analysis/account_resolver.js.map +0 -1
  177. package/dist/analysis/ama_fitting/analyze_ama_price_changes.d.ts.map +0 -1
  178. package/dist/analysis/ama_fitting/analyze_ama_price_changes.js.map +0 -1
  179. package/dist/analysis/ama_fitting/analyze_lambda_vs_slow.d.ts.map +0 -1
  180. package/dist/analysis/ama_fitting/analyze_lambda_vs_slow.js.map +0 -1
  181. package/dist/analysis/ama_fitting/calibrate_convergence_er.d.ts.map +0 -1
  182. package/dist/analysis/ama_fitting/calibrate_convergence_er.js.map +0 -1
  183. package/dist/analysis/ama_fitting/fetch_lp_candles.d.ts.map +0 -1
  184. package/dist/analysis/ama_fitting/fetch_lp_candles.js.map +0 -1
  185. package/dist/analysis/ama_fitting/generate_unified_comparison_chart.d.ts.map +0 -1
  186. package/dist/analysis/ama_fitting/generate_unified_comparison_chart.js.map +0 -1
  187. package/dist/analysis/ama_fitting/optimizer_high_resolution.d.ts.map +0 -1
  188. package/dist/analysis/ama_fitting/optimizer_high_resolution.js.map +0 -1
  189. package/dist/analysis/analyze_dynamic_weight.d.ts.map +0 -1
  190. package/dist/analysis/analyze_dynamic_weight.js.map +0 -1
  191. package/dist/analysis/analyze_kalman.d.ts.map +0 -1
  192. package/dist/analysis/analyze_kalman.js.map +0 -1
  193. package/dist/analysis/analyze_regime.d.ts.map +0 -1
  194. package/dist/analysis/analyze_regime.js.map +0 -1
  195. package/dist/analysis/analyze_regime_windows.d.ts.map +0 -1
  196. package/dist/analysis/analyze_regime_windows.js.map +0 -1
  197. package/dist/analysis/analyze_risk_profile.d.ts.map +0 -1
  198. package/dist/analysis/analyze_risk_profile.js.map +0 -1
  199. package/dist/analysis/analyze_trade_heatmap.d.ts.map +0 -1
  200. package/dist/analysis/analyze_trade_heatmap.js.map +0 -1
  201. package/dist/analysis/analyze_volatility.d.ts.map +0 -1
  202. package/dist/analysis/analyze_volatility.js.map +0 -1
  203. package/dist/analysis/bot_fitting/backtest_ama_sweep.d.ts.map +0 -1
  204. package/dist/analysis/bot_fitting/backtest_ama_sweep.js.map +0 -1
  205. package/dist/analysis/bot_fitting/backtest_bot_fitting.d.ts.map +0 -1
  206. package/dist/analysis/bot_fitting/backtest_bot_fitting.js.map +0 -1
  207. package/dist/analysis/bot_fitting/shared_utils.d.ts.map +0 -1
  208. package/dist/analysis/bot_fitting/shared_utils.js.map +0 -1
  209. package/dist/analysis/bot_key_utils.d.ts.map +0 -1
  210. package/dist/analysis/bot_key_utils.js.map +0 -1
  211. package/dist/analysis/bot_usage/discover_bot_accounts.d.ts.map +0 -1
  212. package/dist/analysis/bot_usage/discover_bot_accounts.js.map +0 -1
  213. package/dist/analysis/bot_usage/kibana_bot_queries.d.ts.map +0 -1
  214. package/dist/analysis/bot_usage/kibana_bot_queries.js.map +0 -1
  215. package/dist/analysis/chain_pool.d.ts.map +0 -1
  216. package/dist/analysis/chain_pool.js.map +0 -1
  217. package/dist/analysis/chart_css.d.ts.map +0 -1
  218. package/dist/analysis/chart_css.js.map +0 -1
  219. package/dist/analysis/chart_ui.d.ts.map +0 -1
  220. package/dist/analysis/chart_ui.js.map +0 -1
  221. package/dist/analysis/chart_utils.d.ts.map +0 -1
  222. package/dist/analysis/chart_utils.js.map +0 -1
  223. package/dist/analysis/fills_source.d.ts.map +0 -1
  224. package/dist/analysis/fills_source.js.map +0 -1
  225. package/dist/analysis/grid_correction_check.d.ts.map +0 -1
  226. package/dist/analysis/grid_correction_check.js.map +0 -1
  227. package/dist/analysis/math_utils.d.ts.map +0 -1
  228. package/dist/analysis/math_utils.js.map +0 -1
  229. package/dist/analysis/price_sources.d.ts.map +0 -1
  230. package/dist/analysis/price_sources.js.map +0 -1
  231. package/dist/analysis/resolve_bot_accounts.d.ts.map +0 -1
  232. package/dist/analysis/resolve_bot_accounts.js.map +0 -1
  233. package/dist/analysis/resolve_source.d.ts.map +0 -1
  234. package/dist/analysis/resolve_source.js.map +0 -1
  235. package/dist/analysis/trade_profitability.d.ts.map +0 -1
  236. package/dist/analysis/trade_profitability.js.map +0 -1
  237. package/dist/analysis/tradingview/analyze_tradingview.d.ts.map +0 -1
  238. package/dist/analysis/tradingview/analyze_tradingview.js.map +0 -1
  239. package/dist/analysis/tradingview/tradingview_uplot_chart_generator.d.ts.map +0 -1
  240. package/dist/analysis/tradingview/tradingview_uplot_chart_generator.js.map +0 -1
  241. package/dist/analysis/trend_detection/dynamic_weight_chart_generator.d.ts.map +0 -1
  242. package/dist/analysis/trend_detection/dynamic_weight_chart_generator.js.map +0 -1
  243. package/dist/analysis/trend_detection/hurst_analyzer.d.ts.map +0 -1
  244. package/dist/analysis/trend_detection/hurst_analyzer.js.map +0 -1
  245. package/dist/analysis/trend_detection/kalman_chart_generator.d.ts.map +0 -1
  246. package/dist/analysis/trend_detection/kalman_chart_generator.js.map +0 -1
  247. package/dist/analysis/trend_detection/kalman_trend_analyzer.d.ts.map +0 -1
  248. package/dist/analysis/trend_detection/kalman_trend_analyzer.js.map +0 -1
  249. package/dist/analysis/trend_detection/kalman_velocity_smoothing.d.ts.map +0 -1
  250. package/dist/analysis/trend_detection/kalman_velocity_smoothing.js.map +0 -1
  251. package/dist/analysis/trend_detection/permutation_entropy_analyzer.d.ts.map +0 -1
  252. package/dist/analysis/trend_detection/permutation_entropy_analyzer.js.map +0 -1
  253. package/dist/analysis/trend_detection/regime_chart_generator.d.ts.map +0 -1
  254. package/dist/analysis/trend_detection/regime_chart_generator.js.map +0 -1
  255. package/dist/analysis/trend_detection/tests/test_kalman_trend.d.ts +0 -2
  256. package/dist/analysis/trend_detection/tests/test_kalman_trend.d.ts.map +0 -1
  257. package/dist/analysis/trend_detection/tests/test_kalman_trend.js +0 -128
  258. package/dist/analysis/trend_detection/tests/test_kalman_trend.js.map +0 -1
  259. package/dist/analysis/trend_detection/tests/test_kalman_velocity_smoothing.d.ts +0 -2
  260. package/dist/analysis/trend_detection/tests/test_kalman_velocity_smoothing.d.ts.map +0 -1
  261. package/dist/analysis/trend_detection/tests/test_kalman_velocity_smoothing.js +0 -37
  262. package/dist/analysis/trend_detection/tests/test_kalman_velocity_smoothing.js.map +0 -1
  263. package/dist/analysis/trend_detection/volatility_chart_generator.d.ts.map +0 -1
  264. package/dist/analysis/trend_detection/volatility_chart_generator.js.map +0 -1
  265. package/dist/bot.d.ts.map +0 -1
  266. package/dist/bot.js.map +0 -1
  267. package/dist/credential-daemon.d.ts.map +0 -1
  268. package/dist/credential-daemon.js.map +0 -1
  269. package/dist/dexbot.d.ts.map +0 -1
  270. package/dist/dexbot.js.map +0 -1
  271. package/dist/market_adapter/ama_signal_runner.d.ts.map +0 -1
  272. package/dist/market_adapter/ama_signal_runner.js.map +0 -1
  273. package/dist/market_adapter/candle_utils.d.ts.map +0 -1
  274. package/dist/market_adapter/candle_utils.js.map +0 -1
  275. package/dist/market_adapter/core/asymmetric_bounds.d.ts.map +0 -1
  276. package/dist/market_adapter/core/asymmetric_bounds.js.map +0 -1
  277. package/dist/market_adapter/core/config_normalizers.d.ts.map +0 -1
  278. package/dist/market_adapter/core/config_normalizers.js.map +0 -1
  279. package/dist/market_adapter/core/kibana_candles.d.ts.map +0 -1
  280. package/dist/market_adapter/core/kibana_candles.js.map +0 -1
  281. package/dist/market_adapter/core/kibana_client.d.ts.map +0 -1
  282. package/dist/market_adapter/core/kibana_client.js.map +0 -1
  283. package/dist/market_adapter/core/kibana_market_candles.d.ts.map +0 -1
  284. package/dist/market_adapter/core/kibana_market_candles.js.map +0 -1
  285. package/dist/market_adapter/core/market_adapter_service.d.ts.map +0 -1
  286. package/dist/market_adapter/core/market_adapter_service.js.map +0 -1
  287. package/dist/market_adapter/core/signals/hurst_analyzer.d.ts.map +0 -1
  288. package/dist/market_adapter/core/signals/hurst_analyzer.js.map +0 -1
  289. package/dist/market_adapter/core/signals/kalman_trend_analyzer.d.ts.map +0 -1
  290. package/dist/market_adapter/core/signals/kalman_trend_analyzer.js.map +0 -1
  291. package/dist/market_adapter/core/signals/kalman_velocity_smoothing.d.ts.map +0 -1
  292. package/dist/market_adapter/core/signals/kalman_velocity_smoothing.js.map +0 -1
  293. package/dist/market_adapter/core/signals/permutation_entropy_analyzer.d.ts.map +0 -1
  294. package/dist/market_adapter/core/signals/permutation_entropy_analyzer.js.map +0 -1
  295. package/dist/market_adapter/core/strategies/ama.d.ts.map +0 -1
  296. package/dist/market_adapter/core/strategies/ama.js.map +0 -1
  297. package/dist/market_adapter/core/strategies/ama_slope_model.d.ts.map +0 -1
  298. package/dist/market_adapter/core/strategies/ama_slope_model.js.map +0 -1
  299. package/dist/market_adapter/core/strategies/atr/calculator.d.ts.map +0 -1
  300. package/dist/market_adapter/core/strategies/atr/calculator.js.map +0 -1
  301. package/dist/market_adapter/core/strategies/collateral_manager.d.ts.map +0 -1
  302. package/dist/market_adapter/core/strategies/collateral_manager.js.map +0 -1
  303. package/dist/market_adapter/core/strategies/dynamic_weight_series.d.ts.map +0 -1
  304. package/dist/market_adapter/core/strategies/dynamic_weight_series.js.map +0 -1
  305. package/dist/market_adapter/core/strategies/regime_gate.d.ts.map +0 -1
  306. package/dist/market_adapter/core/strategies/regime_gate.js.map +0 -1
  307. package/dist/market_adapter/core/strategies/regime_interp.d.ts.map +0 -1
  308. package/dist/market_adapter/core/strategies/regime_interp.js.map +0 -1
  309. package/dist/market_adapter/core/strategies/volatility_shift.d.ts.map +0 -1
  310. package/dist/market_adapter/core/strategies/volatility_shift.js.map +0 -1
  311. package/dist/market_adapter/inputs/fetch_book_data.d.ts.map +0 -1
  312. package/dist/market_adapter/inputs/fetch_book_data.js.map +0 -1
  313. package/dist/market_adapter/inputs/fetch_cex_synthetic_data.d.ts.map +0 -1
  314. package/dist/market_adapter/inputs/fetch_cex_synthetic_data.js.map +0 -1
  315. package/dist/market_adapter/inputs/fetch_lp_data.d.ts.map +0 -1
  316. package/dist/market_adapter/inputs/fetch_lp_data.js.map +0 -1
  317. package/dist/market_adapter/inputs/kibana_feed_source.d.ts.map +0 -1
  318. package/dist/market_adapter/inputs/kibana_feed_source.js.map +0 -1
  319. package/dist/market_adapter/inputs/kibana_source.d.ts.map +0 -1
  320. package/dist/market_adapter/inputs/kibana_source.js.map +0 -1
  321. package/dist/market_adapter/inputs/window_cache.d.ts.map +0 -1
  322. package/dist/market_adapter/inputs/window_cache.js.map +0 -1
  323. package/dist/market_adapter/interval_utils.d.ts.map +0 -1
  324. package/dist/market_adapter/interval_utils.js.map +0 -1
  325. package/dist/market_adapter/log_format.d.ts.map +0 -1
  326. package/dist/market_adapter/log_format.js.map +0 -1
  327. package/dist/market_adapter/lp_chart_core.d.ts.map +0 -1
  328. package/dist/market_adapter/lp_chart_core.js.map +0 -1
  329. package/dist/market_adapter/lp_chart_runner.d.ts.map +0 -1
  330. package/dist/market_adapter/lp_chart_runner.js.map +0 -1
  331. package/dist/market_adapter/lp_chart_strategy_loader.d.ts.map +0 -1
  332. package/dist/market_adapter/lp_chart_strategy_loader.js.map +0 -1
  333. package/dist/market_adapter/market_adapter.d.ts.map +0 -1
  334. package/dist/market_adapter/market_adapter.js.map +0 -1
  335. package/dist/market_adapter/test_helpers.d.ts.map +0 -1
  336. package/dist/market_adapter/test_helpers.js.map +0 -1
  337. package/dist/market_adapter/utils/adapter_client.d.ts.map +0 -1
  338. package/dist/market_adapter/utils/adapter_client.js.map +0 -1
  339. package/dist/market_adapter/utils/atomic_write.d.ts.map +0 -1
  340. package/dist/market_adapter/utils/atomic_write.js.map +0 -1
  341. package/dist/market_adapter/utils/chain.d.ts.map +0 -1
  342. package/dist/market_adapter/utils/chain.js.map +0 -1
  343. package/dist/market_adapter/utils/data_discovery.d.ts.map +0 -1
  344. package/dist/market_adapter/utils/data_discovery.js.map +0 -1
  345. package/dist/market_adapter/utils/dynamic_grid_snapshot.d.ts.map +0 -1
  346. package/dist/market_adapter/utils/dynamic_grid_snapshot.js.map +0 -1
  347. package/dist/market_adapter/utils/file_lock.d.ts.map +0 -1
  348. package/dist/market_adapter/utils/file_lock.js.map +0 -1
  349. package/dist/market_adapter/utils/native_history.d.ts.map +0 -1
  350. package/dist/market_adapter/utils/native_history.js.map +0 -1
  351. package/dist/modules/account_bots.d.ts.map +0 -1
  352. package/dist/modules/account_bots.js.map +0 -1
  353. package/dist/modules/account_orders.d.ts.map +0 -1
  354. package/dist/modules/account_orders.js.map +0 -1
  355. package/dist/modules/authority_resolver.d.ts.map +0 -1
  356. package/dist/modules/authority_resolver.js.map +0 -1
  357. package/dist/modules/bitshares-native/chain_client.d.ts.map +0 -1
  358. package/dist/modules/bitshares-native/chain_client.js.map +0 -1
  359. package/dist/modules/bitshares-native/crypto/ecc.browser.d.ts.map +0 -1
  360. package/dist/modules/bitshares-native/crypto/ecc.browser.js.map +0 -1
  361. package/dist/modules/bitshares-native/crypto/ecc.d.ts.map +0 -1
  362. package/dist/modules/bitshares-native/crypto/ecc.js.map +0 -1
  363. package/dist/modules/bitshares-native/crypto/ecc_selector.d.ts.map +0 -1
  364. package/dist/modules/bitshares-native/crypto/ecc_selector.js.map +0 -1
  365. package/dist/modules/bitshares-native/index.d.ts.map +0 -1
  366. package/dist/modules/bitshares-native/index.js.map +0 -1
  367. package/dist/modules/bitshares-native/lru_cache.d.ts.map +0 -1
  368. package/dist/modules/bitshares-native/lru_cache.js.map +0 -1
  369. package/dist/modules/bitshares-native/resolvers.d.ts.map +0 -1
  370. package/dist/modules/bitshares-native/resolvers.js.map +0 -1
  371. package/dist/modules/bitshares-native/serial/chain_constants.d.ts.map +0 -1
  372. package/dist/modules/bitshares-native/serial/chain_constants.js.map +0 -1
  373. package/dist/modules/bitshares-native/serial/index.d.ts.map +0 -1
  374. package/dist/modules/bitshares-native/serial/index.js.map +0 -1
  375. package/dist/modules/bitshares-native/serial/operations.d.ts.map +0 -1
  376. package/dist/modules/bitshares-native/serial/operations.js.map +0 -1
  377. package/dist/modules/bitshares-native/serial/serializer.d.ts.map +0 -1
  378. package/dist/modules/bitshares-native/serial/serializer.js.map +0 -1
  379. package/dist/modules/bitshares-native/serial/types.d.ts.map +0 -1
  380. package/dist/modules/bitshares-native/serial/types.js.map +0 -1
  381. package/dist/modules/bitshares-native/signing_client.d.ts.map +0 -1
  382. package/dist/modules/bitshares-native/signing_client.js.map +0 -1
  383. package/dist/modules/bitshares-native/subscriptions.d.ts.map +0 -1
  384. package/dist/modules/bitshares-native/subscriptions.js.map +0 -1
  385. package/dist/modules/bitshares-native/transport.d.ts.map +0 -1
  386. package/dist/modules/bitshares-native/transport.js.map +0 -1
  387. package/dist/modules/bitshares-native/tx/builder.d.ts.map +0 -1
  388. package/dist/modules/bitshares-native/tx/builder.js.map +0 -1
  389. package/dist/modules/bitshares-native/tx/tx_cache.d.ts.map +0 -1
  390. package/dist/modules/bitshares-native/tx/tx_cache.js.map +0 -1
  391. package/dist/modules/bitshares_client.d.ts.map +0 -1
  392. package/dist/modules/bitshares_client.js.map +0 -1
  393. package/dist/modules/bot_defaults.d.ts.map +0 -1
  394. package/dist/modules/bot_defaults.js.map +0 -1
  395. package/dist/modules/bot_settings.d.ts.map +0 -1
  396. package/dist/modules/bot_settings.js.map +0 -1
  397. package/dist/modules/bots_file_lock.d.ts.map +0 -1
  398. package/dist/modules/bots_file_lock.js.map +0 -1
  399. package/dist/modules/broadcast_failure.d.ts.map +0 -1
  400. package/dist/modules/broadcast_failure.js.map +0 -1
  401. package/dist/modules/chain_keys.d.ts.map +0 -1
  402. package/dist/modules/chain_keys.js.map +0 -1
  403. package/dist/modules/chain_orders.d.ts.map +0 -1
  404. package/dist/modules/chain_orders.js.map +0 -1
  405. package/dist/modules/cli_colors.d.ts.map +0 -1
  406. package/dist/modules/cli_colors.js.map +0 -1
  407. package/dist/modules/config.d.ts.map +0 -1
  408. package/dist/modules/config.js.map +0 -1
  409. package/dist/modules/constants.d.ts.map +0 -1
  410. package/dist/modules/constants.js.map +0 -1
  411. package/dist/modules/cr_planner.d.ts.map +0 -1
  412. package/dist/modules/cr_planner.js.map +0 -1
  413. package/dist/modules/credential_policy.d.ts.map +0 -1
  414. package/dist/modules/credential_policy.js.map +0 -1
  415. package/dist/modules/credential_runtime.d.ts.map +0 -1
  416. package/dist/modules/credential_runtime.js.map +0 -1
  417. package/dist/modules/credential_session_cache.d.ts.map +0 -1
  418. package/dist/modules/credential_session_cache.js.map +0 -1
  419. package/dist/modules/credit_pricing.d.ts.map +0 -1
  420. package/dist/modules/credit_pricing.js.map +0 -1
  421. package/dist/modules/credit_runtime.d.ts.map +0 -1
  422. package/dist/modules/credit_runtime.js.map +0 -1
  423. package/dist/modules/crypto/browser_provider.d.ts.map +0 -1
  424. package/dist/modules/crypto/browser_provider.js.map +0 -1
  425. package/dist/modules/crypto/index.d.ts.map +0 -1
  426. package/dist/modules/crypto/index.js.map +0 -1
  427. package/dist/modules/crypto/node_provider.d.ts.map +0 -1
  428. package/dist/modules/crypto/node_provider.js.map +0 -1
  429. package/dist/modules/crypto/provider.d.ts.map +0 -1
  430. package/dist/modules/crypto/provider.js.map +0 -1
  431. package/dist/modules/crypto/pure_ripemd160.d.ts.map +0 -1
  432. package/dist/modules/crypto/pure_ripemd160.js.map +0 -1
  433. package/dist/modules/crypto/pure_scrypt.d.ts.map +0 -1
  434. package/dist/modules/crypto/pure_scrypt.js.map +0 -1
  435. package/dist/modules/crypto/pure_secp256k1.d.ts.map +0 -1
  436. package/dist/modules/crypto/pure_secp256k1.js.map +0 -1
  437. package/dist/modules/crypto/sync.d.ts.map +0 -1
  438. package/dist/modules/crypto/sync.js.map +0 -1
  439. package/dist/modules/daemon_node_health.d.ts.map +0 -1
  440. package/dist/modules/daemon_node_health.js.map +0 -1
  441. package/dist/modules/dexbot_class.d.ts.map +0 -1
  442. package/dist/modules/dexbot_class.js.map +0 -1
  443. package/dist/modules/dexbot_cow_runtime.d.ts.map +0 -1
  444. package/dist/modules/dexbot_cow_runtime.js.map +0 -1
  445. package/dist/modules/dexbot_credential_client.d.ts.map +0 -1
  446. package/dist/modules/dexbot_credential_client.js.map +0 -1
  447. package/dist/modules/dexbot_fill_runtime.d.ts.map +0 -1
  448. package/dist/modules/dexbot_fill_runtime.js.map +0 -1
  449. package/dist/modules/dexbot_maintenance_runtime.d.ts.map +0 -1
  450. package/dist/modules/dexbot_maintenance_runtime.js.map +0 -1
  451. package/dist/modules/dexbot_startup_runtime.d.ts.map +0 -1
  452. package/dist/modules/dexbot_startup_runtime.js.map +0 -1
  453. package/dist/modules/dexbot_state_recovery.d.ts.map +0 -1
  454. package/dist/modules/dexbot_state_recovery.js.map +0 -1
  455. package/dist/modules/env.d.ts.map +0 -1
  456. package/dist/modules/env.js.map +0 -1
  457. package/dist/modules/fund_registry.d.ts.map +0 -1
  458. package/dist/modules/fund_registry.js.map +0 -1
  459. package/dist/modules/general_settings.d.ts.map +0 -1
  460. package/dist/modules/general_settings.js.map +0 -1
  461. package/dist/modules/graceful_shutdown.d.ts.map +0 -1
  462. package/dist/modules/graceful_shutdown.js.map +0 -1
  463. package/dist/modules/grid_price_source.d.ts.map +0 -1
  464. package/dist/modules/grid_price_source.js.map +0 -1
  465. package/dist/modules/key_store.d.ts.map +0 -1
  466. package/dist/modules/key_store.js.map +0 -1
  467. package/dist/modules/launcher/adapter_requirement.d.ts.map +0 -1
  468. package/dist/modules/launcher/adapter_requirement.js.map +0 -1
  469. package/dist/modules/launcher/bot_supervisor.d.ts.map +0 -1
  470. package/dist/modules/launcher/bot_supervisor.js.map +0 -1
  471. package/dist/modules/launcher/child_env.d.ts.map +0 -1
  472. package/dist/modules/launcher/child_env.js.map +0 -1
  473. package/dist/modules/launcher/credential_bootstrap.d.ts.map +0 -1
  474. package/dist/modules/launcher/credential_bootstrap.js.map +0 -1
  475. package/dist/modules/launcher/credential_daemon.d.ts.map +0 -1
  476. package/dist/modules/launcher/credential_daemon.js.map +0 -1
  477. package/dist/modules/launcher/credential_secret.d.ts.map +0 -1
  478. package/dist/modules/launcher/credential_secret.js.map +0 -1
  479. package/dist/modules/launcher/foreign_cred_daemon.d.ts.map +0 -1
  480. package/dist/modules/launcher/foreign_cred_daemon.js.map +0 -1
  481. package/dist/modules/launcher/headless_password.d.ts.map +0 -1
  482. package/dist/modules/launcher/headless_password.js.map +0 -1
  483. package/dist/modules/launcher/launch_modes.d.ts.map +0 -1
  484. package/dist/modules/launcher/launch_modes.js.map +0 -1
  485. package/dist/modules/launcher/market_adapter_runtime.d.ts.map +0 -1
  486. package/dist/modules/launcher/market_adapter_runtime.js.map +0 -1
  487. package/dist/modules/launcher/market_adapter_watchdog.d.ts.map +0 -1
  488. package/dist/modules/launcher/market_adapter_watchdog.js.map +0 -1
  489. package/dist/modules/launcher/monolithic_runtime.d.ts.map +0 -1
  490. package/dist/modules/launcher/monolithic_runtime.js.map +0 -1
  491. package/dist/modules/launcher/runtime_entry.d.ts.map +0 -1
  492. package/dist/modules/launcher/runtime_entry.js.map +0 -1
  493. package/dist/modules/launcher/status_reporting.d.ts.map +0 -1
  494. package/dist/modules/launcher/status_reporting.js.map +0 -1
  495. package/dist/modules/launcher/supervisor_control.d.ts.map +0 -1
  496. package/dist/modules/launcher/supervisor_control.js.map +0 -1
  497. package/dist/modules/market_adapter_whitelist.d.ts.map +0 -1
  498. package/dist/modules/market_adapter_whitelist.js.map +0 -1
  499. package/dist/modules/node_connect_policy.d.ts.map +0 -1
  500. package/dist/modules/node_connect_policy.js.map +0 -1
  501. package/dist/modules/node_failure_ledger.d.ts.map +0 -1
  502. package/dist/modules/node_failure_ledger.js.map +0 -1
  503. package/dist/modules/node_health_cache.d.ts.map +0 -1
  504. package/dist/modules/node_health_cache.js.map +0 -1
  505. package/dist/modules/node_manager.d.ts.map +0 -1
  506. package/dist/modules/node_manager.js.map +0 -1
  507. package/dist/modules/order/accounting.d.ts.map +0 -1
  508. package/dist/modules/order/accounting.js.map +0 -1
  509. package/dist/modules/order/async_lock.d.ts.map +0 -1
  510. package/dist/modules/order/async_lock.js.map +0 -1
  511. package/dist/modules/order/export.d.ts.map +0 -1
  512. package/dist/modules/order/export.js.map +0 -1
  513. package/dist/modules/order/format.d.ts.map +0 -1
  514. package/dist/modules/order/format.js.map +0 -1
  515. package/dist/modules/order/grid.d.ts.map +0 -1
  516. package/dist/modules/order/grid.js.map +0 -1
  517. package/dist/modules/order/grid_reconcile.d.ts.map +0 -1
  518. package/dist/modules/order/grid_reconcile.js.map +0 -1
  519. package/dist/modules/order/grid_reconcile_internal.d.ts.map +0 -1
  520. package/dist/modules/order/grid_reconcile_internal.js.map +0 -1
  521. package/dist/modules/order/index.d.ts.map +0 -1
  522. package/dist/modules/order/index.js.map +0 -1
  523. package/dist/modules/order/logger.d.ts.map +0 -1
  524. package/dist/modules/order/logger.js.map +0 -1
  525. package/dist/modules/order/logger_state.d.ts.map +0 -1
  526. package/dist/modules/order/logger_state.js.map +0 -1
  527. package/dist/modules/order/manager.d.ts.map +0 -1
  528. package/dist/modules/order/manager.js.map +0 -1
  529. package/dist/modules/order/processed_fill_store.d.ts.map +0 -1
  530. package/dist/modules/order/processed_fill_store.js.map +0 -1
  531. package/dist/modules/order/strategy.d.ts.map +0 -1
  532. package/dist/modules/order/strategy.js.map +0 -1
  533. package/dist/modules/order/sync_engine.d.ts.map +0 -1
  534. package/dist/modules/order/sync_engine.js.map +0 -1
  535. package/dist/modules/order/utils/math.d.ts.map +0 -1
  536. package/dist/modules/order/utils/math.js.map +0 -1
  537. package/dist/modules/order/utils/order.d.ts.map +0 -1
  538. package/dist/modules/order/utils/order.js.map +0 -1
  539. package/dist/modules/order/utils/slot.d.ts.map +0 -1
  540. package/dist/modules/order/utils/slot.js.map +0 -1
  541. package/dist/modules/order/utils/system.d.ts.map +0 -1
  542. package/dist/modules/order/utils/system.js.map +0 -1
  543. package/dist/modules/order/utils/timeout.d.ts.map +0 -1
  544. package/dist/modules/order/utils/timeout.js.map +0 -1
  545. package/dist/modules/order/utils/validate.d.ts.map +0 -1
  546. package/dist/modules/order/utils/validate.js.map +0 -1
  547. package/dist/modules/order/utils/withPoolRef.d.ts.map +0 -1
  548. package/dist/modules/order/utils/withPoolRef.js.map +0 -1
  549. package/dist/modules/order/working_grid.d.ts.map +0 -1
  550. package/dist/modules/order/working_grid.js.map +0 -1
  551. package/dist/modules/path_api.d.ts.map +0 -1
  552. package/dist/modules/path_api.js.map +0 -1
  553. package/dist/modules/paths.d.ts.map +0 -1
  554. package/dist/modules/paths.js.map +0 -1
  555. package/dist/modules/process_discovery.d.ts.map +0 -1
  556. package/dist/modules/process_discovery.js.map +0 -1
  557. package/dist/modules/runtime.d.ts.map +0 -1
  558. package/dist/modules/runtime.js.map +0 -1
  559. package/dist/modules/runtime_settings.d.ts.map +0 -1
  560. package/dist/modules/runtime_settings.js.map +0 -1
  561. package/dist/modules/settings_merge.d.ts.map +0 -1
  562. package/dist/modules/settings_merge.js.map +0 -1
  563. package/dist/modules/socket_json_client.d.ts.map +0 -1
  564. package/dist/modules/socket_json_client.js.map +0 -1
  565. package/dist/modules/storage/browser_adapter.d.ts.map +0 -1
  566. package/dist/modules/storage/browser_adapter.js.map +0 -1
  567. package/dist/modules/storage/index.d.ts.map +0 -1
  568. package/dist/modules/storage/index.js.map +0 -1
  569. package/dist/modules/storage/node_adapter.d.ts.map +0 -1
  570. package/dist/modules/storage/node_adapter.js.map +0 -1
  571. package/dist/modules/storage/types.d.ts.map +0 -1
  572. package/dist/modules/storage/types.js.map +0 -1
  573. package/dist/modules/types.d.ts.map +0 -1
  574. package/dist/modules/types.js.map +0 -1
  575. package/dist/modules/utils/base58check.d.ts.map +0 -1
  576. package/dist/modules/utils/base58check.js.map +0 -1
  577. package/dist/modules/utils/build_dir.d.ts.map +0 -1
  578. package/dist/modules/utils/build_dir.js.map +0 -1
  579. package/dist/modules/utils/chain_logs.d.ts.map +0 -1
  580. package/dist/modules/utils/chain_logs.js.map +0 -1
  581. package/dist/modules/utils/errors.d.ts.map +0 -1
  582. package/dist/modules/utils/errors.js.map +0 -1
  583. package/dist/modules/utils/sanitize_key.d.ts.map +0 -1
  584. package/dist/modules/utils/sanitize_key.js.map +0 -1
  585. package/dist/modules/validate_profiles.d.ts.map +0 -1
  586. package/dist/modules/validate_profiles.js.map +0 -1
  587. package/dist/pm2.d.ts.map +0 -1
  588. package/dist/pm2.js.map +0 -1
  589. package/dist/scripts/analyze-credit.d.ts.map +0 -1
  590. package/dist/scripts/analyze-credit.js.map +0 -1
  591. package/dist/scripts/analyze-git.d.ts.map +0 -1
  592. package/dist/scripts/analyze-git.js.map +0 -1
  593. package/dist/scripts/analyze-orders.d.ts.map +0 -1
  594. package/dist/scripts/analyze-orders.js.map +0 -1
  595. package/dist/scripts/chart_command.d.ts.map +0 -1
  596. package/dist/scripts/chart_command.js.map +0 -1
  597. package/dist/scripts/diagnose-kibana-candles.d.ts.map +0 -1
  598. package/dist/scripts/diagnose-kibana-candles.js.map +0 -1
  599. package/dist/scripts/diagnose-pool-history.d.ts.map +0 -1
  600. package/dist/scripts/diagnose-pool-history.js.map +0 -1
  601. package/dist/scripts/divergence-calc.d.ts.map +0 -1
  602. package/dist/scripts/divergence-calc.js.map +0 -1
  603. package/dist/scripts/dw.d.ts.map +0 -1
  604. package/dist/scripts/dw.js.map +0 -1
  605. package/dist/scripts/generate_lp_chart.d.ts.map +0 -1
  606. package/dist/scripts/generate_lp_chart.js.map +0 -1
  607. package/dist/scripts/generate_mainnet_corpus_report.d.ts.map +0 -1
  608. package/dist/scripts/generate_mainnet_corpus_report.js.map +0 -1
  609. package/dist/scripts/native_release_gates.d.ts.map +0 -1
  610. package/dist/scripts/native_release_gates.js.map +0 -1
  611. package/dist/scripts/print_grid.d.ts.map +0 -1
  612. package/dist/scripts/print_grid.js.map +0 -1
  613. package/dist/scripts/run-tests.d.ts.map +0 -1
  614. package/dist/scripts/run-tests.js.map +0 -1
  615. package/dist/scripts/runner.d.ts.map +0 -1
  616. package/dist/scripts/runner.js.map +0 -1
  617. package/dist/scripts/sync-version.d.ts.map +0 -1
  618. package/dist/scripts/sync-version.js.map +0 -1
  619. package/dist/scripts/test-credit-renewal.d.ts.map +0 -1
  620. package/dist/scripts/test-credit-renewal.js.map +0 -1
  621. package/dist/scripts/tv.d.ts.map +0 -1
  622. package/dist/scripts/tv.js.map +0 -1
  623. package/dist/scripts/update.d.ts.map +0 -1
  624. package/dist/scripts/update.js.map +0 -1
  625. package/dist/scripts/update_dist_freshness.d.ts.map +0 -1
  626. package/dist/scripts/update_dist_freshness.js.map +0 -1
  627. package/dist/scripts/validate_bots.d.ts.map +0 -1
  628. package/dist/scripts/validate_bots.js.map +0 -1
  629. package/dist/scripts/verify-browser-bundle.d.ts.map +0 -1
  630. package/dist/scripts/verify-browser-bundle.js.map +0 -1
  631. package/dist/unlock.d.ts.map +0 -1
  632. package/dist/unlock.js.map +0 -1
@@ -116,12 +116,13 @@ function _snapshotFundState(manager) {
116
116
  sellLocked: Number(manager.accountTotals?.sellLocked || 0),
117
117
  };
118
118
  }
119
- import { floatToBlockchainInt, getPrecisionByOrderType, getPrecisionsForManager, calculateOrderCreationFees, calculateOrderSizes, calculateRotationOrderSizes, calculateAvailableFundsValue, calculateGridSideDivergenceMetric, getPrecisionSlack, getMinOrderSize, getSingleDustThreshold, getGridBestPrices, calculateSpreadFromOrders, allocateFundsByWeights, calculateGapSlots as _mathGapSlots, priceSlotEqual, getBtsSide, getSellStartIdx, resolveGapBand, countGapBandSpread, validatePersistedBoundary, isTransientInBandRejection, adjustBudgetForBtsFees, clamp, buildGenesisFromPriceLevels, assertSlotPriceInvariant, priceForSlot, hashPriceLevels, } from './utils/math.js';
120
- import { filterOrdersByType, checkSizesBeforeMinimum, checkSizeThreshold, resolveConfiguredPriceBound, shouldFlagOutOfSpread, isOrderHealthy, isPhantomOrder, isSlotAvailable, isOrderOnChain, isOrderPlaced, hasOnChainId, isEmptyGridSlot, parseSlotIndex, calculateIdealBoundary, assignGridRoles, resolveOnChainRetypeType, resolveReserveCount, reserveEdgeIdSet, resolveLiveReserveEdgeAnchorPrice } from './utils/order.js';
121
- import { loadAmaCenterPrice, loadAmaCenterSnapshot, withBlockchainRetry } from './utils/system.js';
119
+ import { floatToBlockchainInt, getPrecisionByOrderType, getPrecisionsForManager, calculateOrderCreationFees, calculateOrderSizes, calculateRotationOrderSizes, calculateAvailableFundsValue, calculateGridSideDivergenceMetric, getPrecisionSlack, getMinOrderSize, getSingleDustThreshold, getGridBestPrices, calculateSpreadFromOrders, allocateFundsByWeights, calculateGapSlots as _mathGapSlots, priceSlotEqual, getBtsSide, getSellStartIdx, resolveGapBand, countGapBandSpread, validatePersistedBoundary, isTransientInBandRejection, adjustBudgetForBtsFees, clamp, derivePriceLevels, buildGenesisFromPriceLevels, assertSlotPriceInvariant, priceForSlot, hashPriceLevels, } from './utils/math.js';
120
+ import { filterOrdersByType, checkSizesBeforeMinimum, checkSizeThreshold, resolveConfiguredPriceBound, shouldFlagOutOfSpread, isOrderHealthy, isPhantomOrder, isSlotAvailable, isOrderOnChain, isOrderPlaced, hasOnChainId, isEmptyGridSlot, parseSlotIndex, calculateIdealBoundary, assignGridRoles, resolveOnChainRetypeType, resolveReserveCount, reserveEdgeIdSet, resolveLiveReserveEdgeAnchorPrice, liveWindowIdSet } from './utils/order.js';
121
+ import { loadAmaCenterPrice, loadAmaCenterSnapshot, withBlockchainRetry, restoreLastFillPivot, resetLastFillPivot } from './utils/system.js';
122
122
  import * as MathUtils from './utils/math.js';
123
123
  import { derivePriceWithPoolRef, resolveStartPriceMode } from './utils/withPoolRef.js';
124
124
  import { getWhitelistFlags } from '../market_adapter_whitelist.js';
125
+ import { hasGenesisLadder, recordMissingGenesisFault, resolvePersistedGenesis } from './genesis_policy.js';
125
126
  import { getErrorMessage } from '../utils/errors.js';
126
127
  const calculateGapSlots = _mathGapSlots;
127
128
  export { calculateGapSlots };
@@ -331,8 +332,8 @@ export function createOrderGrid(config) {
331
332
  throw new Error(`Invalid incrementPercent: ${incrementPercent}. Must be a finite number.`);
332
333
  }
333
334
  // Fall back to the canonical INCREMENT_BOUNDS when the config omits
334
- // incrementBounds. Without this, a non-positive incrementPercent (e.g. 0)
335
- // silently passes validation and the geometric loop below spins forever.
335
+ // incrementBounds. derivePriceLevels also refuses a step that cannot
336
+ // advance, but this enforces the configured increment range.
336
337
  const incrementBounds = config.incrementBounds || INCREMENT_BOUNDS;
337
338
  const minPercent = incrementBounds.MIN_PERCENT;
338
339
  const maxPercent = incrementBounds.MAX_PERCENT;
@@ -340,53 +341,13 @@ export function createOrderGrid(config) {
340
341
  throw new Error(`Invalid incrementPercent: ${incrementPercent}. Must be between ` +
341
342
  `${minPercent} and ${maxPercent} (inclusive).`);
342
343
  }
343
- const stepUp = 1 + (incrementPercent / 100);
344
- const stepDown = 1 - (incrementPercent / 100);
345
344
  // ================================================================================
346
345
  // STEP 1: GENERATE PRICE LEVELS (Geometric progression)
347
346
  // ================================================================================
348
- // Create a geometric series of prices from minPrice to maxPrice.
349
- // Each level is incrementPercent% away from its neighbors.
350
- //
351
- // We start from startPrice and expand outward in both directions to ensure
352
- // the grid is centered around the market price.
353
- const priceLevels = [];
354
- // Generate levels upwards from startPrice (higher prices for SELL orders)
355
- // Start from sqrt(stepUp) × startPrice to center the grid
356
- let upPrice = startPrice * Math.sqrt(stepUp);
357
- while (upPrice <= maxPrice) {
358
- priceLevels.push(upPrice);
359
- upPrice *= stepUp;
360
- }
361
- // Generate levels downwards from startPrice (lower prices for BUY orders)
362
- // Start from sqrt(stepDown) × startPrice to center the grid
363
- let downPrice = startPrice * Math.sqrt(stepDown);
364
- while (downPrice >= minPrice) {
365
- priceLevels.push(downPrice);
366
- downPrice *= stepDown;
367
- }
368
- // Sort all levels from lowest to highest (Master Rail order)
369
- priceLevels.sort((a, b) => a - b);
370
- // Dedupe geometric levels that collide at float precision (tiny increments);
371
- // keeps slot-N ↔ index mapping stable vs migration dedupe (grid.ts:652)
372
- {
373
- const seen = new Set();
374
- const deduped = [];
375
- for (const p of priceLevels) {
376
- const key = Number(p).toFixed(12);
377
- if (!seen.has(key)) {
378
- seen.add(key);
379
- deduped.push(p);
380
- }
381
- }
382
- priceLevels.length = 0;
383
- priceLevels.push(...deduped);
384
- }
385
- if (priceLevels.length === 0) {
386
- throw new Error(`Grid generation produced no price levels for startPrice=${startPrice}, ` +
387
- `bounds=[${minPrice}, ${maxPrice}], incrementPercent=${incrementPercent}. ` +
388
- `Widen bounds or reduce incrementPercent.`);
389
- }
347
+ // Rail geometry lives in ONE place (modules/order/utils/math.ts,
348
+ // derivePriceLevels) so a fresh build and a legacy-snapshot migration
349
+ // cannot drift into two different ladders for the same config.
350
+ const priceLevels = derivePriceLevels(startPrice, minPrice, maxPrice, incrementPercent);
390
351
  // ================================================================================
391
352
  // STEP 2: CALCULATE SPREAD GAP SIZE
392
353
  // ================================================================================
@@ -471,11 +432,47 @@ export async function loadGrid(manager, grid, boundaryIdx = null, genesisInput =
471
432
  // Genesis determinism: if snapshot provided genesis, validate slots
472
433
  // against it; if legacy snapshot has no genesis, migrate by building
473
434
  // genesis from live config and re-sorting to canonical price order.
474
- let genesis = genesisInput || manager._genesis || null;
435
+ //
436
+ // GENESIS INVARIANT (docs/GRID_PRICE_INVARIANT.md, E1): a snapshot that
437
+ // carries orders MUST carry a ladder. The decision lives in
438
+ // genesis_policy.resolvePersistedGenesis, so the startup gate can ask
439
+ // the same question before committing to a resume. A refused snapshot
440
+ // throws BEFORE any mutation (no asset init, no fund reset, no
441
+ // boundary restore), so the caller rebuilds from a clean manager.
442
+ // Assigned from the single resolver below; the raw inputs are only
443
+ // inspected by that resolver (so a malformed `genesisInput` cannot
444
+ // shadow the manager's own ladder or the migration path).
445
+ let genesis = null;
446
+ const validationMode = (() => {
447
+ try {
448
+ const raw = (typeof process !== 'undefined' && process.env?.GRID_PRICE_SLOT_VALIDATION) || 'log';
449
+ return String(raw).toLowerCase() === 'enforce' ? 'enforce' : 'log';
450
+ }
451
+ catch {
452
+ return 'log';
453
+ }
454
+ })();
455
+ const resolution = resolvePersistedGenesis({
456
+ config: manager.config,
457
+ grid,
458
+ genesisInput,
459
+ managerGenesis: manager._genesis,
460
+ validationMode,
461
+ log: (msg, level) => manager.logger?.log?.(msg, level)
462
+ });
463
+ if (!resolution.ok) {
464
+ throw recordMissingGenesisFault(manager, resolution);
465
+ }
466
+ genesis = resolution.genesis;
467
+ // A ladder is (re)established: clear any fault recorded by an earlier
468
+ // attempt in this process, so the observability record reflects the
469
+ // CURRENT state rather than a resolved one.
470
+ if (manager._missingGenesis)
471
+ manager._missingGenesis = null;
475
472
  // Validate genesis hash if present (wired for stale-pair detection #3)
476
473
  // On mismatch we only warn — genesis is still used for validation (log mode) / virtualization (enforce mode);
477
474
  // a stale persisted snapshot vs fresh manager._genesis scenario is covered by the log/enforce gate above
478
- if (genesis && Array.isArray(genesis.priceLevels) && typeof genesis.priceLevelsHash === 'string') {
475
+ if (hasGenesisLadder(genesis) && typeof genesis.priceLevelsHash === 'string') {
479
476
  try {
480
477
  const recomputed = hashPriceLevels(genesis.priceLevels);
481
478
  if (recomputed !== genesis.priceLevelsHash) {
@@ -484,16 +481,7 @@ export async function loadGrid(manager, grid, boundaryIdx = null, genesisInput =
484
481
  }
485
482
  catch { }
486
483
  }
487
- const validationMode = (() => {
488
- try {
489
- const raw = (typeof process !== 'undefined' && process.env?.GRID_PRICE_SLOT_VALIDATION) || 'log';
490
- return String(raw).toLowerCase() === 'enforce' ? 'enforce' : 'log';
491
- }
492
- catch {
493
- return 'log';
494
- }
495
- })();
496
- if (genesis && Array.isArray(genesis.priceLevels)) {
484
+ if (hasGenesisLadder(genesis)) {
497
485
  // Validate each slot's price against genesis; virtualize only in enforce mode (plan §13)
498
486
  //
499
487
  // REPAIR (both modes): a slot id determines its price from the
@@ -587,72 +575,17 @@ export async function loadGrid(manager, grid, boundaryIdx = null, genesisInput =
587
575
  else {
588
576
  manager._genesis = genesis;
589
577
  }
590
- }
591
- else if (grid.length > 0) {
592
- // Migration: build genesis from live geometric rail (plan §4.1/§10)
593
- // Do NOT derive priceLevels from persisted slot prices — a truncated
594
- // persisted array would permanently shrink genesis. Recompute from
595
- // startPrice/min/max/increment per createOrderGrid §2.1.
596
- const startPrice = Number(manager.config?.startPrice);
597
- const minPrice = Number(manager.config?.minPrice);
598
- const maxPrice = Number(manager.config?.maxPrice);
599
- const incPct = Number(manager.config?.incrementPercent);
600
- if (Number.isFinite(startPrice) && Number.isFinite(minPrice) && Number.isFinite(maxPrice) && Number.isFinite(incPct)) {
601
- try {
602
- const stepUp = 1 + (incPct / 100);
603
- const stepDown = 1 - (incPct / 100);
604
- const priceLevels = [];
605
- let upPrice = startPrice * Math.sqrt(stepUp);
606
- while (upPrice <= maxPrice) {
607
- priceLevels.push(upPrice);
608
- upPrice *= stepUp;
609
- }
610
- let downPrice = startPrice * Math.sqrt(stepDown);
611
- while (downPrice >= minPrice) {
612
- priceLevels.push(downPrice);
613
- downPrice *= stepDown;
614
- }
615
- priceLevels.sort((a, b) => a - b);
616
- // Dedupe (floatToBlockchainInt equality via fixed 12-decimals)
617
- const uniq = [];
618
- const seen = new Set();
619
- for (const p of priceLevels) {
620
- const key = Number(p).toFixed(12);
621
- if (!seen.has(key)) {
622
- seen.add(key);
623
- uniq.push(p);
624
- }
625
- }
626
- const gapSlotsForGenesis = calculateGapSlots(incPct, manager.config?.targetSpreadPercent, manager.config?.gridLimits);
627
- const built = buildGenesisFromPriceLevels(startPrice, incPct, gapSlotsForGenesis, uniq);
628
- // Cross-check: if user edited startPrice/min/max/increment across restarts on a legacy snapshot,
629
- // the new-config rail will mismatch most persisted slot prices → noisy log / mass-virtualize
630
- // in enforce mode and the mismatched genesis would be persisted. Count failures first.
631
- let mismatchCount = 0;
632
- for (const slot of grid) {
633
- try {
634
- assertSlotPriceInvariant(slot, built);
635
- }
636
- catch {
637
- mismatchCount++;
638
- }
639
- }
640
- const mismatchRatio = grid.length > 0 ? mismatchCount / grid.length : 0;
641
- if (mismatchRatio > 0.5) {
642
- manager.logger?.log?.(`[GENESIS] Migration: ${mismatchCount}/${grid.length} slots mismatch new-config rail (ratio ${mismatchRatio.toFixed(2)}) — config may have changed since snapshot; NOT adopting migration genesis (validation would ${validationMode === 'enforce' ? 'mass-virtualize' : 'be noisy'}). Persisted grid will be kept as-is until a clean rebuild`, 'warn');
643
- }
644
- else {
645
- if (mismatchCount > 0) {
646
- manager.logger?.log?.(`[GENESIS] Migration: ${mismatchCount}/${grid.length} slots mismatch new-config rail — will be logged${validationMode === 'enforce' ? '/virtualized' : ''} on next load`, 'warn');
647
- }
648
- manager._genesis = built;
649
- genesis = built;
650
- manager.logger?.log?.(`[GENESIS] Migrated legacy grid: built genesis with ${uniq.length} levels (hash ${built.priceLevelsHash})`, 'info');
651
- }
652
- }
653
- catch (e) {
654
- manager.logger?.log?.(`[GENESIS] Migration failed: ${getErrorMessage(e)}`, 'warn');
655
- }
578
+ // Legacy snapshot with no persisted ladder: the resolver built one
579
+ // from the live geometric rail and cross-checked it against the
580
+ // persisted slots (mismatch ratio at or below
581
+ // MISSING_GENESIS_MISMATCH_RATIO), so it describes THIS generation.
582
+ // A refused ladder throws above (E1), so there is no genesis-less
583
+ // state left to load into. This is the only place a migration
584
+ // ladder is installed, so its adoption log lives here too (the
585
+ // former `else if` branch was unreachable, since this branch
586
+ // already handles every ladder-bearing resolution).
587
+ if (resolution.source === 'migration') {
588
+ manager.logger?.log?.(`[GENESIS] Migrated legacy grid: built genesis with ${genesis.priceLevels.length} levels (hash ${genesis.priceLevelsHash})`, 'info');
656
589
  }
657
590
  }
658
591
  try {
@@ -749,6 +682,23 @@ export async function loadGrid(manager, grid, boundaryIdx = null, genesisInput =
749
682
  manager._restoreBoundary(restoredBoundary);
750
683
  manager.logger?.log?.(`Restored boundary index: ${restoredBoundary}`, 'info');
751
684
  }
685
+ // Restart resilience: restore the persisted LAST-FILL-GUARD pivot
686
+ // WITH the boundary — after the persisted genesis is applied and
687
+ // the grid re-typed, before the first reconcile/broadcast — so a
688
+ // restart cannot re-open the cold window where the guard is
689
+ // disabled and evacuation stamps get applied against a boundary
690
+ // that is still being rebuilt. restoreLastFillPivot validates the
691
+ // row against the manager's live genesis (refuses on mismatch —
692
+ // a regenerated grid drops it) and onto the price ladder with the
693
+ // same one-increment drift rule the runtime guard applies.
694
+ if (restoredBoundary !== null) {
695
+ try {
696
+ restoreLastFillPivot(manager, manager?.accountOrders?.loadLastFillPivot?.() ?? null);
697
+ }
698
+ catch (pivotErr) {
699
+ manager.logger?.log?.(`[LAST-FILL-GUARD] Persisted pivot restore failed (${getErrorMessage(pivotErr)}); book seed takes over`, 'warn');
700
+ }
701
+ }
752
702
  // Reassign slot types based on current boundary.
753
703
  // Every slot's type must match its price-slot index (parseSlotIndex)
754
704
  // relative to the boundary + gapSlots, not array position. After
@@ -1178,8 +1128,8 @@ export async function initializeGrid(manager) {
1178
1128
  buy: resolveLiveReserveEdgeAnchorPrice(manager, 'buy'),
1179
1129
  sell: resolveLiveReserveEdgeAnchorPrice(manager, 'sell')
1180
1130
  };
1181
- const reserveBuyIds = reserveEdgeIdSet(oldSlots, manager.config, ORDER_TYPES.BUY, edgeAnchors.buy);
1182
- const reserveSellIds = reserveEdgeIdSet(oldSlots, manager.config, ORDER_TYPES.SELL, edgeAnchors.sell);
1131
+ const reserveBuyIds = reserveEdgeIdSet(oldSlots, manager.config, ORDER_TYPES.BUY, edgeAnchors.buy, liveWindowIdSet(manager, ORDER_TYPES.BUY));
1132
+ const reserveSellIds = reserveEdgeIdSet(oldSlots, manager.config, ORDER_TYPES.SELL, edgeAnchors.sell, liveWindowIdSet(manager, ORDER_TYPES.SELL));
1183
1133
  let netShift = 0;
1184
1134
  for (const e of owedCrawls) {
1185
1135
  if (e?.side === ORDER_TYPES.BUY && reserveBuyIds?.has(e.slotId))
@@ -1236,14 +1186,36 @@ export async function initializeGrid(manager) {
1236
1186
  maxPrice: resolvedMaxP,
1237
1187
  });
1238
1188
  manager._gapSlots = gapSlots;
1239
- if (genesis)
1189
+ if (genesis) {
1240
1190
  manager._genesis = genesis;
1191
+ // New generation: clear the missing-genesis fault/counter records so
1192
+ // the E2 sync-entry assert stops re-reporting a resolved condition
1193
+ // and an operator reading the logs sees only live faults.
1194
+ manager._missingGenesis = null;
1195
+ manager._genesisInvariantViolations = 0;
1196
+ manager._genesisInvariantLoggedAt = 0;
1197
+ }
1241
1198
  // A rebuilt grid is a NEW generation: the boundary below is re-derived
1242
1199
  // absolutely from the fresh price ladder, so owed fill crawls recorded
1243
1200
  // against the previous generation must not survive — their relative
1244
1201
  // deltas would shift the new anchor again for movement it already
1245
1202
  // contains (and their slot ids now name different prices).
1246
1203
  manager._clearPendingFillCrawls?.('grid rebuild');
1204
+ // Same generation contract for the LAST-FILL-GUARD pivot: it was
1205
+ // armed against the previous ladder, and restoreLastFillPivot would
1206
+ // refuse it against the new genesis anyway. Drop it now so the guard
1207
+ // re-arms on the first real fill of the new generation (the startup
1208
+ // book seed may arm a heuristic pivot in the meantime, which is
1209
+ // in-memory-only by provenance).
1210
+ try {
1211
+ if (typeof manager._resetLastFillPivot === 'function') {
1212
+ manager._resetLastFillPivot('grid rebuild');
1213
+ }
1214
+ else {
1215
+ resetLastFillPivot(manager, 'grid rebuild');
1216
+ }
1217
+ }
1218
+ catch { }
1247
1219
  // RC-8: Update boundary with notification to dependent systems
1248
1220
  // Persist master boundary for StrategyEngine
1249
1221
  if (manager.boundaryIdx !== boundaryIdx) {
@@ -1595,11 +1567,13 @@ export async function _recalculateGridOrderSizesFromBlockchain(manager, orderTyp
1595
1567
  // geometric progression including empties, then re-type the picked slot
1596
1568
  // to BUY/SELL before placement. The COW boundary-shift path re-types
1597
1569
  // the working grid by geometry first, so crossers stay in the correct
1598
- // side's denominator. Reserve edge slots are deliberately excluded from
1599
- // that startup re-derivation: they activate only with the size the
1600
- // target-grid sizing pipeline has already written (exact values, one
1601
- // sizing rule), and an unsized reserve waits for that pipeline instead
1602
- // of being placed with a locally guessed size.
1570
+ // side's denominator. Reserve edge slots are included here like any
1571
+ // other slot-N side slot: this geometric curve sizes them too, and the
1572
+ // activation picker (_pickEdgeReserveSlots) only ever places a reserve
1573
+ // with the stored size the target-grid sizing pipeline already wrote
1574
+ // (exact values, one sizing rule). Skipping reserves in this pass
1575
+ // would make the divergence resize disagree with that pipeline. Only
1576
+ // non-slot-N shelf/manual ids are skipped below.
1603
1577
  const orderSource = collectActions ? workingGrid : manager.orders;
1604
1578
  const allSideSlots = Array.from(orderSource.values())
1605
1579
  .filter((o) => o.type === orderType)
@@ -1,4 +1,13 @@
1
1
  /**
2
+ * Resume a persisted grid whose order ids no longer match the book, by
3
+ * re-adopting the live chain orders into the frozen ladder (nearest-slot).
4
+ *
5
+ * The name is historical: there is no price matcher here any more. It loads the
6
+ * persisted grid (which establishes the price ladder, or is refused with
7
+ * MissingGenesisError and reported as "not resumed") and lets the normal sync
8
+ * bind each live chain order to the slot its price maps to. A grid whose ladder
9
+ * is unusable never resumes — the caller regenerates.
10
+ *
2
11
  * Returns { resumed: boolean, matchedCount: number }.
3
12
  * @param {Object} params - Destructured parameters
4
13
  * @param {Object} params.manager - OrderManager instance
@@ -49,6 +49,15 @@ function _startupCancelPlanStillCurrent(plan, manager, initialChainSignature, cu
49
49
  return !findLiveOrderOwnerByChainId(manager, plan.chainOrderId);
50
50
  }
51
51
  /**
52
+ * Resume a persisted grid whose order ids no longer match the book, by
53
+ * re-adopting the live chain orders into the frozen ladder (nearest-slot).
54
+ *
55
+ * The name is historical: there is no price matcher here any more. It loads the
56
+ * persisted grid (which establishes the price ladder, or is refused with
57
+ * MissingGenesisError and reported as "not resumed") and lets the normal sync
58
+ * bind each live chain order to the slot its price maps to. A grid whose ladder
59
+ * is unusable never resumes — the caller regenerates.
60
+ *
52
61
  * Returns { resumed: boolean, matchedCount: number }.
53
62
  * @param {Object} params - Destructured parameters
54
63
  * @param {Object} params.manager - OrderManager instance
@@ -66,7 +75,7 @@ export async function attemptResumePersistedGridByPriceMatch({ manager, persiste
66
75
  if (!manager || typeof manager.synchronizeWithChain !== 'function')
67
76
  return { resumed: false, matchedCount: 0 };
68
77
  try {
69
- logger && logger.log && logger.log('No matching active order IDs found. Attempting to match by price...', 'info');
78
+ logger && logger.log && logger.log('No matching active order IDs found. Attempting to re-adopt by ladder level...', 'info');
70
79
  const { loadGrid } = require('./grid');
71
80
  // Prefer explicit genesis if caller wired it, else fall back to manager._genesis
72
81
  const genesisArg = genesis ?? manager?._genesis ?? null;
@@ -77,17 +86,17 @@ export async function attemptResumePersistedGridByPriceMatch({ manager, persiste
77
86
  .map((o) => o.orderId)
78
87
  .filter(Boolean));
79
88
  if (matchedOrderIds.size === 0) {
80
- logger && logger.log && logger.log('Price-based matching found no matches. Generating new grid.', 'info');
89
+ logger && logger.log && logger.log('Ladder-level re-adoption found no matches. Generating new grid.', 'info');
81
90
  return { resumed: false, matchedCount: 0 };
82
91
  }
83
- logger && logger.log && logger.log(`Successfully matched ${matchedOrderIds.size} orders by price. Resuming with existing grid.`, 'info');
92
+ logger && logger.log && logger.log(`Successfully re-adopted ${matchedOrderIds.size} orders by ladder level. Resuming with existing grid.`, 'info');
84
93
  if (typeof storeGrid === 'function') {
85
94
  await storeGrid(Array.from(manager.orders.values()));
86
95
  }
87
96
  return { resumed: true, matchedCount: matchedOrderIds.size };
88
97
  }
89
98
  catch (err) {
90
- logger && logger.log && logger.log(`Price-based resume attempt failed: ${err && getErrorMessage(err) ? getErrorMessage(err) : err}`, 'warn');
99
+ logger && logger.log && logger.log(`Ladder-level resume attempt failed: ${err && getErrorMessage(err) ? getErrorMessage(err) : err}`, 'warn');
91
100
  return { resumed: false, matchedCount: 0 };
92
101
  }
93
102
  }
@@ -7,7 +7,7 @@
7
7
  import { ORDER_TYPES, ORDER_STATES, TIMING, BTS_PRECISION } from '../constants.js';
8
8
  import { readOpenOrdersGuarded } from '../chain_orders.js';
9
9
  import { getMinOrderSize, getAssetFees, getAssetFeesSafe, blockchainToFloat, findCrossedOrder, resolveGapBand, isSlotInRail, priceSlotEqual } from './utils/math.js';
10
- import { isOrderPlaced, parseChainOrder, buildCreateOrderArgs, buildOutsideInPairGroups, extractBatchOperationResults, chainOrderMatchesSlotWithTolerance, buildCrossingCheckCandidates, isCrossingCheckCandidate, getSideBudget, calculateBudgetedSizes, getActiveOrdersTotal, convertToSpreadPlaceholder, isOrderGoneErrorMessage, clearDuplicateOrphanDetection, resolveReserveCount, resolveLiveReserveEdgeAnchorPrice, reserveEdgeIdSet, compareReserveEdge, parseSlotIndex, reportGridPriceInvariant } from './utils/order.js';
10
+ import { isOrderPlaced, parseChainOrder, buildCreateOrderArgs, buildOutsideInPairGroups, extractBatchOperationResults, chainOrderMatchesSlotWithTolerance, buildCrossingCheckCandidates, isCrossingCheckCandidate, getSideBudget, calculateBudgetedSizes, getActiveOrdersTotal, convertToSpreadPlaceholder, isOrderGoneErrorMessage, clearDuplicateOrphanDetection, resolveReserveCount, resolveLiveReserveEdgeAnchorPrice, reserveEdgeIdSet, compareReserveEdge, parseSlotIndex, reportGridPriceInvariant, liveWindowIdSet } from './utils/order.js';
11
11
  import { resolveAccountRef } from './utils/system.js';
12
12
  import * as Format from './format.js';
13
13
  import { getErrorMessage } from '../utils/errors.js';
@@ -1334,6 +1334,15 @@ async function _executePlannedStartupCreates({ createPlans, chainOrders, account
1334
1334
  if (groups.length === 0)
1335
1335
  return createdOrderIds;
1336
1336
  logger?.log?.(`Startup: Executing ${createPlans.length} planned create(s) in ${groups.length} outside->center group(s)`, 'info');
1337
+ // 7c: yield to the event loop between create groups. Phase 2 holds the
1338
+ // broadcasting region across the whole loop; a blocking/synchronous
1339
+ // stretch of group prep + master mutations must not starve timers and
1340
+ // watchdog pollers (region-end reschedule, _awaitBroadcastIdle, stale-flag
1341
+ // clear) that run on the macrotask queue. The network I/O in each group
1342
+ // already yields, but an explicit yield guarantees it per group.
1343
+ // setTimeout(0) (not setImmediate): this module is browser-safe, and
1344
+ // setImmediate is Node-only.
1345
+ const yieldBetweenCreateGroups = () => new Promise((resolve) => setTimeout(resolve, 0));
1337
1346
  for (let i = 0; i < groups.length; i++) {
1338
1347
  const group = groups[i];
1339
1348
  const labels = group.map((p) => `${p.orderType.toUpperCase()}:${p.gridOrder?.id}`).join(', ');
@@ -1352,6 +1361,7 @@ async function _executePlannedStartupCreates({ createPlans, chainOrders, account
1352
1361
  });
1353
1362
  for (const id of batchIds)
1354
1363
  createdOrderIds.add(id);
1364
+ await yieldBetweenCreateGroups();
1355
1365
  continue;
1356
1366
  }
1357
1367
  if (group.length > 1 && !canBatchCreate) {
@@ -1371,6 +1381,7 @@ async function _executePlannedStartupCreates({ createPlans, chainOrders, account
1371
1381
  if (chainOrderId)
1372
1382
  createdOrderIds.add(chainOrderId);
1373
1383
  }
1384
+ await yieldBetweenCreateGroups();
1374
1385
  }
1375
1386
  const failedCount = Math.max(0, createPlans.length - createdOrderIds.size);
1376
1387
  logger?.log?.(`Startup: Create execution summary: ${createdOrderIds.size}/${createPlans.length} planned create(s) placed ` +
@@ -1396,7 +1407,7 @@ async function _reconcileStartupSide({ orderType, targetCount, chainSideOrders,
1396
1407
  const pickedIds = new Set(desiredSlots.map((s) => s?.id).filter(Boolean));
1397
1408
  const freshEdge = _pickEdgeReserveSlots(manager, orderType, reserveCount, pickedIds);
1398
1409
  const reserveAnchor = resolveLiveReserveEdgeAnchorPrice(manager, reserveSide);
1399
- reserveEdgeIds = reserveEdgeIdSet(Array.from(manager.orders.values()), manager.config, orderType, reserveAnchor);
1410
+ reserveEdgeIds = reserveEdgeIdSet(Array.from(manager.orders.values()), manager.config, orderType, reserveAnchor, liveWindowIdSet(manager, orderType));
1400
1411
  // Window first, then the ready edge reserves. Only the reserve share
1401
1412
  // still MISSING on-chain is held back for the edge (a live reserve is
1402
1413
  // already part of matchedOnGrid and must not shrink the window plan), so
@@ -49,7 +49,10 @@ declare class Logger {
49
49
  * @param {string} [category='DEXBot'] - Logger category/prefix
50
50
  * @param {Object} [options]
51
51
  * @param {boolean} [options.quiet] - Suppress console output
52
- * @param {boolean} [options.quietUnderPm2=true] - Auto-quiet under PM2
52
+ * @param {boolean} [options.quietUnderPm2=false] - Legacy opt-in to suppress
53
+ * console output under PM2. Keep this false in normal operation: under
54
+ * PM2 stdout is the only sink (direct file writes are suppressed), so
55
+ * auto-quieting drops every log line.
53
56
  * @param {string} [options.logFile] - Optional path to log file
54
57
  * @param {string} [options.level='info'] - Log level
55
58
  * @param {Object} [options.configOverride] - Override LOGGING_CONFIG
@@ -135,9 +138,16 @@ declare class Logger {
135
138
  displayStatus(manager: any, forceOutput?: boolean): void;
136
139
  }
137
140
  declare function isPm2Runtime(): boolean;
141
+ /**
142
+ * True when PM2 owns the log files for this process (pm_out_log_path /
143
+ * pm_err_log_path present). In that case stdout/stderr are the only sink and
144
+ * the Logger suppresses its own file writes to avoid double-writing into the
145
+ * PM2-managed file.
146
+ */
147
+ declare function isPm2LogCaptureActive(): boolean;
138
148
  declare function createPm2AwareLogger(category: string, options?: {
139
149
  quietUnderPm2?: boolean;
140
150
  }): Logger;
141
- export { createPm2AwareLogger, isPm2Runtime, setGlobalConsoleLevel, getGlobalConsoleLevel };
151
+ export { createPm2AwareLogger, isPm2Runtime, isPm2LogCaptureActive, setGlobalConsoleLevel, getGlobalConsoleLevel };
142
152
  export default Logger;
143
153
  //# sourceMappingURL=logger.d.ts.map
@@ -73,7 +73,10 @@ class Logger {
73
73
  * @param {string} [category='DEXBot'] - Logger category/prefix
74
74
  * @param {Object} [options]
75
75
  * @param {boolean} [options.quiet] - Suppress console output
76
- * @param {boolean} [options.quietUnderPm2=true] - Auto-quiet under PM2
76
+ * @param {boolean} [options.quietUnderPm2=false] - Legacy opt-in to suppress
77
+ * console output under PM2. Keep this false in normal operation: under
78
+ * PM2 stdout is the only sink (direct file writes are suppressed), so
79
+ * auto-quieting drops every log line.
77
80
  * @param {string} [options.logFile] - Optional path to log file
78
81
  * @param {string} [options.level='info'] - Log level
79
82
  * @param {Object} [options.configOverride] - Override LOGGING_CONFIG
@@ -82,11 +85,21 @@ class Logger {
82
85
  constructor(category = 'DEXBot', options = {}) {
83
86
  this.category = category;
84
87
  const isUnderPm2 = !!Config.pm_exec_path;
85
- const hasPm2Logging = !!(Config.pm_out_log_path || Config.pm_err_log_path);
86
- const pm2AutoQuiet = isUnderPm2 && hasPm2Logging;
87
- const quietUnderPm2 = options.quietUnderPm2 !== false;
88
88
  this.logFile = options.logFile || null;
89
- this.quiet = options.quiet ?? (!!this.logFile || (quietUnderPm2 && pm2AutoQuiet));
89
+ if (options.quiet !== undefined) {
90
+ this.quiet = options.quiet;
91
+ }
92
+ else if (options.quietUnderPm2 === true && isUnderPm2) {
93
+ // Legacy escape hatch: explicit opt-in to the old silent behaviour.
94
+ this.quiet = true;
95
+ }
96
+ else {
97
+ // Non-PM2 runs with a logFile write to the file only, so console is
98
+ // quiet to avoid duplication. Under PM2 the file sink is suppressed
99
+ // (see _enqueueWrite) and PM2 captures stdout, so console must stay
100
+ // on or nothing is logged at all.
101
+ this.quiet = !!this.logFile && !isPm2LogCaptureActive();
102
+ }
90
103
  this.level = options.level || 'info';
91
104
  this.config = options.configOverride || LOGGING_CONFIG;
92
105
  this.state = new LoggerState();
@@ -125,7 +138,7 @@ class Logger {
125
138
  _enqueueWrite(text) {
126
139
  if (!this.logFile)
127
140
  return;
128
- if (Config.pm_out_log_path || Config.pm_err_log_path)
141
+ if (isPm2LogCaptureActive())
129
142
  return;
130
143
  this._writeQueue.push(text);
131
144
  if (this._writeQueue.length >= this._maxQueueSize) {
@@ -586,9 +599,18 @@ class Logger {
586
599
  function isPm2Runtime() {
587
600
  return !!Config.pm_exec_path;
588
601
  }
602
+ /**
603
+ * True when PM2 owns the log files for this process (pm_out_log_path /
604
+ * pm_err_log_path present). In that case stdout/stderr are the only sink and
605
+ * the Logger suppresses its own file writes to avoid double-writing into the
606
+ * PM2-managed file.
607
+ */
608
+ function isPm2LogCaptureActive() {
609
+ return !!(Config.pm_out_log_path || Config.pm_err_log_path);
610
+ }
589
611
  function createPm2AwareLogger(category, options = {}) {
590
612
  return new Logger(category, options);
591
613
  }
592
- export { createPm2AwareLogger, isPm2Runtime, setGlobalConsoleLevel, getGlobalConsoleLevel };
614
+ export { createPm2AwareLogger, isPm2Runtime, isPm2LogCaptureActive, setGlobalConsoleLevel, getGlobalConsoleLevel };
593
615
  export default Logger;
594
616
  //# sourceMappingURL=logger.js.map
@@ -153,6 +153,10 @@ declare class OrderManager {
153
153
  _committedOrderIdsBuiltAt: number;
154
154
  _orderIdAssignedAt: Map<string, number>;
155
155
  _gapSlots: number;
156
+ _genesis: any;
157
+ _missingGenesis: any;
158
+ _genesisInvariantViolations: number;
159
+ _genesisInvariantLoggedAt: number;
156
160
  _gridDirtyAt: number | null;
157
161
  _lastStaleTotalsWarnAt: Record<string, number>;
158
162
  _orphanFillsCreditedAt: number | null;
@@ -175,6 +179,7 @@ declare class OrderManager {
175
179
  _lastFilledPrice: number | null;
176
180
  _lastFilledType: string | null;
177
181
  _lastFilledAt: number;
182
+ lastFillPivotSource: 'fill' | 'book' | null;
178
183
  _deferredRebalanceAt: number;
179
184
  _lastHeldPlanSignature: any;
180
185
  _heldPlanSuppressionCount: number;
@@ -653,6 +658,54 @@ declare class OrderManager {
653
658
  * only; no behavioral effect.
654
659
  */
655
660
  _logBoundaryDebug(source: string, newIdx: number | null): void;
661
+ /**
662
+ * Single writer for the LAST-FILL-GUARD pivot scalar
663
+ * family(_lastFilledPrice/_lastFilledType/_lastFilledAt/lastFillPivotSource
664
+ * + the _lastFilledBuyPrice/_lastFilledSellPrice per-side mirror).
665
+ *
666
+ * Thin instance wrapper: the implementation lives in setLastFillPivot
667
+ * (utils/system.ts, shared free function with the legacy-stub fallback
668
+ * built in) so cow_runtime's queued-fill refresh and restoreLastFillPivot
669
+ * write the exact same scalar family through one implementation.
670
+ *
671
+ * Centralizing the write is what makes the persist/restore contract
672
+ * enforceable: only a pivot written with provenance 'fill' (a real fill
673
+ * at a real price) is persist-eligible; a 'book' pivot (seeded from
674
+ * max-resting-buy / min-resting-sell at startup, not market truth) stays
675
+ * in-memory only. The provenance flag and the value can never drift
676
+ * apart.
677
+ *
678
+ * Best-effort mirror persistence: the pivot rides the next grid-persist
679
+ * flush (persistGridSnapshot reads lastFillPivotSource), so a fill that
680
+ * armed the guard is durable across restarts without a dedicated disk
681
+ * write on the hot path.
682
+ *
683
+ * @param {string} type - ORDER_TYPES.BUY or ORDER_TYPES.SELL
684
+ * @param {number} price - Pivot price (finite, > 0; validated by callers)
685
+ * @param {string} provenance - 'fill' (persist-eligible) or 'book' (seed heuristic)
686
+ * @param {number} [atMs] - Fill timestamp to preserve (defaults to now)
687
+ * @returns {boolean} True when the pivot was written
688
+ */
689
+ _setLastFillPivot(type: any, price: number, provenance: 'fill' | 'book', atMs?: number): boolean;
690
+ /**
691
+ * Reset the LAST-FILL-GUARD pivot to cold state, clearing the whole
692
+ * scalar family (per-side mirrors included): leaves seedLastFilledPricesFromBook's
693
+ * early-return check honest after a grid rebuild, so the
694
+ * startup book seed can arm again instead of being silently suppressed
695
+ * by stale per-side mirrors. Delegates to resetLastFillPivot
696
+ * (utils/system.ts) — the free function stays for non-instance callers
697
+ * (cow runtime tests, recovery paths carrying a bare manager).
698
+ *
699
+ * Used whenever the pivot's generation is invalidated: grid rebuild,
700
+ * rejected-snapshot reset, any path that re-anchors the boundary outside
701
+ * the fill flow. Must not touch disk (marks nothing dirty — the pivot is
702
+ * a live-grid invariant, the persist pipeline clears the row on the next
703
+ * flush by passing null).
704
+ *
705
+ * @param {string} reason - Log/debug label
706
+ * @returns {boolean} True when an armed pivot was cleared
707
+ */
708
+ _resetLastFillPivot(reason?: string): boolean;
656
709
  /**
657
710
  * Record last filled price for the single-pivot guard: when armed, BOTH
658
711
  * sides are gated against the most recent fill price (BUY blocked above