dexbot 1.6.16 → 1.6.17

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.
Files changed (60) hide show
  1. package/CHANGELOG.md +26 -0
  2. package/analysis/tradingview/README.md +2 -2
  3. package/analysis/trend_detection/DYNAMIC_WEIGHT_RESEARCH.md +1 -1
  4. package/claw/package.json +1 -1
  5. package/claw/runtimes/openclaw-plugin/openclaw.plugin.json +1 -1
  6. package/claw/runtimes/openclaw-plugin/package.json +1 -1
  7. package/dist/analysis/ama_fitting/analyze_lambda_vs_slow.js +5 -3
  8. package/dist/analysis/tradingview/grid_reset_sim.js +1 -1
  9. package/dist/analysis/tradingview/tradingview_uplot_chart_generator.js +4 -4
  10. package/dist/analysis/trend_detection/backtest_ama_slope_huber.js +1 -1
  11. package/dist/modules/account_bots.d.ts +3 -0
  12. package/dist/modules/chain_keys.d.ts +1 -1
  13. package/dist/modules/constants.d.ts +6 -0
  14. package/dist/modules/constants.js +34 -6
  15. package/dist/modules/credit_pricing.d.ts +20 -1
  16. package/dist/modules/credit_pricing.js +23 -1
  17. package/dist/modules/credit_runtime.js +33 -16
  18. package/dist/modules/dexbot_class.d.ts +3 -1
  19. package/dist/modules/dexbot_class.js +5 -2
  20. package/dist/modules/dexbot_cow_runtime.d.ts +28 -37
  21. package/dist/modules/dexbot_cow_runtime.js +47 -66
  22. package/dist/modules/dexbot_maintenance_runtime.js +68 -10
  23. package/dist/modules/launcher/credential_daemon.d.ts +14 -2
  24. package/dist/modules/launcher/credential_daemon.js +60 -26
  25. package/dist/modules/order/grid.d.ts +7 -0
  26. package/dist/modules/order/grid.js +157 -15
  27. package/dist/modules/order/index.d.ts +15 -0
  28. package/dist/modules/order/manager.d.ts +30 -7
  29. package/dist/modules/order/manager.js +108 -12
  30. package/dist/modules/order/strategy.d.ts +5 -0
  31. package/dist/modules/order/strategy.js +23 -2
  32. package/dist/modules/order/utils/math.d.ts +41 -1
  33. package/dist/modules/order/utils/math.js +47 -1
  34. package/dist/modules/order/utils/order.d.ts +13 -0
  35. package/dist/modules/order/utils/order.js +61 -7
  36. package/dist/modules/order/utils/system.d.ts +66 -0
  37. package/dist/modules/order/utils/system.js +135 -0
  38. package/dist/modules/order/utils/validate.d.ts +3 -1
  39. package/dist/modules/order/utils/validate.js +5 -1
  40. package/dist/modules/types.d.ts +35 -2
  41. package/dist/scripts/analyze-credit.js +64 -23
  42. package/dist/scripts/bts_distribution.d.ts +66 -0
  43. package/dist/scripts/bts_distribution.js +2102 -0
  44. package/dist/scripts/token_distribution.d.ts +45 -0
  45. package/dist/scripts/token_distribution.js +1870 -0
  46. package/dist/unlock.js +42 -24
  47. package/docs/COW_INVARIANTS.md +6 -0
  48. package/docs/DEXBOT_COMPARISON.md +5 -5
  49. package/docs/EVOLUTION.md +9 -8
  50. package/docs/FUND_MOVEMENT_AND_ACCOUNTING.md +3 -1
  51. package/docs/GRID_PRICE_INVARIANT.md +6 -0
  52. package/docs/GRID_RECALCULATION.md +3 -3
  53. package/docs/LOGGING.md +9 -0
  54. package/docs/MPA_CREDIT_USAGE.md +3 -2
  55. package/docs/ORDER_ENGINE_POST_1.0_RETROSPECTIVE.md +117 -0
  56. package/docs/README.md +1 -1
  57. package/docs/architecture.md +98 -1
  58. package/market_adapter/README.md +2 -2
  59. package/package.json +3 -1
  60. package/scripts/README.md +85 -148
package/dist/unlock.js CHANGED
@@ -47,7 +47,7 @@ import { setUmask } from './modules/config.js';
47
47
  import fs from 'node:fs';
48
48
  import { path } from './modules/path_api.js';
49
49
  import { getStorage } from './modules/storage/index.js';
50
- import { createCredentialDaemonController } from './modules/launcher/credential_daemon.js';
50
+ import { createCredentialDaemonController, clearVaultSecret } from './modules/launcher/credential_daemon.js';
51
51
  import { buildScopedChildEnv } from './modules/launcher/child_env.js';
52
52
  import { parseUnlockArgs } from './modules/launcher/launch_modes.js';
53
53
  import { UPDATER, LAUNCHER } from './modules/constants.js';
