dexbot 1.6.11 → 1.6.13

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 (398) hide show
  1. package/CHANGELOG.md +67 -4
  2. package/README.md +2 -1
  3. package/analysis/README.md +11 -11
  4. package/analysis/ama_fitting/README.md +5 -3
  5. package/analysis/tradingview/README.md +1 -1
  6. package/analysis/trend_detection/DYNAMIC_WEIGHT_RESEARCH.md +3 -3
  7. package/claw/README.md +1 -0
  8. package/claw/docs/AI_BOT_LIBRARY_API.md +2 -0
  9. package/claw/docs/DEXBOT2_TUNING_CHEAT_SHEET.md +4 -3
  10. package/claw/modules/chain_broadcast.ts +7 -1
  11. package/claw/modules/claw_bridge.ts +0 -3
  12. package/claw/modules/claw_launcher.ts +1 -1
  13. package/claw/modules/claw_skill_md.ts +1 -0
  14. package/claw/modules/launcher_mode_detector.ts +9 -2
  15. package/claw/package.json +3 -3
  16. package/claw/runtimes/openclaw-plugin/openclaw.plugin.json +1 -1
  17. package/claw/runtimes/openclaw-plugin/package.json +1 -1
  18. package/claw/tsconfig.json +2 -2
  19. package/dist/analysis/account_resolver.d.ts +1 -1
  20. package/dist/analysis/account_resolver.js +2 -1
  21. package/dist/analysis/ama_fitting/analyze_ama_price_changes.js +3 -4
  22. package/dist/analysis/ama_fitting/analyze_lambda_vs_slow.js +3 -21
  23. package/dist/analysis/ama_fitting/calibrate_convergence_er.js +0 -1
  24. package/dist/analysis/ama_fitting/fetch_lp_candles.js +55 -45
  25. package/dist/analysis/ama_fitting/generate_unified_comparison_chart.d.ts +1 -8
  26. package/dist/analysis/ama_fitting/generate_unified_comparison_chart.js +45 -24
  27. package/dist/analysis/ama_fitting/optimizer_high_resolution.js +34 -78
  28. package/dist/analysis/analyze_args.d.ts +43 -0
  29. package/dist/analysis/analyze_args.js +61 -0
  30. package/dist/analysis/analyze_dynamic_weight.js +7 -17
  31. package/dist/analysis/analyze_kalman.js +7 -17
  32. package/dist/analysis/analyze_regime.js +7 -17
  33. package/dist/analysis/analyze_regime_windows.js +8 -18
  34. package/dist/analysis/analyze_risk_profile.js +8 -18
  35. package/dist/analysis/analyze_trade_heatmap.js +7 -17
  36. package/dist/analysis/analyze_volatility.js +7 -17
  37. package/dist/analysis/bot_fitting/backtest_ama_sweep.d.ts +221 -28
  38. package/dist/analysis/bot_fitting/backtest_ama_sweep.js +23 -103
  39. package/dist/analysis/bot_fitting/backtest_bot_fitting.d.ts +34 -4
  40. package/dist/analysis/bot_fitting/backtest_bot_fitting.js +32 -150
  41. package/dist/analysis/bot_fitting/backtest_lookback_drawdown.js +19 -34
  42. package/dist/analysis/bot_fitting/shared_utils.d.ts +77 -9
  43. package/dist/analysis/bot_fitting/shared_utils.js +125 -9
  44. package/dist/analysis/bot_key_utils.d.ts +18 -10
  45. package/dist/analysis/bot_key_utils.js +7 -4
  46. package/dist/analysis/bot_usage/discover_bot_accounts.js +44 -47
  47. package/dist/analysis/bot_usage/kibana_bot_queries.d.ts +1 -21
  48. package/dist/analysis/chain_pool.d.ts +3 -1
  49. package/dist/analysis/chart_ui.d.ts +35 -3
  50. package/dist/analysis/chart_ui.js +43 -4
  51. package/dist/analysis/chart_utils.d.ts +5 -5
  52. package/dist/analysis/chart_utils.js +9 -0
  53. package/dist/analysis/fills_cache.d.ts +4 -24
  54. package/dist/analysis/fills_cache.js +3 -84
  55. package/dist/analysis/fills_source.d.ts +33 -3
  56. package/dist/analysis/fills_source.js +83 -13
  57. package/dist/analysis/grid_correction_check.d.ts +2 -24
  58. package/dist/analysis/grid_correction_check.js +27 -69
  59. package/dist/analysis/math_utils.d.ts +91 -6
  60. package/dist/analysis/math_utils.js +119 -7
  61. package/dist/analysis/pnl_report.js +29 -29
  62. package/dist/analysis/price_sources.d.ts +30 -9
  63. package/dist/analysis/price_sources.js +28 -4
  64. package/dist/analysis/resolve_bot_accounts.js +2 -2
  65. package/dist/analysis/resolve_source.d.ts +1 -1
  66. package/dist/analysis/resolve_source.js +31 -10
  67. package/dist/analysis/trade_profitability.d.ts +29 -2
  68. package/dist/analysis/trade_profitability.js +73 -147
  69. package/dist/analysis/tradingview/analyze_tradingview.d.ts +3 -8
  70. package/dist/analysis/tradingview/analyze_tradingview.js +7 -6
  71. package/dist/analysis/tradingview/grid_reset_config.d.ts +41 -32
  72. package/dist/analysis/tradingview/grid_reset_config.js +23 -11
  73. package/dist/analysis/tradingview/grid_reset_sim.d.ts +75 -9
  74. package/dist/analysis/tradingview/grid_reset_sim.js +4 -3
  75. package/dist/analysis/tradingview/tradingview_uplot_chart_generator.d.ts +69 -4
  76. package/dist/analysis/tradingview/tradingview_uplot_chart_generator.js +20 -34
  77. package/dist/analysis/trend_detection/backtest_ama_slope_huber.d.ts +1 -101
  78. package/dist/analysis/trend_detection/backtest_ama_slope_huber.js +26 -84
  79. package/dist/analysis/trend_detection/dynamic_weight_chart_generator.d.ts +63 -1
  80. package/dist/analysis/trend_detection/dynamic_weight_chart_generator.js +16 -41
  81. package/dist/analysis/trend_detection/huber_scale_variants.d.ts +9 -3
  82. package/dist/analysis/trend_detection/huber_scale_variants.js +4 -4
  83. package/dist/analysis/trend_detection/kalman_chart_generator.d.ts +30 -1
  84. package/dist/analysis/trend_detection/kalman_chart_generator.js +3 -3
  85. package/dist/analysis/trend_detection/regime_chart_generator.d.ts +31 -1
  86. package/dist/analysis/trend_detection/regime_chart_generator.js +2 -2
  87. package/dist/analysis/trend_detection/volatility_chart_generator.d.ts +33 -1
  88. package/dist/analysis/trend_detection/volatility_chart_generator.js +9 -10
  89. package/dist/analysis/worker_pool.d.ts +38 -0
  90. package/dist/analysis/worker_pool.js +67 -0
  91. package/dist/credential-daemon.js +34 -20
  92. package/dist/dexbot.js +78 -59
  93. package/dist/market_adapter/ama_signal_runner.js +21 -54
  94. package/dist/market_adapter/candle_utils.d.ts +29 -19
  95. package/dist/market_adapter/candle_utils.js +35 -21
  96. package/dist/market_adapter/cli_args.d.ts +22 -0
  97. package/dist/market_adapter/cli_args.js +30 -0
  98. package/dist/market_adapter/core/asymmetric_bounds.d.ts +13 -4
  99. package/dist/market_adapter/core/config_normalizers.d.ts +3 -3
  100. package/dist/market_adapter/core/config_normalizers.js +11 -6
  101. package/dist/market_adapter/core/kibana_candles.d.ts +56 -19
  102. package/dist/market_adapter/core/kibana_candles.js +12 -9
  103. package/dist/market_adapter/core/kibana_client.d.ts +9 -1
  104. package/dist/market_adapter/core/kibana_client.js +8 -7
  105. package/dist/market_adapter/core/kibana_market_candles.d.ts +3 -2
  106. package/dist/market_adapter/core/market_adapter_service.d.ts +320 -153
  107. package/dist/market_adapter/core/market_adapter_service.js +228 -269
  108. package/dist/market_adapter/core/signals/hurst_analyzer.d.ts +1 -6
  109. package/dist/market_adapter/core/signals/hurst_analyzer.js +1 -1
  110. package/dist/market_adapter/core/signals/permutation_entropy_analyzer.d.ts +1 -11
  111. package/dist/market_adapter/core/signals/permutation_entropy_analyzer.js +1 -1
  112. package/dist/market_adapter/core/strategies/ama.d.ts +10 -2
  113. package/dist/market_adapter/core/strategies/ama.js +2 -4
  114. package/dist/market_adapter/core/strategies/ama_slope_model.d.ts +14 -1
  115. package/dist/market_adapter/core/strategies/ama_slope_model.js +12 -34
  116. package/dist/market_adapter/core/strategies/atr/calculator.d.ts +7 -2
  117. package/dist/market_adapter/core/strategies/atr/calculator.js +2 -34
  118. package/dist/market_adapter/core/strategies/collateral_manager.d.ts +7 -1
  119. package/dist/market_adapter/core/strategies/collateral_manager.js +0 -22
  120. package/dist/market_adapter/core/strategies/dynamic_weight_series.d.ts +34 -6
  121. package/dist/market_adapter/core/strategies/dynamic_weight_series.js +7 -7
  122. package/dist/market_adapter/core/strategies/regime_gate.d.ts +24 -15
  123. package/dist/market_adapter/core/strategies/regime_gate.js +4 -31
  124. package/dist/market_adapter/core/strategies/regime_interp.d.ts +7 -1
  125. package/dist/market_adapter/core/strategies/regime_interp.js +14 -22
  126. package/dist/market_adapter/core/strategies/volatility_shift.d.ts +11 -1
  127. package/dist/market_adapter/core/strategies/volatility_shift.js +0 -13
  128. package/dist/market_adapter/inputs/cex_candle_parsing.d.ts +29 -0
  129. package/dist/market_adapter/inputs/cex_candle_parsing.js +52 -0
  130. package/dist/market_adapter/inputs/fetch_book_data.d.ts +20 -4
  131. package/dist/market_adapter/inputs/fetch_book_data.js +3 -2
  132. package/dist/market_adapter/inputs/fetch_cex_synthetic_data.js +160 -332
  133. package/dist/market_adapter/inputs/fetch_lp_data.d.ts +50 -8
  134. package/dist/market_adapter/inputs/fetch_lp_data.js +47 -22
  135. package/dist/market_adapter/inputs/kibana_feed_source.d.ts +74 -15
  136. package/dist/market_adapter/inputs/kibana_feed_source.js +26 -41
  137. package/dist/market_adapter/inputs/kibana_source.d.ts +25 -3
  138. package/dist/market_adapter/inputs/kibana_source.js +2 -2
  139. package/dist/market_adapter/inputs/window_cache.d.ts +93 -156
  140. package/dist/market_adapter/inputs/window_cache.js +59 -184
  141. package/dist/market_adapter/interval_utils.d.ts +15 -5
  142. package/dist/market_adapter/interval_utils.js +16 -1
  143. package/dist/market_adapter/log_format.d.ts +6 -6
  144. package/dist/market_adapter/log_format.js +28 -21
  145. package/dist/market_adapter/lp_chart_core.d.ts +22 -1
  146. package/dist/market_adapter/lp_chart_core.js +26 -192
  147. package/dist/market_adapter/lp_chart_runner.d.ts +10 -7
  148. package/dist/market_adapter/lp_chart_runner.js +37 -19
  149. package/dist/market_adapter/lp_chart_strategy_loader.d.ts +41 -6
  150. package/dist/market_adapter/lp_chart_strategy_loader.js +8 -7
  151. package/dist/market_adapter/market_adapter.d.ts +94 -32
  152. package/dist/market_adapter/market_adapter.js +94 -120
  153. package/dist/market_adapter/utils/adapter_client.d.ts +3 -3
  154. package/dist/market_adapter/utils/adapter_client.js +2 -2
  155. package/dist/market_adapter/utils/atomic_write.d.ts +8 -1
  156. package/dist/market_adapter/utils/chain.d.ts +50 -41
  157. package/dist/market_adapter/utils/chain.js +40 -46
  158. package/dist/market_adapter/utils/data_discovery.d.ts +49 -2
  159. package/dist/market_adapter/utils/data_discovery.js +220 -27
  160. package/dist/market_adapter/utils/dynamic_grid_snapshot.d.ts +12 -3
  161. package/dist/market_adapter/utils/file_json_cache.d.ts +2 -2
  162. package/dist/market_adapter/utils/file_lock.d.ts +28 -14
  163. package/dist/market_adapter/utils/file_lock.js +36 -32
  164. package/dist/market_adapter/utils/month_shards.d.ts +84 -0
  165. package/dist/market_adapter/utils/month_shards.js +237 -0
  166. package/dist/market_adapter/utils/native_history.d.ts +9 -2
  167. package/dist/market_adapter/utils/native_history.js +35 -28
  168. package/dist/modules/account_bots.d.ts +578 -21
  169. package/dist/modules/account_bots.js +272 -267
  170. package/dist/modules/account_orders.d.ts +79 -30
  171. package/dist/modules/account_orders.js +60 -64
  172. package/dist/modules/authority_resolver.d.ts +12 -2
  173. package/dist/modules/authority_resolver.js +15 -8
  174. package/dist/modules/bitshares-native/chain_client.d.ts +39 -4
  175. package/dist/modules/bitshares-native/chain_client.js +59 -59
  176. package/dist/modules/bitshares-native/crypto/ecc.browser.js +11 -171
  177. package/dist/modules/bitshares-native/crypto/ecc.js +13 -176
  178. package/dist/modules/bitshares-native/crypto/ecc_core.d.ts +33 -0
  179. package/dist/modules/bitshares-native/crypto/ecc_core.js +213 -0
  180. package/dist/modules/bitshares-native/crypto/ecc_selector.d.ts +2 -1
  181. package/dist/modules/bitshares-native/crypto/ecc_selector.js +1 -13
  182. package/dist/modules/bitshares-native/index.d.ts +1 -1
  183. package/dist/modules/bitshares-native/lru_cache.d.ts +7 -7
  184. package/dist/modules/bitshares-native/resolvers.d.ts +18 -6
  185. package/dist/modules/bitshares-native/resolvers.js +22 -25
  186. package/dist/modules/bitshares-native/serial/lazy_buffer.d.ts +4 -0
  187. package/dist/modules/bitshares-native/serial/lazy_buffer.js +21 -0
  188. package/dist/modules/bitshares-native/serial/operations.d.ts +1 -1
  189. package/dist/modules/bitshares-native/serial/serializer.d.ts +16 -12
  190. package/dist/modules/bitshares-native/serial/serializer.js +7 -13
  191. package/dist/modules/bitshares-native/serial/types.d.ts +25 -16
  192. package/dist/modules/bitshares-native/serial/types.js +73 -108
  193. package/dist/modules/bitshares-native/signing_client.d.ts +32 -2
  194. package/dist/modules/bitshares-native/signing_client.js +19 -14
  195. package/dist/modules/bitshares-native/subscriptions.d.ts +81 -1
  196. package/dist/modules/bitshares-native/subscriptions.js +12 -12
  197. package/dist/modules/bitshares-native/transport.d.ts +5 -4
  198. package/dist/modules/bitshares-native/transport.js +5 -4
  199. package/dist/modules/bitshares-native/tx/builder.d.ts +40 -5
  200. package/dist/modules/bitshares-native/tx/builder.js +4 -3
  201. package/dist/modules/bitshares-native/tx/tx_cache.d.ts +4 -4
  202. package/dist/modules/bitshares_client.d.ts +45 -13
  203. package/dist/modules/bitshares_client.js +28 -19
  204. package/dist/modules/bot_defaults.d.ts +8 -16
  205. package/dist/modules/bot_defaults.js +1 -5
  206. package/dist/modules/bot_settings.d.ts +44 -10
  207. package/dist/modules/bot_settings.js +11 -8
  208. package/dist/modules/bots_file_lock.d.ts +6 -6
  209. package/dist/modules/bots_file_lock.js +16 -12
  210. package/dist/modules/broadcast_failure.d.ts +4 -3
  211. package/dist/modules/broadcast_failure.js +5 -4
  212. package/dist/modules/chain_keys.d.ts +42 -40
  213. package/dist/modules/chain_keys.js +53 -45
  214. package/dist/modules/chain_orders.d.ts +94 -60
  215. package/dist/modules/chain_orders.js +81 -118
  216. package/dist/modules/cli_start_onboarding.d.ts +2 -1
  217. package/dist/modules/constants.d.ts +534 -32
  218. package/dist/modules/constants.js +35 -48
  219. package/dist/modules/cr_planner.d.ts +41 -3
  220. package/dist/modules/cr_planner.js +1 -5
  221. package/dist/modules/credential_policy.d.ts +68 -8
  222. package/dist/modules/credential_policy.js +37 -31
  223. package/dist/modules/credential_session_cache.d.ts +2 -2
  224. package/dist/modules/credit_pricing.d.ts +43 -6
  225. package/dist/modules/credit_pricing.js +70 -60
  226. package/dist/modules/credit_runtime.d.ts +283 -118
  227. package/dist/modules/credit_runtime.js +500 -231
  228. package/dist/modules/crypto/browser_provider.js +6 -4
  229. package/dist/modules/crypto/node_provider.js +1 -1
  230. package/dist/modules/crypto/pure_scrypt.js +35 -4
  231. package/dist/modules/crypto/pure_secp256k1.js +72 -26
  232. package/dist/modules/crypto/sync.d.ts +9 -9
  233. package/dist/modules/crypto/sync.js +16 -9
  234. package/dist/modules/daemon_node_health.d.ts +4 -3
  235. package/dist/modules/dexbot_class.d.ts +213 -146
  236. package/dist/modules/dexbot_class.js +183 -86
  237. package/dist/modules/dexbot_cow_runtime.d.ts +160 -87
  238. package/dist/modules/dexbot_cow_runtime.js +302 -234
  239. package/dist/modules/dexbot_credential_client.d.ts +19 -18
  240. package/dist/modules/dexbot_credential_client.js +1 -2
  241. package/dist/modules/dexbot_fill_runtime.d.ts +63 -49
  242. package/dist/modules/dexbot_fill_runtime.js +53 -47
  243. package/dist/modules/dexbot_maintenance_runtime.d.ts +127 -71
  244. package/dist/modules/dexbot_maintenance_runtime.js +187 -147
  245. package/dist/modules/dexbot_startup_runtime.d.ts +11 -11
  246. package/dist/modules/dexbot_startup_runtime.js +56 -57
  247. package/dist/modules/dexbot_state_recovery.d.ts +13 -12
  248. package/dist/modules/dexbot_state_recovery.js +18 -13
  249. package/dist/modules/fund_registry.d.ts +4 -2
  250. package/dist/modules/fund_registry.js +10 -10
  251. package/dist/modules/general_settings.d.ts +30 -4
  252. package/dist/modules/graceful_shutdown.d.ts +3 -3
  253. package/dist/modules/graceful_shutdown.js +19 -13
  254. package/dist/modules/grid_price_source.d.ts +1 -1
  255. package/dist/modules/key_store.d.ts +14 -8
  256. package/dist/modules/key_store.js +7 -7
  257. package/dist/modules/launcher/adapter_requirement.d.ts +11 -5
  258. package/dist/modules/launcher/adapter_requirement.js +5 -5
  259. package/dist/modules/launcher/bot_supervisor.d.ts +106 -24
  260. package/dist/modules/launcher/bot_supervisor.js +12 -11
  261. package/dist/modules/launcher/credential_bootstrap.d.ts +1 -1
  262. package/dist/modules/launcher/credential_bootstrap.js +1 -1
  263. package/dist/modules/launcher/credential_daemon.d.ts +4 -4
  264. package/dist/modules/launcher/credential_daemon.js +2 -2
  265. package/dist/modules/launcher/credential_secret.d.ts +1 -1
  266. package/dist/modules/launcher/foreign_cred_daemon.d.ts +2 -2
  267. package/dist/modules/launcher/market_adapter_runtime.d.ts +61 -6
  268. package/dist/modules/launcher/market_adapter_watchdog.d.ts +10 -2
  269. package/dist/modules/launcher/market_adapter_watchdog.js +4 -0
  270. package/dist/modules/launcher/monolithic_runtime.d.ts +18 -16
  271. package/dist/modules/launcher/status_reporting.d.ts +22 -14
  272. package/dist/modules/launcher/supervisor_control.d.ts +8 -1
  273. package/dist/modules/launcher/supervisor_control.js +4 -2
  274. package/dist/modules/lazy_shim.d.ts +11 -0
  275. package/dist/modules/lazy_shim.js +16 -0
  276. package/dist/modules/market_adapter_whitelist.d.ts +9 -3
  277. package/dist/modules/market_adapter_whitelist.js +15 -3
  278. package/dist/modules/node_connect_policy.d.ts +3 -2
  279. package/dist/modules/node_failure_ledger.d.ts +6 -5
  280. package/dist/modules/node_manager.d.ts +41 -11
  281. package/dist/modules/node_manager.js +5 -4
  282. package/dist/modules/order/accounting.d.ts +53 -24
  283. package/dist/modules/order/accounting.js +16 -15
  284. package/dist/modules/order/async_lock.d.ts +5 -2
  285. package/dist/modules/order/async_lock.js +1 -1
  286. package/dist/modules/order/export.d.ts +7 -6
  287. package/dist/modules/order/export.js +1 -7
  288. package/dist/modules/order/format.d.ts +16 -7
  289. package/dist/modules/order/format.js +15 -3
  290. package/dist/modules/order/genesis_policy.d.ts +24 -21
  291. package/dist/modules/order/genesis_policy.js +17 -10
  292. package/dist/modules/order/grid.d.ts +144 -36
  293. package/dist/modules/order/grid.js +226 -145
  294. package/dist/modules/order/grid_reconcile.d.ts +21 -20
  295. package/dist/modules/order/grid_reconcile.js +13 -12
  296. package/dist/modules/order/grid_reconcile_internal.d.ts +85 -72
  297. package/dist/modules/order/grid_reconcile_internal.js +28 -19
  298. package/dist/modules/order/index.d.ts +264 -1
  299. package/dist/modules/order/logger.d.ts +46 -19
  300. package/dist/modules/order/logger.js +38 -49
  301. package/dist/modules/order/logger_state.d.ts +4 -4
  302. package/dist/modules/order/manager.d.ts +232 -191
  303. package/dist/modules/order/manager.js +110 -130
  304. package/dist/modules/order/processed_fill_store.d.ts +18 -3
  305. package/dist/modules/order/processed_fill_store.js +16 -27
  306. package/dist/modules/order/strategy.d.ts +21 -13
  307. package/dist/modules/order/strategy.js +5 -6
  308. package/dist/modules/order/sync_engine.d.ts +91 -33
  309. package/dist/modules/order/sync_engine.js +84 -53
  310. package/dist/modules/order/utils/math.d.ts +157 -102
  311. package/dist/modules/order/utils/math.js +77 -38
  312. package/dist/modules/order/utils/order.d.ts +310 -110
  313. package/dist/modules/order/utils/order.js +153 -126
  314. package/dist/modules/order/utils/slot.d.ts +1 -1
  315. package/dist/modules/order/utils/system.d.ts +156 -26
  316. package/dist/modules/order/utils/system.js +103 -71
  317. package/dist/modules/order/utils/validate.d.ts +89 -41
  318. package/dist/modules/order/utils/validate.js +26 -24
  319. package/dist/modules/order/utils/withPoolRef.d.ts +6 -4
  320. package/dist/modules/order/utils/withPoolRef.js +18 -12
  321. package/dist/modules/order/working_grid.d.ts +14 -13
  322. package/dist/modules/paths.d.ts +1 -4
  323. package/dist/modules/paths.js +33 -61
  324. package/dist/modules/process_discovery.d.ts +1 -1
  325. package/dist/modules/process_discovery.js +2 -1
  326. package/dist/modules/runtime.d.ts +7 -3
  327. package/dist/modules/runtime.js +4 -3
  328. package/dist/modules/runtime_settings.d.ts +14 -11
  329. package/dist/modules/runtime_settings.js +30 -24
  330. package/dist/modules/settings_merge.d.ts +29 -3
  331. package/dist/modules/settings_merge.js +56 -78
  332. package/dist/modules/socket_json_client.d.ts +9 -5
  333. package/dist/modules/storage/browser_adapter.d.ts +38 -53
  334. package/dist/modules/storage/browser_adapter.js +7 -30
  335. package/dist/modules/storage/index.d.ts +1 -1
  336. package/dist/modules/storage/node_adapter.d.ts +45 -27
  337. package/dist/modules/storage/node_adapter.js +9 -9
  338. package/dist/modules/storage/types.d.ts +5 -4
  339. package/dist/modules/types.d.ts +1090 -6
  340. package/dist/modules/types.js +4 -1
  341. package/dist/modules/utils/asset_symbols.d.ts +2 -1
  342. package/dist/modules/utils/asset_symbols.js +2 -1
  343. package/dist/modules/utils/errors.d.ts +9 -0
  344. package/dist/modules/utils/errors.js +24 -4
  345. package/dist/modules/utils/time_range.d.ts +1 -12
  346. package/dist/modules/utils/time_range.js +1 -1
  347. package/dist/modules/validate_profiles.js +53 -43
  348. package/dist/modules/version_notice.d.ts +23 -11
  349. package/dist/modules/version_notice.js +6 -4
  350. package/dist/pm2.d.ts +28 -27
  351. package/dist/pm2.js +61 -40
  352. package/dist/scripts/analyze-credit.d.ts +2 -1
  353. package/dist/scripts/analyze-credit.js +23 -24
  354. package/dist/scripts/analyze-git.js +2 -15
  355. package/dist/scripts/analyze-orders.d.ts +77 -9
  356. package/dist/scripts/analyze-orders.js +65 -40
  357. package/dist/scripts/chart_command.d.ts +27 -18
  358. package/dist/scripts/chart_command.js +15 -13
  359. package/dist/scripts/check_any.d.ts +22 -0
  360. package/dist/scripts/check_any.js +158 -0
  361. package/dist/scripts/diagnose-pool-history.js +13 -13
  362. package/dist/scripts/print_grid.js +0 -1
  363. package/dist/scripts/run-tests.js +39 -8
  364. package/dist/scripts/runner.js +1 -1
  365. package/dist/scripts/sync-version.js +0 -10
  366. package/dist/scripts/test-credit-renewal.js +30 -21
  367. package/dist/scripts/update.d.ts +10 -5
  368. package/dist/scripts/update.js +168 -103
  369. package/dist/scripts/update_dist_freshness.js +1 -0
  370. package/dist/scripts/update_layout.d.ts +61 -0
  371. package/dist/scripts/update_layout.js +180 -0
  372. package/dist/scripts/validate_bots.js +2 -1
  373. package/dist/scripts/verify-browser-bundle.js +8 -0
  374. package/dist/unlock.d.ts +28 -3
  375. package/dist/unlock.js +63 -35
  376. package/docs/BITSHARES_ONBOARDING.md +10 -12
  377. package/docs/COPY_ON_WRITE_MASTER_PLAN.md +2 -2
  378. package/docs/COW_INVARIANTS.md +13 -6
  379. package/docs/DEXBOT_COMPARISON.md +8 -8
  380. package/docs/EVOLUTION.md +10 -8
  381. package/docs/FUND_MOVEMENT_AND_ACCOUNTING.md +5 -5
  382. package/docs/GRID_RECALCULATION.md +4 -2
  383. package/docs/GRID_RECONCILE.md +14 -3
  384. package/docs/LIFECYCLE.md +11 -11
  385. package/docs/MPA_CREDIT_USAGE.md +22 -3
  386. package/docs/README.md +14 -3
  387. package/docs/WORKFLOW.md +1 -0
  388. package/docs/architecture.md +31 -19
  389. package/docs/developer_guide.md +6 -6
  390. package/market_adapter/README.md +12 -5
  391. package/modules/README.md +4 -1
  392. package/package.json +9 -9
  393. package/scripts/README.md +43 -38
  394. package/tests/README.md +25 -10
  395. package/dist/scripts/diagnose-kibana-candles.d.ts +0 -3
  396. package/dist/scripts/diagnose-kibana-candles.js +0 -82
  397. package/scripts/git-viewer.sh +0 -489
  398. package/scripts/postinstall.js +0 -16
