dexbot 1.6.14 → 1.6.16
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 +60 -4
- package/README.md +4 -4
- package/analysis/README.md +6 -6
- package/analysis/tradingview/README.md +2 -1
- package/claw/README.md +7 -7
- package/claw/docs/DEXBOT2_TUNING_CHEAT_SHEET.md +3 -2
- package/claw/modules/chain_queries.ts +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/ama_fitting/fetch_lp_candles.js +8 -1
- package/dist/analysis/ama_fitting/optimizer_high_resolution.d.ts +50 -1
- package/dist/analysis/ama_fitting/optimizer_high_resolution.js +33 -7
- package/dist/analysis/bot_fitting/backtest_bot_fitting.d.ts +8 -6
- package/dist/analysis/bot_fitting/backtest_bot_fitting.js +8 -10
- package/dist/analysis/bot_key_utils.js +9 -7
- package/dist/analysis/chart_utils.d.ts +9 -2
- package/dist/analysis/chart_utils.js +51 -1
- package/dist/analysis/tradingview/tradingview_uplot_chart_generator.d.ts +2 -1
- package/dist/analysis/tradingview/tradingview_uplot_chart_generator.js +99 -11
- package/dist/analysis/trend_detection/dynamic_weight_chart_generator.js +57 -4
- package/dist/analysis/trend_detection/kalman_chart_generator.js +1 -0
- package/dist/analysis/trend_detection/regime_chart_generator.js +1 -1
- package/dist/analysis/trend_detection/volatility_chart_generator.js +1 -0
- package/dist/dexbot.js +112 -141
- package/dist/market_adapter/core/strategies/dynamic_weight_series.js +26 -11
- package/dist/market_adapter/inputs/fetch_book_data.js +36 -12
- package/dist/market_adapter/inputs/fetch_lp_data.d.ts +6 -0
- package/dist/market_adapter/inputs/fetch_lp_data.js +65 -19
- package/dist/market_adapter/inputs/kibana_feed_source.js +45 -12
- package/dist/market_adapter/inputs/window_cache.d.ts +14 -1
- package/dist/market_adapter/inputs/window_cache.js +53 -17
- package/dist/market_adapter/lp_chart_core.js +1 -0
- package/dist/market_adapter/utils/chain.js +4 -3
- package/dist/market_adapter/utils/pair_orientation.d.ts +60 -0
- package/dist/market_adapter/utils/pair_orientation.js +142 -0
- package/dist/modules/account_bots.d.ts +40 -3
- package/dist/modules/account_bots.js +80 -37
- package/dist/modules/account_orders.d.ts +4 -1
- package/dist/modules/account_orders.js +4 -1
- package/dist/modules/bitshares-native/resolvers.js +3 -3
- package/dist/modules/bitshares-native/subscriptions.js +1 -1
- package/dist/modules/bitshares_client.d.ts +12 -10
- package/dist/modules/bitshares_client.js +12 -10
- package/dist/modules/bot_defaults.d.ts +13 -2
- package/dist/modules/bot_defaults.js +31 -2
- package/dist/modules/bot_settings.js +6 -3
- package/dist/modules/chain_keys.d.ts +5 -1
- package/dist/modules/chain_keys.js +5 -1
- package/dist/modules/chain_orders.d.ts +6 -2
- package/dist/modules/chain_orders.js +6 -2
- package/dist/modules/constants.d.ts +11 -0
- package/dist/modules/constants.js +31 -1
- package/dist/modules/credit_runtime.d.ts +35 -5
- package/dist/modules/credit_runtime.js +219 -38
- package/dist/modules/dexbot_class.d.ts +22 -2
- package/dist/modules/dexbot_class.js +61 -21
- package/dist/modules/dexbot_cow_runtime.js +19 -18
- package/dist/modules/dexbot_fill_runtime.d.ts +1 -1
- package/dist/modules/dexbot_fill_runtime.js +4 -7
- package/dist/modules/dexbot_maintenance_runtime.d.ts +7 -2
- package/dist/modules/dexbot_maintenance_runtime.js +52 -7
- package/dist/modules/dexbot_startup_runtime.js +3 -2
- package/dist/modules/dexbot_state_recovery.js +1 -1
- package/dist/modules/graceful_shutdown.d.ts +6 -2
- package/dist/modules/graceful_shutdown.js +6 -2
- package/dist/modules/launcher/bot_supervisor.js +4 -0
- package/dist/modules/launcher/launch_modes.js +6 -3
- package/dist/modules/launcher/monolithic_runtime.d.ts +39 -1
- package/dist/modules/launcher/monolithic_runtime.js +60 -1
- package/dist/modules/launcher/runtime_mode.d.ts +79 -0
- package/dist/modules/launcher/runtime_mode.js +223 -0
- package/dist/modules/market_adapter_whitelist.d.ts +8 -0
- package/dist/modules/market_adapter_whitelist.js +8 -0
- package/dist/modules/order/accounting.d.ts +15 -1
- package/dist/modules/order/accounting.js +15 -1
- package/dist/modules/order/async_lock.d.ts +9 -3
- package/dist/modules/order/async_lock.js +9 -3
- package/dist/modules/order/export.d.ts +0 -5
- package/dist/modules/order/export.js +2 -7
- package/dist/modules/order/format.d.ts +6 -4
- package/dist/modules/order/format.js +6 -4
- package/dist/modules/order/grid.d.ts +147 -19
- package/dist/modules/order/grid.js +321 -68
- package/dist/modules/order/grid_reconcile.js +4 -3
- package/dist/modules/order/grid_reconcile_internal.js +13 -18
- package/dist/modules/order/index.d.ts +4 -2
- package/dist/modules/order/index.js +1 -1
- package/dist/modules/order/logger_state.d.ts +1 -1
- package/dist/modules/order/logger_state.js +1 -1
- package/dist/modules/order/manager.d.ts +1 -0
- package/dist/modules/order/manager.js +5 -14
- package/dist/modules/order/sync_engine.d.ts +26 -11
- package/dist/modules/order/sync_engine.js +44 -20
- package/dist/modules/order/utils/math.d.ts +157 -47
- package/dist/modules/order/utils/math.js +236 -78
- package/dist/modules/order/utils/order.d.ts +64 -20
- package/dist/modules/order/utils/order.js +80 -24
- package/dist/modules/order/utils/system.d.ts +41 -11
- package/dist/modules/order/utils/system.js +43 -13
- package/dist/modules/order/utils/validate.d.ts +6 -3
- package/dist/modules/order/utils/validate.js +53 -60
- package/dist/modules/types.d.ts +7 -0
- package/dist/modules/utils/asset_symbols.d.ts +5 -5
- package/dist/modules/utils/asset_symbols.js +5 -5
- package/dist/modules/utils/errors.d.ts +2 -1
- package/dist/modules/utils/errors.js +2 -1
- package/dist/scripts/analyze-credit.js +44 -27
- package/dist/scripts/diagnose-pool-history.js +35 -30
- package/dist/scripts/pnl.js +1 -1
- package/dist/scripts/rich_list.d.ts +50 -0
- package/dist/scripts/rich_list.js +469 -0
- package/dist/scripts/run-tests.js +80 -4
- package/dist/unlock.d.ts +2 -1
- package/dist/unlock.js +53 -21
- package/docs/BITSHARES_ONBOARDING.md +7 -0
- package/docs/COW_INVARIANTS.md +7 -1
- package/docs/DEXBOT_COMPARISON.md +6 -6
- package/docs/EVOLUTION.md +11 -9
- package/docs/FUND_MOVEMENT_AND_ACCOUNTING.md +3 -3
- package/docs/GRID_RECALCULATION.md +18 -6
- package/docs/LIFECYCLE.md +8 -8
- package/docs/LOGGING.md +16 -1
- package/docs/MPA_CREDIT_USAGE.md +10 -5
- package/docs/ORDER_ENGINE_POST_1.0_RETROSPECTIVE.md +163 -13
- package/docs/README.md +1 -1
- package/docs/WORKFLOW.md +6 -5
- package/docs/architecture.md +56 -2
- package/docs/developer_guide.md +5 -1
- package/market_adapter/README.md +14 -7
- package/modules/README.md +1 -1
- package/package.json +4 -1
- package/scripts/README.md +59 -32
- package/tests/README.md +40 -2
|
@@ -23,9 +23,11 @@ import { DEFAULT_CONFIG } from './constants.js';
|
|
|
23
23
|
* DEFAULT_CONFIG keys the draft seed must NEVER add. Seeding these would change
|
|
24
24
|
* persisted bots.json bytes for existing bots and pre-satisfy
|
|
25
25
|
* `validateBotEntry`'s required-key check (assetA/assetB), hiding genuine
|
|
26
|
-
* configuration mistakes from the validator.
|
|
26
|
+
* configuration mistakes from the validator. `activeOrders`/`reserveOrders` are
|
|
27
|
+
* legacy aliases migrated to `coreOrders`/`edgeOrders`, kept here so an older
|
|
28
|
+
* general.settings.json that still carries them does not fail the parity guard.
|
|
27
29
|
*/
|
|
28
|
-
export const DRAFT_EXCLUDED_KEYS = ['assetA', 'assetB', 'creditOnly', 'min_BTS_value'];
|
|
30
|
+
export const DRAFT_EXCLUDED_KEYS = ['assetA', 'assetB', 'creditOnly', 'min_BTS_value', 'activeOrders', 'reserveOrders'];
|
|
29
31
|
/**
|
|
30
32
|
* Draft seed order — kept identical to the historical if-chain so a freshly
|
|
31
33
|
* created bot's JSON key order does not change. Together with
|
|
@@ -188,4 +190,31 @@ export function seedBotRuntimeConfig(config = {}, options = {}) {
|
|
|
188
190
|
}
|
|
189
191
|
return out;
|
|
190
192
|
}
|
|
193
|
+
/**
|
|
194
|
+
* Fresh zeroed metrics for the bot and its order manager. Both layers used to
|
|
195
|
+
* declare the shared counters independently, so a new shared counter had to be
|
|
196
|
+
* added twice (and could drift). The manager spreads this base and adds its own
|
|
197
|
+
* runtime-only counters (lock stats, sync timing, start time); the bot uses it
|
|
198
|
+
* verbatim. Single source of truth for the shared `BotMetrics` defaults.
|
|
199
|
+
* @returns {Object} A new metrics object with every shared counter zeroed
|
|
200
|
+
*/
|
|
201
|
+
export function createDefaultBotMetrics() {
|
|
202
|
+
return {
|
|
203
|
+
fillsProcessed: 0,
|
|
204
|
+
batchesExecuted: 0,
|
|
205
|
+
fillProcessingTimeMs: 0,
|
|
206
|
+
lockContentionEvents: 0,
|
|
207
|
+
maxQueueDepth: 0,
|
|
208
|
+
gridLockContention: 0,
|
|
209
|
+
fundRecalcCount: 0,
|
|
210
|
+
refusedCommitCount: 0,
|
|
211
|
+
orphanFillCreditedCount: 0,
|
|
212
|
+
restampBuyAboveAnchorCount: 0,
|
|
213
|
+
boundaryDriftExceedsWindowCount: 0,
|
|
214
|
+
gapBandPlacementShadowCount: 0,
|
|
215
|
+
spreadCorrectionRefusedCount: 0,
|
|
216
|
+
spreadCorrectionRefusalCauses: {},
|
|
217
|
+
spreadCorrectionRetryCount: 0
|
|
218
|
+
};
|
|
219
|
+
}
|
|
191
220
|
//# sourceMappingURL=bot_defaults.js.map
|
|
@@ -86,9 +86,9 @@ function normalizeBotEntry(entry, index = 0) {
|
|
|
86
86
|
// (shared with the claw copy — one semantics for both).
|
|
87
87
|
const normalized = seedBotEntry(entry);
|
|
88
88
|
// Asset symbols are canonical UPPERCASE on BitShares. A hand-edited
|
|
89
|
-
// lowercase "assetA": "tokena"
|
|
90
|
-
// breaks every strict symbol comparison downstream (e.g. the
|
|
91
|
-
// side check that reads `assetA === 'CORE'`,
|
|
89
|
+
// lowercase "assetA": "tokena" both fails the case-sensitive chain lookup
|
|
90
|
+
// and breaks every strict symbol comparison downstream (e.g. the
|
|
91
|
+
// core-asset side check that reads `assetA === 'CORE'`,
|
|
92
92
|
// getBtsSide, fee/pool cache keys), so canonicalize at this single read
|
|
93
93
|
// funnel — which key names hold a symbol is defined once, in
|
|
94
94
|
// modules/utils/asset_symbols.canonicalizeBotAssetSymbols, shared with
|
|
@@ -277,6 +277,9 @@ function validateBotEntry(b, i, src) {
|
|
|
277
277
|
if ('renewOnly' in item && typeof item.renewOnly !== 'boolean') {
|
|
278
278
|
problems.push(`debtPolicy.lending[${idx}].renewOnly must be a boolean`);
|
|
279
279
|
}
|
|
280
|
+
if ('useFreeCollateral' in item && typeof item.useFreeCollateral !== 'boolean') {
|
|
281
|
+
problems.push(`debtPolicy.lending[${idx}].useFreeCollateral must be a boolean`);
|
|
282
|
+
}
|
|
280
283
|
if ('allowedOfferIds' in item) {
|
|
281
284
|
if (!Array.isArray(item.allowedOfferIds)) {
|
|
282
285
|
problems.push(`debtPolicy.lending[${idx}].allowedOfferIds must be an array`);
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
* All newly written private keys use the v2 vault format.
|
|
23
23
|
*
|
|
24
24
|
* ===============================================================================
|
|
25
|
-
* EXPORTS (
|
|
25
|
+
* EXPORTS (25 functions + 1 error class)
|
|
26
26
|
* ===============================================================================
|
|
27
27
|
*
|
|
28
28
|
* AUTHENTICATION (3 functions)
|
|
@@ -67,6 +67,10 @@
|
|
|
67
67
|
* 23. probeAccountInDaemon(accountName, timeout, options) - Probe daemon for account (async)
|
|
68
68
|
* 24. pingDaemon(accountName, timeout, options) - Lightweight daemon health check (async)
|
|
69
69
|
*
|
|
70
|
+
* ONBOARDING (1 function)
|
|
71
|
+
* 25. resolveOnboardingUrl(accountData) - Pick the onboarding doc link to show
|
|
72
|
+
* (copy shipped with this install, else the published URL)
|
|
73
|
+
*
|
|
70
74
|
* ERROR HANDLING (1 error class)
|
|
71
75
|
* - MasterPasswordError - Thrown when authentication fails
|
|
72
76
|
*
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
* All newly written private keys use the v2 vault format.
|
|
23
23
|
*
|
|
24
24
|
* ===============================================================================
|
|
25
|
-
* EXPORTS (
|
|
25
|
+
* EXPORTS (25 functions + 1 error class)
|
|
26
26
|
* ===============================================================================
|
|
27
27
|
*
|
|
28
28
|
* AUTHENTICATION (3 functions)
|
|
@@ -67,6 +67,10 @@
|
|
|
67
67
|
* 23. probeAccountInDaemon(accountName, timeout, options) - Probe daemon for account (async)
|
|
68
68
|
* 24. pingDaemon(accountName, timeout, options) - Lightweight daemon health check (async)
|
|
69
69
|
*
|
|
70
|
+
* ONBOARDING (1 function)
|
|
71
|
+
* 25. resolveOnboardingUrl(accountData) - Pick the onboarding doc link to show
|
|
72
|
+
* (copy shipped with this install, else the published URL)
|
|
73
|
+
*
|
|
70
74
|
* ERROR HANDLING (1 error class)
|
|
71
75
|
* - MasterPasswordError - Thrown when authentication fails
|
|
72
76
|
*
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
* converted to blockchain integers internally using asset precision.
|
|
18
18
|
*
|
|
19
19
|
* ===============================================================================
|
|
20
|
-
* EXPORTS (
|
|
20
|
+
* EXPORTS (25 functions + 1 error class)
|
|
21
21
|
* ===============================================================================
|
|
22
22
|
*
|
|
23
23
|
* ACCOUNT MANAGEMENT (4 functions - async)
|
|
@@ -74,8 +74,12 @@
|
|
|
74
74
|
* Returns 'history' (use fill event data) or 'open' (fetch open orders)
|
|
75
75
|
* 24. broadcastTxWithClassification(tx, accountName, operations) - Broadcast with outcome classification
|
|
76
76
|
*
|
|
77
|
+
* BROADCAST FAILURE DETECTION (1 function)
|
|
78
|
+
* 25. findOverReducingUpdateOpError(result, operations) - Detect limit_order_update
|
|
79
|
+
* ops whose negative delta would over-reduce the order
|
|
80
|
+
*
|
|
77
81
|
* ERROR HANDLING:
|
|
78
|
-
*
|
|
82
|
+
* 26. BroadcastUncertainError - Error class for uncertain broadcast results
|
|
79
83
|
*
|
|
80
84
|
* ===============================================================================
|
|
81
85
|
*
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
* converted to blockchain integers internally using asset precision.
|
|
18
18
|
*
|
|
19
19
|
* ===============================================================================
|
|
20
|
-
* EXPORTS (
|
|
20
|
+
* EXPORTS (25 functions + 1 error class)
|
|
21
21
|
* ===============================================================================
|
|
22
22
|
*
|
|
23
23
|
* ACCOUNT MANAGEMENT (4 functions - async)
|
|
@@ -74,8 +74,12 @@
|
|
|
74
74
|
* Returns 'history' (use fill event data) or 'open' (fetch open orders)
|
|
75
75
|
* 24. broadcastTxWithClassification(tx, accountName, operations) - Broadcast with outcome classification
|
|
76
76
|
*
|
|
77
|
+
* BROADCAST FAILURE DETECTION (1 function)
|
|
78
|
+
* 25. findOverReducingUpdateOpError(result, operations) - Detect limit_order_update
|
|
79
|
+
* ops whose negative delta would over-reduce the order
|
|
80
|
+
*
|
|
77
81
|
* ERROR HANDLING:
|
|
78
|
-
*
|
|
82
|
+
* 26. BroadcastUncertainError - Error class for uncertain broadcast results
|
|
79
83
|
*
|
|
80
84
|
* ===============================================================================
|
|
81
85
|
*
|
|
@@ -105,6 +105,7 @@
|
|
|
105
105
|
* 17. COW_PERFORMANCE - Copy-on-write grid performance settings
|
|
106
106
|
* 18. REBALANCE_STATES - Rebalance lifecycle state enum
|
|
107
107
|
* 19. COW_ACTIONS - Copy-on-write action type enum
|
|
108
|
+
* COW_ORIGINS - Copy-on-write action origin/source enum
|
|
108
109
|
* 20. CR_ZONES - Credit ratio zone constants
|
|
109
110
|
* 21. DEFAULT_TARGET_CR - Default target collateral ratio
|
|
110
111
|
* 22. NATIVE_CLIENT - Native blockchain client configuration
|
|
@@ -114,6 +115,10 @@
|
|
|
114
115
|
* 26. DAEMON_ERRORS - Credential daemon error codes
|
|
115
116
|
* 27. DAEMON_CODES - Credential daemon codes
|
|
116
117
|
* 28. CREDENTIAL_PROMPTS - Credential prompt configuration
|
|
118
|
+
* 29. RANGE_QUALITY - Bot-editor pre-entry price-range legend thresholds
|
|
119
|
+
* 30. buildDefaultGeneralSettings() - Build the canonical default
|
|
120
|
+
* general.settings.json document (first-run seed, editor fallback,
|
|
121
|
+
* and local-overrides merge all share it)
|
|
117
122
|
*
|
|
118
123
|
* ===============================================================================
|
|
119
124
|
*
|
|
@@ -225,6 +230,8 @@ declare let TIMING: {
|
|
|
225
230
|
FILL_TOTALS_RETRY_MAX_MS: number;
|
|
226
231
|
SPREAD_STALE_WARN_MS: number;
|
|
227
232
|
SPREAD_STALE_ESCALATE_MS: number;
|
|
233
|
+
SPREAD_CORRECTION_MAX_ATTEMPTS: number;
|
|
234
|
+
SPREAD_STALE_TRANSIENT_GRACE: number;
|
|
228
235
|
SPREAD_CORRECTION_SYNC_FRESH_MS: number;
|
|
229
236
|
SPREAD_STALE_RESYNC_COOLDOWN_MS: number;
|
|
230
237
|
BOUNDARY_HOLD_RESYNC_THRESHOLD: number;
|
|
@@ -332,6 +339,7 @@ declare let API_LIMITS: {
|
|
|
332
339
|
declare let FILL_PROCESSING: {
|
|
333
340
|
MODE: string;
|
|
334
341
|
OPERATION_TYPE: number;
|
|
342
|
+
COALESCE_BACKLOG_REPLAY: boolean;
|
|
335
343
|
MAX_CONSECUTIVE_CONSUMER_FAILURES: number;
|
|
336
344
|
CONSUMER_BACKOFF_INITIAL_MS: number;
|
|
337
345
|
CONSUMER_BACKOFF_MAX_MS: number;
|
|
@@ -765,6 +773,8 @@ declare function buildDefaultGeneralSettings(): {
|
|
|
765
773
|
FILL_TOTALS_RETRY_MAX_MS: number;
|
|
766
774
|
SPREAD_STALE_WARN_MS: number;
|
|
767
775
|
SPREAD_STALE_ESCALATE_MS: number;
|
|
776
|
+
SPREAD_CORRECTION_MAX_ATTEMPTS: number;
|
|
777
|
+
SPREAD_STALE_TRANSIENT_GRACE: number;
|
|
768
778
|
SPREAD_CORRECTION_SYNC_FRESH_MS: number;
|
|
769
779
|
SPREAD_STALE_RESYNC_COOLDOWN_MS: number;
|
|
770
780
|
BOUNDARY_HOLD_RESYNC_THRESHOLD: number;
|
|
@@ -1001,6 +1011,7 @@ declare function buildDefaultGeneralSettings(): {
|
|
|
1001
1011
|
FILL_PROCESSING: {
|
|
1002
1012
|
MODE: string;
|
|
1003
1013
|
OPERATION_TYPE: number;
|
|
1014
|
+
COALESCE_BACKLOG_REPLAY: boolean;
|
|
1004
1015
|
MAX_CONSECUTIVE_CONSUMER_FAILURES: number;
|
|
1005
1016
|
CONSUMER_BACKOFF_INITIAL_MS: number;
|
|
1006
1017
|
CONSUMER_BACKOFF_MAX_MS: number;
|
|
@@ -106,6 +106,7 @@
|
|
|
106
106
|
* 17. COW_PERFORMANCE - Copy-on-write grid performance settings
|
|
107
107
|
* 18. REBALANCE_STATES - Rebalance lifecycle state enum
|
|
108
108
|
* 19. COW_ACTIONS - Copy-on-write action type enum
|
|
109
|
+
* COW_ORIGINS - Copy-on-write action origin/source enum
|
|
109
110
|
* 20. CR_ZONES - Credit ratio zone constants
|
|
110
111
|
* 21. DEFAULT_TARGET_CR - Default target collateral ratio
|
|
111
112
|
* 22. NATIVE_CLIENT - Native blockchain client configuration
|
|
@@ -115,6 +116,10 @@
|
|
|
115
116
|
* 26. DAEMON_ERRORS - Credential daemon error codes
|
|
116
117
|
* 27. DAEMON_CODES - Credential daemon codes
|
|
117
118
|
* 28. CREDENTIAL_PROMPTS - Credential prompt configuration
|
|
119
|
+
* 29. RANGE_QUALITY - Bot-editor pre-entry price-range legend thresholds
|
|
120
|
+
* 30. buildDefaultGeneralSettings() - Build the canonical default
|
|
121
|
+
* general.settings.json document (first-run seed, editor fallback,
|
|
122
|
+
* and local-overrides merge all share it)
|
|
118
123
|
*
|
|
119
124
|
* ===============================================================================
|
|
120
125
|
*
|
|
@@ -330,6 +335,20 @@ let TIMING = {
|
|
|
330
335
|
// by moving the boundary). Time-based so it holds for any tick cadence.
|
|
331
336
|
SPREAD_STALE_WARN_MS: 10 * 60 * 1000, // 10 minutes
|
|
332
337
|
SPREAD_STALE_ESCALATE_MS: 30 * 60 * 1000, // 30 minutes
|
|
338
|
+
// SPREAD_CORRECTION_MAX_ATTEMPTS: bounded attempts for one spread-correction
|
|
339
|
+
// cycle (initial broadcast + fresh-master re-plan retries). Kept next to the
|
|
340
|
+
// other SPREAD_* tunables so the retry budget is centralized; a value < 1
|
|
341
|
+
// falls back to 2. Overridable per deployment under TIMING in
|
|
342
|
+
// profiles/general.settings.json (TIMING is a shallow-merged section).
|
|
343
|
+
SPREAD_CORRECTION_MAX_ATTEMPTS: 2,
|
|
344
|
+
// SPREAD_STALE_TRANSIENT_GRACE: consecutive TRANSIENT spread-correction
|
|
345
|
+
// refusals (stale plan / duplicate CREATE / unclassified non-execution)
|
|
346
|
+
// tolerated before the out-of-spread watchdog stops treating them as
|
|
347
|
+
// retryable and lets the persistent-stale clock escalate to a structural
|
|
348
|
+
// re-center. checkSpreadCondition's bounded re-plan heals most transient
|
|
349
|
+
// refusals in-cycle; the grace keeps a genuinely deadlocked transient from
|
|
350
|
+
// hiding behind the retry path forever.
|
|
351
|
+
SPREAD_STALE_TRANSIENT_GRACE: 3,
|
|
333
352
|
// SPREAD_CORRECTION_SYNC_FRESH_MS: how old the last completed open-orders
|
|
334
353
|
// sync may be before a spread-correction CREATE loses its LAST-FILL-GUARD
|
|
335
354
|
// bypass. A stale local snapshot (old sync or known-unmatched chain
|
|
@@ -863,6 +882,16 @@ let FILL_PROCESSING = {
|
|
|
863
882
|
// NOTE: fill/broadcast batch sizing is derived from the grid gap-slot
|
|
864
883
|
// count (DEXBot._getGapSlotBatchSize). There is deliberately no fixed
|
|
865
884
|
// fill-batch or ops-per-broadcast constant here.
|
|
885
|
+
// COALESCE_BACKLOG_REPLAY: when true, a fill backlog larger than the
|
|
886
|
+
// gap-slot batch size is planned as ONE reconcile instead of the default
|
|
887
|
+
// chunked replay (each chunk mutating the boundary before broadcasting).
|
|
888
|
+
// Reuses the existing unified-plan path; the boundary-shift budget and
|
|
889
|
+
// _getMaxOpsPerBroadcast still bound the shift and split the broadcast
|
|
890
|
+
// into gapSlots+1-op transactions, so this only removes the intermediate
|
|
891
|
+
// plan/broadcast cycles (Stale-Restart #5). Default OFF: opt-in rollout
|
|
892
|
+
// for the live boundary engine, overridable per bot via
|
|
893
|
+
// `fillProcessing.COALESCE_BACKLOG_REPLAY` in general settings.
|
|
894
|
+
COALESCE_BACKLOG_REPLAY: false,
|
|
866
895
|
// MAX_CONSECUTIVE_CONSUMER_FAILURES: Threshold for the _consumeFillQueue
|
|
867
896
|
// watchdog. Below this count, the consumer re-schedules on every failure
|
|
868
897
|
// via setImmediate. At or above this count, the consumer switches to
|
|
@@ -1147,7 +1176,8 @@ let MARKET_ADAPTER = {
|
|
|
1147
1176
|
// nob: nz% (Neutral Zone %)
|
|
1148
1177
|
DYNAMIC_WEIGHT_AMA_NEUTRAL_ZONE_PCT: 0,
|
|
1149
1178
|
// DYNAMIC_WEIGHT_AMA_HUBER: Single source of truth for the canonical AMA-slope
|
|
1150
|
-
// estimator (computeHuberWindowSlopePct in
|
|
1179
|
+
// estimator (computeHuberWindowSlopePct in
|
|
1180
|
+
// market_adapter/core/strategies/dynamic_weight_series.ts).
|
|
1151
1181
|
// Every consumer — live market adapter, grid-reset replay, bot-fitting
|
|
1152
1182
|
// backtests, both browser-embedded research charts — reads these values:
|
|
1153
1183
|
// Node callers via the module import, generated HTML via an injected
|
|
@@ -253,16 +253,46 @@ declare class CreditRuntime {
|
|
|
253
253
|
*/
|
|
254
254
|
_getFreeDebtAssetBalance(debtAssetId: unknown, debtAsset: UnknownRecord | null): Promise<number | null>;
|
|
255
255
|
/**
|
|
256
|
-
*
|
|
257
|
-
*
|
|
256
|
+
* Read the chain-free balance of a collateral asset. Mirrors
|
|
257
|
+
* `_getFreeDebtAssetBalance`; returns null when it cannot be determined.
|
|
258
|
+
*/
|
|
259
|
+
_getFreeCollateralBalance(collateralAssetId: unknown, collateralAsset: UnknownRecord | null): Promise<number | null>;
|
|
260
|
+
/**
|
|
261
|
+
* Highest raw collateral this deal's position may hold, from the position's
|
|
262
|
+
* `assignedCollateralBudget`. The renewed deal is one member of the
|
|
263
|
+
* position, so its ceiling is the budget minus the collateral the position's
|
|
264
|
+
* other deals already hold. Returns null when no budget is known.
|
|
265
|
+
*/
|
|
266
|
+
_positionCollateralCapInt(dealSummary: DealSummary | UnknownRecord | null, collateralAsset: UnknownRecord | null, releasedInt: number): number | null;
|
|
267
|
+
/**
|
|
268
|
+
* Raw collateral available to a reborrow, as `{ released, budget }`:
|
|
269
|
+
* - `released` — the portion freed by this repay (the collateral floor),
|
|
270
|
+
* - `budget` — the ceiling the new accept may lock: the released portion
|
|
271
|
+
* plus the borrower's free balance of the same asset (when
|
|
272
|
+
* `useFreeCollateral` is on, the default), bounded by the
|
|
273
|
+
* position's `assignedCollateralBudget`.
|
|
274
|
+
* Precedence for `released`:
|
|
258
275
|
* 1. explicit raw `options.availableCollateralAmount` (collateral-switch flow),
|
|
259
276
|
* 2. exact on-chain `floor(repay * collateral / debt)` when the deal's own
|
|
260
277
|
* collateral asset is used,
|
|
261
278
|
* 3. explicit `options.pendingReleaseCollateralAmount` (float) as a fallback.
|
|
262
|
-
* Returns null when it cannot be determined, so
|
|
263
|
-
* legacy (unclamped) behaviour.
|
|
279
|
+
* Returns `{ released: null, budget: null }` when it cannot be determined, so
|
|
280
|
+
* the accept builder keeps the legacy (unclamped) behaviour.
|
|
281
|
+
*/
|
|
282
|
+
_computeCollateralBudget(dealSummary: DealSummary | UnknownRecord | null, repayAmount: unknown, options: UnknownRecord): Promise<{
|
|
283
|
+
released: number | null;
|
|
284
|
+
budget: number | null;
|
|
285
|
+
}>;
|
|
286
|
+
/**
|
|
287
|
+
* Recompute a persisted pending reborrow's collateral budget from its stored
|
|
288
|
+
* released base, the current free balance, and the current position budget —
|
|
289
|
+
* not the snapshot taken when it was queued. If the free balance shrank after
|
|
290
|
+
* deferral the ceiling drops (no over-lock / on-chain failure); if it grew the
|
|
291
|
+
* ceiling rises (no unnecessary clamp). Entries without a released base —
|
|
292
|
+
* legacy ones and the collateral-switch flow, whose budget is the new asset's
|
|
293
|
+
* total balance, not freed collateral — keep their stored budget unchanged.
|
|
264
294
|
*/
|
|
265
|
-
|
|
295
|
+
_refreshReborrowBudget(request: UnknownRecord | null): Promise<number | null>;
|
|
266
296
|
/**
|
|
267
297
|
* Decide how much of a maturing deal can actually be repaid and reborrowed
|
|
268
298
|
* with the currently free debt-asset balance. The repay leg is funded from
|