dexbot 1.3.3 → 1.4.1
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 +21 -22
- 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 -494
- package/dist/modules/constants.d.ts.map +1 -1
- package/dist/modules/constants.js +69 -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 +262 -81
- package/dist/modules/dexbot_class.d.ts.map +1 -1
- package/dist/modules/dexbot_class.js +156 -123
- package/dist/modules/dexbot_class.js.map +1 -1
- package/dist/modules/dexbot_cow_runtime.d.ts +12 -9
- package/dist/modules/dexbot_cow_runtime.d.ts.map +1 -1
- package/dist/modules/dexbot_cow_runtime.js +144 -63
- package/dist/modules/dexbot_cow_runtime.js.map +1 -1
- 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 +5 -20
- package/dist/modules/dexbot_fill_runtime.d.ts.map +1 -1
- package/dist/modules/dexbot_fill_runtime.js +55 -116
- package/dist/modules/dexbot_fill_runtime.js.map +1 -1
- package/dist/modules/dexbot_maintenance_runtime.d.ts +12 -12
- package/dist/modules/dexbot_maintenance_runtime.d.ts.map +1 -1
- package/dist/modules/dexbot_maintenance_runtime.js +55 -45
- package/dist/modules/dexbot_maintenance_runtime.js.map +1 -1
- package/dist/modules/dexbot_startup_runtime.d.ts +2 -6
- package/dist/modules/dexbot_startup_runtime.d.ts.map +1 -1
- package/dist/modules/dexbot_startup_runtime.js +122 -91
- package/dist/modules/dexbot_startup_runtime.js.map +1 -1
- package/dist/modules/dexbot_state_recovery.d.ts +11 -24
- package/dist/modules/dexbot_state_recovery.d.ts.map +1 -1
- package/dist/modules/dexbot_state_recovery.js +62 -28
- package/dist/modules/dexbot_state_recovery.js.map +1 -1
- 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 -21
- 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 -14
- 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 -19
- 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 -33
- 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 -38
- 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 +346 -212
- 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 +80 -23
- 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 +159 -73
- 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 +103 -45
- package/dist/modules/order/utils/system.d.ts.map +1 -1
- package/dist/modules/order/utils/system.js +271 -150
- package/dist/modules/order/utils/system.js.map +1 -1
- package/dist/modules/order/utils/validate.d.ts +35 -47
- package/dist/modules/order/utils/validate.d.ts.map +1 -1
- package/dist/modules/order/utils/validate.js +233 -116
- 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 +50 -56
- package/dist/modules/paths.d.ts.map +1 -1
- package/dist/modules/paths.js +66 -57
- 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/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 +1 -1
- 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
|
@@ -29,12 +29,13 @@
|
|
|
29
29
|
* SECTION 4: GRID UTILITIES (1 function)
|
|
30
30
|
* - syncBoundaryToFunds(manager) - Sync boundary position to available funds
|
|
31
31
|
*
|
|
32
|
-
* SECTION 5: UI & INTERACTIVE UTILITIES (
|
|
32
|
+
* SECTION 5: UI & INTERACTIVE UTILITIES (6 functions)
|
|
33
33
|
* - ensureProfilesDirectory(profilesDir) - Ensure profiles directory exists
|
|
34
34
|
* - sleep(ms) - Pause execution for specified duration
|
|
35
35
|
* - readInput(prompt, options) - Read user input from stdin
|
|
36
36
|
* - readPassword(prompt) - Read password with masked echo
|
|
37
37
|
* - withRetry(fn, options) - Execute async function with exponential backoff
|
|
38
|
+
* - withBlockchainRetry(fn, label, options) - Blockchain op with timeout + retry + node failover
|
|
38
39
|
*
|
|
39
40
|
* SECTION 6: GENERAL UTILITIES (5 functions)
|
|
40
41
|
* - resolveAccountRef(manager, account) - Resolve best account reference
|
|
@@ -45,23 +46,83 @@
|
|
|
45
46
|
*
|
|
46
47
|
* ===============================================================================
|
|
47
48
|
*/
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
49
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
50
|
+
if (k2 === undefined) k2 = k;
|
|
51
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
52
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
53
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
54
|
+
}
|
|
55
|
+
Object.defineProperty(o, k2, desc);
|
|
56
|
+
}) : (function(o, m, k, k2) {
|
|
57
|
+
if (k2 === undefined) k2 = k;
|
|
58
|
+
o[k2] = m[k];
|
|
59
|
+
}));
|
|
60
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
61
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
62
|
+
}) : function(o, v) {
|
|
63
|
+
o["default"] = v;
|
|
64
|
+
});
|
|
65
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
66
|
+
var ownKeys = function(o) {
|
|
67
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
68
|
+
var ar = [];
|
|
69
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
70
|
+
return ar;
|
|
71
|
+
};
|
|
72
|
+
return ownKeys(o);
|
|
73
|
+
};
|
|
74
|
+
return function (mod) {
|
|
75
|
+
if (mod && mod.__esModule) return mod;
|
|
76
|
+
var result = {};
|
|
77
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
78
|
+
__setModuleDefault(result, mod);
|
|
79
|
+
return result;
|
|
80
|
+
};
|
|
81
|
+
})();
|
|
82
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
83
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
84
|
+
};
|
|
85
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
86
|
+
exports.ensureDir = exports.derivePrice = exports.derivePoolPrice = exports.deriveMarketPrice = exports.lookupAsset = void 0;
|
|
87
|
+
exports.resolveLiquidityPoolByShareAsset = resolveLiquidityPoolByShareAsset;
|
|
88
|
+
exports.deriveLiquidityPoolTokenValue = deriveLiquidityPoolTokenValue;
|
|
89
|
+
exports.loadAmaCenterSnapshot = loadAmaCenterSnapshot;
|
|
90
|
+
exports.loadAmaCenterPrice = loadAmaCenterPrice;
|
|
91
|
+
exports._loadFeeCacheFromDisk = _loadFeeCacheFromDisk;
|
|
92
|
+
exports._saveFeeCacheToDisk = _saveFeeCacheToDisk;
|
|
93
|
+
exports.initializeFeeCache = initializeFeeCache;
|
|
94
|
+
exports.persistGridSnapshot = persistGridSnapshot;
|
|
95
|
+
exports.retryPersistenceIfNeeded = retryPersistenceIfNeeded;
|
|
96
|
+
exports.applyGridDivergenceCorrections = applyGridDivergenceCorrections;
|
|
97
|
+
exports.syncBoundaryToFunds = syncBoundaryToFunds;
|
|
98
|
+
exports.ensureProfilesDirectory = ensureProfilesDirectory;
|
|
99
|
+
exports.sleep = sleep;
|
|
100
|
+
exports.readInput = readInput;
|
|
101
|
+
exports.readPassword = readPassword;
|
|
102
|
+
exports.withRetry = withRetry;
|
|
103
|
+
exports.withBlockchainRetry = withBlockchainRetry;
|
|
104
|
+
exports.resolveAccountRef = resolveAccountRef;
|
|
105
|
+
exports.deepFreeze = deepFreeze;
|
|
106
|
+
exports.cloneMap = cloneMap;
|
|
107
|
+
exports.parseJsonWithComments = parseJsonWithComments;
|
|
108
|
+
const path_api_1 = require("../../path_api");
|
|
109
|
+
const storage_1 = require("../../storage");
|
|
110
|
+
const storage = (0, storage_1.getStorage)();
|
|
111
|
+
const constants_1 = require("../../constants");
|
|
112
|
+
const paths_1 = require("../../paths");
|
|
113
|
+
const format_1 = require("../format");
|
|
114
|
+
const MathUtils = __importStar(require("./math"));
|
|
115
|
+
const OrderUtils = __importStar(require("./order"));
|
|
116
|
+
const logger_1 = __importDefault(require("../../logger"));
|
|
117
|
+
const runtime_1 = require("../../runtime");
|
|
118
|
+
const fs_utils_1 = require("../../utils/fs_utils");
|
|
119
|
+
Object.defineProperty(exports, "ensureDir", { enumerable: true, get: function () { return fs_utils_1.ensureDir; } });
|
|
120
|
+
const errors_1 = require("../../utils/errors");
|
|
121
|
+
const systemLogger = new logger_1.default('System');
|
|
61
122
|
function _debugLogAndNull(method, symA, symB) {
|
|
62
123
|
return (err) => {
|
|
63
124
|
// debug level: underlying derivePoolPrice/deriveMarketPrice already log at warn
|
|
64
|
-
systemLogger.debug(`derivePrice(${method}) for ${symA}/${symB}: ${err
|
|
125
|
+
systemLogger.debug(`derivePrice(${method}) for ${symA}/${symB}: ${(0, errors_1.getErrorMessage)(err)}`);
|
|
65
126
|
return null;
|
|
66
127
|
};
|
|
67
128
|
}
|
|
@@ -107,11 +168,12 @@ const lookupAsset = async (BitShares, s) => {
|
|
|
107
168
|
}
|
|
108
169
|
}
|
|
109
170
|
catch (e) {
|
|
110
|
-
systemLogger.debug(`lookupAsset: method failed for ${s}: ${e
|
|
171
|
+
systemLogger.debug(`lookupAsset: method failed for ${s}: ${(0, errors_1.getErrorMessage)(e)}`);
|
|
111
172
|
}
|
|
112
173
|
}
|
|
113
174
|
throw new Error(`CRITICAL: Cannot fetch asset precision for '${s}'`);
|
|
114
175
|
};
|
|
176
|
+
exports.lookupAsset = lookupAsset;
|
|
115
177
|
/**
|
|
116
178
|
* Derive price from BitShares DEX order book.
|
|
117
179
|
* Returns price in B/A format (units of asset B per 1 unit of asset A).
|
|
@@ -125,8 +187,8 @@ const lookupAsset = async (BitShares, s) => {
|
|
|
125
187
|
const deriveMarketPrice = async (BitShares, symA, symB) => {
|
|
126
188
|
try {
|
|
127
189
|
const [aMeta, bMeta] = await Promise.all([
|
|
128
|
-
lookupAsset(BitShares, symA),
|
|
129
|
-
lookupAsset(BitShares, symB)
|
|
190
|
+
(0, exports.lookupAsset)(BitShares, symA),
|
|
191
|
+
(0, exports.lookupAsset)(BitShares, symB)
|
|
130
192
|
]);
|
|
131
193
|
if (!aMeta?.id || !bMeta?.id)
|
|
132
194
|
return null;
|
|
@@ -135,23 +197,23 @@ const deriveMarketPrice = async (BitShares, symA, symB) => {
|
|
|
135
197
|
let mid = null;
|
|
136
198
|
if (typeof BitShares.db?.get_order_book === 'function') {
|
|
137
199
|
try {
|
|
138
|
-
const ob = await BitShares.db.get_order_book(baseId, quoteId, API_LIMITS.ORDERBOOK_DEPTH);
|
|
139
|
-
const bestBid = isValidNumber(ob.bids?.[0]?.price) ? toFiniteNumber(ob.bids[0].price) : null;
|
|
140
|
-
const bestAsk = isValidNumber(ob.asks?.[0]?.price) ? toFiniteNumber(ob.asks[0].price) : null;
|
|
200
|
+
const ob = await BitShares.db.get_order_book(baseId, quoteId, constants_1.API_LIMITS.ORDERBOOK_DEPTH);
|
|
201
|
+
const bestBid = (0, format_1.isValidNumber)(ob.bids?.[0]?.price) ? (0, format_1.toFiniteNumber)(ob.bids[0].price) : null;
|
|
202
|
+
const bestAsk = (0, format_1.isValidNumber)(ob.asks?.[0]?.price) ? (0, format_1.toFiniteNumber)(ob.asks[0].price) : null;
|
|
141
203
|
if (bestBid !== null && bestAsk !== null)
|
|
142
204
|
mid = (bestBid + bestAsk) / 2;
|
|
143
205
|
}
|
|
144
206
|
catch (e) {
|
|
145
|
-
systemLogger.debug(`deriveMarketPrice: get_order_book failed for ${symA}/${symB}: ${e
|
|
207
|
+
systemLogger.debug(`deriveMarketPrice: get_order_book failed for ${symA}/${symB}: ${(0, errors_1.getErrorMessage)(e)}`);
|
|
146
208
|
}
|
|
147
209
|
}
|
|
148
210
|
if (mid === null && typeof BitShares.db?.get_ticker === 'function') {
|
|
149
211
|
try {
|
|
150
212
|
const t = await BitShares.db.get_ticker(baseId, quoteId);
|
|
151
|
-
mid = isValidNumber(t?.latest) ? toFiniteNumber(t.latest) : (isValidNumber(t?.latest_price) ? toFiniteNumber(t.latest_price) : null);
|
|
213
|
+
mid = (0, format_1.isValidNumber)(t?.latest) ? (0, format_1.toFiniteNumber)(t.latest) : ((0, format_1.isValidNumber)(t?.latest_price) ? (0, format_1.toFiniteNumber)(t.latest_price) : null);
|
|
152
214
|
}
|
|
153
215
|
catch (err) {
|
|
154
|
-
systemLogger.debug(`deriveMarketPrice: get_ticker failed for ${symA}/${symB}: ${err
|
|
216
|
+
systemLogger.debug(`deriveMarketPrice: get_ticker failed for ${symA}/${symB}: ${(0, errors_1.getErrorMessage)(err)}`);
|
|
155
217
|
}
|
|
156
218
|
}
|
|
157
219
|
// Return B/A orientation to match market price format
|
|
@@ -162,10 +224,11 @@ const deriveMarketPrice = async (BitShares, symA, symB) => {
|
|
|
162
224
|
return finalPrice;
|
|
163
225
|
}
|
|
164
226
|
catch (err) {
|
|
165
|
-
systemLogger.warn(`deriveMarketPrice failed for ${symA}/${symB}: ${err
|
|
227
|
+
systemLogger.warn(`deriveMarketPrice failed for ${symA}/${symB}: ${(0, errors_1.getErrorMessage)(err)}`);
|
|
166
228
|
return null;
|
|
167
229
|
}
|
|
168
230
|
};
|
|
231
|
+
exports.deriveMarketPrice = deriveMarketPrice;
|
|
169
232
|
/**
|
|
170
233
|
* Derive price from BitShares Liquidity Pool (AMM).
|
|
171
234
|
* Returns price in B/A format (units of asset B per 1 unit of asset A).
|
|
@@ -179,8 +242,8 @@ const deriveMarketPrice = async (BitShares, symA, symB) => {
|
|
|
179
242
|
const derivePoolPrice = async (BitShares, symA, symB) => {
|
|
180
243
|
try {
|
|
181
244
|
const [aMeta, bMeta] = await Promise.all([
|
|
182
|
-
lookupAsset(BitShares, symA),
|
|
183
|
-
lookupAsset(BitShares, symB)
|
|
245
|
+
(0, exports.lookupAsset)(BitShares, symA),
|
|
246
|
+
(0, exports.lookupAsset)(BitShares, symB)
|
|
184
247
|
]);
|
|
185
248
|
if (!aMeta?.id || !bMeta?.id)
|
|
186
249
|
return null;
|
|
@@ -191,10 +254,10 @@ const derivePoolPrice = async (BitShares, symA, symB) => {
|
|
|
191
254
|
try {
|
|
192
255
|
const pools = await BitShares.db.get_liquidity_pools_by_both_assets(aMeta.id, bMeta.id);
|
|
193
256
|
if (Array.isArray(pools) && pools.length > 0) {
|
|
194
|
-
const valid = pools.filter(p => p?.id);
|
|
257
|
+
const valid = pools.filter((p) => p?.id);
|
|
195
258
|
if (valid.length) {
|
|
196
259
|
chosen = valid.sort((a, b) => {
|
|
197
|
-
const getBal = p => toFiniteNumber(String(p.asset_a) === String(aMeta.id) ? p.balance_a : p.balance_b);
|
|
260
|
+
const getBal = (p) => (0, format_1.toFiniteNumber)(String(p.asset_a) === String(aMeta.id) ? p.balance_a : p.balance_b);
|
|
198
261
|
return getBal(b) - getBal(a);
|
|
199
262
|
})[0];
|
|
200
263
|
if (chosen)
|
|
@@ -203,7 +266,7 @@ const derivePoolPrice = async (BitShares, symA, symB) => {
|
|
|
203
266
|
}
|
|
204
267
|
}
|
|
205
268
|
catch (e) {
|
|
206
|
-
systemLogger.debug(`derivePoolPrice: get_liquidity_pools_by_both_assets failed: ${e
|
|
269
|
+
systemLogger.debug(`derivePoolPrice: get_liquidity_pools_by_both_assets failed: ${(0, errors_1.getErrorMessage)(e)}`);
|
|
207
270
|
}
|
|
208
271
|
}
|
|
209
272
|
if (!chosen && cachedPoolId && typeof BitShares.db?.get_objects === 'function') {
|
|
@@ -232,7 +295,7 @@ const derivePoolPrice = async (BitShares, symA, symB) => {
|
|
|
232
295
|
const effectivePools = (startId === '1.19.0') ? pools : pools.slice(1);
|
|
233
296
|
if (effectivePools.length === 0)
|
|
234
297
|
break;
|
|
235
|
-
const matches = effectivePools.filter(p => {
|
|
298
|
+
const matches = effectivePools.filter((p) => {
|
|
236
299
|
const ids = (p.asset_ids || [p.asset_a, p.asset_b]).map(String);
|
|
237
300
|
return ids.includes(String(aMeta.id)) && ids.includes(String(bMeta.id));
|
|
238
301
|
});
|
|
@@ -249,55 +312,55 @@ const derivePoolPrice = async (BitShares, symA, symB) => {
|
|
|
249
312
|
if (allMatches.length) {
|
|
250
313
|
// Select pool with highest balance for our assetA
|
|
251
314
|
chosen = allMatches.sort((a, b) => {
|
|
252
|
-
const getBal = p => toFiniteNumber(String(p.asset_a) === String(aMeta.id) ? p.balance_a : p.balance_b);
|
|
315
|
+
const getBal = (p) => (0, format_1.toFiniteNumber)(String(p.asset_a) === String(aMeta.id) ? p.balance_a : p.balance_b);
|
|
253
316
|
return getBal(b) - getBal(a);
|
|
254
317
|
})[0];
|
|
255
318
|
poolIdCache.set(cacheKey, chosen.id);
|
|
256
319
|
}
|
|
257
320
|
}
|
|
258
321
|
catch (e) {
|
|
259
|
-
systemLogger.warn(`derivePoolPrice: pool pagination failed: ${e
|
|
322
|
+
systemLogger.warn(`derivePoolPrice: pool pagination failed: ${(0, errors_1.getErrorMessage)(e) || e}`);
|
|
260
323
|
}
|
|
261
324
|
}
|
|
262
325
|
}
|
|
263
326
|
if (!chosen)
|
|
264
327
|
return null;
|
|
265
|
-
if (!chosen.reserves && !isValidNumber(chosen.balance_a) && typeof BitShares.db?.get_objects === 'function') {
|
|
328
|
+
if (!chosen.reserves && !(0, format_1.isValidNumber)(chosen.balance_a) && typeof BitShares.db?.get_objects === 'function') {
|
|
266
329
|
try {
|
|
267
330
|
const [full] = await BitShares.db.get_objects([chosen.id]);
|
|
268
331
|
if (full)
|
|
269
332
|
chosen = full;
|
|
270
333
|
}
|
|
271
334
|
catch (e) {
|
|
272
|
-
systemLogger.debug(`derivePoolPrice: get_objects failed for pool ${chosen.id}: ${e
|
|
335
|
+
systemLogger.debug(`derivePoolPrice: get_objects failed for pool ${chosen.id}: ${(0, errors_1.getErrorMessage)(e)}`);
|
|
273
336
|
}
|
|
274
337
|
}
|
|
275
338
|
let amtA = null, amtB = null;
|
|
276
|
-
if (isValidNumber(chosen.balance_a) && isValidNumber(chosen.balance_b)) {
|
|
339
|
+
if ((0, format_1.isValidNumber)(chosen.balance_a) && (0, format_1.isValidNumber)(chosen.balance_b)) {
|
|
277
340
|
// Pools store assets ordered by ID: lower ID is always first (asset_a)
|
|
278
|
-
const aIdNum = toFiniteNumber(String(aMeta.id).split('.')[2]);
|
|
279
|
-
const bIdNum = toFiniteNumber(String(bMeta.id).split('.')[2]);
|
|
341
|
+
const aIdNum = (0, format_1.toFiniteNumber)(String(aMeta.id).split('.')[2]);
|
|
342
|
+
const bIdNum = (0, format_1.toFiniteNumber)(String(bMeta.id).split('.')[2]);
|
|
280
343
|
const aIsFirst = aIdNum < bIdNum;
|
|
281
344
|
// If config's assetA has lower ID, it's the pool's first asset (asset_a)
|
|
282
345
|
// Otherwise, our assetA corresponds to pool's second asset (asset_b)
|
|
283
346
|
if (aIsFirst) {
|
|
284
|
-
amtA = toFiniteNumber(chosen.balance_a);
|
|
285
|
-
amtB = toFiniteNumber(chosen.balance_b);
|
|
347
|
+
amtA = (0, format_1.toFiniteNumber)(chosen.balance_a);
|
|
348
|
+
amtB = (0, format_1.toFiniteNumber)(chosen.balance_b);
|
|
286
349
|
}
|
|
287
350
|
else {
|
|
288
|
-
amtA = toFiniteNumber(chosen.balance_b);
|
|
289
|
-
amtB = toFiniteNumber(chosen.balance_a);
|
|
351
|
+
amtA = (0, format_1.toFiniteNumber)(chosen.balance_b);
|
|
352
|
+
amtB = (0, format_1.toFiniteNumber)(chosen.balance_a);
|
|
290
353
|
}
|
|
291
354
|
}
|
|
292
355
|
else if (Array.isArray(chosen.reserves)) {
|
|
293
|
-
const resA = chosen.reserves.find(r => String(r.asset_id) === String(aMeta.id));
|
|
294
|
-
const resB = chosen.reserves.find(r => String(r.asset_id) === String(bMeta.id));
|
|
356
|
+
const resA = chosen.reserves.find((r) => String(r.asset_id) === String(aMeta.id));
|
|
357
|
+
const resB = chosen.reserves.find((r) => String(r.asset_id) === String(bMeta.id));
|
|
295
358
|
if (resA && resB) {
|
|
296
359
|
amtA = resA.amount;
|
|
297
360
|
amtB = resB.amount;
|
|
298
361
|
}
|
|
299
362
|
}
|
|
300
|
-
if (!isValidNumber(amtA) || !isValidNumber(amtB) || toFiniteNumber(amtB) === 0)
|
|
363
|
+
if (!(0, format_1.isValidNumber)(amtA) || !(0, format_1.isValidNumber)(amtB) || (0, format_1.toFiniteNumber)(amtB) === 0)
|
|
301
364
|
return null;
|
|
302
365
|
const floatA = MathUtils.blockchainToFloat(amtA, aMeta.precision);
|
|
303
366
|
const floatB = MathUtils.blockchainToFloat(amtB, bMeta.precision);
|
|
@@ -309,10 +372,11 @@ const derivePoolPrice = async (BitShares, symA, symB) => {
|
|
|
309
372
|
return finalPrice;
|
|
310
373
|
}
|
|
311
374
|
catch (err) {
|
|
312
|
-
systemLogger.warn(`derivePoolPrice failed for ${symA}/${symB}: ${err
|
|
375
|
+
systemLogger.warn(`derivePoolPrice failed for ${symA}/${symB}: ${(0, errors_1.getErrorMessage)(err)}`);
|
|
313
376
|
return null;
|
|
314
377
|
}
|
|
315
378
|
};
|
|
379
|
+
exports.derivePoolPrice = derivePoolPrice;
|
|
316
380
|
/**
|
|
317
381
|
* Derive price from blockchain using specified mode.
|
|
318
382
|
* Attempts pool or market derivation based on mode, with fallback chain.
|
|
@@ -331,22 +395,23 @@ const derivePrice = async (BitShares, symA, symB, mode = 'auto') => {
|
|
|
331
395
|
return null;
|
|
332
396
|
}
|
|
333
397
|
if (mode === 'pool') {
|
|
334
|
-
return await derivePoolPrice(BitShares, symA, symB).catch(_debugLogAndNull('pool', symA, symB));
|
|
398
|
+
return await (0, exports.derivePoolPrice)(BitShares, symA, symB).catch(_debugLogAndNull('pool', symA, symB));
|
|
335
399
|
}
|
|
336
400
|
if (mode === 'book') {
|
|
337
|
-
return await deriveMarketPrice(BitShares, symA, symB).catch(_debugLogAndNull('book', symA, symB));
|
|
401
|
+
return await (0, exports.deriveMarketPrice)(BitShares, symA, symB).catch(_debugLogAndNull('book', symA, symB));
|
|
338
402
|
}
|
|
339
403
|
// mode === 'auto': pool preferred, market fallback
|
|
340
404
|
let poolP = null;
|
|
341
|
-
poolP = await derivePoolPrice(BitShares, symA, symB).catch(_debugLogAndNull('auto/pool', symA, symB));
|
|
342
|
-
if (poolP > 0)
|
|
405
|
+
poolP = await (0, exports.derivePoolPrice)(BitShares, symA, symB).catch(_debugLogAndNull('auto/pool', symA, symB));
|
|
406
|
+
if (poolP != null && poolP > 0)
|
|
343
407
|
return poolP;
|
|
344
|
-
const m = await deriveMarketPrice(BitShares, symA, symB).catch(_debugLogAndNull('auto/book', symA, symB));
|
|
345
|
-
if (m > 0)
|
|
408
|
+
const m = await (0, exports.deriveMarketPrice)(BitShares, symA, symB).catch(_debugLogAndNull('auto/book', symA, symB));
|
|
409
|
+
if (m != null && m > 0)
|
|
346
410
|
return m;
|
|
347
411
|
systemLogger.debug(`derivePrice: all methods failed for ${symA}/${symB}`);
|
|
348
412
|
return null;
|
|
349
413
|
};
|
|
414
|
+
exports.derivePrice = derivePrice;
|
|
350
415
|
/**
|
|
351
416
|
* Resolve a liquidity pool from a share asset reference.
|
|
352
417
|
* Looks up the share asset, then queries the blockchain for associated pools.
|
|
@@ -359,15 +424,15 @@ async function resolveLiquidityPoolByShareAsset(BitShares, shareAssetRef) {
|
|
|
359
424
|
if (!BitShares?.db || typeof BitShares.db.get_liquidity_pools_by_share_asset !== 'function') {
|
|
360
425
|
return null;
|
|
361
426
|
}
|
|
362
|
-
const shareAsset = await lookupAsset(BitShares, shareAssetRef).catch((e) => {
|
|
363
|
-
systemLogger.debug(`resolveLiquidityPoolByShareAsset: lookupAsset failed for ${shareAssetRef}: ${e
|
|
427
|
+
const shareAsset = await (0, exports.lookupAsset)(BitShares, shareAssetRef).catch((e) => {
|
|
428
|
+
systemLogger.debug(`resolveLiquidityPoolByShareAsset: lookupAsset failed for ${shareAssetRef}: ${(0, errors_1.getErrorMessage)(e)}`);
|
|
364
429
|
return null;
|
|
365
430
|
});
|
|
366
431
|
if (!shareAsset?.id) {
|
|
367
432
|
return null;
|
|
368
433
|
}
|
|
369
434
|
const response = await BitShares.db.get_liquidity_pools_by_share_asset([shareAsset.id], false, false).catch((e) => {
|
|
370
|
-
systemLogger.debug(`resolveLiquidityPoolByShareAsset: get_liquidity_pools_by_share_asset failed for ${shareAssetRef}: ${e
|
|
435
|
+
systemLogger.debug(`resolveLiquidityPoolByShareAsset: get_liquidity_pools_by_share_asset failed for ${shareAssetRef}: ${(0, errors_1.getErrorMessage)(e)}`);
|
|
371
436
|
return null;
|
|
372
437
|
});
|
|
373
438
|
if (!Array.isArray(response)) {
|
|
@@ -385,14 +450,14 @@ async function resolveLiquidityPoolByShareAsset(BitShares, shareAssetRef) {
|
|
|
385
450
|
async function getAssetCurrentSupply(BitShares, assetRef) {
|
|
386
451
|
const asset = typeof assetRef === 'object' && assetRef !== null
|
|
387
452
|
? assetRef
|
|
388
|
-
: await lookupAsset(BitShares, assetRef).catch((e) => {
|
|
389
|
-
systemLogger.debug(`getAssetCurrentSupply: lookupAsset failed for ${assetRef}: ${e
|
|
453
|
+
: await (0, exports.lookupAsset)(BitShares, assetRef).catch((e) => {
|
|
454
|
+
systemLogger.debug(`getAssetCurrentSupply: lookupAsset failed for ${assetRef}: ${(0, errors_1.getErrorMessage)(e)}`);
|
|
390
455
|
return null;
|
|
391
456
|
});
|
|
392
457
|
if (!asset) {
|
|
393
458
|
return null;
|
|
394
459
|
}
|
|
395
|
-
const directSupply = toFiniteNumber(asset.current_supply?.amount ?? asset.current_supply,
|
|
460
|
+
const directSupply = (0, format_1.toFiniteNumber)(asset.current_supply?.amount ?? asset.current_supply, undefined);
|
|
396
461
|
if (Number.isFinite(directSupply) && directSupply >= 0) {
|
|
397
462
|
return directSupply;
|
|
398
463
|
}
|
|
@@ -401,13 +466,13 @@ async function getAssetCurrentSupply(BitShares, assetRef) {
|
|
|
401
466
|
return null;
|
|
402
467
|
}
|
|
403
468
|
const objects = await BitShares.db.get_objects([dynamicId]).catch((e) => {
|
|
404
|
-
systemLogger.debug(`getAssetCurrentSupply: get_objects failed for ${dynamicId}: ${e
|
|
469
|
+
systemLogger.debug(`getAssetCurrentSupply: get_objects failed for ${dynamicId}: ${(0, errors_1.getErrorMessage)(e)}`);
|
|
405
470
|
return null;
|
|
406
471
|
});
|
|
407
472
|
const dynamicData = Array.isArray(objects) ? objects[0] : null;
|
|
408
|
-
const supply = toFiniteNumber(dynamicData?.current_supply?.amount
|
|
473
|
+
const supply = (0, format_1.toFiniteNumber)(dynamicData?.current_supply?.amount
|
|
409
474
|
?? dynamicData?.current_supply?.value
|
|
410
|
-
?? dynamicData?.current_supply,
|
|
475
|
+
?? dynamicData?.current_supply, undefined);
|
|
411
476
|
return Number.isFinite(supply) && supply >= 0 ? supply : null;
|
|
412
477
|
}
|
|
413
478
|
/**
|
|
@@ -424,8 +489,8 @@ async function getAssetCurrentSupply(BitShares, assetRef) {
|
|
|
424
489
|
async function deriveLiquidityPoolTokenValue(BitShares, shareAssetRef, denominationAssetRef, mode = 'auto') {
|
|
425
490
|
try {
|
|
426
491
|
const [shareAsset, denominationAsset] = await Promise.all([
|
|
427
|
-
lookupAsset(BitShares, shareAssetRef),
|
|
428
|
-
lookupAsset(BitShares, denominationAssetRef),
|
|
492
|
+
(0, exports.lookupAsset)(BitShares, shareAssetRef),
|
|
493
|
+
(0, exports.lookupAsset)(BitShares, denominationAssetRef),
|
|
429
494
|
]);
|
|
430
495
|
if (!shareAsset?.id || !denominationAsset?.id) {
|
|
431
496
|
return null;
|
|
@@ -435,8 +500,8 @@ async function deriveLiquidityPoolTokenValue(BitShares, shareAssetRef, denominat
|
|
|
435
500
|
return null;
|
|
436
501
|
}
|
|
437
502
|
const [assetA, assetB, supply] = await Promise.all([
|
|
438
|
-
lookupAsset(BitShares, poolInfo.pool.asset_a),
|
|
439
|
-
lookupAsset(BitShares, poolInfo.pool.asset_b),
|
|
503
|
+
(0, exports.lookupAsset)(BitShares, poolInfo.pool.asset_a),
|
|
504
|
+
(0, exports.lookupAsset)(BitShares, poolInfo.pool.asset_b),
|
|
440
505
|
getAssetCurrentSupply(BitShares, shareAsset),
|
|
441
506
|
]);
|
|
442
507
|
if (!assetA?.id || !assetB?.id || !Number.isFinite(supply) || supply <= 0) {
|
|
@@ -444,34 +509,34 @@ async function deriveLiquidityPoolTokenValue(BitShares, shareAssetRef, denominat
|
|
|
444
509
|
}
|
|
445
510
|
const reserveA = MathUtils.blockchainToFloat(poolInfo.pool.balance_a, assetA.precision);
|
|
446
511
|
const reserveB = MathUtils.blockchainToFloat(poolInfo.pool.balance_b, assetB.precision);
|
|
447
|
-
if (!isValidNumber(reserveA) || !isValidNumber(reserveB)) {
|
|
512
|
+
if (!(0, format_1.isValidNumber)(reserveA) || !(0, format_1.isValidNumber)(reserveB)) {
|
|
448
513
|
return null;
|
|
449
514
|
}
|
|
450
515
|
const priceA = String(assetA.id) === String(denominationAsset.id)
|
|
451
516
|
? 1
|
|
452
|
-
: await derivePrice(BitShares, assetA.id, denominationAsset.id, mode).catch((e) => {
|
|
453
|
-
systemLogger.debug(`deriveLiquidityPoolTokenValue: derivePrice failed for ${assetA.id}/${denominationAsset.id}: ${e
|
|
517
|
+
: await (0, exports.derivePrice)(BitShares, assetA.id, denominationAsset.id, mode).catch((e) => {
|
|
518
|
+
systemLogger.debug(`deriveLiquidityPoolTokenValue: derivePrice failed for ${assetA.id}/${denominationAsset.id}: ${(0, errors_1.getErrorMessage)(e)}`);
|
|
454
519
|
return null;
|
|
455
520
|
});
|
|
456
521
|
const priceB = String(assetB.id) === String(denominationAsset.id)
|
|
457
522
|
? 1
|
|
458
|
-
: await derivePrice(BitShares, assetB.id, denominationAsset.id, mode).catch((e) => {
|
|
459
|
-
systemLogger.debug(`deriveLiquidityPoolTokenValue: derivePrice failed for ${assetB.id}/${denominationAsset.id}: ${e
|
|
523
|
+
: await (0, exports.derivePrice)(BitShares, assetB.id, denominationAsset.id, mode).catch((e) => {
|
|
524
|
+
systemLogger.debug(`deriveLiquidityPoolTokenValue: derivePrice failed for ${assetB.id}/${denominationAsset.id}: ${(0, errors_1.getErrorMessage)(e)}`);
|
|
460
525
|
return null;
|
|
461
526
|
});
|
|
462
|
-
if (!isValidNumber(priceA) || !isValidNumber(priceB) || priceA <= 0 || priceB <= 0) {
|
|
527
|
+
if (priceA == null || priceB == null || !(0, format_1.isValidNumber)(priceA) || !(0, format_1.isValidNumber)(priceB) || priceA <= 0 || priceB <= 0) {
|
|
463
528
|
return null;
|
|
464
529
|
}
|
|
465
530
|
const supplyFloat = MathUtils.blockchainToFloat(supply, shareAsset.precision);
|
|
466
|
-
if (!isValidNumber(supplyFloat) || supplyFloat <= 0) {
|
|
531
|
+
if (!(0, format_1.isValidNumber)(supplyFloat) || supplyFloat <= 0) {
|
|
467
532
|
return null;
|
|
468
533
|
}
|
|
469
534
|
const totalValue = reserveA * priceA + reserveB * priceB;
|
|
470
535
|
const valuePerShare = totalValue / supplyFloat;
|
|
471
|
-
return isValidNumber(valuePerShare) && valuePerShare > 0 ? valuePerShare : null;
|
|
536
|
+
return (0, format_1.isValidNumber)(valuePerShare) && valuePerShare > 0 ? valuePerShare : null;
|
|
472
537
|
}
|
|
473
538
|
catch (err) {
|
|
474
|
-
systemLogger.debug(`deriveLiquidityPoolTokenValue failed for ${shareAssetRef}/${denominationAssetRef}: ${err
|
|
539
|
+
systemLogger.debug(`deriveLiquidityPoolTokenValue failed for ${shareAssetRef}/${denominationAssetRef}: ${(0, errors_1.getErrorMessage)(err)}`);
|
|
475
540
|
return null;
|
|
476
541
|
}
|
|
477
542
|
}
|
|
@@ -492,8 +557,8 @@ async function deriveLiquidityPoolTokenValue(BitShares, shareAssetRef, denominat
|
|
|
492
557
|
*/
|
|
493
558
|
function loadAmaCenterSnapshot(botKey) {
|
|
494
559
|
try {
|
|
495
|
-
const gridPriceFile = path.join(PATHS.ORDERS_DIR, `${botKey}.dynamicgrid.json`);
|
|
496
|
-
const data = readJSON(gridPriceFile);
|
|
560
|
+
const gridPriceFile = path_api_1.path.join(paths_1.PATHS.ORDERS_DIR, `${botKey}.dynamicgrid.json`);
|
|
561
|
+
const data = (0, fs_utils_1.readJSON)(gridPriceFile);
|
|
497
562
|
const gridCenterPrice = Number(data?.gridCenterPrice ?? data?.centerPrice);
|
|
498
563
|
const amaCenterPrice = Number(data?.amaCenterPrice);
|
|
499
564
|
if (!Number.isFinite(gridCenterPrice) || gridCenterPrice <= 0) {
|
|
@@ -546,7 +611,7 @@ function loadAmaCenterPrice(botKey) {
|
|
|
546
611
|
*/
|
|
547
612
|
function _loadFeeCacheFromDisk() {
|
|
548
613
|
try {
|
|
549
|
-
const filePath = PATHS.PROFILES.FEE_CACHE_JSON;
|
|
614
|
+
const filePath = paths_1.PATHS.PROFILES.FEE_CACHE_JSON;
|
|
550
615
|
if (storage.exists(filePath)) {
|
|
551
616
|
const diskCache = storage.readJSON(filePath);
|
|
552
617
|
if (diskCache && typeof diskCache === 'object') {
|
|
@@ -556,7 +621,7 @@ function _loadFeeCacheFromDisk() {
|
|
|
556
621
|
}
|
|
557
622
|
}
|
|
558
623
|
catch (e) {
|
|
559
|
-
systemLogger.debug(`_loadFeeCacheFromDisk: ${e
|
|
624
|
+
systemLogger.debug(`_loadFeeCacheFromDisk: ${(0, errors_1.getErrorMessage)(e)}`);
|
|
560
625
|
}
|
|
561
626
|
return {};
|
|
562
627
|
}
|
|
@@ -566,10 +631,10 @@ function _loadFeeCacheFromDisk() {
|
|
|
566
631
|
*/
|
|
567
632
|
function _saveFeeCacheToDisk(cache) {
|
|
568
633
|
try {
|
|
569
|
-
storage.writeJSON(PATHS.PROFILES.FEE_CACHE_JSON, cache);
|
|
634
|
+
storage.writeJSON(paths_1.PATHS.PROFILES.FEE_CACHE_JSON, cache);
|
|
570
635
|
}
|
|
571
636
|
catch (e) {
|
|
572
|
-
systemLogger.debug(`_saveFeeCacheToDisk: ${e
|
|
637
|
+
systemLogger.debug(`_saveFeeCacheToDisk: ${(0, errors_1.getErrorMessage)(e)}`);
|
|
573
638
|
}
|
|
574
639
|
}
|
|
575
640
|
/**
|
|
@@ -592,8 +657,8 @@ async function initializeFeeCache(botsConfig, BitShares) {
|
|
|
592
657
|
}
|
|
593
658
|
// Seed from disk so previously cached assets survive transient API failures
|
|
594
659
|
const cache = _loadFeeCacheFromDisk();
|
|
595
|
-
const maxAttempts = FEE_PARAMETERS.FEE_CACHE_RETRY_ATTEMPTS;
|
|
596
|
-
const baseDelay = FEE_PARAMETERS.FEE_CACHE_RETRY_DELAY_MS;
|
|
660
|
+
const maxAttempts = constants_1.FEE_PARAMETERS.FEE_CACHE_RETRY_ATTEMPTS;
|
|
661
|
+
const baseDelay = constants_1.FEE_PARAMETERS.FEE_CACHE_RETRY_DELAY_MS;
|
|
597
662
|
for (const assetSymbol of uniqueAssets) {
|
|
598
663
|
let lastError = null;
|
|
599
664
|
for (let attempt = 1; attempt <= maxAttempts; attempt++) {
|
|
@@ -602,16 +667,16 @@ async function initializeFeeCache(botsConfig, BitShares) {
|
|
|
602
667
|
const globalProps = await BitShares.db.getGlobalProperties();
|
|
603
668
|
const currentFees = globalProps.parameters.current_fees.parameters;
|
|
604
669
|
const findFee = (opCode) => {
|
|
605
|
-
const param = currentFees.find(p => p[0] === opCode);
|
|
670
|
+
const param = currentFees.find((p) => p[0] === opCode);
|
|
606
671
|
const fee = param?.[1]?.fee;
|
|
607
|
-
const feeNum = toFiniteNumber(fee);
|
|
672
|
+
const feeNum = (0, format_1.toFiniteNumber)(fee);
|
|
608
673
|
return {
|
|
609
674
|
raw: feeNum,
|
|
610
675
|
satoshis: feeNum,
|
|
611
|
-
bts: MathUtils.blockchainToFloat(feeNum, BTS_PRECISION)
|
|
676
|
+
bts: MathUtils.blockchainToFloat(feeNum, constants_1.BTS_PRECISION)
|
|
612
677
|
};
|
|
613
678
|
};
|
|
614
|
-
const makerFeeDiscountRaw = toFiniteNumber(globalProps?.parameters?.extensions?.maker_fee_discount_percent, FEE_PARAMETERS.MAKER_REFUND_PERCENT * 10000);
|
|
679
|
+
const makerFeeDiscountRaw = (0, format_1.toFiniteNumber)(globalProps?.parameters?.extensions?.maker_fee_discount_percent, constants_1.FEE_PARAMETERS.MAKER_REFUND_PERCENT * 10000);
|
|
615
680
|
cache.BTS = {
|
|
616
681
|
limitOrderCreate: findFee(1),
|
|
617
682
|
limitOrderCancel: findFee(2),
|
|
@@ -620,7 +685,7 @@ async function initializeFeeCache(botsConfig, BitShares) {
|
|
|
620
685
|
};
|
|
621
686
|
}
|
|
622
687
|
else {
|
|
623
|
-
const fullAsset = await lookupAsset(BitShares, assetSymbol);
|
|
688
|
+
const fullAsset = await (0, exports.lookupAsset)(BitShares, assetSymbol);
|
|
624
689
|
const options = fullAsset.options || {};
|
|
625
690
|
cache[assetSymbol] = {
|
|
626
691
|
assetId: fullAsset.id,
|
|
@@ -642,14 +707,14 @@ async function initializeFeeCache(botsConfig, BitShares) {
|
|
|
642
707
|
lastError = error;
|
|
643
708
|
if (attempt < maxAttempts) {
|
|
644
709
|
const delay = baseDelay * attempt;
|
|
645
|
-
systemLogger.warn(`initializeFeeCache: attempt ${attempt}/${maxAttempts} failed for ${assetSymbol}: ${error
|
|
710
|
+
systemLogger.warn(`initializeFeeCache: attempt ${attempt}/${maxAttempts} failed for ${assetSymbol}: ${(0, errors_1.getErrorMessage)(error)}. Retrying in ${delay}ms...`);
|
|
646
711
|
await sleep(delay);
|
|
647
712
|
}
|
|
648
713
|
}
|
|
649
714
|
}
|
|
650
715
|
if (lastError) {
|
|
651
716
|
const hasDiskFallback = cache[assetSymbol] !== undefined;
|
|
652
|
-
systemLogger.warn(`initializeFeeCache: all ${maxAttempts} attempts failed for ${assetSymbol}: ${lastError
|
|
717
|
+
systemLogger.warn(`initializeFeeCache: all ${maxAttempts} attempts failed for ${assetSymbol}: ${(0, errors_1.getErrorMessage)(lastError)}` +
|
|
653
718
|
(hasDiskFallback ? '. Using previously cached value from disk.' : '.'));
|
|
654
719
|
}
|
|
655
720
|
}
|
|
@@ -721,7 +786,7 @@ async function retryPersistenceIfNeeded(manager) {
|
|
|
721
786
|
return success;
|
|
722
787
|
}
|
|
723
788
|
catch (e) {
|
|
724
|
-
systemLogger.warn(`retryPersistenceIfNeeded failed: ${e
|
|
789
|
+
systemLogger.warn(`retryPersistenceIfNeeded failed: ${(0, errors_1.getErrorMessage)(e)}`);
|
|
725
790
|
return false;
|
|
726
791
|
}
|
|
727
792
|
}
|
|
@@ -739,10 +804,10 @@ async function retryPersistenceIfNeeded(manager) {
|
|
|
739
804
|
* @param {Function} updateOrdersOnChainBatchFn - Batch update function for blockchain operations
|
|
740
805
|
* @returns {Promise<void>}
|
|
741
806
|
*/
|
|
742
|
-
async function applyGridDivergenceCorrections(manager, accountOrders,
|
|
807
|
+
async function applyGridDivergenceCorrections(manager, accountOrders, _botKey, updateOrdersOnChainBatchFn) {
|
|
743
808
|
if (!manager._gridLock)
|
|
744
809
|
return;
|
|
745
|
-
const {
|
|
810
|
+
const { updateGridFromBlockchainSnapshot } = require('../grid');
|
|
746
811
|
const { WorkingGrid } = require('../working_grid');
|
|
747
812
|
const { hasActionForOrder, removeActionsForOrder } = require('./validate');
|
|
748
813
|
// Phase 1: Pre-lock grid resizing using COW
|
|
@@ -753,13 +818,13 @@ async function applyGridDivergenceCorrections(manager, accountOrders, botKey, up
|
|
|
753
818
|
let resizeCowResult = null;
|
|
754
819
|
let pendingBoundaryIdx = manager.boundaryIdx;
|
|
755
820
|
if (manager._gridSidesUpdated && manager._gridSidesUpdated.size > 0) {
|
|
756
|
-
const hasBuy = manager._gridSidesUpdated.has(ORDER_TYPES.BUY);
|
|
757
|
-
const hasSell = manager._gridSidesUpdated.has(ORDER_TYPES.SELL);
|
|
821
|
+
const hasBuy = manager._gridSidesUpdated.has(constants_1.ORDER_TYPES.BUY);
|
|
822
|
+
const hasSell = manager._gridSidesUpdated.has(constants_1.ORDER_TYPES.SELL);
|
|
758
823
|
let resizeOrderType = hasBuy && hasSell
|
|
759
824
|
? 'both'
|
|
760
825
|
: hasBuy
|
|
761
|
-
? ORDER_TYPES.BUY
|
|
762
|
-
: ORDER_TYPES.SELL;
|
|
826
|
+
? constants_1.ORDER_TYPES.BUY
|
|
827
|
+
: constants_1.ORDER_TYPES.SELL;
|
|
763
828
|
// If out-of-spread correction moves boundary, recompute both sides.
|
|
764
829
|
// Store the new index in pendingBoundaryIdx — do NOT touch manager.boundaryIdx
|
|
765
830
|
// here; updateGridFromBlockchainSnapshot will re-assign slot types in the
|
|
@@ -768,14 +833,14 @@ async function applyGridDivergenceCorrections(manager, accountOrders, botKey, up
|
|
|
768
833
|
if (manager.outOfSpread > 0 && boundarySync.changed) {
|
|
769
834
|
pendingBoundaryIdx = boundarySync.newIdx;
|
|
770
835
|
resizeOrderType = 'both';
|
|
771
|
-
manager._gridSidesUpdated.add(ORDER_TYPES.BUY);
|
|
772
|
-
manager._gridSidesUpdated.add(ORDER_TYPES.SELL);
|
|
836
|
+
manager._gridSidesUpdated.add(constants_1.ORDER_TYPES.BUY);
|
|
837
|
+
manager._gridSidesUpdated.add(constants_1.ORDER_TYPES.SELL);
|
|
773
838
|
}
|
|
774
839
|
try {
|
|
775
840
|
resizeCowResult = await updateGridFromBlockchainSnapshot(manager, resizeOrderType, true, pendingBoundaryIdx);
|
|
776
841
|
}
|
|
777
842
|
catch (err) {
|
|
778
|
-
manager.logger?.log?.(`[DIVERGENCE-COW] Grid resize failed: ${err
|
|
843
|
+
manager.logger?.log?.(`[DIVERGENCE-COW] Grid resize failed: ${(0, errors_1.getErrorMessage)(err)}`, 'error');
|
|
779
844
|
manager._gridSidesUpdated.clear();
|
|
780
845
|
return;
|
|
781
846
|
}
|
|
@@ -792,14 +857,14 @@ async function applyGridDivergenceCorrections(manager, accountOrders, botKey, up
|
|
|
792
857
|
: new WorkingGrid(manager.orders, { baseVersion: manager._gridVersion });
|
|
793
858
|
const actions = resizeCowResult?.actions ? [...resizeCowResult.actions] : [];
|
|
794
859
|
for (const orderType of manager._gridSidesUpdated) {
|
|
795
|
-
const sideName = orderType === ORDER_TYPES.BUY ? 'buy' : 'sell';
|
|
860
|
+
const sideName = orderType === constants_1.ORDER_TYPES.BUY ? 'buy' : 'sell';
|
|
796
861
|
const sidePrecision = MathUtils.getPrecisionByOrderType(manager.assets, orderType);
|
|
797
862
|
// Get current on-chain orders for this side (from master, not working)
|
|
798
863
|
const currentOnChainOrders = Array.from(manager.orders.values())
|
|
799
|
-
.filter(o => o.type === orderType && OrderUtils.isOrderPlaced(o));
|
|
864
|
+
.filter((o) => o.type === orderType && OrderUtils.isOrderPlaced(o));
|
|
800
865
|
// Get all slots for this side from working grid
|
|
801
866
|
const allSideSlots = Array.from(workingGrid.values())
|
|
802
|
-
.filter(o => o.type === orderType)
|
|
867
|
+
.filter((o) => o.type === orderType)
|
|
803
868
|
.sort((a, b) => sideName === 'buy' ? b.price - a.price : a.price - b.price);
|
|
804
869
|
// Calculate target count
|
|
805
870
|
const baseTargetCount = (manager.config.activeOrders && Number.isFinite(manager.config.activeOrders[sideName]))
|
|
@@ -808,8 +873,8 @@ async function applyGridDivergenceCorrections(manager, accountOrders, botKey, up
|
|
|
808
873
|
const targetCount = baseTargetCount;
|
|
809
874
|
// Determine desired slots (closest to market)
|
|
810
875
|
const desiredSlots = allSideSlots.slice(0, targetCount);
|
|
811
|
-
const desiredSlotIds = new Set(desiredSlots.map(s => s.id));
|
|
812
|
-
const onChainBySlotId = new Map(currentOnChainOrders.map(o => [o.id, o]));
|
|
876
|
+
const desiredSlotIds = new Set(desiredSlots.map((s) => s.id));
|
|
877
|
+
const onChainBySlotId = new Map(currentOnChainOrders.map((o) => [o.id, o]));
|
|
813
878
|
// Process on-chain orders:
|
|
814
879
|
// - In desired window: keep/update committed size (if not already queued by Phase 1)
|
|
815
880
|
// - Outside desired window: cancel surplus order
|
|
@@ -817,13 +882,13 @@ async function applyGridDivergenceCorrections(manager, accountOrders, botKey, up
|
|
|
817
882
|
// Get current slot from working grid (may have been updated in Phase 1)
|
|
818
883
|
const slot = workingGrid.get(onChainOrder.id);
|
|
819
884
|
const isDesired = desiredSlotIds.has(onChainOrder.id);
|
|
820
|
-
if (!isDesired || !slot || !(toFiniteNumber(slot.size) > 0)) {
|
|
821
|
-
removeActionsForOrder(actions, COW_ACTIONS.UPDATE, onChainOrder);
|
|
822
|
-
const hasQueuedCancel = hasActionForOrder(actions, COW_ACTIONS.CANCEL, onChainOrder);
|
|
885
|
+
if (!isDesired || !slot || !((0, format_1.toFiniteNumber)(slot.size) > 0)) {
|
|
886
|
+
removeActionsForOrder(actions, constants_1.COW_ACTIONS.UPDATE, onChainOrder);
|
|
887
|
+
const hasQueuedCancel = hasActionForOrder(actions, constants_1.COW_ACTIONS.CANCEL, onChainOrder);
|
|
823
888
|
if (!hasQueuedCancel) {
|
|
824
889
|
manager.logger.log(`[DIVERGENCE-COW] Queueing cancel for surplus ${onChainOrder.id} (chain id ${onChainOrder.orderId})`, 'info');
|
|
825
890
|
actions.push({
|
|
826
|
-
type: COW_ACTIONS.CANCEL,
|
|
891
|
+
type: constants_1.COW_ACTIONS.CANCEL,
|
|
827
892
|
id: onChainOrder.id,
|
|
828
893
|
orderId: onChainOrder.orderId
|
|
829
894
|
});
|
|
@@ -833,20 +898,20 @@ async function applyGridDivergenceCorrections(manager, accountOrders, botKey, up
|
|
|
833
898
|
continue;
|
|
834
899
|
}
|
|
835
900
|
// Phase 1 already queued committed size updates. Avoid duplicate UPDATEs.
|
|
836
|
-
const hasQueuedUpdate = hasActionForOrder(actions, COW_ACTIONS.UPDATE, onChainOrder);
|
|
837
|
-
const hasQueuedCancel = hasActionForOrder(actions, COW_ACTIONS.CANCEL, onChainOrder);
|
|
901
|
+
const hasQueuedUpdate = hasActionForOrder(actions, constants_1.COW_ACTIONS.UPDATE, onChainOrder);
|
|
902
|
+
const hasQueuedCancel = hasActionForOrder(actions, constants_1.COW_ACTIONS.CANCEL, onChainOrder);
|
|
838
903
|
if (hasQueuedUpdate || hasQueuedCancel) {
|
|
839
904
|
continue;
|
|
840
905
|
}
|
|
841
|
-
const newSize = toFiniteNumber(slot.size);
|
|
842
|
-
const currentSize = toFiniteNumber(onChainOrder.size);
|
|
906
|
+
const newSize = (0, format_1.toFiniteNumber)(slot.size);
|
|
907
|
+
const currentSize = (0, format_1.toFiniteNumber)(onChainOrder.size);
|
|
843
908
|
const sizeChanged = Number.isFinite(sidePrecision)
|
|
844
909
|
? MathUtils.floatToBlockchainInt(newSize, sidePrecision) !== MathUtils.floatToBlockchainInt(currentSize, sidePrecision)
|
|
845
910
|
: newSize !== currentSize;
|
|
846
911
|
if (sizeChanged) {
|
|
847
912
|
manager.logger.log(`[DIVERGENCE-COW] Queueing size update for ${onChainOrder.id}: ${currentSize} -> ${newSize}`, 'info');
|
|
848
913
|
actions.push({
|
|
849
|
-
type: COW_ACTIONS.UPDATE,
|
|
914
|
+
type: constants_1.COW_ACTIONS.UPDATE,
|
|
850
915
|
id: onChainOrder.id,
|
|
851
916
|
orderId: onChainOrder.orderId,
|
|
852
917
|
newGridId: onChainOrder.id,
|
|
@@ -863,11 +928,11 @@ async function applyGridDivergenceCorrections(manager, accountOrders, botKey, up
|
|
|
863
928
|
}
|
|
864
929
|
// Process holes: CREATE new orders for empty desired slots
|
|
865
930
|
for (const slot of desiredSlots) {
|
|
866
|
-
const hasCreate = hasActionForOrder(actions, COW_ACTIONS.CREATE, slot);
|
|
931
|
+
const hasCreate = hasActionForOrder(actions, constants_1.COW_ACTIONS.CREATE, slot);
|
|
867
932
|
if (!onChainBySlotId.has(slot.id) && slot.size > 0 && !hasCreate) {
|
|
868
933
|
manager.logger.log(`[DIVERGENCE-COW] Queueing new placement for slot ${slot.id}`, 'info');
|
|
869
934
|
actions.push({
|
|
870
|
-
type: COW_ACTIONS.CREATE,
|
|
935
|
+
type: constants_1.COW_ACTIONS.CREATE,
|
|
871
936
|
id: slot.id,
|
|
872
937
|
order: {
|
|
873
938
|
id: slot.id,
|
|
@@ -938,7 +1003,7 @@ async function applyGridDivergenceCorrections(manager, accountOrders, botKey, up
|
|
|
938
1003
|
}
|
|
939
1004
|
}
|
|
940
1005
|
catch (err) {
|
|
941
|
-
manager.logger.log(`[DIVERGENCE-COW] Error executing divergence corrections: ${err
|
|
1006
|
+
manager.logger.log(`[DIVERGENCE-COW] Error executing divergence corrections: ${(0, errors_1.getErrorMessage)(err)}`, 'error');
|
|
942
1007
|
manager._gridSidesUpdated.clear();
|
|
943
1008
|
}
|
|
944
1009
|
}
|
|
@@ -983,9 +1048,9 @@ function syncBoundaryToFunds(manager) {
|
|
|
983
1048
|
let minSellIdx = allSlots.length;
|
|
984
1049
|
for (let i = 0; i < allSlots.length; i++) {
|
|
985
1050
|
const slot = allSlots[i];
|
|
986
|
-
if (slot.type === ORDER_TYPES.BUY && i > maxBuyIdx)
|
|
1051
|
+
if (slot.type === constants_1.ORDER_TYPES.BUY && i > maxBuyIdx)
|
|
987
1052
|
maxBuyIdx = i;
|
|
988
|
-
if (slot.type === ORDER_TYPES.SELL && i < minSellIdx)
|
|
1053
|
+
if (slot.type === constants_1.ORDER_TYPES.SELL && i < minSellIdx)
|
|
989
1054
|
minSellIdx = i;
|
|
990
1055
|
}
|
|
991
1056
|
// Build clamp bounds from whichever sides have typed slots.
|
|
@@ -1016,7 +1081,7 @@ function syncBoundaryToFunds(manager) {
|
|
|
1016
1081
|
*/
|
|
1017
1082
|
function ensureProfilesDirectory(profilesDir) {
|
|
1018
1083
|
if (!storage.exists(profilesDir)) {
|
|
1019
|
-
ensureDir(profilesDir);
|
|
1084
|
+
(0, fs_utils_1.ensureDir)(profilesDir);
|
|
1020
1085
|
return true;
|
|
1021
1086
|
}
|
|
1022
1087
|
return false;
|
|
@@ -1027,7 +1092,7 @@ function ensureProfilesDirectory(profilesDir) {
|
|
|
1027
1092
|
* @returns {Promise<void>}
|
|
1028
1093
|
*/
|
|
1029
1094
|
function sleep(ms) {
|
|
1030
|
-
return new Promise(resolve => setTimeout(resolve, ms));
|
|
1095
|
+
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
1031
1096
|
}
|
|
1032
1097
|
/**
|
|
1033
1098
|
* Read user input from stdin with optional masking.
|
|
@@ -1042,8 +1107,8 @@ function sleep(ms) {
|
|
|
1042
1107
|
*/
|
|
1043
1108
|
function readInput(prompt, options = {}) {
|
|
1044
1109
|
return new Promise((resolve) => {
|
|
1045
|
-
const stdin = runtime.stdin;
|
|
1046
|
-
const stdout = runtime.stdout;
|
|
1110
|
+
const stdin = runtime_1.runtime.stdin;
|
|
1111
|
+
const stdout = runtime_1.runtime.stdout;
|
|
1047
1112
|
const ESC_SEQUENCE_TIMEOUT_MS = 150;
|
|
1048
1113
|
let input = '';
|
|
1049
1114
|
let cursorPos = 0;
|
|
@@ -1134,7 +1199,7 @@ function readInput(prompt, options = {}) {
|
|
|
1134
1199
|
if (ch === '\u0003') {
|
|
1135
1200
|
cleanup();
|
|
1136
1201
|
stdout.write('\r\x1b[K\n');
|
|
1137
|
-
runtime.exit(0);
|
|
1202
|
+
runtime_1.runtime.exit(0);
|
|
1138
1203
|
}
|
|
1139
1204
|
// Backspace
|
|
1140
1205
|
if (ch === '\u007f' || ch === '\u0008') {
|
|
@@ -1204,7 +1269,7 @@ async function readPassword(prompt) { return readInput(prompt, { mask: '*', hide
|
|
|
1204
1269
|
* @throws {Error} If all attempts fail, throws the final error
|
|
1205
1270
|
*/
|
|
1206
1271
|
async function withRetry(fn, options = {}) {
|
|
1207
|
-
const { maxAttempts = PIPELINE_TIMING.RETRY_MAX_ATTEMPTS, baseDelayMs = PIPELINE_TIMING.RETRY_BASE_DELAY_MS, maxDelayMs = PIPELINE_TIMING.RETRY_MAX_DELAY_MS, logger = null, operationName = 'operation' } = options;
|
|
1272
|
+
const { maxAttempts = constants_1.PIPELINE_TIMING.RETRY_MAX_ATTEMPTS, baseDelayMs = constants_1.PIPELINE_TIMING.RETRY_BASE_DELAY_MS, maxDelayMs = constants_1.PIPELINE_TIMING.RETRY_MAX_DELAY_MS, logger = null, operationName = 'operation' } = options;
|
|
1208
1273
|
for (let attempt = 1; attempt <= maxAttempts; attempt++) {
|
|
1209
1274
|
try {
|
|
1210
1275
|
return await fn();
|
|
@@ -1217,6 +1282,87 @@ async function withRetry(fn, options = {}) {
|
|
|
1217
1282
|
await sleep(delay);
|
|
1218
1283
|
}
|
|
1219
1284
|
}
|
|
1285
|
+
throw new Error(`${operationName} failed after ${maxAttempts} attempts`);
|
|
1286
|
+
}
|
|
1287
|
+
/**
|
|
1288
|
+
* Execute a blockchain operation with timeout, retry, and node failover reporting.
|
|
1289
|
+
* Reports each failure to NodeManager so the node gets blacklisted after
|
|
1290
|
+
* consecutive failures, triggering automatic failover to a healthy node.
|
|
1291
|
+
*
|
|
1292
|
+
* After exhausting the retry budget, force-blacklists the current node and
|
|
1293
|
+
* reconnects to a different healthy node, then makes one final attempt.
|
|
1294
|
+
* This prevents the bot from hanging indefinitely on a stuck node.
|
|
1295
|
+
*
|
|
1296
|
+
* Defaults: 30s timeout, 3 retries (PIPELINE_TIMING.RETRY_MAX_ATTEMPTS), 2s retry delay.
|
|
1297
|
+
* All configurable via options.
|
|
1298
|
+
*
|
|
1299
|
+
* @param fn - Async function wrapping the blockchain operation
|
|
1300
|
+
* @param label - Short human-readable label for error messages
|
|
1301
|
+
* @param options.logger - Optional logger for retry warnings
|
|
1302
|
+
* @param options.timeoutMs - Override timeout per attempt (default 30000)
|
|
1303
|
+
* @param options.maxRetries - Override max retry count (default PIPELINE_TIMING.RETRY_MAX_ATTEMPTS)
|
|
1304
|
+
* @param options.retryDelayMs - Override delay between retries (default 2000)
|
|
1305
|
+
*/
|
|
1306
|
+
async function withBlockchainRetry(fn, label, options) {
|
|
1307
|
+
const timeoutMs = options?.timeoutMs ?? 30000;
|
|
1308
|
+
const maxRetries = options?.maxRetries ?? constants_1.PIPELINE_TIMING.RETRY_MAX_ATTEMPTS;
|
|
1309
|
+
const retryDelayMs = options?.retryDelayMs ?? 2000;
|
|
1310
|
+
const logger = options?.logger;
|
|
1311
|
+
let lastError;
|
|
1312
|
+
for (let attempt = 1; attempt <= maxRetries; attempt++) {
|
|
1313
|
+
try {
|
|
1314
|
+
const resultPromise = fn();
|
|
1315
|
+
// Swallow late unhandled rejections from the race loser
|
|
1316
|
+
Promise.resolve(resultPromise).catch(() => { });
|
|
1317
|
+
return await Promise.race([
|
|
1318
|
+
resultPromise,
|
|
1319
|
+
new Promise((_, reject) => {
|
|
1320
|
+
setTimeout(() => reject(new Error(`${label} timed out after ${timeoutMs}ms (attempt ${attempt}/${maxRetries})`)), timeoutMs);
|
|
1321
|
+
})
|
|
1322
|
+
]);
|
|
1323
|
+
}
|
|
1324
|
+
catch (err) {
|
|
1325
|
+
lastError = err;
|
|
1326
|
+
// Report node failure so NodeManager can blacklist and trigger failover
|
|
1327
|
+
try {
|
|
1328
|
+
const { getNodeManager } = require('../../bitshares_client');
|
|
1329
|
+
const nodeManager = getNodeManager();
|
|
1330
|
+
const nodeUrl = nodeManager?.getBestNode?.();
|
|
1331
|
+
if (nodeUrl && typeof nodeManager.reportNodeFailure === 'function') {
|
|
1332
|
+
nodeManager.reportNodeFailure(nodeUrl, (0, errors_1.getErrorMessage)(err), 'blockchain-op');
|
|
1333
|
+
}
|
|
1334
|
+
}
|
|
1335
|
+
catch (_) { /* reporting errors are non-fatal */ }
|
|
1336
|
+
if (attempt < maxRetries) {
|
|
1337
|
+
logger?.log?.(`${label} attempt ${attempt}/${maxRetries} failed: ${(0, errors_1.getErrorMessage)(err)}. Retrying in ${retryDelayMs}ms...`, 'warn');
|
|
1338
|
+
await sleep(retryDelayMs);
|
|
1339
|
+
}
|
|
1340
|
+
}
|
|
1341
|
+
}
|
|
1342
|
+
// All retries exhausted — force-switch to a different node and retry once more
|
|
1343
|
+
try {
|
|
1344
|
+
const { getNodeManager, reconnectForCycle } = require('../../bitshares_client');
|
|
1345
|
+
const nodeManager = getNodeManager?.();
|
|
1346
|
+
const failedNode = nodeManager?.getBestNode?.();
|
|
1347
|
+
if (failedNode && typeof nodeManager.blacklistNode === 'function') {
|
|
1348
|
+
nodeManager.blacklistNode(failedNode);
|
|
1349
|
+
logger?.log?.(`${label}: blacklisted node ${failedNode.substring(0, 40)}... after ${maxRetries} failed attempts. Switching nodes...`, 'warn');
|
|
1350
|
+
}
|
|
1351
|
+
const reconnected = await reconnectForCycle(label + ' failover');
|
|
1352
|
+
if (reconnected) {
|
|
1353
|
+
logger?.log?.(`${label}: reconnected to different node. Retrying operation...`, 'warn');
|
|
1354
|
+
const resultPromise = fn();
|
|
1355
|
+
Promise.resolve(resultPromise).catch(() => { });
|
|
1356
|
+
return await Promise.race([
|
|
1357
|
+
resultPromise,
|
|
1358
|
+
new Promise((_, reject) => {
|
|
1359
|
+
setTimeout(() => reject(new Error(`${label} timed out after ${timeoutMs}ms (failover attempt)`)), timeoutMs);
|
|
1360
|
+
})
|
|
1361
|
+
]);
|
|
1362
|
+
}
|
|
1363
|
+
}
|
|
1364
|
+
catch (_) { /* failover recovery errors are non-fatal — throw original error */ }
|
|
1365
|
+
throw new Error(`${label} failed after ${maxRetries} attempts: ${(0, errors_1.getErrorMessage)(lastError)}`);
|
|
1220
1366
|
}
|
|
1221
1367
|
// ================================================================================
|
|
1222
1368
|
// SECTION 6: GENERAL UTILITIES
|
|
@@ -1250,7 +1396,7 @@ function deepFreeze(obj) {
|
|
|
1250
1396
|
if (obj === null || typeof obj !== 'object')
|
|
1251
1397
|
return obj;
|
|
1252
1398
|
Object.freeze(obj);
|
|
1253
|
-
Object.getOwnPropertyNames(obj).forEach(prop => {
|
|
1399
|
+
Object.getOwnPropertyNames(obj).forEach((prop) => {
|
|
1254
1400
|
if (Object.prototype.hasOwnProperty.call(obj, prop) &&
|
|
1255
1401
|
obj[prop] !== null &&
|
|
1256
1402
|
(typeof obj[prop] === 'object' || typeof obj[prop] === 'function') &&
|
|
@@ -1278,29 +1424,4 @@ function parseJsonWithComments(raw) {
|
|
|
1278
1424
|
const stripped = raw.replace(/\/\*(?:.|[\r\n])*?\*\//g, '').replace(/(^|\s*)\/\/.*$/gm, '');
|
|
1279
1425
|
return JSON.parse(stripped);
|
|
1280
1426
|
}
|
|
1281
|
-
module.exports = {
|
|
1282
|
-
lookupAsset,
|
|
1283
|
-
deriveMarketPrice,
|
|
1284
|
-
derivePoolPrice,
|
|
1285
|
-
derivePrice,
|
|
1286
|
-
resolveLiquidityPoolByShareAsset,
|
|
1287
|
-
deriveLiquidityPoolTokenValue,
|
|
1288
|
-
loadAmaCenterPrice,
|
|
1289
|
-
loadAmaCenterSnapshot,
|
|
1290
|
-
initializeFeeCache,
|
|
1291
|
-
persistGridSnapshot,
|
|
1292
|
-
retryPersistenceIfNeeded,
|
|
1293
|
-
applyGridDivergenceCorrections,
|
|
1294
|
-
syncBoundaryToFunds,
|
|
1295
|
-
ensureProfilesDirectory,
|
|
1296
|
-
sleep,
|
|
1297
|
-
readInput,
|
|
1298
|
-
readPassword,
|
|
1299
|
-
withRetry,
|
|
1300
|
-
resolveAccountRef,
|
|
1301
|
-
deepFreeze,
|
|
1302
|
-
cloneMap,
|
|
1303
|
-
ensureDir,
|
|
1304
|
-
parseJsonWithComments
|
|
1305
|
-
};
|
|
1306
1427
|
//# sourceMappingURL=system.js.map
|