dexbot 1.4.13 → 1.4.15

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 (330) hide show
  1. package/README.md +77 -68
  2. package/claw/data/positions.json +3391 -1
  3. package/claw/docs/AI_BOT_LIBRARY_API.md +1 -1
  4. package/claw/docs/POSITION_HEALTH.md +2 -2
  5. package/claw/modules/claw_catalog.ts +1 -3
  6. package/claw/modules/claw_launcher.ts +2 -3
  7. package/claw/modules/claw_skill_md.ts +1 -1
  8. package/claw/modules/decision_loop.ts +1 -1
  9. package/claw/modules/dexbot_profiles.ts +2 -33
  10. package/claw/modules/feed_price_source.ts +3 -32
  11. package/claw/modules/launcher_mode_detector.ts +1 -1
  12. package/claw/modules/mcp_utils.ts +1 -1
  13. package/claw/modules/mpa_utils.ts +36 -1
  14. package/claw/modules/position_discovery.ts +1 -28
  15. package/claw/modules/position_health.ts +1 -20
  16. package/claw/modules/position_manager.ts +3 -28
  17. package/claw/modules/skill_utils.ts +1 -1
  18. package/claw/modules/types.ts +0 -53
  19. package/claw/package.json +1 -1
  20. package/claw/runtimes/openclaw-plugin/openclaw.plugin.json +1 -1
  21. package/claw/runtimes/openclaw-plugin/package.json +1 -1
  22. package/claw/skills/margin-trading/references/honest-assets.md +1 -1
  23. package/claw/skills/margin-trading/references/position-management.md +2 -2
  24. package/claw/skills/shared/references/js-automation-overview.md +2 -2
  25. package/claw/skills/trend-detection/references/service.md +24 -17
  26. package/claw/tests/test_claw_bridge.ts +47 -47
  27. package/claw/tests/test_claw_catalog_and_credentials.ts +9 -9
  28. package/claw/tests/test_claw_chain_layer.ts +54 -54
  29. package/claw/tests/test_claw_data_flow.ts +41 -41
  30. package/claw/tests/test_claw_domain_logic.ts +26 -26
  31. package/claw/tests/test_claw_manifest_and_matrix.ts +1 -1
  32. package/claw/tests/test_claw_mcp_transport.ts +16 -16
  33. package/claw/tests/test_claw_regressions.ts +43 -43
  34. package/claw/tests/test_claw_skill_generation.ts +1 -1
  35. package/claw/tests/test_claw_state_store.ts +2 -2
  36. package/claw/tests/test_dexbot_profiles.ts +4 -4
  37. package/claw/tests/test_memu_bridge.ts +3 -3
  38. package/claw/tests/test_nullclaw_tmp_integration.ts +1 -1
  39. package/claw/tests/test_position_health.ts +2 -2
  40. package/claw/tests/test_position_manager.ts +18 -18
  41. package/claw/tests/test_position_manager_watch_health.ts +2 -2
  42. package/claw/tests/test_short_mpa_strategy.ts +12 -12
  43. package/dist/analysis/chart_utils.d.ts +13 -1
  44. package/dist/analysis/chart_utils.d.ts.map +1 -1
  45. package/dist/analysis/chart_utils.js +16 -1
  46. package/dist/analysis/chart_utils.js.map +1 -1
  47. package/dist/analysis/math_utils.d.ts +8 -12
  48. package/dist/analysis/math_utils.d.ts.map +1 -1
  49. package/dist/analysis/math_utils.js +9 -75
  50. package/dist/analysis/math_utils.js.map +1 -1
  51. package/dist/analysis/tradingview/tradingview_uplot_chart_generator.js +4 -4
  52. package/dist/dexbot.d.ts.map +1 -1
  53. package/dist/dexbot.js +54 -35
  54. package/dist/dexbot.js.map +1 -1
  55. package/dist/market_adapter/candle_utils.d.ts +18 -1
  56. package/dist/market_adapter/candle_utils.d.ts.map +1 -1
  57. package/dist/market_adapter/candle_utils.js +50 -1
  58. package/dist/market_adapter/candle_utils.js.map +1 -1
  59. package/dist/market_adapter/core/config_normalizers.js +1 -1
  60. package/dist/market_adapter/core/config_normalizers.js.map +1 -1
  61. package/dist/market_adapter/core/kibana_client.d.ts +2 -2
  62. package/dist/market_adapter/core/kibana_client.js +2 -2
  63. package/dist/market_adapter/core/kibana_market_candles.d.ts +1 -87
  64. package/dist/market_adapter/core/kibana_market_candles.d.ts.map +1 -1
  65. package/dist/market_adapter/core/kibana_market_candles.js +1 -80
  66. package/dist/market_adapter/core/kibana_market_candles.js.map +1 -1
  67. package/dist/market_adapter/core/market_adapter_service.d.ts +0 -8
  68. package/dist/market_adapter/core/market_adapter_service.d.ts.map +1 -1
  69. package/dist/market_adapter/core/market_adapter_service.js +28 -115
  70. package/dist/market_adapter/core/market_adapter_service.js.map +1 -1
  71. package/dist/market_adapter/core/signals/hurst_analyzer.d.ts.map +1 -0
  72. package/dist/{analysis/trend_detection → market_adapter/core/signals}/hurst_analyzer.js +2 -2
  73. package/dist/market_adapter/core/signals/hurst_analyzer.js.map +1 -0
  74. package/dist/{analysis/trend_detection → market_adapter/core/signals}/kalman_trend_analyzer.d.ts +0 -1
  75. package/dist/market_adapter/core/signals/kalman_trend_analyzer.d.ts.map +1 -0
  76. package/dist/{analysis/trend_detection → market_adapter/core/signals}/kalman_trend_analyzer.js +2 -4
  77. package/dist/market_adapter/core/signals/kalman_trend_analyzer.js.map +1 -0
  78. package/dist/{analysis/trend_detection → market_adapter/core/signals}/kalman_velocity_smoothing.d.ts +25 -4
  79. package/dist/market_adapter/core/signals/kalman_velocity_smoothing.d.ts.map +1 -0
  80. package/dist/{analysis/trend_detection → market_adapter/core/signals}/kalman_velocity_smoothing.js +41 -19
  81. package/dist/market_adapter/core/signals/kalman_velocity_smoothing.js.map +1 -0
  82. package/dist/market_adapter/core/signals/permutation_entropy_analyzer.d.ts.map +1 -0
  83. package/dist/{analysis/trend_detection → market_adapter/core/signals}/permutation_entropy_analyzer.js +2 -2
  84. package/dist/market_adapter/core/signals/permutation_entropy_analyzer.js.map +1 -0
  85. package/dist/market_adapter/core/strategies/ama.d.ts +1 -19
  86. package/dist/market_adapter/core/strategies/ama.d.ts.map +1 -1
  87. package/dist/market_adapter/core/strategies/ama.js +1 -1
  88. package/dist/market_adapter/core/strategies/ama.js.map +1 -1
  89. package/dist/market_adapter/core/strategies/ama_slope_model.d.ts +2 -13
  90. package/dist/market_adapter/core/strategies/ama_slope_model.d.ts.map +1 -1
  91. package/dist/market_adapter/core/strategies/ama_slope_model.js +15 -26
  92. package/dist/market_adapter/core/strategies/ama_slope_model.js.map +1 -1
  93. package/dist/market_adapter/core/strategies/atr/calculator.d.ts +38 -3
  94. package/dist/market_adapter/core/strategies/atr/calculator.d.ts.map +1 -1
  95. package/dist/market_adapter/core/strategies/atr/calculator.js +84 -24
  96. package/dist/market_adapter/core/strategies/atr/calculator.js.map +1 -1
  97. package/dist/market_adapter/core/strategies/collateral_manager.d.ts +1 -1
  98. package/dist/market_adapter/core/strategies/collateral_manager.js +1 -1
  99. package/dist/market_adapter/core/strategies/dynamic_weight_series.d.ts +32 -0
  100. package/dist/market_adapter/core/strategies/dynamic_weight_series.d.ts.map +1 -0
  101. package/dist/market_adapter/core/strategies/dynamic_weight_series.js +136 -0
  102. package/dist/market_adapter/core/strategies/dynamic_weight_series.js.map +1 -0
  103. package/dist/market_adapter/core/strategies/regime_gate.d.ts +6 -21
  104. package/dist/market_adapter/core/strategies/regime_gate.d.ts.map +1 -1
  105. package/dist/market_adapter/core/strategies/regime_gate.js +11 -74
  106. package/dist/market_adapter/core/strategies/regime_gate.js.map +1 -1
  107. package/dist/market_adapter/core/strategies/regime_interp.d.ts +13 -0
  108. package/dist/market_adapter/core/strategies/regime_interp.d.ts.map +1 -0
  109. package/dist/market_adapter/core/strategies/regime_interp.js +74 -0
  110. package/dist/market_adapter/core/strategies/regime_interp.js.map +1 -0
  111. package/dist/market_adapter/core/strategies/volatility_shift.d.ts +22 -0
  112. package/dist/market_adapter/core/strategies/volatility_shift.d.ts.map +1 -0
  113. package/dist/market_adapter/core/strategies/volatility_shift.js +37 -0
  114. package/dist/market_adapter/core/strategies/volatility_shift.js.map +1 -0
  115. package/dist/market_adapter/inputs/fetch_cex_synthetic_data.js +3 -4
  116. package/dist/market_adapter/inputs/fetch_cex_synthetic_data.js.map +1 -1
  117. package/dist/market_adapter/inputs/fetch_lp_data.d.ts +1 -10
  118. package/dist/market_adapter/inputs/fetch_lp_data.d.ts.map +1 -1
  119. package/dist/market_adapter/inputs/fetch_lp_data.js +1 -1
  120. package/dist/market_adapter/inputs/fetch_lp_data.js.map +1 -1
  121. package/dist/market_adapter/lp_chart_core.d.ts.map +1 -1
  122. package/dist/market_adapter/lp_chart_core.js +0 -10
  123. package/dist/market_adapter/lp_chart_core.js.map +1 -1
  124. package/dist/market_adapter/lp_chart_runner.d.ts +1 -16
  125. package/dist/market_adapter/lp_chart_runner.d.ts.map +1 -1
  126. package/dist/market_adapter/lp_chart_runner.js +1 -15
  127. package/dist/market_adapter/lp_chart_runner.js.map +1 -1
  128. package/dist/market_adapter/market_adapter.d.ts +3 -3
  129. package/dist/market_adapter/market_adapter.d.ts.map +1 -1
  130. package/dist/market_adapter/market_adapter.js +6 -8
  131. package/dist/market_adapter/market_adapter.js.map +1 -1
  132. package/dist/market_adapter/merge_lp_data.js +5 -5
  133. package/dist/market_adapter/utils/adapter_client.d.ts +1 -3
  134. package/dist/market_adapter/utils/adapter_client.d.ts.map +1 -1
  135. package/dist/market_adapter/utils/adapter_client.js +1 -14
  136. package/dist/market_adapter/utils/adapter_client.js.map +1 -1
  137. package/dist/market_adapter/utils/data_discovery.d.ts.map +1 -1
  138. package/dist/market_adapter/utils/data_discovery.js +1 -2
  139. package/dist/market_adapter/utils/data_discovery.js.map +1 -1
  140. package/dist/market_adapter/utils/dynamic_grid_snapshot.d.ts +1 -3
  141. package/dist/market_adapter/utils/dynamic_grid_snapshot.d.ts.map +1 -1
  142. package/dist/market_adapter/utils/dynamic_grid_snapshot.js +1 -1
  143. package/dist/market_adapter/utils/dynamic_grid_snapshot.js.map +1 -1
  144. package/dist/market_adapter/utils/file_lock.d.ts +10 -2
  145. package/dist/market_adapter/utils/file_lock.d.ts.map +1 -1
  146. package/dist/market_adapter/utils/file_lock.js +171 -102
  147. package/dist/market_adapter/utils/file_lock.js.map +1 -1
  148. package/dist/market_adapter/utils/native_history.d.ts +1 -9
  149. package/dist/market_adapter/utils/native_history.d.ts.map +1 -1
  150. package/dist/market_adapter/utils/native_history.js +1 -21
  151. package/dist/market_adapter/utils/native_history.js.map +1 -1
  152. package/dist/modules/account_bots.d.ts +16 -38
  153. package/dist/modules/account_bots.d.ts.map +1 -1
  154. package/dist/modules/account_bots.js +16 -38
  155. package/dist/modules/account_bots.js.map +1 -1
  156. package/dist/modules/account_orders.d.ts +11 -11
  157. package/dist/modules/account_orders.d.ts.map +1 -1
  158. package/dist/modules/account_orders.js +11 -18
  159. package/dist/modules/account_orders.js.map +1 -1
  160. package/dist/modules/bitshares_client.d.ts +5 -8
  161. package/dist/modules/bitshares_client.d.ts.map +1 -1
  162. package/dist/modules/bitshares_client.js +6 -10
  163. package/dist/modules/bitshares_client.js.map +1 -1
  164. package/dist/modules/bots_file_lock.d.ts +8 -5
  165. package/dist/modules/bots_file_lock.d.ts.map +1 -1
  166. package/dist/modules/bots_file_lock.js +8 -5
  167. package/dist/modules/bots_file_lock.js.map +1 -1
  168. package/dist/modules/chain_keys.d.ts +31 -22
  169. package/dist/modules/chain_keys.d.ts.map +1 -1
  170. package/dist/modules/chain_keys.js +31 -22
  171. package/dist/modules/chain_keys.js.map +1 -1
  172. package/dist/modules/chain_orders.d.ts +52 -48
  173. package/dist/modules/chain_orders.d.ts.map +1 -1
  174. package/dist/modules/chain_orders.js +124 -49
  175. package/dist/modules/chain_orders.js.map +1 -1
  176. package/dist/modules/config.d.ts +3 -0
  177. package/dist/modules/config.d.ts.map +1 -1
  178. package/dist/modules/config.js +3 -0
  179. package/dist/modules/config.js.map +1 -1
  180. package/dist/modules/constants.d.ts +17 -13
  181. package/dist/modules/constants.d.ts.map +1 -1
  182. package/dist/modules/constants.js +42 -21
  183. package/dist/modules/constants.js.map +1 -1
  184. package/dist/modules/cr_planner.d.ts +2 -1
  185. package/dist/modules/cr_planner.d.ts.map +1 -1
  186. package/dist/modules/cr_planner.js +1 -1
  187. package/dist/modules/cr_planner.js.map +1 -1
  188. package/dist/modules/credential_policy.d.ts +6 -4
  189. package/dist/modules/credential_policy.d.ts.map +1 -1
  190. package/dist/modules/credential_policy.js +6 -4
  191. package/dist/modules/credential_policy.js.map +1 -1
  192. package/dist/modules/credit_runtime.d.ts.map +1 -1
  193. package/dist/modules/credit_runtime.js +4 -8
  194. package/dist/modules/credit_runtime.js.map +1 -1
  195. package/dist/modules/dexbot_class.d.ts +33 -88
  196. package/dist/modules/dexbot_class.d.ts.map +1 -1
  197. package/dist/modules/dexbot_class.js +36 -68
  198. package/dist/modules/dexbot_class.js.map +1 -1
  199. package/dist/modules/dexbot_cow_runtime.d.ts +7 -7
  200. package/dist/modules/dexbot_cow_runtime.d.ts.map +1 -1
  201. package/dist/modules/dexbot_cow_runtime.js +7 -7
  202. package/dist/modules/dexbot_cow_runtime.js.map +1 -1
  203. package/dist/modules/dexbot_credential_client.d.ts +3 -3
  204. package/dist/modules/dexbot_credential_client.js +3 -3
  205. package/dist/modules/dexbot_credential_client.js.map +1 -1
  206. package/dist/modules/dexbot_fill_runtime.d.ts +1 -7
  207. package/dist/modules/dexbot_fill_runtime.d.ts.map +1 -1
  208. package/dist/modules/dexbot_fill_runtime.js +1 -9
  209. package/dist/modules/dexbot_fill_runtime.js.map +1 -1
  210. package/dist/modules/dexbot_maintenance_runtime.d.ts.map +1 -1
  211. package/dist/modules/dexbot_maintenance_runtime.js +3 -1
  212. package/dist/modules/dexbot_maintenance_runtime.js.map +1 -1
  213. package/dist/modules/dexbot_state_recovery.d.ts.map +1 -1
  214. package/dist/modules/dexbot_state_recovery.js +99 -1
  215. package/dist/modules/dexbot_state_recovery.js.map +1 -1
  216. package/dist/modules/graceful_shutdown.d.ts +4 -2
  217. package/dist/modules/graceful_shutdown.d.ts.map +1 -1
  218. package/dist/modules/graceful_shutdown.js +4 -2
  219. package/dist/modules/graceful_shutdown.js.map +1 -1
  220. package/dist/modules/launcher/bot_supervisor.d.ts +1 -1
  221. package/dist/modules/launcher/bot_supervisor.d.ts.map +1 -1
  222. package/dist/modules/launcher/bot_supervisor.js +1 -4
  223. package/dist/modules/launcher/bot_supervisor.js.map +1 -1
  224. package/dist/modules/launcher/child_env.d.ts.map +1 -1
  225. package/dist/modules/launcher/child_env.js +3 -0
  226. package/dist/modules/launcher/child_env.js.map +1 -1
  227. package/dist/modules/market_adapter_whitelist.d.ts +1 -2
  228. package/dist/modules/market_adapter_whitelist.d.ts.map +1 -1
  229. package/dist/modules/market_adapter_whitelist.js +1 -4
  230. package/dist/modules/market_adapter_whitelist.js.map +1 -1
  231. package/dist/modules/node_health_cache.d.ts +12 -4
  232. package/dist/modules/node_health_cache.d.ts.map +1 -1
  233. package/dist/modules/node_health_cache.js +13 -13
  234. package/dist/modules/node_health_cache.js.map +1 -1
  235. package/dist/modules/node_manager.d.ts.map +1 -1
  236. package/dist/modules/node_manager.js +3 -6
  237. package/dist/modules/node_manager.js.map +1 -1
  238. package/dist/modules/order/accounting.d.ts +2 -37
  239. package/dist/modules/order/accounting.d.ts.map +1 -1
  240. package/dist/modules/order/accounting.js +2 -64
  241. package/dist/modules/order/accounting.js.map +1 -1
  242. package/dist/modules/order/export.d.ts +1 -37
  243. package/dist/modules/order/export.d.ts.map +1 -1
  244. package/dist/modules/order/export.js +1 -1
  245. package/dist/modules/order/export.js.map +1 -1
  246. package/dist/modules/order/format.d.ts +28 -14
  247. package/dist/modules/order/format.d.ts.map +1 -1
  248. package/dist/modules/order/format.js +73 -18
  249. package/dist/modules/order/format.js.map +1 -1
  250. package/dist/modules/order/grid.d.ts +11 -5
  251. package/dist/modules/order/grid.d.ts.map +1 -1
  252. package/dist/modules/order/grid.js +79 -37
  253. package/dist/modules/order/grid.js.map +1 -1
  254. package/dist/modules/order/grid_reconcile_internal.js +2 -2
  255. package/dist/modules/order/grid_reconcile_internal.js.map +1 -1
  256. package/dist/modules/order/logger_state.d.ts +3 -45
  257. package/dist/modules/order/logger_state.d.ts.map +1 -1
  258. package/dist/modules/order/logger_state.js +3 -55
  259. package/dist/modules/order/logger_state.js.map +1 -1
  260. package/dist/modules/order/manager.d.ts +0 -4
  261. package/dist/modules/order/manager.d.ts.map +1 -1
  262. package/dist/modules/order/manager.js +3 -9
  263. package/dist/modules/order/manager.js.map +1 -1
  264. package/dist/modules/order/sync_engine.d.ts +0 -2
  265. package/dist/modules/order/sync_engine.d.ts.map +1 -1
  266. package/dist/modules/order/sync_engine.js +1 -4
  267. package/dist/modules/order/sync_engine.js.map +1 -1
  268. package/dist/modules/order/utils/math.d.ts +2 -11
  269. package/dist/modules/order/utils/math.d.ts.map +1 -1
  270. package/dist/modules/order/utils/math.js +3 -14
  271. package/dist/modules/order/utils/math.js.map +1 -1
  272. package/dist/modules/order/utils/order.d.ts +1 -17
  273. package/dist/modules/order/utils/order.d.ts.map +1 -1
  274. package/dist/modules/order/utils/order.js +3 -21
  275. package/dist/modules/order/utils/order.js.map +1 -1
  276. package/dist/modules/order/utils/system.d.ts +1 -11
  277. package/dist/modules/order/utils/system.d.ts.map +1 -1
  278. package/dist/modules/order/utils/system.js +3 -3
  279. package/dist/modules/order/utils/system.js.map +1 -1
  280. package/dist/modules/order/utils/validate.d.ts +1 -26
  281. package/dist/modules/order/utils/validate.d.ts.map +1 -1
  282. package/dist/modules/order/utils/validate.js +1 -1
  283. package/dist/modules/order/utils/validate.js.map +1 -1
  284. package/dist/modules/order/working_grid.d.ts +3 -9
  285. package/dist/modules/order/working_grid.d.ts.map +1 -1
  286. package/dist/modules/order/working_grid.js +3 -11
  287. package/dist/modules/order/working_grid.js.map +1 -1
  288. package/dist/modules/paths.d.ts +43 -2
  289. package/dist/modules/paths.d.ts.map +1 -1
  290. package/dist/modules/paths.js +81 -21
  291. package/dist/modules/paths.js.map +1 -1
  292. package/dist/modules/runtime_settings.js +1 -1
  293. package/dist/modules/runtime_settings.js.map +1 -1
  294. package/dist/pm2.d.ts +1 -1
  295. package/dist/pm2.d.ts.map +1 -1
  296. package/dist/pm2.js +1 -4
  297. package/dist/pm2.js.map +1 -1
  298. package/dist/scripts/analyze-orders.d.ts.map +1 -1
  299. package/dist/scripts/analyze-orders.js +36 -45
  300. package/dist/scripts/analyze-orders.js.map +1 -1
  301. package/dist/scripts/sync-version.js +22 -0
  302. package/dist/scripts/sync-version.js.map +1 -1
  303. package/ecosystem.config.cjs +32 -0
  304. package/package.json +4 -1
  305. package/scripts/README.md +24 -8
  306. package/scripts/clear-all.sh +39 -12
  307. package/scripts/clear-logs.sh +1 -1
  308. package/scripts/clear-market-adapter.sh +3 -3
  309. package/scripts/clear-orders.sh +1 -1
  310. package/scripts/create-bot-symlinks.sh +4 -2
  311. package/scripts/lib/dexbot-paths.sh +63 -0
  312. package/scripts/reset-settings.sh +1 -1
  313. package/dist/analysis/trend_detection/hurst_analyzer.d.ts.map +0 -1
  314. package/dist/analysis/trend_detection/hurst_analyzer.js.map +0 -1
  315. package/dist/analysis/trend_detection/kalman_trend_analyzer.d.ts.map +0 -1
  316. package/dist/analysis/trend_detection/kalman_trend_analyzer.js.map +0 -1
  317. package/dist/analysis/trend_detection/kalman_velocity_smoothing.d.ts.map +0 -1
  318. package/dist/analysis/trend_detection/kalman_velocity_smoothing.js.map +0 -1
  319. package/dist/analysis/trend_detection/permutation_entropy_analyzer.d.ts.map +0 -1
  320. package/dist/analysis/trend_detection/permutation_entropy_analyzer.js.map +0 -1
  321. package/dist/market_adapter/index.d.ts +0 -32
  322. package/dist/market_adapter/index.d.ts.map +0 -1
  323. package/dist/market_adapter/index.js +0 -39
  324. package/dist/market_adapter/index.js.map +0 -1
  325. package/dist/scripts/fix-err-message.d.ts +0 -3
  326. package/dist/scripts/fix-err-message.d.ts.map +0 -1
  327. package/dist/scripts/fix-err-message.js +0 -193
  328. package/dist/scripts/fix-err-message.js.map +0 -1
  329. /package/dist/{analysis/trend_detection → market_adapter/core/signals}/hurst_analyzer.d.ts +0 -0
  330. /package/dist/{analysis/trend_detection → market_adapter/core/signals}/permutation_entropy_analyzer.d.ts +0 -0
