dexbot 1.4.23 → 1.4.25
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 +47 -0
- package/README.md +1 -0
- package/analysis/README.md +49 -0
- package/analysis/ama_fitting/package.json +1 -1
- package/analysis/grid_correction_check.ts +896 -0
- package/analysis/trend_detection/package.json +1 -1
- package/claw/package.json +1 -1
- package/claw/runtimes/openclaw-plugin/openclaw.plugin.json +1 -1
- package/claw/runtimes/openclaw-plugin/package.json +1 -1
- package/claw/tests/test_claw_mcp_transport.ts +2 -2
- package/dist/analysis/grid_correction_check.d.ts +90 -0
- package/dist/analysis/grid_correction_check.d.ts.map +1 -0
- package/dist/analysis/grid_correction_check.js +861 -0
- package/dist/analysis/grid_correction_check.js.map +1 -0
- package/dist/dexbot.d.ts.map +1 -1
- package/dist/dexbot.js +62 -6
- package/dist/dexbot.js.map +1 -1
- package/dist/modules/account_bots.d.ts.map +1 -1
- package/dist/modules/account_bots.js +53 -5
- package/dist/modules/account_bots.js.map +1 -1
- package/dist/modules/account_orders.d.ts +7 -10
- package/dist/modules/account_orders.d.ts.map +1 -1
- package/dist/modules/account_orders.js +26 -2
- package/dist/modules/account_orders.js.map +1 -1
- package/dist/modules/bitshares-native/subscriptions.d.ts.map +1 -1
- package/dist/modules/bitshares-native/subscriptions.js +176 -21
- package/dist/modules/bitshares-native/subscriptions.js.map +1 -1
- package/dist/modules/chain_orders.d.ts.map +1 -1
- package/dist/modules/chain_orders.js +21 -2
- package/dist/modules/chain_orders.js.map +1 -1
- package/dist/modules/config.d.ts.map +1 -1
- package/dist/modules/config.js +27 -0
- package/dist/modules/config.js.map +1 -1
- package/dist/modules/constants.d.ts +15 -1
- package/dist/modules/constants.d.ts.map +1 -1
- package/dist/modules/constants.js +70 -6
- package/dist/modules/constants.js.map +1 -1
- package/dist/modules/credit_runtime.d.ts.map +1 -1
- package/dist/modules/credit_runtime.js +31 -32
- package/dist/modules/credit_runtime.js.map +1 -1
- package/dist/modules/dexbot_class.d.ts +24 -0
- package/dist/modules/dexbot_class.d.ts.map +1 -1
- package/dist/modules/dexbot_class.js +66 -12
- package/dist/modules/dexbot_class.js.map +1 -1
- package/dist/modules/dexbot_cow_runtime.d.ts +22 -17
- package/dist/modules/dexbot_cow_runtime.d.ts.map +1 -1
- package/dist/modules/dexbot_cow_runtime.js +646 -128
- package/dist/modules/dexbot_cow_runtime.js.map +1 -1
- package/dist/modules/dexbot_fill_runtime.d.ts +11 -1
- package/dist/modules/dexbot_fill_runtime.d.ts.map +1 -1
- package/dist/modules/dexbot_fill_runtime.js +108 -1
- package/dist/modules/dexbot_fill_runtime.js.map +1 -1
- package/dist/modules/dexbot_maintenance_runtime.d.ts +17 -1
- package/dist/modules/dexbot_maintenance_runtime.d.ts.map +1 -1
- package/dist/modules/dexbot_maintenance_runtime.js +215 -26
- package/dist/modules/dexbot_maintenance_runtime.js.map +1 -1
- package/dist/modules/dexbot_startup_runtime.d.ts +1 -0
- package/dist/modules/dexbot_startup_runtime.d.ts.map +1 -1
- package/dist/modules/dexbot_startup_runtime.js +58 -7
- package/dist/modules/dexbot_startup_runtime.js.map +1 -1
- package/dist/modules/dexbot_state_recovery.d.ts.map +1 -1
- package/dist/modules/dexbot_state_recovery.js +55 -3
- package/dist/modules/dexbot_state_recovery.js.map +1 -1
- package/dist/modules/graceful_shutdown.d.ts +12 -1
- package/dist/modules/graceful_shutdown.d.ts.map +1 -1
- package/dist/modules/graceful_shutdown.js +39 -1
- package/dist/modules/graceful_shutdown.js.map +1 -1
- package/dist/modules/key_store.d.ts.map +1 -1
- package/dist/modules/key_store.js +38 -1
- package/dist/modules/key_store.js.map +1 -1
- package/dist/modules/order/accounting.d.ts.map +1 -1
- package/dist/modules/order/accounting.js +20 -3
- package/dist/modules/order/accounting.js.map +1 -1
- package/dist/modules/order/grid.d.ts +1 -1
- package/dist/modules/order/grid.d.ts.map +1 -1
- package/dist/modules/order/grid.js +288 -31
- package/dist/modules/order/grid.js.map +1 -1
- package/dist/modules/order/grid_reconcile.d.ts +4 -2
- package/dist/modules/order/grid_reconcile.d.ts.map +1 -1
- package/dist/modules/order/grid_reconcile.js +242 -222
- package/dist/modules/order/grid_reconcile.js.map +1 -1
- package/dist/modules/order/grid_reconcile_internal.d.ts +11 -1
- package/dist/modules/order/grid_reconcile_internal.d.ts.map +1 -1
- package/dist/modules/order/grid_reconcile_internal.js +132 -6
- package/dist/modules/order/grid_reconcile_internal.js.map +1 -1
- package/dist/modules/order/manager.d.ts +68 -14
- package/dist/modules/order/manager.d.ts.map +1 -1
- package/dist/modules/order/manager.js +241 -52
- package/dist/modules/order/manager.js.map +1 -1
- package/dist/modules/order/strategy.d.ts.map +1 -1
- package/dist/modules/order/strategy.js +25 -8
- package/dist/modules/order/strategy.js.map +1 -1
- package/dist/modules/order/sync_engine.d.ts.map +1 -1
- package/dist/modules/order/sync_engine.js +261 -166
- package/dist/modules/order/sync_engine.js.map +1 -1
- package/dist/modules/order/utils/math.d.ts +47 -5
- package/dist/modules/order/utils/math.d.ts.map +1 -1
- package/dist/modules/order/utils/math.js +175 -11
- package/dist/modules/order/utils/math.js.map +1 -1
- package/dist/modules/order/utils/order.d.ts +16 -15
- package/dist/modules/order/utils/order.d.ts.map +1 -1
- package/dist/modules/order/utils/order.js +199 -32
- package/dist/modules/order/utils/order.js.map +1 -1
- package/dist/modules/order/utils/slot.d.ts +8 -0
- package/dist/modules/order/utils/slot.d.ts.map +1 -0
- package/dist/modules/order/utils/slot.js +16 -0
- package/dist/modules/order/utils/slot.js.map +1 -0
- package/dist/modules/order/utils/system.d.ts.map +1 -1
- package/dist/modules/order/utils/system.js +3 -2
- package/dist/modules/order/utils/system.js.map +1 -1
- package/dist/modules/order/utils/validate.d.ts +5 -8
- package/dist/modules/order/utils/validate.d.ts.map +1 -1
- package/dist/modules/order/utils/validate.js +64 -82
- package/dist/modules/order/utils/validate.js.map +1 -1
- package/dist/modules/order/working_grid.d.ts +5 -0
- package/dist/modules/order/working_grid.d.ts.map +1 -1
- package/dist/modules/order/working_grid.js +21 -0
- package/dist/modules/order/working_grid.js.map +1 -1
- package/dist/modules/paths.d.ts +4 -2
- package/dist/modules/paths.d.ts.map +1 -1
- package/dist/modules/paths.js +79 -24
- package/dist/modules/paths.js.map +1 -1
- package/dist/scripts/analyze-orders.d.ts.map +1 -1
- package/dist/scripts/analyze-orders.js +23 -2
- package/dist/scripts/analyze-orders.js.map +1 -1
- package/dist/scripts/generate_market_adapter_whitelist.d.ts +2 -5
- package/dist/scripts/generate_market_adapter_whitelist.d.ts.map +1 -1
- package/dist/scripts/generate_market_adapter_whitelist.js +83 -1
- package/dist/scripts/generate_market_adapter_whitelist.js.map +1 -1
- package/docs/DEXBOT_COMPARISON.md +15 -15
- package/docs/EVOLUTION.md +10 -8
- package/docs/FUND_MOVEMENT_AND_ACCOUNTING.md +1 -1
- package/docs/GRID_RECALCULATION.md +6 -0
- package/docs/README.md +2 -2
- package/market_adapter/README.md +10 -0
- package/package.json +2 -1
- package/scripts/README.md +4 -0
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,53 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
|
|
5
|
+
## [1.4.25] - 2026-09-02 - Genesis-Frozen Price-Slot Determinism, Self-Trade & Fill-Guard Hardening, Grid Orphan & Recovery Hardening
|
|
6
|
+
|
|
7
|
+
### 2026-08-29
|
|
8
|
+
|
|
9
|
+
- **Fix(grid)**: restore strict ERROR diagnostics by fixing hidden fund-invariant and precision failures — re-enables strict diagnostics that were masked by NaN fund-invariant comparisons and float precision drift; fixes fund-invariant tolerance fallback, amount precision helpers, and related silent-failure paths so ERROR logs fire correctly (`modules/order/accounting.ts`, `modules/order/utils/math.ts`, `modules/constants.ts`, etc.).
|
|
10
|
+
- **Fix(gap-band)**: enforce gap-band invariant across COW plan, sync, reconcile and recovery (P1–P5) — introduces authoritative gap-band checks that reject placements violating the reserved gap, validates gap-band geometry in COW planning, sync adoption, startup reconcile and recovery persistence so boundaries cannot drift into the forbidden band (`modules/order/grid.ts`, `modules/order/utils/math.ts`, `modules/dexbot_cow_runtime.ts`, `modules/order/sync_engine.ts`, `modules/order/grid_reconcile*.ts`, `modules/dexbot_state_recovery.ts`).
|
|
11
|
+
- **Fix(grid)**: prevent same-slot re-placement and truncation-drop orphans after COW commit — guards against re-creating an order on a slot that was just committed and against truncation-ambiguous reads dropping live orphans; keeps slot provenance across COW commit so placed orders are not re-issued or lost on a truncated read (`modules/dexbot_cow_runtime.ts`, `modules/order/sync_engine.ts`, `modules/order/grid_reconcile_internal.ts`).
|
|
12
|
+
- **Fix(grid)**: make chain evidence authoritative and remove destructive gap-band cancellation — cancels that swept the gap band based on stale local state are removed; chain-observed orders are the sole authority for gap/rail membership and gap-band sweeps are no longer triggered from local-only evidence (`modules/order/grid_reconcile*.ts`, `modules/order/sync_engine.ts`).
|
|
13
|
+
- **Fix(grid)**: heal and prevent sized-orphan phantom orders in spread and COW commit — spread-correction and COW commit paths that left VIRTUAL slots with `size>0` and no `orderId` (sized orphans causing 2.02% vs 3.04% spread divergence) are healed on reload (virtual-size zeroing with `createUncertain` preservation) and prevented at commit (orphan exclusion from sizing denominator, durable markers) (`modules/order/grid.ts`, `modules/order/manager.ts`, `modules/account_orders.ts`, `modules/dexbot_cow_runtime.ts`).
|
|
14
|
+
|
|
15
|
+
### 2026-08-30
|
|
16
|
+
|
|
17
|
+
- **Fix(recovery)**: stop recovery re-anchoring and make orphan adoption durable — structural resync no longer re-anchors to the latest AMA center (state repair only); orphan adoption widened with `ORPHAN_ADOPTION_TOLERANCE_MULTIPLIER` (×4) on empty slots, reconcile prefers in-place price updates over pre-emptive cancels, and boundary/slot persistence is hardened (`modules/dexbot_maintenance_runtime.ts`, `modules/order/sync_engine.ts`, `modules/order/grid_reconcile.ts`, `modules/constants.ts`).
|
|
18
|
+
- **Fix(engine)**: harden order engine against orphan-cascade failure modes — closes four unvalidated local-state paths (stale-slot fill price poisoning the anchor, off-market placement, phantom virtualization from empty reads, blind unknown-fill proceed credit) via broadcast orphan gates, anchor outlier rejection, price-sanity clamp, suspect empty-read guard (3 confirms), adoption retry, and durable `createUncertain` markers; placement now wrapped in `startBroadcasting` so fill-driven rebalances cannot duplicate plans (`modules/order/grid_reconcile.ts`, `modules/order/manager.ts`, `modules/dexbot_maintenance_runtime.ts`, `modules/constants.ts`, `modules/order/utils/order.ts`, `modules/dexbot_fill_runtime.ts`, `modules/dexbot_cow_runtime.ts`).
|
|
19
|
+
- **Fix(maintenance)**: make trigger reset reliable — skip idle gate, drain stalled fills, repair infeasible boundaries — trigger-file resets now execute immediately (`skipIdle`), fill queues deferred by `batchInFlight`/`recoverySyncInFlight` are drained on pipeline clear via `_onBroadcastRegionEnd` (wired at both `OrderManager` creation sites), and `NO_FEASIBLE_BOUNDARY` (overlapping BUY/SELL inside gap) escalates to a minimal cancel ladder so placements resume instead of freezing in adoption-only mode (`modules/dexbot_maintenance_runtime.ts`, `modules/order/manager.ts`, `modules/dexbot_startup_runtime.ts`, `modules/order/utils/math.ts`, `modules/order/grid_reconcile*.ts`).
|
|
20
|
+
- **Docs**: consolidate orphan-fix plans and add grid monotonicity gate — four test-branch incident/plan docs merged into `docs/CONSOLIDATED_ORPHAN_FIX_SUMMARY.md` (LANDED/REVERTED/SUPERSEDED annotated) and new `npm run analysis:grid-check` (`analysis/grid_correction_check.ts`) validates consecutive same-direction fills are monotonic (sell rising / buy falling) via Kibana `fill_order` history (`analysis/*`, `docs/*`, `modules/constants.ts`).
|
|
21
|
+
|
|
22
|
+
### 2026-08-31
|
|
23
|
+
|
|
24
|
+
- **Fix(launcher)**: ensure bot detection within 5min and correct disable/enable active check — new `TIMING.BOTS_CONFIG_POLL_INTERVAL_MS` (5min) decouples fingerprint polling from the heavy 240min chain fetch so new/reenabled bots are observed within 5min; `dexbot.ts` `setBotActiveState` now treats `undefined` as active (`active !== false`) fixing `enable all` churn on implicit-active bots (`modules/constants.ts`, `modules/dexbot_maintenance_runtime.ts`, `modules/dexbot_class.ts`, `modules/dexbot_startup_runtime.ts`, `dexbot.ts`).
|
|
25
|
+
- **Fix(security)**: close shutdown race that wiped live signing tokens — `_shutdownImpl` no longer nulls `botHmacSecret` while deferred SAFE-REBALANCE continuations are pending; tokens are wiped only on process `exit` via `registerExitWipe`; `SOURCE_AUTH_DENIED` retries re-read `daemon-policies.json`, `OrderManager` gains `_shuttingDown`/`_awaitBroadcastIdle` abort, and monolithic mode retries failed bot startups bounded (3×30s) (`modules/dexbot_class.ts`, `modules/graceful_shutdown.ts`, `modules/key_store.ts`, `modules/order/manager.ts`, `modules/dexbot_fill_runtime.ts`, `modules/dexbot_cow_runtime.ts`, `dexbot.ts`).
|
|
26
|
+
- **Fix(grid)**: block self-trading grid placements across all broadcast paths — adds tolerance-widened crossing guard (`findCrossedOrder` in `modules/order/utils/math.ts`, `buildCrossingCandidates` merging master/pending/chain) to COW CREATE/rotation NOT-FOUND fallback and to startup reconcile/relocation/price-correction paths; rotation now uses swept-band exclusion instead of stale slot-type rotation that caused chunked-broadcast self-fills (`modules/dexbot_cow_runtime.ts`, `modules/order/utils/math.ts`, `modules/order/grid_reconcile_internal.ts`, `modules/order/utils/order.ts`, `modules/order/strategy.ts`).
|
|
27
|
+
- **Fix(fill)**: restore main fill queue handling stalled by broadcasting gate — removes `isBroadcastingActive` from `consumeFillQueue` defer gate (already serialized by `_fillProcessingLock`/stale-plan guard; defer had no reschedule and starved the queue during chunked broadcasts) and drains deferred fills when `_batchInFlight`/`_recoverySyncInFlight` clears (`modules/dexbot_fill_runtime.ts`, `modules/dexbot_maintenance_runtime.ts`, `modules/dexbot_class.ts`).
|
|
28
|
+
- **Fix(grid)**: re-price duplicate-price grid stragglers instead of cancelling them — burst re-anchor that left multiple BUYs at the same level (e.g. 902.08089 ×2, 894.01113 ×3) and self-filled is now fixed by re-pricing stragglers to the next unique ladder step away from market (clamped to `[minPrice,maxPrice]`, preserving `orderId`/`size`) via `correctOrderPriceOnChain` UPDATEs instead of virtualize→cancel; adds whole-burst swept-band caching and asymmetric multi-sell-sweep buy exclusion for chunked and unified bursts (`modules/order/strategy.ts`, `modules/dexbot_class.ts`, `tests/test_grid_robustness.ts`).
|
|
29
|
+
|
|
30
|
+
### 2026-09-01
|
|
31
|
+
|
|
32
|
+
- **Fix(engine)**: revert anchor divergence and boundary-evidence, restore last-fill guard — removes `MarketAnchor`/`BOUNDARY-EVIDENCE`/`BAND-EXCLUSION` paths that drifted from self-trade fills and cancelled stranded orders, restores `deriveTargetBoundary`/`snapRail` grid-dedupe and seeds `LAST-FILL-GUARD` from book at startup/post-fill to block BUY above last filled BUY and SELL below last filled SELL with cross-guard per-type collision checks (`modules/constants.ts`, `modules/order/utils/order.ts`, `modules/order/strategy.ts`, `modules/order/grid_reconcile.ts`, `modules/dexbot_class.ts`, `modules/order/manager.ts`, `modules/dexbot_cow_runtime.ts`).
|
|
33
|
+
- **Fix(grid)**: close duplicate-order incident class from trigger-reset phantom empty read — a trigger reset that observed a single 0-order lagging-node read rebuilt over a live order and queued the wrong duplicate for cancel (books 0.5626 vs chain 0.5626+0.6659). Fix: trigger `GRID-RESYNC` empty reads now require a 2s confirming re-read (`SYNC_EMPTY_READ_CONFIRM_DELAY_MS`), rotation/plan UPDATEs clamp or skip growing PARTIAL slots above booked remaining size, Pass 1 size-consistency tiebreak rebinds a slot to the same-price chain order matching booked size (exact), and `updateOrdersOnChainBatchCOW` drains pending price corrections before planning (`modules/dexbot_maintenance_runtime.ts`, `modules/constants.ts`, `modules/dexbot_cow_runtime.ts`, `modules/order/sync_engine.ts`, `modules/order/manager.ts`).
|
|
34
|
+
- **Fix(g guard)**: last-fill guard pivot ± halfIncrement (BUY < pivot*(1-half), SELL > pivot*(1+half)) — replaces dual-pivot + tolerance with single global pivot (most recent fill) ± half grid increment (e.g. i=0.5% @1000 → BUY<997.5, SELL>1002.5); fixes SELL 1013>1001 after BUY 1001 being wrongly blocked and closes half-step profit hole; spread-correction bypass retained (`modules/order/manager.ts`, `modules/dexbot_cow_runtime.ts`).
|
|
35
|
+
|
|
36
|
+
### 2026-09-02
|
|
37
|
+
|
|
38
|
+
- **Feat(genesis)**: implement genesis-frozen price-slot determinism (Phase 1–2, log mode) — `slot-N` becomes the single source of truth (`price = genesis.priceLevels[N]`); adds `GridGenesis`/`hashPriceLevels`/`priceLevelsForGenesis`/`priceForSlot`/`slotIndexForPrice` (binary search, lower-wins tie)/`priceSlotEqual` (int equality)/`buildGenesisFromPriceLevels`/`assertSlotPriceInvariant`, canonical `parseSlotIndex` (`modules/order/utils/slot.ts`), `createOrderGrid` dedup+genesis build, `loadGrid` genesis validation/canonical re-sort/type re-assignment via `parseSlotIndex` with legacy migration, `account_orders`/`working_grid`/`system`/`startup`/`recovery` genesis threading, and `GRID_PRICE_SLOT_DETERMINISM_PLAN.md` (`modules/order/utils/math.ts`, `modules/order/grid.ts`, `modules/account_orders.ts`, `modules/order/working_grid.ts`, `modules/order/utils/system.ts`, `modules/dexbot_startup_runtime.ts`, `modules/dexbot_state_recovery.ts`, `modules/order/grid_reconcile.ts`, `docs/*`, `tests/test_grid_price_slot_invariant.ts`).
|
|
39
|
+
- **Feat(genesis)**: complete genesis-frozen price-slot determinism (phases 3–9) — replaces all tolerance-based price matching with `slotId` equality / `priceSlotEqual`; sync engine Pass 2 adopts by nearest slot via `slotIndexForPrice` with `isSlotInRail` gap check and VIRTUAL/free slot bind; COW guards `hasSlotPriceCollision`/`validateCreateTargetSlots` use `priceSlotEqual`; fill/grid/rail paths (`isSlotInRail` fail-closed, `chainOrderMatchesSlot`, `hasDuplicatePriceLevel`, `grid_reconcile` cleanup) unified on genesis; legacy tolerance retained only for no-genesis migration (`modules/order/sync_engine.ts`, `modules/dexbot_cow_runtime.ts`, `modules/order/utils/validate.ts`, `modules/dexbot_fill_runtime.ts`, `modules/order/*`, `tests/*` 12 suites).
|
|
40
|
+
- **Feat(editor)**: add Range quality legend with tiered coloring — `RANGE_QUALITY` thresholds (`GREEN_MIN 2.0` wide / `YELLOW_MIN 1.55` efficient / `ORANGE_MIN 1.45` tight / `RED_MAX 1.45` suicidal `<1.45x`) drive a pre-entry legend and live `colorRangeValueByQuality` in `askNumberOrMultiplier`/`askMaxPrice` and summary Pair display (cyan) (`modules/constants.ts`, `modules/account_bots.ts`).
|
|
41
|
+
- **Feat(whitelist)**: add scoped `--bot` overwrite with validation and warnings — `dexbot white --bot <botKey>` overwrites only the targeted whitelist key (merge preserves unknown flags like `derivativeSignals`) while additive-only behavior is preserved without `--bot`; `parseOptions` now collects `botKeys` (`--bot`/`--bot-key`/`--botKey`, `=` and comma forms, repeatable) with missing/flag-like validation (throws, main prints usage and exits 1), `buildWhitelist` filters to targeted keys and warns when `--bot` target not found or has non-AMA `gridPrice` (`scripts/generate_market_adapter_whitelist.ts`, `dexbot.ts`, `docs/*`, `tests/test_market_adapter_fixes.ts`).
|
|
42
|
+
- **Fix(editor)**: align Range quality wording — legend `≤1.35x: suizidal` → `<1.45x: suizidal` to match `getRangeQuality` (`<1.45x` red, `1.45x–1.55x` orange) and make `RANGE_QUALITY.RED_MAX` authoritative (`modules/constants.ts`, `modules/account_bots.ts`).
|
|
43
|
+
|
|
44
|
+
## [1.4.24] - 2026-08-28 - Native Fill Gap Recovery, Eager Coalesced Retry, LP Collateral Offer-First Pricing
|
|
45
|
+
|
|
46
|
+
### 2026-08-28
|
|
47
|
+
|
|
48
|
+
- **Fix(native-client)**: recover dropped fills after subscription notice gaps — **core engine fix** for the 2026-08-28 crash burst (24 and 38 fills dropped, Fund invariant violation SELL / oversell). `handleNotice` advanced `lastDeliveredHistoryId` to the max op id present in the notice (including non-fill ops like `limit_order_create`), so any fill whose `1.11.x` id fell between the old cursor and that max was skipped by the strictly-newer-than-cursor `get_account_history` scan and lost forever; reconnect/poll did not arm recovery and the history merge left entries unsorted so the cursor could land on a gap entry. The fix: `handleNotice` now advances only to the max `fillMatchesAccount` id for that subscription and arms `_gapRecovery` for the next coalesced `processObjects`; `fetchFillHistoryEntries` gains a `lookbackOps` window (`NATIVE_CLIENT.SUBSCRIPTIONS.HISTORY_GAP_LOOKBACK_OPS = 2000` per-account `1.11.x` slots) that lowers `stop` to `cursor-lookback-1` inclusive (core `api.cpp:443` stop is exclusive) and skips entries below the lookback floor — so `[lookbackStop, head]` is re-covered with re-delivery safe via downstream history-id dedup; `processObjects` consumes `_gapRecovery` with a single inclusive lookback+tail scan, sorts oldest-first, and only clears the flag after a successful fetch (retry on throw/timeout); `resubscribeEntry`/`resubscribeAll` arm `_gapRecovery` unconditionally on reconnect; `startFillPolling` no longer arms every 60s tick (avoids ~80 pages/min steady-state cost); new `decrementObjectIdBy` helper and defensive sorting added (`modules/bitshares-native/subscriptions.ts`, `modules/constants.ts`, new `tests/test_fill_gap_recovery.ts` reproducing 5095..5099 gap with cursor 5000→6002 and asserting recovery).
|
|
49
|
+
- **Fix(native-client)**: eager gap recovery without waiting for poll — the initial gap fix armed `_gapRecovery` but recovery was only consumed by the next non-fill notice coalesce (250ms) or the 60s fill poll, leaving up to a 60s correctness window in the quiet-after-gap case where the burst gap (5095..5099 dropped, cursor 5000→6002) could still cause inventory drift before the lightweight 15min/240min open-orders syncs. Now `_gapRecovery` is armed only when the cursor gap exceeds one op (`gap = latest - oldCursor > 1`, so sequential 5000→5001 skips the scan while burst 5000→6002 arms it, avoiding a 40-page scan on every sequential fill) and an eager coalesced lookback is scheduled via `pendingScans`/`_processingHistory` for each armed sub (fires in ~250ms `NOTICE_COALESCE_MS`, unref timer, coalesced per burst, respects in-flight scans); `processObjects` pollution is avoided by skipping poll when `_processingHistory` is true, with poll retained only as a safety-net fallback — cost is one 40-page window per gap event, not per poll, retry-safe via history-id dedup (`modules/bitshares-native/subscriptions.ts`, `tests/test_fill_gap_recovery.ts` tightened to eager-only path without a second no-fill notice).
|
|
50
|
+
- **Fix(credit-runtime)**: prefer offer map over pool for LP collateral pricing — the hourly `live credit offer price unavailable` warn fired for LP share collateral where pool derivation failed for the debt denomination (e.g. pool requires pricing an underlying reserve with no market) even though the offer's `acceptable_collateral` listed the LP explicitly; the LP-exclusive branch ran before the offer-map lookup and returned `cached-offer` on pool miss, shadowing the live offer and logging both the pool derivation failure and the cached-offer warn on every hourly collateral distribution call, with redundant asset resolution and stale line-number refs. `_resolveCreditConversionRate` now tries the offer map (live-offer / owned-offer) first and only falls back to `deriveLiquidityPoolTokenValue` when the offer has no entry for the debt/collateral pair; pool fallback is gated on `!cachedIsFresh` to avoid hourly `deriveLiquidityPoolTokenValue` failures when a fresh cached rate exists; already-resolved `debtAsset`/`collateralAsset` are reused instead of re-resolving for the pool path; early cached return on owned-offer miss is replaced by fall-through so genuine LP-no-offer pairs still reach the pool fallback (`modules/credit_runtime.ts`).
|
|
51
|
+
|
|
5
52
|
## [1.4.23] - 2026-08-28 - Even AMA Ladder, BTS Fee-Carve Fix, Price-Bound Rejection, TradingView Axis, Doc Realignment
|
|
6
53
|
|
|
7
54
|
### 2026-08-26
|
package/README.md
CHANGED
|
@@ -178,6 +178,7 @@ Keep the default settings first, and tune these:
|
|
|
178
178
|
This writes `market_adapter_whitelist.json` in the profiles directory. New AMA bots get AMA
|
|
179
179
|
live writes and range scaling. Use `dexbot white --dynamic-weight` for
|
|
180
180
|
newly generated dynamic-weight entries; existing entries are preserved.
|
|
181
|
+
To overwrite an existing bot: `dexbot white --dynamic-weight --bot <botKey>`.
|
|
181
182
|
|
|
182
183
|
6. **Start DEXBot2** with `dexbot start`.
|
|
183
184
|
|
package/analysis/README.md
CHANGED
|
@@ -21,6 +21,7 @@ Tools that inspect DEXBot trading behavior and the market data it operates on. O
|
|
|
21
21
|
| Tool | Ask this when… | One-line command |
|
|
22
22
|
|------|----------------|------------------|
|
|
23
23
|
| [`trade_profitability.ts`](#trade-profitability-analyzer-trade_profitabilityts) | "Is my bot making money?" — PnL, R-multiples, drawdown | `npm run analysis:trade-pnl -- <account-id>` |
|
|
24
|
+
| [`grid_correction_check.ts`](#grid-correction-check-grid_correction_checkts) | "Is my grid placing orders monotonically?" — sell/buy price inversion detector | `npm run analysis:grid-check -- --bot-key <bot-key>` |
|
|
24
25
|
| [`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>` |
|
|
25
26
|
| [`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>` |
|
|
26
27
|
| [`tradingview/analyze_tradingview.ts`](#tradingview-chart-tradingviewanalyze_tradingviewts) | "Just give me a candle chart" | `npm run analysis:tradingview -- --source market_adapter --bot-key <bot-key>` |
|
|
@@ -219,6 +220,49 @@ node dist/analysis/trade_profitability.js 1.2.123456 \
|
|
|
219
220
|
|
|
220
221
|
</details>
|
|
221
222
|
|
|
223
|
+
### Grid Correction Check (`grid_correction_check.ts`)
|
|
224
|
+
|
|
225
|
+
Validates grid discipline from the same Kibana fill pipeline as `trade_profitability.ts`: two consecutive same-direction fills on a pair must be monotonic — sell prices rising, buy prices falling (equal is OK). An inversion means the bot placed an order below its own previous sell (or above its own previous buy), e.g. an orphaned order filling outside grid accounting. Used as the external regression gate for the orphan-fix plans in `docs/CONSOLIDATED_ORPHAN_FIX_SUMMARY.md`.
|
|
226
|
+
|
|
227
|
+
**Pipeline:** Kibana `fill_order` query (paginated `search_after`) → on-chain asset precision resolution → buy/sell classification → chronological sort → per-order aggregation (multi-fill orders collapsed to weighted-avg price by default) → consecutive same-direction pair comparison → violation report with daily histogram.
|
|
228
|
+
|
|
229
|
+
```bash
|
|
230
|
+
# Per-order aggregated check (default), last 7 days
|
|
231
|
+
npm run analysis:grid-check -- --bot-key <bot-key> --hours 168
|
|
232
|
+
|
|
233
|
+
# 30 days, JSON + CSV export of violations
|
|
234
|
+
npm run analysis:grid-check -- --bot-key <bot-key> --hours 720 --json out.json --csv out.csv
|
|
235
|
+
|
|
236
|
+
# Raw fill granularity instead of per-order aggregation
|
|
237
|
+
npm run analysis:grid-check -- --bot-key <bot-key> --per-fill --hours 168
|
|
238
|
+
|
|
239
|
+
# Forgive small adverse moves within 0.1%
|
|
240
|
+
npm run analysis:grid-check -- --bot-key <bot-key> --hours 168 --tolerance 0.1
|
|
241
|
+
```
|
|
242
|
+
|
|
243
|
+
Exit code `0` = pass, `2` = violations found, `1` = fatal error. Bot keys resolve via `profiles/bots.json` (`--list-bots` to enumerate); the account defaults to the bot's `preferredAccount` and can be overridden with `--account <1.2.x|name>`.
|
|
244
|
+
|
|
245
|
+
<details><summary>Options (click to expand)</summary>
|
|
246
|
+
|
|
247
|
+
| Flag | Default | Description |
|
|
248
|
+
|------|---------|-------------|
|
|
249
|
+
| `--bot-key <key>` | — | Bot key or name from `profiles/bots.json` (required) |
|
|
250
|
+
| `--hours <n>` | `168` | Lookback hours from now |
|
|
251
|
+
| `--start <iso>` / `--end <iso>` | — | Absolute time window |
|
|
252
|
+
| `--account <id>` | bot `preferredAccount` | Override account ID or name |
|
|
253
|
+
| `--lookup` | off | Resolve account name to 1.2.x via BitShares node |
|
|
254
|
+
| `--node <url>` | first built-in node | Node for account/asset resolution |
|
|
255
|
+
| `--per-fill` | off | Check at fill granularity instead of per-order aggregated |
|
|
256
|
+
| `--include-cross-pair` | off | Also check consecutive fills across different pairs |
|
|
257
|
+
| `--tolerance <pct>` | `0` | Adverse price move (%) forgiven before flagging |
|
|
258
|
+
| `--json <file>` / `--csv <file>` | — | Export violations |
|
|
259
|
+
| `--verbose` | off | Print the full trade sequence |
|
|
260
|
+
| `--list-bots` | — | List available bot keys and exit |
|
|
261
|
+
|
|
262
|
+
</details>
|
|
263
|
+
|
|
264
|
+
**Notes:** strict sat-level comparison is the ground truth (`--tolerance` only forgives small inversions); multi-fill orders are collapsed to a weighted-average price for the default per-order mode, so a single order's partial fills at identical prices never count as inversions.
|
|
265
|
+
|
|
222
266
|
## Charts & Visualization
|
|
223
267
|
|
|
224
268
|
### Trade Heatmap (`analyze_trade_heatmap.ts`)
|
|
@@ -445,6 +489,7 @@ These npm scripts wrap common analysis runners:
|
|
|
445
489
|
|--------|---------|
|
|
446
490
|
| `npm run analysis:tradingview` | `node dist/analysis/tradingview/analyze_tradingview.js` |
|
|
447
491
|
| `npm run analysis:trade-pnl` | `node dist/analysis/trade_profitability.js` |
|
|
492
|
+
| `npm run analysis:grid-check` | `node dist/analysis/grid_correction_check.js` |
|
|
448
493
|
| `npm run analysis:derivatives` | `node dist/analysis/analyze_derivatives.js` (legacy SMA/MACD/RSI layer, reference only) |
|
|
449
494
|
| `npm run ama:chart:lp-local` | `node dist/analysis/ama_fitting/generate_unified_comparison_chart.js` (chart also auto-generated by optimizer) |
|
|
450
495
|
|
|
@@ -457,6 +502,9 @@ npm run analysis:tradingview -- --source market_adapter --bot-key <bot-key>
|
|
|
457
502
|
# Trade PnL
|
|
458
503
|
npm run analysis:trade-pnl -- 1.2.123456 --hours 720
|
|
459
504
|
|
|
505
|
+
# Grid correction check (monotonicity regression gate)
|
|
506
|
+
npm run analysis:grid-check -- --bot-key <bot-key> --hours 168
|
|
507
|
+
|
|
460
508
|
# File-based
|
|
461
509
|
npm run analysis:tradingview -- --file market_adapter/data/market_adapter_<bot-key>_1h.json
|
|
462
510
|
npm run ama:chart:lp-local -- --data market_adapter/data/lp/<pair>/lp_pool_<id>_<interval>.json
|
|
@@ -465,4 +513,5 @@ npm run ama:chart:lp-local -- --data market_adapter/data/lp/<pair>/lp_pool_<id>_
|
|
|
465
513
|
## Related Docs
|
|
466
514
|
|
|
467
515
|
- [Market Adapter](../market_adapter/README.md) — live AMA pricing, grid triggers, dynamic weights, and recalc triggers
|
|
516
|
+
- [Consolidated Orphan-Fix Summary](../docs/CONSOLIDATED_ORPHAN_FIX_SUMMARY.md) — orphan/gap-band root-cause plans; `grid_correction_check` is their regression gate
|
|
468
517
|
- [DEXBot2 Tuning Cheat Sheet](../claw/docs/DEXBOT2_TUNING_CHEAT_SHEET.md) — grid tuning reference for live bots
|