@@ -954,23 +954,33 @@ async function handleControl({ cmd, target }) {
954
954
  const summaryServiceNames = getControlServiceNames(effectiveCmd, summaryBotNames);
955
955
  if (effectiveCmd === 'restart-all' || effectiveCmd === 'reload-all') {
956
956
  if (effectiveCmd === 'restart-all' && process.stdin.isTTY) {
957
- const credResult = await stopCredentialDaemon();
958
- if (credResult.signaled) {
959
- console.log('Stop signal sent to credential daemon');
960
- }
957
+ // Verify the master password BEFORE stopping the live
958
+ // daemon. A wrong or cancelled password must leave the
959
+ // existing daemon (and every bot's key access) intact
960
+ // instead of killing it and then failing to re-unlock.
961
961
  const daemonOpts = { detached: true };
962
- const unlockedNow = await controller.ensureCredentialDaemon(daemonOpts);
963
- if (unlockedNow) {
964
- console.log(statusSuccess('✓ Authentication successful'));
965
- }
966
- const newCredPid = controller.getManagedDaemonPid();
967
- if (newCredPid) {
968
- try {
969
- storage.writeFile(MONOLITHIC_CRED_PID_FILE, String(newCredPid), { mode: 0o600 });
962
+ const vaultSecret = await controller.authenticateCredential();
963
+ try {
964
+ const credResult = await stopCredentialDaemon();
965
+ if (credResult.signaled) {
966
+ console.log('Stop signal sent to credential daemon');
970
967
  }
971
- catch (_) { }
968
+ const unlockedNow = await controller.ensureCredentialDaemon({ ...daemonOpts, vaultSecret });
969
+ if (unlockedNow) {
970
+ console.log(statusSuccess('✓ Authentication successful'));
971
+ }
972
+ const newCredPid = controller.getManagedDaemonPid();
973
+ if (newCredPid) {
974
+ try {
975
+ storage.writeFile(MONOLITHIC_CRED_PID_FILE, String(newCredPid), { mode: 0o600 });
976
+ }
977
+ catch (_) { }
978
+ }
979
+ controller.releaseManagedDaemon();
980
+ }
981
+ finally {
982
+ clearVaultSecret(vaultSecret);
972
983
  }
973
- controller.releaseManagedDaemon();
974
984
  }
975
985
  // reload-all intentionally skips the credential daemon
976
986
  // stop/re-unlock above: bots keep their key access while the
@@ -1146,17 +1156,25 @@ async function handleControl({ cmd, target }) {
1146
1156
  controlCmd.bot = effectiveTarget;
1147
1157
  // Restart credential daemon for restart-all (no target) in isolated mode
1148
1158
  if (!effectiveTarget && effectiveCmd === 'restart-all' && process.stdin.isTTY) {
1149
- const ownerPid = findCredentialSocketOwnerPid();
1150
- if (ownerPid > 0 && isLikelyCredentialDaemonProcess(ownerPid)) {
1151
- await stopCredentialDaemonPid(ownerPid);
1152
- }
1153
- cleanupCredentialRuntimeFiles();
1159
+ // Authenticate first: the running daemon is only stopped once the
1160
+ // master password is confirmed, so a failed restart keeps keys live.
1154
1161
  const daemonOpts = { detached: true };
1155
- const unlockedNow = await controller.ensureCredentialDaemon(daemonOpts);
1156
- if (unlockedNow) {
1157
- console.log(statusSuccess('✓ Authentication successful'));
1162
+ const vaultSecret = await controller.authenticateCredential();
1163
+ try {
1164
+ const ownerPid = findCredentialSocketOwnerPid();
1165
+ if (ownerPid > 0 && isLikelyCredentialDaemonProcess(ownerPid)) {
1166
+ await stopCredentialDaemonPid(ownerPid);
1167
+ }
1168
+ cleanupCredentialRuntimeFiles();
1169
+ const unlockedNow = await controller.ensureCredentialDaemon({ ...daemonOpts, vaultSecret });
1170
+ if (unlockedNow) {
1171
+ console.log(statusSuccess('✓ Authentication successful'));
1172
+ }
1173
+ controller.releaseManagedDaemon();
1174
+ }
1175
+ finally {
1176
+ clearVaultSecret(vaultSecret);
1158
1177
  }
1159
- controller.releaseManagedDaemon();
1160
1178
  }
1161
1179
  try {
1162
1180
  const resp = await sendControlCommand(controlCmd);
@@ -71,6 +71,9 @@ This document defines the non-negotiable behavioral invariants for the DEXBot2 s
71
71
  - `INV-COW-008` Owed fill crawls survive unapplied commits
72
72
  - `order/strategy.ts` records a crawl per shift-eligible fill at intake (slot-level dedupe, capped at 500); `deriveTargetBoundary` folds still-owed `_pendingFillCrawls` into the next derivation, excluding the current batch's slots, edge slots, and window members — a window that reaches the grid edge is not an edge order, using the same window exclusion every placement picker and `countLiveEdgeOrders` apply.
73
73
  - `_commitWorkingGrid` clears them only when the plan's boundary was actually applied — a held boundary (`boundaryHeld`), a gate-rejected boundary, and a null boundary all leave them owed.
74
+ - A window that lands BEHIND the newest real fill is repaired by `reanchorBoundaryFromLastFill` (called from `calculateTargetGrid` right after the derivation): the fill anchors the geometry — `SELL fill at f => boundary ≥ f − gapSlots`, `BUY fill at f => boundary ≤ f − 1` — because a ±1 crawl can never catch up. Fail-closed preconditions: fill-provenanced pivot with a recorded side, on-ladder price within one increment, and `validatePersistedBoundary` (a strand refuses the re-anchor). This is what unblocks a sweep whose crawls were lost, without a rebuild.
75
+ - Consumption is SCOPED to what the derivation applied: `deriveTargetBoundary` returns `consumedCrawlIds` (the owed records whose shift it folded, plus the records it deliberately never counts — current-batch slots, edge-classified slots, malformed records), the plan carries it (`buildSuccessResult` → `CowResult` → `_commitWorkingGrid` options), and `_consumePendingFillCrawls` drops exactly those, logging `Dropped N … kept=M`. A capped fold consumes only the entries it actually applied (same-side prefix up to the applied magnitude), so the remainder stays owed exactly once. `_clearPendingFillCrawls` remains the explicit allowed-loss path (rebuild, rejected snapshot, restart replay) and drops everything.
76
+ - A commit **without** the wire consumes nothing (a create-only plan never derived a boundary): clearing it would be the old silent-loss bug (2026-10-25: 7 slots 147–153 swept, every record dropped, boundary ending 7 levels behind).
74
77
  - `consumePendingFillCrawls` applies them onto a restored finite boundary; `applyPersistedPendingCrawls` is the shared startup/recovery wrapper used before sync/reconcile; `_clearPendingFillCrawls` drops them when the boundary is re-anchored (grid rebuild via `initializeGrid`, rejected snapshot via `rejectCorruptedGridSnapshot`, persisted snapshot wipe via `AccountOrders.clearGrid`).
75
78
 
76
79
  - `INV-COW-009` LAST-FILL-GUARD pivot survives restarts with the snapshot, and only as a fill fact
@@ -85,6 +88,9 @@ This document defines the non-negotiable behavioral invariants for the DEXBot2 s
85
88
  - `checkSpreadCondition` holds the refcounted broadcast region (`startBroadcasting` / `stopBroadcasting`, released in `finally`) across its whole attempt loop, so a fill-driven rebalance defers rather than committing a master-version bump between the initial plan and its broadcast. This narrows the race; the COW commit guard remains the backstop.
86
89
  - Before broadcasting, `resolveOccupiedCorrection` re-derives a plan whose CREATE destination became a live order since planning (`getOccupiedCorrectionSlots`), or withholds it — a known-taken slot is never shipped. The COW build layer stays authoritative against a detector false positive.
87
90
  - A transient refusal re-plans ONCE from fresh master (`replanSpreadCorrectionFromFreshMaster`, bounded by `TIMING.SPREAD_CORRECTION_MAX_ATTEMPTS`); a non-transient refusal (`commit-refused` / `update-target-missing` / `unmatched-chain-orders` / `shutdown`) is not retried and counts toward the out-of-spread stale clock.
91
+ - Candidates are tightening-edge-only on real grid slots (`tightensSpread` + distance-to-edge ordering + `doesNotCrossMarket`) AND last-fill consistent: the planner applies the guard's own direction rule (`passesLastFill`, same pivot, same predicate) before the quota slice, so a batch is never built from ops the broadcast guard would drop. An unplaceable side reports the geometry bind `last-fill-blocked` instead of a wasted "prepared but not executed" cycle.
92
+ - The budget spent by the loop is chain-truth for a known candidate set: `available = chainFree − virtualReservation` is circular when the reservation describes the very slots being funded, so an over-sized projection (rail sized from a larger balance or from inventory locked in resting orders) would read 0 forever (`planned 3, placing 0`, 84 minutes live). `deriveChainTruthFundBudget` re-derives it as `min(chainFree, min(virtualReservation, Σ candidate ideals))` when `available` is 0 **and** the reservation exceeds chain free (a zero caused by fees or an empty balance is a real constraint and is honoured); the chain stays the final arbiter.
93
+ - Terminal stalls are named and escalated on their own windows rather than the structural 30 minutes: rail oversubscription (`availableFund = chainFree − virtual` reads 0 while the side still holds inventory) on `SPREAD_STALE_FUND_ESCALATE_MS`, the `last-fill-blocked` geometry bind on `SPREAD_STALE_GEOMETRY_ESCALATE_MS`, and the persistence clock clears only after sustained tolerance (`SPREAD_STALE_IN_TOLERANCE_RESET_MS`) or a placement.
88
94
  - This is the grid layer's counterpart to `INV-COW-003` (COW-layer pre-broadcast re-plan) and to `INV-COW-007`'s broadcast-flag deferral contract.
89
95
 
90
96
  - `INV-PROJ-001` New projected orders remain virtual
@@ -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.16).
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.17).
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.16 |
39
+ | **Release Track** | 1.0.0 | v1.6.17 |
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.16 |
779
+ | **Release Track** | 1.0.0 | v1.6.17 |
780
780
  | **Active Since** | ~2018 | December 2025 |
781
- | **Last Commit** | May 23, 2020 | 2026-10-18 |
782
- | **Total Commits** | 2281 | 2,426 (current HEAD, v1.6.16 line) |
781
+ | **Last Commit** | May 23, 2020 | 2026-10-30 |
782
+ | **Total Commits** | 2281 | 2,438 (current HEAD, v1.6.17 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.16 release.
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.17 release.
6
6
 
7
7
  ### Key Milestones
8
8
  - **Project Inception**: December 2, 2025
9
- - **Growth Phase**: 2,426 commits over ~9 active months
9
+ - **Growth Phase**: 2,438 commits over ~9 active months
10
10
  - **Code Maturity**: Evolution from basic utilities to a ~100,000+ LoC intelligent TypeScript system
11
- - **Stability**: Progression from manual testing to a suite of 310 automated test files
12
- - **Releases**: 148 version entries in the changelog (v0.1.0 to v1.6.16)
11
+ - **Stability**: Progression from manual testing to a suite of 321 automated test files
12
+ - **Releases**: 149 version entries in the changelog (v0.1.0 to v1.6.17)
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-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).
152
+ Compact, era-level view; commit counts are `git rev-list --count <tag>..<tag>` over the current history (2026-10-30). The 107 commits up to and including the `v0.1.0` tag are not attributed to an era, so the current totals are 2,331 (`v0.1.0..HEAD`) and 2,438 (`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
  |-----|--------:|-------|
@@ -174,11 +174,12 @@ Compact, era-level view; commit counts are `git rev-list --count <tag>..<tag>` o
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
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 |
177
+ | v1.6.16 → v1.6.17 | 11 | Last-fill direction guard, placeable-slot spread planning with named stalls, chain-truth funding + fill-anchored boundary re-anchor, owed-crawl consumption, restart auth-before-stop with cleared vault secret, pool-priced LP-share collateral, AMA slowPeriod/slope retune, BTS & per-token supply distribution analyzers |
177
178
 
178
179
  ---
179
180
 
180
181
  **Report Originally Generated**: February 19, 2026
181
- **Last Updated**: October 18, 2026
182
- **Total Commits**: 2,426
183
- **Date Range**: December 2, 2025 – October 18, 2026
182
+ **Last Updated**: October 30, 2026
183
+ **Total Commits**: 2,438
184
+ **Date Range**: December 2, 2025 – October 30, 2026
184
185
  **Repository**: DEXBot2 (BitShares DEX Trading Bot)
@@ -53,6 +53,8 @@ funds.allocated → _getSizingContext() (budget for spread correction)
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
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
+ - `funds.available[side] = max(0, chainFree − virtualReservation − fees)`. When the empty rail already reserves more than the chain holds, this reads 0 while the side still holds inventory — the **rail oversubscribed** state. Spread correction names it in the log, flags it on the manager, and the out-of-spread watchdog escalates it on `TIMING.SPREAD_STALE_FUND_ESCALATE_MS`: the durable repair is re-sizing the rail from chain truth (structural re-center).
57
+ - For a KNOWN candidate set the reservation must not veto the placement it describes: `deriveChainTruthFundBudget` (`utils/math.ts`) re-derives `min(chainFree, min(virtualReservation, Σ candidate ideals))` when `available` reads 0, so an over-sized projection cannot deadlock placement. The chain rejects an over-commit at broadcast, so this cannot spend more than exists.
56
58
 
57
59
  ---
58
60
 
@@ -803,4 +805,4 @@ To prevent "Time-of-Check to Time-of-Use" errors:
803
805
  **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
806
 
805
807
  ---
806
- *Technical Reference for DEXBot2 v1.6.16 release*
808
+ *Technical Reference for DEXBot2 v1.6.17 release*
@@ -116,6 +116,12 @@ fixture), as is a destination hole carrying an already-corrupted price (28%).
116
116
 
117
117
  ### The seventh gate: final pre-broadcast pivot re-check
118
118
 
119
+ The per-action LAST-FILL-GUARD rule is direction-only relative to that pivot —
120
+ a BUY is blocked at/above it, a SELL at/below it (equal price is a re-place at
121
+ the just-filled level). The spread-correction planner applies the SAME predicate
122
+ to its candidates before planning, so a correction batch never contains an op
123
+ the guard would drop.
124
+
119
125
  The per-action LAST-FILL-GUARD checks run against the pivot frozen at batch
120
126
  start. A fill queued between that freeze and the broadcast passes every
121
127
  per-action check on a stale pivot and ships (live incident: freeze at 0.745,
@@ -160,16 +160,16 @@ node dist/market_adapter/market_adapter.js --deltaPercent 2
160
160
  "ama": {
161
161
  "erPeriod": 781, // Efficiency Ratio lookback period (candles)
162
162
  "fastPeriod": 5.2, // Fast smoothing period for trending markets
163
- "slowPeriod": 83.6 // Slow smoothing period for choppy markets
163
+ "slowPeriod": 83.5 // Slow smoothing period for choppy markets
164
164
  }
165
165
  }
166
166
  ```
167
167
 
168
168
  > Optional. A bot-level `ama` block overrides the preset (or matched pair profile)
169
169
  > field by field, and supplying any period marks the bot's AMA as `custom` in the
170
- > adapter state. The values above are the fitted `AMA3` built-in defaults
170
+ > adapter state. The values above are the built-in `AMA3` defaults
171
171
  > (`MARKET_ADAPTER.AMAS`): `erPeriod: 781` and `fastPeriod: 5.2` are shared, while
172
- > `slowPeriod` runs `62.1` (AMA1) to `96.9` (AMA4).
172
+ > `slowPeriod` runs `62.1` (AMA1) to `99.3` (AMA4).
173
173
 
174
174
  > **`gridPrice` is the only switch.** A bot is AMA-driven when `gridPrice` says
175
175
  > so — `usesAmaGridPrice()`, the source of truth shared by the bot, maintenance
package/docs/LOGGING.md CHANGED
@@ -307,6 +307,15 @@ re-plan retries). Kept separate from the generic `refusedCommitCount`.
307
307
  | `[SPREAD-CORRECTION] Plan-time dedupe: N planned slot(s) occupied since planning (...); re-planning from fresh master` | A planned CREATE destination was taken after planning; the plan is re-derived from fresh master |
308
308
  | `[SPREAD-CORRECTION] Plan-time dedupe: ...; no re-plan candidate — refusing this cycle` | Collision detected but no fresh candidate exists; the colliding plan is withheld (never broadcast) |
309
309
  | `[SPREAD-CORRECTION] Batch refused (cause); re-planning from fresh master (attempt 2/2)` | Transient refusal; the bounded fresh-master re-plan is in progress |
310
+ | `[SPREAD-CORRECTION] Excluded N candidate(s) from <side> planning: SELL must be above / BUY must be below the last fill ... (the broadcast guard would drop them)` | The planner dropped tightening-edge candidates that the LAST-FILL-GUARD would veto. They were never planned, so no batch is wasted on a guaranteed refusal |
311
+ | `[SPREAD-CORRECTION] No placeable <side> slot: every tightening slot is at/through the last fill ...` | Honest no-op: the side cannot be tightened against the last fill (a boundary move or a new fill must restore headroom). Not a batch refusal |
312
+ | `[SPREAD-CORRECTION] <side> rail is OVERSUBSCRIBED: virtual reservation X exceeds chain free Y by Z — no correction can be funded until the rail is re-sized ...` | `availableFund` is `free − virtual`, so an oversubscribed rail reads 0 while the side still holds inventory. The watchdog escalates this on its short fund window |
313
+ | `[SPREAD-STALE] Spread out of tolerance for Nmin ... (outOfSpread=..., stall=...)` | Persistence warn with the last stall cause; the clock survives single in-tolerance readings and the terminal cases escalate early: `stall=last-fill-blocked` (sell window behind the last fill) on the 10-minute geometry window, a rail oversubscription on the 5-minute fund window |
314
+ | `[SPREAD-STALE] ... (sell window behind the last fill — re-centering)` | The `last-fill-blocked` geometry bind is escalating; placement cannot repair it, a re-center can |
315
+ | `[BOUNDARY] Re-anchored from the last fill: SELL filled at slot 153 (0.447640); boundary 146 -> 149 so the fill sits outside its own window` | The window was behind the fill and a ±1 crawl cannot catch up; the fill now anchors the geometry. Refusals are silent by design (cold/off-ladder/unsafe preconditions) |
316
+ | `[SPREAD-CORRECTION] sell projection exceeds chain free by 1485.41092974; funding the candidates from chain truth (2171.2 for 2171.2 of ideal size) instead of placing nothing` | The virtual reservation is the projection of these very candidates and is larger than the chain free balance; the correction funds what the chain actually holds instead of deadlocking on a circular budget |
317
+ | `[BOUNDARY] Dropped N owed fill crawl(s) (boundary commit): buy=B sell=S net=N±M oldest=Ns kept=M boundary X -> Y` | The commit consumed the records the derivation folded (`kept=M` = records that stayed owed — a capped fold or a re-recorded slot) |
318
+ | `[BOUNDARY] Kept N owed fill crawl(s) unconsumed (boundary commit)` | The commit arrived without a consumed-set (a plan that never derived a boundary) or folded nothing it could apply; the records stay owed for the next derivation |
310
319
  | `Spread correction batch was prepared but not executed. Keeping local state unchanged. (cause=...)` | Terminal refusal; `cause` is the classified `SPREAD_CORRECTION_REFUSAL` value |
311
320
  | `Shutdown complete. Final metrics: ... spreadCorrectionRefusals=N [cause=count, ...], spreadCorrectionRetries=M` | Refusal breakdown on shutdown; the suffix appears only when at least one refusal occurred |
312
321
 
@@ -170,9 +170,10 @@ C_i = C_total * weight_i / sum(all weights)
170
170
  ```
171
171
 
172
172
  - **MPA**: `feedPrice_i` is the current settlement feed price (collateral per debt asset), discovered from the chain and cached per position.
173
- - **Credit**: `conversionRate_i` is the offer's `acceptable_collateral` price (debt asset per collateral unit), discovered from existing deals or `allowedOfferIds`.
174
- - **Fallback chain** (every pair resolves a rate, so every CR is calculable): offer map → LP pool valuation (`pool-derived`) → universal DEX price (`market-direct`, else `market-bridge:<asset>` via bridge hops, default BTS). Only when all three fail does the group keep its existing budget with a warning and `weight = outputWeight * targetCR`.
173
+ - **Credit**: `conversionRate_i` is the live pool value for LP-share collateral (`pool-derived`); other collateral uses the offer's `acceptable_collateral` price (debt asset per collateral unit), discovered from existing deals or `allowedOfferIds`.
174
+ - **Fallback chain** (every pair resolves a rate, so every CR is calculable): LP-share collateral tries pool valuation (`pool-derived`) → offer map → universal DEX price; other collateral tries offer map → LP pool valuation → universal DEX price (`market-direct`, else `market-bridge:<asset>` via bridge hops, default BTS). Only when all three fail does the group keep its existing budget with a warning and `weight = outputWeight * targetCR`.
175
175
  - All offer-price orientation, conversion-rate, and CR math lives in `modules/credit_pricing.ts`, shared by the runtime and `dexbot credit`.
176
+ - LP-share collateral is valued at the pure pool market value: reserves/supply, with no slippage, taker fee, or withdrawal-fee deduction, matching the runtime borrow gate.
176
177
  - `outputWeight` is the user's output proportion. Equal weights produce **equal economic debt value** across all lending items, regardless of price or CR differences.
177
178
 
178
179
  ### Examples
@@ -642,6 +642,123 @@ required is no longer reachable at runtime.
642
642
  - **Placed is not surplus:** an order inside `SURPLUS_CANCEL_GRACE_MS` is never cancelled by a
643
643
  sweep running on a stale snapshot.
644
644
 
645
+ #### 9.7 The guard was a band, not an economic rule (`c86b4b0e`)
646
+
647
+ **Observed (2026-10-24/25, a live market-pair bot).** A dump swept the grid and the
648
+ market then held. Spread correction planned, the broadcast guard dropped the creates,
649
+ `SPREAD-STALE` reported **84 minutes with no correction placed**, and only a structural
650
+ re-center (grid rebuild) restored the spread. Two distinct guard defects, both from one
651
+ predicate:
652
+
653
+ 1. **The pivot band ignored the fill's side.** `isLastFillGuardBlocked` judged against
654
+ `pivot ± increment/2`:
655
+ ```ts
656
+ BUY blocked if price > pivot * (1 - inc/2/100)
657
+ SELL blocked if price < pivot * (1 + inc/2/100)
658
+ ```
659
+ The `lastType` argument was passed and never read. Consequences: a BUY **below** a SELL
660
+ fill was blocked (the doc claimed "buy-below-sell is never gated"; the code gated it),
661
+ and a SELL 0.2% **above** our cost was blocked after a BUY fill — exactly the spread
662
+ edge, which correction places tighter than a full increment by design. Repair therefore
663
+ depended on the `SPREAD_CORRECTION` bypass, which `09dbaad7` denies whenever a real fill
664
+ reference exists — so after any fill, tightening was structurally impossible.
665
+ 2. **Planner and guard disagreed.** `09dbaad7` intended a planner-side filter against the
666
+ fill reference, but the implementation used the readiness *crossing floor*, which
667
+ prefers a **fresh live market read** over the fill anchor. With a fresh read the planner
668
+ admitted what the guard would drop, producing the live sequence
669
+ `planned 2, placing 1 → Skipping sell CREATE … below last filled → Transient refusal 1/3
670
+ → batch was prepared but not executed` — a whole cycle spent on a guaranteed refusal.
671
+
672
+ **Fix.** Direction only, one predicate shared by both sides:
673
+
674
+ ```ts
675
+ BUY blocked if price >= pivot // never place a higher BUY
676
+ SELL blocked if price <= pivot // never place a lower SELL
677
+ ```
678
+
679
+ Equal price stays blocked (re-place at the filled level). The predicate lives in
680
+ `order/utils/system.ts` next to `resolveLastFillGuardReference`; `dexbot_cow_runtime`
681
+ re-exports it. The planner now filters every candidate pool (and boundary promotion) with
682
+ the **same** predicate before the quota slice, so a batch is never built out of ops the
683
+ guard will drop, and an unplaceable side reports it honestly.
684
+
685
+ **Deliberately not relaxed.** A lower SELL is still refused **when the last fill was a
686
+ SELL**: after a fill the sell window must move *up*, so a sell slot below the last sale is
687
+ evidence that the boundary/crawl is behind the fill — a geometry fault, not a placement
688
+ opportunity. The log confirms it: seven slots (147–153) filled in one sync, the boundary
689
+ then **moved down** to 146 (two commits each dropping owed crawls), leaving slots 151/152
690
+ as sell-zone holes below the last sale. A cost-basis rule (sell only above the last BUY)
691
+ would have *placed into* that corrupted geometry.
692
+
693
+ #### 9.8 Stalls that placement cannot repair get their own clocks
694
+
695
+ Three states were previously indistinguishable from patience and all waited for the
696
+ 30-minute structural window:
697
+
698
+ - **Rail oversubscribed** — `availableFund = chainFree − virtual` reads 0 when the empty
699
+ rail already reserves more than the account holds (live: free 454560.80 vs virtual
700
+ 456046.21, `planned 3, placing 0` for 84 minutes). Named in the log, flagged on the
701
+ manager, escalated on `SPREAD_STALE_FUND_ESCALATE_MS` (5 min).
702
+ - **Geometry bind (`last-fill-blocked`)** — every tightening slot is at/through the last
703
+ fill, i.e. the window is behind the fill. A distinct stall value, preserved through the
704
+ starvation-fallback merge (`mergeSpreadStalls`), escalated on
705
+ `SPREAD_STALE_GEOMETRY_ESCALATE_MS` (10 min).
706
+ - **Oscillating measurement** — one in-tolerance reading no longer clears the persistence
707
+ clock; tolerance must hold for `SPREAD_STALE_IN_TOLERANCE_RESET_MS` (10 min), and a
708
+ placed correction still clears it immediately. A single good glance between refusals was
709
+ what let 84 minutes pass.
710
+
711
+ **RESOLVED (crawl consumption is now scoped).** The clear was ledger-wide while
712
+ the derivation folded a subset. `deriveTargetBoundary` now returns
713
+ `consumedCrawlIds`, the plan carries it to the commit (`_consumePendingFillCrawls`),
714
+ and only the applied records are dropped — a capped fold consumes a same-side
715
+ prefix up to the applied magnitude, so the remainder stays owed exactly once.
716
+ A commit without the wire consumes nothing. The instrumentation below remains
717
+ (and now reports `kept=M`), and the historical leak record is kept for context:
718
+
719
+ **Original finding (leak #6): the crawl ledger dropped records it never applied.** A commit clears
720
+ **all** owed fill crawls whenever the plan's boundary is accepted and not held
721
+ (`_clearPendingFillCrawls('boundary commit')`), while the derivation folds only the subset
722
+ that passes its batch-dedupe, edge classification and `fallbackCap`. Any excluded entry is
723
+ lost — the same class `77e763f6` fixed for the held boundary, still open for the rest, and
724
+ the mechanism behind a multi-slot sweep leaving the boundary *behind* the fills.
725
+
726
+ #### 9.9 Two deadlocks that were bookkeeping, not market (`430dee6a` follow-up)
727
+
728
+ Both incidents in §9.7/§9.8 ended in a rebuild. Neither was a fund shortage and
729
+ neither needed a new guard — each was a self-referential calculation that could
730
+ only be broken from outside.
731
+
732
+ **The budget that vetoed its own placement.** `available = chainFree −
733
+ virtualReservation` is the right question for "how much room is left beyond the
734
+ projected rail", but the correction then spends it on *that same projection*:
735
+ when the rail was sized from a larger balance (or from inventory locked in
736
+ resting orders), the reservation exceeds chain free, `available` reads 0, no
737
+ placement can consume the reservation, and it can never shrink. Live: free
738
+ 454560.80 vs virtual 456046.21 — `planned 3, placing 0` every cycle for 84
739
+ minutes. The fix is arithmetic, not policy: for a known candidate set the budget
740
+ is `min(chainFree, min(virtualReservation, Σ candidate ideals))` when `available`
741
+ is 0 (`deriveChainTruthFundBudget`). Bound on both sides, and the chain rejects
742
+ an over-commit anyway.
743
+
744
+ **The crawl that could not catch up.** A boundary crawl is ±1 slot per committed
745
+ fill, so once a sweep leaves the window *behind* the fill, crawling is
746
+ arithmetically unable to recover: every tightening slot is then at/through the
747
+ fill, `passesLastFill` refuses all of them, and the funds sit in the stranded
748
+ resting inventory. The cheapest repair (rotate the stranded orders down) is
749
+ itself a lower sell, which the same guard forbids — three locks, no key. The fill
750
+ is the anchor: `SELL fill at f => boundary ≥ f − gapSlots`, `BUY fill at f =>
751
+ boundary ≤ f − 1` (`reanchorBoundaryFromLastFill`), subject to a real
752
+ fill-provenanced pivot, an on-ladder price and `validatePersistedBoundary`.
753
+
754
+ **Deliberately rejected: the pair ledger.** Making each fill mint its counter
755
+ order (reserve the exact proceeds) would prove per-trade funding and delete the
756
+ `fund-constrained prefix` logic — but it also turns the ladder into a set of
757
+ independent round trips, so sizes stop following the side budget. Spread repair
758
+ must stay fund-driven from the side pool: a SELL fill returns quote while the
759
+ same-side repair needs base, so no fill can ever fund its own side, and pairing
760
+ would hide that asymmetry instead of resolving it.
761
+
645
762
  ---
646
763
 
647
764
  ### A. Grid-Price Invariant — former failure trace
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.16 (released).
5
+ **Version context:** v1.6.17 (released).
6
6
 
7
7
  ---
8
8
 
@@ -488,7 +488,12 @@ The correction path is fund-only and never manufactures budget by shrinking a re
488
488
  without shrinking inventory, and log the fund-constrained remainder.
489
489
  6. If neither side places an effective order, `checkSpreadCondition` reports a
490
490
  `stall` cause (`no-free-funds` / `unfunded` / `no-candidates` / `cold-book` /
491
- `unmatched-orders` / `readiness-gate` / `batch-not-executed` / `apply-error`).
491
+ `unmatched-orders` / `readiness-gate` / `last-fill-blocked` /
492
+ `batch-not-executed` / `apply-error`). `last-fill-blocked` is the geometry
493
+ bind: every tightening slot on that side is at/through the last fill, so a
494
+ sell slot below the last sale means the boundary/crawl is behind the fill —
495
+ placement cannot repair it and the re-center can, so it escalates on the
496
+ short geometry window.
492
497
  Every cause arms the targeted
493
498
  balances + open-orders refresh: the local snapshot the check reasoned over
494
499
  may be stale (`no-candidates` can mean a missed fill left an ACTIVE slot
@@ -520,6 +525,88 @@ const availableFund = Math.max(0, Math.min(
520
525
  // No resting ACTIVE/PARTIAL order is shrunk to fund the correction.
521
526
  ```
522
527
 
528
+ `availableFund` is `chainFree − virtualReservation`, so it reads 0 when the
529
+ empty rail already reserves more than the chain holds. That state
530
+ (*rail oversubscribed*) is named explicitly in the log and flagged on the
531
+ manager; the out-of-spread watchdog then escalates on its short fund window
532
+ instead of waiting for a fill that cannot free existing inventory.
533
+
534
+ The budget the loop spends is **not** `availableFund`, because subtracting the
535
+ projection from the budget that funds that same projection is circular: a rail
536
+ sized from a larger balance (or from inventory locked in resting orders) reads 0
537
+ forever and no placement can ever shrink it. `deriveChainTruthFundBudget`
538
+ (`order/utils/math.ts`) re-derives it for a known candidate set:
539
+
540
+ ```text
541
+ budget = availableFund > 0 ? availableFund // healthy: accounting wins
542
+ : virtualReservation > chainFree ? min(chainFree, min(virtualReservation, Σ candidate ideals))
543
+ : availableFund // zero for fees/empty balance: honour it
544
+ ```
545
+
546
+ so the correction funds what the chain actually holds free (capped by what the
547
+ candidates need, and the chain stays the final arbiter). Live effect: the
548
+ `planned 3, placing 0` cycle that ran for 84 minutes now places the three holes.
549
+
550
+ ### Owed Fill Crawls: consume what was applied, keep the rest owed
551
+
552
+ Every shift-eligible fill records a relative boundary delta (`_pendingFillCrawls`)
553
+ because the batch that saw the fill may not commit a boundary (refused
554
+ broadcast, held boundary, restart). The derivation folds a *subset* — current-batch
555
+ slots are deduped (their shift comes from `fills`), edge slots never crawl, and
556
+ the cross-chunk budget caps how far one plan may move. So the commit must not
557
+ clear the whole ledger: `deriveTargetBoundary` returns `consumedCrawlIds`
558
+ (what it applied, plus what it deliberately never counts), the plan carries it
559
+ to `_consumePendingFillCrawls` via `buildSuccessResult` → `CowResult` →
560
+ `_commitWorkingGrid({ consumedCrawlIds })`, and only those records are dropped.
561
+ A capped fold consumes a same-side prefix up to the applied magnitude; the rest
562
+ stays owed and applies exactly once on a later derivation. `_clearPendingFillCrawls`
563
+ is the explicit allowed-loss path (rebuild, rejected snapshot, restart replay).
564
+
565
+ ### Boundary Re-Anchoring: the fill is the anchor
566
+
567
+ A boundary crawl is ±1 slot per committed fill, so a window that ends up
568
+ **behind** the newest real fill cannot catch up by crawling — every tightening
569
+ slot on that side is then at/through the fill and `passesLastFill` refuses all of
570
+ them while the funds sit in the resting (stranded) inventory. `reanchorBoundaryFromLastFill`
571
+ (`order/utils/system.ts`, called from `calculateTargetGrid` right after the
572
+ derivation) treats the fill as the anchor:
573
+
574
+ ```text
575
+ SELL fill at slot f -> boundary >= f - gapSlots (sellStart = f + 1)
576
+ BUY fill at slot f -> boundary <= f - 1 (buy window ends below f)
577
+ ```
578
+
579
+ Preconditions, all fail-closed: a real fill-provenanced pivot (a cold/book-seeded
580
+ pivot or a price without a recorded fill side never anchors), an on-ladder price
581
+ within one increment (`off-ladder-fill`), and the candidate must pass
582
+ `validatePersistedBoundary` — a re-anchor that would strand a live order inside
583
+ the re-typed band is refused (`unsafe: placed_order_in_band`). Every accepted
584
+ re-anchor is logged at warn with the fill slot, the pivot price and the boundary
585
+ move.
586
+
587
+ ### Candidate Selection: Spread Edge, Grid Slot, Last-Fill Consistent
588
+
589
+ The planner only ever emits the tightening edge on a real grid slot:
590
+
591
+ - `tightensSpread` — a SELL must improve (be below) the lowest live sell, a BUY
592
+ must improve the highest live buy;
593
+ - `sortCandidates` + `.slice(0, missingSlots)` — the nearest empty level to the
594
+ live edge, so no interior hole is created;
595
+ - `doesNotCrossMarket` — the absolute crossing floor (fresh live read, fill
596
+ reference as fallback);
597
+ - **`passesLastFill`** — the same direction rule the broadcast guard applies
598
+ (`SELL` above the last fill, `BUY` below it), evaluated on the same pivot.
599
+
600
+ The last filter is what keeps planner and guard from disagreeing: without it a
601
+ cycle could plan a candidate the guard was guaranteed to drop, and the whole
602
+ batch would be reported as "prepared but not executed" (observed live: the only
603
+ funded candidate sat at the fill price, both attempts were dropped, and the
604
+ correction spent its cycle on a refusal). With it, an unplaceable side reports
605
+ *no placeable slot — every tightening slot is at/through the last fill* and the
606
+ batch is never built. Only a fill arriving **during** the check can still change
607
+ the pivot under the batch; the final pre-broadcast gate remains the last line
608
+ for that race.
609
+
523
610
  **Benefits**:
524
611
  - ✅ No inventory recycling from stale-size snapshots
525
612
  - ✅ Constant, predictable spread width
@@ -570,6 +657,16 @@ effective correction**:
570
657
  - warns once past `TIMING.SPREAD_STALE_WARN_MS`;
571
658
  - escalates to a structural re-center past `TIMING.SPREAD_STALE_ESCALATE_MS`
572
659
  (cooldown `TIMING.SPREAD_STALE_RESYNC_COOLDOWN_MS`);
660
+ - clears the clock only after the spread has stayed in tolerance for
661
+ `TIMING.SPREAD_STALE_IN_TOLERANCE_RESET_MS` (or immediately on a placed
662
+ correction). A single in-tolerance reading does not clear it: the measured
663
+ spread oscillates around the tolerance edge, and resetting per good glance let
664
+ a live bot sit out of tolerance for 84 minutes while every cycle looked
665
+ recoverable;
666
+ - escalates on a **shorter** window (`TIMING.SPREAD_STALE_FUND_ESCALATE_MS`) when
667
+ the correction reports a rail-oversubscribed fund stall (`virtual` reservation
668
+ > chain free on the corrected side). That state cannot heal by waiting for a
669
+ fill — the rail must be re-sized from chain truth, which the re-center does;
573
670
  - tolerates up to `TIMING.SPREAD_STALE_TRANSIENT_GRACE` consecutive **transient**
574
671
  refusals (which reset the stale clock) before they count toward escalation, so a
575
672
  retryable refusal is not mistaken for a structural dead end — a persistent one
@@ -241,13 +241,13 @@ Pair-specific AMA profiles live in `profiles/market_profiles.json`:
241
241
  "defaultAma": "AMA1",
242
242
  "amas": {
243
243
  "AMA1": { "erPeriod": 781, "fastPeriod": 5.2, "slowPeriod": 62.1 },
244
- "AMA2": { "erPeriod": 781, "fastPeriod": 5.2, "slowPeriod": 72.0 }
244
+ "AMA2": { "erPeriod": 781, "fastPeriod": 5.2, "slowPeriod": 71.5 }
245
245
  }
246
246
  }]
247
247
  }
248
248
  ```
249
249
 
250
- > The `amas` periods above are the fitted built-in presets (`MARKET_ADAPTER.AMAS`),
250
+ > The `amas` periods above are the built-in presets (`MARKET_ADAPTER.AMAS`),
251
251
  > shown here only to make the shape concrete. A real pair profile needs just the
252
252
  > fields it changes — e.g. `"AMA3": { "slowPeriod": 90 }` keeps the built-in
253
253
  > `erPeriod`/`fastPeriod` and overrides only `slowPeriod`.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dexbot",
3
- "version": "1.6.16",
3
+ "version": "1.6.17",
4
4
  "description": "The first open source trading bot with zero runtime dependencies and a fully adaptive market making strategy.",
5
5
  "main": "dist/modules/dexbot_class.js",
6
6
  "exports": {
@@ -99,6 +99,8 @@
99
99
  "analysis:grid-check": "npm run build && node dist/analysis/grid_correction_check.js",
100
100
  "analysis:resolve-accounts": "npm run build && node dist/analysis/resolve_bot_accounts.js",
101
101
  "richlist": "npm run build && node dist/scripts/rich_list.js",
102
+ "distribution": "npm run build && node dist/scripts/bts_distribution.js",
103
+ "token-distribution": "npm run build && node dist/scripts/token_distribution.js",
102
104
  "native:release-gates": "npm run build && npm run build:tests && node dist/scripts/native_release_gates.js",
103
105
  "native:serial-snapshots": "npm run build && npm run build:tests && node dist/tests/test_native_serial_ops.js",
104
106
  "native:ecc-invariants": "npm run build && npm run build:tests && node dist/tests/test_native_ecc.js",