@@ -3,7 +3,7 @@ const Module = require('module');
3
3
  const path = require('path');
4
4
  const { setCachedModule, restoreCachedModule } = require('../../tests/helpers/module_cache_stub');
5
5
 
6
- function clearModule(modulePath) {
6
+ function clearModule(modulePath: string) {
7
7
  delete require.cache[modulePath];
8
8
  }
9
9
 
@@ -28,11 +28,11 @@ async function testClawBitsharesClientWaitForConnectedTriggersNativeConnect() {
28
28
  const clawBitsharesPath = require.resolve('../modules/bitshares_client');
29
29
  const nativePath = require.resolve('../../modules/bitshares-native');
30
30
  let connectCalls = 0;
31
- let nodes = [];
31
+ let nodes: any[] = [];
32
32
  let connected = false;
33
33
 
34
34
  const originalNativeEntry = setCachedModule(nativePath, {
35
- createChainClient: ({ onStatusChange }) => ({
35
+ createChainClient: ({ onStatusChange }: any) => ({
36
36
  connect: async () => {
37
37
  connectCalls += 1;
38
38
  connected = true;
@@ -43,7 +43,7 @@ async function testClawBitsharesClientWaitForConnectedTriggersNativeConnect() {
43
43
  if (typeof onStatusChange === 'function') onStatusChange('closed');
44
44
  },
45
45
  getStatus: () => connected ? 'connected' : 'closed',
46
- setNodes: (nextNodes) => { nodes = Array.isArray(nextNodes) ? nextNodes.slice() : []; },
46
+ setNodes: (nextNodes: any[]) => { nodes = Array.isArray(nextNodes) ? nextNodes.slice() : []; },
47
47
  getNodes: () => nodes.slice(),
48
48
  getCoreAsset: () => '1.3.0',
49
49
  db: {},
@@ -86,22 +86,22 @@ function testClawRootExportsAvoidSilentCollisions() {
86
86
  assert.strictEqual(hermesManifest.compatibility.name, 'Hermes');
87
87
  assert.strictEqual(openclawManifest.options.runtimeName, 'openclaw');
88
88
  assert.strictEqual(openclawManifest.compatibility.name, 'OpenClaw');
89
- assert.strictEqual(openclawManifest.commandExamples.some((example) => example.includes('scripts/claw_bridge.ts')), true);
89
+ assert.strictEqual(openclawManifest.commandExamples.some((example: any) => example.includes('scripts/claw_bridge.ts')), true);
90
90
  assert.strictEqual(openfangManifest.options.runtimeName, 'openfang');
91
- assert.strictEqual(openfangManifest.commandExamples.some((example) => example.includes('claw_bridge.ts')), true);
91
+ assert.strictEqual(openfangManifest.commandExamples.some((example: any) => example.includes('claw_bridge.ts')), true);
92
92
  assert.strictEqual(nullManifest.options.runtimeName, 'nullclaw');
93
- assert.strictEqual(nullManifest.commandExamples.some((example) => example.includes('claw_bridge.ts')), true);
93
+ assert.strictEqual(nullManifest.commandExamples.some((example: any) => example.includes('claw_bridge.ts')), true);
94
94
  assert.strictEqual(manifest.options.runtimeName, 'zeroclaw');
95
- assert.strictEqual(manifest.commandExamples.some((example) => example.includes('claw_bridge.ts')), true);
95
+ assert.strictEqual(manifest.commandExamples.some((example: any) => example.includes('claw_bridge.ts')), true);
96
96
  }
97
97
 
98
98
  function testClawCommandInjectsRuntimeNameViaOption() {
99
99
  const clawBridgePath = require.resolve('../modules/claw_bridge');
100
100
  const clawInfraPath = require.resolve('../modules/claw_infra');
101
101
 
102
- let capturedOptions = null;
102
+ let capturedOptions: any = null;
103
103
  const originalClawInfra = setCachedModule(clawInfraPath, {
104
- createClawInfrastructure: (opts) => {
104
+ createClawInfrastructure: (opts: any) => {
105
105
  capturedOptions = opts;
106
106
  return {
107
107
  runtime: { name: opts.runtime?.name || 'claw-bridge', accountName: null },
@@ -152,13 +152,13 @@ function testLiquidityPoolWrapperInjectsSharedBitSharesClient() {
152
152
  const originalDexbotBridge = setCachedModule(dexbotBridgePath, {
153
153
  getDexbot2Root: () => '/tmp',
154
154
  loadDexbotOrderSystemUtils: () => ({
155
- cloneMap: (value) => value,
156
- deepFreeze: (value) => value,
157
- derivePoolPrice: (...args) => {
155
+ cloneMap: (value: any) => value,
156
+ deepFreeze: (value: any) => value,
157
+ derivePoolPrice: (...args: any[]) => {
158
158
  capturedPoolArgs = args;
159
159
  return 'pool-price';
160
160
  },
161
- derivePrice: (...args) => {
161
+ derivePrice: (...args: any[]) => {
162
162
  capturedPriceArgs = args;
163
163
  return 'derived-price';
164
164
  },
@@ -195,12 +195,12 @@ async function testDecisionLoopReusesAnalyzerStateForDuplicateMarkets() {
195
195
  const discoveryPath = require.resolve('../modules/position_discovery');
196
196
  const healthPath = require.resolve('../modules/position_health');
197
197
  const feedPriceSourcePath = require.resolve('../modules/feed_price_source');
198
- const trendAnalyzerPath = require.resolve('../../analysis/trend_detection/kalman_trend_analyzer');
198
+ const trendAnalyzerPath = require.resolve('../../market_adapter/core/signals/kalman_trend_analyzer');
199
199
  let trendFetchCount = 0;
200
200
 
201
201
  class FakeTrendAnalyzer {
202
202
  [key: string]: any;
203
- update(marketPrice, feedPrice) {
203
+ update(marketPrice: number, feedPrice: number) {
204
204
  this.analysis = {
205
205
  confidence: 77,
206
206
  isReady: true,
@@ -232,7 +232,7 @@ async function testDecisionLoopReusesAnalyzerStateForDuplicateMarkets() {
232
232
  ])
233
233
  } as any);
234
234
  const originalHealth = setCachedModule(healthPath, {
235
- assessPosition: (position, trendSignal) => ({
235
+ assessPosition: (position: any, trendSignal: any) => ({
236
236
  actions: [],
237
237
  positionId: position.id,
238
238
  trend: trendSignal
@@ -273,17 +273,17 @@ async function testDecisionLoopReplacesAnalyzerOnConfigChange() {
273
273
  const discoveryPath = require.resolve('../modules/position_discovery');
274
274
  const healthPath = require.resolve('../modules/position_health');
275
275
  const feedPriceSourcePath = require.resolve('../modules/feed_price_source');
276
- const trendAnalyzerPath = require.resolve('../../analysis/trend_detection/kalman_trend_analyzer');
276
+ const trendAnalyzerPath = require.resolve('../../market_adapter/core/signals/kalman_trend_analyzer');
277
277
  let constructionCount = 0;
278
278
 
279
279
  class ConfigTrackingAnalyzer {
280
280
  [key: string]: any;
281
- constructor(config) {
281
+ constructor(config: any) {
282
282
  constructionCount += 1;
283
283
  this.config = config;
284
284
  }
285
285
 
286
- update(marketPrice, feedPrice) {
286
+ update(marketPrice: number, feedPrice: number) {
287
287
  return { confidence: 50, isReady: true, trend: 'NEUTRAL' };
288
288
  }
289
289
 
@@ -298,7 +298,7 @@ async function testDecisionLoopReplacesAnalyzerOnConfigChange() {
298
298
  ])
299
299
  } as any);
300
300
  const originalHealth = setCachedModule(healthPath, {
301
- assessPosition: (position, trendSignal) => ({ actions: [], positionId: position.id, trend: trendSignal })
301
+ assessPosition: (position: any, trendSignal: any) => ({ actions: [], positionId: position.id, trend: trendSignal })
302
302
  } as any);
303
303
  const originalFeedPriceSource = setCachedModule(feedPriceSourcePath, {
304
304
  fetchTrendInput: async () => ({ feedPrice: 100, marketPrice: 95, premium: -5 })
@@ -330,7 +330,7 @@ async function testPositionManagerEntryExposesSellPriceInBts() {
330
330
  const mpaUtilsPath = require.resolve('../modules/mpa_utils');
331
331
 
332
332
  const originalMpaUtils = setCachedModule(mpaUtilsPath, {
333
- requireBtsBackedMpa: async (sym) => ({
333
+ requireBtsBackedMpa: async (sym: string) => ({
334
334
  backingAsset: { id: '1.3.0', symbol: 'BTS', precision: 5 },
335
335
  mpaAsset: { id: `1.3.${sym.length}`, symbol: sym, precision: 5, bitasset_data_id: '2.4.1' }
336
336
  })
@@ -342,7 +342,7 @@ async function testPositionManagerEntryExposesSellPriceInBts() {
342
342
  const savedState: any = {};
343
343
  const pm = new PositionManager({
344
344
  loadState: async () => savedState.data || { positions: [] },
345
- saveState: async (state) => { savedState.data = state; }
345
+ saveState: async (state: any) => { savedState.data = state; }
346
346
  });
347
347
 
348
348
  const position = await pm.createShortPosition({
@@ -364,9 +364,9 @@ function testClawBridgeRespectsRuntimeNameOption() {
364
364
  const clawBridgePath = require.resolve('../modules/claw_bridge');
365
365
  const clawInfraPath = require.resolve('../modules/claw_infra');
366
366
 
367
- let capturedOptions = null;
367
+ let capturedOptions: any = null;
368
368
  const originalClawInfra = setCachedModule(clawInfraPath, {
369
- createClawInfrastructure: (opts) => {
369
+ createClawInfrastructure: (opts: any) => {
370
370
  capturedOptions = opts;
371
371
  return {
372
372
  runtime: { name: opts.runtime?.name || 'claw-bridge' },
@@ -400,43 +400,43 @@ function testClawBridgeScriptManifestUsesRuntimeSpecificDescriptors() {
400
400
 
401
401
  const hermesManifest = describeRuntimeManifest('hermes', {});
402
402
  assert.strictEqual(hermesManifest.compatibility.name, 'Hermes');
403
- assert.strictEqual(hermesManifest.commandExamples.some((example) => example.includes('scripts/claw_bridge.ts')), true);
403
+ assert.strictEqual(hermesManifest.commandExamples.some((example: any) => example.includes('scripts/claw_bridge.ts')), true);
404
404
 
405
405
  const openclawManifest = describeRuntimeManifest('openclaw', {});
406
406
  assert.strictEqual(openclawManifest.compatibility.name, 'OpenClaw');
407
- assert.strictEqual(openclawManifest.commandExamples.some((example) => example.includes('scripts/claw_bridge.ts')), true);
407
+ assert.strictEqual(openclawManifest.commandExamples.some((example: any) => example.includes('scripts/claw_bridge.ts')), true);
408
408
 
409
409
  const openfangManifest = describeRuntimeManifest('openfang', {});
410
410
  assert.strictEqual(openfangManifest.compatibility.name, 'OpenFang');
411
- assert.strictEqual(openfangManifest.commandExamples.some((example) => example.includes('claw_bridge.ts')), true);
411
+ assert.strictEqual(openfangManifest.commandExamples.some((example: any) => example.includes('claw_bridge.ts')), true);
412
412
 
413
413
  const nanoclawManifest = describeRuntimeManifest('nanoclaw', {});
414
414
  assert.strictEqual(nanoclawManifest.compatibility.name, 'NanoClaw');
415
- assert.strictEqual(nanoclawManifest.commandExamples.some((example) => example.includes('claw_bridge.ts')), true);
415
+ assert.strictEqual(nanoclawManifest.commandExamples.some((example: any) => example.includes('claw_bridge.ts')), true);
416
416
 
417
417
  const nullclawManifest = describeRuntimeManifest('nullclaw', {});
418
418
  assert.strictEqual(nullclawManifest.compatibility.name, 'NullClaw');
419
- assert.strictEqual(nullclawManifest.commandExamples.some((example) => example.includes('claw_bridge.ts')), true);
419
+ assert.strictEqual(nullclawManifest.commandExamples.some((example: any) => example.includes('claw_bridge.ts')), true);
420
420
 
421
421
  const zeroclawManifest = describeRuntimeManifest('zeroclaw', {});
422
422
  assert.strictEqual(zeroclawManifest.compatibility.name, 'ZeroClaw');
423
- assert.strictEqual(zeroclawManifest.commandExamples.some((example) => example.includes('claw_bridge.ts')), true);
423
+ assert.strictEqual(zeroclawManifest.commandExamples.some((example: any) => example.includes('claw_bridge.ts')), true);
424
424
 
425
425
  const genericManifest = describeRuntimeManifest(null, {});
426
426
  assert.strictEqual(genericManifest.compatibility.name, 'Claw');
427
- assert.strictEqual(genericManifest.commandExamples.some((example) => example.includes('scripts/claw_bridge.ts')), true);
427
+ assert.strictEqual(genericManifest.commandExamples.some((example: any) => example.includes('scripts/claw_bridge.ts')), true);
428
428
 
429
429
  const payloadSelectedManifest = describeRuntimeManifest(null, { runtimeName: 'openfang' });
430
430
  assert.strictEqual(payloadSelectedManifest.compatibility.name, 'OpenFang');
431
- assert.strictEqual(payloadSelectedManifest.commandExamples.some((example) => example.includes('claw_bridge.ts')), true);
431
+ assert.strictEqual(payloadSelectedManifest.commandExamples.some((example: any) => example.includes('claw_bridge.ts')), true);
432
432
 
433
433
  const normalizedPayloadManifest = describeRuntimeManifest(null, { runtimeName: ' OpenFang ' });
434
434
  assert.strictEqual(normalizedPayloadManifest.compatibility.name, 'OpenFang');
435
- assert.strictEqual(normalizedPayloadManifest.commandExamples.some((example) => example.includes('claw_bridge.ts')), true);
435
+ assert.strictEqual(normalizedPayloadManifest.commandExamples.some((example: any) => example.includes('claw_bridge.ts')), true);
436
436
 
437
437
  const hermesPayloadManifest = describeRuntimeManifest(null, { runtimeName: ' Hermes ' });
438
438
  assert.strictEqual(hermesPayloadManifest.compatibility.name, 'Hermes');
439
- assert.strictEqual(hermesPayloadManifest.commandExamples.some((example) => example.includes('scripts/claw_bridge.ts')), true);
439
+ assert.strictEqual(hermesPayloadManifest.commandExamples.some((example: any) => example.includes('scripts/claw_bridge.ts')), true);
440
440
 
441
441
  clearModule(scriptPath);
442
442
  }
@@ -451,19 +451,19 @@ async function testRuntimeCommandManifestUsesRuntimeSpecificDescriptors() {
451
451
 
452
452
  const openfangManifest = await runClawCommand('manifest', { runtimeName: 'openfang' });
453
453
  assert.strictEqual(openfangManifest.compatibility.name, 'OpenFang');
454
- assert.strictEqual(openfangManifest.commandExamples.some((example) => example.includes('claw_bridge.ts')), true);
454
+ assert.strictEqual(openfangManifest.commandExamples.some((example: any) => example.includes('claw_bridge.ts')), true);
455
455
 
456
456
  const nanoclawManifest = await runClawCommand('manifest', { runtimeName: 'nanoclaw' });
457
457
  assert.strictEqual(nanoclawManifest.compatibility.name, 'NanoClaw');
458
- assert.strictEqual(nanoclawManifest.commandExamples.some((example) => example.includes('claw_bridge.ts')), true);
458
+ assert.strictEqual(nanoclawManifest.commandExamples.some((example: any) => example.includes('claw_bridge.ts')), true);
459
459
 
460
460
  const nullclawManifest = await runClawCommand('manifest', { runtimeName: 'nullclaw' });
461
461
  assert.strictEqual(nullclawManifest.compatibility.name, 'NullClaw');
462
- assert.strictEqual(nullclawManifest.commandExamples.some((example) => example.includes('claw_bridge.ts')), true);
462
+ assert.strictEqual(nullclawManifest.commandExamples.some((example: any) => example.includes('claw_bridge.ts')), true);
463
463
 
464
464
  const zeroclawManifest = await runClawCommand('manifest', { runtimeName: 'zeroclaw' });
465
465
  assert.strictEqual(zeroclawManifest.compatibility.name, 'ZeroClaw');
466
- assert.strictEqual(zeroclawManifest.commandExamples.some((example) => example.includes('claw_bridge.ts')), true);
466
+ assert.strictEqual(zeroclawManifest.commandExamples.some((example: any) => example.includes('claw_bridge.ts')), true);
467
467
  }
468
468
 
469
469
  function testAccountOrdersBotKeyFallsBackToAssetIds() {
@@ -508,11 +508,11 @@ function testBuildQueryScopesAnyPoolByReceivedAsset() {
508
508
  });
509
509
  const poolFilters = poolScoped.query.bool.filter;
510
510
  assert.ok(
511
- poolFilters.some((f) => f.term?.['operation_history.op_object.pool.keyword'] === '1.19.133'),
511
+ poolFilters.some((f: any) => f.term?.['operation_history.op_object.pool.keyword'] === '1.19.133'),
512
512
  'pool-scoped query should filter by pool'
513
513
  );
514
514
  assert.ok(
515
- !poolFilters.some((f) => f.term?.['operation_history.op_object.min_to_receive.asset_id.keyword']),
515
+ !poolFilters.some((f: any) => f.term?.['operation_history.op_object.min_to_receive.asset_id.keyword']),
516
516
  'pool-scoped query should not add receivedAssetId filter'
517
517
  );
518
518
 
@@ -528,11 +528,11 @@ function testBuildQueryScopesAnyPoolByReceivedAsset() {
528
528
  });
529
529
  const pairFilters = pairScoped.query.bool.filter;
530
530
  assert.ok(
531
- !pairFilters.some((f) => f.term?.['operation_history.op_object.pool.keyword']),
531
+ !pairFilters.some((f: any) => f.term?.['operation_history.op_object.pool.keyword']),
532
532
  'any-pool query should not have pool filter'
533
533
  );
534
534
  assert.ok(
535
- pairFilters.some((f) => f.term?.['operation_history.op_object.min_to_receive.asset_id.keyword'] === '1.3.1'),
535
+ pairFilters.some((f: any) => f.term?.['operation_history.op_object.min_to_receive.asset_id.keyword'] === '1.3.1'),
536
536
  'any-pool query should filter by received asset ID'
537
537
  );
538
538
  }
@@ -5,7 +5,7 @@ const fs = require('fs/promises');
5
5
  const os = require('os');
6
6
  const path = require('path');
7
7
 
8
- function countOccurrences(text, needle) {
8
+ function countOccurrences(text: string, needle: string) {
9
9
  return (text.match(new RegExp(needle.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'), 'g')) || []).length;
10
10
  }
11
11
 
@@ -15,14 +15,14 @@ async function testConcurrentUpdatesPreserveBothWrites() {
15
15
  const secondStore = createStateStore({ filePath, defaultValue: {} });
16
16
 
17
17
  await Promise.all([
18
- firstStore.update(async (state) => {
18
+ firstStore.update(async (state: any) => {
19
19
  await new Promise((resolve) => setTimeout(resolve, 60));
20
20
  return {
21
21
  ...(state || {}),
22
22
  alpha: 1
23
23
  };
24
24
  }),
25
- secondStore.update(async (state) => ({
25
+ secondStore.update(async (state: any) => ({
26
26
  ...(state || {}),
27
27
  beta: 1
28
28
  }))
@@ -15,11 +15,11 @@ const {
15
15
  } = require('../modules/dexbot_profiles');
16
16
 
17
17
  function createCaptureLogger() {
18
- const messages = [];
18
+ const messages: any[] = [];
19
19
  return {
20
20
  logger: {
21
- log: (msg) => messages.push(String(msg)),
22
- warn: (msg) => messages.push(String(msg))
21
+ log: (msg: any) => messages.push(String(msg)),
22
+ warn: (msg: any) => messages.push(String(msg))
23
23
  },
24
24
  messages
25
25
  };
@@ -459,7 +459,7 @@ async function testNestedPatchValidationDoesNotDuplicateErrors() {
459
459
  forceReload: true
460
460
  });
461
461
 
462
- const sellErrors = preview.errors.filter((entry) => entry === 'weightDistribution.sell must be a finite number');
462
+ const sellErrors = preview.errors.filter((entry: any) => entry === 'weightDistribution.sell must be a finite number');
463
463
  assert.strictEqual(sellErrors.length, 1, 'nested patch validation should not duplicate the same field error');
464
464
  }
465
465
 
@@ -8,7 +8,7 @@ const { spawnSync } = require('child_process');
8
8
  const { getStorage } = require('../../modules/storage');
9
9
  const { ensureDir } = getStorage();
10
10
 
11
- function writeFakeMemuPackage(tmpRoot) {
11
+ function writeFakeMemuPackage(tmpRoot: string) {
12
12
  const memuDir = path.join(tmpRoot, 'memu');
13
13
  ensureDir(memuDir);
14
14
  fs.writeFileSync(path.join(memuDir, '__init__.py'), `
@@ -94,7 +94,7 @@ class MemoryService:
94
94
  `);
95
95
  }
96
96
 
97
- function runMemuRunner(args) {
97
+ function runMemuRunner(args: any[]) {
98
98
  const tmpRoot = fs.mkdtempSync(path.join(os.tmpdir(), 'dexbot2-memu-test-'));
99
99
  const candidatePaths = [
100
100
  path.resolve(__dirname, '..', 'scripts', 'memu_runner.py'),
@@ -122,7 +122,7 @@ function runMemuRunner(args) {
122
122
  }
123
123
  }
124
124
 
125
- function parseRun(run, label) {
125
+ function parseRun(run: any, label: string) {
126
126
  assert.strictEqual(run.code, 0, `${label} failed:\nSTDERR:\n${run.stderr}\nSTDOUT:\n${run.stdout}`);
127
127
  return JSON.parse(run.stdout.trim());
128
128
  }
@@ -42,7 +42,7 @@ async function main() {
42
42
  assert.strictEqual(manifest.options.runtimeName, 'nullclaw');
43
43
  assert.strictEqual(manifest.options.profileRoot, dexbotRoot);
44
44
  assert.strictEqual(manifest.compatibility.recommendedTransport, 'skill-toml-or-mcp');
45
- assert.ok(manifest.commandExamples.some((example) => example.includes('claw_bridge.ts')));
45
+ assert.ok(manifest.commandExamples.some((example: any) => example.includes('claw_bridge.ts')));
46
46
  assert.ok(Array.isArray(manifest.tools.catalog));
47
47
  assert.strictEqual(runtime.name, 'nullclaw');
48
48
  assert.strictEqual(runtime.profileRoot, dexbotRoot);
@@ -85,7 +85,7 @@ function testTrendAlignment() {
85
85
 
86
86
  // --- assessPosition: two-layer actions ---
87
87
 
88
- function makePosition(cr, debtAmount = 100) {
88
+ function makePosition(cr: any, debtAmount: any = 100) {
89
89
  return {
90
90
  id: 'test_pos',
91
91
  status: 'debt_open',
@@ -160,7 +160,7 @@ function testAssessTrendOpposed() {
160
160
  const trend = { trend: 'UP', confidence: 70, premium: 1.5 };
161
161
  const result = assessPosition(makePosition(2.2), trend);
162
162
  assert.strictEqual(result.trend.alignment, 'opposed');
163
- const reviewAction = result.actions.find(a => a.action === 'review_direction');
163
+ const reviewAction = result.actions.find((a: any) => a.action === 'review_direction');
164
164
  assert.ok(reviewAction, 'should have review_direction action');
165
165
  assert.strictEqual(reviewAction.priority, 'evaluate');
166
166
 
@@ -5,11 +5,11 @@ const fs = require('fs/promises');
5
5
  const os = require('os');
6
6
  const path = require('path');
7
7
 
8
- function clearModule(modulePath) {
8
+ function clearModule(modulePath: string) {
9
9
  delete require.cache[modulePath];
10
10
  }
11
11
 
12
- function registerMock(modulePath, exports) {
12
+ function registerMock(modulePath: string, exports: any) {
13
13
  require.cache[modulePath] = {
14
14
  id: modulePath,
15
15
  filename: modulePath,
@@ -31,11 +31,11 @@ async function createHarness() {
31
31
  const statePath = path.join(tempDir, 'positions.json');
32
32
 
33
33
  const calls = {
34
- closeShortOnBts: [],
35
- listenForFills: [],
36
- openShortOnBts: [],
37
- placeTakeProfitBuyOrderOnBts: [],
38
- savedStates: []
34
+ closeShortOnBts: [] as any[],
35
+ listenForFills: [] as any[],
36
+ openShortOnBts: [] as any[],
37
+ placeTakeProfitBuyOrderOnBts: [] as any[],
38
+ savedStates: [] as any[]
39
39
  };
40
40
 
41
41
  const coreAsset = { id: '1.3.0', precision: 5, symbol: 'BTS' };
@@ -46,7 +46,7 @@ async function createHarness() {
46
46
  symbol: 'HONEST.USD'
47
47
  };
48
48
 
49
- let accountSnapshot = {
49
+ let accountSnapshot: any = {
50
50
  balances: [{ asset_type: '1.3.0', balance: 500000 }],
51
51
  call_orders: [],
52
52
  limit_orders: []
@@ -54,19 +54,19 @@ async function createHarness() {
54
54
 
55
55
  registerMock(bridgePath, {
56
56
  loadDexbotOrderUtils: () => ({
57
- blockchainToFloat: (amount, precision) => Number(amount) / (10 ** precision)
57
+ blockchainToFloat: (amount: number, precision: number) => Number(amount) / (10 ** precision)
58
58
  })
59
59
  });
60
60
 
61
61
  registerMock(profilesPath, {
62
- writeJsonFileAtomic: async (filePath, state) => {
62
+ writeJsonFileAtomic: async (filePath: string, state: any) => {
63
63
  calls.savedStates.push({ filePath, state: clone(state) });
64
64
  await fs.writeFile(filePath, JSON.stringify(state, null, 2));
65
65
  }
66
66
  });
67
67
 
68
68
  registerMock(shortStrategyPath, {
69
- closeShortOnBts: async (options) => {
69
+ closeShortOnBts: async (options: any) => {
70
70
  calls.closeShortOnBts.push(options);
71
71
  accountSnapshot = {
72
72
  ...accountSnapshot,
@@ -79,7 +79,7 @@ async function createHarness() {
79
79
  }
80
80
  };
81
81
  },
82
- openShortOnBts: async (options) => {
82
+ openShortOnBts: async (options: any) => {
83
83
  calls.openShortOnBts.push(options);
84
84
  accountSnapshot = {
85
85
  ...accountSnapshot,
@@ -106,7 +106,7 @@ async function createHarness() {
106
106
  }
107
107
  };
108
108
  },
109
- placeTakeProfitBuyOrderOnBts: async (options) => {
109
+ placeTakeProfitBuyOrderOnBts: async (options: any) => {
110
110
  calls.placeTakeProfitBuyOrderOnBts.push(options);
111
111
  accountSnapshot = {
112
112
  ...accountSnapshot,
@@ -131,7 +131,7 @@ async function createHarness() {
131
131
  });
132
132
 
133
133
  registerMock(actionsPath, {
134
- listenForFills: async (accountName, callback) => {
134
+ listenForFills: async (accountName: string, callback: any) => {
135
135
  calls.listenForFills.push({ accountName, callback });
136
136
  return async () => {
137
137
  calls.listenForFills.push({ accountName, type: 'unsubscribe' });
@@ -140,7 +140,7 @@ async function createHarness() {
140
140
  });
141
141
 
142
142
  registerMock(queriesPath, {
143
- getAsset: async (symbolOrId) => {
143
+ getAsset: async (symbolOrId: string) => {
144
144
  if (symbolOrId === 'BTS' || symbolOrId === coreAsset.id) {
145
145
  return coreAsset;
146
146
  }
@@ -177,7 +177,7 @@ async function createHarness() {
177
177
  clearModule(shortStrategyPath);
178
178
  },
179
179
  manager: new PositionManager({ statePath }),
180
- setAccountSnapshot(nextSnapshot) {
180
+ setAccountSnapshot(nextSnapshot: any) {
181
181
  accountSnapshot = clone(nextSnapshot);
182
182
  },
183
183
  statePath
@@ -224,7 +224,7 @@ async function testPositionManagerLifecycle() {
224
224
 
225
225
  const watchedPositionId = planned.id;
226
226
  const state = await manager.loadState();
227
- const watchedPosition = state.positions.find((entry) => entry.id === watchedPositionId);
227
+ const watchedPosition = state.positions.find((entry: any) => entry.id === watchedPositionId);
228
228
  watchedPosition.entry.orderId = '1.7.500';
229
229
  watchedPosition.entry.orderOpen = true;
230
230
  watchedPosition.status = 'entry_order_open';
@@ -251,7 +251,7 @@ async function testPositionManagerLifecycle() {
251
251
  const accountState = await manager.getPosition(watchedPositionId);
252
252
  assert.strictEqual(accountState.entry.orderId, '1.7.500');
253
253
 
254
- const unsubscribe = await manager.watchAccount('alice', async (position, fill) => {
254
+ const unsubscribe = await manager.watchAccount('alice', async (position: any, fill: any) => {
255
255
  calls.listenForFills.push({ accountName: 'alice', fill, type: 'onFill', positionId: position.id });
256
256
  });
257
257
 
@@ -11,12 +11,12 @@ const watcherModulePath = require.resolve('../modules/position_manager_watch');
11
11
  const positionManagerPath = require.resolve('../modules/position_manager');
12
12
  const bitsharesClientPath = require.resolve('../modules/bitshares_client');
13
13
 
14
- function loadWatcherModule(mockPositionManager, waitForConnected) {
14
+ function loadWatcherModule(mockPositionManager: any, waitForConnected: any) {
15
15
  delete require.cache[watcherModulePath];
16
16
  delete require.cache[positionManagerPath];
17
17
  delete require.cache[bitsharesClientPath];
18
18
 
19
- Module._load = function(request, parent, isMain) {
19
+ Module._load = function(request: any, parent: any, isMain: any) {
20
20
  if (['./position_manager', './position_manager.js'].includes(request) && parent?.filename === watcherModulePath) {
21
21
  return {
22
22
  DEFAULT_STATE_PATH: path.join(os.tmpdir(), 'unused-positions.json'),
@@ -2,11 +2,11 @@
2
2
 
3
3
  const assert = require('assert');
4
4
 
5
- function clearModule(modulePath) {
5
+ function clearModule(modulePath: string) {
6
6
  delete require.cache[modulePath];
7
7
  }
8
8
 
9
- function registerMock(modulePath, exports) {
9
+ function registerMock(modulePath: string, exports: any) {
10
10
  require.cache[modulePath] = {
11
11
  id: modulePath,
12
12
  filename: modulePath,
@@ -21,29 +21,29 @@ function createStrategyHarness() {
21
21
  const chainQueriesPath = require.resolve('../modules/chain_queries');
22
22
 
23
23
  const calls = {
24
- borrowMpa: [],
25
- createLimitOrder: [],
26
- getAsset: [],
27
- getBackingAsset: [],
28
- repayMpaDebt: []
24
+ borrowMpa: [] as any[],
25
+ createLimitOrder: [] as any[],
26
+ getAsset: [] as string[],
27
+ getBackingAsset: [] as string[],
28
+ repayMpaDebt: [] as any[]
29
29
  };
30
30
 
31
31
  registerMock(chainActionsPath, {
32
- borrowMpa: async (options) => {
32
+ borrowMpa: async (options: any) => {
33
33
  calls.borrowMpa.push(options);
34
34
  return {
35
35
  options,
36
36
  source: 'borrowMpa'
37
37
  };
38
38
  },
39
- createLimitOrder: async (options) => {
39
+ createLimitOrder: async (options: any) => {
40
40
  calls.createLimitOrder.push(options);
41
41
  return {
42
42
  options,
43
43
  source: 'createLimitOrder'
44
44
  };
45
45
  },
46
- repayMpaDebt: async (options) => {
46
+ repayMpaDebt: async (options: any) => {
47
47
  calls.repayMpaDebt.push(options);
48
48
  return {
49
49
  options,
@@ -53,7 +53,7 @@ function createStrategyHarness() {
53
53
  });
54
54
 
55
55
  registerMock(chainQueriesPath, {
56
- getAsset: async (symbolOrId) => {
56
+ getAsset: async (symbolOrId: string) => {
57
57
  calls.getAsset.push(symbolOrId);
58
58
  return {
59
59
  bitasset_data_id: '2.4.100',
@@ -62,7 +62,7 @@ function createStrategyHarness() {
62
62
  symbol: 'HONEST.USD'
63
63
  };
64
64
  },
65
- getBackingAsset: async (assetId) => {
65
+ getBackingAsset: async (assetId: string) => {
66
66
  calls.getBackingAsset.push(assetId);
67
67
  return {
68
68
  id: '1.3.0',
@@ -5,11 +5,23 @@ declare function escapeHtml(str: string): string;
5
5
  declare function serializeJsonForScript(value: any): string;
6
6
  declare function toEpochSeconds(ts: any, fallbackIdx: any): number;
7
7
  declare function writeChartFile(filePath: any, html: any): void;
8
+ /**
9
+ * Serialize the exact source of the given pure functions for injection into a
10
+ * generated HTML <script> block. Each function is emitted as a top-level
11
+ * function declaration (Function.prototype.toString()), so browser-embedded
12
+ * charts run the same logic as the Node-side modules instead of a hand-copied
13
+ * copy. Functions must be self-contained (no imports or module-level constants
14
+ * referenced from their bodies); callers pass all config values explicitly.
15
+ *
16
+ * The emitted block is wrapped in marker comments so test harnesses can extract
17
+ * the embedded sources reliably regardless of the function list or ordering.
18
+ */
19
+ declare function embedFunctionSources(fns: Array<Function>): string;
8
20
  /**
9
21
  * Shared uPlot interaction boilerplate for embedded browser scripts.
10
22
  * Consumers must define `xMin`, `xMax`, `charts`, `pendingRange`, and `pendingRangeRaf`
11
23
  * before embedding this script block.
12
24
  */
13
25
  declare const UPLOT_SHARED_SCRIPT = "\nfunction clampXRange(min, max) {\n let nextMin = min, nextMax = max;\n if (!Number.isFinite(nextMin) || !Number.isFinite(nextMax) || nextMax <= nextMin) {\n return { min: xMin, max: xMax };\n }\n if (nextMin < xMin) { nextMax += xMin - nextMin; nextMin = xMin; }\n if (nextMax > xMax) { nextMin -= nextMax - xMax; nextMax = xMax; }\n if (nextMin < xMin) nextMin = xMin;\n if (nextMax > xMax) nextMax = xMax;\n if (nextMax <= nextMin) return { min: xMin, max: xMax };\n return { min: nextMin, max: nextMax };\n}\n\nfunction syncXRange(min, max) {\n pendingRange = clampXRange(min, max);\n if (pendingRangeRaf) return;\n const raf = typeof requestAnimationFrame !== 'undefined' ? requestAnimationFrame.bind(window) : (fn) => setTimeout(fn, 0);\n pendingRangeRaf = raf(() => {\n const next = pendingRange;\n pendingRange = null;\n pendingRangeRaf = 0;\n if (!next) return;\n charts.forEach(c => c && c.batch(() => c.setScale('x', next)));\n });\n}\n\nfunction bindWheelZoom(chart) {\n chart.root.addEventListener('wheel', (e) => {\n if (e.ctrlKey || e.metaKey || e.altKey) return;\n e.preventDefault();\n e.stopPropagation();\n const rect = chart.root.getBoundingClientRect();\n \n // Correctly calculate plot-relative 'left' for accurate centering\n const left = e.clientX - rect.left - (chart.bbox.left / (chart.pxRatio || 1));\n const center = chart.posToVal(left, 'x');\n \n const s = chart.scales.x || {};\n const currMin = Number.isFinite(s.min) ? s.min : xMin;\n const currMax = Number.isFinite(s.max) ? s.max : xMax;\n const span = currMax - currMin;\n if (!Number.isFinite(span) || span <= 0) return;\n const factor = e.deltaY < 0 ? 0.85 : 1.15;\n const nextSpan = Math.max(1, Math.min(xMax - xMin, span * factor));\n const ratio = (center - currMin) / span;\n syncXRange(center - nextSpan * ratio, center - nextSpan * ratio + nextSpan);\n }, { passive: false });\n}\n\nfunction bindPan(chart) {\n let dragging = false, startClientX = 0, startClientY = 0, startMin = xMin, startMax = xMax, xUnitsPerPx = 0;\n const getScale = () => {\n const s = chart.scales.x || {};\n return { currMin: Number.isFinite(s.min) ? s.min : xMin, currMax: Number.isFinite(s.max) ? s.max : xMax };\n };\n const onMouseMove = (e) => {\n if (!dragging) return;\n \n // Ignore if vertical movement is dominant (likely scrolling)\n if (Math.abs(e.clientY - startClientY) > 20) return;\n \n e.preventDefault();\n const deltaPx = e.clientX - startClientX;\n const deltaVal = deltaPx * xUnitsPerPx;\n syncXRange(startMin - deltaVal, startMax - deltaVal);\n };\n const endDrag = () => {\n if (!dragging) return;\n dragging = false;\n document.body.style.cursor = '';\n window.removeEventListener('mousemove', onMouseMove);\n window.removeEventListener('mouseup', endDrag);\n };\n chart.root.addEventListener('mousedown', (e) => {\n if (!e || e.button !== 0 || e.ctrlKey || e.metaKey || e.altKey) return;\n const rect = chart.root.getBoundingClientRect();\n if (e.clientX < rect.left || e.clientX > rect.right || e.clientY < rect.top || e.clientY > rect.bottom) return;\n \n e.preventDefault();\n e.stopPropagation();\n \n dragging = true;\n startClientX = e.clientX;\n startClientY = e.clientY;\n const cur = getScale();\n startMin = cur.currMin; startMax = cur.currMax;\n \n // Calculate units per pixel once at start of drag to avoid sliding bug\n // chart.bbox.width is in device pixels; divide by pxRatio for CSS pixels\n xUnitsPerPx = (cur.currMax - cur.currMin) / (chart.bbox.width / (chart.pxRatio || 1));\n \n document.body.style.cursor = 'grabbing';\n window.addEventListener('mousemove', onMouseMove);\n window.addEventListener('mouseup', endDrag, { once: true });\n });\n}\n";
14
- export { escapeHtml, serializeJsonForScript, toEpochSeconds, writeChartFile, UPLOT_SHARED_SCRIPT };
26
+ export { escapeHtml, serializeJsonForScript, toEpochSeconds, writeChartFile, embedFunctionSources, UPLOT_SHARED_SCRIPT };
15
27
  //# sourceMappingURL=chart_utils.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"chart_utils.d.ts","sourceRoot":"","sources":["../../analysis/chart_utils.ts"],"names":[],"mappings":"AAOA;;GAEG;AAGH,iBAAS,UAAU,CAAC,GAAG,EAAE,MAAM,UAS9B;AAED,iBAAS,sBAAsB,CAAC,KAAK,EAAE,GAAG,UAEzC;AAED,iBAAS,cAAc,CAAC,EAAE,EAAE,GAAG,EAAE,WAAW,EAAE,GAAG,UAIhD;AAED,iBAAS,cAAc,CAAC,QAAQ,EAAE,GAAG,EAAE,IAAI,EAAE,GAAG,QAI/C;AAED;;;;GAIG;AACH,QAAA,MAAM,mBAAmB,okIAiGxB,CAAC;AAEF,OAAO,EAAE,UAAU,EAAE,sBAAsB,EAAE,cAAc,EAAE,cAAc,EAAE,mBAAmB,EAAE,CAAA"}
1
+ {"version":3,"file":"chart_utils.d.ts","sourceRoot":"","sources":["../../analysis/chart_utils.ts"],"names":[],"mappings":"AAOA;;GAEG;AAGH,iBAAS,UAAU,CAAC,GAAG,EAAE,MAAM,UAS9B;AAED,iBAAS,sBAAsB,CAAC,KAAK,EAAE,GAAG,UAEzC;AAED,iBAAS,cAAc,CAAC,EAAE,EAAE,GAAG,EAAE,WAAW,EAAE,GAAG,UAIhD;AAED,iBAAS,cAAc,CAAC,QAAQ,EAAE,GAAG,EAAE,IAAI,EAAE,GAAG,QAI/C;AAED;;;;;;;;;;GAUG;AACH,iBAAS,oBAAoB,CAAC,GAAG,EAAE,KAAK,CAAC,QAAQ,CAAC,GAAG,MAAM,CAG1D;AAED;;;;GAIG;AACH,QAAA,MAAM,mBAAmB,okIAiGxB,CAAC;AAEF,OAAO,EAAE,UAAU,EAAE,sBAAsB,EAAE,cAAc,EAAE,cAAc,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,CAAA"}
@@ -31,6 +31,21 @@ function writeChartFile(filePath, html) {
31
31
  ensureDir(chartDir);
32
32
  fs.writeFileSync(filePath, html, 'utf8');
33
33
  }
34
+ /**
35
+ * Serialize the exact source of the given pure functions for injection into a
36
+ * generated HTML <script> block. Each function is emitted as a top-level
37
+ * function declaration (Function.prototype.toString()), so browser-embedded
38
+ * charts run the same logic as the Node-side modules instead of a hand-copied
39
+ * copy. Functions must be self-contained (no imports or module-level constants
40
+ * referenced from their bodies); callers pass all config values explicitly.
41
+ *
42
+ * The emitted block is wrapped in marker comments so test harnesses can extract
43
+ * the embedded sources reliably regardless of the function list or ordering.
44
+ */
45
+ function embedFunctionSources(fns) {
46
+ const sources = fns.map((fn) => fn.toString()).join('\n\n');
47
+ return `/* EMBEDDED_FUNCS_START */\n${sources}\n/* EMBEDDED_FUNCS_END */`;
48
+ }
34
49
  /**
35
50
  * Shared uPlot interaction boilerplate for embedded browser scripts.
36
51
  * Consumers must define `xMin`, `xMax`, `charts`, `pendingRange`, and `pendingRangeRaf`
@@ -134,5 +149,5 @@ function bindPan(chart) {
134
149
  });
135
150
  }
136
151
  `;
137
- export { escapeHtml, serializeJsonForScript, toEpochSeconds, writeChartFile, UPLOT_SHARED_SCRIPT };
152
+ export { escapeHtml, serializeJsonForScript, toEpochSeconds, writeChartFile, embedFunctionSources, UPLOT_SHARED_SCRIPT };
138
153
  //# sourceMappingURL=chart_utils.js.map