dexbot 1.1.10

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 (807) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +287 -0
  3. package/claw/README.md +513 -0
  4. package/claw/scripts/memu_runner.py +385 -0
  5. package/claw/skills/bitshares-guide/SKILL.md +14 -0
  6. package/claw/skills/bitshares-guide/references/example-skill-shells.md +18 -0
  7. package/claw/skills/bitshares-guide/references/presentation-patterns.md +19 -0
  8. package/claw/skills/bitshares-guide/references/scope-guardrails.md +9 -0
  9. package/claw/skills/launcher-ops/SKILL.md +18 -0
  10. package/claw/skills/launcher-ops/references/launcher-workflow.md +23 -0
  11. package/claw/skills/margin-trading/SKILL.md +23 -0
  12. package/claw/skills/margin-trading/references/honest-asset-list.md +74 -0
  13. package/claw/skills/margin-trading/references/honest-assets.md +44 -0
  14. package/claw/skills/margin-trading/references/position-management.md +203 -0
  15. package/claw/skills/margin-trading/references/trading-concepts.md +80 -0
  16. package/claw/skills/memu-memory/SKILL.md +218 -0
  17. package/claw/skills/shared/references/js-automation-overview.md +24 -0
  18. package/claw/skills/shared/references/safety-and-staleness.md +11 -0
  19. package/claw/skills/shared/references/skill-boundaries.md +17 -0
  20. package/claw/skills/trend-detection/SKILL.md +33 -0
  21. package/claw/skills/trend-detection/agents/openai.yaml +3 -0
  22. package/claw/skills/trend-detection/references/service.md +45 -0
  23. package/dist/analysis/ama_fitting/analyze_ama_price_changes.d.ts +3 -0
  24. package/dist/analysis/ama_fitting/analyze_ama_price_changes.d.ts.map +1 -0
  25. package/dist/analysis/ama_fitting/analyze_ama_price_changes.js +149 -0
  26. package/dist/analysis/ama_fitting/analyze_ama_price_changes.js.map +1 -0
  27. package/dist/analysis/ama_fitting/analyze_lambda_vs_slow.d.ts +3 -0
  28. package/dist/analysis/ama_fitting/analyze_lambda_vs_slow.d.ts.map +1 -0
  29. package/dist/analysis/ama_fitting/analyze_lambda_vs_slow.js +387 -0
  30. package/dist/analysis/ama_fitting/analyze_lambda_vs_slow.js.map +1 -0
  31. package/dist/analysis/ama_fitting/calibrate_convergence_er.d.ts +3 -0
  32. package/dist/analysis/ama_fitting/calibrate_convergence_er.d.ts.map +1 -0
  33. package/dist/analysis/ama_fitting/calibrate_convergence_er.js +200 -0
  34. package/dist/analysis/ama_fitting/calibrate_convergence_er.js.map +1 -0
  35. package/dist/analysis/ama_fitting/fetch_lp_candles.d.ts +3 -0
  36. package/dist/analysis/ama_fitting/fetch_lp_candles.d.ts.map +1 -0
  37. package/dist/analysis/ama_fitting/fetch_lp_candles.js +212 -0
  38. package/dist/analysis/ama_fitting/fetch_lp_candles.js.map +1 -0
  39. package/dist/analysis/ama_fitting/generate_unified_comparison_chart.d.ts +31 -0
  40. package/dist/analysis/ama_fitting/generate_unified_comparison_chart.d.ts.map +1 -0
  41. package/dist/analysis/ama_fitting/generate_unified_comparison_chart.js +249 -0
  42. package/dist/analysis/ama_fitting/generate_unified_comparison_chart.js.map +1 -0
  43. package/dist/analysis/ama_fitting/optimizer_high_resolution.d.ts +2 -0
  44. package/dist/analysis/ama_fitting/optimizer_high_resolution.d.ts.map +1 -0
  45. package/dist/analysis/ama_fitting/optimizer_high_resolution.js +782 -0
  46. package/dist/analysis/ama_fitting/optimizer_high_resolution.js.map +1 -0
  47. package/dist/analysis/analyze_derivatives.d.ts +95 -0
  48. package/dist/analysis/analyze_derivatives.d.ts.map +1 -0
  49. package/dist/analysis/analyze_derivatives.js +295 -0
  50. package/dist/analysis/analyze_derivatives.js.map +1 -0
  51. package/dist/analysis/analyze_dynamic_weight.d.ts +14 -0
  52. package/dist/analysis/analyze_dynamic_weight.d.ts.map +1 -0
  53. package/dist/analysis/analyze_dynamic_weight.js +208 -0
  54. package/dist/analysis/analyze_dynamic_weight.js.map +1 -0
  55. package/dist/analysis/analyze_kalman.d.ts +13 -0
  56. package/dist/analysis/analyze_kalman.d.ts.map +1 -0
  57. package/dist/analysis/analyze_kalman.js +123 -0
  58. package/dist/analysis/analyze_kalman.js.map +1 -0
  59. package/dist/analysis/analyze_regime.d.ts +20 -0
  60. package/dist/analysis/analyze_regime.d.ts.map +1 -0
  61. package/dist/analysis/analyze_regime.js +139 -0
  62. package/dist/analysis/analyze_regime.js.map +1 -0
  63. package/dist/analysis/analyze_regime_windows.d.ts +19 -0
  64. package/dist/analysis/analyze_regime_windows.d.ts.map +1 -0
  65. package/dist/analysis/analyze_regime_windows.js +413 -0
  66. package/dist/analysis/analyze_regime_windows.js.map +1 -0
  67. package/dist/analysis/analyze_risk_profile.d.ts +3 -0
  68. package/dist/analysis/analyze_risk_profile.d.ts.map +1 -0
  69. package/dist/analysis/analyze_risk_profile.js +159 -0
  70. package/dist/analysis/analyze_risk_profile.js.map +1 -0
  71. package/dist/analysis/analyze_trade_heatmap.d.ts +3 -0
  72. package/dist/analysis/analyze_trade_heatmap.d.ts.map +1 -0
  73. package/dist/analysis/analyze_trade_heatmap.js +367 -0
  74. package/dist/analysis/analyze_trade_heatmap.js.map +1 -0
  75. package/dist/analysis/analyze_volatility.d.ts +22 -0
  76. package/dist/analysis/analyze_volatility.d.ts.map +1 -0
  77. package/dist/analysis/analyze_volatility.js +172 -0
  78. package/dist/analysis/analyze_volatility.js.map +1 -0
  79. package/dist/analysis/bot_fitting/backtest_ama_sweep.d.ts +99 -0
  80. package/dist/analysis/bot_fitting/backtest_ama_sweep.d.ts.map +1 -0
  81. package/dist/analysis/bot_fitting/backtest_ama_sweep.js +804 -0
  82. package/dist/analysis/bot_fitting/backtest_ama_sweep.js.map +1 -0
  83. package/dist/analysis/bot_fitting/backtest_bot_fitting.d.ts +2 -0
  84. package/dist/analysis/bot_fitting/backtest_bot_fitting.d.ts.map +1 -0
  85. package/dist/analysis/bot_fitting/backtest_bot_fitting.js +347 -0
  86. package/dist/analysis/bot_fitting/backtest_bot_fitting.js.map +1 -0
  87. package/dist/analysis/bot_fitting/shared_utils.d.ts +15 -0
  88. package/dist/analysis/bot_fitting/shared_utils.d.ts.map +1 -0
  89. package/dist/analysis/bot_fitting/shared_utils.js +48 -0
  90. package/dist/analysis/bot_fitting/shared_utils.js.map +1 -0
  91. package/dist/analysis/bot_key_utils.d.ts +16 -0
  92. package/dist/analysis/bot_key_utils.d.ts.map +1 -0
  93. package/dist/analysis/bot_key_utils.js +61 -0
  94. package/dist/analysis/bot_key_utils.js.map +1 -0
  95. package/dist/analysis/bot_usage/discover_bot_accounts.d.ts +3 -0
  96. package/dist/analysis/bot_usage/discover_bot_accounts.d.ts.map +1 -0
  97. package/dist/analysis/bot_usage/discover_bot_accounts.js +498 -0
  98. package/dist/analysis/bot_usage/discover_bot_accounts.js.map +1 -0
  99. package/dist/analysis/bot_usage/kibana_bot_queries.d.ts +546 -0
  100. package/dist/analysis/bot_usage/kibana_bot_queries.d.ts.map +1 -0
  101. package/dist/analysis/bot_usage/kibana_bot_queries.js +427 -0
  102. package/dist/analysis/bot_usage/kibana_bot_queries.js.map +1 -0
  103. package/dist/analysis/chart_utils.d.ts +13 -0
  104. package/dist/analysis/chart_utils.d.ts.map +1 -0
  105. package/dist/analysis/chart_utils.js +142 -0
  106. package/dist/analysis/chart_utils.js.map +1 -0
  107. package/dist/analysis/derivative_chart_generator.d.ts +18 -0
  108. package/dist/analysis/derivative_chart_generator.d.ts.map +1 -0
  109. package/dist/analysis/derivative_chart_generator.js +896 -0
  110. package/dist/analysis/derivative_chart_generator.js.map +1 -0
  111. package/dist/analysis/math_utils.d.ts +35 -0
  112. package/dist/analysis/math_utils.d.ts.map +1 -0
  113. package/dist/analysis/math_utils.js +121 -0
  114. package/dist/analysis/math_utils.js.map +1 -0
  115. package/dist/analysis/price_sources.d.ts +34 -0
  116. package/dist/analysis/price_sources.d.ts.map +1 -0
  117. package/dist/analysis/price_sources.js +103 -0
  118. package/dist/analysis/price_sources.js.map +1 -0
  119. package/dist/analysis/trade_profitability.d.ts +115 -0
  120. package/dist/analysis/trade_profitability.d.ts.map +1 -0
  121. package/dist/analysis/trade_profitability.js +1247 -0
  122. package/dist/analysis/trade_profitability.js.map +1 -0
  123. package/dist/analysis/tradingview/analyze_tradingview.d.ts +38 -0
  124. package/dist/analysis/tradingview/analyze_tradingview.d.ts.map +1 -0
  125. package/dist/analysis/tradingview/analyze_tradingview.js +212 -0
  126. package/dist/analysis/tradingview/analyze_tradingview.js.map +1 -0
  127. package/dist/analysis/tradingview/tradingview_uplot_chart_generator.d.ts +9 -0
  128. package/dist/analysis/tradingview/tradingview_uplot_chart_generator.d.ts.map +1 -0
  129. package/dist/analysis/tradingview/tradingview_uplot_chart_generator.js +1717 -0
  130. package/dist/analysis/tradingview/tradingview_uplot_chart_generator.js.map +1 -0
  131. package/dist/analysis/trend_detection/derivative_analyzer.d.ts +250 -0
  132. package/dist/analysis/trend_detection/derivative_analyzer.d.ts.map +1 -0
  133. package/dist/analysis/trend_detection/derivative_analyzer.js +903 -0
  134. package/dist/analysis/trend_detection/derivative_analyzer.js.map +1 -0
  135. package/dist/analysis/trend_detection/dynamic_weight_chart_generator.d.ts +6 -0
  136. package/dist/analysis/trend_detection/dynamic_weight_chart_generator.d.ts.map +1 -0
  137. package/dist/analysis/trend_detection/dynamic_weight_chart_generator.js +1449 -0
  138. package/dist/analysis/trend_detection/dynamic_weight_chart_generator.js.map +1 -0
  139. package/dist/analysis/trend_detection/hurst_analyzer.d.ts +42 -0
  140. package/dist/analysis/trend_detection/hurst_analyzer.d.ts.map +1 -0
  141. package/dist/analysis/trend_detection/hurst_analyzer.js +159 -0
  142. package/dist/analysis/trend_detection/hurst_analyzer.js.map +1 -0
  143. package/dist/analysis/trend_detection/kalman_chart_generator.d.ts +6 -0
  144. package/dist/analysis/trend_detection/kalman_chart_generator.d.ts.map +1 -0
  145. package/dist/analysis/trend_detection/kalman_chart_generator.js +408 -0
  146. package/dist/analysis/trend_detection/kalman_chart_generator.js.map +1 -0
  147. package/dist/analysis/trend_detection/kalman_trend_analyzer.d.ts +103 -0
  148. package/dist/analysis/trend_detection/kalman_trend_analyzer.d.ts.map +1 -0
  149. package/dist/analysis/trend_detection/kalman_trend_analyzer.js +229 -0
  150. package/dist/analysis/trend_detection/kalman_trend_analyzer.js.map +1 -0
  151. package/dist/analysis/trend_detection/kalman_velocity_smoothing.d.ts +34 -0
  152. package/dist/analysis/trend_detection/kalman_velocity_smoothing.d.ts.map +1 -0
  153. package/dist/analysis/trend_detection/kalman_velocity_smoothing.js +89 -0
  154. package/dist/analysis/trend_detection/kalman_velocity_smoothing.js.map +1 -0
  155. package/dist/analysis/trend_detection/permutation_entropy_analyzer.d.ts +39 -0
  156. package/dist/analysis/trend_detection/permutation_entropy_analyzer.d.ts.map +1 -0
  157. package/dist/analysis/trend_detection/permutation_entropy_analyzer.js +132 -0
  158. package/dist/analysis/trend_detection/permutation_entropy_analyzer.js.map +1 -0
  159. package/dist/analysis/trend_detection/regime_chart_generator.d.ts +6 -0
  160. package/dist/analysis/trend_detection/regime_chart_generator.d.ts.map +1 -0
  161. package/dist/analysis/trend_detection/regime_chart_generator.js +345 -0
  162. package/dist/analysis/trend_detection/regime_chart_generator.js.map +1 -0
  163. package/dist/analysis/trend_detection/tests/test_kalman_trend.d.ts +2 -0
  164. package/dist/analysis/trend_detection/tests/test_kalman_trend.d.ts.map +1 -0
  165. package/dist/analysis/trend_detection/tests/test_kalman_trend.js +130 -0
  166. package/dist/analysis/trend_detection/tests/test_kalman_trend.js.map +1 -0
  167. package/dist/analysis/trend_detection/tests/test_kalman_velocity_smoothing.d.ts +2 -0
  168. package/dist/analysis/trend_detection/tests/test_kalman_velocity_smoothing.d.ts.map +1 -0
  169. package/dist/analysis/trend_detection/tests/test_kalman_velocity_smoothing.js +38 -0
  170. package/dist/analysis/trend_detection/tests/test_kalman_velocity_smoothing.js.map +1 -0
  171. package/dist/analysis/trend_detection/volatility_chart_generator.d.ts +6 -0
  172. package/dist/analysis/trend_detection/volatility_chart_generator.d.ts.map +1 -0
  173. package/dist/analysis/trend_detection/volatility_chart_generator.js +732 -0
  174. package/dist/analysis/trend_detection/volatility_chart_generator.js.map +1 -0
  175. package/dist/bot.d.ts +49 -0
  176. package/dist/bot.d.ts.map +1 -0
  177. package/dist/bot.js +221 -0
  178. package/dist/bot.js.map +1 -0
  179. package/dist/credential-daemon.d.ts +64 -0
  180. package/dist/credential-daemon.d.ts.map +1 -0
  181. package/dist/credential-daemon.js +987 -0
  182. package/dist/credential-daemon.js.map +1 -0
  183. package/dist/dexbot.d.ts +87 -0
  184. package/dist/dexbot.d.ts.map +1 -0
  185. package/dist/dexbot.js +1222 -0
  186. package/dist/dexbot.js.map +1 -0
  187. package/dist/market_adapter/ama_signal_runner.d.ts +3 -0
  188. package/dist/market_adapter/ama_signal_runner.d.ts.map +1 -0
  189. package/dist/market_adapter/ama_signal_runner.js +175 -0
  190. package/dist/market_adapter/ama_signal_runner.js.map +1 -0
  191. package/dist/market_adapter/candle_utils.d.ts +57 -0
  192. package/dist/market_adapter/candle_utils.d.ts.map +1 -0
  193. package/dist/market_adapter/candle_utils.js +252 -0
  194. package/dist/market_adapter/candle_utils.js.map +1 -0
  195. package/dist/market_adapter/core/asymmetric_bounds.d.ts +20 -0
  196. package/dist/market_adapter/core/asymmetric_bounds.d.ts.map +1 -0
  197. package/dist/market_adapter/core/asymmetric_bounds.js +88 -0
  198. package/dist/market_adapter/core/asymmetric_bounds.js.map +1 -0
  199. package/dist/market_adapter/core/config_normalizers.d.ts +10 -0
  200. package/dist/market_adapter/core/config_normalizers.d.ts.map +1 -0
  201. package/dist/market_adapter/core/config_normalizers.js +24 -0
  202. package/dist/market_adapter/core/config_normalizers.js.map +1 -0
  203. package/dist/market_adapter/core/kibana_candles.d.ts +74 -0
  204. package/dist/market_adapter/core/kibana_candles.d.ts.map +1 -0
  205. package/dist/market_adapter/core/kibana_candles.js +249 -0
  206. package/dist/market_adapter/core/kibana_candles.js.map +1 -0
  207. package/dist/market_adapter/core/kibana_client.d.ts +27 -0
  208. package/dist/market_adapter/core/kibana_client.d.ts.map +1 -0
  209. package/dist/market_adapter/core/kibana_client.js +120 -0
  210. package/dist/market_adapter/core/kibana_client.js.map +1 -0
  211. package/dist/market_adapter/core/kibana_market_candles.d.ts +143 -0
  212. package/dist/market_adapter/core/kibana_market_candles.d.ts.map +1 -0
  213. package/dist/market_adapter/core/kibana_market_candles.js +170 -0
  214. package/dist/market_adapter/core/kibana_market_candles.js.map +1 -0
  215. package/dist/market_adapter/core/market_adapter_service.d.ts +210 -0
  216. package/dist/market_adapter/core/market_adapter_service.d.ts.map +1 -0
  217. package/dist/market_adapter/core/market_adapter_service.js +2328 -0
  218. package/dist/market_adapter/core/market_adapter_service.js.map +1 -0
  219. package/dist/market_adapter/core/strategies/ama.d.ts +2 -0
  220. package/dist/market_adapter/core/strategies/ama.d.ts.map +1 -0
  221. package/dist/market_adapter/core/strategies/ama.js +138 -0
  222. package/dist/market_adapter/core/strategies/ama.js.map +1 -0
  223. package/dist/market_adapter/core/strategies/ama_slope_model.d.ts +50 -0
  224. package/dist/market_adapter/core/strategies/ama_slope_model.d.ts.map +1 -0
  225. package/dist/market_adapter/core/strategies/ama_slope_model.js +143 -0
  226. package/dist/market_adapter/core/strategies/ama_slope_model.js.map +1 -0
  227. package/dist/market_adapter/core/strategies/atr/calculator.d.ts +12 -0
  228. package/dist/market_adapter/core/strategies/atr/calculator.d.ts.map +1 -0
  229. package/dist/market_adapter/core/strategies/atr/calculator.js +47 -0
  230. package/dist/market_adapter/core/strategies/atr/calculator.js.map +1 -0
  231. package/dist/market_adapter/core/strategies/collateral_manager.d.ts +32 -0
  232. package/dist/market_adapter/core/strategies/collateral_manager.d.ts.map +1 -0
  233. package/dist/market_adapter/core/strategies/collateral_manager.js +68 -0
  234. package/dist/market_adapter/core/strategies/collateral_manager.js.map +1 -0
  235. package/dist/market_adapter/core/strategies/regime_gate.d.ts +66 -0
  236. package/dist/market_adapter/core/strategies/regime_gate.d.ts.map +1 -0
  237. package/dist/market_adapter/core/strategies/regime_gate.js +189 -0
  238. package/dist/market_adapter/core/strategies/regime_gate.js.map +1 -0
  239. package/dist/market_adapter/index.d.ts +10 -0
  240. package/dist/market_adapter/index.d.ts.map +1 -0
  241. package/dist/market_adapter/index.js +71 -0
  242. package/dist/market_adapter/index.js.map +1 -0
  243. package/dist/market_adapter/inputs/fetch_cex_synthetic_data.d.ts +3 -0
  244. package/dist/market_adapter/inputs/fetch_cex_synthetic_data.d.ts.map +1 -0
  245. package/dist/market_adapter/inputs/fetch_cex_synthetic_data.js +1165 -0
  246. package/dist/market_adapter/inputs/fetch_cex_synthetic_data.js.map +1 -0
  247. package/dist/market_adapter/inputs/fetch_lp_data.d.ts +54 -0
  248. package/dist/market_adapter/inputs/fetch_lp_data.d.ts.map +1 -0
  249. package/dist/market_adapter/inputs/fetch_lp_data.js +743 -0
  250. package/dist/market_adapter/inputs/fetch_lp_data.js.map +1 -0
  251. package/dist/market_adapter/inputs/kibana_source.d.ts +68 -0
  252. package/dist/market_adapter/inputs/kibana_source.d.ts.map +1 -0
  253. package/dist/market_adapter/inputs/kibana_source.js +143 -0
  254. package/dist/market_adapter/inputs/kibana_source.js.map +1 -0
  255. package/dist/market_adapter/interval_utils.d.ts +6 -0
  256. package/dist/market_adapter/interval_utils.d.ts.map +1 -0
  257. package/dist/market_adapter/interval_utils.js +14 -0
  258. package/dist/market_adapter/interval_utils.js.map +1 -0
  259. package/dist/market_adapter/log_format.d.ts +16 -0
  260. package/dist/market_adapter/log_format.d.ts.map +1 -0
  261. package/dist/market_adapter/log_format.js +72 -0
  262. package/dist/market_adapter/log_format.js.map +1 -0
  263. package/dist/market_adapter/lp_chart_core.d.ts +6 -0
  264. package/dist/market_adapter/lp_chart_core.d.ts.map +1 -0
  265. package/dist/market_adapter/lp_chart_core.js +874 -0
  266. package/dist/market_adapter/lp_chart_core.js.map +1 -0
  267. package/dist/market_adapter/lp_chart_runner.d.ts +135 -0
  268. package/dist/market_adapter/lp_chart_runner.d.ts.map +1 -0
  269. package/dist/market_adapter/lp_chart_runner.js +337 -0
  270. package/dist/market_adapter/lp_chart_runner.js.map +1 -0
  271. package/dist/market_adapter/lp_chart_strategy_loader.d.ts +23 -0
  272. package/dist/market_adapter/lp_chart_strategy_loader.d.ts.map +1 -0
  273. package/dist/market_adapter/lp_chart_strategy_loader.js +169 -0
  274. package/dist/market_adapter/lp_chart_strategy_loader.js.map +1 -0
  275. package/dist/market_adapter/market_adapter.d.ts +133 -0
  276. package/dist/market_adapter/market_adapter.d.ts.map +1 -0
  277. package/dist/market_adapter/market_adapter.js +1331 -0
  278. package/dist/market_adapter/market_adapter.js.map +1 -0
  279. package/dist/market_adapter/merge_lp_data.d.ts +3 -0
  280. package/dist/market_adapter/merge_lp_data.d.ts.map +1 -0
  281. package/dist/market_adapter/merge_lp_data.js +125 -0
  282. package/dist/market_adapter/merge_lp_data.js.map +1 -0
  283. package/dist/market_adapter/test_helpers.d.ts +14 -0
  284. package/dist/market_adapter/test_helpers.d.ts.map +1 -0
  285. package/dist/market_adapter/test_helpers.js +22 -0
  286. package/dist/market_adapter/test_helpers.js.map +1 -0
  287. package/dist/market_adapter/utils/adapter_client.d.ts +20 -0
  288. package/dist/market_adapter/utils/adapter_client.d.ts.map +1 -0
  289. package/dist/market_adapter/utils/adapter_client.js +88 -0
  290. package/dist/market_adapter/utils/adapter_client.js.map +1 -0
  291. package/dist/market_adapter/utils/atomic_write.d.ts +9 -0
  292. package/dist/market_adapter/utils/atomic_write.d.ts.map +1 -0
  293. package/dist/market_adapter/utils/atomic_write.js +13 -0
  294. package/dist/market_adapter/utils/atomic_write.js.map +1 -0
  295. package/dist/market_adapter/utils/chain.d.ts +50 -0
  296. package/dist/market_adapter/utils/chain.d.ts.map +1 -0
  297. package/dist/market_adapter/utils/chain.js +196 -0
  298. package/dist/market_adapter/utils/chain.js.map +1 -0
  299. package/dist/market_adapter/utils/data_discovery.d.ts +6 -0
  300. package/dist/market_adapter/utils/data_discovery.d.ts.map +1 -0
  301. package/dist/market_adapter/utils/data_discovery.js +35 -0
  302. package/dist/market_adapter/utils/data_discovery.js.map +1 -0
  303. package/dist/market_adapter/utils/dynamic_grid_snapshot.d.ts +15 -0
  304. package/dist/market_adapter/utils/dynamic_grid_snapshot.d.ts.map +1 -0
  305. package/dist/market_adapter/utils/dynamic_grid_snapshot.js +60 -0
  306. package/dist/market_adapter/utils/dynamic_grid_snapshot.js.map +1 -0
  307. package/dist/market_adapter/utils/file_lock.d.ts +19 -0
  308. package/dist/market_adapter/utils/file_lock.d.ts.map +1 -0
  309. package/dist/market_adapter/utils/file_lock.js +191 -0
  310. package/dist/market_adapter/utils/file_lock.js.map +1 -0
  311. package/dist/market_adapter/utils/native_history.d.ts +19 -0
  312. package/dist/market_adapter/utils/native_history.d.ts.map +1 -0
  313. package/dist/market_adapter/utils/native_history.js +172 -0
  314. package/dist/market_adapter/utils/native_history.js.map +1 -0
  315. package/dist/market_adapter/utils/paths.d.ts +5 -0
  316. package/dist/market_adapter/utils/paths.d.ts.map +1 -0
  317. package/dist/market_adapter/utils/paths.js +7 -0
  318. package/dist/market_adapter/utils/paths.js.map +1 -0
  319. package/dist/modules/account_bots.d.ts +112 -0
  320. package/dist/modules/account_bots.d.ts.map +1 -0
  321. package/dist/modules/account_bots.js +1259 -0
  322. package/dist/modules/account_bots.js.map +1 -0
  323. package/dist/modules/account_orders.d.ts +273 -0
  324. package/dist/modules/account_orders.d.ts.map +1 -0
  325. package/dist/modules/account_orders.js +662 -0
  326. package/dist/modules/account_orders.js.map +1 -0
  327. package/dist/modules/authority_resolver.d.ts +2 -0
  328. package/dist/modules/authority_resolver.d.ts.map +1 -0
  329. package/dist/modules/authority_resolver.js +231 -0
  330. package/dist/modules/authority_resolver.js.map +1 -0
  331. package/dist/modules/bitshares-native/chain_client.d.ts +38 -0
  332. package/dist/modules/bitshares-native/chain_client.d.ts.map +1 -0
  333. package/dist/modules/bitshares-native/chain_client.js +322 -0
  334. package/dist/modules/bitshares-native/chain_client.js.map +1 -0
  335. package/dist/modules/bitshares-native/crypto/ecc.browser.d.ts +59 -0
  336. package/dist/modules/bitshares-native/crypto/ecc.browser.d.ts.map +1 -0
  337. package/dist/modules/bitshares-native/crypto/ecc.browser.js +456 -0
  338. package/dist/modules/bitshares-native/crypto/ecc.browser.js.map +1 -0
  339. package/dist/modules/bitshares-native/crypto/ecc.d.ts +66 -0
  340. package/dist/modules/bitshares-native/crypto/ecc.d.ts.map +1 -0
  341. package/dist/modules/bitshares-native/crypto/ecc.js +557 -0
  342. package/dist/modules/bitshares-native/crypto/ecc.js.map +1 -0
  343. package/dist/modules/bitshares-native/crypto/ecc_selector.d.ts +2 -0
  344. package/dist/modules/bitshares-native/crypto/ecc_selector.d.ts.map +1 -0
  345. package/dist/modules/bitshares-native/crypto/ecc_selector.js +20 -0
  346. package/dist/modules/bitshares-native/crypto/ecc_selector.js.map +1 -0
  347. package/dist/modules/bitshares-native/index.d.ts +3 -0
  348. package/dist/modules/bitshares-native/index.d.ts.map +1 -0
  349. package/dist/modules/bitshares-native/index.js +32 -0
  350. package/dist/modules/bitshares-native/index.js.map +1 -0
  351. package/dist/modules/bitshares-native/resolvers.d.ts +40 -0
  352. package/dist/modules/bitshares-native/resolvers.d.ts.map +1 -0
  353. package/dist/modules/bitshares-native/resolvers.js +161 -0
  354. package/dist/modules/bitshares-native/resolvers.js.map +1 -0
  355. package/dist/modules/bitshares-native/serial/chain_constants.d.ts +56 -0
  356. package/dist/modules/bitshares-native/serial/chain_constants.d.ts.map +1 -0
  357. package/dist/modules/bitshares-native/serial/chain_constants.js +92 -0
  358. package/dist/modules/bitshares-native/serial/chain_constants.js.map +1 -0
  359. package/dist/modules/bitshares-native/serial/index.d.ts +10 -0
  360. package/dist/modules/bitshares-native/serial/index.d.ts.map +1 -0
  361. package/dist/modules/bitshares-native/serial/index.js +14 -0
  362. package/dist/modules/bitshares-native/serial/index.js.map +1 -0
  363. package/dist/modules/bitshares-native/serial/operations.d.ts +102 -0
  364. package/dist/modules/bitshares-native/serial/operations.d.ts.map +1 -0
  365. package/dist/modules/bitshares-native/serial/operations.js +615 -0
  366. package/dist/modules/bitshares-native/serial/operations.js.map +1 -0
  367. package/dist/modules/bitshares-native/serial/serializer.d.ts +64 -0
  368. package/dist/modules/bitshares-native/serial/serializer.d.ts.map +1 -0
  369. package/dist/modules/bitshares-native/serial/serializer.js +252 -0
  370. package/dist/modules/bitshares-native/serial/serializer.js.map +1 -0
  371. package/dist/modules/bitshares-native/serial/types.d.ts +120 -0
  372. package/dist/modules/bitshares-native/serial/types.d.ts.map +1 -0
  373. package/dist/modules/bitshares-native/serial/types.js +837 -0
  374. package/dist/modules/bitshares-native/serial/types.js.map +1 -0
  375. package/dist/modules/bitshares-native/signing_client.d.ts +6 -0
  376. package/dist/modules/bitshares-native/signing_client.d.ts.map +1 -0
  377. package/dist/modules/bitshares-native/signing_client.js +141 -0
  378. package/dist/modules/bitshares-native/signing_client.js.map +1 -0
  379. package/dist/modules/bitshares-native/subscriptions.d.ts +6 -0
  380. package/dist/modules/bitshares-native/subscriptions.d.ts.map +1 -0
  381. package/dist/modules/bitshares-native/subscriptions.js +865 -0
  382. package/dist/modules/bitshares-native/subscriptions.js.map +1 -0
  383. package/dist/modules/bitshares-native/transport.d.ts +51 -0
  384. package/dist/modules/bitshares-native/transport.d.ts.map +1 -0
  385. package/dist/modules/bitshares-native/transport.js +447 -0
  386. package/dist/modules/bitshares-native/transport.js.map +1 -0
  387. package/dist/modules/bitshares-native/tx/builder.d.ts +30 -0
  388. package/dist/modules/bitshares-native/tx/builder.d.ts.map +1 -0
  389. package/dist/modules/bitshares-native/tx/builder.js +262 -0
  390. package/dist/modules/bitshares-native/tx/builder.js.map +1 -0
  391. package/dist/modules/bitshares_client.d.ts +129 -0
  392. package/dist/modules/bitshares_client.d.ts.map +1 -0
  393. package/dist/modules/bitshares_client.js +627 -0
  394. package/dist/modules/bitshares_client.js.map +1 -0
  395. package/dist/modules/bot_settings.d.ts +33 -0
  396. package/dist/modules/bot_settings.d.ts.map +1 -0
  397. package/dist/modules/bot_settings.js +328 -0
  398. package/dist/modules/bot_settings.js.map +1 -0
  399. package/dist/modules/bots_file_lock.d.ts +88 -0
  400. package/dist/modules/bots_file_lock.d.ts.map +1 -0
  401. package/dist/modules/bots_file_lock.js +161 -0
  402. package/dist/modules/bots_file_lock.js.map +1 -0
  403. package/dist/modules/chain_keys.d.ts +302 -0
  404. package/dist/modules/chain_keys.d.ts.map +1 -0
  405. package/dist/modules/chain_keys.js +1095 -0
  406. package/dist/modules/chain_keys.js.map +1 -0
  407. package/dist/modules/chain_orders.d.ts +423 -0
  408. package/dist/modules/chain_orders.d.ts.map +1 -0
  409. package/dist/modules/chain_orders.js +1201 -0
  410. package/dist/modules/chain_orders.js.map +1 -0
  411. package/dist/modules/cli_whitelist_args.d.ts +6 -0
  412. package/dist/modules/cli_whitelist_args.d.ts.map +1 -0
  413. package/dist/modules/cli_whitelist_args.js +13 -0
  414. package/dist/modules/cli_whitelist_args.js.map +1 -0
  415. package/dist/modules/config.d.ts +57 -0
  416. package/dist/modules/config.d.ts.map +1 -0
  417. package/dist/modules/config.js +107 -0
  418. package/dist/modules/config.js.map +1 -0
  419. package/dist/modules/constants.d.ts +635 -0
  420. package/dist/modules/constants.d.ts.map +1 -0
  421. package/dist/modules/constants.js +1464 -0
  422. package/dist/modules/constants.js.map +1 -0
  423. package/dist/modules/cr_planner.d.ts +51 -0
  424. package/dist/modules/cr_planner.d.ts.map +1 -0
  425. package/dist/modules/cr_planner.js +299 -0
  426. package/dist/modules/cr_planner.js.map +1 -0
  427. package/dist/modules/credential_policy.d.ts +188 -0
  428. package/dist/modules/credential_policy.d.ts.map +1 -0
  429. package/dist/modules/credential_policy.js +1452 -0
  430. package/dist/modules/credential_policy.js.map +1 -0
  431. package/dist/modules/credential_runtime.d.ts +42 -0
  432. package/dist/modules/credential_runtime.d.ts.map +1 -0
  433. package/dist/modules/credential_runtime.js +148 -0
  434. package/dist/modules/credential_runtime.js.map +1 -0
  435. package/dist/modules/credential_session_cache.d.ts +36 -0
  436. package/dist/modules/credential_session_cache.d.ts.map +1 -0
  437. package/dist/modules/credential_session_cache.js +106 -0
  438. package/dist/modules/credential_session_cache.js.map +1 -0
  439. package/dist/modules/credit_runtime.d.ts +412 -0
  440. package/dist/modules/credit_runtime.d.ts.map +1 -0
  441. package/dist/modules/credit_runtime.js +2866 -0
  442. package/dist/modules/credit_runtime.js.map +1 -0
  443. package/dist/modules/crypto/browser_provider.d.ts +15 -0
  444. package/dist/modules/crypto/browser_provider.d.ts.map +1 -0
  445. package/dist/modules/crypto/browser_provider.js +113 -0
  446. package/dist/modules/crypto/browser_provider.js.map +1 -0
  447. package/dist/modules/crypto/index.d.ts +9 -0
  448. package/dist/modules/crypto/index.d.ts.map +1 -0
  449. package/dist/modules/crypto/index.js +44 -0
  450. package/dist/modules/crypto/index.js.map +1 -0
  451. package/dist/modules/crypto/node_provider.d.ts +15 -0
  452. package/dist/modules/crypto/node_provider.d.ts.map +1 -0
  453. package/dist/modules/crypto/node_provider.js +74 -0
  454. package/dist/modules/crypto/node_provider.js.map +1 -0
  455. package/dist/modules/crypto/provider.d.ts +34 -0
  456. package/dist/modules/crypto/provider.d.ts.map +1 -0
  457. package/dist/modules/crypto/provider.js +3 -0
  458. package/dist/modules/crypto/provider.js.map +1 -0
  459. package/dist/modules/crypto/pure_ripemd160.d.ts +8 -0
  460. package/dist/modules/crypto/pure_ripemd160.d.ts.map +1 -0
  461. package/dist/modules/crypto/pure_ripemd160.js +142 -0
  462. package/dist/modules/crypto/pure_ripemd160.js.map +1 -0
  463. package/dist/modules/crypto/pure_scrypt.d.ts +23 -0
  464. package/dist/modules/crypto/pure_scrypt.d.ts.map +1 -0
  465. package/dist/modules/crypto/pure_scrypt.js +161 -0
  466. package/dist/modules/crypto/pure_scrypt.js.map +1 -0
  467. package/dist/modules/crypto/pure_secp256k1.d.ts +29 -0
  468. package/dist/modules/crypto/pure_secp256k1.d.ts.map +1 -0
  469. package/dist/modules/crypto/pure_secp256k1.js +195 -0
  470. package/dist/modules/crypto/pure_secp256k1.js.map +1 -0
  471. package/dist/modules/crypto/sync.d.ts +13 -0
  472. package/dist/modules/crypto/sync.d.ts.map +1 -0
  473. package/dist/modules/crypto/sync.js +37 -0
  474. package/dist/modules/crypto/sync.js.map +1 -0
  475. package/dist/modules/dexbot_class.d.ts +1074 -0
  476. package/dist/modules/dexbot_class.d.ts.map +1 -0
  477. package/dist/modules/dexbot_class.js +4613 -0
  478. package/dist/modules/dexbot_class.js.map +1 -0
  479. package/dist/modules/dexbot_credential_client.d.ts +71 -0
  480. package/dist/modules/dexbot_credential_client.d.ts.map +1 -0
  481. package/dist/modules/dexbot_credential_client.js +224 -0
  482. package/dist/modules/dexbot_credential_client.js.map +1 -0
  483. package/dist/modules/dexbot_fill_runtime.d.ts +173 -0
  484. package/dist/modules/dexbot_fill_runtime.d.ts.map +1 -0
  485. package/dist/modules/dexbot_fill_runtime.js +217 -0
  486. package/dist/modules/dexbot_fill_runtime.js.map +1 -0
  487. package/dist/modules/dexbot_maintenance_runtime.d.ts +279 -0
  488. package/dist/modules/dexbot_maintenance_runtime.d.ts.map +1 -0
  489. package/dist/modules/dexbot_maintenance_runtime.js +1613 -0
  490. package/dist/modules/dexbot_maintenance_runtime.js.map +1 -0
  491. package/dist/modules/env.d.ts +12 -0
  492. package/dist/modules/env.d.ts.map +1 -0
  493. package/dist/modules/env.js +57 -0
  494. package/dist/modules/env.js.map +1 -0
  495. package/dist/modules/fund_registry.d.ts +96 -0
  496. package/dist/modules/fund_registry.d.ts.map +1 -0
  497. package/dist/modules/fund_registry.js +261 -0
  498. package/dist/modules/fund_registry.js.map +1 -0
  499. package/dist/modules/general_settings.d.ts +36 -0
  500. package/dist/modules/general_settings.d.ts.map +1 -0
  501. package/dist/modules/general_settings.js +63 -0
  502. package/dist/modules/general_settings.js.map +1 -0
  503. package/dist/modules/graceful_shutdown.d.ts +86 -0
  504. package/dist/modules/graceful_shutdown.d.ts.map +1 -0
  505. package/dist/modules/graceful_shutdown.js +164 -0
  506. package/dist/modules/graceful_shutdown.js.map +1 -0
  507. package/dist/modules/key_store.d.ts +60 -0
  508. package/dist/modules/key_store.d.ts.map +1 -0
  509. package/dist/modules/key_store.js +215 -0
  510. package/dist/modules/key_store.js.map +1 -0
  511. package/dist/modules/launcher/bot_supervisor.d.ts +84 -0
  512. package/dist/modules/launcher/bot_supervisor.d.ts.map +1 -0
  513. package/dist/modules/launcher/bot_supervisor.js +1067 -0
  514. package/dist/modules/launcher/bot_supervisor.js.map +1 -0
  515. package/dist/modules/launcher/child_env.d.ts +9 -0
  516. package/dist/modules/launcher/child_env.d.ts.map +1 -0
  517. package/dist/modules/launcher/child_env.js +78 -0
  518. package/dist/modules/launcher/child_env.js.map +1 -0
  519. package/dist/modules/launcher/credential_bootstrap.d.ts +22 -0
  520. package/dist/modules/launcher/credential_bootstrap.d.ts.map +1 -0
  521. package/dist/modules/launcher/credential_bootstrap.js +303 -0
  522. package/dist/modules/launcher/credential_bootstrap.js.map +1 -0
  523. package/dist/modules/launcher/credential_daemon.d.ts +32 -0
  524. package/dist/modules/launcher/credential_daemon.d.ts.map +1 -0
  525. package/dist/modules/launcher/credential_daemon.js +173 -0
  526. package/dist/modules/launcher/credential_daemon.js.map +1 -0
  527. package/dist/modules/launcher/credential_secret.d.ts +6 -0
  528. package/dist/modules/launcher/credential_secret.d.ts.map +1 -0
  529. package/dist/modules/launcher/credential_secret.js +15 -0
  530. package/dist/modules/launcher/credential_secret.js.map +1 -0
  531. package/dist/modules/launcher/foreign_cred_daemon.d.ts +2 -0
  532. package/dist/modules/launcher/foreign_cred_daemon.d.ts.map +1 -0
  533. package/dist/modules/launcher/foreign_cred_daemon.js +166 -0
  534. package/dist/modules/launcher/foreign_cred_daemon.js.map +1 -0
  535. package/dist/modules/launcher/headless_password.d.ts +8 -0
  536. package/dist/modules/launcher/headless_password.d.ts.map +1 -0
  537. package/dist/modules/launcher/headless_password.js +33 -0
  538. package/dist/modules/launcher/headless_password.js.map +1 -0
  539. package/dist/modules/launcher/launch_modes.d.ts +36 -0
  540. package/dist/modules/launcher/launch_modes.d.ts.map +1 -0
  541. package/dist/modules/launcher/launch_modes.js +129 -0
  542. package/dist/modules/launcher/launch_modes.js.map +1 -0
  543. package/dist/modules/launcher/market_adapter_runtime.d.ts +43 -0
  544. package/dist/modules/launcher/market_adapter_runtime.d.ts.map +1 -0
  545. package/dist/modules/launcher/market_adapter_runtime.js +217 -0
  546. package/dist/modules/launcher/market_adapter_runtime.js.map +1 -0
  547. package/dist/modules/launcher/market_adapter_watchdog.d.ts +26 -0
  548. package/dist/modules/launcher/market_adapter_watchdog.d.ts.map +1 -0
  549. package/dist/modules/launcher/market_adapter_watchdog.js +214 -0
  550. package/dist/modules/launcher/market_adapter_watchdog.js.map +1 -0
  551. package/dist/modules/launcher/monolithic_runtime.d.ts +89 -0
  552. package/dist/modules/launcher/monolithic_runtime.d.ts.map +1 -0
  553. package/dist/modules/launcher/monolithic_runtime.js +425 -0
  554. package/dist/modules/launcher/monolithic_runtime.js.map +1 -0
  555. package/dist/modules/launcher/runtime_entry.d.ts +26 -0
  556. package/dist/modules/launcher/runtime_entry.d.ts.map +1 -0
  557. package/dist/modules/launcher/runtime_entry.js +49 -0
  558. package/dist/modules/launcher/runtime_entry.js.map +1 -0
  559. package/dist/modules/launcher/status_reporting.d.ts +48 -0
  560. package/dist/modules/launcher/status_reporting.d.ts.map +1 -0
  561. package/dist/modules/launcher/status_reporting.js +113 -0
  562. package/dist/modules/launcher/status_reporting.js.map +1 -0
  563. package/dist/modules/launcher/supervisor_control.d.ts +6 -0
  564. package/dist/modules/launcher/supervisor_control.d.ts.map +1 -0
  565. package/dist/modules/launcher/supervisor_control.js +59 -0
  566. package/dist/modules/launcher/supervisor_control.js.map +1 -0
  567. package/dist/modules/logger.d.ts +2 -0
  568. package/dist/modules/logger.d.ts.map +1 -0
  569. package/dist/modules/logger.js +71 -0
  570. package/dist/modules/logger.js.map +1 -0
  571. package/dist/modules/market_adapter_whitelist.d.ts +22 -0
  572. package/dist/modules/market_adapter_whitelist.d.ts.map +1 -0
  573. package/dist/modules/market_adapter_whitelist.js +82 -0
  574. package/dist/modules/market_adapter_whitelist.js.map +1 -0
  575. package/dist/modules/node_health_cache.d.ts +55 -0
  576. package/dist/modules/node_health_cache.d.ts.map +1 -0
  577. package/dist/modules/node_health_cache.js +134 -0
  578. package/dist/modules/node_health_cache.js.map +1 -0
  579. package/dist/modules/node_manager.d.ts +215 -0
  580. package/dist/modules/node_manager.d.ts.map +1 -0
  581. package/dist/modules/node_manager.js +628 -0
  582. package/dist/modules/node_manager.js.map +1 -0
  583. package/dist/modules/order/accounting.d.ts +349 -0
  584. package/dist/modules/order/accounting.d.ts.map +1 -0
  585. package/dist/modules/order/accounting.js +1191 -0
  586. package/dist/modules/order/accounting.js.map +1 -0
  587. package/dist/modules/order/async_lock.d.ts +126 -0
  588. package/dist/modules/order/async_lock.d.ts.map +1 -0
  589. package/dist/modules/order/async_lock.js +195 -0
  590. package/dist/modules/order/async_lock.js.map +1 -0
  591. package/dist/modules/order/export.d.ts +129 -0
  592. package/dist/modules/order/export.d.ts.map +1 -0
  593. package/dist/modules/order/export.js +316 -0
  594. package/dist/modules/order/export.js.map +1 -0
  595. package/dist/modules/order/format.d.ts +158 -0
  596. package/dist/modules/order/format.d.ts.map +1 -0
  597. package/dist/modules/order/format.js +232 -0
  598. package/dist/modules/order/format.js.map +1 -0
  599. package/dist/modules/order/grid.d.ts +549 -0
  600. package/dist/modules/order/grid.d.ts.map +1 -0
  601. package/dist/modules/order/grid.js +1746 -0
  602. package/dist/modules/order/grid.js.map +1 -0
  603. package/dist/modules/order/grid_reconcile.d.ts +154 -0
  604. package/dist/modules/order/grid_reconcile.d.ts.map +1 -0
  605. package/dist/modules/order/grid_reconcile.js +1192 -0
  606. package/dist/modules/order/grid_reconcile.js.map +1 -0
  607. package/dist/modules/order/index.d.ts +55 -0
  608. package/dist/modules/order/index.d.ts.map +1 -0
  609. package/dist/modules/order/index.js +79 -0
  610. package/dist/modules/order/index.js.map +1 -0
  611. package/dist/modules/order/logger.d.ts +136 -0
  612. package/dist/modules/order/logger.d.ts.map +1 -0
  613. package/dist/modules/order/logger.js +614 -0
  614. package/dist/modules/order/logger.js.map +1 -0
  615. package/dist/modules/order/logger_state.d.ts +133 -0
  616. package/dist/modules/order/logger_state.d.ts.map +1 -0
  617. package/dist/modules/order/logger_state.js +170 -0
  618. package/dist/modules/order/logger_state.js.map +1 -0
  619. package/dist/modules/order/manager.d.ts +413 -0
  620. package/dist/modules/order/manager.d.ts.map +1 -0
  621. package/dist/modules/order/manager.js +1605 -0
  622. package/dist/modules/order/manager.js.map +1 -0
  623. package/dist/modules/order/processed_fill_store.d.ts +135 -0
  624. package/dist/modules/order/processed_fill_store.d.ts.map +1 -0
  625. package/dist/modules/order/processed_fill_store.js +288 -0
  626. package/dist/modules/order/processed_fill_store.js.map +1 -0
  627. package/dist/modules/order/runner.d.ts +70 -0
  628. package/dist/modules/order/runner.d.ts.map +1 -0
  629. package/dist/modules/order/runner.js +140 -0
  630. package/dist/modules/order/runner.js.map +1 -0
  631. package/dist/modules/order/strategy.d.ts +196 -0
  632. package/dist/modules/order/strategy.d.ts.map +1 -0
  633. package/dist/modules/order/strategy.js +398 -0
  634. package/dist/modules/order/strategy.js.map +1 -0
  635. package/dist/modules/order/sync_engine.d.ts +386 -0
  636. package/dist/modules/order/sync_engine.d.ts.map +1 -0
  637. package/dist/modules/order/sync_engine.js +1459 -0
  638. package/dist/modules/order/sync_engine.js.map +1 -0
  639. package/dist/modules/order/utils/math.d.ts +677 -0
  640. package/dist/modules/order/utils/math.d.ts.map +1 -0
  641. package/dist/modules/order/utils/math.js +1172 -0
  642. package/dist/modules/order/utils/math.js.map +1 -0
  643. package/dist/modules/order/utils/order.d.ts +572 -0
  644. package/dist/modules/order/utils/order.d.ts.map +1 -0
  645. package/dist/modules/order/utils/order.js +1145 -0
  646. package/dist/modules/order/utils/order.js.map +1 -0
  647. package/dist/modules/order/utils/system.d.ts +268 -0
  648. package/dist/modules/order/utils/system.d.ts.map +1 -0
  649. package/dist/modules/order/utils/system.js +1261 -0
  650. package/dist/modules/order/utils/system.js.map +1 -0
  651. package/dist/modules/order/utils/validate.d.ts +280 -0
  652. package/dist/modules/order/utils/validate.d.ts.map +1 -0
  653. package/dist/modules/order/utils/validate.js +918 -0
  654. package/dist/modules/order/utils/validate.js.map +1 -0
  655. package/dist/modules/order/working_grid.d.ts +212 -0
  656. package/dist/modules/order/working_grid.d.ts.map +1 -0
  657. package/dist/modules/order/working_grid.js +279 -0
  658. package/dist/modules/order/working_grid.js.map +1 -0
  659. package/dist/modules/path_api.d.ts +32 -0
  660. package/dist/modules/path_api.d.ts.map +1 -0
  661. package/dist/modules/path_api.js +148 -0
  662. package/dist/modules/path_api.js.map +1 -0
  663. package/dist/modules/paths.d.ts +58 -0
  664. package/dist/modules/paths.d.ts.map +1 -0
  665. package/dist/modules/paths.js +82 -0
  666. package/dist/modules/paths.js.map +1 -0
  667. package/dist/modules/process_discovery.d.ts +58 -0
  668. package/dist/modules/process_discovery.d.ts.map +1 -0
  669. package/dist/modules/process_discovery.js +265 -0
  670. package/dist/modules/process_discovery.js.map +1 -0
  671. package/dist/modules/runtime.d.ts +34 -0
  672. package/dist/modules/runtime.d.ts.map +1 -0
  673. package/dist/modules/runtime.js +98 -0
  674. package/dist/modules/runtime.js.map +1 -0
  675. package/dist/modules/runtime_settings.d.ts +12 -0
  676. package/dist/modules/runtime_settings.d.ts.map +1 -0
  677. package/dist/modules/runtime_settings.js +122 -0
  678. package/dist/modules/runtime_settings.js.map +1 -0
  679. package/dist/modules/settings_merge.d.ts +38 -0
  680. package/dist/modules/settings_merge.d.ts.map +1 -0
  681. package/dist/modules/settings_merge.js +246 -0
  682. package/dist/modules/settings_merge.js.map +1 -0
  683. package/dist/modules/storage/browser_adapter.d.ts +56 -0
  684. package/dist/modules/storage/browser_adapter.d.ts.map +1 -0
  685. package/dist/modules/storage/browser_adapter.js +231 -0
  686. package/dist/modules/storage/browser_adapter.js.map +1 -0
  687. package/dist/modules/storage/index.d.ts +28 -0
  688. package/dist/modules/storage/index.d.ts.map +1 -0
  689. package/dist/modules/storage/index.js +52 -0
  690. package/dist/modules/storage/index.js.map +1 -0
  691. package/dist/modules/storage/node_adapter.d.ts +49 -0
  692. package/dist/modules/storage/node_adapter.d.ts.map +1 -0
  693. package/dist/modules/storage/node_adapter.js +167 -0
  694. package/dist/modules/storage/node_adapter.js.map +1 -0
  695. package/dist/modules/storage/types.d.ts +92 -0
  696. package/dist/modules/storage/types.d.ts.map +1 -0
  697. package/dist/modules/storage/types.js +3 -0
  698. package/dist/modules/storage/types.js.map +1 -0
  699. package/dist/modules/types.d.ts +1382 -0
  700. package/dist/modules/types.d.ts.map +1 -0
  701. package/dist/modules/types.js +11 -0
  702. package/dist/modules/types.js.map +1 -0
  703. package/dist/modules/utils/base58check.d.ts +12 -0
  704. package/dist/modules/utils/base58check.d.ts.map +1 -0
  705. package/dist/modules/utils/base58check.js +112 -0
  706. package/dist/modules/utils/base58check.js.map +1 -0
  707. package/dist/modules/utils/build_dir.d.ts +7 -0
  708. package/dist/modules/utils/build_dir.d.ts.map +1 -0
  709. package/dist/modules/utils/build_dir.js +8 -0
  710. package/dist/modules/utils/build_dir.js.map +1 -0
  711. package/dist/modules/utils/fs_utils.d.ts +25 -0
  712. package/dist/modules/utils/fs_utils.d.ts.map +1 -0
  713. package/dist/modules/utils/fs_utils.js +27 -0
  714. package/dist/modules/utils/fs_utils.js.map +1 -0
  715. package/dist/modules/utils/math_utils.d.ts +10 -0
  716. package/dist/modules/utils/math_utils.d.ts.map +1 -0
  717. package/dist/modules/utils/math_utils.js +17 -0
  718. package/dist/modules/utils/math_utils.js.map +1 -0
  719. package/dist/modules/validate_profiles.d.ts +37 -0
  720. package/dist/modules/validate_profiles.d.ts.map +1 -0
  721. package/dist/modules/validate_profiles.js +369 -0
  722. package/dist/modules/validate_profiles.js.map +1 -0
  723. package/dist/pm2.d.ts +167 -0
  724. package/dist/pm2.d.ts.map +1 -0
  725. package/dist/pm2.js +998 -0
  726. package/dist/pm2.js.map +1 -0
  727. package/dist/scripts/analyze-git.d.ts +11 -0
  728. package/dist/scripts/analyze-git.d.ts.map +1 -0
  729. package/dist/scripts/analyze-git.js +851 -0
  730. package/dist/scripts/analyze-git.js.map +1 -0
  731. package/dist/scripts/analyze-orders.d.ts +17 -0
  732. package/dist/scripts/analyze-orders.d.ts.map +1 -0
  733. package/dist/scripts/analyze-orders.js +1568 -0
  734. package/dist/scripts/analyze-orders.js.map +1 -0
  735. package/dist/scripts/diagnose-kibana-candles.d.ts +3 -0
  736. package/dist/scripts/diagnose-kibana-candles.d.ts.map +1 -0
  737. package/dist/scripts/diagnose-kibana-candles.js +82 -0
  738. package/dist/scripts/diagnose-kibana-candles.js.map +1 -0
  739. package/dist/scripts/diagnose-pool-history.d.ts +3 -0
  740. package/dist/scripts/diagnose-pool-history.d.ts.map +1 -0
  741. package/dist/scripts/diagnose-pool-history.js +296 -0
  742. package/dist/scripts/diagnose-pool-history.js.map +1 -0
  743. package/dist/scripts/divergence-calc.d.ts +26 -0
  744. package/dist/scripts/divergence-calc.d.ts.map +1 -0
  745. package/dist/scripts/divergence-calc.js +119 -0
  746. package/dist/scripts/divergence-calc.js.map +1 -0
  747. package/dist/scripts/generate_lp_chart.d.ts +31 -0
  748. package/dist/scripts/generate_lp_chart.d.ts.map +1 -0
  749. package/dist/scripts/generate_lp_chart.js +92 -0
  750. package/dist/scripts/generate_lp_chart.js.map +1 -0
  751. package/dist/scripts/generate_mainnet_corpus_report.d.ts +24 -0
  752. package/dist/scripts/generate_mainnet_corpus_report.d.ts.map +1 -0
  753. package/dist/scripts/generate_mainnet_corpus_report.js +237 -0
  754. package/dist/scripts/generate_mainnet_corpus_report.js.map +1 -0
  755. package/dist/scripts/generate_market_adapter_whitelist.d.ts +2 -0
  756. package/dist/scripts/generate_market_adapter_whitelist.d.ts.map +1 -0
  757. package/dist/scripts/generate_market_adapter_whitelist.js +111 -0
  758. package/dist/scripts/generate_market_adapter_whitelist.js.map +1 -0
  759. package/dist/scripts/migrate_bot_keys.d.ts +6 -0
  760. package/dist/scripts/migrate_bot_keys.d.ts.map +1 -0
  761. package/dist/scripts/migrate_bot_keys.js +301 -0
  762. package/dist/scripts/migrate_bot_keys.js.map +1 -0
  763. package/dist/scripts/native_release_gates.d.ts +3 -0
  764. package/dist/scripts/native_release_gates.d.ts.map +1 -0
  765. package/dist/scripts/native_release_gates.js +52 -0
  766. package/dist/scripts/native_release_gates.js.map +1 -0
  767. package/dist/scripts/print_grid.d.ts +16 -0
  768. package/dist/scripts/print_grid.d.ts.map +1 -0
  769. package/dist/scripts/print_grid.js +80 -0
  770. package/dist/scripts/print_grid.js.map +1 -0
  771. package/dist/scripts/run-tests.d.ts +2 -0
  772. package/dist/scripts/run-tests.d.ts.map +1 -0
  773. package/dist/scripts/run-tests.js +49 -0
  774. package/dist/scripts/run-tests.js.map +1 -0
  775. package/dist/scripts/sync-version.d.ts +14 -0
  776. package/dist/scripts/sync-version.d.ts.map +1 -0
  777. package/dist/scripts/sync-version.js +158 -0
  778. package/dist/scripts/sync-version.js.map +1 -0
  779. package/dist/scripts/test-credit-renewal.d.ts +2 -0
  780. package/dist/scripts/test-credit-renewal.d.ts.map +1 -0
  781. package/dist/scripts/test-credit-renewal.js +329 -0
  782. package/dist/scripts/test-credit-renewal.js.map +1 -0
  783. package/dist/scripts/update.d.ts +24 -0
  784. package/dist/scripts/update.d.ts.map +1 -0
  785. package/dist/scripts/update.js +650 -0
  786. package/dist/scripts/update.js.map +1 -0
  787. package/dist/scripts/validate_bots.d.ts +16 -0
  788. package/dist/scripts/validate_bots.d.ts.map +1 -0
  789. package/dist/scripts/validate_bots.js +106 -0
  790. package/dist/scripts/validate_bots.js.map +1 -0
  791. package/dist/scripts/verify-browser-bundle.d.ts +22 -0
  792. package/dist/scripts/verify-browser-bundle.d.ts.map +1 -0
  793. package/dist/scripts/verify-browser-bundle.js +339 -0
  794. package/dist/scripts/verify-browser-bundle.js.map +1 -0
  795. package/dist/unlock.d.ts +48 -0
  796. package/dist/unlock.d.ts.map +1 -0
  797. package/dist/unlock.js +925 -0
  798. package/dist/unlock.js.map +1 -0
  799. package/package.json +112 -0
  800. package/scripts/README.md +356 -0
  801. package/scripts/clear-all.sh +195 -0
  802. package/scripts/clear-logs.sh +95 -0
  803. package/scripts/clear-market-adapter.sh +196 -0
  804. package/scripts/clear-orders.sh +113 -0
  805. package/scripts/create-bot-symlinks.sh +51 -0
  806. package/scripts/postinstall.js +9 -0
  807. package/scripts/reset-settings.sh +118 -0
