dexbot 1.6.18 → 1.7.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +68 -0
- package/README.md +24 -18
- package/analysis/README.md +117 -5
- package/claw/package.json +1 -1
- package/claw/runtimes/openclaw-plugin/openclaw.plugin.json +1 -1
- package/claw/runtimes/openclaw-plugin/package.json +1 -1
- package/dist/analysis/account_resolver.js +5 -6
- package/dist/analysis/analyze_dynamic_weight.js +2 -1
- package/dist/analysis/analyze_kalman.js +3 -2
- package/dist/analysis/analyze_liquidity.d.ts +17 -0
- package/dist/analysis/analyze_liquidity.js +336 -0
- package/dist/analysis/analyze_regime.js +3 -2
- package/dist/analysis/analyze_regime_windows.js +3 -2
- package/dist/analysis/analyze_volatility.js +3 -2
- package/dist/analysis/bot_key_utils.d.ts +44 -1
- package/dist/analysis/bot_key_utils.js +76 -7
- package/dist/analysis/fills_cache.js +2 -1
- package/dist/analysis/grid_correction_check.d.ts +1 -19
- package/dist/analysis/grid_correction_check.js +12 -30
- package/dist/analysis/liquidity/liquidity_chain.d.ts +66 -0
- package/dist/analysis/liquidity/liquidity_chain.js +178 -0
- package/dist/analysis/liquidity/liquidity_chart_generator.d.ts +19 -0
- package/dist/analysis/liquidity/liquidity_chart_generator.js +693 -0
- package/dist/analysis/liquidity/liquidity_depth_model.d.ts +166 -0
- package/dist/analysis/liquidity/liquidity_depth_model.js +258 -0
- package/dist/analysis/liquidity/liquidity_view.d.ts +53 -0
- package/dist/analysis/liquidity/liquidity_view.js +66 -0
- package/dist/analysis/resolve_bot_accounts.js +7 -6
- package/dist/analysis/trade_profitability.js +4 -2
- package/dist/analysis/tradingview/analyze_tradingview.js +2 -1
- package/dist/credential-daemon.js +13 -2
- package/dist/dexbot.js +77 -172
- package/dist/modules/account_bots.d.ts +11 -1
- package/dist/modules/account_orders.d.ts +12 -0
- package/dist/modules/account_orders.js +30 -0
- package/dist/modules/asset_lookup.d.ts +25 -0
- package/dist/modules/asset_lookup.js +75 -0
- package/dist/modules/bitshares-native/transport.js +24 -6
- package/dist/modules/bitshares_client.d.ts +24 -6
- package/dist/modules/bitshares_client.js +44 -7
- package/dist/modules/bot_settings.d.ts +2 -0
- package/dist/modules/chain_scan.d.ts +64 -0
- package/dist/modules/chain_scan.js +80 -0
- package/dist/modules/cli_colors.d.ts +5 -0
- package/dist/modules/cli_colors.js +7 -0
- package/dist/modules/cli_progress.d.ts +51 -0
- package/dist/modules/cli_progress.js +113 -0
- package/dist/modules/constants.d.ts +26 -3
- package/dist/modules/constants.js +63 -8
- package/dist/modules/dexbot_class.d.ts +1 -6
- package/dist/modules/dexbot_class.js +14 -0
- package/dist/modules/dexbot_cow_runtime.d.ts +97 -7
- package/dist/modules/dexbot_cow_runtime.js +634 -136
- package/dist/modules/dexbot_fill_runtime.js +132 -23
- package/dist/modules/dexbot_maintenance_runtime.js +242 -74
- package/dist/modules/dexbot_startup_runtime.js +32 -20
- package/dist/modules/dexbot_state_recovery.d.ts +33 -1
- package/dist/modules/dexbot_state_recovery.js +167 -5
- package/dist/modules/launcher/runtime_entry.d.ts +21 -1
- package/dist/modules/launcher/runtime_entry.js +36 -1
- package/dist/modules/liquidity_pool_ref.d.ts +32 -0
- package/dist/modules/liquidity_pool_ref.js +116 -0
- package/dist/modules/node_connect_policy.d.ts +8 -1
- package/dist/modules/node_connect_policy.js +18 -2
- package/dist/modules/node_flap_score.d.ts +87 -0
- package/dist/modules/node_flap_score.js +124 -0
- package/dist/modules/node_health_cache.d.ts +40 -3
- package/dist/modules/node_health_cache.js +66 -20
- package/dist/modules/node_manager.d.ts +101 -19
- package/dist/modules/node_manager.js +255 -65
- package/dist/modules/order/accounting.js +56 -7
- package/dist/modules/order/format.d.ts +24 -10
- package/dist/modules/order/format.js +30 -10
- package/dist/modules/order/grid.js +91 -13
- package/dist/modules/order/grid_reconcile.d.ts +5 -1
- package/dist/modules/order/grid_reconcile.js +333 -189
- package/dist/modules/order/grid_reconcile_internal.d.ts +38 -2
- package/dist/modules/order/grid_reconcile_internal.js +298 -100
- package/dist/modules/order/index.d.ts +19 -1
- package/dist/modules/order/lifecycle.d.ts +353 -0
- package/dist/modules/order/lifecycle.js +1109 -0
- package/dist/modules/order/manager.d.ts +273 -5
- package/dist/modules/order/manager.js +654 -48
- package/dist/modules/order/placement_lock.d.ts +102 -0
- package/dist/modules/order/placement_lock.js +222 -0
- package/dist/modules/order/strategy.js +13 -1
- package/dist/modules/order/sync_engine.d.ts +33 -1
- package/dist/modules/order/sync_engine.js +241 -73
- package/dist/modules/order/utils/math.d.ts +39 -1
- package/dist/modules/order/utils/math.js +83 -1
- package/dist/modules/order/utils/order.d.ts +181 -5
- package/dist/modules/order/utils/order.js +455 -9
- package/dist/modules/order/utils/system.d.ts +81 -1
- package/dist/modules/order/utils/system.js +331 -44
- package/dist/modules/order/utils/validate.d.ts +7 -1
- package/dist/modules/order/utils/validate.js +80 -3
- package/dist/modules/outcome.d.ts +54 -0
- package/dist/modules/outcome.js +51 -0
- package/dist/modules/settings_merge.d.ts +4 -0
- package/dist/modules/settings_merge.js +9 -0
- package/dist/modules/timing_policy.d.ts +82 -0
- package/dist/modules/timing_policy.js +244 -0
- package/dist/modules/types.d.ts +137 -0
- package/dist/modules/utils/asset_symbols.d.ts +13 -2
- package/dist/modules/utils/asset_symbols.js +21 -2
- package/dist/scripts/analysis_runner.d.ts +10 -0
- package/dist/scripts/analysis_runner.js +33 -0
- package/dist/scripts/analyze-credit.js +54 -17
- package/dist/scripts/analyze-orders.d.ts +4 -2
- package/dist/scripts/analyze-orders.js +115 -35
- package/dist/scripts/asset.d.ts +26 -0
- package/dist/scripts/asset.js +165 -0
- package/dist/scripts/bts_distribution.d.ts +1 -0
- package/dist/scripts/bts_distribution.js +194 -142
- package/dist/scripts/chart_command.d.ts +1 -1
- package/dist/scripts/chart_command.js +60 -86
- package/dist/scripts/chart_targets.d.ts +18 -0
- package/dist/scripts/chart_targets.js +48 -0
- package/dist/scripts/dw.js +1 -1
- package/dist/scripts/liquid.d.ts +24 -0
- package/dist/scripts/liquid.js +134 -0
- package/dist/scripts/rich_list.js +12 -16
- package/dist/scripts/test-credit-renewal.js +12 -5
- package/dist/scripts/token_distribution.d.ts +2 -0
- package/dist/scripts/token_distribution.js +132 -108
- package/dist/scripts/tv.js +1 -1
- package/dist/scripts/verify-browser-bundle.js +18 -0
- package/docs/COW_INVARIANTS.md +69 -10
- package/docs/DEXBOT_COMPARISON.md +6 -6
- package/docs/EVOLUTION.md +10 -8
- package/docs/FUND_MOVEMENT_AND_ACCOUNTING.md +1 -1
- package/docs/GRID_PRICE_INVARIANT.md +5 -2
- package/docs/GRID_RECONCILE.md +36 -11
- package/docs/LOGGING.md +50 -4
- package/docs/ORDER_ENGINE_POST_1.0_RETROSPECTIVE.md +177 -27
- package/docs/README.md +23 -2
- package/docs/WORKFLOW.md +12 -4
- package/docs/architecture.md +42 -5
- package/docs/developer_guide.md +25 -8
- package/modules/README.md +8 -1
- package/package.json +3 -1
- package/scripts/README.md +39 -7
- package/scripts/pdev.sh +14 -1
- package/scripts/pmain.sh +23 -8
- package/scripts/ptest.sh +7 -0
- package/tests/README.md +30 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,74 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
|
|
5
|
+
## [1.7.1] - 2026-11-04 - One Existence Record per Slot, Placement-Region Hardening, Forced-Retreat Gap Evacuation, Fee-Adjusted Pool Depth, Stability-Ranked Nodes
|
|
6
|
+
|
|
7
|
+
### 2026-11-04
|
|
8
|
+
|
|
9
|
+
- **Feat(order)**: unify chain existence behind one lifecycle registry — "does this order exist on chain, and how sure are we?" was answered from seven structures with seven different clocks (`_pendingBroadcasts`, `createUncertain`, `_committedOrderIds` + its built-at stamp, `_orderIdAssignedAt`, `_placedAt`, `_chainSizeAppliedFills`, `_lastUnmatchedChainOrders`), and four read sites each consulted a different subset, which is why every fix resurfaced in a new path. `modules/order/lifecycle.ts` now owns ONE record per slot (intent → chain id → partial → gone) and the legacy structures become live Map/Set views onto it, projected in through `_applyOrderUpdate`, so no site has to remember which structure to touch. Behaviour that falls out of having one answer: sync pass 1 no longer reads an unparseable chain entry as absent (a live-but-undecodable order used to be virtualized and re-CREATEd on top of itself); an ABANDONED pending CREATE records `unknown` instead of a clean hole (a lost receipt turning into a duplicate order); a filled or virtualized id loses protection; the placement stamp lands on the slot record (300 rotations across 5 slots previously leaked 300 unreachable order-keyed records and reported every order as not-freshly-placed); a create-uncertain slot reads `unknown` without writing; and an unrelated slot mutation cannot downgrade unresolved evidence to `intent`. Risk: a consumer that relied on a narrower guard defers cleanup one cycle instead of virtualizing — the fail-safe direction, bounded by 2x the pending-broadcast TTL. Docs: new `docs/ORDER_LIFECYCLE.md`. Covered by new `tests/test_order_lifecycle.ts` plus `recon_fuzz`.
|
|
10
|
+
|
|
11
|
+
- **Feat(order)**: make broadcast uncertainty a typed three-valued outcome — an unknown batch result was encoded as an ad-hoc `uncertain: true` beside a second ad-hoc flag (`ambiguousRead`), set by hand at four sites, so the two could disagree and nothing forced a consumer to handle "we do not know" at all. `modules/outcome.ts` is now the only place those results are constructed (`unknownCowOutcome(cause)` derives both flags from one cause and refuses to let a caller field override them), and the four COW return sites name their cause explicitly (`ambiguous-read`, `unavailable`, `lost-receipt`). Behavioral impact: the same fields are returned with the same values, but they can no longer be set inconsistently. Covered by new `tests/test_outcome_contract.ts` and the extended `test_uncertain_broadcast`.
|
|
12
|
+
|
|
13
|
+
- **Feat(order)**: classify every timing window and gate its growth — the engine carried 84 timing knobs, a number that grew because every "the state was briefly wrong" bug was fixed by adding a wait, and nothing ever removed one. `modules/timing_policy.ts` classifies every window as `external` (how long the outside world takes), `bound` (a leak/GC cap that cannot produce a wrong decision), `policy` (a deliberate product choice) or `self-healing` (compensates for our own lost state — a REMOVAL TARGET that must name the replacing evidence), with the two timings computed from other timings declared as derived. Current split: 33 external, 19 bound, 26 policy, 6 self-healing. `tests/test_timing_policy.ts` fails on an unclassified window, so the inventory can only shrink by decision, and pins the derived relationships under override. The six removal targets are deliberately not deleted here: each changes live trading behaviour and needs live validation. Docs: new `docs/TIMING_INVENTORY.md`. Risk: none behavioural — no value changed and no window removed; only new failure mode is a build failure when an unexplained window is added.
|
|
14
|
+
|
|
15
|
+
- **Test(order)**: add an interleaving fuzzer for the reconciliation engine — the engine's failure modes are interleavings (a fill that lands before the snapshot that would have matched it, a read that lags a confirmed broadcast, a truncated snapshot that looks exactly like "the account is empty"), which example-based tests cannot enumerate. `tests/recon_fuzz.ts` drives the REAL `SyncEngine` against a deterministic scripted chain with nine adversarial operations (land, vanish, partial fill, full fill, orphan, duplicate-level, un-adoptable stray, lagging read, unparseable read) and asserts eight policy-free invariants after EVERY event: one slot per chain id, one order per (type, price) level, lifecycle agreement, structural soundness, fund sanity, and "every parseable chain order is accounted for — tracked, reported unmatched, or queued for cancel". It deliberately asserts no policy ("clean after exactly N cycles" would encode one grace and reject correct alternatives), shrinks a failing sequence to a seed + step count replayable with `RECON_FUZZ_SEED`/`RECON_FUZZ_STEPS`, and fails on vacuous runs via coverage floors. Verified by mutation: dropping a duplicate-level orphan report shrinks to a five-step reproduction. Deliberately not `test_*.ts`, so `npm test` stays pass/fail.
|
|
16
|
+
|
|
17
|
+
- **Fix(order)**: one writer per life-cycle clock, one guard per absence decision — a review of the new lifecycle/placement arc found every finding to be the same shape: one question answered in more than one place. (1) `_commitWorkingGrid` swaps the master map wholesale and bypassed the write funnel, so a COW-placed order got no `assignedAt`/`placedAt` at all — the 15-minute surplus-cancel grace was inert on the PRIMARY placement path; every committed slot is now projected through `_syncLifecycleFromMutation` first. (2) `_applyOrderUpdate` wrote both stamps a second time on top of the funnel; one writer now. (3) `timingWindowMs()` replaces five copy-pasted `Number(TIMING.X) > 0 ? … : <literal>` fallbacks, and the reconcile reads gap geometry and the `createUncertain` marker through `resolveGapSlots`/`isSlotCreateUncertain` instead of raw fields it could disagree with. (4) sync pass 1 asked a SUBSET of the absence guard while the startup reconcile and the recovery sweep asked `isInFlight()`, so an order whose CREATE receipt was merely lost could be virtualized and re-created — all three sites now ask `isInFlight()` through `readSlotLifecycle`. (5) Evidence is now ranked and monotonic within a phase (a local re-assertion cannot overwrite a `chain-snapshot`, and pass-2 adoption records `adoption` evidence), so `observedAt` means "when the chain last told us" again. (6) `observe`/`markIntent`/`setPending` cleared `pending` but left the fingerprint index, so `pendingSize()`/`getPending()` disagreed with the engine's facade. (7) The unresolved bound was refreshable for free (the funnel re-asserts `unknown` on every mutation); `recordedAt` now advances only on a phase change or chain-backed evidence, `markIntentIfResolved` resolves an expired unknown, `prune` can evict past-bound records, and a synthesized record is no longer stamped fresh on every read. Covered by new sections in `tests/test_order_lifecycle.ts` plus `ageChainIdAssignment()` in the order test helpers.
|
|
18
|
+
|
|
19
|
+
- **Fix(order)**: serialize the placement paths and re-verify their lease before broadcasting — a trigger-file grid rebuild could run while a fill-driven COW rebalance was mid-plan: the rebuild marked the working grid stale, the bounded stale-plan handler re-planned from a master with no chain ids, that re-plan emitted CREATEs at levels the startup reconcile was concurrently re-pricing via UPDATE, and the startup surplus sweep cancelled only what its lagging read could see — 25 duplicate-price orders on chain in a production incident. `modules/order/placement_lock.ts` introduces a token-based exclusive placement region (bounded wait, shutdown force-release, `isPlacementLeaseCurrent()` via a token WeakMap), `manager.withPlacement()` is the single acquire/release contract with `allowDuringRebuild` for a rebuild's own reconcile, the COW body and the reconcile now re-check their own lease immediately before `startBroadcasting`/Phase 2 and abort (`PLACEMENT_LEASE_LOST`) or discard the plan instead of shipping from a region the watchdog already released, a stale plan caused by a structural rebuild is aborted instead of re-planned create-only (dropping its pending-broadcast entries), the startup surplus sweep skips on a lagging read or live pending broadcasts, `_clearStalePlacementRegion()` is the single teardown authority (it refuses while a younger pipeline counter proves progress and clears the region's stale broadcast refcount atomically), and `endStructuralRebuild()` notifies region end so "never wake into a live broadcast region" has one spelling. Cancel-only holders stay exempt (a cancel carries its own id and cannot duplicate a CREATE). Docs: `INV-BROADCAST-005`, INV-MAINT-001 correction, placement-region section in architecture/developer guide, new `[PLACEMENT]` LOGGING rows. Covered by new `tests/test_placement_lock.ts`, `tests/test_structural_rebuild_guard.ts`, `tests/test_startup_dust_policy.ts`, plus COW-GUARD-REPLAN-006 and Regression 9i.
|
|
20
|
+
|
|
21
|
+
- **Fix(order)**: close the follow-up gaps in placement and fill-marker handling — an audit of the placement arc found one-directional watchdog cross-checks, a fill-marker flag that could mask a partial applied amount, a reconcile CREATE guard that only matched slot ids, an unrestored per-batch anchor budget, and one liveness policy duplicated three times. Fill accounting: the legacy `alreadyAppliedChainSize` boolean is a FALLBACK, not a floor (a group where one entry was marked no longer skips the unapplied remainder of its siblings), and the zero-remainder brake runs after residual verification so a clamped-to-zero fill is virtualized while the chain residual it leaves is still cancelled. Planner/guards: `getLivePendingBroadcasts()` is the single pending-broadcast liveness policy (used by the COW guard, crossing candidates, the reconcile surplus sweep, the maintenance sync gate and the reconcile CREATE path, replacing two hand-rolled TTLs and a no-TTL raw-map read), reconcile CREATEs are refused on a pending-broadcast level match as well as a slot-id match, and a stale-plan re-plan hands back the abandoned plan's absolute re-anchor so an abandoned plan cannot consume the batch's one anchor. Placement: the maintenance tick no longer tears placement down and clears the refcount in separate steps, and the nested correction drain verifies its inherited lease instead of the always-true `isPlacementActive()`. Covered by extended fill-transition, placement-lock, price-collision and COW re-plan suites.
|
|
22
|
+
|
|
23
|
+
- **Fix(order)**: make pass-1 fill markers accumulate and persist, and revalidate pending CREATEs on startup — the pass-1 size markers were single-shot, in-memory only, and double-released the trade's drum (`3.6604 → 3.3046 → 2.9488`), because the duplicate was the second size release rather than the trade. Markers now accumulate and partially consume, persist with the grid snapshot, and keep the trade's pays/receives in fill accounting; corrupt-snapshot rejection is gated on a settled pipeline (empty fill queue, no fill batch, no deferred rebalance/owed crawls); pending uncertain CREATEs join the CREATE collision set with a 30-minute TTL; PARTIAL update targets are planned at the booked remainder; dust chain-count subtraction uses the actually queued cancel count. Also: the COW placement lease is released on every pre-broadcast exit (the `try/finally` now starts at claim time), a placement stale-region watchdog exists, placement-backed regions defer fills past the broadcast bound instead of falling through into a live region, and the fill queue wakes on pipeline force-clear. Covered by `tests/test_fill_transition_idempotency.ts` and `tests/test_snapshot_reject_gate.ts`.
|
|
24
|
+
|
|
25
|
+
- **Fix(gap-evac)**: let forced retreats evacuate, then re-plan the committed band — a live market-pair bot lost its fixed spread: a fill inside the band crawled the boundary down and stranded the live orders above it, the plan's evacuation rotations were refused as stale by LAST-FILL-GUARD (re-proven against the PRE-COMMIT geometry where those slots are still rail members), the batch committed the retreat with the stranded orders still live, and plans are fill-driven — so on a quiet market nothing ever re-planned and the 2.0% band sat at 1.21% for hours while every plan reported success. `liveRailsConflictWithGap` now identifies the no-consistent-boundary case (`maxBuy > minSell - gap - 1`) and `forcedRetreatJustifiesEvacuation` is the single decision point for all three stale-stamp sites, refusing to override a stamp whose source/dest ids are unparseable; the unstamped branch still re-proves direction and size live, and every other stale stamp still fails closed (the 2026-10-30 bid-edge non-regression is pinned). A committed-geometry sweep (`scheduleGapEvacRepair`, hooked after a successful commit and on every maintenance tick) detects live orders inside the COMMITTED band, re-derives the streak ledger and schedules a fill-less re-plan, with the cancel-only teeth as fallback only (never in the same tick), rate-limited to one repair per bot per minute, and unknown geometry treated as unknown. Docs: `INV-COW-011`, LOGGING rows. Covered by new `tests/test_gap_evac_spread_collapse.ts`.
|
|
26
|
+
|
|
27
|
+
- **Fix(gap-evac)**: don't let the cancel teeth destroy the rotation that evacuates — the first live run of the committed-geometry sweep repaired the band through the wrong path: the sweep ticked the streak ledger a second time for the same observation (a restored streak of 1 reached the cancel threshold of 3 in one cycle), and the cancel-only teeth queued cancels for the two chain orders the plan was rotating, so the pre-batch correction drain executed them first, the UPDATE batch found its own sources gone, and the grid fell back to a structural resync plus full reload. `updateGapEvacuationStreaks` gains `increment: false` (re-derive: prune resolved ids, report readiness) and the sweep uses it, and `splitEvacuationCancelsSupersededByRotations` holds any cancel-only evacuation whose chain order this batch rotates out of the drain (restoring it afterwards, so it is dropped as stale once the slot no longer owns the order) while unrelated corrections keep draining. Behavioral impact: a stranded-band repair is now one batch of in-place price updates — no cancels, no "target(s) missing on chain" rejection, no reload. Docs: `[COW] Holding N gap-evacuation cancel(s)` line and corrected tick/hold semantics.
|
|
28
|
+
|
|
29
|
+
- **Fix(geometry)**: stop reading unknown gap geometry as gap 0 — an absent gap band classified the slot just above the boundary as a SELL rail member, mis-classifying in-band orphan adoption (sync engine, fill runtime) and booking SPREAD-placeholder size on the wrong side (accounting), i.e. it could hide or double-count exactly the orders GAP-EVAC exists to evacuate. `resolveGapSlots` is now the fallback in all four sites. The same "absent reads as 0" pattern made restore telemetry lie: `loadGrid` called `_restoreBoundary` before publishing `_gapSlots`, and `_logBoundaryDebug` read the raw field with a `0` fallback, so every restart printed `gapSlots=0 sellStart=boundary+1 spreadCount=0` — indistinguishable from a genuinely collapsed band (this is what produced the "bot lost its fixed spread, only one slot is used" report on a healthy 4-slot band). `_gapSlots` is published before the restore gate, the debug line resolves through `resolveGapSlots` and prints `spreadCount=?` until measured (new `_spreadCountKnown`, so a measured EMPTY band still prints 0). Behavioral impact: adoption/accounting are unchanged whenever the gap is set (the normal case); only the unknown fallback and the restore line change.
|
|
30
|
+
|
|
31
|
+
- **Fix(order)**: repair stranded boundaries without re-arming on replays — the boundary could teleport on a replayed fill and then stay stranded: the orphan sweep re-attributed already-booked fills (re-arming the pivot and owed crawls from a stale execution price), the refill hold pinned a fill-driven retreat to the old boundary, and both boundary writers refused a move that reduced — but did not eliminate — in-band orders. Fill attribution now runs only when the processed ledger did not report `duplicate`; the refill hold is scoped to the promotion direction (BUY up / SELL down) and resolves its side from the plan/master grid; the re-anchor and the rail clamp share one rule (accept a move only when it strands strictly fewer placed orders than the committed boundary; equal counts and structural refusals stay closed); and spread promotion steps over a same-side placed band edge (absorbing it as a rail member) instead of stopping there, with depth counting both so reserve/stranding caps still bound the slide. Docs: `COW_INVARIANTS`, `GRID_RECONCILE`, architecture, `LOGGING`.
|
|
32
|
+
|
|
33
|
+
- **Fix(analyze)**: classify grid slots by type in `dexbot order` — the report bucketed BUY/SELL slots with `i <= boundaryIdx` slicing, so a live order stranded inside the spread band was dropped from every bucket: the counts summed to fewer slots than the grid holds and the "real" spread was measured from the geometry edge (2.02% reported against 1.21% on chain, with two live buys hidden inside a 4-slot band), which made a collapsed spread invisible to operators exactly when they needed to see it. Buckets and rail lists are now type-based, matching the runtime's `getGridBestPrices`/`calculateSpreadFromOrders`; the new `gapBand.inBandPlaced` names every live order resting strictly inside the band and the report prints a "Spread band occupied" warning; the band width comes from the snapshot's frozen genesis and then the live config, staying unknown when geometry is unknown. Behavioral impact: the reported spread changes for snapshots carrying in-band live orders — that is the point; clean snapshots report exactly as before.
|
|
34
|
+
|
|
35
|
+
- **Fix(analysis)**: use the live last-fill predicate in the offline checker — `analysis/grid_correction_check.ts` carried its own copy of `isLastFillGuardBlocked` labelled "mirrors `modules/order/utils/system.ts` 1:1", which had already drifted (it still returned the removed `halfInc` band term). The checker now imports the predicate from the runtime module, so the offline verdict is the runtime binding rather than a re-derivation; the direction verdicts are unchanged, and the rule's release in the header and `--help` is corrected from v1.6.16+ to v1.6.17+.
|
|
36
|
+
|
|
37
|
+
- **Fix(node)**: rank nodes by connection stability, not ping alone — a live run showed all 52 abnormal socket closes landing on the three CDN-fronted public endpoints while the endpoints that were never selected dropped none, and the bot spent 46% of its connected time on the flapping ones: selection sorted on raw latency, and live-transport strikes were erased by a successful health probe, so the blacklist threshold was almost unreachable at a 4h probe interval. New `modules/node_flap_score.ts` (pure, browser-safe, time-decayed churn scoring: effective latency = latency + Σ 0.5^(age/halfLife) · perDrop over a capped 24h window) feeds `node_manager`'s ranking, strikes now decay over `FAILURE_STRIKE_DECAY_MS` instead of being wiped (ledger reseeded so count and ledger stay in step), churn is persisted through `node_health_cache` (and removing a node no longer erases a sibling's history), `restartBitsharesConnection` keeps a healthy socket when the active node is already valid (~88 needless reconnects/re-subscribes in 18 days), the connect policy keeps the connected node in the candidate list, the credential daemon no longer evicts it, and failure reports name the node the operation actually ran on instead of `getBestNode()`. `FAILURE_STRIKE_DECAY_MS` and the `FLAP_*` defaults are surfaced as `NODES.healthCheck.{strikeDecayMs,flapHalfLifeMs,flapPenaltyMsPerDrop,flapPenaltyMaxMs}`. Behavioral impact: a flapping node is demoted for up to a day and can finally be blacklisted; a stable node still wins on ping when nothing flaps, and `preferredNode` still overrides ranking.
|
|
38
|
+
|
|
39
|
+
- **Feat(cli)**: accept a chain account as the `<bot>` target for `credit`/`order` — `dexbot credit [<bot>]` matched only a bot name/key, so passing an account name or `1.2.x` id (the grouping chain positions actually use) reported "no credit bot found" although `dexbot pnl` accepts `<bot|account>`. The matching rule set had also been duplicated five ways with subtly different semantics, so it now lives in `analysis/bot_key_utils` as `matchBotEntryTarget` (name/key), `matchBotAccountTarget` (`preferredAccount` name or typed `1.2.x` id, or the `accountId` stamped by `account_resolver.ts`) and `matchBotTargetIn` (every match, tagged `matchedBy`), letting each caller choose the spellings it accepts; an account target selects every bot entry on it. Diagnostics now separate "no such bot/account", "matched only inactive entries" and "no enabled entry has `debtPolicy.lending`", listing matched entries instead of asserting nothing matched. Two more copies folded away: the `1.2.x` regex is `isAccountIdRef()` and `analyze-orders` calls `computeBotKey` instead of its own verbatim copy. `tv`/`dw`/`liquid` stay bot-only (one account can back several bots). Read-only surface; bot runtime untouched. Docs: README cheat sheet, `docs/WORKFLOW.md`, `analysis/README.md`, `scripts/README.md`, help/examples. Covered by new `tests/test_credit_cli_target.ts` and `tests/test_bot_key_utils.ts`.
|
|
40
|
+
|
|
41
|
+
- **Feat(liquidity)**: price the pool curve net of the AMM fee and show both spreads — the depth chart plotted the raw `x*y = k` curve, so the pool's two sides met at the reserve price even though a taker always pays the pool fee: the pool looked like a zero-spread venue and the fee existed only as a badge. The curve is now parameterized by the fee-adjusted effective price (the chain takes the fee off the output side and keeps it), so bid and ask depth stop at `(1-f)·p0` and `p0/(1-f)` — the fee band a taker must cross — while cumulative depth keeps its local slope and still satisfies `x*y = k` for the fee-free reserves; `f = 0` collapses onto the previous curve. The chart shades the order-book spread next to the pool fee band, the readout lists each percentage with its absolute edges and tags the tighter one, and both follow an inverted price. The guide labels moved out of the band into one aligned block drawn at a device-pixel-ratio-correct size (uPlot leaves the 2D context unscaled, so the fixed 11px font rendered at half size on HiDPI). Percentages share one rule through `formatPercentLabel` (2 decimals below 100%, 1 from 100%, none from 1000%, fixed-point so SI suffixes cannot leak into a spread). Display-only: no bot, adapter or order-engine path touched. Covered by `tests/test_liquidity_depth.ts` and `tests/test_format_percent.ts`.
|
|
42
|
+
|
|
43
|
+
- **Fix(scripts)**: abort branch promotion before it moves anything and make `pmain` atomic — the force-push promotion scripts could move a ref before discovering that the remote was unreachable (a live SSH outage left a half-synced `dev`/`main`). A read-only preflight probe now runs before any ref moves: a dead remote, a missing remote or an unset remote aborts with a clear message before `test`/`dev` and `dev`/`main` diverge, and `pmain` mirrors both refs through one atomic push so it can no longer half-sync. The probe honours a skip env for CI and is documented as point-in-time: a flapping auth path can still fail at the push, where the atomic mirror bounds the damage to "neither". Docs: `scripts/README.md`, `docs/WORKFLOW.md`. Verified with `bash -n` on all four scripts and against the live outage (5/6 probes aborted, every ref unchanged).
|
|
44
|
+
|
|
45
|
+
- **Docs**: record the lifecycle and timing invariants and reconcile the retrospective — new `INV-LIFE-001..005` (unknown is never gone; one record per slot; one definition per guard — absence uses `isInFlight`, the committed guard uses `isRecentlyCommitted`, the fresh-id guard uses `isRecentlyAssigned`; unresolved records are never evicted or downgraded; an unparseable chain entry makes absence unknown, not absent) and `INV-TIME-001` (every timing window is classified, and a self-healing window must name the evidence that replaces it) join the stable theory contract, so a change that reintroduces the old ambiguity is a review failure rather than a judgement call. `ORDER_ENGINE_POST_1.0_RETROSPECTIVE` is rescoped from v1.6.14 to v1.7.0 plus the unreleased arc (§9.10 marked released in v1.6.18, new §9.11 on fill identity/the pivot as a row/one existence record/violation-reducing repair, three new bug families in R2, four "what fixed it" entries in R4, lessons 12-14, a dead cited hash corrected), `COW_INVARIANTS` states the real duplicate rule (`chainPriceOnSameLevel`, not `calculatePriceTolerance`) and renumbers/extends the life-cycle invariants, `GRID_PRICE_INVARIANT` moves its review baseline to v1.7.0, and `modules/README.md` lists `order/lifecycle.ts` and `order/placement_lock.ts`. Full suite: 353/353 files (`npm test`, 14 live tests skipped); `typecheck`, `typecheck:analysis`, `check:any` and `verify:browser-bundle` clean.
|
|
46
|
+
|
|
47
|
+
## [1.7.0] - 2026-11-02 - Liquidity Depth Chart & `dexbot liquid`, Asset Distribution Shortcut, Pool-Ref Chart Targets, Case-Insensitive Asset Lookup, Orphan-Fill Attribution & Stale-Grid Re-Buy Discipline
|
|
48
|
+
|
|
49
|
+
### 2026-11-02
|
|
50
|
+
|
|
51
|
+
- **Feat(liquidity)**: add a cumulative liquidity depth chart and the `dexbot liquid` command — a read-only analyzer (`analysis/analyze_liquidity.ts`, `analysis/liquidity/*`) blends a pair's live order book with its constant-product AMM pool using the vendored uPlot runtime. The curves stay separate rather than summed, support depth-asset switching and price inversion via axis clicks, reuse the shared 4-digit formatters, and keep the market centre centred when inverted. Depth is fetched through `get_limit_orders` (up to ~300 levels per side) with a `get_order_book` fallback, because the latter is commonly capped at 50 and silently truncated the curves; transport chatter is suppressed for the generator. Exposed as `dexbot liquid <bot|AssetA/AssetB>` with the same clickable `file://` trailer as `dexbot tv`, and the bot-target resolution plus analysis-script spawning is now shared between `tv`, `dw` and `liquid` instead of duplicated. Covered by new `tests/test_liquidity_depth.ts` and `tests/test_liquid_cli.ts` (pool invariant math, order-book side mapping, limit-order decoding and fallback, view inversion, HTML payload/formatting, offline CLI parsing).
|
|
52
|
+
|
|
53
|
+
- **Feat(cli)**: add `liq` and `liqu` as shortcuts for the liquidity depth chart — the command was only reachable as `liquid`/`liquidity`, which is cumbersome for something used repeatedly during research. Both aliases forward `--help` to the liquid script (alias resolution runs before the help-owning command check), and `--help`, `--cli-examples`, the README cheat sheet and the analysis/WORKFLOW docs all show `liq` while naming `liquid` canonical. Covered by new `tests/test_cli_aliases.ts`, which spawns the entrypoint to assert every spelling and the help listing.
|
|
54
|
+
|
|
55
|
+
- **Feat(cli)**: add `dexbot asset <bts|symbol>` (shorthand `a`) for supply distribution — the two analyzers were only reachable through `dist/scripts/*.js` or npm scripts, which sat awkwardly beside the other analysis commands. The router sends `bts` (or the core asset id) to the BTS report and any other symbol/id to the token report, with no `token` keyword: `asset token X` fails with a hint instead of a chain lookup. Forwarded flags are validated against the chosen analyzer (core asset: `--holders`/`--circulating`; issued asset: `--no-orders`/`--concurrency`) while the analyzers stay the single flag reference, and `asset` is help-owning so `--help` works offline. Both analyzers now log in the `[Liquidity]` style (`[Assets] Loading`, tagged transient progress, `Report saved` link, `[Assets] Error:`), and the `asset` npm script plus README/scripts README/WORKFLOW docs are added. Covered by new `tests/test_asset_cli.ts`.
|
|
56
|
+
|
|
57
|
+
- **Feat(cli)**: accept a pool id or pool token wherever `liq`/`tv`/`dw` take a target — `dexbot liq` resolved only bots and `AssetA/AssetB` pairs, and the shared chart pipeline behind `tv`/`dw` accepted numeric pool ids only. All three now take the same three target kinds (bot, pool, pair), where a pool is either its object id (`133` / `1.19.133`) or its pool token (the LP-share asset symbol, the same value a bot names in its `pool` setting). Parsing lives once in `modules/liquidity_pool_ref.ts` (`normalizePoolRef`, `isPoolIdRef`/`isPoolRefLike`, `poolAssetIds`, `resolvePoolRef`) with the chain read injected, so the module stays browser-safe and the commands cannot drift. `analysis/analyze_liquidity.ts --pool` accepts the same spellings and derives both legs when `--base`/`--quote` are omitted; a half-given pair beside `--pool`, a pool target combined with `--pool`, a valueless `--pool` and a pool/pair mismatch are all rejected with specific messages instead of silently charting something else, and a bare `--help` now prints usage rather than failing target validation. The CLI's child-process plumbing is centralized in `modules/launcher/runtime_entry.runRuntimeScript` (one `SCRIPT_COMMANDS` map, replacing nine copy-pasted spawn blocks plus the router copies in `scripts/analysis_runner.ts` and `scripts/asset.ts`), and `modules/cli_progress.ts` owns the `[Tag] …` progress/saved-line style. Behavioral impact: new accepted targets on read-only chart commands; existing targets, flags, reports and exit codes are unchanged, except a missing build or failed spawn now reports through the shared runner and `status` exits 1 rather than 0 when the unlock probe cannot be spawned. Covered by `tests/test_liquidity_pool_ref.ts`, `tests/test_cli_progress.ts` and the extended liquid/liquidity suites.
|
|
58
|
+
|
|
59
|
+
- **Fix(cli)**: resolve asset symbols case-insensitively through one lookup — every command that takes an asset from a human (`dexbot asset <symbol>`, `dexbot rich <asset...>`, `dexbot liq`/`tv`/`dw` pairs and pool tokens, `--base`/`--quote`) failed on any spelling that was not exactly the on-chain UPPERCASE symbol, because `get_assets`/`lookup_asset_symbols` are case-sensitive and a lowercase symbol resolved to null. `modules/asset_lookup.ts` is now the single resolver: refs are canonicalised with `normalizeAssetSymbol` (1.3.x ids pass through untouched), resolved in one batched `get_assets` call, and only an unresolved ref is retried once with the spelling as typed so a node holding a genuinely non-canonical symbol still resolves. The reader is injected, keeping the module browser-safe, and `assetSymbolCandidates` is the only place that decides the two spellings. Wired through `scripts/token_distribution.ts`, `scripts/rich_list.ts` (which keeps the caller's spelling in result rows and still applies the legacy `bit*` alias retry) and `analysis/liquidity/liquidity_chain.ts` (dropping its private id regex); `modules/liquidity_pool_ref.ts` resolves pool tokens through the same resolver. Behavioral impact: lowercase/mixed-case symbols now resolve instead of failing; `asset not found` still echoes the typed spelling, and already-correct input is unchanged. Covered by new `tests/test_asset_lookup.ts` plus reworked `test_liquidity_pool_ref` and `test_rich_list_symbol_normalization`.
|
|
60
|
+
|
|
61
|
+
- **Perf(cli)**: cut the asset reports' chain requests by an order of magnitude — both supply distribution commands only need per-asset metadata but asked the node for far more. The BTS report listed every asset (100 per page over thousands of assets) just to find the smart assets and sum fee pools, then fetched dynamic/bitasset data by id; it now derives smart assets from a dense walk of the 2.4.x implementation space plus one `get_assets` call (extended objects, so `total_in_collateral` stays available), sums fee pools from a 2.3.x walk, looks up symbols only for printed rows, uses the asset-scoped SameT/credit calls with `list_*` fallbacks on older nodes, and uses `list_htlcs` instead of probing the 1.16.0..1.16.99,999 range. The token report enumerates assets through the same dense 1.3.x walk (9 calls instead of 67 `list_assets` pages), fetches rich-list pages in parallel (with one sentinel page so a mid-scan rank shift cannot truncate the list), and raises the per-asset `get_limit_orders` sweep concurrency from 12 to 32 while keeping `--no-orders` as the fast path. The shared walks live in new `modules/chain_scan.ts`, which batches 1000 ids per call, halves the batch on nodes that refuse it, and defines `--gap` as exactly "gap consecutive missing ids" so results no longer depend on batch size; scans that hit their id limit now warn instead of silently shortening a bucket. Measured on mainnet: BTS ~92s → ~20s and token full runs ~50s → ~19s (~29s → ~12s with `--no-orders`), with outputs unchanged apart from chain drift. Covered by new `tests/test_chain_scan.ts` and pinned browser-safe in `scripts/verify-browser-bundle.ts`.
|
|
62
|
+
|
|
63
|
+
- **Refactor(cli)**: centralize report terminal output — the file-writing commands each re-implemented the same furniture: the section header (two copies), a warning block (`! ` in one report, `• ` in the other), the muted trailing summary, the `[Tag] Loading …` opener, and a saved-file trailer that had drifted into four spellings. `modules/cli_progress.ts` now owns all of them (`loadingLine`, `section`, `warningLines`/`warningsBlock`, `summaryLine`, `savedLine` with an optional `kind` so a mixed-case label still reads "Open report"), and `modules/cli_colors.ts` exports `colorize()`, the local `c(color, text)` wrapper scripts kept redeclaring; `CLI_TAGS` covers the remaining tags. Behavioral impact: every command that writes a file ends with the same clickable `file://` trailer (the research analyzers now get a link too), warnings render identically everywhere, and the BTS report no longer prints a duplicate plain `HTML report: <path>` plus `Collateral:` source line (provenance moved into the HTML footer). `--quiet`, `--json` and `--no-html` keep their behavior: no trailer when no file is written. Covered by the extended `tests/test_cli_progress.ts`.
|
|
64
|
+
|
|
65
|
+
- **Fix(order)**: stop stale-grid re-buys after a fill — a live incident had the bot buying at successively higher prices: a multi-minute stale broadcast region deferred the fill queue, then the post-fill targeted reconcile derived its window from a master that still held the filled slots as ACTIVE and re-created same-side orders at the top of the un-crawled rail, which filled within seconds. The root cause was upstream: fills whose order id no longer sat on an ACTIVE/PARTIAL slot were dropped ("order not found in active grid") after their accounting was booked, so neither the last-fill pivot nor the owed boundary crawl learned the real execution price, and every downstream geometry gate compared against a stale, higher pivot. Four gates now close it: (1) `hasUnsettledFills` defers the targeted reconcile and the window top-up while fills are queued, draining, in flight or owed a crawl, while 1:1 repairs (cancelled-slot replacement, vacated-rail refill) still run so a rail is never left un-repaired; (2) `SyncEngine._absorbUnmatchedFill` attributes such a fill to the slot that still owns the chain id and records the pivot plus owed crawl from the real execution price, without mutating the slot or already-booked accounting, and dry runs never grow the crawl ledger; (3) `isLastFillPlacementBlocked` applies the direction rule plus a same-grid-level refusal to every reconcile placement (both create paths and the re-pricing relocation), keeping a same-price relocation exempt as an adoption; (4) `_pickVirtualSlotsToActivate` uses the same predicate so the pick budget rolls to the next level instead of being spent on a level the create would refuse, restoring the documented rotate-to-bottom/counter-SELL behaviour. Behavioral impact: fail-closed during an unsettled fill window (a top-up waits one cycle, and a level on the wrong side of the last fill waits for the crawl); no new orders, sizes or boundary semantics. Docs: `GRID_RECONCILE` (fill discipline) and `LOGGING`. Covered by new `tests/test_grid_fill_discipline.ts` and `tests/test_fill_attribution_virtual_slot.ts`.
|
|
66
|
+
|
|
67
|
+
- **Fix(order)**: attribute orphan fills by price and repair dark levels — a follow-up audit of the stale-grid fix found six gaps of the same class, the first in the fix itself. Fill attribution looked the slot up by chain order id, but `virtualizeOrder()` nulls `orderId` on every virtualisation path, so the absorption never fired for the very fills it was written for (the re-delivered fills logged "order not found in active grid" and the reconcile re-created their levels); attribution now falls back to the genesis ladder level of the execution price (the same authority pass 2 uses for adoption), refuses prices outside the frozen rail so a shelf/manual order can never arm the pivot, and only owes a crawl for a hole the grid owns. A slot virtualised while its order stayed live on chain counted as inactive for window accounting while its order still counted in `chainCount`, so the side reported a shortfall it could never repair and the planner saw a free level that already held an order; `reviveVirtualSlotFromChain` now re-materialises such a slot in place (master-only, no broadcast) when the chain order rests at that slot's own level, wired into sync pass 1 and reconcile Phase 1, so a rotation alias whose cancel has not landed is never resurrected. Duplicate CREATEs are closed by keying slot occupancy on the id alone (any state) instead of `isOrderOnChain()`, with a soft reason that withholds only a possibly-landed CREATE rather than aborting the batch, and sync pass 1 clears a genuinely stale id on a non-placed slot without booking a fill (freshly assigned ids are deferred). The orphan-credit sweep now attributes before crediting through the same shared helper, the spread-correction planner uses the same ladder-snapped predicate as the broadcast guards instead of planning same-level creates that were refused, and the re-stamp leak counter uses the same same-level comparison its comment claims to detect. Behavioral impact: no new orders, sizes or boundary semantics; attribution and the revive are master-side only, the revive is level-gated, and everything stays fail-closed for one cycle while fills are unsettled. Docs: `GRID_RECONCILE` (identities, revive, occupancy) and `LOGGING`. Covered by extended fill-attribution, revive, occupancy, hole-gate and planner/guard-parity tests.
|
|
68
|
+
|
|
69
|
+
- **Fix(order)**: anchor-aware residual allow-list, pivot clock provenance and read-time TTL — three defects of the same shape (1) `reanchorBoundaryFromLastFill` derives the boundary from the fill batch's extremum, but the in-band allow-list that lets the fill's own PARTIAL residual survive was keyed on the last-processed pivot, so for every chunked sweep whose furthest fill was not the pivot the list matched nothing and the re-anchor was refused as `unsafe: placed_order_in_band` — exactly the shape the extremum resolution exists for; the list is now keyed on the anchor and stays narrow (one explicit slot, same side, same ladder level; REANCHOR-21 pins that a foreign in-band order still refuses). (2) `rearmLastFillPivotFromMarketFill` read `_lastFilledAt || _lastMarketFillAt` while the price came from the market-row resolver, so a market-row price could inherit a fresh book-seed timestamp and then re-stamp `_lastMarketFillAt` with it, refreshing the 24h lifetime on every rebuild until the row never expired; price, side and clock now travel as one row. (3) The pivot lifetime only existed at restore, so a long-lived process kept a >24h fill vetoing one side forever even though the geometry-bind watchdog reports that a fill or the pivot TTL restores the side; the TTL is now enforced where the reference is read, in both entry points, so that line is true with or without a restart, while an unknown age (legacy managers, the ambiguous two-sided book seed) never expires. `recordRestampBuyAboveAnchor` reads the same reference the guard does. Centralisation: one TTL reader and expiry predicate for all four sites (both restores and both read paths), one row reader with live/market adapters replacing four near-copies, and expiry logged once per expired value rather than per probe. Deliberately unchanged: the COW build lane keeps judging a ladder-snapped pivot (`resolveOnGridPivot`, tolerance one increment) rather than the raw placement predicate, pinned by PIVOT-004 and a `GRID_RECONCILE` note. Behavioral impact: a chunked sweep can now complete its re-anchor instead of stalling, and a side whose last fill is older than 24h is placeable again (the documented lifetime, already true across a restart); no new orders, sizes or boundary semantics, and no persistence-contract change. Docs: `COW_INVARIANTS`, `GRID_PRICE_INVARIANT`, `GRID_RECONCILE`, `LOGGING`, `ORDER_ENGINE_POST_1.0_RETROSPECTIVE`. Tests: REANCHOR-20/21, REARM-6/7/8, LFP-10, PIVOT-004, plus two fixtures corrected because they hard-coded a fill date.
|
|
70
|
+
|
|
71
|
+
- **Docs**: align the CLI reference and document the shared lookup, scan and trailer — `dexbot help` and the README "Bot Management" block disagreed on both order and naming: the block opened with the runtime-only `status` (spelled as its `stat` alias), taught the `liq` alias while the help called `liquid` canonical, and never listed `dw` or `rich`, so a reader could not know that `tv`/`dw` take the same targets or that `rich` exists. Both surfaces now use one investigation-order sequence (grid state and its data export, then market research, then accounting/chain context, then maintenance); the README moves `status` into the runtime block above and regroups the rest into those clusters, lists `liquid` instead of `liq`, corrects `asset <bts/token>` to `<bts|symbol>`, and the help Analysis group is reordered to match with `liq`/`liqu`/`liquidity` moved into the `liquid` description; `CLI_EXAMPLES` drops its alias-first snippet. `modules/README.md` lists the two new browser-safe modules (`asset_lookup`, `chain_scan`) and the widened `cli_colors`/`cli_progress` responsibilities, and `scripts/README.md` states the two cross-cutting rules (case-insensitive asset symbols through `modules/asset_lookup.ts`, one terminal trailer through `modules/cli_progress.ts`) and records how 1.13.x/1.15.x objects are enumerated now that no per-asset index exists. Docs and help text only: nothing is renamed, added or removed — `stat`, `liq`, `liqu`, `liquidity` and `a` still resolve. The CLI alias test's help-shape assertions are updated to match the new layout (`liquid` row plus `aliases: liq, liqu, liquidity`), since the previous `liq <target>` expectation no longer described the documented output. Full suite: 341/341 files (`npm test`, 14 live tests skipped); `typecheck`, `check:any`, `typecheck:analysis` and `verify:browser-bundle` clean.
|
|
72
|
+
|
|
5
73
|
## [1.6.18] - 2026-11-01 - Partial-Fill Re-Anchor Recovery, Rail-Derived Boundary & Live Fill Prices, Edge-Fill Pivot Exclusion, Guard Arity Pinning, CLI `--flag=value`, Export-Surface Cleanup
|
|
6
74
|
|
|
7
75
|
### 2026-11-01
|
package/README.md
CHANGED
|
@@ -317,6 +317,7 @@ Defaults in [`modules/constants.ts`](modules/constants.ts) are overridable at gl
|
|
|
317
317
|
`dexbot start` is the recommended production runtime (global install). Repo-root users can run `./unlock` instead. It runs the selected bot set as one monolithic bot process, with the credential daemon and market adapter in separate helper processes. Monolithic start/stop/reload/restart controls apply to the whole runtime, not to individual bots: a bot argument (e.g. `dexbot reload <bot>`) is validated and then folds into the whole-runtime action with a notice. Per-bot control needs `--isolated` (one supervisor process per bot, then `stop`/`reload`/`restart <bot>` acts on just that bot). `delete` and `status` are whole-runtime only. `dexbot help` detects which runtime is up (monolithic, isolated, or PM2) and lists the controls for that mode.
|
|
318
318
|
|
|
319
319
|
```bash
|
|
320
|
+
dexbot status # Runtime health: credential daemon, adapter, bots
|
|
320
321
|
dexbot start/stop # Stop/start the monolithic runtime
|
|
321
322
|
dexbot start --dryrun # Dry-run (no transactions broadcast)
|
|
322
323
|
dexbot reload [<bot>] # Reload (monolithic: whole runtime; isolated: one bot)
|
|
@@ -329,24 +330,29 @@ First-run details and common mistakes are covered in the [BitShares Onboarding T
|
|
|
329
330
|
## 🛠️ Bot Management
|
|
330
331
|
|
|
331
332
|
```bash
|
|
332
|
-
dexbot key
|
|
333
|
-
dexbot bot
|
|
334
|
-
|
|
335
|
-
dexbot reset {all|<bot>}
|
|
336
|
-
dexbot disable {all|<bot>}
|
|
337
|
-
dexbot enable {all|<bot>}
|
|
338
|
-
|
|
339
|
-
dexbot
|
|
340
|
-
dexbot
|
|
341
|
-
|
|
342
|
-
dexbot
|
|
343
|
-
dexbot
|
|
344
|
-
dexbot
|
|
345
|
-
|
|
346
|
-
dexbot
|
|
347
|
-
dexbot
|
|
348
|
-
dexbot
|
|
349
|
-
dexbot
|
|
333
|
+
dexbot key # Master password/keyring
|
|
334
|
+
dexbot bot # Interactive bot configurator
|
|
335
|
+
|
|
336
|
+
dexbot reset {all|<bot>} # Regenerate grid
|
|
337
|
+
dexbot disable {all|<bot>} # Disable bot in config
|
|
338
|
+
dexbot enable {all|<bot>} # Enable bot in config
|
|
339
|
+
|
|
340
|
+
dexbot order [<bot|account>] # Grid state: spread, increment, funds (--export → HTML)
|
|
341
|
+
dexbot export <bot> # Trades + settings → CSV/JSON for analysis/
|
|
342
|
+
|
|
343
|
+
dexbot tv <bot|pool|A/B> # TradingView 1h chart with AMA overlay (default: 3 months)
|
|
344
|
+
dexbot dw <bot|pool|A/B> # Dynamic-weight research chart (same targets/flags as tv)
|
|
345
|
+
dexbot liquid <bot|pool|A/B> # Liquidity depth: order book + AMM pool (aliases: liq, liqu)
|
|
346
|
+
|
|
347
|
+
dexbot pnl <bot|account> # HTML PnL report (--month N, optional --pair A/B)
|
|
348
|
+
dexbot credit [<bot|account>] # Live summed MPA + borrowed-credit positions
|
|
349
|
+
dexbot asset <bts|symbol> # Supply distribution + HTML report (short: dexbot a bts)
|
|
350
|
+
dexbot rich <asset...> # Top holders per asset
|
|
351
|
+
|
|
352
|
+
dexbot update # Update DEXBot2
|
|
353
|
+
dexbot clear # Delete log files in <profiles>/logs
|
|
354
|
+
dexbot default # Reset settings to defaults
|
|
355
|
+
dexbot help # Grouped command reference
|
|
350
356
|
```
|
|
351
357
|
|
|
352
358
|
## 🎯 PM2 Process Management
|
package/analysis/README.md
CHANGED
|
@@ -26,6 +26,7 @@ Tools that inspect DEXBot trading behavior and the market data it operates on. O
|
|
|
26
26
|
| [`analyze_risk_profile.ts`](#risk-profile-analyzer-analyze_risk_profilets) | "How wide should my Safe Range clamps be?" | `node dist/analysis/analyze_risk_profile.js --bot-key <bot-key>` |
|
|
27
27
|
| [`analyze_trade_heatmap.ts`](#trade-heatmap-analyze_trade_heatmapts) | "Where did trade volume cluster vs the AMA?" | `node dist/analysis/analyze_trade_heatmap.js --bot-key <bot-key>` |
|
|
28
28
|
| [`tradingview/analyze_tradingview.ts`](#tradingview-chart-tradingviewanalyze_tradingviewts) | "Just give me a candle chart" | `dexbot tv <bot-key>` |
|
|
29
|
+
| [`analyze_liquidity.ts`](#liquidity-depth-chart-analyze_liquidityts) | "Where is the pair's real liquidity — order book, AMM pool, or both?" | `npm run analysis:liquidity -- --pair TOKENA/TOKENB` |
|
|
29
30
|
| [`analyze_dynamic_weight.ts`](#dynamic-weight-research-analyze_dynamic_weightts) | "Are buy/sell weights tuned for this regime?" | `dexbot dw <bot-key>` |
|
|
30
31
|
| [`analyze_volatility.ts`](#volatility-analyze_volatilityts) | "Both weights clipped too hard / not enough?" | `node dist/analysis/analyze_volatility.js --bot-key <bot-key>` |
|
|
31
32
|
| [`analyze_regime.ts`](#supporting-sub-signals) | "Is the trend/chaos gate too aggressive?" | `node dist/analysis/analyze_regime.js --bot-key <bot-key>` |
|
|
@@ -258,7 +259,7 @@ All amounts use the shared 4-significant-figure formatter (compact `K`/`M`, sign
|
|
|
258
259
|
|
|
259
260
|
### LAST-FILL-GUARD Check (`grid_correction_check.ts`)
|
|
260
261
|
|
|
261
|
-
Validates LAST-FILL-GUARD discipline from the same Kibana fill pipeline as `trade_profitability.ts`. The rule is **direction only** (v1.6.
|
|
262
|
+
Validates LAST-FILL-GUARD discipline from the same Kibana fill pipeline as `trade_profitability.ts`. The rule is **direction only** (v1.6.17+) and comes from the runtime's own `isLastFillGuardBlocked` — the tool imports it instead of re-implementing it, so the offline verdict cannot drift from the live guard. With the previous fill at price `p`, the next order must satisfy `BUY < p` and `SELL > p` (equal price is blocked — a re-place at the just-filled level). There is no increment band: the older `pivot ± i/2` rule blocked a BUY below a SELL fill and a SELL one tick above our cost, i.e. it flagged the tightening placements the engine legitimately makes. A violation is a buy fill at/above its pivot or a sell fill at/below it.
|
|
262
263
|
|
|
263
264
|
**Offline limits:** the tool reconstructs pivots from consecutive fills, so it cannot see the runtime's edge-pinned-fill exclusion (no slot identity per fill) nor the spread-correction bypass — expect rare false positives on wick/insurance fills.
|
|
264
265
|
|
|
@@ -302,6 +303,111 @@ Exit code `0` = pass, `2` = violations found, `1` = fatal error. Bot keys resolv
|
|
|
302
303
|
|
|
303
304
|
## Charts & Visualization
|
|
304
305
|
|
|
306
|
+
### Liquidity Depth Chart (`analyze_liquidity.ts`)
|
|
307
|
+
|
|
308
|
+
Blends one pair's live limit-order book with its constant-product AMM pool into a
|
|
309
|
+
single cumulative-depth chart (the PoolTool depth view, rebuilt with the vendored
|
|
310
|
+
uPlot runtime). The chart plots **both** liquidity sources side by side as
|
|
311
|
+
independent curves — they are deliberately **not summed**, because an on-chain
|
|
312
|
+
order and an AMM reserve are different claims on liquidity. You can see which
|
|
313
|
+
source supplies the depth at a given price, where the pool price sits relative
|
|
314
|
+
to the book mid, and how far the two diverge.
|
|
315
|
+
|
|
316
|
+
- **Price axis**: quote per base (B/A), e.g. `QUOTE per BASE`
|
|
317
|
+
- **Depth axis**: cumulative quote liquidity (e.g. BTS) at or better than that price;
|
|
318
|
+
click the right y-axis to toggle the same curves into cumulative base units
|
|
319
|
+
(e.g. BASE) — both are precomputed server-side
|
|
320
|
+
- **Click the x-axis to invert price** (`1/p`, e.g. `BASE per QUOTE`). Inversion
|
|
321
|
+
also swaps bid/ask roles and flips the depth asset to the new quote, so the
|
|
322
|
+
chart stays a valid book view rather than a mirrored picture with the wrong sides
|
|
323
|
+
- **Bids**: order-book bids (`quote` of every bid at price >= p) drawn next to
|
|
324
|
+
the pool's fee-adjusted bid curve, which starts at `(1 - f) * p0` and nets
|
|
325
|
+
`(1 - f) * quoteReserve * (1 - sqrt(p / ((1 - f) * p0)))`
|
|
326
|
+
- **Asks**: order-book asks (`quote` of every ask at price <= p) drawn next to
|
|
327
|
+
the pool's fee-adjusted ask curve, which starts at `p0 / (1 - f)` and is
|
|
328
|
+
`quoteReserve * (sqrt(p * (1 - f) / p0) - 1)`
|
|
329
|
+
- **Spread bands**: the order-book spread (best bid .. best ask, amber) and the
|
|
330
|
+
pool fee band (violet, between the fee-adjusted edges) are both shaded, so the
|
|
331
|
+
two spreads a taker could cross are directly comparable. The overlay lists
|
|
332
|
+
each percentage with its absolute edges and tags the tighter one; clicking the
|
|
333
|
+
x-axis to invert flips both bands with the rest of the view
|
|
334
|
+
|
|
335
|
+
The window is symmetric around the pool price (book mid when there is no pool),
|
|
336
|
+
so the whole `0.5x .. 1.5x` range is visible by default. The chain's
|
|
337
|
+
`get_order_book` side convention is handled by the tool. Pool depth is the exact
|
|
338
|
+
constant-product solution (verified against the `x*y = k` swap invariant) and is
|
|
339
|
+
**net of the AMM taker fee** `f` (`taker_fee_percent / 100`): the chain charges
|
|
340
|
+
it on the output side and keeps it in the pool, so a swap's effective price is
|
|
341
|
+
`(1 - f) * p` when selling into the pool and `p / (1 - f)` when buying. The
|
|
342
|
+
curve is parameterized by that effective price, so the two pool curves no
|
|
343
|
+
longer meet at the pool price — they stop at their own edges, `(1 - f) * p0` and
|
|
344
|
+
`p0 / (1 - f)`, and the shaded band between them (`~2f` wide) is the AMM spread
|
|
345
|
+
a taker has to cross. That band is drawn in the chart next to the book spread,
|
|
346
|
+
reported in the readout (`BOOK` / `POOL` rows, with the tighter one tagged) and
|
|
347
|
+
in the header (`BOOK SPREAD`, `FEE … · POOL SPREAD …`), and mirrored in the
|
|
348
|
+
console summary (`pool edge bid/ask`). With `f = 0` the two sides collapse onto
|
|
349
|
+
the pool price and the curves match PoolTool's depth chart exactly. PoolTool's
|
|
350
|
+
`depthchart.py` plots the same fee-free curves with the reciprocal price
|
|
351
|
+
convention (`amount_y * (sqrt(p_pool/p) - 1)` for buys and
|
|
352
|
+
`amount_y * (1 - sqrt(p_pool/p))` for sells).
|
|
353
|
+
|
|
354
|
+
Order-book depth prefers `get_limit_orders` (up to ~300 levels per side) over
|
|
355
|
+
`get_order_book`, which many nodes cap at 50 — otherwise thin far levels are
|
|
356
|
+
silently missing from the curves. If the wider call is unavailable the tool
|
|
357
|
+
falls back to the classic 50-level endpoint.
|
|
358
|
+
|
|
359
|
+
All displayed numbers use DEXBot's shared formatters (`modules/order/format.ts`)
|
|
360
|
+
embedded into the generated page so it renders identically offline:
|
|
361
|
+
`formatCurrency` for prices (4 active digits), `formatFundsValue` for amounts,
|
|
362
|
+
and `formatPercentLabel` for every percentage — 2 decimals below 100%
|
|
363
|
+
(`2.27%`, `0.40%`, `18.18%`), 1 from 100% (`100.0%`) and none from 1000%
|
|
364
|
+
(`1235%`), fixed-point so a small percentage never picks up the SI suffixes
|
|
365
|
+
`formatCurrency` produces.
|
|
366
|
+
|
|
367
|
+
```bash
|
|
368
|
+
# Default example pair
|
|
369
|
+
npm run analysis:liquidity -- --pair TOKENA/TOKENB
|
|
370
|
+
|
|
371
|
+
# CLI wrapper: resolves a bot key, a pool (id or pool token) or a pair
|
|
372
|
+
dexbot liq TOKENA/TOKENB --range 0.25
|
|
373
|
+
dexbot liq <bot-key>
|
|
374
|
+
dexbot liq 1.19.123 # pool by id
|
|
375
|
+
dexbot liq <pool-token-symbol> # pool by its LP share-asset symbol
|
|
376
|
+
# Aliases: liqu, liquidity (canonical command: liquid)
|
|
377
|
+
|
|
378
|
+
# Tighter window, deeper book, explicit pool
|
|
379
|
+
node dist/analysis/analyze_liquidity.js \
|
|
380
|
+
--pair TOKENA/TOKENB --range 0.25 --depth 50 --pool 1.19.123 --json liquidity.json
|
|
381
|
+
|
|
382
|
+
# Any pair by symbol or asset id
|
|
383
|
+
node dist/analysis/analyze_liquidity.js --base 1.3.123 --quote TOKENB --chart /tmp/lp.html
|
|
384
|
+
|
|
385
|
+
# One pool by id or pool token (legs derived from the pool)
|
|
386
|
+
node dist/analysis/analyze_liquidity.js --pool 1.19.123 --chart /tmp/pool.html
|
|
387
|
+
node dist/analysis/analyze_liquidity.js --pool <pool-token-symbol> --json pool.json
|
|
388
|
+
```
|
|
389
|
+
|
|
390
|
+
<details><summary><mark>Options (click to expand)</mark></summary>
|
|
391
|
+
|
|
392
|
+
| Flag | Default | Description |
|
|
393
|
+
|------|---------|-------------|
|
|
394
|
+
| `--base` / `--quote` | — | Assets by symbol or `1.3.x` id (required via `--pair` or `--base` + `--quote`) |
|
|
395
|
+
| `--pair <base>/<quote>` | — | Shorthand for `--base` + `--quote` (also accepts `:`) |
|
|
396
|
+
| `--pool` | deepest pool | One pool: id (`133` / `1.19.133`) or its pool token (LP share-asset symbol). With no `--base`/`--quote`, both legs come from the pool |
|
|
397
|
+
| `--depth` | `300` | Order-book levels per side; fetched via `get_limit_orders` (commonly capped at 300) with a `get_order_book` fallback |
|
|
398
|
+
| `--range` | `0.5` | Window half-width as a fraction of the center price |
|
|
399
|
+
| `--steps` | `400` | Price samples across the window (exact book levels are always added) |
|
|
400
|
+
| `--chart` | `analysis/charts/liquidity_<base>_<quote>.html` | HTML output path |
|
|
401
|
+
| `--json` | — | Optional JSON dump of the sampled series and summary |
|
|
402
|
+
| `--quiet` | off | Suppress the console summary |
|
|
403
|
+
|
|
404
|
+
</details>
|
|
405
|
+
|
|
406
|
+
Generation is read-only and uses an ephemeral chain connection (`analysis/chain_pool.ts`),
|
|
407
|
+
so it never disturbs a running bot. The output is a single self-contained HTML file
|
|
408
|
+
(uPlot inlined, no CDN or sibling assets); hovering shows book/pool depth at
|
|
409
|
+
the cursor price, scroll zooms, drag pans, double-click resets.
|
|
410
|
+
|
|
305
411
|
### Trade Heatmap (`analyze_trade_heatmap.ts`)
|
|
306
412
|
|
|
307
413
|
Generates a 2D heatmap + summed histogram showing where trade volume concentrates relative to AMA deviation. Time-slice rows show how the distribution evolved; the bottom histogram shows the aggregate bell-curve shape with threshold annotations.
|
|
@@ -347,9 +453,10 @@ Generates a standalone TradingView-style HTML chart with candle OHLC, SMA, AMA,
|
|
|
347
453
|
|
|
348
454
|
# Recommended one-step: bot, pool, or pair (fetches candles + renders, default 3 months)
|
|
349
455
|
dexbot tv <bot-key>
|
|
350
|
-
dexbot tv 133
|
|
456
|
+
dexbot tv 133 # pool by id
|
|
457
|
+
dexbot tv <pool-token-symbol> # pool by its LP share-asset symbol
|
|
351
458
|
dexbot tv TOKENA/TOKENB
|
|
352
|
-
dexbot tv BTS/HONEST.USD --feed
|
|
459
|
+
dexbot tv BTS/HONEST.USD --feed # opt-in: MPA price-feed history instead of market candles
|
|
353
460
|
# Manual: bot-key (auto-resolves candle file and AMA settings)
|
|
354
461
|
npm run analysis:tradingview -- --source market_adapter --bot-key <bot-key>
|
|
355
462
|
|
|
@@ -374,7 +481,8 @@ Interactive 4-panel chart for the asymmetric path: AMA slope plus Kalman confirm
|
|
|
374
481
|
# Recommended one-step (advanced): bot, pool, or pair — fetches candles and renders,
|
|
375
482
|
# same pipeline as `dexbot tv`, default 3 months
|
|
376
483
|
dexbot dw <bot-key>
|
|
377
|
-
dexbot dw 133 --month 6
|
|
484
|
+
dexbot dw 133 --month 6 # pool by id
|
|
485
|
+
dexbot dw <pool-token-symbol> --month 6
|
|
378
486
|
dexbot dw TOKENA/TOKENB --month 1
|
|
379
487
|
|
|
380
488
|
# Direct analyzer (own candle files, research knobs --alpha/--gain/--dw/--lb/--clip)
|
|
@@ -525,7 +633,7 @@ Details: [bot_fitting/README.md](bot_fitting/README.md)
|
|
|
525
633
|
| `chart_css.ts` | Shared uPlot CSS fragments for generated charts |
|
|
526
634
|
| `chart_ui.ts` | Shared browser-side uPlot helpers (cursor, hover, zoom-reset, sizing) |
|
|
527
635
|
| `math_utils.ts` | Shared math utilities |
|
|
528
|
-
| `bot_key_utils.ts` | Bot-key resolution, candle file lookup, `accountId` persistence (`persistBotAccountId`) |
|
|
636
|
+
| `bot_key_utils.ts` | Bot-key resolution, `<bot|account>` target matching (`matchBotEntryTarget` / `matchBotAccountTarget` / `matchBotTargetIn` — shared by `credit`, `order`, `pnl` and the chart commands), candle file lookup, `accountId` persistence (`persistBotAccountId`) |
|
|
529
637
|
| `account_resolver.ts` | Account resolution for all tools: `preferredAccount` / `--account` → `1.2.x`, stamping the result into `profiles/bots.json` |
|
|
530
638
|
| `chain_pool.ts` | Ephemeral read-only chain client over the built-in node pool (account + asset lookups) |
|
|
531
639
|
| `fills_source.ts` | Shared `fill_order` Kibana fetch/query and the static asset-precision table + on-chain cache |
|
|
@@ -543,6 +651,7 @@ These npm scripts wrap common analysis runners:
|
|
|
543
651
|
| `npm run analysis:tradingview` | `node dist/analysis/tradingview/analyze_tradingview.js` |
|
|
544
652
|
| `npm run analysis:trade-pnl` | `node dist/analysis/trade_profitability.js` |
|
|
545
653
|
| `npm run analysis:grid-check` | `node dist/analysis/grid_correction_check.js` |
|
|
654
|
+
| `npm run analysis:liquidity` | `node dist/analysis/analyze_liquidity.js` |
|
|
546
655
|
| `npm run ama:chart:lp-local` | `node dist/analysis/ama_fitting/generate_unified_comparison_chart.js` (chart also auto-generated by optimizer) |
|
|
547
656
|
|
|
548
657
|
All accept `--` forwarded flags.
|
|
@@ -554,6 +663,9 @@ npm run analysis:tradingview -- --source market_adapter --bot-key <bot-key>
|
|
|
554
663
|
# Trade PnL
|
|
555
664
|
npm run analysis:trade-pnl -- 1.2.123456 --hours 720
|
|
556
665
|
|
|
666
|
+
# Liquidity depth (order book + AMM pool)
|
|
667
|
+
npm run analysis:liquidity -- --pair TOKENA/TOKENB --range 0.5
|
|
668
|
+
|
|
557
669
|
# LAST-FILL-GUARD check
|
|
558
670
|
npm run analysis:grid-check -- --bot-key <bot-key> --hours 168
|
|
559
671
|
|
package/claw/package.json
CHANGED
|
@@ -11,9 +11,8 @@
|
|
|
11
11
|
* handling — all of it lives here now.
|
|
12
12
|
*/
|
|
13
13
|
import { getErrorMessage } from '../modules/utils/errors.js';
|
|
14
|
-
import { findBotKeyByAccountRef, loadBotMeta, persistBotAccountId, resolveBotKey } from './bot_key_utils.js';
|
|
14
|
+
import { findBotKeyByAccountRef, isAccountIdRef, loadBotMeta, persistBotAccountId, resolveBotKey } from './bot_key_utils.js';
|
|
15
15
|
import { withReadOnlyClient } from './chain_pool.js';
|
|
16
|
-
const ACCOUNT_ID_RE = /^1\.2\.\d+$/;
|
|
17
16
|
/** Default lookup: ephemeral read-only client over the built-in node pool. */
|
|
18
17
|
async function lookupNameOnChain(name) {
|
|
19
18
|
try {
|
|
@@ -62,7 +61,7 @@ async function resolveBotAccount(botKey, options = {}) {
|
|
|
62
61
|
// An explicit override always wins and is never persisted.
|
|
63
62
|
const override = overrideAccount != null ? String(overrideAccount).trim() : '';
|
|
64
63
|
if (override) {
|
|
65
|
-
if (
|
|
64
|
+
if (isAccountIdRef(override)) {
|
|
66
65
|
return { accountId: override, botKey, botMeta, source: 'override-id', reason: null };
|
|
67
66
|
}
|
|
68
67
|
if (!quiet)
|
|
@@ -79,10 +78,10 @@ async function resolveBotAccount(botKey, options = {}) {
|
|
|
79
78
|
const prefRaw = botMeta.preferredAccount != null ? String(botMeta.preferredAccount).trim() : '';
|
|
80
79
|
if (!prefRaw)
|
|
81
80
|
return { accountId: null, botKey, botMeta, source: null, reason: 'no-preferred-account' };
|
|
82
|
-
const stored =
|
|
81
|
+
const stored = isAccountIdRef(String(botMeta.accountId ?? '')) ? String(botMeta.accountId) : null;
|
|
83
82
|
// A typed 1.2.x preferredAccount is authoritative — the stored accountId is
|
|
84
83
|
// a derived cache and must never override it. Self-heal the cache.
|
|
85
|
-
if (
|
|
84
|
+
if (isAccountIdRef(prefRaw)) {
|
|
86
85
|
if (stored !== prefRaw)
|
|
87
86
|
persistResolvedAccountId(botKey, prefRaw, stored, quiet, botsFile);
|
|
88
87
|
return { accountId: prefRaw, botKey, botMeta, source: 'preferred-id', reason: null };
|
|
@@ -110,7 +109,7 @@ async function resolveBotAccount(botKey, options = {}) {
|
|
|
110
109
|
*/
|
|
111
110
|
async function resolveAccountRef(accountRef, options = {}) {
|
|
112
111
|
const ref = String(accountRef ?? '').trim();
|
|
113
|
-
if (
|
|
112
|
+
if (isAccountIdRef(ref)) {
|
|
114
113
|
return { accountId: ref, botKey: null, botMeta: null, source: 'typed-id', reason: null };
|
|
115
114
|
}
|
|
116
115
|
// Local profile first: a bot whose profile name/key matches the reference
|
|
@@ -22,6 +22,7 @@ import { computeAmaSlopeWeights, createAmaSlopeClipTracker } from '../market_ada
|
|
|
22
22
|
import { MARKET_ADAPTER } from '../modules/constants.js';
|
|
23
23
|
import { PATHS } from '../modules/paths.js';
|
|
24
24
|
import { writeChartFile, toFileUrl } from './chart_utils.js';
|
|
25
|
+
import { CLI_TAGS, savedLine } from '../modules/cli_progress.js';
|
|
25
26
|
import { getCandleClose } from './math_utils.js';
|
|
26
27
|
import { resolveSource, listAvailableBots } from './resolve_source.js';
|
|
27
28
|
import { baseAnalysisConfig, consumeCommonAnalysisArg } from './analyze_args.js';
|
|
@@ -195,7 +196,7 @@ async function main() {
|
|
|
195
196
|
}, config.title || 'Dynamic Weight Research Tool');
|
|
196
197
|
writeChartFile(config.chartFile, html);
|
|
197
198
|
if (!config.quiet)
|
|
198
|
-
console.log(
|
|
199
|
+
console.log(savedLine(CLI_TAGS.dynamicWeight, 'Chart', toFileUrl(config.chartFile)));
|
|
199
200
|
}
|
|
200
201
|
catch (err) {
|
|
201
202
|
console.error(`[DynamicWeight] Error: ${getErrorMessage(err)}`);
|
|
@@ -18,7 +18,8 @@ import { calculateAMA } from '../market_adapter/core/strategies/ama.js';
|
|
|
18
18
|
import { computeAmaSlopeWeights, createAmaSlopeClipTracker } from '../market_adapter/core/strategies/ama_slope_model.js';
|
|
19
19
|
import { MARKET_ADAPTER } from '../modules/constants.js';
|
|
20
20
|
import { getCandleClose } from './math_utils.js';
|
|
21
|
-
import { writeChartFile } from './chart_utils.js';
|
|
21
|
+
import { writeChartFile, toFileUrl } from './chart_utils.js';
|
|
22
|
+
import { CLI_TAGS, savedLine } from '../modules/cli_progress.js';
|
|
22
23
|
import { PATHS } from '../modules/paths.js';
|
|
23
24
|
import { resolveSource, listAvailableBots } from './resolve_source.js';
|
|
24
25
|
import { baseAnalysisConfig, consumeCommonAnalysisArg } from './analyze_args.js';
|
|
@@ -124,7 +125,7 @@ async function main() {
|
|
|
124
125
|
const html = generateHTML({ allResults, amaConfig, clipPct: MARKET_ADAPTER.DYNAMIC_WEIGHT_CLIP_PERCENTILE }, 'Kalman Trend Analysis');
|
|
125
126
|
writeChartFile(config.chartFile, html);
|
|
126
127
|
if (!config.quiet)
|
|
127
|
-
console.log(
|
|
128
|
+
console.log(savedLine(CLI_TAGS.kalman, 'Chart', toFileUrl(config.chartFile)));
|
|
128
129
|
}
|
|
129
130
|
catch (err) {
|
|
130
131
|
console.error(`[Kalman] Error: ${getErrorMessage(err)}`);
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
interface LiquidityConfig {
|
|
3
|
+
base: string;
|
|
4
|
+
quote: string;
|
|
5
|
+
poolId: string | null;
|
|
6
|
+
depth: number;
|
|
7
|
+
range: number;
|
|
8
|
+
steps: number;
|
|
9
|
+
chartFile: string | null;
|
|
10
|
+
jsonFile: string | null;
|
|
11
|
+
quiet: boolean;
|
|
12
|
+
help: boolean;
|
|
13
|
+
}
|
|
14
|
+
declare function parseArgs(argv: string[]): LiquidityConfig;
|
|
15
|
+
export { parseArgs };
|
|
16
|
+
export type { LiquidityConfig };
|
|
17
|
+
//# sourceMappingURL=analyze_liquidity.d.ts.map
|