dexbot 1.6.4 → 1.6.6
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 +75 -3
- package/README.md +109 -40
- package/analysis/README.md +19 -17
- package/analysis/account_resolver.ts +1 -11
- package/analysis/analyze_dynamic_weight.ts +9 -3
- package/analysis/bot_usage/kibana_bot_queries.ts +1 -1
- package/analysis/chain_pool.ts +1 -1
- package/analysis/fills_source.ts +0 -6
- package/analysis/grid_correction_check.ts +20 -26
- package/analysis/resolve_source.ts +1 -1
- package/analysis/trade_profitability.ts +2 -5
- package/analysis/tradingview/analyze_tradingview.ts +5 -0
- package/analysis/tradingview/tradingview_uplot_chart_generator.ts +2 -2
- package/analysis/trend_detection/DYNAMIC_WEIGHT_RESEARCH.md +35 -2
- package/analysis/trend_detection/README.md +1 -3
- package/analysis/trend_detection/dynamic_weight_chart_generator.ts +82 -10
- package/analysis/trend_detection/package.json +1 -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/claw/tests/test_dexbot_profiles.ts +18 -1
- package/dist/analysis/account_resolver.d.ts +1 -4
- package/dist/analysis/account_resolver.d.ts.map +1 -1
- package/dist/analysis/account_resolver.js +1 -1
- package/dist/analysis/account_resolver.js.map +1 -1
- package/dist/analysis/analyze_dynamic_weight.js +9 -3
- package/dist/analysis/analyze_dynamic_weight.js.map +1 -1
- package/dist/analysis/bot_usage/kibana_bot_queries.d.ts +1 -2
- package/dist/analysis/bot_usage/kibana_bot_queries.d.ts.map +1 -1
- package/dist/analysis/bot_usage/kibana_bot_queries.js +1 -1
- package/dist/analysis/bot_usage/kibana_bot_queries.js.map +1 -1
- package/dist/analysis/chain_pool.d.ts +1 -3
- package/dist/analysis/chain_pool.d.ts.map +1 -1
- package/dist/analysis/chain_pool.js +1 -1
- package/dist/analysis/chain_pool.js.map +1 -1
- package/dist/analysis/fills_source.d.ts +1 -51
- package/dist/analysis/fills_source.d.ts.map +1 -1
- package/dist/analysis/fills_source.js +1 -1
- package/dist/analysis/fills_source.js.map +1 -1
- package/dist/analysis/grid_correction_check.d.ts +2 -3
- package/dist/analysis/grid_correction_check.d.ts.map +1 -1
- package/dist/analysis/grid_correction_check.js +18 -26
- package/dist/analysis/grid_correction_check.js.map +1 -1
- package/dist/analysis/resolve_source.d.ts +1 -1
- package/dist/analysis/resolve_source.d.ts.map +1 -1
- package/dist/analysis/trade_profitability.d.ts.map +1 -1
- package/dist/analysis/trade_profitability.js +2 -7
- package/dist/analysis/trade_profitability.js.map +1 -1
- package/dist/analysis/tradingview/analyze_tradingview.d.ts.map +1 -1
- package/dist/analysis/tradingview/analyze_tradingview.js +5 -0
- package/dist/analysis/tradingview/analyze_tradingview.js.map +1 -1
- package/dist/analysis/tradingview/tradingview_uplot_chart_generator.js +2 -2
- package/dist/analysis/trend_detection/dynamic_weight_chart_generator.d.ts.map +1 -1
- package/dist/analysis/trend_detection/dynamic_weight_chart_generator.js +82 -10
- package/dist/analysis/trend_detection/dynamic_weight_chart_generator.js.map +1 -1
- package/dist/dexbot.d.ts.map +1 -1
- package/dist/dexbot.js +85 -140
- package/dist/dexbot.js.map +1 -1
- package/dist/market_adapter/core/asymmetric_bounds.d.ts +2 -2
- package/dist/market_adapter/core/asymmetric_bounds.d.ts.map +1 -1
- package/dist/market_adapter/core/asymmetric_bounds.js +15 -12
- package/dist/market_adapter/core/asymmetric_bounds.js.map +1 -1
- package/dist/market_adapter/core/kibana_candles.d.ts +1 -15
- package/dist/market_adapter/core/kibana_candles.d.ts.map +1 -1
- package/dist/market_adapter/core/kibana_candles.js +1 -1
- package/dist/market_adapter/core/kibana_candles.js.map +1 -1
- package/dist/market_adapter/inputs/fetch_lp_data.d.ts +1 -35
- package/dist/market_adapter/inputs/fetch_lp_data.d.ts.map +1 -1
- package/dist/market_adapter/inputs/fetch_lp_data.js +10 -54
- package/dist/market_adapter/inputs/fetch_lp_data.js.map +1 -1
- package/dist/market_adapter/inputs/kibana_feed_source.d.ts +1 -8
- package/dist/market_adapter/inputs/kibana_feed_source.d.ts.map +1 -1
- package/dist/market_adapter/inputs/kibana_feed_source.js +1 -1
- package/dist/market_adapter/inputs/kibana_feed_source.js.map +1 -1
- package/dist/market_adapter/inputs/window_cache.d.ts +2 -63
- package/dist/market_adapter/inputs/window_cache.d.ts.map +1 -1
- package/dist/market_adapter/inputs/window_cache.js +22 -102
- package/dist/market_adapter/inputs/window_cache.js.map +1 -1
- package/dist/market_adapter/interval_utils.d.ts +1 -1
- package/dist/market_adapter/interval_utils.js +1 -1
- package/dist/modules/account_bots.d.ts +70 -6
- package/dist/modules/account_bots.d.ts.map +1 -1
- package/dist/modules/account_bots.js +353 -149
- package/dist/modules/account_bots.js.map +1 -1
- package/dist/modules/bitshares-native/crypto/ecc.browser.d.ts.map +1 -1
- package/dist/modules/bitshares-native/crypto/ecc.browser.js +0 -31
- package/dist/modules/bitshares-native/crypto/ecc.browser.js.map +1 -1
- package/dist/modules/bot_defaults.d.ts +98 -0
- package/dist/modules/bot_defaults.d.ts.map +1 -0
- package/dist/modules/bot_defaults.js +169 -0
- package/dist/modules/bot_defaults.js.map +1 -0
- package/dist/modules/bot_settings.d.ts.map +1 -1
- package/dist/modules/bot_settings.js +4 -1
- package/dist/modules/bot_settings.js.map +1 -1
- package/dist/modules/config.d.ts +1 -0
- package/dist/modules/config.d.ts.map +1 -1
- package/dist/modules/config.js +1 -0
- package/dist/modules/config.js.map +1 -1
- package/dist/modules/constants.d.ts +11 -2
- package/dist/modules/constants.d.ts.map +1 -1
- package/dist/modules/constants.js +40 -27
- package/dist/modules/constants.js.map +1 -1
- package/dist/modules/credit_runtime.d.ts +0 -2
- package/dist/modules/credit_runtime.d.ts.map +1 -1
- package/dist/modules/credit_runtime.js +1 -10
- package/dist/modules/credit_runtime.js.map +1 -1
- package/dist/modules/dexbot_class.d.ts +13 -10
- package/dist/modules/dexbot_class.d.ts.map +1 -1
- package/dist/modules/dexbot_class.js +0 -9
- package/dist/modules/dexbot_class.js.map +1 -1
- package/dist/modules/dexbot_cow_runtime.d.ts +13 -0
- package/dist/modules/dexbot_cow_runtime.d.ts.map +1 -1
- package/dist/modules/dexbot_cow_runtime.js +13 -1
- package/dist/modules/dexbot_cow_runtime.js.map +1 -1
- package/dist/modules/dexbot_maintenance_runtime.d.ts +1 -1
- package/dist/modules/dexbot_maintenance_runtime.d.ts.map +1 -1
- package/dist/modules/dexbot_maintenance_runtime.js +9 -4
- package/dist/modules/dexbot_maintenance_runtime.js.map +1 -1
- package/dist/modules/launcher/adapter_requirement.js +1 -1
- package/dist/modules/launcher/launch_modes.d.ts +17 -1
- package/dist/modules/launcher/launch_modes.d.ts.map +1 -1
- package/dist/modules/launcher/launch_modes.js +18 -1
- package/dist/modules/launcher/launch_modes.js.map +1 -1
- package/dist/modules/launcher/monolithic_runtime.d.ts.map +1 -1
- package/dist/modules/launcher/monolithic_runtime.js +8 -1
- package/dist/modules/launcher/monolithic_runtime.js.map +1 -1
- package/dist/modules/market_adapter_whitelist.d.ts +40 -1
- package/dist/modules/market_adapter_whitelist.d.ts.map +1 -1
- package/dist/modules/market_adapter_whitelist.js +161 -11
- package/dist/modules/market_adapter_whitelist.js.map +1 -1
- package/dist/modules/order/accounting.d.ts +4 -18
- package/dist/modules/order/accounting.d.ts.map +1 -1
- package/dist/modules/order/accounting.js +4 -34
- package/dist/modules/order/accounting.js.map +1 -1
- package/dist/modules/order/export.d.ts +9 -12
- package/dist/modules/order/export.d.ts.map +1 -1
- package/dist/modules/order/export.js +9 -12
- package/dist/modules/order/export.js.map +1 -1
- package/dist/modules/order/grid.d.ts +44 -40
- package/dist/modules/order/grid.d.ts.map +1 -1
- package/dist/modules/order/grid.js +66 -48
- package/dist/modules/order/grid.js.map +1 -1
- package/dist/modules/order/grid_reconcile.d.ts.map +1 -1
- package/dist/modules/order/grid_reconcile.js +111 -20
- package/dist/modules/order/grid_reconcile.js.map +1 -1
- package/dist/modules/order/grid_reconcile_internal.d.ts +5 -3
- package/dist/modules/order/grid_reconcile_internal.d.ts.map +1 -1
- package/dist/modules/order/grid_reconcile_internal.js +18 -3
- package/dist/modules/order/grid_reconcile_internal.js.map +1 -1
- package/dist/modules/order/manager.d.ts +0 -8
- package/dist/modules/order/manager.d.ts.map +1 -1
- package/dist/modules/order/manager.js +3 -12
- package/dist/modules/order/manager.js.map +1 -1
- package/dist/modules/order/utils/order.d.ts +22 -7
- package/dist/modules/order/utils/order.d.ts.map +1 -1
- package/dist/modules/order/utils/order.js +103 -21
- package/dist/modules/order/utils/order.js.map +1 -1
- package/dist/modules/order/utils/system.d.ts +5 -1
- package/dist/modules/order/utils/system.d.ts.map +1 -1
- package/dist/modules/order/utils/system.js +5 -2
- package/dist/modules/order/utils/system.js.map +1 -1
- package/dist/modules/order/utils/withPoolRef.d.ts +12 -0
- package/dist/modules/order/utils/withPoolRef.d.ts.map +1 -1
- package/dist/modules/order/utils/withPoolRef.js +17 -0
- package/dist/modules/order/utils/withPoolRef.js.map +1 -1
- package/dist/modules/order/working_grid.d.ts +8 -13
- package/dist/modules/order/working_grid.d.ts.map +1 -1
- package/dist/modules/order/working_grid.js +8 -29
- package/dist/modules/order/working_grid.js.map +1 -1
- package/dist/modules/settings_merge.d.ts +10 -1
- package/dist/modules/settings_merge.d.ts.map +1 -1
- package/dist/modules/settings_merge.js +27 -17
- package/dist/modules/settings_merge.js.map +1 -1
- package/dist/modules/validate_profiles.d.ts.map +1 -1
- package/dist/modules/validate_profiles.js +4 -3
- package/dist/modules/validate_profiles.js.map +1 -1
- package/dist/scripts/chart_command.d.ts +48 -0
- package/dist/scripts/chart_command.d.ts.map +1 -0
- package/dist/scripts/chart_command.js +504 -0
- package/dist/scripts/chart_command.js.map +1 -0
- package/dist/scripts/dw.d.ts +3 -0
- package/dist/scripts/dw.d.ts.map +1 -0
- package/dist/scripts/dw.js +30 -0
- package/dist/scripts/dw.js.map +1 -0
- package/dist/scripts/sync-version.js +0 -22
- package/dist/scripts/sync-version.js.map +1 -1
- package/dist/scripts/tv.d.ts +1 -31
- package/dist/scripts/tv.d.ts.map +1 -1
- package/dist/scripts/tv.js +10 -463
- package/dist/scripts/tv.js.map +1 -1
- package/dist/scripts/update.js +99 -62
- package/dist/scripts/update.js.map +1 -1
- package/dist/scripts/update_dist_freshness.d.ts +58 -0
- package/dist/scripts/update_dist_freshness.d.ts.map +1 -0
- package/dist/scripts/update_dist_freshness.js +144 -0
- package/dist/scripts/update_dist_freshness.js.map +1 -0
- package/dist/unlock.js +1 -1
- package/dist/unlock.js.map +1 -1
- package/docs/BITSHARES_ONBOARDING.md +16 -10
- package/docs/COW_INVARIANTS.md +1 -0
- package/docs/DEXBOT_COMPARISON.md +11 -11
- package/docs/EVOLUTION.md +9 -7
- package/docs/FUND_MOVEMENT_AND_ACCOUNTING.md +4 -4
- package/docs/GRID_PRICE_INVARIANT.md +518 -0
- package/docs/GRID_RECALCULATION.md +20 -24
- package/docs/GRID_RECONCILE.md +62 -41
- package/docs/LOGGING.md +1 -0
- package/docs/ORDER_ENGINE_POST_1.0_RETROSPECTIVE.md +556 -0
- package/docs/README.md +18 -18
- package/docs/WORKFLOW.md +13 -8
- package/docs/architecture.md +42 -40
- package/docs/developer_guide.md +5 -8
- package/market_adapter/README.md +45 -65
- package/modules/README.md +3 -2
- package/package.json +7 -4
- package/scripts/README.md +18 -34
- package/scripts/reset-settings.sh +1 -1
- package/analysis/ama_fitting/package.json +0 -12
- package/analysis/analyze_derivatives.ts +0 -320
- package/analysis/derivative_chart_generator.ts +0 -874
- package/analysis/trend_detection/SIGNAL_DOCUMENTATION.md +0 -403
- package/analysis/trend_detection/derivative_analyzer.ts +0 -1059
- package/dist/analysis/analyze_derivatives.d.ts +0 -68
- package/dist/analysis/analyze_derivatives.d.ts.map +0 -1
- package/dist/analysis/analyze_derivatives.js +0 -287
- package/dist/analysis/analyze_derivatives.js.map +0 -1
- package/dist/analysis/derivative_chart_generator.d.ts +0 -12
- package/dist/analysis/derivative_chart_generator.d.ts.map +0 -1
- package/dist/analysis/derivative_chart_generator.js +0 -891
- package/dist/analysis/derivative_chart_generator.js.map +0 -1
- package/dist/analysis/trend_detection/derivative_analyzer.d.ts +0 -248
- package/dist/analysis/trend_detection/derivative_analyzer.d.ts.map +0 -1
- package/dist/analysis/trend_detection/derivative_analyzer.js +0 -910
- package/dist/analysis/trend_detection/derivative_analyzer.js.map +0 -1
- package/dist/scripts/generate_market_adapter_whitelist.d.ts +0 -15
- package/dist/scripts/generate_market_adapter_whitelist.d.ts.map +0 -1
- package/dist/scripts/generate_market_adapter_whitelist.js +0 -191
- package/dist/scripts/generate_market_adapter_whitelist.js.map +0 -1
package/docs/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
This directory contains the comprehensive technical documentation for the DEXBot2 trading bot. It is designed to guide developers from high-level architecture down to the nuances of fund accounting and state management.
|
|
4
4
|
|
|
5
|
-
**Version context:** v1.6.
|
|
5
|
+
**Version context:** v1.6.6 (released).
|
|
6
6
|
|
|
7
7
|
---
|
|
8
8
|
|
|
@@ -17,7 +17,7 @@ This directory contains the comprehensive technical documentation for the DEXBot
|
|
|
17
17
|
|
|
18
18
|
### 📡 [Market Adapter](../market_adapter/README.md)
|
|
19
19
|
*Live AMA pricing, dynamic weights, and recalc trigger orchestration.*
|
|
20
|
-
- **Quick Start**: Enable AMA,
|
|
20
|
+
- **Quick Start**: Enable AMA, set the per-bot adapter flags in `dexbot bot`, and start DEXBot2
|
|
21
21
|
- **Settings**: Global, pair, and bot-specific adapter overrides
|
|
22
22
|
- **Dynamic Weights**: How adapter signals write live weight snapshots
|
|
23
23
|
- **Troubleshooting**: Common adapter startup and trigger issues
|
|
@@ -32,7 +32,7 @@ This directory contains the comprehensive technical documentation for the DEXBot
|
|
|
32
32
|
|
|
33
33
|
### 📈 [Analysis](../analysis/README.md)
|
|
34
34
|
*Research runners, chart generators, and tuning helpers.*
|
|
35
|
-
- **Trend Detection**:
|
|
35
|
+
- **Trend Detection**: Hurst, Kalman, and regime analysis tools
|
|
36
36
|
- **AMA Fitting**: Parameter fitting, comparison charts, and LP data workflows
|
|
37
37
|
- **Bot Fitting**: Grid parameter sweep backtests for AMA winners
|
|
38
38
|
- **TradingView Exports**: Chart export utilities for visual analysis
|
|
@@ -44,7 +44,7 @@ This directory contains the comprehensive technical documentation for the DEXBot
|
|
|
44
44
|
- **Purpose**: Exposes BitShares capabilities and DEXBot2 infrastructure through JSON/CLI bridges, MCP, and runtime-native skill packaging for OpenClaw and compatible runtimes (see [claw/README.md](../claw/README.md) for the full list).
|
|
45
45
|
- **API Boundary**: Responsibility split between the AI decision layer and the DEXBot2 execution substrate ([AI_BOT_LIBRARY_API.md](../claw/docs/AI_BOT_LIBRARY_API.md))
|
|
46
46
|
- **Tuning Reference**: Practical grid-tuning baselines ([DEXBOT2_TUNING_CHEAT_SHEET.md](../claw/docs/DEXBOT2_TUNING_CHEAT_SHEET.md))
|
|
47
|
-
- **Position Management**:
|
|
47
|
+
- **Position Management**: Short-position tracking, position health monitoring (3-zone CR model), and shared CR planning via `cr_planner.ts`
|
|
48
48
|
- **Skills**: Presentation-only, concept-reference, and launcher-orchestration skill packs for bitshares-guide, margin-trading, launcher-ops, and shared references
|
|
49
49
|
|
|
50
50
|
## Operational & Security
|
|
@@ -65,19 +65,19 @@ This directory contains the comprehensive technical documentation for the DEXBot
|
|
|
65
65
|
### 🔁 [Grid Reconciliation](GRID_RECONCILE.md)
|
|
66
66
|
*How the bot re-aligns its intended grid with on-chain reality at startup.*
|
|
67
67
|
- **3-Phase Plan-then-Execute**: Phase 1 pure in-memory planning under `_gridLock`, Phase 2 blockchain execution outside the lock, Phase 3 fresh re-read and stale surplus cleanup
|
|
68
|
-
- **Safety Guardrails**: Fresh-grid `matchedOnGrid > 0` guard,
|
|
68
|
+
- **Safety Guardrails**: Fresh-grid `matchedOnGrid > 0` guard, exact slot-price duplicate cancel, freshly-assigned deferral, and truncated-read ambiguity handling
|
|
69
69
|
- **Partial Failure State**: No rollback on partial Phase 2 success; remaining mismatches caught by the next maintenance or startup cycle
|
|
70
70
|
- **Lock Hierarchy**: Canonical `_syncLock`/`_gridLock` level reference and the 1.4.6 ABBA deadlock correction
|
|
71
71
|
|
|
72
72
|
### 📝 [Logging System](LOGGING.md)
|
|
73
73
|
*Configuration reference for log levels, rotation, JSON output, and categories.*
|
|
74
74
|
- **5 Severity Levels**: `debug`, `info`, `warn`, `error`, `critical`.
|
|
75
|
-
- **Rotation**: Size-based (1GB default), auto-prune (
|
|
75
|
+
- **Rotation**: Size-based (1.1GB total budget default), auto-prune (10 rotated files).
|
|
76
76
|
- **JSON Output**: Structured lines for log aggregators (opt-in).
|
|
77
77
|
- **Categories**: 6 independently enablable category groups.
|
|
78
78
|
- **Change Detection**: Skips redundant logs (40-50% reduction).
|
|
79
79
|
- **Batch Processing Logs**: Fill batching, recovery retry, and orphan-fill deduplication messages.
|
|
80
|
-
- **Fill History Scans**: The `Subscriptions` logger emits `fetchFillHistoryEntries: maxPages (X) reached` at `
|
|
80
|
+
- **Fill History Scans**: The `Subscriptions` logger emits `fetchFillHistoryEntries: maxPages (X) reached` at `debug` level when the history scan hits its page cap — normal on busy accounts; see LOGGING.md for the `--partial-operations` diagnostic.
|
|
81
81
|
|
|
82
82
|
### 🐳 [Docker](docker.md)
|
|
83
83
|
*Container build, release images, and secure startup.*
|
|
@@ -88,8 +88,8 @@ This directory contains the comprehensive technical documentation for the DEXBot
|
|
|
88
88
|
### 🛠️ [Scripts](../scripts/README.md)
|
|
89
89
|
*CLI maintenance and diagnostic utilities.*
|
|
90
90
|
- **Update**: Safe production update via `dexbot update`
|
|
91
|
-
- **Reset & Cleanup**: Log
|
|
92
|
-
- **
|
|
91
|
+
- **Reset & Cleanup**: Log/order wipes, settings resets, and market-adapter/claw state cleanup
|
|
92
|
+
- **Diagnostics**: Configuration audit, grid divergence/trading analysis, and candle/pool history checks
|
|
93
93
|
|
|
94
94
|
## Reference Docs
|
|
95
95
|
|
|
@@ -97,9 +97,9 @@ This directory contains the comprehensive technical documentation for the DEXBot
|
|
|
97
97
|
*The blueprint of the system.*
|
|
98
98
|
- **Design Philosophy**: Simplicity, constant spread, minimal blockchain interaction, and closed-loop market dynamics.
|
|
99
99
|
- **System Design**: High-level overview of how the bot components interact.
|
|
100
|
-
- **Module Responsibilities**: Detailed breakdown of the **Manager**, **Accountant**, **Strategy**, **Grid**, **FillRuntime**, and **MaintenanceRuntime** modules.
|
|
100
|
+
- **Module Responsibilities**: Detailed breakdown of the **Manager**, **Accountant**, **Strategy**, **SyncEngine**, **Grid**, **FillRuntime**, and **MaintenanceRuntime** modules.
|
|
101
101
|
- **Copy-on-Write Pattern**: Safe concurrent rebalancing with isolated working grids (see [COPY_ON_WRITE_MASTER_PLAN.md](COPY_ON_WRITE_MASTER_PLAN.md))
|
|
102
|
-
- **Fill Processing Pipeline**: Fixed-cap batch fill processing (1
|
|
102
|
+
- **Fill Processing Pipeline**: Fixed-cap batch fill processing (`gapSlots+1` fills per broadcast; documented Feb 7 29-fill scenario: ~24s)
|
|
103
103
|
- **Spread Correction**: Conservative, fund-aware maintenance of constant spread width
|
|
104
104
|
- **Periodic Market Price Refresh**: Background 4-hour price updates
|
|
105
105
|
- **Pipeline Safety & Diagnostics**: 5-minute timeout safeguard and health monitoring
|
|
@@ -119,14 +119,14 @@ This directory contains the comprehensive technical documentation for the DEXBot
|
|
|
119
119
|
### 🧩 [Copy-on-Write Master Plan](COPY_ON_WRITE_MASTER_PLAN.md)
|
|
120
120
|
*COW design, phases, and state machine details.*
|
|
121
121
|
- **Architecture**: Master-grid projection model and rebalance flow
|
|
122
|
-
- **Lifecycle**:
|
|
122
|
+
- **Lifecycle**: State machine, rebalance/fill data flows, fill handling strategy, and operational rules
|
|
123
123
|
- **Safety**: Invariants and guardrails for concurrent updates
|
|
124
124
|
|
|
125
125
|
### 🔒 [COW Invariants](COW_INVARIANTS.md)
|
|
126
126
|
*Stable theory contract for COW pipeline.*
|
|
127
127
|
- **Non-negotiable invariants**: Master immutability, commit atomicity, projection rules, accounting separation
|
|
128
|
-
- **
|
|
129
|
-
- **
|
|
128
|
+
- **Subsystem Scope**: 13 `INV-*` prefix groups mapping each invariant to its runtime subsystem
|
|
129
|
+
- **Change Policy**: Required steps for an intentional invariant change — same-PR doc update, rationale, and regression tests
|
|
130
130
|
|
|
131
131
|
### 📐 [Grid-Price Invariant](GRID_PRICE_INVARIANT.md)
|
|
132
132
|
*Why a slot's emitted price must equal its genesis level — and how that failed.*
|
|
@@ -140,7 +140,7 @@ This directory contains the comprehensive technical documentation for the DEXBot
|
|
|
140
140
|
*The most critical part of the bot: safe capital management.*
|
|
141
141
|
- **Single Source of Truth**: How the bot avoids double-spending and out-of-sync balances.
|
|
142
142
|
- **Optimistic ChainFree**: The mechanism that allows the bot to trade with fill proceeds before they are finalized on-chain.
|
|
143
|
-
- **Fill Batch Processing**: Fixed-cap batching for efficient fill processing (
|
|
143
|
+
- **Fill Batch Processing**: Fixed-cap batching for efficient fill processing (`1..gapSlots+1` unified, deeper queues chunked at `gapSlots+1`)
|
|
144
144
|
- **Partial Order Consolidation**: Simplified, direct consolidation through grid rebuilding (no merge/split mechanics)
|
|
145
145
|
- **Dust Detection & Management**: Partials below the dust threshold are cancelled on-chain immediately on detection (no delay, no timer)
|
|
146
146
|
- **BTS Fee Object Structure**: `netProceeds` field for accounting precision
|
|
@@ -158,9 +158,9 @@ This directory contains the comprehensive technical documentation for the DEXBot
|
|
|
158
158
|
- **Configurable startPrice & gridPrice**: Fixed numeric, pool, book-derived, or AMA keyword pricing modes
|
|
159
159
|
- **Pool ID Caching**: Optimization for price derivation
|
|
160
160
|
- **Order State Helper Functions**: Centralized predicate functions for state checking
|
|
161
|
-
- **Signal Concepts**: Dynamic weights, regime detection,
|
|
161
|
+
- **Signal Concepts**: Dynamic weights, regime detection, and market adapter integration
|
|
162
162
|
- **Debt Policy**: Native MPA and credit offer configuration and runtime rules
|
|
163
|
-
- **
|
|
163
|
+
- **Practical How-Tos**: Adding features step by step, common pitfalls to avoid, and useful debugging commands.
|
|
164
164
|
- **Glossary**: Definitions of project-specific terminology (e.g., "Virtual Orders", "Rotation", "Pipeline Safety", "WorkingGrid", "COW Commit", "Dynamic Weight", "Regime Detection").
|
|
165
165
|
|
|
166
166
|
### 🔄 [Workflow](WORKFLOW.md)
|
|
@@ -172,7 +172,7 @@ This directory contains the comprehensive technical documentation for the DEXBot
|
|
|
172
172
|
*Test organization, categories, and key architectural patterns tested.*
|
|
173
173
|
- **Test Layout**: Directory structure, helpers, and quick-start commands
|
|
174
174
|
- **Categories**: Core infrastructure, order management, COW rebalancing, fees/accounting, integration, edge cases, and more
|
|
175
|
-
- **Architectural Patterns**: COW rebalancing, RMS divergence,
|
|
175
|
+
- **Architectural Patterns**: COW rebalancing, RMS divergence, fund invariants, and the grid-price invariant with doc cross-references
|
|
176
176
|
|
|
177
177
|
### 🧭 [Evolution Report](EVOLUTION.md)
|
|
178
178
|
*Project timeline and major architecture phases.*
|
package/docs/WORKFLOW.md
CHANGED
|
@@ -238,28 +238,33 @@ the canonical name is preferred in scripts and docs.
|
|
|
238
238
|
|
|
239
239
|
| Command (canonical) | Aliases | Purpose |
|
|
240
240
|
|---------|---------|---------|
|
|
241
|
-
| `dexbot test <bot>` | — |
|
|
241
|
+
| `dexbot test <bot>` | — | Run a single bot in live mode (one-shot; not a dry run) |
|
|
242
242
|
| `dexbot drystart <bot>` | — | Same as `test` but forces dry-run execution |
|
|
243
|
-
| `dexbot reset <bot>` | — | Trigger a grid reset (applies live or on next start) |
|
|
243
|
+
| `dexbot reset <bot>` | — | Trigger a grid reset (applies live or on next start; `reset all` for all) |
|
|
244
244
|
| `dexbot default` | `defaults` | Reset settings to defaults (deletes generated settings files) |
|
|
245
245
|
| `dexbot disable <bot>` | — | Mark a bot inactive in config (`disable all` for all) |
|
|
246
246
|
| `dexbot enable <bot>` | — | Mark a bot active in config (`enable all` for all) |
|
|
247
|
-
| `dexbot key` | `
|
|
248
|
-
| `dexbot bot` | `
|
|
247
|
+
| `dexbot key` | `keys` | Launch the chain key helper (`modules/chain_keys.ts`) |
|
|
248
|
+
| `dexbot bot` | `bots` | Launch the interactive bot configurator |
|
|
249
249
|
| `dexbot pm2` | — | Start all active bots via PM2 |
|
|
250
250
|
| `dexbot update` | — | Update DEXBot2 from the repository and restart active bots |
|
|
251
251
|
| `dexbot export <bot>` | — | Export bot trades/settings to CSV/JSON for local analysis/ |
|
|
252
|
-
| `dexbot order` | `orders` | Analyze persisted order grids (spread, increment, funds) |
|
|
252
|
+
| `dexbot order` | `orders` | Analyze persisted order grids (spread, increment, funds); `--export` for HTML |
|
|
253
253
|
| `dexbot order [<bot>]` | — | Analyze only the specified bot's order grid |
|
|
254
254
|
| `dexbot credit` | — | Live summed MPA + borrowed-credit positions per asset per bot (`[<bot>]`) |
|
|
255
|
-
| `dexbot
|
|
255
|
+
| `dexbot tv <target>` | — | TradingView 1h chart for `<bot|pool-id|AssetA/AssetB>` over `--month N` (default 3) |
|
|
256
|
+
| `dexbot dw <target>` | — | Dynamic-weight research chart: same targets/flags as `tv` |
|
|
257
|
+
| `dexbot status` | `stat`, `stats` | Unified runtime health — daemon, adapter, bots |
|
|
256
258
|
| `dexbot start` | `unlock` | Run credential daemon + bot (equivalent to running the `unlock` runtime, `dist/unlock.js`) |
|
|
257
|
-
| `dexbot stop`
|
|
259
|
+
| `dexbot stop` | `stp`, `stopall` | Stop the monolithic runtime (unlock mode) |
|
|
258
260
|
| `dexbot reload` | `reloadall` | Reload the monolithic runtime without touching the credential daemon (unlock mode) |
|
|
259
261
|
| `dexbot restart` | `restartall` | Restart the monolithic runtime (unlock mode, re-unlocks credential daemon) |
|
|
260
262
|
| `dexbot delete` | — | Shut down and clean up the monolithic runtime (unlock mode) |
|
|
261
|
-
| `dexbot whitelist` | `white` | Generate market adapter whitelist from AMA bot configs |
|
|
262
263
|
| `dexbot clear` | — | Remove all log files from the logs directory (`<profiles>/logs`) |
|
|
264
|
+
| `dexbot clear-orders` | — | Remove all persisted order files (`<profiles>/orders`) |
|
|
265
|
+
| `dexbot clear-market-adapter` | — | Remove market adapter data, state, and logs |
|
|
266
|
+
| `dexbot clear-all` | — | Remove orders, logs, market adapter, and claw files (all of the above) |
|
|
267
|
+
| `dexbot help` | — | Print the full CLI reference (grouped by Runtime/Trading/Config/Analysis/Files) |
|
|
263
268
|
|
|
264
269
|
## NPM Scripts for Branch Synchronization
|
|
265
270
|
|
package/docs/architecture.md
CHANGED
|
@@ -22,7 +22,7 @@ DEXBot2 is a grid trading bot for the BitShares blockchain. It maintains a geome
|
|
|
22
22
|
DEXBot2 prioritizes **simplicity and operational efficiency** over complex partial-handling mechanics:
|
|
23
23
|
|
|
24
24
|
1. **Constant Spread**: The spread zone width remains fixed at `targetSpreadPercent`, eliminating dynamic inflation triggers.
|
|
25
|
-
2. **
|
|
25
|
+
2. **Immediate Dust Cancellation**: Sub-threshold partials are cancelled on-chain as soon as detection runs; surviving non-dust partials are handled by ordinary fund-driven rebalancing without complex merge/split logic.
|
|
26
26
|
3. **Minimal Blockchain Interaction**: Fund-driven rebalancing occurs once per fill batch, not per-partial. Grid generation uses only available funds—no forced allocations.
|
|
27
27
|
4. **Closed-Loop Market Dynamics**: The boundary-crawl mechanism naturally handles price movement and fill flows without special-case logic.
|
|
28
28
|
5. **Powerful Maintenance Tools**: Periodic grid regeneration, recovery retries, and fund invariant verification keep the system healthy over long operations.
|
|
@@ -56,10 +56,10 @@ graph TB
|
|
|
56
56
|
MASTERGRID[Master Grid - immutable/frozen<br/>slot-id, price, size, state<br/>orderId, blockchain, grid, proceeds]
|
|
57
57
|
TWOPASS[SyncEngine<br/>2-pass: grid-to-chain then chain-to-grid<br/>match orderId, detect partials, flag stale]
|
|
58
58
|
FUNDS["Accounting - SSOT for funds<br/>available, virtual, committed<br/>btsFeesOwed<br/>Avail = max 0 ChainFree minus Virtual minus Fees"]
|
|
59
|
-
TARGET[Strategy Engine<br/>calculateTargetGrid<br/>boundary-crawl pivot<br/>partial
|
|
59
|
+
TARGET[Strategy Engine<br/>calculateTargetGrid<br/>boundary-crawl pivot<br/>partial correction, rotation]
|
|
60
60
|
WORKGRID[WorkingGrid - COW copy<br/>all mutations here only<br/>commit to Master on confirmation]
|
|
61
61
|
FILLQUEUE[Fill Queue<br/>AsyncLock + dedup 5-60 min]
|
|
62
|
-
BATCHER[Fixed-Cap Batcher<br/>queue within cap: unified batch<br/>queue above cap: chunk at cap size<br/>
|
|
62
|
+
BATCHER[Fixed-Cap Batcher<br/>queue within cap: unified batch<br/>queue above cap: chunk at cap size<br/>cap = gapSlots + 1]
|
|
63
63
|
end
|
|
64
64
|
|
|
65
65
|
subgraph "OUTPUTS"
|
|
@@ -107,7 +107,7 @@ graph TB
|
|
|
107
107
|
| **Immutability** | Master Grid is frozen; all changes go through a disposable WorkingGrid (Copy-on-Write) |
|
|
108
108
|
| **Single Source of Truth** | Accounting engine owns all fund data; everything reads from it |
|
|
109
109
|
| **Event-driven + Polling** | Fill Events (real-time) and Open-Order polling feed the same queue |
|
|
110
|
-
| **Fixed-Cap Batching** | Deterministic batching with hard cap per broadcast (
|
|
110
|
+
| **Fixed-Cap Batching** | Deterministic batching with hard cap per broadcast (cap = gapSlots + 1 fills) |
|
|
111
111
|
| **Persistence** | Grid snapshot written after every confirmed blockchain commit |
|
|
112
112
|
|
|
113
113
|
---
|
|
@@ -443,7 +443,7 @@ The fill pipeline handles incoming filled orders efficiently through fixed-cap b
|
|
|
443
443
|
|
|
444
444
|
Scenario source: 29-fill burst during the Feb 7 market crash, modeled at
|
|
445
445
|
roughly 3 seconds per broadcast; see
|
|
446
|
-
[`FUND_MOVEMENT_AND_ACCOUNTING.md`](FUND_MOVEMENT_AND_ACCOUNTING.md#
|
|
446
|
+
[`FUND_MOVEMENT_AND_ACCOUNTING.md`](FUND_MOVEMENT_AND_ACCOUNTING.md#15-fill-batch-processing--timeline).
|
|
447
447
|
|
|
448
448
|
| Metric | Legacy (1-at-a-time) | Fixed-Cap Batching | Improvement |
|
|
449
449
|
|--------|---------------------|-------------------|-------------|
|
|
@@ -464,46 +464,53 @@ Instead of complex partial handling, spread corrections are **conservative and f
|
|
|
464
464
|
- Target spread width stays **constant** at `targetSpreadPercent`
|
|
465
465
|
- Corrections scale with **actual available funds**, not arbitrary slot budgets
|
|
466
466
|
- No dynamic spread inflation based on partial consolidation flags
|
|
467
|
-
-
|
|
467
|
+
- Safe window-contiguous candidate ordering (with an edge-first fallback) prevents cross-side placement
|
|
468
468
|
|
|
469
469
|
### Algorithm
|
|
470
470
|
|
|
471
|
-
**Location**: `modules/order/
|
|
471
|
+
**Location**: `modules/order/grid.ts::prepareSpreadCorrectionOrders()`, selected by
|
|
472
|
+
`modules/order/grid.ts::determineOrderSideByFunds()`.
|
|
472
473
|
|
|
473
|
-
The
|
|
474
|
+
The correction path is fund-only and never manufactures budget by shrinking a resting order:
|
|
474
475
|
|
|
475
476
|
```
|
|
476
|
-
1. Detect that
|
|
477
|
-
2.
|
|
478
|
-
3.
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
6.
|
|
477
|
+
1. Detect that the live window is wider than targetSpreadPercent.
|
|
478
|
+
2. Select up to `outOfSpread` eligible holes in safe window/gap order.
|
|
479
|
+
3. If the funded edge holds a non-dust PARTIAL, optionally top it up, but only
|
|
480
|
+
when `ideal - current` is positive and free funds can cover the increase.
|
|
481
|
+
4. Create replacements from free available/chainFree funds; contiguous gap-slot
|
|
482
|
+
promotion may extend the window while preserving MIN_SPREAD_ORDERS and the
|
|
483
|
+
opposite placed rail.
|
|
484
|
+
5. If free funds cannot cover every target, place/top up the affordable prefix,
|
|
485
|
+
stop without shrinking inventory, and log the fund-constrained remainder.
|
|
486
|
+
6. If neither side has free funds, skip correction and let the maintenance
|
|
487
|
+
runtime refresh balances and open orders rather than recycle stale inventory.
|
|
486
488
|
```
|
|
487
489
|
|
|
490
|
+
Detected dust partials never enter this path: `cancelDustOrders()` cancels them
|
|
491
|
+
on-chain immediately, and the five-minute health check is only a restart safety net.
|
|
492
|
+
|
|
488
493
|
### Fund-Safe Constraints
|
|
489
494
|
|
|
490
495
|
Spread corrections respect these hard limits:
|
|
491
496
|
|
|
492
497
|
```javascript
|
|
493
498
|
// In modules/constants.ts (GRID_LIMITS)
|
|
494
|
-
MIN_SPREAD_ORDERS: 2, //
|
|
499
|
+
MIN_SPREAD_ORDERS: 2, // Preserve the minimum empty gap reserve
|
|
495
500
|
|
|
496
|
-
//
|
|
497
|
-
//
|
|
501
|
+
// `outOfSpread` supplies the requested slot count. Execution is bounded by
|
|
502
|
+
// safe candidate selection, healthy minimum sizes, and actual free funds.
|
|
503
|
+
const availableFund = Math.max(0, Math.min(
|
|
504
|
+
manager.funds.available[side],
|
|
505
|
+
manager.accountTotals[side === 'buy' ? 'buyFree' : 'sellFree']
|
|
506
|
+
));
|
|
498
507
|
|
|
499
|
-
// Each
|
|
500
|
-
|
|
501
|
-
const affordableOrderCount = Math.floor(availableFunds / minHealthySize);
|
|
502
|
-
const correctionOrders = Math.min(missingSlots, affordableOrderCount);
|
|
508
|
+
// Each target is created or topped up only while remainingBudget covers it.
|
|
509
|
+
// No resting ACTIVE/PARTIAL order is shrunk to fund the correction.
|
|
503
510
|
```
|
|
504
511
|
|
|
505
512
|
**Benefits**:
|
|
506
|
-
- ✅ No
|
|
513
|
+
- ✅ No inventory recycling from stale-size snapshots
|
|
507
514
|
- ✅ Constant, predictable spread width
|
|
508
515
|
- ✅ Funds always respected (no forced allocation)
|
|
509
516
|
- ✅ Natural smoothing over multiple rebalance cycles
|
|
@@ -591,12 +598,11 @@ if (mgr.outOfSpread) {
|
|
|
591
598
|
### After (Numeric Distance)
|
|
592
599
|
|
|
593
600
|
```javascript
|
|
594
|
-
// New approach:
|
|
595
|
-
mgr.outOfSpread = 3; //
|
|
601
|
+
// New approach: requested missing slots derived from the live geometry
|
|
602
|
+
mgr.outOfSpread = 3; // three slots beyond the target spread
|
|
596
603
|
|
|
597
|
-
//
|
|
598
|
-
|
|
599
|
-
const replacementSlots = Math.min(spreadDistance, MAX_CORRECTION_SLOTS);
|
|
604
|
+
// The grid engine bounds actual work by eligible candidates, MIN_SPREAD_ORDERS,
|
|
605
|
+
// healthy sizes, and available free funds. There is no MAX_CORRECTION_SLOTS cap.
|
|
600
606
|
```
|
|
601
607
|
|
|
602
608
|
**Benefit**: Enables scaled corrections based on actual severity.
|
|
@@ -706,7 +712,7 @@ stateDiagram-v2
|
|
|
706
712
|
|
|
707
713
|
note right of PARTIAL
|
|
708
714
|
Partially filled on-chain
|
|
709
|
-
|
|
715
|
+
Dust is cancelled immediately; non-dust is corrected in rebalance
|
|
710
716
|
end note
|
|
711
717
|
```
|
|
712
718
|
|
|
@@ -881,7 +887,7 @@ sequenceDiagram
|
|
|
881
887
|
Strat-->>Mgr: target grid
|
|
882
888
|
Mgr->>Mgr: Apply rotations via WorkingGrid
|
|
883
889
|
Mgr->>Acct: Deduct BTS fees during recalculateFunds
|
|
884
|
-
Mgr->>Mgr:
|
|
890
|
+
Mgr->>Mgr: Cancel detected dust partials immediately
|
|
885
891
|
```
|
|
886
892
|
|
|
887
893
|
### 2. Order Rotation (Crawl Mechanism)
|
|
@@ -1059,7 +1065,7 @@ The system has been optimized to use a "memory-driven" model for order updates,
|
|
|
1059
1065
|
- **Faster reaction time**: No waiting for blockchain queries during order updates
|
|
1060
1066
|
- **Reduced API load**: Fewer fetches, less network congestion
|
|
1061
1067
|
- **Mathematical precision**: Integer-based tracking prevents float precision errors
|
|
1062
|
-
- *See [FUND_MOVEMENT_AND_ACCOUNTING.md § 5.5](FUND_MOVEMENT_AND_ACCOUNTING.md#55-precision--quantization
|
|
1068
|
+
- *See [FUND_MOVEMENT_AND_ACCOUNTING.md § 5.5](FUND_MOVEMENT_AND_ACCOUNTING.md#55-precision--quantization) for quantization utilities and best practices*
|
|
1063
1069
|
- **Fallback safety**: Automatic recovery if memory state becomes inconsistent
|
|
1064
1070
|
|
|
1065
1071
|
### Performance Impact
|
|
@@ -1155,8 +1161,6 @@ graph LR
|
|
|
1155
1161
|
B -->|Real-world Scenarios| B3["Fills/FEE Tests"]
|
|
1156
1162
|
|
|
1157
1163
|
C -->|Dynamic Weight| C1["dynamic_weight"]
|
|
1158
|
-
C -->|Derivative Trap| C2["derivative_signal"]
|
|
1159
|
-
C -->|Momentum Gate| C3["momentum_gate"]
|
|
1160
1164
|
|
|
1161
1165
|
D -->|CR Planner| D1["cr_planner"]
|
|
1162
1166
|
D -->|Credit Runtime| D2["credit_runtime"]
|
|
@@ -1189,13 +1193,12 @@ node dist/tests/test_dexbot_credit_wiring.js
|
|
|
1189
1193
|
- ✅ Edge cases covered (zero funds, max orders, etc.)
|
|
1190
1194
|
- ✅ Concurrent operations tested with locks
|
|
1191
1195
|
- ✅ State transitions validated end-to-end
|
|
1192
|
-
- ✅ Signal pipelines tested (dynamic weight
|
|
1196
|
+
- ✅ Signal pipelines tested (dynamic weight)
|
|
1193
1197
|
- ✅ Credit/debt runtime tested (CR planner, MPA wiring)
|
|
1194
1198
|
|
|
1195
1199
|
**Test Suite Evolution:**
|
|
1196
1200
|
- 50+ test cases for signal intelligence and credit runtime
|
|
1197
1201
|
- Dynamic weight override and market adapter signal gate tests
|
|
1198
|
-
- Derivative momentum gate and signal trap regression tests
|
|
1199
1202
|
- Credit/debt tests with CR planner and MPA wiring validation
|
|
1200
1203
|
|
|
1201
1204
|
### Testing Best Practices
|
|
@@ -1323,8 +1326,7 @@ The strategy engine has been significantly strengthened with improvements to fun
|
|
|
1323
1326
|
**2. Dust Partial Handling**
|
|
1324
1327
|
- Improved dust detection algorithm prevents false positives
|
|
1325
1328
|
- Detects dust as `< 5% of ideal order size`
|
|
1326
|
-
-
|
|
1327
|
-
- **Auto-Cancellation**: `_cancelDustOrders()` cancels dust partials on-chain immediately on detection — no delay, no timer maps, no retry budgets. Cancel is attempted post-fill (inside fill lock) and every 5-min health check (safety net).
|
|
1329
|
+
- **Immediate Cancellation**: `_cancelDustOrders()` cancels dust partials on-chain when detection runs — no delay, timer map, or consolidation cycle. Detection runs after fills/sync, and a 5-minute health check is the restart safety net.
|
|
1328
1330
|
|
|
1329
1331
|
**3. Strict Order Size Constraints**
|
|
1330
1332
|
- Orders validated to not exceed available funds
|
package/docs/developer_guide.md
CHANGED
|
@@ -129,8 +129,6 @@ A **phantom order** is an order in ACTIVE/PARTIAL state WITHOUT a valid `orderId
|
|
|
129
129
|
| **Kalman Confirmation** | Kalman-filtered trend signal blended with AMA slope for smoother weight transitions |
|
|
130
130
|
| **Symmetric Shift** | Volatility-driven downward weight penalty applied equally to both sides (ATR-based) |
|
|
131
131
|
| **Asymmetric Offset** | Directional weight shift (buy-heavy or sell-heavy) driven by AMA/Kalman trend |
|
|
132
|
-
| **Derivative Signal** | SMA/MACD/RSI-based entry bias and momentum gate for optional strategy filtering |
|
|
133
|
-
| **Momentum Gate** | N-bar commitment tracking that confirms derivative signals before acting |
|
|
134
132
|
| **GridPrice** | Price anchor for grid math; can be numeric, `"pool"`, `"book"`, or AMA keyword (`"ama"`, `"ama1"`–`"ama4"`) |
|
|
135
133
|
|
|
136
134
|
### Grid Concepts
|
|
@@ -165,7 +163,7 @@ A **phantom order** is an order in ACTIVE/PARTIAL state WITHOUT a valid `orderId
|
|
|
165
163
|
| Term | Meaning |
|
|
166
164
|
|------|---------|
|
|
167
165
|
| **Rotation** | Moving an order from one price level to another |
|
|
168
|
-
| **Consolidation** | Absorbing dust partials into
|
|
166
|
+
| **Consolidation** | Absorbing surviving non-dust partials into ordinary fund-driven rebalancing. Detected dust is cancelled immediately and never waits for a rebuild. |
|
|
169
167
|
| **Rebalancing** | Adjusting order sizes based on current funds |
|
|
170
168
|
| **Global Side Capping** | Scaling order sizes when insufficient funds |
|
|
171
169
|
| **Atomic Check-and-Deduct** | Verify funds + deduct in single operation |
|
|
@@ -277,7 +275,7 @@ const correctedPrice = quantizeFloat(derivedPrice, 8);
|
|
|
277
275
|
const normalized = normalizeInt(currentSizeInt, assetPrecision);
|
|
278
276
|
```
|
|
279
277
|
|
|
280
|
-
**See [FUND_MOVEMENT_AND_ACCOUNTING.md § 5.5](FUND_MOVEMENT_AND_ACCOUNTING.md#55-precision--quantization
|
|
278
|
+
**See [FUND_MOVEMENT_AND_ACCOUNTING.md § 5.5](FUND_MOVEMENT_AND_ACCOUNTING.md#55-precision--quantization) for complete quantization guide and edge case handling.**
|
|
281
279
|
|
|
282
280
|
---
|
|
283
281
|
|
|
@@ -620,7 +618,7 @@ const minHealthySize = getMinOrderSize(ORDER_TYPES.BUY, assets, 1.0);
|
|
|
620
618
|
if (isOrderHealthy(order, minHealthySize)) {
|
|
621
619
|
// Order is valid for placement/rotation
|
|
622
620
|
} else {
|
|
623
|
-
// Order is dust -
|
|
621
|
+
// Order is dust - skip it here; cancelDustOrders() handles it on-chain
|
|
624
622
|
}
|
|
625
623
|
```
|
|
626
624
|
|
|
@@ -737,7 +735,7 @@ _verifyFundInvariants(...)
|
|
|
737
735
|
- Process filled orders
|
|
738
736
|
- Identify shortages and surpluses
|
|
739
737
|
- Execute order rotations
|
|
740
|
-
- Handle
|
|
738
|
+
- Handle surviving non-dust partials during rebalance
|
|
741
739
|
|
|
742
740
|
**Critical Methods**:
|
|
743
741
|
```javascript
|
|
@@ -1211,8 +1209,6 @@ Located in `tests/` (with `helpers/` subdirectory):
|
|
|
1211
1209
|
- `test_bts_fee_logic.ts` - BTS fee deduction and settlement
|
|
1212
1210
|
- `test_market_adapter_signal_gates.ts` - Market adapter signal validation
|
|
1213
1211
|
- `test_dynamic_weight_override_wiring.ts` - Dynamic weight config wiring
|
|
1214
|
-
- `test_derivative_signal_trap_regression.ts` - Derivative signal trap tests
|
|
1215
|
-
- `test_derivative_momentum_gate.ts` - Momentum gate tests
|
|
1216
1212
|
- `test_cr_planner.ts` - Collateral ratio planner tests
|
|
1217
1213
|
- `test_dexbot_credit_wiring.ts` - Credit runtime integration tests
|
|
1218
1214
|
- `test_credential_daemon.ts` / `test_credential_session_cache.ts` - Credential security tests
|
|
@@ -1559,6 +1555,7 @@ console.log('Locked?', manager.isOrderLocked(order.id));
|
|
|
1559
1555
|
- `modules/node_manager.ts` - Multi-node health checking and failover
|
|
1560
1556
|
- `modules/fund_registry.ts` - Shared-account fund registry with cross-bot invariants
|
|
1561
1557
|
- `modules/settings_merge.ts` - Consolidated settings merge (single source of truth)
|
|
1558
|
+
- `modules/bot_defaults.ts` - Central bot-defaults seeder (draft/entry/runtime-config modes); single source for how `DEFAULT_CONFIG` is applied
|
|
1562
1559
|
- `modules/chain_orders.ts` - Blockchain order operations
|
|
1563
1560
|
- `modules/account_orders.ts` - Account order queries
|
|
1564
1561
|
|