dexbot 1.4.11 → 1.4.12
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.
- package/README.md +4 -4
- package/dist/analysis/chart_utils.d.ts.map +1 -1
- package/dist/analysis/chart_utils.js +9 -18
- package/dist/analysis/chart_utils.js.map +1 -1
- package/dist/analysis/math_utils.d.ts.map +1 -1
- package/dist/analysis/math_utils.js +6 -16
- package/dist/analysis/math_utils.js.map +1 -1
- package/dist/analysis/tradingview/tradingview_uplot_chart_generator.d.ts +1 -1
- package/dist/analysis/tradingview/tradingview_uplot_chart_generator.d.ts.map +1 -1
- package/dist/analysis/tradingview/tradingview_uplot_chart_generator.js +31 -38
- package/dist/analysis/tradingview/tradingview_uplot_chart_generator.js.map +1 -1
- package/dist/analysis/trend_detection/hurst_analyzer.js +7 -10
- package/dist/analysis/trend_detection/hurst_analyzer.js.map +1 -1
- package/dist/analysis/trend_detection/kalman_trend_analyzer.js +10 -14
- package/dist/analysis/trend_detection/kalman_trend_analyzer.js.map +1 -1
- package/dist/analysis/trend_detection/kalman_velocity_smoothing.js +10 -15
- package/dist/analysis/trend_detection/kalman_velocity_smoothing.js.map +1 -1
- package/dist/analysis/trend_detection/permutation_entropy_analyzer.js +7 -10
- package/dist/analysis/trend_detection/permutation_entropy_analyzer.js.map +1 -1
- package/dist/bot.d.ts.map +1 -1
- package/dist/bot.js +4 -12
- package/dist/bot.js.map +1 -1
- package/dist/credential-daemon.d.ts +0 -1
- package/dist/credential-daemon.d.ts.map +1 -1
- package/dist/credential-daemon.js +3 -123
- package/dist/credential-daemon.js.map +1 -1
- package/dist/dexbot.d.ts +0 -87
- package/dist/dexbot.d.ts.map +1 -1
- package/dist/dexbot.js +11 -14
- package/dist/dexbot.js.map +1 -1
- package/dist/market_adapter/ama_signal_runner.js +8 -9
- package/dist/market_adapter/ama_signal_runner.js.map +1 -1
- package/dist/market_adapter/candle_utils.js +1 -7
- package/dist/market_adapter/candle_utils.js.map +1 -1
- package/dist/market_adapter/core/asymmetric_bounds.js +1 -4
- package/dist/market_adapter/core/asymmetric_bounds.js.map +1 -1
- package/dist/market_adapter/core/config_normalizers.js +5 -9
- package/dist/market_adapter/core/config_normalizers.js.map +1 -1
- package/dist/market_adapter/core/kibana_candles.js +8 -15
- package/dist/market_adapter/core/kibana_candles.js.map +1 -1
- package/dist/market_adapter/core/kibana_client.js +7 -13
- package/dist/market_adapter/core/kibana_client.js.map +1 -1
- package/dist/market_adapter/core/kibana_market_candles.js +6 -12
- package/dist/market_adapter/core/kibana_market_candles.js.map +1 -1
- package/dist/market_adapter/core/market_adapter_service.js +92 -102
- package/dist/market_adapter/core/market_adapter_service.js.map +1 -1
- package/dist/market_adapter/core/strategies/ama.js +5 -10
- package/dist/market_adapter/core/strategies/ama.js.map +1 -1
- package/dist/market_adapter/core/strategies/ama_slope_model.js +21 -24
- package/dist/market_adapter/core/strategies/ama_slope_model.js.map +1 -1
- package/dist/market_adapter/core/strategies/atr/calculator.js +3 -5
- package/dist/market_adapter/core/strategies/atr/calculator.js.map +1 -1
- package/dist/market_adapter/core/strategies/collateral_manager.js +4 -6
- package/dist/market_adapter/core/strategies/collateral_manager.js.map +1 -1
- package/dist/market_adapter/core/strategies/regime_gate.js +15 -22
- package/dist/market_adapter/core/strategies/regime_gate.js.map +1 -1
- package/dist/market_adapter/index.d.ts +23 -23
- package/dist/market_adapter/index.d.ts.map +1 -1
- package/dist/market_adapter/index.js +24 -82
- package/dist/market_adapter/index.js.map +1 -1
- package/dist/market_adapter/inputs/fetch_cex_synthetic_data.js +2 -1
- package/dist/market_adapter/inputs/fetch_cex_synthetic_data.js.map +1 -1
- package/dist/market_adapter/inputs/fetch_lp_data.d.ts.map +1 -1
- package/dist/market_adapter/inputs/fetch_lp_data.js +59 -98
- package/dist/market_adapter/inputs/fetch_lp_data.js.map +1 -1
- package/dist/market_adapter/inputs/kibana_source.js +11 -17
- package/dist/market_adapter/inputs/kibana_source.js.map +1 -1
- package/dist/market_adapter/interval_utils.js +1 -2
- package/dist/market_adapter/interval_utils.js.map +1 -1
- package/dist/market_adapter/log_format.js +1 -7
- package/dist/market_adapter/log_format.js.map +1 -1
- package/dist/market_adapter/lp_chart_core.js +20 -22
- package/dist/market_adapter/lp_chart_core.js.map +1 -1
- package/dist/market_adapter/lp_chart_runner.d.ts +1 -1
- package/dist/market_adapter/lp_chart_runner.d.ts.map +1 -1
- package/dist/market_adapter/lp_chart_runner.js +41 -57
- package/dist/market_adapter/lp_chart_runner.js.map +1 -1
- package/dist/market_adapter/lp_chart_strategy_loader.js +30 -34
- package/dist/market_adapter/lp_chart_strategy_loader.js.map +1 -1
- package/dist/market_adapter/market_adapter.d.ts +2 -2
- package/dist/market_adapter/market_adapter.d.ts.map +1 -1
- package/dist/market_adapter/market_adapter.js +157 -221
- package/dist/market_adapter/market_adapter.js.map +1 -1
- package/dist/market_adapter/merge_lp_data.js +17 -18
- package/dist/market_adapter/merge_lp_data.js.map +1 -1
- package/dist/market_adapter/test_helpers.js +3 -14
- package/dist/market_adapter/test_helpers.js.map +1 -1
- package/dist/market_adapter/utils/adapter_client.js +7 -16
- package/dist/market_adapter/utils/adapter_client.js.map +1 -1
- package/dist/market_adapter/utils/atomic_write.js +3 -5
- package/dist/market_adapter/utils/atomic_write.js.map +1 -1
- package/dist/market_adapter/utils/chain.d.ts.map +1 -1
- package/dist/market_adapter/utils/chain.js +9 -17
- package/dist/market_adapter/utils/chain.js.map +1 -1
- package/dist/market_adapter/utils/data_discovery.js +8 -10
- package/dist/market_adapter/utils/data_discovery.js.map +1 -1
- package/dist/market_adapter/utils/dynamic_grid_snapshot.d.ts.map +1 -1
- package/dist/market_adapter/utils/dynamic_grid_snapshot.js +11 -14
- package/dist/market_adapter/utils/dynamic_grid_snapshot.js.map +1 -1
- package/dist/market_adapter/utils/file_lock.js +14 -19
- package/dist/market_adapter/utils/file_lock.js.map +1 -1
- package/dist/market_adapter/utils/native_history.js +8 -14
- package/dist/market_adapter/utils/native_history.js.map +1 -1
- package/dist/market_adapter/utils/paths.js +3 -6
- package/dist/market_adapter/utils/paths.js.map +1 -1
- package/dist/modules/account_bots.d.ts +1 -1
- package/dist/modules/account_bots.d.ts.map +1 -1
- package/dist/modules/account_bots.js +90 -97
- package/dist/modules/account_bots.js.map +1 -1
- package/dist/modules/account_orders.d.ts +0 -9
- package/dist/modules/account_orders.d.ts.map +1 -1
- package/dist/modules/account_orders.js +26 -121
- package/dist/modules/account_orders.js.map +1 -1
- package/dist/modules/authority_resolver.js +12 -18
- package/dist/modules/authority_resolver.js.map +1 -1
- package/dist/modules/bitshares-native/chain_client.js +16 -21
- package/dist/modules/bitshares-native/chain_client.js.map +1 -1
- package/dist/modules/bitshares-native/crypto/ecc.browser.js +12 -72
- package/dist/modules/bitshares-native/crypto/ecc.browser.js.map +1 -1
- package/dist/modules/bitshares-native/crypto/ecc.js +13 -40
- package/dist/modules/bitshares-native/crypto/ecc.js.map +1 -1
- package/dist/modules/bitshares-native/crypto/ecc_selector.d.ts.map +1 -1
- package/dist/modules/bitshares-native/crypto/ecc_selector.js +5 -6
- package/dist/modules/bitshares-native/crypto/ecc_selector.js.map +1 -1
- package/dist/modules/bitshares-native/index.d.ts +8 -8
- package/dist/modules/bitshares-native/index.d.ts.map +1 -1
- package/dist/modules/bitshares-native/index.js +11 -68
- package/dist/modules/bitshares-native/index.js.map +1 -1
- package/dist/modules/bitshares-native/lru_cache.js +3 -6
- package/dist/modules/bitshares-native/lru_cache.js.map +1 -1
- package/dist/modules/bitshares-native/resolvers.js +9 -11
- package/dist/modules/bitshares-native/resolvers.js.map +1 -1
- package/dist/modules/bitshares-native/serial/chain_constants.js +3 -28
- package/dist/modules/bitshares-native/serial/chain_constants.js.map +1 -1
- package/dist/modules/bitshares-native/serial/index.d.ts +4 -4
- package/dist/modules/bitshares-native/serial/index.d.ts.map +1 -1
- package/dist/modules/bitshares-native/serial/index.js +5 -46
- package/dist/modules/bitshares-native/serial/index.js.map +1 -1
- package/dist/modules/bitshares-native/serial/operations.d.ts +98 -98
- package/dist/modules/bitshares-native/serial/operations.d.ts.map +1 -1
- package/dist/modules/bitshares-native/serial/operations.js +372 -473
- package/dist/modules/bitshares-native/serial/operations.js.map +1 -1
- package/dist/modules/bitshares-native/serial/serializer.js +3 -8
- package/dist/modules/bitshares-native/serial/serializer.js.map +1 -1
- package/dist/modules/bitshares-native/serial/types.js +9 -74
- package/dist/modules/bitshares-native/serial/types.js.map +1 -1
- package/dist/modules/bitshares-native/signing_client.d.ts.map +1 -1
- package/dist/modules/bitshares-native/signing_client.js +11 -48
- package/dist/modules/bitshares-native/signing_client.js.map +1 -1
- package/dist/modules/bitshares-native/subscriptions.d.ts.map +1 -1
- package/dist/modules/bitshares-native/subscriptions.js +24 -27
- package/dist/modules/bitshares-native/subscriptions.js.map +1 -1
- package/dist/modules/bitshares-native/transport.d.ts.map +1 -1
- package/dist/modules/bitshares-native/transport.js +14 -26
- package/dist/modules/bitshares-native/transport.js.map +1 -1
- package/dist/modules/bitshares-native/tx/builder.js +29 -72
- package/dist/modules/bitshares-native/tx/builder.js.map +1 -1
- package/dist/modules/bitshares-native/tx/tx_cache.js +12 -21
- package/dist/modules/bitshares-native/tx/tx_cache.js.map +1 -1
- package/dist/modules/bitshares_client.d.ts +21 -0
- package/dist/modules/bitshares_client.d.ts.map +1 -1
- package/dist/modules/bitshares_client.js +32 -86
- package/dist/modules/bitshares_client.js.map +1 -1
- package/dist/modules/bot_settings.d.ts.map +1 -1
- package/dist/modules/bot_settings.js +30 -49
- package/dist/modules/bot_settings.js.map +1 -1
- package/dist/modules/bots_file_lock.d.ts.map +1 -1
- package/dist/modules/bots_file_lock.js +5 -13
- package/dist/modules/bots_file_lock.js.map +1 -1
- package/dist/modules/broadcast_failure.js +1 -3
- package/dist/modules/broadcast_failure.js.map +1 -1
- package/dist/modules/chain_keys.d.ts +4 -9
- package/dist/modules/chain_keys.d.ts.map +1 -1
- package/dist/modules/chain_keys.js +77 -182
- package/dist/modules/chain_keys.js.map +1 -1
- package/dist/modules/chain_orders.d.ts +2 -2
- package/dist/modules/chain_orders.d.ts.map +1 -1
- package/dist/modules/chain_orders.js +81 -144
- package/dist/modules/chain_orders.js.map +1 -1
- package/dist/modules/config.d.ts.map +1 -1
- package/dist/modules/config.js +23 -28
- package/dist/modules/config.js.map +1 -1
- package/dist/modules/constants.d.ts +2 -9
- package/dist/modules/constants.d.ts.map +1 -1
- package/dist/modules/constants.js +38 -73
- package/dist/modules/constants.js.map +1 -1
- package/dist/modules/cr_planner.js +15 -26
- package/dist/modules/cr_planner.js.map +1 -1
- package/dist/modules/credential_policy.d.ts +3 -6
- package/dist/modules/credential_policy.d.ts.map +1 -1
- package/dist/modules/credential_policy.js +62 -153
- package/dist/modules/credential_policy.js.map +1 -1
- package/dist/modules/credential_runtime.d.ts +1 -1
- package/dist/modules/credential_runtime.d.ts.map +1 -1
- package/dist/modules/credential_runtime.js +34 -41
- package/dist/modules/credential_runtime.js.map +1 -1
- package/dist/modules/credential_session_cache.d.ts +1 -1
- package/dist/modules/credential_session_cache.d.ts.map +1 -1
- package/dist/modules/credential_session_cache.js +5 -42
- package/dist/modules/credential_session_cache.js.map +1 -1
- package/dist/modules/credit_runtime.d.ts.map +1 -1
- package/dist/modules/credit_runtime.js +126 -162
- package/dist/modules/credit_runtime.js.map +1 -1
- package/dist/modules/crypto/browser_provider.d.ts +1 -1
- package/dist/modules/crypto/browser_provider.d.ts.map +1 -1
- package/dist/modules/crypto/browser_provider.js +7 -11
- package/dist/modules/crypto/browser_provider.js.map +1 -1
- package/dist/modules/crypto/index.d.ts +6 -6
- package/dist/modules/crypto/index.d.ts.map +1 -1
- package/dist/modules/crypto/index.js +12 -30
- package/dist/modules/crypto/index.js.map +1 -1
- package/dist/modules/crypto/node_provider.d.ts +1 -1
- package/dist/modules/crypto/node_provider.d.ts.map +1 -1
- package/dist/modules/crypto/node_provider.js +3 -5
- package/dist/modules/crypto/node_provider.js.map +1 -1
- package/dist/modules/crypto/provider.js +1 -2
- package/dist/modules/crypto/pure_ripemd160.js +1 -3
- package/dist/modules/crypto/pure_ripemd160.js.map +1 -1
- package/dist/modules/crypto/pure_scrypt.js +1 -4
- package/dist/modules/crypto/pure_scrypt.js.map +1 -1
- package/dist/modules/crypto/pure_secp256k1.d.ts +1 -1
- package/dist/modules/crypto/pure_secp256k1.d.ts.map +1 -1
- package/dist/modules/crypto/pure_secp256k1.js +1 -16
- package/dist/modules/crypto/pure_secp256k1.js.map +1 -1
- package/dist/modules/crypto/sync.d.ts.map +1 -1
- package/dist/modules/crypto/sync.js +16 -17
- package/dist/modules/crypto/sync.js.map +1 -1
- package/dist/modules/daemon_node_health.js +14 -16
- package/dist/modules/daemon_node_health.js.map +1 -1
- package/dist/modules/dexbot_class.d.ts +19 -14
- package/dist/modules/dexbot_class.d.ts.map +1 -1
- package/dist/modules/dexbot_class.js +127 -164
- package/dist/modules/dexbot_class.js.map +1 -1
- package/dist/modules/dexbot_cow_runtime.d.ts +28 -27
- package/dist/modules/dexbot_cow_runtime.d.ts.map +1 -1
- package/dist/modules/dexbot_cow_runtime.js +55 -45
- package/dist/modules/dexbot_cow_runtime.js.map +1 -1
- package/dist/modules/dexbot_credential_client.d.ts +6 -2
- package/dist/modules/dexbot_credential_client.d.ts.map +1 -1
- package/dist/modules/dexbot_credential_client.js +21 -31
- package/dist/modules/dexbot_credential_client.js.map +1 -1
- package/dist/modules/dexbot_fill_runtime.d.ts +23 -23
- package/dist/modules/dexbot_fill_runtime.d.ts.map +1 -1
- package/dist/modules/dexbot_fill_runtime.js +119 -77
- package/dist/modules/dexbot_fill_runtime.js.map +1 -1
- package/dist/modules/dexbot_maintenance_runtime.d.ts +46 -38
- package/dist/modules/dexbot_maintenance_runtime.d.ts.map +1 -1
- package/dist/modules/dexbot_maintenance_runtime.js +81 -81
- package/dist/modules/dexbot_maintenance_runtime.js.map +1 -1
- package/dist/modules/dexbot_startup_runtime.d.ts +3 -3
- package/dist/modules/dexbot_startup_runtime.d.ts.map +1 -1
- package/dist/modules/dexbot_startup_runtime.js +43 -81
- package/dist/modules/dexbot_startup_runtime.js.map +1 -1
- package/dist/modules/dexbot_state_recovery.d.ts +11 -11
- package/dist/modules/dexbot_state_recovery.js +32 -78
- package/dist/modules/dexbot_state_recovery.js.map +1 -1
- package/dist/modules/env.js +3 -7
- package/dist/modules/env.js.map +1 -1
- package/dist/modules/fund_registry.d.ts.map +1 -1
- package/dist/modules/fund_registry.js +12 -24
- package/dist/modules/fund_registry.js.map +1 -1
- package/dist/modules/general_settings.js +10 -16
- package/dist/modules/general_settings.js.map +1 -1
- package/dist/modules/graceful_shutdown.d.ts.map +1 -1
- package/dist/modules/graceful_shutdown.js +12 -19
- package/dist/modules/graceful_shutdown.js.map +1 -1
- package/dist/modules/key_store.d.ts.map +1 -1
- package/dist/modules/key_store.js +27 -65
- package/dist/modules/key_store.js.map +1 -1
- package/dist/modules/launcher/bot_supervisor.d.ts +1 -1
- package/dist/modules/launcher/bot_supervisor.d.ts.map +1 -1
- package/dist/modules/launcher/bot_supervisor.js +89 -118
- package/dist/modules/launcher/bot_supervisor.js.map +1 -1
- package/dist/modules/launcher/child_env.js +1 -5
- package/dist/modules/launcher/child_env.js.map +1 -1
- package/dist/modules/launcher/credential_bootstrap.js +22 -31
- package/dist/modules/launcher/credential_bootstrap.js.map +1 -1
- package/dist/modules/launcher/credential_daemon.js +37 -75
- package/dist/modules/launcher/credential_daemon.js.map +1 -1
- package/dist/modules/launcher/credential_secret.js +2 -37
- package/dist/modules/launcher/credential_secret.js.map +1 -1
- package/dist/modules/launcher/foreign_cred_daemon.js +25 -31
- package/dist/modules/launcher/foreign_cred_daemon.js.map +1 -1
- package/dist/modules/launcher/headless_password.js +10 -12
- package/dist/modules/launcher/headless_password.js.map +1 -1
- package/dist/modules/launcher/launch_modes.js +3 -9
- package/dist/modules/launcher/launch_modes.js.map +1 -1
- package/dist/modules/launcher/market_adapter_runtime.d.ts +1 -1
- package/dist/modules/launcher/market_adapter_runtime.d.ts.map +1 -1
- package/dist/modules/launcher/market_adapter_runtime.js +25 -35
- package/dist/modules/launcher/market_adapter_runtime.js.map +1 -1
- package/dist/modules/launcher/market_adapter_watchdog.d.ts.map +1 -1
- package/dist/modules/launcher/market_adapter_watchdog.js +42 -45
- package/dist/modules/launcher/market_adapter_watchdog.js.map +1 -1
- package/dist/modules/launcher/monolithic_runtime.d.ts +1 -1
- package/dist/modules/launcher/monolithic_runtime.d.ts.map +1 -1
- package/dist/modules/launcher/monolithic_runtime.js +67 -138
- package/dist/modules/launcher/monolithic_runtime.js.map +1 -1
- package/dist/modules/launcher/runtime_entry.d.ts +1 -11
- package/dist/modules/launcher/runtime_entry.d.ts.map +1 -1
- package/dist/modules/launcher/runtime_entry.js +12 -15
- package/dist/modules/launcher/runtime_entry.js.map +1 -1
- package/dist/modules/launcher/status_reporting.d.ts +1 -1
- package/dist/modules/launcher/status_reporting.d.ts.map +1 -1
- package/dist/modules/launcher/status_reporting.js +15 -36
- package/dist/modules/launcher/status_reporting.js.map +1 -1
- package/dist/modules/launcher/supervisor_control.js +4 -9
- package/dist/modules/launcher/supervisor_control.js.map +1 -1
- package/dist/modules/logger.d.ts +1 -1
- package/dist/modules/logger.d.ts.map +1 -1
- package/dist/modules/logger.js +3 -38
- package/dist/modules/logger.js.map +1 -1
- package/dist/modules/market_adapter_whitelist.js +9 -18
- package/dist/modules/market_adapter_whitelist.js.map +1 -1
- package/dist/modules/node_failure_ledger.js +1 -3
- package/dist/modules/node_failure_ledger.js.map +1 -1
- package/dist/modules/node_health_cache.d.ts.map +1 -1
- package/dist/modules/node_health_cache.js +15 -25
- package/dist/modules/node_health_cache.js.map +1 -1
- package/dist/modules/node_manager.d.ts +1 -1
- package/dist/modules/node_manager.d.ts.map +1 -1
- package/dist/modules/node_manager.js +44 -43
- package/dist/modules/node_manager.js.map +1 -1
- package/dist/modules/order/accounting.d.ts.map +1 -1
- package/dist/modules/order/accounting.js +102 -118
- package/dist/modules/order/accounting.js.map +1 -1
- package/dist/modules/order/async_lock.d.ts +3 -15
- package/dist/modules/order/async_lock.d.ts.map +1 -1
- package/dist/modules/order/async_lock.js +6 -26
- package/dist/modules/order/async_lock.js.map +1 -1
- package/dist/modules/order/export.js +34 -75
- package/dist/modules/order/export.js.map +1 -1
- package/dist/modules/order/format.d.ts +1 -3
- package/dist/modules/order/format.d.ts.map +1 -1
- package/dist/modules/order/format.js +4 -24
- package/dist/modules/order/format.js.map +1 -1
- package/dist/modules/order/grid.d.ts +3 -3
- package/dist/modules/order/grid.d.ts.map +1 -1
- package/dist/modules/order/grid.js +206 -262
- package/dist/modules/order/grid.js.map +1 -1
- package/dist/modules/order/grid_reconcile.d.ts.map +1 -1
- package/dist/modules/order/grid_reconcile.js +77 -94
- package/dist/modules/order/grid_reconcile.js.map +1 -1
- package/dist/modules/order/grid_reconcile_internal.d.ts.map +1 -1
- package/dist/modules/order/grid_reconcile_internal.js +117 -149
- package/dist/modules/order/grid_reconcile_internal.js.map +1 -1
- package/dist/modules/order/index.d.ts.map +1 -1
- package/dist/modules/order/index.js +11 -45
- package/dist/modules/order/index.js.map +1 -1
- package/dist/modules/order/logger.js +28 -69
- package/dist/modules/order/logger.js.map +1 -1
- package/dist/modules/order/logger_state.d.ts.map +1 -1
- package/dist/modules/order/logger_state.js +3 -4
- package/dist/modules/order/logger_state.js.map +1 -1
- package/dist/modules/order/manager.d.ts +10 -0
- package/dist/modules/order/manager.d.ts.map +1 -1
- package/dist/modules/order/manager.js +131 -151
- package/dist/modules/order/manager.js.map +1 -1
- package/dist/modules/order/processed_fill_store.js +2 -7
- package/dist/modules/order/processed_fill_store.js.map +1 -1
- package/dist/modules/order/strategy.js +23 -25
- package/dist/modules/order/strategy.js.map +1 -1
- package/dist/modules/order/sync_engine.d.ts +27 -0
- package/dist/modules/order/sync_engine.d.ts.map +1 -1
- package/dist/modules/order/sync_engine.js +232 -181
- package/dist/modules/order/sync_engine.js.map +1 -1
- package/dist/modules/order/utils/math.d.ts +1 -25
- package/dist/modules/order/utils/math.d.ts.map +1 -1
- package/dist/modules/order/utils/math.js +49 -172
- package/dist/modules/order/utils/math.js.map +1 -1
- package/dist/modules/order/utils/order.d.ts +46 -2
- package/dist/modules/order/utils/order.d.ts.map +1 -1
- package/dist/modules/order/utils/order.js +165 -143
- package/dist/modules/order/utils/order.js.map +1 -1
- package/dist/modules/order/utils/system.d.ts +3 -1
- package/dist/modules/order/utils/system.d.ts.map +1 -1
- package/dist/modules/order/utils/system.js +152 -211
- package/dist/modules/order/utils/system.js.map +1 -1
- package/dist/modules/order/utils/timeout.js +1 -4
- package/dist/modules/order/utils/timeout.js.map +1 -1
- package/dist/modules/order/utils/validate.js +91 -142
- package/dist/modules/order/utils/validate.js.map +1 -1
- package/dist/modules/order/utils/withPoolRef.js +21 -61
- package/dist/modules/order/utils/withPoolRef.js.map +1 -1
- package/dist/modules/order/working_grid.js +6 -9
- package/dist/modules/order/working_grid.js.map +1 -1
- package/dist/modules/path_api.d.ts.map +1 -1
- package/dist/modules/path_api.js +8 -11
- package/dist/modules/path_api.js.map +1 -1
- package/dist/modules/paths.d.ts.map +1 -1
- package/dist/modules/paths.js +61 -67
- package/dist/modules/paths.js.map +1 -1
- package/dist/modules/process_discovery.js +13 -21
- package/dist/modules/process_discovery.js.map +1 -1
- package/dist/modules/runtime.js +7 -11
- package/dist/modules/runtime.js.map +1 -1
- package/dist/modules/runtime_settings.d.ts.map +1 -1
- package/dist/modules/runtime_settings.js +14 -16
- package/dist/modules/runtime_settings.js.map +1 -1
- package/dist/modules/settings_merge.js +1 -3
- package/dist/modules/settings_merge.js.map +1 -1
- package/dist/modules/socket_json_client.js +3 -5
- package/dist/modules/socket_json_client.js.map +1 -1
- package/dist/modules/storage/browser_adapter.js +1 -4
- package/dist/modules/storage/browser_adapter.js.map +1 -1
- package/dist/modules/storage/index.d.ts +3 -2
- package/dist/modules/storage/index.d.ts.map +1 -1
- package/dist/modules/storage/index.js +5 -8
- package/dist/modules/storage/index.js.map +1 -1
- package/dist/modules/storage/node_adapter.d.ts +3 -4
- package/dist/modules/storage/node_adapter.d.ts.map +1 -1
- package/dist/modules/storage/node_adapter.js +12 -16
- package/dist/modules/storage/node_adapter.js.map +1 -1
- package/dist/modules/storage/types.js +1 -2
- package/dist/modules/types.d.ts +0 -6
- package/dist/modules/types.d.ts.map +1 -1
- package/dist/modules/types.js +1 -2
- package/dist/modules/types.js.map +1 -1
- package/dist/modules/utils/base58check.js +8 -15
- package/dist/modules/utils/base58check.js.map +1 -1
- package/dist/modules/utils/build_dir.js +3 -7
- package/dist/modules/utils/build_dir.js.map +1 -1
- package/dist/modules/utils/errors.js +1 -5
- package/dist/modules/utils/errors.js.map +1 -1
- package/dist/modules/utils/math_utils.d.ts +1 -1
- package/dist/modules/utils/math_utils.d.ts.map +1 -1
- package/dist/modules/utils/math_utils.js +2 -7
- package/dist/modules/utils/math_utils.js.map +1 -1
- package/dist/modules/validate_profiles.d.ts.map +1 -1
- package/dist/modules/validate_profiles.js +18 -25
- package/dist/modules/validate_profiles.js.map +1 -1
- package/dist/pm2.d.ts +4 -70
- package/dist/pm2.d.ts.map +1 -1
- package/dist/pm2.js +106 -132
- package/dist/pm2.js.map +1 -1
- package/dist/scripts/analyze-git.js +13 -17
- package/dist/scripts/analyze-git.js.map +1 -1
- package/dist/scripts/analyze-orders.d.ts.map +1 -1
- package/dist/scripts/analyze-orders.js +48 -63
- package/dist/scripts/analyze-orders.js.map +1 -1
- package/dist/scripts/diagnose-kibana-candles.d.ts.map +1 -1
- package/dist/scripts/diagnose-kibana-candles.js +2 -1
- package/dist/scripts/diagnose-kibana-candles.js.map +1 -1
- package/dist/scripts/diagnose-pool-history.d.ts.map +1 -1
- package/dist/scripts/diagnose-pool-history.js +2 -1
- package/dist/scripts/diagnose-pool-history.js.map +1 -1
- package/dist/scripts/divergence-calc.d.ts.map +1 -1
- package/dist/scripts/divergence-calc.js +2 -2
- package/dist/scripts/divergence-calc.js.map +1 -1
- package/dist/scripts/fix-err-message.js +17 -22
- package/dist/scripts/fix-err-message.js.map +1 -1
- package/dist/scripts/generate_lp_chart.d.ts.map +1 -1
- package/dist/scripts/generate_lp_chart.js +7 -15
- package/dist/scripts/generate_lp_chart.js.map +1 -1
- package/dist/scripts/generate_mainnet_corpus_report.d.ts.map +1 -1
- package/dist/scripts/generate_mainnet_corpus_report.js +3 -2
- package/dist/scripts/generate_mainnet_corpus_report.js.map +1 -1
- package/dist/scripts/generate_market_adapter_whitelist.d.ts.map +1 -1
- package/dist/scripts/generate_market_adapter_whitelist.js +18 -24
- package/dist/scripts/generate_market_adapter_whitelist.js.map +1 -1
- package/dist/scripts/native_release_gates.js +15 -19
- package/dist/scripts/native_release_gates.js.map +1 -1
- package/dist/scripts/print_grid.d.ts.map +1 -1
- package/dist/scripts/print_grid.js +2 -2
- package/dist/scripts/print_grid.js.map +1 -1
- package/dist/scripts/run-tests.js +12 -17
- package/dist/scripts/run-tests.js.map +1 -1
- package/dist/scripts/runner.d.ts.map +1 -1
- package/dist/scripts/runner.js +18 -20
- package/dist/scripts/runner.js.map +1 -1
- package/dist/scripts/sync-version.js +2 -2
- package/dist/scripts/sync-version.js.map +1 -1
- package/dist/scripts/test-credit-renewal.d.ts.map +1 -1
- package/dist/scripts/test-credit-renewal.js +4 -3
- package/dist/scripts/test-credit-renewal.js.map +1 -1
- package/dist/scripts/update.js +77 -89
- package/dist/scripts/update.js.map +1 -1
- package/dist/scripts/validate_bots.d.ts.map +1 -1
- package/dist/scripts/validate_bots.js +2 -2
- package/dist/scripts/validate_bots.js.map +1 -1
- package/dist/scripts/verify-browser-bundle.js +12 -17
- package/dist/scripts/verify-browser-bundle.js.map +1 -1
- package/dist/unlock.d.ts +0 -30
- package/dist/unlock.d.ts.map +1 -1
- package/dist/unlock.js +95 -143
- package/dist/unlock.js.map +1 -1
- package/package.json +5 -8
- package/scripts/README.md +1 -1
- package/scripts/create-bot-symlinks.sh +2 -2
- package/dist/modules/utils/fs_utils.d.ts +0 -18
- package/dist/modules/utils/fs_utils.d.ts.map +0 -1
- package/dist/modules/utils/fs_utils.js +0 -32
- package/dist/modules/utils/fs_utils.js.map +0 -1
- package/dist/scripts/migrate_bot_keys.d.ts +0 -3
- package/dist/scripts/migrate_bot_keys.d.ts.map +0 -1
- package/dist/scripts/migrate_bot_keys.js +0 -225
- package/dist/scripts/migrate_bot_keys.js.map +0 -1
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
/**
|
|
3
2
|
* modules/dexbot_class.ts - DEXBot Core Engine
|
|
4
3
|
*
|
|
@@ -53,60 +52,25 @@
|
|
|
53
52
|
*
|
|
54
53
|
* ===============================================================================
|
|
55
54
|
*/
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
60
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
61
|
-
}
|
|
62
|
-
Object.defineProperty(o, k2, desc);
|
|
63
|
-
}) : (function(o, m, k, k2) {
|
|
64
|
-
if (k2 === undefined) k2 = k;
|
|
65
|
-
o[k2] = m[k];
|
|
66
|
-
}));
|
|
67
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
68
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
69
|
-
}) : function(o, v) {
|
|
70
|
-
o["default"] = v;
|
|
71
|
-
});
|
|
72
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
73
|
-
var ownKeys = function(o) {
|
|
74
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
75
|
-
var ar = [];
|
|
76
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
77
|
-
return ar;
|
|
78
|
-
};
|
|
79
|
-
return ownKeys(o);
|
|
80
|
-
};
|
|
81
|
-
return function (mod) {
|
|
82
|
-
if (mod && mod.__esModule) return mod;
|
|
83
|
-
var result = {};
|
|
84
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
85
|
-
__setModuleDefault(result, mod);
|
|
86
|
-
return result;
|
|
87
|
-
};
|
|
88
|
-
})();
|
|
89
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
90
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
91
|
-
};
|
|
92
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
93
|
-
const client = __importStar(require("./bitshares_client"));
|
|
55
|
+
import { createRequire } from 'node:module';
|
|
56
|
+
const require = createRequire(import.meta.url);
|
|
57
|
+
import * as client from './bitshares_client.js';
|
|
94
58
|
const { BitShares } = client;
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
59
|
+
import * as chainKeys from './chain_keys.js';
|
|
60
|
+
import * as chainOrders from './chain_orders.js';
|
|
61
|
+
import * as fundRegistry from './fund_registry.js';
|
|
62
|
+
import * as DexbotFillRuntime from './dexbot_fill_runtime.js';
|
|
63
|
+
import DexbotMaintenanceRuntime from './dexbot_maintenance_runtime.js';
|
|
64
|
+
import * as DexbotStateRecovery from './dexbot_state_recovery.js';
|
|
65
|
+
import * as DexbotStartupRuntime from './dexbot_startup_runtime.js';
|
|
66
|
+
import CreditRuntime from './credit_runtime.js';
|
|
67
|
+
import { PATHS } from './paths.js';
|
|
68
|
+
import * as Format from './order/format.js';
|
|
69
|
+
import cowRuntime from './dexbot_cow_runtime.js';
|
|
70
|
+
import { ProcessedFillStore, PROCESSED_FILL_PERSISTENCE_MODES } from './order/processed_fill_store.js';
|
|
71
|
+
import { TIMING, FILL_PROCESSING, DAEMON_CODES, } from './constants.js';
|
|
72
|
+
import { normalizeBotEntry } from './bot_settings.js';
|
|
73
|
+
import { getErrorMessage } from './utils/errors.js';
|
|
110
74
|
function waitForConnected(...args) { return require('./bitshares_client').waitForConnected(...args); }
|
|
111
75
|
function getKeyStore(...args) { return require('./key_store').getKeyStore(...args); }
|
|
112
76
|
function hasExecutableActions(...args) { return require('./order/utils/validate').hasExecutableActions(...args); }
|
|
@@ -201,9 +165,9 @@ class DEXBot {
|
|
|
201
165
|
this.config.logging = rs.logging;
|
|
202
166
|
this._fillDedupeWindowMs = this.config.timing.FILL_DEDUPE_WINDOW_MS;
|
|
203
167
|
this._fillRecordRetentionMs = this.config.timing.FILL_RECORD_RETENTION_MS;
|
|
204
|
-
this._processedFillPersistBatchMs =
|
|
205
|
-
this._processedFillPersistBatchSize =
|
|
206
|
-
this._processedFillStore = new
|
|
168
|
+
this._processedFillPersistBatchMs = TIMING.PROCESSED_FILL_PERSIST_BATCH_MS;
|
|
169
|
+
this._processedFillPersistBatchSize = TIMING.PROCESSED_FILL_PERSIST_BATCH_SIZE;
|
|
170
|
+
this._processedFillStore = new ProcessedFillStore({
|
|
207
171
|
batchMs: this._processedFillPersistBatchMs,
|
|
208
172
|
batchSize: this._processedFillPersistBatchSize,
|
|
209
173
|
warn: (message) => this._warn(message)
|
|
@@ -367,7 +331,7 @@ class DEXBot {
|
|
|
367
331
|
* @returns {{incomingFillQueueLength: number, shadowLocks: number, batchInFlight: boolean, recoveryInFlight: boolean, broadcasting: boolean}}
|
|
368
332
|
*/
|
|
369
333
|
_getPipelineSignals() {
|
|
370
|
-
return
|
|
334
|
+
return DexbotMaintenanceRuntime.getPipelineSignals(this);
|
|
371
335
|
}
|
|
372
336
|
/**
|
|
373
337
|
* Mark that grid activity occurred (updates idle timer).
|
|
@@ -375,7 +339,7 @@ class DEXBot {
|
|
|
375
339
|
* @returns {void}
|
|
376
340
|
*/
|
|
377
341
|
_markGridActivity(reason = 'activity') {
|
|
378
|
-
return
|
|
342
|
+
return DexbotMaintenanceRuntime.markGridActivity(this, reason);
|
|
379
343
|
}
|
|
380
344
|
/**
|
|
381
345
|
* Trigger a full state recovery sync (fetch chain + sync from open orders + persist).
|
|
@@ -544,7 +508,7 @@ class DEXBot {
|
|
|
544
508
|
/**
|
|
545
509
|
* Apply replay-safe fill accounting using a provided fill key.
|
|
546
510
|
* @param {Object} fill - Fill event object
|
|
547
|
-
* @param {import('./types').FillOperationData} fillOp - Fill operation data
|
|
511
|
+
* @param {import('./types.js').FillOperationData} fillOp - Fill operation data
|
|
548
512
|
* @param {Object} [options={}] - Options
|
|
549
513
|
* @param {string} [options.missingKeyMessage]
|
|
550
514
|
* @param {string} [options.fallbackKeyMessage]
|
|
@@ -556,9 +520,9 @@ class DEXBot {
|
|
|
556
520
|
* @param {string} [options.replayLevel='debug']
|
|
557
521
|
* @param {string} [options.persistenceMode='immediate']
|
|
558
522
|
* @param {boolean} [options.allowOrphanFallbackKey=false]
|
|
559
|
-
* @returns {Promise<import('./types').ReplaySafeFillResult>}
|
|
523
|
+
* @returns {Promise<import('./types.js').ReplaySafeFillResult>}
|
|
560
524
|
*/
|
|
561
|
-
async _applyReplaySafeFillAccounting(fill, fillOp, { missingKeyMessage, fallbackKeyMessage, replayMessage, errorMessage, logger = this.manager?.logger, missingKeyLevel = 'warn', fallbackKeyLevel = 'warn', replayLevel = 'debug', persistenceMode =
|
|
525
|
+
async _applyReplaySafeFillAccounting(fill, fillOp, { missingKeyMessage, fallbackKeyMessage, replayMessage, errorMessage, logger = this.manager?.logger, missingKeyLevel = 'warn', fallbackKeyLevel = 'warn', replayLevel = 'debug', persistenceMode = PROCESSED_FILL_PERSISTENCE_MODES.IMMEDIATE, allowOrphanFallbackKey = false } = {}) {
|
|
562
526
|
return DexbotFillRuntime.applyReplaySafeFillAccounting(this, fill, fillOp, {
|
|
563
527
|
missingKeyMessage,
|
|
564
528
|
fallbackKeyMessage,
|
|
@@ -575,15 +539,15 @@ class DEXBot {
|
|
|
575
539
|
/**
|
|
576
540
|
* Apply replay-safe fill accounting for tracked fills (those with a valid grid order).
|
|
577
541
|
* @param {Object} fill - Fill event object
|
|
578
|
-
* @param {import('./types').FillOperationData} fillOp - Fill operation data
|
|
542
|
+
* @param {import('./types.js').FillOperationData} fillOp - Fill operation data
|
|
579
543
|
* @param {Object} [options={}]
|
|
580
544
|
* @param {string} [options.context]
|
|
581
545
|
* @param {Object} [options.logger]
|
|
582
546
|
* @param {string} [options.replayMessage]
|
|
583
547
|
* @param {string} [options.persistenceMode='batched']
|
|
584
|
-
* @returns {Promise<import('./types').ReplaySafeFillResult>}
|
|
548
|
+
* @returns {Promise<import('./types.js').ReplaySafeFillResult>}
|
|
585
549
|
*/
|
|
586
|
-
async _applyReplaySafeTrackedFillAccounting(fill, fillOp, { context, logger = this.manager?.logger, replayMessage, persistenceMode =
|
|
550
|
+
async _applyReplaySafeTrackedFillAccounting(fill, fillOp, { context, logger = this.manager?.logger, replayMessage, persistenceMode = PROCESSED_FILL_PERSISTENCE_MODES.BATCHED } = {}) {
|
|
587
551
|
return DexbotFillRuntime.applyReplaySafeTrackedFillAccounting(this, fill, fillOp, {
|
|
588
552
|
context,
|
|
589
553
|
logger,
|
|
@@ -594,15 +558,15 @@ class DEXBot {
|
|
|
594
558
|
/**
|
|
595
559
|
* Apply replay-safe fill accounting for orphan fills (grid order not found).
|
|
596
560
|
* @param {Object} fill - Fill event object
|
|
597
|
-
* @param {import('./types').FillOperationData} fillOp - Fill operation data
|
|
561
|
+
* @param {import('./types.js').FillOperationData} fillOp - Fill operation data
|
|
598
562
|
* @param {Object} [options={}]
|
|
599
563
|
* @param {string} [options.context]
|
|
600
564
|
* @param {Object} [options.logger]
|
|
601
565
|
* @param {string} [options.replayMessage]
|
|
602
566
|
* @param {string} [options.persistenceMode='batched']
|
|
603
|
-
* @returns {Promise<import('./types').ReplaySafeFillResult>}
|
|
567
|
+
* @returns {Promise<import('./types.js').ReplaySafeFillResult>}
|
|
604
568
|
*/
|
|
605
|
-
async _applyReplaySafeOrphanFillAccounting(fill, fillOp, { context, logger = this.manager?.logger, replayMessage, persistenceMode =
|
|
569
|
+
async _applyReplaySafeOrphanFillAccounting(fill, fillOp, { context, logger = this.manager?.logger, replayMessage, persistenceMode = PROCESSED_FILL_PERSISTENCE_MODES.BATCHED } = {}) {
|
|
606
570
|
return DexbotFillRuntime.applyReplaySafeOrphanFillAccounting(this, fill, fillOp, {
|
|
607
571
|
context,
|
|
608
572
|
logger,
|
|
@@ -613,10 +577,10 @@ class DEXBot {
|
|
|
613
577
|
/**
|
|
614
578
|
* Refresh dynamic weight distribution from market adapter.
|
|
615
579
|
* @param {string} [context='runtime'] - Context label for logging
|
|
616
|
-
* @returns {import('./types').DynamicWeightRefreshResult|null}
|
|
580
|
+
* @returns {import('./types.js').DynamicWeightRefreshResult|null}
|
|
617
581
|
*/
|
|
618
582
|
_refreshDynamicWeightDistribution(context = 'runtime') {
|
|
619
|
-
return
|
|
583
|
+
return DexbotMaintenanceRuntime.refreshDynamicWeightDistribution(this, context);
|
|
620
584
|
}
|
|
621
585
|
/**
|
|
622
586
|
* Finalize the bot startup after account and initial grid sync are complete.
|
|
@@ -644,7 +608,7 @@ class DEXBot {
|
|
|
644
608
|
* @returns {Promise<{syncResult: Object|null, aborted: boolean, hasUnmatched: number, openOrders: Array|null}>}
|
|
645
609
|
*/
|
|
646
610
|
async _syncOpenOrdersAndProcessFills(tag) {
|
|
647
|
-
return
|
|
611
|
+
return DexbotMaintenanceRuntime.syncOpenOrdersAndProcessFills(this, tag);
|
|
648
612
|
}
|
|
649
613
|
_maxConsecutiveFillConsumerFailures() {
|
|
650
614
|
return DexbotFillRuntime.maxConsecutiveFillConsumerFailures(this);
|
|
@@ -724,7 +688,7 @@ class DEXBot {
|
|
|
724
688
|
* @throws {Error} If initialization fails or preferredAccount is missing.
|
|
725
689
|
*/
|
|
726
690
|
async initialize(vaultSecret = null) {
|
|
727
|
-
await waitForConnected(
|
|
691
|
+
await waitForConnected(TIMING.CONNECTION_TIMEOUT_MS);
|
|
728
692
|
if (this.config && this.config.preferredAccount) {
|
|
729
693
|
try {
|
|
730
694
|
let privateKey = null;
|
|
@@ -734,7 +698,7 @@ class DEXBot {
|
|
|
734
698
|
catch (err) {
|
|
735
699
|
if (vaultSecret)
|
|
736
700
|
throw err;
|
|
737
|
-
this._warn(`Credential daemon probe failed: ${
|
|
701
|
+
this._warn(`Credential daemon probe failed: ${getErrorMessage(err)}. Falling back to interactive authentication.`);
|
|
738
702
|
}
|
|
739
703
|
if (!privateKey) {
|
|
740
704
|
const unlockSecret = await chainKeys.authenticate();
|
|
@@ -747,7 +711,7 @@ class DEXBot {
|
|
|
747
711
|
if (chainKeys.isMasterPasswordFailure(err)) {
|
|
748
712
|
throw err;
|
|
749
713
|
}
|
|
750
|
-
this._warn(`Auto-selection of preferredAccount failed: ${
|
|
714
|
+
this._warn(`Auto-selection of preferredAccount failed: ${getErrorMessage(err)}`);
|
|
751
715
|
// dexbot.ts has fallback to selectAccount, bot.ts throws
|
|
752
716
|
if (typeof chainOrders.selectAccount === 'function') {
|
|
753
717
|
const accountData = await chainOrders.selectAccount();
|
|
@@ -776,7 +740,7 @@ class DEXBot {
|
|
|
776
740
|
* @returns {Array<Array<Object>>} Grouped order arrays
|
|
777
741
|
*/
|
|
778
742
|
_buildOutsideInPairGroupsForOrders(orders) {
|
|
779
|
-
return
|
|
743
|
+
return cowRuntime.buildOutsideInPairGroupsForOrders(orders);
|
|
780
744
|
}
|
|
781
745
|
/**
|
|
782
746
|
* Build outside-in pair groups for create entry contexts.
|
|
@@ -784,14 +748,14 @@ class DEXBot {
|
|
|
784
748
|
* @returns {Array<Array<Object>>} Grouped entry arrays
|
|
785
749
|
*/
|
|
786
750
|
_buildOutsideInPairGroupsForCreateEntries(createEntries) {
|
|
787
|
-
return
|
|
751
|
+
return cowRuntime.buildOutsideInPairGroupsForCreateEntries(createEntries);
|
|
788
752
|
}
|
|
789
753
|
/**
|
|
790
754
|
* Resolve the centralized fill batch cap.
|
|
791
755
|
* @returns {number} Positive maximum number of fill-driven rotations per broadcast cycle
|
|
792
756
|
*/
|
|
793
757
|
_getMaxFillBatchSize() {
|
|
794
|
-
return Math.max(1, this.config.fillProcessing?.MAX_FILL_BATCH_SIZE ??
|
|
758
|
+
return Math.max(1, this.config.fillProcessing?.MAX_FILL_BATCH_SIZE ?? FILL_PROCESSING.MAX_FILL_BATCH_SIZE);
|
|
795
759
|
}
|
|
796
760
|
/**
|
|
797
761
|
* Extract operation results from a batch transaction result.
|
|
@@ -800,7 +764,7 @@ class DEXBot {
|
|
|
800
764
|
* @returns {Array} Array of operation result entries
|
|
801
765
|
*/
|
|
802
766
|
_extractOperationResults(result, warnContext = '') {
|
|
803
|
-
return
|
|
767
|
+
return cowRuntime.extractOperationResults(result, warnContext, this.manager?.logger?.log?.bind(this.manager?.logger));
|
|
804
768
|
}
|
|
805
769
|
/**
|
|
806
770
|
* Find CREATE operation contexts whose broadcast result did not include a chain order id.
|
|
@@ -810,7 +774,7 @@ class DEXBot {
|
|
|
810
774
|
* @returns {Array<{index:number, ctx:Object}>} Missing create result contexts.
|
|
811
775
|
*/
|
|
812
776
|
_findMissingCreateResultContexts(operationResults, opContexts) {
|
|
813
|
-
return
|
|
777
|
+
return cowRuntime.findMissingCreateResultContexts(operationResults, opContexts);
|
|
814
778
|
}
|
|
815
779
|
/**
|
|
816
780
|
* Run an immediate chain sync after a successful CREATE broadcast returned incomplete ids.
|
|
@@ -824,7 +788,7 @@ class DEXBot {
|
|
|
824
788
|
* @returns {Promise<void>}
|
|
825
789
|
*/
|
|
826
790
|
async _recoverAfterMissingCreateResults(reason = 'missing create operation results') {
|
|
827
|
-
return
|
|
791
|
+
return cowRuntime.recoverAfterMissingCreateResults(this, reason);
|
|
828
792
|
}
|
|
829
793
|
/**
|
|
830
794
|
* Restore unresolved missing-create blockers after recovery if sync did not adopt them.
|
|
@@ -834,7 +798,7 @@ class DEXBot {
|
|
|
834
798
|
* @returns {void}
|
|
835
799
|
*/
|
|
836
800
|
_preserveMissingCreateBlockersAfterRecovery(blockers, recoveryResult) {
|
|
837
|
-
return
|
|
801
|
+
return cowRuntime.preserveMissingCreateBlockersAfterRecovery(this, blockers, recoveryResult);
|
|
838
802
|
}
|
|
839
803
|
/**
|
|
840
804
|
* Merge missing CREATE result contexts into manager._lastUnmatchedChainOrders.
|
|
@@ -848,7 +812,7 @@ class DEXBot {
|
|
|
848
812
|
* @returns {void}
|
|
849
813
|
*/
|
|
850
814
|
_markMissingCreateResultsAsStructuralBlocker(missingCreateResults) {
|
|
851
|
-
return
|
|
815
|
+
return cowRuntime.markMissingCreateResultsAsStructuralBlocker(this, missingCreateResults);
|
|
852
816
|
}
|
|
853
817
|
/**
|
|
854
818
|
* Format an unmatched chain order/blocker for COW logs.
|
|
@@ -857,7 +821,7 @@ class DEXBot {
|
|
|
857
821
|
* @returns {string} Compact human-readable diagnostic.
|
|
858
822
|
*/
|
|
859
823
|
_formatUnmatchedChainOrderForLog(order) {
|
|
860
|
-
return
|
|
824
|
+
return cowRuntime.formatUnmatchedChainOrderForLog(order);
|
|
861
825
|
}
|
|
862
826
|
/**
|
|
863
827
|
* Record a pending CREATE broadcast on the manager.
|
|
@@ -880,7 +844,7 @@ class DEXBot {
|
|
|
880
844
|
* @returns {void}
|
|
881
845
|
*/
|
|
882
846
|
_recordPendingBroadcast(entry) {
|
|
883
|
-
return
|
|
847
|
+
return cowRuntime.recordPendingBroadcast(this, entry);
|
|
884
848
|
}
|
|
885
849
|
/**
|
|
886
850
|
* Clear the pending-broadcast cache.
|
|
@@ -891,7 +855,7 @@ class DEXBot {
|
|
|
891
855
|
* _reconcileAfterUncertainBroadcast before calling this).
|
|
892
856
|
*/
|
|
893
857
|
_clearPendingBroadcasts() {
|
|
894
|
-
return
|
|
858
|
+
return cowRuntime.clearPendingBroadcasts(this.manager?._pendingBroadcasts);
|
|
895
859
|
}
|
|
896
860
|
/**
|
|
897
861
|
* Build a fingerprint for an on-chain order so it can be matched against
|
|
@@ -902,7 +866,7 @@ class DEXBot {
|
|
|
902
866
|
* @returns {string|null} Fingerprint or null on bad input
|
|
903
867
|
*/
|
|
904
868
|
_buildChainOrderFingerprint(chainOrder, slotId) {
|
|
905
|
-
return
|
|
869
|
+
return cowRuntime.buildChainOrderFingerprint(this, chainOrder, slotId);
|
|
906
870
|
}
|
|
907
871
|
/**
|
|
908
872
|
* Normalize raw BitShares limit_order_object data into the integer tuple
|
|
@@ -916,7 +880,7 @@ class DEXBot {
|
|
|
916
880
|
* @returns {{side: string, assetA: string, assetB: string, sellInt: number, receiveInt: number}|null}
|
|
917
881
|
*/
|
|
918
882
|
_normalizeChainOrderForPendingMatch(chainOrder) {
|
|
919
|
-
return
|
|
883
|
+
return cowRuntime.normalizeChainOrderForPendingMatch(this, chainOrder);
|
|
920
884
|
}
|
|
921
885
|
/**
|
|
922
886
|
* Find a chain order that matches a planned slot using price+size proximity.
|
|
@@ -934,7 +898,7 @@ class DEXBot {
|
|
|
934
898
|
* @returns {Object|null} Matching chain order, or null
|
|
935
899
|
*/
|
|
936
900
|
_findChainOrderForSlot(chainOrders, slotId, planned) {
|
|
937
|
-
return
|
|
901
|
+
return cowRuntime.findChainOrderForSlot(this, chainOrders, slotId, planned);
|
|
938
902
|
}
|
|
939
903
|
/**
|
|
940
904
|
* Reconcile a broadcast whose chain state is unknown.
|
|
@@ -963,10 +927,10 @@ class DEXBot {
|
|
|
963
927
|
* @returns {Promise<Object>} Result object compatible with batch return shape
|
|
964
928
|
*/
|
|
965
929
|
async _reconcileAfterUncertainBroadcast(err, opContexts, options = {}) {
|
|
966
|
-
return
|
|
930
|
+
return cowRuntime.reconcileAfterUncertainBroadcast(this, err, opContexts, options);
|
|
967
931
|
}
|
|
968
932
|
async _reconcileAfterUncertainBroadcastImpl(err, opContexts, options) {
|
|
969
|
-
return
|
|
933
|
+
return cowRuntime.reconcileAfterUncertainBroadcastImpl(this, err, opContexts, options);
|
|
970
934
|
}
|
|
971
935
|
/**
|
|
972
936
|
* Auto-cancel a price-drift orphan from the unmatched-order snapshot.
|
|
@@ -994,7 +958,7 @@ class DEXBot {
|
|
|
994
958
|
* @returns {Promise<{cancelled: boolean, orderId?: string, reason?: string}>}
|
|
995
959
|
*/
|
|
996
960
|
async _autoCancelOneUnmatchedOrphan() {
|
|
997
|
-
return
|
|
961
|
+
return cowRuntime.autoCancelOneUnmatchedOrphan(this);
|
|
998
962
|
}
|
|
999
963
|
// Pair mode applies only when create contexts include both BUY and SELL.
|
|
1000
964
|
// Single-side create batches intentionally remain a single executeBatch.
|
|
@@ -1004,7 +968,7 @@ class DEXBot {
|
|
|
1004
968
|
* @returns {boolean} True if pair mode should be used
|
|
1005
969
|
*/
|
|
1006
970
|
_shouldExecuteCreatePairMode(opContexts) {
|
|
1007
|
-
return
|
|
971
|
+
return cowRuntime.shouldExecuteCreatePairMode(this, opContexts);
|
|
1008
972
|
}
|
|
1009
973
|
/**
|
|
1010
974
|
* Execute operations with retry on BroadcastUncertainError.
|
|
@@ -1020,16 +984,16 @@ class DEXBot {
|
|
|
1020
984
|
* the full operations array would duplicate those creates on chain.
|
|
1021
985
|
*/
|
|
1022
986
|
async _executeWithRetryOnUncertain(operations, opContexts) {
|
|
1023
|
-
return
|
|
987
|
+
return cowRuntime.executeWithRetryOnUncertain(this, operations, opContexts);
|
|
1024
988
|
}
|
|
1025
989
|
/**
|
|
1026
990
|
* Execute blockchain operations with appropriate strategy (single batch or pair mode).
|
|
1027
|
-
* @param {Array<import('./types').CreatedOperation>} operations - Array of operation objects
|
|
991
|
+
* @param {Array<import('./types.js').CreatedOperation>} operations - Array of operation objects
|
|
1028
992
|
* @param {Array<Object>} opContexts - Array of operation context metadata (1:1 with operations)
|
|
1029
993
|
* @returns {Promise<{result: Object, opContexts: Array}>} Execution result with contexts
|
|
1030
994
|
*/
|
|
1031
995
|
async _executeOperationsWithStrategy(operations, opContexts) {
|
|
1032
|
-
return
|
|
996
|
+
return cowRuntime.executeOperationsWithStrategy(this, operations, opContexts);
|
|
1033
997
|
}
|
|
1034
998
|
/**
|
|
1035
999
|
* Validate that operations can be executed with available funds before broadcasting.
|
|
@@ -1041,7 +1005,7 @@ class DEXBot {
|
|
|
1041
1005
|
* @private
|
|
1042
1006
|
*/
|
|
1043
1007
|
_validateOperationFunds(operations, assetA, assetB) {
|
|
1044
|
-
return
|
|
1008
|
+
return cowRuntime.validateOperationFunds(this, operations, assetA, assetB);
|
|
1045
1009
|
}
|
|
1046
1010
|
/**
|
|
1047
1011
|
* Resolve the ideal size from an order-like object with fallback.
|
|
@@ -1050,7 +1014,7 @@ class DEXBot {
|
|
|
1050
1014
|
* @returns {number|null} Resolved size or null
|
|
1051
1015
|
*/
|
|
1052
1016
|
_resolveIdealSizeForValidation(orderLike, fallbackSize = null) {
|
|
1053
|
-
return
|
|
1017
|
+
return cowRuntime.resolveIdealSizeForValidation(this, orderLike, fallbackSize);
|
|
1054
1018
|
}
|
|
1055
1019
|
/**
|
|
1056
1020
|
* Validate that an order size is safe to execute (above minimum dust thresholds).
|
|
@@ -1058,10 +1022,10 @@ class DEXBot {
|
|
|
1058
1022
|
* @param {string} type - ORDER_TYPES.BUY or ORDER_TYPES.SELL
|
|
1059
1023
|
* @param {Object|null} [orderLike=null] - Optional order-like object for ideal size comparison
|
|
1060
1024
|
* @param {number|null} [fallbackSize=null] - Fallback ideal size
|
|
1061
|
-
* @returns {import('./types').OrderValidationResult}
|
|
1025
|
+
* @returns {import('./types.js').OrderValidationResult}
|
|
1062
1026
|
*/
|
|
1063
1027
|
_validateOrderSizeForExecution(size, type, orderLike = null, fallbackSize = null) {
|
|
1064
|
-
return
|
|
1028
|
+
return cowRuntime.validateOrderSizeForExecution(this, size, type, orderLike, fallbackSize);
|
|
1065
1029
|
}
|
|
1066
1030
|
/**
|
|
1067
1031
|
* Execute a batch of order operations if the rebalance result has executable actions.
|
|
@@ -1082,7 +1046,7 @@ class DEXBot {
|
|
|
1082
1046
|
// outputs, updateOrdersOnChainPlan cowResults, reconcileGridOrders
|
|
1083
1047
|
// null results) must NOT pop the stack — an unmatched pop could steal
|
|
1084
1048
|
// a nested grid's entry.
|
|
1085
|
-
|
|
1049
|
+
cowRuntime.popPushedWorkingGrid(this, rebalanceResult);
|
|
1086
1050
|
// Persist master grid mutations that may have occurred outside COW
|
|
1087
1051
|
// broadcast (e.g., partial-fill size updates applied directly by the
|
|
1088
1052
|
// sync engine). Without this, a partial fill that does not trigger a
|
|
@@ -1232,17 +1196,17 @@ class DEXBot {
|
|
|
1232
1196
|
}
|
|
1233
1197
|
try {
|
|
1234
1198
|
if (this.privateKey && getKeyStore().isDaemonSigningKey(this.privateKey)) {
|
|
1235
|
-
await chainKeys.pingDaemon(this.privateKey.accountName, Math.min(
|
|
1199
|
+
await chainKeys.pingDaemon(this.privateKey.accountName, Math.min(TIMING.DAEMON_PING_TIMEOUT_MS, TIMING.DAEMON_STARTUP_TIMEOUT_MS), { socketPath: this.privateKey.socketPath });
|
|
1236
1200
|
}
|
|
1237
1201
|
}
|
|
1238
1202
|
catch (err) {
|
|
1239
|
-
const message = `Credential daemon unavailable before ${contextLabel}: ${
|
|
1203
|
+
const message = `Credential daemon unavailable before ${contextLabel}: ${getErrorMessage(err)}`;
|
|
1240
1204
|
this._credentialDaemonDown = true;
|
|
1241
1205
|
this._credentialRecoveryNeeded = true;
|
|
1242
1206
|
this._suspendGridPersistenceForCredentialOutage(message);
|
|
1243
1207
|
this.manager?.logger?.log?.(`[CREDENTIAL] ${message}. Write operations paused; re-unlock with dexbot pm2.`, 'error');
|
|
1244
1208
|
const wrapped = new Error(message);
|
|
1245
|
-
wrapped.code =
|
|
1209
|
+
wrapped.code = DAEMON_CODES.CREDENTIAL_DAEMON_UNAVAILABLE;
|
|
1246
1210
|
wrapped.cause = err;
|
|
1247
1211
|
throw wrapped;
|
|
1248
1212
|
}
|
|
@@ -1255,9 +1219,9 @@ class DEXBot {
|
|
|
1255
1219
|
_isCredentialDaemonError(err) {
|
|
1256
1220
|
if (!err)
|
|
1257
1221
|
return false;
|
|
1258
|
-
if (err.code ===
|
|
1222
|
+
if (err.code === DAEMON_CODES.CREDENTIAL_DAEMON_UNAVAILABLE)
|
|
1259
1223
|
return true;
|
|
1260
|
-
const message = String(
|
|
1224
|
+
const message = String(getErrorMessage(err) || '');
|
|
1261
1225
|
return /Credential daemon|Daemon connection failed|daemon .*unavailable|dexbot-cred-daemon\.sock|ECONNREFUSED|ENOENT/.test(message);
|
|
1262
1226
|
}
|
|
1263
1227
|
/**
|
|
@@ -1274,7 +1238,7 @@ class DEXBot {
|
|
|
1274
1238
|
this._credentialRecoveryDeferredTimer = setTimeout(() => {
|
|
1275
1239
|
this._credentialRecoveryDeferredTimer = null;
|
|
1276
1240
|
this._runCredentialRecoveryAfterDaemonRestored().catch((err) => {
|
|
1277
|
-
this.manager?.logger?.log?.(`[CREDENTIAL] Deferred recovery failed: ${
|
|
1241
|
+
this.manager?.logger?.log?.(`[CREDENTIAL] Deferred recovery failed: ${getErrorMessage(err)}`, 'error');
|
|
1278
1242
|
if (this.manager) {
|
|
1279
1243
|
this.manager._recoveryState = { ...this.manager._recoveryState, lastFailureAt: Date.now() };
|
|
1280
1244
|
}
|
|
@@ -1302,8 +1266,8 @@ class DEXBot {
|
|
|
1302
1266
|
}
|
|
1303
1267
|
catch (err) {
|
|
1304
1268
|
this._credentialRecoveryNeeded = true;
|
|
1305
|
-
this._suspendGridPersistenceForCredentialOutage(`credential recovery failed: ${
|
|
1306
|
-
this.manager?.logger?.log?.(`[CREDENTIAL] Credential recovery sync failed: ${
|
|
1269
|
+
this._suspendGridPersistenceForCredentialOutage(`credential recovery failed: ${getErrorMessage(err)}`);
|
|
1270
|
+
this.manager?.logger?.log?.(`[CREDENTIAL] Credential recovery sync failed: ${getErrorMessage(err)}. Writes remain guarded by preflight.`, 'error');
|
|
1307
1271
|
}
|
|
1308
1272
|
finally {
|
|
1309
1273
|
this._credentialRecoveryInFlight = false;
|
|
@@ -1322,7 +1286,7 @@ class DEXBot {
|
|
|
1322
1286
|
this._credentialDaemonDown = false;
|
|
1323
1287
|
return;
|
|
1324
1288
|
}
|
|
1325
|
-
const intervalMs = Math.max(
|
|
1289
|
+
const intervalMs = Math.max(TIMING.DAEMON_PING_TIMEOUT_MS, TIMING.CREDENTIAL_DAEMON_WATCHDOG_MS);
|
|
1326
1290
|
const probe = async () => {
|
|
1327
1291
|
if (this._shuttingDown || !this._isCredentialDaemonWriteRequired())
|
|
1328
1292
|
return;
|
|
@@ -1346,7 +1310,7 @@ class DEXBot {
|
|
|
1346
1310
|
}
|
|
1347
1311
|
catch (err) {
|
|
1348
1312
|
if (!this._credentialDaemonDown) {
|
|
1349
|
-
const errMsg = String(
|
|
1313
|
+
const errMsg = String(getErrorMessage(err) || '');
|
|
1350
1314
|
let hint = '';
|
|
1351
1315
|
if (errMsg.includes('ENOENT')) {
|
|
1352
1316
|
hint = `Socket file missing at ${token.socketPath}. The credential daemon process may have been killed (e.g. by stray Ctrl-C). Restart it with: dexbot pm2 restart dexbot-cred. If the problem persists, check the daemon log: profiles/logs/dexbot-cred.log`;
|
|
@@ -1360,10 +1324,10 @@ class DEXBot {
|
|
|
1360
1324
|
else {
|
|
1361
1325
|
hint = `Write operations will remain paused until re-unlocked with dexbot pm2.`;
|
|
1362
1326
|
}
|
|
1363
|
-
this.manager?.logger?.log?.(`[CREDENTIAL] Credential daemon watchdog failed: ${
|
|
1327
|
+
this.manager?.logger?.log?.(`[CREDENTIAL] Credential daemon watchdog failed: ${getErrorMessage(err)}. ${hint}`, 'error');
|
|
1364
1328
|
}
|
|
1365
1329
|
this._credentialDaemonDown = true;
|
|
1366
|
-
this._suspendGridPersistenceForCredentialOutage(`credential daemon watchdog failed: ${
|
|
1330
|
+
this._suspendGridPersistenceForCredentialOutage(`credential daemon watchdog failed: ${getErrorMessage(err)}`);
|
|
1367
1331
|
}
|
|
1368
1332
|
}
|
|
1369
1333
|
finally {
|
|
@@ -1372,14 +1336,14 @@ class DEXBot {
|
|
|
1372
1336
|
};
|
|
1373
1337
|
this._credentialDaemonWatchdogInterval = setInterval(() => {
|
|
1374
1338
|
probe().catch((err) => {
|
|
1375
|
-
this.manager?.logger?.log?.(`[CREDENTIAL] Credential daemon watchdog error: ${
|
|
1339
|
+
this.manager?.logger?.log?.(`[CREDENTIAL] Credential daemon watchdog error: ${getErrorMessage(err)}`, 'warn');
|
|
1376
1340
|
});
|
|
1377
1341
|
}, intervalMs);
|
|
1378
1342
|
if (typeof this._credentialDaemonWatchdogInterval.unref === 'function') {
|
|
1379
1343
|
this._credentialDaemonWatchdogInterval.unref();
|
|
1380
1344
|
}
|
|
1381
1345
|
void probe();
|
|
1382
|
-
this._log(`Credential daemon watchdog started (${Math.round(intervalMs /
|
|
1346
|
+
this._log(`Credential daemon watchdog started (${Math.round(intervalMs / TIMING.MILLISECONDS_PER_SECOND)}s interval)`);
|
|
1383
1347
|
}
|
|
1384
1348
|
/**
|
|
1385
1349
|
* Stop the credential daemon watchdog interval.
|
|
@@ -1421,25 +1385,25 @@ class DEXBot {
|
|
|
1421
1385
|
* @returns {Array<{type: string, id: string, order?: Object, orderId?: string, newSize?: number, newPrice?: number, newGridId?: string}>}
|
|
1422
1386
|
*/
|
|
1423
1387
|
_buildActionsFromPlan(plan) {
|
|
1424
|
-
return
|
|
1388
|
+
return cowRuntime.buildActionsFromPlan(this, plan);
|
|
1425
1389
|
}
|
|
1426
1390
|
/**
|
|
1427
1391
|
* Build a COW result object (workingGrid + actions) from a simple plan.
|
|
1428
1392
|
* @param {Object|Array} plan - Plan object or array of ordersToPlace
|
|
1429
|
-
* @returns {{workingGrid: import('./types').WorkingGrid, workingIndexes: Object, workingBoundary: number, actions: Array}}
|
|
1393
|
+
* @returns {{workingGrid: import('./types.js').WorkingGrid, workingIndexes: Object, workingBoundary: number, actions: Array}}
|
|
1430
1394
|
*/
|
|
1431
1395
|
_buildCowResultFromPlan(plan) {
|
|
1432
|
-
return
|
|
1396
|
+
return cowRuntime.buildCowResultFromPlan(this, plan);
|
|
1433
1397
|
}
|
|
1434
1398
|
/**
|
|
1435
1399
|
* Restore skipped update slots in the working grid to master state.
|
|
1436
|
-
* @param {import('./types').WorkingGrid} workingGrid - Working grid to restore slots into
|
|
1400
|
+
* @param {import('./types.js').WorkingGrid} workingGrid - Working grid to restore slots into
|
|
1437
1401
|
* @param {Set<string>} skippedSlotIds - Set of slot IDs that were skipped
|
|
1438
1402
|
* @param {number} [skippedCount=0] - Count of skipped actions for logging
|
|
1439
1403
|
* @returns {void}
|
|
1440
1404
|
*/
|
|
1441
1405
|
_restoreSkippedUpdateSlotsInWorkingGrid(workingGrid, skippedSlotIds, skippedCount = 0) {
|
|
1442
|
-
return
|
|
1406
|
+
return cowRuntime.restoreSkippedUpdateSlotsInWorkingGrid(this, workingGrid, skippedSlotIds, skippedCount);
|
|
1443
1407
|
}
|
|
1444
1408
|
/**
|
|
1445
1409
|
* COW broadcast: Execute blockchain operations and commit working grid on success.
|
|
@@ -1449,10 +1413,10 @@ class DEXBot {
|
|
|
1449
1413
|
* @private
|
|
1450
1414
|
*/
|
|
1451
1415
|
async _updateOrdersOnChainBatchCOW(cowResult, options = {}) {
|
|
1452
|
-
return
|
|
1416
|
+
return cowRuntime.updateOrdersOnChainBatchCOW(this, cowResult, options);
|
|
1453
1417
|
}
|
|
1454
1418
|
async _processBatchResults(result, opContexts) {
|
|
1455
|
-
return
|
|
1419
|
+
return cowRuntime.processBatchResults(this, result, opContexts);
|
|
1456
1420
|
}
|
|
1457
1421
|
/**
|
|
1458
1422
|
* Perform grid recalculation triggered by trigger file.
|
|
@@ -1463,7 +1427,7 @@ class DEXBot {
|
|
|
1463
1427
|
* @private
|
|
1464
1428
|
*/
|
|
1465
1429
|
async _performGridResync(options = {}) {
|
|
1466
|
-
return
|
|
1430
|
+
return DexbotMaintenanceRuntime.performGridResync(this, options);
|
|
1467
1431
|
}
|
|
1468
1432
|
/**
|
|
1469
1433
|
* Handle any pending trigger file reset at startup.
|
|
@@ -1472,7 +1436,7 @@ class DEXBot {
|
|
|
1472
1436
|
* @private
|
|
1473
1437
|
*/
|
|
1474
1438
|
async _handlePendingTriggerReset() {
|
|
1475
|
-
return
|
|
1439
|
+
return DexbotMaintenanceRuntime.handlePendingTriggerReset(this);
|
|
1476
1440
|
}
|
|
1477
1441
|
/**
|
|
1478
1442
|
* Setup trigger file detection for grid reset.
|
|
@@ -1480,7 +1444,7 @@ class DEXBot {
|
|
|
1480
1444
|
* @private
|
|
1481
1445
|
*/
|
|
1482
1446
|
async _setupTriggerFileDetection() {
|
|
1483
|
-
return
|
|
1447
|
+
return DexbotMaintenanceRuntime.setupTriggerFileDetection(this);
|
|
1484
1448
|
}
|
|
1485
1449
|
/**
|
|
1486
1450
|
* Starts the bot's operation.
|
|
@@ -1499,14 +1463,14 @@ class DEXBot {
|
|
|
1499
1463
|
*/
|
|
1500
1464
|
async startWithPrivateKey(privateKey) {
|
|
1501
1465
|
// Initialize account data with provided private key
|
|
1502
|
-
await waitForConnected(
|
|
1466
|
+
await waitForConnected(TIMING.CONNECTION_TIMEOUT_MS);
|
|
1503
1467
|
if (this.config && this.config.preferredAccount) {
|
|
1504
1468
|
try {
|
|
1505
1469
|
this.privateKey = privateKey;
|
|
1506
1470
|
await this._setupAccountContext(this.config.preferredAccount);
|
|
1507
1471
|
}
|
|
1508
1472
|
catch (err) {
|
|
1509
|
-
this._warn(`Auto-selection of preferredAccount failed: ${
|
|
1473
|
+
this._warn(`Auto-selection of preferredAccount failed: ${getErrorMessage(err)}`);
|
|
1510
1474
|
throw err;
|
|
1511
1475
|
}
|
|
1512
1476
|
}
|
|
@@ -1529,7 +1493,7 @@ class DEXBot {
|
|
|
1529
1493
|
await this._finishStartupSequence(startupState);
|
|
1530
1494
|
}
|
|
1531
1495
|
catch (err) {
|
|
1532
|
-
this._warn(`Error during grid initialization: ${
|
|
1496
|
+
this._warn(`Error during grid initialization: ${getErrorMessage(err)}`);
|
|
1533
1497
|
await this.shutdown();
|
|
1534
1498
|
throw err;
|
|
1535
1499
|
}
|
|
@@ -1552,10 +1516,10 @@ class DEXBot {
|
|
|
1552
1516
|
* @private
|
|
1553
1517
|
*/
|
|
1554
1518
|
async _performPeriodicGridChecks() {
|
|
1555
|
-
return
|
|
1519
|
+
return DexbotMaintenanceRuntime.performPeriodicGridChecks(this);
|
|
1556
1520
|
}
|
|
1557
1521
|
_isOpenOrdersSyncLoopEnabled() {
|
|
1558
|
-
return
|
|
1522
|
+
return DexbotMaintenanceRuntime.isOpenOrdersSyncLoopEnabled(this);
|
|
1559
1523
|
}
|
|
1560
1524
|
/**
|
|
1561
1525
|
* Start the open-orders watchdog sync loop.
|
|
@@ -1563,14 +1527,14 @@ class DEXBot {
|
|
|
1563
1527
|
* @private
|
|
1564
1528
|
*/
|
|
1565
1529
|
_startOpenOrdersSyncLoop() {
|
|
1566
|
-
return
|
|
1530
|
+
return DexbotMaintenanceRuntime.startOpenOrdersSyncLoop(this);
|
|
1567
1531
|
}
|
|
1568
1532
|
/**
|
|
1569
1533
|
* Stop the open-orders watchdog sync loop.
|
|
1570
1534
|
* @private
|
|
1571
1535
|
*/
|
|
1572
1536
|
async _stopOpenOrdersSyncLoop() {
|
|
1573
|
-
return
|
|
1537
|
+
return DexbotMaintenanceRuntime.stopOpenOrdersSyncLoop(this);
|
|
1574
1538
|
}
|
|
1575
1539
|
/**
|
|
1576
1540
|
* Set up periodic blockchain account balance fetch interval.
|
|
@@ -1578,21 +1542,21 @@ class DEXBot {
|
|
|
1578
1542
|
* @private
|
|
1579
1543
|
*/
|
|
1580
1544
|
_setupBlockchainFetchInterval() {
|
|
1581
|
-
return
|
|
1545
|
+
return DexbotMaintenanceRuntime.setupBlockchainFetchInterval(this);
|
|
1582
1546
|
}
|
|
1583
1547
|
/**
|
|
1584
1548
|
* Stop the periodic blockchain fetch interval.
|
|
1585
1549
|
* @private
|
|
1586
1550
|
*/
|
|
1587
1551
|
_stopBlockchainFetchInterval() {
|
|
1588
|
-
return
|
|
1552
|
+
return DexbotMaintenanceRuntime.stopBlockchainFetchInterval(this);
|
|
1589
1553
|
}
|
|
1590
1554
|
async _releaseMarketAdapterRuntime(context = 'shutdown') {
|
|
1591
|
-
return
|
|
1555
|
+
return DexbotMaintenanceRuntime.releaseMarketAdapterRuntime(this, this.config?.botKey || this.config?.name, context);
|
|
1592
1556
|
}
|
|
1593
1557
|
/**
|
|
1594
1558
|
* Get or create the credit runtime for debt policy management.
|
|
1595
|
-
* @returns {import('./credit_runtime').CreditRuntime|null}
|
|
1559
|
+
* @returns {import('./credit_runtime.js').CreditRuntime|null}
|
|
1596
1560
|
*/
|
|
1597
1561
|
_getCreditRuntime() {
|
|
1598
1562
|
const lending = this.config?.debtPolicy?.lending;
|
|
@@ -1604,15 +1568,15 @@ class DEXBot {
|
|
|
1604
1568
|
return null;
|
|
1605
1569
|
}
|
|
1606
1570
|
if (!this._creditRuntime) {
|
|
1607
|
-
this._creditRuntime = new
|
|
1608
|
-
stateDir:
|
|
1571
|
+
this._creditRuntime = new CreditRuntime(this, {
|
|
1572
|
+
stateDir: PATHS.CREDIT_RUNTIME_DIR,
|
|
1609
1573
|
});
|
|
1610
1574
|
}
|
|
1611
1575
|
return this._creditRuntime;
|
|
1612
1576
|
}
|
|
1613
1577
|
/**
|
|
1614
1578
|
* Set up the credit runtime by loading its persisted state.
|
|
1615
|
-
* @returns {Promise<import('./credit_runtime').CreditRuntime|null>}
|
|
1579
|
+
* @returns {Promise<import('./credit_runtime.js').CreditRuntime|null>}
|
|
1616
1580
|
*/
|
|
1617
1581
|
async _setupCreditRuntime() {
|
|
1618
1582
|
const runtime = this._getCreditRuntime();
|
|
@@ -1634,7 +1598,7 @@ class DEXBot {
|
|
|
1634
1598
|
await runtime.refreshState();
|
|
1635
1599
|
}
|
|
1636
1600
|
catch (err) {
|
|
1637
|
-
this._warn(`Credit runtime refresh/sync failed: ${
|
|
1601
|
+
this._warn(`Credit runtime refresh/sync failed: ${getErrorMessage(err)}`);
|
|
1638
1602
|
}
|
|
1639
1603
|
}
|
|
1640
1604
|
/**
|
|
@@ -1659,7 +1623,7 @@ class DEXBot {
|
|
|
1659
1623
|
if (!runtime) {
|
|
1660
1624
|
return;
|
|
1661
1625
|
}
|
|
1662
|
-
const intervalMin = Number(this.config?.TIMING?.CREDIT_DEAL_CHECK_INTERVAL_MIN ??
|
|
1626
|
+
const intervalMin = Number(this.config?.TIMING?.CREDIT_DEAL_CHECK_INTERVAL_MIN ?? TIMING.CREDIT_DEAL_CHECK_INTERVAL_MIN);
|
|
1663
1627
|
if (!Number.isFinite(intervalMin) || intervalMin <= 0) {
|
|
1664
1628
|
this._log('Credit deal watchdog disabled by configuration (TIMING.CREDIT_DEAL_CHECK_INTERVAL_MIN <= 0)');
|
|
1665
1629
|
return;
|
|
@@ -1668,13 +1632,13 @@ class DEXBot {
|
|
|
1668
1632
|
clearInterval(this._creditWatchdogInterval);
|
|
1669
1633
|
this._creditWatchdogInterval = null;
|
|
1670
1634
|
}
|
|
1671
|
-
const intervalMs = intervalMin * 60 *
|
|
1635
|
+
const intervalMs = intervalMin * 60 * TIMING.MILLISECONDS_PER_SECOND;
|
|
1672
1636
|
this._creditWatchdogInterval = setInterval(async () => {
|
|
1673
1637
|
try {
|
|
1674
1638
|
await runtime.runCreditWatchdog();
|
|
1675
1639
|
}
|
|
1676
1640
|
catch (err) {
|
|
1677
|
-
this._warn(`Credit watchdog error: ${
|
|
1641
|
+
this._warn(`Credit watchdog error: ${getErrorMessage(err)}`);
|
|
1678
1642
|
}
|
|
1679
1643
|
}, intervalMs);
|
|
1680
1644
|
if (typeof this._creditWatchdogInterval?.unref === 'function') {
|
|
@@ -1693,17 +1657,17 @@ class DEXBot {
|
|
|
1693
1657
|
}
|
|
1694
1658
|
}
|
|
1695
1659
|
async requestGridReset(reason = 'structural change', options = {}) {
|
|
1696
|
-
return
|
|
1660
|
+
return DexbotMaintenanceRuntime.requestGridReset(this, reason, options);
|
|
1697
1661
|
}
|
|
1698
1662
|
_wireStructuralGridResyncRequest() {
|
|
1699
|
-
return
|
|
1663
|
+
return DexbotMaintenanceRuntime.wireStructuralGridResyncRequest(this);
|
|
1700
1664
|
}
|
|
1701
1665
|
/**
|
|
1702
1666
|
* Get current metrics for monitoring and debugging.
|
|
1703
1667
|
* @returns {Object} Metrics snapshot
|
|
1704
1668
|
*/
|
|
1705
1669
|
getMetrics() {
|
|
1706
|
-
return
|
|
1670
|
+
return DexbotMaintenanceRuntime.getMetrics(this);
|
|
1707
1671
|
}
|
|
1708
1672
|
/**
|
|
1709
1673
|
* Execute grid maintenance checks in strict order with pipeline consensus.
|
|
@@ -1737,7 +1701,7 @@ class DEXBot {
|
|
|
1737
1701
|
* @private
|
|
1738
1702
|
*/
|
|
1739
1703
|
async _executeMaintenanceLogic(context) {
|
|
1740
|
-
return
|
|
1704
|
+
return DexbotMaintenanceRuntime.executeMaintenanceLogic(this, context);
|
|
1741
1705
|
}
|
|
1742
1706
|
/**
|
|
1743
1707
|
* Cancel dust partial orders immediately — no maps, no timers, no delay.
|
|
@@ -1748,7 +1712,7 @@ class DEXBot {
|
|
|
1748
1712
|
* @private
|
|
1749
1713
|
*/
|
|
1750
1714
|
async _cancelDustOrders({ buy: buyDust = [], sell: sellDust = [] } = {}) {
|
|
1751
|
-
return
|
|
1715
|
+
return DexbotMaintenanceRuntime.cancelDustOrders(this, { buy: buyDust, sell: sellDust });
|
|
1752
1716
|
}
|
|
1753
1717
|
/**
|
|
1754
1718
|
* Run a single dust health check cycle: inspect grid for partials below the
|
|
@@ -1758,7 +1722,7 @@ class DEXBot {
|
|
|
1758
1722
|
* @private
|
|
1759
1723
|
*/
|
|
1760
1724
|
async _runDustHealthCheck() {
|
|
1761
|
-
return
|
|
1725
|
+
return DexbotMaintenanceRuntime.runDustHealthCheck(this);
|
|
1762
1726
|
}
|
|
1763
1727
|
/**
|
|
1764
1728
|
* Set up the periodic dust health check interval.
|
|
@@ -1768,7 +1732,7 @@ class DEXBot {
|
|
|
1768
1732
|
* @private
|
|
1769
1733
|
*/
|
|
1770
1734
|
_setupDustHealthCheckInterval() {
|
|
1771
|
-
return
|
|
1735
|
+
return DexbotMaintenanceRuntime.setupDustHealthCheckInterval(this);
|
|
1772
1736
|
}
|
|
1773
1737
|
/**
|
|
1774
1738
|
* Perform grid maintenance: fund thresholds, spread condition, grid health, divergence.
|
|
@@ -1795,7 +1759,7 @@ class DEXBot {
|
|
|
1795
1759
|
* @private
|
|
1796
1760
|
*/
|
|
1797
1761
|
async _runGridMaintenance(context = 'periodic', options = {}) {
|
|
1798
|
-
return
|
|
1762
|
+
return DexbotMaintenanceRuntime.runGridMaintenance(this, context, options);
|
|
1799
1763
|
}
|
|
1800
1764
|
/**
|
|
1801
1765
|
* Gracefully shutdown the bot.
|
|
@@ -1852,7 +1816,7 @@ class DEXBot {
|
|
|
1852
1816
|
await this._creditRuntime.shutdown();
|
|
1853
1817
|
}
|
|
1854
1818
|
catch (err) {
|
|
1855
|
-
this._warn(`Failed to persist credit runtime state: ${
|
|
1819
|
+
this._warn(`Failed to persist credit runtime state: ${getErrorMessage(err)}`);
|
|
1856
1820
|
}
|
|
1857
1821
|
}
|
|
1858
1822
|
if (this._triggerWatcher && typeof this._triggerWatcher.close === 'function') {
|
|
@@ -1860,7 +1824,7 @@ class DEXBot {
|
|
|
1860
1824
|
this._triggerWatcher.close();
|
|
1861
1825
|
}
|
|
1862
1826
|
catch (err) {
|
|
1863
|
-
this._warn(`Failed to close trigger watcher: ${
|
|
1827
|
+
this._warn(`Failed to close trigger watcher: ${getErrorMessage(err)}`);
|
|
1864
1828
|
}
|
|
1865
1829
|
finally {
|
|
1866
1830
|
this._triggerWatcher = null;
|
|
@@ -1871,7 +1835,7 @@ class DEXBot {
|
|
|
1871
1835
|
await this._fillsUnsubscribe();
|
|
1872
1836
|
}
|
|
1873
1837
|
catch (err) {
|
|
1874
|
-
this._warn(`Failed to unsubscribe fill listener: ${
|
|
1838
|
+
this._warn(`Failed to unsubscribe fill listener: ${getErrorMessage(err)}`);
|
|
1875
1839
|
}
|
|
1876
1840
|
finally {
|
|
1877
1841
|
this._fillsUnsubscribe = null;
|
|
@@ -1882,7 +1846,7 @@ class DEXBot {
|
|
|
1882
1846
|
this._reconnectUnregister();
|
|
1883
1847
|
}
|
|
1884
1848
|
catch (err) {
|
|
1885
|
-
this._warn(`Error unregistering reconnect callback: ${
|
|
1849
|
+
this._warn(`Error unregistering reconnect callback: ${getErrorMessage(err)}`);
|
|
1886
1850
|
}
|
|
1887
1851
|
this._reconnectUnregister = null;
|
|
1888
1852
|
}
|
|
@@ -1890,13 +1854,13 @@ class DEXBot {
|
|
|
1890
1854
|
await this._stopOpenOrdersSyncLoop();
|
|
1891
1855
|
}
|
|
1892
1856
|
catch (err) {
|
|
1893
|
-
this._warn(`Error while stopping open-orders sync loop: ${
|
|
1857
|
+
this._warn(`Error while stopping open-orders sync loop: ${getErrorMessage(err)}`);
|
|
1894
1858
|
}
|
|
1895
1859
|
try {
|
|
1896
1860
|
await this._releaseMarketAdapterRuntime('shutdown');
|
|
1897
1861
|
}
|
|
1898
1862
|
catch (err) {
|
|
1899
|
-
this._warn(`Error while releasing market adapter runtime: ${
|
|
1863
|
+
this._warn(`Error while releasing market adapter runtime: ${getErrorMessage(err)}`);
|
|
1900
1864
|
}
|
|
1901
1865
|
// Wait for current fill processing to complete
|
|
1902
1866
|
try {
|
|
@@ -1934,7 +1898,7 @@ class DEXBot {
|
|
|
1934
1898
|
this._log('Final grid snapshot persisted');
|
|
1935
1899
|
}
|
|
1936
1900
|
catch (err) {
|
|
1937
|
-
this._warn(`Failed to persist final state: ${
|
|
1901
|
+
this._warn(`Failed to persist final state: ${getErrorMessage(err)}`);
|
|
1938
1902
|
}
|
|
1939
1903
|
}
|
|
1940
1904
|
}).then(() => 'acquired'),
|
|
@@ -1973,12 +1937,12 @@ class DEXBot {
|
|
|
1973
1937
|
this._log('Final grid snapshot persisted (best-effort, lock not held)');
|
|
1974
1938
|
}
|
|
1975
1939
|
catch (err) {
|
|
1976
|
-
this._warn(`Failed to persist final state (best-effort): ${
|
|
1940
|
+
this._warn(`Failed to persist final state (best-effort): ${getErrorMessage(err)}`);
|
|
1977
1941
|
}
|
|
1978
1942
|
}
|
|
1979
1943
|
}
|
|
1980
1944
|
catch (err) {
|
|
1981
|
-
this._warn(`Best-effort flush during shutdown failed: ${
|
|
1945
|
+
this._warn(`Best-effort flush during shutdown failed: ${getErrorMessage(err)}`);
|
|
1982
1946
|
}
|
|
1983
1947
|
}
|
|
1984
1948
|
// Always reset the fill-consumer watchdog on shutdown completion,
|
|
@@ -1988,14 +1952,14 @@ class DEXBot {
|
|
|
1988
1952
|
}
|
|
1989
1953
|
}
|
|
1990
1954
|
catch (err) {
|
|
1991
|
-
this._warn(`Error during shutdown lock acquisition: ${
|
|
1955
|
+
this._warn(`Error during shutdown lock acquisition: ${getErrorMessage(err)}`);
|
|
1992
1956
|
}
|
|
1993
1957
|
// Release fund registry allocation
|
|
1994
1958
|
if (this.config?.preferredAccount) {
|
|
1995
1959
|
const botName = this.config.botKey;
|
|
1996
1960
|
if (botName) {
|
|
1997
1961
|
fundRegistry.releaseAllocation(this.config.preferredAccount, botName).catch((err) => {
|
|
1998
|
-
this._warn(`Failed to release fund allocation for ${botName}: ${
|
|
1962
|
+
this._warn(`Failed to release fund allocation for ${botName}: ${getErrorMessage(err)}`);
|
|
1999
1963
|
});
|
|
2000
1964
|
}
|
|
2001
1965
|
}
|
|
@@ -2012,7 +1976,6 @@ class DEXBot {
|
|
|
2012
1976
|
await this.manager?.logger?.flush();
|
|
2013
1977
|
}
|
|
2014
1978
|
}
|
|
2015
|
-
DEXBot.normalizeBotEntry =
|
|
2016
|
-
|
|
2017
|
-
module.exports = DEXBot;
|
|
1979
|
+
DEXBot.normalizeBotEntry = normalizeBotEntry;
|
|
1980
|
+
export default DEXBot;
|
|
2018
1981
|
//# sourceMappingURL=dexbot_class.js.map
|