dexbot 1.3.2 → 1.4.0
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/dist/analysis/chart_utils.d.ts +11 -9
- package/dist/analysis/chart_utils.d.ts.map +1 -1
- package/dist/analysis/chart_utils.js +21 -16
- package/dist/analysis/chart_utils.js.map +1 -1
- package/dist/analysis/math_utils.d.ts +4 -13
- package/dist/analysis/math_utils.d.ts.map +1 -1
- package/dist/analysis/math_utils.js +16 -18
- package/dist/analysis/math_utils.js.map +1 -1
- package/dist/analysis/tradingview/tradingview_uplot_chart_generator.d.ts +3 -7
- package/dist/analysis/tradingview/tradingview_uplot_chart_generator.d.ts.map +1 -1
- package/dist/analysis/tradingview/tradingview_uplot_chart_generator.js +38 -34
- package/dist/analysis/tradingview/tradingview_uplot_chart_generator.js.map +1 -1
- package/dist/analysis/trend_detection/hurst_analyzer.d.ts +1 -4
- package/dist/analysis/trend_detection/hurst_analyzer.d.ts.map +1 -1
- package/dist/analysis/trend_detection/hurst_analyzer.js +10 -7
- package/dist/analysis/trend_detection/hurst_analyzer.js.map +1 -1
- package/dist/analysis/trend_detection/kalman_trend_analyzer.d.ts +6 -6
- package/dist/analysis/trend_detection/kalman_trend_analyzer.d.ts.map +1 -1
- package/dist/analysis/trend_detection/kalman_trend_analyzer.js +23 -15
- package/dist/analysis/trend_detection/kalman_trend_analyzer.js.map +1 -1
- package/dist/analysis/trend_detection/kalman_velocity_smoothing.d.ts +12 -13
- package/dist/analysis/trend_detection/kalman_velocity_smoothing.d.ts.map +1 -1
- package/dist/analysis/trend_detection/kalman_velocity_smoothing.js +16 -16
- package/dist/analysis/trend_detection/kalman_velocity_smoothing.js.map +1 -1
- package/dist/analysis/trend_detection/permutation_entropy_analyzer.d.ts +1 -4
- package/dist/analysis/trend_detection/permutation_entropy_analyzer.d.ts.map +1 -1
- package/dist/analysis/trend_detection/permutation_entropy_analyzer.js +10 -7
- package/dist/analysis/trend_detection/permutation_entropy_analyzer.js.map +1 -1
- package/dist/bot.d.ts.map +1 -1
- package/dist/bot.js +6 -13
- package/dist/bot.js.map +1 -1
- package/dist/credential-daemon.d.ts.map +1 -1
- package/dist/credential-daemon.js +74 -35
- package/dist/credential-daemon.js.map +1 -1
- package/dist/dexbot.d.ts.map +1 -1
- package/dist/dexbot.js +16 -15
- package/dist/dexbot.js.map +1 -1
- package/dist/market_adapter/ama_signal_runner.d.ts +1 -1
- package/dist/market_adapter/ama_signal_runner.d.ts.map +1 -1
- package/dist/market_adapter/ama_signal_runner.js +8 -20
- package/dist/market_adapter/ama_signal_runner.js.map +1 -1
- package/dist/market_adapter/candle_utils.d.ts +2 -10
- package/dist/market_adapter/candle_utils.d.ts.map +1 -1
- package/dist/market_adapter/candle_utils.js +7 -8
- package/dist/market_adapter/candle_utils.js.map +1 -1
- package/dist/market_adapter/core/asymmetric_bounds.d.ts +12 -7
- package/dist/market_adapter/core/asymmetric_bounds.d.ts.map +1 -1
- package/dist/market_adapter/core/asymmetric_bounds.js +4 -5
- package/dist/market_adapter/core/asymmetric_bounds.js.map +1 -1
- package/dist/market_adapter/core/config_normalizers.d.ts +4 -9
- package/dist/market_adapter/core/config_normalizers.d.ts.map +1 -1
- package/dist/market_adapter/core/config_normalizers.js +9 -9
- package/dist/market_adapter/core/config_normalizers.js.map +1 -1
- package/dist/market_adapter/core/kibana_candles.d.ts +16 -20
- package/dist/market_adapter/core/kibana_candles.d.ts.map +1 -1
- package/dist/market_adapter/core/kibana_candles.js +16 -15
- package/dist/market_adapter/core/kibana_candles.js.map +1 -1
- package/dist/market_adapter/core/kibana_client.d.ts +8 -11
- package/dist/market_adapter/core/kibana_client.d.ts.map +1 -1
- package/dist/market_adapter/core/kibana_client.js +13 -11
- package/dist/market_adapter/core/kibana_client.js.map +1 -1
- package/dist/market_adapter/core/kibana_market_candles.d.ts +5 -12
- package/dist/market_adapter/core/kibana_market_candles.d.ts.map +1 -1
- package/dist/market_adapter/core/kibana_market_candles.js +12 -21
- package/dist/market_adapter/core/kibana_market_candles.js.map +1 -1
- package/dist/market_adapter/core/market_adapter_service.d.ts +75 -53
- package/dist/market_adapter/core/market_adapter_service.d.ts.map +1 -1
- package/dist/market_adapter/core/market_adapter_service.js +102 -98
- package/dist/market_adapter/core/market_adapter_service.js.map +1 -1
- package/dist/market_adapter/core/strategies/ama.d.ts +21 -1
- package/dist/market_adapter/core/strategies/ama.d.ts.map +1 -1
- package/dist/market_adapter/core/strategies/ama.js +10 -10
- package/dist/market_adapter/core/strategies/ama.js.map +1 -1
- package/dist/market_adapter/core/strategies/ama_slope_model.d.ts +7 -11
- package/dist/market_adapter/core/strategies/ama_slope_model.d.ts.map +1 -1
- package/dist/market_adapter/core/strategies/ama_slope_model.js +23 -30
- package/dist/market_adapter/core/strategies/ama_slope_model.js.map +1 -1
- package/dist/market_adapter/core/strategies/atr/calculator.d.ts +5 -4
- package/dist/market_adapter/core/strategies/atr/calculator.d.ts.map +1 -1
- package/dist/market_adapter/core/strategies/atr/calculator.js +5 -3
- package/dist/market_adapter/core/strategies/atr/calculator.js.map +1 -1
- package/dist/market_adapter/core/strategies/collateral_manager.d.ts +4 -7
- package/dist/market_adapter/core/strategies/collateral_manager.d.ts.map +1 -1
- package/dist/market_adapter/core/strategies/collateral_manager.js +5 -4
- package/dist/market_adapter/core/strategies/collateral_manager.js.map +1 -1
- package/dist/market_adapter/core/strategies/regime_gate.d.ts +11 -19
- package/dist/market_adapter/core/strategies/regime_gate.d.ts.map +1 -1
- package/dist/market_adapter/core/strategies/regime_gate.js +22 -22
- package/dist/market_adapter/core/strategies/regime_gate.js.map +1 -1
- package/dist/market_adapter/index.d.ts +24 -2
- package/dist/market_adapter/index.d.ts.map +1 -1
- package/dist/market_adapter/index.js +82 -56
- package/dist/market_adapter/index.js.map +1 -1
- package/dist/market_adapter/inputs/fetch_cex_synthetic_data.js +26 -37
- package/dist/market_adapter/inputs/fetch_cex_synthetic_data.js.map +1 -1
- package/dist/market_adapter/inputs/fetch_lp_data.d.ts +4 -12
- package/dist/market_adapter/inputs/fetch_lp_data.d.ts.map +1 -1
- package/dist/market_adapter/inputs/fetch_lp_data.js +100 -66
- package/dist/market_adapter/inputs/fetch_lp_data.js.map +1 -1
- package/dist/market_adapter/inputs/kibana_source.d.ts +4 -9
- package/dist/market_adapter/inputs/kibana_source.d.ts.map +1 -1
- package/dist/market_adapter/inputs/kibana_source.js +17 -18
- package/dist/market_adapter/inputs/kibana_source.js.map +1 -1
- package/dist/market_adapter/interval_utils.d.ts +1 -4
- package/dist/market_adapter/interval_utils.d.ts.map +1 -1
- package/dist/market_adapter/interval_utils.js +2 -3
- package/dist/market_adapter/interval_utils.js.map +1 -1
- package/dist/market_adapter/log_format.d.ts +1 -9
- package/dist/market_adapter/log_format.d.ts.map +1 -1
- package/dist/market_adapter/log_format.js +7 -8
- package/dist/market_adapter/log_format.js.map +1 -1
- package/dist/market_adapter/lp_chart_core.d.ts +1 -4
- package/dist/market_adapter/lp_chart_core.d.ts.map +1 -1
- package/dist/market_adapter/lp_chart_core.js +22 -20
- package/dist/market_adapter/lp_chart_core.js.map +1 -1
- package/dist/market_adapter/lp_chart_runner.d.ts +13 -24
- package/dist/market_adapter/lp_chart_runner.d.ts.map +1 -1
- package/dist/market_adapter/lp_chart_runner.js +58 -56
- package/dist/market_adapter/lp_chart_runner.js.map +1 -1
- package/dist/market_adapter/lp_chart_strategy_loader.d.ts +4 -17
- package/dist/market_adapter/lp_chart_strategy_loader.d.ts.map +1 -1
- package/dist/market_adapter/lp_chart_strategy_loader.js +36 -36
- package/dist/market_adapter/lp_chart_strategy_loader.js.map +1 -1
- package/dist/market_adapter/market_adapter.d.ts +51 -72
- package/dist/market_adapter/market_adapter.d.ts.map +1 -1
- package/dist/market_adapter/market_adapter.js +227 -192
- package/dist/market_adapter/market_adapter.js.map +1 -1
- package/dist/market_adapter/merge_lp_data.js +17 -16
- package/dist/market_adapter/merge_lp_data.js.map +1 -1
- package/dist/market_adapter/test_helpers.d.ts +9 -13
- package/dist/market_adapter/test_helpers.d.ts.map +1 -1
- package/dist/market_adapter/test_helpers.js +14 -14
- package/dist/market_adapter/test_helpers.js.map +1 -1
- package/dist/market_adapter/utils/adapter_client.d.ts +6 -14
- package/dist/market_adapter/utils/adapter_client.d.ts.map +1 -1
- package/dist/market_adapter/utils/adapter_client.js +16 -15
- package/dist/market_adapter/utils/adapter_client.js.map +1 -1
- package/dist/market_adapter/utils/atomic_write.d.ts +2 -5
- package/dist/market_adapter/utils/atomic_write.d.ts.map +1 -1
- package/dist/market_adapter/utils/atomic_write.js +5 -5
- package/dist/market_adapter/utils/atomic_write.js.map +1 -1
- package/dist/market_adapter/utils/chain.d.ts +19 -21
- package/dist/market_adapter/utils/chain.d.ts.map +1 -1
- package/dist/market_adapter/utils/chain.js +15 -16
- package/dist/market_adapter/utils/chain.js.map +1 -1
- package/dist/market_adapter/utils/data_discovery.d.ts +1 -4
- package/dist/market_adapter/utils/data_discovery.d.ts.map +1 -1
- package/dist/market_adapter/utils/data_discovery.js +10 -10
- package/dist/market_adapter/utils/data_discovery.js.map +1 -1
- package/dist/market_adapter/utils/dynamic_grid_snapshot.d.ts +1 -6
- package/dist/market_adapter/utils/dynamic_grid_snapshot.d.ts.map +1 -1
- package/dist/market_adapter/utils/dynamic_grid_snapshot.js +14 -14
- package/dist/market_adapter/utils/dynamic_grid_snapshot.js.map +1 -1
- package/dist/market_adapter/utils/file_lock.d.ts +1 -7
- package/dist/market_adapter/utils/file_lock.d.ts.map +1 -1
- package/dist/market_adapter/utils/file_lock.js +21 -25
- package/dist/market_adapter/utils/file_lock.js.map +1 -1
- package/dist/market_adapter/utils/native_history.d.ts +12 -12
- package/dist/market_adapter/utils/native_history.d.ts.map +1 -1
- package/dist/market_adapter/utils/native_history.js +15 -15
- package/dist/market_adapter/utils/native_history.js.map +1 -1
- package/dist/market_adapter/utils/paths.d.ts +2 -4
- package/dist/market_adapter/utils/paths.d.ts.map +1 -1
- package/dist/market_adapter/utils/paths.js +6 -5
- package/dist/market_adapter/utils/paths.js.map +1 -1
- package/dist/modules/account_bots.d.ts +7 -8
- package/dist/modules/account_bots.d.ts.map +1 -1
- package/dist/modules/account_bots.js +92 -114
- package/dist/modules/account_bots.js.map +1 -1
- package/dist/modules/account_orders.d.ts +5 -9
- package/dist/modules/account_orders.d.ts.map +1 -1
- package/dist/modules/account_orders.js +69 -32
- package/dist/modules/account_orders.js.map +1 -1
- package/dist/modules/authority_resolver.d.ts +32 -1
- package/dist/modules/authority_resolver.d.ts.map +1 -1
- package/dist/modules/authority_resolver.js +18 -12
- package/dist/modules/authority_resolver.js.map +1 -1
- package/dist/modules/bitshares-native/chain_client.d.ts +3 -8
- package/dist/modules/bitshares-native/chain_client.d.ts.map +1 -1
- package/dist/modules/bitshares-native/chain_client.js +21 -16
- package/dist/modules/bitshares-native/chain_client.js.map +1 -1
- package/dist/modules/bitshares-native/crypto/ecc.browser.d.ts +21 -29
- package/dist/modules/bitshares-native/crypto/ecc.browser.d.ts.map +1 -1
- package/dist/modules/bitshares-native/crypto/ecc.browser.js +72 -38
- package/dist/modules/bitshares-native/crypto/ecc.browser.js.map +1 -1
- package/dist/modules/bitshares-native/crypto/ecc.d.ts +9 -36
- package/dist/modules/bitshares-native/crypto/ecc.d.ts.map +1 -1
- package/dist/modules/bitshares-native/crypto/ecc.js +40 -83
- package/dist/modules/bitshares-native/crypto/ecc.js.map +1 -1
- package/dist/modules/bitshares-native/crypto/ecc_selector.d.ts +14 -1
- package/dist/modules/bitshares-native/crypto/ecc_selector.d.ts.map +1 -1
- package/dist/modules/bitshares-native/crypto/ecc_selector.js +5 -3
- package/dist/modules/bitshares-native/crypto/ecc_selector.js.map +1 -1
- package/dist/modules/bitshares-native/index.d.ts +10 -2
- package/dist/modules/bitshares-native/index.d.ts.map +1 -1
- package/dist/modules/bitshares-native/index.js +68 -31
- package/dist/modules/bitshares-native/index.js.map +1 -1
- package/dist/modules/bitshares-native/lru_cache.d.ts +1 -4
- package/dist/modules/bitshares-native/lru_cache.d.ts.map +1 -1
- package/dist/modules/bitshares-native/lru_cache.js +6 -3
- package/dist/modules/bitshares-native/lru_cache.js.map +1 -1
- package/dist/modules/bitshares-native/resolvers.d.ts +3 -6
- package/dist/modules/bitshares-native/resolvers.d.ts.map +1 -1
- package/dist/modules/bitshares-native/resolvers.js +11 -9
- package/dist/modules/bitshares-native/resolvers.js.map +1 -1
- package/dist/modules/bitshares-native/serial/chain_constants.d.ts +53 -55
- package/dist/modules/bitshares-native/serial/chain_constants.d.ts.map +1 -1
- package/dist/modules/bitshares-native/serial/chain_constants.js +28 -27
- package/dist/modules/bitshares-native/serial/chain_constants.js.map +1 -1
- package/dist/modules/bitshares-native/serial/index.d.ts +5 -9
- package/dist/modules/bitshares-native/serial/index.d.ts.map +1 -1
- package/dist/modules/bitshares-native/serial/index.js +46 -12
- package/dist/modules/bitshares-native/serial/index.js.map +1 -1
- package/dist/modules/bitshares-native/serial/operations.d.ts +102 -100
- package/dist/modules/bitshares-native/serial/operations.d.ts.map +1 -1
- package/dist/modules/bitshares-native/serial/operations.js +473 -471
- package/dist/modules/bitshares-native/serial/operations.js.map +1 -1
- package/dist/modules/bitshares-native/serial/serializer.d.ts +2 -7
- package/dist/modules/bitshares-native/serial/serializer.d.ts.map +1 -1
- package/dist/modules/bitshares-native/serial/serializer.js +8 -3
- package/dist/modules/bitshares-native/serial/serializer.js.map +1 -1
- package/dist/modules/bitshares-native/serial/types.d.ts +26 -41
- package/dist/modules/bitshares-native/serial/types.d.ts.map +1 -1
- package/dist/modules/bitshares-native/serial/types.js +76 -42
- package/dist/modules/bitshares-native/serial/types.js.map +1 -1
- package/dist/modules/bitshares-native/signing_client.d.ts +1 -5
- package/dist/modules/bitshares-native/signing_client.d.ts.map +1 -1
- package/dist/modules/bitshares-native/signing_client.js +49 -11
- package/dist/modules/bitshares-native/signing_client.js.map +1 -1
- package/dist/modules/bitshares-native/subscriptions.d.ts +1 -4
- package/dist/modules/bitshares-native/subscriptions.d.ts.map +1 -1
- package/dist/modules/bitshares-native/subscriptions.js +47 -84
- package/dist/modules/bitshares-native/subscriptions.js.map +1 -1
- package/dist/modules/bitshares-native/transport.d.ts +1 -8
- package/dist/modules/bitshares-native/transport.d.ts.map +1 -1
- package/dist/modules/bitshares-native/transport.js +22 -15
- package/dist/modules/bitshares-native/transport.js.map +1 -1
- package/dist/modules/bitshares-native/tx/builder.d.ts +3 -8
- package/dist/modules/bitshares-native/tx/builder.d.ts.map +1 -1
- package/dist/modules/bitshares-native/tx/builder.js +61 -23
- package/dist/modules/bitshares-native/tx/builder.js.map +1 -1
- package/dist/modules/bitshares-native/tx/tx_cache.d.ts +1 -8
- package/dist/modules/bitshares-native/tx/tx_cache.d.ts.map +1 -1
- package/dist/modules/bitshares-native/tx/tx_cache.js +21 -17
- package/dist/modules/bitshares-native/tx/tx_cache.js.map +1 -1
- package/dist/modules/bitshares_client.d.ts +12 -23
- package/dist/modules/bitshares_client.d.ts.map +1 -1
- package/dist/modules/bitshares_client.js +109 -56
- package/dist/modules/bitshares_client.js.map +1 -1
- package/dist/modules/bot_settings.d.ts +1 -13
- package/dist/modules/bot_settings.d.ts.map +1 -1
- package/dist/modules/bot_settings.js +34 -34
- package/dist/modules/bot_settings.js.map +1 -1
- package/dist/modules/bots_file_lock.d.ts +3 -9
- package/dist/modules/bots_file_lock.d.ts.map +1 -1
- package/dist/modules/bots_file_lock.js +8 -9
- package/dist/modules/bots_file_lock.js.map +1 -1
- package/dist/modules/chain_keys.d.ts +7 -39
- package/dist/modules/chain_keys.d.ts.map +1 -1
- package/dist/modules/chain_keys.js +126 -90
- package/dist/modules/chain_keys.js.map +1 -1
- package/dist/modules/chain_orders.d.ts +46 -52
- package/dist/modules/chain_orders.d.ts.map +1 -1
- package/dist/modules/chain_orders.js +152 -104
- package/dist/modules/chain_orders.js.map +1 -1
- package/dist/modules/config.d.ts +50 -57
- package/dist/modules/config.d.ts.map +1 -1
- package/dist/modules/config.js +28 -24
- package/dist/modules/config.js.map +1 -1
- package/dist/modules/constants.d.ts +492 -492
- package/dist/modules/constants.d.ts.map +1 -1
- package/dist/modules/constants.js +79 -39
- package/dist/modules/constants.js.map +1 -1
- package/dist/modules/cr_planner.d.ts +1 -13
- package/dist/modules/cr_planner.d.ts.map +1 -1
- package/dist/modules/cr_planner.js +28 -28
- package/dist/modules/cr_planner.js.map +1 -1
- package/dist/modules/credential_policy.d.ts +18 -33
- package/dist/modules/credential_policy.d.ts.map +1 -1
- package/dist/modules/credential_policy.js +114 -87
- package/dist/modules/credential_policy.js.map +1 -1
- package/dist/modules/credential_runtime.d.ts +11 -21
- package/dist/modules/credential_runtime.d.ts.map +1 -1
- package/dist/modules/credential_runtime.js +40 -40
- package/dist/modules/credential_runtime.js.map +1 -1
- package/dist/modules/credential_session_cache.d.ts +8 -8
- package/dist/modules/credential_session_cache.d.ts.map +1 -1
- package/dist/modules/credential_session_cache.js +41 -8
- package/dist/modules/credential_session_cache.js.map +1 -1
- package/dist/modules/credit_runtime.d.ts +51 -316
- package/dist/modules/credit_runtime.d.ts.map +1 -1
- package/dist/modules/credit_runtime.js +257 -183
- package/dist/modules/credit_runtime.js.map +1 -1
- package/dist/modules/crypto/browser_provider.js +6 -6
- package/dist/modules/crypto/browser_provider.js.map +1 -1
- package/dist/modules/crypto/index.d.ts.map +1 -1
- package/dist/modules/crypto/index.js +2 -0
- package/dist/modules/crypto/index.js.map +1 -1
- package/dist/modules/crypto/sync.js +3 -3
- package/dist/modules/crypto/sync.js.map +1 -1
- package/dist/modules/dexbot_class.d.ts +124 -73
- package/dist/modules/dexbot_class.d.ts.map +1 -1
- package/dist/modules/dexbot_class.js +198 -3577
- package/dist/modules/dexbot_class.js.map +1 -1
- package/dist/modules/dexbot_cow_runtime.d.ts +322 -0
- package/dist/modules/dexbot_cow_runtime.d.ts.map +1 -0
- package/dist/modules/dexbot_cow_runtime.js +1836 -0
- package/dist/modules/dexbot_cow_runtime.js.map +1 -0
- package/dist/modules/dexbot_credential_client.d.ts +5 -11
- package/dist/modules/dexbot_credential_client.d.ts.map +1 -1
- package/dist/modules/dexbot_credential_client.js +32 -30
- package/dist/modules/dexbot_credential_client.js.map +1 -1
- package/dist/modules/dexbot_fill_runtime.d.ts +47 -15
- package/dist/modules/dexbot_fill_runtime.d.ts.map +1 -1
- package/dist/modules/dexbot_fill_runtime.js +565 -22
- package/dist/modules/dexbot_fill_runtime.js.map +1 -1
- package/dist/modules/dexbot_maintenance_runtime.d.ts +79 -10
- package/dist/modules/dexbot_maintenance_runtime.d.ts.map +1 -1
- package/dist/modules/dexbot_maintenance_runtime.js +294 -55
- package/dist/modules/dexbot_maintenance_runtime.js.map +1 -1
- package/dist/modules/dexbot_startup_runtime.d.ts +26 -0
- package/dist/modules/dexbot_startup_runtime.d.ts.map +1 -0
- package/dist/modules/dexbot_startup_runtime.js +575 -0
- package/dist/modules/dexbot_startup_runtime.js.map +1 -0
- package/dist/modules/dexbot_state_recovery.d.ts +115 -0
- package/dist/modules/dexbot_state_recovery.d.ts.map +1 -0
- package/dist/modules/dexbot_state_recovery.js +431 -0
- package/dist/modules/dexbot_state_recovery.js.map +1 -0
- package/dist/modules/fund_registry.d.ts +1 -13
- package/dist/modules/fund_registry.d.ts.map +1 -1
- package/dist/modules/fund_registry.js +23 -22
- package/dist/modules/fund_registry.js.map +1 -1
- package/dist/modules/general_settings.d.ts +3 -7
- package/dist/modules/general_settings.d.ts.map +1 -1
- package/dist/modules/general_settings.js +15 -15
- package/dist/modules/general_settings.js.map +1 -1
- package/dist/modules/graceful_shutdown.d.ts +1 -6
- package/dist/modules/graceful_shutdown.d.ts.map +1 -1
- package/dist/modules/graceful_shutdown.js +19 -16
- 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 +53 -20
- package/dist/modules/key_store.js.map +1 -1
- package/dist/modules/launcher/bot_supervisor.d.ts +23 -66
- package/dist/modules/launcher/bot_supervisor.d.ts.map +1 -1
- package/dist/modules/launcher/bot_supervisor.js +115 -107
- package/dist/modules/launcher/bot_supervisor.js.map +1 -1
- package/dist/modules/launcher/child_env.d.ts +2 -5
- package/dist/modules/launcher/child_env.d.ts.map +1 -1
- package/dist/modules/launcher/child_env.js +4 -4
- package/dist/modules/launcher/child_env.js.map +1 -1
- package/dist/modules/launcher/credential_bootstrap.d.ts +4 -8
- package/dist/modules/launcher/credential_bootstrap.d.ts.map +1 -1
- package/dist/modules/launcher/credential_bootstrap.js +30 -26
- package/dist/modules/launcher/credential_bootstrap.js.map +1 -1
- package/dist/modules/launcher/credential_daemon.d.ts +8 -15
- package/dist/modules/launcher/credential_daemon.d.ts.map +1 -1
- package/dist/modules/launcher/credential_daemon.js +72 -41
- package/dist/modules/launcher/credential_daemon.js.map +1 -1
- package/dist/modules/launcher/credential_secret.d.ts +1 -4
- package/dist/modules/launcher/credential_secret.d.ts.map +1 -1
- package/dist/modules/launcher/credential_secret.js +36 -4
- package/dist/modules/launcher/credential_secret.js.map +1 -1
- package/dist/modules/launcher/foreign_cred_daemon.d.ts +32 -1
- package/dist/modules/launcher/foreign_cred_daemon.d.ts.map +1 -1
- package/dist/modules/launcher/foreign_cred_daemon.js +25 -28
- package/dist/modules/launcher/foreign_cred_daemon.js.map +1 -1
- package/dist/modules/launcher/headless_password.d.ts +1 -4
- package/dist/modules/launcher/headless_password.d.ts.map +1 -1
- package/dist/modules/launcher/headless_password.js +11 -11
- package/dist/modules/launcher/headless_password.js.map +1 -1
- package/dist/modules/launcher/launch_modes.d.ts +15 -14
- package/dist/modules/launcher/launch_modes.d.ts.map +1 -1
- package/dist/modules/launcher/launch_modes.js +8 -8
- package/dist/modules/launcher/launch_modes.js.map +1 -1
- package/dist/modules/launcher/market_adapter_runtime.d.ts +10 -19
- package/dist/modules/launcher/market_adapter_runtime.d.ts.map +1 -1
- package/dist/modules/launcher/market_adapter_runtime.js +33 -34
- package/dist/modules/launcher/market_adapter_runtime.js.map +1 -1
- package/dist/modules/launcher/market_adapter_watchdog.d.ts +10 -17
- package/dist/modules/launcher/market_adapter_watchdog.d.ts.map +1 -1
- package/dist/modules/launcher/market_adapter_watchdog.js +42 -39
- package/dist/modules/launcher/market_adapter_watchdog.js.map +1 -1
- package/dist/modules/launcher/monolithic_runtime.d.ts +28 -57
- package/dist/modules/launcher/monolithic_runtime.d.ts.map +1 -1
- package/dist/modules/launcher/monolithic_runtime.js +135 -108
- package/dist/modules/launcher/monolithic_runtime.js.map +1 -1
- package/dist/modules/launcher/runtime_entry.d.ts +5 -10
- package/dist/modules/launcher/runtime_entry.d.ts.map +1 -1
- package/dist/modules/launcher/runtime_entry.js +14 -14
- package/dist/modules/launcher/runtime_entry.js.map +1 -1
- package/dist/modules/launcher/status_reporting.d.ts +17 -37
- package/dist/modules/launcher/status_reporting.d.ts.map +1 -1
- package/dist/modules/launcher/status_reporting.js +35 -34
- package/dist/modules/launcher/status_reporting.js.map +1 -1
- package/dist/modules/launcher/supervisor_control.d.ts +1 -4
- package/dist/modules/launcher/supervisor_control.d.ts.map +1 -1
- package/dist/modules/launcher/supervisor_control.js +9 -4
- package/dist/modules/launcher/supervisor_control.js.map +1 -1
- package/dist/modules/logger.d.ts +3 -1
- package/dist/modules/logger.d.ts.map +1 -1
- package/dist/modules/logger.js +38 -28
- package/dist/modules/logger.js.map +1 -1
- package/dist/modules/market_adapter_whitelist.d.ts +2 -10
- package/dist/modules/market_adapter_whitelist.d.ts.map +1 -1
- package/dist/modules/market_adapter_whitelist.js +18 -16
- package/dist/modules/market_adapter_whitelist.js.map +1 -1
- package/dist/modules/node_health_cache.d.ts +2 -12
- package/dist/modules/node_health_cache.d.ts.map +1 -1
- package/dist/modules/node_health_cache.js +24 -24
- 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 -38
- package/dist/modules/node_manager.js.map +1 -1
- package/dist/modules/order/accounting.d.ts +12 -12
- package/dist/modules/order/accounting.d.ts.map +1 -1
- package/dist/modules/order/accounting.js +111 -76
- package/dist/modules/order/accounting.js.map +1 -1
- package/dist/modules/order/async_lock.d.ts +1 -2
- package/dist/modules/order/async_lock.d.ts.map +1 -1
- package/dist/modules/order/async_lock.js +4 -4
- package/dist/modules/order/async_lock.js.map +1 -1
- package/dist/modules/order/export.d.ts +8 -14
- package/dist/modules/order/export.d.ts.map +1 -1
- package/dist/modules/order/export.js +77 -42
- package/dist/modules/order/export.js.map +1 -1
- package/dist/modules/order/format.d.ts +17 -22
- package/dist/modules/order/format.d.ts.map +1 -1
- package/dist/modules/order/format.js +25 -31
- package/dist/modules/order/format.js.map +1 -1
- package/dist/modules/order/grid.d.ts +18 -104
- package/dist/modules/order/grid.d.ts.map +1 -1
- package/dist/modules/order/grid.js +246 -188
- package/dist/modules/order/grid.js.map +1 -1
- package/dist/modules/order/grid_reconcile.d.ts +8 -8
- package/dist/modules/order/grid_reconcile.d.ts.map +1 -1
- package/dist/modules/order/grid_reconcile.js +24 -24
- package/dist/modules/order/grid_reconcile.js.map +1 -1
- package/dist/modules/order/grid_reconcile_internal.d.ts +224 -1
- package/dist/modules/order/grid_reconcile_internal.d.ts.map +1 -1
- package/dist/modules/order/grid_reconcile_internal.js +145 -72
- package/dist/modules/order/grid_reconcile_internal.js.map +1 -1
- package/dist/modules/order/index.d.ts +1 -1
- package/dist/modules/order/index.d.ts.map +1 -1
- package/dist/modules/order/index.js +42 -7
- package/dist/modules/order/index.js.map +1 -1
- package/dist/modules/order/logger.d.ts +6 -16
- package/dist/modules/order/logger.d.ts.map +1 -1
- package/dist/modules/order/logger.js +76 -53
- package/dist/modules/order/logger.js.map +1 -1
- package/dist/modules/order/logger_state.d.ts +4 -4
- package/dist/modules/order/logger_state.d.ts.map +1 -1
- package/dist/modules/order/logger_state.js +3 -1
- package/dist/modules/order/logger_state.js.map +1 -1
- package/dist/modules/order/manager.d.ts +160 -37
- package/dist/modules/order/manager.d.ts.map +1 -1
- package/dist/modules/order/manager.js +166 -128
- package/dist/modules/order/manager.js.map +1 -1
- package/dist/modules/order/processed_fill_store.d.ts +6 -10
- package/dist/modules/order/processed_fill_store.d.ts.map +1 -1
- package/dist/modules/order/processed_fill_store.js +10 -9
- package/dist/modules/order/processed_fill_store.js.map +1 -1
- package/dist/modules/order/strategy.d.ts +3 -3
- package/dist/modules/order/strategy.d.ts.map +1 -1
- package/dist/modules/order/strategy.js +29 -27
- package/dist/modules/order/strategy.js.map +1 -1
- package/dist/modules/order/sync_engine.d.ts +9 -19
- package/dist/modules/order/sync_engine.d.ts.map +1 -1
- package/dist/modules/order/sync_engine.js +176 -126
- package/dist/modules/order/sync_engine.js.map +1 -1
- package/dist/modules/order/utils/math.d.ts +55 -85
- package/dist/modules/order/utils/math.d.ts.map +1 -1
- package/dist/modules/order/utils/math.js +155 -88
- package/dist/modules/order/utils/math.js.map +1 -1
- package/dist/modules/order/utils/order.d.ts +27 -72
- package/dist/modules/order/utils/order.d.ts.map +1 -1
- package/dist/modules/order/utils/order.js +144 -105
- package/dist/modules/order/utils/order.js.map +1 -1
- package/dist/modules/order/utils/system.d.ts +74 -44
- package/dist/modules/order/utils/system.d.ts.map +1 -1
- package/dist/modules/order/utils/system.js +188 -149
- package/dist/modules/order/utils/system.js.map +1 -1
- package/dist/modules/order/utils/validate.d.ts +21 -43
- package/dist/modules/order/utils/validate.d.ts.map +1 -1
- package/dist/modules/order/utils/validate.js +140 -110
- package/dist/modules/order/utils/validate.js.map +1 -1
- package/dist/modules/order/working_grid.d.ts +1 -4
- package/dist/modules/order/working_grid.d.ts.map +1 -1
- package/dist/modules/order/working_grid.js +9 -7
- package/dist/modules/order/working_grid.js.map +1 -1
- package/dist/modules/path_api.js +2 -2
- package/dist/modules/path_api.js.map +1 -1
- package/dist/modules/paths.d.ts +51 -55
- package/dist/modules/paths.d.ts.map +1 -1
- package/dist/modules/paths.js +72 -52
- package/dist/modules/paths.js.map +1 -1
- package/dist/modules/process_discovery.d.ts +1 -1
- package/dist/modules/process_discovery.d.ts.map +1 -1
- package/dist/modules/process_discovery.js +7 -7
- package/dist/modules/process_discovery.js.map +1 -1
- package/dist/modules/runtime.d.ts +1 -1
- package/dist/modules/runtime.d.ts.map +1 -1
- package/dist/modules/runtime.js +4 -4
- package/dist/modules/runtime.js.map +1 -1
- package/dist/modules/runtime_settings.d.ts +1 -0
- package/dist/modules/runtime_settings.d.ts.map +1 -1
- package/dist/modules/runtime_settings.js +15 -10
- package/dist/modules/runtime_settings.js.map +1 -1
- package/dist/modules/settings_merge.d.ts +1 -4
- package/dist/modules/settings_merge.d.ts.map +1 -1
- package/dist/modules/settings_merge.js +2 -1
- package/dist/modules/settings_merge.js.map +1 -1
- package/dist/modules/storage/browser_adapter.d.ts +7 -3
- package/dist/modules/storage/browser_adapter.d.ts.map +1 -1
- package/dist/modules/storage/browser_adapter.js +2 -0
- package/dist/modules/storage/browser_adapter.js.map +1 -1
- package/dist/modules/storage/index.d.ts +2 -2
- package/dist/modules/storage/index.d.ts.map +1 -1
- package/dist/modules/storage/index.js +2 -5
- package/dist/modules/storage/index.js.map +1 -1
- package/dist/modules/storage/node_adapter.d.ts +3 -3
- package/dist/modules/storage/node_adapter.d.ts.map +1 -1
- package/dist/modules/storage/node_adapter.js +9 -7
- package/dist/modules/storage/node_adapter.js.map +1 -1
- package/dist/modules/storage/types.d.ts +13 -10
- package/dist/modules/storage/types.d.ts.map +1 -1
- package/dist/modules/types.d.ts +0 -2
- package/dist/modules/types.d.ts.map +1 -1
- package/dist/modules/utils/base58check.d.ts +1 -9
- package/dist/modules/utils/base58check.d.ts.map +1 -1
- package/dist/modules/utils/base58check.js +14 -16
- package/dist/modules/utils/base58check.js.map +1 -1
- package/dist/modules/utils/build_dir.d.ts +2 -5
- package/dist/modules/utils/build_dir.d.ts.map +1 -1
- package/dist/modules/utils/build_dir.js +6 -3
- package/dist/modules/utils/build_dir.js.map +1 -1
- package/dist/modules/utils/errors.d.ts +2 -0
- package/dist/modules/utils/errors.d.ts.map +1 -0
- package/dist/modules/utils/errors.js +12 -0
- package/dist/modules/utils/errors.js.map +1 -0
- package/dist/modules/utils/fs_utils.d.ts +1 -8
- package/dist/modules/utils/fs_utils.d.ts.map +1 -1
- package/dist/modules/utils/fs_utils.js +8 -3
- package/dist/modules/utils/fs_utils.js.map +1 -1
- package/dist/modules/utils/math_utils.d.ts +2 -6
- package/dist/modules/utils/math_utils.d.ts.map +1 -1
- package/dist/modules/utils/math_utils.js +6 -2
- package/dist/modules/utils/math_utils.js.map +1 -1
- package/dist/modules/validate_profiles.d.ts +1 -11
- package/dist/modules/validate_profiles.d.ts.map +1 -1
- package/dist/modules/validate_profiles.js +25 -27
- package/dist/modules/validate_profiles.js.map +1 -1
- package/dist/pm2.d.ts +7 -6
- package/dist/pm2.d.ts.map +1 -1
- package/dist/pm2.js +132 -106
- package/dist/pm2.js.map +1 -1
- package/dist/scripts/analyze-git.d.ts.map +1 -1
- package/dist/scripts/analyze-git.js +15 -11
- package/dist/scripts/analyze-git.js.map +1 -1
- package/dist/scripts/analyze-orders.d.ts +146 -1
- package/dist/scripts/analyze-orders.d.ts.map +1 -1
- package/dist/scripts/analyze-orders.js +81 -105
- package/dist/scripts/analyze-orders.js.map +1 -1
- package/dist/scripts/diagnose-pool-history.d.ts.map +1 -1
- package/dist/scripts/diagnose-pool-history.js +9 -8
- 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 +11 -8
- package/dist/scripts/divergence-calc.js.map +1 -1
- package/dist/scripts/fix-err-message.d.ts +3 -0
- package/dist/scripts/fix-err-message.d.ts.map +1 -0
- package/dist/scripts/fix-err-message.js +198 -0
- package/dist/scripts/fix-err-message.js.map +1 -0
- package/dist/scripts/generate_lp_chart.d.ts +2 -9
- package/dist/scripts/generate_lp_chart.d.ts.map +1 -1
- package/dist/scripts/generate_lp_chart.js +14 -10
- package/dist/scripts/generate_lp_chart.js.map +1 -1
- package/dist/scripts/generate_mainnet_corpus_report.js +4 -4
- package/dist/scripts/generate_mainnet_corpus_report.js.map +1 -1
- package/dist/scripts/generate_market_adapter_whitelist.d.ts +17 -1
- package/dist/scripts/generate_market_adapter_whitelist.d.ts.map +1 -1
- package/dist/scripts/generate_market_adapter_whitelist.js +23 -20
- package/dist/scripts/generate_market_adapter_whitelist.js.map +1 -1
- package/dist/scripts/migrate_bot_keys.d.ts +1 -4
- package/dist/scripts/migrate_bot_keys.d.ts.map +1 -1
- package/dist/scripts/migrate_bot_keys.js +48 -124
- package/dist/scripts/migrate_bot_keys.js.map +1 -1
- package/dist/scripts/native_release_gates.d.ts.map +1 -1
- package/dist/scripts/native_release_gates.js +18 -14
- package/dist/scripts/native_release_gates.js.map +1 -1
- package/dist/scripts/print_grid.js +1 -1
- package/dist/scripts/print_grid.js.map +1 -1
- package/dist/scripts/run-tests.js +1 -0
- package/dist/scripts/run-tests.js.map +1 -1
- package/dist/scripts/runner.d.ts +1 -11
- package/dist/scripts/runner.d.ts.map +1 -1
- package/dist/scripts/runner.js +21 -19
- package/dist/scripts/runner.js.map +1 -1
- package/dist/scripts/test-credit-renewal.d.ts.map +1 -1
- package/dist/scripts/test-credit-renewal.js +2 -1
- package/dist/scripts/test-credit-renewal.js.map +1 -1
- package/dist/scripts/update.d.ts.map +1 -1
- package/dist/scripts/update.js +85 -79
- package/dist/scripts/update.js.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 +25 -1
- package/dist/scripts/verify-browser-bundle.js.map +1 -1
- package/dist/unlock.d.ts +4 -17
- package/dist/unlock.d.ts.map +1 -1
- package/dist/unlock.js +141 -108
- package/dist/unlock.js.map +1 -1
- package/package.json +7 -2
- package/dist/analysis/ama_fitting/analyze_ama_price_changes.d.ts +0 -3
- package/dist/analysis/ama_fitting/analyze_ama_price_changes.d.ts.map +0 -1
- package/dist/analysis/ama_fitting/analyze_ama_price_changes.js +0 -149
- package/dist/analysis/ama_fitting/analyze_ama_price_changes.js.map +0 -1
- package/dist/analysis/ama_fitting/analyze_lambda_vs_slow.d.ts +0 -3
- package/dist/analysis/ama_fitting/analyze_lambda_vs_slow.d.ts.map +0 -1
- package/dist/analysis/ama_fitting/analyze_lambda_vs_slow.js +0 -387
- package/dist/analysis/ama_fitting/analyze_lambda_vs_slow.js.map +0 -1
- package/dist/analysis/ama_fitting/calibrate_convergence_er.d.ts +0 -3
- package/dist/analysis/ama_fitting/calibrate_convergence_er.d.ts.map +0 -1
- package/dist/analysis/ama_fitting/calibrate_convergence_er.js +0 -200
- package/dist/analysis/ama_fitting/calibrate_convergence_er.js.map +0 -1
- package/dist/analysis/ama_fitting/fetch_lp_candles.d.ts +0 -3
- package/dist/analysis/ama_fitting/fetch_lp_candles.d.ts.map +0 -1
- package/dist/analysis/ama_fitting/fetch_lp_candles.js +0 -212
- package/dist/analysis/ama_fitting/fetch_lp_candles.js.map +0 -1
- package/dist/analysis/ama_fitting/generate_unified_comparison_chart.d.ts +0 -31
- package/dist/analysis/ama_fitting/generate_unified_comparison_chart.d.ts.map +0 -1
- package/dist/analysis/ama_fitting/generate_unified_comparison_chart.js +0 -249
- package/dist/analysis/ama_fitting/generate_unified_comparison_chart.js.map +0 -1
- package/dist/analysis/ama_fitting/optimizer_high_resolution.d.ts +0 -2
- package/dist/analysis/ama_fitting/optimizer_high_resolution.d.ts.map +0 -1
- package/dist/analysis/ama_fitting/optimizer_high_resolution.js +0 -782
- package/dist/analysis/ama_fitting/optimizer_high_resolution.js.map +0 -1
- package/dist/analysis/analyze_derivatives.d.ts +0 -95
- package/dist/analysis/analyze_derivatives.d.ts.map +0 -1
- package/dist/analysis/analyze_derivatives.js +0 -295
- package/dist/analysis/analyze_derivatives.js.map +0 -1
- package/dist/analysis/analyze_dynamic_weight.d.ts +0 -14
- package/dist/analysis/analyze_dynamic_weight.d.ts.map +0 -1
- package/dist/analysis/analyze_dynamic_weight.js +0 -207
- package/dist/analysis/analyze_dynamic_weight.js.map +0 -1
- package/dist/analysis/analyze_kalman.d.ts +0 -13
- package/dist/analysis/analyze_kalman.d.ts.map +0 -1
- package/dist/analysis/analyze_kalman.js +0 -123
- package/dist/analysis/analyze_kalman.js.map +0 -1
- package/dist/analysis/analyze_regime.d.ts +0 -20
- package/dist/analysis/analyze_regime.d.ts.map +0 -1
- package/dist/analysis/analyze_regime.js +0 -139
- package/dist/analysis/analyze_regime.js.map +0 -1
- package/dist/analysis/analyze_regime_windows.d.ts +0 -19
- package/dist/analysis/analyze_regime_windows.d.ts.map +0 -1
- package/dist/analysis/analyze_regime_windows.js +0 -413
- package/dist/analysis/analyze_regime_windows.js.map +0 -1
- package/dist/analysis/analyze_risk_profile.d.ts +0 -3
- package/dist/analysis/analyze_risk_profile.d.ts.map +0 -1
- package/dist/analysis/analyze_risk_profile.js +0 -159
- package/dist/analysis/analyze_risk_profile.js.map +0 -1
- package/dist/analysis/analyze_trade_heatmap.d.ts +0 -3
- package/dist/analysis/analyze_trade_heatmap.d.ts.map +0 -1
- package/dist/analysis/analyze_trade_heatmap.js +0 -367
- package/dist/analysis/analyze_trade_heatmap.js.map +0 -1
- package/dist/analysis/analyze_volatility.d.ts +0 -22
- package/dist/analysis/analyze_volatility.d.ts.map +0 -1
- package/dist/analysis/analyze_volatility.js +0 -172
- package/dist/analysis/analyze_volatility.js.map +0 -1
- package/dist/analysis/bot_fitting/backtest_ama_sweep.d.ts +0 -99
- package/dist/analysis/bot_fitting/backtest_ama_sweep.d.ts.map +0 -1
- package/dist/analysis/bot_fitting/backtest_ama_sweep.js +0 -804
- package/dist/analysis/bot_fitting/backtest_ama_sweep.js.map +0 -1
- package/dist/analysis/bot_fitting/backtest_bot_fitting.d.ts +0 -2
- package/dist/analysis/bot_fitting/backtest_bot_fitting.d.ts.map +0 -1
- package/dist/analysis/bot_fitting/backtest_bot_fitting.js +0 -347
- package/dist/analysis/bot_fitting/backtest_bot_fitting.js.map +0 -1
- package/dist/analysis/bot_fitting/shared_utils.d.ts +0 -15
- package/dist/analysis/bot_fitting/shared_utils.d.ts.map +0 -1
- package/dist/analysis/bot_fitting/shared_utils.js +0 -48
- package/dist/analysis/bot_fitting/shared_utils.js.map +0 -1
- package/dist/analysis/bot_key_utils.d.ts +0 -22
- package/dist/analysis/bot_key_utils.d.ts.map +0 -1
- package/dist/analysis/bot_key_utils.js +0 -162
- package/dist/analysis/bot_key_utils.js.map +0 -1
- package/dist/analysis/bot_usage/discover_bot_accounts.d.ts +0 -3
- package/dist/analysis/bot_usage/discover_bot_accounts.d.ts.map +0 -1
- package/dist/analysis/bot_usage/discover_bot_accounts.js +0 -498
- package/dist/analysis/bot_usage/discover_bot_accounts.js.map +0 -1
- package/dist/analysis/bot_usage/kibana_bot_queries.d.ts +0 -546
- package/dist/analysis/bot_usage/kibana_bot_queries.d.ts.map +0 -1
- package/dist/analysis/bot_usage/kibana_bot_queries.js +0 -427
- package/dist/analysis/bot_usage/kibana_bot_queries.js.map +0 -1
- package/dist/analysis/derivative_chart_generator.d.ts +0 -18
- package/dist/analysis/derivative_chart_generator.d.ts.map +0 -1
- package/dist/analysis/derivative_chart_generator.js +0 -896
- package/dist/analysis/derivative_chart_generator.js.map +0 -1
- package/dist/analysis/price_sources.d.ts +0 -34
- package/dist/analysis/price_sources.d.ts.map +0 -1
- package/dist/analysis/price_sources.js +0 -103
- package/dist/analysis/price_sources.js.map +0 -1
- package/dist/analysis/trade_profitability.d.ts +0 -115
- package/dist/analysis/trade_profitability.d.ts.map +0 -1
- package/dist/analysis/trade_profitability.js +0 -1247
- package/dist/analysis/trade_profitability.js.map +0 -1
- package/dist/analysis/tradingview/analyze_tradingview.d.ts +0 -36
- package/dist/analysis/tradingview/analyze_tradingview.d.ts.map +0 -1
- package/dist/analysis/tradingview/analyze_tradingview.js +0 -172
- package/dist/analysis/tradingview/analyze_tradingview.js.map +0 -1
- package/dist/analysis/trend_detection/derivative_analyzer.d.ts +0 -250
- package/dist/analysis/trend_detection/derivative_analyzer.d.ts.map +0 -1
- package/dist/analysis/trend_detection/derivative_analyzer.js +0 -903
- package/dist/analysis/trend_detection/derivative_analyzer.js.map +0 -1
- package/dist/analysis/trend_detection/dynamic_weight_chart_generator.d.ts +0 -6
- package/dist/analysis/trend_detection/dynamic_weight_chart_generator.d.ts.map +0 -1
- package/dist/analysis/trend_detection/dynamic_weight_chart_generator.js +0 -1450
- package/dist/analysis/trend_detection/dynamic_weight_chart_generator.js.map +0 -1
- package/dist/analysis/trend_detection/kalman_chart_generator.d.ts +0 -6
- package/dist/analysis/trend_detection/kalman_chart_generator.d.ts.map +0 -1
- package/dist/analysis/trend_detection/kalman_chart_generator.js +0 -408
- package/dist/analysis/trend_detection/kalman_chart_generator.js.map +0 -1
- package/dist/analysis/trend_detection/regime_chart_generator.d.ts +0 -6
- package/dist/analysis/trend_detection/regime_chart_generator.d.ts.map +0 -1
- package/dist/analysis/trend_detection/regime_chart_generator.js +0 -345
- package/dist/analysis/trend_detection/regime_chart_generator.js.map +0 -1
- package/dist/analysis/trend_detection/tests/test_kalman_trend.d.ts +0 -2
- package/dist/analysis/trend_detection/tests/test_kalman_trend.d.ts.map +0 -1
- package/dist/analysis/trend_detection/tests/test_kalman_trend.js +0 -130
- package/dist/analysis/trend_detection/tests/test_kalman_trend.js.map +0 -1
- package/dist/analysis/trend_detection/tests/test_kalman_velocity_smoothing.d.ts +0 -2
- package/dist/analysis/trend_detection/tests/test_kalman_velocity_smoothing.d.ts.map +0 -1
- package/dist/analysis/trend_detection/tests/test_kalman_velocity_smoothing.js +0 -38
- package/dist/analysis/trend_detection/tests/test_kalman_velocity_smoothing.js.map +0 -1
- package/dist/analysis/trend_detection/volatility_chart_generator.d.ts +0 -6
- package/dist/analysis/trend_detection/volatility_chart_generator.d.ts.map +0 -1
- package/dist/analysis/trend_detection/volatility_chart_generator.js +0 -732
- package/dist/analysis/trend_detection/volatility_chart_generator.js.map +0 -1
|
@@ -14,23 +14,61 @@
|
|
|
14
14
|
* SECTION 3: ORDER MANAGER CLASS
|
|
15
15
|
* ===============================================================================
|
|
16
16
|
*/
|
|
17
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
18
|
+
if (k2 === undefined) k2 = k;
|
|
19
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
20
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
21
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
22
|
+
}
|
|
23
|
+
Object.defineProperty(o, k2, desc);
|
|
24
|
+
}) : (function(o, m, k, k2) {
|
|
25
|
+
if (k2 === undefined) k2 = k;
|
|
26
|
+
o[k2] = m[k];
|
|
27
|
+
}));
|
|
28
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
29
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
30
|
+
}) : function(o, v) {
|
|
31
|
+
o["default"] = v;
|
|
32
|
+
});
|
|
33
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
34
|
+
var ownKeys = function(o) {
|
|
35
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
36
|
+
var ar = [];
|
|
37
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
38
|
+
return ar;
|
|
39
|
+
};
|
|
40
|
+
return ownKeys(o);
|
|
41
|
+
};
|
|
42
|
+
return function (mod) {
|
|
43
|
+
if (mod && mod.__esModule) return mod;
|
|
44
|
+
var result = {};
|
|
45
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
46
|
+
__setModuleDefault(result, mod);
|
|
47
|
+
return result;
|
|
48
|
+
};
|
|
49
|
+
})();
|
|
50
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
51
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
52
|
+
};
|
|
53
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
54
|
+
exports.OrderManager = void 0;
|
|
17
55
|
// ===============================================================================
|
|
18
56
|
// SECTION 1: EXTERNAL DEPENDENCIES
|
|
19
57
|
// ===============================================================================
|
|
20
|
-
const
|
|
21
|
-
const
|
|
22
|
-
const
|
|
23
|
-
const
|
|
24
|
-
const
|
|
25
|
-
const
|
|
26
|
-
const
|
|
27
|
-
const
|
|
28
|
-
const
|
|
29
|
-
const
|
|
30
|
-
const
|
|
31
|
-
const
|
|
32
|
-
const
|
|
33
|
-
const { toFiniteNumber
|
|
58
|
+
const system_1 = require("./utils/system");
|
|
59
|
+
const working_grid_1 = require("./working_grid");
|
|
60
|
+
const logger_1 = __importDefault(require("./logger"));
|
|
61
|
+
const async_lock_1 = __importDefault(require("./async_lock"));
|
|
62
|
+
const accounting_1 = __importDefault(require("./accounting"));
|
|
63
|
+
const strategy_1 = __importDefault(require("./strategy"));
|
|
64
|
+
const sync_engine_1 = __importDefault(require("./sync_engine"));
|
|
65
|
+
const grid_1 = require("./grid");
|
|
66
|
+
const Format = __importStar(require("./format"));
|
|
67
|
+
const constants_1 = require("../constants");
|
|
68
|
+
const math_1 = require("./utils/math");
|
|
69
|
+
const validate_1 = require("./utils/validate");
|
|
70
|
+
const errors_1 = require("../utils/errors");
|
|
71
|
+
const { toFiniteNumber } = Format;
|
|
34
72
|
// ===============================================================================
|
|
35
73
|
// SECTION 2: COW REBALANCE ENGINE
|
|
36
74
|
// ===============================================================================
|
|
@@ -86,7 +124,7 @@ class COWRebalanceEngine {
|
|
|
86
124
|
}
|
|
87
125
|
async execute({ masterGrid, gridVersion, boundaryIdx, funds, fills = [], excludeIds = new Set() }) {
|
|
88
126
|
const startTime = Date.now();
|
|
89
|
-
const workingGrid = new WorkingGrid(masterGrid, { baseVersion: gridVersion });
|
|
127
|
+
const workingGrid = new working_grid_1.WorkingGrid(masterGrid, { baseVersion: gridVersion });
|
|
90
128
|
const strategyParams = {
|
|
91
129
|
frozenMasterGrid: masterGrid,
|
|
92
130
|
config: this.config,
|
|
@@ -98,36 +136,36 @@ class COWRebalanceEngine {
|
|
|
98
136
|
};
|
|
99
137
|
const { targetGrid, boundaryIdx: targetBoundary } = this.strategy.calculateTargetGrid(strategyParams);
|
|
100
138
|
let dustThresholdPercent = this.config?.gridLimits?.PARTIAL_DUST_THRESHOLD_PERCENTAGE;
|
|
101
|
-
const reconcileResult = reconcileGrid(masterGrid, targetGrid, targetBoundary, {
|
|
139
|
+
const reconcileResult = (0, validate_1.reconcileGrid)(masterGrid, targetGrid, targetBoundary, {
|
|
102
140
|
logger: (msg, level) => this.logger?.log(msg, level),
|
|
103
141
|
dustThresholdPercent
|
|
104
142
|
});
|
|
105
143
|
if (reconcileResult.aborted) {
|
|
106
|
-
return buildAbortedResult(reconcileResult.reason);
|
|
144
|
+
return (0, validate_1.buildAbortedResult)(reconcileResult.reason);
|
|
107
145
|
}
|
|
108
|
-
const optimizedActions = optimizeRebalanceActions(reconcileResult.actions, masterGrid);
|
|
109
|
-
projectTargetToWorkingGrid(workingGrid, targetGrid, { actions: optimizedActions });
|
|
146
|
+
const optimizedActions = (0, validate_1.optimizeRebalanceActions)(reconcileResult.actions, masterGrid);
|
|
147
|
+
(0, validate_1.projectTargetToWorkingGrid)(workingGrid, targetGrid, { actions: optimizedActions });
|
|
110
148
|
const precisions = {
|
|
111
149
|
buyPrecision: this.assets?.assetB?.precision,
|
|
112
150
|
sellPrecision: this.assets?.assetA?.precision
|
|
113
151
|
};
|
|
114
|
-
const fundCheck = validateWorkingGridFunds(workingGrid, funds, precisions, this.assets);
|
|
152
|
+
const fundCheck = (0, validate_1.validateWorkingGridFunds)(workingGrid, funds, precisions, this.assets);
|
|
115
153
|
if (!fundCheck.isValid) {
|
|
116
154
|
this.logger?.log(`[COW] Fund validation failed: ${fundCheck.reason}`, 'warn');
|
|
117
|
-
return buildAbortedResult(fundCheck.reason);
|
|
155
|
+
return (0, validate_1.buildAbortedResult)(fundCheck.reason);
|
|
118
156
|
}
|
|
119
157
|
if (workingGrid.isStale()) {
|
|
120
158
|
const reason = workingGrid.getStaleReason() || 'Master grid changed during planning';
|
|
121
159
|
this.logger?.log(`[COW] Rebalance plan invalidated: ${reason}`, 'warn');
|
|
122
|
-
return buildAbortedResult(reason);
|
|
160
|
+
return (0, validate_1.buildAbortedResult)(reason);
|
|
123
161
|
}
|
|
124
|
-
const stateUpdates = buildStateUpdates(optimizedActions, masterGrid);
|
|
162
|
+
const stateUpdates = (0, validate_1.buildStateUpdates)(optimizedActions, masterGrid);
|
|
125
163
|
const duration = Date.now() - startTime;
|
|
126
164
|
if (duration > 100) {
|
|
127
165
|
this.logger?.log(`[COW] Rebalance planning took ${duration}ms`, 'warn');
|
|
128
166
|
}
|
|
129
167
|
this.logger?.log(`[COW] Plan: Actions=${optimizedActions.length}, StateUpdates=${stateUpdates.length}`, 'info');
|
|
130
|
-
return buildSuccessResult({
|
|
168
|
+
return (0, validate_1.buildSuccessResult)({
|
|
131
169
|
actions: optimizedActions,
|
|
132
170
|
stateUpdates,
|
|
133
171
|
workingGrid,
|
|
@@ -206,12 +244,12 @@ class OrderManager {
|
|
|
206
244
|
* @param {Object} [config] - Configuration overrides
|
|
207
245
|
*/
|
|
208
246
|
constructor(config = {}) {
|
|
209
|
-
this.config = { ...DEFAULT_CONFIG, ...config };
|
|
247
|
+
this.config = { ...constants_1.DEFAULT_CONFIG, ...config };
|
|
210
248
|
this.marketName = this.config.market || (this.config.assetA && this.config.assetB ? `${this.config.assetA}/${this.config.assetB}` : null);
|
|
211
249
|
const logFile = config.logFile || undefined;
|
|
212
250
|
const loggingConfig = this.config.logging;
|
|
213
|
-
this.logger = new
|
|
214
|
-
level: loggingConfig?.level ?? LOG_LEVEL,
|
|
251
|
+
this.logger = new logger_1.default('DEXBot', {
|
|
252
|
+
level: loggingConfig?.level ?? constants_1.LOG_LEVEL,
|
|
215
253
|
logFile,
|
|
216
254
|
configOverride: loggingConfig?.config ?? undefined
|
|
217
255
|
});
|
|
@@ -219,10 +257,10 @@ class OrderManager {
|
|
|
219
257
|
this.orders = Object.freeze(new Map());
|
|
220
258
|
this.boundaryIdx = null;
|
|
221
259
|
this.targetGrid = null;
|
|
222
|
-
this.accountant = new
|
|
223
|
-
this.strategy = new
|
|
224
|
-
this.sync = new
|
|
225
|
-
this._rebalanceState = REBALANCE_STATES.NORMAL;
|
|
260
|
+
this.accountant = new accounting_1.default(this);
|
|
261
|
+
this.strategy = new strategy_1.default(this);
|
|
262
|
+
this.sync = new sync_engine_1.default(this);
|
|
263
|
+
this._rebalanceState = constants_1.REBALANCE_STATES.NORMAL;
|
|
226
264
|
this._bootstrapping = false;
|
|
227
265
|
this._broadcastingFlag = false;
|
|
228
266
|
this._broadcastingStartedAt = 0;
|
|
@@ -243,14 +281,14 @@ class OrderManager {
|
|
|
243
281
|
// These are private implementation details and must NOT be mutated directly
|
|
244
282
|
// All external code must go through the COW pipeline
|
|
245
283
|
this._ordersByState = {
|
|
246
|
-
[ORDER_STATES.VIRTUAL]: new Set(),
|
|
247
|
-
[ORDER_STATES.ACTIVE]: new Set(),
|
|
248
|
-
[ORDER_STATES.PARTIAL]: new Set()
|
|
284
|
+
[constants_1.ORDER_STATES.VIRTUAL]: new Set(),
|
|
285
|
+
[constants_1.ORDER_STATES.ACTIVE]: new Set(),
|
|
286
|
+
[constants_1.ORDER_STATES.PARTIAL]: new Set()
|
|
249
287
|
};
|
|
250
288
|
this._ordersByType = {
|
|
251
|
-
[ORDER_TYPES.BUY]: new Set(),
|
|
252
|
-
[ORDER_TYPES.SELL]: new Set(),
|
|
253
|
-
[ORDER_TYPES.SPREAD]: new Set()
|
|
289
|
+
[constants_1.ORDER_TYPES.BUY]: new Set(),
|
|
290
|
+
[constants_1.ORDER_TYPES.SELL]: new Set(),
|
|
291
|
+
[constants_1.ORDER_TYPES.SPREAD]: new Set()
|
|
254
292
|
};
|
|
255
293
|
this.resetFunds();
|
|
256
294
|
this.btsBalance = { free: 0, total: 0, locked: 0 };
|
|
@@ -274,14 +312,14 @@ class OrderManager {
|
|
|
274
312
|
// Level 3: _syncLock (sync operations)
|
|
275
313
|
// Level 4: _fundLock (fund operations — innermost)
|
|
276
314
|
// Note: AsyncLock IS re-entrant (acquire detects nested calls via _holding).
|
|
277
|
-
this._divergenceLock = new
|
|
278
|
-
this._fillProcessingLock = new
|
|
279
|
-
this._gridLock = new
|
|
315
|
+
this._divergenceLock = new async_lock_1.default({ level: 0 });
|
|
316
|
+
this._fillProcessingLock = new async_lock_1.default({ level: 1 });
|
|
317
|
+
this._gridLock = new async_lock_1.default({
|
|
280
318
|
level: 2,
|
|
281
319
|
onContention: () => { this._metrics.gridLockContention++; }
|
|
282
320
|
});
|
|
283
|
-
this._syncLock = new
|
|
284
|
-
this._fundLock = new
|
|
321
|
+
this._syncLock = new async_lock_1.default({ level: 3 });
|
|
322
|
+
this._fundLock = new async_lock_1.default({ level: 4, timeout: 30000 });
|
|
285
323
|
this._recentlyRotatedOrderIds = new Set();
|
|
286
324
|
this._gridSidesUpdated = new Set();
|
|
287
325
|
this._pauseFundRecalc = 0;
|
|
@@ -329,7 +367,7 @@ class OrderManager {
|
|
|
329
367
|
}
|
|
330
368
|
_clearWorkingGridRef() {
|
|
331
369
|
this._currentWorkingGrid = null;
|
|
332
|
-
this._rebalanceState = REBALANCE_STATES.NORMAL;
|
|
370
|
+
this._rebalanceState = constants_1.REBALANCE_STATES.NORMAL;
|
|
333
371
|
}
|
|
334
372
|
_setRebalanceState(state) {
|
|
335
373
|
this._rebalanceState = state;
|
|
@@ -339,13 +377,13 @@ class OrderManager {
|
|
|
339
377
|
* @returns {boolean}
|
|
340
378
|
*/
|
|
341
379
|
isRebalancing() {
|
|
342
|
-
return this._rebalanceState === REBALANCE_STATES.REBALANCING;
|
|
380
|
+
return this._rebalanceState === constants_1.REBALANCE_STATES.REBALANCING;
|
|
343
381
|
}
|
|
344
382
|
/**
|
|
345
383
|
* @returns {boolean}
|
|
346
384
|
*/
|
|
347
385
|
isBroadcasting() {
|
|
348
|
-
return this._rebalanceState === REBALANCE_STATES.BROADCASTING;
|
|
386
|
+
return this._rebalanceState === constants_1.REBALANCE_STATES.BROADCASTING;
|
|
349
387
|
}
|
|
350
388
|
/**
|
|
351
389
|
* @returns {boolean}
|
|
@@ -451,7 +489,7 @@ class OrderManager {
|
|
|
451
489
|
* @returns {import('./types').ChainFundsSnapshot}
|
|
452
490
|
*/
|
|
453
491
|
getChainFundsSnapshot() {
|
|
454
|
-
const totals = computeChainFundTotals(this.accountTotals, this.funds?.committed?.chain);
|
|
492
|
+
const totals = (0, math_1.computeChainFundTotals)(this.accountTotals, this.funds?.committed?.chain);
|
|
455
493
|
const allocatedBuy = toFiniteNumber(this.funds?.allocated?.buy, totals.chainTotalBuy);
|
|
456
494
|
const allocatedSell = toFiniteNumber(this.funds?.allocated?.sell, totals.chainTotalSell);
|
|
457
495
|
const btsBalance = (this.config.assetA !== 'BTS' && this.config.assetB !== 'BTS')
|
|
@@ -463,12 +501,12 @@ class OrderManager {
|
|
|
463
501
|
* @param {number} [timeoutMs]
|
|
464
502
|
* @returns {Promise<void>}
|
|
465
503
|
*/
|
|
466
|
-
async waitForAccountTotals(timeoutMs = TIMING.ACCOUNT_TOTALS_TIMEOUT_MS) {
|
|
467
|
-
if (hasValidAccountTotals(this.accountTotals, true))
|
|
504
|
+
async waitForAccountTotals(timeoutMs = constants_1.TIMING.ACCOUNT_TOTALS_TIMEOUT_MS) {
|
|
505
|
+
if ((0, math_1.hasValidAccountTotals)(this.accountTotals, true))
|
|
468
506
|
return;
|
|
469
507
|
let waitPromise = null;
|
|
470
508
|
await this._fundLock.acquire(async () => {
|
|
471
|
-
if (hasValidAccountTotals(this.accountTotals, true))
|
|
509
|
+
if ((0, math_1.hasValidAccountTotals)(this.accountTotals, true))
|
|
472
510
|
return;
|
|
473
511
|
if (!this._accountTotalsPromise) {
|
|
474
512
|
this._accountTotalsPromise = new Promise((resolve) => {
|
|
@@ -515,12 +553,12 @@ class OrderManager {
|
|
|
515
553
|
if (!this.funds)
|
|
516
554
|
this.resetFunds();
|
|
517
555
|
await this._recalculateFunds();
|
|
518
|
-
if (hasValidAccountTotals(this.accountTotals, true) && typeof this._accountTotalsResolve === 'function') {
|
|
556
|
+
if ((0, math_1.hasValidAccountTotals)(this.accountTotals, true) && typeof this._accountTotalsResolve === 'function') {
|
|
519
557
|
try {
|
|
520
558
|
this._accountTotalsResolve();
|
|
521
559
|
}
|
|
522
560
|
catch (e) {
|
|
523
|
-
this.logger?.log?.(`Error resolving account totals promise: ${e
|
|
561
|
+
this.logger?.log?.(`Error resolving account totals promise: ${(0, errors_1.getErrorMessage)(e)}`, 'warn');
|
|
524
562
|
}
|
|
525
563
|
this._accountTotalsPromise = null;
|
|
526
564
|
this._accountTotalsResolve = null;
|
|
@@ -540,11 +578,11 @@ class OrderManager {
|
|
|
540
578
|
applyBotFundsAllocation() {
|
|
541
579
|
if (!this.config.botFunds || !this.accountTotals)
|
|
542
580
|
return;
|
|
543
|
-
const { chainTotalBuy, chainTotalSell } = computeChainFundTotals(this.accountTotals, this.funds?.committed?.chain);
|
|
581
|
+
const { chainTotalBuy, chainTotalSell } = (0, math_1.computeChainFundTotals)(this.accountTotals, this.funds?.committed?.chain);
|
|
544
582
|
const account = this.config.preferredAccount;
|
|
545
583
|
const botName = this.config.botKey;
|
|
546
|
-
const allocatedBuy = resolveConfigValueWithRegistry(this.config.botFunds.buy, chainTotalBuy, account, botName, 'buy');
|
|
547
|
-
const allocatedSell = resolveConfigValueWithRegistry(this.config.botFunds.sell, chainTotalSell, account, botName, 'sell');
|
|
584
|
+
const allocatedBuy = (0, math_1.resolveConfigValueWithRegistry)(this.config.botFunds.buy, chainTotalBuy, account, botName, 'buy');
|
|
585
|
+
const allocatedSell = (0, math_1.resolveConfigValueWithRegistry)(this.config.botFunds.sell, chainTotalSell, account, botName, 'sell');
|
|
548
586
|
if (allocatedBuy === 0 && typeof this.config.botFunds.buy === 'string' && this.config.botFunds.buy.trim().endsWith('%')) {
|
|
549
587
|
if (chainTotalBuy === 0)
|
|
550
588
|
this._triggerAccountTotalsFetchIfNeeded();
|
|
@@ -554,8 +592,8 @@ class OrderManager {
|
|
|
554
592
|
this._triggerAccountTotalsFetchIfNeeded();
|
|
555
593
|
}
|
|
556
594
|
this.funds.allocated = { buy: allocatedBuy, sell: allocatedSell };
|
|
557
|
-
const shouldCapBuy = allocatedBuy > 0 || isExplicitZeroAllocation(this.config.botFunds.buy);
|
|
558
|
-
const shouldCapSell = allocatedSell > 0 || isExplicitZeroAllocation(this.config.botFunds.sell);
|
|
595
|
+
const shouldCapBuy = allocatedBuy > 0 || (0, math_1.isExplicitZeroAllocation)(this.config.botFunds.buy);
|
|
596
|
+
const shouldCapSell = allocatedSell > 0 || (0, math_1.isExplicitZeroAllocation)(this.config.botFunds.sell);
|
|
559
597
|
if (shouldCapBuy)
|
|
560
598
|
this.funds.available.buy = Math.min(this.funds.available.buy, Math.max(0, allocatedBuy));
|
|
561
599
|
if (shouldCapSell)
|
|
@@ -610,10 +648,10 @@ class OrderManager {
|
|
|
610
648
|
this._pauseFundRecalc = 0;
|
|
611
649
|
this._pauseFundRecalcWatchdog = null;
|
|
612
650
|
this._recalculateFunds().catch((err) => {
|
|
613
|
-
this.logger?.log?.(`[MANAGER] Watchdog recalc failed: ${err
|
|
651
|
+
this.logger?.log?.(`[MANAGER] Watchdog recalc failed: ${(0, errors_1.getErrorMessage)(err)}`, 'error');
|
|
614
652
|
});
|
|
615
653
|
}
|
|
616
|
-
}, TIMING.SAFETY_PAUSE_TIMEOUT_MS);
|
|
654
|
+
}, constants_1.TIMING.SAFETY_PAUSE_TIMEOUT_MS);
|
|
617
655
|
}
|
|
618
656
|
}
|
|
619
657
|
/**
|
|
@@ -651,10 +689,10 @@ class OrderManager {
|
|
|
651
689
|
clearTimeout(this._pauseRecalcLoggingWatchdog);
|
|
652
690
|
}
|
|
653
691
|
this._pauseRecalcLoggingWatchdog = setTimeout(() => {
|
|
654
|
-
this.logger?.log?.(`[MANAGER] pauseRecalcLogging safety watchdog: forcing resume after ${TIMING.SAFETY_PAUSE_TIMEOUT_MS}ms`, 'warn');
|
|
692
|
+
this.logger?.log?.(`[MANAGER] pauseRecalcLogging safety watchdog: forcing resume after ${constants_1.TIMING.SAFETY_PAUSE_TIMEOUT_MS}ms`, 'warn');
|
|
655
693
|
this._pauseRecalcLogging = false;
|
|
656
694
|
this._pauseRecalcLoggingWatchdog = null;
|
|
657
|
-
}, TIMING.SAFETY_PAUSE_TIMEOUT_MS);
|
|
695
|
+
}, constants_1.TIMING.SAFETY_PAUSE_TIMEOUT_MS);
|
|
658
696
|
}
|
|
659
697
|
/**
|
|
660
698
|
* Resume recalc debug logging.
|
|
@@ -715,7 +753,7 @@ class OrderManager {
|
|
|
715
753
|
lockOrders(orderIds) {
|
|
716
754
|
if (!orderIds)
|
|
717
755
|
return;
|
|
718
|
-
const expiration = Date.now() + TIMING.LOCK_TIMEOUT_MS;
|
|
756
|
+
const expiration = Date.now() + constants_1.TIMING.LOCK_TIMEOUT_MS;
|
|
719
757
|
for (const id of orderIds)
|
|
720
758
|
if (id)
|
|
721
759
|
this.shadowOrderIds.set(id, expiration);
|
|
@@ -780,12 +818,12 @@ class OrderManager {
|
|
|
780
818
|
const updateOptions = this._normalizeOrderUpdateOptions(options);
|
|
781
819
|
const { skipAccounting, fee: normalizedFee } = updateOptions;
|
|
782
820
|
const oldOrder = this.orders.get(order.id);
|
|
783
|
-
const validation = validateOrder(order, oldOrder, context);
|
|
821
|
+
const validation = (0, validate_1.validateOrder)(order, oldOrder, context);
|
|
784
822
|
for (const warning of validation.warnings) {
|
|
785
823
|
this.logger.log(warning.message, 'warn');
|
|
786
824
|
}
|
|
787
825
|
if (!validation.isValid && validation.errors.length > 0) {
|
|
788
|
-
const fatalError = validation.errors.find(e => e.isFatal || e.code === 'ILLEGAL_SPREAD_STATE');
|
|
826
|
+
const fatalError = validation.errors.find((e) => e.isFatal || e.code === 'ILLEGAL_SPREAD_STATE');
|
|
789
827
|
if (fatalError) {
|
|
790
828
|
this.logger.log(fatalError.message, 'error');
|
|
791
829
|
this._lastIllegalState = {
|
|
@@ -806,24 +844,24 @@ class OrderManager {
|
|
|
806
844
|
// and _resolveBtsFeeLifecycle mutates btsFeeState on the order object.
|
|
807
845
|
let nextOrder = { ...validation.normalizedOrder };
|
|
808
846
|
// Apply phantom order auto-correction to the normalized order
|
|
809
|
-
const phantomError = validation.errors.find(e => e.code === 'PHANTOM_ORDER');
|
|
847
|
+
const phantomError = validation.errors.find((e) => e.code === 'PHANTOM_ORDER');
|
|
810
848
|
if (phantomError && phantomError.autoCorrect) {
|
|
811
849
|
nextOrder = { ...nextOrder, ...phantomError.autoCorrect };
|
|
812
850
|
}
|
|
813
851
|
if (this.accountant) {
|
|
814
852
|
await this.accountant.updateOptimisticFreeBalance(oldOrder, nextOrder, context, normalizedFee, skipAccounting);
|
|
815
853
|
}
|
|
816
|
-
const updatedOrder = deepFreeze({ ...nextOrder });
|
|
854
|
+
const updatedOrder = (0, system_1.deepFreeze)({ ...nextOrder });
|
|
817
855
|
const id = order.id;
|
|
818
|
-
Object.values(this._ordersByState).forEach(set => set.delete(id));
|
|
819
|
-
Object.values(this._ordersByType).forEach(set => set.delete(id));
|
|
856
|
+
Object.values(this._ordersByState).forEach((set) => set.delete(id));
|
|
857
|
+
Object.values(this._ordersByType).forEach((set) => set.delete(id));
|
|
820
858
|
if (this._ordersByState[updatedOrder.state]) {
|
|
821
859
|
this._ordersByState[updatedOrder.state].add(id);
|
|
822
860
|
}
|
|
823
861
|
if (this._ordersByType[updatedOrder.type]) {
|
|
824
862
|
this._ordersByType[updatedOrder.type].add(id);
|
|
825
863
|
}
|
|
826
|
-
const newMap = cloneMap(this.orders);
|
|
864
|
+
const newMap = (0, system_1.cloneMap)(this.orders);
|
|
827
865
|
newMap.set(id, updatedOrder);
|
|
828
866
|
this.orders = Object.freeze(newMap);
|
|
829
867
|
this._gridVersion++;
|
|
@@ -843,8 +881,8 @@ class OrderManager {
|
|
|
843
881
|
this._currentWorkingGrid.syncFromMaster(this.orders, orderId, this._gridVersion);
|
|
844
882
|
}
|
|
845
883
|
catch (syncErr) {
|
|
846
|
-
this._currentWorkingGrid.markStale(`working-grid sync failure: ${syncErr
|
|
847
|
-
this.logger.log(`[COW] Failed to sync working grid for order ${orderId}: ${syncErr
|
|
884
|
+
this._currentWorkingGrid.markStale(`working-grid sync failure: ${(0, errors_1.getErrorMessage)(syncErr)}`);
|
|
885
|
+
this.logger.log(`[COW] Failed to sync working grid for order ${orderId}: ${(0, errors_1.getErrorMessage)(syncErr)}`, 'warn');
|
|
848
886
|
}
|
|
849
887
|
}
|
|
850
888
|
/**
|
|
@@ -936,17 +974,17 @@ class OrderManager {
|
|
|
936
974
|
* @param {Object} [options]
|
|
937
975
|
* @returns {Promise<import('./types').CowRebalanceResult>}
|
|
938
976
|
*/
|
|
939
|
-
async processFilledOrders(orders, excl,
|
|
977
|
+
async processFilledOrders(orders, excl, _options) {
|
|
940
978
|
// Step 1: Handle Fills (Accounting & State Updates)
|
|
941
979
|
await this.strategy.processFillsOnly(orders, excl);
|
|
942
980
|
// Step 2: Trigger Safe Rebalance only for actual fills.
|
|
943
|
-
const triggerFills = orders.filter(f => !f.isPartial || f.isDelayedRotationTrigger);
|
|
981
|
+
const triggerFills = orders.filter((f) => !f.isPartial || f.isDelayedRotationTrigger);
|
|
944
982
|
const shouldRebalance = triggerFills.length > 0;
|
|
945
983
|
if (shouldRebalance) {
|
|
946
984
|
const rebalanceResult = await this.performSafeRebalance(orders, excl);
|
|
947
985
|
return rebalanceResult;
|
|
948
986
|
}
|
|
949
|
-
const workingGrid = new WorkingGrid(this.orders, { baseVersion: this._gridVersion });
|
|
987
|
+
const workingGrid = new working_grid_1.WorkingGrid(this.orders, { baseVersion: this._gridVersion });
|
|
950
988
|
return {
|
|
951
989
|
actions: [],
|
|
952
990
|
stateUpdates: [],
|
|
@@ -966,28 +1004,28 @@ class OrderManager {
|
|
|
966
1004
|
const buyCount = Math.max(0, toFiniteNumber(this.config.activeOrders?.buy, 1));
|
|
967
1005
|
// Get minimum sizes for validation
|
|
968
1006
|
const minOrderSizeFactor = this.config?.gridLimits?.MIN_ORDER_SIZE_FACTOR;
|
|
969
|
-
const minSellSize = getMinAbsoluteOrderSize(ORDER_TYPES.SELL, this.assets, minOrderSizeFactor);
|
|
970
|
-
const minBuySize = getMinAbsoluteOrderSize(ORDER_TYPES.BUY, this.assets, minOrderSizeFactor);
|
|
1007
|
+
const minSellSize = (0, math_1.getMinAbsoluteOrderSize)(constants_1.ORDER_TYPES.SELL, this.assets, minOrderSizeFactor);
|
|
1008
|
+
const minBuySize = (0, math_1.getMinAbsoluteOrderSize)(constants_1.ORDER_TYPES.BUY, this.assets, minOrderSizeFactor);
|
|
971
1009
|
// Use integer arithmetic for size comparisons to match blockchain behavior
|
|
972
1010
|
const sellPrecision = this.assets?.assetA?.precision;
|
|
973
1011
|
const buyPrecision = this.assets?.assetB?.precision;
|
|
974
|
-
const minSellSizeInt = floatToBlockchainInt(minSellSize, sellPrecision);
|
|
975
|
-
const minBuySizeInt = floatToBlockchainInt(minBuySize, buyPrecision);
|
|
1012
|
+
const minSellSizeInt = (0, math_1.floatToBlockchainInt)(minSellSize, sellPrecision);
|
|
1013
|
+
const minBuySizeInt = (0, math_1.floatToBlockchainInt)(minBuySize, buyPrecision);
|
|
976
1014
|
// Get closest virtual sells (lowest prices first = closest to market), limit to sellCount
|
|
977
|
-
const vSells = this.getOrdersByTypeAndState(ORDER_TYPES.SELL, ORDER_STATES.VIRTUAL)
|
|
1015
|
+
const vSells = this.getOrdersByTypeAndState(constants_1.ORDER_TYPES.SELL, constants_1.ORDER_STATES.VIRTUAL)
|
|
978
1016
|
.sort((a, b) => a.price - b.price)
|
|
979
1017
|
.slice(0, sellCount);
|
|
980
1018
|
// Filter by minimum size, then reverse for placement order (highest first)
|
|
981
1019
|
const validSells = vSells
|
|
982
|
-
.filter(o => floatToBlockchainInt(o.size, sellPrecision) >= minSellSizeInt)
|
|
1020
|
+
.filter((o) => (0, math_1.floatToBlockchainInt)(o.size, sellPrecision) >= minSellSizeInt)
|
|
983
1021
|
.sort((a, b) => b.price - a.price);
|
|
984
1022
|
// Get closest virtual buys (highest prices first = closest to market), limit to buyCount
|
|
985
|
-
const vBuys = this.getOrdersByTypeAndState(ORDER_TYPES.BUY, ORDER_STATES.VIRTUAL)
|
|
1023
|
+
const vBuys = this.getOrdersByTypeAndState(constants_1.ORDER_TYPES.BUY, constants_1.ORDER_STATES.VIRTUAL)
|
|
986
1024
|
.sort((a, b) => b.price - a.price)
|
|
987
1025
|
.slice(0, buyCount);
|
|
988
1026
|
// Filter by minimum size, then reverse for placement order (lowest first)
|
|
989
1027
|
const validBuys = vBuys
|
|
990
|
-
.filter(o => floatToBlockchainInt(o.size, buyPrecision) >= minBuySizeInt)
|
|
1028
|
+
.filter((o) => (0, math_1.floatToBlockchainInt)(o.size, buyPrecision) >= minBuySizeInt)
|
|
991
1029
|
.sort((a, b) => a.price - b.price);
|
|
992
1030
|
return [...validSells, ...validBuys];
|
|
993
1031
|
}
|
|
@@ -1018,7 +1056,7 @@ class OrderManager {
|
|
|
1018
1056
|
* @returns {Array<import('./types').Order>}
|
|
1019
1057
|
*/
|
|
1020
1058
|
getPartialOrdersOnSide(type) {
|
|
1021
|
-
return this.getOrdersByTypeAndState(type, ORDER_STATES.PARTIAL);
|
|
1059
|
+
return this.getOrdersByTypeAndState(type, constants_1.ORDER_STATES.PARTIAL);
|
|
1022
1060
|
}
|
|
1023
1061
|
/**
|
|
1024
1062
|
* @returns {boolean}
|
|
@@ -1077,14 +1115,14 @@ class OrderManager {
|
|
|
1077
1115
|
_repairIndices() {
|
|
1078
1116
|
try {
|
|
1079
1117
|
const rebuiltByState = {
|
|
1080
|
-
[ORDER_STATES.VIRTUAL]: new Set(),
|
|
1081
|
-
[ORDER_STATES.ACTIVE]: new Set(),
|
|
1082
|
-
[ORDER_STATES.PARTIAL]: new Set()
|
|
1118
|
+
[constants_1.ORDER_STATES.VIRTUAL]: new Set(),
|
|
1119
|
+
[constants_1.ORDER_STATES.ACTIVE]: new Set(),
|
|
1120
|
+
[constants_1.ORDER_STATES.PARTIAL]: new Set()
|
|
1083
1121
|
};
|
|
1084
1122
|
const rebuiltByType = {
|
|
1085
|
-
[ORDER_TYPES.BUY]: new Set(),
|
|
1086
|
-
[ORDER_TYPES.SELL]: new Set(),
|
|
1087
|
-
[ORDER_TYPES.SPREAD]: new Set()
|
|
1123
|
+
[constants_1.ORDER_TYPES.BUY]: new Set(),
|
|
1124
|
+
[constants_1.ORDER_TYPES.SELL]: new Set(),
|
|
1125
|
+
[constants_1.ORDER_TYPES.SPREAD]: new Set()
|
|
1088
1126
|
};
|
|
1089
1127
|
for (const [id, order] of this.orders) {
|
|
1090
1128
|
if (order && order.state && order.type) {
|
|
@@ -1105,7 +1143,7 @@ class OrderManager {
|
|
|
1105
1143
|
return false;
|
|
1106
1144
|
}
|
|
1107
1145
|
catch (e) {
|
|
1108
|
-
this.logger.log(`Index repair failed with exception: ${e
|
|
1146
|
+
this.logger.log(`Index repair failed with exception: ${(0, errors_1.getErrorMessage)(e)}`, 'error');
|
|
1109
1147
|
return false;
|
|
1110
1148
|
}
|
|
1111
1149
|
}
|
|
@@ -1131,29 +1169,29 @@ class OrderManager {
|
|
|
1131
1169
|
* @returns {Promise<Object>}
|
|
1132
1170
|
*/
|
|
1133
1171
|
async checkSpreadCondition(BitShares, batchCb) {
|
|
1134
|
-
return await checkSpreadCondition(this, BitShares, batchCb);
|
|
1172
|
+
return await (0, grid_1.checkSpreadCondition)(this, BitShares, batchCb);
|
|
1135
1173
|
}
|
|
1136
1174
|
/**
|
|
1137
1175
|
* @param {Function} batchCb - Batch callback
|
|
1138
1176
|
* @returns {Promise<Object>}
|
|
1139
1177
|
*/
|
|
1140
1178
|
async checkGridHealth(batchCb) {
|
|
1141
|
-
return await checkGridHealth(this, batchCb);
|
|
1179
|
+
return await (0, grid_1.checkGridHealth)(this, batchCb);
|
|
1142
1180
|
}
|
|
1143
1181
|
/**
|
|
1144
1182
|
* @returns {Object} Current spread calculation
|
|
1145
1183
|
*/
|
|
1146
1184
|
calculateCurrentSpread() {
|
|
1147
|
-
return calculateCurrentSpread(this);
|
|
1185
|
+
return (0, grid_1.calculateCurrentSpread)(this);
|
|
1148
1186
|
}
|
|
1149
1187
|
/**
|
|
1150
1188
|
* @returns {import('./types').DriftCheckResult}
|
|
1151
1189
|
*/
|
|
1152
1190
|
checkFundDriftAfterFills() {
|
|
1153
|
-
if (!this.assets || !hasValidAccountTotals(this.accountTotals)) {
|
|
1191
|
+
if (!this.assets || !(0, math_1.hasValidAccountTotals)(this.accountTotals)) {
|
|
1154
1192
|
return { isValid: true, reason: 'Skipped: missing assets or totals' };
|
|
1155
1193
|
}
|
|
1156
|
-
return checkFundDrift(this.orders, this.accountTotals, this.assets, this.config?.gridLimits ?? null);
|
|
1194
|
+
return (0, validate_1.checkFundDrift)(this.orders, this.accountTotals, this.assets, this.config?.gridLimits ?? null);
|
|
1157
1195
|
}
|
|
1158
1196
|
/**
|
|
1159
1197
|
* @param {Object|number} [pipelineSignals] - Pipeline state signals or queue length
|
|
@@ -1210,7 +1248,7 @@ class OrderManager {
|
|
|
1210
1248
|
if (!this._pipelineBlockedSince)
|
|
1211
1249
|
return false;
|
|
1212
1250
|
const age = Date.now() - this._pipelineBlockedSince;
|
|
1213
|
-
const timeoutMs = this.config?.pipelineTiming?.TIMEOUT_MS ?? PIPELINE_TIMING.TIMEOUT_MS;
|
|
1251
|
+
const timeoutMs = this.config?.pipelineTiming?.TIMEOUT_MS ?? constants_1.PIPELINE_TIMING.TIMEOUT_MS;
|
|
1214
1252
|
if (age < timeoutMs)
|
|
1215
1253
|
return false;
|
|
1216
1254
|
this.ordersNeedingPriceCorrection = [];
|
|
@@ -1224,7 +1262,7 @@ class OrderManager {
|
|
|
1224
1262
|
const blockedDuration = this._pipelineBlockedSince
|
|
1225
1263
|
? Date.now() - this._pipelineBlockedSince
|
|
1226
1264
|
: 0;
|
|
1227
|
-
const timeoutMs = this.config?.pipelineTiming?.TIMEOUT_MS ?? PIPELINE_TIMING.TIMEOUT_MS;
|
|
1265
|
+
const timeoutMs = this.config?.pipelineTiming?.TIMEOUT_MS ?? constants_1.PIPELINE_TIMING.TIMEOUT_MS;
|
|
1228
1266
|
return {
|
|
1229
1267
|
isBlocked: this._pipelineBlockedSince !== null,
|
|
1230
1268
|
blockedDurationMs: blockedDuration,
|
|
@@ -1240,7 +1278,7 @@ class OrderManager {
|
|
|
1240
1278
|
* @returns {Object}
|
|
1241
1279
|
*/
|
|
1242
1280
|
reconcileGrid(targetGrid, targetBoundary) {
|
|
1243
|
-
return reconcileGrid(this.orders, targetGrid, targetBoundary, {
|
|
1281
|
+
return (0, validate_1.reconcileGrid)(this.orders, targetGrid, targetBoundary, {
|
|
1244
1282
|
logger: (msg, level) => this.logger.log(msg, level),
|
|
1245
1283
|
dustThresholdPercent: this.config?.gridLimits?.PARTIAL_DUST_THRESHOLD_PERCENTAGE
|
|
1246
1284
|
});
|
|
@@ -1259,9 +1297,9 @@ class OrderManager {
|
|
|
1259
1297
|
async _applySafeRebalanceCOW(fills = [], excludeIds = new Set()) {
|
|
1260
1298
|
const cowEngine = this._getCOWEngine();
|
|
1261
1299
|
if (!cowEngine) {
|
|
1262
|
-
return buildAbortedResult('COW Engine not initialized (assets not available)');
|
|
1300
|
+
return (0, validate_1.buildAbortedResult)('COW Engine not initialized (assets not available)');
|
|
1263
1301
|
}
|
|
1264
|
-
this._setRebalanceState(REBALANCE_STATES.REBALANCING);
|
|
1302
|
+
this._setRebalanceState(constants_1.REBALANCE_STATES.REBALANCING);
|
|
1265
1303
|
const result = await cowEngine.execute({
|
|
1266
1304
|
masterGrid: this.orders,
|
|
1267
1305
|
gridVersion: this._gridVersion,
|
|
@@ -1281,22 +1319,22 @@ class OrderManager {
|
|
|
1281
1319
|
const result = this.reconcileGrid(targetGrid, targetBoundary);
|
|
1282
1320
|
if (result.aborted)
|
|
1283
1321
|
return result;
|
|
1284
|
-
const actions = optimizeRebalanceActions(result.actions || [], this.orders);
|
|
1285
|
-
projectTargetToWorkingGrid(workingGrid, targetGrid, { actions });
|
|
1322
|
+
const actions = (0, validate_1.optimizeRebalanceActions)(result.actions || [], this.orders);
|
|
1323
|
+
(0, validate_1.projectTargetToWorkingGrid)(workingGrid, targetGrid, { actions });
|
|
1286
1324
|
return {
|
|
1287
1325
|
...result,
|
|
1288
1326
|
actions,
|
|
1289
|
-
...summarizeActions(actions)
|
|
1327
|
+
...(0, validate_1.summarizeActions)(actions)
|
|
1290
1328
|
};
|
|
1291
1329
|
}
|
|
1292
1330
|
_validateWorkingGridFunds(workingGrid, projectedFunds) {
|
|
1293
|
-
return validateWorkingGridFunds(workingGrid, projectedFunds, {
|
|
1331
|
+
return (0, validate_1.validateWorkingGridFunds)(workingGrid, projectedFunds, {
|
|
1294
1332
|
buyPrecision: this.assets?.assetB?.precision,
|
|
1295
1333
|
sellPrecision: this.assets?.assetA?.precision
|
|
1296
1334
|
}, this.assets);
|
|
1297
1335
|
}
|
|
1298
1336
|
_calculateRequiredFundsFromGrid(workingGrid, precisions = {}) {
|
|
1299
|
-
return calculateRequiredFunds(workingGrid, {
|
|
1337
|
+
return (0, validate_1.calculateRequiredFunds)(workingGrid, {
|
|
1300
1338
|
buyPrecision: precisions.buyPrecision || this.assets?.assetB?.precision,
|
|
1301
1339
|
sellPrecision: precisions.sellPrecision || this.assets?.assetA?.precision
|
|
1302
1340
|
});
|
|
@@ -1326,12 +1364,12 @@ class OrderManager {
|
|
|
1326
1364
|
};
|
|
1327
1365
|
}
|
|
1328
1366
|
_buildStateUpdates(actions, masterGrid) {
|
|
1329
|
-
return buildStateUpdates(actions, masterGrid);
|
|
1367
|
+
return (0, validate_1.buildStateUpdates)(actions, masterGrid);
|
|
1330
1368
|
}
|
|
1331
1369
|
_buildAbortedCOWResult(reason) {
|
|
1332
|
-
return buildAbortedResult(reason);
|
|
1370
|
+
return (0, validate_1.buildAbortedResult)(reason);
|
|
1333
1371
|
}
|
|
1334
|
-
async _commitWorkingGrid(workingGrid,
|
|
1372
|
+
async _commitWorkingGrid(workingGrid, _workingIndexes, workingBoundary, options = {}) {
|
|
1335
1373
|
const { skipRecalc } = this._normalizeCommitOptions(options);
|
|
1336
1374
|
const startTime = Date.now();
|
|
1337
1375
|
const stats = workingGrid.getMemoryStats();
|
|
@@ -1341,11 +1379,11 @@ class OrderManager {
|
|
|
1341
1379
|
comparePrecisions = this._getCowComparePrecisions();
|
|
1342
1380
|
}
|
|
1343
1381
|
catch (precisionErr) {
|
|
1344
|
-
this.logger.log(`[COW] ${precisionErr
|
|
1382
|
+
this.logger.log(`[COW] ${(0, errors_1.getErrorMessage)(precisionErr)}`, 'error');
|
|
1345
1383
|
this._clearWorkingGridRef();
|
|
1346
1384
|
return false;
|
|
1347
1385
|
}
|
|
1348
|
-
const preCommitGuard = evaluateCommit(workingGrid, {
|
|
1386
|
+
const preCommitGuard = (0, validate_1.evaluateCommit)(workingGrid, {
|
|
1349
1387
|
hasLock: false,
|
|
1350
1388
|
currentVersion: this._gridVersion,
|
|
1351
1389
|
masterGrid: this.orders,
|
|
@@ -1357,7 +1395,7 @@ class OrderManager {
|
|
|
1357
1395
|
return false;
|
|
1358
1396
|
}
|
|
1359
1397
|
await this._gridLock.acquire(async () => {
|
|
1360
|
-
const lockCommitGuard = evaluateCommit(workingGrid, {
|
|
1398
|
+
const lockCommitGuard = (0, validate_1.evaluateCommit)(workingGrid, {
|
|
1361
1399
|
hasLock: true,
|
|
1362
1400
|
currentVersion: this._gridVersion,
|
|
1363
1401
|
masterGrid: this.orders,
|
|
@@ -1372,9 +1410,9 @@ class OrderManager {
|
|
|
1372
1410
|
const finalMap = workingGrid.toMap();
|
|
1373
1411
|
// RC-4: Deep-freeze all modified orders before committing to master state
|
|
1374
1412
|
// Ensures COW immutability invariants are maintained for all grid entries.
|
|
1375
|
-
for (const [
|
|
1413
|
+
for (const [, order] of finalMap.entries()) {
|
|
1376
1414
|
if (order && !Object.isFrozen(order)) {
|
|
1377
|
-
deepFreeze(order);
|
|
1415
|
+
(0, system_1.deepFreeze)(order);
|
|
1378
1416
|
}
|
|
1379
1417
|
}
|
|
1380
1418
|
this.orders = Object.freeze(finalMap);
|
|
@@ -1386,7 +1424,7 @@ class OrderManager {
|
|
|
1386
1424
|
// avoid the intermediate empty state that clear() creates — a crash
|
|
1387
1425
|
// during clear()+repopulate would lose all committed IDs.
|
|
1388
1426
|
const newCommittedIds = new Set();
|
|
1389
|
-
for (const [
|
|
1427
|
+
for (const [, order] of finalMap.entries()) {
|
|
1390
1428
|
if (order.orderId)
|
|
1391
1429
|
newCommittedIds.add(order.orderId);
|
|
1392
1430
|
}
|
|
@@ -1394,14 +1432,14 @@ class OrderManager {
|
|
|
1394
1432
|
this._committedOrderIdsBuiltAt = Date.now();
|
|
1395
1433
|
const freshIndexes = workingGrid.getIndexes();
|
|
1396
1434
|
this._ordersByState = {
|
|
1397
|
-
[ORDER_STATES.VIRTUAL]: freshIndexes[ORDER_STATES.VIRTUAL] || new Set(),
|
|
1398
|
-
[ORDER_STATES.ACTIVE]: freshIndexes[ORDER_STATES.ACTIVE] || new Set(),
|
|
1399
|
-
[ORDER_STATES.PARTIAL]: freshIndexes[ORDER_STATES.PARTIAL] || new Set()
|
|
1435
|
+
[constants_1.ORDER_STATES.VIRTUAL]: freshIndexes[constants_1.ORDER_STATES.VIRTUAL] || new Set(),
|
|
1436
|
+
[constants_1.ORDER_STATES.ACTIVE]: freshIndexes[constants_1.ORDER_STATES.ACTIVE] || new Set(),
|
|
1437
|
+
[constants_1.ORDER_STATES.PARTIAL]: freshIndexes[constants_1.ORDER_STATES.PARTIAL] || new Set()
|
|
1400
1438
|
};
|
|
1401
1439
|
this._ordersByType = {
|
|
1402
|
-
[ORDER_TYPES.BUY]: freshIndexes[ORDER_TYPES.BUY] || new Set(),
|
|
1403
|
-
[ORDER_TYPES.SELL]: freshIndexes[ORDER_TYPES.SELL] || new Set(),
|
|
1404
|
-
[ORDER_TYPES.SPREAD]: freshIndexes[ORDER_TYPES.SPREAD] || new Set()
|
|
1440
|
+
[constants_1.ORDER_TYPES.BUY]: freshIndexes[constants_1.ORDER_TYPES.BUY] || new Set(),
|
|
1441
|
+
[constants_1.ORDER_TYPES.SELL]: freshIndexes[constants_1.ORDER_TYPES.SELL] || new Set(),
|
|
1442
|
+
[constants_1.ORDER_TYPES.SPREAD]: freshIndexes[constants_1.ORDER_TYPES.SPREAD] || new Set()
|
|
1405
1443
|
};
|
|
1406
1444
|
});
|
|
1407
1445
|
if (!committed) {
|
|
@@ -1421,12 +1459,12 @@ class OrderManager {
|
|
|
1421
1459
|
}
|
|
1422
1460
|
const duration = Date.now() - startTime;
|
|
1423
1461
|
this.logger.log(`[COW] Grid committed in ${duration}ms`, 'debug');
|
|
1424
|
-
if (stats.size > COW_PERFORMANCE.GRID_MEMORY_WARNING) {
|
|
1462
|
+
if (stats.size > constants_1.COW_PERFORMANCE.GRID_MEMORY_WARNING) {
|
|
1425
1463
|
this.logger.log(`[COW] Warning: Large grid size (${stats.size} orders). Peak memory: ~${Math.round(stats.estimatedBytes / 1024)}KB`, 'warn');
|
|
1426
1464
|
}
|
|
1427
1465
|
}
|
|
1428
1466
|
catch (recalcErr) {
|
|
1429
|
-
this.logger.log(`[COW] Fund recalculation failed post-commit: ${recalcErr
|
|
1467
|
+
this.logger.log(`[COW] Fund recalculation failed post-commit: ${(0, errors_1.getErrorMessage)(recalcErr)}`, 'error');
|
|
1430
1468
|
this._recoveryState = { ...this._recoveryState, lastFailureAt: Date.now() };
|
|
1431
1469
|
}
|
|
1432
1470
|
finally {
|
|
@@ -1440,7 +1478,7 @@ class OrderManager {
|
|
|
1440
1478
|
* @returns {import('./types').PersistenceValidationResult}
|
|
1441
1479
|
*/
|
|
1442
1480
|
validateGridStateForPersistence(options = {}) {
|
|
1443
|
-
const result = validateGridForPersistence(this.orders, this.accountTotals);
|
|
1481
|
+
const result = (0, validate_1.validateGridForPersistence)(this.orders, this.accountTotals);
|
|
1444
1482
|
const allowBootstrapTransient = options.allowBootstrapTransient !== false;
|
|
1445
1483
|
if (!result.isValid && allowBootstrapTransient && this._bootstrapping) {
|
|
1446
1484
|
this.logger.log(`[BOOTSTRAP] Transient state (expected): ${result.reason}`, 'debug');
|
|
@@ -1483,7 +1521,7 @@ class OrderManager {
|
|
|
1483
1521
|
this.logger.log(`[PERSISTENCE-GATE] Skipping persistence of corrupted state: ${validation.reason}`, 'warn');
|
|
1484
1522
|
return validation;
|
|
1485
1523
|
}
|
|
1486
|
-
await persistGridSnapshot(this, this.accountOrders, snapshotOrders, recentFillKeys);
|
|
1524
|
+
await (0, system_1.persistGridSnapshot)(this, this.accountOrders, snapshotOrders, recentFillKeys);
|
|
1487
1525
|
// On a successful live-grid persist (the default — no explicit
|
|
1488
1526
|
// snapshotOrders was passed in), clear the dirty flag so that
|
|
1489
1527
|
// a subsequent end-of-tick flushGridDirty() call sees the grid
|
|
@@ -1514,10 +1552,10 @@ class OrderManager {
|
|
|
1514
1552
|
};
|
|
1515
1553
|
}
|
|
1516
1554
|
_projectTargetToWorkingGrid(workingGrid, targetGrid) {
|
|
1517
|
-
return projectTargetToWorkingGrid(workingGrid, targetGrid);
|
|
1555
|
+
return (0, validate_1.projectTargetToWorkingGrid)(workingGrid, targetGrid);
|
|
1518
1556
|
}
|
|
1519
1557
|
_summarizeCowActions(actions) {
|
|
1520
|
-
return summarizeActions(actions);
|
|
1558
|
+
return (0, validate_1.summarizeActions)(actions);
|
|
1521
1559
|
}
|
|
1522
1560
|
_evaluateWorkingGridCommit(workingGrid, hasLock = false) {
|
|
1523
1561
|
let comparePrecisions;
|
|
@@ -1527,11 +1565,11 @@ class OrderManager {
|
|
|
1527
1565
|
catch (precisionErr) {
|
|
1528
1566
|
return {
|
|
1529
1567
|
canCommit: false,
|
|
1530
|
-
reason: precisionErr
|
|
1568
|
+
reason: (0, errors_1.getErrorMessage)(precisionErr),
|
|
1531
1569
|
level: 'error'
|
|
1532
1570
|
};
|
|
1533
1571
|
}
|
|
1534
|
-
return evaluateCommit(workingGrid, {
|
|
1572
|
+
return (0, validate_1.evaluateCommit)(workingGrid, {
|
|
1535
1573
|
hasLock,
|
|
1536
1574
|
currentVersion: this._gridVersion,
|
|
1537
1575
|
masterGrid: this.orders,
|
|
@@ -1590,5 +1628,5 @@ class OrderManager {
|
|
|
1590
1628
|
};
|
|
1591
1629
|
}
|
|
1592
1630
|
}
|
|
1593
|
-
|
|
1631
|
+
exports.OrderManager = OrderManager;
|
|
1594
1632
|
//# sourceMappingURL=manager.js.map
|