dexbot 1.6.7 → 1.6.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (613) hide show
  1. package/CHANGELOG.md +49 -1
  2. package/README.md +3 -3
  3. package/analysis/README.md +2 -3
  4. package/analysis/tradingview/README.md +78 -1
  5. package/analysis/trend_detection/DYNAMIC_WEIGHT_RESEARCH.md +1 -1
  6. package/claw/package.json +1 -1
  7. package/claw/runtimes/openclaw-plugin/openclaw.plugin.json +1 -1
  8. package/claw/runtimes/openclaw-plugin/package.json +1 -1
  9. package/dist/analysis/tradingview/analyze_tradingview.d.ts +4 -0
  10. package/dist/analysis/tradingview/analyze_tradingview.js +55 -0
  11. package/dist/analysis/tradingview/grid_reset_config.d.ts +61 -0
  12. package/dist/analysis/tradingview/grid_reset_config.js +235 -0
  13. package/dist/analysis/tradingview/grid_reset_sim.d.ts +67 -0
  14. package/dist/analysis/tradingview/grid_reset_sim.js +307 -0
  15. package/dist/analysis/tradingview/tradingview_uplot_chart_generator.js +419 -3
  16. package/dist/dexbot.js +22 -6
  17. package/dist/market_adapter/core/market_adapter_service.js +14 -2
  18. package/dist/market_adapter/core/strategies/dynamic_weight_series.d.ts +8 -1
  19. package/dist/market_adapter/core/strategies/dynamic_weight_series.js +5 -1
  20. package/dist/market_adapter/inputs/window_cache.d.ts +97 -19
  21. package/dist/market_adapter/inputs/window_cache.js +302 -48
  22. package/dist/market_adapter/market_adapter.d.ts +8 -1
  23. package/dist/market_adapter/market_adapter.js +22 -4
  24. package/dist/modules/account_bots.js +10 -0
  25. package/dist/modules/account_orders.d.ts +24 -2
  26. package/dist/modules/account_orders.js +41 -4
  27. package/dist/modules/bot_settings.js +10 -1
  28. package/dist/modules/config.d.ts +1 -0
  29. package/dist/modules/config.js +1 -0
  30. package/dist/modules/constants.d.ts +11 -3
  31. package/dist/modules/constants.js +116 -37
  32. package/dist/modules/dexbot_class.d.ts +6 -76
  33. package/dist/modules/dexbot_class.js +0 -32
  34. package/dist/modules/dexbot_cow_runtime.d.ts +3 -58
  35. package/dist/modules/dexbot_cow_runtime.js +4 -87
  36. package/dist/modules/dexbot_maintenance_runtime.d.ts +15 -1
  37. package/dist/modules/dexbot_maintenance_runtime.js +59 -11
  38. package/dist/modules/dexbot_startup_runtime.js +73 -20
  39. package/dist/modules/dexbot_state_recovery.d.ts +6 -0
  40. package/dist/modules/dexbot_state_recovery.js +21 -0
  41. package/dist/modules/order/async_lock.d.ts +8 -0
  42. package/dist/modules/order/async_lock.js +15 -0
  43. package/dist/modules/order/genesis_policy.d.ts +162 -0
  44. package/dist/modules/order/genesis_policy.js +267 -0
  45. package/dist/modules/order/grid.js +76 -134
  46. package/dist/modules/order/grid_reconcile.d.ts +9 -0
  47. package/dist/modules/order/grid_reconcile.js +13 -4
  48. package/dist/modules/order/grid_reconcile_internal.js +2 -2
  49. package/dist/modules/order/manager.d.ts +4 -0
  50. package/dist/modules/order/manager.js +14 -1
  51. package/dist/modules/order/sync_engine.d.ts +19 -0
  52. package/dist/modules/order/sync_engine.js +284 -344
  53. package/dist/modules/order/utils/math.d.ts +22 -1
  54. package/dist/modules/order/utils/math.js +64 -1
  55. package/dist/modules/order/utils/order.d.ts +43 -58
  56. package/dist/modules/order/utils/order.js +220 -197
  57. package/dist/modules/order/utils/system.js +8 -1
  58. package/dist/modules/paths.d.ts +1 -0
  59. package/dist/modules/paths.js +1 -0
  60. package/dist/modules/version_notice.d.ts +165 -0
  61. package/dist/modules/version_notice.js +364 -0
  62. package/dist/pm2.js +9 -0
  63. package/dist/unlock.js +28 -0
  64. package/docs/BITSHARES_ONBOARDING.md +8 -1
  65. package/docs/COW_INVARIANTS.md +3 -2
  66. package/docs/DEXBOT_COMPARISON.md +4 -4
  67. package/docs/EVOLUTION.md +20 -19
  68. package/docs/FUND_MOVEMENT_AND_ACCOUNTING.md +1 -1
  69. package/docs/GRID_PRICE_INVARIANT.md +149 -31
  70. package/docs/GRID_RECALCULATION.md +12 -0
  71. package/docs/README.md +3 -1
  72. package/docs/WORKFLOW.md +16 -5
  73. package/market_adapter/README.md +1 -1
  74. package/modules/README.md +18 -1
  75. package/package.json +13 -5
  76. package/scripts/README.md +28 -2
  77. package/scripts/clear-all.sh +13 -4
  78. package/scripts/clear-logs.sh +13 -4
  79. package/scripts/clear-market-adapter.sh +6 -0
  80. package/scripts/clear-orders.sh +5 -0
  81. package/scripts/lib/dexbot-paths.sh +108 -0
  82. package/tests/README.md +11 -3
  83. package/analysis/account_resolver.ts +0 -161
  84. package/analysis/ama_fitting/analyze_ama_price_changes.ts +0 -155
  85. package/analysis/ama_fitting/analyze_lambda_vs_slow.ts +0 -404
  86. package/analysis/ama_fitting/calibrate_convergence_er.ts +0 -201
  87. package/analysis/ama_fitting/fetch_lp_candles.ts +0 -184
  88. package/analysis/ama_fitting/generate_unified_comparison_chart.ts +0 -232
  89. package/analysis/ama_fitting/optimizer_high_resolution.ts +0 -802
  90. package/analysis/analyze_dynamic_weight.ts +0 -243
  91. package/analysis/analyze_kalman.ts +0 -157
  92. package/analysis/analyze_regime.ts +0 -158
  93. package/analysis/analyze_regime_windows.ts +0 -470
  94. package/analysis/analyze_risk_profile.ts +0 -199
  95. package/analysis/analyze_trade_heatmap.ts +0 -362
  96. package/analysis/analyze_volatility.ts +0 -182
  97. package/analysis/bot_fitting/backtest_ama_sweep.ts +0 -934
  98. package/analysis/bot_fitting/backtest_bot_fitting.ts +0 -861
  99. package/analysis/bot_fitting/shared_utils.ts +0 -52
  100. package/analysis/bot_key_utils.ts +0 -426
  101. package/analysis/bot_usage/discover_bot_accounts.ts +0 -635
  102. package/analysis/bot_usage/kibana_bot_queries.ts +0 -211
  103. package/analysis/chain_pool.ts +0 -47
  104. package/analysis/chart_css.ts +0 -62
  105. package/analysis/chart_ui.ts +0 -105
  106. package/analysis/chart_utils.ts +0 -210
  107. package/analysis/fills_source.ts +0 -228
  108. package/analysis/grid_correction_check.ts +0 -786
  109. package/analysis/math_utils.ts +0 -53
  110. package/analysis/price_sources.ts +0 -136
  111. package/analysis/resolve_bot_accounts.ts +0 -199
  112. package/analysis/resolve_source.ts +0 -99
  113. package/analysis/results/ama_sweep_results_lp_pool_133_1h.json +0 -2455
  114. package/analysis/results/bot_fitting_results_lp_pool_133_1h.json +0 -218
  115. package/analysis/trade_profitability.ts +0 -1335
  116. package/analysis/tradingview/analyze_tradingview.ts +0 -280
  117. package/analysis/tradingview/h-bts_tradingview.html +0 -1570
  118. package/analysis/tradingview/t-bts_tradingview.html +0 -1570
  119. package/analysis/tradingview/tradingview_uplot_chart_generator.ts +0 -3268
  120. package/analysis/trend_detection/dynamic_weight_chart_generator.ts +0 -1481
  121. package/analysis/trend_detection/hurst_analyzer.ts +0 -7
  122. package/analysis/trend_detection/kalman_chart_generator.ts +0 -398
  123. package/analysis/trend_detection/kalman_trend_analyzer.ts +0 -9
  124. package/analysis/trend_detection/kalman_velocity_smoothing.ts +0 -7
  125. package/analysis/trend_detection/package.json +0 -23
  126. package/analysis/trend_detection/permutation_entropy_analyzer.ts +0 -7
  127. package/analysis/trend_detection/regime_chart_generator.ts +0 -338
  128. package/analysis/trend_detection/tests/test_kalman_trend.ts +0 -153
  129. package/analysis/trend_detection/tests/test_kalman_velocity_smoothing.ts +0 -64
  130. package/analysis/trend_detection/volatility_chart_generator.ts +0 -654
  131. package/analysis/tsconfig.json +0 -29
  132. package/claw/tests/package.json +0 -3
  133. package/claw/tests/test_claw_bridge.ts +0 -570
  134. package/claw/tests/test_claw_catalog_and_credentials.ts +0 -156
  135. package/claw/tests/test_claw_chain_layer.ts +0 -739
  136. package/claw/tests/test_claw_data_flow.ts +0 -525
  137. package/claw/tests/test_claw_domain_logic.ts +0 -471
  138. package/claw/tests/test_claw_manifest_and_matrix.ts +0 -222
  139. package/claw/tests/test_claw_mcp_transport.ts +0 -243
  140. package/claw/tests/test_claw_regressions.ts +0 -711
  141. package/claw/tests/test_claw_skill_generation.ts +0 -103
  142. package/claw/tests/test_claw_state_store.ts +0 -44
  143. package/claw/tests/test_dexbot_profiles.ts +0 -654
  144. package/claw/tests/test_memu_bridge.ts +0 -189
  145. package/claw/tests/test_nullclaw_tmp_integration.ts +0 -57
  146. package/claw/tests/test_position_health.ts +0 -343
  147. package/claw/tests/test_position_manager.ts +0 -429
  148. package/claw/tests/test_position_manager_watch_health.ts +0 -100
  149. package/claw/tests/test_short_mpa_strategy.ts +0 -232
  150. package/dist/analysis/account_resolver.d.ts.map +0 -1
  151. package/dist/analysis/account_resolver.js.map +0 -1
  152. package/dist/analysis/ama_fitting/analyze_ama_price_changes.d.ts.map +0 -1
  153. package/dist/analysis/ama_fitting/analyze_ama_price_changes.js.map +0 -1
  154. package/dist/analysis/ama_fitting/analyze_lambda_vs_slow.d.ts.map +0 -1
  155. package/dist/analysis/ama_fitting/analyze_lambda_vs_slow.js.map +0 -1
  156. package/dist/analysis/ama_fitting/calibrate_convergence_er.d.ts.map +0 -1
  157. package/dist/analysis/ama_fitting/calibrate_convergence_er.js.map +0 -1
  158. package/dist/analysis/ama_fitting/fetch_lp_candles.d.ts.map +0 -1
  159. package/dist/analysis/ama_fitting/fetch_lp_candles.js.map +0 -1
  160. package/dist/analysis/ama_fitting/generate_unified_comparison_chart.d.ts.map +0 -1
  161. package/dist/analysis/ama_fitting/generate_unified_comparison_chart.js.map +0 -1
  162. package/dist/analysis/ama_fitting/optimizer_high_resolution.d.ts.map +0 -1
  163. package/dist/analysis/ama_fitting/optimizer_high_resolution.js.map +0 -1
  164. package/dist/analysis/analyze_dynamic_weight.d.ts.map +0 -1
  165. package/dist/analysis/analyze_dynamic_weight.js.map +0 -1
  166. package/dist/analysis/analyze_kalman.d.ts.map +0 -1
  167. package/dist/analysis/analyze_kalman.js.map +0 -1
  168. package/dist/analysis/analyze_regime.d.ts.map +0 -1
  169. package/dist/analysis/analyze_regime.js.map +0 -1
  170. package/dist/analysis/analyze_regime_windows.d.ts.map +0 -1
  171. package/dist/analysis/analyze_regime_windows.js.map +0 -1
  172. package/dist/analysis/analyze_risk_profile.d.ts.map +0 -1
  173. package/dist/analysis/analyze_risk_profile.js.map +0 -1
  174. package/dist/analysis/analyze_trade_heatmap.d.ts.map +0 -1
  175. package/dist/analysis/analyze_trade_heatmap.js.map +0 -1
  176. package/dist/analysis/analyze_volatility.d.ts.map +0 -1
  177. package/dist/analysis/analyze_volatility.js.map +0 -1
  178. package/dist/analysis/bot_fitting/backtest_ama_sweep.d.ts.map +0 -1
  179. package/dist/analysis/bot_fitting/backtest_ama_sweep.js.map +0 -1
  180. package/dist/analysis/bot_fitting/backtest_bot_fitting.d.ts.map +0 -1
  181. package/dist/analysis/bot_fitting/backtest_bot_fitting.js.map +0 -1
  182. package/dist/analysis/bot_fitting/shared_utils.d.ts.map +0 -1
  183. package/dist/analysis/bot_fitting/shared_utils.js.map +0 -1
  184. package/dist/analysis/bot_key_utils.d.ts.map +0 -1
  185. package/dist/analysis/bot_key_utils.js.map +0 -1
  186. package/dist/analysis/bot_usage/discover_bot_accounts.d.ts.map +0 -1
  187. package/dist/analysis/bot_usage/discover_bot_accounts.js.map +0 -1
  188. package/dist/analysis/bot_usage/kibana_bot_queries.d.ts.map +0 -1
  189. package/dist/analysis/bot_usage/kibana_bot_queries.js.map +0 -1
  190. package/dist/analysis/chain_pool.d.ts.map +0 -1
  191. package/dist/analysis/chain_pool.js.map +0 -1
  192. package/dist/analysis/chart_css.d.ts.map +0 -1
  193. package/dist/analysis/chart_css.js.map +0 -1
  194. package/dist/analysis/chart_ui.d.ts.map +0 -1
  195. package/dist/analysis/chart_ui.js.map +0 -1
  196. package/dist/analysis/chart_utils.d.ts.map +0 -1
  197. package/dist/analysis/chart_utils.js.map +0 -1
  198. package/dist/analysis/fills_source.d.ts.map +0 -1
  199. package/dist/analysis/fills_source.js.map +0 -1
  200. package/dist/analysis/grid_correction_check.d.ts.map +0 -1
  201. package/dist/analysis/grid_correction_check.js.map +0 -1
  202. package/dist/analysis/math_utils.d.ts.map +0 -1
  203. package/dist/analysis/math_utils.js.map +0 -1
  204. package/dist/analysis/price_sources.d.ts.map +0 -1
  205. package/dist/analysis/price_sources.js.map +0 -1
  206. package/dist/analysis/resolve_bot_accounts.d.ts.map +0 -1
  207. package/dist/analysis/resolve_bot_accounts.js.map +0 -1
  208. package/dist/analysis/resolve_source.d.ts.map +0 -1
  209. package/dist/analysis/resolve_source.js.map +0 -1
  210. package/dist/analysis/trade_profitability.d.ts.map +0 -1
  211. package/dist/analysis/trade_profitability.js.map +0 -1
  212. package/dist/analysis/tradingview/analyze_tradingview.d.ts.map +0 -1
  213. package/dist/analysis/tradingview/analyze_tradingview.js.map +0 -1
  214. package/dist/analysis/tradingview/tradingview_uplot_chart_generator.d.ts.map +0 -1
  215. package/dist/analysis/tradingview/tradingview_uplot_chart_generator.js.map +0 -1
  216. package/dist/analysis/trend_detection/dynamic_weight_chart_generator.d.ts.map +0 -1
  217. package/dist/analysis/trend_detection/dynamic_weight_chart_generator.js.map +0 -1
  218. package/dist/analysis/trend_detection/hurst_analyzer.d.ts.map +0 -1
  219. package/dist/analysis/trend_detection/hurst_analyzer.js.map +0 -1
  220. package/dist/analysis/trend_detection/kalman_chart_generator.d.ts.map +0 -1
  221. package/dist/analysis/trend_detection/kalman_chart_generator.js.map +0 -1
  222. package/dist/analysis/trend_detection/kalman_trend_analyzer.d.ts.map +0 -1
  223. package/dist/analysis/trend_detection/kalman_trend_analyzer.js.map +0 -1
  224. package/dist/analysis/trend_detection/kalman_velocity_smoothing.d.ts.map +0 -1
  225. package/dist/analysis/trend_detection/kalman_velocity_smoothing.js.map +0 -1
  226. package/dist/analysis/trend_detection/permutation_entropy_analyzer.d.ts.map +0 -1
  227. package/dist/analysis/trend_detection/permutation_entropy_analyzer.js.map +0 -1
  228. package/dist/analysis/trend_detection/regime_chart_generator.d.ts.map +0 -1
  229. package/dist/analysis/trend_detection/regime_chart_generator.js.map +0 -1
  230. package/dist/analysis/trend_detection/tests/test_kalman_trend.d.ts +0 -2
  231. package/dist/analysis/trend_detection/tests/test_kalman_trend.d.ts.map +0 -1
  232. package/dist/analysis/trend_detection/tests/test_kalman_trend.js +0 -128
  233. package/dist/analysis/trend_detection/tests/test_kalman_trend.js.map +0 -1
  234. package/dist/analysis/trend_detection/tests/test_kalman_velocity_smoothing.d.ts +0 -2
  235. package/dist/analysis/trend_detection/tests/test_kalman_velocity_smoothing.d.ts.map +0 -1
  236. package/dist/analysis/trend_detection/tests/test_kalman_velocity_smoothing.js +0 -37
  237. package/dist/analysis/trend_detection/tests/test_kalman_velocity_smoothing.js.map +0 -1
  238. package/dist/analysis/trend_detection/volatility_chart_generator.d.ts.map +0 -1
  239. package/dist/analysis/trend_detection/volatility_chart_generator.js.map +0 -1
  240. package/dist/bot.d.ts.map +0 -1
  241. package/dist/bot.js.map +0 -1
  242. package/dist/credential-daemon.d.ts.map +0 -1
  243. package/dist/credential-daemon.js.map +0 -1
  244. package/dist/dexbot.d.ts.map +0 -1
  245. package/dist/dexbot.js.map +0 -1
  246. package/dist/market_adapter/ama_signal_runner.d.ts.map +0 -1
  247. package/dist/market_adapter/ama_signal_runner.js.map +0 -1
  248. package/dist/market_adapter/candle_utils.d.ts.map +0 -1
  249. package/dist/market_adapter/candle_utils.js.map +0 -1
  250. package/dist/market_adapter/core/asymmetric_bounds.d.ts.map +0 -1
  251. package/dist/market_adapter/core/asymmetric_bounds.js.map +0 -1
  252. package/dist/market_adapter/core/config_normalizers.d.ts.map +0 -1
  253. package/dist/market_adapter/core/config_normalizers.js.map +0 -1
  254. package/dist/market_adapter/core/kibana_candles.d.ts.map +0 -1
  255. package/dist/market_adapter/core/kibana_candles.js.map +0 -1
  256. package/dist/market_adapter/core/kibana_client.d.ts.map +0 -1
  257. package/dist/market_adapter/core/kibana_client.js.map +0 -1
  258. package/dist/market_adapter/core/kibana_market_candles.d.ts.map +0 -1
  259. package/dist/market_adapter/core/kibana_market_candles.js.map +0 -1
  260. package/dist/market_adapter/core/market_adapter_service.d.ts.map +0 -1
  261. package/dist/market_adapter/core/market_adapter_service.js.map +0 -1
  262. package/dist/market_adapter/core/signals/hurst_analyzer.d.ts.map +0 -1
  263. package/dist/market_adapter/core/signals/hurst_analyzer.js.map +0 -1
  264. package/dist/market_adapter/core/signals/kalman_trend_analyzer.d.ts.map +0 -1
  265. package/dist/market_adapter/core/signals/kalman_trend_analyzer.js.map +0 -1
  266. package/dist/market_adapter/core/signals/kalman_velocity_smoothing.d.ts.map +0 -1
  267. package/dist/market_adapter/core/signals/kalman_velocity_smoothing.js.map +0 -1
  268. package/dist/market_adapter/core/signals/permutation_entropy_analyzer.d.ts.map +0 -1
  269. package/dist/market_adapter/core/signals/permutation_entropy_analyzer.js.map +0 -1
  270. package/dist/market_adapter/core/strategies/ama.d.ts.map +0 -1
  271. package/dist/market_adapter/core/strategies/ama.js.map +0 -1
  272. package/dist/market_adapter/core/strategies/ama_slope_model.d.ts.map +0 -1
  273. package/dist/market_adapter/core/strategies/ama_slope_model.js.map +0 -1
  274. package/dist/market_adapter/core/strategies/atr/calculator.d.ts.map +0 -1
  275. package/dist/market_adapter/core/strategies/atr/calculator.js.map +0 -1
  276. package/dist/market_adapter/core/strategies/collateral_manager.d.ts.map +0 -1
  277. package/dist/market_adapter/core/strategies/collateral_manager.js.map +0 -1
  278. package/dist/market_adapter/core/strategies/dynamic_weight_series.d.ts.map +0 -1
  279. package/dist/market_adapter/core/strategies/dynamic_weight_series.js.map +0 -1
  280. package/dist/market_adapter/core/strategies/regime_gate.d.ts.map +0 -1
  281. package/dist/market_adapter/core/strategies/regime_gate.js.map +0 -1
  282. package/dist/market_adapter/core/strategies/regime_interp.d.ts.map +0 -1
  283. package/dist/market_adapter/core/strategies/regime_interp.js.map +0 -1
  284. package/dist/market_adapter/core/strategies/volatility_shift.d.ts.map +0 -1
  285. package/dist/market_adapter/core/strategies/volatility_shift.js.map +0 -1
  286. package/dist/market_adapter/inputs/fetch_book_data.d.ts.map +0 -1
  287. package/dist/market_adapter/inputs/fetch_book_data.js.map +0 -1
  288. package/dist/market_adapter/inputs/fetch_cex_synthetic_data.d.ts.map +0 -1
  289. package/dist/market_adapter/inputs/fetch_cex_synthetic_data.js.map +0 -1
  290. package/dist/market_adapter/inputs/fetch_lp_data.d.ts.map +0 -1
  291. package/dist/market_adapter/inputs/fetch_lp_data.js.map +0 -1
  292. package/dist/market_adapter/inputs/kibana_feed_source.d.ts.map +0 -1
  293. package/dist/market_adapter/inputs/kibana_feed_source.js.map +0 -1
  294. package/dist/market_adapter/inputs/kibana_source.d.ts.map +0 -1
  295. package/dist/market_adapter/inputs/kibana_source.js.map +0 -1
  296. package/dist/market_adapter/inputs/window_cache.d.ts.map +0 -1
  297. package/dist/market_adapter/inputs/window_cache.js.map +0 -1
  298. package/dist/market_adapter/interval_utils.d.ts.map +0 -1
  299. package/dist/market_adapter/interval_utils.js.map +0 -1
  300. package/dist/market_adapter/log_format.d.ts.map +0 -1
  301. package/dist/market_adapter/log_format.js.map +0 -1
  302. package/dist/market_adapter/lp_chart_core.d.ts.map +0 -1
  303. package/dist/market_adapter/lp_chart_core.js.map +0 -1
  304. package/dist/market_adapter/lp_chart_runner.d.ts.map +0 -1
  305. package/dist/market_adapter/lp_chart_runner.js.map +0 -1
  306. package/dist/market_adapter/lp_chart_strategy_loader.d.ts.map +0 -1
  307. package/dist/market_adapter/lp_chart_strategy_loader.js.map +0 -1
  308. package/dist/market_adapter/market_adapter.d.ts.map +0 -1
  309. package/dist/market_adapter/market_adapter.js.map +0 -1
  310. package/dist/market_adapter/test_helpers.d.ts.map +0 -1
  311. package/dist/market_adapter/test_helpers.js.map +0 -1
  312. package/dist/market_adapter/utils/adapter_client.d.ts.map +0 -1
  313. package/dist/market_adapter/utils/adapter_client.js.map +0 -1
  314. package/dist/market_adapter/utils/atomic_write.d.ts.map +0 -1
  315. package/dist/market_adapter/utils/atomic_write.js.map +0 -1
  316. package/dist/market_adapter/utils/chain.d.ts.map +0 -1
  317. package/dist/market_adapter/utils/chain.js.map +0 -1
  318. package/dist/market_adapter/utils/data_discovery.d.ts.map +0 -1
  319. package/dist/market_adapter/utils/data_discovery.js.map +0 -1
  320. package/dist/market_adapter/utils/dynamic_grid_snapshot.d.ts.map +0 -1
  321. package/dist/market_adapter/utils/dynamic_grid_snapshot.js.map +0 -1
  322. package/dist/market_adapter/utils/file_lock.d.ts.map +0 -1
  323. package/dist/market_adapter/utils/file_lock.js.map +0 -1
  324. package/dist/market_adapter/utils/native_history.d.ts.map +0 -1
  325. package/dist/market_adapter/utils/native_history.js.map +0 -1
  326. package/dist/modules/account_bots.d.ts.map +0 -1
  327. package/dist/modules/account_bots.js.map +0 -1
  328. package/dist/modules/account_orders.d.ts.map +0 -1
  329. package/dist/modules/account_orders.js.map +0 -1
  330. package/dist/modules/authority_resolver.d.ts.map +0 -1
  331. package/dist/modules/authority_resolver.js.map +0 -1
  332. package/dist/modules/bitshares-native/chain_client.d.ts.map +0 -1
  333. package/dist/modules/bitshares-native/chain_client.js.map +0 -1
  334. package/dist/modules/bitshares-native/crypto/ecc.browser.d.ts.map +0 -1
  335. package/dist/modules/bitshares-native/crypto/ecc.browser.js.map +0 -1
  336. package/dist/modules/bitshares-native/crypto/ecc.d.ts.map +0 -1
  337. package/dist/modules/bitshares-native/crypto/ecc.js.map +0 -1
  338. package/dist/modules/bitshares-native/crypto/ecc_selector.d.ts.map +0 -1
  339. package/dist/modules/bitshares-native/crypto/ecc_selector.js.map +0 -1
  340. package/dist/modules/bitshares-native/index.d.ts.map +0 -1
  341. package/dist/modules/bitshares-native/index.js.map +0 -1
  342. package/dist/modules/bitshares-native/lru_cache.d.ts.map +0 -1
  343. package/dist/modules/bitshares-native/lru_cache.js.map +0 -1
  344. package/dist/modules/bitshares-native/resolvers.d.ts.map +0 -1
  345. package/dist/modules/bitshares-native/resolvers.js.map +0 -1
  346. package/dist/modules/bitshares-native/serial/chain_constants.d.ts.map +0 -1
  347. package/dist/modules/bitshares-native/serial/chain_constants.js.map +0 -1
  348. package/dist/modules/bitshares-native/serial/index.d.ts.map +0 -1
  349. package/dist/modules/bitshares-native/serial/index.js.map +0 -1
  350. package/dist/modules/bitshares-native/serial/operations.d.ts.map +0 -1
  351. package/dist/modules/bitshares-native/serial/operations.js.map +0 -1
  352. package/dist/modules/bitshares-native/serial/serializer.d.ts.map +0 -1
  353. package/dist/modules/bitshares-native/serial/serializer.js.map +0 -1
  354. package/dist/modules/bitshares-native/serial/types.d.ts.map +0 -1
  355. package/dist/modules/bitshares-native/serial/types.js.map +0 -1
  356. package/dist/modules/bitshares-native/signing_client.d.ts.map +0 -1
  357. package/dist/modules/bitshares-native/signing_client.js.map +0 -1
  358. package/dist/modules/bitshares-native/subscriptions.d.ts.map +0 -1
  359. package/dist/modules/bitshares-native/subscriptions.js.map +0 -1
  360. package/dist/modules/bitshares-native/transport.d.ts.map +0 -1
  361. package/dist/modules/bitshares-native/transport.js.map +0 -1
  362. package/dist/modules/bitshares-native/tx/builder.d.ts.map +0 -1
  363. package/dist/modules/bitshares-native/tx/builder.js.map +0 -1
  364. package/dist/modules/bitshares-native/tx/tx_cache.d.ts.map +0 -1
  365. package/dist/modules/bitshares-native/tx/tx_cache.js.map +0 -1
  366. package/dist/modules/bitshares_client.d.ts.map +0 -1
  367. package/dist/modules/bitshares_client.js.map +0 -1
  368. package/dist/modules/bot_defaults.d.ts.map +0 -1
  369. package/dist/modules/bot_defaults.js.map +0 -1
  370. package/dist/modules/bot_settings.d.ts.map +0 -1
  371. package/dist/modules/bot_settings.js.map +0 -1
  372. package/dist/modules/bots_file_lock.d.ts.map +0 -1
  373. package/dist/modules/bots_file_lock.js.map +0 -1
  374. package/dist/modules/broadcast_failure.d.ts.map +0 -1
  375. package/dist/modules/broadcast_failure.js.map +0 -1
  376. package/dist/modules/chain_keys.d.ts.map +0 -1
  377. package/dist/modules/chain_keys.js.map +0 -1
  378. package/dist/modules/chain_orders.d.ts.map +0 -1
  379. package/dist/modules/chain_orders.js.map +0 -1
  380. package/dist/modules/cli_colors.d.ts.map +0 -1
  381. package/dist/modules/cli_colors.js.map +0 -1
  382. package/dist/modules/cli_start_onboarding.d.ts.map +0 -1
  383. package/dist/modules/cli_start_onboarding.js.map +0 -1
  384. package/dist/modules/cli_start_output.d.ts.map +0 -1
  385. package/dist/modules/cli_start_output.js.map +0 -1
  386. package/dist/modules/config.d.ts.map +0 -1
  387. package/dist/modules/config.js.map +0 -1
  388. package/dist/modules/constants.d.ts.map +0 -1
  389. package/dist/modules/constants.js.map +0 -1
  390. package/dist/modules/cr_planner.d.ts.map +0 -1
  391. package/dist/modules/cr_planner.js.map +0 -1
  392. package/dist/modules/credential_policy.d.ts.map +0 -1
  393. package/dist/modules/credential_policy.js.map +0 -1
  394. package/dist/modules/credential_runtime.d.ts.map +0 -1
  395. package/dist/modules/credential_runtime.js.map +0 -1
  396. package/dist/modules/credential_session_cache.d.ts.map +0 -1
  397. package/dist/modules/credential_session_cache.js.map +0 -1
  398. package/dist/modules/credit_pricing.d.ts.map +0 -1
  399. package/dist/modules/credit_pricing.js.map +0 -1
  400. package/dist/modules/credit_runtime.d.ts.map +0 -1
  401. package/dist/modules/credit_runtime.js.map +0 -1
  402. package/dist/modules/crypto/browser_provider.d.ts.map +0 -1
  403. package/dist/modules/crypto/browser_provider.js.map +0 -1
  404. package/dist/modules/crypto/index.d.ts.map +0 -1
  405. package/dist/modules/crypto/index.js.map +0 -1
  406. package/dist/modules/crypto/node_provider.d.ts.map +0 -1
  407. package/dist/modules/crypto/node_provider.js.map +0 -1
  408. package/dist/modules/crypto/provider.d.ts.map +0 -1
  409. package/dist/modules/crypto/provider.js.map +0 -1
  410. package/dist/modules/crypto/pure_ripemd160.d.ts.map +0 -1
  411. package/dist/modules/crypto/pure_ripemd160.js.map +0 -1
  412. package/dist/modules/crypto/pure_scrypt.d.ts.map +0 -1
  413. package/dist/modules/crypto/pure_scrypt.js.map +0 -1
  414. package/dist/modules/crypto/pure_secp256k1.d.ts.map +0 -1
  415. package/dist/modules/crypto/pure_secp256k1.js.map +0 -1
  416. package/dist/modules/crypto/sync.d.ts.map +0 -1
  417. package/dist/modules/crypto/sync.js.map +0 -1
  418. package/dist/modules/daemon_node_health.d.ts.map +0 -1
  419. package/dist/modules/daemon_node_health.js.map +0 -1
  420. package/dist/modules/dexbot_class.d.ts.map +0 -1
  421. package/dist/modules/dexbot_class.js.map +0 -1
  422. package/dist/modules/dexbot_cow_runtime.d.ts.map +0 -1
  423. package/dist/modules/dexbot_cow_runtime.js.map +0 -1
  424. package/dist/modules/dexbot_credential_client.d.ts.map +0 -1
  425. package/dist/modules/dexbot_credential_client.js.map +0 -1
  426. package/dist/modules/dexbot_fill_runtime.d.ts.map +0 -1
  427. package/dist/modules/dexbot_fill_runtime.js.map +0 -1
  428. package/dist/modules/dexbot_maintenance_runtime.d.ts.map +0 -1
  429. package/dist/modules/dexbot_maintenance_runtime.js.map +0 -1
  430. package/dist/modules/dexbot_startup_runtime.d.ts.map +0 -1
  431. package/dist/modules/dexbot_startup_runtime.js.map +0 -1
  432. package/dist/modules/dexbot_state_recovery.d.ts.map +0 -1
  433. package/dist/modules/dexbot_state_recovery.js.map +0 -1
  434. package/dist/modules/env.d.ts.map +0 -1
  435. package/dist/modules/env.js.map +0 -1
  436. package/dist/modules/fund_registry.d.ts.map +0 -1
  437. package/dist/modules/fund_registry.js.map +0 -1
  438. package/dist/modules/general_settings.d.ts.map +0 -1
  439. package/dist/modules/general_settings.js.map +0 -1
  440. package/dist/modules/graceful_shutdown.d.ts.map +0 -1
  441. package/dist/modules/graceful_shutdown.js.map +0 -1
  442. package/dist/modules/grid_price_source.d.ts.map +0 -1
  443. package/dist/modules/grid_price_source.js.map +0 -1
  444. package/dist/modules/key_store.d.ts.map +0 -1
  445. package/dist/modules/key_store.js.map +0 -1
  446. package/dist/modules/launcher/adapter_requirement.d.ts.map +0 -1
  447. package/dist/modules/launcher/adapter_requirement.js.map +0 -1
  448. package/dist/modules/launcher/bot_supervisor.d.ts.map +0 -1
  449. package/dist/modules/launcher/bot_supervisor.js.map +0 -1
  450. package/dist/modules/launcher/child_env.d.ts.map +0 -1
  451. package/dist/modules/launcher/child_env.js.map +0 -1
  452. package/dist/modules/launcher/credential_bootstrap.d.ts.map +0 -1
  453. package/dist/modules/launcher/credential_bootstrap.js.map +0 -1
  454. package/dist/modules/launcher/credential_daemon.d.ts.map +0 -1
  455. package/dist/modules/launcher/credential_daemon.js.map +0 -1
  456. package/dist/modules/launcher/credential_secret.d.ts.map +0 -1
  457. package/dist/modules/launcher/credential_secret.js.map +0 -1
  458. package/dist/modules/launcher/foreign_cred_daemon.d.ts.map +0 -1
  459. package/dist/modules/launcher/foreign_cred_daemon.js.map +0 -1
  460. package/dist/modules/launcher/headless_password.d.ts.map +0 -1
  461. package/dist/modules/launcher/headless_password.js.map +0 -1
  462. package/dist/modules/launcher/launch_modes.d.ts.map +0 -1
  463. package/dist/modules/launcher/launch_modes.js.map +0 -1
  464. package/dist/modules/launcher/market_adapter_runtime.d.ts.map +0 -1
  465. package/dist/modules/launcher/market_adapter_runtime.js.map +0 -1
  466. package/dist/modules/launcher/market_adapter_watchdog.d.ts.map +0 -1
  467. package/dist/modules/launcher/market_adapter_watchdog.js.map +0 -1
  468. package/dist/modules/launcher/monolithic_runtime.d.ts.map +0 -1
  469. package/dist/modules/launcher/monolithic_runtime.js.map +0 -1
  470. package/dist/modules/launcher/runtime_entry.d.ts.map +0 -1
  471. package/dist/modules/launcher/runtime_entry.js.map +0 -1
  472. package/dist/modules/launcher/status_reporting.d.ts.map +0 -1
  473. package/dist/modules/launcher/status_reporting.js.map +0 -1
  474. package/dist/modules/launcher/supervisor_control.d.ts.map +0 -1
  475. package/dist/modules/launcher/supervisor_control.js.map +0 -1
  476. package/dist/modules/market_adapter_whitelist.d.ts.map +0 -1
  477. package/dist/modules/market_adapter_whitelist.js.map +0 -1
  478. package/dist/modules/node_connect_policy.d.ts.map +0 -1
  479. package/dist/modules/node_connect_policy.js.map +0 -1
  480. package/dist/modules/node_failure_ledger.d.ts.map +0 -1
  481. package/dist/modules/node_failure_ledger.js.map +0 -1
  482. package/dist/modules/node_health_cache.d.ts.map +0 -1
  483. package/dist/modules/node_health_cache.js.map +0 -1
  484. package/dist/modules/node_manager.d.ts.map +0 -1
  485. package/dist/modules/node_manager.js.map +0 -1
  486. package/dist/modules/order/accounting.d.ts.map +0 -1
  487. package/dist/modules/order/accounting.js.map +0 -1
  488. package/dist/modules/order/async_lock.d.ts.map +0 -1
  489. package/dist/modules/order/async_lock.js.map +0 -1
  490. package/dist/modules/order/export.d.ts.map +0 -1
  491. package/dist/modules/order/export.js.map +0 -1
  492. package/dist/modules/order/format.d.ts.map +0 -1
  493. package/dist/modules/order/format.js.map +0 -1
  494. package/dist/modules/order/grid.d.ts.map +0 -1
  495. package/dist/modules/order/grid.js.map +0 -1
  496. package/dist/modules/order/grid_reconcile.d.ts.map +0 -1
  497. package/dist/modules/order/grid_reconcile.js.map +0 -1
  498. package/dist/modules/order/grid_reconcile_internal.d.ts.map +0 -1
  499. package/dist/modules/order/grid_reconcile_internal.js.map +0 -1
  500. package/dist/modules/order/index.d.ts.map +0 -1
  501. package/dist/modules/order/index.js.map +0 -1
  502. package/dist/modules/order/logger.d.ts.map +0 -1
  503. package/dist/modules/order/logger.js.map +0 -1
  504. package/dist/modules/order/logger_state.d.ts.map +0 -1
  505. package/dist/modules/order/logger_state.js.map +0 -1
  506. package/dist/modules/order/manager.d.ts.map +0 -1
  507. package/dist/modules/order/manager.js.map +0 -1
  508. package/dist/modules/order/processed_fill_store.d.ts.map +0 -1
  509. package/dist/modules/order/processed_fill_store.js.map +0 -1
  510. package/dist/modules/order/strategy.d.ts.map +0 -1
  511. package/dist/modules/order/strategy.js.map +0 -1
  512. package/dist/modules/order/sync_engine.d.ts.map +0 -1
  513. package/dist/modules/order/sync_engine.js.map +0 -1
  514. package/dist/modules/order/utils/math.d.ts.map +0 -1
  515. package/dist/modules/order/utils/math.js.map +0 -1
  516. package/dist/modules/order/utils/order.d.ts.map +0 -1
  517. package/dist/modules/order/utils/order.js.map +0 -1
  518. package/dist/modules/order/utils/slot.d.ts.map +0 -1
  519. package/dist/modules/order/utils/slot.js.map +0 -1
  520. package/dist/modules/order/utils/system.d.ts.map +0 -1
  521. package/dist/modules/order/utils/system.js.map +0 -1
  522. package/dist/modules/order/utils/timeout.d.ts.map +0 -1
  523. package/dist/modules/order/utils/timeout.js.map +0 -1
  524. package/dist/modules/order/utils/validate.d.ts.map +0 -1
  525. package/dist/modules/order/utils/validate.js.map +0 -1
  526. package/dist/modules/order/utils/withPoolRef.d.ts.map +0 -1
  527. package/dist/modules/order/utils/withPoolRef.js.map +0 -1
  528. package/dist/modules/order/working_grid.d.ts.map +0 -1
  529. package/dist/modules/order/working_grid.js.map +0 -1
  530. package/dist/modules/path_api.d.ts.map +0 -1
  531. package/dist/modules/path_api.js.map +0 -1
  532. package/dist/modules/paths.d.ts.map +0 -1
  533. package/dist/modules/paths.js.map +0 -1
  534. package/dist/modules/process_discovery.d.ts.map +0 -1
  535. package/dist/modules/process_discovery.js.map +0 -1
  536. package/dist/modules/runtime.d.ts.map +0 -1
  537. package/dist/modules/runtime.js.map +0 -1
  538. package/dist/modules/runtime_settings.d.ts.map +0 -1
  539. package/dist/modules/runtime_settings.js.map +0 -1
  540. package/dist/modules/settings_merge.d.ts.map +0 -1
  541. package/dist/modules/settings_merge.js.map +0 -1
  542. package/dist/modules/socket_json_client.d.ts.map +0 -1
  543. package/dist/modules/socket_json_client.js.map +0 -1
  544. package/dist/modules/storage/browser_adapter.d.ts.map +0 -1
  545. package/dist/modules/storage/browser_adapter.js.map +0 -1
  546. package/dist/modules/storage/index.d.ts.map +0 -1
  547. package/dist/modules/storage/index.js.map +0 -1
  548. package/dist/modules/storage/node_adapter.d.ts.map +0 -1
  549. package/dist/modules/storage/node_adapter.js.map +0 -1
  550. package/dist/modules/storage/types.d.ts.map +0 -1
  551. package/dist/modules/storage/types.js.map +0 -1
  552. package/dist/modules/types.d.ts.map +0 -1
  553. package/dist/modules/types.js.map +0 -1
  554. package/dist/modules/utils/base58check.d.ts.map +0 -1
  555. package/dist/modules/utils/base58check.js.map +0 -1
  556. package/dist/modules/utils/build_dir.d.ts.map +0 -1
  557. package/dist/modules/utils/build_dir.js.map +0 -1
  558. package/dist/modules/utils/chain_logs.d.ts.map +0 -1
  559. package/dist/modules/utils/chain_logs.js.map +0 -1
  560. package/dist/modules/utils/errors.d.ts.map +0 -1
  561. package/dist/modules/utils/errors.js.map +0 -1
  562. package/dist/modules/utils/sanitize_key.d.ts.map +0 -1
  563. package/dist/modules/utils/sanitize_key.js.map +0 -1
  564. package/dist/modules/utils/text_width.d.ts.map +0 -1
  565. package/dist/modules/utils/text_width.js.map +0 -1
  566. package/dist/modules/validate_profiles.d.ts.map +0 -1
  567. package/dist/modules/validate_profiles.js.map +0 -1
  568. package/dist/pm2.d.ts.map +0 -1
  569. package/dist/pm2.js.map +0 -1
  570. package/dist/scripts/analyze-credit.d.ts.map +0 -1
  571. package/dist/scripts/analyze-credit.js.map +0 -1
  572. package/dist/scripts/analyze-git.d.ts.map +0 -1
  573. package/dist/scripts/analyze-git.js.map +0 -1
  574. package/dist/scripts/analyze-orders.d.ts.map +0 -1
  575. package/dist/scripts/analyze-orders.js.map +0 -1
  576. package/dist/scripts/chart_command.d.ts.map +0 -1
  577. package/dist/scripts/chart_command.js.map +0 -1
  578. package/dist/scripts/diagnose-kibana-candles.d.ts.map +0 -1
  579. package/dist/scripts/diagnose-kibana-candles.js.map +0 -1
  580. package/dist/scripts/diagnose-pool-history.d.ts.map +0 -1
  581. package/dist/scripts/diagnose-pool-history.js.map +0 -1
  582. package/dist/scripts/divergence-calc.d.ts.map +0 -1
  583. package/dist/scripts/divergence-calc.js.map +0 -1
  584. package/dist/scripts/dw.d.ts.map +0 -1
  585. package/dist/scripts/dw.js.map +0 -1
  586. package/dist/scripts/generate_lp_chart.d.ts.map +0 -1
  587. package/dist/scripts/generate_lp_chart.js.map +0 -1
  588. package/dist/scripts/generate_mainnet_corpus_report.d.ts.map +0 -1
  589. package/dist/scripts/generate_mainnet_corpus_report.js.map +0 -1
  590. package/dist/scripts/native_release_gates.d.ts.map +0 -1
  591. package/dist/scripts/native_release_gates.js.map +0 -1
  592. package/dist/scripts/print_grid.d.ts.map +0 -1
  593. package/dist/scripts/print_grid.js.map +0 -1
  594. package/dist/scripts/run-tests.d.ts.map +0 -1
  595. package/dist/scripts/run-tests.js.map +0 -1
  596. package/dist/scripts/runner.d.ts.map +0 -1
  597. package/dist/scripts/runner.js.map +0 -1
  598. package/dist/scripts/sync-version.d.ts.map +0 -1
  599. package/dist/scripts/sync-version.js.map +0 -1
  600. package/dist/scripts/test-credit-renewal.d.ts.map +0 -1
  601. package/dist/scripts/test-credit-renewal.js.map +0 -1
  602. package/dist/scripts/tv.d.ts.map +0 -1
  603. package/dist/scripts/tv.js.map +0 -1
  604. package/dist/scripts/update.d.ts.map +0 -1
  605. package/dist/scripts/update.js.map +0 -1
  606. package/dist/scripts/update_dist_freshness.d.ts.map +0 -1
  607. package/dist/scripts/update_dist_freshness.js.map +0 -1
  608. package/dist/scripts/validate_bots.d.ts.map +0 -1
  609. package/dist/scripts/validate_bots.js.map +0 -1
  610. package/dist/scripts/verify-browser-bundle.d.ts.map +0 -1
  611. package/dist/scripts/verify-browser-bundle.js.map +0 -1
  612. package/dist/unlock.d.ts.map +0 -1
  613. package/dist/unlock.js.map +0 -1
