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
@@ -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';
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
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 {
@@ -1195,8 +1128,8 @@ export async function initializeGrid(manager) {
1195
1128
  buy: resolveLiveReserveEdgeAnchorPrice(manager, 'buy'),
1196
1129
  sell: resolveLiveReserveEdgeAnchorPrice(manager, 'sell')
1197
1130
  };
1198
- const reserveBuyIds = reserveEdgeIdSet(oldSlots, manager.config, ORDER_TYPES.BUY, edgeAnchors.buy);
1199
- 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));
1200
1133
  let netShift = 0;
1201
1134
  for (const e of owedCrawls) {
1202
1135
  if (e?.side === ORDER_TYPES.BUY && reserveBuyIds?.has(e.slotId))
@@ -1253,8 +1186,15 @@ export async function initializeGrid(manager) {
1253
1186
  maxPrice: resolvedMaxP,
1254
1187
  });
1255
1188
  manager._gapSlots = gapSlots;
1256
- if (genesis)
1189
+ if (genesis) {
1257
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
+ }
1258
1198
  // A rebuilt grid is a NEW generation: the boundary below is re-derived
1259
1199
  // absolutely from the fresh price ladder, so owed fill crawls recorded
1260
1200
  // against the previous generation must not survive — their relative
@@ -1627,11 +1567,13 @@ export async function _recalculateGridOrderSizesFromBlockchain(manager, orderTyp
1627
1567
  // geometric progression including empties, then re-type the picked slot
1628
1568
  // to BUY/SELL before placement. The COW boundary-shift path re-types
1629
1569
  // the working grid by geometry first, so crossers stay in the correct
1630
- // side's denominator. Reserve edge slots are deliberately excluded from
1631
- // that startup re-derivation: they activate only with the size the
1632
- // target-grid sizing pipeline has already written (exact values, one
1633
- // sizing rule), and an unsized reserve waits for that pipeline instead
1634
- // 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.
1635
1577
  const orderSource = collectActions ? workingGrid : manager.orders;
1636
1578
  const allSideSlots = Array.from(orderSource.values())
1637
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';
@@ -1407,7 +1407,7 @@ async function _reconcileStartupSide({ orderType, targetCount, chainSideOrders,
1407
1407
  const pickedIds = new Set(desiredSlots.map((s) => s?.id).filter(Boolean));
1408
1408
  const freshEdge = _pickEdgeReserveSlots(manager, orderType, reserveCount, pickedIds);
1409
1409
  const reserveAnchor = resolveLiveReserveEdgeAnchorPrice(manager, reserveSide);
1410
- 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));
1411
1411
  // Window first, then the ready edge reserves. Only the reserve share
1412
1412
  // still MISSING on-chain is held back for the edge (a live reserve is
1413
1413
  // already part of matchedOnGrid and must not shrink the window plan), so
@@ -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;
@@ -241,7 +241,8 @@ class COWRebalanceEngine {
241
241
  const refillSlotIds = collectRefillSlotIds(optimizedActions, {
242
242
  config: this.config,
243
243
  slots: masterGrid,
244
- edgeAnchors: reserveEdgeAnchors
244
+ edgeAnchors: reserveEdgeAnchors,
245
+ manager: this
245
246
  });
246
247
  projectTargetToWorkingGrid(workingGrid, targetGrid, { actions: optimizedActions });
247
248
  const precisions = {
@@ -417,6 +418,10 @@ class OrderManager {
417
418
  _committedOrderIdsBuiltAt;
418
419
  _orderIdAssignedAt;
419
420
  _gapSlots;
421
+ _genesis;
422
+ _missingGenesis;
423
+ _genesisInvariantViolations;
424
+ _genesisInvariantLoggedAt;
420
425
  _gridDirtyAt;
421
426
  _lastStaleTotalsWarnAt;
422
427
  _orphanFillsCreditedAt;
@@ -536,6 +541,14 @@ class OrderManager {
536
541
  this._committedOrderIdsBuiltAt = 0;
537
542
  this._orderIdAssignedAt = new Map();
538
543
  this._gapSlots = 0;
544
+ // Genesis (price-ladder) state. `_genesis` is established by
545
+ // loadGrid/initializeGrid; these records are the missing-genesis fault
546
+ // and the sync-entry invariant counter, reset with each new generation
547
+ // (initializeGrid) and read by the E2 assert (order/sync_engine).
548
+ this._genesis = null;
549
+ this._missingGenesis = null;
550
+ this._genesisInvariantViolations = 0;
551
+ this._genesisInvariantLoggedAt = 0;
539
552
  this._gridDirtyAt = null;
540
553
  this._orphanFillsCreditedAt = null;
541
554
  this._fundDriftLedger = null;
@@ -369,6 +369,25 @@ declare class SyncEngine {
369
369
  * @param {string} source - Source identifier ('createOrder', 'cancelOrder', 'readOpenOrders', etc.)
370
370
  * @returns {Promise<Object>} { newOrders, ordersNeedingCorrection }
371
371
  */
372
+ /**
373
+ * E2 invariant assert: a manager holding grid slots but no price ladder is
374
+ * in the undefined state the grid-price invariant forbids (INV-GRID-004).
375
+ *
376
+ * Reports once per grid generation (latched on the manager, counted in
377
+ * `_genesisInvariantViolations`) and, when the bot wired the structural
378
+ * resync, requests one so the ladder is re-derived. Returns FALSE so the
379
+ * caller ABORTS the sync untouched: with no ladder there is no authority for
380
+ * a slot's price, and the legacy tolerance matcher that used to cover this
381
+ * state is gone — continuing would let an off-grid chain price be adopted
382
+ * into a slot.
383
+ *
384
+ * Non-throwing on purpose: the load-side gates (E1/E3) own the fail-closed
385
+ * decision, this one makes a bypass loud without stranding a live manager.
386
+ * @param {any} mgr - OrderManager instance
387
+ * @returns {boolean} true when the grid may be synced (no slots, or a usable
388
+ * ladder is present); false when the sync must not run.
389
+ */
390
+ _assertGenesisInvariant(mgr: any): boolean;
372
391
  synchronizeWithChain(chainData: any, source: string): Promise<any>;
373
392
  /**
374
393
  * Fetch account balances from blockchain and update optimistic fund totals.