dexbot 1.4.20 → 1.4.22

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 (674) hide show
  1. package/CHANGELOG.md +53 -0
  2. package/README.md +23 -13
  3. package/analysis/ama_fitting/analyze_ama_price_changes.ts +7 -3
  4. package/analysis/ama_fitting/analyze_lambda_vs_slow.ts +3 -3
  5. package/analysis/ama_fitting/calibrate_convergence_er.ts +8 -6
  6. package/analysis/ama_fitting/fetch_lp_candles.ts +8 -3
  7. package/analysis/ama_fitting/generate_unified_comparison_chart.ts +30 -67
  8. package/analysis/ama_fitting/optimizer_high_resolution.ts +22 -13
  9. package/analysis/ama_fitting/package.json +1 -1
  10. package/analysis/analyze_derivatives.ts +4 -4
  11. package/analysis/analyze_dynamic_weight.ts +21 -5
  12. package/analysis/analyze_kalman.ts +54 -25
  13. package/analysis/analyze_regime.ts +2 -2
  14. package/analysis/analyze_regime_windows.ts +27 -19
  15. package/analysis/analyze_risk_profile.ts +3 -3
  16. package/analysis/analyze_trade_heatmap.ts +3 -3
  17. package/analysis/analyze_volatility.ts +2 -2
  18. package/analysis/bot_fitting/README.md +93 -19
  19. package/analysis/bot_fitting/backtest_ama_sweep.ts +316 -199
  20. package/analysis/bot_fitting/backtest_bot_fitting.ts +520 -85
  21. package/analysis/bot_fitting/shared_utils.ts +16 -10
  22. package/analysis/bot_key_utils.ts +14 -11
  23. package/analysis/bot_usage/discover_bot_accounts.ts +5 -3
  24. package/analysis/bot_usage/kibana_bot_queries.ts +2 -257
  25. package/analysis/chart_css.ts +6 -4
  26. package/analysis/chart_ui.ts +0 -1
  27. package/analysis/chart_utils.ts +11 -2
  28. package/analysis/derivative_chart_generator.ts +2 -2
  29. package/analysis/math_utils.ts +1 -8
  30. package/analysis/price_sources.ts +8 -2
  31. package/analysis/resolve_source.ts +1 -1
  32. package/analysis/results/ama_sweep_results_lp_pool_133_1h.json +2455 -0
  33. package/analysis/results/bot_fitting_results_lp_pool_133_1h.json +218 -0
  34. package/analysis/trade_profitability.ts +61 -28
  35. package/analysis/tradingview/analyze_tradingview.ts +1 -1
  36. package/analysis/tradingview/h-bts_tradingview.html +1570 -0
  37. package/analysis/tradingview/t-bts_tradingview.html +1570 -0
  38. package/analysis/tradingview/tradingview_uplot_chart_generator.ts +302 -74
  39. package/analysis/trend_detection/DYNAMIC_WEIGHT_RESEARCH.md +1 -1
  40. package/analysis/trend_detection/derivative_analyzer.ts +12 -3
  41. package/analysis/trend_detection/dynamic_weight_chart_generator.ts +25 -27
  42. package/analysis/trend_detection/hurst_analyzer.ts +1 -1
  43. package/analysis/trend_detection/kalman_chart_generator.ts +42 -14
  44. package/analysis/trend_detection/package.json +1 -1
  45. package/analysis/trend_detection/regime_chart_generator.ts +39 -19
  46. package/analysis/trend_detection/tests/test_kalman_trend.ts +1 -1
  47. package/analysis/trend_detection/tests/test_kalman_velocity_smoothing.ts +1 -1
  48. package/analysis/trend_detection/volatility_chart_generator.ts +1 -1
  49. package/claw/ecosystem.config.cjs +2 -3
  50. package/claw/examples/memu_integration_example.ts +17 -17
  51. package/claw/index.ts +1 -1
  52. package/claw/modules/chain_actions.ts +51 -54
  53. package/claw/modules/chain_broadcast.ts +66 -104
  54. package/claw/modules/claw_bridge.ts +63 -83
  55. package/claw/modules/claw_catalog.ts +48 -17
  56. package/claw/modules/claw_infra.ts +1 -5
  57. package/claw/modules/claw_launcher.ts +48 -50
  58. package/claw/modules/claw_skill_md.ts +15 -21
  59. package/claw/modules/credit_runtime_adapter.ts +3 -19
  60. package/claw/modules/decision_loop.ts +9 -9
  61. package/claw/modules/dexbot_bridge.ts +8 -8
  62. package/claw/modules/dexbot_profiles.ts +5 -21
  63. package/claw/modules/feed_price_source.ts +1 -1
  64. package/claw/modules/honest_ecosystem.ts +24 -8
  65. package/claw/modules/kibana_price_source.ts +1 -1
  66. package/claw/modules/launcher_mode_detector.ts +1 -1
  67. package/claw/modules/launcher_paths.ts +1 -1
  68. package/claw/modules/liquidity_pools.ts +10 -3
  69. package/claw/modules/mcp_utils.ts +109 -0
  70. package/claw/modules/memu_bridge.ts +76 -54
  71. package/claw/modules/mpa_utils.ts +26 -3
  72. package/claw/modules/position_discovery.ts +17 -28
  73. package/claw/modules/position_health.ts +1 -1
  74. package/claw/modules/position_manager.ts +32 -41
  75. package/claw/modules/position_manager_watch.ts +3 -2
  76. package/claw/modules/short_mpa_strategy.ts +1 -9
  77. package/claw/modules/skill_utils.ts +5 -3
  78. package/claw/modules/utils.ts +9 -1
  79. package/claw/package.json +3 -3
  80. package/claw/runtimes/openclaw-plugin/index.ts +27 -10
  81. package/claw/runtimes/openclaw-plugin/openclaw.plugin.json +1 -1
  82. package/claw/runtimes/openclaw-plugin/package.json +1 -1
  83. package/claw/scripts/claw_bridge.ts +1 -1
  84. package/claw/scripts/claw_mcp_server.ts +19 -78
  85. package/claw/scripts/honest_assets_report.ts +19 -84
  86. package/claw/scripts/memu_mcp_server.ts +57 -155
  87. package/claw/skills/launcher-ops/references/launcher-workflow.md +2 -2
  88. package/claw/tests/package.json +1 -1
  89. package/claw/tests/test_claw_bridge.ts +47 -19
  90. package/claw/tests/test_claw_catalog_and_credentials.ts +8 -4
  91. package/claw/tests/test_claw_chain_layer.ts +39 -19
  92. package/claw/tests/test_claw_data_flow.ts +28 -20
  93. package/claw/tests/test_claw_domain_logic.ts +25 -19
  94. package/claw/tests/test_claw_manifest_and_matrix.ts +23 -3
  95. package/claw/tests/test_claw_mcp_transport.ts +13 -8
  96. package/claw/tests/test_claw_regressions.ts +254 -128
  97. package/claw/tests/test_claw_skill_generation.ts +1 -1
  98. package/claw/tests/test_nullclaw_tmp_integration.ts +2 -3
  99. package/claw/tests/test_position_health.ts +1 -77
  100. package/claw/tests/test_position_manager.ts +20 -18
  101. package/claw/tests/test_position_manager_watch_health.ts +39 -43
  102. package/claw/tests/test_short_mpa_strategy.ts +20 -17
  103. package/claw/tsconfig.json +4 -3
  104. package/dist/analysis/ama_fitting/analyze_ama_price_changes.js +7 -3
  105. package/dist/analysis/ama_fitting/analyze_ama_price_changes.js.map +1 -1
  106. package/dist/analysis/ama_fitting/analyze_lambda_vs_slow.js +3 -3
  107. package/dist/analysis/ama_fitting/analyze_lambda_vs_slow.js.map +1 -1
  108. package/dist/analysis/ama_fitting/calibrate_convergence_er.js +8 -6
  109. package/dist/analysis/ama_fitting/calibrate_convergence_er.js.map +1 -1
  110. package/dist/analysis/ama_fitting/fetch_lp_candles.js +8 -3
  111. package/dist/analysis/ama_fitting/fetch_lp_candles.js.map +1 -1
  112. package/dist/analysis/ama_fitting/generate_unified_comparison_chart.d.ts +2 -2
  113. package/dist/analysis/ama_fitting/generate_unified_comparison_chart.d.ts.map +1 -1
  114. package/dist/analysis/ama_fitting/generate_unified_comparison_chart.js +31 -75
  115. package/dist/analysis/ama_fitting/generate_unified_comparison_chart.js.map +1 -1
  116. package/dist/analysis/ama_fitting/optimizer_high_resolution.d.ts.map +1 -1
  117. package/dist/analysis/ama_fitting/optimizer_high_resolution.js +21 -13
  118. package/dist/analysis/ama_fitting/optimizer_high_resolution.js.map +1 -1
  119. package/dist/analysis/analyze_derivatives.d.ts +0 -18
  120. package/dist/analysis/analyze_derivatives.d.ts.map +1 -1
  121. package/dist/analysis/analyze_derivatives.js +4 -4
  122. package/dist/analysis/analyze_derivatives.js.map +1 -1
  123. package/dist/analysis/analyze_dynamic_weight.d.ts +0 -11
  124. package/dist/analysis/analyze_dynamic_weight.d.ts.map +1 -1
  125. package/dist/analysis/analyze_dynamic_weight.js +19 -5
  126. package/dist/analysis/analyze_dynamic_weight.js.map +1 -1
  127. package/dist/analysis/analyze_kalman.d.ts +0 -10
  128. package/dist/analysis/analyze_kalman.d.ts.map +1 -1
  129. package/dist/analysis/analyze_kalman.js +51 -26
  130. package/dist/analysis/analyze_kalman.js.map +1 -1
  131. package/dist/analysis/analyze_regime.d.ts +0 -17
  132. package/dist/analysis/analyze_regime.d.ts.map +1 -1
  133. package/dist/analysis/analyze_regime.js +2 -2
  134. package/dist/analysis/analyze_regime.js.map +1 -1
  135. package/dist/analysis/analyze_regime_windows.d.ts +0 -16
  136. package/dist/analysis/analyze_regime_windows.d.ts.map +1 -1
  137. package/dist/analysis/analyze_regime_windows.js +28 -21
  138. package/dist/analysis/analyze_regime_windows.js.map +1 -1
  139. package/dist/analysis/analyze_risk_profile.js +3 -3
  140. package/dist/analysis/analyze_risk_profile.js.map +1 -1
  141. package/dist/analysis/analyze_trade_heatmap.js +3 -3
  142. package/dist/analysis/analyze_trade_heatmap.js.map +1 -1
  143. package/dist/analysis/analyze_volatility.d.ts +0 -19
  144. package/dist/analysis/analyze_volatility.d.ts.map +1 -1
  145. package/dist/analysis/analyze_volatility.js +2 -2
  146. package/dist/analysis/analyze_volatility.js.map +1 -1
  147. package/dist/analysis/bot_fitting/backtest_ama_sweep.d.ts +30 -14
  148. package/dist/analysis/bot_fitting/backtest_ama_sweep.d.ts.map +1 -1
  149. package/dist/analysis/bot_fitting/backtest_ama_sweep.js +330 -193
  150. package/dist/analysis/bot_fitting/backtest_ama_sweep.js.map +1 -1
  151. package/dist/analysis/bot_fitting/backtest_bot_fitting.d.ts +136 -1
  152. package/dist/analysis/bot_fitting/backtest_bot_fitting.d.ts.map +1 -1
  153. package/dist/analysis/bot_fitting/backtest_bot_fitting.js +527 -83
  154. package/dist/analysis/bot_fitting/backtest_bot_fitting.js.map +1 -1
  155. package/dist/analysis/bot_fitting/shared_utils.d.ts +2 -13
  156. package/dist/analysis/bot_fitting/shared_utils.d.ts.map +1 -1
  157. package/dist/analysis/bot_fitting/shared_utils.js +15 -9
  158. package/dist/analysis/bot_fitting/shared_utils.js.map +1 -1
  159. package/dist/analysis/bot_key_utils.d.ts +1 -1
  160. package/dist/analysis/bot_key_utils.d.ts.map +1 -1
  161. package/dist/analysis/bot_key_utils.js +14 -11
  162. package/dist/analysis/bot_key_utils.js.map +1 -1
  163. package/dist/analysis/bot_usage/discover_bot_accounts.js +5 -3
  164. package/dist/analysis/bot_usage/discover_bot_accounts.js.map +1 -1
  165. package/dist/analysis/bot_usage/kibana_bot_queries.d.ts +1 -337
  166. package/dist/analysis/bot_usage/kibana_bot_queries.d.ts.map +1 -1
  167. package/dist/analysis/bot_usage/kibana_bot_queries.js +2 -242
  168. package/dist/analysis/bot_usage/kibana_bot_queries.js.map +1 -1
  169. package/dist/analysis/chart_css.d.ts +2 -14
  170. package/dist/analysis/chart_css.d.ts.map +1 -1
  171. package/dist/analysis/chart_css.js +6 -3
  172. package/dist/analysis/chart_css.js.map +1 -1
  173. package/dist/analysis/chart_ui.d.ts.map +1 -1
  174. package/dist/analysis/chart_ui.js.map +1 -1
  175. package/dist/analysis/chart_utils.d.ts.map +1 -1
  176. package/dist/analysis/chart_utils.js +15 -2
  177. package/dist/analysis/chart_utils.js.map +1 -1
  178. package/dist/analysis/derivative_chart_generator.js +2 -2
  179. package/dist/analysis/derivative_chart_generator.js.map +1 -1
  180. package/dist/analysis/math_utils.d.ts +3 -5
  181. package/dist/analysis/math_utils.d.ts.map +1 -1
  182. package/dist/analysis/math_utils.js +3 -5
  183. package/dist/analysis/math_utils.js.map +1 -1
  184. package/dist/analysis/price_sources.d.ts +1 -0
  185. package/dist/analysis/price_sources.d.ts.map +1 -1
  186. package/dist/analysis/price_sources.js +8 -2
  187. package/dist/analysis/price_sources.js.map +1 -1
  188. package/dist/analysis/resolve_source.d.ts.map +1 -1
  189. package/dist/analysis/resolve_source.js +1 -1
  190. package/dist/analysis/resolve_source.js.map +1 -1
  191. package/dist/analysis/trade_profitability.d.ts.map +1 -1
  192. package/dist/analysis/trade_profitability.js +58 -29
  193. package/dist/analysis/trade_profitability.js.map +1 -1
  194. package/dist/analysis/tradingview/analyze_tradingview.js +1 -1
  195. package/dist/analysis/tradingview/analyze_tradingview.js.map +1 -1
  196. package/dist/analysis/tradingview/tradingview_uplot_chart_generator.d.ts.map +1 -1
  197. package/dist/analysis/tradingview/tradingview_uplot_chart_generator.js +302 -74
  198. package/dist/analysis/tradingview/tradingview_uplot_chart_generator.js.map +1 -1
  199. package/dist/analysis/trend_detection/derivative_analyzer.d.ts +1 -0
  200. package/dist/analysis/trend_detection/derivative_analyzer.d.ts.map +1 -1
  201. package/dist/analysis/trend_detection/derivative_analyzer.js +12 -3
  202. package/dist/analysis/trend_detection/derivative_analyzer.js.map +1 -1
  203. package/dist/analysis/trend_detection/dynamic_weight_chart_generator.d.ts.map +1 -1
  204. package/dist/analysis/trend_detection/dynamic_weight_chart_generator.js +26 -27
  205. package/dist/analysis/trend_detection/dynamic_weight_chart_generator.js.map +1 -1
  206. package/dist/analysis/trend_detection/hurst_analyzer.d.ts +1 -1
  207. package/dist/analysis/trend_detection/hurst_analyzer.d.ts.map +1 -1
  208. package/dist/analysis/trend_detection/hurst_analyzer.js +1 -1
  209. package/dist/analysis/trend_detection/hurst_analyzer.js.map +1 -1
  210. package/dist/analysis/trend_detection/kalman_chart_generator.d.ts.map +1 -1
  211. package/dist/analysis/trend_detection/kalman_chart_generator.js +41 -13
  212. package/dist/analysis/trend_detection/kalman_chart_generator.js.map +1 -1
  213. package/dist/analysis/trend_detection/regime_chart_generator.d.ts.map +1 -1
  214. package/dist/analysis/trend_detection/regime_chart_generator.js +38 -19
  215. package/dist/analysis/trend_detection/regime_chart_generator.js.map +1 -1
  216. package/dist/analysis/trend_detection/tests/test_kalman_trend.js +1 -1
  217. package/dist/analysis/trend_detection/tests/test_kalman_trend.js.map +1 -1
  218. package/dist/analysis/trend_detection/tests/test_kalman_velocity_smoothing.js +1 -1
  219. package/dist/analysis/trend_detection/tests/test_kalman_velocity_smoothing.js.map +1 -1
  220. package/dist/analysis/trend_detection/volatility_chart_generator.js +1 -1
  221. package/dist/analysis/trend_detection/volatility_chart_generator.js.map +1 -1
  222. package/dist/bot.js +3 -3
  223. package/dist/bot.js.map +1 -1
  224. package/dist/credential-daemon.d.ts +1 -1
  225. package/dist/credential-daemon.js +2 -2
  226. package/dist/credential-daemon.js.map +1 -1
  227. package/dist/dexbot.d.ts.map +1 -1
  228. package/dist/dexbot.js +25 -22
  229. package/dist/dexbot.js.map +1 -1
  230. package/dist/market_adapter/ama_signal_runner.js +6 -4
  231. package/dist/market_adapter/ama_signal_runner.js.map +1 -1
  232. package/dist/market_adapter/candle_utils.d.ts +1 -3
  233. package/dist/market_adapter/candle_utils.d.ts.map +1 -1
  234. package/dist/market_adapter/candle_utils.js +1 -11
  235. package/dist/market_adapter/candle_utils.js.map +1 -1
  236. package/dist/market_adapter/core/asymmetric_bounds.d.ts.map +1 -1
  237. package/dist/market_adapter/core/asymmetric_bounds.js +33 -30
  238. package/dist/market_adapter/core/asymmetric_bounds.js.map +1 -1
  239. package/dist/market_adapter/core/config_normalizers.d.ts.map +1 -1
  240. package/dist/market_adapter/core/config_normalizers.js +10 -1
  241. package/dist/market_adapter/core/config_normalizers.js.map +1 -1
  242. package/dist/market_adapter/core/kibana_candles.d.ts +18 -42
  243. package/dist/market_adapter/core/kibana_candles.d.ts.map +1 -1
  244. package/dist/market_adapter/core/kibana_candles.js +101 -7
  245. package/dist/market_adapter/core/kibana_candles.js.map +1 -1
  246. package/dist/market_adapter/core/kibana_client.d.ts +1 -17
  247. package/dist/market_adapter/core/kibana_client.d.ts.map +1 -1
  248. package/dist/market_adapter/core/kibana_client.js +40 -7
  249. package/dist/market_adapter/core/kibana_client.js.map +1 -1
  250. package/dist/market_adapter/core/kibana_market_candles.d.ts +0 -27
  251. package/dist/market_adapter/core/kibana_market_candles.d.ts.map +1 -1
  252. package/dist/market_adapter/core/kibana_market_candles.js +1 -1
  253. package/dist/market_adapter/core/kibana_market_candles.js.map +1 -1
  254. package/dist/market_adapter/core/market_adapter_service.d.ts +22 -13
  255. package/dist/market_adapter/core/market_adapter_service.d.ts.map +1 -1
  256. package/dist/market_adapter/core/market_adapter_service.js +96 -38
  257. package/dist/market_adapter/core/market_adapter_service.js.map +1 -1
  258. package/dist/market_adapter/core/signals/hurst_analyzer.d.ts +10 -1
  259. package/dist/market_adapter/core/signals/hurst_analyzer.d.ts.map +1 -1
  260. package/dist/market_adapter/core/signals/hurst_analyzer.js +28 -17
  261. package/dist/market_adapter/core/signals/hurst_analyzer.js.map +1 -1
  262. package/dist/market_adapter/core/signals/kalman_trend_analyzer.d.ts +5 -0
  263. package/dist/market_adapter/core/signals/kalman_trend_analyzer.d.ts.map +1 -1
  264. package/dist/market_adapter/core/signals/kalman_trend_analyzer.js +24 -24
  265. package/dist/market_adapter/core/signals/kalman_trend_analyzer.js.map +1 -1
  266. package/dist/market_adapter/core/signals/kalman_velocity_smoothing.d.ts.map +1 -1
  267. package/dist/market_adapter/core/signals/kalman_velocity_smoothing.js +5 -1
  268. package/dist/market_adapter/core/signals/kalman_velocity_smoothing.js.map +1 -1
  269. package/dist/market_adapter/core/signals/permutation_entropy_analyzer.d.ts.map +1 -1
  270. package/dist/market_adapter/core/signals/permutation_entropy_analyzer.js +20 -3
  271. package/dist/market_adapter/core/signals/permutation_entropy_analyzer.js.map +1 -1
  272. package/dist/market_adapter/core/strategies/ama.js +1 -1
  273. package/dist/market_adapter/core/strategies/ama.js.map +1 -1
  274. package/dist/market_adapter/core/strategies/ama_slope_model.d.ts +2 -2
  275. package/dist/market_adapter/core/strategies/ama_slope_model.d.ts.map +1 -1
  276. package/dist/market_adapter/core/strategies/ama_slope_model.js +16 -4
  277. package/dist/market_adapter/core/strategies/ama_slope_model.js.map +1 -1
  278. package/dist/market_adapter/core/strategies/atr/calculator.d.ts +4 -3
  279. package/dist/market_adapter/core/strategies/atr/calculator.d.ts.map +1 -1
  280. package/dist/market_adapter/core/strategies/atr/calculator.js +16 -8
  281. package/dist/market_adapter/core/strategies/atr/calculator.js.map +1 -1
  282. package/dist/market_adapter/core/strategies/collateral_manager.d.ts.map +1 -1
  283. package/dist/market_adapter/core/strategies/collateral_manager.js +8 -3
  284. package/dist/market_adapter/core/strategies/collateral_manager.js.map +1 -1
  285. package/dist/market_adapter/core/strategies/dynamic_weight_series.d.ts +40 -1
  286. package/dist/market_adapter/core/strategies/dynamic_weight_series.d.ts.map +1 -1
  287. package/dist/market_adapter/core/strategies/dynamic_weight_series.js +116 -2
  288. package/dist/market_adapter/core/strategies/dynamic_weight_series.js.map +1 -1
  289. package/dist/market_adapter/core/strategies/regime_gate.d.ts +1 -2
  290. package/dist/market_adapter/core/strategies/regime_gate.d.ts.map +1 -1
  291. package/dist/market_adapter/core/strategies/regime_gate.js +27 -21
  292. package/dist/market_adapter/core/strategies/regime_gate.js.map +1 -1
  293. package/dist/market_adapter/core/strategies/volatility_shift.d.ts.map +1 -1
  294. package/dist/market_adapter/core/strategies/volatility_shift.js +3 -0
  295. package/dist/market_adapter/core/strategies/volatility_shift.js.map +1 -1
  296. package/dist/market_adapter/inputs/fetch_cex_synthetic_data.js +71 -57
  297. package/dist/market_adapter/inputs/fetch_cex_synthetic_data.js.map +1 -1
  298. package/dist/market_adapter/inputs/fetch_lp_data.d.ts +0 -26
  299. package/dist/market_adapter/inputs/fetch_lp_data.d.ts.map +1 -1
  300. package/dist/market_adapter/inputs/fetch_lp_data.js +72 -19
  301. package/dist/market_adapter/inputs/fetch_lp_data.js.map +1 -1
  302. package/dist/market_adapter/inputs/kibana_source.d.ts +5 -30
  303. package/dist/market_adapter/inputs/kibana_source.d.ts.map +1 -1
  304. package/dist/market_adapter/inputs/kibana_source.js +6 -3
  305. package/dist/market_adapter/inputs/kibana_source.js.map +1 -1
  306. package/dist/market_adapter/lp_chart_core.js +1 -1
  307. package/dist/market_adapter/lp_chart_core.js.map +1 -1
  308. package/dist/market_adapter/lp_chart_runner.d.ts +10 -1
  309. package/dist/market_adapter/lp_chart_runner.d.ts.map +1 -1
  310. package/dist/market_adapter/lp_chart_runner.js +2 -2
  311. package/dist/market_adapter/lp_chart_runner.js.map +1 -1
  312. package/dist/market_adapter/lp_chart_strategy_loader.d.ts +1 -2
  313. package/dist/market_adapter/lp_chart_strategy_loader.d.ts.map +1 -1
  314. package/dist/market_adapter/lp_chart_strategy_loader.js +5 -5
  315. package/dist/market_adapter/lp_chart_strategy_loader.js.map +1 -1
  316. package/dist/market_adapter/market_adapter.d.ts +1 -2
  317. package/dist/market_adapter/market_adapter.d.ts.map +1 -1
  318. package/dist/market_adapter/market_adapter.js +5 -7
  319. package/dist/market_adapter/market_adapter.js.map +1 -1
  320. package/dist/market_adapter/test_helpers.d.ts +3 -3
  321. package/dist/market_adapter/test_helpers.d.ts.map +1 -1
  322. package/dist/market_adapter/test_helpers.js +3 -3
  323. package/dist/market_adapter/test_helpers.js.map +1 -1
  324. package/dist/market_adapter/utils/adapter_client.js +1 -1
  325. package/dist/market_adapter/utils/adapter_client.js.map +1 -1
  326. package/dist/market_adapter/utils/atomic_write.js +1 -1
  327. package/dist/market_adapter/utils/atomic_write.js.map +1 -1
  328. package/dist/market_adapter/utils/chain.d.ts +0 -2
  329. package/dist/market_adapter/utils/chain.d.ts.map +1 -1
  330. package/dist/market_adapter/utils/chain.js +2 -3
  331. package/dist/market_adapter/utils/chain.js.map +1 -1
  332. package/dist/market_adapter/utils/data_discovery.d.ts.map +1 -1
  333. package/dist/market_adapter/utils/data_discovery.js +24 -8
  334. package/dist/market_adapter/utils/data_discovery.js.map +1 -1
  335. package/dist/market_adapter/utils/dynamic_grid_snapshot.d.ts.map +1 -1
  336. package/dist/market_adapter/utils/dynamic_grid_snapshot.js +2 -5
  337. package/dist/market_adapter/utils/dynamic_grid_snapshot.js.map +1 -1
  338. package/dist/market_adapter/utils/file_lock.d.ts +4 -1
  339. package/dist/market_adapter/utils/file_lock.d.ts.map +1 -1
  340. package/dist/market_adapter/utils/file_lock.js +89 -25
  341. package/dist/market_adapter/utils/file_lock.js.map +1 -1
  342. package/dist/market_adapter/utils/native_history.d.ts.map +1 -1
  343. package/dist/market_adapter/utils/native_history.js +5 -1
  344. package/dist/market_adapter/utils/native_history.js.map +1 -1
  345. package/dist/modules/account_bots.d.ts +3 -0
  346. package/dist/modules/account_bots.d.ts.map +1 -1
  347. package/dist/modules/account_bots.js +157 -47
  348. package/dist/modules/account_bots.js.map +1 -1
  349. package/dist/modules/account_orders.d.ts +1 -7
  350. package/dist/modules/account_orders.d.ts.map +1 -1
  351. package/dist/modules/account_orders.js +9 -17
  352. package/dist/modules/account_orders.js.map +1 -1
  353. package/dist/modules/authority_resolver.js +1 -1
  354. package/dist/modules/authority_resolver.js.map +1 -1
  355. package/dist/modules/bitshares-native/chain_client.js +1 -1
  356. package/dist/modules/bitshares-native/chain_client.js.map +1 -1
  357. package/dist/modules/bitshares-native/crypto/ecc.browser.d.ts +0 -12
  358. package/dist/modules/bitshares-native/crypto/ecc.browser.d.ts.map +1 -1
  359. package/dist/modules/bitshares-native/crypto/ecc.browser.js +1 -1
  360. package/dist/modules/bitshares-native/crypto/ecc.browser.js.map +1 -1
  361. package/dist/modules/bitshares-native/crypto/ecc_selector.js +1 -1
  362. package/dist/modules/bitshares-native/crypto/ecc_selector.js.map +1 -1
  363. package/dist/modules/bitshares-native/index.d.ts.map +1 -1
  364. package/dist/modules/bitshares-native/index.js +1 -1
  365. package/dist/modules/bitshares-native/index.js.map +1 -1
  366. package/dist/modules/bitshares-native/lru_cache.js +1 -1
  367. package/dist/modules/bitshares-native/lru_cache.js.map +1 -1
  368. package/dist/modules/bitshares-native/resolvers.d.ts +0 -2
  369. package/dist/modules/bitshares-native/resolvers.d.ts.map +1 -1
  370. package/dist/modules/bitshares-native/resolvers.js +18 -4
  371. package/dist/modules/bitshares-native/resolvers.js.map +1 -1
  372. package/dist/modules/bitshares-native/serial/chain_constants.js +1 -1
  373. package/dist/modules/bitshares-native/serial/chain_constants.js.map +1 -1
  374. package/dist/modules/bitshares-native/serial/index.d.ts.map +1 -1
  375. package/dist/modules/bitshares-native/serial/index.js +1 -1
  376. package/dist/modules/bitshares-native/serial/index.js.map +1 -1
  377. package/dist/modules/bitshares-native/serial/operations.js +1 -1
  378. package/dist/modules/bitshares-native/serial/operations.js.map +1 -1
  379. package/dist/modules/bitshares-native/serial/serializer.js +1 -1
  380. package/dist/modules/bitshares-native/serial/serializer.js.map +1 -1
  381. package/dist/modules/bitshares-native/serial/types.js +1 -1
  382. package/dist/modules/bitshares-native/serial/types.js.map +1 -1
  383. package/dist/modules/bitshares-native/signing_client.js +2 -2
  384. package/dist/modules/bitshares-native/signing_client.js.map +1 -1
  385. package/dist/modules/bitshares-native/subscriptions.d.ts.map +1 -1
  386. package/dist/modules/bitshares-native/subscriptions.js +5 -14
  387. package/dist/modules/bitshares-native/subscriptions.js.map +1 -1
  388. package/dist/modules/bitshares-native/transport.js +1 -1
  389. package/dist/modules/bitshares-native/transport.js.map +1 -1
  390. package/dist/modules/bitshares-native/tx/builder.js +1 -1
  391. package/dist/modules/bitshares-native/tx/builder.js.map +1 -1
  392. package/dist/modules/bitshares-native/tx/tx_cache.d.ts +3 -2
  393. package/dist/modules/bitshares-native/tx/tx_cache.d.ts.map +1 -1
  394. package/dist/modules/bitshares-native/tx/tx_cache.js +7 -4
  395. package/dist/modules/bitshares-native/tx/tx_cache.js.map +1 -1
  396. package/dist/modules/bitshares_client.d.ts +2 -14
  397. package/dist/modules/bitshares_client.d.ts.map +1 -1
  398. package/dist/modules/bitshares_client.js +32 -41
  399. package/dist/modules/bitshares_client.js.map +1 -1
  400. package/dist/modules/bot_settings.d.ts.map +1 -1
  401. package/dist/modules/bot_settings.js +12 -19
  402. package/dist/modules/bot_settings.js.map +1 -1
  403. package/dist/modules/bots_file_lock.d.ts +1 -1
  404. package/dist/modules/bots_file_lock.js +1 -1
  405. package/dist/modules/broadcast_failure.d.ts +13 -0
  406. package/dist/modules/broadcast_failure.d.ts.map +1 -1
  407. package/dist/modules/broadcast_failure.js +0 -13
  408. package/dist/modules/broadcast_failure.js.map +1 -1
  409. package/dist/modules/chain_keys.js +2 -2
  410. package/dist/modules/chain_keys.js.map +1 -1
  411. package/dist/modules/chain_orders.d.ts +2 -3
  412. package/dist/modules/chain_orders.d.ts.map +1 -1
  413. package/dist/modules/chain_orders.js +23 -42
  414. package/dist/modules/chain_orders.js.map +1 -1
  415. package/dist/modules/config.d.ts.map +1 -1
  416. package/dist/modules/config.js +5 -2
  417. package/dist/modules/config.js.map +1 -1
  418. package/dist/modules/constants.d.ts +21 -21
  419. package/dist/modules/constants.d.ts.map +1 -1
  420. package/dist/modules/constants.js +53 -60
  421. package/dist/modules/constants.js.map +1 -1
  422. package/dist/modules/cr_planner.d.ts +1 -7
  423. package/dist/modules/cr_planner.d.ts.map +1 -1
  424. package/dist/modules/cr_planner.js +3 -77
  425. package/dist/modules/cr_planner.js.map +1 -1
  426. package/dist/modules/credential_policy.d.ts +0 -4
  427. package/dist/modules/credential_policy.d.ts.map +1 -1
  428. package/dist/modules/credential_policy.js +18 -3
  429. package/dist/modules/credential_policy.js.map +1 -1
  430. package/dist/modules/credit_runtime.d.ts +0 -7
  431. package/dist/modules/credit_runtime.d.ts.map +1 -1
  432. package/dist/modules/credit_runtime.js +21 -60
  433. package/dist/modules/credit_runtime.js.map +1 -1
  434. package/dist/modules/crypto/index.d.ts +0 -2
  435. package/dist/modules/crypto/index.d.ts.map +1 -1
  436. package/dist/modules/crypto/index.js +0 -2
  437. package/dist/modules/crypto/index.js.map +1 -1
  438. package/dist/modules/crypto/sync.js.map +1 -1
  439. package/dist/modules/daemon_node_health.js +1 -1
  440. package/dist/modules/daemon_node_health.js.map +1 -1
  441. package/dist/modules/dexbot_class.d.ts +8 -134
  442. package/dist/modules/dexbot_class.d.ts.map +1 -1
  443. package/dist/modules/dexbot_class.js +39 -199
  444. package/dist/modules/dexbot_class.js.map +1 -1
  445. package/dist/modules/dexbot_credential_client.js +1 -1
  446. package/dist/modules/dexbot_credential_client.js.map +1 -1
  447. package/dist/modules/dexbot_fill_runtime.d.ts.map +1 -1
  448. package/dist/modules/dexbot_fill_runtime.js +3 -6
  449. package/dist/modules/dexbot_fill_runtime.js.map +1 -1
  450. package/dist/modules/dexbot_maintenance_runtime.d.ts +6 -34
  451. package/dist/modules/dexbot_maintenance_runtime.d.ts.map +1 -1
  452. package/dist/modules/dexbot_maintenance_runtime.js +27 -19
  453. package/dist/modules/dexbot_maintenance_runtime.js.map +1 -1
  454. package/dist/modules/dexbot_startup_runtime.d.ts.map +1 -1
  455. package/dist/modules/dexbot_startup_runtime.js +31 -15
  456. package/dist/modules/dexbot_startup_runtime.js.map +1 -1
  457. package/dist/modules/dexbot_state_recovery.d.ts +2 -2
  458. package/dist/modules/dexbot_state_recovery.d.ts.map +1 -1
  459. package/dist/modules/dexbot_state_recovery.js +11 -7
  460. package/dist/modules/dexbot_state_recovery.js.map +1 -1
  461. package/dist/modules/fund_registry.d.ts.map +1 -1
  462. package/dist/modules/fund_registry.js +24 -6
  463. package/dist/modules/fund_registry.js.map +1 -1
  464. package/dist/modules/general_settings.d.ts +1 -2
  465. package/dist/modules/general_settings.d.ts.map +1 -1
  466. package/dist/modules/general_settings.js +1 -2
  467. package/dist/modules/general_settings.js.map +1 -1
  468. package/dist/modules/graceful_shutdown.d.ts.map +1 -1
  469. package/dist/modules/graceful_shutdown.js +10 -1
  470. package/dist/modules/graceful_shutdown.js.map +1 -1
  471. package/dist/modules/grid_price_source.d.ts +19 -0
  472. package/dist/modules/grid_price_source.d.ts.map +1 -0
  473. package/dist/modules/grid_price_source.js +23 -0
  474. package/dist/modules/grid_price_source.js.map +1 -0
  475. package/dist/modules/key_store.d.ts +0 -5
  476. package/dist/modules/key_store.d.ts.map +1 -1
  477. package/dist/modules/key_store.js +1 -14
  478. package/dist/modules/key_store.js.map +1 -1
  479. package/dist/modules/launcher/bot_supervisor.d.ts.map +1 -1
  480. package/dist/modules/launcher/bot_supervisor.js +15 -26
  481. package/dist/modules/launcher/bot_supervisor.js.map +1 -1
  482. package/dist/modules/launcher/child_env.d.ts +1 -2
  483. package/dist/modules/launcher/child_env.d.ts.map +1 -1
  484. package/dist/modules/launcher/child_env.js +1 -1
  485. package/dist/modules/launcher/child_env.js.map +1 -1
  486. package/dist/modules/launcher/foreign_cred_daemon.d.ts.map +1 -1
  487. package/dist/modules/launcher/foreign_cred_daemon.js +7 -13
  488. package/dist/modules/launcher/foreign_cred_daemon.js.map +1 -1
  489. package/dist/modules/launcher/market_adapter_runtime.d.ts +3 -4
  490. package/dist/modules/launcher/market_adapter_runtime.d.ts.map +1 -1
  491. package/dist/modules/launcher/market_adapter_runtime.js +10 -29
  492. package/dist/modules/launcher/market_adapter_runtime.js.map +1 -1
  493. package/dist/modules/launcher/market_adapter_watchdog.d.ts.map +1 -1
  494. package/dist/modules/launcher/market_adapter_watchdog.js +3 -2
  495. package/dist/modules/launcher/market_adapter_watchdog.js.map +1 -1
  496. package/dist/modules/launcher/monolithic_runtime.d.ts +0 -1
  497. package/dist/modules/launcher/monolithic_runtime.d.ts.map +1 -1
  498. package/dist/modules/launcher/monolithic_runtime.js +4 -18
  499. package/dist/modules/launcher/monolithic_runtime.js.map +1 -1
  500. package/dist/modules/launcher/runtime_entry.d.ts.map +1 -1
  501. package/dist/modules/launcher/runtime_entry.js +4 -5
  502. package/dist/modules/launcher/runtime_entry.js.map +1 -1
  503. package/dist/modules/launcher/status_reporting.d.ts +1 -2
  504. package/dist/modules/launcher/status_reporting.d.ts.map +1 -1
  505. package/dist/modules/launcher/status_reporting.js +2 -5
  506. package/dist/modules/launcher/status_reporting.js.map +1 -1
  507. package/dist/modules/launcher/supervisor_control.js +1 -1
  508. package/dist/modules/launcher/supervisor_control.js.map +1 -1
  509. package/dist/modules/market_adapter_whitelist.d.ts +2 -2
  510. package/dist/modules/market_adapter_whitelist.d.ts.map +1 -1
  511. package/dist/modules/market_adapter_whitelist.js +12 -6
  512. package/dist/modules/market_adapter_whitelist.js.map +1 -1
  513. package/dist/modules/node_failure_ledger.d.ts +23 -0
  514. package/dist/modules/node_failure_ledger.d.ts.map +1 -1
  515. package/dist/modules/node_failure_ledger.js +0 -23
  516. package/dist/modules/node_failure_ledger.js.map +1 -1
  517. package/dist/modules/node_manager.d.ts.map +1 -1
  518. package/dist/modules/node_manager.js +3 -3
  519. package/dist/modules/node_manager.js.map +1 -1
  520. package/dist/modules/order/accounting.js +3 -3
  521. package/dist/modules/order/accounting.js.map +1 -1
  522. package/dist/modules/order/async_lock.d.ts +6 -0
  523. package/dist/modules/order/async_lock.d.ts.map +1 -1
  524. package/dist/modules/order/async_lock.js +11 -0
  525. package/dist/modules/order/async_lock.js.map +1 -1
  526. package/dist/modules/order/export.d.ts +1 -1
  527. package/dist/modules/order/export.js +10 -10
  528. package/dist/modules/order/export.js.map +1 -1
  529. package/dist/modules/order/format.d.ts +1 -8
  530. package/dist/modules/order/format.d.ts.map +1 -1
  531. package/dist/modules/order/format.js +0 -14
  532. package/dist/modules/order/format.js.map +1 -1
  533. package/dist/modules/order/grid.d.ts +2 -12
  534. package/dist/modules/order/grid.d.ts.map +1 -1
  535. package/dist/modules/order/grid.js +23 -24
  536. package/dist/modules/order/grid.js.map +1 -1
  537. package/dist/modules/order/grid_reconcile.d.ts +1 -1
  538. package/dist/modules/order/grid_reconcile.js +1 -1
  539. package/dist/modules/order/grid_reconcile_internal.js +1 -1
  540. package/dist/modules/order/grid_reconcile_internal.js.map +1 -1
  541. package/dist/modules/order/logger.d.ts +3 -0
  542. package/dist/modules/order/logger.d.ts.map +1 -1
  543. package/dist/modules/order/logger.js +23 -14
  544. package/dist/modules/order/logger.js.map +1 -1
  545. package/dist/modules/order/logger_state.d.ts +5 -22
  546. package/dist/modules/order/logger_state.d.ts.map +1 -1
  547. package/dist/modules/order/logger_state.js +6 -25
  548. package/dist/modules/order/logger_state.js.map +1 -1
  549. package/dist/modules/order/manager.d.ts +1 -4
  550. package/dist/modules/order/manager.d.ts.map +1 -1
  551. package/dist/modules/order/manager.js +34 -33
  552. package/dist/modules/order/manager.js.map +1 -1
  553. package/dist/modules/order/processed_fill_store.d.ts +0 -5
  554. package/dist/modules/order/processed_fill_store.d.ts.map +1 -1
  555. package/dist/modules/order/processed_fill_store.js +10 -15
  556. package/dist/modules/order/processed_fill_store.js.map +1 -1
  557. package/dist/modules/order/strategy.d.ts +6 -4
  558. package/dist/modules/order/strategy.d.ts.map +1 -1
  559. package/dist/modules/order/strategy.js +6 -4
  560. package/dist/modules/order/strategy.js.map +1 -1
  561. package/dist/modules/order/sync_engine.d.ts.map +1 -1
  562. package/dist/modules/order/sync_engine.js +17 -10
  563. package/dist/modules/order/sync_engine.js.map +1 -1
  564. package/dist/modules/order/utils/math.d.ts +7 -1
  565. package/dist/modules/order/utils/math.d.ts.map +1 -1
  566. package/dist/modules/order/utils/math.js +19 -1
  567. package/dist/modules/order/utils/math.js.map +1 -1
  568. package/dist/modules/order/utils/order.d.ts.map +1 -1
  569. package/dist/modules/order/utils/order.js +11 -4
  570. package/dist/modules/order/utils/order.js.map +1 -1
  571. package/dist/modules/order/utils/system.d.ts +3 -8
  572. package/dist/modules/order/utils/system.d.ts.map +1 -1
  573. package/dist/modules/order/utils/system.js +14 -4
  574. package/dist/modules/order/utils/system.js.map +1 -1
  575. package/dist/modules/order/utils/validate.js +1 -1
  576. package/dist/modules/order/utils/validate.js.map +1 -1
  577. package/dist/modules/path_api.js +1 -1
  578. package/dist/modules/path_api.js.map +1 -1
  579. package/dist/modules/paths.d.ts +1 -7
  580. package/dist/modules/paths.d.ts.map +1 -1
  581. package/dist/modules/paths.js +1 -1
  582. package/dist/modules/paths.js.map +1 -1
  583. package/dist/modules/process_discovery.d.ts +3 -0
  584. package/dist/modules/process_discovery.d.ts.map +1 -1
  585. package/dist/modules/process_discovery.js +15 -1
  586. package/dist/modules/process_discovery.js.map +1 -1
  587. package/dist/modules/runtime_settings.js +4 -2
  588. package/dist/modules/runtime_settings.js.map +1 -1
  589. package/dist/modules/settings_merge.d.ts +5 -1
  590. package/dist/modules/settings_merge.d.ts.map +1 -1
  591. package/dist/modules/settings_merge.js +17 -4
  592. package/dist/modules/settings_merge.js.map +1 -1
  593. package/dist/modules/socket_json_client.d.ts.map +1 -1
  594. package/dist/modules/socket_json_client.js +12 -2
  595. package/dist/modules/socket_json_client.js.map +1 -1
  596. package/dist/modules/storage/browser_adapter.d.ts +8 -3
  597. package/dist/modules/storage/browser_adapter.d.ts.map +1 -1
  598. package/dist/modules/storage/browser_adapter.js +58 -7
  599. package/dist/modules/storage/browser_adapter.js.map +1 -1
  600. package/dist/modules/storage/index.d.ts +1 -1
  601. package/dist/modules/storage/index.js +1 -1
  602. package/dist/modules/types.d.ts +1 -1
  603. package/dist/modules/types.d.ts.map +1 -1
  604. package/dist/modules/utils/sanitize_key.d.ts +7 -0
  605. package/dist/modules/utils/sanitize_key.d.ts.map +1 -0
  606. package/dist/modules/utils/sanitize_key.js +15 -0
  607. package/dist/modules/utils/sanitize_key.js.map +1 -0
  608. package/dist/modules/validate_profiles.d.ts.map +1 -1
  609. package/dist/modules/validate_profiles.js +6 -8
  610. package/dist/modules/validate_profiles.js.map +1 -1
  611. package/dist/pm2.d.ts.map +1 -1
  612. package/dist/pm2.js +8 -9
  613. package/dist/pm2.js.map +1 -1
  614. package/dist/scripts/analyze-git.d.ts +1 -1
  615. package/dist/scripts/analyze-git.js +1 -1
  616. package/dist/scripts/analyze-orders.d.ts +2 -2
  617. package/dist/scripts/analyze-orders.d.ts.map +1 -1
  618. package/dist/scripts/analyze-orders.js +39 -28
  619. package/dist/scripts/analyze-orders.js.map +1 -1
  620. package/dist/scripts/diagnose-pool-history.js +1 -1
  621. package/dist/scripts/divergence-calc.d.ts +1 -1
  622. package/dist/scripts/divergence-calc.js +3 -3
  623. package/dist/scripts/native_release_gates.js +4 -2
  624. package/dist/scripts/native_release_gates.js.map +1 -1
  625. package/dist/scripts/print_grid.d.ts +1 -1
  626. package/dist/scripts/print_grid.js +1 -1
  627. package/dist/scripts/run-tests.js +38 -19
  628. package/dist/scripts/run-tests.js.map +1 -1
  629. package/dist/scripts/runner.d.ts +3 -5
  630. package/dist/scripts/runner.d.ts.map +1 -1
  631. package/dist/scripts/runner.js +4 -6
  632. package/dist/scripts/runner.js.map +1 -1
  633. package/dist/scripts/sync-version.d.ts +2 -2
  634. package/dist/scripts/sync-version.js +2 -2
  635. package/dist/scripts/update.d.ts +1 -1
  636. package/dist/scripts/update.js +2 -2
  637. package/dist/scripts/update.js.map +1 -1
  638. package/dist/scripts/validate_bots.d.ts +1 -1
  639. package/dist/scripts/validate_bots.js +1 -1
  640. package/dist/scripts/verify-browser-bundle.d.ts +1 -1
  641. package/dist/scripts/verify-browser-bundle.js +1 -1
  642. package/dist/unlock.js +4 -4
  643. package/dist/unlock.js.map +1 -1
  644. package/docs/BITSHARES_ONBOARDING.md +63 -18
  645. package/docs/COPY_ON_WRITE_MASTER_PLAN.md +14 -23
  646. package/docs/COW_INVARIANTS.md +4 -4
  647. package/docs/CREDENTIAL_SECURITY.md +0 -11
  648. package/docs/DEXBOT_COMPARISON.md +12 -12
  649. package/docs/EVOLUTION.md +17 -43
  650. package/docs/FUND_MOVEMENT_AND_ACCOUNTING.md +27 -83
  651. package/docs/GRID_RECALCULATION.md +1 -13
  652. package/docs/GRID_RECONCILE.md +24 -24
  653. package/docs/LIFECYCLE.md +4 -4
  654. package/docs/LOGGING.md +1 -1
  655. package/docs/MPA_CREDIT_USAGE.md +3 -3
  656. package/docs/README.md +2 -2
  657. package/docs/WORKFLOW.md +2 -2
  658. package/docs/architecture.md +48 -43
  659. package/docs/developer_guide.md +22 -24
  660. package/market_adapter/README.md +0 -2
  661. package/modules/README.md +2 -1
  662. package/package.json +22 -14
  663. package/scripts/README.md +34 -8
  664. package/scripts/clean-dist.js +10 -2
  665. package/tests/README.md +4 -3
  666. package/claw/openclaw.plugin.json +0 -13
  667. package/dist/market_adapter/merge_lp_data.d.ts +0 -3
  668. package/dist/market_adapter/merge_lp_data.d.ts.map +0 -1
  669. package/dist/market_adapter/merge_lp_data.js +0 -125
  670. package/dist/market_adapter/merge_lp_data.js.map +0 -1
  671. package/dist/market_adapter/utils/paths.d.ts +0 -3
  672. package/dist/market_adapter/utils/paths.d.ts.map +0 -1
  673. package/dist/market_adapter/utils/paths.js +0 -5
  674. package/dist/market_adapter/utils/paths.js.map +0 -1