@@ -71,6 +71,45 @@
71
71
  *
72
72
  * ===============================================================================
73
73
  */
74
+ import type { OrderManagerLike, AccountTotals, ManagerFunds, ActiveOrdersConfig, GridFeeParams, ManagedOrder, AssetPair, GridConfig, GridLimitsLike, WeightDistributionConfig } from '../../types.js';
75
+ interface FeeCacheEntry {
76
+ limitOrderCreate: {
77
+ bts: number;
78
+ };
79
+ limitOrderUpdate: {
80
+ bts: number;
81
+ };
82
+ limitOrderCancel?: {
83
+ bts?: number;
84
+ };
85
+ makerFeeDiscountPercent?: number;
86
+ chargesMarketFees?: boolean;
87
+ marketFee?: {
88
+ percent?: number;
89
+ };
90
+ takerFee?: {
91
+ percent?: number;
92
+ };
93
+ maxMarketFee?: {
94
+ float?: number;
95
+ };
96
+ [key: string]: unknown;
97
+ }
98
+ type PricedOrder = {
99
+ price: number;
100
+ };
101
+ interface CollisionItem {
102
+ id?: string;
103
+ price?: number;
104
+ size?: number;
105
+ type?: string;
106
+ order?: {
107
+ price?: number;
108
+ size?: number;
109
+ type?: string;
110
+ } | null;
111
+ [key: string]: unknown;
112
+ }
74
113
  /**
75
114
  * Check if a value is explicitly set to zero (number 0, string "0", or "0%").
76
115
  * Used to distinguish between "not set" and "explicitly disabled".
@@ -78,35 +117,35 @@
78
117
  * @param {*} value - Value to check
79
118
  * @returns {boolean} True if value is explicitly zero
80
119
  */
