dexbot 1.6.6 → 1.6.8
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/CHANGELOG.md +89 -1
- package/README.md +8 -5
- package/analysis/README.md +2 -3
- package/analysis/tradingview/README.md +78 -1
- package/analysis/trend_detection/DYNAMIC_WEIGHT_RESEARCH.md +1 -1
- package/claw/package.json +1 -1
- package/claw/runtimes/openclaw-plugin/openclaw.plugin.json +1 -1
- package/claw/runtimes/openclaw-plugin/package.json +1 -1
- package/dist/analysis/tradingview/analyze_tradingview.d.ts +4 -0
- package/dist/analysis/tradingview/analyze_tradingview.js +55 -0
- package/dist/analysis/tradingview/grid_reset_config.d.ts +61 -0
- package/dist/analysis/tradingview/grid_reset_config.js +235 -0
- package/dist/analysis/tradingview/grid_reset_sim.d.ts +67 -0
- package/dist/analysis/tradingview/grid_reset_sim.js +307 -0
- package/dist/analysis/tradingview/tradingview_uplot_chart_generator.js +419 -3
- package/dist/dexbot.js +44 -15
- package/dist/market_adapter/core/market_adapter_service.js +14 -2
- package/dist/market_adapter/core/strategies/dynamic_weight_series.d.ts +8 -1
- package/dist/market_adapter/core/strategies/dynamic_weight_series.js +5 -1
- package/dist/market_adapter/inputs/window_cache.d.ts +97 -19
- package/dist/market_adapter/inputs/window_cache.js +302 -48
- package/dist/market_adapter/market_adapter.d.ts +8 -1
- package/dist/market_adapter/market_adapter.js +22 -4
- package/dist/modules/account_bots.js +20 -9
- package/dist/modules/account_orders.d.ts +44 -4
- package/dist/modules/account_orders.js +104 -7
- package/dist/modules/bitshares-native/chain_client.d.ts +10 -0
- package/dist/modules/bitshares-native/chain_client.js +197 -28
- package/dist/modules/bitshares-native/subscriptions.js +312 -10
- package/dist/modules/bitshares-native/transport.d.ts +1 -0
- package/dist/modules/bitshares-native/transport.js +97 -3
- package/dist/modules/bitshares_client.d.ts +20 -0
- package/dist/modules/bitshares_client.js +29 -0
- package/dist/modules/bot_settings.js +10 -1
- package/dist/modules/chain_keys.d.ts +37 -22
- package/dist/modules/chain_keys.js +145 -44
- package/dist/modules/cli_start_onboarding.d.ts +10 -0
- package/dist/modules/cli_start_onboarding.js +15 -0
- package/dist/modules/cli_start_output.d.ts +6 -0
- package/dist/modules/cli_start_output.js +8 -0
- package/dist/modules/config.d.ts +1 -0
- package/dist/modules/config.js +1 -0
- package/dist/modules/constants.d.ts +23 -2
- package/dist/modules/constants.js +196 -15
- package/dist/modules/dexbot_class.d.ts +6 -76
- package/dist/modules/dexbot_class.js +0 -32
- package/dist/modules/dexbot_cow_runtime.d.ts +3 -58
- package/dist/modules/dexbot_cow_runtime.js +53 -96
- package/dist/modules/dexbot_fill_runtime.d.ts +6 -1
- package/dist/modules/dexbot_fill_runtime.js +22 -3
- package/dist/modules/dexbot_maintenance_runtime.d.ts +38 -1
- package/dist/modules/dexbot_maintenance_runtime.js +103 -11
- package/dist/modules/dexbot_startup_runtime.js +73 -20
- package/dist/modules/dexbot_state_recovery.d.ts +6 -0
- package/dist/modules/dexbot_state_recovery.js +34 -1
- package/dist/modules/order/async_lock.d.ts +8 -0
- package/dist/modules/order/async_lock.js +15 -0
- package/dist/modules/order/genesis_policy.d.ts +162 -0
- package/dist/modules/order/genesis_policy.js +267 -0
- package/dist/modules/order/grid.js +109 -135
- package/dist/modules/order/grid_reconcile.d.ts +9 -0
- package/dist/modules/order/grid_reconcile.js +13 -4
- package/dist/modules/order/grid_reconcile_internal.js +13 -2
- package/dist/modules/order/logger.d.ts +12 -2
- package/dist/modules/order/logger.js +29 -7
- package/dist/modules/order/manager.d.ts +53 -0
- package/dist/modules/order/manager.js +86 -25
- package/dist/modules/order/sync_engine.d.ts +19 -0
- package/dist/modules/order/sync_engine.js +284 -344
- package/dist/modules/order/utils/math.d.ts +22 -1
- package/dist/modules/order/utils/math.js +64 -1
- package/dist/modules/order/utils/order.d.ts +43 -58
- package/dist/modules/order/utils/order.js +302 -194
- package/dist/modules/order/utils/system.d.ts +97 -0
- package/dist/modules/order/utils/system.js +282 -3
- package/dist/modules/paths.d.ts +8 -1
- package/dist/modules/paths.js +11 -3
- package/dist/modules/utils/text_width.d.ts +19 -0
- package/dist/modules/utils/text_width.js +97 -0
- package/dist/modules/version_notice.d.ts +165 -0
- package/dist/modules/version_notice.js +364 -0
- package/dist/pm2.js +104 -18
- package/dist/scripts/update.js +62 -13
- package/dist/unlock.d.ts +14 -2
- package/dist/unlock.js +101 -4
- package/docs/BITSHARES_ONBOARDING.md +8 -1
- package/docs/COW_INVARIANTS.md +11 -2
- package/docs/CREDENTIAL_SECURITY.md +26 -0
- package/docs/DEXBOT_COMPARISON.md +4 -4
- package/docs/EVOLUTION.md +20 -18
- package/docs/FUND_MOVEMENT_AND_ACCOUNTING.md +1 -1
- package/docs/GRID_PRICE_INVARIANT.md +204 -31
- package/docs/GRID_RECALCULATION.md +12 -0
- package/docs/LOGGING.md +17 -2
- package/docs/ORDER_ENGINE_POST_1.0_RETROSPECTIVE.md +6 -7
- package/docs/README.md +3 -1
- package/docs/WORKFLOW.md +16 -5
- package/market_adapter/README.md +1 -1
- package/modules/README.md +18 -1
- package/package.json +14 -6
- package/scripts/README.md +28 -2
- package/scripts/clear-all.sh +13 -4
- package/scripts/clear-logs.sh +13 -4
- package/scripts/clear-market-adapter.sh +6 -0
- package/scripts/clear-orders.sh +5 -0
- package/scripts/lib/dexbot-paths.sh +108 -0
- package/tests/README.md +11 -3
- package/analysis/account_resolver.ts +0 -161
- package/analysis/ama_fitting/analyze_ama_price_changes.ts +0 -155
- package/analysis/ama_fitting/analyze_lambda_vs_slow.ts +0 -404
- package/analysis/ama_fitting/calibrate_convergence_er.ts +0 -201
- package/analysis/ama_fitting/fetch_lp_candles.ts +0 -184
- package/analysis/ama_fitting/generate_unified_comparison_chart.ts +0 -232
- package/analysis/ama_fitting/optimizer_high_resolution.ts +0 -802
- package/analysis/analyze_dynamic_weight.ts +0 -243
- package/analysis/analyze_kalman.ts +0 -157
- package/analysis/analyze_regime.ts +0 -158
- package/analysis/analyze_regime_windows.ts +0 -470
- package/analysis/analyze_risk_profile.ts +0 -199
- package/analysis/analyze_trade_heatmap.ts +0 -362
- package/analysis/analyze_volatility.ts +0 -182
- package/analysis/bot_fitting/backtest_ama_sweep.ts +0 -934
- package/analysis/bot_fitting/backtest_bot_fitting.ts +0 -861
- package/analysis/bot_fitting/shared_utils.ts +0 -52
- package/analysis/bot_key_utils.ts +0 -426
- package/analysis/bot_usage/discover_bot_accounts.ts +0 -635
- package/analysis/bot_usage/kibana_bot_queries.ts +0 -211
- package/analysis/chain_pool.ts +0 -47
- package/analysis/chart_css.ts +0 -62
- package/analysis/chart_ui.ts +0 -105
- package/analysis/chart_utils.ts +0 -210
- package/analysis/fills_source.ts +0 -228
- package/analysis/grid_correction_check.ts +0 -786
- package/analysis/math_utils.ts +0 -53
- package/analysis/price_sources.ts +0 -136
- package/analysis/resolve_bot_accounts.ts +0 -199
- package/analysis/resolve_source.ts +0 -99
- package/analysis/results/ama_sweep_results_lp_pool_133_1h.json +0 -2455
- package/analysis/results/bot_fitting_results_lp_pool_133_1h.json +0 -218
- package/analysis/trade_profitability.ts +0 -1335
- package/analysis/tradingview/analyze_tradingview.ts +0 -280
- package/analysis/tradingview/h-bts_tradingview.html +0 -1570
- package/analysis/tradingview/t-bts_tradingview.html +0 -1570
- package/analysis/tradingview/tradingview_uplot_chart_generator.ts +0 -3268
- package/analysis/trend_detection/dynamic_weight_chart_generator.ts +0 -1481
- package/analysis/trend_detection/hurst_analyzer.ts +0 -7
- package/analysis/trend_detection/kalman_chart_generator.ts +0 -398
- package/analysis/trend_detection/kalman_trend_analyzer.ts +0 -9
- package/analysis/trend_detection/kalman_velocity_smoothing.ts +0 -7
- package/analysis/trend_detection/package.json +0 -23
- package/analysis/trend_detection/permutation_entropy_analyzer.ts +0 -7
- package/analysis/trend_detection/regime_chart_generator.ts +0 -338
- package/analysis/trend_detection/tests/test_kalman_trend.ts +0 -153
- package/analysis/trend_detection/tests/test_kalman_velocity_smoothing.ts +0 -64
- package/analysis/trend_detection/volatility_chart_generator.ts +0 -654
- package/analysis/tsconfig.json +0 -29
- package/claw/tests/package.json +0 -3
- package/claw/tests/test_claw_bridge.ts +0 -570
- package/claw/tests/test_claw_catalog_and_credentials.ts +0 -156
- package/claw/tests/test_claw_chain_layer.ts +0 -739
- package/claw/tests/test_claw_data_flow.ts +0 -525
- package/claw/tests/test_claw_domain_logic.ts +0 -471
- package/claw/tests/test_claw_manifest_and_matrix.ts +0 -222
- package/claw/tests/test_claw_mcp_transport.ts +0 -243
- package/claw/tests/test_claw_regressions.ts +0 -711
- package/claw/tests/test_claw_skill_generation.ts +0 -103
- package/claw/tests/test_claw_state_store.ts +0 -44
- package/claw/tests/test_dexbot_profiles.ts +0 -654
- package/claw/tests/test_memu_bridge.ts +0 -189
- package/claw/tests/test_nullclaw_tmp_integration.ts +0 -57
- package/claw/tests/test_position_health.ts +0 -343
- package/claw/tests/test_position_manager.ts +0 -429
- package/claw/tests/test_position_manager_watch_health.ts +0 -100
- package/claw/tests/test_short_mpa_strategy.ts +0 -232
- package/dist/analysis/account_resolver.d.ts.map +0 -1
- package/dist/analysis/account_resolver.js.map +0 -1
- package/dist/analysis/ama_fitting/analyze_ama_price_changes.d.ts.map +0 -1
- package/dist/analysis/ama_fitting/analyze_ama_price_changes.js.map +0 -1
- package/dist/analysis/ama_fitting/analyze_lambda_vs_slow.d.ts.map +0 -1
- package/dist/analysis/ama_fitting/analyze_lambda_vs_slow.js.map +0 -1
- package/dist/analysis/ama_fitting/calibrate_convergence_er.d.ts.map +0 -1
- package/dist/analysis/ama_fitting/calibrate_convergence_er.js.map +0 -1
- package/dist/analysis/ama_fitting/fetch_lp_candles.d.ts.map +0 -1
- package/dist/analysis/ama_fitting/fetch_lp_candles.js.map +0 -1
- package/dist/analysis/ama_fitting/generate_unified_comparison_chart.d.ts.map +0 -1
- package/dist/analysis/ama_fitting/generate_unified_comparison_chart.js.map +0 -1
- package/dist/analysis/ama_fitting/optimizer_high_resolution.d.ts.map +0 -1
- package/dist/analysis/ama_fitting/optimizer_high_resolution.js.map +0 -1
- package/dist/analysis/analyze_dynamic_weight.d.ts.map +0 -1
- package/dist/analysis/analyze_dynamic_weight.js.map +0 -1
- package/dist/analysis/analyze_kalman.d.ts.map +0 -1
- package/dist/analysis/analyze_kalman.js.map +0 -1
- package/dist/analysis/analyze_regime.d.ts.map +0 -1
- package/dist/analysis/analyze_regime.js.map +0 -1
- package/dist/analysis/analyze_regime_windows.d.ts.map +0 -1
- package/dist/analysis/analyze_regime_windows.js.map +0 -1
- package/dist/analysis/analyze_risk_profile.d.ts.map +0 -1
- package/dist/analysis/analyze_risk_profile.js.map +0 -1
- package/dist/analysis/analyze_trade_heatmap.d.ts.map +0 -1
- package/dist/analysis/analyze_trade_heatmap.js.map +0 -1
- package/dist/analysis/analyze_volatility.d.ts.map +0 -1
- package/dist/analysis/analyze_volatility.js.map +0 -1
- package/dist/analysis/bot_fitting/backtest_ama_sweep.d.ts.map +0 -1
- package/dist/analysis/bot_fitting/backtest_ama_sweep.js.map +0 -1
- package/dist/analysis/bot_fitting/backtest_bot_fitting.d.ts.map +0 -1
- package/dist/analysis/bot_fitting/backtest_bot_fitting.js.map +0 -1
- package/dist/analysis/bot_fitting/shared_utils.d.ts.map +0 -1
- package/dist/analysis/bot_fitting/shared_utils.js.map +0 -1
- package/dist/analysis/bot_key_utils.d.ts.map +0 -1
- package/dist/analysis/bot_key_utils.js.map +0 -1
- package/dist/analysis/bot_usage/discover_bot_accounts.d.ts.map +0 -1
- package/dist/analysis/bot_usage/discover_bot_accounts.js.map +0 -1
- package/dist/analysis/bot_usage/kibana_bot_queries.d.ts.map +0 -1
- package/dist/analysis/bot_usage/kibana_bot_queries.js.map +0 -1
- package/dist/analysis/chain_pool.d.ts.map +0 -1
- package/dist/analysis/chain_pool.js.map +0 -1
- package/dist/analysis/chart_css.d.ts.map +0 -1
- package/dist/analysis/chart_css.js.map +0 -1
- package/dist/analysis/chart_ui.d.ts.map +0 -1
- package/dist/analysis/chart_ui.js.map +0 -1
- package/dist/analysis/chart_utils.d.ts.map +0 -1
- package/dist/analysis/chart_utils.js.map +0 -1
- package/dist/analysis/fills_source.d.ts.map +0 -1
- package/dist/analysis/fills_source.js.map +0 -1
- package/dist/analysis/grid_correction_check.d.ts.map +0 -1
- package/dist/analysis/grid_correction_check.js.map +0 -1
- package/dist/analysis/math_utils.d.ts.map +0 -1
- package/dist/analysis/math_utils.js.map +0 -1
- package/dist/analysis/price_sources.d.ts.map +0 -1
- package/dist/analysis/price_sources.js.map +0 -1
- package/dist/analysis/resolve_bot_accounts.d.ts.map +0 -1
- package/dist/analysis/resolve_bot_accounts.js.map +0 -1
- package/dist/analysis/resolve_source.d.ts.map +0 -1
- package/dist/analysis/resolve_source.js.map +0 -1
- package/dist/analysis/trade_profitability.d.ts.map +0 -1
- package/dist/analysis/trade_profitability.js.map +0 -1
- package/dist/analysis/tradingview/analyze_tradingview.d.ts.map +0 -1
- package/dist/analysis/tradingview/analyze_tradingview.js.map +0 -1
- package/dist/analysis/tradingview/tradingview_uplot_chart_generator.d.ts.map +0 -1
- package/dist/analysis/tradingview/tradingview_uplot_chart_generator.js.map +0 -1
- package/dist/analysis/trend_detection/dynamic_weight_chart_generator.d.ts.map +0 -1
- package/dist/analysis/trend_detection/dynamic_weight_chart_generator.js.map +0 -1
- package/dist/analysis/trend_detection/hurst_analyzer.d.ts.map +0 -1
- package/dist/analysis/trend_detection/hurst_analyzer.js.map +0 -1
- package/dist/analysis/trend_detection/kalman_chart_generator.d.ts.map +0 -1
- package/dist/analysis/trend_detection/kalman_chart_generator.js.map +0 -1
- package/dist/analysis/trend_detection/kalman_trend_analyzer.d.ts.map +0 -1
- package/dist/analysis/trend_detection/kalman_trend_analyzer.js.map +0 -1
- package/dist/analysis/trend_detection/kalman_velocity_smoothing.d.ts.map +0 -1
- package/dist/analysis/trend_detection/kalman_velocity_smoothing.js.map +0 -1
- package/dist/analysis/trend_detection/permutation_entropy_analyzer.d.ts.map +0 -1
- package/dist/analysis/trend_detection/permutation_entropy_analyzer.js.map +0 -1
- package/dist/analysis/trend_detection/regime_chart_generator.d.ts.map +0 -1
- 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 -128
- 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 -37
- package/dist/analysis/trend_detection/tests/test_kalman_velocity_smoothing.js.map +0 -1
- package/dist/analysis/trend_detection/volatility_chart_generator.d.ts.map +0 -1
- package/dist/analysis/trend_detection/volatility_chart_generator.js.map +0 -1
- package/dist/bot.d.ts.map +0 -1
- package/dist/bot.js.map +0 -1
- package/dist/credential-daemon.d.ts.map +0 -1
- package/dist/credential-daemon.js.map +0 -1
- package/dist/dexbot.d.ts.map +0 -1
- package/dist/dexbot.js.map +0 -1
- package/dist/market_adapter/ama_signal_runner.d.ts.map +0 -1
- package/dist/market_adapter/ama_signal_runner.js.map +0 -1
- package/dist/market_adapter/candle_utils.d.ts.map +0 -1
- package/dist/market_adapter/candle_utils.js.map +0 -1
- package/dist/market_adapter/core/asymmetric_bounds.d.ts.map +0 -1
- package/dist/market_adapter/core/asymmetric_bounds.js.map +0 -1
- package/dist/market_adapter/core/config_normalizers.d.ts.map +0 -1
- package/dist/market_adapter/core/config_normalizers.js.map +0 -1
- package/dist/market_adapter/core/kibana_candles.d.ts.map +0 -1
- package/dist/market_adapter/core/kibana_candles.js.map +0 -1
- package/dist/market_adapter/core/kibana_client.d.ts.map +0 -1
- package/dist/market_adapter/core/kibana_client.js.map +0 -1
- package/dist/market_adapter/core/kibana_market_candles.d.ts.map +0 -1
- package/dist/market_adapter/core/kibana_market_candles.js.map +0 -1
- package/dist/market_adapter/core/market_adapter_service.d.ts.map +0 -1
- package/dist/market_adapter/core/market_adapter_service.js.map +0 -1
- package/dist/market_adapter/core/signals/hurst_analyzer.d.ts.map +0 -1
- package/dist/market_adapter/core/signals/hurst_analyzer.js.map +0 -1
- package/dist/market_adapter/core/signals/kalman_trend_analyzer.d.ts.map +0 -1
- package/dist/market_adapter/core/signals/kalman_trend_analyzer.js.map +0 -1
- package/dist/market_adapter/core/signals/kalman_velocity_smoothing.d.ts.map +0 -1
- package/dist/market_adapter/core/signals/kalman_velocity_smoothing.js.map +0 -1
- package/dist/market_adapter/core/signals/permutation_entropy_analyzer.d.ts.map +0 -1
- package/dist/market_adapter/core/signals/permutation_entropy_analyzer.js.map +0 -1
- package/dist/market_adapter/core/strategies/ama.d.ts.map +0 -1
- package/dist/market_adapter/core/strategies/ama.js.map +0 -1
- package/dist/market_adapter/core/strategies/ama_slope_model.d.ts.map +0 -1
- package/dist/market_adapter/core/strategies/ama_slope_model.js.map +0 -1
- package/dist/market_adapter/core/strategies/atr/calculator.d.ts.map +0 -1
- package/dist/market_adapter/core/strategies/atr/calculator.js.map +0 -1
- package/dist/market_adapter/core/strategies/collateral_manager.d.ts.map +0 -1
- package/dist/market_adapter/core/strategies/collateral_manager.js.map +0 -1
- package/dist/market_adapter/core/strategies/dynamic_weight_series.d.ts.map +0 -1
- package/dist/market_adapter/core/strategies/dynamic_weight_series.js.map +0 -1
- package/dist/market_adapter/core/strategies/regime_gate.d.ts.map +0 -1
- package/dist/market_adapter/core/strategies/regime_gate.js.map +0 -1
- package/dist/market_adapter/core/strategies/regime_interp.d.ts.map +0 -1
- package/dist/market_adapter/core/strategies/regime_interp.js.map +0 -1
- package/dist/market_adapter/core/strategies/volatility_shift.d.ts.map +0 -1
- package/dist/market_adapter/core/strategies/volatility_shift.js.map +0 -1
- package/dist/market_adapter/inputs/fetch_book_data.d.ts.map +0 -1
- package/dist/market_adapter/inputs/fetch_book_data.js.map +0 -1
- package/dist/market_adapter/inputs/fetch_cex_synthetic_data.d.ts.map +0 -1
- package/dist/market_adapter/inputs/fetch_cex_synthetic_data.js.map +0 -1
- package/dist/market_adapter/inputs/fetch_lp_data.d.ts.map +0 -1
- package/dist/market_adapter/inputs/fetch_lp_data.js.map +0 -1
- package/dist/market_adapter/inputs/kibana_feed_source.d.ts.map +0 -1
- package/dist/market_adapter/inputs/kibana_feed_source.js.map +0 -1
- package/dist/market_adapter/inputs/kibana_source.d.ts.map +0 -1
- package/dist/market_adapter/inputs/kibana_source.js.map +0 -1
- package/dist/market_adapter/inputs/window_cache.d.ts.map +0 -1
- package/dist/market_adapter/inputs/window_cache.js.map +0 -1
- package/dist/market_adapter/interval_utils.d.ts.map +0 -1
- package/dist/market_adapter/interval_utils.js.map +0 -1
- package/dist/market_adapter/log_format.d.ts.map +0 -1
- package/dist/market_adapter/log_format.js.map +0 -1
- package/dist/market_adapter/lp_chart_core.d.ts.map +0 -1
- package/dist/market_adapter/lp_chart_core.js.map +0 -1
- package/dist/market_adapter/lp_chart_runner.d.ts.map +0 -1
- package/dist/market_adapter/lp_chart_runner.js.map +0 -1
- package/dist/market_adapter/lp_chart_strategy_loader.d.ts.map +0 -1
- package/dist/market_adapter/lp_chart_strategy_loader.js.map +0 -1
- package/dist/market_adapter/market_adapter.d.ts.map +0 -1
- package/dist/market_adapter/market_adapter.js.map +0 -1
- package/dist/market_adapter/test_helpers.d.ts.map +0 -1
- package/dist/market_adapter/test_helpers.js.map +0 -1
- package/dist/market_adapter/utils/adapter_client.d.ts.map +0 -1
- package/dist/market_adapter/utils/adapter_client.js.map +0 -1
- package/dist/market_adapter/utils/atomic_write.d.ts.map +0 -1
- package/dist/market_adapter/utils/atomic_write.js.map +0 -1
- package/dist/market_adapter/utils/chain.d.ts.map +0 -1
- package/dist/market_adapter/utils/chain.js.map +0 -1
- package/dist/market_adapter/utils/data_discovery.d.ts.map +0 -1
- package/dist/market_adapter/utils/data_discovery.js.map +0 -1
- package/dist/market_adapter/utils/dynamic_grid_snapshot.d.ts.map +0 -1
- package/dist/market_adapter/utils/dynamic_grid_snapshot.js.map +0 -1
- package/dist/market_adapter/utils/file_lock.d.ts.map +0 -1
- package/dist/market_adapter/utils/file_lock.js.map +0 -1
- package/dist/market_adapter/utils/native_history.d.ts.map +0 -1
- package/dist/market_adapter/utils/native_history.js.map +0 -1
- package/dist/modules/account_bots.d.ts.map +0 -1
- package/dist/modules/account_bots.js.map +0 -1
- package/dist/modules/account_orders.d.ts.map +0 -1
- package/dist/modules/account_orders.js.map +0 -1
- package/dist/modules/authority_resolver.d.ts.map +0 -1
- package/dist/modules/authority_resolver.js.map +0 -1
- package/dist/modules/bitshares-native/chain_client.d.ts.map +0 -1
- package/dist/modules/bitshares-native/chain_client.js.map +0 -1
- package/dist/modules/bitshares-native/crypto/ecc.browser.d.ts.map +0 -1
- package/dist/modules/bitshares-native/crypto/ecc.browser.js.map +0 -1
- package/dist/modules/bitshares-native/crypto/ecc.d.ts.map +0 -1
- package/dist/modules/bitshares-native/crypto/ecc.js.map +0 -1
- package/dist/modules/bitshares-native/crypto/ecc_selector.d.ts.map +0 -1
- package/dist/modules/bitshares-native/crypto/ecc_selector.js.map +0 -1
- package/dist/modules/bitshares-native/index.d.ts.map +0 -1
- package/dist/modules/bitshares-native/index.js.map +0 -1
- package/dist/modules/bitshares-native/lru_cache.d.ts.map +0 -1
- package/dist/modules/bitshares-native/lru_cache.js.map +0 -1
- package/dist/modules/bitshares-native/resolvers.d.ts.map +0 -1
- package/dist/modules/bitshares-native/resolvers.js.map +0 -1
- package/dist/modules/bitshares-native/serial/chain_constants.d.ts.map +0 -1
- package/dist/modules/bitshares-native/serial/chain_constants.js.map +0 -1
- package/dist/modules/bitshares-native/serial/index.d.ts.map +0 -1
- package/dist/modules/bitshares-native/serial/index.js.map +0 -1
- package/dist/modules/bitshares-native/serial/operations.d.ts.map +0 -1
- package/dist/modules/bitshares-native/serial/operations.js.map +0 -1
- package/dist/modules/bitshares-native/serial/serializer.d.ts.map +0 -1
- package/dist/modules/bitshares-native/serial/serializer.js.map +0 -1
- package/dist/modules/bitshares-native/serial/types.d.ts.map +0 -1
- package/dist/modules/bitshares-native/serial/types.js.map +0 -1
- package/dist/modules/bitshares-native/signing_client.d.ts.map +0 -1
- package/dist/modules/bitshares-native/signing_client.js.map +0 -1
- package/dist/modules/bitshares-native/subscriptions.d.ts.map +0 -1
- package/dist/modules/bitshares-native/subscriptions.js.map +0 -1
- package/dist/modules/bitshares-native/transport.d.ts.map +0 -1
- package/dist/modules/bitshares-native/transport.js.map +0 -1
- package/dist/modules/bitshares-native/tx/builder.d.ts.map +0 -1
- package/dist/modules/bitshares-native/tx/builder.js.map +0 -1
- package/dist/modules/bitshares-native/tx/tx_cache.d.ts.map +0 -1
- package/dist/modules/bitshares-native/tx/tx_cache.js.map +0 -1
- package/dist/modules/bitshares_client.d.ts.map +0 -1
- package/dist/modules/bitshares_client.js.map +0 -1
- package/dist/modules/bot_defaults.d.ts.map +0 -1
- package/dist/modules/bot_defaults.js.map +0 -1
- package/dist/modules/bot_settings.d.ts.map +0 -1
- package/dist/modules/bot_settings.js.map +0 -1
- package/dist/modules/bots_file_lock.d.ts.map +0 -1
- package/dist/modules/bots_file_lock.js.map +0 -1
- package/dist/modules/broadcast_failure.d.ts.map +0 -1
- package/dist/modules/broadcast_failure.js.map +0 -1
- package/dist/modules/chain_keys.d.ts.map +0 -1
- package/dist/modules/chain_keys.js.map +0 -1
- package/dist/modules/chain_orders.d.ts.map +0 -1
- package/dist/modules/chain_orders.js.map +0 -1
- package/dist/modules/cli_colors.d.ts.map +0 -1
- package/dist/modules/cli_colors.js.map +0 -1
- package/dist/modules/config.d.ts.map +0 -1
- package/dist/modules/config.js.map +0 -1
- package/dist/modules/constants.d.ts.map +0 -1
- package/dist/modules/constants.js.map +0 -1
- package/dist/modules/cr_planner.d.ts.map +0 -1
- package/dist/modules/cr_planner.js.map +0 -1
- package/dist/modules/credential_policy.d.ts.map +0 -1
- package/dist/modules/credential_policy.js.map +0 -1
- package/dist/modules/credential_runtime.d.ts.map +0 -1
- package/dist/modules/credential_runtime.js.map +0 -1
- package/dist/modules/credential_session_cache.d.ts.map +0 -1
- package/dist/modules/credential_session_cache.js.map +0 -1
- package/dist/modules/credit_pricing.d.ts.map +0 -1
- package/dist/modules/credit_pricing.js.map +0 -1
- package/dist/modules/credit_runtime.d.ts.map +0 -1
- package/dist/modules/credit_runtime.js.map +0 -1
- package/dist/modules/crypto/browser_provider.d.ts.map +0 -1
- package/dist/modules/crypto/browser_provider.js.map +0 -1
- package/dist/modules/crypto/index.d.ts.map +0 -1
- package/dist/modules/crypto/index.js.map +0 -1
- package/dist/modules/crypto/node_provider.d.ts.map +0 -1
- package/dist/modules/crypto/node_provider.js.map +0 -1
- package/dist/modules/crypto/provider.d.ts.map +0 -1
- package/dist/modules/crypto/provider.js.map +0 -1
- package/dist/modules/crypto/pure_ripemd160.d.ts.map +0 -1
- package/dist/modules/crypto/pure_ripemd160.js.map +0 -1
- package/dist/modules/crypto/pure_scrypt.d.ts.map +0 -1
- package/dist/modules/crypto/pure_scrypt.js.map +0 -1
- package/dist/modules/crypto/pure_secp256k1.d.ts.map +0 -1
- package/dist/modules/crypto/pure_secp256k1.js.map +0 -1
- package/dist/modules/crypto/sync.d.ts.map +0 -1
- package/dist/modules/crypto/sync.js.map +0 -1
- package/dist/modules/daemon_node_health.d.ts.map +0 -1
- package/dist/modules/daemon_node_health.js.map +0 -1
- package/dist/modules/dexbot_class.d.ts.map +0 -1
- package/dist/modules/dexbot_class.js.map +0 -1
- package/dist/modules/dexbot_cow_runtime.d.ts.map +0 -1
- package/dist/modules/dexbot_cow_runtime.js.map +0 -1
- package/dist/modules/dexbot_credential_client.d.ts.map +0 -1
- package/dist/modules/dexbot_credential_client.js.map +0 -1
- package/dist/modules/dexbot_fill_runtime.d.ts.map +0 -1
- package/dist/modules/dexbot_fill_runtime.js.map +0 -1
- package/dist/modules/dexbot_maintenance_runtime.d.ts.map +0 -1
- package/dist/modules/dexbot_maintenance_runtime.js.map +0 -1
- package/dist/modules/dexbot_startup_runtime.d.ts.map +0 -1
- package/dist/modules/dexbot_startup_runtime.js.map +0 -1
- package/dist/modules/dexbot_state_recovery.d.ts.map +0 -1
- package/dist/modules/dexbot_state_recovery.js.map +0 -1
- package/dist/modules/env.d.ts.map +0 -1
- package/dist/modules/env.js.map +0 -1
- package/dist/modules/fund_registry.d.ts.map +0 -1
- package/dist/modules/fund_registry.js.map +0 -1
- package/dist/modules/general_settings.d.ts.map +0 -1
- package/dist/modules/general_settings.js.map +0 -1
- package/dist/modules/graceful_shutdown.d.ts.map +0 -1
- package/dist/modules/graceful_shutdown.js.map +0 -1
- package/dist/modules/grid_price_source.d.ts.map +0 -1
- package/dist/modules/grid_price_source.js.map +0 -1
- package/dist/modules/key_store.d.ts.map +0 -1
- package/dist/modules/key_store.js.map +0 -1
- package/dist/modules/launcher/adapter_requirement.d.ts.map +0 -1
- package/dist/modules/launcher/adapter_requirement.js.map +0 -1
- package/dist/modules/launcher/bot_supervisor.d.ts.map +0 -1
- package/dist/modules/launcher/bot_supervisor.js.map +0 -1
- package/dist/modules/launcher/child_env.d.ts.map +0 -1
- package/dist/modules/launcher/child_env.js.map +0 -1
- package/dist/modules/launcher/credential_bootstrap.d.ts.map +0 -1
- package/dist/modules/launcher/credential_bootstrap.js.map +0 -1
- package/dist/modules/launcher/credential_daemon.d.ts.map +0 -1
- package/dist/modules/launcher/credential_daemon.js.map +0 -1
- package/dist/modules/launcher/credential_secret.d.ts.map +0 -1
- package/dist/modules/launcher/credential_secret.js.map +0 -1
- package/dist/modules/launcher/foreign_cred_daemon.d.ts.map +0 -1
- package/dist/modules/launcher/foreign_cred_daemon.js.map +0 -1
- package/dist/modules/launcher/headless_password.d.ts.map +0 -1
- package/dist/modules/launcher/headless_password.js.map +0 -1
- package/dist/modules/launcher/launch_modes.d.ts.map +0 -1
- package/dist/modules/launcher/launch_modes.js.map +0 -1
- package/dist/modules/launcher/market_adapter_runtime.d.ts.map +0 -1
- package/dist/modules/launcher/market_adapter_runtime.js.map +0 -1
- package/dist/modules/launcher/market_adapter_watchdog.d.ts.map +0 -1
- package/dist/modules/launcher/market_adapter_watchdog.js.map +0 -1
- package/dist/modules/launcher/monolithic_runtime.d.ts.map +0 -1
- package/dist/modules/launcher/monolithic_runtime.js.map +0 -1
- package/dist/modules/launcher/runtime_entry.d.ts.map +0 -1
- package/dist/modules/launcher/runtime_entry.js.map +0 -1
- package/dist/modules/launcher/status_reporting.d.ts.map +0 -1
- package/dist/modules/launcher/status_reporting.js.map +0 -1
- package/dist/modules/launcher/supervisor_control.d.ts.map +0 -1
- package/dist/modules/launcher/supervisor_control.js.map +0 -1
- package/dist/modules/market_adapter_whitelist.d.ts.map +0 -1
- package/dist/modules/market_adapter_whitelist.js.map +0 -1
- package/dist/modules/node_connect_policy.d.ts.map +0 -1
- package/dist/modules/node_connect_policy.js.map +0 -1
- package/dist/modules/node_failure_ledger.d.ts.map +0 -1
- package/dist/modules/node_failure_ledger.js.map +0 -1
- package/dist/modules/node_health_cache.d.ts.map +0 -1
- package/dist/modules/node_health_cache.js.map +0 -1
- package/dist/modules/node_manager.d.ts.map +0 -1
- package/dist/modules/node_manager.js.map +0 -1
- package/dist/modules/order/accounting.d.ts.map +0 -1
- package/dist/modules/order/accounting.js.map +0 -1
- package/dist/modules/order/async_lock.d.ts.map +0 -1
- package/dist/modules/order/async_lock.js.map +0 -1
- package/dist/modules/order/export.d.ts.map +0 -1
- package/dist/modules/order/export.js.map +0 -1
- package/dist/modules/order/format.d.ts.map +0 -1
- package/dist/modules/order/format.js.map +0 -1
- package/dist/modules/order/grid.d.ts.map +0 -1
- package/dist/modules/order/grid.js.map +0 -1
- package/dist/modules/order/grid_reconcile.d.ts.map +0 -1
- package/dist/modules/order/grid_reconcile.js.map +0 -1
- package/dist/modules/order/grid_reconcile_internal.d.ts.map +0 -1
- package/dist/modules/order/grid_reconcile_internal.js.map +0 -1
- package/dist/modules/order/index.d.ts.map +0 -1
- package/dist/modules/order/index.js.map +0 -1
- package/dist/modules/order/logger.d.ts.map +0 -1
- package/dist/modules/order/logger.js.map +0 -1
- package/dist/modules/order/logger_state.d.ts.map +0 -1
- package/dist/modules/order/logger_state.js.map +0 -1
- package/dist/modules/order/manager.d.ts.map +0 -1
- package/dist/modules/order/manager.js.map +0 -1
- package/dist/modules/order/processed_fill_store.d.ts.map +0 -1
- package/dist/modules/order/processed_fill_store.js.map +0 -1
- package/dist/modules/order/strategy.d.ts.map +0 -1
- package/dist/modules/order/strategy.js.map +0 -1
- package/dist/modules/order/sync_engine.d.ts.map +0 -1
- package/dist/modules/order/sync_engine.js.map +0 -1
- package/dist/modules/order/utils/math.d.ts.map +0 -1
- package/dist/modules/order/utils/math.js.map +0 -1
- package/dist/modules/order/utils/order.d.ts.map +0 -1
- package/dist/modules/order/utils/order.js.map +0 -1
- package/dist/modules/order/utils/slot.d.ts.map +0 -1
- package/dist/modules/order/utils/slot.js.map +0 -1
- package/dist/modules/order/utils/system.d.ts.map +0 -1
- package/dist/modules/order/utils/system.js.map +0 -1
- package/dist/modules/order/utils/timeout.d.ts.map +0 -1
- package/dist/modules/order/utils/timeout.js.map +0 -1
- package/dist/modules/order/utils/validate.d.ts.map +0 -1
- package/dist/modules/order/utils/validate.js.map +0 -1
- package/dist/modules/order/utils/withPoolRef.d.ts.map +0 -1
- package/dist/modules/order/utils/withPoolRef.js.map +0 -1
- package/dist/modules/order/working_grid.d.ts.map +0 -1
- package/dist/modules/order/working_grid.js.map +0 -1
- package/dist/modules/path_api.d.ts.map +0 -1
- package/dist/modules/path_api.js.map +0 -1
- package/dist/modules/paths.d.ts.map +0 -1
- package/dist/modules/paths.js.map +0 -1
- package/dist/modules/process_discovery.d.ts.map +0 -1
- package/dist/modules/process_discovery.js.map +0 -1
- package/dist/modules/runtime.d.ts.map +0 -1
- package/dist/modules/runtime.js.map +0 -1
- package/dist/modules/runtime_settings.d.ts.map +0 -1
- package/dist/modules/runtime_settings.js.map +0 -1
- package/dist/modules/settings_merge.d.ts.map +0 -1
- package/dist/modules/settings_merge.js.map +0 -1
- package/dist/modules/socket_json_client.d.ts.map +0 -1
- package/dist/modules/socket_json_client.js.map +0 -1
- package/dist/modules/storage/browser_adapter.d.ts.map +0 -1
- package/dist/modules/storage/browser_adapter.js.map +0 -1
- package/dist/modules/storage/index.d.ts.map +0 -1
- package/dist/modules/storage/index.js.map +0 -1
- package/dist/modules/storage/node_adapter.d.ts.map +0 -1
- package/dist/modules/storage/node_adapter.js.map +0 -1
- package/dist/modules/storage/types.d.ts.map +0 -1
- package/dist/modules/storage/types.js.map +0 -1
- package/dist/modules/types.d.ts.map +0 -1
- package/dist/modules/types.js.map +0 -1
- package/dist/modules/utils/base58check.d.ts.map +0 -1
- package/dist/modules/utils/base58check.js.map +0 -1
- package/dist/modules/utils/build_dir.d.ts.map +0 -1
- package/dist/modules/utils/build_dir.js.map +0 -1
- package/dist/modules/utils/chain_logs.d.ts.map +0 -1
- package/dist/modules/utils/chain_logs.js.map +0 -1
- package/dist/modules/utils/errors.d.ts.map +0 -1
- package/dist/modules/utils/errors.js.map +0 -1
- package/dist/modules/utils/sanitize_key.d.ts.map +0 -1
- package/dist/modules/utils/sanitize_key.js.map +0 -1
- package/dist/modules/validate_profiles.d.ts.map +0 -1
- package/dist/modules/validate_profiles.js.map +0 -1
- package/dist/pm2.d.ts.map +0 -1
- package/dist/pm2.js.map +0 -1
- package/dist/scripts/analyze-credit.d.ts.map +0 -1
- package/dist/scripts/analyze-credit.js.map +0 -1
- package/dist/scripts/analyze-git.d.ts.map +0 -1
- package/dist/scripts/analyze-git.js.map +0 -1
- package/dist/scripts/analyze-orders.d.ts.map +0 -1
- package/dist/scripts/analyze-orders.js.map +0 -1
- package/dist/scripts/chart_command.d.ts.map +0 -1
- package/dist/scripts/chart_command.js.map +0 -1
- package/dist/scripts/diagnose-kibana-candles.d.ts.map +0 -1
- package/dist/scripts/diagnose-kibana-candles.js.map +0 -1
- package/dist/scripts/diagnose-pool-history.d.ts.map +0 -1
- package/dist/scripts/diagnose-pool-history.js.map +0 -1
- package/dist/scripts/divergence-calc.d.ts.map +0 -1
- package/dist/scripts/divergence-calc.js.map +0 -1
- package/dist/scripts/dw.d.ts.map +0 -1
- package/dist/scripts/dw.js.map +0 -1
- package/dist/scripts/generate_lp_chart.d.ts.map +0 -1
- package/dist/scripts/generate_lp_chart.js.map +0 -1
- package/dist/scripts/generate_mainnet_corpus_report.d.ts.map +0 -1
- package/dist/scripts/generate_mainnet_corpus_report.js.map +0 -1
- package/dist/scripts/native_release_gates.d.ts.map +0 -1
- package/dist/scripts/native_release_gates.js.map +0 -1
- package/dist/scripts/print_grid.d.ts.map +0 -1
- package/dist/scripts/print_grid.js.map +0 -1
- package/dist/scripts/run-tests.d.ts.map +0 -1
- package/dist/scripts/run-tests.js.map +0 -1
- package/dist/scripts/runner.d.ts.map +0 -1
- package/dist/scripts/runner.js.map +0 -1
- package/dist/scripts/sync-version.d.ts.map +0 -1
- package/dist/scripts/sync-version.js.map +0 -1
- package/dist/scripts/test-credit-renewal.d.ts.map +0 -1
- package/dist/scripts/test-credit-renewal.js.map +0 -1
- package/dist/scripts/tv.d.ts.map +0 -1
- package/dist/scripts/tv.js.map +0 -1
- package/dist/scripts/update.d.ts.map +0 -1
- package/dist/scripts/update.js.map +0 -1
- package/dist/scripts/update_dist_freshness.d.ts.map +0 -1
- package/dist/scripts/update_dist_freshness.js.map +0 -1
- package/dist/scripts/validate_bots.d.ts.map +0 -1
- package/dist/scripts/validate_bots.js.map +0 -1
- package/dist/scripts/verify-browser-bundle.d.ts.map +0 -1
- package/dist/scripts/verify-browser-bundle.js.map +0 -1
- package/dist/unlock.d.ts.map +0 -1
- package/dist/unlock.js.map +0 -1
|
@@ -116,12 +116,13 @@ function _snapshotFundState(manager) {
|
|
|
116
116
|
sellLocked: Number(manager.accountTotals?.sellLocked || 0),
|
|
117
117
|
};
|
|
118
118
|
}
|
|
119
|
-
import { floatToBlockchainInt, getPrecisionByOrderType, getPrecisionsForManager, calculateOrderCreationFees, calculateOrderSizes, calculateRotationOrderSizes, calculateAvailableFundsValue, calculateGridSideDivergenceMetric, getPrecisionSlack, getMinOrderSize, getSingleDustThreshold, getGridBestPrices, calculateSpreadFromOrders, allocateFundsByWeights, calculateGapSlots as _mathGapSlots, priceSlotEqual, getBtsSide, getSellStartIdx, resolveGapBand, countGapBandSpread, validatePersistedBoundary, isTransientInBandRejection, adjustBudgetForBtsFees, clamp, buildGenesisFromPriceLevels, assertSlotPriceInvariant, priceForSlot, hashPriceLevels, } from './utils/math.js';
|
|
120
|
-
import { filterOrdersByType, checkSizesBeforeMinimum, checkSizeThreshold, resolveConfiguredPriceBound, shouldFlagOutOfSpread, isOrderHealthy, isPhantomOrder, isSlotAvailable, isOrderOnChain, isOrderPlaced, hasOnChainId, isEmptyGridSlot, parseSlotIndex, calculateIdealBoundary, assignGridRoles, resolveOnChainRetypeType, resolveReserveCount, reserveEdgeIdSet, resolveLiveReserveEdgeAnchorPrice } from './utils/order.js';
|
|
121
|
-
import { loadAmaCenterPrice, loadAmaCenterSnapshot, withBlockchainRetry } from './utils/system.js';
|
|
119
|
+
import { floatToBlockchainInt, getPrecisionByOrderType, getPrecisionsForManager, calculateOrderCreationFees, calculateOrderSizes, calculateRotationOrderSizes, calculateAvailableFundsValue, calculateGridSideDivergenceMetric, getPrecisionSlack, getMinOrderSize, getSingleDustThreshold, getGridBestPrices, calculateSpreadFromOrders, allocateFundsByWeights, calculateGapSlots as _mathGapSlots, priceSlotEqual, getBtsSide, getSellStartIdx, resolveGapBand, countGapBandSpread, validatePersistedBoundary, isTransientInBandRejection, adjustBudgetForBtsFees, clamp, derivePriceLevels, buildGenesisFromPriceLevels, assertSlotPriceInvariant, priceForSlot, hashPriceLevels, } from './utils/math.js';
|
|
120
|
+
import { filterOrdersByType, checkSizesBeforeMinimum, checkSizeThreshold, resolveConfiguredPriceBound, shouldFlagOutOfSpread, isOrderHealthy, isPhantomOrder, isSlotAvailable, isOrderOnChain, isOrderPlaced, hasOnChainId, isEmptyGridSlot, parseSlotIndex, calculateIdealBoundary, assignGridRoles, resolveOnChainRetypeType, resolveReserveCount, reserveEdgeIdSet, resolveLiveReserveEdgeAnchorPrice, liveWindowIdSet } from './utils/order.js';
|
|
121
|
+
import { loadAmaCenterPrice, loadAmaCenterSnapshot, withBlockchainRetry, restoreLastFillPivot, resetLastFillPivot } from './utils/system.js';
|
|
122
122
|
import * as MathUtils from './utils/math.js';
|
|
123
123
|
import { derivePriceWithPoolRef, resolveStartPriceMode } from './utils/withPoolRef.js';
|
|
124
124
|
import { getWhitelistFlags } from '../market_adapter_whitelist.js';
|
|
125
|
+
import { hasGenesisLadder, recordMissingGenesisFault, resolvePersistedGenesis } from './genesis_policy.js';
|
|
125
126
|
import { getErrorMessage } from '../utils/errors.js';
|
|
126
127
|
const calculateGapSlots = _mathGapSlots;
|
|
127
128
|
export { calculateGapSlots };
|
|
@@ -331,8 +332,8 @@ export function createOrderGrid(config) {
|
|
|
331
332
|
throw new Error(`Invalid incrementPercent: ${incrementPercent}. Must be a finite number.`);
|
|
332
333
|
}
|
|
333
334
|
// Fall back to the canonical INCREMENT_BOUNDS when the config omits
|
|
334
|
-
// incrementBounds.
|
|
335
|
-
//
|
|
335
|
+
// incrementBounds. derivePriceLevels also refuses a step that cannot
|
|
336
|
+
// advance, but this enforces the configured increment range.
|
|
336
337
|
const incrementBounds = config.incrementBounds || INCREMENT_BOUNDS;
|
|
337
338
|
const minPercent = incrementBounds.MIN_PERCENT;
|
|
338
339
|
const maxPercent = incrementBounds.MAX_PERCENT;
|
|
@@ -340,53 +341,13 @@ export function createOrderGrid(config) {
|
|
|
340
341
|
throw new Error(`Invalid incrementPercent: ${incrementPercent}. Must be between ` +
|
|
341
342
|
`${minPercent} and ${maxPercent} (inclusive).`);
|
|
342
343
|
}
|
|
343
|
-
const stepUp = 1 + (incrementPercent / 100);
|
|
344
|
-
const stepDown = 1 - (incrementPercent / 100);
|
|
345
344
|
// ================================================================================
|
|
346
345
|
// STEP 1: GENERATE PRICE LEVELS (Geometric progression)
|
|
347
346
|
// ================================================================================
|
|
348
|
-
//
|
|
349
|
-
//
|
|
350
|
-
//
|
|
351
|
-
|
|
352
|
-
// the grid is centered around the market price.
|
|
353
|
-
const priceLevels = [];
|
|
354
|
-
// Generate levels upwards from startPrice (higher prices for SELL orders)
|
|
355
|
-
// Start from sqrt(stepUp) × startPrice to center the grid
|
|
356
|
-
let upPrice = startPrice * Math.sqrt(stepUp);
|
|
357
|
-
while (upPrice <= maxPrice) {
|
|
358
|
-
priceLevels.push(upPrice);
|
|
359
|
-
upPrice *= stepUp;
|
|
360
|
-
}
|
|
361
|
-
// Generate levels downwards from startPrice (lower prices for BUY orders)
|
|
362
|
-
// Start from sqrt(stepDown) × startPrice to center the grid
|
|
363
|
-
let downPrice = startPrice * Math.sqrt(stepDown);
|
|
364
|
-
while (downPrice >= minPrice) {
|
|
365
|
-
priceLevels.push(downPrice);
|
|
366
|
-
downPrice *= stepDown;
|
|
367
|
-
}
|
|
368
|
-
// Sort all levels from lowest to highest (Master Rail order)
|
|
369
|
-
priceLevels.sort((a, b) => a - b);
|
|
370
|
-
// Dedupe geometric levels that collide at float precision (tiny increments);
|
|
371
|
-
// keeps slot-N ↔ index mapping stable vs migration dedupe (grid.ts:652)
|
|
372
|
-
{
|
|
373
|
-
const seen = new Set();
|
|
374
|
-
const deduped = [];
|
|
375
|
-
for (const p of priceLevels) {
|
|
376
|
-
const key = Number(p).toFixed(12);
|
|
377
|
-
if (!seen.has(key)) {
|
|
378
|
-
seen.add(key);
|
|
379
|
-
deduped.push(p);
|
|
380
|
-
}
|
|
381
|
-
}
|
|
382
|
-
priceLevels.length = 0;
|
|
383
|
-
priceLevels.push(...deduped);
|
|
384
|
-
}
|
|
385
|
-
if (priceLevels.length === 0) {
|
|
386
|
-
throw new Error(`Grid generation produced no price levels for startPrice=${startPrice}, ` +
|
|
387
|
-
`bounds=[${minPrice}, ${maxPrice}], incrementPercent=${incrementPercent}. ` +
|
|
388
|
-
`Widen bounds or reduce incrementPercent.`);
|
|
389
|
-
}
|
|
347
|
+
// Rail geometry lives in ONE place (modules/order/utils/math.ts,
|
|
348
|
+
// derivePriceLevels) so a fresh build and a legacy-snapshot migration
|
|
349
|
+
// cannot drift into two different ladders for the same config.
|
|
350
|
+
const priceLevels = derivePriceLevels(startPrice, minPrice, maxPrice, incrementPercent);
|
|
390
351
|
// ================================================================================
|
|
391
352
|
// STEP 2: CALCULATE SPREAD GAP SIZE
|
|
392
353
|
// ================================================================================
|
|
@@ -471,11 +432,47 @@ export async function loadGrid(manager, grid, boundaryIdx = null, genesisInput =
|
|
|
471
432
|
// Genesis determinism: if snapshot provided genesis, validate slots
|
|
472
433
|
// against it; if legacy snapshot has no genesis, migrate by building
|
|
473
434
|
// genesis from live config and re-sorting to canonical price order.
|
|
474
|
-
|
|
435
|
+
//
|
|
436
|
+
// GENESIS INVARIANT (docs/GRID_PRICE_INVARIANT.md, E1): a snapshot that
|
|
437
|
+
// carries orders MUST carry a ladder. The decision lives in
|
|
438
|
+
// genesis_policy.resolvePersistedGenesis, so the startup gate can ask
|
|
439
|
+
// the same question before committing to a resume. A refused snapshot
|
|
440
|
+
// throws BEFORE any mutation (no asset init, no fund reset, no
|
|
441
|
+
// boundary restore), so the caller rebuilds from a clean manager.
|
|
442
|
+
// Assigned from the single resolver below; the raw inputs are only
|
|
443
|
+
// inspected by that resolver (so a malformed `genesisInput` cannot
|
|
444
|
+
// shadow the manager's own ladder or the migration path).
|
|
445
|
+
let genesis = null;
|
|
446
|
+
const validationMode = (() => {
|
|
447
|
+
try {
|
|
448
|
+
const raw = (typeof process !== 'undefined' && process.env?.GRID_PRICE_SLOT_VALIDATION) || 'log';
|
|
449
|
+
return String(raw).toLowerCase() === 'enforce' ? 'enforce' : 'log';
|
|
450
|
+
}
|
|
451
|
+
catch {
|
|
452
|
+
return 'log';
|
|
453
|
+
}
|
|
454
|
+
})();
|
|
455
|
+
const resolution = resolvePersistedGenesis({
|
|
456
|
+
config: manager.config,
|
|
457
|
+
grid,
|
|
458
|
+
genesisInput,
|
|
459
|
+
managerGenesis: manager._genesis,
|
|
460
|
+
validationMode,
|
|
461
|
+
log: (msg, level) => manager.logger?.log?.(msg, level)
|
|
462
|
+
});
|
|
463
|
+
if (!resolution.ok) {
|
|
464
|
+
throw recordMissingGenesisFault(manager, resolution);
|
|
465
|
+
}
|
|
466
|
+
genesis = resolution.genesis;
|
|
467
|
+
// A ladder is (re)established: clear any fault recorded by an earlier
|
|
468
|
+
// attempt in this process, so the observability record reflects the
|
|
469
|
+
// CURRENT state rather than a resolved one.
|
|
470
|
+
if (manager._missingGenesis)
|
|
471
|
+
manager._missingGenesis = null;
|
|
475
472
|
// Validate genesis hash if present (wired for stale-pair detection #3)
|
|
476
473
|
// On mismatch we only warn — genesis is still used for validation (log mode) / virtualization (enforce mode);
|
|
477
474
|
// a stale persisted snapshot vs fresh manager._genesis scenario is covered by the log/enforce gate above
|
|
478
|
-
if (
|
|
475
|
+
if (hasGenesisLadder(genesis) && typeof genesis.priceLevelsHash === 'string') {
|
|
479
476
|
try {
|
|
480
477
|
const recomputed = hashPriceLevels(genesis.priceLevels);
|
|
481
478
|
if (recomputed !== genesis.priceLevelsHash) {
|
|
@@ -484,16 +481,7 @@ export async function loadGrid(manager, grid, boundaryIdx = null, genesisInput =
|
|
|
484
481
|
}
|
|
485
482
|
catch { }
|
|
486
483
|
}
|
|
487
|
-
|
|
488
|
-
try {
|
|
489
|
-
const raw = (typeof process !== 'undefined' && process.env?.GRID_PRICE_SLOT_VALIDATION) || 'log';
|
|
490
|
-
return String(raw).toLowerCase() === 'enforce' ? 'enforce' : 'log';
|
|
491
|
-
}
|
|
492
|
-
catch {
|
|
493
|
-
return 'log';
|
|
494
|
-
}
|
|
495
|
-
})();
|
|
496
|
-
if (genesis && Array.isArray(genesis.priceLevels)) {
|
|
484
|
+
if (hasGenesisLadder(genesis)) {
|
|
497
485
|
// Validate each slot's price against genesis; virtualize only in enforce mode (plan §13)
|
|
498
486
|
//
|
|
499
487
|
// REPAIR (both modes): a slot id determines its price from the
|
|
@@ -587,72 +575,17 @@ export async function loadGrid(manager, grid, boundaryIdx = null, genesisInput =
|
|
|
587
575
|
else {
|
|
588
576
|
manager._genesis = genesis;
|
|
589
577
|
}
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
//
|
|
593
|
-
//
|
|
594
|
-
//
|
|
595
|
-
//
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
try {
|
|
602
|
-
const stepUp = 1 + (incPct / 100);
|
|
603
|
-
const stepDown = 1 - (incPct / 100);
|
|
604
|
-
const priceLevels = [];
|
|
605
|
-
let upPrice = startPrice * Math.sqrt(stepUp);
|
|
606
|
-
while (upPrice <= maxPrice) {
|
|
607
|
-
priceLevels.push(upPrice);
|
|
608
|
-
upPrice *= stepUp;
|
|
609
|
-
}
|
|
610
|
-
let downPrice = startPrice * Math.sqrt(stepDown);
|
|
611
|
-
while (downPrice >= minPrice) {
|
|
612
|
-
priceLevels.push(downPrice);
|
|
613
|
-
downPrice *= stepDown;
|
|
614
|
-
}
|
|
615
|
-
priceLevels.sort((a, b) => a - b);
|
|
616
|
-
// Dedupe (floatToBlockchainInt equality via fixed 12-decimals)
|
|
617
|
-
const uniq = [];
|
|
618
|
-
const seen = new Set();
|
|
619
|
-
for (const p of priceLevels) {
|
|
620
|
-
const key = Number(p).toFixed(12);
|
|
621
|
-
if (!seen.has(key)) {
|
|
622
|
-
seen.add(key);
|
|
623
|
-
uniq.push(p);
|
|
624
|
-
}
|
|
625
|
-
}
|
|
626
|
-
const gapSlotsForGenesis = calculateGapSlots(incPct, manager.config?.targetSpreadPercent, manager.config?.gridLimits);
|
|
627
|
-
const built = buildGenesisFromPriceLevels(startPrice, incPct, gapSlotsForGenesis, uniq);
|
|
628
|
-
// Cross-check: if user edited startPrice/min/max/increment across restarts on a legacy snapshot,
|
|
629
|
-
// the new-config rail will mismatch most persisted slot prices → noisy log / mass-virtualize
|
|
630
|
-
// in enforce mode and the mismatched genesis would be persisted. Count failures first.
|
|
631
|
-
let mismatchCount = 0;
|
|
632
|
-
for (const slot of grid) {
|
|
633
|
-
try {
|
|
634
|
-
assertSlotPriceInvariant(slot, built);
|
|
635
|
-
}
|
|
636
|
-
catch {
|
|
637
|
-
mismatchCount++;
|
|
638
|
-
}
|
|
639
|
-
}
|
|
640
|
-
const mismatchRatio = grid.length > 0 ? mismatchCount / grid.length : 0;
|
|
641
|
-
if (mismatchRatio > 0.5) {
|
|
642
|
-
manager.logger?.log?.(`[GENESIS] Migration: ${mismatchCount}/${grid.length} slots mismatch new-config rail (ratio ${mismatchRatio.toFixed(2)}) — config may have changed since snapshot; NOT adopting migration genesis (validation would ${validationMode === 'enforce' ? 'mass-virtualize' : 'be noisy'}). Persisted grid will be kept as-is until a clean rebuild`, 'warn');
|
|
643
|
-
}
|
|
644
|
-
else {
|
|
645
|
-
if (mismatchCount > 0) {
|
|
646
|
-
manager.logger?.log?.(`[GENESIS] Migration: ${mismatchCount}/${grid.length} slots mismatch new-config rail — will be logged${validationMode === 'enforce' ? '/virtualized' : ''} on next load`, 'warn');
|
|
647
|
-
}
|
|
648
|
-
manager._genesis = built;
|
|
649
|
-
genesis = built;
|
|
650
|
-
manager.logger?.log?.(`[GENESIS] Migrated legacy grid: built genesis with ${uniq.length} levels (hash ${built.priceLevelsHash})`, 'info');
|
|
651
|
-
}
|
|
652
|
-
}
|
|
653
|
-
catch (e) {
|
|
654
|
-
manager.logger?.log?.(`[GENESIS] Migration failed: ${getErrorMessage(e)}`, 'warn');
|
|
655
|
-
}
|
|
578
|
+
// Legacy snapshot with no persisted ladder: the resolver built one
|
|
579
|
+
// from the live geometric rail and cross-checked it against the
|
|
580
|
+
// persisted slots (mismatch ratio at or below
|
|
581
|
+
// MISSING_GENESIS_MISMATCH_RATIO), so it describes THIS generation.
|
|
582
|
+
// A refused ladder throws above (E1), so there is no genesis-less
|
|
583
|
+
// state left to load into. This is the only place a migration
|
|
584
|
+
// ladder is installed, so its adoption log lives here too (the
|
|
585
|
+
// former `else if` branch was unreachable, since this branch
|
|
586
|
+
// already handles every ladder-bearing resolution).
|
|
587
|
+
if (resolution.source === 'migration') {
|
|
588
|
+
manager.logger?.log?.(`[GENESIS] Migrated legacy grid: built genesis with ${genesis.priceLevels.length} levels (hash ${genesis.priceLevelsHash})`, 'info');
|
|
656
589
|
}
|
|
657
590
|
}
|
|
658
591
|
try {
|
|
@@ -749,6 +682,23 @@ export async function loadGrid(manager, grid, boundaryIdx = null, genesisInput =
|
|
|
749
682
|
manager._restoreBoundary(restoredBoundary);
|
|
750
683
|
manager.logger?.log?.(`Restored boundary index: ${restoredBoundary}`, 'info');
|
|
751
684
|
}
|
|
685
|
+
// Restart resilience: restore the persisted LAST-FILL-GUARD pivot
|
|
686
|
+
// WITH the boundary — after the persisted genesis is applied and
|
|
687
|
+
// the grid re-typed, before the first reconcile/broadcast — so a
|
|
688
|
+
// restart cannot re-open the cold window where the guard is
|
|
689
|
+
// disabled and evacuation stamps get applied against a boundary
|
|
690
|
+
// that is still being rebuilt. restoreLastFillPivot validates the
|
|
691
|
+
// row against the manager's live genesis (refuses on mismatch —
|
|
692
|
+
// a regenerated grid drops it) and onto the price ladder with the
|
|
693
|
+
// same one-increment drift rule the runtime guard applies.
|
|
694
|
+
if (restoredBoundary !== null) {
|
|
695
|
+
try {
|
|
696
|
+
restoreLastFillPivot(manager, manager?.accountOrders?.loadLastFillPivot?.() ?? null);
|
|
697
|
+
}
|
|
698
|
+
catch (pivotErr) {
|
|
699
|
+
manager.logger?.log?.(`[LAST-FILL-GUARD] Persisted pivot restore failed (${getErrorMessage(pivotErr)}); book seed takes over`, 'warn');
|
|
700
|
+
}
|
|
701
|
+
}
|
|
752
702
|
// Reassign slot types based on current boundary.
|
|
753
703
|
// Every slot's type must match its price-slot index (parseSlotIndex)
|
|
754
704
|
// relative to the boundary + gapSlots, not array position. After
|
|
@@ -1178,8 +1128,8 @@ export async function initializeGrid(manager) {
|
|
|
1178
1128
|
buy: resolveLiveReserveEdgeAnchorPrice(manager, 'buy'),
|
|
1179
1129
|
sell: resolveLiveReserveEdgeAnchorPrice(manager, 'sell')
|
|
1180
1130
|
};
|
|
1181
|
-
const reserveBuyIds = reserveEdgeIdSet(oldSlots, manager.config, ORDER_TYPES.BUY, edgeAnchors.buy);
|
|
1182
|
-
const reserveSellIds = reserveEdgeIdSet(oldSlots, manager.config, ORDER_TYPES.SELL, edgeAnchors.sell);
|
|
1131
|
+
const reserveBuyIds = reserveEdgeIdSet(oldSlots, manager.config, ORDER_TYPES.BUY, edgeAnchors.buy, liveWindowIdSet(manager, ORDER_TYPES.BUY));
|
|
1132
|
+
const reserveSellIds = reserveEdgeIdSet(oldSlots, manager.config, ORDER_TYPES.SELL, edgeAnchors.sell, liveWindowIdSet(manager, ORDER_TYPES.SELL));
|
|
1183
1133
|
let netShift = 0;
|
|
1184
1134
|
for (const e of owedCrawls) {
|
|
1185
1135
|
if (e?.side === ORDER_TYPES.BUY && reserveBuyIds?.has(e.slotId))
|
|
@@ -1236,14 +1186,36 @@ export async function initializeGrid(manager) {
|
|
|
1236
1186
|
maxPrice: resolvedMaxP,
|
|
1237
1187
|
});
|
|
1238
1188
|
manager._gapSlots = gapSlots;
|
|
1239
|
-
if (genesis)
|
|
1189
|
+
if (genesis) {
|
|
1240
1190
|
manager._genesis = genesis;
|
|
1191
|
+
// New generation: clear the missing-genesis fault/counter records so
|
|
1192
|
+
// the E2 sync-entry assert stops re-reporting a resolved condition
|
|
1193
|
+
// and an operator reading the logs sees only live faults.
|
|
1194
|
+
manager._missingGenesis = null;
|
|
1195
|
+
manager._genesisInvariantViolations = 0;
|
|
1196
|
+
manager._genesisInvariantLoggedAt = 0;
|
|
1197
|
+
}
|
|
1241
1198
|
// A rebuilt grid is a NEW generation: the boundary below is re-derived
|
|
1242
1199
|
// absolutely from the fresh price ladder, so owed fill crawls recorded
|
|
1243
1200
|
// against the previous generation must not survive — their relative
|
|
1244
1201
|
// deltas would shift the new anchor again for movement it already
|
|
1245
1202
|
// contains (and their slot ids now name different prices).
|
|
1246
1203
|
manager._clearPendingFillCrawls?.('grid rebuild');
|
|
1204
|
+
// Same generation contract for the LAST-FILL-GUARD pivot: it was
|
|
1205
|
+
// armed against the previous ladder, and restoreLastFillPivot would
|
|
1206
|
+
// refuse it against the new genesis anyway. Drop it now so the guard
|
|
1207
|
+
// re-arms on the first real fill of the new generation (the startup
|
|
1208
|
+
// book seed may arm a heuristic pivot in the meantime, which is
|
|
1209
|
+
// in-memory-only by provenance).
|
|
1210
|
+
try {
|
|
1211
|
+
if (typeof manager._resetLastFillPivot === 'function') {
|
|
1212
|
+
manager._resetLastFillPivot('grid rebuild');
|
|
1213
|
+
}
|
|
1214
|
+
else {
|
|
1215
|
+
resetLastFillPivot(manager, 'grid rebuild');
|
|
1216
|
+
}
|
|
1217
|
+
}
|
|
1218
|
+
catch { }
|
|
1247
1219
|
// RC-8: Update boundary with notification to dependent systems
|
|
1248
1220
|
// Persist master boundary for StrategyEngine
|
|
1249
1221
|
if (manager.boundaryIdx !== boundaryIdx) {
|
|
@@ -1595,11 +1567,13 @@ export async function _recalculateGridOrderSizesFromBlockchain(manager, orderTyp
|
|
|
1595
1567
|
// geometric progression including empties, then re-type the picked slot
|
|
1596
1568
|
// to BUY/SELL before placement. The COW boundary-shift path re-types
|
|
1597
1569
|
// the working grid by geometry first, so crossers stay in the correct
|
|
1598
|
-
// side's denominator. Reserve edge slots are
|
|
1599
|
-
//
|
|
1600
|
-
//
|
|
1601
|
-
//
|
|
1602
|
-
//
|
|
1570
|
+
// side's denominator. Reserve edge slots are included here like any
|
|
1571
|
+
// other slot-N side slot: this geometric curve sizes them too, and the
|
|
1572
|
+
// activation picker (_pickEdgeReserveSlots) only ever places a reserve
|
|
1573
|
+
// with the stored size the target-grid sizing pipeline already wrote
|
|
1574
|
+
// (exact values, one sizing rule). Skipping reserves in this pass
|
|
1575
|
+
// would make the divergence resize disagree with that pipeline. Only
|
|
1576
|
+
// non-slot-N shelf/manual ids are skipped below.
|
|
1603
1577
|
const orderSource = collectActions ? workingGrid : manager.orders;
|
|
1604
1578
|
const allSideSlots = Array.from(orderSource.values())
|
|
1605
1579
|
.filter((o) => o.type === orderType)
|
|
@@ -1,4 +1,13 @@
|
|
|
1
1
|
/**
|
|
2
|
+
* Resume a persisted grid whose order ids no longer match the book, by
|
|
3
|
+
* re-adopting the live chain orders into the frozen ladder (nearest-slot).
|
|
4
|
+
*
|
|
5
|
+
* The name is historical: there is no price matcher here any more. It loads the
|
|
6
|
+
* persisted grid (which establishes the price ladder, or is refused with
|
|
7
|
+
* MissingGenesisError and reported as "not resumed") and lets the normal sync
|
|
8
|
+
* bind each live chain order to the slot its price maps to. A grid whose ladder
|
|
9
|
+
* is unusable never resumes — the caller regenerates.
|
|
10
|
+
*
|
|
2
11
|
* Returns { resumed: boolean, matchedCount: number }.
|
|
3
12
|
* @param {Object} params - Destructured parameters
|
|
4
13
|
* @param {Object} params.manager - OrderManager instance
|
|
@@ -49,6 +49,15 @@ function _startupCancelPlanStillCurrent(plan, manager, initialChainSignature, cu
|
|
|
49
49
|
return !findLiveOrderOwnerByChainId(manager, plan.chainOrderId);
|
|
50
50
|
}
|
|
51
51
|
/**
|
|
52
|
+
* Resume a persisted grid whose order ids no longer match the book, by
|
|
53
|
+
* re-adopting the live chain orders into the frozen ladder (nearest-slot).
|
|
54
|
+
*
|
|
55
|
+
* The name is historical: there is no price matcher here any more. It loads the
|
|
56
|
+
* persisted grid (which establishes the price ladder, or is refused with
|
|
57
|
+
* MissingGenesisError and reported as "not resumed") and lets the normal sync
|
|
58
|
+
* bind each live chain order to the slot its price maps to. A grid whose ladder
|
|
59
|
+
* is unusable never resumes — the caller regenerates.
|
|
60
|
+
*
|
|
52
61
|
* Returns { resumed: boolean, matchedCount: number }.
|
|
53
62
|
* @param {Object} params - Destructured parameters
|
|
54
63
|
* @param {Object} params.manager - OrderManager instance
|
|
@@ -66,7 +75,7 @@ export async function attemptResumePersistedGridByPriceMatch({ manager, persiste
|
|
|
66
75
|
if (!manager || typeof manager.synchronizeWithChain !== 'function')
|
|
67
76
|
return { resumed: false, matchedCount: 0 };
|
|
68
77
|
try {
|
|
69
|
-
logger && logger.log && logger.log('No matching active order IDs found. Attempting to
|
|
78
|
+
logger && logger.log && logger.log('No matching active order IDs found. Attempting to re-adopt by ladder level...', 'info');
|
|
70
79
|
const { loadGrid } = require('./grid');
|
|
71
80
|
// Prefer explicit genesis if caller wired it, else fall back to manager._genesis
|
|
72
81
|
const genesisArg = genesis ?? manager?._genesis ?? null;
|
|
@@ -77,17 +86,17 @@ export async function attemptResumePersistedGridByPriceMatch({ manager, persiste
|
|
|
77
86
|
.map((o) => o.orderId)
|
|
78
87
|
.filter(Boolean));
|
|
79
88
|
if (matchedOrderIds.size === 0) {
|
|
80
|
-
logger && logger.log && logger.log('
|
|
89
|
+
logger && logger.log && logger.log('Ladder-level re-adoption found no matches. Generating new grid.', 'info');
|
|
81
90
|
return { resumed: false, matchedCount: 0 };
|
|
82
91
|
}
|
|
83
|
-
logger && logger.log && logger.log(`Successfully
|
|
92
|
+
logger && logger.log && logger.log(`Successfully re-adopted ${matchedOrderIds.size} orders by ladder level. Resuming with existing grid.`, 'info');
|
|
84
93
|
if (typeof storeGrid === 'function') {
|
|
85
94
|
await storeGrid(Array.from(manager.orders.values()));
|
|
86
95
|
}
|
|
87
96
|
return { resumed: true, matchedCount: matchedOrderIds.size };
|
|
88
97
|
}
|
|
89
98
|
catch (err) {
|
|
90
|
-
logger && logger.log && logger.log(`
|
|
99
|
+
logger && logger.log && logger.log(`Ladder-level resume attempt failed: ${err && getErrorMessage(err) ? getErrorMessage(err) : err}`, 'warn');
|
|
91
100
|
return { resumed: false, matchedCount: 0 };
|
|
92
101
|
}
|
|
93
102
|
}
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
import { ORDER_TYPES, ORDER_STATES, TIMING, BTS_PRECISION } from '../constants.js';
|
|
8
8
|
import { readOpenOrdersGuarded } from '../chain_orders.js';
|
|
9
9
|
import { getMinOrderSize, getAssetFees, getAssetFeesSafe, blockchainToFloat, findCrossedOrder, resolveGapBand, isSlotInRail, priceSlotEqual } from './utils/math.js';
|
|
10
|
-
import { isOrderPlaced, parseChainOrder, buildCreateOrderArgs, buildOutsideInPairGroups, extractBatchOperationResults, chainOrderMatchesSlotWithTolerance, buildCrossingCheckCandidates, isCrossingCheckCandidate, getSideBudget, calculateBudgetedSizes, getActiveOrdersTotal, convertToSpreadPlaceholder, isOrderGoneErrorMessage, clearDuplicateOrphanDetection, resolveReserveCount, resolveLiveReserveEdgeAnchorPrice, reserveEdgeIdSet, compareReserveEdge, parseSlotIndex, reportGridPriceInvariant } from './utils/order.js';
|
|
10
|
+
import { isOrderPlaced, parseChainOrder, buildCreateOrderArgs, buildOutsideInPairGroups, extractBatchOperationResults, chainOrderMatchesSlotWithTolerance, buildCrossingCheckCandidates, isCrossingCheckCandidate, getSideBudget, calculateBudgetedSizes, getActiveOrdersTotal, convertToSpreadPlaceholder, isOrderGoneErrorMessage, clearDuplicateOrphanDetection, resolveReserveCount, resolveLiveReserveEdgeAnchorPrice, reserveEdgeIdSet, compareReserveEdge, parseSlotIndex, reportGridPriceInvariant, liveWindowIdSet } from './utils/order.js';
|
|
11
11
|
import { resolveAccountRef } from './utils/system.js';
|
|
12
12
|
import * as Format from './format.js';
|
|
13
13
|
import { getErrorMessage } from '../utils/errors.js';
|
|
@@ -1334,6 +1334,15 @@ async function _executePlannedStartupCreates({ createPlans, chainOrders, account
|
|
|
1334
1334
|
if (groups.length === 0)
|
|
1335
1335
|
return createdOrderIds;
|
|
1336
1336
|
logger?.log?.(`Startup: Executing ${createPlans.length} planned create(s) in ${groups.length} outside->center group(s)`, 'info');
|
|
1337
|
+
// 7c: yield to the event loop between create groups. Phase 2 holds the
|
|
1338
|
+
// broadcasting region across the whole loop; a blocking/synchronous
|
|
1339
|
+
// stretch of group prep + master mutations must not starve timers and
|
|
1340
|
+
// watchdog pollers (region-end reschedule, _awaitBroadcastIdle, stale-flag
|
|
1341
|
+
// clear) that run on the macrotask queue. The network I/O in each group
|
|
1342
|
+
// already yields, but an explicit yield guarantees it per group.
|
|
1343
|
+
// setTimeout(0) (not setImmediate): this module is browser-safe, and
|
|
1344
|
+
// setImmediate is Node-only.
|
|
1345
|
+
const yieldBetweenCreateGroups = () => new Promise((resolve) => setTimeout(resolve, 0));
|
|
1337
1346
|
for (let i = 0; i < groups.length; i++) {
|
|
1338
1347
|
const group = groups[i];
|
|
1339
1348
|
const labels = group.map((p) => `${p.orderType.toUpperCase()}:${p.gridOrder?.id}`).join(', ');
|
|
@@ -1352,6 +1361,7 @@ async function _executePlannedStartupCreates({ createPlans, chainOrders, account
|
|
|
1352
1361
|
});
|
|
1353
1362
|
for (const id of batchIds)
|
|
1354
1363
|
createdOrderIds.add(id);
|
|
1364
|
+
await yieldBetweenCreateGroups();
|
|
1355
1365
|
continue;
|
|
1356
1366
|
}
|
|
1357
1367
|
if (group.length > 1 && !canBatchCreate) {
|
|
@@ -1371,6 +1381,7 @@ async function _executePlannedStartupCreates({ createPlans, chainOrders, account
|
|
|
1371
1381
|
if (chainOrderId)
|
|
1372
1382
|
createdOrderIds.add(chainOrderId);
|
|
1373
1383
|
}
|
|
1384
|
+
await yieldBetweenCreateGroups();
|
|
1374
1385
|
}
|
|
1375
1386
|
const failedCount = Math.max(0, createPlans.length - createdOrderIds.size);
|
|
1376
1387
|
logger?.log?.(`Startup: Create execution summary: ${createdOrderIds.size}/${createPlans.length} planned create(s) placed ` +
|
|
@@ -1396,7 +1407,7 @@ async function _reconcileStartupSide({ orderType, targetCount, chainSideOrders,
|
|
|
1396
1407
|
const pickedIds = new Set(desiredSlots.map((s) => s?.id).filter(Boolean));
|
|
1397
1408
|
const freshEdge = _pickEdgeReserveSlots(manager, orderType, reserveCount, pickedIds);
|
|
1398
1409
|
const reserveAnchor = resolveLiveReserveEdgeAnchorPrice(manager, reserveSide);
|
|
1399
|
-
reserveEdgeIds = reserveEdgeIdSet(Array.from(manager.orders.values()), manager.config, orderType, reserveAnchor);
|
|
1410
|
+
reserveEdgeIds = reserveEdgeIdSet(Array.from(manager.orders.values()), manager.config, orderType, reserveAnchor, liveWindowIdSet(manager, orderType));
|
|
1400
1411
|
// Window first, then the ready edge reserves. Only the reserve share
|
|
1401
1412
|
// still MISSING on-chain is held back for the edge (a live reserve is
|
|
1402
1413
|
// already part of matchedOnGrid and must not shrink the window plan), so
|
|
@@ -49,7 +49,10 @@ declare class Logger {
|
|
|
49
49
|
* @param {string} [category='DEXBot'] - Logger category/prefix
|
|
50
50
|
* @param {Object} [options]
|
|
51
51
|
* @param {boolean} [options.quiet] - Suppress console output
|
|
52
|
-
* @param {boolean} [options.quietUnderPm2=
|
|
52
|
+
* @param {boolean} [options.quietUnderPm2=false] - Legacy opt-in to suppress
|
|
53
|
+
* console output under PM2. Keep this false in normal operation: under
|
|
54
|
+
* PM2 stdout is the only sink (direct file writes are suppressed), so
|
|
55
|
+
* auto-quieting drops every log line.
|
|
53
56
|
* @param {string} [options.logFile] - Optional path to log file
|
|
54
57
|
* @param {string} [options.level='info'] - Log level
|
|
55
58
|
* @param {Object} [options.configOverride] - Override LOGGING_CONFIG
|
|
@@ -135,9 +138,16 @@ declare class Logger {
|
|
|
135
138
|
displayStatus(manager: any, forceOutput?: boolean): void;
|
|
136
139
|
}
|
|
137
140
|
declare function isPm2Runtime(): boolean;
|
|
141
|
+
/**
|
|
142
|
+
* True when PM2 owns the log files for this process (pm_out_log_path /
|
|
143
|
+
* pm_err_log_path present). In that case stdout/stderr are the only sink and
|
|
144
|
+
* the Logger suppresses its own file writes to avoid double-writing into the
|
|
145
|
+
* PM2-managed file.
|
|
146
|
+
*/
|
|
147
|
+
declare function isPm2LogCaptureActive(): boolean;
|
|
138
148
|
declare function createPm2AwareLogger(category: string, options?: {
|
|
139
149
|
quietUnderPm2?: boolean;
|
|
140
150
|
}): Logger;
|
|
141
|
-
export { createPm2AwareLogger, isPm2Runtime, setGlobalConsoleLevel, getGlobalConsoleLevel };
|
|
151
|
+
export { createPm2AwareLogger, isPm2Runtime, isPm2LogCaptureActive, setGlobalConsoleLevel, getGlobalConsoleLevel };
|
|
142
152
|
export default Logger;
|
|
143
153
|
//# sourceMappingURL=logger.d.ts.map
|
|
@@ -73,7 +73,10 @@ class Logger {
|
|
|
73
73
|
* @param {string} [category='DEXBot'] - Logger category/prefix
|
|
74
74
|
* @param {Object} [options]
|
|
75
75
|
* @param {boolean} [options.quiet] - Suppress console output
|
|
76
|
-
* @param {boolean} [options.quietUnderPm2=
|
|
76
|
+
* @param {boolean} [options.quietUnderPm2=false] - Legacy opt-in to suppress
|
|
77
|
+
* console output under PM2. Keep this false in normal operation: under
|
|
78
|
+
* PM2 stdout is the only sink (direct file writes are suppressed), so
|
|
79
|
+
* auto-quieting drops every log line.
|
|
77
80
|
* @param {string} [options.logFile] - Optional path to log file
|
|
78
81
|
* @param {string} [options.level='info'] - Log level
|
|
79
82
|
* @param {Object} [options.configOverride] - Override LOGGING_CONFIG
|
|
@@ -82,11 +85,21 @@ class Logger {
|
|
|
82
85
|
constructor(category = 'DEXBot', options = {}) {
|
|
83
86
|
this.category = category;
|
|
84
87
|
const isUnderPm2 = !!Config.pm_exec_path;
|
|
85
|
-
const hasPm2Logging = !!(Config.pm_out_log_path || Config.pm_err_log_path);
|
|
86
|
-
const pm2AutoQuiet = isUnderPm2 && hasPm2Logging;
|
|
87
|
-
const quietUnderPm2 = options.quietUnderPm2 !== false;
|
|
88
88
|
this.logFile = options.logFile || null;
|
|
89
|
-
|
|
89
|
+
if (options.quiet !== undefined) {
|
|
90
|
+
this.quiet = options.quiet;
|
|
91
|
+
}
|
|
92
|
+
else if (options.quietUnderPm2 === true && isUnderPm2) {
|
|
93
|
+
// Legacy escape hatch: explicit opt-in to the old silent behaviour.
|
|
94
|
+
this.quiet = true;
|
|
95
|
+
}
|
|
96
|
+
else {
|
|
97
|
+
// Non-PM2 runs with a logFile write to the file only, so console is
|
|
98
|
+
// quiet to avoid duplication. Under PM2 the file sink is suppressed
|
|
99
|
+
// (see _enqueueWrite) and PM2 captures stdout, so console must stay
|
|
100
|
+
// on or nothing is logged at all.
|
|
101
|
+
this.quiet = !!this.logFile && !isPm2LogCaptureActive();
|
|
102
|
+
}
|
|
90
103
|
this.level = options.level || 'info';
|
|
91
104
|
this.config = options.configOverride || LOGGING_CONFIG;
|
|
92
105
|
this.state = new LoggerState();
|
|
@@ -125,7 +138,7 @@ class Logger {
|
|
|
125
138
|
_enqueueWrite(text) {
|
|
126
139
|
if (!this.logFile)
|
|
127
140
|
return;
|
|
128
|
-
if (
|
|
141
|
+
if (isPm2LogCaptureActive())
|
|
129
142
|
return;
|
|
130
143
|
this._writeQueue.push(text);
|
|
131
144
|
if (this._writeQueue.length >= this._maxQueueSize) {
|
|
@@ -586,9 +599,18 @@ class Logger {
|
|
|
586
599
|
function isPm2Runtime() {
|
|
587
600
|
return !!Config.pm_exec_path;
|
|
588
601
|
}
|
|
602
|
+
/**
|
|
603
|
+
* True when PM2 owns the log files for this process (pm_out_log_path /
|
|
604
|
+
* pm_err_log_path present). In that case stdout/stderr are the only sink and
|
|
605
|
+
* the Logger suppresses its own file writes to avoid double-writing into the
|
|
606
|
+
* PM2-managed file.
|
|
607
|
+
*/
|
|
608
|
+
function isPm2LogCaptureActive() {
|
|
609
|
+
return !!(Config.pm_out_log_path || Config.pm_err_log_path);
|
|
610
|
+
}
|
|
589
611
|
function createPm2AwareLogger(category, options = {}) {
|
|
590
612
|
return new Logger(category, options);
|
|
591
613
|
}
|
|
592
|
-
export { createPm2AwareLogger, isPm2Runtime, setGlobalConsoleLevel, getGlobalConsoleLevel };
|
|
614
|
+
export { createPm2AwareLogger, isPm2Runtime, isPm2LogCaptureActive, setGlobalConsoleLevel, getGlobalConsoleLevel };
|
|
593
615
|
export default Logger;
|
|
594
616
|
//# sourceMappingURL=logger.js.map
|
|
@@ -153,6 +153,10 @@ declare class OrderManager {
|
|
|
153
153
|
_committedOrderIdsBuiltAt: number;
|
|
154
154
|
_orderIdAssignedAt: Map<string, number>;
|
|
155
155
|
_gapSlots: number;
|
|
156
|
+
_genesis: any;
|
|
157
|
+
_missingGenesis: any;
|
|
158
|
+
_genesisInvariantViolations: number;
|
|
159
|
+
_genesisInvariantLoggedAt: number;
|
|
156
160
|
_gridDirtyAt: number | null;
|
|
157
161
|
_lastStaleTotalsWarnAt: Record<string, number>;
|
|
158
162
|
_orphanFillsCreditedAt: number | null;
|
|
@@ -175,6 +179,7 @@ declare class OrderManager {
|
|
|
175
179
|
_lastFilledPrice: number | null;
|
|
176
180
|
_lastFilledType: string | null;
|
|
177
181
|
_lastFilledAt: number;
|
|
182
|
+
lastFillPivotSource: 'fill' | 'book' | null;
|
|
178
183
|
_deferredRebalanceAt: number;
|
|
179
184
|
_lastHeldPlanSignature: any;
|
|
180
185
|
_heldPlanSuppressionCount: number;
|
|
@@ -653,6 +658,54 @@ declare class OrderManager {
|
|
|
653
658
|
* only; no behavioral effect.
|
|
654
659
|
*/
|
|
655
660
|
_logBoundaryDebug(source: string, newIdx: number | null): void;
|
|
661
|
+
/**
|
|
662
|
+
* Single writer for the LAST-FILL-GUARD pivot scalar
|
|
663
|
+
* family(_lastFilledPrice/_lastFilledType/_lastFilledAt/lastFillPivotSource
|
|
664
|
+
* + the _lastFilledBuyPrice/_lastFilledSellPrice per-side mirror).
|
|
665
|
+
*
|
|
666
|
+
* Thin instance wrapper: the implementation lives in setLastFillPivot
|
|
667
|
+
* (utils/system.ts, shared free function with the legacy-stub fallback
|
|
668
|
+
* built in) so cow_runtime's queued-fill refresh and restoreLastFillPivot
|
|
669
|
+
* write the exact same scalar family through one implementation.
|
|
670
|
+
*
|
|
671
|
+
* Centralizing the write is what makes the persist/restore contract
|
|
672
|
+
* enforceable: only a pivot written with provenance 'fill' (a real fill
|
|
673
|
+
* at a real price) is persist-eligible; a 'book' pivot (seeded from
|
|
674
|
+
* max-resting-buy / min-resting-sell at startup, not market truth) stays
|
|
675
|
+
* in-memory only. The provenance flag and the value can never drift
|
|
676
|
+
* apart.
|
|
677
|
+
*
|
|
678
|
+
* Best-effort mirror persistence: the pivot rides the next grid-persist
|
|
679
|
+
* flush (persistGridSnapshot reads lastFillPivotSource), so a fill that
|
|
680
|
+
* armed the guard is durable across restarts without a dedicated disk
|
|
681
|
+
* write on the hot path.
|
|
682
|
+
*
|
|
683
|
+
* @param {string} type - ORDER_TYPES.BUY or ORDER_TYPES.SELL
|
|
684
|
+
* @param {number} price - Pivot price (finite, > 0; validated by callers)
|
|
685
|
+
* @param {string} provenance - 'fill' (persist-eligible) or 'book' (seed heuristic)
|
|
686
|
+
* @param {number} [atMs] - Fill timestamp to preserve (defaults to now)
|
|
687
|
+
* @returns {boolean} True when the pivot was written
|
|
688
|
+
*/
|
|
689
|
+
_setLastFillPivot(type: any, price: number, provenance: 'fill' | 'book', atMs?: number): boolean;
|
|
690
|
+
/**
|
|
691
|
+
* Reset the LAST-FILL-GUARD pivot to cold state, clearing the whole
|
|
692
|
+
* scalar family (per-side mirrors included): leaves seedLastFilledPricesFromBook's
|
|
693
|
+
* early-return check honest after a grid rebuild, so the
|
|
694
|
+
* startup book seed can arm again instead of being silently suppressed
|
|
695
|
+
* by stale per-side mirrors. Delegates to resetLastFillPivot
|
|
696
|
+
* (utils/system.ts) — the free function stays for non-instance callers
|
|
697
|
+
* (cow runtime tests, recovery paths carrying a bare manager).
|
|
698
|
+
*
|
|
699
|
+
* Used whenever the pivot's generation is invalidated: grid rebuild,
|
|
700
|
+
* rejected-snapshot reset, any path that re-anchors the boundary outside
|
|
701
|
+
* the fill flow. Must not touch disk (marks nothing dirty — the pivot is
|
|
702
|
+
* a live-grid invariant, the persist pipeline clears the row on the next
|
|
703
|
+
* flush by passing null).
|
|
704
|
+
*
|
|
705
|
+
* @param {string} reason - Log/debug label
|
|
706
|
+
* @returns {boolean} True when an armed pivot was cleared
|
|
707
|
+
*/
|
|
708
|
+
_resetLastFillPivot(reason?: string): boolean;
|
|
656
709
|
/**
|
|
657
710
|
* Record last filled price for the single-pivot guard: when armed, BOTH
|
|
658
711
|
* sides are gated against the most recent fill price (BUY blocked above
|