@@ -1,711 +0,0 @@
1
- 'use strict';
2
-
3
- const assert = require('assert');
4
- const path = require('path');
5
- const { runEsmMockStages, defineEsmMockAbs } = require('../../tests/helpers/esm_mocks');
6
-
7
- // Compiled ESM graphs cannot be mocked via require.cache; the helper installs
8
- // loader hooks (one child process per stage so fresh module instances load).
9
- function clearModule(_modulePath: string) {
10
- /* no-op under ESM hooks */
11
- }
12
-
13
- function registerMock(modulePath: string, exports: any) {
14
- defineEsmMockAbs(modulePath, Object.keys(exports), exports);
15
- }
16
-
17
- async function testClawBitsharesClientNativePathAndConnection() {
18
- console.log(' bitshares_client native path and connection...');
19
-
20
- const clawBitsharesPath = require.resolve('../modules/bitshares_client');
21
- clearModule(clawBitsharesPath);
22
-
23
- const clawBitshares = require('../modules/bitshares_client');
24
-
25
- assert.strictEqual(clawBitshares.isConnected(), false, 'initial state should not be connected');
26
- assert.strictEqual(typeof clawBitshares.BitShares, 'object', 'BitShares proxy should exist');
27
- assert.strictEqual(typeof clawBitshares.createAccountClient, 'function');
28
- await assert.rejects(() => clawBitshares.createAccountClient('', 'wif'), /accountName is required/);
29
- await assert.rejects(() => clawBitshares.createAccountClient('alice', ''), /privateKey is required/);
30
-
31
- console.log(' PASS');
32
- }
33
-
34
- async function testClawBitsharesClientWaitForConnectedTriggersNativeConnect() {
35
- console.log(' bitshares_client waitForConnected lazy connect...');
36
-
37
- const nativePath = require.resolve('../../modules/bitshares-native');
38
- let connectCalls = 0;
39
- let nodes: any[] = [];
40
- let connected = false;
41
-
42
- registerMock(nativePath, {
43
- createChainClient: ({ onStatusChange }: any) => ({
44
- connect: async () => {
45
- connectCalls += 1;
46
- connected = true;
47
- if (typeof onStatusChange === 'function') onStatusChange('connected');
48
- },
49
- disconnect: () => {
50
- connected = false;
51
- if (typeof onStatusChange === 'function') onStatusChange('closed');
52
- },
53
- getStatus: () => connected ? 'connected' : 'closed',
54
- setNodes: (nextNodes: any[]) => { nodes = Array.isArray(nextNodes) ? nextNodes.slice() : []; },
55
- getNodes: () => nodes.slice(),
56
- getCoreAsset: () => '1.3.0',
57
- db: {},
58
- history: {},
59
- }),
60
- createSigningClient: () => ({ client: { initPromise: Promise.resolve(), newTx() {} } }),
61
- createSubscriptionManager: () => ({
62
- onReconnect: async () => {},
63
- subscribe: async () => () => {},
64
- unsubscribe: async () => {},
65
- }),
66
- });
67
-
68
- const clawBitsharesPath = require.resolve('../modules/bitshares_client');
69
- clearModule(clawBitsharesPath);
70
- const clawBitshares = require('../modules/bitshares_client');
71
-
72
- await clawBitshares.waitForConnected(200);
73
-
74
- assert.strictEqual(connectCalls, 1, 'waitForConnected should initiate a native connect when idle');
75
- assert.strictEqual(clawBitshares.isConnected(), true, 'client should report connected after lazy connect');
76
- assert.ok(Array.isArray(clawBitshares.BitShares.node) && clawBitshares.BitShares.node.length > 0, 'default node list should be populated');
77
-
78
- console.log(' PASS');
79
- }
80
-
81
- function testClawRootExportsAvoidSilentCollisions() {
82
- console.log(' claw root exports...');
83
-
84
- const clawIndexPath = require.resolve('..');
85
- clearModule(clawIndexPath);
86
-
87
- const claw = require('..').default;
88
- const hermesManifest = claw.describeClawBridge({ runtimeName: 'hermes' });
89
- const openclawManifest = claw.describeClawBridge({ runtimeName: 'openclaw' });
90
- const openfangManifest = claw.describeClawBridge({ runtimeName: 'openfang' });
91
- const nullManifest = claw.describeClawBridge({ runtimeName: 'nullclaw' });
92
- const manifest = claw.describeClawBridge({ runtimeName: 'zeroclaw' });
93
-
94
- assert.strictEqual(typeof claw.resolveSigningAccountName, 'function');
95
- assert.strictEqual(claw.resolveSigningAccountName({ accountName: 'alice' }), 'alice');
96
- assert.strictEqual(typeof claw.resolveAccountName, 'function');
97
- assert.strictEqual(claw.resolveAccountName('alice') instanceof Promise, true);
98
- assert.strictEqual(hermesManifest.options.runtimeName, 'hermes');
99
- assert.strictEqual(hermesManifest.compatibility.name, 'Hermes');
100
- assert.strictEqual(openclawManifest.options.runtimeName, 'openclaw');
101
- assert.strictEqual(openclawManifest.compatibility.name, 'OpenClaw');
102
- assert.strictEqual(openclawManifest.commandExamples.some((example: any) => example.includes('scripts/claw_bridge.js')), true);
103
- assert.strictEqual(openfangManifest.options.runtimeName, 'openfang');
104
- assert.strictEqual(openfangManifest.commandExamples.some((example: any) => example.includes('claw_bridge.js')), true);
105
- assert.strictEqual(nullManifest.options.runtimeName, 'nullclaw');
106
- assert.strictEqual(nullManifest.commandExamples.some((example: any) => example.includes('claw_bridge.js')), true);
107
- assert.strictEqual(manifest.options.runtimeName, 'zeroclaw');
108
- assert.strictEqual(manifest.commandExamples.some((example: any) => example.includes('claw_bridge.js')), true);
109
-
110
- console.log(' PASS');
111
- }
112
-
113
- function testRuntimeSkillTomlQuotesPayloadPlaceholders() {
114
- console.log(' runtime skill toml quoting...');
115
-
116
- const { buildRuntimeSkillToml } = require('../modules/claw_skill_md');
117
-
118
- const toml = buildRuntimeSkillToml(
119
- { runtime: 'zeroclaw', displayName: 'ZeroClaw' },
120
- '/tmp/repo root',
121
- '/tmp/profile root'
122
- );
123
-
124
- assert(
125
- toml.includes("'--payload' '{{payload_json}}'"),
126
- 'generated skill commands must shell-quote payload placeholders'
127
- );
128
- assert(
129
- toml.includes("'--profile-root' '/tmp/profile root'"),
130
- 'generated skill commands must shell-quote profile roots with spaces'
131
- );
132
-
133
- console.log(' PASS');
134
- }
135
-
136
- function testLiquidityPoolWrapperInjectsSharedBitSharesClient() {
137
- console.log(' liquidity_pools shared client injection...');
138
-
139
- const bitsharesPath = require.resolve('../modules/bitshares_client');
140
- const dexbotBridgePath = require.resolve('../modules/dexbot_bridge');
141
- const liquidityPoolsPath = require.resolve('../modules/liquidity_pools');
142
- const sharedBitShares = { name: 'shared-bitshares-client' };
143
- let capturedPoolArgs = null;
144
- let capturedPriceArgs = null;
145
-
146
- registerMock(bitsharesPath, { BitShares: sharedBitShares } as any);
147
- registerMock(dexbotBridgePath, {
148
- getDexbot2Root: () => '/tmp',
149
- loadDexbotOrderSystemUtils: () => ({
150
- cloneMap: (value: any) => value,
151
- deepFreeze: (value: any) => value,
152
- derivePoolPrice: (...args: any[]) => {
153
- capturedPoolArgs = args;
154
- return 'pool-price';
155
- },
156
- derivePrice: (...args: any[]) => {
157
- capturedPriceArgs = args;
158
- return 'derived-price';
159
- },
160
- loadAmaCenterPrice: () => null,
161
- lookupAsset: () => null
162
- }),
163
- requireDexbot2Module: () => null
164
- } as any);
165
- clearModule(liquidityPoolsPath);
166
-
167
- const liquidityPools = require('../modules/liquidity_pools');
168
-
169
- assert.strictEqual(liquidityPools.derivePoolPrice('HONEST.USD', 'BTS'), 'pool-price');
170
- assert.deepStrictEqual(
171
- capturedPoolArgs,
172
- [sharedBitShares, 'HONEST.USD', 'BTS'],
173
- 'derivePoolPrice wrapper must inject the shared BitShares client'
174
- );
175
-
176
- assert.strictEqual(liquidityPools.derivePrice('HONEST.USD', 'BTS', 'pool'), 'derived-price');
177
- assert.deepStrictEqual(
178
- capturedPriceArgs,
179
- [sharedBitShares, 'HONEST.USD', 'BTS', 'pool'],
180
- 'derivePrice wrapper must inject the shared BitShares client'
181
- );
182
-
183
- console.log(' PASS');
184
- }
185
-
186
- async function testDecisionLoopReusesAnalyzerStateForDuplicateMarkets() {
187
- console.log(' decision_loop analyzer state reuse...');
188
-
189
- const decisionLoopPath = require.resolve('../modules/decision_loop');
190
- const discoveryPath = require.resolve('../modules/position_discovery');
191
- const healthPath = require.resolve('../modules/position_health');
192
- const feedPriceSourcePath = require.resolve('../modules/feed_price_source');
193
- const trendAnalyzerPath = require.resolve('../../market_adapter/core/signals/kalman_trend_analyzer');
194
- let trendFetchCount = 0;
195
-
196
- class FakeTrendAnalyzer {
197
- [key: string]: any;
198
- update(marketPrice: number, feedPrice: number) {
199
- this.analysis = {
200
- confidence: 77,
201
- isReady: true,
202
- marketPrice,
203
- premium: {
204
- percent: ((marketPrice - feedPrice) / feedPrice) * 100
205
- },
206
- trend: 'DOWN'
207
- };
208
- return this.analysis;
209
- }
210
-
211
- getAnalysis() {
212
- return this.analysis || {
213
- confidence: 0,
214
- isReady: false,
215
- premium: {
216
- percent: null
217
- },
218
- trend: 'NEUTRAL'
219
- };
220
- }
221
- }
222
-
223
- registerMock(discoveryPath, {
224
- discoverPositions: async () => ([
225
- { id: 'pos-1', market: 'HONEST.USD/BTS', mpaSymbol: 'HONEST.USD', onChain: { debtAmount: 5 } },
226
- { id: 'pos-2', market: 'HONEST.USD/BTS', mpaSymbol: 'HONEST.USD', onChain: { debtAmount: 3 } }
227
- ])
228
- } as any);
229
- registerMock(healthPath, {
230
- assessPosition: (position: any, trendSignal: any) => ({
231
- actions: [],
232
- positionId: position.id,
233
- trend: trendSignal
234
- })
235
- } as any);
236
- registerMock(feedPriceSourcePath, {
237
- fetchTrendInput: async () => {
238
- trendFetchCount += 1;
239
- return {
240
- feedPrice: 100,
241
- marketPrice: 95,
242
- premium: -5
243
- };
244
- }
245
- } as any);
246
- registerMock(trendAnalyzerPath, { KalmanTrendAnalyzer: FakeTrendAnalyzer } as any);
247
- clearModule(decisionLoopPath);
248
-
249
- const { evaluate, resetAnalyzers } = require('../modules/decision_loop');
250
- const result = await evaluate('alice');
251
-
252
- assert.strictEqual(trendFetchCount, 1, 'trend input should be fetched once per market');
253
- assert.strictEqual(result.positionCount, 2, 'both positions should be evaluated');
254
- assert.strictEqual(result.positions[0].trend.trend, 'DOWN');
255
- assert.strictEqual(result.positions[1].trend.trend, 'DOWN');
256
- assert.strictEqual(result.positions[1].trend.premium, -5, 'reused trend signal should come from cached analyzer state');
257
-
258
- resetAnalyzers();
259
-
260
- console.log(' PASS');
261
- }
262
-
263
- async function testDecisionLoopReplacesAnalyzerOnConfigChange() {
264
- console.log(' decision_loop analyzer config replacement...');
265
-
266
- const decisionLoopPath = require.resolve('../modules/decision_loop');
267
- const discoveryPath = require.resolve('../modules/position_discovery');
268
- const healthPath = require.resolve('../modules/position_health');
269
- const feedPriceSourcePath = require.resolve('../modules/feed_price_source');
270
- const trendAnalyzerPath = require.resolve('../../market_adapter/core/signals/kalman_trend_analyzer');
271
- let constructionCount = 0;
272
-
273
- class ConfigTrackingAnalyzer {
274
- [key: string]: any;
275
- constructor(config: any) {
276
- constructionCount += 1;
277
- this.config = config;
278
- }
279
-
280
- update(marketPrice: number, feedPrice: number) {
281
- return { confidence: 50, isReady: true, trend: 'NEUTRAL' };
282
- }
283
-
284
- getAnalysis() {
285
- return { confidence: 50, isReady: true, premium: { percent: 0 }, trend: 'NEUTRAL' };
286
- }
287
- }
288
-
289
- registerMock(discoveryPath, {
290
- discoverPositions: async () => ([
291
- { id: 'pos-1', market: 'HONEST.USD/BTS', mpaSymbol: 'HONEST.USD', onChain: { debtAmount: 5 } }
292
- ])
293
- } as any);
294
- registerMock(healthPath, {
295
- assessPosition: (position: any, trendSignal: any) => ({ actions: [], positionId: position.id, trend: trendSignal })
296
- } as any);
297
- registerMock(feedPriceSourcePath, {
298
- fetchTrendInput: async () => ({ feedPrice: 100, marketPrice: 95, premium: -5 })
299
- } as any);
300
- registerMock(trendAnalyzerPath, { KalmanTrendAnalyzer: ConfigTrackingAnalyzer } as any);
301
- clearModule(decisionLoopPath);
302
-
303
- const { evaluate, resetAnalyzers } = require('../modules/decision_loop');
304
-
305
- await evaluate('alice', { analyzerConfig: { kamaPeriod: 10 } });
306
- assert.strictEqual(constructionCount, 1, 'first evaluate should create one analyzer');
307
-
308
- await evaluate('alice', { analyzerConfig: { kamaPeriod: 10 } });
309
- assert.strictEqual(constructionCount, 1, 'same config should reuse the cached analyzer');
310
-
311
- await evaluate('alice', { analyzerConfig: { kamaPeriod: 20 } });
312
- assert.strictEqual(constructionCount, 2, 'changed config should replace the analyzer');
313
-
314
- resetAnalyzers();
315
-
316
- console.log(' PASS');
317
- }
318
-
319
- async function testPositionManagerEntryExposesSellPriceInBts() {
320
- console.log(' position_manager entry sellPriceInBts...');
321
-
322
- const positionManagerPath = require.resolve('../modules/position_manager');
323
- const mpaUtilsPath = require.resolve('../modules/mpa_utils');
324
-
325
- // ESM hooks turn mock keys into synthetic named re-exports, so every name
326
- // position_manager statically imports from mpa_utils must exist here. The
327
- // two helpers beside requireBtsBackedMpa are minimal inline replicas of the
328
- // real ones (requiring the real module would bypass the mock and poison
329
- // the module cache with the real instance).
330
- const blockchainToFloat = (amount: any, precision: any) => Number(amount) / (10 ** precision);
331
- const computeBtsPerMpa = (settlementPrice: any, mpaAsset: any, backingAsset: any) => {
332
- const base = settlementPrice?.base;
333
- const quote = settlementPrice?.quote;
334
- if (!base || !quote) return null;
335
- const baseAmount = blockchainToFloat(base.amount, base.asset_id === mpaAsset.id ? mpaAsset.precision : backingAsset.precision);
336
- const quoteAmount = blockchainToFloat(quote.amount, quote.asset_id === mpaAsset.id ? mpaAsset.precision : backingAsset.precision);
337
- if (!baseAmount || !quoteAmount) return null;
338
- if (base.asset_id === backingAsset.id && quote.asset_id === mpaAsset.id) return baseAmount / quoteAmount;
339
- if (base.asset_id === mpaAsset.id && quote.asset_id === backingAsset.id) return quoteAmount / baseAmount;
340
- return null;
341
- };
342
-
343
- registerMock(mpaUtilsPath, {
344
- computeCallOrderAmounts: (callOrder: any, mpaAsset: any, backingAsset: any, bitassetData: any) => {
345
- const debtAmount = blockchainToFloat(callOrder.debt, mpaAsset.precision);
346
- const collateralAmount = blockchainToFloat(callOrder.collateral, backingAsset.precision);
347
- const btsPerMpa = computeBtsPerMpa(bitassetData?.current_feed?.settlement_price, mpaAsset, backingAsset);
348
- const debtValueInBts = debtAmount && btsPerMpa ? debtAmount * btsPerMpa : 0;
349
- const collateralRatio = debtValueInBts > 0 ? collateralAmount / debtValueInBts : null;
350
- return {
351
- btsPerMpa,
352
- collateralAmount: collateralAmount || 0,
353
- collateralRatio,
354
- debtAmount: debtAmount || 0,
355
- debtValueInBts
356
- };
357
- },
358
- getBlockchainToFloat: () => blockchainToFloat,
359
- requireBtsBackedMpa: async (sym: string) => ({
360
- backingAsset: { id: '1.3.0', symbol: 'BTS', precision: 5 },
361
- mpaAsset: { id: `1.3.${sym.length}`, symbol: sym, precision: 5, bitasset_data_id: '2.4.1' }
362
- })
363
- } as any);
364
-
365
- clearModule(positionManagerPath);
366
- const { PositionManager } = require('../modules/position_manager');
367
-
368
- const savedState: any = {};
369
- const pm = new PositionManager({
370
- loadState: async () => savedState.data || { positions: [] },
371
- saveState: async (state: any) => { savedState.data = state; }
372
- });
373
-
374
- const position = await pm.createShortPosition({
375
- accountName: 'alice',
376
- mpaAsset: 'HONEST.USD',
377
- debtAmount: 10,
378
- collateralAmount: 25000,
379
- sellPriceInBts: 1000
380
- });
381
-
382
- assert.strictEqual(position.entry.sellPriceInBts, 1000, 'entry must expose sellPriceInBts for openShort');
383
- assert.strictEqual(position.entry.priceInBts, 1000, 'entry must also have generic priceInBts from createOrderTracking');
384
-
385
- console.log(' PASS');
386
- }
387
-
388
- function testClawBridgeRespectsRuntimeNameOption() {
389
- console.log(' claw_bridge runtime name option...');
390
-
391
- const clawBridgePath = require.resolve('../modules/claw_bridge');
392
- const clawInfraPath = require.resolve('../modules/claw_infra');
393
-
394
- let capturedOptions: any = null;
395
- registerMock(clawInfraPath, {
396
- createClawInfrastructure: (opts: any) => {
397
- capturedOptions = opts;
398
- return {
399
- runtime: { name: opts.runtime?.name || 'claw-bridge' },
400
- profiles: {},
401
- market: {}
402
- };
403
- }
404
- } as any);
405
-
406
- clearModule(clawBridgePath);
407
- const { createClawBridge } = require('../modules/claw_bridge');
408
-
409
- createClawBridge({ runtimeName: 'openclaw' });
410
- assert.strictEqual(capturedOptions.runtime.name, 'openclaw', 'runtimeName option should propagate to runtime.name');
411
-
412
- createClawBridge({ runtime: { name: 'picoclaw' } });
413
- assert.strictEqual(capturedOptions.runtime.name, 'picoclaw', 'runtime.name should still work directly');
414
-
415
- createClawBridge({});
416
- assert.strictEqual(capturedOptions.runtime.name, 'claw-bridge', 'should fall back to claw-bridge');
417
-
418
- console.log(' PASS');
419
- }
420
-
421
- function testClawBridgeScriptManifestUsesRuntimeSpecificDescriptors() {
422
- console.log(' claw_bridge script manifest descriptors...');
423
-
424
- const scriptPath = require.resolve('../scripts/claw_bridge');
425
- clearModule(scriptPath);
426
-
427
- const { describeRuntimeManifest } = require('../scripts/claw_bridge');
428
-
429
- const hermesManifest = describeRuntimeManifest('hermes', {});
430
- assert.strictEqual(hermesManifest.compatibility.name, 'Hermes');
431
- assert.strictEqual(hermesManifest.commandExamples.some((example: any) => example.includes('scripts/claw_bridge.js')), true);
432
-
433
- const openclawManifest = describeRuntimeManifest('openclaw', {});
434
- assert.strictEqual(openclawManifest.compatibility.name, 'OpenClaw');
435
- assert.strictEqual(openclawManifest.commandExamples.some((example: any) => example.includes('scripts/claw_bridge.js')), true);
436
-
437
- const openfangManifest = describeRuntimeManifest('openfang', {});
438
- assert.strictEqual(openfangManifest.compatibility.name, 'OpenFang');
439
- assert.strictEqual(openfangManifest.commandExamples.some((example: any) => example.includes('claw_bridge.js')), true);
440
-
441
- const nanoclawManifest = describeRuntimeManifest('nanoclaw', {});
442
- assert.strictEqual(nanoclawManifest.compatibility.name, 'NanoClaw');
443
- assert.strictEqual(nanoclawManifest.commandExamples.some((example: any) => example.includes('claw_bridge.js')), true);
444
-
445
- const nullclawManifest = describeRuntimeManifest('nullclaw', {});
446
- assert.strictEqual(nullclawManifest.compatibility.name, 'NullClaw');
447
- assert.strictEqual(nullclawManifest.commandExamples.some((example: any) => example.includes('claw_bridge.js')), true);
448
-
449
- const zeroclawManifest = describeRuntimeManifest('zeroclaw', {});
450
- assert.strictEqual(zeroclawManifest.compatibility.name, 'ZeroClaw');
451
- assert.strictEqual(zeroclawManifest.commandExamples.some((example: any) => example.includes('claw_bridge.js')), true);
452
-
453
- const genericManifest = describeRuntimeManifest(null, {});
454
- assert.strictEqual(genericManifest.compatibility.name, 'Claw');
455
- assert.strictEqual(genericManifest.commandExamples.some((example: any) => example.includes('scripts/claw_bridge.js')), true);
456
-
457
- const payloadSelectedManifest = describeRuntimeManifest(null, { runtimeName: 'openfang' });
458
- assert.strictEqual(payloadSelectedManifest.compatibility.name, 'OpenFang');
459
- assert.strictEqual(payloadSelectedManifest.commandExamples.some((example: any) => example.includes('claw_bridge.js')), true);
460
-
461
- const normalizedPayloadManifest = describeRuntimeManifest(null, { runtimeName: ' OpenFang ' });
462
- assert.strictEqual(normalizedPayloadManifest.compatibility.name, 'OpenFang');
463
- assert.strictEqual(normalizedPayloadManifest.commandExamples.some((example: any) => example.includes('claw_bridge.js')), true);
464
-
465
- const hermesPayloadManifest = describeRuntimeManifest(null, { runtimeName: ' Hermes ' });
466
- assert.strictEqual(hermesPayloadManifest.compatibility.name, 'Hermes');
467
- assert.strictEqual(hermesPayloadManifest.commandExamples.some((example: any) => example.includes('scripts/claw_bridge.js')), true);
468
-
469
- console.log(' PASS');
470
- }
471
-
472
- async function testRuntimeCommandManifestUsesRuntimeSpecificDescriptors() {
473
- console.log(' runClawCommand manifest descriptors...');
474
-
475
- const { runClawCommand } = require('../modules/claw_bridge');
476
-
477
- const hermesManifest = await runClawCommand('manifest', { runtimeName: 'hermes' });
478
- assert.strictEqual(hermesManifest.compatibility.name, 'Hermes');
479
- assert.strictEqual(hermesManifest.options.runtimeName, 'hermes');
480
- assert.ok(hermesManifest.compatibility.trustModel.includes('Hermes'));
481
-
482
- const openfangManifest = await runClawCommand('manifest', { runtimeName: 'openfang' });
483
- assert.strictEqual(openfangManifest.compatibility.name, 'OpenFang');
484
- assert.strictEqual(openfangManifest.commandExamples.some((example: any) => example.includes('claw_bridge.js')), true);
485
-
486
- const nanoclawManifest = await runClawCommand('manifest', { runtimeName: 'nanoclaw' });
487
- assert.strictEqual(nanoclawManifest.compatibility.name, 'NanoClaw');
488
- assert.strictEqual(nanoclawManifest.commandExamples.some((example: any) => example.includes('claw_bridge.js')), true);
489
-
490
- const nullclawManifest = await runClawCommand('manifest', { runtimeName: 'nullclaw' });
491
- assert.strictEqual(nullclawManifest.compatibility.name, 'NullClaw');
492
- assert.strictEqual(nullclawManifest.commandExamples.some((example: any) => example.includes('claw_bridge.js')), true);
493
-
494
- const zeroclawManifest = await runClawCommand('manifest', { runtimeName: 'zeroclaw' });
495
- assert.strictEqual(zeroclawManifest.compatibility.name, 'ZeroClaw');
496
- assert.strictEqual(zeroclawManifest.commandExamples.some((example: any) => example.includes('claw_bridge.js')), true);
497
-
498
- console.log(' PASS');
499
- }
500
-
501
- function testClawCommandInjectsRuntimeNameViaOption() {
502
- console.log(' runClawCommand runtime name injection...');
503
-
504
- const clawBridgePath = require.resolve('../modules/claw_bridge');
505
- const clawInfraPath = require.resolve('../modules/claw_infra');
506
-
507
- let capturedOptions: any = null;
508
- registerMock(clawInfraPath, {
509
- createClawInfrastructure: (opts: any) => {
510
- capturedOptions = opts;
511
- return {
512
- runtime: { name: opts.runtime?.name || 'claw-bridge', accountName: null },
513
- profiles: {},
514
- market: {}
515
- };
516
- }
517
- } as any);
518
-
519
- clearModule(clawBridgePath);
520
- const { runClawCommand } = require('../modules/claw_bridge');
521
-
522
- runClawCommand('runtime', { runtimeName: 'openfang' });
523
- assert.strictEqual(capturedOptions.runtime.name, 'openfang', 'runtimeName option should propagate to runtime.name');
524
-
525
- console.log(' PASS');
526
- }
527
-
528
- function testAccountOrdersBotKeyFallsBackToAssetIds() {
529
- console.log(' account_orders botKey fallback...');
530
-
531
- const { createBotKey } = require('../../modules/account_orders');
532
-
533
- const idOnlyBot = { assetAId: '1.3.1', assetBId: '1.3.0' };
534
- const key = createBotKey(idOnlyBot, 0);
535
- assert.ok(key.includes('1-3-1'), `account_orders botKey should derive from assetAId, got: ${key}`);
536
- assert.ok(key.includes('1-3-0'), `account_orders botKey should include assetBId, got: ${key}`);
537
-
538
- // Symbol fields still take precedence
539
- const symBot = { assetA: 'IOB.XRP', assetB: 'BTS', assetAId: '1.3.1', assetBId: '1.3.0' };
540
- const symKey = createBotKey(symBot, 0);
541
- assert.ok(symKey.includes('iob'), `symbol-based key should take precedence, got: ${symKey}`);
542
- assert.ok(!symKey.includes('1-3-1'), `symbol key should not include asset ID, got: ${symKey}`);
543
-
544
- // Aligns with claw's createBotKey
545
- const clawProfiles = require('../modules/dexbot_profiles');
546
- const clawKey = clawProfiles.createBotKey(idOnlyBot, 0);
547
- assert.strictEqual(key, clawKey, `account_orders and claw botKey must match for same input, got: ${key} vs ${clawKey}`);
548
-
549
- console.log(' PASS');
550
- }
551
-
552
- function testBuildQueryScopesAnyPoolByReceivedAsset() {
553
- console.log(' kibana query pool scoping...');
554
-
555
- const { buildDirectionalDocumentQuery } = require('../../market_adapter/core/kibana_candles');
556
- const fieldMap = {
557
- soldAssetField: 'operation_history.op_object.amount_to_sell.asset_id.keyword',
558
- receivedAssetField: 'operation_history.op_object.min_to_receive.asset_id.keyword',
559
- poolField: 'operation_history.op_object.pool.keyword'
560
- };
561
-
562
- // With poolId: no received asset filter needed
563
- const poolScoped = buildDirectionalDocumentQuery({
564
- opType: 63,
565
- ...fieldMap,
566
- soldAssetId: '1.3.0',
567
- receivedAssetId: null,
568
- lookbackHours: 100,
569
- poolId: '1.19.133',
570
- size: 10000
571
- });
572
- const poolFilters = poolScoped.query.bool.filter;
573
- assert.ok(
574
- poolFilters.some((f: any) => f.term?.['operation_history.op_object.pool.keyword'] === '1.19.133'),
575
- 'pool-scoped query should filter by pool'
576
- );
577
- assert.ok(
578
- !poolFilters.some((f: any) => f.term?.['operation_history.op_object.min_to_receive.asset_id.keyword']),
579
- 'pool-scoped query should not add receivedAssetId filter'
580
- );
581
-
582
- // Without poolId but with receivedAssetId: must scope by counterpart
583
- const pairScoped = buildDirectionalDocumentQuery({
584
- opType: 63,
585
- ...fieldMap,
586
- soldAssetId: '1.3.0',
587
- receivedAssetId: '1.3.1',
588
- lookbackHours: 100,
589
- poolId: null,
590
- size: 10000
591
- });
592
- const pairFilters = pairScoped.query.bool.filter;
593
- assert.ok(
594
- !pairFilters.some((f: any) => f.term?.['operation_history.op_object.pool.keyword']),
595
- 'any-pool query should not have pool filter'
596
- );
597
- assert.ok(
598
- pairFilters.some((f: any) => f.term?.['operation_history.op_object.min_to_receive.asset_id.keyword'] === '1.3.1'),
599
- 'any-pool query should filter by received asset ID'
600
- );
601
-
602
- console.log(' PASS');
603
- }
604
-
605
- function testClawDefaultDataPathsStayInsideClawFolder() {
606
- console.log(' claw default data paths...');
607
-
608
- // modules/paths.ts resolveClawDirs keeps claw state inside the repo's
609
- // claw/ folder regardless of where the code runs from (dist or source),
610
- // so anchor expectations to that folder rather than to this test file.
611
- const clawDataDir = path.join(__dirname, '..', '..', '..', 'claw', 'data');
612
- const clawStateDir = path.join(clawDataDir, 'state');
613
- const clawInfra = require('../modules/claw_infra');
614
- const { DEFAULT_STATE_PATH } = require('../modules/position_manager');
615
- const { DEFAULT_HEALTH_PATH } = require('../modules/position_manager_watch');
616
-
617
- assert.strictEqual(DEFAULT_STATE_PATH, path.join(clawDataDir, 'positions.json'));
618
- assert.strictEqual(DEFAULT_HEALTH_PATH, path.join(clawDataDir, 'watcher-health.json'));
619
-
620
- const runtime = clawInfra.createRuntimeContext();
621
- assert.strictEqual(runtime.dataDir, clawDataDir);
622
- assert.strictEqual(runtime.stateDir, clawStateDir);
623
-
624
- const stateStore = clawInfra.createStateStore();
625
- assert.strictEqual(stateStore.filePath, path.join(clawStateDir, 'claw-state.json'));
626
-
627
- console.log(' PASS');
628
- }
629
-
630
- runEsmMockStages(
631
- [
632
- 'native-path',
633
- 'wait-connected',
634
- 'root-exports',
635
- 'skill-toml',
636
- 'liquidity-pools',
637
- 'analyzer-reuse',
638
- 'analyzer-replace',
639
- 'position-manager',
640
- 'bridge-runtime-name',
641
- 'script-manifest',
642
- 'runtime-manifest',
643
- 'command-runtime-name',
644
- 'account-orders-bot-key',
645
- 'kibana-query-scopes',
646
- 'default-data-paths'
647
- ],
648
- async (stage: string) => {
649
- if (stage === 'native-path') {
650
- await testClawBitsharesClientNativePathAndConnection();
651
- return;
652
- }
653
- if (stage === 'wait-connected') {
654
- await testClawBitsharesClientWaitForConnectedTriggersNativeConnect();
655
- return;
656
- }
657
- if (stage === 'root-exports') {
658
- testClawRootExportsAvoidSilentCollisions();
659
- return;
660
- }
661
- if (stage === 'skill-toml') {
662
- testRuntimeSkillTomlQuotesPayloadPlaceholders();
663
- return;
664
- }
665
- if (stage === 'liquidity-pools') {
666
- testLiquidityPoolWrapperInjectsSharedBitSharesClient();
667
- return;
668
- }
669
- if (stage === 'analyzer-reuse') {
670
- await testDecisionLoopReusesAnalyzerStateForDuplicateMarkets();
671
- return;
672
- }
673
- if (stage === 'analyzer-replace') {
674
- await testDecisionLoopReplacesAnalyzerOnConfigChange();
675
- return;
676
- }
677
- if (stage === 'position-manager') {
678
- await testPositionManagerEntryExposesSellPriceInBts();
679
- return;
680
- }
681
- if (stage === 'bridge-runtime-name') {
682
- testClawBridgeRespectsRuntimeNameOption();
683
- return;
684
- }
685
- if (stage === 'script-manifest') {
686
- testClawBridgeScriptManifestUsesRuntimeSpecificDescriptors();
687
- return;
688
- }
689
- if (stage === 'runtime-manifest') {
690
- await testRuntimeCommandManifestUsesRuntimeSpecificDescriptors();
691
- return;
692
- }
693
- if (stage === 'command-runtime-name') {
694
- testClawCommandInjectsRuntimeNameViaOption();
695
- return;
696
- }
697
- if (stage === 'account-orders-bot-key') {
698
- testAccountOrdersBotKeyFallsBackToAssetIds();
699
- return;
700
- }
701
- if (stage === 'kibana-query-scopes') {
702
- testBuildQueryScopesAnyPoolByReceivedAsset();
703
- return;
704
- }
705
- if (stage === 'default-data-paths') {
706
- testClawDefaultDataPathsStayInsideClawFolder();
707
- return;
708
- }
709
- throw new Error(`Unknown stage: ${stage}`);
710
- }
711
- );