@@ -0,0 +1,1464 @@
1
+ "use strict";
2
+ /**
3
+ * modules/constants.ts - Configuration and Constants
4
+ *
5
+ * Global configuration, constants, and defaults for DEXBot2.
6
+ * All constants are frozen to prevent accidental runtime modifications.
7
+ * Local overrides can be loaded from profiles/general.settings.json
8
+ *
9
+ * ===============================================================================
10
+ * EXPORTED CONSTANTS
11
+ * ===============================================================================
12
+ *
13
+ * ENUM DEFINITIONS:
14
+ * 1. ORDER_TYPES - Grid entry categories
15
+ * { SELL: 'sell', BUY: 'buy', SPREAD: 'spread' }
16
+ * - SELL: Orders above market price, size in base asset (assetA)
17
+ * - BUY: Orders below market price, size in quote asset (assetB)
18
+ * - SPREAD: Placeholder orders in spread zone around market price
19
+ *
20
+ * 2. ORDER_STATES - Order lifecycle states (affects fund tracking)
21
+ * { VIRTUAL: 'virtual', ACTIVE: 'active', PARTIAL: 'partial' }
22
+ * - VIRTUAL: Not yet on-chain, size in funds.virtual (reserved)
23
+ * Also used for filled orders converted to SPREAD placeholders
24
+ * - ACTIVE: Placed on-chain, size in funds.committed
25
+ * - PARTIAL: Partially filled on-chain, mixed state
26
+ *
27
+ * DEFAULT CONFIGURATION (applied when not explicitly set):
28
+ * 3. DEFAULT_CONFIG - Bot configuration defaults
29
+ * Price: startPrice, minPrice, maxPrice, incrementPercent, targetSpreadPercent
30
+ * Control: active, dryRun
31
+ * Trading pair: assetA, assetB
32
+ * Allocation: weightDistribution, botFunds, activeOrders
33
+ *
34
+ * TIMING PARAMETERS:
35
+ * 4. TIMING - Operational timing constants
36
+ * SYNC_DELAY_MS, ACCOUNT_TOTALS_TIMEOUT_MS, MILLISECONDS_PER_SECOND
37
+ * BLOCKCHAIN_FETCH_INTERVAL_MIN, FILL_DEDUPE_WINDOW_MS
38
+ * FILL_RECORD_RETENTION_MS
39
+ * LOCK_TIMEOUT_MS, SYNC_LOCK_TIMEOUT_MS
40
+ * CONNECTION_TIMEOUT_MS, DAEMON_STARTUP_TIMEOUT_MS
41
+ * RUN_LOOP_DEFAULT_MS, OPEN_ORDERS_SYNC_LOOP_ENABLED, CHECK_INTERVAL_MS
42
+ * CREDENTIAL_BROADCAST_TIMEOUT_MS, CREDENTIAL_DAEMON_INNER_DEADLINE_MS
43
+ *
44
+ * GRID & ORDER LIMITS:
45
+ * 5. GRID_LIMITS - Grid sizing and scaling constraints
46
+ * MIN_SPREAD_FACTOR, MIN_SPREAD_ORDERS, MIN_ORDER_COUNT
47
+ * FUND_INVARIANT_PERCENT_TOLERANCE
48
+ * Includes GRID_COMPARISON sub-object for grid divergence metrics
49
+ *
50
+ * 6. INCREMENT_BOUNDS - Price increment percentage validation
51
+ * MIN_INCREMENT_PERCENT, MAX_INCREMENT_PERCENT
52
+ *
53
+ * FEE CONFIGURATION:
54
+ * 7. FEE_PARAMETERS - Fee calculation and reservation parameters
55
+ * BTS_RESERVATION_MULTIPLIER, MARKET_FEE_PERCENT, TAKER_FEE_PERCENT
56
+ * TAKER_PERCENT_OVERRIDE, BTS_TAKER_OVERRIDE
57
+ *
58
+ * API & BLOCKCHAIN:
59
+ * 8. API_LIMITS - Blockchain API call constraints
60
+ * MAX_ORDERS_PER_CALL, API_TIMEOUT_MS, API_RETRY_DELAY_MS
61
+ * MAX_API_RETRIES, HISTORICAL_SYNC_BATCH_SIZE
62
+ *
63
+ * FILL PROCESSING:
64
+ * 9. FILL_PROCESSING - Fill event handling configuration
65
+ * FILL_ACK_WAIT_MS, FILL_TIMEOUT_MS, FILL_RETRY_ATTEMPTS
66
+ * Includes BATCH_LIMITS sub-object
67
+ *
68
+ * MARKET ADAPTER CONFIGURATION:
69
+ * 10. MARKET_ADAPTER - Price tracking and grid recalculation trigger settings
70
+ * AMA_DELTA_THRESHOLD_PERCENT: % change in AMA center price that triggers grid reset
71
+ * DEFAULT_AMA_KEY: Default AMA profile used for `gridPrice: "ama"`
72
+ * AMAS: Built-in AMA1..AMA4 presets for market adapter defaults
73
+ * Related to bot AMA configuration (profiles/bots.json: ama.enabled, erPeriod, etc.)
74
+ * Stored in: profiles/general.settings.json
75
+ *
76
+ * MAINTENANCE & MONITORING:
77
+ * 11. MAINTENANCE - Background maintenance task configuration
78
+ * HEALTH_CHECK_INTERVAL_MS, PERSISTENCE_CHECK_INTERVAL_MS
79
+ * LOCK_CLEANUP_INTERVAL_MS
80
+ *
81
+ * 12. NODE_MANAGEMENT - Multi-node health checking and failover configuration
82
+ * DEFAULT_NODES: List of BitShares nodes for redundancy
83
+ * HEALTH_CHECK_INTERVAL_MS, HEALTH_CHECK_TIMEOUT_MS, MAX_PING_MS
84
+ * BLACKLIST_THRESHOLD: Failures before node is blacklisted
85
+ * EXPECTED_CHAIN_ID: BitShares mainnet chain ID validation
86
+ * SELECTION_STRATEGY: Node selection algorithm (latency-based)
87
+ *
88
+ * 13. UPDATER - Version checking and update notification
89
+ * CHECK_INTERVAL_MS, REPO_URL, NOTIFICATION_MIN_LEVEL
90
+ *
91
+ * LOGGING CONFIGURATION:
92
+ * 14. LOGGING_CONFIG - Structured logging configuration
93
+ * changeTracking: Smart change detection
94
+ * display.colors: TTY color support
95
+ * display.fundStatus, display.statusSummary, display.gridDiagnostics
96
+ * Categories for enabling/disabling log types
97
+ *
98
+ * 15. LOG_LEVEL - Current logging verbosity level
99
+ * Affects which messages are displayed: 'debug', 'info', 'warn', 'error'
100
+ *
101
+ * 16. PIPELINE_TIMING - Pipeline execution timing thresholds
102
+ * 17. COW_PERFORMANCE - Copy-on-write grid performance settings
103
+ * 18. REBALANCE_STATES - Rebalance lifecycle state enum
104
+ * 19. COW_ACTIONS - Copy-on-write action type enum
105
+ * 20. CR_ZONES - Credit ratio zone constants
106
+ * 21. DEFAULT_TARGET_CR - Default target collateral ratio
107
+ * 22. NATIVE_CLIENT - Native blockchain client configuration
108
+ * 23. LAUNCHER - Launcher configuration (PM2, Docker)
109
+ * 24. BUILD_DIR - Build directory path
110
+ * 25. BTS_PRECISION - BTS asset precision
111
+ * 26. DAEMON_ERRORS - Credential daemon error codes
112
+ * 27. DAEMON_CODES - Credential daemon codes
113
+ * 28. CREDENTIAL_PROMPTS - Credential prompt configuration
114
+ *
115
+ * ===============================================================================
116
+ *
117
+ * LOCAL SETTINGS OVERRIDE:
118
+ * Read from profiles/general.settings.json if it exists.
119
+ * Supports overriding any exported constant with custom values.
120
+ * Useful for development, testing, and performance tuning.
121
+ *
122
+ * FREEZING:
123
+ * Most exported objects are frozen at module load to prevent accidental runtime modifications.
124
+ * This ensures constants remain truly constant throughout bot lifetime.
125
+ *
126
+ * ===============================================================================
127
+ */
128
+ // Order categories used by the OrderManager when classifying grid entries.
129
+ const ORDER_TYPES = Object.freeze({
130
+ SELL: 'sell',
131
+ BUY: 'buy',
132
+ SPREAD: 'spread'
133
+ });
134
+ // Life-cycle states assigned to generated or active orders.
135
+ // State transitions affect fund calculations in manager.recalculateFunds()
136
+ const ORDER_STATES = Object.freeze({
137
+ VIRTUAL: 'virtual', // Not on-chain, size in funds.virtual; also used for fully filled orders converted to SPREAD
138
+ ACTIVE: 'active', // On-chain, size in funds.committed.grid (and .chain if has orderId)
139
+ PARTIAL: 'partial' // On-chain, partially filled order, size in funds.committed.grid (and .chain if has orderId)
140
+ });
141
+ // Rebalance lifecycle states used by COW planning/broadcast/commit pipeline.
142
+ const REBALANCE_STATES = Object.freeze({
143
+ NORMAL: 'NORMAL',
144
+ REBALANCING: 'REBALANCING',
145
+ BROADCASTING: 'BROADCASTING'
146
+ });
147
+ // Canonical action labels used by grid reconciliation and batch broadcasting.
148
+ const COW_ACTIONS = Object.freeze({
149
+ CREATE: 'create',
150
+ CANCEL: 'cancel',
151
+ UPDATE: 'update'
152
+ });
153
+ // Defaults applied when instantiating an OrderManager with minimal configuration.
154
+ // These values are used when a parameter is not explicitly provided in the bot config.
155
+ let DEFAULT_CONFIG = {
156
+ // Price configuration
157
+ startPrice: "pool", // Market price source: "pool" (liquidity pool), "book" (order book), or numeric value
158
+ minPrice: "2x", // Lower price bound: "Nx" = N times below startPrice, or numeric value
159
+ maxPrice: "2x", // Upper price bound: "Nx" = N times above startPrice, or numeric value
160
+ gridPrice: null, // Optional reference price for x-factor bounds calculation.
161
+ // "pool" = use the live pool price for the pair
162
+ // "book" = use the live order book price for the pair
163
+ // "ama"/"ama1".."ama4" = use the effective center snapshot from profiles/orders/<botKey>.dynamicgrid.json
164
+ // numeric = fixed numeric value
165
+ // null = use startPrice
166
+ incrementPercent: 0.5, // Price step between grid levels (0.5 = 0.5% geometric spacing)
167
+ targetSpreadPercent: 2, // Target spread width between best buy and best sell (2 = 2%)
168
+ // Bot control
169
+ active: true, // Whether bot should actively place/manage orders
170
+ dryRun: false, // If true, simulate operations without blockchain transactions
171
+ // Trading pair
172
+ assetA: null, // Base asset symbol (e.g., "BTS")
173
+ assetB: null, // Quote asset symbol (e.g., "USD")
174
+ // Fund allocation
175
+ weightDistribution: { sell: 1, buy: 1 }, // Geometric weight for order sizing (1 = ~1:2 center/outer split, 0.5 = linear)
176
+ botFunds: { sell: "100%", buy: "100%" }, // Percentage of wallet balance to allocate ("100%" or numeric value)
177
+ activeOrders: { sell: 20, buy: 20 }, // Number of orders to maintain closest to market on each side
178
+ // BTS fee management for non-BTS pairs
179
+ min_BTS_value: null, // Minimum BTS balance to maintain (null = auto from activeOrders × fees × multiplier)
180
+ };
181
+ // Timing constants used by OrderManager and helpers
182
+ let TIMING = {
183
+ SYNC_DELAY_MS: 500,
184
+ ACCOUNT_TOTALS_TIMEOUT_MS: 10000,
185
+ // Conversion factor: milliseconds per second
186
+ MILLISECONDS_PER_SECOND: 1000,
187
+ // Blockchain fetch interval: how often to refresh blockchain account values (in minutes)
188
+ // Default: 240 minutes (4 hours). Set to 0 or non-number to disable periodic fetches.
189
+ BLOCKCHAIN_FETCH_INTERVAL_MIN: 240,
190
+ // Override interval for shared accounts (multiple bots on same account).
191
+ // When the fund registry detects multiple bots on the same account, the fetch
192
+ // interval drops to this value to reduce stale balance window.
193
+ SHARED_ACCOUNT_FETCH_INTERVAL_MIN: 5,
194
+ // BTS acquisition for non-BTS pairs: min cooldown between acquisition attempts (minutes)
195
+ BTS_ACQUIRE_COOLDOWN_MIN: 60,
196
+ // Fill processing timing
197
+ FILL_DEDUPE_WINDOW_MS: 5000, // 5 seconds - window for deduplicating same fill events
198
+ FILL_RECORD_RETENTION_MS: 7 * 24 * 60 * 60 * 1000, // 7 days - how long to keep persisted fill records (was 1h, increased to close double-credit window on restarts >1h apart)
199
+ PROCESSED_FILL_PERSIST_BATCH_MS: 250, // 250ms - coalesce processed-fill persistence writes under burst load
200
+ PROCESSED_FILL_PERSIST_BATCH_SIZE: 25, // Flush immediately once this many processed fills are queued
201
+ AUDIT_LOG_MAX_SIZE: 100 * 1024 * 1024, // 100 MB total disk budget for audit logs (current + rotated)
202
+ AUDIT_LOG_MAX_FILES: 5, // number of rotated audit log files to retain
203
+ // Order locking timing
204
+ // Reduced from 30s to 10s to prevent lock-based starvation under high fill rates.
205
+ // Locks that exceed this timeout are auto-expired by _cleanExpiredLocks() to ensure
206
+ // orders are never permanently blocked if a process crashes while holding the lock.
207
+ // This self-healing mechanism prevents deadlocks while still protecting against races.
208
+ LOCK_TIMEOUT_MS: 10000, // 10 seconds - balances transaction latency with lock starvation prevention
209
+ // Sync lock acquisition timeout - prevents indefinite lock hangs
210
+ // Uses Promise.race() to enforce timeout on lock acquisition attempts
211
+ SYNC_LOCK_TIMEOUT_MS: 20000, // 20 seconds - prevents deadlocks while allowing slow operations
212
+ // Connection and initialization timeouts
213
+ CONNECTION_TIMEOUT_MS: 30000, // 30 seconds - BitShares client connection establishment timeout
214
+ DAEMON_STARTUP_TIMEOUT_MS: 60000, // 60 seconds - Private key daemon startup timeout
215
+ RETRY_BACKOFF_CAP_MS: 30000, // 30 seconds - Max exponential backoff delay for connection retries
216
+ DAEMON_PING_TIMEOUT_MS: 5000, // 5 seconds - Private key daemon ping/healthcheck timeout
217
+ CREDENTIAL_DAEMON_WATCHDOG_MS: 60000, // 60 seconds - Credential daemon watchdog polling interval
218
+ // Main loop and polling defaults
219
+ RUN_LOOP_DEFAULT_MS: 300000, // 5 minutes - default open-orders sync cycle delay (env override: OPEN_ORDERS_SYNC_LOOP_MS)
220
+ OPEN_ORDERS_SYNC_LOOP_ENABLED: false, // Preferred flag: continuous open-order watchdog sync loop (default false — react to fills only)
221
+ CHECK_INTERVAL_MS: 100, // 100 milliseconds - polling interval for connection/daemon readiness checks
222
+ // Blockchain settle delay before follow-up structural work after a scheduled maintenance action.
223
+ // Gives maintenance-triggered cancels/rebalances time to acquire locks, broadcast, and settle
224
+ // before a deferred grid resync attempts more on-chain changes.
225
+ BLOCKCHAIN_SETTLE_DELAY_MS: 6000,
226
+ // Credit deal proactive renewal timing
227
+ CREDIT_DEAL_CHECK_INTERVAL_MIN: 60, // How often to check credit deal expiry (minutes)
228
+ CREDIT_DEAL_EXPIRY_THRESHOLD_HOURS: 12, // Proactively renew deals expiring within this window
229
+ CREDIT_DEAL_SPLIT_MAX_PIECES: 48, // Max pieces per _splitOversizedCreditDeals cycle (~4.8min at 6s/piece)
230
+ // LOCK_REFRESH_MIN_MS: Minimum interval for refreshing order lock leases during long operations.
231
+ // Prevents lock expiration during extended reconciliations or batch operations.
232
+ // Default: 250ms (4 refreshes per second minimum during long operations).
233
+ LOCK_REFRESH_MIN_MS: 250,
234
+ // LOG_THROTTLE_INTERVAL_MS: Default throttle interval for _logThrottled
235
+ // in accounting.ts et al. Prevents repeated identical log messages from
236
+ // flooding the log during sustained error conditions.
237
+ LOG_THROTTLE_INTERVAL_MS: 30000,
238
+ // CREDENTIAL_BROADCAST_TIMEOUT_MS: Outer timeout for a credential-daemon broadcast
239
+ // request, enforced by the bot socket client (modules/dexbot_credential_client.ts).
240
+ // Rationale: Broadcasts can take much longer than read-only daemon calls because the
241
+ // daemon must sign locally, then push the signed transaction to a BitShares node and
242
+ // wait for chain inclusion. 30s gives slow mainnet nodes enough headroom on cold
243
+ // start while still bounding bot-side wait time.
244
+ // If this outer timer fires before the daemon responds, the bot raises a typed
245
+ // BroadcastUncertainError and enters the recovery path (chain may or may not have
246
+ // accepted the operations).
247
+ CREDENTIAL_BROADCAST_TIMEOUT_MS: 30000,
248
+ // CREDENTIAL_DAEMON_INNER_DEADLINE_MS: Inner deadline enforced inside the credential
249
+ // daemon's broadcastWithRetry (credential-daemon.ts). Must be strictly less than
250
+ // CREDENTIAL_BROADCAST_TIMEOUT_MS so the daemon can report a typed
251
+ // { success:false, code:'BROADCAST_DEADLINE' } failure before the bot-side
252
+ // socket timer fires. 5s of slack is enough for the bot to receive and
253
+ // process the typed reply on a slow connection. 25s gives slow mainnet
254
+ // nodes most of the outer window for a successful broadcast; the recovery
255
+ // path handles whatever takes longer.
256
+ CREDENTIAL_DAEMON_INNER_DEADLINE_MS: 25000,
257
+ // CREDENTIAL_DAEMON_BROADCAST_RETRIES: Number of broadcast attempts inside the
258
+ // credential daemon's broadcastWithRetry. Each attempt connects, signs, and pushes
259
+ // the transaction. Total wall time across all attempts is capped by
260
+ // CREDENTIAL_DAEMON_INNER_DEADLINE_MS above. 2 is a pragmatic balance: try once,
261
+ // retry once on disconnect, while leaving room for a slow block before the deadline.
262
+ CREDENTIAL_DAEMON_BROADCAST_RETRIES: 3,
263
+ // SAFETY_NET_SYNC_TIMEOUT_MS: Cap on the post-reconnect safety-net sync
264
+ // in dexbot_class.ts. Must stay below the 20s shutdown lock timeout so
265
+ // it never holds _fillProcessingLock longer than the shutdown deadline.
266
+ SAFETY_NET_SYNC_TIMEOUT_MS: 25000,
267
+ // TARGETED_DRIFT_SYNC_COOLDOWN_MS: Minimum interval between targeted drift
268
+ // reconciliation cycles. Prevents rapid re-triggering when the grid is
269
+ // oscillating around the drift threshold.
270
+ TARGETED_DRIFT_SYNC_COOLDOWN_MS: 60000,
271
+ };
272
+ // Grid limits and scaling constants
273
+ let GRID_LIMITS = {
274
+ // MIN_SPREAD_FACTOR: Ensures spread is at least (incrementPercent × MIN_SPREAD_FACTOR) slots wide.
275
+ // Rationale: Spread must be sufficiently wide to:
276
+ // 1. Avoid order collision (orders too close get rejected by blockchain)
277
+ // 2. Allow bid-ask arbitrage room (market makers profit from the spread)
278
+ // 3. Scale proportionally to grid spacing (tighter increments need tighter spread buffer)
279
+ //
280
+ // Example Calculation (incrementPercent = 0.5%, targetSpread = 2%):
281
+ // - MIN_SPREAD_FACTOR = 2.1 → minSpread = 0.5% × 2.1 = 1.05%
282
+ // - But target is 2%, so final spread = max(1.05%, 2%) = 2% (target wins)
283
+ // - This ensures spread is at least (0.5% × 2.1) but respects user's targetSpread
284
+ //
285
+ // Default: 2.1 ensures 3-slot minimum gap even with tight increment (see grid.ts::SPREAD_GAP_FORMULA)
286
+ MIN_SPREAD_FACTOR: 2.1,
287
+ // MIN_ORDER_SIZE_FACTOR: Minimum order size = blockchain_minimum × this factor.
288
+ // Rationale: Orders smaller than blockchain minimum are rejected.
289
+ // - Blockchain minimum ≈ 1 satoshi (10^-8 per unit)
290
+ // - Float arithmetic and fee deductions can round amounts down
291
+ // - Safety factor = 50× ensures orders survive rounding
292
+ // Example: If blockchainMin = 1 BTS, then minSize = 50 BTS (very conservative for mainnet)
293
+ // This trades off efficiency (larger minimum) for reliability (never hits rounding floor)
294
+ MIN_ORDER_SIZE_FACTOR: 50,
295
+ // PRICE_TOLERANCE_MAX_PERCENT: Maximum price tolerance as fraction of grid price.
296
+ // Clamps calculatePriceTolerance so tiny dust-sized orders never produce tolerances
297
+ // larger than this fraction. 0.01 = 1% of price.
298
+ PRICE_TOLERANCE_MAX_PERCENT: 0.01,
299
+ // PRICE_TOLERANCE_MIN_ABSOLUTE: Floor for the price tolerance cap in price units.
300
+ // Ensures the cap is non-zero even for extremely cheap assets.
301
+ PRICE_TOLERANCE_MIN_ABSOLUTE: 0.0001,
302
+ // GRID_REGENERATION_PERCENTAGE: Trigger threshold for automatic grid size recalculation.
303
+ // Formula: IF (availableFunds / allocatedCapital) × 100 ≥ threshold → regenerate
304
+ // Rationale: After fills, free balance rises relative to allocated grid capital.
305
+ // - 3% = regen triggered when available funds represent ≥3% of side allocation
306
+ // - This allows gradual accumulation while preventing lag during high-fill periods
307
+ // - If threshold too low: constant regeneration (churn, fees)
308
+ // - If threshold too high: capital remains underutilized, grid undersized
309
+ // Example: 20 active orders × 100 BTS each = 2000 BTS grid
310
+ // - availableFunds ≥ 60 BTS → (60/2000 = 3%) triggers regeneration
311
+ // - Allows ~3 fill-proceeds before resize (reduces churn)
312
+ // Checked independently per side, allowing asymmetric fill patterns.
313
+ GRID_REGENERATION_PERCENTAGE: 3,
314
+ // PARTIAL_DUST_THRESHOLD_PERCENTAGE: Threshold for treating partially-filled orders as "dust".
315
+ // Formula: IF (actualSize / idealSize) × 100 < threshold → dust
316
+ // Rationale: Partially-filled orders become progressively smaller.
317
+ // - 5% = orders below 5% of ideal size are rotated (to restore grid symmetry)
318
+ // - Dust orders waste grid slots (they should be closed or brought back to ideal size)
319
+ // - Rotation replaces dust order with a fresh one at proper size
320
+ // - Detects both accidental low fills and normal fill-chain truncation
321
+ // Example: idealSize = 100 BTS, but actual = 3 BTS → (3/100 = 3%) < 5% → dust
322
+ // - This order would be rotated to free the slot
323
+ PARTIAL_DUST_THRESHOLD_PERCENTAGE: 5,
324
+ // DUST_CANCEL_DELAY_SEC: Legacy — no longer used. Dust is cancelled immediately on detection
325
+ // (no delay, no timer). Kept for backward-compat so existing configs don't break on load.
326
+ // Default -1 (disabled) makes freshly-written configs self-documenting.
327
+ DUST_CANCEL_DELAY_SEC: -1,
328
+ // FUND_INVARIANT_PERCENT_TOLERANCE: Allowed percentage drift in fund tracking before triggering recovery.
329
+ // Formula: tolerance = max(precisionSlack, balance × percentTolerance)
330
+ // Rationale: Fund tracking can drift due to:
331
+ // 1. Float arithmetic rounding (resolved by precisionSlack, ~10^-precision)
332
+ // 2. In-flight blockchain transactions (resolved by percentTolerance)
333
+ // 3. Fee accumulation from multiple operations
334
+ // Default: 0.1% (0.1%) means for 1000 BTS balance, drift up to 1 BTS is tolerated
335
+ // - Accounts for ~5 fill-fee events before recovery triggered
336
+ // - Too low: false positives (recoveries on healthy operations)
337
+ // - Too high: undetected drift (fund leaks)
338
+ // Drifts larger than this tolerance trigger immediate recovery (re-sync from blockchain).
339
+ FUND_INVARIANT_PERCENT_TOLERANCE: 0.1,
340
+ // MIN_SPREAD_ORDERS: Minimum number of empty slots in spread zone (between best buy and best sell).
341
+ // Rationale: Spread must be sufficiently wide to:
342
+ // 1. Prevent order collision (blockchain rejects orders with identical price)
343
+ // 2. Ensure market makers profit from the bid-ask difference
344
+ // 3. Allow price movement without orders crossing each other
345
+ // Default: 2 (at least 2 empty slots between buy and sell sides)
346
+ // Example: Buy @ 99.9, empty, empty, Sell @ 100.1 → 2-slot spread (acceptable)
347
+ // Buy @ 99.9, empty, Sell @ 100.0 → 1-slot spread (too tight, rebalance triggered)
348
+ MIN_SPREAD_ORDERS: 2,
349
+ // Grid comparison metrics
350
+ // Detects significant divergence between calculated (in-memory) and persisted grid state
351
+ // after order fills and rotations
352
+ // NOTE: Independent from MARKET_ADAPTER.AMA_DELTA_THRESHOLD_PERCENT
353
+ // - RMS_PERCENTAGE: Triggers grid reset when calculated grid diverges from blockchain state
354
+ // - AMA_DELTA_THRESHOLD_PERCENT: Triggers grid reset when AMA center price moves significantly
355
+ // Both can be configured independently in profiles/general.settings.json
356
+ GRID_COMPARISON: {
357
+ // Metric calculation: RMS (Root Mean Square) of relative order size differences
358
+ // Formula: RMS = √(mean of ((calculated - persisted) / persisted)²)
359
+ // Represents the quadratic mean of relative size errors
360
+ SUMMED_RELATIVE_SQUARED_DIFFERENCE: 'summedRelativeSquaredDiff',
361
+ // Divergence threshold for automatic grid regeneration (RMS as percentage)
362
+ // When compareGrids() metric exceeds this threshold, updateGridOrderSizes will be triggered
363
+ // Set to 0 to completely disable RMS divergence checks (Issue #5: RMS Divergence Check Disabling)
364
+ //
365
+ // RMS Threshold Reference Table (for 5% distribution: 5% outliers, 95% perfect):
366
+ // ┌────────────────────────────────────────────────────────┐
367
+ // │ RMS % │ Avg Error │ Description │
368
+ // ├────────────────────────────────────────────────────────┤
369
+ // │ 0 │ N/A │ Disabled (no checks) │
370
+ // │ 4.5% │ ~1.0% │ Very strict │
371
+ // │ 9.8% │ ~2.2% │ Strict │
372
+ // │ 14.3% │ ~3.2% │ Default (balanced) │
373
+ // │ 20.1% │ ~4.5% │ Lenient │
374
+ // │ 31.7% │ ~7.1% │ Very lenient │
375
+ // │ 44.7% │ ~10% │ Extremely lenient │
376
+ // └────────────────────────────────────────────────────────┘
377
+ RMS_PERCENTAGE: 14.3
378
+ },
379
+ // STATE_CHANGE_HISTORY_MAX: Maximum number of state changes to retain in circular buffer.
380
+ // Used by StateChangeLogger for tracking recent grid/fund mutations.
381
+ // Default: 100 entries (balances memory usage with debugging utility).
382
+ STATE_CHANGE_HISTORY_MAX: 100,
383
+ // RELATIVE_ORDER_UPDATE_THRESHOLD_PERCENT: Relative threshold for in-memory
384
+ // order equality checks in COW delta planning.
385
+ // Example: 0.1 means two values are considered equal when diff < 0.1% of magnitude.
386
+ // Note: Final blockchain update filtering still happens with integer precision checks.
387
+ RELATIVE_ORDER_UPDATE_THRESHOLD_PERCENT: 0.1,
388
+ // PRICE_DRIFT_TOLERANCE_MULTIPLIER: Tolerance multiplier for matching
389
+ // chain-order price drift against planned grid slots in sync_engine.ts.
390
+ // Drift beyond strict tolerance but within multiplier × tolerance is
391
+ // tagged as "price-drift-orphan" instead of rejected outright.
392
+ PRICE_DRIFT_TOLERANCE_MULTIPLIER: 4,
393
+ };
394
+ // Increment percentage bounds for grid configuration
395
+ let INCREMENT_BOUNDS = {
396
+ // Minimum increment percentage allowed (0.01%)
397
+ MIN_PERCENT: 0.01,
398
+ // Maximum increment percentage allowed (10%)
399
+ MAX_PERCENT: 10,
400
+ // Minimum increment as decimal factor (0.01% = 0.0001)
401
+ MIN_FACTOR: 0.0001,
402
+ // Maximum increment as decimal factor (10% = 0.10)
403
+ MAX_FACTOR: 0.10
404
+ };
405
+ // Fee-related parameters for order operations
406
+ let FEE_PARAMETERS = {
407
+ // BTS_RESERVATION_MULTIPLIER: Factor applied to totalTargetOrders to reserve BTS fee budget.
408
+ // Formula: BTS reserved = totalTargetOrders × BTS_RESERVATION_MULTIPLIER
409
+ // Rationale: Each order can be updated/cancelled during rebalancing, and each operation incurs a fee.
410
+ // - Conservative estimate: each order may be touched ~5 times during its lifetime
411
+ // - Orders get: created (1 fee), rotated (2 fees: cancel + place), updated (1 fee), cancelled (1 fee)
412
+ // - So ~5 fees per order is safe buffer to prevent fee starvation
413
+ // Example: 20 active orders → 20 × 5 = 100 BTS reserved for fee operations
414
+ // Set to 0 to disable fee reservation (not recommended for production).
415
+ BTS_RESERVATION_MULTIPLIER: 5,
416
+ // Fallback BTS fee (satoshis) when dynamic fee calculation fails.
417
+ // Rationale: During startup or when fee API is unavailable, use this conservative estimate.
418
+ // - 100 satoshis = 0.00000100 BTS (typical limit order fee is 1-2 BTS on mainnet)
419
+ // - Using satoshi precision prevents integer division errors
420
+ // - Actual fees are calculated and deducted once fee API responds
421
+ BTS_FALLBACK_FEE: 100,
422
+ // MAKER_FEE_PERCENT: Percentage of base fee charged for maker orders (orders that rest in book).
423
+ // Rationale: BitShares incentivizes providing liquidity (making orders) with lower fees.
424
+ // - 0.1 = 10% of the base order creation fee
425
+ // - Typical: 2 BTS base fee × 0.1 = 0.2 BTS charged (maker)
426
+ // - vs. 2 BTS for taker orders (taker: 100% of base fee)
427
+ // - This 10× discount encourages grid bots (primarily makers) to place orders
428
+ MAKER_FEE_PERCENT: 0.1,
429
+ // MAKER_REFUND_PERCENT: Percentage of maker fee refunded after order execution/cancellation.
430
+ // Rationale: BitShares refunds unused maker fees when order is cancelled or fills.
431
+ // - 0.9 = 90% refund of the maker fee paid
432
+ // - Typical: Paid 0.2 BTS, get 0.18 BTS refund, net cost 0.02 BTS
433
+ // - Refund arrives in a separate transaction after cancellation
434
+ // - This incentive structure encourages taker participation (market efficiency)
435
+ MAKER_REFUND_PERCENT: 0.9,
436
+ // TAKER_FEE_PERCENT: Percentage of base fee charged for taker orders (orders that cross spread).
437
+ // Rationale: Takers (who immediately fill) pay full fee; they consume liquidity.
438
+ // - 1.0 = 100% of the base order creation fee
439
+ // - Typical: 2 BTS base fee × 1.0 = 2 BTS charged (no refund)
440
+ // - Full fee covers order broadcast and execution costs
441
+ TAKER_FEE_PERCENT: 1.0,
442
+ // GRAPHENE_FEE_RATE_DENOM: BitShares credit-offer fee-rate denominator.
443
+ // The on-chain fee_rate is an integer; fee percent = fee_rate / DENOM.
444
+ // Example: fee_rate 30000 → 30000 / 1000000 = 3% flat fee at repayment.
445
+ GRAPHENE_FEE_RATE_DENOM: 1000000,
446
+ // DEFAULT_MAX_FEE_RATE_PER_DAY: Default maximum daily fee rate for credit offers.
447
+ // 1/2900 ≈ 0.0003448 = 0.03448% per day = ~1.034% per month.
448
+ // This provides a reasonable default cap so short-duration high-flat-fee offers
449
+ // are rejected while long-duration low-flat-fee offers are accepted.
450
+ DEFAULT_MAX_FEE_RATE_PER_DAY: 1 / 2900,
451
+ // GRAPHENE_COLLATERAL_RATIO_DENOM: Denominator for target_collateral_ratio in call_order_update operations.
452
+ // Matches the protocol constant in bitshares-core (libraries/protocol/include/graphene/protocol/config.hpp).
453
+ // On-chain value = human_CR * DENOM. Example: 2.0 CR → 2000 on chain.
454
+ GRAPHENE_COLLATERAL_RATIO_DENOM: 1000,
455
+ // BTS_ACQUIRE_THRESHOLD: Trigger acquisition when BTS free drops below min_BTS_value × this factor.
456
+ // At 1.0, acquisition fires exactly when BTS hits min_BTS_value.
457
+ BTS_ACQUIRE_THRESHOLD: 1,
458
+ // BTS_ACQUIRE_TARGET_MULTIPLIER: Target BTS after acquisition = min_BTS_value × this factor.
459
+ // At 3.0, fills to 3× min_BTS_value, creating a hysteresis band.
460
+ // The bot won't re-acquire until it burns through 2× min_BTS_value in fees.
461
+ BTS_ACQUIRE_TARGET_MULTIPLIER: 3,
462
+ // POOL_SLIPPAGE_TOLERANCE: Max slippage for pool swaps (decimal fraction).
463
+ // min_to_receive = expectedAmount × (1 - tolerance).
464
+ POOL_SLIPPAGE_TOLERANCE: 0.02,
465
+ };
466
+ // Collateral ratio health zones for MPA position management.
467
+ // Only the red boundaries are stored; everything between is green (acceptable).
468
+ let CR_ZONES = Object.freeze({
469
+ RED_HIGH: 3.0,
470
+ RED_LOW: 1.7,
471
+ });
472
+ // Default target collateral ratio when returning to green zone.
473
+ // Computed as the midpoint of the green band.
474
+ const DEFAULT_TARGET_CR = (CR_ZONES.RED_LOW + CR_ZONES.RED_HIGH) / 2;
475
+ // Build output directory name (relative to project root).
476
+ // Centralized in modules/utils/build_dir.ts to avoid circular dependency with
477
+ // general_settings.ts (both constants.ts and general_settings.ts import it).
478
+ const { BUILD_DIR } = require('./utils/build_dir');
479
+ const DAEMON_ERRORS = Object.freeze({
480
+ SESSION_EXPIRED: 'invalid or expired session',
481
+ SOURCE_AUTH_DENIED: 'invalid source authentication',
482
+ });
483
+ // DAEMON_CODES: Canonical error-code constants shared between the credential
484
+ // daemon, the bot client, and tests. Every code value is identical to its
485
+ // property name so that a receiver comparing against e.g.
486
+ // err.code === DAEMON_CODES.BROADCAST_DEADLINE stays in sync with
487
+ // senders that assign the same symbol.
488
+ const DAEMON_CODES = Object.freeze({
489
+ BROADCAST_DEADLINE: 'BROADCAST_DEADLINE',
490
+ CREDENTIAL_DAEMON_UNAVAILABLE: 'CREDENTIAL_DAEMON_UNAVAILABLE',
491
+ });
492
+ // Interactive credential-prompt limits
493
+ // (modules/chain_keys.ts master-password authentication, etc.).
494
+ // Capped to prevent infinite stdin loops on a corrupted vault or a forgotten
495
+ // password without requiring Ctrl+C.
496
+ let CREDENTIAL_PROMPTS = {
497
+ // MAX_MASTER_PASSWORD_ATTEMPTS: Hard upper bound on master-password
498
+ // retries. The vault unlock throws MasterPasswordError after this many
499
+ // failed attempts. The check is enforced both in _promptPassword and at
500
+ // the top of the authenticate() loop as defense-in-depth.
501
+ // 3 attempts: scrypt N=2^17 makes each guess expensive (~1s), so 3
502
+ // attempts absorbs legitimate typos without meaningfully weakening
503
+ // brute-force resistance.
504
+ MAX_MASTER_PASSWORD_ATTEMPTS: 3,
505
+ };
506
+ // BTS blockchain precision constant.
507
+ // Number of decimal places for BTS on BitShares (5 decimals → 1 satoshi = 0.00001 BTS).
508
+ // Used for converting raw chain deferred_fee to float BTS in sync/reconcile paths.
509
+ let BTS_PRECISION = 5;
510
+ // API request limits and batch sizes for blockchain operations
511
+ let API_LIMITS = {
512
+ // Maximum number of liquidity pools per batch request
513
+ POOL_BATCH_SIZE: 100,
514
+ // Maximum number of batch iterations for pool scanning (~10k total pools)
515
+ MAX_POOL_SCAN_BATCHES: 100,
516
+ // Depth of order book to fetch for market price derivation
517
+ ORDERBOOK_DEPTH: 5,
518
+ // Maximum number of limit orders per batch request
519
+ LIMIT_ORDERS_BATCH: 100,
520
+ // Maximum page for LP history API queries (market adapter)
521
+ LP_API_MAX_PAGE: 101,
522
+ };
523
+ // Fill processing configuration
524
+ let FILL_PROCESSING = {
525
+ // Mode for fill processing: 'history' reads from historical fills
526
+ MODE: 'history',
527
+ // Operation type for fill_order blockchain operations
528
+ OPERATION_TYPE: 4,
529
+ // Indicator for taker (non-maker) fills
530
+ TAKER_INDICATOR: 0,
531
+ // Maximum fills processed per rebalance/broadcast cycle.
532
+ // Behavior:
533
+ // - 1..MAX_FILL_BATCH_SIZE fills -> single unified batch
534
+ // - >MAX_FILL_BATCH_SIZE fills -> fixed-size chunking at MAX_FILL_BATCH_SIZE
535
+ // Set to 1 for current sequential behavior.
536
+ MAX_FILL_BATCH_SIZE: 4,
537
+ // MAX_CONSECUTIVE_CONSUMER_FAILURES: Threshold for the _consumeFillQueue
538
+ // watchdog. Below this count, the consumer re-schedules on every failure
539
+ // via setImmediate. At or above this count, the consumer switches to
540
+ // exponential backoff (see CONSUMER_BACKOFF_* below) instead of stopping
541
+ // permanently. The counter is reset on the consumer's success path and on
542
+ // shutdown, so transient failure bursts (e.g., a credential daemon outage
543
+ // that self-resolves) recover automatically once a cycle succeeds.
544
+ MAX_CONSECUTIVE_CONSUMER_FAILURES: 5,
545
+ // CONSUMER_BACKOFF_INITIAL_MS: First backoff delay after the consumer
546
+ // has hit MAX_CONSECUTIVE_CONSUMER_FAILURES. Each subsequent failure
547
+ // doubles the delay up to CONSUMER_BACKOFF_MAX_MS.
548
+ CONSUMER_BACKOFF_INITIAL_MS: 15000,
549
+ // CONSUMER_BACKOFF_MAX_MS: Upper bound on the consumer's backoff delay
550
+ // between retries once the failure budget is exhausted. With defaults
551
+ // (5 failures, 15s initial, 60s cap) the worst-case retry interval
552
+ // after a sustained outage is 60 seconds. The consumer NEVER stops
553
+ // re-scheduling entirely — the original infinite setImmediate loop was
554
+ // changed to slow-but-persistent retries.
555
+ // Reduced from 300s to 60s per tuning review: time-sensitive fills (e.g.,
556
+ // credential daemon recovery) should not wait 5 minutes between retries.
557
+ CONSUMER_BACKOFF_MAX_MS: 60000,
558
+ };
559
+ // Cleanup and maintenance parameters
560
+ // NOTE: CLEANUP_PROBABILITY is defined here but currently unused.
561
+ // Reserved for future cleanup-scheduling feature.
562
+ let MAINTENANCE = {
563
+ // Probability of running cleanup operation on any cycle (0.1 = 10%)
564
+ CLEANUP_PROBABILITY: 0.1
565
+ };
566
+ // Node management and health checking configuration
567
+ let NODE_MANAGEMENT = {
568
+ // Whether node failover is enabled when no explicit setting is present.
569
+ DEFAULT_ENABLED: true,
570
+ // Startup retry/backoff for transient BitShares connection failures.
571
+ STARTUP_RETRY_INITIAL_DELAY_MS: 500,
572
+ STARTUP_RETRY_MAX_DELAY_MS: 5000,
573
+ STARTUP_REFRESH_INTERVAL_MS: 30000,
574
+ STARTUP_CONNECT_TIMEOUT_MS: 5000,
575
+ // Cooldown window between successive failover assessments (ms).
576
+ // Kept above the native transport close-coalesce window so cascading
577
+ // close events normally collapse into one node-health assessment.
578
+ FAILOVER_ASSESSMENT_COOLDOWN_MS: 500,
579
+ // Default node list (used if no config file)
580
+ DEFAULT_NODES: [
581
+ 'wss://btsws.roelandp.nl/ws',
582
+ 'wss://cloud.xbts.io/ws',
583
+ 'wss://node.xbts.io/ws',
584
+ 'wss://public.xbts.io/ws',
585
+ 'wss://dex.iobanker.com/ws',
586
+ 'wss://api.dex.trading/',
587
+ 'wss://api.bts.mobi/ws',
588
+ 'wss://api.btslebin.com/ws'
589
+ ],
590
+ // Health check defaults
591
+ HEALTH_CHECK_INTERVAL_MS: 4 * 60 * 60 * 1000, // 4 hours
592
+ CREDENTIAL_DAEMON_NODE_REFRESH_INTERVAL_MS: 60 * 60 * 1000, // 1 hour - lightweight health-cache reread by credential daemon
593
+ HEALTH_CHECK_TIMEOUT_MS: 5000, // 5 seconds per check
594
+ MAX_PING_MS: 3000, // Max acceptable latency
595
+ BLACKLIST_THRESHOLD: 3, // Failures before blacklist
596
+ BLACKLIST_COOLDOWN_MS: 7 * 24 * 60 * 60 * 1000, // 7 days before retrying blacklisted nodes
597
+ // Expected chain ID (BitShares mainnet)
598
+ EXPECTED_CHAIN_ID: '4018d7844c78f6a6c41c6a552b898022310fc5dec06da467ee7905a8dad512c8',
599
+ // Selection strategy
600
+ SELECTION_STRATEGY: 'latency' // latency-based selection
601
+ };
602
+ // Pipeline timeout configuration
603
+ let PIPELINE_TIMING = {
604
+ // TIMEOUT_MS: Maximum duration for pipeline operations before forcing maintenance.
605
+ // Rationale: If pipeline hangs (stuck in lock, slow blockchain, etc), force a maintenance cycle.
606
+ // - 300000 ms = 5 minutes
607
+ // - Prevents infinite hangs; ensures bot recovers or logs the problem
608
+ // - Typical pipeline cycle completes in <100ms (unless blockchain is slow)
609
+ // - 5 minute timeout allows for slow network periods while still being responsive
610
+ // When timeout is exceeded, pipeline triggers maintenance (logs, cleanup, state check).
611
+ TIMEOUT_MS: 300000,
612
+ // RECOVERY_RETRY_INTERVAL_MS: Minimum cooldown time between fund invariant recovery attempts.
613
+ // Rationale: When a fund tracking invariant violation is detected:
614
+ // - First attempt: immediate (no wait) — try to fix quickly
615
+ // - Subsequent attempts: wait at least this duration — prevent tight retry loops
616
+ // - Prevents blockchain query spam while allowing eventual convergence
617
+ //
618
+ // Backoff Timeline Example (defaults):
619
+ // - T=0s: Violation detected → immediate recovery attempt #1
620
+ // - T=45s: Next violation check → still in cooldown, skip retry
621
+ // - T=65s: Next violation check → cooldown expired, attempt #2
622
+ // - T=125s: Attempt #3 (another 60s)
623
+ // - T=180s: Attempt #4
624
+ // - T=240s: Attempt #5 (max reached)
625
+ // - T=300s: Fill arrives → counter resets, ready for new recovery episode
626
+ //
627
+ // Default: 60000 ms (60 seconds) balances responsiveness with resource efficiency.
628
+ // - Too low (e.g., 5s): constant recovery attempts, high blockchain load
629
+ // - Too high (e.g., 600s): slow detection of new invariant drift, bad UX
630
+ RECOVERY_RETRY_INTERVAL_MS: 60000,
631
+ // MAX_RECOVERY_ATTEMPTS: Maximum recovery retry attempts before giving up.
632
+ // Rationale: Limit total recovery effort to prevent runaway loop.
633
+ // - After N failed attempts, bot stops recovery until next fill/sync
634
+ // - This allows bot to stabilize when recovery is impossible
635
+ // - Example: if funds are impossible to recover, don't keep trying indefinitely
636
+ //
637
+ // Retry Lifecycle (defaults, MAX = 5):
638
+ // - Attempts 1-5: Each spaced RECOVERY_RETRY_INTERVAL_MS apart (~60s each)
639
+ // - Attempt 5 fails: stop retrying
640
+ // - Next fill or blockchain fetch (after ~1 minute): counter resets, new episode starts
641
+ // - Total time blocked per episode: ~5 × 60s = 5 minutes before giving up
642
+ //
643
+ // Special Cases:
644
+ // - Set to 0: unlimited retries (not recommended; can cause infinite recovery loops)
645
+ // - Set to 1: one-shot only (minimal recovery effort; original patch15 behavior)
646
+ // - Set to 5: balanced (typical value; ~5 min of effort)
647
+ MAX_RECOVERY_ATTEMPTS: 5,
648
+ // FEE_EVENT_DEDUP_TTL_MS: How long to remember settled fee events for deduplication.
649
+ // Prevents the same fill from being fee-settled multiple times when
650
+ // re-detected across sync cycles or reconnections.
651
+ // Default: 6 hours (21600000 ms).
652
+ FEE_EVENT_DEDUP_TTL_MS: 6 * 60 * 60 * 1000,
653
+ // MAX_FEE_EVENT_CACHE_SIZE: Maximum number of fee events to keep in deduplication cache.
654
+ // Prevents unbounded memory growth during extended operation with many fills.
655
+ // When exceeded, oldest entries are evicted to 75% capacity.
656
+ // Default: 10000 entries (~60MB worst case with long event IDs).
657
+ MAX_FEE_EVENT_CACHE_SIZE: 10000,
658
+ // CACHE_EVICTION_RETENTION_RATIO: Target ratio of entries to keep during cache eviction.
659
+ // When cache exceeds max size, evict down to (maxSize × ratio) entries.
660
+ // Default: 0.75 (75%) - evicts oldest 25% to get back to 75% capacity.
661
+ CACHE_EVICTION_RETENTION_RATIO: 0.75,
662
+ // RECOVERY_DECAY_FALLBACK_MS: Default decay window for recovery attempt counter (milliseconds).
663
+ // Used when RECOVERY_RETRY_INTERVAL_MS is not configured.
664
+ // After this idle time, recovery attempt count resets to prevent permanent exhaustion.
665
+ // Default: 3 minutes (180000 ms).
666
+ RECOVERY_DECAY_FALLBACK_MS: 3 * 60 * 1000,
667
+ // RETRY defaults for generic withRetry() utility and similar patterns.
668
+ RETRY_MAX_ATTEMPTS: 3,
669
+ RETRY_BASE_DELAY_MS: 1000,
670
+ RETRY_MAX_DELAY_MS: 10000,
671
+ };
672
+ // Market Adapter Configuration
673
+ // Controls price tracking and grid recalculation triggers.
674
+ // See: market_adapter/market_adapter.ts, modules/account_bots.ts
675
+ let MARKET_ADAPTER = {
676
+ // Default candle/runtime cadence for the standalone market adapter.
677
+ // Keep these centralized so the adapter, logs, and tests do not drift from
678
+ // the production 1h candle workflow.
679
+ RUNTIME_DEFAULTS: {
680
+ intervalSeconds: 3600,
681
+ intervalLabel: '1h',
682
+ pollSeconds: 3600,
683
+ bootstrapLookbackHours: 720,
684
+ nativeBackfillHours: 6,
685
+ maxStaleHours: 6,
686
+ sourceRetries: 3,
687
+ retryDelayMs: 800,
688
+ maxPages: 80,
689
+ pageLimit: 100,
690
+ minRequiredCandles: 80,
691
+ },
692
+ // Watchdog defaults for launchers that supervise the standalone adapter.
693
+ // Reuse existing node-startup and recovery timings so restart polling and
694
+ // stability windows stay aligned with the rest of the runtime.
695
+ WATCHDOG_DEFAULTS: {
696
+ staleLockGraceMs: 30 * 60 * 1000,
697
+ // Poll every 30s during startup/recovery and allow 13 fast retries:
698
+ // enough to ride out transient launch failures without retrying forever.
699
+ intervalMs: NODE_MANAGEMENT.STARTUP_REFRESH_INTERVAL_MS,
700
+ maxRestarts: 13,
701
+ minUptimeMs: PIPELINE_TIMING.RECOVERY_RETRY_INTERVAL_MS,
702
+ restartExhaustionResetMs: PIPELINE_TIMING.RECOVERY_DECAY_FALLBACK_MS,
703
+ },
704
+ // KIBANA_REQUEST_TIMEOUT_MS: Shared per-request timeout for Kibana-backed candle fetches.
705
+ // Used by both the standalone LP history fetcher and the live market adapter's
706
+ // bootstrap / repair / backfill calls so long-running scans share one ceiling.
707
+ KIBANA_REQUEST_TIMEOUT_MS: 3 * 60 * 1000,
708
+ // KIBANA_FETCH_CHUNK_MONTHS: Default historical window size for the standalone
709
+ // LP fetcher when it splits long requests into sequential sub-requests.
710
+ KIBANA_FETCH_CHUNK_MONTHS: 3,
711
+ // CEX_API_DELAY_MS: Minimum delay between paginated CEX API requests to avoid
712
+ // rate limiting. Applied between candle-fetch pages during synthetic data seeding.
713
+ CEX_API_DELAY_MS: 500,
714
+ // AMA_DELTA_THRESHOLD_PERCENT: Percentage change in AMA center price that triggers a grid reset.
715
+ // - When AMA price moves ±AMA_DELTA_THRESHOLD_PERCENT from the last recorded center,
716
+ // a recalculate.<botKey>.trigger file is written to signal grid regeneration.
717
+ // - Configurable per deployment via profiles/general.settings.json under MARKET_ADAPTER.
718
+ // - Range: 0.1 to 50.0 (enforced in account_bots.ts)
719
+ // - Default: 1.00 (slightly more responsive than the 1.21% sigma calibration baseline)
720
+ AMA_DELTA_THRESHOLD_PERCENT: 1.00,
721
+ // AMA_SLOPE_DELTA_THRESHOLD_PERCENT: Percentage of max slope used as the slope trigger
722
+ // threshold. Used as (AMA_SLOPE_DELTA_THRESHOLD_PERCENT / 100) in the computation:
723
+ // threshold = (AMA_SLOPE_DELTA_THRESHOLD_PERCENT / 100) × maxSlopePct
724
+ // - Default: 10 (meaning 10% of max slope)
725
+ AMA_SLOPE_DELTA_THRESHOLD_PERCENT: 10,
726
+ // DYNAMIC_WEIGHT_ASYMMETRIC_TREND_THRESHOLD: Minimum blended trend strength required
727
+ // before the bot applies a directional weight shift in the asymmetrical path.
728
+ // Higher values ignore weaker trend signals and keep weights closer to the static baseline.
729
+ // Lower values allow smaller trend signals to affect buy/sell weighting.
730
+ // Default is 0 so the gate stays disabled unless a market/bot override enables it.
731
+ // nob: th% (Min Output Threshold)
732
+ DYNAMIC_WEIGHT_ASYMMETRIC_TREND_THRESHOLD: 0,
733
+ // DYNAMIC_WEIGHT_SYMMETRIC_SHIFT_THRESHOLD: Minimum volatility shift required before the
734
+ // symmetric ATR dampening actually changes the output weights.
735
+ // Higher values ignore smaller ATR-driven adjustments.
736
+ // Lower values let volatility influence the symmetric shift sooner.
737
+ // (used by the volatility research tool)
738
+ DYNAMIC_WEIGHT_SYMMETRIC_SHIFT_THRESHOLD: 0.1,
739
+ // DYNAMIC_WEIGHT_CLIP_PERCENTILE: Outlier filter for unusually large AMA/Kalman moves.
740
+ // Higher values suppress more extreme spikes before they influence dynamic weights.
741
+ // 0 disables clipping.
742
+ // Configurable per market or per bot via market_profiles.json or botOverrides.
743
+ // nob: clip%
744
+ DYNAMIC_WEIGHT_CLIP_PERCENTILE: 10,
745
+ // DYNAMIC_WEIGHT_AMA_LOOKBACK_BARS: Lookback window for measuring AMA trend.
746
+ // Lower values react faster to recent price changes.
747
+ // Higher values smooth the signal and require a more sustained move.
748
+ // nob: lb (Lookback Bars)
749
+ DYNAMIC_WEIGHT_AMA_LOOKBACK_BARS: 9,
750
+ // DYNAMIC_WEIGHT_AMA_MAX_SLOPE_PCT: Average per-bar trend size that counts as "full strength" for AMA.
751
+ // Lower values make the AMA channel reach maximum influence more easily.
752
+ // Higher values require a stronger price move before AMA reaches full effect.
753
+ // nob: amaS% (AMA Max Slope %)
754
+ DYNAMIC_WEIGHT_AMA_MAX_SLOPE_PCT: 0.085,
755
+ // DYNAMIC_WEIGHT_KALMAN_MAX_SLOPE_PCT: Trend size that counts as "full strength" for
756
+ // the Kalman composite branch. Kept separate from the AMA slope knob so the two
757
+ // channels can saturate independently.
758
+ // Lower values make the Kalman channel reach maximum influence more easily.
759
+ // Higher values require a stronger move before the Kalman branch reaches full effect.
760
+ // nob: kalS% (Kalman Max Slope %)
761
+ DYNAMIC_WEIGHT_KALMAN_MAX_SLOPE_PCT: 0.8,
762
+ // DYNAMIC_WEIGHT_AMA_NEUTRAL_ZONE_PCT: Ignore small AMA moves around flat price action.
763
+ // Higher values create a larger neutral zone and reduce small trend reactions.
764
+ // Lower values make the AMA channel react to smaller moves.
765
+ // nob: nz% (Neutral Zone %)
766
+ DYNAMIC_WEIGHT_AMA_NEUTRAL_ZONE_PCT: 0,
767
+ // DYNAMIC_WEIGHT_ALPHA: Blend between AMA trend and Kalman trend.
768
+ // 0 = pure Kalman, 1 = pure AMA.
769
+ // Higher values trust AMA more, lower values trust Kalman more.
770
+ // nob: alpha
771
+ DYNAMIC_WEIGHT_ALPHA: 0.5,
772
+ // DYNAMIC_WEIGHT_DW: Blend inside the Kalman signal between velocity and displacement.
773
+ // Lower values emphasize momentum/velocity.
774
+ // Higher values emphasize how far price has moved away from the modal baseline.
775
+ // Default 0.5 balances velocity and displacement.
776
+ // nob: dw (Displacement Weight)
777
+ DYNAMIC_WEIGHT_DW: 0.5,
778
+ // DYNAMIC_WEIGHT_GAIN: Overall strength of the blended dynamic-weight signal.
779
+ // Higher values make dynamic weights more aggressive.
780
+ // Lower values keep weights closer to the static baseline.
781
+ // nob: gain
782
+ DYNAMIC_WEIGHT_GAIN: 1.0,
783
+ // DYNAMIC_WEIGHT_ASYMMETRIC_OFFSET_CLAMP: Maximum directional offset away from neutral.
784
+ // Overridable per market pair or per bot via market_adapter_settings.json.
785
+ DYNAMIC_WEIGHT_ASYMMETRIC_OFFSET_CLAMP: 0.5,
786
+ // DYNAMIC_WEIGHT_SYMMETRIC_SHIFT_CLAMP: Maximum symmetric downward shift from volatility.
787
+ // Overridable per market pair or per bot via market_adapter_settings.json.
788
+ DYNAMIC_WEIGHT_SYMMETRIC_SHIFT_CLAMP: 0.5,
789
+ // DYNAMIC_WEIGHT_ATR_PERIOD_DEFAULT: ATR lookback used by the live volatility penalty
790
+ // and the volatility research chart. 14 is the standard Wilder ATR window.
791
+ // Overridable per market pair or per bot via market_adapter_settings.json.
792
+ DYNAMIC_WEIGHT_ATR_PERIOD_DEFAULT: 14,
793
+ // DYNAMIC_WEIGHT_MIN_WEIGHT / MAX_WEIGHT: Final weight clamp after all adjustments.
794
+ DYNAMIC_WEIGHT_MIN_WEIGHT: -1,
795
+ DYNAMIC_WEIGHT_MAX_WEIGHT: 2,
796
+ // DYNAMIC_WEIGHT_REGIME_SENSITIVITY: How strongly the regime filter dampens or preserves
797
+ // the dynamic-weight signal.
798
+ // 0 ignores regime filtering, 1 uses the table as-is, and higher values make bad regimes
799
+ // suppress the signal more aggressively.
800
+ // nob: regime
801
+ DYNAMIC_WEIGHT_REGIME_SENSITIVITY: 1,
802
+ // Shared Kalman tuning defaults used by both the research HTML and the live dynamic-weight
803
+ // market adapter so both paths start from the same smoothing and echo behavior.
804
+ DYNAMIC_WEIGHT_KALMAN_R_NOISE_DEFAULT: 0.05,
805
+ DYNAMIC_WEIGHT_KALMAN_Q_TACTICAL_DEFAULT: 0.01,
806
+ DYNAMIC_WEIGHT_KALMAN_Q_MODAL_DEFAULT: 0.0001,
807
+ DYNAMIC_WEIGHT_KALMAN_SMOOTH_PCT_DEFAULT: 100,
808
+ DYNAMIC_WEIGHT_KALMAN_DISP_SCALE_MULT_DEFAULT: 1.8,
809
+ DYNAMIC_WEIGHT_KALMAN_DISP_THRESHOLD_MULT_DEFAULT: 1.5,
810
+ DYNAMIC_WEIGHT_KALMAN_SMOOTH_SPAN_PCT_DEFAULT: 100,
811
+ DYNAMIC_WEIGHT_SIGNAL_CONFIRM_BARS_DEFAULT: 0,
812
+ // Adaptive Kalman velocity smoothing budget (0-1.0)
813
+ DYNAMIC_WEIGHT_KALMAN_SMOOTHING_BUDGET: 0.60,
814
+ DYNAMIC_WEIGHT_KALMAN_SMOOTHING_FLOOR: 0,
815
+ // DYNAMIC_WEIGHT_ABSOLUTE_THRESHOLD_DEFAULT: Minimum raw regime multiplier deviation before
816
+ // the dampening branch is allowed to reduce the output.
817
+ DYNAMIC_WEIGHT_ABSOLUTE_THRESHOLD_DEFAULT: 0.05,
818
+ // DYNAMIC_WEIGHT_DISP_SCALE_MIN_PCT: Minimum Kalman displacement scale in percent.
819
+ // This is the active Kalman displacement scale in both the HTML research tool and the
820
+ // live directional signal path.
821
+ // The live smoother clamps this to at least 1.0 so 0.5% displacements do not saturate
822
+ // confidence too early.
823
+ // Exposed in the research chart as the `dsp` control.
824
+ DYNAMIC_WEIGHT_DISP_SCALE_MIN_PCT: 1.0,
825
+ // DYNAMIC_WEIGHT_VOLATILITY_EXPONENT: Controls how quickly the volatility penalty ramps up.
826
+ // Higher values delay the penalty in calm markets and make it matter more in higher volatility.
827
+ // Lower values make the penalty start affecting weights earlier.
828
+ // Overridable per market pair or per bot via market_adapter_settings.json.
829
+ DYNAMIC_WEIGHT_VOLATILITY_EXPONENT: 1.0,
830
+ // DYNAMIC_WEIGHT_VOLATILITY_SCALE_X_DEFAULT: Overall strength multiplier of the ATR-based
831
+ // volatility penalty. Higher = more aggressive shrinking of unused inventory.
832
+ // 1-100 range; 10.0 is a recommended start that leaves orders on the book during
833
+ // mild volatility. Increase to 20-30 if you want the bot to pull orders more
834
+ // aggressively during volatile periods.
835
+ // Overridable per market pair or per bot via market_adapter_settings.json.
836
+ DYNAMIC_WEIGHT_VOLATILITY_SCALE_X_DEFAULT: 10.0,
837
+ // ASYMMETRIC_BOUNDS_MAX_ASYMMETRY_FACTOR: Maximum ratio tilt applied to min/max
838
+ // grid bounds when the AMA slope indicates a strong trend. At full slope strength:
839
+ // Downtrend: minPrice divisor grows by 1+factor, maxPrice multiplier shrinks by 1-factor
840
+ // Uptrend: maxPrice multiplier grows by 1+factor, minPrice divisor shrinks by 1-factor
841
+ // This widens the bound in the trend direction and tightens the opposite side,
842
+ // giving the grid more room when the AMA center trails price in a trend.
843
+ // 0 disables asymmetry. Recommended range: 0.15–0.35.
844
+ // Overridable per bot via market_adapter_settings.json.
845
+ ASYMMETRIC_BOUNDS_MAX_ASYMMETRY_FACTOR: 0.35,
846
+ // STALE_TAIL_THRESHOLD_CANDLES: Number of consecutive candles with an identical close
847
+ // price that triggers pruning of the trailing tail. Prevents gap-filled synthetic candles
848
+ // from carrying a frozen price forward indefinitely when the pool has no activity.
849
+ // At 1h intervals, 24 = 24 hours. Overridable via cfg.staleTailThreshold.
850
+ STALE_TAIL_THRESHOLD_CANDLES: 24,
851
+ // HURST_CONFIG: Standard window and scales for Hurst exponent calculation.
852
+ HURST_CONFIG: {
853
+ window: 256,
854
+ scales: [8, 16, 32, 64],
855
+ },
856
+ // PE_CONFIG: Standard parameters for Permutation Entropy calculation.
857
+ PE_CONFIG: {
858
+ m: 5,
859
+ delay: 1,
860
+ window: 54,
861
+ },
862
+ // HURST_ZONE_BAND: Width of the neutral Hurst zone between trending and mean-reverting regimes.
863
+ // Higher values classify more markets as "random/unclear".
864
+ // Lower values switch more quickly into trending or mean-reverting states.
865
+ HURST_ZONE_BAND: 0.05,
866
+ // PE_NODES: Signal-quality bands for permutation entropy.
867
+ // Lower entropy means cleaner, more structured price action.
868
+ // Higher entropy means noisier price action, where the bot should trust signals less.
869
+ PE_NODES: [0.60, 0.725, 0.85],
870
+ // REGIME_TABLE: Signal-strength table for combinations of market structure and noise.
871
+ // Rows are Hurst regimes [trending, random, mean-reverting].
872
+ // Columns are entropy regimes [structured, mixed, noisy].
873
+ // Higher values preserve more of the dynamic-weight signal.
874
+ // Lower values dampen the signal in unclear or hostile conditions.
875
+ REGIME_TABLE: [
876
+ [1.0, 0.7, 0.3], // Trending (H > 0.5 + HURST_ZONE_BAND)
877
+ [0.6, 0.4, 0.15], // Random
878
+ [0.3, 0.2, 0.05], // Mean-reverting (H < 0.5 - HURST_ZONE_BAND)
879
+ ],
880
+ // DEFAULT_AMA_KEY: Built-in default profile for `gridPrice: "ama"` when no
881
+ // pair-specific market_profiles entry exists.
882
+ DEFAULT_AMA_KEY: 'AMA3',
883
+ // AMAS: Built-in AMA presets derived from the local LP 1.19.133 fitting results.
884
+ // Fitted with per-AMA λ weights (0.0031 / 0.0025 / 0.00185 / 0.0013) on 1h candles
885
+ // (2023-07 → 2026-07, SMA-warmup-aligned optimizer, ER=781 fixed, Fast=5.2 fixed).
886
+ // These serve as stable defaults for the market adapter and can be overridden by
887
+ // pair-specific profiles in profiles/market_profiles.json.
888
+ AMAS: {
889
+ AMA1: {
890
+ name: 'AMA1 (cap 25%)',
891
+ erPeriod: 781,
892
+ fastPeriod: 5.2,
893
+ slowPeriod: 62.1,
894
+ },
895
+ AMA2: {
896
+ name: 'AMA2 (cap 30%)',
897
+ erPeriod: 781,
898
+ fastPeriod: 5.2,
899
+ slowPeriod: 71.7,
900
+ },
901
+ AMA3: {
902
+ name: 'AMA3 (cap 35%)',
903
+ erPeriod: 781,
904
+ fastPeriod: 5.2,
905
+ slowPeriod: 82.7,
906
+ },
907
+ AMA4: {
908
+ name: 'AMA4 (cap 40%)',
909
+ erPeriod: 781,
910
+ fastPeriod: 5.2,
911
+ slowPeriod: 95.5,
912
+ },
913
+ },
914
+ // AMA_CONVERGENCE_ER_AVG: Typical market Efficiency Ratio used to estimate
915
+ // average AMA convergence rate from cold start. Lower = more conservative
916
+ // (assumes more noise → slower convergence → more candles needed).
917
+ // Calibrated against pool 133 1h (2023-05-07 -> 2026-05-06) — implied ER corrects for
918
+ // Jensen's inequality (E[f(ER)] ≠ f(E[ER]) for convex f = x²).
919
+ AMA_CONVERGENCE_ER_AVG: 0.151,
920
+ // AMA_CONVERGENCE_EPSILON: Target fraction of initialization bias remaining
921
+ // after convergence. 0.01 = 99 % of the initial bias has decayed.
922
+ AMA_CONVERGENCE_EPSILON: 0.01,
923
+ // AMA_ER_SMOOTH_FAST_PERIOD: Fast-period equivalent for smoothing the raw
924
+ // Efficiency Ratio via EMA before it enters the SC formula. Raw ER can spike
925
+ // at regime boundaries (trending ↔ ranging), causing jerky AMA transitions
926
+ // and false grid re-centering triggers.
927
+ // 0 = disabled (raw ER used directly, backward compatible).
928
+ // Enabled alpha = 2 / (AMA_ER_SMOOTH_FAST_PERIOD + 1).
929
+ // Overridable per bot via bots.json inline `ama.erSmoothPeriod` field.
930
+ AMA_ER_SMOOTH_FAST_PERIOD: 0,
931
+ };
932
+ // Logging Level Configuration
933
+ // Options:
934
+ // - 'debug': Verbose output including calculation details, API calls, and flow tracing.
935
+ // - 'info': Standard production output. State changes (Active/Filled), keys confirmations, and errors.
936
+ // - 'warn': Warnings (non-critical issues) and errors only.
937
+ // - 'error': Critical errors only.
938
+ // - 'critical': Sustained critical failures (fill consumer cascade, permanent faults).
939
+ let LOG_LEVEL = 'info';
940
+ // Fine-grained Logging Configuration
941
+ // Controls what gets logged at each level and which categories are enabled
942
+ // Can be overridden in profiles/general.settings.json via LOGGING_CONFIG
943
+ let LOGGING_CONFIG = {
944
+ changeTracking: {
945
+ enabled: true,
946
+ ignoreMinor: {
947
+ fundPrecision: 8, // Ignore fund changes smaller than 0.00000001
948
+ pricePrecision: 4 // Ignore price changes smaller than 0.0001
949
+ }
950
+ },
951
+ categories: {
952
+ fundChanges: {
953
+ enabled: true,
954
+ level: "debug",
955
+ options: {
956
+ onlyChanges: true,
957
+ aggregateSmall: true,
958
+ hideComponentBreakdown: true
959
+ }
960
+ },
961
+ orderStateChanges: {
962
+ enabled: true,
963
+ level: "info",
964
+ options: {
965
+ onlyChanges: true,
966
+ compactFormat: true
967
+ }
968
+ },
969
+ fillEvents: {
970
+ enabled: true,
971
+ level: "info",
972
+ options: {
973
+ onlyChanges: true,
974
+ aggregateFees: true
975
+ }
976
+ },
977
+ boundaryEvents: {
978
+ enabled: true,
979
+ level: "info",
980
+ options: {
981
+ onlyChanges: true
982
+ }
983
+ },
984
+ errorWarnings: {
985
+ enabled: true,
986
+ level: "warn",
987
+ options: {
988
+ alwaysLog: true
989
+ }
990
+ },
991
+ edgeCases: {
992
+ enabled: true,
993
+ level: "warn",
994
+ options: {
995
+ alwaysLog: true
996
+ }
997
+ }
998
+ },
999
+ // Rotation config: maxSize is the total disk budget for all log files (current + rotated).
1000
+ // Per-file limit = maxSize / (maxFiles + 1). Oldest rotated files are pruned beyond maxFiles.
1001
+ rotation: {
1002
+ enabled: true,
1003
+ maxSize: 1181116007, // 1.1 GB total log budget
1004
+ maxFiles: 10
1005
+ },
1006
+ json: {
1007
+ enabled: false
1008
+ },
1009
+ display: {
1010
+ gridDiagnostics: {
1011
+ enabled: false,
1012
+ showOnDemandOnly: true
1013
+ },
1014
+ fundStatus: {
1015
+ enabled: false,
1016
+ showDetailed: false,
1017
+ compactFormat: true
1018
+ },
1019
+ statusSummary: {
1020
+ enabled: false
1021
+ },
1022
+ colors: {
1023
+ enabled: "auto"
1024
+ }
1025
+ }
1026
+ };
1027
+ // Updater Configuration
1028
+ let UPDATER = {
1029
+ // Whether the automated updater is enabled
1030
+ ACTIVE: false,
1031
+ // Hardcoded repository URL
1032
+ REPOSITORY_URL: "https://github.com/froooze/DEXBot2.git",
1033
+ // Default branch policy: 'auto' (track current), 'main', 'dev', 'test'
1034
+ BRANCH: "auto",
1035
+ // Automated update schedule using Cron format:
1036
+ // ┌────────────── minute (0 - 59)
1037
+ // │ ┌──────────── hour (0 - 23)
1038
+ // │ │ ┌────────── day of month (1 - 31)
1039
+ // │ │ │ ┌──────── month (1 - 12)
1040
+ // │ │ │ │ ┌────── day of week (0 - 6) (0 is Sunday)
1041
+ // │ │ │ │ │
1042
+ // 0 0 * * * (Default: Daily at midnight)
1043
+ SCHEDULE: "0 0 * * *"
1044
+ };
1045
+ let LAUNCHER = {
1046
+ MONOLITHIC: {
1047
+ maxRestarts: 13,
1048
+ minUptimeMs: 24 * 60 * 60 * 1000,
1049
+ restartDelayMs: 3000,
1050
+ controlStopTimeoutMs: 12000,
1051
+ // SUPERVISOR_POLL_TIMEOUT_MS: Maximum wall-clock duration the
1052
+ // `node unlock <bot>` (or monolithic wrapper) waits for the
1053
+ // supervisor to report that all supervised bots have stopped. If a
1054
+ // bot is stuck in a PM2 restart loop and reports `restarting`
1055
+ // indefinitely, the launcher's setInterval poll would never clear.
1056
+ // After this timeout the launcher rejects the runIsolated promise
1057
+ // with a descriptive error so the user can intervene.
1058
+ SUPERVISOR_POLL_TIMEOUT_MS: 60000,
1059
+ // DAEMON_SIGKILL_DEADLINE_MS: Maximum time the credential-daemon
1060
+ // stop path will wait for a SIGKILL to take effect before giving up
1061
+ // and warning that the process may be in uninterruptible sleep.
1062
+ // Most credential daemons exit within ~100ms of SIGKILL on healthy
1063
+ // systems; 10s is a generous upper bound for slow disks or heavy
1064
+ // process state.
1065
+ DAEMON_SIGKILL_DEADLINE_MS: 10000,
1066
+ },
1067
+ // SUPERVISOR: Centralized defaults for bot_supervisor.ts.
1068
+ // Previously hardcoded locally in the supervisor module.
1069
+ SUPERVISOR: {
1070
+ MAX_RESTARTS: 13,
1071
+ MIN_UPTIME_MS: 24 * 60 * 60 * 1000,
1072
+ RESTART_DELAY_MS: 3000,
1073
+ SHUTDOWN_TIMEOUT_MS: 5000,
1074
+ STAGGER_DELAY_MS: 500,
1075
+ MAX_MEMORY_MB: 250,
1076
+ MEMORY_CHECK_INTERVAL_MS: 60000,
1077
+ STATUS_LOG_INTERVAL_MS: 300000,
1078
+ MAX_CRON_LOOKAHEAD_MINUTES: 366 * 24 * 60,
1079
+ },
1080
+ };
1081
+ // Copy-on-Write (COW) Grid performance thresholds
1082
+ // NOTE: Currently unused — reserved for future COW performance monitoring.
1083
+ let COW_PERFORMANCE = {
1084
+ MAX_REBALANCE_PLANNING_MS: 100,
1085
+ MAX_COMMIT_MS: 50,
1086
+ MAX_MEMORY_MB: 50,
1087
+ INDEX_REBUILD_THRESHOLD: 10000,
1088
+ GRID_MEMORY_WARNING: 5000,
1089
+ GRID_MEMORY_CRITICAL: 10000,
1090
+ // WORKING_GRID_BYTES_PER_ORDER: Estimated memory usage per order in working grid (bytes).
1091
+ // Used for memory profiling and warning thresholds.
1092
+ // Default: 500 bytes (includes order object, metadata, and overhead).
1093
+ WORKING_GRID_BYTES_PER_ORDER: 500
1094
+ };
1095
+ // Native BitShares Client Configuration
1096
+ // Constants from the btsdex → native integration (modules/bitshares-native/).
1097
+ // Documents chain-level constants, transport tuning, cache sizing, and serialization
1098
+ // parameters. The underlying native module is self-contained; these mirror its
1099
+ // defaults and serve as the canonical reference for DEXBot2 runtime behavior.
1100
+ //
1101
+ // Structure:
1102
+ // NATIVE_CLIENT.CHAIN - Graphene chain parameters
1103
+ // NATIVE_CLIENT.OPERATIONS - Operation type IDs
1104
+ // NATIVE_CLIENT.OBJECT_TYPES - Object space/type IDs
1105
+ // NATIVE_CLIENT.TRANSACTION - Transaction builder limits
1106
+ // NATIVE_CLIENT.TRANSPORT - WebSocket transport tuning
1107
+ // NATIVE_CLIENT.SUBSCRIPTIONS - Fill-detection subscription settings
1108
+ // NATIVE_CLIENT.RESOLVERS - Asset/account cache configuration
1109
+ // NATIVE_CLIENT.ECC - Cryptographic constants (reference only)
1110
+ //
1111
+ // Source files:
1112
+ // modules/bitshares-native/serial/chain_constants.ts (CHAIN, OPERATIONS, OBJECT_TYPES)
1113
+ // modules/bitshares-native/tx/builder.ts (TRANSACTION)
1114
+ // modules/bitshares-native/transport.ts (TRANSPORT)
1115
+ // modules/bitshares-native/subscriptions.ts (SUBSCRIPTIONS)
1116
+ // modules/bitshares-native/resolvers.ts (RESOLVERS)
1117
+ // modules/bitshares-native/crypto/ecc.ts (ECC)
1118
+ // modules/bitshares-native/serial/types.ts (object_id encoding)
1119
+ // modules/bitshares-native/serial/operations.ts (operation serializers)
1120
+ // modules/bitshares-native/chain_client.ts (API registration, core asset)
1121
+ // modules/bitshares_client.ts (connection proxy, event wiring)
1122
+ //
1123
+ let NATIVE_CLIENT = {
1124
+ // -------------------------------------------------------------------------
1125
+ // CHAIN — Graphene blockchain parameters
1126
+ // -------------------------------------------------------------------------
1127
+ CHAIN: {
1128
+ // Precision divisor for blockchain amounts (e.g. 100000 = 5 decimal places).
1129
+ // All on-chain amounts are integers; divide by this for human-readable display.
1130
+ PRECISION: 100000,
1131
+ // Maximum serialized transaction size allowed by the Graphene protocol (bytes).
1132
+ // Transactions exceeding this are rejected by the network. Distinct from the
1133
+ // smaller MAX_TX_SIZE soft limit used by the transaction builder.
1134
+ MAX_TRANSACTION_SIZE: 262144,
1135
+ // Maximum time until transaction expiration (seconds, 24 hours).
1136
+ // Transactions expire after this if not included in a block.
1137
+ MAX_TIME_UNTIL_EXPIRATION: 86400,
1138
+ // Human-readable address prefix for public keys (BTS = BitShares mainnet).
1139
+ ADDRESS_PREFIX: 'BTS',
1140
+ // BitShares mainnet chain ID.
1141
+ // References NODE_MANAGEMENT.EXPECTED_CHAIN_ID (defined above) to avoid
1142
+ // duplicating the same hex literal across two locations.
1143
+ CHAIN_ID: NODE_MANAGEMENT.EXPECTED_CHAIN_ID,
1144
+ // 100% and 1% in Graphene basis points (bps).
1145
+ // Used for fee calculations, credit-offer rates, and collateral ratio checks.
1146
+ PERCENT_100: 10000,
1147
+ PERCENT_1: 100,
1148
+ // Core (fee) asset object ID. Always BTS on mainnet (1.3.0).
1149
+ // Used as default fee payment asset for transaction preparation.
1150
+ CORE_ASSET_ID: '1.3.0',
1151
+ },
1152
+ // -------------------------------------------------------------------------
1153
+ // OPERATIONS — Graphene operation type IDs
1154
+ // -------------------------------------------------------------------------
1155
+ // Corresponds to OP_* constants in serial/chain_constants.ts.
1156
+ // FILL_PROCESSING.OPERATION_TYPE (4) references OP_FILL_ORDER.
1157
+ OPERATIONS: {
1158
+ TRANSFER: 0,
1159
+ LIMIT_ORDER_CREATE: 1,
1160
+ LIMIT_ORDER_CANCEL: 2,
1161
+ CALL_ORDER_UPDATE: 3,
1162
+ FILL_ORDER: 4,
1163
+ ASSET_SETTLE: 17,
1164
+ CREDIT_OFFER_ACCEPT: 72,
1165
+ CREDIT_DEAL_REPAY: 73,
1166
+ CREDIT_DEAL_UPDATE: 76,
1167
+ LIMIT_ORDER_UPDATE: 77,
1168
+ LIQUIDITY_POOL: 63,
1169
+ },
1170
+ // -------------------------------------------------------------------------
1171
+ // OBJECT_TYPES — Graphene object space/type IDs
1172
+ // -------------------------------------------------------------------------
1173
+ // Space 1 (protocol), used for blockchain entity identification.
1174
+ // Object IDs follow the format "space.type.instance" (e.g. "1.2.12345" = account).
1175
+ OBJECT_TYPES: {
1176
+ NULL: 0,
1177
+ BASE: 1,
1178
+ ACCOUNT: 2,
1179
+ ASSET: 3,
1180
+ FORCE_SETTLEMENT: 4,
1181
+ COMMITTEE_MEMBER: 5,
1182
+ WITNESS: 6,
1183
+ LIMIT_ORDER: 7,
1184
+ CALL_ORDER: 8,
1185
+ CUSTOM: 9,
1186
+ PROPOSAL: 10,
1187
+ OPERATION_HISTORY: 11,
1188
+ WITHDRAW_PERMISSION: 12,
1189
+ VESTING_BALANCE: 13,
1190
+ WORKER: 14,
1191
+ BALANCE: 15,
1192
+ HTLC: 16,
1193
+ TICKET: 17,
1194
+ LIQUIDITY_POOL: 18,
1195
+ SAMET_FUND: 19,
1196
+ CREDIT_OFFER: 20,
1197
+ CREDIT_DEAL: 21,
1198
+ },
1199
+ // -------------------------------------------------------------------------
1200
+ // TRANSACTION — Transaction builder limits (tx/builder.js)
1201
+ // -------------------------------------------------------------------------
1202
+ TRANSACTION: {
1203
+ // Soft limit: maximum serialized transaction size (bytes).
1204
+ // Transactions larger than this are rejected by the builder before broadcast.
1205
+ // Must be ≤ CHAIN.MAX_TRANSACTION_SIZE (262144).
1206
+ MAX_SIZE_BYTES: 64000,
1207
+ // Maximum number of operations per single transaction.
1208
+ // Batching above this limit requires multiple transactions.
1209
+ MAX_OPS_PER_TX: 200,
1210
+ // Default transaction expiration time (seconds, 5 minutes).
1211
+ // After signing, the transaction must be broadcast and confirmed within this window.
1212
+ DEFAULT_EXPIRE_SEC: 300,
1213
+ // Hard cap on transaction expiration (seconds, 24 hours).
1214
+ // Enforced by the builder; values above this are clamped down.
1215
+ MAX_EXPIRE_SEC: 86400,
1216
+ },
1217
+ // -------------------------------------------------------------------------
1218
+ // TRANSPORT — WebSocket connection tuning (transport.js)
1219
+ // -------------------------------------------------------------------------
1220
+ TRANSPORT: {
1221
+ // Maximum time for WebSocket handshake to complete (ms).
1222
+ // If the handshake does not complete within this window, the node is skipped.
1223
+ CONNECT_TIMEOUT_MS: 10000,
1224
+ // Outer bound on a full _nativeClient.connect() operation (ms).
1225
+ // The native transport sweeps all configured nodes sequentially, each
1226
+ // bounded by CONNECT_TIMEOUT_MS, before giving up. With 8 default
1227
+ // nodes × 10s handshake = 80s worst case; this gives a 10s buffer
1228
+ // so the outer wrapper rejects cleanly without a hard tail-latency
1229
+ // cliff. The native's connect() cannot be cancelled, so this is a
1230
+ // "stop waiting" signal only — the underlying sweep continues in
1231
+ // the background even after the outer bound fires.
1232
+ CONNECT_TOTAL_TIMEOUT_MS: 90000,
1233
+ // Maximum time waiting for an RPC response before timing out (ms).
1234
+ // Applies to all native JSON-RPC calls (database, history, broadcast).
1235
+ RPC_TIMEOUT_MS: 15000,
1236
+ // Interval between keepalive pings during idle periods (ms).
1237
+ // Uses a lightweight `login` call to detect severed connections early.
1238
+ KEEPALIVE_INTERVAL_MS: 45000,
1239
+ // Coalesce duplicate close events from the same active socket (ms).
1240
+ // Some WebSocket implementations can emit close/error cascades for one
1241
+ // underlying connection failure; this window prevents redundant failover work.
1242
+ CLOSE_COALESCE_MS: 250,
1243
+ // NOTE: These constants are informational but not imported by transport.ts
1244
+ // Reconnection backoff parameters (ms).
1245
+ // Reconnect delay = min(base × 2^attempt + random(0..1000), max).
1246
+ RECONNECT_BASE_MS: 1000,
1247
+ RECONNECT_MAX_MS: 30000,
1248
+ },
1249
+ // -------------------------------------------------------------------------
1250
+ // SUBSCRIPTIONS — Fill-detection subscription settings (subscriptions.js)
1251
+ // -------------------------------------------------------------------------
1252
+ SUBSCRIPTIONS: {
1253
+ // Graphene callback ID used for set_subscribe_callback.
1254
+ // Fixed value; must match the ID registered with the API.
1255
+ CALLBACK_ID: 1,
1256
+ // Object space/type prefix for operation history objects (1.11.x).
1257
+ // Fill_order virtual operations produce 1.11.x operation history objects.
1258
+ // Notice handlers filter incoming object-change notifications by this prefix
1259
+ // to isolate fill events from other blockchain activity.
1260
+ OPERATION_HISTORY_PREFIX: '1.11',
1261
+ // Default operation history object ID used as a fallback starting point
1262
+ // when the account's most_recent_op cannot be resolved.
1263
+ HISTORY_API_OBJECT: '1.11.0',
1264
+ // Maximum number of history entries to fetch per page when scanning for
1265
+ // fills after a subscription notice. The scan pages until it catches up
1266
+ // to the per-subscription cursor (lastDeliveredHistoryId).
1267
+ // This is used as an upper bound; at runtime the actual page limit is
1268
+ // capped at min(HISTORY_LOOKBACK_MAX, node's api_limit_get_account_history)
1269
+ // to avoid FC_ASSERT on nodes with a lower configured limit.
1270
+ HISTORY_LOOKBACK_MAX: 50,
1271
+ // HISTORY_MAX_PAGES: Default cap on pages fetched by
1272
+ // fetchFillHistoryEntries in modules/bitshares-native/subscriptions.ts
1273
+ // when the caller does not pass `options.maxPages`. Bounds the loop in
1274
+ // case the history API keeps returning full pages (which would otherwise
1275
+ // run unbounded). At HISTORY_LOOKBACK_MAX=50 entries per page this caps
1276
+ // the per-call scan at 5k history entries by default.
1277
+ HISTORY_MAX_PAGES: 100,
1278
+ // SUBSCRIBE_TIMEOUT_MS: Outer bound on a single BitShares.subscribe
1279
+ // operation. subscribe() chains several RPCs (get_full_accounts,
1280
+ // primeLastDeliveredHistoryId, refreshSubscriptions), each individually
1281
+ // capped by TRANSPORT.RPC_TIMEOUT_MS (15s). The total can therefore
1282
+ // legitimately take 4× that on a deep-history account. 60s covers
1283
+ // the typical case with headroom; the native per-RPC timeout still
1284
+ // fires earlier on a hard hang.
1285
+ SUBSCRIBE_TIMEOUT_MS: 75000,
1286
+ // Delay before retrying a failed reconnect catch-up for a subscription.
1287
+ RECONNECT_RETRY_DELAY_MS: 5000,
1288
+ // Maximum fill events accepted into the in-memory processing queue.
1289
+ // Subscription callbacks throw before acknowledging history when this
1290
+ // limit would be exceeded, so the cursor remains retryable.
1291
+ MAX_INCOMING_FILL_QUEUE: 1000,
1292
+ // Coalesce window (ms) for the no-fill fallback scan in handleNotice.
1293
+ // Back-to-back non-fill notices that arrive within this window share a
1294
+ // single history scan per subscription instead of triggering one RPC
1295
+ // per notice. Set to 0 to disable coalescing.
1296
+ NOTICE_COALESCE_MS: 250,
1297
+ // Subscription health watchdog — detects silent subscription death
1298
+ // where the websocket stays connected and keep-alive passes but the
1299
+ // node stops delivering notices (server-side timeout, node overload).
1300
+ //
1301
+ // SUBSCRIPTION_HEALTH_CHECK_INTERVAL_MS: How often the watchdog timer
1302
+ // runs to check for stale subscriptions. Default: 60s.
1303
+ SUBSCRIPTION_HEALTH_CHECK_INTERVAL_MS: 60000,
1304
+ // SUBSCRIPTION_SILENT_THRESHOLD_MS: If a subscription has not received
1305
+ // any notice (fill or non-fill) within this window, the watchdog
1306
+ // triggers a resubscribe + history scan. Default: 5 minutes.
1307
+ // Choose a value longer than the expected quiet period between
1308
+ // account operations — low-activity bots should use 10–15 min.
1309
+ SUBSCRIPTION_SILENT_THRESHOLD_MS: 300000,
1310
+ },
1311
+ // -------------------------------------------------------------------------
1312
+ // ORDER_EVENTS — Local order-event correlation settings (chain_orders.js)
1313
+ // -------------------------------------------------------------------------
1314
+ ORDER_EVENTS: {
1315
+ // Time window (ms) for remembering order ids this process just cancelled.
1316
+ // Used only to discard malformed non-economic fill artifacts that are
1317
+ // actually local cancel propagation; real fills with economics are kept.
1318
+ RECENT_OWN_CANCEL_TTL_MS: 5000,
1319
+ // Lazy-GC threshold for the recent-own-cancel map.
1320
+ RECENT_OWN_CANCEL_MAX_ENTRIES: 256,
1321
+ },
1322
+ // -------------------------------------------------------------------------
1323
+ // RESOLVERS — Asset/account resolution cache (resolvers.js)
1324
+ // -------------------------------------------------------------------------
1325
+ RESOLVERS: {
1326
+ // Time-to-live for cached asset and account lookups (ms, 1 hour).
1327
+ // After expiry, the next lookup re-fetches from the blockchain.
1328
+ ASSET_TTL_MS: 3600000,
1329
+ ACCOUNT_TTL_MS: 3600000,
1330
+ // Maximum number of cached assets / accounts.
1331
+ // Least-recently-used entries are evicted when the limit is reached.
1332
+ MAX_ASSETS: 2000,
1333
+ MAX_ACCOUNTS: 1000,
1334
+ // Default LRU cache capacity when no explicit maxSize is provided.
1335
+ LRU_DEFAULT_SIZE: 1000,
1336
+ },
1337
+ // -------------------------------------------------------------------------
1338
+ // ECC — Cryptographic constants (crypto/ecc.js, reference only)
1339
+ // -------------------------------------------------------------------------
1340
+ // These are protocol-level constants that MUST NOT be changed.
1341
+ // Included here for completeness; the native ECC module uses its own copies.
1342
+ ECC: {
1343
+ // Compact signature length (bytes): 1-byte recovery ID + 32-byte r + 32-byte s.
1344
+ SIGNATURE_LENGTH: 65,
1345
+ // Recovery ID offset for BitShares: 27 (Bitcoin standard) + 4 (Graphene offset).
1346
+ // Used when encoding compact [rec|r|s] signatures for broadcast.
1347
+ RECOVERY_OFFSET: 31,
1348
+ // Checksum length for base58check-encoded keys and addresses (bytes).
1349
+ // Uses double-SHA256 for WIF/base58check, ripemd160 for address hashes.
1350
+ CHECKSUM_BYTES: 4,
1351
+ // Wallet Import Format (WIF) magic bytes.
1352
+ // 0x80 = WIF mainnet version prefix (prepended before the private key bytes).
1353
+ // 0x01 = compressed public key indicator (appended after private key bytes).
1354
+ WIF_VERSION_BYTE: 0x80,
1355
+ WIF_COMPRESSED_FLAG: 0x01,
1356
+ // Public key encoding constants.
1357
+ // 0x02/0x03 = compressed (even/odd y), 0x04 = uncompressed prefix.
1358
+ // Valid key lengths: 33 (compressed), 64 (raw xy), 65 (uncompressed).
1359
+ PUBKEY_COMPRESSED_EVEN: 0x02,
1360
+ PUBKEY_COMPRESSED_ODD: 0x03,
1361
+ PUBKEY_UNCOMPRESSED_PREF: 0x04,
1362
+ PUBKEY_LEN_COMPRESSED: 33,
1363
+ PUBKEY_LEN_RAW_XY: 64,
1364
+ PUBKEY_LEN_UNCOMPRESSED: 65,
1365
+ // Deterministic K (RFC 6979) initial HMAC seeds.
1366
+ // K = hmac-sha256(Buffer.alloc(32, 0x00), Buffer.alloc(32, 0x01)).
1367
+ // Only relevant for signature generation internally.
1368
+ DETERMINISTIC_K_SEED: '00-filled + 01-filled 32-byte buffers',
1369
+ },
1370
+ };
1371
+ // --- LOCAL SETTINGS OVERRIDES ---
1372
+ // Load user-defined settings from profiles/general.settings.json if it exists.
1373
+ // This allows preserving settings during updates without git stashing.
1374
+ // Lazy require breaks the circular dependency: constants → general_settings → constants
1375
+ const { readGeneralSettings } = require('./general_settings');
1376
+ const settings = readGeneralSettings({
1377
+ fallback: null,
1378
+ onError: (err, filePath) => {
1379
+ console.warn(`[WARN] Failed to load local settings from ${filePath}: ${err.message}`);
1380
+ }
1381
+ });
1382
+ if (settings) {
1383
+ const { mergeSettings } = require('./settings_merge');
1384
+ const merged = mergeSettings(settings, {
1385
+ LOG_LEVEL,
1386
+ TIMING,
1387
+ GRID_LIMITS,
1388
+ FILL_PROCESSING,
1389
+ PIPELINE_TIMING,
1390
+ DEFAULT_CONFIG,
1391
+ UPDATER,
1392
+ CREDENTIAL_PROMPTS,
1393
+ MAINTENANCE,
1394
+ COW_PERFORMANCE,
1395
+ INCREMENT_BOUNDS,
1396
+ FEE_PARAMETERS,
1397
+ API_LIMITS,
1398
+ LOGGING_CONFIG,
1399
+ NATIVE_CLIENT,
1400
+ LAUNCHER,
1401
+ NODE_MANAGEMENT,
1402
+ MARKET_ADAPTER,
1403
+ });
1404
+ LOG_LEVEL = merged.LOG_LEVEL;
1405
+ TIMING = merged.TIMING;
1406
+ GRID_LIMITS = merged.GRID_LIMITS;
1407
+ FILL_PROCESSING = merged.FILL_PROCESSING;
1408
+ PIPELINE_TIMING = merged.PIPELINE_TIMING;
1409
+ DEFAULT_CONFIG = merged.DEFAULT_CONFIG;
1410
+ UPDATER = merged.UPDATER;
1411
+ CREDENTIAL_PROMPTS = merged.CREDENTIAL_PROMPTS;
1412
+ MAINTENANCE = merged.MAINTENANCE;
1413
+ COW_PERFORMANCE = merged.COW_PERFORMANCE;
1414
+ INCREMENT_BOUNDS = merged.INCREMENT_BOUNDS;
1415
+ FEE_PARAMETERS = merged.FEE_PARAMETERS;
1416
+ API_LIMITS = merged.API_LIMITS;
1417
+ LOGGING_CONFIG = merged.LOGGING_CONFIG;
1418
+ NATIVE_CLIENT = merged.NATIVE_CLIENT;
1419
+ LAUNCHER = merged.LAUNCHER;
1420
+ NODE_MANAGEMENT = merged.NODE_MANAGEMENT;
1421
+ MARKET_ADAPTER = merged.MARKET_ADAPTER;
1422
+ }
1423
+ // Freeze objects to prevent accidental runtime modifications
1424
+ Object.freeze(ORDER_TYPES);
1425
+ Object.freeze(ORDER_STATES);
1426
+ Object.freeze(REBALANCE_STATES);
1427
+ Object.freeze(COW_ACTIONS);
1428
+ Object.freeze(TIMING);
1429
+ Object.freeze(GRID_LIMITS);
1430
+ Object.freeze(GRID_LIMITS.GRID_COMPARISON);
1431
+ Object.freeze(INCREMENT_BOUNDS);
1432
+ Object.freeze(FEE_PARAMETERS);
1433
+ Object.freeze(CR_ZONES);
1434
+ Object.freeze(API_LIMITS);
1435
+ Object.freeze(FILL_PROCESSING);
1436
+ Object.freeze(MAINTENANCE);
1437
+ Object.freeze(NODE_MANAGEMENT);
1438
+ Object.freeze(PIPELINE_TIMING);
1439
+ Object.freeze(UPDATER);
1440
+ Object.freeze(LAUNCHER.MONOLITHIC);
1441
+ Object.freeze(LAUNCHER.SUPERVISOR);
1442
+ Object.freeze(LAUNCHER);
1443
+ Object.freeze(COW_PERFORMANCE);
1444
+ Object.freeze(LOGGING_CONFIG);
1445
+ Object.freeze(NATIVE_CLIENT.CHAIN);
1446
+ Object.freeze(NATIVE_CLIENT.OPERATIONS);
1447
+ Object.freeze(NATIVE_CLIENT.OBJECT_TYPES);
1448
+ Object.freeze(NATIVE_CLIENT.TRANSACTION);
1449
+ Object.freeze(NATIVE_CLIENT.TRANSPORT);
1450
+ Object.freeze(NATIVE_CLIENT.SUBSCRIPTIONS);
1451
+ Object.freeze(NATIVE_CLIENT.RESOLVERS);
1452
+ Object.freeze(NATIVE_CLIENT.ECC);
1453
+ Object.freeze(NATIVE_CLIENT);
1454
+ Object.freeze(MARKET_ADAPTER.RUNTIME_DEFAULTS);
1455
+ Object.freeze(MARKET_ADAPTER.WATCHDOG_DEFAULTS);
1456
+ Object.freeze(MARKET_ADAPTER.AMAS.AMA1);
1457
+ Object.freeze(MARKET_ADAPTER.AMAS.AMA2);
1458
+ Object.freeze(MARKET_ADAPTER.AMAS.AMA3);
1459
+ Object.freeze(MARKET_ADAPTER.AMAS.AMA4);
1460
+ Object.freeze(MARKET_ADAPTER.AMAS);
1461
+ Object.freeze(MARKET_ADAPTER);
1462
+ Object.freeze(CREDENTIAL_PROMPTS);
1463
+ module.exports = { ORDER_TYPES, ORDER_STATES, REBALANCE_STATES, COW_ACTIONS, DEFAULT_CONFIG, TIMING, GRID_LIMITS, LOG_LEVEL, LOGGING_CONFIG, INCREMENT_BOUNDS, FEE_PARAMETERS, CR_ZONES, DEFAULT_TARGET_CR, API_LIMITS, FILL_PROCESSING, MAINTENANCE, NODE_MANAGEMENT, PIPELINE_TIMING, UPDATER, LAUNCHER, COW_PERFORMANCE, NATIVE_CLIENT, MARKET_ADAPTER, BUILD_DIR, BTS_PRECISION, DAEMON_ERRORS, DAEMON_CODES, CREDENTIAL_PROMPTS };
1464
+ //# sourceMappingURL=constants.js.map