81
- declare function isExplicitZeroAllocation(value: any): boolean;
120
+ declare function isExplicitZeroAllocation(value: unknown): boolean;
82
121
  /**
83
122
  * Check if a value is a percentage string (ends with '%').
84
123
  *
85
124
  * @param {*} v - Value to test
86
125
  * @returns {boolean} True if v is a string ending with '%'
87
126
  */
88
- declare function isPercentageString(v: any): v is string;
127
+ declare function isPercentageString(v: unknown): v is string;
89
128
  /**
90
129
  * Check if a value is a positive number.
91
130
  *
92
131
  * @param {*} value - Value to test
93
132
  * @returns {boolean} True if the value is a finite number greater than 0
94
133
  */
95
- declare function isPositiveNumber(value: any): boolean;
134
+ declare function isPositiveNumber(value: unknown): boolean;
96
135
  /**
97
136
  * Check if a value is a positive number or a positive percentage string.
98
137
  *
99
138
  * @param {*} value - Value to test
100
139
  * @returns {boolean} True if the value is a positive number or a percentage string like "25%"
101
140
  */
102
- declare function isPositiveNumberOrPercent(value: any): boolean;
141
+ declare function isPositiveNumberOrPercent(value: unknown): boolean;
103
142
  /**
104
143
  * Check if a value is a positive integer.
105
144
  *
106
145
  * @param {*} value - Value to test
107
146
  * @returns {boolean} True if the value is an integer greater than 0
108
147
  */
