dexbot 1.6.12 → 1.6.14
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 +65 -1
- package/README.md +2 -2
- package/analysis/README.md +9 -11
- package/analysis/ama_fitting/README.md +5 -3
- package/claw/README.md +1 -0
- package/claw/docs/AI_BOT_LIBRARY_API.md +3 -1
- package/claw/docs/DEXBOT2_TUNING_CHEAT_SHEET.md +4 -4
- package/claw/modules/claw_bridge.ts +0 -3
- package/claw/modules/claw_catalog.ts +8 -4
- package/claw/modules/claw_skill_md.ts +1 -0
- package/claw/modules/dexbot_profiles.ts +59 -15
- package/claw/modules/types.ts +2 -1
- package/claw/package.json +3 -3
- package/claw/runtimes/openclaw-plugin/openclaw.plugin.json +1 -1
- package/claw/runtimes/openclaw-plugin/package.json +1 -1
- package/claw/skills/margin-trading/SKILL.md +1 -1
- package/claw/skills/margin-trading/references/position-management.md +1 -1
- package/claw/tsconfig.json +2 -2
- package/dist/analysis/ama_fitting/analyze_lambda_vs_slow.js +1 -14
- package/dist/analysis/ama_fitting/fetch_lp_candles.js +51 -41
- package/dist/analysis/ama_fitting/generate_unified_comparison_chart.d.ts +1 -24
- package/dist/analysis/ama_fitting/generate_unified_comparison_chart.js +36 -18
- package/dist/analysis/ama_fitting/optimizer_high_resolution.js +18 -66
- package/dist/analysis/analyze_args.d.ts +12 -0
- package/dist/analysis/analyze_args.js +20 -0
- package/dist/analysis/bot_fitting/backtest_ama_sweep.d.ts +1 -16
- package/dist/analysis/bot_fitting/backtest_ama_sweep.js +20 -101
- package/dist/analysis/bot_fitting/backtest_bot_fitting.js +26 -92
- package/dist/analysis/bot_fitting/backtest_lookback_drawdown.js +19 -34
- package/dist/analysis/bot_fitting/shared_utils.d.ts +71 -3
- package/dist/analysis/bot_fitting/shared_utils.js +124 -8
- package/dist/analysis/chart_ui.d.ts +30 -1
- package/dist/analysis/chart_ui.js +37 -1
- package/dist/analysis/fills_cache.d.ts +3 -23
- package/dist/analysis/fills_cache.js +3 -84
- package/dist/analysis/fills_source.d.ts +31 -1
- package/dist/analysis/fills_source.js +69 -1
- package/dist/analysis/grid_correction_check.d.ts +1 -23
- package/dist/analysis/grid_correction_check.js +15 -58
- package/dist/analysis/math_utils.d.ts +85 -1
- package/dist/analysis/math_utils.js +116 -1
- package/dist/analysis/price_sources.d.ts +22 -1
- package/dist/analysis/price_sources.js +23 -0
- package/dist/analysis/resolve_source.js +31 -10
- package/dist/analysis/trade_profitability.d.ts +6 -0
- package/dist/analysis/trade_profitability.js +23 -97
- package/dist/analysis/tradingview/analyze_tradingview.d.ts +1 -17
- package/dist/analysis/tradingview/analyze_tradingview.js +1 -1
- package/dist/analysis/tradingview/tradingview_uplot_chart_generator.js +27 -40
- package/dist/analysis/trend_detection/backtest_ama_slope_huber.d.ts +1 -101
- package/dist/analysis/trend_detection/backtest_ama_slope_huber.js +22 -80
- package/dist/analysis/trend_detection/dynamic_weight_chart_generator.js +11 -37
- package/dist/analysis/trend_detection/volatility_chart_generator.js +9 -10
- package/dist/analysis/worker_pool.d.ts +38 -0
- package/dist/analysis/worker_pool.js +67 -0
- package/dist/dexbot.js +67 -48
- package/dist/market_adapter/ama_signal_runner.js +21 -54
- package/dist/market_adapter/candle_utils.d.ts +7 -1
- package/dist/market_adapter/candle_utils.js +11 -1
- package/dist/market_adapter/cli_args.d.ts +22 -0
- package/dist/market_adapter/cli_args.js +30 -0
- package/dist/market_adapter/core/config_normalizers.js +11 -6
- package/dist/market_adapter/core/kibana_candles.d.ts +3 -1
- package/dist/market_adapter/core/kibana_candles.js +3 -2
- package/dist/market_adapter/core/market_adapter_service.d.ts +85 -85
- package/dist/market_adapter/core/market_adapter_service.js +93 -158
- package/dist/market_adapter/core/signals/hurst_analyzer.d.ts +1 -6
- package/dist/market_adapter/core/signals/hurst_analyzer.js +1 -1
- package/dist/market_adapter/core/signals/permutation_entropy_analyzer.d.ts +1 -11
- package/dist/market_adapter/core/signals/permutation_entropy_analyzer.js +1 -1
- package/dist/market_adapter/inputs/fetch_book_data.js +0 -1
- package/dist/market_adapter/inputs/fetch_cex_synthetic_data.js +63 -107
- package/dist/market_adapter/inputs/fetch_lp_data.d.ts +8 -1
- package/dist/market_adapter/inputs/fetch_lp_data.js +25 -7
- package/dist/market_adapter/inputs/kibana_feed_source.js +4 -26
- package/dist/market_adapter/inputs/window_cache.d.ts +4 -72
- package/dist/market_adapter/inputs/window_cache.js +52 -177
- package/dist/market_adapter/interval_utils.d.ts +11 -1
- package/dist/market_adapter/interval_utils.js +16 -1
- package/dist/market_adapter/lp_chart_runner.d.ts +3 -0
- package/dist/market_adapter/lp_chart_runner.js +37 -19
- package/dist/market_adapter/market_adapter.js +27 -72
- package/dist/market_adapter/utils/data_discovery.d.ts +45 -1
- package/dist/market_adapter/utils/data_discovery.js +220 -27
- package/dist/market_adapter/utils/month_shards.d.ts +84 -0
- package/dist/market_adapter/utils/month_shards.js +237 -0
- package/dist/modules/account_bots.d.ts +8 -6
- package/dist/modules/account_bots.js +112 -131
- package/dist/modules/account_orders.d.ts +49 -4
- package/dist/modules/account_orders.js +114 -49
- package/dist/modules/bitshares-native/chain_client.d.ts +1 -1
- package/dist/modules/bitshares-native/chain_client.js +14 -13
- package/dist/modules/bitshares-native/crypto/ecc_core.d.ts +1 -2
- package/dist/modules/bitshares-native/crypto/ecc_core.js +1 -1
- package/dist/modules/bitshares-native/resolvers.js +22 -25
- package/dist/modules/bitshares-native/serial/chain_constants.d.ts +1 -2
- package/dist/modules/bitshares-native/serial/chain_constants.js +1 -2
- package/dist/modules/bitshares-native/serial/types.js +22 -50
- package/dist/modules/bitshares-native/signing_client.d.ts +1 -1
- package/dist/modules/bot_defaults.d.ts +18 -3
- package/dist/modules/bot_defaults.js +34 -8
- package/dist/modules/bot_settings.d.ts +5 -1
- package/dist/modules/bot_settings.js +55 -21
- package/dist/modules/broadcast_failure.d.ts +2 -1
- package/dist/modules/chain_orders.d.ts +1 -1
- package/dist/modules/chain_orders.js +51 -96
- package/dist/modules/cli_start_onboarding.d.ts +2 -1
- package/dist/modules/config.js +6 -1
- package/dist/modules/constants.d.ts +14 -6
- package/dist/modules/constants.js +32 -6
- package/dist/modules/cr_planner.d.ts +1 -1
- package/dist/modules/cr_planner.js +1 -5
- package/dist/modules/credit_pricing.d.ts +2 -1
- package/dist/modules/credit_pricing.js +36 -40
- package/dist/modules/credit_runtime.d.ts +7 -0
- package/dist/modules/credit_runtime.js +45 -73
- package/dist/modules/daemon_node_health.d.ts +4 -3
- package/dist/modules/dexbot_class.d.ts +33 -17
- package/dist/modules/dexbot_class.js +113 -61
- package/dist/modules/dexbot_cow_runtime.d.ts +62 -181
- package/dist/modules/dexbot_cow_runtime.js +380 -69
- package/dist/modules/dexbot_credential_client.d.ts +1 -23
- package/dist/modules/dexbot_credential_client.js +2 -3
- package/dist/modules/dexbot_fill_runtime.d.ts +2 -3
- package/dist/modules/dexbot_fill_runtime.js +17 -7
- package/dist/modules/dexbot_maintenance_runtime.d.ts +36 -81
- package/dist/modules/dexbot_maintenance_runtime.js +137 -133
- package/dist/modules/dexbot_startup_runtime.d.ts +0 -1
- package/dist/modules/dexbot_startup_runtime.js +25 -14
- package/dist/modules/dexbot_state_recovery.js +16 -0
- package/dist/modules/general_settings.d.ts +1 -1
- package/dist/modules/graceful_shutdown.js +17 -11
- package/dist/modules/key_store.d.ts +0 -5
- package/dist/modules/key_store.js +1 -2
- package/dist/modules/lazy_shim.d.ts +11 -0
- package/dist/modules/lazy_shim.js +16 -0
- package/dist/modules/node_connect_policy.d.ts +3 -2
- package/dist/modules/node_failure_ledger.d.ts +6 -5
- package/dist/modules/order/accounting.js +11 -11
- package/dist/modules/order/export.js +2 -2
- package/dist/modules/order/format.d.ts +26 -3
- package/dist/modules/order/format.js +33 -3
- package/dist/modules/order/genesis_policy.d.ts +4 -4
- package/dist/modules/order/genesis_policy.js +6 -3
- package/dist/modules/order/grid.d.ts +26 -12
- package/dist/modules/order/grid.js +468 -80
- package/dist/modules/order/grid_reconcile.d.ts +1 -1
- package/dist/modules/order/grid_reconcile.js +5 -5
- package/dist/modules/order/grid_reconcile_internal.js +48 -40
- package/dist/modules/order/index.d.ts +35 -8
- package/dist/modules/order/logger.d.ts +1 -8
- package/dist/modules/order/logger.js +2 -11
- package/dist/modules/order/manager.d.ts +18 -15
- package/dist/modules/order/manager.js +91 -74
- package/dist/modules/order/strategy.d.ts +2 -2
- package/dist/modules/order/strategy.js +51 -21
- package/dist/modules/order/sync_engine.js +4 -0
- package/dist/modules/order/utils/math.d.ts +3 -3
- package/dist/modules/order/utils/math.js +38 -27
- package/dist/modules/order/utils/order.d.ts +58 -58
- package/dist/modules/order/utils/order.js +158 -137
- package/dist/modules/order/utils/system.d.ts +202 -35
- package/dist/modules/order/utils/system.js +409 -31
- package/dist/modules/order/utils/validate.js +28 -6
- package/dist/modules/order/utils/withPoolRef.d.ts +2 -1
- package/dist/modules/paths.js +32 -34
- package/dist/modules/runtime_settings.d.ts +3 -5
- package/dist/modules/runtime_settings.js +3 -3
- package/dist/modules/settings_merge.d.ts +2 -2
- package/dist/modules/socket_json_client.d.ts +2 -1
- package/dist/modules/types.d.ts +89 -30
- package/dist/modules/utils/errors.js +1 -3
- package/dist/modules/version_notice.d.ts +11 -10
- package/dist/pm2.d.ts +0 -1
- package/dist/pm2.js +56 -35
- package/dist/scripts/analyze-git.js +2 -15
- package/dist/scripts/analyze-orders.d.ts +1 -1
- package/dist/scripts/analyze-orders.js +4 -4
- package/dist/scripts/chart_command.js +2 -2
- package/dist/scripts/check_any.d.ts +4 -0
- package/dist/scripts/check_any.js +53 -21
- package/dist/scripts/diagnose-pool-history.js +1 -6
- package/dist/scripts/divergence-calc.js +6 -6
- package/dist/scripts/run-tests.js +0 -1
- package/dist/scripts/sync-version.js +0 -10
- package/dist/scripts/validate_bots.d.ts +1 -1
- package/dist/scripts/validate_bots.js +3 -3
- package/dist/unlock.js +7 -2
- package/docs/BITSHARES_ONBOARDING.md +8 -12
- package/docs/COPY_ON_WRITE_MASTER_PLAN.md +2 -3
- package/docs/COW_INVARIANTS.md +6 -6
- package/docs/DEXBOT_COMPARISON.md +7 -7
- package/docs/EVOLUTION.md +10 -8
- package/docs/FUND_MOVEMENT_AND_ACCOUNTING.md +8 -6
- package/docs/GRID_PRICE_INVARIANT.md +3 -3
- package/docs/GRID_RECALCULATION.md +4 -1
- package/docs/GRID_RECONCILE.md +4 -4
- package/docs/LIFECYCLE.md +11 -11
- package/docs/LOGGING.md +14 -0
- package/docs/MPA_CREDIT_USAGE.md +1 -1
- package/docs/ORDER_ENGINE_POST_1.0_RETROSPECTIVE.md +12 -4
- package/docs/README.md +3 -3
- package/docs/WORKFLOW.md +1 -0
- package/docs/architecture.md +25 -16
- package/docs/developer_guide.md +7 -2
- package/market_adapter/README.md +6 -4
- package/package.json +6 -9
- package/scripts/README.md +43 -38
- package/tests/README.md +26 -11
- package/dist/scripts/diagnose-kibana-candles.d.ts +0 -3
- package/dist/scripts/diagnose-kibana-candles.js +0 -82
- package/scripts/git-viewer.sh +0 -489
- package/scripts/postinstall.js +0 -16
|
@@ -60,13 +60,13 @@
|
|
|
60
60
|
* - getOrderSize(order) - Extract order size with fallback
|
|
61
61
|
*
|
|
62
62
|
* SECTION 10: STRATEGY CALCULATIONS (7 functions)
|
|
63
|
-
* -
|
|
64
|
-
* -
|
|
65
|
-
* -
|
|
66
|
-
* -
|
|
67
|
-
* -
|
|
68
|
-
* -
|
|
69
|
-
* -
|
|
63
|
+
* - resolveEdgeCount(config, side) - Clamped per-side edge count (>=0 int, 0 disables)
|
|
64
|
+
* - resolveEdgeOrders(config) - Total edge orders buy+sell (fee/count totals)
|
|
65
|
+
* - resolveLiveEdgeAnchorPrice(manager, side) - Live-grid edge anchor (genesis ladder extreme; null when no usable ladder)
|
|
66
|
+
* - resolveEdgeAnchorPrice(config, side) - Config-bound anchor fallback (buy→minPrice, sell→maxPrice; null when unresolvable)
|
|
67
|
+
* - compareEdge(a, b, edge, anchorPrice) - Shared anchored edge comparator (single ordering source)
|
|
68
|
+
* - edgeOrderIdSet(allSlots, config, orderType, anchorPrice?, excludeIds?) - Edge order id set (config count; shares the picker ordering; excludeIds carries the window exclusion)
|
|
69
|
+
* - selectEdgeSlots(sortedAsc, count, excludeIds, edge, anchorPrice?) - Shared position picker (both edges anchor toward their bound)
|
|
70
70
|
*
|
|
71
71
|
* ===============================================================================
|
|
72
72
|
*/
|
|
@@ -875,13 +875,13 @@ interface DeltaAction {
|
|
|
875
875
|
orderId?: string | null;
|
|
876
876
|
[key: string]: unknown;
|
|
877
877
|
}
|
|
878
|
-
interface
|
|
879
|
-
|
|
878
|
+
interface OrderConfigView {
|
|
879
|
+
edgeOrders?: number | {
|
|
880
880
|
buy?: number;
|
|
881
881
|
sell?: number;
|
|
882
882
|
[key: string]: unknown;
|
|
883
883
|
};
|
|
884
|
-
|
|
884
|
+
coreOrders?: {
|
|
885
885
|
buy?: number;
|
|
886
886
|
sell?: number;
|
|
887
887
|
[key: string]: unknown;
|
|
@@ -1015,7 +1015,7 @@ declare function deriveTargetBoundary(fills: Array<{
|
|
|
1015
1015
|
}> | null | undefined, currentBoundaryIdx: number | null | undefined, allSlots: ManagedOrder[], config: {
|
|
1016
1016
|
startPrice?: number | string;
|
|
1017
1017
|
genesisStartPrice?: number | string;
|
|
1018
|
-
|
|
1018
|
+
coreOrders?: {
|
|
1019
1019
|
buy?: number;
|
|
1020
1020
|
sell?: number;
|
|
1021
1021
|
[key: string]: unknown;
|
|
@@ -1058,56 +1058,56 @@ export declare function consumePendingFillCrawls(manager: OrderManagerLike): {
|
|
|
1058
1058
|
reason?: string;
|
|
1059
1059
|
};
|
|
1060
1060
|
/**
|
|
1061
|
-
* Per-side
|
|
1062
|
-
* Buy
|
|
1061
|
+
* Per-side edge count (edge-pinned fat-finger insurance orders).
|
|
1062
|
+
* Buy edges pin at the grid floor, sell edges at the grid ceiling.
|
|
1063
1063
|
* Non-finite/non-integer/negative values disable (0).
|
|
1064
1064
|
*
|
|
1065
|
-
* The legacy numeric form (`
|
|
1065
|
+
* The legacy numeric form (`edgeOrders: n`) is migrated here at read time
|
|
1066
1066
|
* to `{ buy: n, sell: 0 }`: the editor seeder rewrites the persisted JSON, but
|
|
1067
|
-
* a hand-edited bots.json that bypassed the editor must not have its
|
|
1067
|
+
* a hand-edited bots.json that bypassed the editor must not have its edge
|
|
1068
1068
|
* count silently read as 0.
|
|
1069
1069
|
*
|
|
1070
1070
|
* @param {Object} config - Bot configuration
|
|
1071
1071
|
* @param {string} side - 'buy' or 'sell'
|
|
1072
|
-
* @returns {number}
|
|
1072
|
+
* @returns {number} Edge count for the side (>= 0 integer)
|
|
1073
1073
|
*/
|
|
1074
|
-
declare function
|
|
1074
|
+
declare function resolveEdgeCount(config: OrderConfigView | null | undefined, side: string): number;
|
|
1075
1075
|
/**
|
|
1076
|
-
* Total
|
|
1076
|
+
* Total edge count across both sides (fee/count totals).
|
|
1077
1077
|
*
|
|
1078
1078
|
* @param {Object} config - Bot configuration
|
|
1079
|
-
* @returns {number} Total
|
|
1079
|
+
* @returns {number} Total edges (buy + sell)
|
|
1080
1080
|
*/
|
|
1081
|
-
declare function
|
|
1081
|
+
declare function resolveEdgeOrders(config: OrderConfigView | null | undefined): number;
|
|
1082
1082
|
/**
|
|
1083
|
-
* Edge-pinned
|
|
1083
|
+
* Edge-pinned order id set for one side, or null when disabled.
|
|
1084
1084
|
* Type/price-filtered, then ordered by the SAME edge order the placement
|
|
1085
|
-
* pickers use (
|
|
1085
|
+
* pickers use (compareEdge via selectEdgeSlots) — single source
|
|
1086
1086
|
* of truth, so the no-crawl classification can never drift from placement.
|
|
1087
1087
|
* Anchor: explicit live-grid edge when supplied, otherwise the config-bound
|
|
1088
1088
|
* fallback (unresolved -> plain rank). Shelf/manual ids (non-slot-N, e.g.
|
|
1089
|
-
* fork-kept deep-* orders below the rail) are never
|
|
1089
|
+
* fork-kept deep-* orders below the rail) are never edge orders: they would
|
|
1090
1090
|
* otherwise win the cheapest-first rank and poison the deficit check while
|
|
1091
1091
|
* the shelf is live (issue #27 follow-up). No-op upstream (grids only mint
|
|
1092
1092
|
* slot-N).
|
|
1093
1093
|
*
|
|
1094
1094
|
* @param {Array<Object>} allSlots - All grid slots (need id/price/type)
|
|
1095
|
-
* @param {Object} config - Bot configuration (
|
|
1095
|
+
* @param {Object} config - Bot configuration (edge count source)
|
|
1096
1096
|
* @param {string} orderType - ORDER_TYPES.BUY (floor) or SELL (ceiling)
|
|
1097
1097
|
* @param {number|null} [anchorPrice] - Explicit edge anchor (live grid edge);
|
|
1098
1098
|
* callers that picked slots must pass the SAME anchor so no-crawl
|
|
1099
1099
|
* classification matches placement. NB: null/undefined falls back to the
|
|
1100
1100
|
* config-bound anchor (unresolved -> plain rank) — unlike
|
|
1101
|
-
*
|
|
1101
|
+
* selectEdgeSlots, where null alone means plain rank.
|
|
1102
1102
|
* @param {Set<string>|null} [excludeIds] - Windowed ids to skip (same set the
|
|
1103
1103
|
* placement pickers exclude). Window + edge are additive in every target
|
|
1104
1104
|
* (order counts, fees, hold-back), so a window that reaches the grid edge
|
|
1105
1105
|
* (e.g. a keep-low window sitting on the floor) must not let the edge pick
|
|
1106
1106
|
* land on window members — otherwise counting reads N/N with zero
|
|
1107
|
-
* dedicated
|
|
1107
|
+
* dedicated edge orders and the deficit never fires (issue #27 follow-up).
|
|
1108
1108
|
* @returns {Set<string>|null} Edge slot ids, or null when side disabled
|
|
1109
1109
|
*/
|
|
1110
|
-
declare function
|
|
1110
|
+
declare function edgeOrderIdSet(allSlots: SlotLike[], config: OrderConfigView | null | undefined, orderType: OrderType, anchorPrice?: unknown, excludeIds?: Set<string> | null): Set<string> | null;
|
|
1111
1111
|
/**
|
|
1112
1112
|
* Window member ids for one side from the live manager (see
|
|
1113
1113
|
* windowIdSetFromSlots). Delegates so the manager and explicit-geometry
|
|
@@ -1130,29 +1130,29 @@ declare function liveWindowIdSet(manager: OrderManagerLike, orderType: OrderType
|
|
|
1130
1130
|
*
|
|
1131
1131
|
* - CREATE ids of the plan (the slots a fold did not convert into an
|
|
1132
1132
|
* UPDATE), minus
|
|
1133
|
-
* -
|
|
1133
|
+
* - edge-ladder ids. Edge orders are static edge insurance; their fills
|
|
1134
1134
|
* never crawl (deriveTargetBoundary filters them), so a guard-skipped
|
|
1135
|
-
*
|
|
1135
|
+
* edge order must not pin geometry either. Without this exclusion an edge order
|
|
1136
1136
|
* CREATE skipped at the wrong moment (e.g. a floor BUY above the last-fill
|
|
1137
1137
|
* pivot while the market dumps below the grid) would hold the boundary for
|
|
1138
1138
|
* a cycle although nothing was stranded.
|
|
1139
1139
|
*
|
|
1140
|
-
* Absent/disabled
|
|
1141
|
-
* so callers that never configured
|
|
1140
|
+
* Absent/disabled edge orders or an empty action list yield the plain CREATE ids,
|
|
1141
|
+
* so callers that never configured edge orders keep the previous behavior.
|
|
1142
1142
|
*
|
|
1143
1143
|
* @param {Array<Object>} actions - Optimized COW actions
|
|
1144
1144
|
* @param {Object} [options]
|
|
1145
|
-
* @param {Object} [options.config] - Bot configuration (
|
|
1146
|
-
* @param {Iterable<Object>} [options.slots] - Master slots (
|
|
1145
|
+
* @param {Object} [options.config] - Bot configuration (edge count source)
|
|
1146
|
+
* @param {Iterable<Object>} [options.slots] - Master slots (edge classification)
|
|
1147
1147
|
* @param {{buy?: number|null, sell?: number|null}} [options.edgeAnchors] - Live
|
|
1148
|
-
* edge anchors (same pair the strategy classifies
|
|
1148
|
+
* edge anchors (same pair the strategy classifies edge fills against)
|
|
1149
1149
|
* @param {unknown} [options.manager] - OrderManager for the window exclusion (same
|
|
1150
1150
|
* set the placement pickers exclude); omit to fall back to the previous
|
|
1151
1151
|
* exclusion-free classification (fail-open)
|
|
1152
|
-
* @returns {string[]} Refill slot ids (CREATE ids minus
|
|
1152
|
+
* @returns {string[]} Refill slot ids (CREATE ids minus edge ids)
|
|
1153
1153
|
*/
|
|
1154
1154
|
declare function collectRefillSlotIds(actions: CowAction[], options?: {
|
|
1155
|
-
config?:
|
|
1155
|
+
config?: OrderConfigView | null;
|
|
1156
1156
|
slots?: unknown;
|
|
1157
1157
|
edgeAnchors?: {
|
|
1158
1158
|
buy?: number | null;
|
|
@@ -1161,7 +1161,7 @@ declare function collectRefillSlotIds(actions: CowAction[], options?: {
|
|
|
1161
1161
|
manager?: OrderManagerLike | null;
|
|
1162
1162
|
}): string[];
|
|
1163
1163
|
/**
|
|
1164
|
-
* Resolved bound anchor for
|
|
1164
|
+
* Resolved bound anchor for edges from CONFIG alone.
|
|
1165
1165
|
* BUY floor anchors toward minPrice (dip-insurance end), SELL ceiling toward
|
|
1166
1166
|
* maxPrice (spike-insurance end). Resolves numeric and "Nx" relative forms
|
|
1167
1167
|
* via resolveConfiguredPriceBound (startPrice-referenced); falls back to the
|
|
@@ -1169,18 +1169,18 @@ declare function collectRefillSlotIds(actions: CowAction[], options?: {
|
|
|
1169
1169
|
*
|
|
1170
1170
|
* Known limit: this is the statically resolved config bound, not the
|
|
1171
1171
|
* gridPrice/AMA-referenced live rail bound. Placement call sites should use
|
|
1172
|
-
*
|
|
1172
|
+
* resolveLiveEdgeAnchorPrice(manager, side), which prefers the genesis
|
|
1173
1173
|
* ladder extreme and returns null when there is no usable ladder. Callers that
|
|
1174
|
-
* need a fallback (e.g.
|
|
1174
|
+
* need a fallback (e.g. edgeOrderIdSet) still resolve this config bound when
|
|
1175
1175
|
* the live anchor is null; the live resolver itself no longer computes it.
|
|
1176
1176
|
*
|
|
1177
1177
|
* @param {Object} config - Bot configuration
|
|
1178
1178
|
* @param {string} side - 'buy' or 'sell'
|
|
1179
1179
|
* @returns {number|null} Finite anchor price, or null
|
|
1180
1180
|
*/
|
|
1181
|
-
declare function
|
|
1182
|
-
/** Manager surface the live
|
|
1183
|
-
type
|
|
1181
|
+
declare function resolveEdgeAnchorPrice(config: OrderConfigView | null | undefined, side: string): number | null;
|
|
1182
|
+
/** Manager surface the live edge anchor reads (structural view). */
|
|
1183
|
+
type EdgeAnchorManager = {
|
|
1184
1184
|
_genesis?: {
|
|
1185
1185
|
priceLevels?: readonly unknown[];
|
|
1186
1186
|
} | null;
|
|
@@ -1192,7 +1192,7 @@ type ReserveEdgeAnchorManager = {
|
|
|
1192
1192
|
config?: unknown;
|
|
1193
1193
|
};
|
|
1194
1194
|
/**
|
|
1195
|
-
* Live-grid
|
|
1195
|
+
* Live-grid edge anchor (single source for edge placement).
|
|
1196
1196
|
*
|
|
1197
1197
|
* The anchor must come from the geometry the bot is actually trading, never
|
|
1198
1198
|
* from a config value that can be a mode string ("pool"/"book"), a relative
|
|
@@ -1210,7 +1210,7 @@ type ReserveEdgeAnchorManager = {
|
|
|
1210
1210
|
* paper over. The former tiers — the live in-rail slot extreme and the resolved
|
|
1211
1211
|
* config bound — are gone with the legacy matcher they only existed to cover;
|
|
1212
1212
|
* any config-bound fallback is now resolved by the individual consumer that
|
|
1213
|
-
* wants one (see
|
|
1213
|
+
* wants one (see edgeOrderIdSet), not by this live-edge resolver. The fault
|
|
1214
1214
|
* itself is reported
|
|
1215
1215
|
* once per grid generation by the sync-entry gate; this resolver stays silent
|
|
1216
1216
|
* because it is called from per-fill and per-placement paths.
|
|
@@ -1219,9 +1219,9 @@ type ReserveEdgeAnchorManager = {
|
|
|
1219
1219
|
* @param {string} side - 'buy' or 'sell'
|
|
1220
1220
|
* @returns {number|null} Finite anchor price, or null
|
|
1221
1221
|
*/
|
|
1222
|
-
declare function
|
|
1222
|
+
declare function resolveLiveEdgeAnchorPrice(manager: EdgeAnchorManager | null | undefined, side: unknown): number | null;
|
|
1223
1223
|
/**
|
|
1224
|
-
* Shared anchored edge comparator for
|
|
1224
|
+
* Shared anchored edge comparator for edge selection (single source).
|
|
1225
1225
|
* With a finite anchor: in-bound slots first, nearest the anchor first
|
|
1226
1226
|
* (floor ascending, ceiling descending); stale out-of-bound slots last,
|
|
1227
1227
|
* still nearest the anchor first. Without one: plain rank fallback
|
|
@@ -1233,36 +1233,36 @@ declare function resolveLiveReserveEdgeAnchorPrice(manager: ReserveEdgeAnchorMan
|
|
|
1233
1233
|
* @param {number|null} anchorPrice - Resolved bound anchor (null = rank fallback)
|
|
1234
1234
|
* @returns {number} Comparator result for Array.prototype.sort
|
|
1235
1235
|
*/
|
|
1236
|
-
declare function
|
|
1236
|
+
declare function compareEdge(a: SlotLike, b: SlotLike, edge: string, anchorPrice: number | null): number;
|
|
1237
1237
|
/**
|
|
1238
|
-
* Central edge selector: take
|
|
1238
|
+
* Central edge selector: take edge slots from a price-ascending list,
|
|
1239
1239
|
* skipping already-windowed ids. Both edges anchor at the live grid's own
|
|
1240
|
-
* edge (
|
|
1240
|
+
* edge (resolveLiveEdgeAnchorPrice) when finite — floor: nearest
|
|
1241
1241
|
* at/above the live floor first, slots below it rank last; ceiling: nearest
|
|
1242
1242
|
* at/below the live ceiling first, slots above it rank last. Anchoring to the
|
|
1243
|
-
* live edge keeps the
|
|
1243
|
+
* live edge keeps the edge order on genuine live-rail slots when the grid still
|
|
1244
1244
|
* carries leftovers from an older bound or the configured bound disagrees
|
|
1245
1245
|
* with the geometry being traded. Callers pre-filter rail/type and apply
|
|
1246
1246
|
* their own size gates; this only picks positions. A null anchor degrades to
|
|
1247
1247
|
* plain rank (floor: lowest first; ceiling: highest first).
|
|
1248
1248
|
*
|
|
1249
1249
|
* @param {Array<Object>} sortedAsc - Slots sorted by price ascending
|
|
1250
|
-
* @param {number} count -
|
|
1250
|
+
* @param {number} count - Edge count
|
|
1251
1251
|
* @param {Set<string>|null} excludeIds - Windowed ids to skip
|
|
1252
1252
|
* @param {string} edge - 'floor' or 'ceiling'
|
|
1253
1253
|
* @param {number|null} [anchorPrice] - Live edge anchor for the side (null = rank-based)
|
|
1254
|
-
* @returns {Array<Object>}
|
|
1254
|
+
* @returns {Array<Object>} Edge slots (ascending for floor, descending for ceiling)
|
|
1255
1255
|
*/
|
|
1256
|
-
declare function
|
|
1256
|
+
declare function selectEdgeSlots<T extends SlotLike>(sortedAsc: T[], count: number, excludeIds: Set<string> | null, edge: string, anchorPrice?: number | null): T[];
|
|
1257
1257
|
/**
|
|
1258
1258
|
* Total target order count across both sides (used for BTS fee calculation).
|
|
1259
1259
|
* Single source of truth so every budget derivation sizes identically.
|
|
1260
|
-
* Includes per-side
|
|
1260
|
+
* Includes per-side edge orders: they rest live on-chain and pay creation fees.
|
|
1261
1261
|
*
|
|
1262
1262
|
* @param {Object} config - Bot configuration
|
|
1263
1263
|
* @returns {number} Total target order count
|
|
1264
1264
|
*/
|
|
1265
|
-
declare function
|
|
1265
|
+
declare function getCoreOrdersTotal(config: OrderConfigView | null | undefined): number;
|
|
1266
1266
|
/**
|
|
1267
1267
|
* Calculate side budget after BTS fee deduction.
|
|
1268
1268
|
*
|
|
@@ -1272,7 +1272,7 @@ declare function getActiveOrdersTotal(config: ReserveConfig | null | undefined):
|
|
|
1272
1272
|
* @param {number} totalTarget - Total target order count (used for BTS fee calculation on both sides)
|
|
1273
1273
|
* @returns {number} Available budget for the side
|
|
1274
1274
|
*/
|
|
1275
|
-
declare function getSideBudget(side: string, funds: ManagerFundsLike | ProjectedFunds | null, config:
|
|
1275
|
+
declare function getSideBudget(side: string, funds: ManagerFundsLike | ProjectedFunds | null, config: OrderConfigView, totalTarget: number): number;
|
|
1276
1276
|
/**
|
|
1277
1277
|
* Calculate sizes for all slots on a side using weighted distribution.
|
|
1278
1278
|
*
|
|
@@ -1358,6 +1358,6 @@ declare function collectKnownOnChainOrderIds(mgr: OrderManagerLike, placedResult
|
|
|
1358
1358
|
createIds: string[];
|
|
1359
1359
|
all: string[];
|
|
1360
1360
|
};
|
|
1361
|
-
export { parseChainOrder, applyChainSizeToGridOrder, buildFillKey, correctOrderPriceOnChain, correctAllPriceMismatches, _validatePriceCorrectionEntry, _stampCorrectionProvenance, findLiveOrderOwnerByChainId, buildCreateOrderArgs, getOrderTypeFromUpdatedFlags, resolveConfiguredPriceBound, virtualizeOrder, convertToSpreadPlaceholder, toRailHolePlaceholder, geometryTypeForSlotIndex, detectGapEvacuationCandidates, updateGapEvacuationStreaks, resolveSpreadOrderSide, chainOrderMatchesSlot, chainOrderMatchesSlotWithTolerance, crossingCandidateChainId, isCrossingCheckCandidate, buildCrossingCheckCandidates, parseSlotIndex, filterOrdersByType, buildOutsideInPairGroups, extractBatchOperationResults, formatUnmatchedChainOrder, isNonBlockingUnmatchedOrder, isStrandedHoldOrder, isOrderOnChain, isOrderVirtual, hasOnChainId, isOrderPlaced, isPhantomOrder, isSlotAvailable, isEmptyGridSlot, isOrderHealthy, checkSizeThreshold, checkSizesBeforeMinimum, calculateIdealBoundary, assignGridRoles, resolveOnChainRetypeType, shouldFlagOutOfSpread, buildIndexes, validateIndexes, ordersEqual, buildDelta, deriveTargetBoundary, isShiftEligibleFill,
|
|
1362
|
-
export {
|
|
1361
|
+
export { parseChainOrder, applyChainSizeToGridOrder, buildFillKey, correctOrderPriceOnChain, correctAllPriceMismatches, _validatePriceCorrectionEntry, _stampCorrectionProvenance, findLiveOrderOwnerByChainId, buildCreateOrderArgs, getOrderTypeFromUpdatedFlags, resolveConfiguredPriceBound, virtualizeOrder, convertToSpreadPlaceholder, toRailHolePlaceholder, geometryTypeForSlotIndex, detectGapEvacuationCandidates, updateGapEvacuationStreaks, resolveSpreadOrderSide, chainOrderMatchesSlot, chainOrderMatchesSlotWithTolerance, crossingCandidateChainId, isCrossingCheckCandidate, buildCrossingCheckCandidates, parseSlotIndex, filterOrdersByType, buildOutsideInPairGroups, extractBatchOperationResults, formatUnmatchedChainOrder, isNonBlockingUnmatchedOrder, isStrandedHoldOrder, isOrderOnChain, isOrderVirtual, hasOnChainId, isOrderPlaced, isPhantomOrder, isSlotAvailable, isEmptyGridSlot, isOrderHealthy, checkSizeThreshold, checkSizesBeforeMinimum, calculateIdealBoundary, assignGridRoles, resolveOnChainRetypeType, shouldFlagOutOfSpread, buildIndexes, validateIndexes, ordersEqual, buildDelta, deriveTargetBoundary, isShiftEligibleFill, resolveEdgeCount, resolveEdgeOrders, selectEdgeSlots, getCoreOrdersTotal, getSideBudget, calculateBudgetedSizes, buildCreateOpFingerprint, isOrderGoneErrorMessage, recordDuplicateOrphanDetection, clearDuplicateOrphanDetection, duplicateOrphanLogInfo, chainOrderUnchangedFromCache, detectCrossedBookPlan, collectKnownOnChainOrderIds, edgeOrderIdSet, liveWindowIdSet, checkGridPriceInvariant, reportGridPriceInvariant };
|
|
1362
|
+
export { resolveEdgeAnchorPrice, resolveLiveEdgeAnchorPrice, compareEdge, collectRefillSlotIds, recordOrderPlacement, isFreshlyPlacedOrder, _filterUnmatchedChainOrders };
|
|
1363
1363
|
//# sourceMappingURL=order.d.ts.map
|