dexbot 1.6.11 → 1.6.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +35 -4
- package/README.md +2 -1
- package/analysis/README.md +2 -0
- package/analysis/tradingview/README.md +1 -1
- package/analysis/trend_detection/DYNAMIC_WEIGHT_RESEARCH.md +3 -3
- package/claw/docs/DEXBOT2_TUNING_CHEAT_SHEET.md +4 -3
- package/claw/modules/chain_broadcast.ts +7 -1
- package/claw/modules/claw_launcher.ts +1 -1
- package/claw/modules/launcher_mode_detector.ts +9 -2
- 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/account_resolver.d.ts +1 -1
- package/dist/analysis/account_resolver.js +2 -1
- package/dist/analysis/ama_fitting/analyze_ama_price_changes.js +3 -4
- package/dist/analysis/ama_fitting/analyze_lambda_vs_slow.js +2 -7
- package/dist/analysis/ama_fitting/calibrate_convergence_er.js +0 -1
- package/dist/analysis/ama_fitting/fetch_lp_candles.js +4 -4
- package/dist/analysis/ama_fitting/generate_unified_comparison_chart.d.ts +20 -4
- package/dist/analysis/ama_fitting/generate_unified_comparison_chart.js +9 -6
- package/dist/analysis/ama_fitting/optimizer_high_resolution.js +16 -12
- package/dist/analysis/analyze_args.d.ts +31 -0
- package/dist/analysis/analyze_args.js +41 -0
- package/dist/analysis/analyze_dynamic_weight.js +7 -17
- package/dist/analysis/analyze_kalman.js +7 -17
- package/dist/analysis/analyze_regime.js +7 -17
- package/dist/analysis/analyze_regime_windows.js +8 -18
- package/dist/analysis/analyze_risk_profile.js +8 -18
- package/dist/analysis/analyze_trade_heatmap.js +7 -17
- package/dist/analysis/analyze_volatility.js +7 -17
- package/dist/analysis/bot_fitting/backtest_ama_sweep.d.ts +220 -12
- package/dist/analysis/bot_fitting/backtest_ama_sweep.js +6 -5
- package/dist/analysis/bot_fitting/backtest_bot_fitting.d.ts +34 -4
- package/dist/analysis/bot_fitting/backtest_bot_fitting.js +11 -63
- package/dist/analysis/bot_fitting/shared_utils.d.ts +7 -7
- package/dist/analysis/bot_fitting/shared_utils.js +2 -2
- package/dist/analysis/bot_key_utils.d.ts +18 -10
- package/dist/analysis/bot_key_utils.js +7 -4
- package/dist/analysis/bot_usage/discover_bot_accounts.js +44 -47
- package/dist/analysis/bot_usage/kibana_bot_queries.d.ts +1 -21
- package/dist/analysis/chain_pool.d.ts +3 -1
- package/dist/analysis/chart_ui.d.ts +5 -2
- package/dist/analysis/chart_ui.js +6 -3
- package/dist/analysis/chart_utils.d.ts +5 -5
- package/dist/analysis/chart_utils.js +9 -0
- package/dist/analysis/fills_cache.d.ts +1 -1
- package/dist/analysis/fills_source.d.ts +2 -2
- package/dist/analysis/fills_source.js +14 -12
- package/dist/analysis/grid_correction_check.d.ts +1 -1
- package/dist/analysis/grid_correction_check.js +12 -11
- package/dist/analysis/math_utils.d.ts +7 -6
- package/dist/analysis/math_utils.js +5 -8
- package/dist/analysis/pnl_report.js +29 -29
- package/dist/analysis/price_sources.d.ts +8 -8
- package/dist/analysis/price_sources.js +5 -4
- package/dist/analysis/resolve_bot_accounts.js +2 -2
- package/dist/analysis/resolve_source.d.ts +1 -1
- package/dist/analysis/trade_profitability.d.ts +23 -2
- package/dist/analysis/trade_profitability.js +50 -50
- package/dist/analysis/tradingview/analyze_tradingview.d.ts +17 -6
- package/dist/analysis/tradingview/analyze_tradingview.js +6 -5
- package/dist/analysis/tradingview/grid_reset_config.d.ts +41 -32
- package/dist/analysis/tradingview/grid_reset_config.js +23 -11
- package/dist/analysis/tradingview/grid_reset_sim.d.ts +75 -9
- package/dist/analysis/tradingview/grid_reset_sim.js +4 -3
- package/dist/analysis/tradingview/tradingview_uplot_chart_generator.d.ts +69 -4
- package/dist/analysis/tradingview/tradingview_uplot_chart_generator.js +18 -19
- package/dist/analysis/trend_detection/backtest_ama_slope_huber.d.ts +1 -1
- package/dist/analysis/trend_detection/backtest_ama_slope_huber.js +5 -5
- package/dist/analysis/trend_detection/dynamic_weight_chart_generator.d.ts +63 -1
- package/dist/analysis/trend_detection/dynamic_weight_chart_generator.js +5 -4
- package/dist/analysis/trend_detection/huber_scale_variants.d.ts +9 -3
- package/dist/analysis/trend_detection/huber_scale_variants.js +4 -4
- package/dist/analysis/trend_detection/kalman_chart_generator.d.ts +30 -1
- package/dist/analysis/trend_detection/kalman_chart_generator.js +3 -3
- package/dist/analysis/trend_detection/regime_chart_generator.d.ts +31 -1
- package/dist/analysis/trend_detection/regime_chart_generator.js +2 -2
- package/dist/analysis/trend_detection/volatility_chart_generator.d.ts +33 -1
- package/dist/credential-daemon.js +34 -20
- package/dist/dexbot.js +11 -11
- package/dist/market_adapter/candle_utils.d.ts +22 -18
- package/dist/market_adapter/candle_utils.js +24 -20
- package/dist/market_adapter/core/asymmetric_bounds.d.ts +13 -4
- package/dist/market_adapter/core/config_normalizers.d.ts +3 -3
- package/dist/market_adapter/core/kibana_candles.d.ts +53 -18
- package/dist/market_adapter/core/kibana_candles.js +9 -7
- package/dist/market_adapter/core/kibana_client.d.ts +9 -1
- package/dist/market_adapter/core/kibana_client.js +8 -7
- package/dist/market_adapter/core/kibana_market_candles.d.ts +3 -2
- package/dist/market_adapter/core/market_adapter_service.d.ts +284 -117
- package/dist/market_adapter/core/market_adapter_service.js +137 -113
- package/dist/market_adapter/core/strategies/ama.d.ts +10 -2
- package/dist/market_adapter/core/strategies/ama.js +2 -4
- package/dist/market_adapter/core/strategies/ama_slope_model.d.ts +14 -1
- package/dist/market_adapter/core/strategies/ama_slope_model.js +12 -34
- package/dist/market_adapter/core/strategies/atr/calculator.d.ts +7 -2
- package/dist/market_adapter/core/strategies/atr/calculator.js +2 -34
- package/dist/market_adapter/core/strategies/collateral_manager.d.ts +7 -1
- package/dist/market_adapter/core/strategies/collateral_manager.js +0 -22
- package/dist/market_adapter/core/strategies/dynamic_weight_series.d.ts +34 -6
- package/dist/market_adapter/core/strategies/dynamic_weight_series.js +7 -7
- package/dist/market_adapter/core/strategies/regime_gate.d.ts +24 -15
- package/dist/market_adapter/core/strategies/regime_gate.js +4 -31
- package/dist/market_adapter/core/strategies/regime_interp.d.ts +7 -1
- package/dist/market_adapter/core/strategies/regime_interp.js +14 -22
- package/dist/market_adapter/core/strategies/volatility_shift.d.ts +11 -1
- package/dist/market_adapter/core/strategies/volatility_shift.js +0 -13
- package/dist/market_adapter/inputs/cex_candle_parsing.d.ts +29 -0
- package/dist/market_adapter/inputs/cex_candle_parsing.js +52 -0
- package/dist/market_adapter/inputs/fetch_book_data.d.ts +20 -4
- package/dist/market_adapter/inputs/fetch_book_data.js +3 -1
- package/dist/market_adapter/inputs/fetch_cex_synthetic_data.js +96 -224
- package/dist/market_adapter/inputs/fetch_lp_data.d.ts +42 -7
- package/dist/market_adapter/inputs/fetch_lp_data.js +22 -15
- package/dist/market_adapter/inputs/kibana_feed_source.d.ts +74 -15
- package/dist/market_adapter/inputs/kibana_feed_source.js +29 -22
- package/dist/market_adapter/inputs/kibana_source.d.ts +25 -3
- package/dist/market_adapter/inputs/kibana_source.js +2 -2
- package/dist/market_adapter/inputs/window_cache.d.ts +99 -94
- package/dist/market_adapter/inputs/window_cache.js +8 -8
- package/dist/market_adapter/interval_utils.d.ts +4 -4
- package/dist/market_adapter/log_format.d.ts +6 -6
- package/dist/market_adapter/log_format.js +28 -21
- package/dist/market_adapter/lp_chart_core.d.ts +22 -1
- package/dist/market_adapter/lp_chart_core.js +26 -192
- package/dist/market_adapter/lp_chart_runner.d.ts +7 -7
- package/dist/market_adapter/lp_chart_strategy_loader.d.ts +41 -6
- package/dist/market_adapter/lp_chart_strategy_loader.js +8 -7
- package/dist/market_adapter/market_adapter.d.ts +94 -32
- package/dist/market_adapter/market_adapter.js +67 -48
- package/dist/market_adapter/utils/adapter_client.d.ts +3 -3
- package/dist/market_adapter/utils/adapter_client.js +2 -2
- package/dist/market_adapter/utils/atomic_write.d.ts +8 -1
- package/dist/market_adapter/utils/chain.d.ts +50 -41
- package/dist/market_adapter/utils/chain.js +40 -46
- package/dist/market_adapter/utils/data_discovery.d.ts +4 -1
- package/dist/market_adapter/utils/dynamic_grid_snapshot.d.ts +12 -3
- package/dist/market_adapter/utils/file_json_cache.d.ts +2 -2
- package/dist/market_adapter/utils/file_lock.d.ts +28 -14
- package/dist/market_adapter/utils/file_lock.js +36 -32
- package/dist/market_adapter/utils/native_history.d.ts +9 -2
- package/dist/market_adapter/utils/native_history.js +35 -28
- package/dist/modules/account_bots.d.ts +577 -21
- package/dist/modules/account_bots.js +182 -158
- package/dist/modules/account_orders.d.ts +66 -30
- package/dist/modules/account_orders.js +22 -20
- package/dist/modules/authority_resolver.d.ts +12 -2
- package/dist/modules/authority_resolver.js +15 -8
- package/dist/modules/bitshares-native/chain_client.d.ts +38 -3
- package/dist/modules/bitshares-native/chain_client.js +45 -46
- package/dist/modules/bitshares-native/crypto/ecc.browser.js +11 -171
- package/dist/modules/bitshares-native/crypto/ecc.js +13 -176
- package/dist/modules/bitshares-native/crypto/ecc_core.d.ts +33 -0
- package/dist/modules/bitshares-native/crypto/ecc_core.js +213 -0
- package/dist/modules/bitshares-native/crypto/ecc_selector.d.ts +2 -1
- package/dist/modules/bitshares-native/crypto/ecc_selector.js +1 -13
- package/dist/modules/bitshares-native/index.d.ts +1 -1
- package/dist/modules/bitshares-native/lru_cache.d.ts +7 -7
- package/dist/modules/bitshares-native/resolvers.d.ts +18 -6
- package/dist/modules/bitshares-native/serial/lazy_buffer.d.ts +4 -0
- package/dist/modules/bitshares-native/serial/lazy_buffer.js +21 -0
- package/dist/modules/bitshares-native/serial/operations.d.ts +1 -1
- package/dist/modules/bitshares-native/serial/serializer.d.ts +16 -12
- package/dist/modules/bitshares-native/serial/serializer.js +7 -13
- package/dist/modules/bitshares-native/serial/types.d.ts +25 -16
- package/dist/modules/bitshares-native/serial/types.js +55 -62
- package/dist/modules/bitshares-native/signing_client.d.ts +32 -2
- package/dist/modules/bitshares-native/signing_client.js +19 -14
- package/dist/modules/bitshares-native/subscriptions.d.ts +81 -1
- package/dist/modules/bitshares-native/subscriptions.js +12 -12
- package/dist/modules/bitshares-native/transport.d.ts +5 -4
- package/dist/modules/bitshares-native/transport.js +5 -4
- package/dist/modules/bitshares-native/tx/builder.d.ts +40 -5
- package/dist/modules/bitshares-native/tx/builder.js +4 -3
- package/dist/modules/bitshares-native/tx/tx_cache.d.ts +4 -4
- package/dist/modules/bitshares_client.d.ts +45 -13
- package/dist/modules/bitshares_client.js +28 -19
- package/dist/modules/bot_defaults.d.ts +6 -15
- package/dist/modules/bot_defaults.js +1 -5
- package/dist/modules/bot_settings.d.ts +44 -10
- package/dist/modules/bot_settings.js +11 -8
- package/dist/modules/bots_file_lock.d.ts +6 -6
- package/dist/modules/bots_file_lock.js +16 -12
- package/dist/modules/broadcast_failure.d.ts +2 -2
- package/dist/modules/broadcast_failure.js +5 -4
- package/dist/modules/chain_keys.d.ts +42 -40
- package/dist/modules/chain_keys.js +53 -45
- package/dist/modules/chain_orders.d.ts +93 -59
- package/dist/modules/chain_orders.js +31 -23
- package/dist/modules/constants.d.ts +527 -31
- package/dist/modules/constants.js +15 -47
- package/dist/modules/cr_planner.d.ts +40 -2
- package/dist/modules/credential_policy.d.ts +68 -8
- package/dist/modules/credential_policy.js +37 -31
- package/dist/modules/credential_session_cache.d.ts +2 -2
- package/dist/modules/credit_pricing.d.ts +42 -6
- package/dist/modules/credit_pricing.js +44 -30
- package/dist/modules/credit_runtime.d.ts +276 -118
- package/dist/modules/credit_runtime.js +462 -165
- package/dist/modules/crypto/browser_provider.js +6 -4
- package/dist/modules/crypto/node_provider.js +1 -1
- package/dist/modules/crypto/pure_scrypt.js +35 -4
- package/dist/modules/crypto/pure_secp256k1.js +72 -26
- package/dist/modules/crypto/sync.d.ts +9 -9
- package/dist/modules/crypto/sync.js +16 -9
- package/dist/modules/dexbot_class.d.ts +195 -139
- package/dist/modules/dexbot_class.js +78 -28
- package/dist/modules/dexbot_cow_runtime.d.ts +167 -87
- package/dist/modules/dexbot_cow_runtime.js +248 -206
- package/dist/modules/dexbot_credential_client.d.ts +19 -11
- package/dist/modules/dexbot_fill_runtime.d.ts +63 -48
- package/dist/modules/dexbot_fill_runtime.js +48 -41
- package/dist/modules/dexbot_maintenance_runtime.d.ts +109 -70
- package/dist/modules/dexbot_maintenance_runtime.js +108 -83
- package/dist/modules/dexbot_startup_runtime.d.ts +11 -10
- package/dist/modules/dexbot_startup_runtime.js +43 -43
- package/dist/modules/dexbot_state_recovery.d.ts +13 -12
- package/dist/modules/dexbot_state_recovery.js +18 -13
- package/dist/modules/fund_registry.d.ts +4 -2
- package/dist/modules/fund_registry.js +10 -10
- package/dist/modules/general_settings.d.ts +30 -4
- package/dist/modules/graceful_shutdown.d.ts +3 -3
- package/dist/modules/graceful_shutdown.js +2 -2
- package/dist/modules/grid_price_source.d.ts +1 -1
- package/dist/modules/key_store.d.ts +14 -8
- package/dist/modules/key_store.js +7 -6
- package/dist/modules/launcher/adapter_requirement.d.ts +11 -5
- package/dist/modules/launcher/adapter_requirement.js +5 -5
- package/dist/modules/launcher/bot_supervisor.d.ts +106 -24
- package/dist/modules/launcher/bot_supervisor.js +12 -11
- package/dist/modules/launcher/credential_bootstrap.d.ts +1 -1
- package/dist/modules/launcher/credential_bootstrap.js +1 -1
- package/dist/modules/launcher/credential_daemon.d.ts +4 -4
- package/dist/modules/launcher/credential_daemon.js +2 -2
- package/dist/modules/launcher/credential_secret.d.ts +1 -1
- package/dist/modules/launcher/foreign_cred_daemon.d.ts +2 -2
- package/dist/modules/launcher/market_adapter_runtime.d.ts +61 -6
- package/dist/modules/launcher/market_adapter_watchdog.d.ts +10 -2
- package/dist/modules/launcher/market_adapter_watchdog.js +4 -0
- package/dist/modules/launcher/monolithic_runtime.d.ts +18 -16
- package/dist/modules/launcher/status_reporting.d.ts +22 -14
- package/dist/modules/launcher/supervisor_control.d.ts +8 -1
- package/dist/modules/launcher/supervisor_control.js +4 -2
- package/dist/modules/market_adapter_whitelist.d.ts +9 -3
- package/dist/modules/market_adapter_whitelist.js +15 -3
- package/dist/modules/node_manager.d.ts +41 -11
- package/dist/modules/node_manager.js +5 -4
- package/dist/modules/order/accounting.d.ts +53 -24
- package/dist/modules/order/accounting.js +16 -15
- package/dist/modules/order/async_lock.d.ts +5 -2
- package/dist/modules/order/async_lock.js +1 -1
- package/dist/modules/order/export.d.ts +7 -6
- package/dist/modules/order/export.js +1 -7
- package/dist/modules/order/format.d.ts +4 -4
- package/dist/modules/order/genesis_policy.d.ts +21 -18
- package/dist/modules/order/genesis_policy.js +12 -8
- package/dist/modules/order/grid.d.ts +142 -36
- package/dist/modules/order/grid.js +148 -123
- package/dist/modules/order/grid_reconcile.d.ts +21 -20
- package/dist/modules/order/grid_reconcile.js +13 -12
- package/dist/modules/order/grid_reconcile_internal.d.ts +85 -72
- package/dist/modules/order/grid_reconcile_internal.js +28 -19
- package/dist/modules/order/index.d.ts +263 -1
- package/dist/modules/order/logger.d.ts +45 -11
- package/dist/modules/order/logger.js +38 -40
- package/dist/modules/order/logger_state.d.ts +4 -4
- package/dist/modules/order/manager.d.ts +225 -180
- package/dist/modules/order/manager.js +80 -83
- package/dist/modules/order/processed_fill_store.d.ts +18 -3
- package/dist/modules/order/processed_fill_store.js +16 -27
- package/dist/modules/order/strategy.d.ts +21 -13
- package/dist/modules/order/strategy.js +5 -6
- package/dist/modules/order/sync_engine.d.ts +91 -33
- package/dist/modules/order/sync_engine.js +84 -53
- package/dist/modules/order/utils/math.d.ts +157 -102
- package/dist/modules/order/utils/math.js +77 -38
- package/dist/modules/order/utils/order.d.ts +310 -110
- package/dist/modules/order/utils/order.js +122 -99
- package/dist/modules/order/utils/slot.d.ts +1 -1
- package/dist/modules/order/utils/system.d.ts +176 -26
- package/dist/modules/order/utils/system.js +86 -69
- package/dist/modules/order/utils/validate.d.ts +89 -41
- package/dist/modules/order/utils/validate.js +24 -22
- package/dist/modules/order/utils/withPoolRef.d.ts +4 -3
- package/dist/modules/order/utils/withPoolRef.js +18 -12
- package/dist/modules/order/working_grid.d.ts +14 -13
- package/dist/modules/paths.d.ts +1 -4
- package/dist/modules/paths.js +1 -27
- package/dist/modules/process_discovery.d.ts +1 -1
- package/dist/modules/process_discovery.js +2 -1
- package/dist/modules/runtime.d.ts +7 -3
- package/dist/modules/runtime.js +4 -3
- package/dist/modules/runtime_settings.d.ts +15 -10
- package/dist/modules/runtime_settings.js +30 -24
- package/dist/modules/settings_merge.d.ts +29 -3
- package/dist/modules/settings_merge.js +56 -78
- package/dist/modules/socket_json_client.d.ts +7 -4
- package/dist/modules/storage/browser_adapter.d.ts +38 -53
- package/dist/modules/storage/browser_adapter.js +7 -30
- package/dist/modules/storage/index.d.ts +1 -1
- package/dist/modules/storage/node_adapter.d.ts +45 -27
- package/dist/modules/storage/node_adapter.js +9 -9
- package/dist/modules/storage/types.d.ts +5 -4
- package/dist/modules/types.d.ts +1071 -2
- package/dist/modules/types.js +4 -1
- package/dist/modules/utils/asset_symbols.d.ts +2 -1
- package/dist/modules/utils/asset_symbols.js +2 -1
- package/dist/modules/utils/errors.d.ts +9 -0
- package/dist/modules/utils/errors.js +23 -1
- package/dist/modules/utils/time_range.d.ts +1 -12
- package/dist/modules/utils/time_range.js +1 -1
- package/dist/modules/validate_profiles.js +53 -43
- package/dist/modules/version_notice.d.ts +14 -3
- package/dist/modules/version_notice.js +6 -4
- package/dist/pm2.d.ts +29 -27
- package/dist/pm2.js +5 -5
- package/dist/scripts/analyze-credit.d.ts +2 -1
- package/dist/scripts/analyze-credit.js +23 -24
- package/dist/scripts/analyze-orders.d.ts +77 -9
- package/dist/scripts/analyze-orders.js +65 -40
- package/dist/scripts/chart_command.d.ts +27 -18
- package/dist/scripts/chart_command.js +13 -11
- package/dist/scripts/check_any.d.ts +18 -0
- package/dist/scripts/check_any.js +126 -0
- package/dist/scripts/diagnose-pool-history.js +12 -7
- package/dist/scripts/print_grid.js +0 -1
- package/dist/scripts/run-tests.js +39 -7
- package/dist/scripts/runner.js +1 -1
- package/dist/scripts/test-credit-renewal.js +30 -21
- package/dist/scripts/update.d.ts +10 -5
- package/dist/scripts/update.js +168 -103
- package/dist/scripts/update_dist_freshness.js +1 -0
- package/dist/scripts/update_layout.d.ts +61 -0
- package/dist/scripts/update_layout.js +180 -0
- package/dist/scripts/validate_bots.js +2 -1
- package/dist/scripts/verify-browser-bundle.js +8 -0
- package/dist/unlock.d.ts +28 -3
- package/dist/unlock.js +63 -35
- package/docs/BITSHARES_ONBOARDING.md +2 -0
- package/docs/COPY_ON_WRITE_MASTER_PLAN.md +1 -1
- package/docs/COW_INVARIANTS.md +13 -6
- package/docs/DEXBOT_COMPARISON.md +8 -8
- package/docs/EVOLUTION.md +10 -9
- package/docs/FUND_MOVEMENT_AND_ACCOUNTING.md +5 -5
- package/docs/GRID_RECALCULATION.md +4 -2
- package/docs/GRID_RECONCILE.md +14 -3
- package/docs/LIFECYCLE.md +11 -11
- package/docs/MPA_CREDIT_USAGE.md +22 -3
- package/docs/README.md +14 -3
- package/docs/architecture.md +12 -9
- package/docs/developer_guide.md +6 -6
- package/market_adapter/README.md +6 -1
- package/modules/README.md +4 -1
- package/package.json +4 -1
|
@@ -70,6 +70,18 @@
|
|
|
70
70
|
*
|
|
71
71
|
* ===============================================================================
|
|
72
72
|
*/
|
|
73
|
+
import type { OrderManagerLike, PendingPriceCorrection, ChainOrder, ParsedChainOrder, AssetPair, AssetInfo, OrderType, ManagedOrder, UnmatchedChainOrder, CowAction, ProjectedFunds } from '../../types.js';
|
|
74
|
+
import type { GridGenesis } from './math.js';
|
|
75
|
+
interface CorrectionAccountOrdersLike {
|
|
76
|
+
cancelOrder(account: string, privateKey: string, chainOrderId: string): Promise<unknown>;
|
|
77
|
+
updateOrder(account: string, privateKey: string, chainOrderId: string, params: {
|
|
78
|
+
amountToSell: unknown;
|
|
79
|
+
minToReceive: unknown;
|
|
80
|
+
}): Promise<unknown>;
|
|
81
|
+
buildCancelOrderOp(account: string, chainOrderId: string): Promise<unknown>;
|
|
82
|
+
batchReadOrders(ids: string[]): Promise<Map<string, unknown>>;
|
|
83
|
+
executeBatch(account: string, privateKey: string, ops: unknown[]): Promise<unknown>;
|
|
84
|
+
}
|
|
73
85
|
/**
|
|
74
86
|
* Detect a "chain order does not exist" error from a broadcast/read failure.
|
|
75
87
|
* Single canonical implementation used by the correction, reconcile-cancel,
|
|
@@ -86,7 +98,7 @@
|
|
|
86
98
|
* for generic object-missing phrasings (precision mode).
|
|
87
99
|
* @returns {boolean} True if the message indicates the order is gone.
|
|
88
100
|
*/
|
|
89
|
-
declare function isOrderGoneErrorMessage(message:
|
|
101
|
+
declare function isOrderGoneErrorMessage(message: string | null | undefined, orderId?: string | null): boolean;
|
|
90
102
|
/**
|
|
91
103
|
* Record a duplicate-orphan detection for an orderId.
|
|
92
104
|
* First sighting stays quiet (count 1). A repeated sighting of the same
|
|
@@ -94,7 +106,7 @@ declare function isOrderGoneErrorMessage(message: any, orderId?: any): boolean;
|
|
|
94
106
|
* @param {string} orderId - Duplicate orphan chain order ID.
|
|
95
107
|
* @returns {{ count: number; shouldEscalate: boolean }} Detection stats.
|
|
96
108
|
*/
|
|
97
|
-
declare function recordDuplicateOrphanDetection(orderId:
|
|
109
|
+
declare function recordDuplicateOrphanDetection(orderId: string | null | undefined): {
|
|
98
110
|
count: number;
|
|
99
111
|
shouldEscalate: boolean;
|
|
100
112
|
};
|
|
@@ -103,7 +115,7 @@ declare function recordDuplicateOrphanDetection(orderId: any): {
|
|
|
103
115
|
* so a resolved orphan never lingers and false-escalates later.
|
|
104
116
|
* @param {string} orderId - Chain order ID to forget.
|
|
105
117
|
*/
|
|
106
|
-
declare function clearDuplicateOrphanDetection(orderId:
|
|
118
|
+
declare function clearDuplicateOrphanDetection(orderId: string | null | undefined): void;
|
|
107
119
|
/**
|
|
108
120
|
* Record a duplicate-orphan detection and return the log level + re-detection
|
|
109
121
|
* suffix for the caller's diagnostic line. First sightings log at info; a
|
|
@@ -111,30 +123,30 @@ declare function clearDuplicateOrphanDetection(orderId: any): void;
|
|
|
111
123
|
* @param {string} orderId - Duplicate orphan chain order ID.
|
|
112
124
|
* @returns {{ level: 'info'|'warn'; suffix: string }} Log level and suffix text.
|
|
113
125
|
*/
|
|
114
|
-
declare function duplicateOrphanLogInfo(orderId:
|
|
126
|
+
declare function duplicateOrphanLogInfo(orderId: string | null | undefined): {
|
|
115
127
|
level: string;
|
|
116
128
|
suffix: string;
|
|
117
129
|
};
|
|
118
|
-
declare function _filterUnmatchedChainOrders(manager:
|
|
130
|
+
declare function _filterUnmatchedChainOrders(manager: OrderManagerLike, chainOrderId: string): void;
|
|
119
131
|
/**
|
|
120
132
|
* Record a fresh on-chain placement timestamp for surplus-cancel grace.
|
|
121
133
|
* Called when a slot gains a chain orderId it did not have before (create,
|
|
122
134
|
* adopt, rotation target). Powers isFreshlyPlacedOrder below.
|
|
123
|
-
* @param {
|
|
135
|
+
* @param {unknown} manager - OrderManager instance (owns `_placedAt`)
|
|
124
136
|
* @param {string} chainOrderId - Chain order id that was just placed
|
|
125
137
|
*/
|
|
126
|
-
declare function recordOrderPlacement(manager:
|
|
138
|
+
declare function recordOrderPlacement(manager: OrderManagerLike, chainOrderId: string | null | undefined): void;
|
|
127
139
|
/**
|
|
128
140
|
* True when the chain order was placed within the surplus-cancel grace
|
|
129
141
|
* window. Surplus sweeps must skip such orders: a fill landing between two
|
|
130
142
|
* controllers' count snapshots otherwise makes the second cancel what the
|
|
131
143
|
* first just placed (fee bleed + empty levels, no net change).
|
|
132
|
-
* @param {
|
|
144
|
+
* @param {unknown} manager - OrderManager instance
|
|
133
145
|
* @param {string} chainOrderId - Chain order id to test
|
|
134
146
|
* @param {number} [graceMs] - Override grace window (defaults to TIMING.SURPLUS_CANCEL_GRACE_MS)
|
|
135
147
|
* @returns {boolean} True while the order is still inside its grace window
|
|
136
148
|
*/
|
|
137
|
-
declare function isFreshlyPlacedOrder(manager:
|
|
149
|
+
declare function isFreshlyPlacedOrder(manager: OrderManagerLike, chainOrderId: string | null | undefined, graceMs?: number): boolean;
|
|
138
150
|
/**
|
|
139
151
|
* Stamp queue provenance on a correction entry: queued-at timestamp plus
|
|
140
152
|
* the detector that produced it. Existing provenance (e.g. a fresher
|
|
@@ -145,14 +157,14 @@ declare function isFreshlyPlacedOrder(manager: any, chainOrderId: string | null
|
|
|
145
157
|
* @param {string} source - provenance tag (see queuedBy values)
|
|
146
158
|
* @returns {Object} The same entry, stamped
|
|
147
159
|
*/
|
|
148
|
-
declare function _stampCorrectionProvenance(entry:
|
|
160
|
+
declare function _stampCorrectionProvenance(entry: PendingPriceCorrection, source: string): PendingPriceCorrection;
|
|
149
161
|
/**
|
|
150
162
|
* Find the live grid slot that currently owns a chain order.
|
|
151
163
|
* When slotId is supplied, only that exact slot is considered; otherwise all
|
|
152
164
|
* live slots are searched. This keeps stale-decision guards consistent without
|
|
153
165
|
* changing which owner is considered valid.
|
|
154
166
|
*/
|
|
155
|
-
declare function findLiveOrderOwnerByChainId(manager:
|
|
167
|
+
declare function findLiveOrderOwnerByChainId(manager: OrderManagerLike, chainOrderId: string | null | undefined, slotId?: string | null): ManagedOrder | null;
|
|
156
168
|
/**
|
|
157
169
|
* Drain-time staleness validation for a correction entry: verify the queued
|
|
158
170
|
* intent still matches the LIVE grid geometry before broadcasting.
|
|
@@ -189,7 +201,7 @@ declare function findLiveOrderOwnerByChainId(manager: any, chainOrderId: any, sl
|
|
|
189
201
|
* @param {Object} entry - Queued correction entry
|
|
190
202
|
* @returns {{valid: boolean, reason: string}} valid=false drops the entry
|
|
191
203
|
*/
|
|
192
|
-
declare function _validatePriceCorrectionEntry(manager:
|
|
204
|
+
declare function _validatePriceCorrectionEntry(manager: OrderManagerLike, entry: PendingPriceCorrection): {
|
|
193
205
|
valid: boolean;
|
|
194
206
|
reason: string;
|
|
195
207
|
};
|
|
@@ -202,12 +214,7 @@ declare function _validatePriceCorrectionEntry(manager: any, entry: any): {
|
|
|
202
214
|
* @param {Object} assets - Asset metadata with assetA, assetB, and precisions
|
|
203
215
|
* @returns {Object|null} Parsed order {orderId, price, type, size} or null if invalid
|
|
204
216
|
*/
|
|
205
|
-
declare function parseChainOrder(chainOrder:
|
|
206
|
-
orderId: any;
|
|
207
|
-
price: number;
|
|
208
|
-
type: "sell" | "buy";
|
|
209
|
-
size: number | undefined;
|
|
210
|
-
} | null;
|
|
217
|
+
declare function parseChainOrder(chainOrder: ChainOrder | null | undefined, assets: AssetPair | null | undefined): ParsedChainOrder | null;
|
|
211
218
|
/**
|
|
212
219
|
* Update grid order size based on blockchain state.
|
|
213
220
|
* Detects partial fills and updates accounting if size changed.
|
|
@@ -220,7 +227,7 @@ declare function parseChainOrder(chainOrder: any, assets: any): {
|
|
|
220
227
|
* @returns {Promise<Object|null>} Updated order object or null
|
|
221
228
|
* @throws {Error} If chainSize suspicious (possible data corruption)
|
|
222
229
|
*/
|
|
223
|
-
declare function applyChainSizeToGridOrder(manager:
|
|
230
|
+
declare function applyChainSizeToGridOrder(manager: OrderManagerLike, gridOrder: ManagedOrder, chainSize: number | string | null | undefined): Promise<ManagedOrder | null>;
|
|
224
231
|
/**
|
|
225
232
|
* Build a stable fill dedupe key.
|
|
226
233
|
* Accepts either a fill-history entry or explicit parts.
|
|
@@ -230,7 +237,14 @@ declare function applyChainSizeToGridOrder(manager: any, gridOrder: any, chainSi
|
|
|
230
237
|
* @param {Object} fillOrParts - Fill entry ({ op, block_num, id }) or { orderId, blockNum, historyId }
|
|
231
238
|
* @returns {string|null} Stable key in order:block:history form, or null if fields are missing
|
|
232
239
|
*/
|
|
233
|
-
declare function buildFillKey(fillOrParts:
|
|
240
|
+
declare function buildFillKey(fillOrParts: {
|
|
241
|
+
op?: unknown[];
|
|
242
|
+
orderId?: string;
|
|
243
|
+
block_num?: number;
|
|
244
|
+
blockNum?: number;
|
|
245
|
+
id?: string;
|
|
246
|
+
historyId?: string;
|
|
247
|
+
} | null | undefined): string | null;
|
|
234
248
|
/**
|
|
235
249
|
* Correct a single order's price on blockchain.
|
|
236
250
|
* Cancels surplus orders; updates price for others.
|
|
@@ -244,17 +258,23 @@ declare function buildFillKey(fillOrParts: any): string | null;
|
|
|
244
258
|
* @param {Object} accountOrders - AccountOrders accessor for blockchain ops
|
|
245
259
|
* @returns {Promise<Object>} Result {success, cancelled, skipped, error, orderGone}
|
|
246
260
|
*/
|
|
247
|
-
declare function correctOrderPriceOnChain(manager:
|
|
261
|
+
declare function correctOrderPriceOnChain(manager: OrderManagerLike, correctionInfo: PendingPriceCorrection, accountName: string, privateKey: string, accountOrders: CorrectionAccountOrdersLike): Promise<{
|
|
248
262
|
success: boolean;
|
|
249
|
-
|
|
263
|
+
error: string;
|
|
264
|
+
skipped?: undefined;
|
|
250
265
|
cancelled?: undefined;
|
|
266
|
+
orderGone?: undefined;
|
|
267
|
+
} | {
|
|
268
|
+
success: boolean;
|
|
269
|
+
skipped: boolean;
|
|
251
270
|
error?: undefined;
|
|
271
|
+
cancelled?: undefined;
|
|
252
272
|
orderGone?: undefined;
|
|
253
273
|
} | {
|
|
254
274
|
success: boolean;
|
|
255
275
|
cancelled: boolean;
|
|
256
|
-
skipped?: undefined;
|
|
257
276
|
error?: undefined;
|
|
277
|
+
skipped?: undefined;
|
|
258
278
|
orderGone?: undefined;
|
|
259
279
|
} | {
|
|
260
280
|
success: boolean;
|
|
@@ -270,9 +290,9 @@ declare function correctOrderPriceOnChain(manager: any, correctionInfo: any, acc
|
|
|
270
290
|
orderGone?: undefined;
|
|
271
291
|
} | {
|
|
272
292
|
success: boolean;
|
|
293
|
+
error?: undefined;
|
|
273
294
|
skipped?: undefined;
|
|
274
295
|
cancelled?: undefined;
|
|
275
|
-
error?: undefined;
|
|
276
296
|
orderGone?: undefined;
|
|
277
297
|
}>;
|
|
278
298
|
/**
|
|
@@ -286,7 +306,29 @@ declare function correctOrderPriceOnChain(manager: any, correctionInfo: any, acc
|
|
|
286
306
|
* @param {Object} accountOrders - AccountOrders accessor for blockchain ops
|
|
287
307
|
* @returns {Promise<Object>} Summary {corrected, failed, results}
|
|
288
308
|
*/
|
|
289
|
-
declare function correctAllPriceMismatches(manager:
|
|
309
|
+
declare function correctAllPriceMismatches(manager: OrderManagerLike, accountName: string, privateKey: string, accountOrders: CorrectionAccountOrdersLike): Promise<{
|
|
310
|
+
corrected: number;
|
|
311
|
+
failed: number;
|
|
312
|
+
results: (PendingPriceCorrection & {
|
|
313
|
+
result: unknown;
|
|
314
|
+
})[];
|
|
315
|
+
staleDropped: number;
|
|
316
|
+
deferredUpdates: number;
|
|
317
|
+
} | {
|
|
318
|
+
corrected: number;
|
|
319
|
+
failed: number;
|
|
320
|
+
results: never[];
|
|
321
|
+
staleDropped?: undefined;
|
|
322
|
+
deferred?: undefined;
|
|
323
|
+
reason?: undefined;
|
|
324
|
+
} | {
|
|
325
|
+
corrected: number;
|
|
326
|
+
failed: number;
|
|
327
|
+
results: never[];
|
|
328
|
+
staleDropped: number;
|
|
329
|
+
deferred: boolean;
|
|
330
|
+
reason: string;
|
|
331
|
+
}>;
|
|
290
332
|
/**
|
|
291
333
|
* Build blockchain order arguments from grid order.
|
|
292
334
|
* Converts grid order data to blockchain-compatible amounts and asset IDs.
|
|
@@ -298,11 +340,15 @@ declare function correctAllPriceMismatches(manager: any, accountName: any, priva
|
|
|
298
340
|
* @returns {Object} Blockchain args {amountToSell, sellAssetId, minToReceive, receiveAssetId}
|
|
299
341
|
* @throws {Error} If asset precision missing
|
|
300
342
|
*/
|
|
301
|
-
declare function buildCreateOrderArgs(order:
|
|
343
|
+
declare function buildCreateOrderArgs(order: {
|
|
344
|
+
type: OrderType;
|
|
345
|
+
size: number;
|
|
346
|
+
price: number;
|
|
347
|
+
}, assetA: AssetInfo, assetB: AssetInfo): {
|
|
302
348
|
amountToSell: number;
|
|
303
|
-
sellAssetId:
|
|
349
|
+
sellAssetId: string | undefined;
|
|
304
350
|
minToReceive: number;
|
|
305
|
-
receiveAssetId:
|
|
351
|
+
receiveAssetId: string | undefined;
|
|
306
352
|
};
|
|
307
353
|
/**
|
|
308
354
|
* Build a deterministic fingerprint for a planned CREATE order.
|
|
@@ -335,7 +381,14 @@ declare function buildCreateOrderArgs(order: any, assetA: any, assetB: any): {
|
|
|
335
381
|
* @param {string} params.slotId - Grid slot id (e.g. 'sell-3', 'buy-7')
|
|
336
382
|
* @returns {string|null} Fingerprint or null on bad input
|
|
337
383
|
*/
|
|
338
|
-
declare function buildCreateOpFingerprint(params:
|
|
384
|
+
declare function buildCreateOpFingerprint(params: {
|
|
385
|
+
side?: string;
|
|
386
|
+
assetA?: string;
|
|
387
|
+
assetB?: string;
|
|
388
|
+
sellInt?: number | string;
|
|
389
|
+
receiveInt?: number | string;
|
|
390
|
+
slotId?: string;
|
|
391
|
+
} | null): string | null;
|
|
339
392
|
/**
|
|
340
393
|
* Determine which order sides were updated based on update flags.
|
|
341
394
|
*
|
|
@@ -343,7 +396,7 @@ declare function buildCreateOpFingerprint(params: any): string | null;
|
|
|
343
396
|
* @param {boolean} sellUpdated - Whether sell side was updated
|
|
344
397
|
* @returns {string} "buy", "sell", or "both"
|
|
345
398
|
*/
|
|
346
|
-
declare function getOrderTypeFromUpdatedFlags(buyUpdated:
|
|
399
|
+
declare function getOrderTypeFromUpdatedFlags(buyUpdated: boolean | undefined, sellUpdated: boolean | undefined): "sell" | "buy" | "both";
|
|
347
400
|
/**
|
|
348
401
|
* Resolve configured price bound (minPrice/maxPrice) to numeric value.
|
|
349
402
|
* Supports relative expressions like "2x" and fallback defaults.
|
|
@@ -355,7 +408,7 @@ declare function getOrderTypeFromUpdatedFlags(buyUpdated: any, sellUpdated: any)
|
|
|
355
408
|
* @returns {number} Resolved numeric price
|
|
356
409
|
* @throws {Error} If value is invalid and cannot be interpreted
|
|
357
410
|
*/
|
|
358
|
-
declare function resolveConfiguredPriceBound(value:
|
|
411
|
+
declare function resolveConfiguredPriceBound(value: unknown, fallback: number | string | null | undefined, startPrice: number | string | null | undefined, mode: string): number | null;
|
|
359
412
|
/**
|
|
360
413
|
* Convert order to virtual state.
|
|
361
414
|
* Clears on-chain ID and raw blockchain data, marks as VIRTUAL.
|
|
@@ -363,7 +416,27 @@ declare function resolveConfiguredPriceBound(value: any, fallback: any, startPri
|
|
|
363
416
|
* @param {Object} order - Order to virtualize
|
|
364
417
|
* @returns {Object} Virtualized order (VIRTUAL state, no orderId)
|
|
365
418
|
*/
|
|
366
|
-
|
|
419
|
+
interface CrossingCandidate {
|
|
420
|
+
orderId?: string | null;
|
|
421
|
+
chainOrderId?: string | null;
|
|
422
|
+
slotId?: string;
|
|
423
|
+
price?: number;
|
|
424
|
+
type?: string;
|
|
425
|
+
order?: {
|
|
426
|
+
price?: number;
|
|
427
|
+
[key: string]: unknown;
|
|
428
|
+
} | null;
|
|
429
|
+
[key: string]: unknown;
|
|
430
|
+
}
|
|
431
|
+
interface SlotLike {
|
|
432
|
+
id?: string;
|
|
433
|
+
state?: string;
|
|
434
|
+
orderId?: string | null;
|
|
435
|
+
size?: number;
|
|
436
|
+
type?: OrderType | null;
|
|
437
|
+
price?: number;
|
|
438
|
+
}
|
|
439
|
+
declare function virtualizeOrder(order: ManagedOrder): ManagedOrder;
|
|
367
440
|
/**
|
|
368
441
|
* Convert order to spread placeholder (virtual, zero-sized spread order).
|
|
369
442
|
* Used when clearing order slots during rotations or rebalancing.
|
|
@@ -371,7 +444,7 @@ declare function virtualizeOrder(order: any): any;
|
|
|
371
444
|
* @param {Object} order - Order to convert
|
|
372
445
|
* @returns {Object} Spread placeholder order (VIRTUAL, SPREAD type, zero size)
|
|
373
446
|
*/
|
|
374
|
-
declare function convertToSpreadPlaceholder(order:
|
|
447
|
+
declare function convertToSpreadPlaceholder(order: ManagedOrder): ManagedOrder;
|
|
375
448
|
/**
|
|
376
449
|
* Convert an order to a rail-typed hole placeholder: VIRTUAL with the rail
|
|
377
450
|
* (BUY/SELL) type and the booked size preserved.
|
|
@@ -388,13 +461,13 @@ declare function convertToSpreadPlaceholder(order: any): any;
|
|
|
388
461
|
* @param {number} [sizeOverride] - Explicit size (defaults to booked size, 0 when non-finite)
|
|
389
462
|
* @returns {Object} Rail hole placeholder (VIRTUAL, rail type, preserved size)
|
|
390
463
|
*/
|
|
391
|
-
declare function toRailHolePlaceholder(order:
|
|
464
|
+
declare function toRailHolePlaceholder(order: ManagedOrder, railType: string, sizeOverride?: number | null): ManagedOrder;
|
|
392
465
|
/**
|
|
393
466
|
* Geometry type for a slot index: BUY at/below the boundary, SELL at/above
|
|
394
467
|
* sellStart, SPREAD inside the gap band. Null-safe — returns null when the
|
|
395
468
|
* index, boundary, or gap width is unusable so callers fail closed.
|
|
396
469
|
*/
|
|
397
|
-
declare function geometryTypeForSlotIndex(idx:
|
|
470
|
+
declare function geometryTypeForSlotIndex(idx: number | string | null | undefined, boundaryIdx: number | string | null | undefined, gapSlots: number | string | null | undefined): OrderType | null;
|
|
398
471
|
/**
|
|
399
472
|
* Detect gap-evacuation candidates by GEOMETRY ONLY: live on-chain orders
|
|
400
473
|
* whose parsed slot index sits strictly inside the gap band
|
|
@@ -407,7 +480,14 @@ declare function geometryTypeForSlotIndex(idx: any, boundaryIdx: any, gapSlots:
|
|
|
407
480
|
* @param {number} gapSlots - Spread gap slot count (frozen at plan-build)
|
|
408
481
|
* @returns {Array} Candidates [{id, idx, type, price, size, orderId}]
|
|
409
482
|
*/
|
|
410
|
-
declare function detectGapEvacuationCandidates(masterGrid:
|
|
483
|
+
declare function detectGapEvacuationCandidates(masterGrid: Map<string, ManagedOrder>, boundaryIdx: number | string | null, gapSlots: number | string | null): Array<{
|
|
484
|
+
id: string;
|
|
485
|
+
idx: number;
|
|
486
|
+
type: OrderType;
|
|
487
|
+
price: number;
|
|
488
|
+
size: number;
|
|
489
|
+
orderId: string;
|
|
490
|
+
}>;
|
|
411
491
|
/**
|
|
412
492
|
* Tick the per-slot gap-evacuation streak counter. In-memory on the manager
|
|
413
493
|
* (resets on restart — acceptable; a restart re-plans evacuation anyway).
|
|
@@ -419,9 +499,12 @@ declare function detectGapEvacuationCandidates(masterGrid: any, boundaryIdx: any
|
|
|
419
499
|
* @param {number} [threshold] - GRID_LIMITS.GAP_EVACUATION_STREAK_THRESHOLD default
|
|
420
500
|
* @returns {{streaks: Object, ready: Array}}
|
|
421
501
|
*/
|
|
422
|
-
declare function updateGapEvacuationStreaks(streakMap:
|
|
502
|
+
declare function updateGapEvacuationStreaks(streakMap: Map<string, number>, candidates: unknown, threshold?: number | null): {
|
|
423
503
|
streaks: Record<string, number>;
|
|
424
|
-
ready:
|
|
504
|
+
ready: Array<{
|
|
505
|
+
id: string;
|
|
506
|
+
[key: string]: unknown;
|
|
507
|
+
}>;
|
|
425
508
|
};
|
|
426
509
|
/**
|
|
427
510
|
* Resolve the real BUY/SELL side of a SPREAD-typed grid slot from its price
|
|
@@ -434,14 +517,14 @@ declare function updateGapEvacuationStreaks(streakMap: any, candidates: any, thr
|
|
|
434
517
|
* @param {number} startPrice - The configured grid center price.
|
|
435
518
|
* @returns {string} ORDER_TYPES.BUY or ORDER_TYPES.SELL
|
|
436
519
|
*/
|
|
437
|
-
declare function resolveSpreadOrderSide(price:
|
|
520
|
+
declare function resolveSpreadOrderSide(price: number | string, startPrice: number | string | null | undefined): OrderType;
|
|
438
521
|
/**
|
|
439
522
|
* Parse a grid slot id ("slot-123") to its rail index. Delegates to
|
|
440
523
|
* shared slot.ts single source (GRID_PRICE_SLOT_DETERMINISM_PLAN §2.1).
|
|
441
|
-
* @param {
|
|
524
|
+
* @param {unknown} id - grid slot id string
|
|
442
525
|
* @returns {number|null}
|
|
443
526
|
*/
|
|
444
|
-
declare function parseSlotIndex(id:
|
|
527
|
+
declare function parseSlotIndex(id: string | null | undefined): number | null;
|
|
445
528
|
/**
|
|
446
529
|
* Whether a parsed chain order matches a grid slot exactly:
|
|
447
530
|
* type-compatible (slot may be SPREAD), price strictly equal via integer
|
|
@@ -456,7 +539,7 @@ declare function parseSlotIndex(id: any): number | null;
|
|
|
456
539
|
* @param {Object} assets - Manager assets ({assetA, assetB} with precision)
|
|
457
540
|
* @returns {boolean}
|
|
458
541
|
*/
|
|
459
|
-
declare function chainOrderMatchesSlot(parsed:
|
|
542
|
+
declare function chainOrderMatchesSlot(parsed: ParsedChainOrder, slot: ManagedOrder, assets: AssetPair): boolean;
|
|
460
543
|
/**
|
|
461
544
|
* Whether a parsed chain order matches a grid slot within price tolerance:
|
|
462
545
|
* type-compatible (slot may be SPREAD), price within calculatePriceTolerance
|
|
@@ -472,7 +555,7 @@ declare function chainOrderMatchesSlot(parsed: any, slot: any, assets: any): boo
|
|
|
472
555
|
* @param {Object} assets - Manager assets ({assetA, assetB} with precision)
|
|
473
556
|
* @returns {boolean}
|
|
474
557
|
*/
|
|
475
|
-
declare function chainOrderMatchesSlotWithTolerance(parsed:
|
|
558
|
+
declare function chainOrderMatchesSlotWithTolerance(parsed: ParsedChainOrder, slot: ManagedOrder, assets: AssetPair): boolean;
|
|
476
559
|
/**
|
|
477
560
|
* Identity of a crossing-check candidate. Master orders carry orderId,
|
|
478
561
|
* unmatched chain orders carry chainOrderId, pending-broadcast wrappers
|
|
@@ -484,7 +567,7 @@ declare function chainOrderMatchesSlotWithTolerance(parsed: any, slot: any, asse
|
|
|
484
567
|
* @param {Object} o - Candidate order or pending-broadcast wrapper entry
|
|
485
568
|
* @returns {string|null} Chain/slot identity, or null when not placeable
|
|
486
569
|
*/
|
|
487
|
-
declare function crossingCandidateChainId(o:
|
|
570
|
+
declare function crossingCandidateChainId(o: CrossingCandidate | null | undefined): string | null;
|
|
488
571
|
/**
|
|
489
572
|
* Shared predicate for every crossing-placement guard (COW create/rotation/
|
|
490
573
|
* fallback, startup reconcile placement, price-correction re-queue). Accepts
|
|
@@ -499,7 +582,7 @@ declare function crossingCandidateChainId(o: any): string | null;
|
|
|
499
582
|
* @param {Map|null} [cancelOpIndexByOrderId=null] - orderId -> op index of its already-queued cancel
|
|
500
583
|
* @returns {boolean} True when the candidate participates in crossing checks
|
|
501
584
|
*/
|
|
502
|
-
declare function isCrossingCheckCandidate(o:
|
|
585
|
+
declare function isCrossingCheckCandidate(o: CrossingCandidate | null | undefined, excludeChainOrderId?: string | null, cancelOpIndexByOrderId?: Map<string, unknown> | null): boolean;
|
|
503
586
|
/**
|
|
504
587
|
* Shared candidate set for crossing-placement checks: master orders plus
|
|
505
588
|
* chain-side orders that may exist on chain but are not (yet) adopted into
|
|
@@ -511,9 +594,9 @@ declare function isCrossingCheckCandidate(o: any, excludeChainOrderId?: any, can
|
|
|
511
594
|
* master-grid-only checks cannot see (the pending/unmatched batch guards
|
|
512
595
|
* fire only for CREATE batches).
|
|
513
596
|
* @param {Object} manager - OrderManager instance (orders Map, _pendingBroadcasts, _lastUnmatchedChainOrders)
|
|
514
|
-
* @returns {
|
|
597
|
+
* @returns {unknown[]} Candidate orders/wrappers for findCrossedOrder
|
|
515
598
|
*/
|
|
516
|
-
declare function buildCrossingCheckCandidates(manager:
|
|
599
|
+
declare function buildCrossingCheckCandidates(manager: OrderManagerLike): CrossingCandidate[];
|
|
517
600
|
/**
|
|
518
601
|
* Filter orders array by type.
|
|
519
602
|
*
|
|
@@ -521,7 +604,7 @@ declare function buildCrossingCheckCandidates(manager: any): any[];
|
|
|
521
604
|
* @param {string} orderType - Order type to match (BUY, SELL, SPREAD)
|
|
522
605
|
* @returns {Array<Object>} Filtered orders of specified type
|
|
523
606
|
*/
|
|
524
|
-
declare function filterOrdersByType(orders:
|
|
607
|
+
declare function filterOrdersByType(orders: ManagedOrder[], orderType: OrderType): ManagedOrder[];
|
|
525
608
|
/**
|
|
526
609
|
* Build outside->center paired groups from mixed BUY/SELL items.
|
|
527
610
|
* SELL items are ordered highest->lowest price, BUY items lowest->highest,
|
|
@@ -534,7 +617,11 @@ declare function filterOrdersByType(orders: any, orderType: any): any[];
|
|
|
534
617
|
* @param {(item: any) => number|string} accessors.getPrice - Returns item price.
|
|
535
618
|
* @returns {Array<Array<*>>} Grouped items in outside->center pair order.
|
|
536
619
|
*/
|
|
537
|
-
declare function buildOutsideInPairGroups(items:
|
|
620
|
+
declare function buildOutsideInPairGroups<T>(items: T[], { isValid, getType, getPrice }: {
|
|
621
|
+
isValid?: (item: T) => boolean;
|
|
622
|
+
getType: (item: T) => string;
|
|
623
|
+
getPrice: (item: T) => number | string;
|
|
624
|
+
}): T[][];
|
|
538
625
|
/**
|
|
539
626
|
* Extract operation_results from a chain batch execution result.
|
|
540
627
|
* Handles the multiple result shapes returned by different chain library versions
|
|
@@ -543,14 +630,14 @@ declare function buildOutsideInPairGroups(items: any, { isValid, getType, getPri
|
|
|
543
630
|
* @param {Object|Array} result - Raw chain batch execution result.
|
|
544
631
|
* @returns {Array} Array of operation result tuples, or empty array if unrecognized.
|
|
545
632
|
*/
|
|
546
|
-
declare function extractBatchOperationResults(result:
|
|
633
|
+
declare function extractBatchOperationResults(result: unknown): unknown[][] | null;
|
|
547
634
|
/**
|
|
548
635
|
* Format an unmatched chain order/blocker for operator logs.
|
|
549
636
|
*
|
|
550
637
|
* @param {Object} order - Unmatched chain order or structural blocker.
|
|
551
638
|
* @returns {string} Compact human-readable diagnostic.
|
|
552
639
|
*/
|
|
553
|
-
declare function formatUnmatchedChainOrder(order:
|
|
640
|
+
declare function formatUnmatchedChainOrder(order: UnmatchedChainOrder | null | undefined): string;
|
|
554
641
|
/**
|
|
555
642
|
* Whether an unmatched chain-order entry is a deliberate hold that must NOT
|
|
556
643
|
* block CREATEs or snapshot recovery.
|
|
@@ -567,13 +654,17 @@ declare function formatUnmatchedChainOrder(order: any): string;
|
|
|
567
654
|
* @param {Object} order - Unmatched chain order entry.
|
|
568
655
|
* @returns {boolean} True when the entry is a non-blocking deferred hold.
|
|
569
656
|
*/
|
|
570
|
-
declare function isNonBlockingUnmatchedOrder(order:
|
|
657
|
+
declare function isNonBlockingUnmatchedOrder(order: {
|
|
658
|
+
reason?: unknown;
|
|
659
|
+
} | null | undefined): boolean;
|
|
571
660
|
/**
|
|
572
661
|
* @param {Object} order - Unmatched chain order entry.
|
|
573
662
|
* @returns {boolean} True when the hold is stranded and a structural resync is
|
|
574
663
|
* a plausible remedy (see STRANDED_HOLD_REASONS).
|
|
575
664
|
*/
|
|
576
|
-
declare function isStrandedHoldOrder(order:
|
|
665
|
+
declare function isStrandedHoldOrder(order: {
|
|
666
|
+
reason?: unknown;
|
|
667
|
+
} | null | undefined): boolean;
|
|
577
668
|
/**
|
|
578
669
|
* GRID-PRICE-INVARIANT — the price emitted for a slot must be its genesis
|
|
579
670
|
* level. Range guards (isChainPriceOutOfGrid) only test the configured min/max
|
|
@@ -588,10 +679,10 @@ declare function isStrandedHoldOrder(order: any): boolean;
|
|
|
588
679
|
*
|
|
589
680
|
* @param {string} slotId - Grid slot id (slot-<idx>)
|
|
590
681
|
* @param {number} price - Price about to be emitted
|
|
591
|
-
* @param {
|
|
682
|
+
* @param {unknown} genesis - manager._genesis (priceLevels table)
|
|
592
683
|
* @returns {{ok: boolean, reason: string, expected: number|null, idx: number|null, drift: number|null}}
|
|
593
684
|
*/
|
|
594
|
-
declare function checkGridPriceInvariant(slotId:
|
|
685
|
+
declare function checkGridPriceInvariant(slotId: string | null | undefined, price: number | string | null | undefined, genesis: GridGenesis | null | undefined): {
|
|
595
686
|
ok: boolean;
|
|
596
687
|
reason: string;
|
|
597
688
|
expected: number | null;
|
|
@@ -609,7 +700,7 @@ declare function checkGridPriceInvariant(slotId: any, price: any, genesis: any):
|
|
|
609
700
|
* reconcile sites treat `false` as blocking (skip the emission and let the next
|
|
610
701
|
* cycle re-plan). See docs/GRID_PRICE_INVARIANT.md.
|
|
611
702
|
*
|
|
612
|
-
* @param {
|
|
703
|
+
* @param {unknown} manager - OrderManager (reads _genesis, writes logger)
|
|
613
704
|
* @param {string} slotId - Destination slot id whose level the price must match
|
|
614
705
|
* @param {number} price - Price about to be emitted
|
|
615
706
|
* @param {string} site - Emitting site label (CREATE / UPDATE / RECONCILE-*)
|
|
@@ -617,14 +708,14 @@ declare function checkGridPriceInvariant(slotId: any, price: any, genesis: any):
|
|
|
617
708
|
* at the reconcile sites treat `false` as a blocking mismatch and skip the
|
|
618
709
|
* emission, so this must return the check result rather than void.
|
|
619
710
|
*/
|
|
620
|
-
declare function reportGridPriceInvariant(manager:
|
|
711
|
+
declare function reportGridPriceInvariant(manager: OrderManagerLike, slotId: string | null | undefined, price: number | string, site: string): boolean;
|
|
621
712
|
/**
|
|
622
713
|
* Check if order is on blockchain (ACTIVE or PARTIAL state).
|
|
623
714
|
*
|
|
624
715
|
* @param {Object} order - Order to check
|
|
625
716
|
* @returns {boolean} True if order has on-chain state
|
|
626
717
|
*/
|
|
627
|
-
declare function isOrderOnChain(order:
|
|
718
|
+
declare function isOrderOnChain(order: SlotLike | null | undefined): boolean;
|
|
628
719
|
/**
|
|
629
720
|
* Resolve the type to keep when a slot holding a live on-chain order would
|
|
630
721
|
* otherwise be reassigned to SPREAD. SPREAD+ACTIVE/PARTIAL is an illegal state
|
|
@@ -644,14 +735,17 @@ declare function isOrderOnChain(order: any): boolean;
|
|
|
644
735
|
* @param {Object} ORDER_TYPES - ORDER_TYPES constants
|
|
645
736
|
* @returns {string} Type to keep for the on-chain slot
|
|
646
737
|
*/
|
|
647
|
-
declare function resolveOnChainRetypeType(slot:
|
|
738
|
+
declare function resolveOnChainRetypeType(slot: SlotLike, idx: number, buyEndIdx: number, orderTypes: {
|
|
739
|
+
BUY: OrderType;
|
|
740
|
+
SELL: OrderType;
|
|
741
|
+
}): OrderType;
|
|
648
742
|
/**
|
|
649
743
|
* Check if order is virtual (not on blockchain yet).
|
|
650
744
|
*
|
|
651
745
|
* @param {Object} order - Order to check
|
|
652
746
|
* @returns {boolean} True if order in VIRTUAL state
|
|
653
747
|
*/
|
|
654
|
-
declare function isOrderVirtual(order:
|
|
748
|
+
declare function isOrderVirtual(order: SlotLike | null | undefined): boolean;
|
|
655
749
|
/**
|
|
656
750
|
* Whether a slot is an empty reusable placeholder: VIRTUAL, no chain order,
|
|
657
751
|
* and zero size. Empty slots are normalized to SPREAD (side-neutral) so their
|
|
@@ -674,7 +768,7 @@ declare function isOrderVirtual(order: any): boolean;
|
|
|
674
768
|
* @param {boolean} [opts.allowNullType=false] - Treat `type: null` slots as empty.
|
|
675
769
|
* @returns {boolean} True when the slot is a size-0 VIRTUAL placeholder.
|
|
676
770
|
*/
|
|
677
|
-
declare function isEmptyGridSlot(slot:
|
|
771
|
+
declare function isEmptyGridSlot(slot: SlotLike | null | undefined, liveSlot?: SlotLike | null, opts?: {
|
|
678
772
|
allowNullType?: boolean;
|
|
679
773
|
}): boolean;
|
|
680
774
|
/**
|
|
@@ -683,7 +777,9 @@ declare function isEmptyGridSlot(slot: any, liveSlot?: any, opts?: {
|
|
|
683
777
|
* @param {Object} order - Order to check
|
|
684
778
|
* @returns {boolean} True if order has orderId
|
|
685
779
|
*/
|
|
686
|
-
declare function hasOnChainId(order:
|
|
780
|
+
declare function hasOnChainId(order: {
|
|
781
|
+
orderId?: string | null;
|
|
782
|
+
} | null | undefined): boolean;
|
|
687
783
|
/**
|
|
688
784
|
* Check if order is placed and confirmed on blockchain.
|
|
689
785
|
* Must be on-chain (ACTIVE/PARTIAL) with orderId.
|
|
@@ -691,7 +787,7 @@ declare function hasOnChainId(order: any): boolean;
|
|
|
691
787
|
* @param {Object} order - Order to check
|
|
692
788
|
* @returns {boolean} True if order is confirmed placed
|
|
693
789
|
*/
|
|
694
|
-
declare function isOrderPlaced(order:
|
|
790
|
+
declare function isOrderPlaced(order: SlotLike | null | undefined): boolean;
|
|
695
791
|
/**
|
|
696
792
|
* Check if order is phantom (on-chain but missing orderId).
|
|
697
793
|
* Indicates a sync error or ghost order state.
|
|
@@ -699,7 +795,7 @@ declare function isOrderPlaced(order: any): boolean;
|
|
|
699
795
|
* @param {Object} order - Order to check
|
|
700
796
|
* @returns {boolean} True if order appears on-chain but has no ID
|
|
701
797
|
*/
|
|
702
|
-
declare function isPhantomOrder(order:
|
|
798
|
+
declare function isPhantomOrder(order: SlotLike | null | undefined): boolean;
|
|
703
799
|
/**
|
|
704
800
|
* Check if slot is available for new order placement.
|
|
705
801
|
* Slot must be VIRTUAL (not on-chain) and have no orderId.
|
|
@@ -707,7 +803,7 @@ declare function isPhantomOrder(order: any): boolean;
|
|
|
707
803
|
* @param {Object} order - Order/slot to check
|
|
708
804
|
* @returns {boolean} True if slot available
|
|
709
805
|
*/
|
|
710
|
-
declare function isSlotAvailable(order:
|
|
806
|
+
declare function isSlotAvailable(order: SlotLike | null | undefined): boolean;
|
|
711
807
|
/**
|
|
712
808
|
* Check if order size meets health thresholds.
|
|
713
809
|
* Must be above absolute minimum and double-dust threshold.
|
|
@@ -718,7 +814,7 @@ declare function isSlotAvailable(order: any): boolean;
|
|
|
718
814
|
* @param {number} idealSize - Ideal grid size for dust calculation
|
|
719
815
|
* @returns {boolean} True if order is healthy
|
|
720
816
|
*/
|
|
721
|
-
declare function isOrderHealthy(size:
|
|
817
|
+
declare function isOrderHealthy(size: number | string, type: OrderType, assets: AssetPair, idealSize: number | string): boolean;
|
|
722
818
|
/**
|
|
723
819
|
* Check if any size in array falls below threshold.
|
|
724
820
|
* Used for validation before order placement.
|
|
@@ -729,7 +825,7 @@ declare function isOrderHealthy(size: any, type: any, assets: any, idealSize: an
|
|
|
729
825
|
* @param {boolean} [includeNonFinite=false] - Treat non-finite values as below threshold
|
|
730
826
|
* @returns {boolean} True if any size is below threshold
|
|
731
827
|
*/
|
|
732
|
-
declare function checkSizeThreshold(sizes:
|
|
828
|
+
declare function checkSizeThreshold(sizes: number[], threshold: number, precision: number, includeNonFinite?: boolean): boolean;
|
|
733
829
|
/**
|
|
734
830
|
* Check if any sizes are below minimum (including non-finite values).
|
|
735
831
|
* Wrapper for checkSizeThreshold with includeNonFinite=true.
|
|
@@ -739,7 +835,7 @@ declare function checkSizeThreshold(sizes: any, threshold: any, precision: any,
|
|
|
739
835
|
* @param {number} precision - Asset precision
|
|
740
836
|
* @returns {boolean} True if any size is below minimum
|
|
741
837
|
*/
|
|
742
|
-
declare function checkSizesBeforeMinimum(sizes:
|
|
838
|
+
declare function checkSizesBeforeMinimum(sizes: number[], minSize: number, precision: number): boolean;
|
|
743
839
|
/**
|
|
744
840
|
* Calculate ideal grid boundary based on reference price.
|
|
745
841
|
* Places boundary near reference price with gap spacing in mind.
|
|
@@ -756,7 +852,7 @@ declare function checkSizesBeforeMinimum(sizes: any, minSize: any, precision: an
|
|
|
756
852
|
* @param {number} gapSlots - Number of gap slots between buy and sell
|
|
757
853
|
* @returns {number} Ideal boundary index or -1 if slots empty
|
|
758
854
|
*/
|
|
759
|
-
declare function calculateIdealBoundary(allSlots:
|
|
855
|
+
declare function calculateIdealBoundary(allSlots: SlotLike[], referencePrice: number | string, gapSlots: number): number;
|
|
760
856
|
/**
|
|
761
857
|
* Assign BUY/SELL/SPREAD roles to grid slots based on boundary.
|
|
762
858
|
* Slots below boundary are BUY, above boundary are SELL, between are SPREAD.
|
|
@@ -771,10 +867,61 @@ declare function calculateIdealBoundary(allSlots: any, referencePrice: any, gapS
|
|
|
771
867
|
* @param {boolean} [options.assignOnChain=false] - Override on-chain orders if true
|
|
772
868
|
* @returns {Array<Object>} Slots with updated type assignments
|
|
773
869
|
*/
|
|
774
|
-
|
|
870
|
+
interface DeltaAction {
|
|
871
|
+
type: 'create' | 'update' | 'cancel';
|
|
872
|
+
id: string;
|
|
873
|
+
order?: ManagedOrder;
|
|
874
|
+
prevOrder?: ManagedOrder;
|
|
875
|
+
orderId?: string | null;
|
|
876
|
+
[key: string]: unknown;
|
|
877
|
+
}
|
|
878
|
+
interface ReserveConfig {
|
|
879
|
+
reserveOrders?: number | {
|
|
880
|
+
buy?: number;
|
|
881
|
+
sell?: number;
|
|
882
|
+
[key: string]: unknown;
|
|
883
|
+
};
|
|
884
|
+
activeOrders?: {
|
|
885
|
+
buy?: number;
|
|
886
|
+
sell?: number;
|
|
887
|
+
[key: string]: unknown;
|
|
888
|
+
};
|
|
889
|
+
startPrice?: number | string;
|
|
890
|
+
minPrice?: number | string | null;
|
|
891
|
+
maxPrice?: number | string | null;
|
|
892
|
+
assetA?: string;
|
|
893
|
+
assetB?: string;
|
|
894
|
+
feeParams?: {
|
|
895
|
+
BTS_RESERVATION_MULTIPLIER?: number;
|
|
896
|
+
[key: string]: unknown;
|
|
897
|
+
};
|
|
898
|
+
min_BTS_value?: number;
|
|
899
|
+
incrementPercent?: number;
|
|
900
|
+
targetSpreadPercent?: number;
|
|
901
|
+
gridLimits?: {
|
|
902
|
+
[key: string]: unknown;
|
|
903
|
+
};
|
|
904
|
+
[key: string]: unknown;
|
|
905
|
+
}
|
|
906
|
+
interface ManagerFundsLike {
|
|
907
|
+
allocatedBuy?: number;
|
|
908
|
+
allocatedSell?: number;
|
|
909
|
+
chainFreeBuy?: number;
|
|
910
|
+
chainFreeSell?: number;
|
|
911
|
+
btsBalance?: {
|
|
912
|
+
free?: number;
|
|
913
|
+
total?: number;
|
|
914
|
+
locked?: number;
|
|
915
|
+
} | null;
|
|
916
|
+
}
|
|
917
|
+
declare function assignGridRoles<T extends SlotLike>(allSlots: T[], boundaryIdx: number, gapSlots: number, ORDER_TYPES: {
|
|
918
|
+
BUY: OrderType;
|
|
919
|
+
SELL: OrderType;
|
|
920
|
+
SPREAD: OrderType;
|
|
921
|
+
}, _ORDER_STATES: unknown, options?: {
|
|
775
922
|
assignOnChain?: boolean;
|
|
776
|
-
getCurrentSlot?: (id:
|
|
777
|
-
}):
|
|
923
|
+
getCurrentSlot?: (id: string) => ManagedOrder | undefined;
|
|
924
|
+
}): T[];
|
|
778
925
|
/**
|
|
779
926
|
* Determine if grid is out of spread and by how many steps.
|
|
780
927
|
* Compares current spread against nominal with tolerance.
|
|
@@ -788,27 +935,20 @@ declare function assignGridRoles(allSlots: any, boundaryIdx: any, gapSlots: any,
|
|
|
788
935
|
* @param {number} [incrementPercent=0.5] - Grid increment percentage
|
|
789
936
|
* @returns {number} Excess steps (0 if in-spread, >0 if out-of-spread)
|
|
790
937
|
*/
|
|
791
|
-
declare function shouldFlagOutOfSpread(currentSpread:
|
|
938
|
+
declare function shouldFlagOutOfSpread(currentSpread: number, nominalSpread: number, toleranceSteps: number, buyCount: number, sellCount: number, incrementPercent?: number): number;
|
|
792
939
|
/**
|
|
793
940
|
* Build complete index set from grid
|
|
794
941
|
* @param {Map} grid - Order grid
|
|
795
942
|
* @returns {Object} - Index object with state and type indexes
|
|
796
943
|
*/
|
|
797
|
-
declare function buildIndexes(grid:
|
|
798
|
-
virtual: Set<unknown>;
|
|
799
|
-
active: Set<unknown>;
|
|
800
|
-
partial: Set<unknown>;
|
|
801
|
-
buy: Set<unknown>;
|
|
802
|
-
sell: Set<unknown>;
|
|
803
|
-
spread: Set<unknown>;
|
|
804
|
-
};
|
|
944
|
+
declare function buildIndexes(grid: Map<string, ManagedOrder>): Record<string, Set<string>>;
|
|
805
945
|
/**
|
|
806
946
|
* Validate index consistency (for testing/debugging)
|
|
807
947
|
* @param {Map} grid - Order grid
|
|
808
948
|
* @param {Object} indexes - Index object
|
|
809
949
|
* @returns {Object} - Validation result
|
|
810
950
|
*/
|
|
811
|
-
declare function validateIndexes(grid:
|
|
951
|
+
declare function validateIndexes(grid: Map<string, ManagedOrder>, indexes: Record<string, Set<string>>): {
|
|
812
952
|
valid: boolean;
|
|
813
953
|
errors: string[];
|
|
814
954
|
};
|
|
@@ -820,7 +960,7 @@ declare function validateIndexes(grid: any, indexes: any): {
|
|
|
820
960
|
* @param {Object} [options.precisions] - Optional precision hints {buyPrecision, sellPrecision, defaultPrecision, priceRelativeTolerance}
|
|
821
961
|
* @returns {boolean} - True if orders are equivalent
|
|
822
962
|
*/
|
|
823
|
-
declare function ordersEqual(a:
|
|
963
|
+
declare function ordersEqual(a: ManagedOrder | null | undefined, b: ManagedOrder | null | undefined, options?: {
|
|
824
964
|
precisions?: {
|
|
825
965
|
buyPrecision?: number;
|
|
826
966
|
sellPrecision?: number;
|
|
@@ -841,7 +981,20 @@ declare function ordersEqual(a: any, b: any, options?: {
|
|
|
841
981
|
* @param {Object} [options={}] - Delta options forwarded to ordersEqual
|
|
842
982
|
* @returns {Array} - Array of action objects
|
|
843
983
|
*/
|
|
844
|
-
declare function buildDelta(masterGrid:
|
|
984
|
+
declare function buildDelta(masterGrid: Map<string, ManagedOrder>, workingGrid: Map<string, ManagedOrder>, options?: {
|
|
985
|
+
precisions?: {
|
|
986
|
+
buyPrecision?: number;
|
|
987
|
+
sellPrecision?: number;
|
|
988
|
+
defaultPrecision?: number;
|
|
989
|
+
priceRelativeTolerance?: number;
|
|
990
|
+
};
|
|
991
|
+
comparePrecisions?: {
|
|
992
|
+
buyPrecision?: number;
|
|
993
|
+
sellPrecision?: number;
|
|
994
|
+
defaultPrecision?: number;
|
|
995
|
+
priceRelativeTolerance?: number;
|
|
996
|
+
};
|
|
997
|
+
}): DeltaAction[];
|
|
845
998
|
/**
|
|
846
999
|
* Check whether a fill is eligible to drive boundary shift / rotation.
|
|
847
1000
|
* Partials only count when they are delayed-rotation triggers.
|
|
@@ -849,8 +1002,30 @@ declare function buildDelta(masterGrid: any, workingGrid: any, options?: any): a
|
|
|
849
1002
|
* @param {Object} fill - Fill event
|
|
850
1003
|
* @returns {boolean} True when the fill may shift the boundary
|
|
851
1004
|
*/
|
|
852
|
-
declare function isShiftEligibleFill(fill:
|
|
853
|
-
|
|
1005
|
+
declare function isShiftEligibleFill(fill: {
|
|
1006
|
+
isPartial?: boolean;
|
|
1007
|
+
isDelayedRotationTrigger?: boolean;
|
|
1008
|
+
[key: string]: unknown;
|
|
1009
|
+
} | null | undefined): boolean;
|
|
1010
|
+
declare function deriveTargetBoundary(fills: Array<{
|
|
1011
|
+
id?: string;
|
|
1012
|
+
price?: number;
|
|
1013
|
+
type?: string;
|
|
1014
|
+
[key: string]: unknown;
|
|
1015
|
+
}> | null | undefined, currentBoundaryIdx: number | null | undefined, allSlots: ManagedOrder[], config: {
|
|
1016
|
+
startPrice?: number | string;
|
|
1017
|
+
genesisStartPrice?: number | string;
|
|
1018
|
+
activeOrders?: {
|
|
1019
|
+
buy?: number;
|
|
1020
|
+
sell?: number;
|
|
1021
|
+
[key: string]: unknown;
|
|
1022
|
+
};
|
|
1023
|
+
[key: string]: unknown;
|
|
1024
|
+
} | null | undefined, gapSlots: number, crossChunkBudget?: number | null, pendingCrawls?: Array<{
|
|
1025
|
+
slotId?: string;
|
|
1026
|
+
side?: string;
|
|
1027
|
+
[key: string]: unknown;
|
|
1028
|
+
}> | null, edgeAnchors?: {
|
|
854
1029
|
buy?: number | null;
|
|
855
1030
|
sell?: number | null;
|
|
856
1031
|
} | null): {
|
|
@@ -872,10 +1047,10 @@ declare function deriveTargetBoundary(fills: any, currentBoundaryIdx: any, allSl
|
|
|
872
1047
|
* dropped rather than stranding live orders. Commits clear the record, so
|
|
873
1048
|
* entries present here predate every commit since recording — always owed.
|
|
874
1049
|
*
|
|
875
|
-
* @param {
|
|
1050
|
+
* @param {unknown} manager - OrderManager (boundaryIdx, orders, config restored)
|
|
876
1051
|
* @returns {{applied: boolean, from?: number, to?: number, count?: number, reason?: string}}
|
|
877
1052
|
*/
|
|
878
|
-
export declare function consumePendingFillCrawls(manager:
|
|
1053
|
+
export declare function consumePendingFillCrawls(manager: OrderManagerLike): {
|
|
879
1054
|
applied: boolean;
|
|
880
1055
|
from?: number;
|
|
881
1056
|
to?: number;
|
|
@@ -896,14 +1071,14 @@ export declare function consumePendingFillCrawls(manager: any): {
|
|
|
896
1071
|
* @param {string} side - 'buy' or 'sell'
|
|
897
1072
|
* @returns {number} Reserve count for the side (>= 0 integer)
|
|
898
1073
|
*/
|
|
899
|
-
declare function resolveReserveCount(config:
|
|
1074
|
+
declare function resolveReserveCount(config: ReserveConfig | null | undefined, side: string): number;
|
|
900
1075
|
/**
|
|
901
1076
|
* Total reserve count across both sides (fee/count totals).
|
|
902
1077
|
*
|
|
903
1078
|
* @param {Object} config - Bot configuration
|
|
904
1079
|
* @returns {number} Total reserves (buy + sell)
|
|
905
1080
|
*/
|
|
906
|
-
declare function resolveReserveOrders(config:
|
|
1081
|
+
declare function resolveReserveOrders(config: ReserveConfig | null | undefined): number;
|
|
907
1082
|
/**
|
|
908
1083
|
* Edge-pinned reserve id set for one side, or null when disabled.
|
|
909
1084
|
* Type/price-filtered, then ordered by the SAME edge order the placement
|
|
@@ -932,17 +1107,17 @@ declare function resolveReserveOrders(config: any): number;
|
|
|
932
1107
|
* dedicated reserves and the deficit never fires (issue #27 follow-up).
|
|
933
1108
|
* @returns {Set<string>|null} Edge slot ids, or null when side disabled
|
|
934
1109
|
*/
|
|
935
|
-
declare function reserveEdgeIdSet(allSlots:
|
|
1110
|
+
declare function reserveEdgeIdSet(allSlots: SlotLike[], config: ReserveConfig | null | undefined, orderType: OrderType, anchorPrice?: unknown, excludeIds?: Set<string> | null): Set<string> | null;
|
|
936
1111
|
/**
|
|
937
1112
|
* Window member ids for one side from the live manager (see
|
|
938
1113
|
* windowIdSetFromSlots). Delegates so the manager and explicit-geometry
|
|
939
1114
|
* callers share one definition.
|
|
940
1115
|
*
|
|
941
|
-
* @param {
|
|
1116
|
+
* @param {unknown} manager - OrderManager (orders Map, config, boundaryIdx)
|
|
942
1117
|
* @param {string} orderType - ORDER_TYPES.BUY or ORDER_TYPES.SELL
|
|
943
1118
|
* @returns {Set<string>|null} Window slot ids, or null when geometry unknown
|
|
944
1119
|
*/
|
|
945
|
-
declare function liveWindowIdSet(manager:
|
|
1120
|
+
declare function liveWindowIdSet(manager: OrderManagerLike, orderType: OrderType): Set<string> | null;
|
|
946
1121
|
/**
|
|
947
1122
|
* Refill-slot wire for the COW boundary hold (single source for both plan
|
|
948
1123
|
* producers: the fill-driven COW engine and the divergence fold).
|
|
@@ -971,19 +1146,19 @@ declare function liveWindowIdSet(manager: any, orderType: any): Set<string> | nu
|
|
|
971
1146
|
* @param {Iterable<Object>} [options.slots] - Master slots (reserve classification)
|
|
972
1147
|
* @param {{buy?: number|null, sell?: number|null}} [options.edgeAnchors] - Live
|
|
973
1148
|
* edge anchors (same pair the strategy classifies reserve fills against)
|
|
974
|
-
* @param {
|
|
1149
|
+
* @param {unknown} [options.manager] - OrderManager for the window exclusion (same
|
|
975
1150
|
* set the placement pickers exclude); omit to fall back to the previous
|
|
976
1151
|
* exclusion-free classification (fail-open)
|
|
977
1152
|
* @returns {string[]} Refill slot ids (CREATE ids minus reserve edge ids)
|
|
978
1153
|
*/
|
|
979
|
-
declare function collectRefillSlotIds(actions:
|
|
980
|
-
config?:
|
|
981
|
-
slots?:
|
|
1154
|
+
declare function collectRefillSlotIds(actions: CowAction[], options?: {
|
|
1155
|
+
config?: ReserveConfig | null;
|
|
1156
|
+
slots?: unknown;
|
|
982
1157
|
edgeAnchors?: {
|
|
983
1158
|
buy?: number | null;
|
|
984
1159
|
sell?: number | null;
|
|
985
1160
|
} | null;
|
|
986
|
-
manager?:
|
|
1161
|
+
manager?: OrderManagerLike | null;
|
|
987
1162
|
}): string[];
|
|
988
1163
|
/**
|
|
989
1164
|
* Resolved bound anchor for reserve edges from CONFIG alone.
|
|
@@ -1003,7 +1178,7 @@ declare function collectRefillSlotIds(actions: any, options?: {
|
|
|
1003
1178
|
* @param {string} side - 'buy' or 'sell'
|
|
1004
1179
|
* @returns {number|null} Finite anchor price, or null
|
|
1005
1180
|
*/
|
|
1006
|
-
declare function resolveReserveEdgeAnchorPrice(config:
|
|
1181
|
+
declare function resolveReserveEdgeAnchorPrice(config: ReserveConfig | null | undefined, side: string): number | null;
|
|
1007
1182
|
/** Manager surface the live reserve-edge anchor reads (structural view). */
|
|
1008
1183
|
type ReserveEdgeAnchorManager = {
|
|
1009
1184
|
_genesis?: {
|
|
@@ -1058,7 +1233,7 @@ declare function resolveLiveReserveEdgeAnchorPrice(manager: ReserveEdgeAnchorMan
|
|
|
1058
1233
|
* @param {number|null} anchorPrice - Resolved bound anchor (null = rank fallback)
|
|
1059
1234
|
* @returns {number} Comparator result for Array.prototype.sort
|
|
1060
1235
|
*/
|
|
1061
|
-
declare function compareReserveEdge(a:
|
|
1236
|
+
declare function compareReserveEdge(a: SlotLike, b: SlotLike, edge: string, anchorPrice: number | null): number;
|
|
1062
1237
|
/**
|
|
1063
1238
|
* Central edge selector: take reserve slots from a price-ascending list,
|
|
1064
1239
|
* skipping already-windowed ids. Both edges anchor at the live grid's own
|
|
@@ -1078,7 +1253,7 @@ declare function compareReserveEdge(a: any, b: any, edge: any, anchorPrice: any)
|
|
|
1078
1253
|
* @param {number|null} [anchorPrice] - Live edge anchor for the side (null = rank-based)
|
|
1079
1254
|
* @returns {Array<Object>} Reserve slots (ascending for floor, descending for ceiling)
|
|
1080
1255
|
*/
|
|
1081
|
-
declare function selectReserveEdgeSlots(sortedAsc:
|
|
1256
|
+
declare function selectReserveEdgeSlots<T extends SlotLike>(sortedAsc: T[], count: number, excludeIds: Set<string> | null, edge: string, anchorPrice?: number | null): T[];
|
|
1082
1257
|
/**
|
|
1083
1258
|
* Total target order count across both sides (used for BTS fee calculation).
|
|
1084
1259
|
* Single source of truth so every budget derivation sizes identically.
|
|
@@ -1087,7 +1262,7 @@ declare function selectReserveEdgeSlots(sortedAsc: any, count: any, excludeIds:
|
|
|
1087
1262
|
* @param {Object} config - Bot configuration
|
|
1088
1263
|
* @returns {number} Total target order count
|
|
1089
1264
|
*/
|
|
1090
|
-
declare function getActiveOrdersTotal(config:
|
|
1265
|
+
declare function getActiveOrdersTotal(config: ReserveConfig | null | undefined): number;
|
|
1091
1266
|
/**
|
|
1092
1267
|
* Calculate side budget after BTS fee deduction.
|
|
1093
1268
|
*
|
|
@@ -1097,7 +1272,7 @@ declare function getActiveOrdersTotal(config: any): number;
|
|
|
1097
1272
|
* @param {number} totalTarget - Total target order count (used for BTS fee calculation on both sides)
|
|
1098
1273
|
* @returns {number} Available budget for the side
|
|
1099
1274
|
*/
|
|
1100
|
-
declare function getSideBudget(side:
|
|
1275
|
+
declare function getSideBudget(side: string, funds: ManagerFundsLike | ProjectedFunds | null, config: ReserveConfig, totalTarget: number): number;
|
|
1101
1276
|
/**
|
|
1102
1277
|
* Calculate sizes for all slots on a side using weighted distribution.
|
|
1103
1278
|
*
|
|
@@ -1109,7 +1284,7 @@ declare function getSideBudget(side: any, funds: any, config: any, totalTarget:
|
|
|
1109
1284
|
* @param {Object} assets - Asset metadata for precision
|
|
1110
1285
|
* @returns {Array} Array of calculated sizes
|
|
1111
1286
|
*/
|
|
1112
|
-
declare function calculateBudgetedSizes(slots:
|
|
1287
|
+
declare function calculateBudgetedSizes(slots: SlotLike[], side: string, budget: number, weightDist: unknown, incrementPercent: number | undefined, assets: AssetPair | null): number[];
|
|
1113
1288
|
/**
|
|
1114
1289
|
* Whether a chain order still matches the cached pre-update state the
|
|
1115
1290
|
* limit_order_update delta was built from. Only a provably-unchanged order
|
|
@@ -1119,7 +1294,17 @@ declare function calculateBudgetedSizes(slots: any, side: any, budget: any, weig
|
|
|
1119
1294
|
* @param {Object|null} cachedRaw - The rawOnChain cache captured at build time
|
|
1120
1295
|
* @returns {boolean}
|
|
1121
1296
|
*/
|
|
1122
|
-
declare function chainOrderUnchangedFromCache(chainOrder:
|
|
1297
|
+
declare function chainOrderUnchangedFromCache(chainOrder: ChainOrder | null | undefined, cachedRaw: {
|
|
1298
|
+
sell_price?: {
|
|
1299
|
+
base?: {
|
|
1300
|
+
amount?: unknown;
|
|
1301
|
+
};
|
|
1302
|
+
quote?: {
|
|
1303
|
+
amount?: unknown;
|
|
1304
|
+
};
|
|
1305
|
+
};
|
|
1306
|
+
for_sale?: unknown;
|
|
1307
|
+
} | null | undefined): boolean;
|
|
1123
1308
|
/**
|
|
1124
1309
|
* PRE-BROADCAST CROSSED-BOOK ASSERT (defense-in-depth, any-writer detection).
|
|
1125
1310
|
*
|
|
@@ -1133,7 +1318,7 @@ declare function chainOrderUnchangedFromCache(chainOrder: any, cachedRaw: any):
|
|
|
1133
1318
|
*
|
|
1134
1319
|
* Detector only: any internal failure returns null (never blocks a broadcast).
|
|
1135
1320
|
*/
|
|
1136
|
-
declare function detectCrossedBookPlan(manager:
|
|
1321
|
+
declare function detectCrossedBookPlan(manager: OrderManagerLike, actions: CowAction[]): string | null;
|
|
1137
1322
|
/**
|
|
1138
1323
|
* Collect every on-chain order id master currently needs to converge against,
|
|
1139
1324
|
* so adoption can re-read them by id (immune to the get_full_accounts window
|
|
@@ -1144,16 +1329,31 @@ declare function detectCrossedBookPlan(manager: any, actions: any[]): string | n
|
|
|
1144
1329
|
* - the batch's fresh CREATE ids extracted from the broadcast result
|
|
1145
1330
|
* (operation_results[i][1] aligns positionally with placedContexts[i]).
|
|
1146
1331
|
*
|
|
1147
|
-
* @param {
|
|
1148
|
-
* @param {
|
|
1149
|
-
* @param {
|
|
1332
|
+
* @param {unknown} mgr - bot.manager
|
|
1333
|
+
* @param {unknown} placedResults - broadcast result (has operation_results); null when unavailable
|
|
1334
|
+
* @param {unknown[]} placedContexts - opContexts (aligned with operation_results); null when unavailable
|
|
1150
1335
|
* @param {string[]|null} [extraCreateIds=null] - fresh CREATE chain ids from another
|
|
1151
1336
|
* authoritative source (e.g. the uncertain-broadcast poll confirmation) when
|
|
1152
1337
|
* no broadcast result exists; merged into createIds so the lagging-create
|
|
1153
1338
|
* retry guards them
|
|
1154
1339
|
* @returns {string[]} Unique, well-formed 1.7.x order ids
|
|
1155
1340
|
*/
|
|
1156
|
-
declare function collectKnownOnChainOrderIds(mgr:
|
|
1341
|
+
declare function collectKnownOnChainOrderIds(mgr: OrderManagerLike, placedResults: unknown, placedContexts: Array<{
|
|
1342
|
+
kind?: string;
|
|
1343
|
+
order?: {
|
|
1344
|
+
orderId?: string | null;
|
|
1345
|
+
} | null;
|
|
1346
|
+
rotation?: {
|
|
1347
|
+
oldOrder?: {
|
|
1348
|
+
orderId?: string | null;
|
|
1349
|
+
} | null;
|
|
1350
|
+
} | null;
|
|
1351
|
+
updateInfo?: {
|
|
1352
|
+
partialOrder?: {
|
|
1353
|
+
orderId?: string | null;
|
|
1354
|
+
} | null;
|
|
1355
|
+
} | null;
|
|
1356
|
+
} | null> | null, extraCreateIds?: string[] | null): {
|
|
1157
1357
|
masterIds: string[];
|
|
1158
1358
|
createIds: string[];
|
|
1159
1359
|
all: string[];
|