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
|
@@ -209,6 +209,103 @@ export declare function persistGridSnapshot(manager: any, accountOrders: any, sn
|
|
|
209
209
|
* @returns {number} Number of streak entries restored
|
|
210
210
|
*/
|
|
211
211
|
export declare function restoreGapEvacStreaks(manager: any, persisted: any): number;
|
|
212
|
+
/**
|
|
213
|
+
* Normalize a persisted LAST-FILL-GUARD pivot row (shared by the
|
|
214
|
+
* AccountOrders sanitizer/loader and the payload builder's row contract).
|
|
215
|
+
*
|
|
216
|
+
* Returns the row normalized to {price:number, type, fillsAt:number,
|
|
217
|
+
* genesisHash} when every field passes its gate, null otherwise:
|
|
218
|
+
* - finite price > 0
|
|
219
|
+
* - type is ORDER_TYPES.BUY or ORDER_TYPES.SELL
|
|
220
|
+
* - finite fillsAt > 0
|
|
221
|
+
* - non-empty string genesisHash
|
|
222
|
+
*
|
|
223
|
+
* @param {any} row - Raw candidate row
|
|
224
|
+
* @returns {Object|null} Normalized row or null
|
|
225
|
+
*/
|
|
226
|
+
export declare function normalizeLastFillPivot(row: any): {
|
|
227
|
+
price: number;
|
|
228
|
+
type: string;
|
|
229
|
+
fillsAt: number;
|
|
230
|
+
genesisHash: string;
|
|
231
|
+
} | null;
|
|
232
|
+
/**
|
|
233
|
+
* Write the LAST-FILL-GUARD pivot scalar family in one place (free
|
|
234
|
+
* implementation shared by the manager method, cow_runtime's queued-fill
|
|
235
|
+
* refresh, and restoreLastFillPivot).
|
|
236
|
+
*
|
|
237
|
+
* Writes _lastFilledPrice, _lastFilledType, _lastFilledAt,
|
|
238
|
+
* lastFillPivotSource and the per-side mirror (_lastFilledBuyPrice or
|
|
239
|
+
* _lastFilledSellPrice). `atMs` lets restoreLastFillPivot preserve the
|
|
240
|
+
* persisted fill timestamp (otherwise every restart would re-stamp "now"
|
|
241
|
+
* and the TTL would degrade to "time since last restart"); ordinary fill
|
|
242
|
+
* calls omit it and take Date.now().
|
|
243
|
+
*
|
|
244
|
+
* @param {Object} manager - OrderManager instance (or legacy stub)
|
|
245
|
+
* @param {string} type - ORDER_TYPES.BUY or ORDER_TYPES.SELL
|
|
246
|
+
* @param {number} price - Pivot price (finite, > 0)
|
|
247
|
+
* @param {string} provenance - 'fill' (persist-eligible) or 'book' (seed heuristic)
|
|
248
|
+
* @param {number} [atMs] - Fill timestamp to preserve (defaults to now)
|
|
249
|
+
* @returns {boolean} True when the pivot was written
|
|
250
|
+
*/
|
|
251
|
+
export declare function setLastFillPivot(manager: any, type: any, price: any, provenance: 'fill' | 'book', atMs?: number): boolean;
|
|
252
|
+
/**
|
|
253
|
+
* Clear the manager's LAST-FILL-GUARD pivot to cold state — the FULL scalar
|
|
254
|
+
* family, per-side mirrors included. Clearing only the primary fields would
|
|
255
|
+
* leave seedLastFilledPricesFromBook's early-return (both mirrors set)
|
|
256
|
+
* silently suppressing the startup book seed after every grid rebuild — the
|
|
257
|
+
* exact cold window the persist/restore feature exists to close.
|
|
258
|
+
*
|
|
259
|
+
* Used whenever the pivot's generation is invalidated: grid rebuild via
|
|
260
|
+
* initializeGrid, rejected snapshot reset, and any path that re-anchors the
|
|
261
|
+
* boundary outside the fill flow. The guard re-arms on the next real fill
|
|
262
|
+
* (or via the startup book seed), never against a boundary that no longer
|
|
263
|
+
* exists. Must not touch disk: the pivot is a live-grid invariant, and the
|
|
264
|
+
* persist pipeline clears the stored row on the next flush by passing null.
|
|
265
|
+
*
|
|
266
|
+
* @param {Object} manager - OrderManager instance
|
|
267
|
+
* @param {string} reason - Log/debug label
|
|
268
|
+
* @returns {boolean} True when an armed pivot was cleared
|
|
269
|
+
*/
|
|
270
|
+
export declare function resetLastFillPivot(manager: any, reason?: string): boolean;
|
|
271
|
+
/**
|
|
272
|
+
* Restore the persisted LAST-FILL-GUARD pivot into the manager.
|
|
273
|
+
*
|
|
274
|
+
* MUST run with the boundary (after loadGrid has applied the persisted
|
|
275
|
+
* genesis + re-typed the grid, before the first reconcile/broadcast) so the
|
|
276
|
+
* guard is never armed against a geometry the snapshot does not describe.
|
|
277
|
+
*
|
|
278
|
+
* Validation chain (fail → no-op, never arm on a poisoned value):
|
|
279
|
+
* 1. Shape: normalizeLastFillPivot re-validates the row (shared gate).
|
|
280
|
+
* 2. TTL: a pivot older than GRID_LIMITS.LAST_FILL_PIVOT_TTL_MS expires
|
|
281
|
+
* instead of vetoing legitimate placements after long downtime (the
|
|
282
|
+
* pivot is a "latest fill" fact, not a permanent ratchet). Expired rows
|
|
283
|
+
* are dead rows: the shared drop path (clearPersistedLastFillPivot
|
|
284
|
+
* under the bot's persistence lock, best-effort) erases them so a later
|
|
285
|
+
* validation failure cannot leave a half-invalid row armed.
|
|
286
|
+
* 3. Genesis binding: a row whose genesisHash differs from the manager's
|
|
287
|
+
* current genesis belongs to a dead generation — dropped through the
|
|
288
|
+
* same shared drop path (erased from disk so it cannot re-arm on the
|
|
289
|
+
* next restart).
|
|
290
|
+
* 4. On-grid check reuses the runtime's own ladder validator
|
|
291
|
+
* (resolveOnGridPivot in dexbot_cow_runtime, safe to import from here —
|
|
292
|
+
* utils/system never imports it otherwise, so no cycle). One
|
|
293
|
+
* implementation for both the live guard and the restore path, same
|
|
294
|
+
* increment fallback chain. On success the snapped ladder level is
|
|
295
|
+
* restored — the guard's own convention — never the raw persisted
|
|
296
|
+
* float, and the ORIGINAL fillsAt is preserved through
|
|
297
|
+
* setLastFillPivot's atMs so the TTL keeps meaning "age of the last
|
|
298
|
+
* fill", not "time since this restart".
|
|
299
|
+
*
|
|
300
|
+
* @param {Object} manager - OrderManager instance
|
|
301
|
+
* @param {Object|null} persisted - {price, type, fillsAt, genesisHash} from loadLastFillPivot
|
|
302
|
+
* @param {Object} [options]
|
|
303
|
+
* @param {number} [options.now] - Injectable clock (tests)
|
|
304
|
+
* @returns {boolean} True when the guard was re-armed from the snapshot
|
|
305
|
+
*/
|
|
306
|
+
export declare function restoreLastFillPivot(manager: any, persisted: any, options?: {
|
|
307
|
+
now?: number;
|
|
308
|
+
}): boolean;
|
|
212
309
|
/**
|
|
213
310
|
* Retry grid persistence if previous attempt failed.
|
|
214
311
|
* Clears persistence warning flag if successful.
|
|
@@ -50,7 +50,7 @@ const require = createRequire(import.meta.url);
|
|
|
50
50
|
import { path } from '../../path_api.js';
|
|
51
51
|
import { getStorage } from '../../storage/index.js';
|
|
52
52
|
const storage = getStorage();
|
|
53
|
-
import { API_LIMITS, ORDER_TYPES, COW_ACTIONS, FEE_PARAMETERS, BTS_PRECISION, PIPELINE_TIMING, NATIVE_CLIENT } from '../../constants.js';
|
|
53
|
+
import { API_LIMITS, ORDER_TYPES, COW_ACTIONS, FEE_PARAMETERS, BTS_PRECISION, PIPELINE_TIMING, NATIVE_CLIENT, GRID_LIMITS } from '../../constants.js';
|
|
54
54
|
import { PATHS } from '../../paths.js';
|
|
55
55
|
import { toFiniteNumber, isValidNumber } from '../format.js';
|
|
56
56
|
import * as MathUtils from './math.js';
|
|
@@ -61,6 +61,39 @@ import { getErrorMessage } from '../../utils/errors.js';
|
|
|
61
61
|
import { withTimeout } from './timeout.js';
|
|
62
62
|
const { ensureDir, readJSON } = storage;
|
|
63
63
|
const systemLogger = new Logger('System');
|
|
64
|
+
/**
|
|
65
|
+
* Lazily-bound ladder validator: resolveOnGridPivot from the COW runtime,
|
|
66
|
+
* imported on first use (not at module top level). utils/system.ts Must not
|
|
67
|
+
* statically import dexbot_cow_runtime (the runtime is a startup-graph
|
|
68
|
+
* heavyweight and the static edge would pull the whole COW engine into
|
|
69
|
+
* everything that touches persistence helpers); the runtime CAN statically
|
|
70
|
+
* import utils/system (it already does), so this edge stays one-directional
|
|
71
|
+
* and cycle-free in practice.
|
|
72
|
+
*
|
|
73
|
+
* Shared on purpose (centralization): one ladder-validation implementation
|
|
74
|
+
* — the increment fallback chain (manager.config → DEFAULT_CONFIG) and the
|
|
75
|
+
* one-increment drift refusal — serves both the live guard's per-probe
|
|
76
|
+
* validation and the persisted-pivot restore. The restorer must never
|
|
77
|
+
* accept a pivot value the runtime would itself refuse per probe.
|
|
78
|
+
*
|
|
79
|
+
* @param {Object} manager - OrderManager instance
|
|
80
|
+
* @param {number} price - Candidate pivot price
|
|
81
|
+
* @returns {Object|null} {price, slotIdx, snapped, nearestDrift} or null
|
|
82
|
+
*/
|
|
83
|
+
function cowRuntimeLadderValidator(manager, price) {
|
|
84
|
+
try {
|
|
85
|
+
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
86
|
+
const { resolveOnGridPivot } = require('../../dexbot_cow_runtime');
|
|
87
|
+
const validated = resolveOnGridPivot(manager, price);
|
|
88
|
+
if (!validated || validated.price == null || validated.idx == null)
|
|
89
|
+
return null;
|
|
90
|
+
return { price: validated.price, slotIdx: validated.idx, snapped: !!validated.snapped, nearestDrift: validated.nearestDrift };
|
|
91
|
+
}
|
|
92
|
+
catch (e) {
|
|
93
|
+
systemLogger.warn(`restoreLastFillPivot: ladder validator unavailable (${getErrorMessage(e)})`);
|
|
94
|
+
return null;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
64
97
|
function _debugLogAndNull(method, symA, symB) {
|
|
65
98
|
return (err) => {
|
|
66
99
|
// debug level: underlying derivePoolPrice/deriveMarketPrice already log at warn
|
|
@@ -856,12 +889,19 @@ export async function persistGridSnapshot(manager, accountOrders, snapshotOrders
|
|
|
856
889
|
.slice(-500)
|
|
857
890
|
.map((e) => ({ slotId: e.slotId, side: e.side, ts: Number(e.ts) }))
|
|
858
891
|
: undefined;
|
|
892
|
+
// LAST-FILL-GUARD pivot (restart resilience): only a fill-provenanced
|
|
893
|
+
// pivot is eligible — a book-seeded heuristic is never persisted as if
|
|
894
|
+
// it were market truth. Every other case (book seed, cold manager,
|
|
895
|
+
// legacy stub without the flags) passes null, which storeMasterGrid
|
|
896
|
+
// treats as an explicit clear; the row carries the CURRENT live
|
|
897
|
+
// genesis hash so a restore that sees a re-derived genesis refuses it.
|
|
898
|
+
const lastFillPivot = buildLastFillPivotPayload(manager);
|
|
859
899
|
await accountOrders.storeMasterGrid(orders, btsFeesOwed, manager.boundaryIdx, manager.assets || null, {
|
|
860
900
|
persistedAt: nowIso(),
|
|
861
901
|
config: debugConfig,
|
|
862
902
|
accountTotals,
|
|
863
903
|
btsBalance
|
|
864
|
-
}, fillKeys, genesis, gapEvacStreaks, pendingFillCrawls);
|
|
904
|
+
}, fillKeys, genesis, gapEvacStreaks, pendingFillCrawls, lastFillPivot);
|
|
865
905
|
return true;
|
|
866
906
|
}
|
|
867
907
|
catch (e) {
|
|
@@ -897,6 +937,238 @@ export function restoreGapEvacStreaks(manager, persisted) {
|
|
|
897
937
|
manager._gapEvacStreaks = streaks;
|
|
898
938
|
return streaks.size;
|
|
899
939
|
}
|
|
940
|
+
/**
|
|
941
|
+
* Build the persist payload for the LAST-FILL-GUARD pivot, or null when there
|
|
942
|
+
* is nothing durable to write.
|
|
943
|
+
*
|
|
944
|
+
* Source-of-truth contract (single ledger): the manager's in-memory pivot is
|
|
945
|
+
* authoritative during runtime; the disk row is a mirror that follows the
|
|
946
|
+
* grid snapshot, so it invalidates whenever the snapshot does:
|
|
947
|
+
* - Only a 'fill'-provenance pivot is eligible — a book-seeded pivot is a
|
|
948
|
+
* heuristic, not market truth, and must not fossilize into the snapshot.
|
|
949
|
+
* - The row carries the CURRENT live genesis hash, so a restore that sees a
|
|
950
|
+
* different (re-derived/regenerated) genesis refuses it (a pivot from an
|
|
951
|
+
* old generation is not valid after a grid regeneration).
|
|
952
|
+
* - A pivot without a live genesis is not persistable: null always clears,
|
|
953
|
+
* so an expired generation never leaves a stale row behind on disk.
|
|
954
|
+
*
|
|
955
|
+
* @param {Object} manager - OrderManager instance
|
|
956
|
+
* @returns {Object|null} {price, type, fillsAt, genesisHash} or null to clear
|
|
957
|
+
*/
|
|
958
|
+
function buildLastFillPivotPayload(manager) {
|
|
959
|
+
const price = Number(manager?._lastFilledPrice);
|
|
960
|
+
const type = manager?._lastFilledType;
|
|
961
|
+
if (manager?.lastFillPivotSource !== 'fill')
|
|
962
|
+
return null;
|
|
963
|
+
if (!Number.isFinite(price) || price <= 0)
|
|
964
|
+
return null;
|
|
965
|
+
if (type !== ORDER_TYPES.BUY && type !== ORDER_TYPES.SELL)
|
|
966
|
+
return null;
|
|
967
|
+
const fillsAt = Number(manager._lastFilledAt);
|
|
968
|
+
if (!Number.isFinite(fillsAt))
|
|
969
|
+
return null;
|
|
970
|
+
const genesisHash = manager?._genesis?.priceLevelsHash;
|
|
971
|
+
if (typeof genesisHash !== 'string' || genesisHash.length === 0)
|
|
972
|
+
return null;
|
|
973
|
+
return { price, type, fillsAt, genesisHash };
|
|
974
|
+
}
|
|
975
|
+
/**
|
|
976
|
+
* Normalize a persisted LAST-FILL-GUARD pivot row (shared by the
|
|
977
|
+
* AccountOrders sanitizer/loader and the payload builder's row contract).
|
|
978
|
+
*
|
|
979
|
+
* Returns the row normalized to {price:number, type, fillsAt:number,
|
|
980
|
+
* genesisHash} when every field passes its gate, null otherwise:
|
|
981
|
+
* - finite price > 0
|
|
982
|
+
* - type is ORDER_TYPES.BUY or ORDER_TYPES.SELL
|
|
983
|
+
* - finite fillsAt > 0
|
|
984
|
+
* - non-empty string genesisHash
|
|
985
|
+
*
|
|
986
|
+
* @param {any} row - Raw candidate row
|
|
987
|
+
* @returns {Object|null} Normalized row or null
|
|
988
|
+
*/
|
|
989
|
+
export function normalizeLastFillPivot(row) {
|
|
990
|
+
if (!row || typeof row !== 'object')
|
|
991
|
+
return null;
|
|
992
|
+
const price = Number(row.price);
|
|
993
|
+
const type = row.type;
|
|
994
|
+
const fillsAt = Number(row.fillsAt);
|
|
995
|
+
const genesisHash = row.genesisHash;
|
|
996
|
+
if (!Number.isFinite(price) || price <= 0)
|
|
997
|
+
return null;
|
|
998
|
+
if (type !== ORDER_TYPES.BUY && type !== ORDER_TYPES.SELL)
|
|
999
|
+
return null;
|
|
1000
|
+
if (!Number.isFinite(fillsAt) || fillsAt <= 0)
|
|
1001
|
+
return null;
|
|
1002
|
+
if (typeof genesisHash !== 'string' || genesisHash.length === 0)
|
|
1003
|
+
return null;
|
|
1004
|
+
return { price, type, fillsAt, genesisHash };
|
|
1005
|
+
}
|
|
1006
|
+
/**
|
|
1007
|
+
* Write the LAST-FILL-GUARD pivot scalar family in one place (free
|
|
1008
|
+
* implementation shared by the manager method, cow_runtime's queued-fill
|
|
1009
|
+
* refresh, and restoreLastFillPivot).
|
|
1010
|
+
*
|
|
1011
|
+
* Writes _lastFilledPrice, _lastFilledType, _lastFilledAt,
|
|
1012
|
+
* lastFillPivotSource and the per-side mirror (_lastFilledBuyPrice or
|
|
1013
|
+
* _lastFilledSellPrice). `atMs` lets restoreLastFillPivot preserve the
|
|
1014
|
+
* persisted fill timestamp (otherwise every restart would re-stamp "now"
|
|
1015
|
+
* and the TTL would degrade to "time since last restart"); ordinary fill
|
|
1016
|
+
* calls omit it and take Date.now().
|
|
1017
|
+
*
|
|
1018
|
+
* @param {Object} manager - OrderManager instance (or legacy stub)
|
|
1019
|
+
* @param {string} type - ORDER_TYPES.BUY or ORDER_TYPES.SELL
|
|
1020
|
+
* @param {number} price - Pivot price (finite, > 0)
|
|
1021
|
+
* @param {string} provenance - 'fill' (persist-eligible) or 'book' (seed heuristic)
|
|
1022
|
+
* @param {number} [atMs] - Fill timestamp to preserve (defaults to now)
|
|
1023
|
+
* @returns {boolean} True when the pivot was written
|
|
1024
|
+
*/
|
|
1025
|
+
export function setLastFillPivot(manager, type, price, provenance, atMs) {
|
|
1026
|
+
if (!manager)
|
|
1027
|
+
return false;
|
|
1028
|
+
if (type !== ORDER_TYPES.BUY && type !== ORDER_TYPES.SELL)
|
|
1029
|
+
return false;
|
|
1030
|
+
const p = Number(price);
|
|
1031
|
+
if (!Number.isFinite(p) || p <= 0)
|
|
1032
|
+
return false;
|
|
1033
|
+
const now = Number.isFinite(Number(atMs)) && Number(atMs) > 0 ? Number(atMs) : Date.now();
|
|
1034
|
+
manager._lastFilledPrice = p;
|
|
1035
|
+
manager._lastFilledType = type;
|
|
1036
|
+
manager._lastFilledAt = now;
|
|
1037
|
+
manager.lastFillPivotSource = provenance;
|
|
1038
|
+
if (type === ORDER_TYPES.BUY)
|
|
1039
|
+
manager._lastFilledBuyPrice = p;
|
|
1040
|
+
else
|
|
1041
|
+
manager._lastFilledSellPrice = p;
|
|
1042
|
+
return true;
|
|
1043
|
+
}
|
|
1044
|
+
/**
|
|
1045
|
+
* Clear the manager's LAST-FILL-GUARD pivot to cold state — the FULL scalar
|
|
1046
|
+
* family, per-side mirrors included. Clearing only the primary fields would
|
|
1047
|
+
* leave seedLastFilledPricesFromBook's early-return (both mirrors set)
|
|
1048
|
+
* silently suppressing the startup book seed after every grid rebuild — the
|
|
1049
|
+
* exact cold window the persist/restore feature exists to close.
|
|
1050
|
+
*
|
|
1051
|
+
* Used whenever the pivot's generation is invalidated: grid rebuild via
|
|
1052
|
+
* initializeGrid, rejected snapshot reset, and any path that re-anchors the
|
|
1053
|
+
* boundary outside the fill flow. The guard re-arms on the next real fill
|
|
1054
|
+
* (or via the startup book seed), never against a boundary that no longer
|
|
1055
|
+
* exists. Must not touch disk: the pivot is a live-grid invariant, and the
|
|
1056
|
+
* persist pipeline clears the stored row on the next flush by passing null.
|
|
1057
|
+
*
|
|
1058
|
+
* @param {Object} manager - OrderManager instance
|
|
1059
|
+
* @param {string} reason - Log/debug label
|
|
1060
|
+
* @returns {boolean} True when an armed pivot was cleared
|
|
1061
|
+
*/
|
|
1062
|
+
export function resetLastFillPivot(manager, reason = 'unspecified') {
|
|
1063
|
+
if (!manager)
|
|
1064
|
+
return false;
|
|
1065
|
+
const wasArmed = manager._lastFilledPrice != null && manager._lastFilledType != null;
|
|
1066
|
+
manager._lastFilledPrice = null;
|
|
1067
|
+
manager._lastFilledType = null;
|
|
1068
|
+
manager._lastFilledAt = 0;
|
|
1069
|
+
manager.lastFillPivotSource = null;
|
|
1070
|
+
manager._lastFilledBuyPrice = null;
|
|
1071
|
+
manager._lastFilledSellPrice = null;
|
|
1072
|
+
if (wasArmed) {
|
|
1073
|
+
try {
|
|
1074
|
+
manager.logger?.log?.(`[LAST-FILL-GUARD] Pivot cleared (${reason}); guard re-arms on the next fill`, 'info');
|
|
1075
|
+
}
|
|
1076
|
+
catch { /* logging is best-effort */ }
|
|
1077
|
+
}
|
|
1078
|
+
return wasArmed;
|
|
1079
|
+
}
|
|
1080
|
+
/**
|
|
1081
|
+
* Restore the persisted LAST-FILL-GUARD pivot into the manager.
|
|
1082
|
+
*
|
|
1083
|
+
* MUST run with the boundary (after loadGrid has applied the persisted
|
|
1084
|
+
* genesis + re-typed the grid, before the first reconcile/broadcast) so the
|
|
1085
|
+
* guard is never armed against a geometry the snapshot does not describe.
|
|
1086
|
+
*
|
|
1087
|
+
* Validation chain (fail → no-op, never arm on a poisoned value):
|
|
1088
|
+
* 1. Shape: normalizeLastFillPivot re-validates the row (shared gate).
|
|
1089
|
+
* 2. TTL: a pivot older than GRID_LIMITS.LAST_FILL_PIVOT_TTL_MS expires
|
|
1090
|
+
* instead of vetoing legitimate placements after long downtime (the
|
|
1091
|
+
* pivot is a "latest fill" fact, not a permanent ratchet). Expired rows
|
|
1092
|
+
* are dead rows: the shared drop path (clearPersistedLastFillPivot
|
|
1093
|
+
* under the bot's persistence lock, best-effort) erases them so a later
|
|
1094
|
+
* validation failure cannot leave a half-invalid row armed.
|
|
1095
|
+
* 3. Genesis binding: a row whose genesisHash differs from the manager's
|
|
1096
|
+
* current genesis belongs to a dead generation — dropped through the
|
|
1097
|
+
* same shared drop path (erased from disk so it cannot re-arm on the
|
|
1098
|
+
* next restart).
|
|
1099
|
+
* 4. On-grid check reuses the runtime's own ladder validator
|
|
1100
|
+
* (resolveOnGridPivot in dexbot_cow_runtime, safe to import from here —
|
|
1101
|
+
* utils/system never imports it otherwise, so no cycle). One
|
|
1102
|
+
* implementation for both the live guard and the restore path, same
|
|
1103
|
+
* increment fallback chain. On success the snapped ladder level is
|
|
1104
|
+
* restored — the guard's own convention — never the raw persisted
|
|
1105
|
+
* float, and the ORIGINAL fillsAt is preserved through
|
|
1106
|
+
* setLastFillPivot's atMs so the TTL keeps meaning "age of the last
|
|
1107
|
+
* fill", not "time since this restart".
|
|
1108
|
+
*
|
|
1109
|
+
* @param {Object} manager - OrderManager instance
|
|
1110
|
+
* @param {Object|null} persisted - {price, type, fillsAt, genesisHash} from loadLastFillPivot
|
|
1111
|
+
* @param {Object} [options]
|
|
1112
|
+
* @param {number} [options.now] - Injectable clock (tests)
|
|
1113
|
+
* @returns {boolean} True when the guard was re-armed from the snapshot
|
|
1114
|
+
*/
|
|
1115
|
+
export function restoreLastFillPivot(manager, persisted, options = {}) {
|
|
1116
|
+
if (!manager || !persisted || typeof persisted !== 'object')
|
|
1117
|
+
return false;
|
|
1118
|
+
const row = normalizeLastFillPivot(persisted);
|
|
1119
|
+
if (!row)
|
|
1120
|
+
return false;
|
|
1121
|
+
// Shared drop path for every "this row is dead" verdict: erase the
|
|
1122
|
+
// persisted row best-effort so a rejected value can never re-arm the
|
|
1123
|
+
// same rejection on the next restart (storeMasterGrid deliberately
|
|
1124
|
+
// keeps untouched rows for legacy `undefined` callers, so without the
|
|
1125
|
+
// erase the verdict has no TTL guarantee across restarts either).
|
|
1126
|
+
const dropPersistedRow = () => {
|
|
1127
|
+
try {
|
|
1128
|
+
const acct = manager.accountOrders;
|
|
1129
|
+
if (acct && typeof acct.clearPersistedLastFillPivot === 'function') {
|
|
1130
|
+
void acct.clearPersistedLastFillPivot();
|
|
1131
|
+
}
|
|
1132
|
+
}
|
|
1133
|
+
catch { /* best-effort */ }
|
|
1134
|
+
};
|
|
1135
|
+
// TTL first: an expired pivot is dropped, not re-armed.
|
|
1136
|
+
const now = Number.isFinite(options?.now) ? Number(options.now) : Date.now();
|
|
1137
|
+
if (now - row.fillsAt > Number(GRID_LIMITS.LAST_FILL_PIVOT_TTL_MS)) {
|
|
1138
|
+
manager.logger?.log?.(`[LAST-FILL-GUARD] Persisted pivot expired (age ${Math.round((now - row.fillsAt) / 1000)}s > TTL ${Math.round(Number(GRID_LIMITS.LAST_FILL_PIVOT_TTL_MS) / 1000)}s) — guard re-arms on the next fill`, 'info');
|
|
1139
|
+
dropPersistedRow();
|
|
1140
|
+
return false;
|
|
1141
|
+
}
|
|
1142
|
+
// Genesis binding: a persisted pivot from another genesis is not valid
|
|
1143
|
+
// after a regeneration/re-derive. Drop the row so it cannot resurrect,
|
|
1144
|
+
// and let the startup book seed take over.
|
|
1145
|
+
const liveHash = manager._genesis?.priceLevelsHash;
|
|
1146
|
+
if (typeof liveHash !== 'string' || liveHash.length === 0 || liveHash !== row.genesisHash) {
|
|
1147
|
+
manager.logger?.log?.(`[LAST-FILL-GUARD] Persisted pivot genesis mismatch (stored ${row.genesisHash} vs live ${liveHash ?? 'none'}) — dropping (grid regenerated); book seed will arm instead`, 'warn');
|
|
1148
|
+
dropPersistedRow();
|
|
1149
|
+
return false;
|
|
1150
|
+
}
|
|
1151
|
+
// On-grid validation through the runtime's own ladder validator — the
|
|
1152
|
+
// exact same one-increment drift rule, snap, and off-grid refusal the
|
|
1153
|
+
// live guard applies per probe. Import is safe: utils/system.ts does not
|
|
1154
|
+
// otherwise import the cow runtime, and the runtime's own module top
|
|
1155
|
+
// level already imports utils/system (sleep, then the pivot helpers),
|
|
1156
|
+
// so this adds no new edge to the graph.
|
|
1157
|
+
try {
|
|
1158
|
+
const validated = cowRuntimeLadderValidator(manager, row.price);
|
|
1159
|
+
if (!validated)
|
|
1160
|
+
return false;
|
|
1161
|
+
// Arm through the shared writer, preserving the persisted timestamp.
|
|
1162
|
+
setLastFillPivot(manager, row.type, validated.price, 'fill', row.fillsAt);
|
|
1163
|
+
manager.logger?.log?.(`[LAST-FILL-GUARD] Restored persisted pivot ${validated.price}(${row.type})` +
|
|
1164
|
+
`${validated.slotIdx != null ? ` slot=${validated.slotIdx}` : ''}` +
|
|
1165
|
+
`${validated.snapped ? ' (snapped)' : ''} age=${Math.round((now - row.fillsAt) / 1000)}s from snapshot`, 'info');
|
|
1166
|
+
return true;
|
|
1167
|
+
}
|
|
1168
|
+
catch {
|
|
1169
|
+
return false;
|
|
1170
|
+
}
|
|
1171
|
+
}
|
|
900
1172
|
/**
|
|
901
1173
|
* Retry grid persistence if previous attempt failed.
|
|
902
1174
|
* Clears persistence warning flag if successful.
|
|
@@ -1151,7 +1423,8 @@ export async function applyGridDivergenceCorrections(manager, accountOrders, _bo
|
|
|
1151
1423
|
edgeAnchors: {
|
|
1152
1424
|
buy: OrderUtils.resolveLiveReserveEdgeAnchorPrice(manager, 'buy'),
|
|
1153
1425
|
sell: OrderUtils.resolveLiveReserveEdgeAnchorPrice(manager, 'sell')
|
|
1154
|
-
}
|
|
1426
|
+
},
|
|
1427
|
+
manager
|
|
1155
1428
|
});
|
|
1156
1429
|
// Build COW result with all actions
|
|
1157
1430
|
if (actions.length > 0) {
|
|
@@ -1644,6 +1917,12 @@ export async function applyPersistedPendingCrawls(bot, options = {}) {
|
|
|
1644
1917
|
}
|
|
1645
1918
|
catch { /* best-effort */ }
|
|
1646
1919
|
}
|
|
1920
|
+
else if (result?.reason === 'restore-failed') {
|
|
1921
|
+
// consumePendingFillCrawls deliberately does NOT clear the ledger
|
|
1922
|
+
// on a restore failure, so these records are retained and retried —
|
|
1923
|
+
// they were not dropped.
|
|
1924
|
+
log(`[BOUNDARY] Pending fill crawls retained (${result.reason}); restored boundary kept`, 'warn');
|
|
1925
|
+
}
|
|
1647
1926
|
else if (result?.reason && result.reason !== 'nothing-owed'
|
|
1648
1927
|
&& result.reason !== 'no-op' && result.reason !== 'null-boundary') {
|
|
1649
1928
|
log(`[BOUNDARY] Pending fill crawls dropped (${result.reason})`, 'warn');
|
package/dist/modules/paths.d.ts
CHANGED
|
@@ -90,6 +90,12 @@ declare function resolveAnalysisDirs(profilesDir?: string, projectRoot?: string)
|
|
|
90
90
|
* (scrubbed in tests), so it is testable with fake fixtures.
|
|
91
91
|
*/
|
|
92
92
|
declare function computeRelocationNotices(profilesDir: string, projectRoot: string): string[];
|
|
93
|
+
/**
|
|
94
|
+
* Print notices from the launcher after it knows whether onboarding is
|
|
95
|
+
* needed. Callers that already computed the launcher's effective layout may
|
|
96
|
+
* pass explicit paths (used by tests) instead of the module-level defaults.
|
|
97
|
+
*/
|
|
98
|
+
declare function printRelocationNotices(profilesDir?: string, projectRoot?: string, warn?: (message: string) => void): void;
|
|
93
99
|
declare const PATHS: {
|
|
94
100
|
PROJECT_ROOT: string;
|
|
95
101
|
PROFILES_DIR: string;
|
|
@@ -103,6 +109,7 @@ declare const PATHS: {
|
|
|
103
109
|
FUND_REGISTRY_JSON: string;
|
|
104
110
|
NODE_BLACKLIST_JSON: string;
|
|
105
111
|
NODE_HEALTH_CACHE_JSON: string;
|
|
112
|
+
VERSION_CHECK_JSON: string;
|
|
106
113
|
MARKET_ADAPTER_WHITELIST_JSON: () => string;
|
|
107
114
|
ECOSYSTEM_CONFIG_JS: string;
|
|
108
115
|
SUPERVISOR_SOCK: string;
|
|
@@ -146,5 +153,5 @@ declare const PATHS: {
|
|
|
146
153
|
declare function getNodeBlacklistFile(stateDir?: string): string;
|
|
147
154
|
declare function getNodeHealthCacheFile(stateDir?: string): string;
|
|
148
155
|
declare function getRecalculateTriggerFile(botKey: string): string;
|
|
149
|
-
export { PATHS, HOME_PROFILES_DIR, HOME_CONFIG_DIR, getHomeConfigDir, getHomeProfilesDir, resolveProfilesDir, resolveMarketAdapterDirs, resolveClawDirs, resolveAnalysisDirs, isGlobalNpmPackageDir, getNodeBlacklistFile, getNodeHealthCacheFile, getRecalculateTriggerFile, computeRelocationNotices };
|
|
156
|
+
export { PATHS, HOME_PROFILES_DIR, HOME_CONFIG_DIR, getHomeConfigDir, getHomeProfilesDir, resolveProfilesDir, resolveMarketAdapterDirs, resolveClawDirs, resolveAnalysisDirs, isGlobalNpmPackageDir, getNodeBlacklistFile, getNodeHealthCacheFile, getRecalculateTriggerFile, computeRelocationNotices, printRelocationNotices };
|
|
150
157
|
//# sourceMappingURL=paths.d.ts.map
|
package/dist/modules/paths.js
CHANGED
|
@@ -286,8 +286,15 @@ function computeRelocationNotices(profilesDir, projectRoot) {
|
|
|
286
286
|
}
|
|
287
287
|
return notices;
|
|
288
288
|
}
|
|
289
|
-
|
|
290
|
-
|
|
289
|
+
/**
|
|
290
|
+
* Print notices from the launcher after it knows whether onboarding is
|
|
291
|
+
* needed. Callers that already computed the launcher's effective layout may
|
|
292
|
+
* pass explicit paths (used by tests) instead of the module-level defaults.
|
|
293
|
+
*/
|
|
294
|
+
function printRelocationNotices(profilesDir = PROFILES_DIR, projectRoot = PROJECT_ROOT, warn = (message) => console.warn(message)) {
|
|
295
|
+
for (const notice of computeRelocationNotices(profilesDir, projectRoot)) {
|
|
296
|
+
warn(notice);
|
|
297
|
+
}
|
|
291
298
|
}
|
|
292
299
|
const PATHS = {
|
|
293
300
|
PROJECT_ROOT,
|
|
@@ -302,6 +309,7 @@ const PATHS = {
|
|
|
302
309
|
FUND_REGISTRY_JSON: path.join(PROFILES_DIR, 'fund_registry.json'),
|
|
303
310
|
NODE_BLACKLIST_JSON: path.join(PROFILES_DIR, 'node_blacklist.json'),
|
|
304
311
|
NODE_HEALTH_CACHE_JSON: path.join(PROFILES_DIR, 'node_health_cache.json'),
|
|
312
|
+
VERSION_CHECK_JSON: path.join(PROFILES_DIR, 'version_check.json'),
|
|
305
313
|
MARKET_ADAPTER_WHITELIST_JSON: () => Config.DEXBOT_TEST_MARKET_ADAPTER_WHITELIST_FILE || path.join(PROFILES_DIR, 'market_adapter_whitelist.json'),
|
|
306
314
|
ECOSYSTEM_CONFIG_JS: path.join(PROFILES_DIR, 'ecosystem.config.cjs'),
|
|
307
315
|
SUPERVISOR_SOCK: path.join(PROFILES_DIR, 'supervisor.sock'),
|
|
@@ -333,7 +341,7 @@ function getNodeHealthCacheFile(stateDir) {
|
|
|
333
341
|
function getRecalculateTriggerFile(botKey) {
|
|
334
342
|
return path.join(PATHS.PROFILES_DIR, `recalculate.${botKey}.trigger`);
|
|
335
343
|
}
|
|
336
|
-
export { PATHS, HOME_PROFILES_DIR, HOME_CONFIG_DIR, getHomeConfigDir, getHomeProfilesDir, resolveProfilesDir, resolveMarketAdapterDirs, resolveClawDirs, resolveAnalysisDirs, isGlobalNpmPackageDir, getNodeBlacklistFile, getNodeHealthCacheFile, getRecalculateTriggerFile, computeRelocationNotices };
|
|
344
|
+
export { PATHS, HOME_PROFILES_DIR, HOME_CONFIG_DIR, getHomeConfigDir, getHomeProfilesDir, resolveProfilesDir, resolveMarketAdapterDirs, resolveClawDirs, resolveAnalysisDirs, isGlobalNpmPackageDir, getNodeBlacklistFile, getNodeHealthCacheFile, getRecalculateTriggerFile, computeRelocationNotices, printRelocationNotices };
|
|
337
345
|
// Live getters for CJS require() interop (ESM cache not invalidated via require.cache)
|
|
338
346
|
try {
|
|
339
347
|
// @ts-ignore - patch CJS wrapper if present
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* modules/utils/text_width.ts - Terminal display-width helpers.
|
|
3
|
+
*
|
|
4
|
+
* `String.prototype.length` and `padEnd` count UTF-16 code units, so CJK
|
|
5
|
+
* glyphs (width 2) and combining marks (width 0) break column alignment in
|
|
6
|
+
* console tables. These helpers count terminal cells instead and pad by
|
|
7
|
+
* display width. Pure string logic — browser-safe, no Node dependencies.
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* Width of a single Unicode code point in terminal cells.
|
|
11
|
+
* 0 for control chars / combining marks, 2 for East-Asian wide and emoji,
|
|
12
|
+
* otherwise 1.
|
|
13
|
+
*/
|
|
14
|
+
export declare function codePointWidth(codePoint: number): number;
|
|
15
|
+
/** Grapheme-aware display width of a string. */
|
|
16
|
+
export declare function displayWidth(text: string): number;
|
|
17
|
+
/** Pad `text` with spaces on the right to reach `width` terminal cells. */
|
|
18
|
+
export declare function padDisplay(text: string, width: number): string;
|
|
19
|
+
//# sourceMappingURL=text_width.d.ts.map
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* modules/utils/text_width.ts - Terminal display-width helpers.
|
|
3
|
+
*
|
|
4
|
+
* `String.prototype.length` and `padEnd` count UTF-16 code units, so CJK
|
|
5
|
+
* glyphs (width 2) and combining marks (width 0) break column alignment in
|
|
6
|
+
* console tables. These helpers count terminal cells instead and pad by
|
|
7
|
+
* display width. Pure string logic — browser-safe, no Node dependencies.
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* Width of a single Unicode code point in terminal cells.
|
|
11
|
+
* 0 for control chars / combining marks, 2 for East-Asian wide and emoji,
|
|
12
|
+
* otherwise 1.
|
|
13
|
+
*/
|
|
14
|
+
export function codePointWidth(codePoint) {
|
|
15
|
+
if (codePoint === 0)
|
|
16
|
+
return 0;
|
|
17
|
+
if (codePoint < 0x20 || (codePoint >= 0x7f && codePoint < 0xa0))
|
|
18
|
+
return 0;
|
|
19
|
+
if (isCombining(codePoint))
|
|
20
|
+
return 0;
|
|
21
|
+
return isFullWidth(codePoint) ? 2 : 1;
|
|
22
|
+
}
|
|
23
|
+
/** Grapheme-aware display width of a string. */
|
|
24
|
+
export function displayWidth(text) {
|
|
25
|
+
if (!text)
|
|
26
|
+
return 0;
|
|
27
|
+
let width = 0;
|
|
28
|
+
for (const grapheme of segmentGraphemes(text)) {
|
|
29
|
+
width += graphemeWidth(grapheme);
|
|
30
|
+
}
|
|
31
|
+
return width;
|
|
32
|
+
}
|
|
33
|
+
function graphemeWidth(grapheme) {
|
|
34
|
+
const codePoints = [];
|
|
35
|
+
for (const char of grapheme)
|
|
36
|
+
codePoints.push(char.codePointAt(0));
|
|
37
|
+
// A flag emoji is a pair of regional indicators and renders as one
|
|
38
|
+
// two-cell glyph even though each indicator is one cell on its own.
|
|
39
|
+
if (codePoints.length === 2 && codePoints.every(isRegionalIndicator))
|
|
40
|
+
return 2;
|
|
41
|
+
let width = 0;
|
|
42
|
+
for (const codePoint of codePoints)
|
|
43
|
+
width = Math.max(width, codePointWidth(codePoint));
|
|
44
|
+
return width;
|
|
45
|
+
}
|
|
46
|
+
/** Pad `text` with spaces on the right to reach `width` terminal cells. */
|
|
47
|
+
export function padDisplay(text, width) {
|
|
48
|
+
return text + ' '.repeat(Math.max(0, width - displayWidth(text)));
|
|
49
|
+
}
|
|
50
|
+
function isCombining(codePoint) {
|
|
51
|
+
return ((codePoint >= 0x0300 && codePoint <= 0x036f) || // combining diacritics
|
|
52
|
+
(codePoint >= 0x1ab0 && codePoint <= 0x1aff) ||
|
|
53
|
+
(codePoint >= 0x1dc0 && codePoint <= 0x1dff) ||
|
|
54
|
+
(codePoint >= 0x20d0 && codePoint <= 0x20ff) ||
|
|
55
|
+
(codePoint >= 0xfe20 && codePoint <= 0xfe2f) ||
|
|
56
|
+
(codePoint >= 0xfe00 && codePoint <= 0xfe0f) // variation selectors
|
|
57
|
+
);
|
|
58
|
+
}
|
|
59
|
+
function isRegionalIndicator(codePoint) {
|
|
60
|
+
return codePoint >= 0x1f1e6 && codePoint <= 0x1f1ff;
|
|
61
|
+
}
|
|
62
|
+
const WIDE_RANGES = [
|
|
63
|
+
[0x1100, 0x115f], // Hangul Jamo
|
|
64
|
+
[0x2e80, 0x303e], // CJK radicals, Kangxi
|
|
65
|
+
[0x3041, 0x33ff], // Hiragana/Katakana, CJK symbols
|
|
66
|
+
[0x3400, 0x4dbf], // CJK Ext A
|
|
67
|
+
[0x4e00, 0x9fff], // CJK Unified
|
|
68
|
+
[0xa000, 0xa4cf], // Yi
|
|
69
|
+
[0xac00, 0xd7a3], // Hangul syllables
|
|
70
|
+
[0xf900, 0xfaff], // CJK compatibility
|
|
71
|
+
[0xfe10, 0xfe19],
|
|
72
|
+
[0xfe30, 0xfe6f],
|
|
73
|
+
[0xff00, 0xff60], // fullwidth forms
|
|
74
|
+
[0xffe0, 0xffe6],
|
|
75
|
+
[0x1f300, 0x1faff], // emoji & pictographs
|
|
76
|
+
[0x20000, 0x3fffd], // CJK Ext B+
|
|
77
|
+
];
|
|
78
|
+
function isFullWidth(codePoint) {
|
|
79
|
+
for (const [start, end] of WIDE_RANGES) {
|
|
80
|
+
if (codePoint >= start && codePoint <= end)
|
|
81
|
+
return true;
|
|
82
|
+
}
|
|
83
|
+
return false;
|
|
84
|
+
}
|
|
85
|
+
const segmenter = typeof Intl !== 'undefined' && typeof Intl.Segmenter === 'function'
|
|
86
|
+
? new Intl.Segmenter(undefined, { granularity: 'grapheme' })
|
|
87
|
+
: null;
|
|
88
|
+
function* segmentGraphemes(text) {
|
|
89
|
+
if (!segmenter) {
|
|
90
|
+
yield* text;
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
for (const { segment } of segmenter.segment(text)) {
|
|
94
|
+
yield segment;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
//# sourceMappingURL=text_width.js.map
|