dexbot 1.4.25 → 1.5.1
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 +54 -0
- package/README.md +6 -2
- package/analysis/README.md +14 -7
- package/analysis/ama_fitting/package.json +1 -1
- package/analysis/analyze_derivatives.ts +1 -1
- package/analysis/bot_key_utils.ts +272 -3
- package/analysis/bot_usage/discover_bot_accounts.ts +64 -9
- package/analysis/bot_usage/kibana_bot_queries.ts +40 -1
- package/analysis/chart_utils.ts +6 -3
- package/analysis/grid_correction_check.ts +56 -20
- package/analysis/resolve_bot_accounts.ts +199 -0
- package/analysis/trade_profitability.ts +36 -8
- package/analysis/tradingview/README.md +25 -0
- package/analysis/tradingview/analyze_tradingview.ts +2 -2
- package/analysis/trend_detection/package.json +1 -1
- package/claw/modules/claw_launcher.ts +5 -4
- package/claw/modules/credit_runtime_adapter.ts +2 -1
- package/claw/modules/dexbot_profiles.ts +4 -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/claw/tests/test_claw_mcp_transport.ts +2 -2
- package/dist/analysis/analyze_derivatives.js +1 -1
- package/dist/analysis/bot_key_utils.d.ts +28 -1
- package/dist/analysis/bot_key_utils.d.ts.map +1 -1
- package/dist/analysis/bot_key_utils.js +385 -3
- package/dist/analysis/bot_key_utils.js.map +1 -1
- package/dist/analysis/bot_usage/discover_bot_accounts.js +60 -10
- package/dist/analysis/bot_usage/discover_bot_accounts.js.map +1 -1
- package/dist/analysis/bot_usage/kibana_bot_queries.d.ts +45 -1
- package/dist/analysis/bot_usage/kibana_bot_queries.d.ts.map +1 -1
- package/dist/analysis/bot_usage/kibana_bot_queries.js +39 -1
- package/dist/analysis/bot_usage/kibana_bot_queries.js.map +1 -1
- package/dist/analysis/chart_utils.d.ts +2 -1
- package/dist/analysis/chart_utils.d.ts.map +1 -1
- package/dist/analysis/chart_utils.js +4 -1
- package/dist/analysis/chart_utils.js.map +1 -1
- package/dist/analysis/grid_correction_check.d.ts.map +1 -1
- package/dist/analysis/grid_correction_check.js +60 -20
- package/dist/analysis/grid_correction_check.js.map +1 -1
- package/dist/analysis/resolve_bot_accounts.d.ts +3 -0
- package/dist/analysis/resolve_bot_accounts.d.ts.map +1 -0
- package/dist/analysis/resolve_bot_accounts.js +216 -0
- package/dist/analysis/resolve_bot_accounts.js.map +1 -0
- package/dist/analysis/trade_profitability.d.ts.map +1 -1
- package/dist/analysis/trade_profitability.js +40 -8
- package/dist/analysis/trade_profitability.js.map +1 -1
- package/dist/analysis/tradingview/analyze_tradingview.js +2 -2
- package/dist/analysis/tradingview/analyze_tradingview.js.map +1 -1
- package/dist/bot.d.ts.map +1 -1
- package/dist/bot.js +2 -1
- package/dist/bot.js.map +1 -1
- package/dist/dexbot.d.ts.map +1 -1
- package/dist/dexbot.js +73 -17
- package/dist/dexbot.js.map +1 -1
- package/dist/market_adapter/ama_signal_runner.js +2 -2
- package/dist/market_adapter/inputs/fetch_cex_synthetic_data.js +2 -1
- package/dist/market_adapter/inputs/fetch_cex_synthetic_data.js.map +1 -1
- package/dist/market_adapter/inputs/fetch_lp_data.d.ts +4 -1
- package/dist/market_adapter/inputs/fetch_lp_data.d.ts.map +1 -1
- package/dist/market_adapter/inputs/fetch_lp_data.js +3 -2
- package/dist/market_adapter/inputs/fetch_lp_data.js.map +1 -1
- package/dist/modules/account_bots.d.ts +42 -1
- package/dist/modules/account_bots.d.ts.map +1 -1
- package/dist/modules/account_bots.js +168 -17
- package/dist/modules/account_bots.js.map +1 -1
- package/dist/modules/account_orders.d.ts +7 -1
- package/dist/modules/account_orders.d.ts.map +1 -1
- package/dist/modules/account_orders.js +34 -1
- package/dist/modules/account_orders.js.map +1 -1
- package/dist/modules/bitshares_client.d.ts +4 -1
- package/dist/modules/bitshares_client.d.ts.map +1 -1
- package/dist/modules/bitshares_client.js +12 -4
- package/dist/modules/bitshares_client.js.map +1 -1
- package/dist/modules/bot_settings.d.ts.map +1 -1
- package/dist/modules/bot_settings.js +2 -1
- package/dist/modules/bot_settings.js.map +1 -1
- package/dist/modules/cli_colors.d.ts +39 -0
- package/dist/modules/cli_colors.d.ts.map +1 -0
- package/dist/modules/cli_colors.js +42 -0
- package/dist/modules/cli_colors.js.map +1 -0
- package/dist/modules/constants.d.ts +2 -0
- package/dist/modules/constants.d.ts.map +1 -1
- package/dist/modules/constants.js +27 -11
- package/dist/modules/constants.js.map +1 -1
- package/dist/modules/credit_pricing.d.ts +61 -0
- package/dist/modules/credit_pricing.d.ts.map +1 -0
- package/dist/modules/credit_pricing.js +237 -0
- package/dist/modules/credit_pricing.js.map +1 -0
- package/dist/modules/credit_runtime.d.ts +1 -0
- package/dist/modules/credit_runtime.d.ts.map +1 -1
- package/dist/modules/credit_runtime.js +49 -107
- package/dist/modules/credit_runtime.js.map +1 -1
- package/dist/modules/dexbot_class.d.ts +3 -1
- package/dist/modules/dexbot_class.d.ts.map +1 -1
- package/dist/modules/dexbot_class.js +22 -6
- package/dist/modules/dexbot_class.js.map +1 -1
- package/dist/modules/dexbot_cow_runtime.d.ts +36 -2
- package/dist/modules/dexbot_cow_runtime.d.ts.map +1 -1
- package/dist/modules/dexbot_cow_runtime.js +434 -20
- package/dist/modules/dexbot_cow_runtime.js.map +1 -1
- package/dist/modules/dexbot_maintenance_runtime.d.ts +15 -16
- package/dist/modules/dexbot_maintenance_runtime.d.ts.map +1 -1
- package/dist/modules/dexbot_maintenance_runtime.js +69 -42
- package/dist/modules/dexbot_maintenance_runtime.js.map +1 -1
- package/dist/modules/dexbot_startup_runtime.d.ts +1 -0
- package/dist/modules/dexbot_startup_runtime.d.ts.map +1 -1
- package/dist/modules/dexbot_startup_runtime.js +12 -1
- package/dist/modules/dexbot_startup_runtime.js.map +1 -1
- package/dist/modules/dexbot_state_recovery.d.ts.map +1 -1
- package/dist/modules/dexbot_state_recovery.js +7 -0
- package/dist/modules/dexbot_state_recovery.js.map +1 -1
- package/dist/modules/fund_registry.d.ts +1 -1
- package/dist/modules/fund_registry.js +1 -1
- package/dist/modules/launcher/adapter_requirement.d.ts +38 -0
- package/dist/modules/launcher/adapter_requirement.d.ts.map +1 -0
- package/dist/modules/launcher/adapter_requirement.js +141 -0
- package/dist/modules/launcher/adapter_requirement.js.map +1 -0
- package/dist/modules/launcher/bot_supervisor.d.ts +2 -2
- package/dist/modules/launcher/bot_supervisor.d.ts.map +1 -1
- package/dist/modules/launcher/bot_supervisor.js +32 -3
- package/dist/modules/launcher/bot_supervisor.js.map +1 -1
- package/dist/modules/launcher/launch_modes.d.ts.map +1 -1
- package/dist/modules/launcher/launch_modes.js +5 -4
- package/dist/modules/launcher/launch_modes.js.map +1 -1
- package/dist/modules/launcher/monolithic_runtime.d.ts +1 -1
- package/dist/modules/launcher/monolithic_runtime.d.ts.map +1 -1
- package/dist/modules/launcher/monolithic_runtime.js +12 -8
- package/dist/modules/launcher/monolithic_runtime.js.map +1 -1
- package/dist/modules/launcher/status_reporting.d.ts +6 -6
- package/dist/modules/launcher/status_reporting.d.ts.map +1 -1
- package/dist/modules/launcher/status_reporting.js +9 -6
- package/dist/modules/launcher/status_reporting.js.map +1 -1
- package/dist/modules/order/accounting.d.ts +34 -0
- package/dist/modules/order/accounting.d.ts.map +1 -1
- package/dist/modules/order/accounting.js +182 -5
- package/dist/modules/order/accounting.js.map +1 -1
- package/dist/modules/order/export.d.ts +1 -1
- package/dist/modules/order/export.js +1 -1
- package/dist/modules/order/grid.d.ts.map +1 -1
- package/dist/modules/order/grid.js +68 -28
- package/dist/modules/order/grid.js.map +1 -1
- package/dist/modules/order/grid_reconcile_internal.d.ts.map +1 -1
- package/dist/modules/order/grid_reconcile_internal.js +72 -0
- package/dist/modules/order/grid_reconcile_internal.js.map +1 -1
- package/dist/modules/order/logger.d.ts +23 -1
- package/dist/modules/order/logger.d.ts.map +1 -1
- package/dist/modules/order/logger.js +60 -17
- package/dist/modules/order/logger.js.map +1 -1
- package/dist/modules/order/manager.d.ts +41 -1
- package/dist/modules/order/manager.d.ts.map +1 -1
- package/dist/modules/order/manager.js +186 -17
- package/dist/modules/order/manager.js.map +1 -1
- package/dist/modules/order/strategy.d.ts.map +1 -1
- package/dist/modules/order/strategy.js +17 -2
- package/dist/modules/order/strategy.js.map +1 -1
- package/dist/modules/order/sync_engine.d.ts.map +1 -1
- package/dist/modules/order/sync_engine.js +59 -9
- package/dist/modules/order/sync_engine.js.map +1 -1
- package/dist/modules/order/utils/math.d.ts +42 -1
- package/dist/modules/order/utils/math.d.ts.map +1 -1
- package/dist/modules/order/utils/math.js +91 -1
- package/dist/modules/order/utils/math.js.map +1 -1
- package/dist/modules/order/utils/order.d.ts +52 -1
- package/dist/modules/order/utils/order.d.ts.map +1 -1
- package/dist/modules/order/utils/order.js +137 -7
- package/dist/modules/order/utils/order.js.map +1 -1
- package/dist/modules/order/utils/system.d.ts +66 -4
- package/dist/modules/order/utils/system.d.ts.map +1 -1
- package/dist/modules/order/utils/system.js +156 -16
- package/dist/modules/order/utils/system.js.map +1 -1
- package/dist/modules/order/utils/validate.d.ts +30 -3
- package/dist/modules/order/utils/validate.d.ts.map +1 -1
- package/dist/modules/order/utils/validate.js +206 -11
- package/dist/modules/order/utils/validate.js.map +1 -1
- package/dist/modules/utils/chain_logs.d.ts +11 -0
- package/dist/modules/utils/chain_logs.d.ts.map +1 -0
- package/dist/modules/utils/chain_logs.js +23 -0
- package/dist/modules/utils/chain_logs.js.map +1 -0
- package/dist/modules/utils/sanitize_key.d.ts +7 -0
- package/dist/modules/utils/sanitize_key.d.ts.map +1 -1
- package/dist/modules/utils/sanitize_key.js +15 -0
- package/dist/modules/utils/sanitize_key.js.map +1 -1
- package/dist/pm2.d.ts +11 -1
- package/dist/pm2.d.ts.map +1 -1
- package/dist/pm2.js +66 -15
- package/dist/pm2.js.map +1 -1
- package/dist/scripts/analyze-credit.d.ts +4 -0
- package/dist/scripts/analyze-credit.d.ts.map +1 -0
- package/dist/scripts/analyze-credit.js +760 -0
- package/dist/scripts/analyze-credit.js.map +1 -0
- package/dist/scripts/analyze-orders.d.ts +1 -10
- package/dist/scripts/analyze-orders.d.ts.map +1 -1
- package/dist/scripts/analyze-orders.js +11 -34
- package/dist/scripts/analyze-orders.js.map +1 -1
- package/dist/scripts/test-credit-renewal.d.ts.map +1 -1
- package/dist/scripts/test-credit-renewal.js +37 -5
- package/dist/scripts/test-credit-renewal.js.map +1 -1
- package/dist/scripts/tv.d.ts +11 -0
- package/dist/scripts/tv.d.ts.map +1 -0
- package/dist/scripts/tv.js +357 -0
- package/dist/scripts/tv.js.map +1 -0
- package/dist/scripts/update.js +77 -10
- package/dist/scripts/update.js.map +1 -1
- package/dist/unlock.d.ts.map +1 -1
- package/dist/unlock.js +20 -8
- package/dist/unlock.js.map +1 -1
- package/docs/DEXBOT_COMPARISON.md +3 -3
- package/docs/EVOLUTION.md +8 -6
- package/docs/FUND_MOVEMENT_AND_ACCOUNTING.md +3 -1
- package/docs/GRID_RECONCILE.md +1 -0
- package/docs/LOGGING.md +3 -0
- package/docs/MPA_CREDIT_USAGE.md +3 -1
- package/docs/README.md +2 -2
- package/docs/WORKFLOW.md +3 -1
- package/package.json +2 -1
- package/scripts/README.md +12 -0
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { usesAmaGridPrice } from './grid_price_source.js';
|
|
2
|
+
declare function isWrapperAdapterOwner(...args: any): any;
|
|
2
3
|
/**
|
|
3
4
|
* Check if a bot configuration uses an AMA grid price source.
|
|
4
5
|
*
|
|
@@ -23,21 +24,12 @@ declare function findSnapshotBotForRuntimeConfig(snapshot: any, config: any): an
|
|
|
23
24
|
declare function runtimeConfigNeedsMarketAdapter(snapshot: any, config: any): boolean;
|
|
24
25
|
/**
|
|
25
26
|
* Load and fingerprint the bots.json configuration file.
|
|
27
|
+
* Delegates to the canonical launcher/adapter_requirement helper so the
|
|
28
|
+
* fingerprint is semantic (AMA-relevant changes only) and identical to the
|
|
29
|
+
* unlock wrapper watchdog's view of the same file.
|
|
26
30
|
* @returns {any} Snapshot with exists flag, fingerprint, active bots list, and adapter requirement
|
|
27
31
|
*/
|
|
28
|
-
declare function loadBotsConfigSnapshot():
|
|
29
|
-
exists: boolean;
|
|
30
|
-
fingerprint: null;
|
|
31
|
-
activeBots: never[];
|
|
32
|
-
needsMarketAdapter: boolean;
|
|
33
|
-
config?: undefined;
|
|
34
|
-
} | {
|
|
35
|
-
exists: boolean;
|
|
36
|
-
fingerprint: any;
|
|
37
|
-
config: any;
|
|
38
|
-
activeBots: any;
|
|
39
|
-
needsMarketAdapter: any;
|
|
40
|
-
};
|
|
32
|
+
declare function loadBotsConfigSnapshot(): any;
|
|
41
33
|
/**
|
|
42
34
|
* Stop and delete the market adapter process from PM2.
|
|
43
35
|
* @returns {Promise<void>}
|
|
@@ -148,8 +140,14 @@ declare function setupBlockchainFetchInterval(bot: any): void;
|
|
|
148
140
|
declare function stopBlockchainFetchInterval(bot: any): void;
|
|
149
141
|
/**
|
|
150
142
|
* Set up the periodic bots.json fingerprint poll interval.
|
|
151
|
-
*
|
|
152
|
-
*
|
|
143
|
+
* Fallback config-change detector for wrapper-less modes (dexbot test
|
|
144
|
+
* one-shot, isolated supervisor, PM2): decoupled from the heavy blockchain
|
|
145
|
+
* fetch interval (default 240min) so config changes are visible within
|
|
146
|
+
* BOTS_CONFIG_POLL_INTERVAL_MS (default 1min, shared with the wrapper
|
|
147
|
+
* watchdog interval).
|
|
148
|
+
* In monolithic mode the unlock wrapper watchdog already polls bots.json
|
|
149
|
+
* on the same shared interval as the sole adapter owner, so no per-bot poll
|
|
150
|
+
* is created here.
|
|
153
151
|
* Uses the shared fingerprint via syncMarketAdapterOnPeriodicConfigCheck so
|
|
154
152
|
* the market adapter start/stop logic stays in one place.
|
|
155
153
|
* @param {import('./dexbot_class.js').DEXBot} bot
|
|
@@ -309,9 +307,10 @@ declare function syncOpenOrdersAndProcessFills(bot: any, tag: any): Promise<{
|
|
|
309
307
|
hasUnmatched: any;
|
|
310
308
|
openOrders: any[];
|
|
311
309
|
}>;
|
|
312
|
-
export { loadBotsConfigSnapshot, refreshDynamicWeightDistribution, performGridResync, updateBotGridResetMetadata, handlePendingTriggerReset, setupTriggerFileDetection, performPeriodicGridChecks, isOpenOrdersSyncLoopEnabled, startOpenOrdersSyncLoop, stopOpenOrdersSyncLoop, setupBlockchainFetchInterval, stopBlockchainFetchInterval, setupBotsConfigPollInterval, stopBotsConfigPollInterval, executeMaintenanceLogic, cancelDustOrders, isOrderDoesNotExistError, runGridMaintenance, stopMarketAdapterPm2, releaseMarketAdapterRuntime, syncMarketAdapterOnPeriodicConfigCheck, findSnapshotBotForRuntimeConfig, runtimeConfigNeedsMarketAdapter, usesAmaGridPrice, checkBtsBalanceAndAcquire, acquireBts, runDustHealthCheck, setupDustHealthCheckInterval, requestGridReset, wireStructuralGridResyncRequest, getPipelineSignals, markGridActivity, getMetrics, syncOpenOrdersAndProcessFills };
|
|
310
|
+
export { loadBotsConfigSnapshot, isWrapperAdapterOwner, refreshDynamicWeightDistribution, performGridResync, updateBotGridResetMetadata, handlePendingTriggerReset, setupTriggerFileDetection, performPeriodicGridChecks, isOpenOrdersSyncLoopEnabled, startOpenOrdersSyncLoop, stopOpenOrdersSyncLoop, setupBlockchainFetchInterval, stopBlockchainFetchInterval, setupBotsConfigPollInterval, stopBotsConfigPollInterval, executeMaintenanceLogic, cancelDustOrders, isOrderDoesNotExistError, runGridMaintenance, stopMarketAdapterPm2, releaseMarketAdapterRuntime, syncMarketAdapterOnPeriodicConfigCheck, findSnapshotBotForRuntimeConfig, runtimeConfigNeedsMarketAdapter, usesAmaGridPrice, checkBtsBalanceAndAcquire, acquireBts, runDustHealthCheck, setupDustHealthCheckInterval, requestGridReset, wireStructuralGridResyncRequest, getPipelineSignals, markGridActivity, getMetrics, syncOpenOrdersAndProcessFills };
|
|
313
311
|
declare const _default: {
|
|
314
312
|
loadBotsConfigSnapshot: typeof loadBotsConfigSnapshot;
|
|
313
|
+
isWrapperAdapterOwner: typeof isWrapperAdapterOwner;
|
|
315
314
|
refreshDynamicWeightDistribution: typeof refreshDynamicWeightDistribution;
|
|
316
315
|
performGridResync: typeof performGridResync;
|
|
317
316
|
updateBotGridResetMetadata: typeof updateBotGridResetMetadata;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dexbot_maintenance_runtime.d.ts","sourceRoot":"","sources":["../../modules/dexbot_maintenance_runtime.ts"],"names":[],"mappings":"AA+BA,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"dexbot_maintenance_runtime.d.ts","sourceRoot":"","sources":["../../modules/dexbot_maintenance_runtime.ts"],"names":[],"mappings":"AA+BA,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAc1D,iBAAS,qBAAqB,CAAC,GAAG,IAAI,EAAE,GAAG,OAAsF;AAiEjI;;;;;;GAMG;AAEH;;;;;;GAMG;AACH,iBAAS,+BAA+B,CAAC,QAAQ,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,OAalE;AAED;;;;;GAKG;AACH,iBAAS,+BAA+B,CAAC,QAAQ,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,WAMlE;AA2HD;;;;;;GAMG;AACH,iBAAS,sBAAsB,QAE9B;AAoGD;;;GAGG;AACH,iBAAe,oBAAoB,kBAElC;AAED;;;;;;GAMG;AACH,iBAAe,sCAAsC,CAAC,GAAG,EAAE,GAAG,EAAE,OAAO,GAAE,GAAgB,gBAsKxF;AAED;;;;;;GAMG;AACH,iBAAS,gCAAgC,CAAC,GAAG,EAAE,GAAG,EAAE,OAAO,GAAE,GAAe;;;;;;;;;;EA+D3E;AAyHD;;;;;;;GAOG;AACH,iBAAS,0BAA0B,CAAC,MAAM,EAAE,GAAG,EAAE,OAAO,GAAE;IAAE,OAAO,CAAC,EAAE,MAAM,CAAC;IAAC,WAAW,CAAC,EAAE,MAAM,CAAA;CAAO,OA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iBAAe,6BAA6B,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG;;;;;;;;;;GAI9D;AAiED,OAAO,EAAE,sBAAsB,EAAE,qBAAqB,EAAE,gCAAgC,EAAE,iBAAiB,EAAE,0BAA0B,EAAE,yBAAyB,EAAE,yBAAyB,EAAE,yBAAyB,EAAE,2BAA2B,EAAE,uBAAuB,EAAE,sBAAsB,EAAE,4BAA4B,EAAE,2BAA2B,EAAE,2BAA2B,EAAE,0BAA0B,EAAE,uBAAuB,EAAE,gBAAgB,EAAE,wBAAwB,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,2BAA2B,EAAE,sCAAsC,EAAE,+BAA+B,EAAE,+BAA+B,EAAE,gBAAgB,EAAE,yBAAyB,EAAE,UAAU,EAAE,kBAAkB,EAAE,4BAA4B,EAAE,gBAAgB,EAAE,+BAA+B,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,UAAU,EAAE,6BAA6B,EAAE,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGl4B,wBAoCE"}
|
|
@@ -7,7 +7,6 @@ const __dirname = _esmDirname(__filename);
|
|
|
7
7
|
const require = createRequire(import.meta.url);
|
|
8
8
|
import fs from 'node:fs';
|
|
9
9
|
import { spawn } from 'node:child_process';
|
|
10
|
-
import { createHash } from './crypto/sync.js';
|
|
11
10
|
import { nowIso } from './order/utils/system.js';
|
|
12
11
|
import { path } from './path_api.js';
|
|
13
12
|
import * as chainOrders from './chain_orders.js';
|
|
@@ -27,6 +26,7 @@ import { BroadcastUncertainError } from './dexbot_credential_client.js';
|
|
|
27
26
|
import * as configModule from './config.js';
|
|
28
27
|
const { Config } = configModule;
|
|
29
28
|
import { getErrorMessage } from './utils/errors.js';
|
|
29
|
+
import { isSameBotName } from './utils/sanitize_key.js';
|
|
30
30
|
import { usesAmaGridPrice } from './grid_price_source.js';
|
|
31
31
|
function hasOpenOrdersSyncLoopMsSet(...args) { return require('./config').hasOpenOrdersSyncLoopMsSet(...args); }
|
|
32
32
|
function getOpenOrdersSyncLoopMs(...args) { return require('./config').getOpenOrdersSyncLoopMs(...args); }
|
|
@@ -41,6 +41,8 @@ function loadAmaCenterSnapshot(...args) { return require('./order/utils/system')
|
|
|
41
41
|
function sleep(...args) { return require('./order/utils/system').sleep(...args); }
|
|
42
42
|
function parseJsonWithComments(...args) { return require('./order/utils/system').parseJsonWithComments(...args); }
|
|
43
43
|
function isPm2Runtime(...args) { return require('./order/logger').isPm2Runtime(...args); }
|
|
44
|
+
function isWrapperAdapterOwner(...args) { return require('./launcher/adapter_requirement').isWrapperAdapterOwner(...args); }
|
|
45
|
+
function readAdapterRequirement(...args) { return require('./launcher/adapter_requirement').readAdapterRequirement(...args); }
|
|
44
46
|
function getSharedMarketAdapterRuntime(...args) { return require('./launcher/market_adapter_runtime').getSharedMarketAdapterRuntime(...args); }
|
|
45
47
|
function resetMarketAdapterWhitelistCache(...args) { return require('./market_adapter_whitelist').resetMarketAdapterWhitelistCache(...args); }
|
|
46
48
|
function isBotDynamicWeightWhitelisted(...args) { return require('./market_adapter_whitelist').isBotDynamicWeightWhitelisted(...args); }
|
|
@@ -255,37 +257,13 @@ async function maybeRunTargetedDriftReconciliation(bot, context) {
|
|
|
255
257
|
}
|
|
256
258
|
/**
|
|
257
259
|
* Load and fingerprint the bots.json configuration file.
|
|
260
|
+
* Delegates to the canonical launcher/adapter_requirement helper so the
|
|
261
|
+
* fingerprint is semantic (AMA-relevant changes only) and identical to the
|
|
262
|
+
* unlock wrapper watchdog's view of the same file.
|
|
258
263
|
* @returns {any} Snapshot with exists flag, fingerprint, active bots list, and adapter requirement
|
|
259
264
|
*/
|
|
260
265
|
function loadBotsConfigSnapshot() {
|
|
261
|
-
|
|
262
|
-
return {
|
|
263
|
-
exists: false,
|
|
264
|
-
fingerprint: null,
|
|
265
|
-
activeBots: [],
|
|
266
|
-
needsMarketAdapter: false,
|
|
267
|
-
};
|
|
268
|
-
}
|
|
269
|
-
const raw = storage.readFile(PROFILES_BOTS_FILE);
|
|
270
|
-
if (!raw || !raw.trim()) {
|
|
271
|
-
return {
|
|
272
|
-
exists: false,
|
|
273
|
-
fingerprint: null,
|
|
274
|
-
activeBots: [],
|
|
275
|
-
needsMarketAdapter: false,
|
|
276
|
-
};
|
|
277
|
-
}
|
|
278
|
-
const fingerprint = createHash('sha1').update(raw).digest('hex');
|
|
279
|
-
const parsed = parseJsonWithComments(raw);
|
|
280
|
-
const bots = Array.isArray(parsed?.bots) ? parsed.bots.filter(Boolean) : [];
|
|
281
|
-
const activeBots = bots.filter((bot) => bot.active !== false);
|
|
282
|
-
return {
|
|
283
|
-
exists: true,
|
|
284
|
-
fingerprint,
|
|
285
|
-
config: parsed,
|
|
286
|
-
activeBots,
|
|
287
|
-
needsMarketAdapter: activeBots.some(usesAmaGridPrice),
|
|
288
|
-
};
|
|
266
|
+
return readAdapterRequirement(PROFILES_BOTS_FILE);
|
|
289
267
|
}
|
|
290
268
|
/**
|
|
291
269
|
* Parse PM2 jlist command output to extract process names.
|
|
@@ -379,6 +357,16 @@ async function syncMarketAdapterOnPeriodicConfigCheck(bot, context = 'periodic')
|
|
|
379
357
|
if (typeof bot._syncMarketAdapterHook === 'function') {
|
|
380
358
|
return await bot._syncMarketAdapterHook(context);
|
|
381
359
|
}
|
|
360
|
+
// Centralized ownership: in monolithic mode the unlock wrapper watchdog
|
|
361
|
+
// (shared 1min tick) is the sole market-adapter spawner. A per-bot sync here would
|
|
362
|
+
// re-read bots.json and re-drive the adapter N times (once per bot) and
|
|
363
|
+
// fight the wrapper over the adapter child, so bots skip it entirely and
|
|
364
|
+
// act as pure adapter-output consumers. Wrapper-less modes (dexbot test
|
|
365
|
+
// one-shot, isolated supervisor, PM2) keep the in-bot fallback below.
|
|
366
|
+
// Checked before any file I/O so the skip also removes the duplicate read.
|
|
367
|
+
if (!isPm2Runtime() && isWrapperAdapterOwner()) {
|
|
368
|
+
return { skipped: true, reason: 'wrapper-owned' };
|
|
369
|
+
}
|
|
382
370
|
if (bot._marketAdapterWatchdogInFlight) {
|
|
383
371
|
return { skipped: true, reason: 'in-flight' };
|
|
384
372
|
}
|
|
@@ -387,7 +375,19 @@ async function syncMarketAdapterOnPeriodicConfigCheck(bot, context = 'periodic')
|
|
|
387
375
|
const snapshot = typeof bot._loadBotsConfigSnapshot === 'function'
|
|
388
376
|
? await bot._loadBotsConfigSnapshot()
|
|
389
377
|
: loadBotsConfigSnapshot();
|
|
390
|
-
|
|
378
|
+
// Corrupt/unreadable bots.json must not move the adapter: previously
|
|
379
|
+
// the parse/read throw aborted the check and left the adapter alone.
|
|
380
|
+
// Keep that behavior by skipping the sync without touching the stored
|
|
381
|
+
// fingerprint, so the next tick re-evaluates once the file is valid.
|
|
382
|
+
if (snapshot.corrupt || snapshot.readError) {
|
|
383
|
+
const reason = snapshot.corrupt ? 'corrupt-config' : 'unreadable-config';
|
|
384
|
+
const detail = snapshot.corrupt ? 'corrupt' : 'unreadable';
|
|
385
|
+
bot._warn(`Ignoring ${detail} bots.json during ${context}; keeping previous market adapter state.`);
|
|
386
|
+
return { skipped: true, reason };
|
|
387
|
+
}
|
|
388
|
+
// ?? (not ||): the semantic fingerprint is legitimately '' when no
|
|
389
|
+
// active AMA bot exists, and '' must compare equal to a stored ''.
|
|
390
|
+
const previousFingerprint = bot._marketAdapterWatchdogFingerprint ?? null;
|
|
391
391
|
const changed = snapshot.fingerprint !== previousFingerprint;
|
|
392
392
|
bot._marketAdapterWatchdogFingerprint = snapshot.fingerprint;
|
|
393
393
|
if (changed) {
|
|
@@ -742,7 +742,7 @@ function performGridResync(bot, options = {}) {
|
|
|
742
742
|
const content = storage.readFile(PROFILES_BOTS_FILE);
|
|
743
743
|
const allBotsConfig = parseJsonWithComments(content).bots || [];
|
|
744
744
|
const myName = self.config.name;
|
|
745
|
-
const updatedBot = allBotsConfig.find((b) => b.name
|
|
745
|
+
const updatedBot = allBotsConfig.find((b) => isSameBotName(b.name, myName));
|
|
746
746
|
if (updatedBot) {
|
|
747
747
|
self._log(`Reloaded configuration for bot '${myName}'`);
|
|
748
748
|
const oldKey = self.config.botKey;
|
|
@@ -1218,8 +1218,14 @@ function stopBlockchainFetchInterval(bot) {
|
|
|
1218
1218
|
}
|
|
1219
1219
|
/**
|
|
1220
1220
|
* Set up the periodic bots.json fingerprint poll interval.
|
|
1221
|
-
*
|
|
1222
|
-
*
|
|
1221
|
+
* Fallback config-change detector for wrapper-less modes (dexbot test
|
|
1222
|
+
* one-shot, isolated supervisor, PM2): decoupled from the heavy blockchain
|
|
1223
|
+
* fetch interval (default 240min) so config changes are visible within
|
|
1224
|
+
* BOTS_CONFIG_POLL_INTERVAL_MS (default 1min, shared with the wrapper
|
|
1225
|
+
* watchdog interval).
|
|
1226
|
+
* In monolithic mode the unlock wrapper watchdog already polls bots.json
|
|
1227
|
+
* on the same shared interval as the sole adapter owner, so no per-bot poll
|
|
1228
|
+
* is created here.
|
|
1223
1229
|
* Uses the shared fingerprint via syncMarketAdapterOnPeriodicConfigCheck so
|
|
1224
1230
|
* the market adapter start/stop logic stays in one place.
|
|
1225
1231
|
* @param {import('./dexbot_class.js').DEXBot} bot
|
|
@@ -1234,11 +1240,16 @@ function setupBotsConfigPollInterval(bot) {
|
|
|
1234
1240
|
bot._log(`Bots-config poll interval disabled (value: ${intervalMs}). Fingerprint changes will only be seen on blockchain fetch ticks.`);
|
|
1235
1241
|
return;
|
|
1236
1242
|
}
|
|
1243
|
+
if (!isPm2Runtime() && isWrapperAdapterOwner()) {
|
|
1244
|
+
bot._log('Bots-config poll disabled (market adapter owned by unlock wrapper).');
|
|
1245
|
+
return;
|
|
1246
|
+
}
|
|
1237
1247
|
// Ensure the fingerprint exists before the first interval fires.
|
|
1238
1248
|
// setupBlockchainFetchInterval already fires syncMarketAdapterOnPeriodicConfigCheck
|
|
1239
1249
|
// at startup, so this is a fallback for bots that never run the blockchain interval
|
|
1240
|
-
// (e.g. dryRun or accountId missing).
|
|
1241
|
-
|
|
1250
|
+
// (e.g. dryRun or accountId missing). Gate on === null (never checked):
|
|
1251
|
+
// '' is a valid checked steady-state and must not re-trigger the pre-seed.
|
|
1252
|
+
if (bot._marketAdapterWatchdogFingerprint === null || bot._marketAdapterWatchdogFingerprint === undefined) {
|
|
1242
1253
|
syncMarketAdapterOnPeriodicConfigCheck(bot, 'startup bots-config poll setup').catch((err) => {
|
|
1243
1254
|
bot._warn(`Bots-config poll setup failed: ${getErrorMessage(err)}`);
|
|
1244
1255
|
});
|
|
@@ -1640,12 +1651,27 @@ async function executeMaintenanceLogic(bot, context) {
|
|
|
1640
1651
|
// committed boundary, and re-plans on fund change, so this tick is
|
|
1641
1652
|
// race-safe whenever it does run.
|
|
1642
1653
|
if (!boundaryShiftPending) {
|
|
1643
|
-
|
|
1644
|
-
|
|
1645
|
-
|
|
1646
|
-
|
|
1647
|
-
|
|
1648
|
-
|
|
1654
|
+
// Re-check the fill queue: fills may have arrived during this
|
|
1655
|
+
// tick's earlier phases (health check, dust cancels, divergence
|
|
1656
|
+
// corrections), after the pipeline gate above passed. Sizing a
|
|
1657
|
+
// correction from pre-fill budgets would under/over-fund the
|
|
1658
|
+
// repair — defer to the next tick so the fill cycle runs first
|
|
1659
|
+
// and side choice + sizing read fresh funds.
|
|
1660
|
+
const queuedFills = Array.isArray(bot?._incomingFillQueue)
|
|
1661
|
+
? bot._incomingFillQueue.length
|
|
1662
|
+
: 0;
|
|
1663
|
+
if (queuedFills > 0) {
|
|
1664
|
+
bot._log(`[SPREAD] Deferring spread check: ${queuedFills} fill(s) queued since pipeline gate; ` +
|
|
1665
|
+
`processing fills first for fresh funds`, 'debug');
|
|
1666
|
+
}
|
|
1667
|
+
else {
|
|
1668
|
+
const spreadResult = await bot.manager.checkSpreadCondition(BitShares, bot.updateOrdersOnChainPlan.bind(bot));
|
|
1669
|
+
if (await bot._abortFlowIfIllegalState(`${context} spread check`))
|
|
1670
|
+
return;
|
|
1671
|
+
if (spreadResult && spreadResult.ordersPlaced > 0) {
|
|
1672
|
+
bot._log(`✓ Spread correction during ${context}: ${spreadResult.ordersPlaced} order(s) placed`);
|
|
1673
|
+
await bot._persistAndRecoverIfNeeded();
|
|
1674
|
+
}
|
|
1649
1675
|
}
|
|
1650
1676
|
}
|
|
1651
1677
|
}
|
|
@@ -2315,9 +2341,10 @@ async function syncOpenOrdersAndProcessFillsImpl(bot, tag) {
|
|
|
2315
2341
|
return { syncResult: null, aborted: true, hasUnmatched: -1, openOrders: null };
|
|
2316
2342
|
}
|
|
2317
2343
|
}
|
|
2318
|
-
export { loadBotsConfigSnapshot, refreshDynamicWeightDistribution, performGridResync, updateBotGridResetMetadata, handlePendingTriggerReset, setupTriggerFileDetection, performPeriodicGridChecks, isOpenOrdersSyncLoopEnabled, startOpenOrdersSyncLoop, stopOpenOrdersSyncLoop, setupBlockchainFetchInterval, stopBlockchainFetchInterval, setupBotsConfigPollInterval, stopBotsConfigPollInterval, executeMaintenanceLogic, cancelDustOrders, isOrderDoesNotExistError, runGridMaintenance, stopMarketAdapterPm2, releaseMarketAdapterRuntime, syncMarketAdapterOnPeriodicConfigCheck, findSnapshotBotForRuntimeConfig, runtimeConfigNeedsMarketAdapter, usesAmaGridPrice, checkBtsBalanceAndAcquire, acquireBts, runDustHealthCheck, setupDustHealthCheckInterval, requestGridReset, wireStructuralGridResyncRequest, getPipelineSignals, markGridActivity, getMetrics, syncOpenOrdersAndProcessFills };
|
|
2344
|
+
export { loadBotsConfigSnapshot, isWrapperAdapterOwner, refreshDynamicWeightDistribution, performGridResync, updateBotGridResetMetadata, handlePendingTriggerReset, setupTriggerFileDetection, performPeriodicGridChecks, isOpenOrdersSyncLoopEnabled, startOpenOrdersSyncLoop, stopOpenOrdersSyncLoop, setupBlockchainFetchInterval, stopBlockchainFetchInterval, setupBotsConfigPollInterval, stopBotsConfigPollInterval, executeMaintenanceLogic, cancelDustOrders, isOrderDoesNotExistError, runGridMaintenance, stopMarketAdapterPm2, releaseMarketAdapterRuntime, syncMarketAdapterOnPeriodicConfigCheck, findSnapshotBotForRuntimeConfig, runtimeConfigNeedsMarketAdapter, usesAmaGridPrice, checkBtsBalanceAndAcquire, acquireBts, runDustHealthCheck, setupDustHealthCheckInterval, requestGridReset, wireStructuralGridResyncRequest, getPipelineSignals, markGridActivity, getMetrics, syncOpenOrdersAndProcessFills };
|
|
2319
2345
|
export default {
|
|
2320
2346
|
loadBotsConfigSnapshot,
|
|
2347
|
+
isWrapperAdapterOwner,
|
|
2321
2348
|
refreshDynamicWeightDistribution,
|
|
2322
2349
|
performGridResync,
|
|
2323
2350
|
updateBotGridResetMetadata,
|