dexbot 1.4.20 → 1.4.21
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 +23 -0
- package/README.md +22 -12
- package/analysis/ama_fitting/calibrate_convergence_er.ts +1 -1
- package/analysis/ama_fitting/package.json +1 -1
- package/analysis/bot_fitting/shared_utils.ts +1 -1
- package/analysis/bot_key_utils.ts +1 -5
- package/analysis/bot_usage/kibana_bot_queries.ts +1 -256
- package/analysis/chart_css.ts +1 -1
- package/analysis/math_utils.ts +1 -8
- package/analysis/trend_detection/package.json +1 -1
- package/claw/ecosystem.config.cjs +2 -3
- package/claw/examples/memu_integration_example.ts +17 -17
- package/claw/modules/chain_actions.ts +51 -54
- package/claw/modules/chain_broadcast.ts +66 -104
- package/claw/modules/claw_bridge.ts +60 -80
- package/claw/modules/claw_catalog.ts +47 -16
- package/claw/modules/claw_infra.ts +1 -5
- package/claw/modules/claw_launcher.ts +47 -49
- package/claw/modules/claw_skill_md.ts +8 -11
- package/claw/modules/credit_runtime_adapter.ts +2 -18
- package/claw/modules/decision_loop.ts +4 -0
- package/claw/modules/dexbot_bridge.ts +1 -1
- package/claw/modules/dexbot_profiles.ts +5 -21
- package/claw/modules/honest_ecosystem.ts +24 -8
- package/claw/modules/liquidity_pools.ts +10 -3
- package/claw/modules/mcp_utils.ts +109 -0
- package/claw/modules/memu_bridge.ts +76 -54
- package/claw/modules/mpa_utils.ts +26 -3
- package/claw/modules/position_discovery.ts +16 -27
- package/claw/modules/position_manager.ts +32 -41
- package/claw/modules/position_manager_watch.ts +3 -2
- package/claw/modules/short_mpa_strategy.ts +1 -9
- package/claw/modules/skill_utils.ts +5 -3
- package/claw/modules/utils.ts +9 -1
- package/claw/package.json +1 -1
- package/claw/runtimes/openclaw-plugin/index.ts +27 -10
- package/claw/runtimes/openclaw-plugin/openclaw.plugin.json +1 -1
- package/claw/runtimes/openclaw-plugin/package.json +1 -1
- package/claw/scripts/claw_bridge.ts +1 -1
- package/claw/scripts/claw_mcp_server.ts +19 -78
- package/claw/scripts/honest_assets_report.ts +19 -84
- package/claw/scripts/memu_mcp_server.ts +57 -155
- package/claw/tests/test_claw_bridge.ts +6 -2
- package/claw/tests/test_claw_mcp_transport.ts +2 -2
- package/dist/analysis/ama_fitting/calibrate_convergence_er.js +1 -1
- package/dist/analysis/ama_fitting/calibrate_convergence_er.js.map +1 -1
- package/dist/analysis/bot_fitting/shared_utils.d.ts +1 -12
- package/dist/analysis/bot_fitting/shared_utils.d.ts.map +1 -1
- package/dist/analysis/bot_fitting/shared_utils.js +1 -1
- package/dist/analysis/bot_fitting/shared_utils.js.map +1 -1
- package/dist/analysis/bot_key_utils.d.ts +1 -1
- package/dist/analysis/bot_key_utils.d.ts.map +1 -1
- package/dist/analysis/bot_key_utils.js +1 -5
- package/dist/analysis/bot_key_utils.js.map +1 -1
- package/dist/analysis/bot_usage/kibana_bot_queries.d.ts +1 -337
- package/dist/analysis/bot_usage/kibana_bot_queries.d.ts.map +1 -1
- package/dist/analysis/bot_usage/kibana_bot_queries.js +1 -241
- package/dist/analysis/bot_usage/kibana_bot_queries.js.map +1 -1
- package/dist/analysis/chart_css.d.ts +1 -15
- package/dist/analysis/chart_css.d.ts.map +1 -1
- package/dist/analysis/chart_css.js +1 -1
- package/dist/analysis/chart_css.js.map +1 -1
- package/dist/analysis/math_utils.d.ts +3 -5
- package/dist/analysis/math_utils.d.ts.map +1 -1
- package/dist/analysis/math_utils.js +3 -5
- package/dist/analysis/math_utils.js.map +1 -1
- package/dist/bot.js +2 -2
- package/dist/bot.js.map +1 -1
- package/dist/credential-daemon.js +1 -1
- package/dist/credential-daemon.js.map +1 -1
- package/dist/dexbot.d.ts.map +1 -1
- package/dist/dexbot.js +18 -14
- package/dist/dexbot.js.map +1 -1
- package/dist/market_adapter/ama_signal_runner.js +3 -3
- package/dist/market_adapter/core/kibana_client.d.ts +1 -3
- package/dist/market_adapter/core/kibana_client.d.ts.map +1 -1
- package/dist/market_adapter/core/kibana_client.js +1 -1
- package/dist/market_adapter/core/kibana_client.js.map +1 -1
- package/dist/market_adapter/core/market_adapter_service.d.ts +1 -2
- package/dist/market_adapter/core/market_adapter_service.d.ts.map +1 -1
- package/dist/market_adapter/core/market_adapter_service.js +1 -1
- package/dist/market_adapter/core/market_adapter_service.js.map +1 -1
- package/dist/market_adapter/core/strategies/regime_gate.d.ts +1 -2
- package/dist/market_adapter/core/strategies/regime_gate.d.ts.map +1 -1
- package/dist/market_adapter/core/strategies/regime_gate.js +1 -1
- package/dist/market_adapter/core/strategies/regime_gate.js.map +1 -1
- package/dist/market_adapter/inputs/fetch_cex_synthetic_data.js +2 -2
- package/dist/market_adapter/inputs/fetch_cex_synthetic_data.js.map +1 -1
- package/dist/market_adapter/inputs/fetch_lp_data.d.ts +5 -5
- package/dist/market_adapter/inputs/fetch_lp_data.js +5 -5
- package/dist/market_adapter/inputs/kibana_source.d.ts +1 -2
- package/dist/market_adapter/inputs/kibana_source.d.ts.map +1 -1
- package/dist/market_adapter/inputs/kibana_source.js +1 -1
- package/dist/market_adapter/inputs/kibana_source.js.map +1 -1
- package/dist/market_adapter/lp_chart_strategy_loader.d.ts +1 -2
- package/dist/market_adapter/lp_chart_strategy_loader.d.ts.map +1 -1
- package/dist/market_adapter/lp_chart_strategy_loader.js +4 -4
- package/dist/market_adapter/lp_chart_strategy_loader.js.map +1 -1
- package/dist/market_adapter/market_adapter.d.ts.map +1 -1
- package/dist/market_adapter/market_adapter.js +2 -1
- package/dist/market_adapter/market_adapter.js.map +1 -1
- package/dist/modules/account_bots.d.ts +3 -0
- package/dist/modules/account_bots.d.ts.map +1 -1
- package/dist/modules/account_bots.js +156 -46
- package/dist/modules/account_bots.js.map +1 -1
- package/dist/modules/account_orders.d.ts +1 -7
- package/dist/modules/account_orders.d.ts.map +1 -1
- package/dist/modules/account_orders.js +9 -17
- package/dist/modules/account_orders.js.map +1 -1
- package/dist/modules/bitshares_client.d.ts +2 -14
- package/dist/modules/bitshares_client.d.ts.map +1 -1
- package/dist/modules/bitshares_client.js +22 -31
- package/dist/modules/bitshares_client.js.map +1 -1
- package/dist/modules/bot_settings.js +1 -1
- package/dist/modules/bot_settings.js.map +1 -1
- package/dist/modules/chain_keys.js +2 -2
- package/dist/modules/chain_keys.js.map +1 -1
- package/dist/modules/chain_orders.d.ts +2 -3
- package/dist/modules/chain_orders.d.ts.map +1 -1
- package/dist/modules/chain_orders.js +8 -25
- package/dist/modules/chain_orders.js.map +1 -1
- package/dist/modules/config.d.ts.map +1 -1
- package/dist/modules/config.js +4 -1
- package/dist/modules/config.js.map +1 -1
- package/dist/modules/constants.d.ts +0 -1
- package/dist/modules/constants.d.ts.map +1 -1
- package/dist/modules/constants.js +0 -4
- package/dist/modules/constants.js.map +1 -1
- package/dist/modules/credential_policy.js +1 -1
- package/dist/modules/credential_policy.js.map +1 -1
- package/dist/modules/dexbot_class.d.ts.map +1 -1
- package/dist/modules/dexbot_class.js +3 -2
- package/dist/modules/dexbot_class.js.map +1 -1
- package/dist/modules/dexbot_state_recovery.d.ts.map +1 -1
- package/dist/modules/dexbot_state_recovery.js +2 -1
- package/dist/modules/dexbot_state_recovery.js.map +1 -1
- package/dist/modules/fund_registry.d.ts.map +1 -1
- package/dist/modules/fund_registry.js +5 -2
- package/dist/modules/fund_registry.js.map +1 -1
- package/dist/modules/launcher/bot_supervisor.d.ts.map +1 -1
- package/dist/modules/launcher/bot_supervisor.js +6 -7
- package/dist/modules/launcher/bot_supervisor.js.map +1 -1
- package/dist/modules/launcher/foreign_cred_daemon.d.ts.map +1 -1
- package/dist/modules/launcher/foreign_cred_daemon.js +6 -0
- package/dist/modules/launcher/foreign_cred_daemon.js.map +1 -1
- package/dist/modules/launcher/market_adapter_runtime.d.ts +2 -3
- package/dist/modules/launcher/market_adapter_runtime.d.ts.map +1 -1
- package/dist/modules/launcher/market_adapter_runtime.js +7 -15
- package/dist/modules/launcher/market_adapter_runtime.js.map +1 -1
- package/dist/modules/launcher/monolithic_runtime.d.ts.map +1 -1
- package/dist/modules/launcher/monolithic_runtime.js +1 -0
- package/dist/modules/launcher/monolithic_runtime.js.map +1 -1
- package/dist/modules/launcher/status_reporting.d.ts +1 -2
- package/dist/modules/launcher/status_reporting.d.ts.map +1 -1
- package/dist/modules/launcher/status_reporting.js +1 -4
- package/dist/modules/launcher/status_reporting.js.map +1 -1
- package/dist/modules/order/accounting.js +2 -2
- package/dist/modules/order/accounting.js.map +1 -1
- package/dist/modules/order/format.d.ts +0 -8
- package/dist/modules/order/format.d.ts.map +1 -1
- package/dist/modules/order/format.js +0 -8
- package/dist/modules/order/format.js.map +1 -1
- package/dist/modules/order/logger.js +1 -1
- package/dist/modules/order/logger.js.map +1 -1
- package/dist/modules/order/logger_state.d.ts +1 -13
- package/dist/modules/order/logger_state.d.ts.map +1 -1
- package/dist/modules/order/logger_state.js +1 -11
- package/dist/modules/order/logger_state.js.map +1 -1
- package/dist/modules/order/processed_fill_store.d.ts +0 -5
- package/dist/modules/order/processed_fill_store.d.ts.map +1 -1
- package/dist/modules/order/processed_fill_store.js +1 -12
- package/dist/modules/order/processed_fill_store.js.map +1 -1
- package/dist/modules/order/sync_engine.d.ts.map +1 -1
- package/dist/modules/order/sync_engine.js +10 -3
- package/dist/modules/order/sync_engine.js.map +1 -1
- package/dist/modules/order/utils/math.d.ts +7 -1
- package/dist/modules/order/utils/math.d.ts.map +1 -1
- package/dist/modules/order/utils/math.js +19 -1
- package/dist/modules/order/utils/math.js.map +1 -1
- package/dist/modules/order/utils/order.d.ts.map +1 -1
- package/dist/modules/order/utils/order.js +10 -2
- package/dist/modules/order/utils/order.js.map +1 -1
- package/dist/modules/runtime_settings.js +3 -1
- package/dist/modules/runtime_settings.js.map +1 -1
- package/dist/modules/settings_merge.d.ts.map +1 -1
- package/dist/modules/settings_merge.js +3 -1
- package/dist/modules/settings_merge.js.map +1 -1
- package/dist/modules/storage/browser_adapter.d.ts +8 -3
- package/dist/modules/storage/browser_adapter.d.ts.map +1 -1
- package/dist/modules/storage/browser_adapter.js +53 -4
- package/dist/modules/storage/browser_adapter.js.map +1 -1
- package/dist/modules/utils/sanitize_key.d.ts +7 -0
- package/dist/modules/utils/sanitize_key.d.ts.map +1 -0
- package/dist/modules/utils/sanitize_key.js +15 -0
- package/dist/modules/utils/sanitize_key.js.map +1 -0
- package/dist/pm2.js +6 -6
- package/dist/pm2.js.map +1 -1
- package/dist/scripts/analyze-orders.d.ts +2 -2
- package/dist/scripts/analyze-orders.d.ts.map +1 -1
- package/dist/scripts/analyze-orders.js +4 -12
- package/dist/scripts/analyze-orders.js.map +1 -1
- package/dist/scripts/runner.js +1 -1
- package/dist/scripts/runner.js.map +1 -1
- package/dist/scripts/update.js +1 -1
- package/dist/scripts/update.js.map +1 -1
- package/docs/BITSHARES_ONBOARDING.md +63 -18
- package/docs/COPY_ON_WRITE_MASTER_PLAN.md +5 -14
- package/docs/COW_INVARIANTS.md +4 -4
- package/docs/CREDENTIAL_SECURITY.md +0 -11
- package/docs/DEXBOT_COMPARISON.md +11 -11
- package/docs/EVOLUTION.md +11 -10
- package/docs/FUND_MOVEMENT_AND_ACCOUNTING.md +27 -83
- package/docs/GRID_RECALCULATION.md +1 -13
- package/docs/GRID_RECONCILE.md +24 -24
- package/docs/LIFECYCLE.md +4 -4
- package/docs/LOGGING.md +1 -1
- package/docs/MPA_CREDIT_USAGE.md +3 -3
- package/docs/README.md +2 -2
- package/docs/WORKFLOW.md +2 -2
- package/docs/architecture.md +43 -38
- package/docs/developer_guide.md +16 -18
- package/market_adapter/README.md +0 -2
- package/modules/README.md +2 -1
- package/package.json +1 -1
- package/scripts/README.md +1 -1
- package/claw/openclaw.plugin.json +0 -13
- package/dist/market_adapter/merge_lp_data.d.ts +0 -3
- package/dist/market_adapter/merge_lp_data.d.ts.map +0 -1
- package/dist/market_adapter/merge_lp_data.js +0 -125
- package/dist/market_adapter/merge_lp_data.js.map +0 -1
- package/dist/market_adapter/utils/paths.d.ts +0 -3
- package/dist/market_adapter/utils/paths.d.ts.map +0 -1
- package/dist/market_adapter/utils/paths.js +0 -5
- package/dist/market_adapter/utils/paths.js.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,29 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
|
|
5
|
+
## [1.4.21] - 2026-08-24 - Runtime Audit Fixes, Claw Dedup Hardening, Boundary Ceiling Alignment, Editor Color Feedback
|
|
6
|
+
|
|
7
|
+
### 2026-08-23
|
|
8
|
+
|
|
9
|
+
- **Feat(ui)**: red/green highlight for botFunds percentage inputs — extend the price-multiplier live color feedback to the Funding section of the account bots editor: percentage allocations ("100%") render green while fixed absolute amounts render red, matching the existing min/maxPrice multiplier treatment. New `isPercentageString`/`colorPercentageInput` helpers mirror `isMultiplierString`/`colorMultiplierInput` (the local percentage check is stricter than `order/utils/math.ts` so partial input like "x%" never flashes green mid-typing); `askNumberOrPercentage` colors its default suffix and wires the `readInput` colorize option, and the Funding summary line renders Sell/Buy values through the same colorizer (`modules/account_bots.ts`).
|
|
10
|
+
|
|
11
|
+
### 2026-08-24
|
|
12
|
+
|
|
13
|
+
- **Fix**: correct runtime defects found in a modules-wide audit — silent-failure and initialization-order defects could disable safety checks, defeat batching, or poison configuration at load time: `accounting.ts` falls back to `GRID_LIMITS.FUND_INVARIANT_PERCENT_TOLERANCE` when unset (undefined/100 produced NaN and silently disabled the fund invariant); `processed_fill_store.ts` flushes on batch size only when configured (previous `?? 0` comparison made `size >= 0` always true, flushing every write); `sync_engine.ts` tracks per-invocation `fillGuardLowered` so inner and outer finally blocks cannot double-decrement the shared `_fillBatchInFlight` counter under concurrent batches; `bitshares_client.ts` applies the configured node list even when node management is disabled, races node refresh against the remaining wait budget so it cannot overshoot the connection timeout, preserves `lastConnectionError` across disconnects, and reuses the shared `withTimeout` util; `config.ts` `num()` returns the default on empty or non-finite values instead of 0/NaN; `settings_merge.ts` keeps the base value when a raw override for an object section is not an object instead of spreading char-indexed garbage; `fund_registry.ts` clamps `totalAllocatedPct` at zero in `releaseAllocation` and logs loudly before resetting a corrupt registry file; `account_orders.ts` warns on corrupt profile files before falling back to empty state; `credential_policy.ts` uses `Object.hasOwn` for the allowedOps lookup; `dexbot_state_recovery.ts` normalizes stale-id input through a Set; `runtime_settings.ts` warns with bot-name context when market-adapter override resolution fails (`modules/order/accounting.ts`, `modules/order/processed_fill_store.ts`, `modules/order/sync_engine.ts`, `modules/bitshares_client.ts`, `modules/config.ts`, `modules/settings_merge.ts`, `modules/fund_registry.ts`, `modules/account_orders.ts`, `modules/credential_policy.ts`, `modules/dexbot_state_recovery.ts`, `modules/runtime_settings.ts`).
|
|
14
|
+
- **Fix(grid)**: align boundary writers and add a sell-rail ceiling to the commit gate — `deriveTargetBoundary` clamped to length−1 while `calculateFundDrivenBoundary` clamped to N−gapSlots−1, so fill-driven updates could walk the boundary onto or past the SELL rail where `resolveGapBand` re-derives zero-SELL geometry permanently on every cycle. `deriveTargetBoundary` now caps at N−gapSlots−1 matching the fund-driven writer (degenerate geometries fall back to the legacy ceiling preserving the current boundary); `validateBoundaryCommit` rejects proposals past the shared writer ceiling with stable reason `sell_rail_ceiling_exceeded`; `validatePersistedBoundary` inherits the rule so loadGrid restore and `recoverFromPersistedGrid` refuse past-ceiling snapshots and fall through to clean rebuild — legacy persisted snapshots whose boundary sits past the ceiling now trigger the documented rebuild path instead of silently re-legalizing broken geometry (`modules/order/utils/order.ts`, `modules/order/utils/math.ts`, `tests/test_boundary_restore_validation.ts`).
|
|
15
|
+
- **Refactor(claw)**: dedupe shared logic, remove dead code, harden error paths — bug fixes: `position_manager` guards `syncPosition` against unresolved MPA assets and persists close events before the catch-guarded sync; `dexbot_profiles` fixes spread order in `normalizeBotEntries` so active coercion actually applies; `chain_actions.listenForFills` awaits the subscribe promise before registering callbacks so failures surface as errors instead of unhandled rejections; `memu_mcp_server` redacts malformed `--llm-profile`/`--db-config` values in parse errors (secret leak); `claw_launcher.spawnDetached()` waits one macrotask for async spawn errors instead of returning false `started:true`; `mcp_utils` treats stdin EPIPE/EIO as EOF rather than crashing mid-session and maps tools/list catalog failures to −32603; `decision_loop.resetAnalyzers` clears marketPremiums; honest-ecosystem logs live pool-reserve fetch failures and returns null for unhonorable pinned poolRefs; `position_discovery` actually resolves asset triples in parallel; `memu_bridge` adds an EPIPE guard and the openclaw plugin returns isError results. Deduplication: shared `createJsonRpcToolsHandler()`/`jsonRpcError()`, single `validateMemuCommandArgs()` spec, extracted `viaCredentialDaemon()` broadcast path, unified `computeCallOrderAmounts()` call-order math; ~25 unused exports removed across profiles/infra/launcher/ecosystem/bridge modules plus the orphan `claw/openclaw.plugin.json` stale copy (`claw/modules/*`, `claw/scripts/memu_mcp_server.ts`, `claw/openclaw.plugin.json`).
|
|
16
|
+
- **Fix(launcher)**: supervisor and runtime lifecycle corrections — `bot_supervisor.ts` enforces memory limits only for apps that define one (the previous global fallback restarted unlimited apps at MAX_MEMORY_MB) and the status banner prints real per-app limits; `foreign_cred_daemon.ts` SIGKILL path polls liveness until timeout like SIGTERM instead of a single immediate check that could race process exit; `monolithic_runtime.ts` resolves the updater close promise on spawn error (ENOENT left it pending forever and hung the update flow); `market_adapter_runtime.ts` simplifies `isLockStale` to pid-liveness semantics (the mtime branch was unreachable dead logic) (`modules/launcher/bot_supervisor.ts`, `modules/launcher/foreign_cred_daemon.ts`, `modules/launcher/monolithic_runtime.ts`, `modules/launcher/market_adapter_runtime.ts`).
|
|
17
|
+
- **Fix(storage)**: persist deletions, debounce flushes, guard ingest in the browser adapter — deleted files resurrected after reload because unlink never reached IndexedDB; writes required a manual flush call to persist at all; records mutated before the startup load cursor reached them were clobbered by stale IndexedDB state. Deletions are now tracked as tombstones replayed as IndexedDB deletes on flush (cleared only after a successful transaction, so failed flushes replay deletes on the next cycle), mutations schedule a debounced 500ms flush, and the initial load skips tombstoned and locally-mutated keys so pre-load unlinks and writes win over stored records (`modules/storage/browser_adapter.ts`).
|
|
18
|
+
- **Fix(paths)**: stop hardcoding repo-relative `profiles/*` paths in docs and user-facing messages — docs and runtime/error strings still referenced the legacy repo-relative `profiles/logs`, `profiles/bots.json`, and `profiles/keys.json` locations after state resolution moved to the PATHS resolver in v1.4.15/1.4.16, landing npm-install users on paths that do not exist. BITSHARES_ONBOARDING.md rewrites "Where are the logs?" with the resolver-aware location and completes the log-file table (dexbot-cred.log, dexbot-adapter/-error.log, market_adapter.log, dexbot-update/-error.log were undocumented); WORKFLOW.md and scripts/README.md rows corrected; key-vault/bots-not-found/watchdog/update/analyze error messages now print resolver-derived paths; CLI help documents the `<profiles>` resolution rule. No behavioral change: all file I/O already routed through the resolver (`docs/BITSHARES_ONBOARDING.md`, `docs/WORKFLOW.md`, `scripts/README.md`, `credential-daemon.ts`, `modules/chain_keys.ts`, `pm2.ts`, `bot.ts`, `claw/modules/claw_launcher.ts`, `modules/dexbot_class.ts`, `scripts/update.ts`, `dexbot.ts`).
|
|
19
|
+
- **Feat(ui)**: live green/red highlighting for price inputs in the bot editor — extends the bot-editor color feedback to the remaining price fields: startPrice and gridPrice inputs colorize live (green for dynamic sources "pool"/"book"/AMA keywords, red for fixed numeric anchors); null gridPrice resolves through startPrice so the default label inherits the matching color; Active/DryRun flags render green in their healthy state; targetSpreadPercent prompt rounds minimum/validation/input display to 2 decimals instead of surfacing 6-decimal floats (`modules/account_bots.ts`).
|
|
20
|
+
- **Fix(client)**: skip disconnect teardown when the client was never initialized — `disconnectClient()` called `ensureInitialized()`, which lazily built the whole client stack (including the node-config log) just to discard it immediately, e.g. running `dexbot bot` after an idle bot-manager session; it now returns early when not initialized (`modules/bitshares_client.ts`).
|
|
21
|
+
- **Refactor(orders)**: remove the sub-unit price nudge from `buildUpdateOrderOp` — sub-unit price changes that round to the same `min_to_receive` were nudged by one unit to force an update operation; dust orders are cancelled rather than updated now, so the nudge only produced churn broadcasts with no economic effect and masked genuine no-op skips. Unchanged rounded amount+price is treated as no-op returning null; callers count the skip and restore affected slots via `restoreSkippedUpdateSlotsInWorkingGrid` (`modules/chain_orders.ts`).
|
|
22
|
+
- **Refactor**: remove dead code and consolidate duplicated helpers across analysis/market_adapter — delete `market_adapter/merge_lp_data.ts` and `market_adapter/utils/paths.ts` (no importers); prune ~180 lines of unused query builders/wrappers from `analysis/bot_usage/kibana_bot_queries.ts`; un-export zero-consumer symbols (kibana_client INDEX/KIBANA_URL, `normalizeAmaSlopeLookbackBars`, `loadStrategiesFromResults`, kibanaSearch/bilinearInterpolate re-exports, candle high/low/ATR re-exports, internal CSS fragments, `toCandles`); add `modules/utils/sanitize_key.ts` as the single sanitizeKey source; make the candleFileForBot filename template canonical in `analysis/bot_key_utils.ts` eliminating three-way filename drift; fix stale tsx invocation comments to node dist/ paths (`market_adapter/*`, `analysis/*`, `modules/utils/sanitize_key.ts`).
|
|
23
|
+
- **Chore(logging)**: remove dead state-change history and stale docs — logger_state changeHistory/maxHistory fields were written but never read anywhere; drop them plus the phantom audit-trail doc section and the now-unused `GRID_LIMITS.STATE_CHANGE_HISTORY_MAX`; console fund-status output keeps ANSI colors while the file drain strips them as before (`modules/order/logger_state.ts`, `modules/constants.ts`, `modules/order/logger.ts`).
|
|
24
|
+
- **Refactor(ui)**: centralize bot editor ANSI colors into a shared palette — the account-bots editor scattered raw ANSI escape sequences across ~40 lines; a module-level COLORS palette (13 named entries) now routes all ~152 highlight usages, input/error/OFF highlights use bold red matching the Pair line, rendering stays byte-identical for all other colors (`modules/account_bots.ts`).
|
|
25
|
+
- **Docs**: sync tuning guidance between the root README and the BitShares onboarding tutorial — README adds weightDistribution as optional setup step 3 (super-valley..super-mountain legend vocabulary), anchors steps 1–2 on the cycle-profit formula spread − increment − fees and the increment speed/fee tradeoff, documents ama1–ama4 presets in the gridPrice row, and adds a "prefer relative values" callout with editor green/red hints; BITSHARES_ONBOARDING.md mirrors the relative-values guidance, expands its tuning list to match, and fixes the broken prerequisite anchor link (`README.md`, `docs/BITSHARES_ONBOARDING.md`).
|
|
26
|
+
- **Test**: mute intentional failure-path logs in negative-path fixtures — the run diagnostics listed scary FAILED lines that were assertion-passing fixtures exercising failure branches, making real regressions harder to spot; `test_orphan_fill_death_spiral.ts` filters its two expected underfunding warnings and `test_patch17_invariants.ts` mutes expected COW/persist ERROR logs with restore-on-finally semantics; production log wording untouched (`tests/test_orphan_fill_death_spiral.ts`, `tests/test_patch17_invariants.ts`).
|
|
27
|
+
|
|
5
28
|
## [1.4.20] - 2026-08-23 - Grid Boundary Hardening, Recovery Poison Gate, Analysis Path Centralization
|
|
6
29
|
|
|
7
30
|
### 2026-08-22
|
package/README.md
CHANGED
|
@@ -147,18 +147,26 @@ Both installs use the same CLI and store all user state — keys, `bots.json`, l
|
|
|
147
147
|
|
|
148
148
|
Keep the default settings first, and tune these:
|
|
149
149
|
|
|
150
|
-
1. **Tune `targetSpreadPercent`** — controls profit room per completed cycle
|
|
151
|
-
wider spread targets more profit per
|
|
150
|
+
1. **Tune `targetSpreadPercent`** — controls profit room per completed cycle:
|
|
151
|
+
profit ≈ `spread - increment - fees`. A wider spread targets more profit per
|
|
152
|
+
cycle but trades less often.
|
|
152
153
|
|
|
153
|
-
2. **Tune `incrementPercent`** — controls
|
|
154
|
+
2. **Tune `incrementPercent`** — controls order steps and order size. Smaller
|
|
154
155
|
increments create more grid levels and smaller orders; larger increments
|
|
155
|
-
create fewer levels and larger orders.
|
|
156
|
+
create fewer levels and larger orders. Smaller increments cycle faster —
|
|
157
|
+
higher profits, but more fees.
|
|
156
158
|
|
|
157
|
-
3. **
|
|
159
|
+
3. **Tune `weightDistribution`** (optional) — per-side sizing control. Higher
|
|
160
|
+
weight = more funds in orders near the market price; lower weight = funds
|
|
161
|
+
shifted toward the grid edge. Range `-1` (super-valley) to `2`
|
|
162
|
+
(super-mountain); the default `{ "sell": 1.0, "buy": 1.0 }` suits most
|
|
163
|
+
setups.
|
|
164
|
+
|
|
165
|
+
4. **Set `gridPrice` to `"ama"`** — so the market adapter can center the grid
|
|
158
166
|
on AMA. Pick a specific preset if desired: `"ama1"` is the fastest,
|
|
159
167
|
`"ama4"` the slowest, and `"ama"` uses the pair's default preset.
|
|
160
168
|
|
|
161
|
-
|
|
169
|
+
5. **Generate the market-adapter whitelist:**
|
|
162
170
|
|
|
163
171
|
```bash
|
|
164
172
|
dexbot white
|
|
@@ -168,9 +176,9 @@ Keep the default settings first, and tune these:
|
|
|
168
176
|
live writes and range scaling. Use `dexbot white --dynamic-weight` for
|
|
169
177
|
newly generated dynamic-weight entries; existing entries are preserved.
|
|
170
178
|
|
|
171
|
-
|
|
179
|
+
6. **Start DEXBot2** with `dexbot start`.
|
|
172
180
|
|
|
173
|
-
|
|
181
|
+
7. **Tune `minPrice` / `maxPrice`** around the market's volatility range. Once
|
|
174
182
|
AMA is active, tighten them around the maximum expected market volatility
|
|
175
183
|
instead of using an unnecessarily wide range.
|
|
176
184
|
|
|
@@ -178,6 +186,8 @@ Keep the default settings first, and tune these:
|
|
|
178
186
|
|
|
179
187
|
Configuration options from `dexbot bot`, stored in `bots.json` in the profiles directory:
|
|
180
188
|
|
|
189
|
+
> **Prefer relative values** — use dynamic price sources where available: `"pool"` (liquidity-pool price) or `"book"` (order-book mid) for `startPrice`, `"ama"` for `gridPrice`, `"2x"`-style multipliers for `minPrice` / `maxPrice`, and `"100%"`-style percentages for funds (`botFunds`). Relative values rescale automatically as the market moves; fixed numbers do not. The bot editor highlights these inputs live: **green** = relative/dynamic (recommended), **red** = fixed absolute value.
|
|
190
|
+
|
|
181
191
|
<details><summary><mark>Full parameter reference (click to expand)</mark></summary>
|
|
182
192
|
|
|
183
193
|
| Parameter | Type | Description |
|
|
@@ -192,10 +202,10 @@ Configuration options from `dexbot bot`, stored in `bots.json` in the profiles d
|
|
|
192
202
|
| **`poolRef`** | string \| null | Optional pinned pool ID for `startPrice: "pool"`. Overrides pool discovery with a direct fetch (e.g. `"1.19.48"` or `"48"`). Useful when the trading pair has no native pool. Default `null`. |
|
|
193
203
|
| **`minPrice`** | num \| str | Lower bound. Default `"2x"` means `gridPrice / 2` when AMA is active, otherwise `startPrice / 2`. |
|
|
194
204
|
| **`maxPrice`** | num \| str | Upper bound. Default `"2x"` means `gridPrice * 2` when AMA is active, otherwise `startPrice * 2`. |
|
|
195
|
-
| **`gridPrice`** | num \| str \| null | Grid reference. Use `"ama"` for the recommended AMA center; `null` falls back to `startPrice`; numeric values use that fixed value. |
|
|
196
|
-
| **`incrementPercent`** | number | Geometric step between
|
|
197
|
-
| **`targetSpreadPercent`** | number | Width of the empty spread zone between buy and sell orders. Default `2` = 2%. |
|
|
198
|
-
| **`weightDistribution`** | object | Advanced sizing control. Default `{ "sell": 1.0, "buy": 1.0 }`; leave unchanged for normal setup. |
|
|
205
|
+
| **`gridPrice`** | num \| str \| null | Grid reference. Use `"ama"` for the recommended AMA center (`"ama"` picks the pair's default preset; `"ama1"`–`"ama4"` pin fastest to slowest); `null` falls back to `startPrice`; numeric values use that fixed value. |
|
|
206
|
+
| **`incrementPercent`** | number | Geometric step between orders. Default `0.5` = 0.5%. |
|
|
207
|
+
| **`targetSpreadPercent`** | number | Width of the empty spread zone between buy and sell orders. Default `2` = 2%. Profit per completed cycle ≈ `spread - increment - fees`. |
|
|
208
|
+
| **`weightDistribution`** | object | Advanced sizing control per side. Range `-1` to `2`: `-1` = super-valley, `0` = valley, `0.5` = neutral, `1` = mountain (default), `2` = super-mountain. Higher weight = more funds in orders near the market price; lower weight = more funds shifted toward the grid edge. Default `{ "sell": 1.0, "buy": 1.0 }`; leave unchanged for normal setup. |
|
|
199
209
|
| **`botFunds`** | object | Capital: `{ "sell": "100%", "buy": 1000 }`. Numbers or percentage strings |
|
|
200
210
|
| **`activeOrders`** | object | Target active orders per side: `{ "sell": 20, "buy": 20 }` |
|
|
201
211
|
|
|
@@ -84,7 +84,7 @@ function main() {
|
|
|
84
84
|
if (e.code === 'ENOENT') {
|
|
85
85
|
console.error(`Data file not found: ${opts.data}`);
|
|
86
86
|
console.error('Export LP candles first, or point --data at an existing file.');
|
|
87
|
-
console.error('
|
|
87
|
+
console.error(' node dist/market_adapter/inputs/fetch_lp_data.js --pool 133 --precA 4 --precB 5 --interval 1h --lookback 26280h');
|
|
88
88
|
} else if (e instanceof SyntaxError) {
|
|
89
89
|
console.error(`Failed to parse JSON from: ${opts.data}`);
|
|
90
90
|
console.error(e.message);
|
|
@@ -6,6 +6,7 @@ import { getStorage } from '../modules/storage/index.js';
|
|
|
6
6
|
const { readJSON } = getStorage();
|
|
7
7
|
import { MARKET_ADAPTER } from '../modules/constants.js';
|
|
8
8
|
import { loadMarketProfiles } from './tradingview/tradingview_uplot_chart_generator.js';
|
|
9
|
+
import { sanitizeKey } from '../modules/utils/sanitize_key.js';
|
|
9
10
|
'use strict';
|
|
10
11
|
|
|
11
12
|
|
|
@@ -22,11 +23,6 @@ function loadBotSettings(filePath = PATHS.PROFILES.BOTS_JSON) {
|
|
|
22
23
|
}
|
|
23
24
|
}
|
|
24
25
|
|
|
25
|
-
function sanitizeKey(source: any) {
|
|
26
|
-
if (!source) return 'bot';
|
|
27
|
-
return String(source).trim().toLowerCase().replace(/[^a-z0-9]+/g, '-').replace(/^-+|-+$/g, '') || 'bot';
|
|
28
|
-
}
|
|
29
|
-
|
|
30
26
|
function computeBotKey(bot: any, index: number) {
|
|
31
27
|
if (bot && bot.name) {
|
|
32
28
|
return sanitizeKey(bot.name);
|
|
@@ -34,7 +34,6 @@
|
|
|
34
34
|
*/
|
|
35
35
|
|
|
36
36
|
|
|
37
|
-
import { toIntervalLabel } from '../../market_adapter/interval_utils.js';
|
|
38
37
|
import { kibanaSearch, DEFAULT_CONFIG as BASE_CONFIG } from '../../market_adapter/core/kibana_client.js';
|
|
39
38
|
'use strict';
|
|
40
39
|
|
|
@@ -49,159 +48,6 @@ const DEFAULT_CONFIG = {
|
|
|
49
48
|
timeout: 25000,
|
|
50
49
|
};
|
|
51
50
|
|
|
52
|
-
// ─── Aggregation query builders (size:0, for counts & timelines) ───────────────
|
|
53
|
-
|
|
54
|
-
/**
|
|
55
|
-
* Time-bucketed count of limit_order_create ops for an account.
|
|
56
|
-
* Optionally filtered to orders selling a specific asset.
|
|
57
|
-
*/
|
|
58
|
-
function buildOrderCreateQuery(accountId: string, lookbackHours: number, intervalSeconds: number = 3600, sellAssetId: string | null = null) {
|
|
59
|
-
const filters = [
|
|
60
|
-
{ term: { operation_type: OP_LIMIT_ORDER_CREATE } },
|
|
61
|
-
{ term: { 'operation_history.op_object.seller.keyword': accountId } },
|
|
62
|
-
{ range: { 'block_data.block_time': { gte: `now-${lookbackHours}h`, lte: 'now' } } },
|
|
63
|
-
];
|
|
64
|
-
if (sellAssetId) {
|
|
65
|
-
filters.push({ term: { 'operation_history.op_object.amount_to_sell.asset_id.keyword': sellAssetId } } as any);
|
|
66
|
-
}
|
|
67
|
-
return {
|
|
68
|
-
size: 0,
|
|
69
|
-
query: { bool: { filter: filters } },
|
|
70
|
-
aggs: {
|
|
71
|
-
by_time: {
|
|
72
|
-
date_histogram: {
|
|
73
|
-
field: 'block_data.block_time',
|
|
74
|
-
fixed_interval: toIntervalLabel(intervalSeconds),
|
|
75
|
-
min_doc_count: 1,
|
|
76
|
-
},
|
|
77
|
-
},
|
|
78
|
-
total: { value_count: { field: 'operation_type' } },
|
|
79
|
-
},
|
|
80
|
-
};
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
/**
|
|
84
|
-
* Time-bucketed count of fill_order ops for an account.
|
|
85
|
-
* Optionally filtered to fills where account pays a specific asset.
|
|
86
|
-
*/
|
|
87
|
-
function buildFillOrderQuery(accountId: string, lookbackHours: number, intervalSeconds: number = 3600, paysAssetId: string | null = null) {
|
|
88
|
-
const filters = [
|
|
89
|
-
{ term: { operation_type: OP_FILL_ORDER } },
|
|
90
|
-
{ term: { 'operation_history.op_object.account_id.keyword': accountId } },
|
|
91
|
-
{ range: { 'block_data.block_time': { gte: `now-${lookbackHours}h`, lte: 'now' } } },
|
|
92
|
-
];
|
|
93
|
-
if (paysAssetId) {
|
|
94
|
-
filters.push({ term: { 'operation_history.op_object.pays.asset_id.keyword': paysAssetId } } as any);
|
|
95
|
-
}
|
|
96
|
-
return {
|
|
97
|
-
size: 0,
|
|
98
|
-
query: { bool: { filter: filters } },
|
|
99
|
-
aggs: {
|
|
100
|
-
by_time: {
|
|
101
|
-
date_histogram: {
|
|
102
|
-
field: 'block_data.block_time',
|
|
103
|
-
fixed_interval: toIntervalLabel(intervalSeconds),
|
|
104
|
-
min_doc_count: 1,
|
|
105
|
-
},
|
|
106
|
-
},
|
|
107
|
-
total: { value_count: { field: 'operation_type' } },
|
|
108
|
-
},
|
|
109
|
-
};
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
/**
|
|
113
|
-
* Time-bucketed count of limit_order_cancel ops for an account.
|
|
114
|
-
*/
|
|
115
|
-
function buildOrderCancelQuery(accountId: string, lookbackHours: number, intervalSeconds: number = 3600) {
|
|
116
|
-
return {
|
|
117
|
-
size: 0,
|
|
118
|
-
query: {
|
|
119
|
-
bool: {
|
|
120
|
-
filter: [
|
|
121
|
-
{ term: { operation_type: OP_LIMIT_ORDER_CANCEL } },
|
|
122
|
-
{ term: { 'operation_history.op_object.fee_paying_account.keyword': accountId } },
|
|
123
|
-
{ range: { 'block_data.block_time': { gte: `now-${lookbackHours}h`, lte: 'now' } } },
|
|
124
|
-
],
|
|
125
|
-
},
|
|
126
|
-
},
|
|
127
|
-
aggs: {
|
|
128
|
-
by_time: {
|
|
129
|
-
date_histogram: {
|
|
130
|
-
field: 'block_data.block_time',
|
|
131
|
-
fixed_interval: toIntervalLabel(intervalSeconds),
|
|
132
|
-
min_doc_count: 1,
|
|
133
|
-
},
|
|
134
|
-
},
|
|
135
|
-
total: { value_count: { field: 'operation_type' } },
|
|
136
|
-
},
|
|
137
|
-
};
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
/**
|
|
141
|
-
* Daily activity breakdown by operation type for an account.
|
|
142
|
-
* Merges creates (by seller), fills (by account_id), cancels (by fee_paying_account)
|
|
143
|
-
* into one aggregation using a filter per op type.
|
|
144
|
-
*/
|
|
145
|
-
function buildDailyActivityQuery(accountId: string, lookbackHours: number) {
|
|
146
|
-
return {
|
|
147
|
-
size: 0,
|
|
148
|
-
query: {
|
|
149
|
-
bool: {
|
|
150
|
-
filter: [
|
|
151
|
-
{ range: { 'block_data.block_time': { gte: `now-${lookbackHours}h`, lte: 'now' } } },
|
|
152
|
-
],
|
|
153
|
-
},
|
|
154
|
-
},
|
|
155
|
-
aggs: {
|
|
156
|
-
creates: {
|
|
157
|
-
filter: {
|
|
158
|
-
bool: {
|
|
159
|
-
filter: [
|
|
160
|
-
{ term: { operation_type: OP_LIMIT_ORDER_CREATE } },
|
|
161
|
-
{ term: { 'operation_history.op_object.seller.keyword': accountId } },
|
|
162
|
-
],
|
|
163
|
-
},
|
|
164
|
-
},
|
|
165
|
-
aggs: {
|
|
166
|
-
by_day: {
|
|
167
|
-
date_histogram: { field: 'block_data.block_time', fixed_interval: '1d', min_doc_count: 1 },
|
|
168
|
-
},
|
|
169
|
-
},
|
|
170
|
-
},
|
|
171
|
-
fills: {
|
|
172
|
-
filter: {
|
|
173
|
-
bool: {
|
|
174
|
-
filter: [
|
|
175
|
-
{ term: { operation_type: OP_FILL_ORDER } },
|
|
176
|
-
{ term: { 'operation_history.op_object.account_id.keyword': accountId } },
|
|
177
|
-
],
|
|
178
|
-
},
|
|
179
|
-
},
|
|
180
|
-
aggs: {
|
|
181
|
-
by_day: {
|
|
182
|
-
date_histogram: { field: 'block_data.block_time', fixed_interval: '1d', min_doc_count: 1 },
|
|
183
|
-
},
|
|
184
|
-
},
|
|
185
|
-
},
|
|
186
|
-
cancels: {
|
|
187
|
-
filter: {
|
|
188
|
-
bool: {
|
|
189
|
-
filter: [
|
|
190
|
-
{ term: { operation_type: OP_LIMIT_ORDER_CANCEL } },
|
|
191
|
-
{ term: { 'operation_history.op_object.fee_paying_account.keyword': accountId } },
|
|
192
|
-
],
|
|
193
|
-
},
|
|
194
|
-
},
|
|
195
|
-
aggs: {
|
|
196
|
-
by_day: {
|
|
197
|
-
date_histogram: { field: 'block_data.block_time', fixed_interval: '1d', min_doc_count: 1 },
|
|
198
|
-
},
|
|
199
|
-
},
|
|
200
|
-
},
|
|
201
|
-
},
|
|
202
|
-
};
|
|
203
|
-
}
|
|
204
|
-
|
|
205
51
|
// ─── Raw document query builders (size>0, for price/grid analysis) ────────────
|
|
206
52
|
|
|
207
53
|
/**
|
|
@@ -236,107 +82,6 @@ function buildOrderPriceQuery(accountId: string, lookbackHours: number, sellAsse
|
|
|
236
82
|
};
|
|
237
83
|
}
|
|
238
84
|
|
|
239
|
-
/**
|
|
240
|
-
* Fetch raw fill_order documents for fill-price analysis.
|
|
241
|
-
*
|
|
242
|
-
* @param {string} accountId
|
|
243
|
-
* @param {number} lookbackHours
|
|
244
|
-
* @param {string} [paysAssetId]
|
|
245
|
-
* @param {number} [maxResults]
|
|
246
|
-
* @returns {Object} Elasticsearch query object
|
|
247
|
-
*/
|
|
248
|
-
function buildFillPriceQuery(accountId: string, lookbackHours: number, paysAssetId: string | null = null, maxResults: number = 500) {
|
|
249
|
-
const filters = [
|
|
250
|
-
{ term: { operation_type: OP_FILL_ORDER } },
|
|
251
|
-
{ term: { 'operation_history.op_object.account_id.keyword': accountId } },
|
|
252
|
-
{ range: { 'block_data.block_time': { gte: `now-${lookbackHours}h`, lte: 'now' } } },
|
|
253
|
-
];
|
|
254
|
-
if (paysAssetId) {
|
|
255
|
-
filters.push({ term: { 'operation_history.op_object.pays.asset_id.keyword': paysAssetId } } as any);
|
|
256
|
-
}
|
|
257
|
-
return {
|
|
258
|
-
size: maxResults,
|
|
259
|
-
_source: [
|
|
260
|
-
'block_data.block_time',
|
|
261
|
-
'operation_history.op_object.pays',
|
|
262
|
-
'operation_history.op_object.receives',
|
|
263
|
-
'operation_history.op_object.order_id',
|
|
264
|
-
],
|
|
265
|
-
query: { bool: { filter: filters } },
|
|
266
|
-
sort: [{ 'block_data.block_time': { order: 'desc' } }],
|
|
267
|
-
};
|
|
268
|
-
}
|
|
269
|
-
|
|
270
|
-
/**
|
|
271
|
-
* Discover which asset pairs an account trades by aggregating the sell asset IDs.
|
|
272
|
-
* Returns top asset IDs by order count.
|
|
273
|
-
*/
|
|
274
|
-
function buildAssetDiscoveryQuery(accountId: string, lookbackHours: number) {
|
|
275
|
-
return {
|
|
276
|
-
size: 0,
|
|
277
|
-
query: {
|
|
278
|
-
bool: {
|
|
279
|
-
filter: [
|
|
280
|
-
{ term: { operation_type: OP_LIMIT_ORDER_CREATE } },
|
|
281
|
-
{ term: { 'operation_history.op_object.seller.keyword': accountId } },
|
|
282
|
-
{ range: { 'block_data.block_time': { gte: `now-${lookbackHours}h`, lte: 'now' } } },
|
|
283
|
-
],
|
|
284
|
-
},
|
|
285
|
-
},
|
|
286
|
-
aggs: {
|
|
287
|
-
sell_assets: {
|
|
288
|
-
terms: {
|
|
289
|
-
field: 'operation_history.op_object.amount_to_sell.asset_id.keyword',
|
|
290
|
-
size: 10,
|
|
291
|
-
},
|
|
292
|
-
},
|
|
293
|
-
recv_assets: {
|
|
294
|
-
terms: {
|
|
295
|
-
field: 'operation_history.op_object.min_to_receive.asset_id.keyword',
|
|
296
|
-
size: 10,
|
|
297
|
-
},
|
|
298
|
-
},
|
|
299
|
-
},
|
|
300
|
-
};
|
|
301
|
-
}
|
|
302
|
-
|
|
303
|
-
// ─── Fetch helpers ────────────────────────────────────────────────────────────
|
|
304
|
-
|
|
305
|
-
async function fetchOrderCreate(accountId: string, lookbackHours: number, config: any = {}, sellAssetId: string | null = null, intervalSeconds: number = 3600) {
|
|
306
|
-
const cfg = { ...DEFAULT_CONFIG, ...config };
|
|
307
|
-
return kibanaSearch(cfg, buildOrderCreateQuery(accountId, lookbackHours, intervalSeconds, sellAssetId));
|
|
308
|
-
}
|
|
309
|
-
|
|
310
|
-
async function fetchFillOrder(accountId: string, lookbackHours: number, config: any = {}, paysAssetId: string | null = null, intervalSeconds: number = 3600) {
|
|
311
|
-
const cfg = { ...DEFAULT_CONFIG, ...config };
|
|
312
|
-
return kibanaSearch(cfg, buildFillOrderQuery(accountId, lookbackHours, intervalSeconds, paysAssetId));
|
|
313
|
-
}
|
|
314
|
-
|
|
315
|
-
async function fetchOrderCancel(accountId: string, lookbackHours: number, config: any = {}, intervalSeconds: number = 3600) {
|
|
316
|
-
const cfg = { ...DEFAULT_CONFIG, ...config };
|
|
317
|
-
return kibanaSearch(cfg, buildOrderCancelQuery(accountId, lookbackHours, intervalSeconds));
|
|
318
|
-
}
|
|
319
|
-
|
|
320
|
-
async function fetchOrderPrices(accountId: string, lookbackHours: number, config: any = {}, sellAssetId: string | null = null, maxResults: number = 1000) {
|
|
321
|
-
const cfg = { ...DEFAULT_CONFIG, ...config };
|
|
322
|
-
return kibanaSearch(cfg, buildOrderPriceQuery(accountId, lookbackHours, sellAssetId, maxResults));
|
|
323
|
-
}
|
|
324
|
-
|
|
325
|
-
async function fetchFillPrices(accountId: string, lookbackHours: number, config: any = {}, paysAssetId: string | null = null, maxResults: number = 500) {
|
|
326
|
-
const cfg = { ...DEFAULT_CONFIG, ...config };
|
|
327
|
-
return kibanaSearch(cfg, buildFillPriceQuery(accountId, lookbackHours, paysAssetId, maxResults));
|
|
328
|
-
}
|
|
329
|
-
|
|
330
|
-
async function fetchDailyActivity(accountId: string, lookbackHours: number, config: any = {}) {
|
|
331
|
-
const cfg = { ...DEFAULT_CONFIG, ...config };
|
|
332
|
-
return kibanaSearch(cfg, buildDailyActivityQuery(accountId, lookbackHours));
|
|
333
|
-
}
|
|
334
|
-
|
|
335
|
-
async function fetchAssetDiscovery(accountId: string, lookbackHours: number, config: any = {}) {
|
|
336
|
-
const cfg = { ...DEFAULT_CONFIG, ...config };
|
|
337
|
-
return kibanaSearch(cfg, buildAssetDiscoveryQuery(accountId, lookbackHours));
|
|
338
|
-
}
|
|
339
|
-
|
|
340
85
|
// ─── Discovery query builders ─────────────────────────────────────────────────
|
|
341
86
|
|
|
342
87
|
/**
|
|
@@ -423,5 +168,5 @@ function buildTopFilledAccountsQuery(lookbackHours: number, topN: number = 100,
|
|
|
423
168
|
|
|
424
169
|
// ─── Exports ──────────────────────────────────────────────────────────────────
|
|
425
170
|
|
|
426
|
-
export {
|
|
171
|
+
export { DEFAULT_CONFIG, kibanaSearch, buildOrderPriceQuery, buildTopSellerAccountsQuery, buildTopCancellerAccountsQuery, buildTopFilledAccountsQuery }
|
|
427
172
|
|
package/analysis/chart_css.ts
CHANGED
package/analysis/math_utils.ts
CHANGED
|
@@ -5,19 +5,15 @@ import { getStorage } from '../modules/storage/index.js';
|
|
|
5
5
|
const { readJSON } = getStorage();
|
|
6
6
|
import {
|
|
7
7
|
getCandleClose,
|
|
8
|
-
getCandleHigh,
|
|
9
|
-
getCandleLow,
|
|
10
8
|
getCandleTimestamp,
|
|
11
9
|
normalizeCandle,
|
|
12
10
|
} from '../market_adapter/candle_utils.js';
|
|
13
|
-
import { computeATRSeries } from '../market_adapter/core/strategies/atr/calculator.js';
|
|
14
11
|
|
|
15
12
|
|
|
16
13
|
/**
|
|
17
14
|
* Math utilities for analysis scripts.
|
|
18
15
|
*
|
|
19
|
-
* Candle accessors
|
|
20
|
-
* market_adapter (candle_utils.ts / strategies/atr/calculator.ts) and
|
|
16
|
+
* Candle accessors are centralized in market_adapter (candle_utils.ts) and
|
|
21
17
|
* re-exported here so analysis tooling shares one logic path with the
|
|
22
18
|
* live adapter and the browser-embedded chart scripts.
|
|
23
19
|
*/
|
|
@@ -50,10 +46,7 @@ function loadCandleFile(filePath: any) {
|
|
|
50
46
|
export {
|
|
51
47
|
range,
|
|
52
48
|
calcStdDev,
|
|
53
|
-
computeATRSeries,
|
|
54
49
|
getCandleClose,
|
|
55
|
-
getCandleHigh,
|
|
56
|
-
getCandleLow,
|
|
57
50
|
getCandleTimestamp,
|
|
58
51
|
normalizeCandle,
|
|
59
52
|
loadCandleFile,
|
|
@@ -2,9 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
const path = require('node:path');
|
|
4
4
|
|
|
5
|
-
//
|
|
6
|
-
//
|
|
7
|
-
// layout so `pm2 start ecosystem.config.cjs` works from the claw/ package root.
|
|
5
|
+
// This ecosystem config anchors all paths to the dist/claw build output so
|
|
6
|
+
// `pm2 start ecosystem.config.cjs` works from the claw/ package root.
|
|
8
7
|
const DIST_CLAW = path.join(__dirname, '..', 'dist', 'claw');
|
|
9
8
|
|
|
10
9
|
module.exports = {
|
|
@@ -6,26 +6,26 @@ const { createMemuBridge } = require('../modules/memu_bridge');
|
|
|
6
6
|
async function main() {
|
|
7
7
|
console.log('=== memU + DEXBot2 Integration Example ===\n');
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
9
|
+
try {
|
|
10
|
+
const memu = createMemuBridge({
|
|
11
|
+
memuDir: process.env.MEMU_DIR || undefined,
|
|
12
|
+
llmProfiles: process.env.OPENAI_API_KEY
|
|
13
|
+
? {
|
|
14
|
+
default: {
|
|
15
|
+
base_url: process.env.OPENAI_BASE_URL || 'https://api.openai.com/v1',
|
|
16
|
+
api_key: process.env.OPENAI_API_KEY,
|
|
17
|
+
chat_model: process.env.OPENAI_CHAT_MODEL || 'gpt-4o',
|
|
18
|
+
embed_model: process.env.OPENAI_EMBED_MODEL || 'text-embedding-3-small',
|
|
19
|
+
client_backend: 'sdk'
|
|
20
|
+
}
|
|
19
21
|
}
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
});
|
|
22
|
+
: undefined
|
|
23
|
+
});
|
|
23
24
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
25
|
+
console.log('memU bridge created');
|
|
26
|
+
console.log(` memuDir: ${memu.memuDir}`);
|
|
27
|
+
console.log(` stateDir: ${memu.stateDir}\n`);
|
|
27
28
|
|
|
28
|
-
try {
|
|
29
29
|
console.log('--- Step 1: Check memU status ---');
|
|
30
30
|
const status = await memu.getStatus();
|
|
31
31
|
console.log('Status:', JSON.stringify(status, null, 2));
|