dexbot 1.6.7 → 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 +49 -1
- package/README.md +3 -3
- 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 +22 -6
- 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 +10 -0
- package/dist/modules/account_orders.d.ts +24 -2
- package/dist/modules/account_orders.js +41 -4
- package/dist/modules/bot_settings.js +10 -1
- package/dist/modules/config.d.ts +1 -0
- package/dist/modules/config.js +1 -0
- package/dist/modules/constants.d.ts +11 -3
- package/dist/modules/constants.js +116 -37
- 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 +4 -87
- package/dist/modules/dexbot_maintenance_runtime.d.ts +15 -1
- package/dist/modules/dexbot_maintenance_runtime.js +59 -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 +21 -0
- 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 +76 -134
- 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 +2 -2
- package/dist/modules/order/manager.d.ts +4 -0
- package/dist/modules/order/manager.js +14 -1
- 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 +220 -197
- package/dist/modules/order/utils/system.js +8 -1
- package/dist/modules/paths.d.ts +1 -0
- package/dist/modules/paths.js +1 -0
- package/dist/modules/version_notice.d.ts +165 -0
- package/dist/modules/version_notice.js +364 -0
- package/dist/pm2.js +9 -0
- package/dist/unlock.js +28 -0
- package/docs/BITSHARES_ONBOARDING.md +8 -1
- package/docs/COW_INVARIANTS.md +3 -2
- package/docs/DEXBOT_COMPARISON.md +4 -4
- package/docs/EVOLUTION.md +20 -19
- package/docs/FUND_MOVEMENT_AND_ACCOUNTING.md +1 -1
- package/docs/GRID_PRICE_INVARIANT.md +149 -31
- package/docs/GRID_RECALCULATION.md +12 -0
- 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 +13 -5
- 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/cli_start_onboarding.d.ts.map +0 -1
- package/dist/modules/cli_start_onboarding.js.map +0 -1
- package/dist/modules/cli_start_output.d.ts.map +0 -1
- package/dist/modules/cli_start_output.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/utils/text_width.d.ts.map +0 -1
- package/dist/modules/utils/text_width.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';
|
|
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
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 {
|
|
@@ -1195,8 +1128,8 @@ export async function initializeGrid(manager) {
|
|
|
1195
1128
|
buy: resolveLiveReserveEdgeAnchorPrice(manager, 'buy'),
|
|
1196
1129
|
sell: resolveLiveReserveEdgeAnchorPrice(manager, 'sell')
|
|
1197
1130
|
};
|
|
1198
|
-
const reserveBuyIds = reserveEdgeIdSet(oldSlots, manager.config, ORDER_TYPES.BUY, edgeAnchors.buy);
|
|
1199
|
-
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));
|
|
1200
1133
|
let netShift = 0;
|
|
1201
1134
|
for (const e of owedCrawls) {
|
|
1202
1135
|
if (e?.side === ORDER_TYPES.BUY && reserveBuyIds?.has(e.slotId))
|
|
@@ -1253,8 +1186,15 @@ export async function initializeGrid(manager) {
|
|
|
1253
1186
|
maxPrice: resolvedMaxP,
|
|
1254
1187
|
});
|
|
1255
1188
|
manager._gapSlots = gapSlots;
|
|
1256
|
-
if (genesis)
|
|
1189
|
+
if (genesis) {
|
|
1257
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
|
+
}
|
|
1258
1198
|
// A rebuilt grid is a NEW generation: the boundary below is re-derived
|
|
1259
1199
|
// absolutely from the fresh price ladder, so owed fill crawls recorded
|
|
1260
1200
|
// against the previous generation must not survive — their relative
|
|
@@ -1627,11 +1567,13 @@ export async function _recalculateGridOrderSizesFromBlockchain(manager, orderTyp
|
|
|
1627
1567
|
// geometric progression including empties, then re-type the picked slot
|
|
1628
1568
|
// to BUY/SELL before placement. The COW boundary-shift path re-types
|
|
1629
1569
|
// the working grid by geometry first, so crossers stay in the correct
|
|
1630
|
-
// side's denominator. Reserve edge slots are
|
|
1631
|
-
//
|
|
1632
|
-
//
|
|
1633
|
-
//
|
|
1634
|
-
//
|
|
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.
|
|
1635
1577
|
const orderSource = collectActions ? workingGrid : manager.orders;
|
|
1636
1578
|
const allSideSlots = Array.from(orderSource.values())
|
|
1637
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';
|
|
@@ -1407,7 +1407,7 @@ async function _reconcileStartupSide({ orderType, targetCount, chainSideOrders,
|
|
|
1407
1407
|
const pickedIds = new Set(desiredSlots.map((s) => s?.id).filter(Boolean));
|
|
1408
1408
|
const freshEdge = _pickEdgeReserveSlots(manager, orderType, reserveCount, pickedIds);
|
|
1409
1409
|
const reserveAnchor = resolveLiveReserveEdgeAnchorPrice(manager, reserveSide);
|
|
1410
|
-
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));
|
|
1411
1411
|
// Window first, then the ready edge reserves. Only the reserve share
|
|
1412
1412
|
// still MISSING on-chain is held back for the edge (a live reserve is
|
|
1413
1413
|
// already part of matchedOnGrid and must not shrink the window plan), so
|
|
@@ -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;
|
|
@@ -241,7 +241,8 @@ class COWRebalanceEngine {
|
|
|
241
241
|
const refillSlotIds = collectRefillSlotIds(optimizedActions, {
|
|
242
242
|
config: this.config,
|
|
243
243
|
slots: masterGrid,
|
|
244
|
-
edgeAnchors: reserveEdgeAnchors
|
|
244
|
+
edgeAnchors: reserveEdgeAnchors,
|
|
245
|
+
manager: this
|
|
245
246
|
});
|
|
246
247
|
projectTargetToWorkingGrid(workingGrid, targetGrid, { actions: optimizedActions });
|
|
247
248
|
const precisions = {
|
|
@@ -417,6 +418,10 @@ class OrderManager {
|
|
|
417
418
|
_committedOrderIdsBuiltAt;
|
|
418
419
|
_orderIdAssignedAt;
|
|
419
420
|
_gapSlots;
|
|
421
|
+
_genesis;
|
|
422
|
+
_missingGenesis;
|
|
423
|
+
_genesisInvariantViolations;
|
|
424
|
+
_genesisInvariantLoggedAt;
|
|
420
425
|
_gridDirtyAt;
|
|
421
426
|
_lastStaleTotalsWarnAt;
|
|
422
427
|
_orphanFillsCreditedAt;
|
|
@@ -536,6 +541,14 @@ class OrderManager {
|
|
|
536
541
|
this._committedOrderIdsBuiltAt = 0;
|
|
537
542
|
this._orderIdAssignedAt = new Map();
|
|
538
543
|
this._gapSlots = 0;
|
|
544
|
+
// Genesis (price-ladder) state. `_genesis` is established by
|
|
545
|
+
// loadGrid/initializeGrid; these records are the missing-genesis fault
|
|
546
|
+
// and the sync-entry invariant counter, reset with each new generation
|
|
547
|
+
// (initializeGrid) and read by the E2 assert (order/sync_engine).
|
|
548
|
+
this._genesis = null;
|
|
549
|
+
this._missingGenesis = null;
|
|
550
|
+
this._genesisInvariantViolations = 0;
|
|
551
|
+
this._genesisInvariantLoggedAt = 0;
|
|
539
552
|
this._gridDirtyAt = null;
|
|
540
553
|
this._orphanFillsCreditedAt = null;
|
|
541
554
|
this._fundDriftLedger = null;
|
|
@@ -369,6 +369,25 @@ declare class SyncEngine {
|
|
|
369
369
|
* @param {string} source - Source identifier ('createOrder', 'cancelOrder', 'readOpenOrders', etc.)
|
|
370
370
|
* @returns {Promise<Object>} { newOrders, ordersNeedingCorrection }
|
|
371
371
|
*/
|
|
372
|
+
/**
|
|
373
|
+
* E2 invariant assert: a manager holding grid slots but no price ladder is
|
|
374
|
+
* in the undefined state the grid-price invariant forbids (INV-GRID-004).
|
|
375
|
+
*
|
|
376
|
+
* Reports once per grid generation (latched on the manager, counted in
|
|
377
|
+
* `_genesisInvariantViolations`) and, when the bot wired the structural
|
|
378
|
+
* resync, requests one so the ladder is re-derived. Returns FALSE so the
|
|
379
|
+
* caller ABORTS the sync untouched: with no ladder there is no authority for
|
|
380
|
+
* a slot's price, and the legacy tolerance matcher that used to cover this
|
|
381
|
+
* state is gone — continuing would let an off-grid chain price be adopted
|
|
382
|
+
* into a slot.
|
|
383
|
+
*
|
|
384
|
+
* Non-throwing on purpose: the load-side gates (E1/E3) own the fail-closed
|
|
385
|
+
* decision, this one makes a bypass loud without stranding a live manager.
|
|
386
|
+
* @param {any} mgr - OrderManager instance
|
|
387
|
+
* @returns {boolean} true when the grid may be synced (no slots, or a usable
|
|
388
|
+
* ladder is present); false when the sync must not run.
|
|
389
|
+
*/
|
|
390
|
+
_assertGenesisInvariant(mgr: any): boolean;
|
|
372
391
|
synchronizeWithChain(chainData: any, source: string): Promise<any>;
|
|
373
392
|
/**
|
|
374
393
|
* Fetch account balances from blockchain and update optimistic fund totals.
|