109
- declare function isPositiveInt(value: any): boolean;
148
+ declare function isPositiveInt(value: unknown): boolean;
110
149
  /**
111
150
  * Parse a percentage string to decimal form.
112
151
  * Extracts numeric value before '%' and divides by 100.
@@ -114,7 +153,7 @@ declare function isPositiveInt(value: any): boolean;
114
153
  * @param {string} v - Percentage string (e.g., "50%")
115
154
  * @returns {number|null} Decimal form (e.g., 0.5) or null if invalid
116
155
  */
117
- declare function parsePercentageString(v: any): number | null;
156
+ declare function parsePercentageString(v: unknown): number | null;
118
157
  /**
119
158
  * Convert a value (number, percentage string, or numeric string) to its
120
159
  * decimal form. Unlike parsePercentageString which only handles '%' strings,
@@ -122,7 +161,7 @@ declare function parsePercentageString(v: any): number | null;
122
161
  * @param {*} value - Number (100 = 100), "100%" (= 1.0), or "100" (= 100)
123
162
  * @returns {number} Decimal value, 0 if unparseable
124
163
  */
125
- declare function toDecimal(value: any): number;
164
+ declare function toDecimal(value: unknown): number;
126
165
  /**
127
166
  * Parse a relative multiplier expression (e.g. "3x", " 1.5X ").
128
167
  * Single source of truth for the x-multiplier syntax, shared by price-bound
@@ -131,7 +170,7 @@ declare function toDecimal(value: any): number;
131
170
  * @param {*} value - Candidate value
132
171
  * @returns {number|null} Multiplier number, or null if not a valid expression
133
172
  */
134
- declare function parseRelativeMultiplier(value: any): number | null;
173
+ declare function parseRelativeMultiplier(value: unknown): number | null;
135
174
  /**
136
175
  * Resolve a relative price expression (multiplier format) to absolute price.
137
176
  * Supports expressions like "3x" to mean 3 times the reference price.
@@ -141,7 +180,7 @@ declare function parseRelativeMultiplier(value: any): number | null;
141
180
  * @param {string} [mode='min'] - "min" divides (price/multiplier), "max" multiplies (price*multiplier)
142
181
  * @returns {number|null} Resolved price or null if value is not a relative expression
143
182
  */
144
- declare function resolveRelativePrice(value: any, startPrice: any, mode?: any): number | null;
183
+ declare function resolveRelativePrice(value: unknown, startPrice: unknown, mode?: string): number | null;
145
184
  /**
146
185
  * Validate that resolved price bounds strictly bracket the grid center.
147
186
  *
@@ -156,7 +195,7 @@ declare function resolveRelativePrice(value: any, startPrice: any, mode?: any):
156
195
  * @param {number} centerPrice - Grid center used as the multiplier reference
157
196
  * @throws {Error} If bounds do not strictly bracket the center
158
197
  */
159
- declare function validateGridPriceBounds(minPrice: any, maxPrice: any, centerPrice: any): void;
198
+ declare function validateGridPriceBounds(minPrice: unknown, maxPrice: unknown, centerPrice: unknown): void;
160
199
  /**
161
200
  * Calculate chain fund totals from account balances and committed orders.
162
201
  * Reconciles free/locked balances with committed capital to produce fund summary.
@@ -166,7 +205,10 @@ declare function validateGridPriceBounds(minPrice: any, maxPrice: any, centerPri
166
205
  * @returns {Object} Summary object with chainFreeBuy, chainFreeSell, committedChainBuy,
167
206
  * committedChainSell, freePlusLockedBuy, freePlusLockedSell, chainTotalBuy, chainTotalSell
168
207
  */
