dexbot 1.4.10 → 1.4.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -5
- package/dist/analysis/chart_utils.d.ts.map +1 -1
- package/dist/analysis/chart_utils.js +9 -18
- package/dist/analysis/chart_utils.js.map +1 -1
- package/dist/analysis/math_utils.d.ts.map +1 -1
- package/dist/analysis/math_utils.js +6 -16
- package/dist/analysis/math_utils.js.map +1 -1
- package/dist/analysis/tradingview/tradingview_uplot_chart_generator.d.ts +1 -1
- package/dist/analysis/tradingview/tradingview_uplot_chart_generator.d.ts.map +1 -1
- package/dist/analysis/tradingview/tradingview_uplot_chart_generator.js +31 -38
- package/dist/analysis/tradingview/tradingview_uplot_chart_generator.js.map +1 -1
- package/dist/analysis/trend_detection/hurst_analyzer.js +7 -10
- package/dist/analysis/trend_detection/hurst_analyzer.js.map +1 -1
- package/dist/analysis/trend_detection/kalman_trend_analyzer.js +10 -14
- package/dist/analysis/trend_detection/kalman_trend_analyzer.js.map +1 -1
- package/dist/analysis/trend_detection/kalman_velocity_smoothing.js +10 -15
- package/dist/analysis/trend_detection/kalman_velocity_smoothing.js.map +1 -1
- package/dist/analysis/trend_detection/permutation_entropy_analyzer.js +7 -10
- package/dist/analysis/trend_detection/permutation_entropy_analyzer.js.map +1 -1
- package/dist/bot.d.ts.map +1 -1
- package/dist/bot.js +4 -12
- package/dist/bot.js.map +1 -1
- package/dist/credential-daemon.d.ts +0 -1
- package/dist/credential-daemon.d.ts.map +1 -1
- package/dist/credential-daemon.js +3 -123
- package/dist/credential-daemon.js.map +1 -1
- package/dist/dexbot.d.ts +0 -87
- package/dist/dexbot.d.ts.map +1 -1
- package/dist/dexbot.js +54 -23
- package/dist/dexbot.js.map +1 -1
- package/dist/market_adapter/ama_signal_runner.js +8 -9
- package/dist/market_adapter/ama_signal_runner.js.map +1 -1
- package/dist/market_adapter/candle_utils.js +1 -7
- package/dist/market_adapter/candle_utils.js.map +1 -1
- package/dist/market_adapter/core/asymmetric_bounds.js +1 -4
- package/dist/market_adapter/core/asymmetric_bounds.js.map +1 -1
- package/dist/market_adapter/core/config_normalizers.js +5 -9
- package/dist/market_adapter/core/config_normalizers.js.map +1 -1
- package/dist/market_adapter/core/kibana_candles.js +8 -15
- package/dist/market_adapter/core/kibana_candles.js.map +1 -1
- package/dist/market_adapter/core/kibana_client.js +7 -13
- package/dist/market_adapter/core/kibana_client.js.map +1 -1
- package/dist/market_adapter/core/kibana_market_candles.js +6 -12
- package/dist/market_adapter/core/kibana_market_candles.js.map +1 -1
- package/dist/market_adapter/core/market_adapter_service.d.ts +2 -0
- package/dist/market_adapter/core/market_adapter_service.d.ts.map +1 -1
- package/dist/market_adapter/core/market_adapter_service.js +100 -101
- package/dist/market_adapter/core/market_adapter_service.js.map +1 -1
- package/dist/market_adapter/core/strategies/ama.js +5 -10
- package/dist/market_adapter/core/strategies/ama.js.map +1 -1
- package/dist/market_adapter/core/strategies/ama_slope_model.js +21 -24
- package/dist/market_adapter/core/strategies/ama_slope_model.js.map +1 -1
- package/dist/market_adapter/core/strategies/atr/calculator.js +3 -5
- package/dist/market_adapter/core/strategies/atr/calculator.js.map +1 -1
- package/dist/market_adapter/core/strategies/collateral_manager.js +4 -6
- package/dist/market_adapter/core/strategies/collateral_manager.js.map +1 -1
- package/dist/market_adapter/core/strategies/regime_gate.js +15 -22
- package/dist/market_adapter/core/strategies/regime_gate.js.map +1 -1
- package/dist/market_adapter/index.d.ts +23 -23
- package/dist/market_adapter/index.d.ts.map +1 -1
- package/dist/market_adapter/index.js +24 -82
- package/dist/market_adapter/index.js.map +1 -1
- package/dist/market_adapter/inputs/fetch_cex_synthetic_data.js +2 -1
- package/dist/market_adapter/inputs/fetch_cex_synthetic_data.js.map +1 -1
- package/dist/market_adapter/inputs/fetch_lp_data.d.ts.map +1 -1
- package/dist/market_adapter/inputs/fetch_lp_data.js +59 -98
- package/dist/market_adapter/inputs/fetch_lp_data.js.map +1 -1
- package/dist/market_adapter/inputs/kibana_source.js +11 -17
- package/dist/market_adapter/inputs/kibana_source.js.map +1 -1
- package/dist/market_adapter/interval_utils.js +1 -2
- package/dist/market_adapter/interval_utils.js.map +1 -1
- package/dist/market_adapter/log_format.js +1 -7
- package/dist/market_adapter/log_format.js.map +1 -1
- package/dist/market_adapter/lp_chart_core.js +20 -22
- package/dist/market_adapter/lp_chart_core.js.map +1 -1
- package/dist/market_adapter/lp_chart_runner.d.ts +1 -1
- package/dist/market_adapter/lp_chart_runner.d.ts.map +1 -1
- package/dist/market_adapter/lp_chart_runner.js +41 -57
- package/dist/market_adapter/lp_chart_runner.js.map +1 -1
- package/dist/market_adapter/lp_chart_strategy_loader.js +30 -34
- package/dist/market_adapter/lp_chart_strategy_loader.js.map +1 -1
- package/dist/market_adapter/market_adapter.d.ts +2 -2
- package/dist/market_adapter/market_adapter.d.ts.map +1 -1
- package/dist/market_adapter/market_adapter.js +163 -222
- package/dist/market_adapter/market_adapter.js.map +1 -1
- package/dist/market_adapter/merge_lp_data.js +17 -18
- package/dist/market_adapter/merge_lp_data.js.map +1 -1
- package/dist/market_adapter/test_helpers.js +3 -14
- package/dist/market_adapter/test_helpers.js.map +1 -1
- package/dist/market_adapter/utils/adapter_client.js +7 -16
- package/dist/market_adapter/utils/adapter_client.js.map +1 -1
- package/dist/market_adapter/utils/atomic_write.js +3 -5
- package/dist/market_adapter/utils/atomic_write.js.map +1 -1
- package/dist/market_adapter/utils/chain.d.ts.map +1 -1
- package/dist/market_adapter/utils/chain.js +9 -17
- package/dist/market_adapter/utils/chain.js.map +1 -1
- package/dist/market_adapter/utils/data_discovery.js +8 -10
- package/dist/market_adapter/utils/data_discovery.js.map +1 -1
- package/dist/market_adapter/utils/dynamic_grid_snapshot.d.ts.map +1 -1
- package/dist/market_adapter/utils/dynamic_grid_snapshot.js +11 -14
- package/dist/market_adapter/utils/dynamic_grid_snapshot.js.map +1 -1
- package/dist/market_adapter/utils/file_lock.js +14 -19
- package/dist/market_adapter/utils/file_lock.js.map +1 -1
- package/dist/market_adapter/utils/native_history.js +8 -14
- package/dist/market_adapter/utils/native_history.js.map +1 -1
- package/dist/market_adapter/utils/paths.js +3 -6
- package/dist/market_adapter/utils/paths.js.map +1 -1
- package/dist/modules/account_bots.d.ts +1 -1
- package/dist/modules/account_bots.d.ts.map +1 -1
- package/dist/modules/account_bots.js +90 -97
- package/dist/modules/account_bots.js.map +1 -1
- package/dist/modules/account_orders.d.ts +0 -9
- package/dist/modules/account_orders.d.ts.map +1 -1
- package/dist/modules/account_orders.js +26 -121
- package/dist/modules/account_orders.js.map +1 -1
- package/dist/modules/authority_resolver.js +12 -18
- package/dist/modules/authority_resolver.js.map +1 -1
- package/dist/modules/bitshares-native/chain_client.js +16 -21
- package/dist/modules/bitshares-native/chain_client.js.map +1 -1
- package/dist/modules/bitshares-native/crypto/ecc.browser.js +12 -72
- package/dist/modules/bitshares-native/crypto/ecc.browser.js.map +1 -1
- package/dist/modules/bitshares-native/crypto/ecc.js +13 -40
- package/dist/modules/bitshares-native/crypto/ecc.js.map +1 -1
- package/dist/modules/bitshares-native/crypto/ecc_selector.d.ts.map +1 -1
- package/dist/modules/bitshares-native/crypto/ecc_selector.js +5 -6
- package/dist/modules/bitshares-native/crypto/ecc_selector.js.map +1 -1
- package/dist/modules/bitshares-native/index.d.ts +8 -8
- package/dist/modules/bitshares-native/index.d.ts.map +1 -1
- package/dist/modules/bitshares-native/index.js +11 -68
- package/dist/modules/bitshares-native/index.js.map +1 -1
- package/dist/modules/bitshares-native/lru_cache.js +3 -6
- package/dist/modules/bitshares-native/lru_cache.js.map +1 -1
- package/dist/modules/bitshares-native/resolvers.js +9 -11
- package/dist/modules/bitshares-native/resolvers.js.map +1 -1
- package/dist/modules/bitshares-native/serial/chain_constants.js +3 -28
- package/dist/modules/bitshares-native/serial/chain_constants.js.map +1 -1
- package/dist/modules/bitshares-native/serial/index.d.ts +4 -4
- package/dist/modules/bitshares-native/serial/index.d.ts.map +1 -1
- package/dist/modules/bitshares-native/serial/index.js +5 -46
- package/dist/modules/bitshares-native/serial/index.js.map +1 -1
- package/dist/modules/bitshares-native/serial/operations.d.ts +98 -98
- package/dist/modules/bitshares-native/serial/operations.d.ts.map +1 -1
- package/dist/modules/bitshares-native/serial/operations.js +372 -473
- package/dist/modules/bitshares-native/serial/operations.js.map +1 -1
- package/dist/modules/bitshares-native/serial/serializer.js +3 -8
- package/dist/modules/bitshares-native/serial/serializer.js.map +1 -1
- package/dist/modules/bitshares-native/serial/types.js +9 -74
- package/dist/modules/bitshares-native/serial/types.js.map +1 -1
- package/dist/modules/bitshares-native/signing_client.d.ts.map +1 -1
- package/dist/modules/bitshares-native/signing_client.js +11 -48
- package/dist/modules/bitshares-native/signing_client.js.map +1 -1
- package/dist/modules/bitshares-native/subscriptions.d.ts.map +1 -1
- package/dist/modules/bitshares-native/subscriptions.js +24 -27
- package/dist/modules/bitshares-native/subscriptions.js.map +1 -1
- package/dist/modules/bitshares-native/transport.d.ts.map +1 -1
- package/dist/modules/bitshares-native/transport.js +14 -26
- package/dist/modules/bitshares-native/transport.js.map +1 -1
- package/dist/modules/bitshares-native/tx/builder.js +29 -72
- package/dist/modules/bitshares-native/tx/builder.js.map +1 -1
- package/dist/modules/bitshares-native/tx/tx_cache.js +12 -21
- package/dist/modules/bitshares-native/tx/tx_cache.js.map +1 -1
- package/dist/modules/bitshares_client.d.ts +21 -0
- package/dist/modules/bitshares_client.d.ts.map +1 -1
- package/dist/modules/bitshares_client.js +32 -86
- package/dist/modules/bitshares_client.js.map +1 -1
- package/dist/modules/bot_settings.d.ts.map +1 -1
- package/dist/modules/bot_settings.js +30 -49
- package/dist/modules/bot_settings.js.map +1 -1
- package/dist/modules/bots_file_lock.d.ts.map +1 -1
- package/dist/modules/bots_file_lock.js +5 -13
- package/dist/modules/bots_file_lock.js.map +1 -1
- package/dist/modules/broadcast_failure.js +1 -3
- package/dist/modules/broadcast_failure.js.map +1 -1
- package/dist/modules/chain_keys.d.ts +4 -9
- package/dist/modules/chain_keys.d.ts.map +1 -1
- package/dist/modules/chain_keys.js +77 -182
- package/dist/modules/chain_keys.js.map +1 -1
- package/dist/modules/chain_orders.d.ts +2 -2
- package/dist/modules/chain_orders.d.ts.map +1 -1
- package/dist/modules/chain_orders.js +81 -144
- package/dist/modules/chain_orders.js.map +1 -1
- package/dist/modules/config.d.ts.map +1 -1
- package/dist/modules/config.js +23 -28
- package/dist/modules/config.js.map +1 -1
- package/dist/modules/constants.d.ts +4 -14
- package/dist/modules/constants.d.ts.map +1 -1
- package/dist/modules/constants.js +46 -78
- package/dist/modules/constants.js.map +1 -1
- package/dist/modules/cr_planner.js +15 -26
- package/dist/modules/cr_planner.js.map +1 -1
- package/dist/modules/credential_policy.d.ts +3 -6
- package/dist/modules/credential_policy.d.ts.map +1 -1
- package/dist/modules/credential_policy.js +62 -153
- package/dist/modules/credential_policy.js.map +1 -1
- package/dist/modules/credential_runtime.d.ts +1 -1
- package/dist/modules/credential_runtime.d.ts.map +1 -1
- package/dist/modules/credential_runtime.js +34 -41
- package/dist/modules/credential_runtime.js.map +1 -1
- package/dist/modules/credential_session_cache.d.ts +1 -1
- package/dist/modules/credential_session_cache.d.ts.map +1 -1
- package/dist/modules/credential_session_cache.js +5 -42
- package/dist/modules/credential_session_cache.js.map +1 -1
- package/dist/modules/credit_runtime.d.ts.map +1 -1
- package/dist/modules/credit_runtime.js +126 -162
- package/dist/modules/credit_runtime.js.map +1 -1
- package/dist/modules/crypto/browser_provider.d.ts +1 -1
- package/dist/modules/crypto/browser_provider.d.ts.map +1 -1
- package/dist/modules/crypto/browser_provider.js +7 -11
- package/dist/modules/crypto/browser_provider.js.map +1 -1
- package/dist/modules/crypto/index.d.ts +6 -6
- package/dist/modules/crypto/index.d.ts.map +1 -1
- package/dist/modules/crypto/index.js +12 -30
- package/dist/modules/crypto/index.js.map +1 -1
- package/dist/modules/crypto/node_provider.d.ts +1 -1
- package/dist/modules/crypto/node_provider.d.ts.map +1 -1
- package/dist/modules/crypto/node_provider.js +3 -5
- package/dist/modules/crypto/node_provider.js.map +1 -1
- package/dist/modules/crypto/provider.js +1 -2
- package/dist/modules/crypto/pure_ripemd160.js +1 -3
- package/dist/modules/crypto/pure_ripemd160.js.map +1 -1
- package/dist/modules/crypto/pure_scrypt.js +1 -4
- package/dist/modules/crypto/pure_scrypt.js.map +1 -1
- package/dist/modules/crypto/pure_secp256k1.d.ts +1 -1
- package/dist/modules/crypto/pure_secp256k1.d.ts.map +1 -1
- package/dist/modules/crypto/pure_secp256k1.js +1 -16
- package/dist/modules/crypto/pure_secp256k1.js.map +1 -1
- package/dist/modules/crypto/sync.d.ts.map +1 -1
- package/dist/modules/crypto/sync.js +16 -17
- package/dist/modules/crypto/sync.js.map +1 -1
- package/dist/modules/daemon_node_health.js +14 -16
- package/dist/modules/daemon_node_health.js.map +1 -1
- package/dist/modules/dexbot_class.d.ts +19 -14
- package/dist/modules/dexbot_class.d.ts.map +1 -1
- package/dist/modules/dexbot_class.js +127 -164
- package/dist/modules/dexbot_class.js.map +1 -1
- package/dist/modules/dexbot_cow_runtime.d.ts +28 -27
- package/dist/modules/dexbot_cow_runtime.d.ts.map +1 -1
- package/dist/modules/dexbot_cow_runtime.js +55 -45
- package/dist/modules/dexbot_cow_runtime.js.map +1 -1
- package/dist/modules/dexbot_credential_client.d.ts +6 -2
- package/dist/modules/dexbot_credential_client.d.ts.map +1 -1
- package/dist/modules/dexbot_credential_client.js +21 -31
- package/dist/modules/dexbot_credential_client.js.map +1 -1
- package/dist/modules/dexbot_fill_runtime.d.ts +23 -23
- package/dist/modules/dexbot_fill_runtime.d.ts.map +1 -1
- package/dist/modules/dexbot_fill_runtime.js +119 -77
- package/dist/modules/dexbot_fill_runtime.js.map +1 -1
- package/dist/modules/dexbot_maintenance_runtime.d.ts +46 -38
- package/dist/modules/dexbot_maintenance_runtime.d.ts.map +1 -1
- package/dist/modules/dexbot_maintenance_runtime.js +81 -81
- package/dist/modules/dexbot_maintenance_runtime.js.map +1 -1
- package/dist/modules/dexbot_startup_runtime.d.ts +3 -3
- package/dist/modules/dexbot_startup_runtime.d.ts.map +1 -1
- package/dist/modules/dexbot_startup_runtime.js +43 -81
- package/dist/modules/dexbot_startup_runtime.js.map +1 -1
- package/dist/modules/dexbot_state_recovery.d.ts +11 -11
- package/dist/modules/dexbot_state_recovery.js +32 -78
- package/dist/modules/dexbot_state_recovery.js.map +1 -1
- package/dist/modules/env.js +3 -7
- package/dist/modules/env.js.map +1 -1
- package/dist/modules/fund_registry.d.ts.map +1 -1
- package/dist/modules/fund_registry.js +12 -24
- package/dist/modules/fund_registry.js.map +1 -1
- package/dist/modules/general_settings.js +10 -16
- package/dist/modules/general_settings.js.map +1 -1
- package/dist/modules/graceful_shutdown.d.ts.map +1 -1
- package/dist/modules/graceful_shutdown.js +12 -19
- package/dist/modules/graceful_shutdown.js.map +1 -1
- package/dist/modules/key_store.d.ts.map +1 -1
- package/dist/modules/key_store.js +27 -65
- package/dist/modules/key_store.js.map +1 -1
- package/dist/modules/launcher/bot_supervisor.d.ts +1 -1
- package/dist/modules/launcher/bot_supervisor.d.ts.map +1 -1
- package/dist/modules/launcher/bot_supervisor.js +89 -118
- package/dist/modules/launcher/bot_supervisor.js.map +1 -1
- package/dist/modules/launcher/child_env.js +1 -5
- package/dist/modules/launcher/child_env.js.map +1 -1
- package/dist/modules/launcher/credential_bootstrap.js +22 -31
- package/dist/modules/launcher/credential_bootstrap.js.map +1 -1
- package/dist/modules/launcher/credential_daemon.js +37 -75
- package/dist/modules/launcher/credential_daemon.js.map +1 -1
- package/dist/modules/launcher/credential_secret.js +2 -37
- package/dist/modules/launcher/credential_secret.js.map +1 -1
- package/dist/modules/launcher/foreign_cred_daemon.js +25 -31
- package/dist/modules/launcher/foreign_cred_daemon.js.map +1 -1
- package/dist/modules/launcher/headless_password.js +10 -12
- package/dist/modules/launcher/headless_password.js.map +1 -1
- package/dist/modules/launcher/launch_modes.js +3 -9
- package/dist/modules/launcher/launch_modes.js.map +1 -1
- package/dist/modules/launcher/market_adapter_runtime.d.ts +1 -1
- package/dist/modules/launcher/market_adapter_runtime.d.ts.map +1 -1
- package/dist/modules/launcher/market_adapter_runtime.js +25 -35
- package/dist/modules/launcher/market_adapter_runtime.js.map +1 -1
- package/dist/modules/launcher/market_adapter_watchdog.d.ts.map +1 -1
- package/dist/modules/launcher/market_adapter_watchdog.js +42 -45
- package/dist/modules/launcher/market_adapter_watchdog.js.map +1 -1
- package/dist/modules/launcher/monolithic_runtime.d.ts +3 -2
- package/dist/modules/launcher/monolithic_runtime.d.ts.map +1 -1
- package/dist/modules/launcher/monolithic_runtime.js +97 -138
- package/dist/modules/launcher/monolithic_runtime.js.map +1 -1
- package/dist/modules/launcher/runtime_entry.d.ts +1 -11
- package/dist/modules/launcher/runtime_entry.d.ts.map +1 -1
- package/dist/modules/launcher/runtime_entry.js +12 -15
- package/dist/modules/launcher/runtime_entry.js.map +1 -1
- package/dist/modules/launcher/status_reporting.d.ts +1 -1
- package/dist/modules/launcher/status_reporting.d.ts.map +1 -1
- package/dist/modules/launcher/status_reporting.js +15 -36
- package/dist/modules/launcher/status_reporting.js.map +1 -1
- package/dist/modules/launcher/supervisor_control.js +4 -9
- package/dist/modules/launcher/supervisor_control.js.map +1 -1
- package/dist/modules/logger.d.ts +1 -1
- package/dist/modules/logger.d.ts.map +1 -1
- package/dist/modules/logger.js +3 -38
- package/dist/modules/logger.js.map +1 -1
- package/dist/modules/market_adapter_whitelist.js +9 -18
- package/dist/modules/market_adapter_whitelist.js.map +1 -1
- package/dist/modules/node_failure_ledger.js +1 -3
- package/dist/modules/node_failure_ledger.js.map +1 -1
- package/dist/modules/node_health_cache.d.ts.map +1 -1
- package/dist/modules/node_health_cache.js +15 -25
- package/dist/modules/node_health_cache.js.map +1 -1
- package/dist/modules/node_manager.d.ts +1 -1
- package/dist/modules/node_manager.d.ts.map +1 -1
- package/dist/modules/node_manager.js +44 -43
- package/dist/modules/node_manager.js.map +1 -1
- package/dist/modules/order/accounting.d.ts.map +1 -1
- package/dist/modules/order/accounting.js +102 -118
- package/dist/modules/order/accounting.js.map +1 -1
- package/dist/modules/order/async_lock.d.ts +3 -15
- package/dist/modules/order/async_lock.d.ts.map +1 -1
- package/dist/modules/order/async_lock.js +6 -26
- package/dist/modules/order/async_lock.js.map +1 -1
- package/dist/modules/order/export.js +34 -75
- package/dist/modules/order/export.js.map +1 -1
- package/dist/modules/order/format.d.ts +1 -3
- package/dist/modules/order/format.d.ts.map +1 -1
- package/dist/modules/order/format.js +4 -24
- package/dist/modules/order/format.js.map +1 -1
- package/dist/modules/order/grid.d.ts +8 -8
- package/dist/modules/order/grid.d.ts.map +1 -1
- package/dist/modules/order/grid.js +254 -266
- package/dist/modules/order/grid.js.map +1 -1
- package/dist/modules/order/grid_reconcile.d.ts.map +1 -1
- package/dist/modules/order/grid_reconcile.js +77 -94
- package/dist/modules/order/grid_reconcile.js.map +1 -1
- package/dist/modules/order/grid_reconcile_internal.d.ts.map +1 -1
- package/dist/modules/order/grid_reconcile_internal.js +117 -149
- package/dist/modules/order/grid_reconcile_internal.js.map +1 -1
- package/dist/modules/order/index.d.ts.map +1 -1
- package/dist/modules/order/index.js +11 -45
- package/dist/modules/order/index.js.map +1 -1
- package/dist/modules/order/logger.d.ts +0 -8
- package/dist/modules/order/logger.d.ts.map +1 -1
- package/dist/modules/order/logger.js +28 -141
- package/dist/modules/order/logger.js.map +1 -1
- package/dist/modules/order/logger_state.d.ts.map +1 -1
- package/dist/modules/order/logger_state.js +3 -4
- package/dist/modules/order/logger_state.js.map +1 -1
- package/dist/modules/order/manager.d.ts +10 -79
- package/dist/modules/order/manager.d.ts.map +1 -1
- package/dist/modules/order/manager.js +131 -247
- package/dist/modules/order/manager.js.map +1 -1
- package/dist/modules/order/processed_fill_store.js +2 -7
- package/dist/modules/order/processed_fill_store.js.map +1 -1
- package/dist/modules/order/strategy.js +23 -25
- package/dist/modules/order/strategy.js.map +1 -1
- package/dist/modules/order/sync_engine.d.ts +27 -0
- package/dist/modules/order/sync_engine.d.ts.map +1 -1
- package/dist/modules/order/sync_engine.js +232 -181
- package/dist/modules/order/sync_engine.js.map +1 -1
- package/dist/modules/order/utils/math.d.ts +1 -25
- package/dist/modules/order/utils/math.d.ts.map +1 -1
- package/dist/modules/order/utils/math.js +49 -172
- package/dist/modules/order/utils/math.js.map +1 -1
- package/dist/modules/order/utils/order.d.ts +46 -2
- package/dist/modules/order/utils/order.d.ts.map +1 -1
- package/dist/modules/order/utils/order.js +165 -143
- package/dist/modules/order/utils/order.js.map +1 -1
- package/dist/modules/order/utils/system.d.ts +3 -1
- package/dist/modules/order/utils/system.d.ts.map +1 -1
- package/dist/modules/order/utils/system.js +152 -211
- package/dist/modules/order/utils/system.js.map +1 -1
- package/dist/modules/order/utils/timeout.js +1 -4
- package/dist/modules/order/utils/timeout.js.map +1 -1
- package/dist/modules/order/utils/validate.js +91 -142
- package/dist/modules/order/utils/validate.js.map +1 -1
- package/dist/modules/order/utils/withPoolRef.js +21 -61
- package/dist/modules/order/utils/withPoolRef.js.map +1 -1
- package/dist/modules/order/working_grid.js +6 -9
- package/dist/modules/order/working_grid.js.map +1 -1
- package/dist/modules/path_api.d.ts.map +1 -1
- package/dist/modules/path_api.js +8 -11
- package/dist/modules/path_api.js.map +1 -1
- package/dist/modules/paths.d.ts.map +1 -1
- package/dist/modules/paths.js +61 -67
- package/dist/modules/paths.js.map +1 -1
- package/dist/modules/process_discovery.d.ts.map +1 -1
- package/dist/modules/process_discovery.js +14 -23
- package/dist/modules/process_discovery.js.map +1 -1
- package/dist/modules/runtime.js +7 -11
- package/dist/modules/runtime.js.map +1 -1
- package/dist/modules/runtime_settings.d.ts.map +1 -1
- package/dist/modules/runtime_settings.js +14 -16
- package/dist/modules/runtime_settings.js.map +1 -1
- package/dist/modules/settings_merge.js +1 -3
- package/dist/modules/settings_merge.js.map +1 -1
- package/dist/modules/socket_json_client.js +3 -5
- package/dist/modules/socket_json_client.js.map +1 -1
- package/dist/modules/storage/browser_adapter.js +1 -4
- package/dist/modules/storage/browser_adapter.js.map +1 -1
- package/dist/modules/storage/index.d.ts +3 -2
- package/dist/modules/storage/index.d.ts.map +1 -1
- package/dist/modules/storage/index.js +5 -8
- package/dist/modules/storage/index.js.map +1 -1
- package/dist/modules/storage/node_adapter.d.ts +3 -4
- package/dist/modules/storage/node_adapter.d.ts.map +1 -1
- package/dist/modules/storage/node_adapter.js +12 -16
- package/dist/modules/storage/node_adapter.js.map +1 -1
- package/dist/modules/storage/types.js +1 -2
- package/dist/modules/types.d.ts +0 -6
- package/dist/modules/types.d.ts.map +1 -1
- package/dist/modules/types.js +1 -2
- package/dist/modules/types.js.map +1 -1
- package/dist/modules/utils/base58check.js +8 -15
- package/dist/modules/utils/base58check.js.map +1 -1
- package/dist/modules/utils/build_dir.js +3 -7
- package/dist/modules/utils/build_dir.js.map +1 -1
- package/dist/modules/utils/errors.js +1 -5
- package/dist/modules/utils/errors.js.map +1 -1
- package/dist/modules/utils/math_utils.d.ts +1 -1
- package/dist/modules/utils/math_utils.d.ts.map +1 -1
- package/dist/modules/utils/math_utils.js +2 -7
- package/dist/modules/utils/math_utils.js.map +1 -1
- package/dist/modules/validate_profiles.d.ts.map +1 -1
- package/dist/modules/validate_profiles.js +18 -25
- package/dist/modules/validate_profiles.js.map +1 -1
- package/dist/pm2.d.ts +4 -70
- package/dist/pm2.d.ts.map +1 -1
- package/dist/pm2.js +106 -132
- package/dist/pm2.js.map +1 -1
- package/dist/scripts/analyze-git.js +13 -17
- package/dist/scripts/analyze-git.js.map +1 -1
- package/dist/scripts/analyze-orders.d.ts.map +1 -1
- package/dist/scripts/analyze-orders.js +48 -63
- package/dist/scripts/analyze-orders.js.map +1 -1
- package/dist/scripts/diagnose-kibana-candles.d.ts.map +1 -1
- package/dist/scripts/diagnose-kibana-candles.js +2 -1
- package/dist/scripts/diagnose-kibana-candles.js.map +1 -1
- package/dist/scripts/diagnose-pool-history.d.ts.map +1 -1
- package/dist/scripts/diagnose-pool-history.js +2 -1
- package/dist/scripts/diagnose-pool-history.js.map +1 -1
- package/dist/scripts/divergence-calc.d.ts.map +1 -1
- package/dist/scripts/divergence-calc.js +2 -2
- package/dist/scripts/divergence-calc.js.map +1 -1
- package/dist/scripts/fix-err-message.js +17 -22
- package/dist/scripts/fix-err-message.js.map +1 -1
- package/dist/scripts/generate_lp_chart.d.ts.map +1 -1
- package/dist/scripts/generate_lp_chart.js +7 -15
- package/dist/scripts/generate_lp_chart.js.map +1 -1
- package/dist/scripts/generate_mainnet_corpus_report.d.ts.map +1 -1
- package/dist/scripts/generate_mainnet_corpus_report.js +3 -2
- package/dist/scripts/generate_mainnet_corpus_report.js.map +1 -1
- package/dist/scripts/generate_market_adapter_whitelist.d.ts.map +1 -1
- package/dist/scripts/generate_market_adapter_whitelist.js +18 -24
- package/dist/scripts/generate_market_adapter_whitelist.js.map +1 -1
- package/dist/scripts/native_release_gates.js +15 -19
- package/dist/scripts/native_release_gates.js.map +1 -1
- package/dist/scripts/print_grid.d.ts.map +1 -1
- package/dist/scripts/print_grid.js +2 -2
- package/dist/scripts/print_grid.js.map +1 -1
- package/dist/scripts/run-tests.js +12 -17
- package/dist/scripts/run-tests.js.map +1 -1
- package/dist/scripts/runner.d.ts.map +1 -1
- package/dist/scripts/runner.js +18 -20
- package/dist/scripts/runner.js.map +1 -1
- package/dist/scripts/sync-version.js +2 -2
- package/dist/scripts/sync-version.js.map +1 -1
- package/dist/scripts/test-credit-renewal.d.ts.map +1 -1
- package/dist/scripts/test-credit-renewal.js +4 -3
- package/dist/scripts/test-credit-renewal.js.map +1 -1
- package/dist/scripts/update.js +93 -95
- package/dist/scripts/update.js.map +1 -1
- package/dist/scripts/validate_bots.d.ts.map +1 -1
- package/dist/scripts/validate_bots.js +2 -2
- package/dist/scripts/validate_bots.js.map +1 -1
- package/dist/scripts/verify-browser-bundle.js +12 -17
- package/dist/scripts/verify-browser-bundle.js.map +1 -1
- package/dist/unlock.d.ts +0 -30
- package/dist/unlock.d.ts.map +1 -1
- package/dist/unlock.js +258 -222
- package/dist/unlock.js.map +1 -1
- package/package.json +5 -8
- package/scripts/README.md +1 -1
- package/scripts/create-bot-symlinks.sh +2 -2
- package/dist/modules/utils/fs_utils.d.ts +0 -18
- package/dist/modules/utils/fs_utils.d.ts.map +0 -1
- package/dist/modules/utils/fs_utils.js +0 -32
- package/dist/modules/utils/fs_utils.js.map +0 -1
- package/dist/scripts/migrate_bot_keys.d.ts +0 -3
- package/dist/scripts/migrate_bot_keys.d.ts.map +0 -1
- package/dist/scripts/migrate_bot_keys.js +0 -225
- package/dist/scripts/migrate_bot_keys.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"order.d.ts","sourceRoot":"","sources":["../../../../modules/order/utils/order.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqEG;
|
|
1
|
+
{"version":3,"file":"order.d.ts","sourceRoot":"","sources":["../../../../modules/order/utils/order.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqEG;AAeH;;;;;;;;;;;;;;;GAeG;AACH,iBAAS,uBAAuB,CAAC,OAAO,EAAE,GAAG,EAAE,OAAO,CAAC,EAAE,GAAG,WAW3D;AAgBD;;;;;;GAMG;AACH,iBAAS,8BAA8B,CAAC,OAAO,EAAE,GAAG;;;EA8BnD;AAED;;;;GAIG;AACH,iBAAS,6BAA6B,CAAC,OAAO,EAAE,GAAG,QAElD;AAED;;;;;;GAMG;AACH,iBAAS,sBAAsB,CAAC,OAAO,EAAE,GAAG;;;EAM3C;AAcD;;;;;;;;GAQG;AACH,iBAAS,eAAe,CAAC,UAAU,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG;;;;;SAmCpD;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,iBA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AAY,EAAE,oBAAoB,EAAE,sBAAsB,EAAE,oBAAoB,EAAE,aAAa,EAAE,sBAAsB,EAAE,wBAAwB,EAAE,uBAAuB,EAAE,8BAA8B,EAAE,6BAA6B,EAAE,sBAAsB,EAAE,CAAA"}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
/**
|
|
3
2
|
* modules/order/utils/order.ts - Order Domain Utilities
|
|
4
3
|
*
|
|
@@ -69,97 +68,127 @@
|
|
|
69
68
|
*
|
|
70
69
|
* ===============================================================================
|
|
71
70
|
*/
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
Object.defineProperty(o, k2, desc);
|
|
79
|
-
}) : (function(o, m, k, k2) {
|
|
80
|
-
if (k2 === undefined) k2 = k;
|
|
81
|
-
o[k2] = m[k];
|
|
82
|
-
}));
|
|
83
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
84
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
85
|
-
}) : function(o, v) {
|
|
86
|
-
o["default"] = v;
|
|
87
|
-
});
|
|
88
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
89
|
-
var ownKeys = function(o) {
|
|
90
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
91
|
-
var ar = [];
|
|
92
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
93
|
-
return ar;
|
|
94
|
-
};
|
|
95
|
-
return ownKeys(o);
|
|
96
|
-
};
|
|
97
|
-
return function (mod) {
|
|
98
|
-
if (mod && mod.__esModule) return mod;
|
|
99
|
-
var result = {};
|
|
100
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
101
|
-
__setModuleDefault(result, mod);
|
|
102
|
-
return result;
|
|
103
|
-
};
|
|
104
|
-
})();
|
|
105
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
106
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
107
|
-
};
|
|
108
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
109
|
-
exports.parseChainOrder = parseChainOrder;
|
|
110
|
-
exports.findMatchingGridOrderByOpenOrder = findMatchingGridOrderByOpenOrder;
|
|
111
|
-
exports.applyChainSizeToGridOrder = applyChainSizeToGridOrder;
|
|
112
|
-
exports.buildFillKey = buildFillKey;
|
|
113
|
-
exports.correctOrderPriceOnChain = correctOrderPriceOnChain;
|
|
114
|
-
exports.correctAllPriceMismatches = correctAllPriceMismatches;
|
|
115
|
-
exports.buildCreateOrderArgs = buildCreateOrderArgs;
|
|
116
|
-
exports.getOrderTypeFromUpdatedFlags = getOrderTypeFromUpdatedFlags;
|
|
117
|
-
exports.resolveConfiguredPriceBound = resolveConfiguredPriceBound;
|
|
118
|
-
exports.virtualizeOrder = virtualizeOrder;
|
|
119
|
-
exports.convertToSpreadPlaceholder = convertToSpreadPlaceholder;
|
|
120
|
-
exports.resolveSpreadOrderSide = resolveSpreadOrderSide;
|
|
121
|
-
exports.chainOrderMatchesSlot = chainOrderMatchesSlot;
|
|
122
|
-
exports.parseSlotIndex = parseSlotIndex;
|
|
123
|
-
exports.filterOrdersByType = filterOrdersByType;
|
|
124
|
-
exports.buildOutsideInPairGroups = buildOutsideInPairGroups;
|
|
125
|
-
exports.extractBatchOperationResults = extractBatchOperationResults;
|
|
126
|
-
exports.formatUnmatchedChainOrder = formatUnmatchedChainOrder;
|
|
127
|
-
exports.isOrderOnChain = isOrderOnChain;
|
|
128
|
-
exports.isOrderVirtual = isOrderVirtual;
|
|
129
|
-
exports.hasOnChainId = hasOnChainId;
|
|
130
|
-
exports.isOrderPlaced = isOrderPlaced;
|
|
131
|
-
exports.isPhantomOrder = isPhantomOrder;
|
|
132
|
-
exports.isSlotAvailable = isSlotAvailable;
|
|
133
|
-
exports.isEmptyGridSlot = isEmptyGridSlot;
|
|
134
|
-
exports.isOrderHealthy = isOrderHealthy;
|
|
135
|
-
exports.checkSizeThreshold = checkSizeThreshold;
|
|
136
|
-
exports.checkSizesBeforeMinimum = checkSizesBeforeMinimum;
|
|
137
|
-
exports.calculateIdealBoundary = calculateIdealBoundary;
|
|
138
|
-
exports.calculateFundDrivenBoundary = calculateFundDrivenBoundary;
|
|
139
|
-
exports.assignGridRoles = assignGridRoles;
|
|
140
|
-
exports.resolveOnChainRetypeType = resolveOnChainRetypeType;
|
|
141
|
-
exports.shouldFlagOutOfSpread = shouldFlagOutOfSpread;
|
|
142
|
-
exports.buildIndexes = buildIndexes;
|
|
143
|
-
exports.validateIndexes = validateIndexes;
|
|
144
|
-
exports.ordersEqual = ordersEqual;
|
|
145
|
-
exports.buildDelta = buildDelta;
|
|
146
|
-
exports.getOrderSize = getOrderSize;
|
|
147
|
-
exports.deriveTargetBoundary = deriveTargetBoundary;
|
|
148
|
-
exports.adjustBudgetForBtsFees = adjustBudgetForBtsFees;
|
|
149
|
-
exports.getActiveOrdersTotal = getActiveOrdersTotal;
|
|
150
|
-
exports.getSideBudget = getSideBudget;
|
|
151
|
-
exports.calculateBudgetedSizes = calculateBudgetedSizes;
|
|
152
|
-
exports.buildCreateOpFingerprint = buildCreateOpFingerprint;
|
|
153
|
-
const constants_1 = require("../../constants");
|
|
154
|
-
const Format = __importStar(require("../format"));
|
|
155
|
-
const MathUtils = __importStar(require("./math"));
|
|
156
|
-
const logger_1 = __importDefault(require("../../logger"));
|
|
157
|
-
const system_1 = require("./system");
|
|
158
|
-
const errors_1 = require("../../utils/errors");
|
|
71
|
+
import { ORDER_TYPES, ORDER_STATES, TIMING, FEE_PARAMETERS, GRID_LIMITS, NATIVE_CLIENT } from '../../constants.js';
|
|
72
|
+
import * as Format from '../format.js';
|
|
73
|
+
import * as MathUtils from './math.js';
|
|
74
|
+
import Logger from '../../logger.js';
|
|
75
|
+
import { sleep } from './system.js';
|
|
76
|
+
import { getErrorMessage } from '../../utils/errors.js';
|
|
159
77
|
const { isValidNumber, toFiniteNumber } = Format;
|
|
160
78
|
const { blockchainToFloat, floatToBlockchainInt, quantizeFloat, calculatePriceTolerance } = MathUtils;
|
|
161
|
-
const orderLogger = new
|
|
79
|
+
const orderLogger = new Logger('Order');
|
|
162
80
|
const ORDER_GONE_ERROR_FRAGMENT = 'not found';
|
|
81
|
+
/**
|
|
82
|
+
* Detect a "chain order does not exist" error from a broadcast/read failure.
|
|
83
|
+
* Single canonical implementation used by the correction, reconcile-cancel,
|
|
84
|
+
* dust-cancel, and residual-cancel paths.
|
|
85
|
+
*
|
|
86
|
+
* The explicit "order ... does not exist" phrasings always match. The legacy
|
|
87
|
+
* generic 'not found' fragment and the object-missing phrasings match as-is
|
|
88
|
+
* when no orderId is given (legacy order.ts behavior for the correction path);
|
|
89
|
+
* when an orderId IS given (dust/residual cancel paths) they additionally
|
|
90
|
+
* require the orderId to appear in the message, so an unrelated missing-object
|
|
91
|
+
* error is never mistaken for a gone order.
|
|
92
|
+
* @param {string} message - Error message to inspect.
|
|
93
|
+
* @param {string} [orderId] - Order ID required to be present in the message
|
|
94
|
+
* for generic object-missing phrasings (precision mode).
|
|
95
|
+
* @returns {boolean} True if the message indicates the order is gone.
|
|
96
|
+
*/
|
|
97
|
+
function isOrderGoneErrorMessage(message, orderId) {
|
|
98
|
+
if (typeof message !== 'string' || message.length === 0)
|
|
99
|
+
return false;
|
|
100
|
+
if (/\border\b.*\bdoes not exist\b/i.test(message))
|
|
101
|
+
return true;
|
|
102
|
+
if (/\bdoes not exist\b.*\border\b/i.test(message))
|
|
103
|
+
return true;
|
|
104
|
+
if (orderId && !message.toLowerCase().includes(String(orderId).toLowerCase()))
|
|
105
|
+
return false;
|
|
106
|
+
if (message.includes(ORDER_GONE_ERROR_FRAGMENT))
|
|
107
|
+
return true;
|
|
108
|
+
if (/\bdoes not exist\b/i.test(message))
|
|
109
|
+
return true;
|
|
110
|
+
if (/\bcould not find object\b/i.test(message))
|
|
111
|
+
return true;
|
|
112
|
+
if (/\bunable to find object\b/i.test(message))
|
|
113
|
+
return true;
|
|
114
|
+
if (/\bobject\b.*\bnot found\b/i.test(message))
|
|
115
|
+
return true;
|
|
116
|
+
return false;
|
|
117
|
+
}
|
|
118
|
+
// ---------------------------------------------------------------------------
|
|
119
|
+
// Persistent duplicate-orphan detection escalation. A duplicate-price-level
|
|
120
|
+
// orphan is expected self-healing (fully filled order leaves a sub-dust
|
|
121
|
+
// residual that collides with the rotated replacement). First sightings log at
|
|
122
|
+
// info; if the SAME orderId keeps being re-detected — its cancel keeps failing
|
|
123
|
+
// or it keeps getting re-created — the detection sites escalate to warn so the
|
|
124
|
+
// silent loop is surfaced instead of degrading quietly. Reuses the existing
|
|
125
|
+
// warn-rate-limit and recent-orderId-map tuning from constants.ts rather than
|
|
126
|
+
// defining new knobs: repeats are rate-limited by TIMING.STALE_TOTALS_WARN_
|
|
127
|
+
// RATE_LIMIT_MS and the counter map is capped by ORDER_EVENTS.
|
|
128
|
+
// RECENT_OWN_CANCEL_MAX_ENTRIES (same lazy-GC pattern as chain_orders.ts).
|
|
129
|
+
// ---------------------------------------------------------------------------
|
|
130
|
+
const _duplicateOrphanDetections = new Map();
|
|
131
|
+
/**
|
|
132
|
+
* Record a duplicate-orphan detection for an orderId.
|
|
133
|
+
* First sighting stays quiet (count 1). A repeated sighting of the same
|
|
134
|
+
* orderId escalates, but no more often than TIMING.STALE_TOTALS_WARN_RATE_LIMIT_MS.
|
|
135
|
+
* @param {string} orderId - Duplicate orphan chain order ID.
|
|
136
|
+
* @returns {{ count: number; shouldEscalate: boolean }} Detection stats.
|
|
137
|
+
*/
|
|
138
|
+
function recordDuplicateOrphanDetection(orderId) {
|
|
139
|
+
if (!orderId)
|
|
140
|
+
return { count: 0, shouldEscalate: false };
|
|
141
|
+
const warnRateLimitMs = Number.isFinite(TIMING?.STALE_TOTALS_WARN_RATE_LIMIT_MS)
|
|
142
|
+
? TIMING.STALE_TOTALS_WARN_RATE_LIMIT_MS
|
|
143
|
+
: 60000;
|
|
144
|
+
const maxEntries = Number.isFinite(NATIVE_CLIENT?.ORDER_EVENTS?.RECENT_OWN_CANCEL_MAX_ENTRIES)
|
|
145
|
+
? NATIVE_CLIENT.ORDER_EVENTS.RECENT_OWN_CANCEL_MAX_ENTRIES
|
|
146
|
+
: 256;
|
|
147
|
+
const now = Date.now();
|
|
148
|
+
const existing = _duplicateOrphanDetections.get(String(orderId));
|
|
149
|
+
const count = existing ? existing.count + 1 : 1;
|
|
150
|
+
let shouldEscalate = false;
|
|
151
|
+
let lastWarnAt = existing ? existing.lastWarnAt : null;
|
|
152
|
+
if (count >= 2 && (lastWarnAt == null || now - lastWarnAt >= warnRateLimitMs)) {
|
|
153
|
+
shouldEscalate = true;
|
|
154
|
+
lastWarnAt = now;
|
|
155
|
+
}
|
|
156
|
+
_duplicateOrphanDetections.set(String(orderId), { count, lastWarnAt });
|
|
157
|
+
// Lazy GC: drop the oldest entries when the map exceeds the shared budget.
|
|
158
|
+
if (_duplicateOrphanDetections.size > maxEntries) {
|
|
159
|
+
let toDelete = _duplicateOrphanDetections.size - maxEntries;
|
|
160
|
+
for (const [id] of _duplicateOrphanDetections) {
|
|
161
|
+
if (toDelete <= 0)
|
|
162
|
+
break;
|
|
163
|
+
_duplicateOrphanDetections.delete(id);
|
|
164
|
+
toDelete--;
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
return { count, shouldEscalate };
|
|
168
|
+
}
|
|
169
|
+
/**
|
|
170
|
+
* Clear the detection counter for an orderId (e.g. after a confirmed cancel),
|
|
171
|
+
* so a resolved orphan never lingers and false-escalates later.
|
|
172
|
+
* @param {string} orderId - Chain order ID to forget.
|
|
173
|
+
*/
|
|
174
|
+
function clearDuplicateOrphanDetection(orderId) {
|
|
175
|
+
if (orderId)
|
|
176
|
+
_duplicateOrphanDetections.delete(String(orderId));
|
|
177
|
+
}
|
|
178
|
+
/**
|
|
179
|
+
* Record a duplicate-orphan detection and return the log level + re-detection
|
|
180
|
+
* suffix for the caller's diagnostic line. First sightings log at info; a
|
|
181
|
+
* repeat escalates to warn (rate-limited).
|
|
182
|
+
* @param {string} orderId - Duplicate orphan chain order ID.
|
|
183
|
+
* @returns {{ level: 'info'|'warn'; suffix: string }} Log level and suffix text.
|
|
184
|
+
*/
|
|
185
|
+
function duplicateOrphanLogInfo(orderId) {
|
|
186
|
+
const { count, shouldEscalate } = recordDuplicateOrphanDetection(orderId);
|
|
187
|
+
return {
|
|
188
|
+
level: shouldEscalate ? 'warn' : 'info',
|
|
189
|
+
suffix: count > 1 ? ` [re-detected ${count}×; cancel may be failing or the order keeps getting re-created]` : '',
|
|
190
|
+
};
|
|
191
|
+
}
|
|
163
192
|
function _filterUnmatchedChainOrders(manager, chainOrderId) {
|
|
164
193
|
if (Array.isArray(manager._lastUnmatchedChainOrders)) {
|
|
165
194
|
manager._lastUnmatchedChainOrders = manager._lastUnmatchedChainOrders.filter((u) => (u?.id || u?.orderId || u?.chainOrderId) !== chainOrderId);
|
|
@@ -193,25 +222,25 @@ function parseChainOrder(chainOrder, assets) {
|
|
|
193
222
|
price = precisionDelta >= 0
|
|
194
223
|
? (quote.amount / base.amount) * scaleFactor
|
|
195
224
|
: (quote.amount / base.amount) / scaleFactor;
|
|
196
|
-
type =
|
|
225
|
+
type = ORDER_TYPES.SELL;
|
|
197
226
|
}
|
|
198
227
|
else if (base.asset_id === assets.assetB.id && quote.asset_id === assets.assetA.id) {
|
|
199
228
|
price = precisionDelta >= 0
|
|
200
229
|
? (base.amount / quote.amount) * scaleFactor
|
|
201
230
|
: (base.amount / quote.amount) / scaleFactor;
|
|
202
|
-
type =
|
|
231
|
+
type = ORDER_TYPES.BUY;
|
|
203
232
|
}
|
|
204
233
|
else
|
|
205
234
|
return null;
|
|
206
235
|
let size;
|
|
207
236
|
try {
|
|
208
237
|
if (chainOrder.for_sale !== undefined && chainOrder.for_sale !== null) {
|
|
209
|
-
const prec = (type ===
|
|
238
|
+
const prec = (type === ORDER_TYPES.SELL) ? assets.assetA.precision : assets.assetB.precision;
|
|
210
239
|
size = blockchainToFloat(toFiniteNumber(chainOrder.for_sale), prec);
|
|
211
240
|
}
|
|
212
241
|
}
|
|
213
242
|
catch (e) {
|
|
214
|
-
orderLogger.warn(`parseChainOrder failed for ${chainOrder?.id}: ${
|
|
243
|
+
orderLogger.warn(`parseChainOrder failed for ${chainOrder?.id}: ${getErrorMessage(e)}`);
|
|
215
244
|
return null;
|
|
216
245
|
}
|
|
217
246
|
return { orderId: chainOrder.id, price, type, size };
|
|
@@ -245,7 +274,7 @@ function findMatchingGridOrderByOpenOrder(parsedChainOrder, opts) {
|
|
|
245
274
|
}
|
|
246
275
|
const chainSize = toFiniteNumber(parsedChainOrder.size);
|
|
247
276
|
const chainPrice = toFiniteNumber(parsedChainOrder.price);
|
|
248
|
-
const isSell = parsedChainOrder.type ===
|
|
277
|
+
const isSell = parsedChainOrder.type === ORDER_TYPES.SELL;
|
|
249
278
|
const precision = isSell ? assets?.assetA?.precision : assets?.assetB?.precision;
|
|
250
279
|
if (typeof precision !== 'number')
|
|
251
280
|
return null;
|
|
@@ -254,12 +283,12 @@ function findMatchingGridOrderByOpenOrder(parsedChainOrder, opts) {
|
|
|
254
283
|
let bestPriceDiff = Infinity;
|
|
255
284
|
for (const gridOrder of orders.values()) {
|
|
256
285
|
const typeMatch = gridOrder?.type === parsedChainOrder.type ||
|
|
257
|
-
(opts?.allowSpreadType && gridOrder?.type ===
|
|
286
|
+
(opts?.allowSpreadType && gridOrder?.type === ORDER_TYPES.SPREAD);
|
|
258
287
|
if (!gridOrder || !typeMatch)
|
|
259
288
|
continue;
|
|
260
289
|
if (opts?.excludeGridOrderIds?.has?.(gridOrder.id))
|
|
261
290
|
continue;
|
|
262
|
-
if (![
|
|
291
|
+
if (![ORDER_STATES.ACTIVE, ORDER_STATES.PARTIAL, ORDER_STATES.VIRTUAL].includes(gridOrder.state))
|
|
263
292
|
continue;
|
|
264
293
|
if (opts?.requireAvailableSlot && gridOrder.orderId && gridOrder.orderId !== parsedChainOrder.orderId)
|
|
265
294
|
continue;
|
|
@@ -287,7 +316,6 @@ function findMatchingGridOrderByOpenOrder(parsedChainOrder, opts) {
|
|
|
287
316
|
/**
|
|
288
317
|
* Update grid order size based on blockchain state.
|
|
289
318
|
* Detects partial fills and updates accounting if size changed.
|
|
290
|
-
* Skips dust refills (prevents unnecessary sync when size decreases).
|
|
291
319
|
*
|
|
292
320
|
* Returns the updated order object or null if no update needed.
|
|
293
321
|
*
|
|
@@ -300,9 +328,9 @@ function findMatchingGridOrderByOpenOrder(parsedChainOrder, opts) {
|
|
|
300
328
|
async function applyChainSizeToGridOrder(manager, gridOrder, chainSize) {
|
|
301
329
|
if (!manager || !gridOrder)
|
|
302
330
|
return null;
|
|
303
|
-
if (gridOrder.state !==
|
|
331
|
+
if (gridOrder.state !== ORDER_STATES.ACTIVE && gridOrder.state !== ORDER_STATES.PARTIAL)
|
|
304
332
|
return null;
|
|
305
|
-
const precision = (gridOrder.type ===
|
|
333
|
+
const precision = (gridOrder.type === ORDER_TYPES.SELL) ? manager.assets?.assetA?.precision : manager.assets?.assetB?.precision;
|
|
306
334
|
if (isValidNumber(precision) && isValidNumber(chainSize)) {
|
|
307
335
|
const SUSPICIOUS_SATOSHI_LIMIT = 1e15;
|
|
308
336
|
const suspiciousThreshold = SUSPICIOUS_SATOSHI_LIMIT / Math.pow(10, precision);
|
|
@@ -314,15 +342,6 @@ async function applyChainSizeToGridOrder(manager, gridOrder, chainSize) {
|
|
|
314
342
|
}
|
|
315
343
|
const oldSize = toFiniteNumber(gridOrder.size);
|
|
316
344
|
const newSize = isValidNumber(chainSize) ? toFiniteNumber(chainSize) : oldSize;
|
|
317
|
-
if (gridOrder.isDustRefill && newSize < oldSize) {
|
|
318
|
-
const oldInt = floatToBlockchainInt(oldSize, precision);
|
|
319
|
-
const newInt = floatToBlockchainInt(newSize, precision);
|
|
320
|
-
const deltaInt = Math.max(0, oldInt - newInt);
|
|
321
|
-
// Ignore only negligible one-unit quantization noise on dust refill orders.
|
|
322
|
-
// Real decreases must still be synchronized to avoid stuck PARTIAL states.
|
|
323
|
-
if (deltaInt <= 1)
|
|
324
|
-
return null;
|
|
325
|
-
}
|
|
326
345
|
if (floatToBlockchainInt(oldSize, precision) === floatToBlockchainInt(newSize, precision)) {
|
|
327
346
|
return null;
|
|
328
347
|
}
|
|
@@ -374,20 +393,22 @@ async function correctOrderPriceOnChain(manager, correctionInfo, accountName, pr
|
|
|
374
393
|
if (cancelOnly) {
|
|
375
394
|
let shouldRemove = false;
|
|
376
395
|
try {
|
|
377
|
-
const sideLabel = type ===
|
|
396
|
+
const sideLabel = type === ORDER_TYPES.SELL ? 'SELL' : 'BUY';
|
|
378
397
|
manager.logger?.log?.(`[CORRECTION] Cancelling duplicate orphan ${sideLabel} order ${chainOrderId}`, 'info');
|
|
379
398
|
await accountOrders.cancelOrder(accountName, privateKey, chainOrderId);
|
|
399
|
+
clearDuplicateOrphanDetection(chainOrderId);
|
|
380
400
|
_filterUnmatchedChainOrders(manager, chainOrderId);
|
|
381
401
|
shouldRemove = true;
|
|
382
402
|
return { success: true, cancelled: true };
|
|
383
403
|
}
|
|
384
404
|
catch (error) {
|
|
385
|
-
const orderGone = (
|
|
405
|
+
const orderGone = isOrderGoneErrorMessage(getErrorMessage(error));
|
|
386
406
|
if (orderGone) {
|
|
407
|
+
clearDuplicateOrphanDetection(chainOrderId);
|
|
387
408
|
shouldRemove = true;
|
|
388
409
|
_filterUnmatchedChainOrders(manager, chainOrderId);
|
|
389
410
|
}
|
|
390
|
-
return { success: false, error:
|
|
411
|
+
return { success: false, error: getErrorMessage(error), orderGone };
|
|
391
412
|
}
|
|
392
413
|
finally {
|
|
393
414
|
if (shouldRemove) {
|
|
@@ -399,7 +420,7 @@ async function correctOrderPriceOnChain(manager, correctionInfo, accountName, pr
|
|
|
399
420
|
if (isSurplus) {
|
|
400
421
|
let shouldRemove = false;
|
|
401
422
|
try {
|
|
402
|
-
const sideLabel = type ===
|
|
423
|
+
const sideLabel = type === ORDER_TYPES.SELL ? 'SELL' : 'BUY';
|
|
403
424
|
manager.logger?.log?.(`[CORRECTION] Cancelling surplus/mismatched ${sideLabel} order ${chainOrderId} for slot ${gridOrder?.id || 'unknown'}`, 'info');
|
|
404
425
|
await accountOrders.cancelOrder(accountName, privateKey, chainOrderId);
|
|
405
426
|
if (gridOrder && manager._applyOrderUpdate) {
|
|
@@ -414,12 +435,12 @@ async function correctOrderPriceOnChain(manager, correctionInfo, accountName, pr
|
|
|
414
435
|
return { success: true, cancelled: true };
|
|
415
436
|
}
|
|
416
437
|
catch (error) {
|
|
417
|
-
const orderGone =
|
|
438
|
+
const orderGone = getErrorMessage(error)?.includes(ORDER_GONE_ERROR_FRAGMENT);
|
|
418
439
|
if (orderGone) {
|
|
419
440
|
shouldRemove = true;
|
|
420
441
|
_filterUnmatchedChainOrders(manager, chainOrderId);
|
|
421
442
|
}
|
|
422
|
-
return { success: false, error:
|
|
443
|
+
return { success: false, error: getErrorMessage(error), orderGone };
|
|
423
444
|
}
|
|
424
445
|
finally {
|
|
425
446
|
if (shouldRemove) {
|
|
@@ -428,7 +449,7 @@ async function correctOrderPriceOnChain(manager, correctionInfo, accountName, pr
|
|
|
428
449
|
}
|
|
429
450
|
}
|
|
430
451
|
let amountToSell, minToReceive;
|
|
431
|
-
if (type ===
|
|
452
|
+
if (type === ORDER_TYPES.SELL) {
|
|
432
453
|
amountToSell = size;
|
|
433
454
|
minToReceive = size * expectedPrice;
|
|
434
455
|
}
|
|
@@ -447,7 +468,7 @@ async function correctOrderPriceOnChain(manager, correctionInfo, accountName, pr
|
|
|
447
468
|
return { success: true };
|
|
448
469
|
}
|
|
449
470
|
catch (error) {
|
|
450
|
-
const orderGone =
|
|
471
|
+
const orderGone = getErrorMessage(error)?.includes(ORDER_GONE_ERROR_FRAGMENT);
|
|
451
472
|
if (orderGone) {
|
|
452
473
|
shouldRemove = true;
|
|
453
474
|
_filterUnmatchedChainOrders(manager, chainOrderId);
|
|
@@ -462,7 +483,7 @@ async function correctOrderPriceOnChain(manager, correctionInfo, accountName, pr
|
|
|
462
483
|
shouldRemove = true;
|
|
463
484
|
manager.logger?.log?.(`[CORRECTION] Uncertain price update for ${chainOrderId}; deferring verification to next sync re-detection`, 'warn');
|
|
464
485
|
}
|
|
465
|
-
return { success: false, error:
|
|
486
|
+
return { success: false, error: getErrorMessage(error), orderGone };
|
|
466
487
|
}
|
|
467
488
|
finally {
|
|
468
489
|
if (shouldRemove) {
|
|
@@ -501,7 +522,7 @@ async function correctAllPriceMismatches(manager, accountName, privateKey, accou
|
|
|
501
522
|
corrected++;
|
|
502
523
|
else
|
|
503
524
|
failed++;
|
|
504
|
-
await
|
|
525
|
+
await sleep(TIMING.SYNC_DELAY_MS);
|
|
505
526
|
}
|
|
506
527
|
// Persist master grid mutations from surplus-type-mismatch cancellations.
|
|
507
528
|
// Without this, corrections that cancel an order and convert its grid slot
|
|
@@ -632,7 +653,7 @@ function virtualizeOrder(order) {
|
|
|
632
653
|
if (!order)
|
|
633
654
|
return order;
|
|
634
655
|
const { btsFeeState, ...rest } = order;
|
|
635
|
-
return { ...rest, state:
|
|
656
|
+
return { ...rest, state: ORDER_STATES.VIRTUAL, orderId: null, rawOnChain: null };
|
|
636
657
|
}
|
|
637
658
|
/**
|
|
638
659
|
* Convert order to spread placeholder (virtual, zero-sized spread order).
|
|
@@ -642,7 +663,7 @@ function virtualizeOrder(order) {
|
|
|
642
663
|
* @returns {Object} Spread placeholder order (VIRTUAL, SPREAD type, zero size)
|
|
643
664
|
*/
|
|
644
665
|
function convertToSpreadPlaceholder(order) {
|
|
645
|
-
return { ...virtualizeOrder(order), type:
|
|
666
|
+
return { ...virtualizeOrder(order), type: ORDER_TYPES.SPREAD, size: 0 };
|
|
646
667
|
}
|
|
647
668
|
/**
|
|
648
669
|
* Resolve the real BUY/SELL side of a SPREAD-typed grid slot from its price
|
|
@@ -656,7 +677,7 @@ function convertToSpreadPlaceholder(order) {
|
|
|
656
677
|
* @returns {string} ORDER_TYPES.BUY or ORDER_TYPES.SELL
|
|
657
678
|
*/
|
|
658
679
|
function resolveSpreadOrderSide(price, startPrice) {
|
|
659
|
-
return Number(price) < Number(startPrice) ?
|
|
680
|
+
return Number(price) < Number(startPrice) ? ORDER_TYPES.BUY : ORDER_TYPES.SELL;
|
|
660
681
|
}
|
|
661
682
|
/**
|
|
662
683
|
* Parse a grid slot id ("slot-123") to its rail index. Slot ids are assigned
|
|
@@ -690,12 +711,12 @@ function parseSlotIndex(id) {
|
|
|
690
711
|
function chainOrderMatchesSlot(parsed, slot, assets) {
|
|
691
712
|
if (!parsed || !slot || !assets)
|
|
692
713
|
return false;
|
|
693
|
-
if (parsed.type !== slot.type && slot.type !==
|
|
714
|
+
if (parsed.type !== slot.type && slot.type !== ORDER_TYPES.SPREAD)
|
|
694
715
|
return false;
|
|
695
716
|
const priceTolerance = calculatePriceTolerance(slot.price, slot.size, parsed.type, assets) || 0;
|
|
696
717
|
if (Math.abs(parsed.price - slot.price) > priceTolerance)
|
|
697
718
|
return false;
|
|
698
|
-
const precision = parsed.type ===
|
|
719
|
+
const precision = parsed.type === ORDER_TYPES.SELL ? assets.assetA.precision : assets.assetB.precision;
|
|
699
720
|
const sizeTolerance = Math.max(2, Math.floor(floatToBlockchainInt(slot.size, precision) * 0.01));
|
|
700
721
|
if (Math.abs(floatToBlockchainInt(parsed.size, precision) - floatToBlockchainInt(slot.size, precision)) > sizeTolerance)
|
|
701
722
|
return false;
|
|
@@ -731,10 +752,10 @@ function buildOutsideInPairGroups(items, { isValid = Boolean, getType, getPrice
|
|
|
731
752
|
if (safeItems.length === 0)
|
|
732
753
|
return [];
|
|
733
754
|
const sellItems = safeItems
|
|
734
|
-
.filter((item) => getType(item) ===
|
|
755
|
+
.filter((item) => getType(item) === ORDER_TYPES.SELL)
|
|
735
756
|
.sort((a, b) => Number(getPrice(b) || 0) - Number(getPrice(a) || 0));
|
|
736
757
|
const buyItems = safeItems
|
|
737
|
-
.filter((item) => getType(item) ===
|
|
758
|
+
.filter((item) => getType(item) === ORDER_TYPES.BUY)
|
|
738
759
|
.sort((a, b) => Number(getPrice(a) || 0) - Number(getPrice(b) || 0));
|
|
739
760
|
const groups = [];
|
|
740
761
|
const maxLen = Math.max(sellItems.length, buyItems.length);
|
|
@@ -796,7 +817,7 @@ function formatUnmatchedChainOrder(order) {
|
|
|
796
817
|
* @returns {boolean} True if order has on-chain state
|
|
797
818
|
*/
|
|
798
819
|
function isOrderOnChain(order) {
|
|
799
|
-
return (order?.state ===
|
|
820
|
+
return (order?.state === ORDER_STATES.ACTIVE || order?.state === ORDER_STATES.PARTIAL) && !!order?.orderId;
|
|
800
821
|
}
|
|
801
822
|
/**
|
|
802
823
|
* Resolve the type to keep when a slot holding a live on-chain order would
|
|
@@ -828,7 +849,7 @@ function resolveOnChainRetypeType(slot, idx, buyEndIdx, ORDER_TYPES) {
|
|
|
828
849
|
* @param {Object} order - Order to check
|
|
829
850
|
* @returns {boolean} True if order in VIRTUAL state
|
|
830
851
|
*/
|
|
831
|
-
function isOrderVirtual(order) { return order?.state ===
|
|
852
|
+
function isOrderVirtual(order) { return order?.state === ORDER_STATES.VIRTUAL; }
|
|
832
853
|
/**
|
|
833
854
|
* Whether a slot is an empty reusable placeholder: VIRTUAL, no chain order,
|
|
834
855
|
* and zero size. Empty slots are normalized to SPREAD (side-neutral) so their
|
|
@@ -855,7 +876,7 @@ function isEmptyGridSlot(slot, liveSlot = null, opts = {}) {
|
|
|
855
876
|
if (!slot)
|
|
856
877
|
return false;
|
|
857
878
|
const target = liveSlot || slot;
|
|
858
|
-
if (target.state !==
|
|
879
|
+
if (target.state !== ORDER_STATES.VIRTUAL)
|
|
859
880
|
return false;
|
|
860
881
|
if (target.orderId)
|
|
861
882
|
return false;
|
|
@@ -888,7 +909,7 @@ function isOrderPlaced(order) { return isOrderOnChain(order) && hasOnChainId(ord
|
|
|
888
909
|
* @returns {boolean} True if order appears on-chain but has no ID
|
|
889
910
|
*/
|
|
890
911
|
function isPhantomOrder(order) {
|
|
891
|
-
const inOnChainState = order?.state ===
|
|
912
|
+
const inOnChainState = order?.state === ORDER_STATES.ACTIVE || order?.state === ORDER_STATES.PARTIAL;
|
|
892
913
|
return inOnChainState && !hasOnChainId(order);
|
|
893
914
|
}
|
|
894
915
|
/**
|
|
@@ -916,7 +937,7 @@ function isOrderHealthy(size, type, assets, idealSize) {
|
|
|
916
937
|
return false;
|
|
917
938
|
if (!Number.isFinite(numericIdeal) || numericIdeal <= 0)
|
|
918
939
|
return false;
|
|
919
|
-
return MathUtils.validateOrderSize(numericSize, type, assets,
|
|
940
|
+
return MathUtils.validateOrderSize(numericSize, type, assets, GRID_LIMITS.MIN_ORDER_SIZE_FACTOR, numericIdeal, GRID_LIMITS.PARTIAL_DUST_THRESHOLD_PERCENTAGE).isValid;
|
|
920
941
|
}
|
|
921
942
|
/**
|
|
922
943
|
* Check if any size in array falls below threshold.
|
|
@@ -1087,12 +1108,12 @@ function shouldFlagOutOfSpread(currentSpread, nominalSpread, toleranceSteps, buy
|
|
|
1087
1108
|
*/
|
|
1088
1109
|
function buildIndexes(grid) {
|
|
1089
1110
|
const indexes = {
|
|
1090
|
-
[
|
|
1091
|
-
[
|
|
1092
|
-
[
|
|
1093
|
-
[
|
|
1094
|
-
[
|
|
1095
|
-
[
|
|
1111
|
+
[ORDER_STATES.VIRTUAL]: new Set(),
|
|
1112
|
+
[ORDER_STATES.ACTIVE]: new Set(),
|
|
1113
|
+
[ORDER_STATES.PARTIAL]: new Set(),
|
|
1114
|
+
[ORDER_TYPES.BUY]: new Set(),
|
|
1115
|
+
[ORDER_TYPES.SELL]: new Set(),
|
|
1116
|
+
[ORDER_TYPES.SPREAD]: new Set()
|
|
1096
1117
|
};
|
|
1097
1118
|
for (const order of grid.values()) {
|
|
1098
1119
|
const stateKey = order.state;
|
|
@@ -1139,7 +1160,7 @@ function validateIndexes(grid, indexes) {
|
|
|
1139
1160
|
// ================================================================================
|
|
1140
1161
|
function _getRelativeTolerance(configOverride) {
|
|
1141
1162
|
const raw = configOverride?.gridLimits?.RELATIVE_ORDER_UPDATE_THRESHOLD_PERCENT
|
|
1142
|
-
??
|
|
1163
|
+
?? GRID_LIMITS.RELATIVE_ORDER_UPDATE_THRESHOLD_PERCENT;
|
|
1143
1164
|
return Number(raw) / 100;
|
|
1144
1165
|
}
|
|
1145
1166
|
const ORDER_RELATIVE_TOLERANCE = _getRelativeTolerance();
|
|
@@ -1183,9 +1204,9 @@ function observedQuantum(a, b) {
|
|
|
1183
1204
|
function resolveOrderSizePrecision(orderType, precisions = {}) {
|
|
1184
1205
|
if (!precisions || typeof precisions !== 'object')
|
|
1185
1206
|
return null;
|
|
1186
|
-
if (orderType ===
|
|
1207
|
+
if (orderType === ORDER_TYPES.BUY)
|
|
1187
1208
|
return parseOptionalPrecision(precisions.buyPrecision);
|
|
1188
|
-
if (orderType ===
|
|
1209
|
+
if (orderType === ORDER_TYPES.SELL)
|
|
1189
1210
|
return parseOptionalPrecision(precisions.sellPrecision);
|
|
1190
1211
|
return parseOptionalPrecision(precisions.defaultPrecision);
|
|
1191
1212
|
}
|
|
@@ -1328,9 +1349,9 @@ function deriveTargetBoundary(fills, currentBoundaryIdx, allSlots, config, gapSl
|
|
|
1328
1349
|
fill?.isDelayedRotationTrigger === true;
|
|
1329
1350
|
if (!isShiftEligible)
|
|
1330
1351
|
continue;
|
|
1331
|
-
if (fill.type ===
|
|
1352
|
+
if (fill.type === ORDER_TYPES.SELL)
|
|
1332
1353
|
netShift++;
|
|
1333
|
-
else if (fill.type ===
|
|
1354
|
+
else if (fill.type === ORDER_TYPES.BUY)
|
|
1334
1355
|
netShift--;
|
|
1335
1356
|
}
|
|
1336
1357
|
// Cap cumulative shift to prevent overreaction from burst fills.
|
|
@@ -1396,11 +1417,11 @@ function getSideBudget(side, funds, config, totalTarget) {
|
|
|
1396
1417
|
if (allocated <= 0)
|
|
1397
1418
|
return 0;
|
|
1398
1419
|
const btsOrderType = MathUtils.getBtsSide(config?.assetA, config?.assetB);
|
|
1399
|
-
const isBtsSide = isBuy ? (btsOrderType ===
|
|
1420
|
+
const isBtsSide = isBuy ? (btsOrderType === ORDER_TYPES.BUY) : (btsOrderType === ORDER_TYPES.SELL);
|
|
1400
1421
|
// Non-BTS side without btsBalance data: no fee adjustment to make.
|
|
1401
1422
|
if (!isBtsSide && !funds.btsBalance)
|
|
1402
1423
|
return allocated;
|
|
1403
|
-
const btsReservationMultiplier = config?.feeParams?.BTS_RESERVATION_MULTIPLIER ??
|
|
1424
|
+
const btsReservationMultiplier = config?.feeParams?.BTS_RESERVATION_MULTIPLIER ?? FEE_PARAMETERS.BTS_RESERVATION_MULTIPLIER;
|
|
1404
1425
|
const formulaBudget = MathUtils.calculateOrderCreationFees(config.assetA, config.assetB, totalTarget, btsReservationMultiplier);
|
|
1405
1426
|
if (isBtsSide) {
|
|
1406
1427
|
return adjustBudgetForBtsFees(allocated, true, formulaBudget, 0, 0, 0, 0);
|
|
@@ -1434,4 +1455,5 @@ function calculateBudgetedSizes(slots, side, budget, weightDist, incrementPercen
|
|
|
1434
1455
|
return MathUtils.allocateFundsByWeights(budget, slots.length, weightDist, incrementFactor, isBuy, // Reverse for BUY (Market-Close is last in array)
|
|
1435
1456
|
0, precision);
|
|
1436
1457
|
}
|
|
1458
|
+
export { parseChainOrder, findMatchingGridOrderByOpenOrder, applyChainSizeToGridOrder, buildFillKey, correctOrderPriceOnChain, correctAllPriceMismatches, buildCreateOrderArgs, getOrderTypeFromUpdatedFlags, resolveConfiguredPriceBound, virtualizeOrder, convertToSpreadPlaceholder, resolveSpreadOrderSide, chainOrderMatchesSlot, parseSlotIndex, filterOrdersByType, buildOutsideInPairGroups, extractBatchOperationResults, formatUnmatchedChainOrder, isOrderOnChain, isOrderVirtual, hasOnChainId, isOrderPlaced, isPhantomOrder, isSlotAvailable, isEmptyGridSlot, isOrderHealthy, checkSizeThreshold, checkSizesBeforeMinimum, calculateIdealBoundary, calculateFundDrivenBoundary, assignGridRoles, resolveOnChainRetypeType, shouldFlagOutOfSpread, buildIndexes, validateIndexes, ordersEqual, buildDelta, getOrderSize, deriveTargetBoundary, adjustBudgetForBtsFees, getActiveOrdersTotal, getSideBudget, calculateBudgetedSizes, buildCreateOpFingerprint, isOrderGoneErrorMessage, recordDuplicateOrphanDetection, clearDuplicateOrphanDetection, duplicateOrphanLogInfo };
|
|
1437
1459
|
//# sourceMappingURL=order.js.map
|