dexbot 1.6.15 → 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 +26 -0
- package/README.md +4 -4
- 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 +19 -5
- package/dist/analysis/trend_detection/dynamic_weight_chart_generator.js +21 -2
- 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 +89 -138
- 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 +37 -3
- package/dist/modules/account_bots.js +77 -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_client.d.ts +12 -10
- package/dist/modules/bitshares_client.js +12 -10
- package/dist/modules/bot_settings.js +3 -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 +5 -0
- package/dist/modules/constants.js +7 -1
- package/dist/modules/dexbot_class.d.ts +3 -1
- package/dist/modules/dexbot_class.js +3 -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 +0 -5
- package/dist/modules/order/format.d.ts +6 -4
- package/dist/modules/order/format.js +6 -4
- package/dist/modules/order/grid.d.ts +29 -18
- package/dist/modules/order/grid.js +29 -18
- package/dist/modules/order/index.d.ts +1 -1
- 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/sync_engine.d.ts +26 -11
- package/dist/modules/order/sync_engine.js +26 -11
- package/dist/modules/order/utils/math.d.ts +59 -21
- package/dist/modules/order/utils/math.js +59 -21
- package/dist/modules/order/utils/order.d.ts +64 -20
- package/dist/modules/order/utils/order.js +64 -20
- package/dist/modules/order/utils/system.d.ts +41 -11
- package/dist/modules/order/utils/system.js +41 -11
- package/dist/modules/order/utils/validate.d.ts +5 -2
- package/dist/modules/order/utils/validate.js +5 -2
- 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/rich_list.d.ts +32 -0
- package/dist/scripts/rich_list.js +16 -8
- package/dist/unlock.js +49 -18
- package/docs/BITSHARES_ONBOARDING.md +7 -0
- package/docs/COW_INVARIANTS.md +1 -1
- package/docs/DEXBOT_COMPARISON.md +5 -5
- package/docs/EVOLUTION.md +8 -7
- package/docs/FUND_MOVEMENT_AND_ACCOUNTING.md +3 -3
- package/docs/GRID_RECALCULATION.md +18 -6
- package/docs/LIFECYCLE.md +8 -8
- package/docs/ORDER_ENGINE_POST_1.0_RETROSPECTIVE.md +4 -4
- package/docs/README.md +1 -1
- package/docs/WORKFLOW.md +5 -5
- package/market_adapter/README.md +10 -3
- package/package.json +3 -1
- package/tests/README.md +29 -0
|
@@ -4,45 +4,75 @@
|
|
|
4
4
|
* Price derivation, persistence, grid correction, and UI/interactive utilities.
|
|
5
5
|
*
|
|
6
6
|
* ===============================================================================
|
|
7
|
-
* TABLE OF CONTENTS (
|
|
7
|
+
* TABLE OF CONTENTS (43 exported functions + 11 structural view types)
|
|
8
8
|
* ===============================================================================
|
|
9
9
|
*
|
|
10
|
-
* SECTION 1: PRICE DERIVATION (
|
|
10
|
+
* SECTION 1: PRICE DERIVATION (9 functions + 1 internal)
|
|
11
11
|
* - lookupAsset(BitShares, symbol) - Lookup asset metadata from blockchain
|
|
12
|
+
* - resolveAssetByRef(BitShares, ref) - Resolve a full asset object from id/symbol
|
|
12
13
|
* - deriveMarketPrice(BitShares, symA, symB) - Derive price from order book
|
|
13
14
|
* - derivePoolPrice(BitShares, symA, symB) - Derive price from liquidity pool
|
|
15
|
+
* - setDerivePriceTestHook(hook) - Test-only seam for derivePrice
|
|
14
16
|
* - derivePrice(BitShares, symA, symB, mode) - Derive price with fallback chain
|
|
15
17
|
* - derivePriceViaBridges(BitShares, symA, symB, bridges, mode) - Multi-hop price via bridge assets
|
|
16
18
|
* - derivePriceWithBridges(BitShares, symA, symB, bridges, mode) - Direct price, else bridge hops
|
|
17
|
-
* - resolveLiquidityPoolByShareAsset(BitShares, shareAsset) - Resolve LP by share asset
|
|
18
19
|
* - deriveLiquidityPoolTokenValue(BitShares, symA, symB) - Derive LP token value
|
|
19
|
-
* -
|
|
20
|
-
* - loadAmaCenterSnapshot(manager) - Load AMA center snapshot
|
|
20
|
+
* - resolveLiquidityPoolByShareAsset(BitShares, shareAsset) - Resolve LP by share asset (internal)
|
|
21
21
|
*
|
|
22
|
-
* SECTION 2:
|
|
22
|
+
* SECTION 2: AMA CENTER SNAPSHOT (2 functions)
|
|
23
|
+
* - loadAmaCenterSnapshot(manager) - Load the full dynamic-grid snapshot
|
|
24
|
+
* - loadAmaCenterPrice(manager) - Load the AMA center price
|
|
25
|
+
*
|
|
26
|
+
* SECTION 3: FEE MANAGEMENT (1 function)
|
|
23
27
|
* - initializeFeeCache(botsConfig, BitShares) - Initialize fee cache from blockchain
|
|
24
28
|
*
|
|
25
|
-
* SECTION
|
|
29
|
+
* SECTION 4: GRID STATE MANAGEMENT (5 functions)
|
|
26
30
|
* - persistGridSnapshot(manager, accountOrders) - Persist grid to storage
|
|
31
|
+
* - restoreGapEvacStreaks(manager) - Restore persisted gap-evacuation streaks
|
|
27
32
|
* - retryPersistenceIfNeeded(manager) - Retry persistence if previous failed
|
|
28
33
|
* - applyGridDivergenceCorrections(manager, ...) - Apply grid divergence corrections
|
|
29
|
-
*
|
|
30
|
-
*
|
|
34
|
+
* - applyPersistedPendingCrawls(...) - Apply persisted-but-uncommitted fill crawls
|
|
35
|
+
*
|
|
36
|
+
* SECTION 5: SPREAD-CORRECTION READINESS (7 functions)
|
|
37
|
+
* - resolveSpreadFreshnessMs(manager) - The single freshness window for spread trust
|
|
38
|
+
* - resolveSpreadCrossingFloor(manager) - Crossing floor spread correction must not trade through
|
|
39
|
+
* - refreshLiveMarketPrice(manager) - Refresh the cached live market price
|
|
40
|
+
* - maybeRefreshLiveMarketPrice(manager) - Refresh if stale, paced to one attempt per window
|
|
41
|
+
* - evaluateSpreadCorrectionReadiness(manager) - Evaluate whether spread correction may act
|
|
42
|
+
* - resolveSpreadMarketReference(manager) - Resolve the last real FILL price
|
|
43
|
+
* - resolveLastFillGuardReference(manager) - Resolve the reference the LAST-FILL-GUARD judges
|
|
44
|
+
*
|
|
45
|
+
* SECTION 6: LAST-FILL / MARKET-FILL PERSISTENCE (6 functions)
|
|
46
|
+
* - restoreLastMarketFill(manager) - Restore the persisted last-market-fill reference
|
|
47
|
+
* - normalizeLastFillPivot(row) - Normalize a persisted LAST-FILL-GUARD pivot row
|
|
48
|
+
* - normalizeLastMarketFill(row) - Normalize a persisted last-market-fill row
|
|
49
|
+
* - setLastFillPivot(manager, ...) - Write the LAST-FILL-GUARD pivot scalar family
|
|
50
|
+
* - resetLastFillPivot(manager) - Clear the pivot to cold state
|
|
51
|
+
* - restoreLastFillPivot(manager) - Restore the persisted pivot into the manager
|
|
52
|
+
*
|
|
53
|
+
* SECTION 7: UI & INTERACTIVE UTILITIES (6 functions)
|
|
31
54
|
* - ensureProfilesDirectory(profilesDir) - Ensure profiles directory exists
|
|
32
55
|
* - sleep(ms) - Pause execution for specified duration
|
|
33
56
|
* - readInput(prompt, options) - Read user input from stdin
|
|
34
57
|
* - readPassword(prompt) - Read password with masked echo
|
|
35
58
|
* - withRetry(fn, options) - Execute async function with exponential backoff
|
|
36
|
-
* - withTimeout(promise, timeoutMs, options) - defined in ./timeout
|
|
37
59
|
* - withBlockchainRetry(fn, label, options) - Blockchain op with timeout + retry + node failover
|
|
60
|
+
* (withTimeout lives in ./timeout)
|
|
38
61
|
*
|
|
39
|
-
* SECTION
|
|
62
|
+
* SECTION 8: GENERAL UTILITIES (7 functions)
|
|
40
63
|
* - resolveAccountRef(manager, account) - Resolve best account reference
|
|
41
64
|
* - deepFreeze(obj) - Recursively freeze object for immutability
|
|
42
65
|
* - cloneMap(map) - Create shallow clone of Map
|
|
43
66
|
* - ensureDir(dirPath) - Ensure directory exists, creating recursively
|
|
67
|
+
* - nowIso() - Current time as an ISO string
|
|
68
|
+
* - fireStructuralResync(manager, ...) - Fire-and-forget structural grid resync
|
|
44
69
|
* - parseJsonWithComments(raw) - Parse JSON with comment stripping
|
|
45
70
|
*
|
|
71
|
+
* STRUCTURAL VIEW TYPES:
|
|
72
|
+
* AssetMeta, PoolReserve, PoolEntry, BitSharesClient, AmaCenterSnapshot,
|
|
73
|
+
* FeeCacheEntryData, SpreadCorrectionRefusalReason, SpreadCorrectionReadiness,
|
|
74
|
+
* UnmatchedChainOrderLike, GridResizeResult, CowResult
|
|
75
|
+
*
|
|
46
76
|
* ===============================================================================
|
|
47
77
|
*/
|
|
48
78
|
import type { OrderManagerLike, BotLike, AccountOrdersLike, ManagedOrder, AccountTotals, CowAction } from '../../types.js';
|
|
@@ -4,45 +4,75 @@
|
|
|
4
4
|
* Price derivation, persistence, grid correction, and UI/interactive utilities.
|
|
5
5
|
*
|
|
6
6
|
* ===============================================================================
|
|
7
|
-
* TABLE OF CONTENTS (
|
|
7
|
+
* TABLE OF CONTENTS (43 exported functions + 11 structural view types)
|
|
8
8
|
* ===============================================================================
|
|
9
9
|
*
|
|
10
|
-
* SECTION 1: PRICE DERIVATION (
|
|
10
|
+
* SECTION 1: PRICE DERIVATION (9 functions + 1 internal)
|
|
11
11
|
* - lookupAsset(BitShares, symbol) - Lookup asset metadata from blockchain
|
|
12
|
+
* - resolveAssetByRef(BitShares, ref) - Resolve a full asset object from id/symbol
|
|
12
13
|
* - deriveMarketPrice(BitShares, symA, symB) - Derive price from order book
|
|
13
14
|
* - derivePoolPrice(BitShares, symA, symB) - Derive price from liquidity pool
|
|
15
|
+
* - setDerivePriceTestHook(hook) - Test-only seam for derivePrice
|
|
14
16
|
* - derivePrice(BitShares, symA, symB, mode) - Derive price with fallback chain
|
|
15
17
|
* - derivePriceViaBridges(BitShares, symA, symB, bridges, mode) - Multi-hop price via bridge assets
|
|
16
18
|
* - derivePriceWithBridges(BitShares, symA, symB, bridges, mode) - Direct price, else bridge hops
|
|
17
|
-
* - resolveLiquidityPoolByShareAsset(BitShares, shareAsset) - Resolve LP by share asset
|
|
18
19
|
* - deriveLiquidityPoolTokenValue(BitShares, symA, symB) - Derive LP token value
|
|
19
|
-
* -
|
|
20
|
-
* - loadAmaCenterSnapshot(manager) - Load AMA center snapshot
|
|
20
|
+
* - resolveLiquidityPoolByShareAsset(BitShares, shareAsset) - Resolve LP by share asset (internal)
|
|
21
21
|
*
|
|
22
|
-
* SECTION 2:
|
|
22
|
+
* SECTION 2: AMA CENTER SNAPSHOT (2 functions)
|
|
23
|
+
* - loadAmaCenterSnapshot(manager) - Load the full dynamic-grid snapshot
|
|
24
|
+
* - loadAmaCenterPrice(manager) - Load the AMA center price
|
|
25
|
+
*
|
|
26
|
+
* SECTION 3: FEE MANAGEMENT (1 function)
|
|
23
27
|
* - initializeFeeCache(botsConfig, BitShares) - Initialize fee cache from blockchain
|
|
24
28
|
*
|
|
25
|
-
* SECTION
|
|
29
|
+
* SECTION 4: GRID STATE MANAGEMENT (5 functions)
|
|
26
30
|
* - persistGridSnapshot(manager, accountOrders) - Persist grid to storage
|
|
31
|
+
* - restoreGapEvacStreaks(manager) - Restore persisted gap-evacuation streaks
|
|
27
32
|
* - retryPersistenceIfNeeded(manager) - Retry persistence if previous failed
|
|
28
33
|
* - applyGridDivergenceCorrections(manager, ...) - Apply grid divergence corrections
|
|
29
|
-
*
|
|
30
|
-
*
|
|
34
|
+
* - applyPersistedPendingCrawls(...) - Apply persisted-but-uncommitted fill crawls
|
|
35
|
+
*
|
|
36
|
+
* SECTION 5: SPREAD-CORRECTION READINESS (7 functions)
|
|
37
|
+
* - resolveSpreadFreshnessMs(manager) - The single freshness window for spread trust
|
|
38
|
+
* - resolveSpreadCrossingFloor(manager) - Crossing floor spread correction must not trade through
|
|
39
|
+
* - refreshLiveMarketPrice(manager) - Refresh the cached live market price
|
|
40
|
+
* - maybeRefreshLiveMarketPrice(manager) - Refresh if stale, paced to one attempt per window
|
|
41
|
+
* - evaluateSpreadCorrectionReadiness(manager) - Evaluate whether spread correction may act
|
|
42
|
+
* - resolveSpreadMarketReference(manager) - Resolve the last real FILL price
|
|
43
|
+
* - resolveLastFillGuardReference(manager) - Resolve the reference the LAST-FILL-GUARD judges
|
|
44
|
+
*
|
|
45
|
+
* SECTION 6: LAST-FILL / MARKET-FILL PERSISTENCE (6 functions)
|
|
46
|
+
* - restoreLastMarketFill(manager) - Restore the persisted last-market-fill reference
|
|
47
|
+
* - normalizeLastFillPivot(row) - Normalize a persisted LAST-FILL-GUARD pivot row
|
|
48
|
+
* - normalizeLastMarketFill(row) - Normalize a persisted last-market-fill row
|
|
49
|
+
* - setLastFillPivot(manager, ...) - Write the LAST-FILL-GUARD pivot scalar family
|
|
50
|
+
* - resetLastFillPivot(manager) - Clear the pivot to cold state
|
|
51
|
+
* - restoreLastFillPivot(manager) - Restore the persisted pivot into the manager
|
|
52
|
+
*
|
|
53
|
+
* SECTION 7: UI & INTERACTIVE UTILITIES (6 functions)
|
|
31
54
|
* - ensureProfilesDirectory(profilesDir) - Ensure profiles directory exists
|
|
32
55
|
* - sleep(ms) - Pause execution for specified duration
|
|
33
56
|
* - readInput(prompt, options) - Read user input from stdin
|
|
34
57
|
* - readPassword(prompt) - Read password with masked echo
|
|
35
58
|
* - withRetry(fn, options) - Execute async function with exponential backoff
|
|
36
|
-
* - withTimeout(promise, timeoutMs, options) - defined in ./timeout
|
|
37
59
|
* - withBlockchainRetry(fn, label, options) - Blockchain op with timeout + retry + node failover
|
|
60
|
+
* (withTimeout lives in ./timeout)
|
|
38
61
|
*
|
|
39
|
-
* SECTION
|
|
62
|
+
* SECTION 8: GENERAL UTILITIES (7 functions)
|
|
40
63
|
* - resolveAccountRef(manager, account) - Resolve best account reference
|
|
41
64
|
* - deepFreeze(obj) - Recursively freeze object for immutability
|
|
42
65
|
* - cloneMap(map) - Create shallow clone of Map
|
|
43
66
|
* - ensureDir(dirPath) - Ensure directory exists, creating recursively
|
|
67
|
+
* - nowIso() - Current time as an ISO string
|
|
68
|
+
* - fireStructuralResync(manager, ...) - Fire-and-forget structural grid resync
|
|
44
69
|
* - parseJsonWithComments(raw) - Parse JSON with comment stripping
|
|
45
70
|
*
|
|
71
|
+
* STRUCTURAL VIEW TYPES:
|
|
72
|
+
* AssetMeta, PoolReserve, PoolEntry, BitSharesClient, AmaCenterSnapshot,
|
|
73
|
+
* FeeCacheEntryData, SpreadCorrectionRefusalReason, SpreadCorrectionReadiness,
|
|
74
|
+
* UnmatchedChainOrderLike, GridResizeResult, CowResult
|
|
75
|
+
*
|
|
46
76
|
* ===============================================================================
|
|
47
77
|
*/
|
|
48
78
|
import { createRequire } from 'node:module';
|
|
@@ -12,14 +12,17 @@
|
|
|
12
12
|
* SECTION 2: VALIDATION
|
|
13
13
|
* - validateOrder()
|
|
14
14
|
* - validateGridForPersistence()
|
|
15
|
-
* - calculateRequiredFunds()
|
|
15
|
+
* - calculateRequiredFunds() (internal)
|
|
16
16
|
* - validateWorkingGridFunds()
|
|
17
17
|
* - checkFundDrift()
|
|
18
18
|
*
|
|
19
19
|
* SECTION 3: GRID RECONCILIATION (COW Pipeline)
|
|
20
20
|
* - reconcileGrid()
|
|
21
21
|
* - optimizeRebalanceActions()
|
|
22
|
-
* - summarizeActions()
|
|
22
|
+
* - summarizeActions() (internal)
|
|
23
|
+
* - hasExecutableActions()
|
|
24
|
+
* - validateCreateTargetSlots()
|
|
25
|
+
* - stampGapEvacuationRotation()
|
|
23
26
|
* - hasActionForOrder()
|
|
24
27
|
* - removeActionsForOrder()
|
|
25
28
|
* - projectTargetToWorkingGrid()
|
|
@@ -12,14 +12,17 @@
|
|
|
12
12
|
* SECTION 2: VALIDATION
|
|
13
13
|
* - validateOrder()
|
|
14
14
|
* - validateGridForPersistence()
|
|
15
|
-
* - calculateRequiredFunds()
|
|
15
|
+
* - calculateRequiredFunds() (internal)
|
|
16
16
|
* - validateWorkingGridFunds()
|
|
17
17
|
* - checkFundDrift()
|
|
18
18
|
*
|
|
19
19
|
* SECTION 3: GRID RECONCILIATION (COW Pipeline)
|
|
20
20
|
* - reconcileGrid()
|
|
21
21
|
* - optimizeRebalanceActions()
|
|
22
|
-
* - summarizeActions()
|
|
22
|
+
* - summarizeActions() (internal)
|
|
23
|
+
* - hasExecutableActions()
|
|
24
|
+
* - validateCreateTargetSlots()
|
|
25
|
+
* - stampGapEvacuationRotation()
|
|
23
26
|
* - hasActionForOrder()
|
|
24
27
|
* - removeActionsForOrder()
|
|
25
28
|
* - projectTargetToWorkingGrid()
|
|
@@ -3,11 +3,11 @@
|
|
|
3
3
|
*
|
|
4
4
|
* BitShares stores asset symbols canonically UPPERCASE, so the assetA and
|
|
5
5
|
* assetB symbols of a bot pair are always UPPERCASE on chain.
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
* from
|
|
9
|
-
* cache-file names, Kibana query terms, and
|
|
10
|
-
*
|
|
6
|
+
* `lookup_asset_symbols` is case-sensitive: a lowercase symbol resolves to
|
|
7
|
+
* null (not an error), so a lowercase input silently drops the asset. Casing
|
|
8
|
+
* also leaks into everything built from a resolved symbol: the `symbol` field
|
|
9
|
+
* we attach to assets, chart titles, cache-file names, Kibana query terms, and
|
|
10
|
+
* strict in-process comparisons such as `assetA === 'CORE'`. That is a
|
|
11
11
|
* silent-wrong-answer class of bug, not a loud
|
|
12
12
|
* one, so the conversion is done ONCE here and applied at every boundary that
|
|
13
13
|
* accepts a pair from a human (CLI prompts, `dexbot tv`/`dw` targets) or hands
|
|
@@ -3,11 +3,11 @@
|
|
|
3
3
|
*
|
|
4
4
|
* BitShares stores asset symbols canonically UPPERCASE, so the assetA and
|
|
5
5
|
* assetB symbols of a bot pair are always UPPERCASE on chain.
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
* from
|
|
9
|
-
* cache-file names, Kibana query terms, and
|
|
10
|
-
*
|
|
6
|
+
* `lookup_asset_symbols` is case-sensitive: a lowercase symbol resolves to
|
|
7
|
+
* null (not an error), so a lowercase input silently drops the asset. Casing
|
|
8
|
+
* also leaks into everything built from a resolved symbol: the `symbol` field
|
|
9
|
+
* we attach to assets, chart titles, cache-file names, Kibana query terms, and
|
|
10
|
+
* strict in-process comparisons such as `assetA === 'CORE'`. That is a
|
|
11
11
|
* silent-wrong-answer class of bug, not a loud
|
|
12
12
|
* one, so the conversion is done ONCE here and applied at every boundary that
|
|
13
13
|
* accepts a pair from a human (CLI prompts, `dexbot tv`/`dw` targets) or hands
|
|
@@ -43,7 +43,8 @@ export declare function sleepMs(ms: number): Promise<void>;
|
|
|
43
43
|
* queries) must throw immediately — retrying those only burns time.
|
|
44
44
|
*
|
|
45
45
|
* Single home for the predicate previously triplicated across
|
|
46
|
-
* kibana_client.ts / kibana_candles.ts
|
|
46
|
+
* market_adapter/core/kibana_client.ts / market_adapter/core/kibana_candles.ts
|
|
47
|
+
* / market_adapter/inputs/kibana_feed_source.ts.
|
|
47
48
|
*/
|
|
48
49
|
export declare function isTransientNetworkError(err: unknown): boolean;
|
|
49
50
|
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -70,7 +70,8 @@ export function sleepMs(ms) {
|
|
|
70
70
|
* queries) must throw immediately — retrying those only burns time.
|
|
71
71
|
*
|
|
72
72
|
* Single home for the predicate previously triplicated across
|
|
73
|
-
* kibana_client.ts / kibana_candles.ts
|
|
73
|
+
* market_adapter/core/kibana_client.ts / market_adapter/core/kibana_candles.ts
|
|
74
|
+
* / market_adapter/inputs/kibana_feed_source.ts.
|
|
74
75
|
*/
|
|
75
76
|
export function isTransientNetworkError(err) {
|
|
76
77
|
const msg = String(getErrorMessage(err) || '');
|
|
@@ -14,5 +14,37 @@
|
|
|
14
14
|
* CLI: dexbot rich <ASSET> [ASSET...] [--top N]
|
|
15
15
|
* npm run richlist -- <ASSET> --top 10
|
|
16
16
|
*/
|
|
17
|
+
interface AssetRef {
|
|
18
|
+
request: string;
|
|
19
|
+
found: boolean;
|
|
20
|
+
id?: string;
|
|
21
|
+
symbol?: string;
|
|
22
|
+
precision?: number;
|
|
23
|
+
alias?: string;
|
|
24
|
+
}
|
|
25
|
+
interface Session {
|
|
26
|
+
client: RpcClient;
|
|
27
|
+
assetApi: number;
|
|
28
|
+
dbApi: number;
|
|
29
|
+
holderLimit: number;
|
|
30
|
+
}
|
|
31
|
+
declare class RpcClient {
|
|
32
|
+
readonly url: string;
|
|
33
|
+
private _id;
|
|
34
|
+
private _pending;
|
|
35
|
+
private _closed;
|
|
36
|
+
private _ws;
|
|
37
|
+
constructor(url: string);
|
|
38
|
+
connect(timeoutMs?: number): Promise<void>;
|
|
39
|
+
call<T = unknown>(api: number, method: string, args: unknown[], timeoutMs?: number): Promise<T>;
|
|
40
|
+
close(): void;
|
|
41
|
+
}
|
|
42
|
+
export declare function lookupSymbols(session: Session, symbolsOrIds: string[]): Promise<AssetRef[]>;
|
|
43
|
+
/**
|
|
44
|
+
* Look up symbols/ids. Legacy `bit*` MPA names were renamed on-chain without the
|
|
45
|
+
* `bit` prefix, so unresolved `bit*` names are retried stripped and reported as
|
|
46
|
+
* an alias.
|
|
47
|
+
*/
|
|
48
|
+
export declare function fetchAssets(session: Session, symbolsOrIds: string[]): Promise<AssetRef[]>;
|
|
17
49
|
export {};
|
|
18
50
|
//# sourceMappingURL=rich_list.d.ts.map
|
|
@@ -14,6 +14,8 @@
|
|
|
14
14
|
* CLI: dexbot rich <ASSET> [ASSET...] [--top N]
|
|
15
15
|
* npm run richlist -- <ASSET> --top 10
|
|
16
16
|
*/
|
|
17
|
+
import { pathToFileURL } from 'node:url';
|
|
18
|
+
import { normalizeAssetSymbol } from '../modules/utils/asset_symbols.js';
|
|
17
19
|
const DB_API = 0; // database_api is always registered first
|
|
18
20
|
const LOGIN_API = 1; // login_api (registered second)
|
|
19
21
|
const FALLBACK_HOLDER_LIMIT = 100; // used when the node does not report api_limit_get_asset_holders
|
|
@@ -239,11 +241,16 @@ async function readHolderLimit(client) {
|
|
|
239
241
|
// ---------------------------------------------------------------------------
|
|
240
242
|
// Chain queries
|
|
241
243
|
// ---------------------------------------------------------------------------
|
|
242
|
-
async function lookupSymbols(session, symbolsOrIds) {
|
|
244
|
+
export async function lookupSymbols(session, symbolsOrIds) {
|
|
243
245
|
const out = [];
|
|
244
246
|
for (let i = 0; i < symbolsOrIds.length; i += LOOKUP_PAGE) {
|
|
245
247
|
const slice = symbolsOrIds.slice(i, i + LOOKUP_PAGE);
|
|
246
|
-
|
|
248
|
+
// `lookup_asset_symbols` is case-sensitive: a lowercase symbol returns
|
|
249
|
+
// null on-chain, so canonicalize before handing it to the node. Asset
|
|
250
|
+
// object ids ("1.3.x") pass through untouched. `request` keeps the
|
|
251
|
+
// caller's spelling so "asset not found" still echoes the input.
|
|
252
|
+
const refs = slice.map((s) => normalizeAssetSymbol(s));
|
|
253
|
+
const res = await session.client.call(session.dbApi, 'lookup_asset_symbols', [refs]);
|
|
247
254
|
res.forEach((a, j) => out.push(a
|
|
248
255
|
? { request: slice[j], found: true, id: a.id, symbol: a.symbol, precision: a.precision }
|
|
249
256
|
: { request: slice[j], found: false }));
|
|
@@ -255,7 +262,7 @@ async function lookupSymbols(session, symbolsOrIds) {
|
|
|
255
262
|
* `bit` prefix, so unresolved `bit*` names are retried stripped and reported as
|
|
256
263
|
* an alias.
|
|
257
264
|
*/
|
|
258
|
-
async function fetchAssets(session, symbolsOrIds) {
|
|
265
|
+
export async function fetchAssets(session, symbolsOrIds) {
|
|
259
266
|
const out = await lookupSymbols(session, symbolsOrIds);
|
|
260
267
|
const retry = [];
|
|
261
268
|
out.forEach((a, i) => {
|
|
@@ -453,9 +460,10 @@ async function main() {
|
|
|
453
460
|
session.client.close();
|
|
454
461
|
}
|
|
455
462
|
}
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
463
|
+
if (process.argv[1] && import.meta.url === pathToFileURL(process.argv[1]).href) {
|
|
464
|
+
main().catch((e) => {
|
|
465
|
+
console.error(`Error: ${e.message}`);
|
|
466
|
+
process.exit(1);
|
|
467
|
+
});
|
|
468
|
+
}
|
|
461
469
|
//# sourceMappingURL=rich_list.js.map
|
package/dist/unlock.js
CHANGED
|
@@ -25,10 +25,13 @@ const __dirname = _esmDirname(__filename);
|
|
|
25
25
|
* dexbot start --headless Non-interactive (requires env var or --password-file)
|
|
26
26
|
* dexbot start --headless --password-file <path>
|
|
27
27
|
* dexbot stat, status Runtime status
|
|
28
|
-
* dexbot stop
|
|
29
|
-
*
|
|
30
|
-
*
|
|
31
|
-
* dexbot
|
|
28
|
+
* dexbot stop [<bot>] Stop the runtime. In monolithic mode a target folds
|
|
29
|
+
* into the whole runtime (one worker owns every bot);
|
|
30
|
+
* under --isolated it stops just that bot.
|
|
31
|
+
* dexbot reload [<bot>] Reload without re-unlocking the credential daemon
|
|
32
|
+
* (same target rules as stop)
|
|
33
|
+
* dexbot restart [<bot>] Restart (re-unlocks the credential daemon)
|
|
34
|
+
* dexbot delete Shut down and clean up (whole runtime only)
|
|
32
35
|
*
|
|
33
36
|
* Repo-root users can run `./unlock` instead.
|
|
34
37
|
* `dexbot unlock` is kept as a legacy alias for `dexbot start`.
|
|
@@ -71,7 +74,8 @@ const storage = getStorage();
|
|
|
71
74
|
const { ensureDir } = storage;
|
|
72
75
|
const { createBotSupervisor, SOCKET_PATH, forwardSignal, isPidAlive, waitForPidExit, readMarketAdapterLockPid, stopMarketAdapterFromLock, usesAmaGridPrice, waitForChildSpawn, pidMatchesScriptCandidates, candidateRuntimeScriptPaths, } = require('./modules/launcher/bot_supervisor');
|
|
73
76
|
const { statusTitle, statusLabel, statusBool, statusActiveBotName, statusSuccess, statusError, colorStatus, STATUS_COLORS, readProcStat, readProcMemMB, readProcCpuTime, readProcCpuPercent, readProcUptime, formatMemoryWithUptime, printControlStatus, } = require('./modules/launcher/status_reporting');
|
|
74
|
-
const { MONOLITHIC_PID_FILE, MONOLITHIC_BOT_PID_FILE, MONOLITHIC_BOT_INFO_FILE, MONOLITHIC_CRED_PID_FILE, MONOLITHIC_OUT_LOG, MONOLITHIC_ERROR_LOG, CREDENTIAL_SOCKET_FILE, cleanupStateFiles, readLiveMonolithicPid, readMonolithicBotInfo, isLikelyCredentialDaemonProcess, isExpectedMonolithicBotPid, isProcessInDstate, stopCredentialDaemonPid, stopCredentialDaemon, ensureNoForeignCredentialDaemon, findCredentialSocketOwnerPid, cleanupCredentialRuntimeFiles, readCredentialDaemonStatus, ensureLogDir: ensureMonolithicLogDir, buildDexbotStartArgs, createUpdateScheduler, listConfiguredBots, getControlBotNames, getControlActionLabel, getControlServiceNames, printControlActionSummary, formatBotCount, } = require('./modules/launcher/monolithic_runtime');
|
|
77
|
+
const { MONOLITHIC_PID_FILE, MONOLITHIC_BOT_PID_FILE, MONOLITHIC_BOT_INFO_FILE, MONOLITHIC_CRED_PID_FILE, MONOLITHIC_OUT_LOG, MONOLITHIC_ERROR_LOG, CREDENTIAL_SOCKET_FILE, cleanupStateFiles, readLiveMonolithicPid, readMonolithicBotInfo, isLikelyCredentialDaemonProcess, isExpectedMonolithicBotPid, isProcessInDstate, stopCredentialDaemonPid, stopCredentialDaemon, ensureNoForeignCredentialDaemon, findCredentialSocketOwnerPid, cleanupCredentialRuntimeFiles, readCredentialDaemonStatus, ensureLogDir: ensureMonolithicLogDir, buildDexbotStartArgs, createUpdateScheduler, listConfiguredBots, getControlBotNames, getControlActionLabel, getControlServiceNames, resolveControlRouting, botNotFoundMessage, printControlActionSummary, formatBotCount, } = require('./modules/launcher/monolithic_runtime');
|
|
78
|
+
const { isConfiguredBotName } = require('./modules/launcher/runtime_mode');
|
|
75
79
|
const CODE_ROOT = __dirname;
|
|
76
80
|
const BOTS_FILE = PATHS.PROFILES.BOTS_JSON;
|
|
77
81
|
const LOGS_DIR = PATHS.LOGS_DIR;
|
|
@@ -329,7 +333,7 @@ async function runIsolated({ botName, botEntry = null, stayResident = false, sta
|
|
|
329
333
|
if (botName) {
|
|
330
334
|
const bot = botEntry || resolveBotEntryForName(botName);
|
|
331
335
|
if (!bot) {
|
|
332
|
-
throw new Error(
|
|
336
|
+
throw new Error(botNotFoundMessage(botName));
|
|
333
337
|
}
|
|
334
338
|
supervisor = createBotSupervisor({ bots: [bot] });
|
|
335
339
|
}
|
|
@@ -502,7 +506,7 @@ async function main({ argv = process.argv, startupGraceMs = DEFAULT_STARTUP_GRAC
|
|
|
502
506
|
const shouldStartMonolithicBackground = !clawOnly && !isolated && !isDetachedSupervisorChild && !isMonolithicBgChild && !forceForeground;
|
|
503
507
|
let daemonReleased = false;
|
|
504
508
|
if (botName && !selectedBot) {
|
|
505
|
-
throw new Error(
|
|
509
|
+
throw new Error(botNotFoundMessage(botName));
|
|
506
510
|
}
|
|
507
511
|
if (shouldStartMonolithicBackground) {
|
|
508
512
|
const { pid } = readLiveMonolithicPid();
|
|
@@ -914,10 +918,37 @@ async function drainMonolithicWorkers(deadlineMs = 15000) {
|
|
|
914
918
|
return false;
|
|
915
919
|
}
|
|
916
920
|
async function handleControl({ cmd, target }) {
|
|
917
|
-
|
|
921
|
+
// Resolve the whole-runtime vs per-bot contract in one place. A live
|
|
922
|
+
// monolithic runtime owns every active bot in a single worker, so a bot
|
|
923
|
+
// target cannot be honored and degrades to the whole-runtime command with
|
|
924
|
+
// a printed notice (see resolveControlRouting). `all` is an alias for the
|
|
925
|
+
// whole runtime; `delete` rejects a bot target and `status` validates then
|
|
926
|
+
// ignores one.
|
|
927
|
+
const monolithic = readLiveMonolithicPid();
|
|
928
|
+
const routing = resolveControlRouting({ cmd, target, monolithicLive: monolithic.pid > 0 });
|
|
929
|
+
const effectiveCmd = routing.cmd;
|
|
930
|
+
const effectiveTarget = routing.target;
|
|
918
931
|
const actionLabel = getControlActionLabel(cmd);
|
|
919
|
-
if (
|
|
920
|
-
|
|
932
|
+
if (routing.reject) {
|
|
933
|
+
console.error(statusError(routing.reject));
|
|
934
|
+
process.exitCode = 1;
|
|
935
|
+
return;
|
|
936
|
+
}
|
|
937
|
+
// Validate a target only when it is about to be folded into a whole-runtime
|
|
938
|
+
// action (monolithic, or an ignored `status`): a typo must not reload/stop
|
|
939
|
+
// every bot by mistake. A pass-through to the isolated supervisor is
|
|
940
|
+
// validated there against the bots it actually runs, so a bot renamed or
|
|
941
|
+
// removed from bots.json while running can still be controlled by name.
|
|
942
|
+
const requestedTarget = routing.requestedTarget;
|
|
943
|
+
if (routing.folded && requestedTarget && !isConfiguredBotName(requestedTarget)) {
|
|
944
|
+
console.error(statusError(botNotFoundMessage(requestedTarget)));
|
|
945
|
+
process.exitCode = 1;
|
|
946
|
+
return;
|
|
947
|
+
}
|
|
948
|
+
if (routing.notice)
|
|
949
|
+
console.warn(routing.notice);
|
|
950
|
+
if ((effectiveCmd === 'stop-all' || effectiveCmd === 'delete' || effectiveCmd === 'status' || effectiveCmd === 'restart-all' || effectiveCmd === 'reload-all') && !effectiveTarget) {
|
|
951
|
+
const { pid, stale } = monolithic;
|
|
921
952
|
if (pid > 0) {
|
|
922
953
|
const summaryBotNames = getControlBotNames(undefined, true);
|
|
923
954
|
const summaryServiceNames = getControlServiceNames(effectiveCmd, summaryBotNames);
|
|
@@ -1093,11 +1124,11 @@ async function handleControl({ cmd, target }) {
|
|
|
1093
1124
|
// wrapper was killed without leaving a pid file, or cleanupStateFiles
|
|
1094
1125
|
// already ran). Drain before the isolated fall-through so that path cannot
|
|
1095
1126
|
// race a start into a duplicate worker.
|
|
1096
|
-
if (!
|
|
1127
|
+
if (!effectiveTarget && effectiveCmd !== 'status'
|
|
1097
1128
|
&& (effectiveCmd === 'stop-all' || effectiveCmd === 'delete' || effectiveCmd === 'restart-all' || effectiveCmd === 'reload-all')) {
|
|
1098
1129
|
await drainMonolithicWorkers();
|
|
1099
1130
|
}
|
|
1100
|
-
if (effectiveCmd === 'delete' && !
|
|
1131
|
+
if (effectiveCmd === 'delete' && !effectiveTarget && storage.exists(MONOLITHIC_CRED_PID_FILE)) {
|
|
1101
1132
|
await sendIsolatedDeleteIfAvailable();
|
|
1102
1133
|
const credResult = await stopCredentialDaemon();
|
|
1103
1134
|
if (credResult.signaled) {
|
|
@@ -1111,10 +1142,10 @@ async function handleControl({ cmd, target }) {
|
|
|
1111
1142
|
}
|
|
1112
1143
|
// Fall through to isolated supervisor socket
|
|
1113
1144
|
const controlCmd = { cmd: effectiveCmd };
|
|
1114
|
-
if (
|
|
1115
|
-
controlCmd.bot =
|
|
1145
|
+
if (effectiveTarget)
|
|
1146
|
+
controlCmd.bot = effectiveTarget;
|
|
1116
1147
|
// Restart credential daemon for restart-all (no target) in isolated mode
|
|
1117
|
-
if (!
|
|
1148
|
+
if (!effectiveTarget && effectiveCmd === 'restart-all' && process.stdin.isTTY) {
|
|
1118
1149
|
const ownerPid = findCredentialSocketOwnerPid();
|
|
1119
1150
|
if (ownerPid > 0 && isLikelyCredentialDaemonProcess(ownerPid)) {
|
|
1120
1151
|
await stopCredentialDaemonPid(ownerPid);
|
|
@@ -1133,8 +1164,8 @@ async function handleControl({ cmd, target }) {
|
|
|
1133
1164
|
printControlStatus(resp.status);
|
|
1134
1165
|
}
|
|
1135
1166
|
else {
|
|
1136
|
-
if (
|
|
1137
|
-
const summaryBotNames = getControlBotNames(
|
|
1167
|
+
if (effectiveTarget || effectiveCmd === 'stop-all' || effectiveCmd === 'restart-all' || effectiveCmd === 'reload-all' || effectiveCmd === 'delete') {
|
|
1168
|
+
const summaryBotNames = getControlBotNames(effectiveTarget, !effectiveTarget && (effectiveCmd === 'stop-all' || effectiveCmd === 'restart-all' || effectiveCmd === 'reload-all' || effectiveCmd === 'delete'));
|
|
1138
1169
|
const summaryServiceNames = getControlServiceNames(effectiveCmd, summaryBotNames);
|
|
1139
1170
|
printControlActionSummary(actionLabel, summaryBotNames, summaryServiceNames);
|
|
1140
1171
|
}
|
|
@@ -1142,7 +1173,7 @@ async function handleControl({ cmd, target }) {
|
|
|
1142
1173
|
}
|
|
1143
1174
|
}
|
|
1144
1175
|
catch (err) {
|
|
1145
|
-
if (effectiveCmd === 'delete' && !
|
|
1176
|
+
if (effectiveCmd === 'delete' && !effectiveTarget && isSupervisorTransientError(err)) {
|
|
1146
1177
|
console.log('No runtime processes found.');
|
|
1147
1178
|
return;
|
|
1148
1179
|
}
|
|
@@ -304,6 +304,13 @@ You can re-run `dexbot bot` and save while the bot runs:
|
|
|
304
304
|
- **Market/account changes** — run `dexbot reload` (reloads the runtime
|
|
305
305
|
without logging you out; a full `restart` also works).
|
|
306
306
|
|
|
307
|
+
> `dexbot reload` / `restart` / `stop` are **whole-runtime** in the default
|
|
308
|
+
> monolithic mode: every active bot shares one worker process, so passing a bot
|
|
309
|
+
> name (e.g. `dexbot reload <bot>`) is validated and then applied to the whole
|
|
310
|
+
> runtime with a notice. To act on a single bot, start with `dexbot start
|
|
311
|
+
> --isolated` first. `delete` is whole-runtime and rejects a bot name; `status`
|
|
312
|
+
> is whole-runtime and validates, then ignores, one.
|
|
313
|
+
|
|
307
314
|
The editor prints exactly which group your save falls into every time it
|
|
308
315
|
saves, so you always know whether anything else is needed.
|
|
309
316
|
|
package/docs/COW_INVARIANTS.md
CHANGED
|
@@ -257,7 +257,7 @@ This document defines the non-negotiable behavioral invariants for the DEXBot2 s
|
|
|
257
257
|
|
|
258
258
|
- `INV-BATCH-001` Illegal state batch abort
|
|
259
259
|
- `executeBatch` throws `ILLEGAL_SPREAD_STATE` on an illegal grid layout (emitted at `modules/order/utils/validate.ts`, propagated via `modules/order/manager.ts` `_throwOnIllegalState`).
|
|
260
|
-
- The `_handleBatchHardAbort` catch for `ILLEGAL_ORDER_STATE` (`dexbot_class.ts:
|
|
260
|
+
- The `_handleBatchHardAbort` catch for `ILLEGAL_ORDER_STATE` (`dexbot_class.ts:533`) is a test-only dead branch — production never emits that code; only a test stub uses it.
|
|
261
261
|
- In production, recovery + cooldown are armed on the next maintenance tick via `_abortFlowIfIllegalState` (the `INV-MAINT-002` path), returning `abortedForIllegalState: true` to the caller. The caller does not need to return immediately; the maintenance tick handles recovery.
|
|
262
262
|
- Hard abort triggers one immediate recovery sync (`_triggerStateRecoverySync`) plus arms one maintenance cooldown cycle (`_maintenanceCooldownCycles = Math.max(current, 1)`).
|
|
263
263
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# DEXBot vs DEXBot2 — Detailed Comparison Report
|
|
2
2
|
|
|
3
3
|
> **Date:** 2026-09-02 *(metrics refreshed against local source trees)*
|
|
4
|
-
> **Scope:** Full architectural, functional, and operational comparison between the original [DEXBot](https://github.com/Codaone/DEXBot) (Python, v1.0.0) and DEXBot2 (TypeScript, v1.6.
|
|
4
|
+
> **Scope:** Full architectural, functional, and operational comparison between the original [DEXBot](https://github.com/Codaone/DEXBot) (Python, v1.0.0) and DEXBot2 (TypeScript, v1.6.16).
|
|
5
5
|
> **Audience:** Developers, contributors, and operators evaluating or migrating between the two projects.
|
|
6
6
|
|
|
7
7
|
---
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
|
|
37
37
|
| Attribute | DEXBot (original) | DEXBot2 |
|
|
38
38
|
|---|---|---|
|
|
39
|
-
| **Release Track** | 1.0.0 | v1.6.
|
|
39
|
+
| **Release Track** | 1.0.0 | v1.6.16 |
|
|
40
40
|
| **Language** | Python 3.6+ | TypeScript 5.x |
|
|
41
41
|
| **Status** | Released 1.0.0, unmaintained | Active development |
|
|
42
42
|
| **Last Repo Activity** | May 23, 2020 | 2026-09-02 |
|
|
@@ -776,10 +776,10 @@ Where:
|
|
|
776
776
|
|
|
777
777
|
| Metric | DEXBot | DEXBot2 |
|
|
778
778
|
|---|---|---|
|
|
779
|
-
| **Release Track** | 1.0.0 | v1.6.
|
|
779
|
+
| **Release Track** | 1.0.0 | v1.6.16 |
|
|
780
780
|
| **Active Since** | ~2018 | December 2025 |
|
|
781
|
-
| **Last Commit** | May 23, 2020 | 2026-10-
|
|
782
|
-
| **Total Commits** | 2281 | 2,
|
|
781
|
+
| **Last Commit** | May 23, 2020 | 2026-10-18 |
|
|
782
|
+
| **Total Commits** | 2281 | 2,426 (current HEAD, v1.6.16 line) |
|
|
783
783
|
| **Lines of Code** | ~10,846 Python LOC in `dexbot/` | Large TypeScript runtime + adapter + Claw + analysis + tests |
|
|
784
784
|
| **Source Files** | 72 Python files in `dexbot/` | ~656 TS files across the repo |
|
|
785
785
|
| **Test Files** | 16 Python test files | 327 `test_*.ts` files (310 `tests/` + 17 `claw/tests/`, auto-discovered via `globSync`) |
|
package/docs/EVOLUTION.md
CHANGED
|
@@ -2,14 +2,14 @@
|
|
|
2
2
|
|
|
3
3
|
## Executive Summary
|
|
4
4
|
|
|
5
|
-
DEXBot2 is a sophisticated decentralized exchange trading bot for the BitShares blockchain. This report documents the complete evolution of the project from its inception in December 2025 through the current 1.6.
|
|
5
|
+
DEXBot2 is a sophisticated decentralized exchange trading bot for the BitShares blockchain. This report documents the complete evolution of the project from its inception in December 2025 through the current 1.6.16 release.
|
|
6
6
|
|
|
7
7
|
### Key Milestones
|
|
8
8
|
- **Project Inception**: December 2, 2025
|
|
9
|
-
- **Growth Phase**: 2,
|
|
9
|
+
- **Growth Phase**: 2,426 commits over ~9 active months
|
|
10
10
|
- **Code Maturity**: Evolution from basic utilities to a ~100,000+ LoC intelligent TypeScript system
|
|
11
11
|
- **Stability**: Progression from manual testing to a suite of 310 automated test files
|
|
12
|
-
- **Releases**:
|
|
12
|
+
- **Releases**: 148 version entries in the changelog (v0.1.0 to v1.6.16)
|
|
13
13
|
|
|
14
14
|
> **Post-1.0.0 "why":** the thematic story behind the hardening releases — root cause, recurring
|
|
15
15
|
> bug families, and lessons — lives in
|
|
@@ -149,7 +149,7 @@ Evolved from a basic README to a comprehensive framework (50+ docs entries, 80%+
|
|
|
149
149
|
|
|
150
150
|
## Version History
|
|
151
151
|
|
|
152
|
-
Compact, era-level view; commit counts are `git rev-list --count <tag>..<tag>` over the current history (2026-10-
|
|
152
|
+
Compact, era-level view; commit counts are `git rev-list --count <tag>..<tag>` over the current history (2026-10-18). The 107 commits up to and including the `v0.1.0` tag are not attributed to an era, so the current totals are 2,319 (`v0.1.0..HEAD`) and 2,426 (`HEAD`); the `v1.4.x` era rows overlap slightly because `v1.4.13` is not an ancestor of `v1.4.25` in the current history. Per-release detail lives in [CHANGELOG.md](../CHANGELOG.md); the thematic post-1.0.0 story in [ORDER_ENGINE_POST_1.0_RETROSPECTIVE.md](ORDER_ENGINE_POST_1.0_RETROSPECTIVE.md).
|
|
153
153
|
|
|
154
154
|
| Era | Commits | Theme |
|
|
155
155
|
|-----|--------:|-------|
|
|
@@ -173,11 +173,12 @@ Compact, era-level view; commit counts are `git rev-list --count <tag>..<tag>` o
|
|
|
173
173
|
| v1.6.12 → v1.6.13 | 21 | Spread-stall cause reporting + chain sync on every stall, resync-cascade guards (uncertain broadcast / suspended persistence), month-shard candle cache, dedup & dead-code purge, npm 12 install & PM2 fixes |
|
|
174
174
|
| v1.6.13 → v1.6.14 | 18 | Last-fill guard + live market floor for spread correction, committed-size drift resize, COW pre-broadcast guards & P2 counters, fail-closed unknown geometry, order-key rename, worker-thread test runner |
|
|
175
175
|
| v1.6.14 → v1.6.15 | 20 | Spread-correction resilience (atomic plan/retry, bounded re-plan, transient-refusal grace), price-vs-amount level identity for low-precision assets, credit-renewal free-collateral top-up, TradingView 1h/chart fixes & live data-age badge, per-asset `dexbot rich`, ~4x parallel test runner |
|
|
176
|
+
| v1.6.15 → v1.6.16 | 14 | Monolithic per-bot control routing, orientation-shared candle cache, market-profile orientation tolerance, chart log-axis hang fix + viewport-clipped draw hooks, Firefox Playwright chart suite, adapter-whitelist rename/copy sync, `dexbot rich` symbol canonicalization, doc reconciliation |
|
|
176
177
|
|
|
177
178
|
---
|
|
178
179
|
|
|
179
180
|
**Report Originally Generated**: February 19, 2026
|
|
180
|
-
**Last Updated**: October
|
|
181
|
-
**Total Commits**: 2,
|
|
182
|
-
**Date Range**: December 2, 2025 – October
|
|
181
|
+
**Last Updated**: October 18, 2026
|
|
182
|
+
**Total Commits**: 2,426
|
|
183
|
+
**Date Range**: December 2, 2025 – October 18, 2026
|
|
183
184
|
**Repository**: DEXBot2 (BitShares DEX Trading Bot)
|
|
@@ -52,7 +52,7 @@ funds.allocated → _getSizingContext() (budget for spread correction)
|
|
|
52
52
|
**Key points:**
|
|
53
53
|
- `botFunds` percentage applies to **total** capital (free + locked in orders), not just free. A bot at `"50%"` gets half of everything, not half of what's currently idle.
|
|
54
54
|
- `funds.allocated` is the ceiling for each side. Existing orders already consume part of it; the remaining free portion is available for new placements.
|
|
55
|
-
- The downstream `applyBotFundsAllocation()` (`manager.ts:
|
|
55
|
+
- The downstream `applyBotFundsAllocation()` (`manager.ts:1287`) also caps `funds.available` to `<= allocated` as a safety net, but the primary budget chokepoint is `getSideBudget` / `_getSizingContext` reading `allocated` directly (v1.2.6).
|
|
56
56
|
|
|
57
57
|
---
|
|
58
58
|
|
|
@@ -123,7 +123,7 @@ See [developer_guide.md#order-state-helper-functions](developer_guide.md#order-s
|
|
|
123
123
|
**Per-Batch Execution**:
|
|
124
124
|
|
|
125
125
|
1. **Peek & Pop**: Check `_incomingFillQueue`, pop up to N fills (batch size)
|
|
126
|
-
2. **Replay-safe Accounting Pass**: Each fill is accounted individually via `processFillAccounting(fillOp, fillKey)` with replay-safe dedup (`applyReplaySafeFillAccounting`, `dexbot_fill_runtime.ts:
|
|
126
|
+
2. **Replay-safe Accounting Pass**: Each fill is accounted individually via `processFillAccounting(fillOp, fillKey)` with replay-safe dedup (`applyReplaySafeFillAccounting`, `dexbot_fill_runtime.ts:300`)
|
|
127
127
|
- Proceeds credited directly to `chainFree` (via `adjustTotalBalance`)
|
|
128
128
|
- Same-order fill batching (sync_engine Phase 6 cumulative transition) aggregates multiple fill transitions on one order before a single rebalance
|
|
129
129
|
- All proceeds immediately available to next rebalance cycle (not split across cycles)
|
|
@@ -803,4 +803,4 @@ To prevent "Time-of-Check to Time-of-Use" errors:
|
|
|
803
803
|
**TOCTOU protection in `processFillAccounting`.** `_buildBtsDeferredRefundAdjustment` reads `btsFeeState` from `mgr.orders` while the order lock is held — the lock is acquired before accounting runs, and the POST-RESET and BOOTSTRAP tracked-fill accounting paths follow the same locking pattern.
|
|
804
804
|
|
|
805
805
|
---
|
|
806
|
-
*Technical Reference for DEXBot2 v1.6.
|
|
806
|
+
*Technical Reference for DEXBot2 v1.6.16 release*
|