169
- declare function computeChainFundTotals(accountTotals: any, committedChain: any): {
208
+ declare function computeChainFundTotals(accountTotals: AccountTotals | null | undefined, committedChain: {
209
+ buy?: number;
210
+ sell?: number;
211
+ } | null | undefined): {
170
212
  chainFreeBuy: number;
171
213
  chainFreeSell: number;
172
214
  committedChainBuy: number;
@@ -185,7 +227,7 @@ declare function computeChainFundTotals(accountTotals: any, committedChain: any)
185
227
  * @param {number} precision - Asset precision (satoshis)
186
228
  * @returns {number} Quantized float value
187
229
  */
188
- declare function quantizeFloat(value: any, precision: any): number;
230
+ declare function quantizeFloat(value: number, precision: number): number;
189
231
  /**
190
232
  * Normalize an integer value by round-tripping through float representation.
191
233
  * Converts int → float (readable format) → blockchain int.
@@ -196,14 +238,14 @@ declare function quantizeFloat(value: any, precision: any): number;
196
238
  * @param {number} precision - Asset precision (satoshis)
197
239
  * @returns {number} Normalized integer value
198
240
  */
199
- declare function normalizeInt(value: any, precision: any): number;
241
+ declare function normalizeInt(value: number, precision: number): number;
200
242
  /**
201
243
  * @private Set the fee cache (called by system.js::initializeFeeCache).
202
244
  *
203
245
  * @param {Object} cache - Fee cache object keyed by asset symbol
204
246
  * @returns {void}
205
247
  */
206
- declare function _setFeeCache(cache: any): void;
248
+ declare function _setFeeCache(cache: Record<string, FeeCacheEntry>): void;
207
249
  /**
208
250
  * Get fee information for an asset.
209
251
 
@@ -215,11 +257,11 @@ declare function _setFeeCache(cache: any): void;
215
257
  * @returns {Object} Fee structure with create/update/net fees or net proceeds if amount provided
216
258
  * @throws {Error} If fees not cached (call initializeFeeCache first)
217
259
  */
218
- declare function getAssetFees(assetSymbol: any, assetAmount?: any, isMaker?: any): {
260
+ declare function getAssetFees(assetSymbol: string, assetAmount?: number | null, isMaker?: boolean): {
219
261
  netProceeds: number;
220
262
  total: number;
221
263
  refund: number;
222
- isMaker: any;
264
+ isMaker: boolean;
223
265
  createFee?: undefined;
224
266
  updateFee?: undefined;
225
267
  cancelFee?: undefined;
@@ -233,15 +275,15 @@ declare function getAssetFees(assetSymbol: any, assetAmount?: any, isMaker?: any
233
275
  takerFee?: undefined;
234
276
  percent?: undefined;
235
277
  } | {
236
- total: any;
237
- createFee: any;
238
- updateFee: any;
239
- cancelFee: any;
278
+ total: number;
279
+ createFee: number;
280
+ updateFee: number;
281
+ cancelFee: number;
240
282
  makerFeeDiscountPercent: number;
241
283
  makerNetFee: number;
242
284
  takerNetFee: number;
243
285
  netFee: number;
244
- isMaker: any;
286
+ isMaker: boolean;
245
287
  netProceeds?: undefined;
246
288
  refund?: undefined;
247
289
  feeAmount?: undefined;
@@ -253,8 +295,8 @@ declare function getAssetFees(assetSymbol: any, assetAmount?: any, isMaker?: any
253
295
  netProceeds: number;
254
296
  total: number;
255
297
  feeAmount: number;
256
- feePercent: any;
257
- isMaker: any;
298
+ feePercent: number;
299
+ isMaker: boolean;
258
300
  refund?: undefined;
259
301
  createFee?: undefined;
260
302
  updateFee?: undefined;
@@ -267,9 +309,9 @@ declare function getAssetFees(assetSymbol: any, assetAmount?: any, isMaker?: any
267
309
  takerFee?: undefined;
268
310
  percent?: undefined;
269
311
  } | {
270
- marketFee: any;
271
- takerFee: any;
272
- percent: any;
312
+ marketFee: number;
313
+ takerFee: number;
314
+ percent: number;
273
315
  netProceeds?: undefined;
274
316
  total?: undefined;
275
317
  refund?: undefined;
@@ -293,11 +335,11 @@ declare function getAssetFees(assetSymbol: any, assetAmount?: any, isMaker?: any
293
335
  * @param {boolean} [isMaker=true] - Whether this is a maker or taker
294
336
  * @returns {Object|null} Fee structure or null when fees are not cached
295
337
  */
296
- declare function getAssetFeesSafe(assetSymbol: any, assetAmount?: any, isMaker?: any): {
338
+ declare function getAssetFeesSafe(assetSymbol: string, assetAmount?: number | null, isMaker?: boolean): {
297
339
  netProceeds: number;
298
340
  total: number;
299
341
  refund: number;
300
- isMaker: any;
342
+ isMaker: boolean;
301
343
  createFee?: undefined;
302
344
  updateFee?: undefined;
303
345
  cancelFee?: undefined;
@@ -311,15 +353,15 @@ declare function getAssetFeesSafe(assetSymbol: any, assetAmount?: any, isMaker?:
311
353
  takerFee?: undefined;
312
354
  percent?: undefined;
313
355
  } | {
314
- total: any;
315
- createFee: any;
316
- updateFee: any;
317
- cancelFee: any;
356
+ total: number;
357
+ createFee: number;
358
+ updateFee: number;
359
+ cancelFee: number;
318
360
  makerFeeDiscountPercent: number;
319
361
  makerNetFee: number;
320
362
  takerNetFee: number;
321
363
  netFee: number;
322
- isMaker: any;
364
+ isMaker: boolean;
323
365
  netProceeds?: undefined;
324
366
  refund?: undefined;
325
367
  feeAmount?: undefined;
@@ -331,8 +373,8 @@ declare function getAssetFeesSafe(assetSymbol: any, assetAmount?: any, isMaker?:
331
373
  netProceeds: number;
332
374
  total: number;
333
375
  feeAmount: number;
334
- feePercent: any;
335
- isMaker: any;
376
+ feePercent: number;
377
+ isMaker: boolean;
336
378
  refund?: undefined;
337
379
  createFee?: undefined;
338
380
  updateFee?: undefined;
@@ -345,9 +387,9 @@ declare function getAssetFeesSafe(assetSymbol: any, assetAmount?: any, isMaker?:
345
387
  takerFee?: undefined;
346
388
  percent?: undefined;
347
389
  } | {
348
- marketFee: any;
349
- takerFee: any;
350
- percent: any;
390
+ marketFee: number;
391
+ takerFee: number;
392
+ percent: number;
351
393
  netProceeds?: undefined;
352
394
  total?: undefined;
353
395
  refund?: undefined;
@@ -374,13 +416,13 @@ declare function getAssetFeesSafe(assetSymbol: any, assetAmount?: any, isMaker?:
374
416
  * @param {Object} [activeOrders=null] - Active order counts {buy, sell} for BTS reservation calculation
375
417
  * @returns {number} Available funds for the side (0 if side invalid or insufficient funds)
376
418
  */
377
- declare function calculateAvailableFundsValue(side: any, accountTotals: any, funds: any, assetA: any, assetB: any, activeOrders?: any, configMinBtsValue?: number | null, feeParams?: any): number;
419
+ declare function calculateAvailableFundsValue(side: string, accountTotals: AccountTotals | null | undefined, funds: ManagerFunds, assetA: string | undefined, assetB: string | undefined, activeOrders?: ActiveOrdersConfig | null, configMinBtsValue?: number | null, feeParams?: GridFeeParams | null): number;
378
420
  /**
379
421
  * Adjust an allocated budget for BTS fee reservation.
380
422
  * Uses computeBtsFeeImpact for proportional deduction; falls back to 0.5
381
423
  * split when totalFree is exhausted (legacy sizing-path behavior).
382
424
  */
383
- declare function adjustBudgetForBtsFees(allocated: any, isBtsSide: any, formulaBudget: any, minBtsValue: any, btsFree: any, sideFree: any, totalFree: any): any;
425
+ declare function adjustBudgetForBtsFees(allocated: number, isBtsSide: boolean, formulaBudget: number, minBtsValue: number, btsFree: number, sideFree: number, totalFree: number): number;
384
426
  /**
385
427
  * Find the best (highest) buy price and best (lowest) sell price from active orders.
386
428
  *
@@ -388,7 +430,7 @@ declare function adjustBudgetForBtsFees(allocated: any, isBtsSide: any, formulaB
388
430
  * @param {Array<Object>} activeSells - Active sell orders with price property
389
431
  * @returns {{bestBuy: number|null, bestSell: number|null}} Best prices or null if no orders
390
432
  */
391
- declare function getGridBestPrices(activeBuys: any, activeSells: any): {
433
+ declare function getGridBestPrices(activeBuys: PricedOrder[], activeSells: PricedOrder[]): {
392
434
  bestBuy: number | null;
393
435
  bestSell: number | null;
394
436
  };
@@ -404,7 +446,7 @@ declare function getGridBestPrices(activeBuys: any, activeSells: any): {
404
446
  * (shouldFlagOutOfSpread) take the empty-side branch before touching this
405
447
  * value; display callers must handle non-finite (see logger status line).
406
448
  */
407
- declare function calculateSpreadFromOrders(activeBuys: any, activeSells: any): number;
449
+ declare function calculateSpreadFromOrders(activeBuys: PricedOrder[], activeSells: PricedOrder[]): number;
408
450
  /**
409
451
  * Resolve a config value to a numeric amount.
410
452
  * Interprets percentage strings, numeric strings, or direct numbers.
@@ -413,7 +455,7 @@ declare function calculateSpreadFromOrders(activeBuys: any, activeSells: any): n
413
455
  * @param {number} total - Total amount for percentage calculations
414
456
  * @returns {number} Resolved numeric value or 0 if uninterpretable
415
457
  */
416
- declare function resolveConfigValue(value: any, total: any): number;
458
+ declare function resolveConfigValue(value: unknown, total: unknown): number;
417
459
  /**
418
460
  * Resolve a config value to a numeric amount, accounting for shared-account
419
461
  * fund registry. If the bot has a registry entry, returns the proportional
@@ -427,7 +469,7 @@ declare function resolveConfigValue(value: any, total: any): number;
427
469
  * @param {'buy'|'sell'} side - Trade side
428
470
  * @returns {number} Resolved numeric value or 0 if uninterpretable
429
471
  */
430
- declare function resolveConfigValueWithRegistry(value: any, chainTotal: any, account: any, botName: any, side: any): number;
472
+ declare function resolveConfigValueWithRegistry(value: unknown, chainTotal: number, account: string | undefined, botName: string | undefined, side: string): number;
431
473
  /**
432
474
  * Check if account totals contain valid buy/sell balance data.
433
475
  *
@@ -435,7 +477,7 @@ declare function resolveConfigValueWithRegistry(value: any, chainTotal: any, acc
435
477
  * @param {boolean} [checkFree=true] - Check free balances if true, else check total balances
436
478
  * @returns {boolean} True if both buy and sell values are valid finite numbers
437
479
  */
438
- declare function hasValidAccountTotals(accountTotals: any, checkFree?: any): boolean;
480
+ declare function hasValidAccountTotals(accountTotals: AccountTotals | null | undefined, checkFree?: boolean): boolean;
439
481
  /**
440
482
  * Convert blockchain integer to float using asset precision.
441
483
  * Divides by 10^precision to convert satoshi-level units to human-readable float.
@@ -446,7 +488,7 @@ declare function hasValidAccountTotals(accountTotals: any, checkFree?: any): boo
446
488
  * @returns {number} Float representation in human-readable units
447
489
  * @throws {Error} If precision is invalid
448
490
  */
449
- declare function blockchainToFloat(intValue: any, precision: any): number;
491
+ declare function blockchainToFloat(intValue: unknown, precision: number | null | undefined): number;
450
492
  /**
451
493
  * Convert float to blockchain integer using asset precision.
452
494
  * Multiplies by 10^precision and rounds to satoshi-level units.
@@ -461,7 +503,21 @@ declare function blockchainToFloat(intValue: any, precision: any): number;
461
503
  * @returns {number} Blockchain integer representation (satoshi units)
462
504
  * @throws {Error} If precision is invalid
463
505
  */
464
- declare function floatToBlockchainInt(floatValue: any, precision: any): number;
506
+ declare function floatToBlockchainInt(floatValue: unknown, precision: number | null | undefined): number;
507
+ /**
508
+ * Convert float to a blockchain integer by flooring (never rounding up) at the
509
+ * asset precision. Use whenever a value is a ceiling that must not over-state
510
+ * an available budget (for example a released-collateral allowance).
511
+ *
512
+ * A tiny epsilon counteracts binary-float underflow, e.g. 206 / 1.03 evaluates
513
+ * to 199.99999999999997 at precision 0 but is meant to be 200.
514
+ * Formula: blockchain_int = floor(float * 10^precision + 1e-9)
515
+ *
516
+ * @param {number} floatValue - Float value in human-readable units
517
+ * @param {number} precision - Asset precision exponent (5, 8, 4, ...)
518
+ * @returns {number} Floored blockchain integer representation
519
+ */
520
+ declare function floorToBlockchainInt(floatValue: unknown, precision: number | null | undefined): number;
465
521
  /**
466
522
  * Get asset precision for a specific order type (BUY or SELL).
467
523
  * BUY orders size in assetB, SELL orders size in assetA.
@@ -471,7 +527,7 @@ declare function floatToBlockchainInt(floatValue: any, precision: any): number;
471
527
  * @returns {number} Asset precision
472
528
  * @throws {Error} If precision missing for the required asset
473
529
  */
474
- declare function getPrecisionByOrderType(assets: any, orderType: any): any;
530
+ declare function getPrecisionByOrderType(assets: AssetPair | null | undefined, orderType: string): number;
475
531
  /**
476
532
  * Get asset precisions for both assetA and assetB.
477
533
  *
@@ -479,15 +535,15 @@ declare function getPrecisionByOrderType(assets: any, orderType: any): any;
479
535
  * @returns {Object} Object with A and B precision properties
480
536
  * @throws {Error} If precision missing for either asset
481
537
  */
482
- declare function getPrecisionsForManager(assets: any): {
483
- A: any;
484
- B: any;
538
+ declare function getPrecisionsForManager(assets: AssetPair | null | undefined): {
539
+ A: number;
540
+ B: number;
485
541
  };
486
542
  /**
487
543
  * Compute the quantum (smallest representable unit) for a given asset precision.
488
544
  * quantum = 10^-precision (e.g., 8 decimals → 1e-8).
489
545
  */
490
- declare function quantumForPrecision(precision: any): number;
546
+ declare function quantumForPrecision(precision: number | undefined): number;
491
547
  /**
492
548
  * Calculate precision slack (rounding tolerance) for a given precision level.
493
549
  * Used for safe comparison of blockchain values that may differ by rounding.
@@ -496,7 +552,7 @@ declare function quantumForPrecision(precision: any): number;
496
552
  * @param {number} [factor=2] - Multiplier for slack (default 2)
497
553
  * @returns {number} Tolerance value (e.g., 2 * 10^-8 for 8-decimal precision)
498
554
  */
499
- declare function getPrecisionSlack(precision: any, factor?: any): number;
555
+ declare function getPrecisionSlack(precision: number | undefined, factor?: number): number;
500
556
  /**
501
557
  * Unified precision lookup for assets.
502
558
  *
@@ -504,16 +560,16 @@ declare function getPrecisionSlack(precision: any, factor?: any): number;
504
560
  * @param {Object} [options={}] - Lookup options { type, side, proceeds }
505
561
  * @returns {number} Asset precision
506
562
  */
507
- declare function getPrecision(assets: any, { type, side, proceeds }?: {
563
+ declare function getPrecision(assets: AssetPair | null | undefined, { type, side, proceeds }?: {
508
564
  type?: string;
509
565
  side?: string;
510
566
  proceeds?: boolean;
511
- }): any;
567
+ }): number;
512
568
  /**
513
569
  * Determine which side holds BTS for a trading pair.
514
570
  * Returns ORDER_TYPES.SELL if assetA is BTS, ORDER_TYPES.BUY if assetB is BTS, null otherwise.
515
571
  */
516
- declare function getBtsSide(assetA: string, assetB: string): string | null;
572
+ declare function getBtsSide(assetA: string | undefined, assetB: string | undefined): string | null;
517
573
  /**
518
574
  * Calculate price tolerance for order matching on-chain.
519
575
  * Accounts for precision limits of both assets to determine acceptable price deviation.
@@ -531,7 +587,7 @@ declare function getBtsSide(assetA: string, assetB: string): string | null;
531
587
  * @returns {number|null} Price tolerance value or null if invalid inputs
532
588
  * @throws {Error} If assets missing or precisions invalid
533
589
  */
534
- declare function calculatePriceTolerance(gridPrice: any, orderSize: any, orderType: any, assets?: any): number | null;
590
+ declare function calculatePriceTolerance(gridPrice: unknown, orderSize: unknown, orderType: string, assets?: AssetPair | null): number | null;
535
591
  /**
536
592
  * Scan an iterable of candidate items for a price collision with the target order.
537
593
  * Each candidate must have `id` and a price accessible via `item.price ?? item.order?.price`.
@@ -545,7 +601,7 @@ declare function calculatePriceTolerance(gridPrice: any, orderSize: any, orderTy
545
601
  * @param {Function} [isValid] - Optional predicate; candidate must return true to be considered
546
602
  * @returns {object|null} The colliding item, or null
547
603
  */
548
- declare function findPriceCollision(items: Iterable<any>, excludeId: string, targetPrice: number, targetSize: number, targetType: string, assets: any, isValid?: ((item: any) => boolean) | null): any;
604
+ declare function findPriceCollision(items: Iterable<CollisionItem>, excludeId: string, targetPrice: number, targetSize: number, targetType: string, assets: AssetPair | null, isValid?: ((item: CollisionItem) => boolean) | null): CollisionItem | null;
549
605
  /**
550
606
  * Find an opposite-side order that a candidate placement would CROSS.
551
607
  *
@@ -567,11 +623,11 @@ declare function findPriceCollision(items: Iterable<any>, excludeId: string, tar
567
623
  * @param {Iterable<any>} items - Candidate orders (e.g. manager.orders.values())
568
624
  * @param {number} price - Candidate placement price
569
625
  * @param {string} type - Candidate placement type (ORDER_TYPES.BUY / SELL)
570
- * @param {any} assets - Asset metadata (precisions) for tolerance
626
+ * @param {unknown} assets - Asset metadata (precisions) for tolerance
571
627
  * @param {((item: any) => boolean)|null} [isValid] - Optional filter
572
628
  * @returns {any|null} The first crossed order, or null when the placement crosses nothing
573
629
  */
574
- declare function findCrossedOrder(items: Iterable<any>, price: number, type: string, assets: any, isValid?: ((item: any) => boolean) | null): any;
630
+ declare function findCrossedOrder(items: Iterable<CollisionItem>, price: number, type: string, assets: AssetPair | null, isValid?: ((item: CollisionItem) => boolean) | null): CollisionItem | null;
575
631
  /**
576
632
  * Validate order amounts are within blockchain limits (0 < INT64_MAX).
577
633
  * Converts floats to blockchain integers and checks they fit in signed 64-bit integers.
@@ -582,7 +638,7 @@ declare function findCrossedOrder(items: Iterable<any>, price: number, type: str
582
638
  * @param {number} receivePrecision - Precision of receive asset
583
639
  * @returns {boolean} True if both amounts are valid and within limits
584
640
  */
585
- declare function validateOrderAmountsWithinLimits(amountToSell: any, minToReceive: any, sellPrecision: any, receivePrecision: any): boolean;
641
+ declare function validateOrderAmountsWithinLimits(amountToSell: number, minToReceive: number, sellPrecision: number, receivePrecision: number): boolean;
586
642
  /**
587
643
  * Calculate minimum absolute order size for an order type.
588
644
  * Returns factor * 10^-precision (e.g., 50 * 10^-8 for 8-decimal asset).
@@ -593,14 +649,14 @@ declare function validateOrderAmountsWithinLimits(amountToSell: any, minToReceiv
593
649
  * @returns {number} Minimum order size in asset units
594
650
  * @throws {Error} If precision cannot be determined
595
651
  */
596
- declare function getMinOrderSize(orderType: any, assets: any, factor?: any): number;
652
+ declare function getMinOrderSize(orderType: string, assets: AssetPair | null | undefined, factor?: number): number;
597
653
  /**
598
654
  * Calculate dust threshold factor as decimal fraction.
599
655
  *
600
656
  * @param {number} [dustThresholdPercent=5] - Dust threshold percentage (default 5%)
601
657
  * @returns {number} Dust factor (e.g., 0.05 for 5%)
602
658
  */
603
- declare function getDustThresholdFactor(dustThresholdPercent?: any): number;
659
+ declare function getDustThresholdFactor(dustThresholdPercent?: number): number;
604
660
  /**
605
661
  * Calculate single dust threshold for an ideal order size.
606
662
  * Returns idealSize * (dustThresholdPercent / 100).
@@ -609,7 +665,7 @@ declare function getDustThresholdFactor(dustThresholdPercent?: any): number;
609
665
  * @param {number} [dustThresholdPercent=5] - Threshold percentage (default 5%)
610
666
  * @returns {number} Single dust threshold (0 if idealSize invalid)
611
667
  */
612
- declare function getSingleDustThreshold(idealSize: any, dustThresholdPercent?: any): number;
668
+ declare function getSingleDustThreshold(idealSize: number, dustThresholdPercent?: number): number;
613
669
  /**
614
670
  * Calculate double dust threshold for an ideal order size.
615
671
  * Returns idealSize * (dustThresholdPercent / 100) * 2.
@@ -619,7 +675,7 @@ declare function getSingleDustThreshold(idealSize: any, dustThresholdPercent?: a
619
675
  * @param {number} [dustThresholdPercent=5] - Threshold percentage (default 5%)
620
676
  * @returns {number} Double dust threshold (0 if idealSize invalid)
621
677
  */
622
- declare function getDoubleDustThreshold(idealSize: any, dustThresholdPercent?: any): number;
678
+ declare function getDoubleDustThreshold(idealSize: number, dustThresholdPercent?: number): number;
623
679
  /**
624
680
  * Validate an order size against minimum absolute and dust thresholds.
625
681
  * Returns detailed validation result with reasons if invalid.
@@ -632,16 +688,11 @@ declare function getDoubleDustThreshold(idealSize: any, dustThresholdPercent?: a
632
688
  * @param {number} [dustThresholdPercent=5] - Dust threshold percentage (default 5%)
633
689
  * @returns {Object} Validation result {isValid, reason, minAbsoluteSize, minDustSize}
634
690
  */
635
- declare function validateOrderSize(orderSize: any, orderType: any, assets: any, minFactor?: any, idealSize?: any, dustThresholdPercent?: any): {
691
+ declare function validateOrderSize(orderSize: number, orderType: string, assets: AssetPair | null | undefined, minFactor?: number, idealSize?: number | null, dustThresholdPercent?: number): {
636
692
  isValid: boolean;
637
- reason: string;
693
+ reason: string | null;
638
694
  minAbsoluteSize: number;
639
- minDustSize: any;
640
- } | {
641
- isValid: boolean;
642
- reason: null;
643
- minAbsoluteSize: number;
644
- minDustSize: any;
695
+ minDustSize: number | null;
645
696
  };
646
697
  /**
647
698
  * Allocate total funds across n orders using exponential weight distribution.
@@ -657,7 +708,7 @@ declare function validateOrderSize(orderSize: any, orderType: any, assets: any,
657
708
  * @param {number} [precision=null] - Asset precision; if provided, quantize to blockchain integers
658
709
  * @returns {Array<number>} Array of n allocation sizes
659
710
  */
660
- declare function allocateFundsByWeights(totalFunds: any, n: any, weight: any, incrementFactor: any, reverse?: any, _minSize?: any, precision?: any): any[];
711
+ declare function allocateFundsByWeights(totalFunds: number, n: number, weight: unknown, incrementFactor: number, reverse?: boolean, _minSize?: number, precision?: number | null): number[];
661
712
  /**
662
713
  * Calculate order sizes for a list of orders using weighted fund allocation.
663
714
  * Allocates buy and sell funds separately using weight distribution from config.
@@ -673,7 +724,7 @@ declare function allocateFundsByWeights(totalFunds: any, n: any, weight: any, in
673
724
  * @param {number} [precisionB=null] - Precision for assetB (BUY asset)
674
725
  * @returns {Array<Object>} Orders array with size property added to each
675
726
  */
676
- declare function calculateOrderSizes(orders: any, config: any, sellFunds: any, buyFunds: any, minSellSize?: any, minBuySize?: any, precisionA?: any, precisionB?: any): any;
727
+ declare function calculateOrderSizes(orders: ManagedOrder[], config: GridConfig, sellFunds: number, buyFunds: number, minSellSize?: number, minBuySize?: number, precisionA?: number | null, precisionB?: number | null): ManagedOrder[];
677
728
  /**
678
729
  * Calculate order sizes for rotation operations.
679
730
  * Combines available funds with existing grid allocation for sizing.
@@ -688,7 +739,7 @@ declare function calculateOrderSizes(orders: any, config: any, sellFunds: any, b
688
739
  * @param {number} [precision=null] - Asset precision for quantization
689
740
  * @returns {Array<number>} Array of order sizes
690
741
  */
691
- declare function calculateRotationOrderSizes(availableFunds: any, totalGridAllocation: any, orderCount: any, orderType: any, config: any, minSize?: any, precision?: any): any[];
742
+ declare function calculateRotationOrderSizes(availableFunds: number, totalGridAllocation: number, orderCount: number, orderType: string, config: GridConfig, minSize?: number, precision?: number | null): number[];
692
743
  /**
693
744
  * Calculate RMS (Root Mean Square) divergence between calculated and persisted grids.
694
745
  * Measures how much the current grid differs from the calculated ideal.
@@ -703,7 +754,7 @@ declare function calculateRotationOrderSizes(availableFunds: any, totalGridAlloc
703
754
  * @param {string} [sideName='unknown'] - Side name for logging (buy/sell)
704
755
  * @returns {number} RMS divergence metric (0 = perfect match, higher = more divergence)
705
756
  */
706
- declare function calculateGridSideDivergenceMetric(calculatedOrders: any, persistedOrders: any, _sideName?: any): number;
757
+ declare function calculateGridSideDivergenceMetric(calculatedOrders: ManagedOrder[], persistedOrders: ManagedOrder[], _sideName?: string): number;
707
758
  /**
708
759
  * Calculate estimated BTS order creation fees for a number of orders.
709
760
  * Works for all pairs — returns the BTS fee budget needed for order operations.
@@ -714,7 +765,7 @@ declare function calculateGridSideDivergenceMetric(calculatedOrders: any, persis
714
765
  * @param {number} [feeMultiplier=BTS_RESERVATION_MULTIPLIER] - Multiplier for reservation (typically 5x)
715
766
  * @returns {number} Total fee amount (fallback BTS_FALLBACK_FEE if fee lookup fails; warning logged)
716
767
  */
717
- declare function calculateOrderCreationFees(assetA: any, assetB: any, totalOrders: any, feeMultiplier?: any): number;
768
+ declare function calculateOrderCreationFees(assetA: string | undefined, assetB: string | undefined, totalOrders: number, feeMultiplier?: number): number;
718
769
  /**
719
770
  * Calculate how much input asset to swap into a constant-product AMM pool
720
771
  * to receive a target amount of output asset.
@@ -731,7 +782,7 @@ declare function calculateOrderCreationFees(assetA: any, assetB: any, totalOrder
731
782
  * @param {number} poolReserveIn - Pool reserve of input asset
732
783
  * @returns {number} Amount of input asset to sell
733
784
  */
734
- declare function calculateSwapInAmount(targetReceive: any, poolReserveOut: any, poolReserveIn: any): number;
785
+ declare function calculateSwapInAmount(targetReceive: number, poolReserveOut: number, poolReserveIn: number): number;
735
786
  /**
736
787
  * Calculate the spread gap size (number of empty slots between BUY and SELL rails).
737
788
  * Used by both grid creation and strategy rebalancing to keep spread math consistent.
@@ -741,15 +792,12 @@ declare function calculateSwapInAmount(targetReceive: any, poolReserveOut: any,
741
792
  * @param {Object} GRID_LIMITS - Grid limits constants (optional, uses defaults)
742
793
  * @returns {number} Number of gap slots
743
794
  */
744
- declare function calculateGapSlots(incrementPercent: any, targetSpreadPercent: any, gridLimits?: {
745
- MIN_SPREAD_FACTOR?: number;
746
- MIN_SPREAD_ORDERS?: number;
747
- }): number;
795
+ declare function calculateGapSlots(incrementPercent: number | undefined, targetSpreadPercent: number | undefined, gridLimits?: GridLimitsLike): number;
748
796
  /**
749
797
  * Calculate sell start index from boundary index and gap slots.
750
798
  * sellStartIdx = boundaryIdx + gapSlots + 1
751
799
  */
752
- declare function getSellStartIdx(boundaryIdx: any, gapSlots: any): number;
800
+ declare function getSellStartIdx(boundaryIdx: number | null, gapSlots: number | null): number;
753
801
  /**
754
802
  * Resolve the configured gap-slot count for a manager-like object.
755
803
  * Single source of truth for the `_gapSlots ?? calculateGapSlots(config)`
@@ -757,8 +805,8 @@ declare function getSellStartIdx(boundaryIdx: any, gapSlots: any): number;
757
805
  * two can never disagree on band width.
758
806
  */
759
807
  declare function resolveGapSlots(manager: {
760
- _gapSlots?: any;
761
- config?: any;
808
+ _gapSlots?: number | null;
809
+ config?: GridConfig | null;
762
810
  }): number;
763
811
  /**
764
812
  * Resolve gap-band geometry from a manager-like object.
@@ -773,9 +821,9 @@ declare function resolveGapSlots(manager: {
773
821
  * boundary restored yet" and skip geometry-based filtering.
774
822
  */
775
823
  declare function resolveGapBand(manager: {
776
- _gapSlots?: any;
777
- boundaryIdx?: any;
778
- config?: any;
824
+ _gapSlots?: number | null;
825
+ boundaryIdx?: number | null;
826
+ config?: GridConfig | null;
779
827
  }): {
780
828
  gapSlots: number;
781
829
  boundaryIdx: number | null;
@@ -832,7 +880,7 @@ declare const BOUNDARY_REJECT_PLACED_IN_BAND = "placed_order_in_band";
832
880
  * @returns `{ ok: true }`, or `{ ok: false, reason, detail }` where `reason`
833
881
  * is a stable short code and `detail` carries indices/prices for logs.
834
882
  */
835
- declare function validateBoundaryCommit(proposedBoundary: any, orders: Iterable<any>, gapSlots: number, options?: {
883
+ declare function validateBoundaryCommit(proposedBoundary: number | null | undefined, orders: Iterable<unknown>, gapSlots: number, options?: {
836
884
  rejectInBandPlacements?: boolean;
837
885
  }): {
838
886
  ok: boolean;
@@ -867,7 +915,7 @@ declare function validateBoundaryCommit(proposedBoundary: any, orders: Iterable<
867
915
  * in-progress evacuation; true poison still refuses and structural resync
868
916
  * falls through to the clean full-grid reset instead of re-ingesting damage.
869
917
  */
870
- declare function validatePersistedBoundary(proposedBoundary: any, orders: Iterable<any>, gapSlots: number): {
918
+ declare function validatePersistedBoundary(proposedBoundary: number | null | undefined, orders: Iterable<unknown>, gapSlots: number): {
871
919
  ok: boolean;
872
920
  reason?: string;
873
921
  detail?: string;
@@ -893,7 +941,11 @@ declare function validatePersistedBoundary(proposedBoundary: any, orders: Iterab
893
941
  * @param check - validatePersistedBoundary / validateBoundaryCommit result
894
942
  * @returns True when the check is pure in-band placement (transient).
895
943
  */
896
- declare function isTransientInBandRejection(check: any): boolean;
944
+ declare function isTransientInBandRejection(check: {
945
+ ok?: boolean;
946
+ reason?: string;
947
+ [key: string]: unknown;
948
+ } | null | undefined): boolean;
897
949
  /**
898
950
  * Count SPREAD-typed slots strictly inside the gap band
899
951
  * (`boundaryIdx < idx < sellStartIdx`). Empty slots are normalized to SPREAD
@@ -909,7 +961,7 @@ declare function isTransientInBandRejection(check: any): boolean;
909
961
  * @returns Count of SPREAD slots inside the gap band, or — when no usable
910
962
  * boundary is restored — the total count of SPREAD-typed slots (fallback).
911
963
  */
912
- declare function countGapBandSpread(manager: any, orders: Iterable<any>, resolveIndex: (order: any, arrayIndex: number) => number | null): number;
964
+ declare function countGapBandSpread(manager: OrderManagerLike, orders: Iterable<ManagedOrder>, resolveIndex: (order: ManagedOrder, arrayIndex: number) => number | null): number;
913
965
  /**
914
966
  * Pure geometric rail-membership test for a grid slot.
915
967
  *
@@ -932,7 +984,7 @@ declare function countGapBandSpread(manager: any, orders: Iterable<any>, resolve
932
984
  * @param {number} gapSlots - Spread gap slot count. A non-finite value means
933
985
  * the SELL start cannot be derived, so the slot is not excluded.
934
986
  * @param {string} orderType - ORDER_TYPES.BUY or ORDER_TYPES.SELL.
935
- * @param {any} slot - Grid slot (or any object exposing an id like `slot-3`);
987
+ * @param {unknown} slot - Grid slot (or any object exposing an id like `slot-3`);
936
988
  * slots with an unparseable id are admitted (returns true): geometry cannot
937
989
  * identify the gap for legacy ids, so windowing falls back to the stored
938
990
  * slot type exactly as pre-1.4.25 did (fail-open; consumers still reject
@@ -941,7 +993,9 @@ declare function countGapBandSpread(manager: any, orders: Iterable<any>, resolve
941
993
  * geometry cannot be determined (fail-open), false only when a parseable id
942
994
  * sits provably outside the rail.
943
995
  */
944
- declare function isSlotInRail(boundaryIdx: any, gapSlots: any, orderType: any, slot: any): boolean;
996
+ declare function isSlotInRail(boundaryIdx: number | null, gapSlots: number | null, orderType: string, slot: {
997
+ id?: string;
998
+ } | null | undefined): boolean;
945
999
  /**
946
1000
  * Whether a slot index sits inside the gap (spread) band: strictly between
947
1001
  * the last BUY index (boundary) and the first SELL index. Geometry-only —
@@ -953,7 +1007,7 @@ declare function isSlotInRail(boundaryIdx: any, gapSlots: any, orderType: any, s
953
1007
  * @param {number} gapSlots - Spread gap slot count
954
1008
  * @returns {boolean} True when the index is inside the gap band
955
1009
  */
956
- declare function isSlotIndexInGapBand(idx: any, boundaryIdx: any, gapSlots: any): boolean;
1010
+ declare function isSlotIndexInGapBand(idx: number | string | null | undefined, boundaryIdx: number | string | null | undefined, gapSlots: number): boolean;
957
1011
  /**
958
1012
  * Pure stamped-evacuation size re-proof: a B-stamped (plan-build-proven)
959
1013
  * evacuation bypasses the live probe, but the plan was built against the
@@ -974,7 +1028,7 @@ declare function isSlotIndexInGapBand(idx: any, boundaryIdx: any, gapSlots: any)
974
1028
  * @param {number} [precision] - Asset precision for bit-exact int compare
975
1029
  * @returns {boolean} True when the planned size is still covered by the booking
976
1030
  */
977
- declare function isEvacuationSizeStillValid(newSize: any, bookedRemaining: any, precision?: any): boolean;
1031
+ declare function isEvacuationSizeStillValid(newSize: number, bookedRemaining: number, precision?: number | null): boolean;
978
1032
  /**
979
1033
  * Pure gap-evacuation rotation allowance: decides whether a slot-to-slot
980
1034
  * rotation (UPDATE with newGridId) reduces the violation surface enough to
@@ -1000,7 +1054,7 @@ declare function isEvacuationSizeStillValid(newSize: any, bookedRemaining: any,
1000
1054
  * @param {number} [precision] - Asset precision for bit-exact int compare
1001
1055
  * @returns {{allowed: boolean, reason: string}}
1002
1056
  */
1003
- declare function isEvacuationRotationAllowed(oldPrice: any, oldSize: any, newPrice: any, newSize: any, type: any, precision?: any): {
1057
+ declare function isEvacuationRotationAllowed(oldPrice: unknown, oldSize: unknown, newPrice: unknown, newSize: unknown, type: string, precision?: number | null): {
1004
1058
  allowed: boolean;
1005
1059
  reason: string;
1006
1060
  };
@@ -1027,7 +1081,7 @@ declare function slotIdForPrice(price: number, genesis: GridGenesis): string;
1027
1081
  * cancel as a duplicate.
1028
1082
  */
1029
1083
  declare function isChainPriceOutOfGrid(price: number, genesis: GridGenesis, precision: number): boolean;
1030
- declare function assertSlotPriceInvariant(slot: any, genesis: GridGenesis): void;
1084
+ declare function assertSlotPriceInvariant(slot: unknown, genesis: GridGenesis): void;
1031
1085
  declare function priceSlotEqual(a: number, b: number, precision: number): boolean;
1032
1086
  /**
1033
1087
  * Derive the geometric price ladder (the "rail") from a live config.
@@ -1051,7 +1105,8 @@ declare function priceSlotEqual(a: number, b: number, precision: number): boolea
1051
1105
  */
1052
1106
  declare function derivePriceLevels(startPrice: number, minPrice: number, maxPrice: number, incrementPercent: number): number[];
1053
1107
  declare function buildGenesisFromPriceLevels(startPrice: number, incrementPercent: number, gapSlots: number, priceLevels: number[]): GridGenesis;
1054
- export { getBtsSide, getSellStartIdx, resolveGapBand, countGapBandSpread, calculateGapSlots, isSlotInRail, isSlotIndexInGapBand, isEvacuationRotationAllowed, isEvacuationSizeStillValid, validateBoundaryCommit, validatePersistedBoundary, isTransientInBandRejection, BOUNDARY_REJECT_PLACED_IN_BAND, resolveGapSlots, isPercentageString, isPositiveNumber, isPositiveNumberOrPercent, isPositiveInt, parsePercentageString, toDecimal, resolveRelativePrice, parseRelativeMultiplier, validateGridPriceBounds, isExplicitZeroAllocation, getPrecision, computeChainFundTotals, calculateAvailableFundsValue, adjustBudgetForBtsFees, getGridBestPrices, calculateSpreadFromOrders, resolveConfigValue, resolveConfigValueWithRegistry, hasValidAccountTotals, blockchainToFloat, floatToBlockchainInt, quantizeFloat, normalizeInt, getPrecisionByOrderType, getPrecisionsForManager, getPrecisionSlack, quantumForPrecision, calculatePriceTolerance, findPriceCollision, findCrossedOrder, validateOrderAmountsWithinLimits, getMinOrderSize, getDustThresholdFactor, getSingleDustThreshold, getDoubleDustThreshold, validateOrderSize, getAssetFees, getAssetFeesSafe, allocateFundsByWeights, calculateOrderSizes, calculateRotationOrderSizes, calculateGridSideDivergenceMetric, calculateOrderCreationFees, calculateSwapInAmount, _setFeeCache, cloneWeightDistribution, clamp, roundTo, fixedTo, roundToDecimals, priceLevelsForGenesis, priceForSlot, slotIndexForPrice, slotIdForPrice, assertSlotPriceInvariant, priceSlotEqual, derivePriceLevels, buildGenesisFromPriceLevels, hashPriceLevels, isChainPriceOutOfGrid };
1108
+ export type { FeeCacheEntry };
1109
+ export { getBtsSide, getSellStartIdx, resolveGapBand, countGapBandSpread, calculateGapSlots, isSlotInRail, isSlotIndexInGapBand, isEvacuationRotationAllowed, isEvacuationSizeStillValid, validateBoundaryCommit, validatePersistedBoundary, isTransientInBandRejection, BOUNDARY_REJECT_PLACED_IN_BAND, resolveGapSlots, isPercentageString, isPositiveNumber, isPositiveNumberOrPercent, isPositiveInt, parsePercentageString, toDecimal, resolveRelativePrice, parseRelativeMultiplier, validateGridPriceBounds, isExplicitZeroAllocation, getPrecision, computeChainFundTotals, calculateAvailableFundsValue, adjustBudgetForBtsFees, getGridBestPrices, calculateSpreadFromOrders, resolveConfigValue, resolveConfigValueWithRegistry, hasValidAccountTotals, blockchainToFloat, floatToBlockchainInt, floorToBlockchainInt, quantizeFloat, normalizeInt, getPrecisionByOrderType, getPrecisionsForManager, getPrecisionSlack, quantumForPrecision, calculatePriceTolerance, findPriceCollision, findCrossedOrder, validateOrderAmountsWithinLimits, getMinOrderSize, getDustThresholdFactor, getSingleDustThreshold, getDoubleDustThreshold, validateOrderSize, getAssetFees, getAssetFeesSafe, allocateFundsByWeights, calculateOrderSizes, calculateRotationOrderSizes, calculateGridSideDivergenceMetric, calculateOrderCreationFees, calculateSwapInAmount, _setFeeCache, cloneWeightDistribution, clamp, roundTo, fixedTo, roundToDecimals, priceLevelsForGenesis, priceForSlot, slotIndexForPrice, slotIdForPrice, assertSlotPriceInvariant, priceSlotEqual, derivePriceLevels, buildGenesisFromPriceLevels, hashPriceLevels, isChainPriceOutOfGrid };
1055
1110
  /**
1056
1111
  * Round a value to a given factor.
1057
1112
  * @param {number} value - Value to round
@@ -1080,7 +1135,7 @@ declare function roundToDecimals(value: number, decimals: number): number;
1080
1135
  * @param {number} max - Upper bound
1081
1136
  * @returns {number}
1082
1137
  */
1083
- declare function clamp(value: any, min: any, max: any): number;
1138
+ declare function clamp(value: number, min: number, max: number): number;
1084
1139
  /**
1085
1140
  * Safely clone a weight distribution object.
1086
1141
  * Validates numeric sell/buy values and falls back to a base object if provided.
@@ -1090,7 +1145,7 @@ declare function clamp(value: any, min: any, max: any): number;
1090
1145
  * @param {Object|null} base - Fallback weights if primary is missing/invalid
1091
1146
  * @returns {{sell:number,buy:number}|null}
1092
1147
  */
1093
- declare function cloneWeightDistribution(weightDistribution: any, base?: any): {
1148
+ declare function cloneWeightDistribution(weightDistribution: WeightDistributionConfig | null | undefined, base?: WeightDistributionConfig | null): {
1094
1149
  sell: number;
1095
1150
  buy: number;
1096
1151
  } | null;