@@ -1,3 +1,4 @@
1
+ 'use strict';
1
2
 
2
3
  import { createRequire } from 'node:module';
3
4
  const require = createRequire(import.meta.url);
@@ -8,7 +9,6 @@ import { loadSettingsFile, resolveRawBotEntries, saveSettingsFile, normalizeBotE
8
9
  import { normalizeMode, detectMode, setPreferredMode, describeModeChoice } from './launcher_mode_detector.js';
9
10
  import { normalizeRoot, resolveRuntimeScript, normalizeProfileDir } from './launcher_paths.js';
10
11
  import { getErrorMessage } from '../../modules/utils/errors.js';
11
- 'use strict';
12
12
 
13
13
  const storage = getStorage();
14
14
 
@@ -56,6 +56,40 @@ function getSpawn(): any {
56
56
  return _spawn;
57
57
  }
58
58
 
59
+ /**
60
+ * Spawn a detached background child and wait for the spawn itself to succeed.
61
+ * Spawn failures (missing script, ENOENT, EACCES) are reported asynchronously
62
+ * via the child's 'error' event; waiting one macrotask lets those surface as a
63
+ * thrown error instead of callers receiving a false { started: true } result.
64
+ * A permanent 'error' handler remains attached so late errors are logged
65
+ * rather than crashing the host with an unhandled 'error' event.
66
+ */
67
+ function spawnDetached(scriptPath: string, args: string[], cwd: string): Promise<any> {
68
+ const child = getSpawn()('node', [scriptPath, ...args], {
69
+ detached: true,
70
+ stdio: 'ignore',
71
+ cwd
72
+ });
73
+
74
+ return new Promise((resolve, reject) => {
75
+ let settled = false;
76
+ child.on('error', (err: any) => {
77
+ if (!settled) {
78
+ settled = true;
79
+ reject(new Error(`Failed to spawn ${scriptPath}: ${getErrorMessage(err)}`));
80
+ return;
81
+ }
82
+ console.error(`[LAUNCHER] Child process error (${scriptPath}): ${getErrorMessage(err)}`);
83
+ });
84
+ setImmediate(() => {
85
+ if (!settled) {
86
+ settled = true;
87
+ resolve(child);
88
+ }
89
+ });
90
+ });
91
+ }
92
+
59
93
  let _pm2: any;
60
94
  function getPM2Module(): any {
61
95
  if (_pm2 === undefined) {
@@ -88,16 +122,7 @@ async function launcherStart(botName: string | null, options: Record<string, any
88
122
  args.push(botName);
89
123
  }
90
124
 
91
- const child = getSpawn()('node', [dexbotPath, ...args], {
92
- detached: true,
93
- stdio: 'ignore',
94
- cwd: ROOT
95
- });
96
-
97
- child.on('error', (err: any) => {
98
- console.error(`[LAUNCHER] Failed to spawn ${dexbotPath}: ${getErrorMessage(err)}`);
99
- });
100
-
125
+ const child = await spawnDetached(dexbotPath, args, ROOT);
101
126
  child.unref();
102
127
 
103
128
  return {
@@ -124,16 +149,7 @@ async function launcherDrystart(botName: string | null, options: Record<string,
124
149
  args.push(botName);
125
150
  }
126
151
 
127
- const child = getSpawn()('node', [dexbotPath, ...args], {
128
- detached: true,
129
- stdio: 'ignore',
130
- cwd: ROOT
131
- });
132
-
133
- child.on('error', (err: any) => {
134
- console.error(`[LAUNCHER] Failed to spawn ${dexbotPath}: ${getErrorMessage(err)}`);
135
- });
136
-
152
+ const child = await spawnDetached(dexbotPath, args, ROOT);
137
153
  child.unref();
138
154
 
139
155
  return {
@@ -158,10 +174,10 @@ async function launcherReset(botName: string | null, options: Record<string, any
158
174
  const { config } = loadSettingsFile(PROFILES_BOTS_FILE);
159
175
  const entries = normalizeBotEntries(resolveRawBotEntries(config));
160
176
 
161
- const targets = botName ? entries.filter((b: any) => b.name === botName) : entries.filter((b: any) => b.active);
177
+ const targets = botName ? entries.filter((b: any) => b.name === botName) : entries.filter((b: any) => b.active !== false);
162
178
 
163
179
  if (botName && targets.length === 0) {
164
- throw new Error(`Bot '${botName}' not found in profiles/bots.json`);
180
+ throw new Error(`Bot '${botName}' not found in ${PROFILES_BOTS_FILE}`);
165
181
  }
166
182
 
167
183
  const triggered: Array<Record<string, any>> = [];
@@ -221,7 +237,7 @@ async function launcherDisable(botName: string | null, options: Record<string, a
221
237
 
222
238
  const match = entries.find((b: any) => b.name === botName);
223
239
  if (!match) {
224
- throw new Error(`Bot '${botName}' not found in profiles/bots.json`);
240
+ throw new Error(`Bot '${botName}' not found in ${PROFILES_BOTS_FILE}`);
225
241
  }
226
242
 
227
243
  if (match.active === false) {
@@ -252,10 +268,10 @@ async function launcherPm2Start(botName: string | null, options: Record<string,
252
268
  const { config } = loadSettingsFile(PROFILES_BOTS_FILE);
253
269
  const entries = normalizeBotEntries(resolveRawBotEntries(config));
254
270
 
255
- const targets = botName ? entries.filter((b: any) => b.name === botName) : entries.filter((b: any) => b.active);
271
+ const targets = botName ? entries.filter((b: any) => b.name === botName) : entries.filter((b: any) => b.active !== false);
256
272
 
257
273
  if (botName && targets.length === 0) {
258
- throw new Error(`Bot '${botName}' not found or not active in profiles/bots.json`);
274
+ throw new Error(`Bot '${botName}' not found or not active in ${PROFILES_BOTS_FILE}`);
259
275
  }
260
276
 
261
277
  // Then check if daemon is ready
@@ -292,7 +308,7 @@ async function launcherPm2Start(botName: string | null, options: Record<string,
292
308
  * @param {Object} [options={}] - Options
293
309
  * @returns {Promise<Object>} { stopped: true, target }
294
310
  */
295
- async function launcherPm2Stop(target: string, options: Record<string, any> = {}) {
311
+ async function launcherPm2Stop(target: string, _options: Record<string, any> = {}) {
296
312
  await getPM2Module().stopPM2Processes(target || 'all');
297
313
  return {
298
314
  stopped: true,
@@ -306,7 +322,7 @@ async function launcherPm2Stop(target: string, options: Record<string, any> = {}
306
322
  * @param {Object} [options={}] - Options
307
323
  * @returns {Promise<Object>} { deleted: true, target }
308
324
  */
309
- async function launcherPm2Delete(target: string, options: Record<string, any> = {}) {
325
+ async function launcherPm2Delete(target: string, _options: Record<string, any> = {}) {
310
326
  await getPM2Module().deletePM2Processes(target || 'all');
311
327
  return {
312
328
  deleted: true,
@@ -320,7 +336,7 @@ async function launcherPm2Delete(target: string, options: Record<string, any> =
320
336
  * @param {Object} [options={}] - Options
321
337
  * @returns {Promise<Object>} { restarted: true, target }
322
338
  */
323
- async function launcherPm2Restart(target: string, options: Record<string, any> = {}) {
339
+ async function launcherPm2Restart(target: string, _options: Record<string, any> = {}) {
324
340
  await getPM2Module().restartPM2Processes(target || 'all');
325
341
  return {
326
342
  restarted: true,
@@ -422,16 +438,7 @@ async function launcherClawOnly(options: Record<string, any> = {}) {
422
438
  const ROOT = normalizeRoot(options);
423
439
  const pm2ScriptPath = resolveRuntimeScript(ROOT, 'pm2.js');
424
440
 
425
- const child = getSpawn()('node', [pm2ScriptPath, 'claw-only'], {
426
- detached: true,
427
- stdio: 'ignore',
428
- cwd: ROOT
429
- });
430
-
431
- child.on('error', (err: any) => {
432
- console.error(`[LAUNCHER] Failed to spawn ${pm2ScriptPath}: ${getErrorMessage(err)}`);
433
- });
434
-
441
+ const child = await spawnDetached(pm2ScriptPath, ['claw-only'], ROOT);
435
442
  child.unref();
436
443
 
437
444
  return {
@@ -459,16 +466,7 @@ async function launcherUnlockStart(botName: string | null, options: Record<strin
459
466
  args.push(botName);
460
467
  }
461
468
 
462
- const child = getSpawn()('node', [unlockPath, ...args], {
463
- detached: true,
464
- stdio: 'ignore',
465
- cwd: ROOT
466
- });
467
-
468
- child.on('error', (err: any) => {
469
- console.error(`[LAUNCHER] Failed to spawn ${unlockPath}: ${getErrorMessage(err)}`);
470
- });
471
-
469
+ const child = await spawnDetached(unlockPath, args, ROOT);
472
470
  child.unref();
473
471
 
474
472
  return {
@@ -481,5 +479,5 @@ async function launcherUnlockStart(botName: string | null, options: Record<strin
481
479
  };
482
480
  }
483
481
 
484
- export { launcherRun, launcherStart, launcherDrystart, launcherReset, launcherDisable, launcherPm2Start, launcherPm2Stop, launcherPm2Delete, launcherPm2Restart }
482
+ export { launcherRun, launcherDrystart, launcherReset, launcherDisable, launcherPm2Start, launcherPm2Stop, launcherPm2Delete, launcherPm2Restart }
485
483
 
@@ -12,14 +12,11 @@ function normalizeClawRepoRoot(repoRoot: string) {
12
12
  }
13
13
 
14
14
  // Generated docs must reference scripts that actually exist. Claw tooling
15
- // lives in claw/scripts/ (shipped as source); prefer a compiled sibling when
16
- // present, otherwise fall back to the .ts source run through tsx.
15
+ // ships compiled to dist/claw/scripts/ (npm run build); generated skill
16
+ // files always reference the node + .js form so they work without any
17
+ // TypeScript loader installed.
17
18
  function resolveScriptInvocation(repoRoot: string, name: string) {
18
- const jsPath = path.join(repoRoot, 'claw', 'scripts', `${name}.js`);
19
- if (storage.exists(jsPath)) {
20
- return { command: 'node', script: jsPath };
21
- }
22
- return { command: 'npx tsx', script: path.join(repoRoot, 'claw', 'scripts', `${name}.ts`) };
19
+ return { command: 'node', script: path.join(repoRoot, 'dist', 'claw', 'scripts', `${name}.js`) };
23
20
  }
24
21
 
25
22
  function buildBridgeInvocation(repoRoot: string, profileRoot: string, command: string, extraArgs: any[] = []) {
@@ -49,8 +46,8 @@ function buildToolSummary(runtimeName: string) {
49
46
 
50
47
  function buildRuntimeSetup(runtime: any, repoRoot: string, profileRoot: string) {
51
48
  const { command, script: mcpScriptPath } = resolveScriptInvocation(repoRoot, 'claw_mcp_server');
52
- // command is 'node' or 'npx tsx'; split so the config blocks can set the
53
- // executable and args correctly for both the built and source layouts.
49
+ // command is 'node'; split so the config blocks can set the
50
+ // executable and args correctly for the built layout.
54
51
  const runnerParts = command.split(' ');
55
52
  const mcpExec = runnerParts[0];
56
53
  const mcpArgs = `[${[...runnerParts.slice(1), mcpScriptPath, '--profile-root', profileRoot].map((part: any) => JSON.stringify(part)).join(', ')}]`;
@@ -209,7 +206,7 @@ function buildRuntimeSetup(runtime: any, repoRoot: string, profileRoot: string)
209
206
  'Start the memU MCP server:',
210
207
  '',
211
208
  '```bash',
212
- `tsx ${path.join(repoRoot, 'claw', 'scripts', 'memu_mcp_server.ts').replace(/\\/g, '/')} --memu-dir ${PATHS.CLAW.MEMU_DIR.replace(/\\/g, '/')}`,
209
+ `node ${path.join(repoRoot, 'dist', 'claw', 'scripts', 'memu_mcp_server.js').replace(/\\/g, '/')} --memu-dir ${PATHS.CLAW.MEMU_DIR.replace(/\\/g, '/')}`,
213
210
  '```',
214
211
  '',
215
212
  'Or use the npm script:',
@@ -237,20 +234,17 @@ function buildRuntimeSetup(runtime: any, repoRoot: string, profileRoot: string)
237
234
  }
238
235
 
239
236
  function buildRuntimeWorkflow(runtime: any) {
240
- if (runtime.runtime === 'hermes') {
241
- return [
242
- '- Start with `claw_manifest`, `claw_runtime`, `claw_profile_context`, `claw_market_snapshot`, `claw_account_snapshot`, or `claw_open_orders`.',
243
- '- For MPA and short workflows, use `claw_build_open_short_plan`, `claw_build_take_profit_plan`, or `claw_build_close_short_plan` before executing trades.',
244
- '- Use `claw_honest_context`, `claw_honest_pair`, and `claw_honest_price` when the task involves HONEST assets or discovery.',
245
- '- The shared Claw MCP server registers raw tool ids such as `claw_manifest`; if Hermes shows a namespaced label in its UI, follow the label shown there.'
246
- ].join('\n');
247
- }
248
-
249
- return [
237
+ const baseLines = [
250
238
  '- Start with `claw_manifest`, `claw_runtime`, `claw_profile_context`, `claw_market_snapshot`, `claw_account_snapshot`, or `claw_open_orders`.',
251
239
  '- For MPA and short workflows, use `claw_build_open_short_plan`, `claw_build_take_profit_plan`, or `claw_build_close_short_plan` before executing trades.',
252
240
  '- Use `claw_honest_context`, `claw_honest_pair`, and `claw_honest_price` when the task involves HONEST assets or discovery.'
253
- ].join('\n');
241
+ ];
242
+
243
+ if (runtime.runtime === 'hermes') {
244
+ baseLines.push('- The shared Claw MCP server registers raw tool ids such as `claw_manifest`; if Hermes shows a namespaced label in its UI, follow the label shown there.');
245
+ }
246
+
247
+ return baseLines.join('\n');
254
248
  }
255
249
 
256
250
  function buildRuntimeSkillToml(runtime: any, repoRoot: string, profileRoot: string) {
@@ -1,8 +1,8 @@
1
+ 'use strict';
1
2
 
2
3
  import { PATHS } from '../../modules/paths.js';
3
4
  import CreditRuntime from '../../modules/credit_runtime.js';
4
5
  import { getErrorMessage } from '../../modules/utils/errors.js';
5
- 'use strict';
6
6
 
7
7
 
8
8
  function createCreditRuntimeAdapter(infra: any, options: Record<string, any> = {}) {
@@ -24,7 +24,7 @@ function createCreditRuntimeAdapter(infra: any, options: Record<string, any> = {
24
24
  assetA: botEntry.assetA,
25
25
  assetB: botEntry.assetB,
26
26
  },
27
- _log: (msg: string, level?: string) => {
27
+ _log: (msg: string) => {
28
28
  const logger = infra.runtime?.logger || console;
29
29
  if (typeof logger.info === 'function') logger.info(`[credit-runtime] ${msg}`);
30
30
  else logger.log(`[credit-runtime] ${msg}`);
@@ -100,10 +100,7 @@ function createCreditRuntimeAdapter(infra: any, options: Record<string, any> = {
100
100
  const rt = await _getRuntime(botRef);
101
101
  if (!rt) {
102
102
  try {
103
- const bundle = await infra.profiles.loadBundle();
104
- const bot = bundle.bots.find(
105
- (b: Record<string, any>) => b.botKey === botRef || b.name === botRef,
106
- );
103
+ const bot = await _resolveBotEntry(botRef);
107
104
  if (!bot) return { error: `bot not found: ${botRef}` };
108
105
  if (!bot.debtPolicy) return { error: `bot ${botRef} has no debtPolicy configured` };
109
106
  return { error: `unable to initialize credit runtime for ${botRef}` };
@@ -142,19 +139,6 @@ function createCreditRuntimeAdapter(infra: any, options: Record<string, any> = {
142
139
  _ensureSigningKey(rt, privateKey);
143
140
  return rt.processPendingReborrows();
144
141
  },
145
-
146
- listRuntimes(): any[] {
147
- return Array.from(_runtimes.entries())
148
- .filter(([_, rt]) => rt.isEnabled())
149
- .map(([key, rt]) => ({
150
- botKey: key,
151
- enabled: rt.isEnabled(),
152
- }));
153
- },
154
-
155
- getRuntime(botRef: string): any | null {
156
- return _runtimes.get(botRef) || null;
157
- },
158
142
  };
159
143
  }
160
144
 
@@ -1,3 +1,4 @@
1
+ 'use strict';
1
2
  /**
2
3
  * Decision Loop
3
4
  *
@@ -16,22 +17,17 @@
16
17
  */
17
18
 
18
19
 
19
- import { createRequire } from 'node:module';
20
- const require = createRequire(import.meta.url);
21
-
22
20
  import { discoverPositions } from './position_discovery.js';
23
21
  import { assessPosition } from './position_health.js';
24
22
  import { fetchTrendInput } from './feed_price_source.js';
25
23
  import { getErrorMessage } from '../../modules/utils/errors.js';
26
- 'use strict';
24
+ // Static import (previously a lazy createRequire fallback): lazy require()
25
+ // bypasses the ESM loader hooks that compiled tests use for module mocking,
26
+ // and the analyzer module carries no circular-import risk.
27
+ import { KalmanTrendAnalyzer } from '../../market_adapter/core/signals/kalman_trend_analyzer.js';
27
28
 
28
29
 
29
- // Lazy-load KalmanTrendAnalyzer to avoid circular dependency issues at startup
30
- let KalmanTrendAnalyzer: any = null;
31
30
  function getTrendAnalyzer() {
32
- if (!KalmanTrendAnalyzer) {
33
- KalmanTrendAnalyzer = require('../../market_adapter/core/signals/kalman_trend_analyzer').KalmanTrendAnalyzer;
34
- }
35
31
  return KalmanTrendAnalyzer;
36
32
  }
37
33
 
@@ -186,6 +182,10 @@ function buildSummary(assessments: Array<Record<string, any>>) {
186
182
  function resetAnalyzers() {
187
183
  analyzers.clear();
188
184
  analyzerConfigs.clear();
185
+ // Premiums belong to the analyzer generation that produced them; keeping
186
+ // them across a reset would let the reuse path report a stale value from
187
+ // discarded config.
188
+ marketPremiums.clear();
189
189
  }
190
190
 
191
191
  export { evaluate, getOrCreateAnalyzer, resetAnalyzers }
@@ -41,13 +41,13 @@ function getDexbot2Root() {
41
41
  function resolveDexbot2Path(relativePath: string) {
42
42
  const root = getDexbot2Root();
43
43
  const normalizedPath = String(relativePath || '');
44
- const candidates = [path.join(root, normalizedPath)];
45
44
 
46
- if (normalizedPath.endsWith('.js')) {
47
- candidates.push(path.join(root, normalizedPath.replace(/\.js$/, '.ts')));
48
- }
49
-
50
- candidates.push(path.join(root, BUILD_DIR, normalizedPath));
45
+ // Compiled build first: under plain node there is no tsx-style .js→.ts
46
+ // interception, so resolving to the source tree would break require().
47
+ const candidates = [
48
+ path.join(root, BUILD_DIR, normalizedPath),
49
+ path.join(root, normalizedPath),
50
+ ];
51
51
 
52
52
  for (const candidate of candidates) {
53
53
  if (candidateExists(candidate)) {
@@ -55,7 +55,7 @@ function resolveDexbot2Path(relativePath: string) {
55
55
  }
56
56
  }
57
57
 
58
- return candidates[candidates.length - 1];
58
+ return candidates[0];
59
59
  }
60
60
 
61
61
  function requireDexbot2Module(relativePath: string) {
@@ -78,5 +78,5 @@ function loadDexbotOrderSystemUtils() {
78
78
  return requireDexbot2Module('modules/order/utils/system');
79
79
  }
80
80
 
81
- export { getDexbot2Root, loadDexbotOrderConstants, loadDexbotOrderSubsystem, loadDexbotOrderSystemUtils, loadDexbotOrderUtils, requireDexbot2Module, resolveDexbot2Path }
81
+ export { getDexbot2Root, loadDexbotOrderConstants, loadDexbotOrderSubsystem, loadDexbotOrderSystemUtils, loadDexbotOrderUtils, requireDexbot2Module }
82
82
 
@@ -12,7 +12,7 @@ import { clone } from './utils.js';
12
12
  import { createBotKey, sanitizeKey } from '../../modules/account_orders.js';
13
13
  const storage = getStorage();
14
14
 
15
- import type { BotSettings, ProfileOptions, Logger, ClawProfileBundle } from './types.js';
15
+ import type { BotSettings, ProfileOptions, ClawProfileBundle } from './types.js';
16
16
  import { getErrorMessage } from '../../modules/utils/errors.js';
17
17
 
18
18
  const DEFAULT_MANIFEST_FILE = 'config.json';
@@ -661,7 +661,7 @@ async function normalizeBotEntries(rawEntries: Record<string, any>[], options: P
661
661
  if (logger) {
662
662
  validateBotEntry(entry, index, logger);
663
663
  }
664
- const normalized = { active: entry.active === undefined ? true : !!entry.active, ...entry };
664
+ const normalized = { ...entry, active: entry.active === undefined ? true : !!entry.active };
665
665
  results.push({ ...normalized, botIndex: index, botKey: createBotKey(normalized, index) });
666
666
  }
667
667
  return results;
@@ -1008,8 +1008,8 @@ async function loadDexbotProfileBundle(profileRoot: string | null, options: Part
1008
1008
  * The adapter wraps bundle loading, settings validation, and atomic writes behind
1009
1009
  * per-file locks so concurrent updates do not clobber each other.
1010
1010
  *
1011
- * @returns {Object} Adapter with loadBundle, listBots, findBot, getBotBundle,
1012
- * getBotSettings, previewBotSettingsUpdate, applyBotSettingsPatch, getProfilesDir
1011
+ * @returns {Object} Adapter with loadBundle, getBotSettings,
1012
+ * previewBotSettingsUpdate, applyBotSettingsPatch, updateBotSettings, getClawProfileContext
1013
1013
  */
1014
1014
  function createDexbotProfileAdapter(profileRoot: string | null, options: Partial<ProfileOptions> = {}) {
1015
1015
  let cachedBundle: any = null;
@@ -1025,16 +1025,6 @@ function createDexbotProfileAdapter(profileRoot: string | null, options: Partial
1025
1025
  return resolveProfilesDir(profileRoot || options.profileRoot);
1026
1026
  }
1027
1027
 
1028
- async function listBots({ activeOnly = false, forceReload = false } = {}) {
1029
- const bundle = await loadBundle(forceReload);
1030
- return activeOnly ? bundle.activeBots : bundle.bots;
1031
- }
1032
-
1033
- async function findBot(identifier: any, forceReload = false) {
1034
- const bundle = await loadBundle(forceReload);
1035
- return bundle.bots.find((bot: any) => matchBotIdentifier(bot, identifier)) || null;
1036
- }
1037
-
1038
1028
  async function getBotBundle(identifier: any, forceReload = false) {
1039
1029
  const bundle = await loadBundle(forceReload);
1040
1030
  const bot = bundle.bots.find((entry: any) => matchBotIdentifier(entry, identifier)) || null;
@@ -1272,20 +1262,14 @@ function createDexbotProfileAdapter(profileRoot: string | null, options: Partial
1272
1262
  }
1273
1263
 
1274
1264
  return {
1275
- buildClawProfileContext: (bundle: any, contextOptions = {}) => buildClawProfileContext(bundle, contextOptions),
1276
1265
  applyBotSettingsPatch,
1277
- findBot,
1278
- getBotBundle,
1279
1266
  getBotSettings,
1280
1267
  getClawProfileContext,
1281
- getProfilesDir,
1282
- listBots,
1283
1268
  loadBundle,
1284
1269
  previewBotSettingsUpdate,
1285
- resolveProfilesDir: () => resolveProfilesDir(profileRoot || options.profileRoot),
1286
1270
  updateBotSettings
1287
1271
  };
1288
1272
  }
1289
1273
 
1290
- export { buildBotSettingsView, createBotKey, createDexbotProfileAdapter, buildClawProfileContext, describeBotSettingMutability, loadDexbotProfileBundle, matchBotIdentifier, normalizeBotSettings, normalizeBotEntries, readTriggerFile, resolveProfilesDir, resolveRawBotEntries, sanitizeKey, validateBotEntry, validateBotSettingsPatch, validateBotSettingsState, writeJsonFileAtomic }
1274
+ export { createBotKey, createDexbotProfileAdapter, matchBotIdentifier, normalizeBotEntries, resolveProfilesDir, resolveRawBotEntries, validateBotEntry, writeJsonFileAtomic }
1291
1275
 
@@ -1,3 +1,4 @@
1
+ 'use strict';
1
2
  /**
2
3
  * Feed Price Source
3
4
  *
@@ -12,7 +13,6 @@
12
13
  import { getAsset, getBackingAsset, getBitassetData, dbCall } from './chain_queries.js';
13
14
  import { computeBtsPerMpa } from './mpa_utils.js';
14
15
  import { roundTo } from '../../modules/order/utils/math.js';
15
- 'use strict';
16
16
 
17
17
 
18
18
  /**
@@ -88,7 +88,11 @@ async function fetchLivePoolReserves(poolId: string = HARDCODED_POOL_ID) {
88
88
  };
89
89
  _poolReservesCache = { poolId, ts: Date.now(), value: result };
90
90
  return result;
91
- } catch {
91
+ } catch (err: any) {
92
+ // Never cache failures, but surface them: silently serving the hardcoded
93
+ // fallback snapshot hides a degraded node and produces confidently-wrong
94
+ // bridge prices with no telemetry trail.
95
+ console.warn(`[honest-ecosystem] live pool reserves fetch failed for ${poolId}, using hardcoded fallback: ${err?.message || err}`);
92
96
  return null;
93
97
  }
94
98
  }
@@ -217,10 +221,15 @@ async function resolveHonestPairContext(assetA: any, assetB: any, options: Recor
217
221
  };
218
222
  }
219
223
 
220
- async function loadHonestAssets({ prefix = DEFAULT_PREFIX, batchSize = 100, maxPages = 100, startSymbol = DEFAULT_PREFIX }: Record<string, any> = {}) {
221
- const all = [];
224
+ /**
225
+ * Paginate list_assets with the shared dedup/boundary rules used across the
226
+ * HONEST tooling. `onPage` receives each de-duplicated page and accumulates
227
+ * whatever it needs; returning `false` stops pagination early (e.g. crossing
228
+ * a prefix boundary).
229
+ */
230
+ async function paginateListAssets({ batchSize = 100, maxPages = 100, startSymbol = '' }: Record<string, any> = {}, onPage: (pageItems: any[], batch: any[]) => boolean | void) {
222
231
  let lowerBound = startSymbol;
223
- let previousLastSymbol = null;
232
+ let previousLastSymbol: string | null = null;
224
233
 
225
234
  for (let page = 0; page < maxPages; page += 1) {
226
235
  const batch = await listAssets(lowerBound, batchSize);
@@ -237,17 +246,24 @@ async function loadHonestAssets({ prefix = DEFAULT_PREFIX, batchSize = 100, maxP
237
246
  break;
238
247
  }
239
248
 
240
- const matching = pageItems.filter((asset) => isHonestAsset(asset) && asset.symbol.startsWith(prefix));
241
- all.push(...matching);
249
+ const keepGoing = await onPage(pageItems, batch);
242
250
 
243
251
  previousLastSymbol = pageItems[pageItems.length - 1].symbol;
244
252
  lowerBound = previousLastSymbol;
245
253
 
246
- if (batch.length < batchSize) {
254
+ if (keepGoing === false || batch.length < batchSize) {
247
255
  break;
248
256
  }
249
257
  }
258
+ }
250
259
 
260
+ async function loadHonestAssets({ prefix = DEFAULT_PREFIX, batchSize = 100, maxPages = 100, startSymbol = DEFAULT_PREFIX }: Record<string, any> = {}) {
261
+ const all: any[] = [];
262
+
263
+ await paginateListAssets({ batchSize, maxPages, startSymbol }, (pageItems) => {
264
+ const matching = pageItems.filter((asset) => isHonestAsset(asset) && asset.symbol.startsWith(prefix));
265
+ all.push(...matching);
266
+ });
251
267
  const mpas = [];
252
268
  for (const asset of all) {
253
269
  if (!isMpa(asset)) {
@@ -357,5 +373,5 @@ function createHonestEcosystemAdapter(options: Record<string, any> = {}) {
357
373
  };
358
374
  }
359
375
 
360
- export { CORE_SYMBOL, DEFAULT_PREFIX, REFERENCE_SYMBOL, buildHonestEcosystemContext, createHonestEcosystemAdapter, getHardcodedHonestMoneyBridge, loadHonestAssets, isHardcodedHonestMoneyBtsPair, resolveHardcodedHonestMoneyPrice, resolveHonestPairContext, resolveHonestPairPrice }
376
+ export { buildHonestEcosystemContext, createHonestEcosystemAdapter, getHardcodedHonestMoneyBridge, getHonestMoneyBridge, isMpa, loadHonestAssets, paginateListAssets, resolveHardcodedHonestMoneyPrice, resolveHonestPairContext, resolveHonestPairPrice }
361
377
 
@@ -1,3 +1,4 @@
1
+ 'use strict';
1
2
  /**
2
3
  * Kibana Price Source
3
4
  *
@@ -16,7 +17,6 @@
16
17
  import { getMarketCandles, getMarketClosePrices } from '../../market_adapter/core/kibana_market_candles.js';
17
18
  import { getLpCandlesForPool, getLpClosePricesForPool, discoverPoolAssets } from '../../market_adapter/inputs/kibana_source.js';
18
19
  import { getAsset } from './chain_queries.js';
19
- 'use strict';
20
20
 
21
21
 
22
22
  /**
@@ -1,9 +1,9 @@
1
+ 'use strict';
1
2
 
2
3
  import { path } from '../../modules/path_api.js';
3
4
  import { getStorage } from '../../modules/storage/index.js';
4
5
  import { loadSettingsFile, resolveRawBotEntries } from '../../modules/bot_settings.js';
5
6
  import { normalizeProfileDir } from './launcher_paths.js';
6
- 'use strict';
7
7
 
8
8
  const storage = getStorage();
9
9
  const { ensureDir, readJSON, writeJSON } = storage;
@@ -1,9 +1,9 @@
1
+ 'use strict';
1
2
 
2
3
  import { path } from '../../modules/path_api.js';
3
4
  import { getStorage } from '../../modules/storage/index.js';
4
5
  import { BUILD_DIR } from '../../modules/constants.js';
5
6
  import { PATHS } from '../../modules/paths.js';
6
- 'use strict';
7
7
 
8
8
  const storage = getStorage();
9
9
 
@@ -1,7 +1,7 @@
1
1
 
2
2
 
3
3
  import * as client from './bitshares_client.js';
4
- import { getDexbot2Root, loadDexbotOrderSystemUtils, requireDexbot2Module } from './dexbot_bridge.js';
4
+ import { loadDexbotOrderSystemUtils, requireDexbot2Module } from './dexbot_bridge.js';
5
5
  function getDexbotSystem() {
6
6
  return loadDexbotOrderSystemUtils();
7
7
  }
@@ -13,9 +13,16 @@ function derivePoolPrice(assetA: any, assetB: any, poolRef?: string | null | Rec
13
13
  try {
14
14
  const { withPoolRef: wrapWithPoolRef } = requireDexbot2Module('modules/order/utils/withPoolRef') as any;
15
15
  const override = wrapWithPoolRef(client.BitShares, resolvedPoolRef);
16
- if (override) return override.derivePoolPrice(assetA, assetB);
16
+ // The caller pinned a specific pool: honoring the pin or failing is
17
+ // correct, silently deriving from a different auto-selected pool is not.
18
+ if (!override) {
19
+ console.warn(`[liquidity-pools] derivePoolPrice could not pin pool ${resolvedPoolRef}`);
20
+ return null;
21
+ }
22
+ return override.derivePoolPrice(assetA, assetB);
17
23
  } catch (e: any) {
18
24
  console.warn(`[liquidity-pools] derivePoolPrice with poolRef failed: ${e?.message || e}`);
25
+ return null;
19
26
  }
20
27
  }
21
28
  return system.derivePoolPrice(client.BitShares, assetA, assetB);
@@ -47,5 +54,5 @@ function createDexbotPoolHelper() {
47
54
  };
48
55
  }
49
56
 
50
- export { derivePoolPrice, derivePrice, createDexbotPoolHelper, getDexbot2Root, requireDexbot2Module }
57
+ export { derivePoolPrice, derivePrice, createDexbotPoolHelper }
51
58