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
|
@@ -21,7 +21,7 @@ import * as chainOrdersModule from './chain_orders.js';
|
|
|
21
21
|
export declare function isEvacuationStampStillValid(liveBoundary: unknown, liveGapSlots: unknown, sourceId: unknown, destId: unknown, orderType: unknown): boolean;
|
|
22
22
|
import * as workingGridModule from './order/working_grid.js';
|
|
23
23
|
declare const WorkingGrid: typeof workingGridModule.WorkingGrid;
|
|
24
|
-
import type { BotLike, OrderManagerLike, ManagedOrder, ChainOrder, UnknownRecord,
|
|
24
|
+
import type { BotLike, OrderManagerLike, ManagedOrder, ChainOrder, UnknownRecord, CowAction } from './types.js';
|
|
25
25
|
/** Loose JSON-object view. */
|
|
26
26
|
type JsonObj = UnknownRecord;
|
|
27
27
|
/** Final integer tuple for a planned order op. */
|
|
@@ -58,18 +58,6 @@ export interface CowResult extends JsonObj {
|
|
|
58
58
|
refillSlotIds?: string[];
|
|
59
59
|
fills?: unknown[];
|
|
60
60
|
}
|
|
61
|
-
/** Result of the pre-broadcast guard chain. */
|
|
62
|
-
export interface PreBroadcastGuardResult extends JsonObj {
|
|
63
|
-
proceed: boolean;
|
|
64
|
-
result?: JsonObj;
|
|
65
|
-
crossingCandidates?: unknown[];
|
|
66
|
-
intraBatchCandidates?: unknown[];
|
|
67
|
-
}
|
|
68
|
-
/** A CREATE op context with its resolved order + integer tuple. */
|
|
69
|
-
type CreateContext = OpPhase & {
|
|
70
|
-
finalInts: FinalInts;
|
|
71
|
-
order: ManagedOrder;
|
|
72
|
-
};
|
|
73
61
|
/** A chain order enriched with the loose fields COW recovery reads. */
|
|
74
62
|
export interface ChainOrderLike extends ChainOrder {
|
|
75
63
|
type?: unknown;
|
|
@@ -83,14 +71,6 @@ export interface ChainOrderLike extends ChainOrder {
|
|
|
83
71
|
price?: unknown;
|
|
84
72
|
order?: JsonObj;
|
|
85
73
|
}
|
|
86
|
-
/** Normalized integer tuple used by pending-broadcast recovery. */
|
|
87
|
-
interface NormalizedChainOrder {
|
|
88
|
-
side: string;
|
|
89
|
-
assetA: string;
|
|
90
|
-
assetB: string;
|
|
91
|
-
sellInt: number;
|
|
92
|
-
receiveInt: number;
|
|
93
|
-
}
|
|
94
74
|
/** A COW operation context (create/update/cancel/rotation). */
|
|
95
75
|
export interface OpPhase extends JsonObj {
|
|
96
76
|
kind?: unknown;
|
|
@@ -112,24 +92,6 @@ declare function buildOutsideInPairGroupsForOrders(orders: ManagedOrder[]): unkn
|
|
|
112
92
|
* @returns {Array<Array>}
|
|
113
93
|
*/
|
|
114
94
|
declare function buildOutsideInPairGroupsForCreateEntries(createEntries: PendingEntry[]): unknown[][];
|
|
115
|
-
/**
|
|
116
|
-
* Extract operation results from a batch transaction result.
|
|
117
|
-
* @param {Object|Array|null} result
|
|
118
|
-
* @param {string} [warnContext='']
|
|
119
|
-
* @param {Function} [logFn] - Optional logger function, called with (msg, level) on unrecognized shape
|
|
120
|
-
* @returns {Array}
|
|
121
|
-
*/
|
|
122
|
-
declare function extractOperationResults(result: unknown, warnContext?: string, logFn?: ((message: string, level?: string) => void) | null): unknown[];
|
|
123
|
-
/**
|
|
124
|
-
* Find CREATE operation contexts whose broadcast result did not include a chain order id.
|
|
125
|
-
* @param {Array} operationResults
|
|
126
|
-
* @param {Array} opContexts
|
|
127
|
-
* @returns {Array<{index:number, ctx:Object}>}
|
|
128
|
-
*/
|
|
129
|
-
declare function findMissingCreateResultContexts(operationResults: unknown, opContexts: unknown): {
|
|
130
|
-
index: number;
|
|
131
|
-
ctx: OpPhase;
|
|
132
|
-
}[];
|
|
133
95
|
/**
|
|
134
96
|
* Merge missing CREATE result contexts into manager._lastUnmatchedChainOrders.
|
|
135
97
|
* @param {import('./dexbot_class.js').DEXBot} bot
|
|
@@ -165,21 +127,6 @@ declare function recordPendingBroadcast(bot: BotLike, entry: PendingEntry & {
|
|
|
165
127
|
* @param {Map} pendingBroadcasts
|
|
166
128
|
*/
|
|
167
129
|
declare function clearPendingBroadcasts(pendingBroadcasts: unknown): void;
|
|
168
|
-
/**
|
|
169
|
-
* Drop only the pending-broadcast entries for the given CREATE slots.
|
|
170
|
-
*
|
|
171
|
-
* Used by the re-plan path: the original plan's ops are abandoned with its
|
|
172
|
-
* working grid, so their pending entries must not trip the recursion's own
|
|
173
|
-
* pending-broadcast guard. Entries recorded by an EARLIER unresolved batch
|
|
174
|
-
* (different slots) are KEPT — clearing them here would let the fresh plan
|
|
175
|
-
* re-create slots whose earlier uncertain broadcast may have landed
|
|
176
|
-
* (duplicate orders). The batch-entry guard only fires for batches WITH
|
|
177
|
-
* CREATE actions, so a create-less batch can reach the re-plan path while
|
|
178
|
-
* earlier entries are still live.
|
|
179
|
-
* @param {import('./dexbot_class.js').DEXBot} bot
|
|
180
|
-
* @param {Array} actions - The abandoned batch's actions (COW_ACTIONS)
|
|
181
|
-
*/
|
|
182
|
-
declare function clearPendingBroadcastsForSlots(bot: BotLike, actions: JsonObj[]): void;
|
|
183
130
|
/**
|
|
184
131
|
* Pop a pushed working-grid stack entry exactly once, guarded on the push
|
|
185
132
|
* marker (manager-owned discipline — see OrderManager._pushWorkingGridRef /
|
|
@@ -191,23 +138,6 @@ declare function clearPendingBroadcastsForSlots(bot: BotLike, actions: JsonObj[]
|
|
|
191
138
|
* @param {Object} cowResult - Rebalance/COW result carrying _workingGridPushed
|
|
192
139
|
*/
|
|
193
140
|
declare function popPushedWorkingGrid(bot: BotLike, cowResult: JsonObj): void;
|
|
194
|
-
/**
|
|
195
|
-
* Build a fingerprint for an on-chain order so it can be matched against
|
|
196
|
-
* the pending-broadcast cache.
|
|
197
|
-
* @param {import('./dexbot_class.js').DEXBot} bot
|
|
198
|
-
* @param {Object} chainOrder
|
|
199
|
-
* @param {string} slotId
|
|
200
|
-
* @returns {string|null}
|
|
201
|
-
*/
|
|
202
|
-
declare function buildChainOrderFingerprint(bot: BotLike, chainOrder: ChainOrderLike, slotId: string): string | null;
|
|
203
|
-
/**
|
|
204
|
-
* Normalize raw BitShares limit_order_object data into the integer tuple
|
|
205
|
-
* used by pending-broadcast recovery.
|
|
206
|
-
* @param {import('./dexbot_class.js').DEXBot} bot
|
|
207
|
-
* @param {Object} chainOrder
|
|
208
|
-
* @returns {{side: string, assetA: string, assetB: string, sellInt: number, receiveInt: number}|null}
|
|
209
|
-
*/
|
|
210
|
-
declare function normalizeChainOrderForPendingMatch(bot: BotLike, chainOrder: ChainOrderLike): NormalizedChainOrder | null;
|
|
211
141
|
/**
|
|
212
142
|
* Find a chain order that matches a planned slot using price+size proximity.
|
|
213
143
|
* @param {import('./dexbot_class.js').DEXBot} bot
|
|
@@ -248,27 +178,6 @@ declare function reconcileAfterUncertainBroadcast(bot: BotLike, err: unknown, op
|
|
|
248
178
|
* @returns {Promise<number>} discardedCount
|
|
249
179
|
*/
|
|
250
180
|
declare function restoreDiscardedCreates(bot: BotLike, discarded: PendingEntry[], opContexts: OpPhase[]): Promise<number>;
|
|
251
|
-
/**
|
|
252
|
-
* Reconcile a broadcast whose chain state is unknown (implementation).
|
|
253
|
-
* @param {import('./dexbot_class.js').DEXBot} bot
|
|
254
|
-
* @param {BroadcastUncertainError} err
|
|
255
|
-
* @param {Array<Object>} opContexts
|
|
256
|
-
* @param {Object} options
|
|
257
|
-
* @returns {Promise<Object>}
|
|
258
|
-
*/
|
|
259
|
-
declare function reconcileAfterUncertainBroadcastImpl(bot: BotLike, err: unknown, opContexts: OpPhase[], _options: JsonObj): Promise<UnknownRecord | {
|
|
260
|
-
executed: boolean;
|
|
261
|
-
hadRotation: boolean;
|
|
262
|
-
uncertain: boolean;
|
|
263
|
-
ambiguousRead: boolean;
|
|
264
|
-
}>;
|
|
265
|
-
/**
|
|
266
|
-
* Check whether to execute creates in outside-in pair mode.
|
|
267
|
-
* @param {import('./dexbot_class.js').DEXBot} bot
|
|
268
|
-
* @param {Array} opContexts
|
|
269
|
-
* @returns {boolean}
|
|
270
|
-
*/
|
|
271
|
-
declare function shouldExecuteCreatePairMode(_bot: unknown, opContexts: OpPhase[]): boolean;
|
|
272
181
|
/**
|
|
273
182
|
* Execute operations with retry on BroadcastUncertainError.
|
|
274
183
|
*
|
|
@@ -337,42 +246,6 @@ declare function executeChunkedWithRetryOnUncertain(bot: BotLike, operations: un
|
|
|
337
246
|
result: unknown;
|
|
338
247
|
opContexts: OpPhase[];
|
|
339
248
|
}>;
|
|
340
|
-
/**
|
|
341
|
-
* Validate that operations can be executed with available funds before broadcasting.
|
|
342
|
-
* @param {import('./dexbot_class.js').DEXBot} bot
|
|
343
|
-
* @param {Array} operations
|
|
344
|
-
* @param {Object} assetA
|
|
345
|
-
* @param {Object} assetB
|
|
346
|
-
* @returns {Object} { isValid: boolean, summary: string }
|
|
347
|
-
*/
|
|
348
|
-
declare function validateOperationFunds(bot: BotLike, operations: JsonObj[], assetA: AssetInfo, assetB: AssetInfo): {
|
|
349
|
-
isValid: boolean;
|
|
350
|
-
summary: string;
|
|
351
|
-
violations?: JsonObj[];
|
|
352
|
-
};
|
|
353
|
-
/**
|
|
354
|
-
* Resolve the ideal size from an order-like object with fallback.
|
|
355
|
-
* @param {import('./dexbot_class.js').DEXBot} bot
|
|
356
|
-
* @param {Object|null} orderLike
|
|
357
|
-
* @param {number|null} [fallbackSize=null]
|
|
358
|
-
* @returns {number|null}
|
|
359
|
-
*/
|
|
360
|
-
declare function resolveIdealSizeForValidation(_bot: unknown, orderLike: JsonObj | null | undefined, fallbackSize?: number | null): number | null;
|
|
361
|
-
/**
|
|
362
|
-
* Validate that an order size is safe to execute.
|
|
363
|
-
* @param {import('./dexbot_class.js').DEXBot} bot
|
|
364
|
-
* @param {number} size
|
|
365
|
-
* @param {string} type
|
|
366
|
-
* @param {Object|null} [orderLike=null]
|
|
367
|
-
* @param {number|null} [fallbackSize=null]
|
|
368
|
-
* @returns {unknown}
|
|
369
|
-
*/
|
|
370
|
-
declare function validateOrderSizeForExecution(bot: BotLike, size: number, type: string, orderLike?: JsonObj | null, fallbackSize?: number | null): {
|
|
371
|
-
isValid: boolean;
|
|
372
|
-
reason: string | null;
|
|
373
|
-
minAbsoluteSize: number;
|
|
374
|
-
minDustSize: number | null;
|
|
375
|
-
};
|
|
376
249
|
declare function checkGridPriceInvariant(slotId: unknown, price: unknown, genesis: unknown): {
|
|
377
250
|
ok: boolean;
|
|
378
251
|
reason: string;
|
|
@@ -395,10 +268,47 @@ declare function checkGridPriceInvariant(slotId: unknown, price: unknown, genesi
|
|
|
395
268
|
* planned price — an undefined grid, which the load and sync gates refuse).
|
|
396
269
|
*/
|
|
397
270
|
declare function deriveRotationPrice(bot: BotLike, newGridId: unknown): number;
|
|
271
|
+
/**
|
|
272
|
+
* P2 observability (advisory, never blocks): count a BUY emitted at or above
|
|
273
|
+
* the last filled BUY pivot.
|
|
274
|
+
*
|
|
275
|
+
* This is the "re-stamp a just-filled BUY above the anchor" shape the
|
|
276
|
+
* LAST-FILL-GUARD exists to block (`BUY > pivot*(1-half)`), so a counted
|
|
277
|
+
* emission means the guard was bypassed (spread correction / stamped gap
|
|
278
|
+
* evacuation) or the pivot was unjudgeable and the probe failed open. The
|
|
279
|
+
* counter makes a bypass leak visible without changing placement policy —
|
|
280
|
+
* the guard already owns enforcement, and turning this into a second gate
|
|
281
|
+
* would re-introduce the reverted placement-guard class.
|
|
282
|
+
*
|
|
283
|
+
* Warns at most once per batch (keyed on `_currentCycleId`). Never throws.
|
|
284
|
+
*
|
|
285
|
+
* @returns {boolean} true when the emission was counted
|
|
286
|
+
*/
|
|
287
|
+
declare function recordRestampBuyAboveAnchor(bot: BotLike, price: unknown, type: unknown): boolean;
|
|
288
|
+
/**
|
|
289
|
+
* Collect non-spread-correction CREATE/UPDATE destinations that sit inside
|
|
290
|
+
* the plan's gap band.
|
|
291
|
+
*
|
|
292
|
+
* Mode C(a) SHADOW: the gap band is not unconditionally illegal — spread
|
|
293
|
+
* correction legitimately places INTO it (the LAST-FILL-GUARD bypass exists
|
|
294
|
+
* for exactly that) and gap evacuation moves an order OUT of it. Excluding
|
|
295
|
+
* those origins leaves the genuinely suspicious set: a rail placement whose
|
|
296
|
+
* destination geometry IS the spread. The result is counted/warned, never
|
|
297
|
+
* blocked (see the guard call site for the revert-history rationale).
|
|
298
|
+
*
|
|
299
|
+
* Pure and never throws. A non-finite boundary/gap selects the empty set.
|
|
300
|
+
*
|
|
301
|
+
* @param {Array<Object>|null} actions - COW actions
|
|
302
|
+
* @param {unknown} boundary - The PLAN's boundary (workingBoundary), not the committed one
|
|
303
|
+
* @param {unknown} gapSlots - Gap slot count
|
|
304
|
+
* @returns {string[]} destinations inside the gap band
|
|
305
|
+
*/
|
|
306
|
+
declare function collectGapBandPlacementShadowSlots(actions: CowAction[] | null | undefined, boundary: unknown, gapSlots: unknown): string[];
|
|
398
307
|
/**
|
|
399
308
|
* LAST-FILL-GUARD helper — pivot ± halfIncrement (replaces price-tolerance).
|
|
400
|
-
* last fill @x with increment i
|
|
401
|
-
*
|
|
309
|
+
* last fill @x with increment i (blocked shapes): BUY > x*(1 - i/2/100),
|
|
310
|
+
* SELL < x*(1 + i/2/100)
|
|
311
|
+
* e.g. x=1000, i=0.5% => BUY > 997.5 and SELL < 1002.5 are blocked
|
|
402
312
|
* Cold (pivot null or lastType null) => disabled. Spread-correction CREATES
|
|
403
313
|
* bypass per-action (see broadcast sites); gap-evacuation rotation UPDATEs
|
|
404
314
|
* bypass only via the violation-reducing allowance (origin='gap-evacuation',
|
|
@@ -421,6 +331,26 @@ declare function isLastFillGuardBlocked(price: number, _size: number, type: unkn
|
|
|
421
331
|
halfInc?: number;
|
|
422
332
|
threshold?: number | null;
|
|
423
333
|
};
|
|
334
|
+
/**
|
|
335
|
+
* Whether a spread-correction CREATE may bypass the LAST-FILL-GUARD.
|
|
336
|
+
*
|
|
337
|
+
* The bypass exists so gap repair can close even after a recent fill (the
|
|
338
|
+
* correction is tightening the spread, not chasing it). It must not become a
|
|
339
|
+
* licence to place THROUGH the market the bot last traded at:
|
|
340
|
+
*
|
|
341
|
+
* 1. A real fill pivot (`lastFillPivotSource === 'fill'`) is always honored —
|
|
342
|
+
* no bypass. A sell below the last fill (or a buy above it) is the
|
|
343
|
+
* issue-#31 adverse fill.
|
|
344
|
+
* 2. A cold/book pivot is a heuristic (book seed) or absent, so the historical
|
|
345
|
+
* fail-open bypass is kept — but only while the LOCAL snapshot is fresh.
|
|
346
|
+
* A stale snapshot (known-unmatched chain orders, or an old sync) can hide
|
|
347
|
+
* the real window edge, so the bypass is withheld and the guard applies.
|
|
348
|
+
*
|
|
349
|
+
* Exported for tests.
|
|
350
|
+
* @param {Object} bot
|
|
351
|
+
* @returns {boolean} True when the bypass may be used
|
|
352
|
+
*/
|
|
353
|
+
declare function isSpreadCorrectionBypassAllowed(bot: BotLike): boolean;
|
|
424
354
|
/**
|
|
425
355
|
* Refresh the LAST-FILL guard pivot from fills that arrived while the current
|
|
426
356
|
* batch was being planned or broadcast but have not been ingested yet.
|
|
@@ -462,28 +392,6 @@ declare function buildCowResultFromPlan(bot: BotLike, plan: JsonObj): CowResult;
|
|
|
462
392
|
* in-place rotations already have their size/price changes in the working grid.
|
|
463
393
|
*/
|
|
464
394
|
declare function applyRotationTransitionsToWorkingGrid(bot: BotLike, workingGrid: InstanceType<typeof WorkingGrid>, executedContexts: OpPhase[]): void;
|
|
465
|
-
/**
|
|
466
|
-
* Poll the chain after an uncertain broadcast to check if CREATE operations
|
|
467
|
-
* were actually accepted. Uses fingerprint matching against readOpenOrders.
|
|
468
|
-
* Falls back to reconciliation if polling cannot confirm within retries.
|
|
469
|
-
*
|
|
470
|
-
* We specifically confirm CREATE operations because they leave a detectable
|
|
471
|
-
* footprint on the chain (new order with matching fingerprint). UPDATEs and
|
|
472
|
-
* CANCELs modify existing orders and cannot be reliably distinguished from
|
|
473
|
-
* "not yet visible" state by simple polling.
|
|
474
|
-
*
|
|
475
|
-
* @param {Object} [options]
|
|
476
|
-
* @param {number} [options.maxPollRetries] - Poll attempts before reconciliation fallback
|
|
477
|
-
* @param {number} [options.pollIntervalMs] - Delay between polls; tests pass 0
|
|
478
|
-
* to skip the production 1.5s pacing without changing the poll semantics
|
|
479
|
-
* @returns {{ allConfirmed: boolean, confirmed: Array, unconfirmed: Array }}
|
|
480
|
-
*/
|
|
481
|
-
declare function pollChainForConfirmation(bot: BotLike, opContexts: OpPhase[], options?: JsonObj): Promise<{
|
|
482
|
-
allConfirmed: boolean;
|
|
483
|
-
confirmed: CreateContext[];
|
|
484
|
-
unconfirmed: OpPhase[];
|
|
485
|
-
confirmedChainIds: string[];
|
|
486
|
-
}>;
|
|
487
395
|
/**
|
|
488
396
|
* Normalize a producer-supplied refillSlotIds wire into a Set.
|
|
489
397
|
* Absent/empty/non-array => empty (guarded default, never fail-open).
|
|
@@ -528,14 +436,6 @@ declare function resolveRefillBoundaryHold(workingBoundary: unknown, committedBo
|
|
|
528
436
|
* @returns {number} Consecutive-hold count after this batch (0 when clear)
|
|
529
437
|
*/
|
|
530
438
|
declare function trackBoundaryHold(manager: OrderManagerLike, held: boolean, keptBoundary: unknown, plannedBoundary: unknown, heldSlotIds: string[]): number;
|
|
531
|
-
/**
|
|
532
|
-
* Restore skipped update slots in the working grid to master state.
|
|
533
|
-
* @param {import('./dexbot_class.js').DEXBot} bot
|
|
534
|
-
* @param {unknown} workingGrid
|
|
535
|
-
* @param {Set<string>} skippedSlotIds
|
|
536
|
-
* @param {number} [skippedCount=0]
|
|
537
|
-
*/
|
|
538
|
-
declare function restoreSkippedUpdateSlotsInWorkingGrid(bot: BotLike, workingGrid: InstanceType<typeof WorkingGrid>, skippedSlotIds: Set<string> | null | undefined, skippedCount?: number): void;
|
|
539
439
|
declare function updateOrdersOnChainBatchCOW(bot: BotLike, cowResult: CowResult, options?: JsonObj): Promise<JsonObj>;
|
|
540
440
|
declare function adoptPlacedBatchFromChain(bot: BotLike, chainOrders: typeof chainOrdersModule, logPrefix: string, opts?: JsonObj): Promise<boolean>;
|
|
541
441
|
/**
|
|
@@ -648,42 +548,23 @@ declare function processBatchResults(bot: BotLike, result: JsonObj, opContexts:
|
|
|
648
548
|
hadRotation: boolean;
|
|
649
549
|
updateOperationCount: number;
|
|
650
550
|
}>;
|
|
651
|
-
export { isLastFillGuardBlocked, resolveOnGridPivot, checkGridPriceInvariant, deriveRotationPrice, refreshLastFillPivotFromQueue, runFinalPivotGate, buildOutsideInPairGroupsForOrders, buildOutsideInPairGroupsForCreateEntries, markMissingCreateResultsAsStructuralBlocker, formatUnmatchedChainOrderForLog, recordPendingBroadcast, clearPendingBroadcasts, popPushedWorkingGrid, findChainOrderForSlot, reconcileAfterUncertainBroadcast,
|
|
551
|
+
export { isSpreadCorrectionBypassAllowed, isLastFillGuardBlocked, resolveOnGridPivot, checkGridPriceInvariant, recordRestampBuyAboveAnchor, collectGapBandPlacementShadowSlots, deriveRotationPrice, refreshLastFillPivotFromQueue, runFinalPivotGate, buildOutsideInPairGroupsForOrders, buildOutsideInPairGroupsForCreateEntries, markMissingCreateResultsAsStructuralBlocker, formatUnmatchedChainOrderForLog, recordPendingBroadcast, clearPendingBroadcasts, popPushedWorkingGrid, findChainOrderForSlot, reconcileAfterUncertainBroadcast, executeWithRetryOnUncertain, executeChunkedWithRetryOnUncertain, formatPartialBroadcastSummary, buildActionsFromPlan, buildCowResultFromPlan, applyRotationTransitionsToWorkingGrid, updateOrdersOnChainBatchCOW, processBatchResults, adoptPlacedBatchFromChain, resolveRefillBoundaryHold, toRefillSlotIdSet, trackBoundaryHold };
|
|
652
552
|
export { restoreDiscardedCreates };
|
|
653
553
|
declare const _default: {
|
|
654
554
|
buildOutsideInPairGroupsForOrders: typeof buildOutsideInPairGroupsForOrders;
|
|
655
555
|
buildOutsideInPairGroupsForCreateEntries: typeof buildOutsideInPairGroupsForCreateEntries;
|
|
656
|
-
extractOperationResults: typeof extractOperationResults;
|
|
657
|
-
findMissingCreateResultContexts: typeof findMissingCreateResultContexts;
|
|
658
556
|
markMissingCreateResultsAsStructuralBlocker: typeof markMissingCreateResultsAsStructuralBlocker;
|
|
659
557
|
formatUnmatchedChainOrderForLog: typeof formatUnmatchedChainOrderForLog;
|
|
660
558
|
recordPendingBroadcast: typeof recordPendingBroadcast;
|
|
661
559
|
clearPendingBroadcasts: typeof clearPendingBroadcasts;
|
|
662
|
-
clearPendingBroadcastsForSlots: typeof clearPendingBroadcastsForSlots;
|
|
663
|
-
popPushedWorkingGrid: typeof popPushedWorkingGrid;
|
|
664
|
-
buildChainOrderFingerprint: typeof buildChainOrderFingerprint;
|
|
665
|
-
normalizeChainOrderForPendingMatch: typeof normalizeChainOrderForPendingMatch;
|
|
666
560
|
findChainOrderForSlot: typeof findChainOrderForSlot;
|
|
667
561
|
reconcileAfterUncertainBroadcast: typeof reconcileAfterUncertainBroadcast;
|
|
668
|
-
reconcileAfterUncertainBroadcastImpl: typeof reconcileAfterUncertainBroadcastImpl;
|
|
669
|
-
shouldExecuteCreatePairMode: typeof shouldExecuteCreatePairMode;
|
|
670
562
|
executeWithRetryOnUncertain: typeof executeWithRetryOnUncertain;
|
|
671
563
|
executeChunkedWithRetryOnUncertain: typeof executeChunkedWithRetryOnUncertain;
|
|
672
|
-
|
|
673
|
-
validateOperationFunds: typeof validateOperationFunds;
|
|
674
|
-
resolveIdealSizeForValidation: typeof resolveIdealSizeForValidation;
|
|
675
|
-
validateOrderSizeForExecution: typeof validateOrderSizeForExecution;
|
|
676
|
-
buildActionsFromPlan: typeof buildActionsFromPlan;
|
|
564
|
+
popPushedWorkingGrid: typeof popPushedWorkingGrid;
|
|
677
565
|
buildCowResultFromPlan: typeof buildCowResultFromPlan;
|
|
678
|
-
restoreSkippedUpdateSlotsInWorkingGrid: typeof restoreSkippedUpdateSlotsInWorkingGrid;
|
|
679
|
-
resolveRefillBoundaryHold: typeof resolveRefillBoundaryHold;
|
|
680
|
-
toRefillSlotIdSet: typeof toRefillSlotIdSet;
|
|
681
|
-
trackBoundaryHold: typeof trackBoundaryHold;
|
|
682
|
-
applyRotationTransitionsToWorkingGrid: typeof applyRotationTransitionsToWorkingGrid;
|
|
683
|
-
pollChainForConfirmation: typeof pollChainForConfirmation;
|
|
684
566
|
updateOrdersOnChainBatchCOW: typeof updateOrdersOnChainBatchCOW;
|
|
685
567
|
processBatchResults: typeof processBatchResults;
|
|
686
|
-
runFinalPivotGate: typeof runFinalPivotGate;
|
|
687
568
|
};
|
|
688
569
|
export default _default;
|
|
689
570
|
//# sourceMappingURL=dexbot_cow_runtime.d.ts.map
|