dexbot 1.6.17 → 1.6.18
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 +32 -0
- package/analysis/README.md +10 -9
- package/analysis/ama_fitting/README.md +2 -2
- package/analysis/bot_fitting/README.md +3 -3
- 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/analyze_args.d.ts +2 -1
- package/dist/analysis/fills_source.d.ts +1 -8
- package/dist/analysis/fills_source.js +1 -1
- package/dist/analysis/grid_correction_check.d.ts +9 -6
- package/dist/analysis/grid_correction_check.js +56 -64
- package/dist/analysis/math_utils.d.ts +1 -1
- package/dist/analysis/trade_profitability.d.ts +1 -1
- package/dist/analysis/tradingview/tradingview_uplot_chart_generator.js +3 -3
- package/dist/analysis/trend_detection/huber_scale_variants.d.ts +4 -3
- package/dist/market_adapter/cli_args.d.ts +6 -1
- package/dist/market_adapter/cli_args.js +16 -2
- package/dist/market_adapter/core/kibana_candles.d.ts +5 -1
- package/dist/market_adapter/core/kibana_candles.js +3 -1
- package/dist/market_adapter/core/strategies/regime_gate.d.ts +7 -1
- package/dist/market_adapter/core/strategies/regime_gate.js +3 -1
- package/dist/market_adapter/inputs/cex_candle_parsing.d.ts +7 -2
- package/dist/market_adapter/inputs/cex_candle_parsing.js +3 -1
- package/dist/market_adapter/inputs/fetch_book_data.d.ts +7 -1
- package/dist/market_adapter/inputs/fetch_book_data.js +3 -1
- package/dist/market_adapter/inputs/fetch_cex_synthetic_data.js +2 -11
- package/dist/market_adapter/inputs/fetch_lp_data.d.ts +26 -1
- package/dist/market_adapter/inputs/fetch_lp_data.js +62 -52
- package/dist/market_adapter/inputs/kibana_feed_source.d.ts +14 -2
- package/dist/market_adapter/inputs/kibana_feed_source.js +14 -1
- package/dist/market_adapter/inputs/window_cache.d.ts +14 -3
- package/dist/market_adapter/inputs/window_cache.js +14 -1
- package/dist/market_adapter/lp_chart_runner.d.ts +12 -9
- package/dist/market_adapter/lp_chart_runner.js +3 -1
- package/dist/market_adapter/lp_chart_strategy_loader.d.ts +5 -1
- package/dist/market_adapter/lp_chart_strategy_loader.js +3 -1
- package/dist/market_adapter/market_adapter.d.ts +10 -2
- package/dist/market_adapter/market_adapter.js +10 -11
- package/dist/market_adapter/utils/chain.d.ts +2 -3
- package/dist/market_adapter/utils/file_json_cache.d.ts +5 -1
- package/dist/market_adapter/utils/file_json_cache.js +3 -1
- package/dist/market_adapter/utils/file_lock.js +1 -1
- package/dist/market_adapter/utils/native_history.d.ts +7 -3
- package/dist/market_adapter/utils/native_history.js +3 -1
- package/dist/market_adapter/utils/pair_orientation.d.ts +2 -2
- package/dist/modules/bots_file_lock.d.ts +2 -2
- package/dist/modules/bots_file_lock.js +2 -2
- package/dist/modules/constants.js +6 -3
- package/dist/modules/dexbot_class.d.ts +8 -0
- package/dist/modules/dexbot_class.js +10 -0
- package/dist/modules/dexbot_cow_runtime.d.ts +62 -1
- package/dist/modules/dexbot_cow_runtime.js +461 -43
- package/dist/modules/dexbot_credential_client.d.ts +5 -0
- package/dist/modules/dexbot_maintenance_runtime.js +56 -9
- package/dist/modules/dexbot_startup_runtime.js +7 -1
- package/dist/modules/graceful_shutdown.d.ts +2 -2
- package/dist/modules/graceful_shutdown.js +2 -2
- package/dist/modules/launcher/runtime_mode.d.ts +4 -3
- package/dist/modules/node_manager.d.ts +1 -1
- package/dist/modules/node_manager.js +1 -1
- package/dist/modules/order/accounting.js +2 -1
- package/dist/modules/order/export.d.ts +2 -2
- package/dist/modules/order/export.js +2 -2
- package/dist/modules/order/grid.d.ts +19 -14
- package/dist/modules/order/grid.js +262 -61
- package/dist/modules/order/grid_reconcile.js +5 -1
- package/dist/modules/order/grid_reconcile_internal.js +2 -1
- package/dist/modules/order/index.d.ts +9 -3
- package/dist/modules/order/manager.d.ts +10 -0
- package/dist/modules/order/manager.js +41 -11
- package/dist/modules/order/strategy.js +22 -2
- package/dist/modules/order/sync_engine.d.ts +12 -1
- package/dist/modules/order/sync_engine.js +135 -20
- package/dist/modules/order/utils/math.d.ts +8 -9
- package/dist/modules/order/utils/math.js +24 -13
- package/dist/modules/order/utils/order.d.ts +52 -11
- package/dist/modules/order/utils/order.js +137 -21
- package/dist/modules/order/utils/system.d.ts +73 -29
- package/dist/modules/order/utils/system.js +239 -48
- package/dist/modules/order/utils/validate.d.ts +1 -0
- package/dist/modules/order/utils/validate.js +4 -1
- package/dist/modules/storage/index.d.ts +3 -2
- package/dist/modules/storage/index.js +3 -2
- package/dist/modules/types.d.ts +9 -0
- package/docs/COPY_ON_WRITE_MASTER_PLAN.md +1 -1
- package/docs/COW_INVARIANTS.md +20 -10
- package/docs/DEXBOT_COMPARISON.md +5 -5
- package/docs/EVOLUTION.md +9 -8
- package/docs/FUND_MOVEMENT_AND_ACCOUNTING.md +11 -11
- package/docs/GRID_PRICE_INVARIANT.md +24 -4
- package/docs/GRID_RECONCILE.md +5 -5
- package/docs/LIFECYCLE.md +11 -11
- package/docs/LOGGING.md +15 -2
- package/docs/ORDER_ENGINE_POST_1.0_RETROSPECTIVE.md +123 -36
- package/docs/README.md +1 -1
- package/docs/architecture.md +115 -13
- package/docs/developer_guide.md +12 -0
- package/market_adapter/README.md +9 -4
- package/modules/README.md +18 -14
- package/package.json +4 -3
|
@@ -1037,16 +1037,7 @@ async function fetchNativeMarketHistorySince(assetA, assetB, sinceMs, untilMs, i
|
|
|
1037
1037
|
}
|
|
1038
1038
|
const startDate = new Date(Number.isFinite(sinceMs) ? sinceMs : Date.now());
|
|
1039
1039
|
const stopDate = new Date(Number.isFinite(untilMs) ? untilMs : Date.now());
|
|
1040
|
-
|
|
1041
|
-
if (typeof BitShares.history?.getMarketHistory === 'function') {
|
|
1042
|
-
history = await BitShares.history.getMarketHistory(b.id, a.id, intervalSeconds, startDate.toISOString().slice(0, -5), stopDate.toISOString().slice(0, -5));
|
|
1043
|
-
}
|
|
1044
|
-
else if (typeof BitShares.tradeHistory === 'function') {
|
|
1045
|
-
history = await BitShares.tradeHistory(b.symbol || b.id, a.symbol || a.id, startDate, stopDate, intervalSeconds);
|
|
1046
|
-
}
|
|
1047
|
-
else {
|
|
1048
|
-
throw new Error('native market history source unavailable');
|
|
1049
|
-
}
|
|
1040
|
+
const history = await BitShares.history.getMarketHistory(b.id, a.id, intervalSeconds, startDate.toISOString().slice(0, -5), stopDate.toISOString().slice(0, -5));
|
|
1050
1041
|
let candles = normalizeNativeMarketHistoryCandles(history, a, b);
|
|
1051
1042
|
if (candles.length > 0 && typeof options.fillCandleGaps === 'function') {
|
|
1052
1043
|
candles = options.fillCandleGaps(candles, intervalSeconds);
|
|
@@ -1588,5 +1579,13 @@ if (process.argv[1] && import.meta.url === pathToFileURL(process.argv[1]).href)
|
|
|
1588
1579
|
process.exit(1);
|
|
1589
1580
|
});
|
|
1590
1581
|
}
|
|
1591
|
-
export { main, runOnceForAma, DEFAULT_AMA, DEFAULTS, calculateBotThreshold, buildAmaRecord, computeCandleStaleness, normalizeMarketSource, sleepUntilAlignedBoundary, computeStartupDelayMs, evaluateStartupSleep, resolveAmaForBot,
|
|
1582
|
+
export { main, runOnceForAma, DEFAULT_AMA, DEFAULTS, calculateBotThreshold, buildAmaRecord, computeCandleStaleness, normalizeMarketSource, sleepUntilAlignedBoundary, computeStartupDelayMs, evaluateStartupSleep, resolveAmaForBot, applyRuntimeDefaultsFromGeneralSettings, resolveBotCfg, usesAmaGridPrice, isBotWhitelisted, isBotDynamicWeightWhitelisted, isBotAsymmetricBoundsWhitelisted, writeCenterSnapshot, writeBotDynamicGrid, writeGridResetTrigger, normalizeNativeMarketHistoryCandles, fetchNativeMarketHistorySince, loadMarketAdapterSettings, findPairForBot };
|
|
1583
|
+
/** Internal seams exercised directly by tests. */
|
|
1584
|
+
export const __test = {
|
|
1585
|
+
resolveDeltaThresholdPercentFromGeneralSettings,
|
|
1586
|
+
resolveAmaSlopeDeltaThresholdPercentFromGeneralSettings,
|
|
1587
|
+
_resetCycleCache,
|
|
1588
|
+
mergeGridResetMetadataFromDynamicGrid,
|
|
1589
|
+
_setBitsharesClientForTests: setBitsharesClientForTests,
|
|
1590
|
+
};
|
|
1592
1591
|
//# sourceMappingURL=market_adapter.js.map
|
|
@@ -9,7 +9,6 @@ interface RpcClient {
|
|
|
9
9
|
BitShares: {
|
|
10
10
|
db: RpcProxy;
|
|
11
11
|
history: RpcProxy;
|
|
12
|
-
tradeHistory?: (...args: unknown[]) => Promise<unknown>;
|
|
13
12
|
[method: string]: unknown;
|
|
14
13
|
};
|
|
15
14
|
}
|
|
@@ -20,7 +19,7 @@ interface BitsharesClient extends RpcClient {
|
|
|
20
19
|
[key: string]: unknown;
|
|
21
20
|
}
|
|
22
21
|
/** Resolved asset identity used by the pool/context helpers. */
|
|
23
|
-
|
|
22
|
+
interface ResolvedAsset {
|
|
24
23
|
id: string;
|
|
25
24
|
precision: number;
|
|
26
25
|
symbol: string;
|
|
@@ -44,7 +43,7 @@ declare function normalizeMarketSource(raw: unknown): 'pool' | 'book' | null;
|
|
|
44
43
|
declare function hasNumericStartPrice(raw: unknown): boolean;
|
|
45
44
|
declare function resolveMarketSourceForBot(bot: unknown): 'pool' | 'book' | null;
|
|
46
45
|
declare function normalizePoolId(id: unknown): string | null;
|
|
47
|
-
|
|
46
|
+
interface ResolvedBotContext {
|
|
48
47
|
assetA: ResolvedAsset;
|
|
49
48
|
assetB: ResolvedAsset;
|
|
50
49
|
poolId: string | null;
|
|
@@ -25,5 +25,9 @@ declare function readCachedJson<T>(filePath: string, loader: () => T): T;
|
|
|
25
25
|
declare function noteJsonWritten(filePath: string, value: unknown): void;
|
|
26
26
|
/** Drop every cached entry (config reload, tests, explicit cache busting). */
|
|
27
27
|
declare function clearJsonCache(): void;
|
|
28
|
-
export { readCachedJson, noteJsonWritten
|
|
28
|
+
export { readCachedJson, noteJsonWritten };
|
|
29
|
+
/** Internal seams exercised directly by tests. */
|
|
30
|
+
export declare const __test: {
|
|
31
|
+
clearJsonCache: typeof clearJsonCache;
|
|
32
|
+
};
|
|
29
33
|
//# sourceMappingURL=file_json_cache.d.ts.map
|
|
@@ -102,5 +102,7 @@ function noteJsonWritten(filePath, value) {
|
|
|
102
102
|
function clearJsonCache() {
|
|
103
103
|
_cache.clear();
|
|
104
104
|
}
|
|
105
|
-
export { readCachedJson, noteJsonWritten
|
|
105
|
+
export { readCachedJson, noteJsonWritten };
|
|
106
|
+
/** Internal seams exercised directly by tests. */
|
|
107
|
+
export const __test = { clearJsonCache };
|
|
106
108
|
//# sourceMappingURL=file_json_cache.js.map
|
|
@@ -84,7 +84,7 @@ function _resolveLockPayload(lockPath, opts, timeoutMs) {
|
|
|
84
84
|
const buildPayloadFn = opts.buildPayload;
|
|
85
85
|
const buildPayload = typeof buildPayloadFn === 'function'
|
|
86
86
|
? () => ({ ...buildPayloadFn(), ownerId })
|
|
87
|
-
: () => ({ pid:
|
|
87
|
+
: () => ({ pid: runtime.pid, at: Date.now(), ownerId });
|
|
88
88
|
const alreadyRunningMsg = opts.alreadyRunningMsg;
|
|
89
89
|
const resolveRunningMsg = typeof alreadyRunningMsg === 'function'
|
|
90
90
|
? alreadyRunningMsg
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/** Asset identity/precision needed to convert chain amounts. */
|
|
2
|
-
|
|
2
|
+
interface NativeHistoryAssetMeta {
|
|
3
3
|
id?: unknown;
|
|
4
4
|
precision?: number;
|
|
5
5
|
}
|
|
6
6
|
/** Normalized OHLCV candle: [tsMs, open, high, low, close, volume]. */
|
|
7
|
-
|
|
7
|
+
type NativeHistoryCandle = [number, number, number, number, number, number];
|
|
8
8
|
/**
|
|
9
9
|
* Native BitShares market history parsing utilities.
|
|
10
10
|
*
|
|
@@ -14,5 +14,9 @@ export type NativeHistoryCandle = [number, number, number, number, number, numbe
|
|
|
14
14
|
*/
|
|
15
15
|
declare function parseNativeMarketHistoryTimestamp(entry: unknown): number | null;
|
|
16
16
|
declare function normalizeNativeMarketHistoryCandles(history: unknown, assetA: NativeHistoryAssetMeta, assetB: NativeHistoryAssetMeta): NativeHistoryCandle[];
|
|
17
|
-
export {
|
|
17
|
+
export { normalizeNativeMarketHistoryCandles };
|
|
18
|
+
/** Internal seams exercised directly by tests. */
|
|
19
|
+
export declare const __test: {
|
|
20
|
+
parseNativeMarketHistoryTimestamp: typeof parseNativeMarketHistoryTimestamp;
|
|
21
|
+
};
|
|
18
22
|
//# sourceMappingURL=native_history.d.ts.map
|
|
@@ -153,5 +153,7 @@ function normalizeNativeMarketHistoryCandles(history, assetA, assetB) {
|
|
|
153
153
|
}
|
|
154
154
|
return candles.sort((a, b) => a[0] - b[0]);
|
|
155
155
|
}
|
|
156
|
-
export {
|
|
156
|
+
export { normalizeNativeMarketHistoryCandles };
|
|
157
|
+
/** Internal seams exercised directly by tests. */
|
|
158
|
+
export const __test = { parseNativeMarketHistoryTimestamp };
|
|
157
159
|
//# sourceMappingURL=native_history.js.map
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
|
|
1
|
+
interface OrientableAsset {
|
|
2
2
|
id?: string | null;
|
|
3
3
|
precision?: unknown;
|
|
4
4
|
symbol?: string | null;
|
|
5
5
|
}
|
|
6
6
|
/** The asset legs stored on every shard meta and cache request key. */
|
|
7
|
-
|
|
7
|
+
interface AssetPairLike {
|
|
8
8
|
assetA?: {
|
|
9
9
|
id?: string | null;
|
|
10
10
|
precision?: unknown;
|
|
@@ -33,8 +33,8 @@
|
|
|
33
33
|
*
|
|
34
34
|
* ===============================================================================
|
|
35
35
|
*
|
|
36
|
-
* USAGE:
|
|
37
|
-
*
|
|
36
|
+
* USAGE (from the repo root):
|
|
37
|
+
* import { readBotsFileWithLock, writeBotsFileWithLock, readBotsFileSync } from './modules/bots_file_lock.js';
|
|
38
38
|
* const { config } = await readBotsFileWithLock('./profiles/bots.json', JSON.parse);
|
|
39
39
|
* await writeBotsFileWithLock('./profiles/bots.json', updatedConfig);
|
|
40
40
|
*
|
|
@@ -33,8 +33,8 @@
|
|
|
33
33
|
*
|
|
34
34
|
* ===============================================================================
|
|
35
35
|
*
|
|
36
|
-
* USAGE:
|
|
37
|
-
*
|
|
36
|
+
* USAGE (from the repo root):
|
|
37
|
+
* import { readBotsFileWithLock, writeBotsFileWithLock, readBotsFileSync } from './modules/bots_file_lock.js';
|
|
38
38
|
* const { config } = await readBotsFileWithLock('./profiles/bots.json', JSON.parse);
|
|
39
39
|
* await writeBotsFileWithLock('./profiles/bots.json', updatedConfig);
|
|
40
40
|
*
|
|
@@ -353,9 +353,12 @@ let TIMING = {
|
|
|
353
353
|
// SPREAD_STALE_GEOMETRY_ESCALATE_MS: escalated window used when the
|
|
354
354
|
// correction reports the geometry bind 'last-fill-blocked' — every
|
|
355
355
|
// tightening slot on the corrected side sits at/through the last fill, i.e.
|
|
356
|
-
// the
|
|
357
|
-
// amount of waiting fixes that; a re-center does
|
|
358
|
-
//
|
|
356
|
+
// the window itself is behind the last fill (boundary/crawl lag). No
|
|
357
|
+
// amount of waiting fixes that; a re-center does, because it re-derives the
|
|
358
|
+
// center AROUND that same pivot. Waiting the structural 30 minutes just
|
|
359
|
+
// leaves the side unquoted. Capped at ONE re-center per pivot value
|
|
360
|
+
// (`_lastGeometryResyncPivotKey`): the pivot does not move with the grid, so
|
|
361
|
+
// a second attempt re-derives the identical veto.
|
|
359
362
|
SPREAD_STALE_GEOMETRY_ESCALATE_MS: 10 * 60 * 1000, // 10 minutes
|
|
360
363
|
// SPREAD_CORRECTION_MAX_ATTEMPTS: bounded attempts for one spread-correction
|
|
361
364
|
// cycle (initial broadcast + fresh-master re-plan retries). Kept next to the
|
|
@@ -185,6 +185,14 @@ declare class DEXBot implements BotLike {
|
|
|
185
185
|
_lastHeldChainOrderSignatureSince: number;
|
|
186
186
|
_lastHeldChainOrderWarnAt: number;
|
|
187
187
|
_lastSpreadStaleResyncAt: number;
|
|
188
|
+
/**
|
|
189
|
+
* Fill pivot (`price|type`) the geometry-bind escalation already re-centered
|
|
190
|
+
* for. A re-center cannot move the pivot, so the same fill is never
|
|
191
|
+
* re-centered twice — churn guard, cleared when the spread heals.
|
|
192
|
+
*/
|
|
193
|
+
_lastGeometryResyncPivotKey: string;
|
|
194
|
+
/** Pivot key the "re-center cannot clear this" warning was already logged for. */
|
|
195
|
+
_geometryResyncWarnedPivotKey: string;
|
|
188
196
|
_marketAdapterWatchdogInFlight: boolean;
|
|
189
197
|
_outOfSpreadSince: number;
|
|
190
198
|
_outOfSpreadStaleWarned: boolean;
|
|
@@ -213,6 +213,14 @@ class DEXBot {
|
|
|
213
213
|
_lastHeldChainOrderSignatureSince;
|
|
214
214
|
_lastHeldChainOrderWarnAt;
|
|
215
215
|
_lastSpreadStaleResyncAt;
|
|
216
|
+
/**
|
|
217
|
+
* Fill pivot (`price|type`) the geometry-bind escalation already re-centered
|
|
218
|
+
* for. A re-center cannot move the pivot, so the same fill is never
|
|
219
|
+
* re-centered twice — churn guard, cleared when the spread heals.
|
|
220
|
+
*/
|
|
221
|
+
_lastGeometryResyncPivotKey;
|
|
222
|
+
/** Pivot key the "re-center cannot clear this" warning was already logged for. */
|
|
223
|
+
_geometryResyncWarnedPivotKey;
|
|
216
224
|
_marketAdapterWatchdogInFlight;
|
|
217
225
|
_outOfSpreadSince;
|
|
218
226
|
_outOfSpreadStaleWarned;
|
|
@@ -278,6 +286,8 @@ class DEXBot {
|
|
|
278
286
|
// the first maintenance tick. Values mirror the lazy fallbacks in
|
|
279
287
|
// trackOutOfSpreadStaleness.
|
|
280
288
|
this._lastSpreadStaleResyncAt = 0;
|
|
289
|
+
this._lastGeometryResyncPivotKey = '';
|
|
290
|
+
this._geometryResyncWarnedPivotKey = '';
|
|
281
291
|
this._outOfSpreadSince = 0;
|
|
282
292
|
this._outOfSpreadStaleWarned = false;
|
|
283
293
|
this._outOfSpreadTransientCount = 0;
|
|
@@ -403,6 +403,42 @@ declare function resolveRefillBoundaryHold(workingBoundary: unknown, committedBo
|
|
|
403
403
|
effectiveBoundary: unknown;
|
|
404
404
|
heldRefillSlotIds: string[];
|
|
405
405
|
};
|
|
406
|
+
/**
|
|
407
|
+
* Derive the boundary the actual rails imply.
|
|
408
|
+
*
|
|
409
|
+
* `boundary` is a claim about where the BUY rail ends and the gap band begins;
|
|
410
|
+
* live orders are the fact. A fill-driven plan built at a re-anchored boundary
|
|
411
|
+
* places COUNTER orders above the committed boundary (SELL fill at slot s =>
|
|
412
|
+
* counter BUY at s - gapSlots). If the refill hold then keeps the old boundary,
|
|
413
|
+
* those counters sit inside the implied band; the next plan sees the old
|
|
414
|
+
* geometry and places a SELL on top of them, collapsing the spread (live
|
|
415
|
+
* incident: a sweep's counters at 1329.7-1345.7 were reclassified as in-band by
|
|
416
|
+
* a hold to 133, then sells were rotated to 1345.728664 — the exact price of
|
|
417
|
+
* the buy that had just filled).
|
|
418
|
+
*
|
|
419
|
+
* Rails are clamped by construction:
|
|
420
|
+
*
|
|
421
|
+
* maxBuyIdx <= boundary <= minSellIdx - gapSlots - 1
|
|
422
|
+
*
|
|
423
|
+
* Counter orders therefore win over empty refill holes: a held boundary may
|
|
424
|
+
* never strand a placed counter. When the plan did not place an order on the
|
|
425
|
+
* promoted rail (the normal refill-hold case) `maxBuyIdx` stays at/below the
|
|
426
|
+
* committed boundary and the hold is preserved unchanged.
|
|
427
|
+
*
|
|
428
|
+
* @param manager - OrderManager (master grid rails)
|
|
429
|
+
* @param opContexts - Kept op contexts of the batch (post guard/final gate)
|
|
430
|
+
* @param desiredBoundary - Plan boundary (falls back to the committed one)
|
|
431
|
+
* @param gapSlots - Gap band width
|
|
432
|
+
* @returns Boundary implied by the rails, or null when no rail geometry is
|
|
433
|
+
* usable / the rails already cross (caller keeps the current value).
|
|
434
|
+
*/
|
|
435
|
+
export declare function deriveRailBoundary(manager: OrderManagerLike, opContexts: Iterable<unknown> | null | undefined, desiredBoundary: unknown, gapSlots: unknown): {
|
|
436
|
+
boundary: number | null;
|
|
437
|
+
maxBuyIdx: number | null;
|
|
438
|
+
minSellIdx: number | null;
|
|
439
|
+
clamped: boolean;
|
|
440
|
+
reason?: string;
|
|
441
|
+
};
|
|
406
442
|
/**
|
|
407
443
|
* Track consecutive boundary-hold batches on the manager (ops visibility).
|
|
408
444
|
*
|
|
@@ -454,6 +490,28 @@ declare function resolveOnGridPivot(manager: OrderManagerLike, rawPrice: unknown
|
|
|
454
490
|
idx: number | null;
|
|
455
491
|
nearestDrift: number | null;
|
|
456
492
|
};
|
|
493
|
+
/**
|
|
494
|
+
* Warn (once per batch) when a generic CREATE is emitted on the ADVERSE side of
|
|
495
|
+
* the crossing floor — the guard the spread-correction planner applies through
|
|
496
|
+
* `doesNotCrossMarket`.
|
|
497
|
+
*
|
|
498
|
+
* Non-blocking by design (see the call site): a crossing limit order executes at
|
|
499
|
+
* the BEST available price, so the risk is taker fees and unintended immediate
|
|
500
|
+
* execution, not a worse price. Blocking here would re-open the counter-order
|
|
501
|
+
* deadlock — after a gap the counter lands on the better side by construction,
|
|
502
|
+
* and a gapped market can put the planned level on the other side of the floor,
|
|
503
|
+
* where waiting for the market to return is worse than taking it.
|
|
504
|
+
*
|
|
505
|
+
* The floor is a pure read of already-cached evidence (a fresh live market read
|
|
506
|
+
* wins over the fill reference by recency), so this costs no chain call.
|
|
507
|
+
*
|
|
508
|
+
* @param {Object} bot
|
|
509
|
+
* @param {unknown} price - Emitted CREATE price
|
|
510
|
+
* @param {unknown} type - ORDER_TYPES.BUY/SELL
|
|
511
|
+
* @param {unknown} slotId - Slot the CREATE targets (log context)
|
|
512
|
+
* @returns {boolean} True when a warning was emitted (caller stops re-checking this batch)
|
|
513
|
+
*/
|
|
514
|
+
declare function warnCrossingCreate(bot: BotLike, price: unknown, type: unknown, slotId: unknown): boolean;
|
|
457
515
|
/**
|
|
458
516
|
* Final pre-broadcast pivot gate: re-check BUILT ops against a re-refreshed
|
|
459
517
|
* pivot RIGHT BEFORE broadcast.
|
|
@@ -538,8 +596,11 @@ declare function processBatchResults(bot: BotLike, result: JsonObj, opContexts:
|
|
|
538
596
|
executed: boolean;
|
|
539
597
|
hadRotation: boolean;
|
|
540
598
|
updateOperationCount: number;
|
|
599
|
+
executedActionCount: number;
|
|
600
|
+
createOperationCount: number;
|
|
601
|
+
rotationOperationCount: number;
|
|
541
602
|
}>;
|
|
542
|
-
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 };
|
|
603
|
+
export { isSpreadCorrectionBypassAllowed, isLastFillGuardBlocked, resolveOnGridPivot, warnCrossingCreate, 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 };
|
|
543
604
|
export { restoreDiscardedCreates };
|
|
544
605
|
declare const _default: {
|
|
545
606
|
buildOutsideInPairGroupsForOrders: typeof buildOutsideInPairGroupsForOrders;
|