dexbot 1.6.1 → 1.6.3
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 +34 -0
- package/analysis/README.md +2 -2
- package/analysis/ama_fitting/package.json +1 -1
- package/analysis/grid_correction_check.ts +80 -7
- package/analysis/results/ama_sweep_results_lp_pool_133_1h.json +2455 -0
- package/analysis/results/bot_fitting_results_lp_pool_133_1h.json +218 -0
- package/analysis/tradingview/h-bts_tradingview.html +1570 -0
- package/analysis/tradingview/t-bts_tradingview.html +1570 -0
- package/analysis/tradingview/tradingview_uplot_chart_generator.ts +19 -5
- package/analysis/trend_detection/package.json +1 -1
- 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/grid_correction_check.d.ts +5 -1
- package/dist/analysis/grid_correction_check.d.ts.map +1 -1
- package/dist/analysis/grid_correction_check.js +81 -7
- package/dist/analysis/grid_correction_check.js.map +1 -1
- package/dist/analysis/tradingview/tradingview_uplot_chart_generator.d.ts.map +1 -1
- package/dist/analysis/tradingview/tradingview_uplot_chart_generator.js +19 -5
- package/dist/analysis/tradingview/tradingview_uplot_chart_generator.js.map +1 -1
- package/dist/market_adapter/inputs/fetch_book_data.js +2 -2
- package/dist/market_adapter/inputs/fetch_book_data.js.map +1 -1
- package/dist/market_adapter/inputs/fetch_lp_data.d.ts +22 -3
- package/dist/market_adapter/inputs/fetch_lp_data.d.ts.map +1 -1
- package/dist/market_adapter/inputs/fetch_lp_data.js +15 -15
- package/dist/market_adapter/inputs/fetch_lp_data.js.map +1 -1
- package/dist/market_adapter/inputs/kibana_feed_source.js +2 -2
- package/dist/market_adapter/inputs/kibana_feed_source.js.map +1 -1
- package/dist/market_adapter/inputs/window_cache.d.ts +54 -8
- package/dist/market_adapter/inputs/window_cache.d.ts.map +1 -1
- package/dist/market_adapter/inputs/window_cache.js +328 -87
- package/dist/market_adapter/inputs/window_cache.js.map +1 -1
- package/dist/modules/bitshares-native/subscriptions.d.ts +1 -1
- package/dist/modules/bitshares-native/subscriptions.d.ts.map +1 -1
- package/dist/modules/bitshares-native/subscriptions.js +18 -4
- package/dist/modules/bitshares-native/subscriptions.js.map +1 -1
- package/dist/modules/bitshares_client.d.ts.map +1 -1
- package/dist/modules/bitshares_client.js +10 -0
- package/dist/modules/bitshares_client.js.map +1 -1
- package/dist/modules/constants.d.ts +7 -3
- package/dist/modules/constants.d.ts.map +1 -1
- package/dist/modules/constants.js +44 -20
- package/dist/modules/constants.js.map +1 -1
- package/dist/modules/credit_runtime.d.ts.map +1 -1
- package/dist/modules/credit_runtime.js +24 -6
- package/dist/modules/credit_runtime.js.map +1 -1
- package/dist/modules/dexbot_class.d.ts +32 -7
- package/dist/modules/dexbot_class.d.ts.map +1 -1
- package/dist/modules/dexbot_class.js +55 -11
- package/dist/modules/dexbot_class.js.map +1 -1
- package/dist/modules/dexbot_cow_runtime.d.ts +137 -7
- package/dist/modules/dexbot_cow_runtime.d.ts.map +1 -1
- package/dist/modules/dexbot_cow_runtime.js +955 -45
- package/dist/modules/dexbot_cow_runtime.js.map +1 -1
- package/dist/modules/dexbot_fill_runtime.d.ts +28 -1
- package/dist/modules/dexbot_fill_runtime.d.ts.map +1 -1
- package/dist/modules/dexbot_fill_runtime.js +116 -3
- package/dist/modules/dexbot_fill_runtime.js.map +1 -1
- package/dist/modules/dexbot_maintenance_runtime.d.ts +46 -0
- package/dist/modules/dexbot_maintenance_runtime.d.ts.map +1 -1
- package/dist/modules/dexbot_maintenance_runtime.js +193 -6
- package/dist/modules/dexbot_maintenance_runtime.js.map +1 -1
- package/dist/modules/dexbot_startup_runtime.d.ts.map +1 -1
- package/dist/modules/dexbot_startup_runtime.js +6 -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 +16 -3
- package/dist/modules/dexbot_state_recovery.js.map +1 -1
- package/dist/modules/order/grid.d.ts +3 -1
- package/dist/modules/order/grid.d.ts.map +1 -1
- package/dist/modules/order/grid.js +47 -6
- 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 +39 -4
- package/dist/modules/order/grid_reconcile_internal.js.map +1 -1
- package/dist/modules/order/manager.d.ts.map +1 -1
- package/dist/modules/order/manager.js +3 -1
- package/dist/modules/order/manager.js.map +1 -1
- package/dist/modules/order/sync_engine.d.ts.map +1 -1
- package/dist/modules/order/sync_engine.js +200 -15
- package/dist/modules/order/sync_engine.js.map +1 -1
- package/dist/modules/order/utils/math.d.ts +60 -14
- package/dist/modules/order/utils/math.d.ts.map +1 -1
- package/dist/modules/order/utils/math.js +87 -20
- package/dist/modules/order/utils/math.js.map +1 -1
- package/dist/modules/order/utils/order.d.ts +95 -7
- package/dist/modules/order/utils/order.d.ts.map +1 -1
- package/dist/modules/order/utils/order.js +277 -15
- package/dist/modules/order/utils/order.js.map +1 -1
- package/dist/modules/utils/errors.d.ts +22 -0
- package/dist/modules/utils/errors.d.ts.map +1 -1
- package/dist/modules/utils/errors.js +30 -0
- package/dist/modules/utils/errors.js.map +1 -1
- package/docs/COPY_ON_WRITE_MASTER_PLAN.md +1 -1
- package/docs/DEXBOT_COMPARISON.md +3 -7
- package/docs/EVOLUTION.md +9 -7
- package/docs/FUND_MOVEMENT_AND_ACCOUNTING.md +4 -9
- package/docs/LIFECYCLE.md +2 -2
- package/docs/README.md +9 -1
- package/docs/architecture.md +7 -7
- package/docs/developer_guide.md +4 -4
- package/market_adapter/README.md +1 -1
- package/package.json +1 -1
package/docs/LIFECYCLE.md
CHANGED
|
@@ -105,7 +105,7 @@ sequenceDiagram
|
|
|
105
105
|
```
|
|
106
106
|
|
|
107
107
|
Why it matters:
|
|
108
|
-
- **
|
|
108
|
+
- **Gap-slot batching** (batch size = grid gap-slot count, `DEXBot._getGapSlotBatchSize`) keeps bursts
|
|
109
109
|
deterministic — see `docs/architecture.md` §"Fill Processing Pipeline".
|
|
110
110
|
- **Single rebalance cycle**: all fills in a batch share one broadcast, so proceeds
|
|
111
111
|
are immediately available for replacement sizing (no split-across-cycles delay).
|
|
@@ -179,7 +179,7 @@ enforced*, not compiler-enforced — learn them or you will introduce fund bugs.
|
|
|
179
179
|
| **Fund SSOT** | `Accounting` owns every fund number. Nothing else computes available funds. | `docs/architecture.md` §"Fund Flow Architecture" |
|
|
180
180
|
| **Replay-safe fills** | A fill is credited exactly once via processed-fill keys; retries are idempotent. | `modules/dexbot_fill_runtime.ts` |
|
|
181
181
|
| **Single broadcast per cycle** | One `updateOrdersOnChainBatch` per rebalance — never scatter writes. | `docs/architecture.md` §"Fill Processing Pipeline" |
|
|
182
|
-
| **Browser/Node split** | Heavy runtime is Node-only; never import it from a browser bundle. | `AGENTS.md` "Browser-Safe Surface", `
|
|
182
|
+
| **Browser/Node split** | Heavy runtime is Node-only; never import it from a browser bundle. | `AGENTS.md` "Browser-Safe Surface", `package.json` "browser" field |
|
|
183
183
|
| **Lock ordering** | Fill drain and maintenance must not run a rebalance concurrently. | `docs/developer_guide.md` §"Startup Sequence & Lock Ordering" |
|
|
184
184
|
|
|
185
185
|
---
|
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.3 (released).
|
|
6
6
|
|
|
7
7
|
---
|
|
8
8
|
|
|
@@ -162,6 +162,14 @@ This directory contains the comprehensive technical documentation for the DEXBot
|
|
|
162
162
|
- **Test mapping**: Links each invariant to regression tests
|
|
163
163
|
- **Review checklist**: Quick-use verification for COW/accounting changes
|
|
164
164
|
|
|
165
|
+
### 📐 [Grid-Price Invariant](GRID_PRICE_INVARIANT.md)
|
|
166
|
+
*Why a slot's emitted price must equal its genesis level — and how that failed.*
|
|
167
|
+
- **The invariant**: `order.price === priceForSlot(idx, genesis)`, and why range guards cannot substitute for it
|
|
168
|
+
- **Failure mechanism**: Chain price overwriting slot identity, pre-broadcast substitution, untrusted fill-guard pivot
|
|
169
|
+
- **Enforcement**: The six emission sites, the blocking rejection of off-grid emissions, and the fail-open policy on unjudgeable inputs
|
|
170
|
+
- **Out-of-bounds policy**: Hold and surface; refill in-grid slots at their genesis price
|
|
171
|
+
- **Status**: What is landed, what remains open, and why the removed 5% sanity gate must not be naively re-landed
|
|
172
|
+
|
|
165
173
|
### 🧪 [Test Suite](../tests/README.md)
|
|
166
174
|
*Test organization, categories, and key architectural patterns tested.*
|
|
167
175
|
- **Test Layout**: Directory structure, helpers, and quick-start commands
|
package/docs/architecture.md
CHANGED
|
@@ -377,13 +377,13 @@ The fill pipeline handles incoming filled orders efficiently through fixed-cap b
|
|
|
377
377
|
↓
|
|
378
378
|
┌─────────────────────────────────────────────────────────────┐
|
|
379
379
|
│ processFilledOrders() - Entry Point │
|
|
380
|
-
│ Use
|
|
381
|
-
│
|
|
380
|
+
│ Use gap-slot batch size for deterministic batching │
|
|
381
|
+
│ Rules: <=gapSlots unified, >gapSlots chunked │
|
|
382
382
|
└─────────────────────┬───────────────────────────────────────┘
|
|
383
383
|
↓
|
|
384
384
|
┌─────────────────────────────────────────────────────────────┐
|
|
385
|
-
│ Pop Batch (up to
|
|
386
|
-
│
|
|
385
|
+
│ Pop Batch (up to gapSlots) │
|
|
386
|
+
│ Takes N fills from queue head (N = 1..gapSlots) │
|
|
387
387
|
│ Example: pops [fill1, fill2, fill3] for batch processing │
|
|
388
388
|
└─────────────────────┬───────────────────────────────────────┘
|
|
389
389
|
↓
|
|
@@ -418,9 +418,9 @@ The fill pipeline handles incoming filled orders efficiently through fixed-cap b
|
|
|
418
418
|
|
|
419
419
|
### Key Properties
|
|
420
420
|
|
|
421
|
-
- **
|
|
422
|
-
- 1..
|
|
423
|
-
-
|
|
421
|
+
- **Gap-Slot Batch Sizing**: Batch size is deterministic, derived from the grid gap-slot count (`DEXBot._getGapSlotBatchSize`)
|
|
422
|
+
- 1..gapSlots awaiting: single unified batch (one rebalance/broadcast cycle)
|
|
423
|
+
- more than gapSlots awaiting: repeated chunks of gapSlots (last chunk may be smaller)
|
|
424
424
|
|
|
425
425
|
- **Single Rebalance Cycle**: All fills in batch processed in ONE rebalance
|
|
426
426
|
- No "split across cycles" delays
|
package/docs/developer_guide.md
CHANGED
|
@@ -39,7 +39,7 @@ Follow this path through the codebase:
|
|
|
39
39
|
```
|
|
40
40
|
|
|
41
41
|
**Additional Resources**:
|
|
42
|
-
- `modules/constants.ts::FILL_PROCESSING` -
|
|
42
|
+
- `modules/constants.ts::FILL_PROCESSING` - Fill-event handling configuration (batch sizing is gap-slot derived, see `DEXBot._getGapSlotBatchSize`)
|
|
43
43
|
- `modules/constants.ts::PIPELINE_TIMING` - Recovery configuration (RECOVERY_RETRY_INTERVAL_MS, MAX_RECOVERY_ATTEMPTS)
|
|
44
44
|
- `modules/constants.ts::MARKET_ADAPTER` - AMA, dynamic weight, and regime detection defaults
|
|
45
45
|
- `modules/constants.ts::REGIME_TABLE` - Hurst/PE regime signal-strength table
|
|
@@ -79,7 +79,7 @@ A **phantom order** is an order in ACTIVE/PARTIAL state WITHOUT a valid `orderId
|
|
|
79
79
|
|
|
80
80
|
| Term | Meaning |
|
|
81
81
|
|------|---------|
|
|
82
|
-
| **
|
|
82
|
+
| **Gap-Slot Batch Fill Processing** | Groups fills using the grid gap-slot count as batch size (`DEXBot._getGapSlotBatchSize`): `<= gapSlots` uses one unified batch; `> gapSlots` chunks at gapSlots. In the documented 29-fill Feb 7 crash scenario, this reduces the estimated divergence window from ~90s to ~24s; see [`FUND_MOVEMENT_AND_ACCOUNTING.md`](FUND_MOVEMENT_AND_ACCOUNTING.md#15-fill-batch-processing--timeline). |
|
|
83
83
|
| **Recovery Retry System** | Count+time-based retry mechanism with periodic reset. Replaces one-shot `_recoveryAttempted` flag. Max 5 attempts per episode with 60s minimum interval between retries. |
|
|
84
84
|
| **Orphan-Fill Deduplication** | Map+TTL-based tracking of stale-cleaned order IDs to prevent double-crediting. Delayed orphan fill events are still blocked by checking `_staleCleanedOrderIds`. |
|
|
85
85
|
|
|
@@ -171,8 +171,8 @@ A **phantom order** is an order in ACTIVE/PARTIAL state WITHOUT a valid `orderId
|
|
|
171
171
|
| **Atomic Check-and-Deduct** | Verify funds + deduct in single operation |
|
|
172
172
|
| **Divergence Detection** | Comparing ideal grid vs. persisted grid |
|
|
173
173
|
| **Invariant Verification** | Checking fund accounting consistency |
|
|
174
|
-
| **Batch Processing** | Grouping multiple fills into a single rebalance cycle instead of one-at-a-time.
|
|
175
|
-
| **
|
|
174
|
+
| **Batch Processing** | Grouping multiple fills into a single rebalance cycle instead of one-at-a-time. Gap-slot sizing: `<= gapSlots` unified, otherwise chunked at gapSlots. |
|
|
175
|
+
| **Gap-Slot Batch Sizing** | Deterministic chunking model with the grid gap-slot count as the per-broadcast bound. Keeps throughput high while avoiding tier-lookup complexity. |
|
|
176
176
|
| **Stale-Order Recovery** | Fast-path recovery for single-operation batches that encounter stale orders on-chain. Executes cleanup without full state sync. |
|
|
177
177
|
| **Orphan-Fill Prevention** | Deduplication mechanism that prevents double-crediting fills from stale-cleaned orders using timestamp-based ID tracking (TTL pruning). |
|
|
178
178
|
|
package/market_adapter/README.md
CHANGED
|
@@ -854,7 +854,7 @@ closed 1h candles.
|
|
|
854
854
|
|
|
855
855
|
#### Shared Chunk Cache and Fetch Robustness
|
|
856
856
|
|
|
857
|
-
Pool, book, and feed candle fetches share one cache entry point (`runCachedWindows` in `market_adapter/inputs/window_cache.ts`):
|
|
857
|
+
Pool, book, and feed candle fetches share one cache entry point (`runCachedWindows` in `market_adapter/inputs/window_cache.ts`): candles live in fixed calendar-month shards (`<base>.shard_YYYY-MM.json`, UTC) whose names never shift, so a run loads only the shards overlapping its requested range, queries only genuinely missing buckets plus a bounded 48h tail refresh, and rewrites only shards that gained buckets or query coverage — pure-reuse runs perform zero writes and zero deletes. Shard metas record the ranges actually queried (`meta.queriedRanges`, monotonically unioned). A missing range is pruned only when recorded query coverage genuinely covers it — the absence of local buckets alone never certifies history as empty. Partial windows merge into the run output but are never persisted. Legacy run-relative `*.chunk_*` files are still read: overlapping ones are absorbed into the shards (buckets + coverage) and retired once every bucket provably lives in a shard, while disjoint ones are never loaded and never deleted — narrow runs cannot wipe older history by construction. Every range fetch runs through `fetchRangeWithRetry` (per-range attempts + linear backoff + abort-signal timeout; the LP path keeps a 4-attempt budget), one-shot Kibana queries retry transient errors (3 attempts), paged fetchers cap at `kibanaMaxPages` (500), and bidirectional fetches tolerate a one-direction failure.
|
|
858
858
|
|
|
859
859
|
#### AMA Warmup Window — Why Candle Length Matters
|
|
860
860
|
|
package/package.json
CHANGED