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/docs/LOGGING.md
CHANGED
|
@@ -309,7 +309,7 @@ Yes — each bot entry in `profiles/bots.json` accepts an optional `logging` fie
|
|
|
309
309
|
}
|
|
310
310
|
```
|
|
311
311
|
|
|
312
|
-
The per-bot `logging` is deep-merged on top of the global config from `general.settings.json`. See `modules/
|
|
312
|
+
The per-bot `logging` is deep-merged on top of the global config from `general.settings.json`. See `modules/runtime_settings.ts` for the merge logic and `modules/order/manager.ts` for where the merged config reaches the logger.
|
|
313
313
|
|
|
314
314
|
**Q: What about PM2?**
|
|
315
315
|
The logger auto-detects PM2 and suppresses file writes (PM2 captures stdout/stderr). File rotation is also suppressed under PM2.
|
package/docs/MPA_CREDIT_USAGE.md
CHANGED
|
@@ -233,7 +233,7 @@ When `maxBorrowAmountPerOperation` is set, each credit-maintenance cycle runs `_
|
|
|
233
233
|
|
|
234
234
|
- Discovers deals whose `debtAmount` exceeds `maxBorrowAmountPerOperation`.
|
|
235
235
|
- Splits each oversized deal into `ceil(debt / maxPerOp)` equal pieces via atomic repay+reborrow transactions. Total debt across the new deals is preserved; only deal granularity changes.
|
|
236
|
-
- Skips a deal if any piece would fall below the offer's `min_deal_amount` (
|
|
236
|
+
- Skips a deal if any piece would fall below the offer's `min_deal_amount` (offers are cached with a 10-minute TTL — `TIMING.OFFER_CACHE_TTL_MS` — so on-chain `min_deal_amount` changes are picked up on the next re-fetch).
|
|
237
237
|
- Pauses `BLOCKCHAIN_SETTLE_DELAY_MS` between pieces; aborts on shutdown.
|
|
238
238
|
- Stops once `CREDIT_DEAL_SPLIT_MAX_PIECES` pieces have been emitted in the current cycle. Remaining oversized deals are deferred to the next maintenance cycle.
|
|
239
239
|
- Uses an in-process `_splitInFlight` guard so `runMaintenance` and `runCreditWatchdog` cannot start overlapping splits.
|
|
@@ -342,12 +342,12 @@ Treat this file as runtime state, not primary configuration. The source of truth
|
|
|
342
342
|
|
|
343
343
|
- `modules/credit_runtime.ts`: debt workflow executor (Phase 0 oversized-deal splitter lives here)
|
|
344
344
|
- `modules/cr_planner.ts`: MPA debt-first planner; clamps `debtDelta` by `maxBorrowAmountPerOperation`
|
|
345
|
-
- `modules/
|
|
345
|
+
- `modules/cr_planner.ts`: `DebtFirstCrPlanOptions` — planner options carrying `maxBorrowAmountPerOperation`; lending-item shapes are validated inline in `bot_settings.ts`
|
|
346
346
|
- `modules/dexbot_class.ts`: runtime startup and watchdog lifecycle
|
|
347
347
|
- `modules/bot_settings.ts`: `debtPolicy` validation
|
|
348
348
|
- `market_adapter/README.md`: AMA pricing, grid triggers, and dynamic-weight runtime
|
|
349
349
|
- `modules/credential_policy.ts`: signing constraints for credit and call-order operations
|
|
350
|
-
- `tests/test_credit_runtime.ts`: credit runtime behavior coverage (including
|
|
350
|
+
- `tests/test_credit_runtime.ts`: credit runtime behavior coverage (including 3 oversized-deal splitter tests)
|
|
351
351
|
- `tests/test_multi_asset_distribution.ts`: collateral distribution and multi-asset state coverage
|
|
352
352
|
|
|
353
353
|
</details>
|
package/docs/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
This directory contains the comprehensive technical documentation for the DEXBot2 trading bot. It is designed to guide developers from high-level architecture down to the nuances of fund accounting and state management.
|
|
4
4
|
|
|
5
|
-
**Version context:** v1.4.
|
|
5
|
+
**Version context:** v1.4.21 (released).
|
|
6
6
|
|
|
7
7
|
---
|
|
8
8
|
|
|
@@ -144,7 +144,7 @@ This directory contains the comprehensive technical documentation for the DEXBot
|
|
|
144
144
|
|
|
145
145
|
### 🧭 [Evolution Report](EVOLUTION.md)
|
|
146
146
|
*Project timeline and major architecture phases.*
|
|
147
|
-
- **Coverage**: Historical milestones from the initial December 2025 bootstrap through the v1.4.
|
|
147
|
+
- **Coverage**: Historical milestones from the initial December 2025 bootstrap through the v1.4.21 stable release (grid persistence safety, dust pipeline fix, net inventory lots); credit/debt runtime and maintenance hardening are covered under Phase 5 (Mar–Jun 2026)
|
|
148
148
|
- **Focus**: Architecture evolution, release history, test growth, and documentation changes
|
|
149
149
|
|
|
150
150
|
### 🗒️ [Changelog](../CHANGELOG.md)
|
package/docs/WORKFLOW.md
CHANGED
|
@@ -211,7 +211,7 @@ recommended mode:
|
|
|
211
211
|
- **Single process** — no PM2, no separate credential daemon management
|
|
212
212
|
- **Auto-update** — detects new releases, builds, and restarts cleanly
|
|
213
213
|
- **Crash restart** — background mode re-spawns on failure
|
|
214
|
-
- **Per-bot log files** — each bot logs to
|
|
214
|
+
- **Per-bot log files** — each bot logs to `<profiles>/logs/<bot>.log` (`~/.config/dexbot2/profiles/logs` by default)
|
|
215
215
|
- **Built-in daemon** — the credential daemon is managed internally
|
|
216
216
|
|
|
217
217
|
Legacy PM2 mode (`npm run pm2:unlock`) is de-emphasized but still available.
|
|
@@ -257,7 +257,7 @@ the canonical name is preferred in scripts and docs.
|
|
|
257
257
|
| `dexbot restart` | `restartall` | Restart the monolithic runtime (unlock mode) |
|
|
258
258
|
| `dexbot delete` | — | Shut down and clean up the monolithic runtime (unlock mode) |
|
|
259
259
|
| `dexbot whitelist` | `white` | Generate market adapter whitelist from AMA bot configs |
|
|
260
|
-
| `dexbot clear` | — | Remove all log files from
|
|
260
|
+
| `dexbot clear` | — | Remove all log files from the logs directory (`<profiles>/logs`) |
|
|
261
261
|
|
|
262
262
|
## NPM Scripts for Branch Synchronization
|
|
263
263
|
|
package/docs/architecture.md
CHANGED
|
@@ -548,12 +548,11 @@ The simplified approach prioritizes fund availability over aggressive correction
|
|
|
548
548
|
Spread corrections respect these hard limits:
|
|
549
549
|
|
|
550
550
|
```javascript
|
|
551
|
-
// In modules/constants.ts
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
}
|
|
551
|
+
// In modules/constants.ts (GRID_LIMITS)
|
|
552
|
+
MIN_SPREAD_ORDERS: 2, // Always maintain minimum gap
|
|
553
|
+
|
|
554
|
+
// Spread width itself stays user-configured (`targetSpreadPercent`) — fixed, no inflation.
|
|
555
|
+
// Correction count has no separate slot cap; it is bounded by the funds check below.
|
|
557
556
|
|
|
558
557
|
// Each correction order must be healthy
|
|
559
558
|
const minHealthySize = calculateMinOrderSize(side);
|
|
@@ -590,28 +589,31 @@ BLOCKCHAIN_FETCH_INTERVAL_MIN: 240, // 4 hours = 240 minutes
|
|
|
590
589
|
|
|
591
590
|
### Implementation Flow
|
|
592
591
|
|
|
592
|
+
**1. Interval startup** — `setupBlockchainFetchInterval()` in
|
|
593
|
+
`modules/dexbot_maintenance_runtime.ts` starts the interval during bot initialization:
|
|
594
|
+
|
|
593
595
|
```javascript
|
|
594
|
-
|
|
595
|
-
this.periodicRefreshTimer = setInterval(
|
|
596
|
-
() => this._performPeriodicRefresh(),
|
|
597
|
-
BLOCKCHAIN_FETCH_INTERVAL_MIN * 60 * 1000
|
|
598
|
-
);
|
|
599
|
-
|
|
600
|
-
// 2. When timer fires:
|
|
601
|
-
async _performPeriodicRefresh() {
|
|
602
|
-
// Fetch latest market price
|
|
603
|
-
const latestPrice = await derivePrice('book'); // Or 'pool'
|
|
604
|
-
|
|
605
|
-
// Update internal anchor if using dynamic pricing
|
|
606
|
-
if (config.startPrice === 'book' || config.startPrice === 'pool') {
|
|
607
|
-
this.manager.startPrice = latestPrice;
|
|
608
|
-
}
|
|
609
|
-
|
|
610
|
-
// Grid remains un-affected (fund-driven during normal ops)
|
|
611
|
-
// Only used for valuation calculations and divergence checks
|
|
612
|
-
}
|
|
596
|
+
bot._blockchainFetchInterval = setInterval(tick, BLOCKCHAIN_FETCH_INTERVAL_MIN * 60 * 1000);
|
|
613
597
|
```
|
|
614
598
|
|
|
599
|
+
**2. Tick guards** *(no lock held)*
|
|
600
|
+
- Skip if shutdown has begun or a previous tick is still in flight
|
|
601
|
+
- Sync market adapter watchdog config
|
|
602
|
+
|
|
603
|
+
**3. Periodic work** *(under the fill-processing lock)*
|
|
604
|
+
- Reset accountant recovery state
|
|
605
|
+
- Refresh dynamic weight distribution
|
|
606
|
+
- `fetchAccountTotals(accountId)` — refreshes balances and the valuation anchor
|
|
607
|
+
- Read open orders via guarded read — truncated/empty reads defer the sync; fills are still caught by subscriptions and the next cycle
|
|
608
|
+
- `synchronizeWithChain(...)` — re-aligns the grid with on-chain reality; detected fills run through the normal batched rebalance pipeline and the grid is persisted, unmatched chain orders log as surplus/divergence
|
|
609
|
+
- `performPeriodicGridChecks(bot)` — maintenance checks (see [Lifecycle](LIFECYCLE.md))
|
|
610
|
+
|
|
611
|
+
Grid placement remains fund-driven during normal operation; the periodic tick keeps
|
|
612
|
+
balances, valuations, and open-order state fresh rather than directly moving prices.
|
|
613
|
+
A per-instance override (`_blockchainFetchIntervalMin`, e.g. for shared accounts from
|
|
614
|
+
the fund registry) can shorten or lengthen the interval; setting a non-positive value
|
|
615
|
+
disables the loop entirely.
|
|
616
|
+
|
|
615
617
|
### When `startPrice` is Numeric
|
|
616
618
|
|
|
617
619
|
If user set `startPrice: 105.5` in bots.json:
|
|
@@ -780,10 +782,10 @@ stateDiagram-v2
|
|
|
780
782
|
|
|
781
783
|
A **phantom order** is an illegal state where an order exists as ACTIVE/PARTIAL without a corresponding blockchain `orderId`. This corrupts fund tracking and causes "doubled funds" warnings.
|
|
782
784
|
|
|
783
|
-
**
|
|
784
|
-
1. **
|
|
785
|
-
2. **Sync
|
|
786
|
-
3. **
|
|
785
|
+
**Risks the Three-Layer Defense Guards Against**:
|
|
786
|
+
1. **Resize State Forcing**: Grid resize forcing VIRTUAL → ACTIVE without blockchain confirmation
|
|
787
|
+
2. **Sync Gaps**: Orders without `orderId` remaining ACTIVE if sync logic skips them
|
|
788
|
+
3. **Unvalidated Assignment**: Invalid state assignments without a centralized check
|
|
787
789
|
|
|
788
790
|
**Prevention System** (Three-Layer Defense):
|
|
789
791
|
|
|
@@ -983,7 +985,7 @@ graph TB
|
|
|
983
985
|
SKIP --> DONE
|
|
984
986
|
```
|
|
985
987
|
|
|
986
|
-
|
|
988
|
+
The force reload mechanism loads fresh persisted grid data before comparison, preventing stale cache from causing false divergence detections.
|
|
987
989
|
|
|
988
990
|
---
|
|
989
991
|
|
|
@@ -1150,9 +1152,12 @@ The system continuously monitors three mathematical invariants:
|
|
|
1150
1152
|
|
|
1151
1153
|
### Index Consistency
|
|
1152
1154
|
|
|
1153
|
-
- **
|
|
1154
|
-
|
|
1155
|
-
|
|
1155
|
+
- **Grid versioning**: `_gridVersion` is bumped on every grid mutation; the
|
|
1156
|
+
`_ordersByType` / `_ordersByState` index caches invalidate automatically when the
|
|
1157
|
+
version changes (no manual rebuild step)
|
|
1158
|
+
- **Structural checks**: tests use `assertOrdersStructurallySound()`
|
|
1159
|
+
(`tests/helpers/order_test_helpers.ts`) to verify every order in the Map is non-null
|
|
1160
|
+
with valid `state` and `type`
|
|
1156
1161
|
|
|
1157
1162
|
---
|
|
1158
1163
|
|
|
@@ -1278,7 +1283,7 @@ tsx tests/test_dexbot_credit_wiring.ts
|
|
|
1278
1283
|
|
|
1279
1284
|
3. **Verify invariants**
|
|
1280
1285
|
```javascript
|
|
1281
|
-
|
|
1286
|
+
assertOrdersStructurallySound(manager); // Order Map structurally valid
|
|
1282
1287
|
expect(chainTotal === chainFree + chainCommitted).toBe(true);
|
|
1283
1288
|
```
|
|
1284
1289
|
|
|
@@ -1382,7 +1387,7 @@ The strategy engine has been significantly strengthened with improvements to fun
|
|
|
1382
1387
|
- Before executing batch order placements, available funds are validated
|
|
1383
1388
|
- Prevents insufficient fund errors during large rotation cycles
|
|
1384
1389
|
- Uses atomic check-and-deduct pattern for safety
|
|
1385
|
-
- Located in: `modules/
|
|
1390
|
+
- Located in: `modules/dexbot_cow_runtime.ts` - `validateOperationFunds()`
|
|
1386
1391
|
|
|
1387
1392
|
**2. Dust Partial Handling**
|
|
1388
1393
|
- Improved dust detection algorithm prevents false positives
|
|
@@ -1408,9 +1413,9 @@ The strategy engine has been significantly strengthened with improvements to fun
|
|
|
1408
1413
|
- Located in: `modules/order/manager.ts` - `processFilledOrders()`
|
|
1409
1414
|
|
|
1410
1415
|
**6. Precision Spread Management (Logarithmic Logic)**
|
|
1411
|
-
- **Discrete Step Tracking**:
|
|
1412
|
-
- **Center-Gap Awareness**:
|
|
1413
|
-
- **Collision-Free Safety**:
|
|
1416
|
+
- **Discrete Step Tracking**: A discrete 1-slot logarithmic buffer ensures correction triggers exactly when the market moves by one full increment.
|
|
1417
|
+
- **Center-Gap Awareness**: Grid initialization math accounts for the "Center Gap" naturally created during symmetric centering, reducing the initial spread by ~0.5% (one full increment).
|
|
1418
|
+
- **Collision-Free Safety**: `MIN_SPREAD_FACTOR` of 2.1 ensures that the security minimum (2 spread orders) never conflicts with the spread correction threshold, even at micro-spread configurations.
|
|
1414
1419
|
|
|
1415
1420
|
### Related Documentation
|
|
1416
1421
|
|
package/docs/developer_guide.md
CHANGED
|
@@ -79,7 +79,7 @@ A **phantom order** is an order in ACTIVE/PARTIAL state WITHOUT a valid `orderId
|
|
|
79
79
|
|
|
80
80
|
| Term | Meaning |
|
|
81
81
|
|------|---------|
|
|
82
|
-
| **Fixed-Cap Batch Fill Processing** | Groups fills with a hard cap using `MAX_FILL_BATCH_SIZE` (default 4): `<= cap` uses one unified batch; `> cap` chunks at cap size. In the documented 29-fill Feb 7 crash scenario, this reduces the estimated divergence window from ~90s to ~24s; see [`FUND_MOVEMENT_AND_ACCOUNTING.md`](FUND_MOVEMENT_AND_ACCOUNTING.md#
|
|
82
|
+
| **Fixed-Cap Batch Fill Processing** | Groups fills with a hard cap using `MAX_FILL_BATCH_SIZE` (default 4): `<= cap` uses one unified batch; `> cap` chunks at cap size. In the documented 29-fill Feb 7 crash scenario, this reduces the estimated divergence window from ~90s to ~24s; see [`FUND_MOVEMENT_AND_ACCOUNTING.md`](FUND_MOVEMENT_AND_ACCOUNTING.md#15-fill-batch-processing--timeline). |
|
|
83
83
|
| **Recovery Retry System** | Count+time-based retry mechanism with periodic reset. Replaces one-shot `_recoveryAttempted` flag. Max 5 attempts per episode with 60s minimum interval between retries. |
|
|
84
84
|
| **Orphan-Fill Deduplication** | Map+TTL-based tracking of stale-cleaned order IDs to prevent double-crediting. Delayed orphan fill events are still blocked by checking `_staleCleanedOrderIds`. |
|
|
85
85
|
|
|
@@ -226,9 +226,7 @@ If you see prices like `0.000795` when expecting `1350`:
|
|
|
226
226
|
|
|
227
227
|
## Precision & Quantization Best Practices
|
|
228
228
|
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
**Solution**: Use centralized quantization utilities from `modules/order/utils/math.ts` to eliminate accumulation.
|
|
229
|
+
Floating-point arithmetic accumulates rounding errors across repeated price derivations, fund allocations, and order sizing. Always use the centralized quantization utilities in `modules/order/utils/math.ts` to eliminate accumulation.
|
|
232
230
|
|
|
233
231
|
### When to Quantize
|
|
234
232
|
|
|
@@ -304,7 +302,7 @@ _updateOrder(order, context, { skipAccounting, fee })
|
|
|
304
302
|
// COW rebalance pipeline
|
|
305
303
|
performSafeRebalance(fills, excludeIds) // Entry point; delegates to COW
|
|
306
304
|
_applySafeRebalanceCOW(fills, excludeIds) // Creates WorkingGrid, runs planning
|
|
307
|
-
|
|
305
|
+
_workingGrid.buildDelta(masterGrid) // Computes actions vs master (utils/order.ts buildDelta)
|
|
308
306
|
_commitWorkingGrid(workingGrid, indexes, boundary, { skipRecalc }) // Atomic swap: working → master
|
|
309
307
|
|
|
310
308
|
// COW state tracking
|
|
@@ -630,8 +628,9 @@ if (isOrderHealthy(order, minHealthySize)) {
|
|
|
630
628
|
#### `getPrecisionSlack(precision, factor)`
|
|
631
629
|
```javascript
|
|
632
630
|
// Calculate float comparison tolerance for given precision
|
|
633
|
-
//
|
|
634
|
-
|
|
631
|
+
// Location: modules/order/utils/math.ts
|
|
632
|
+
// Returns: factor * quantumForPrecision(precision) (factor defaults to 2)
|
|
633
|
+
const slack = getPrecisionSlack(5); // Returns 2 * 10^-5 = 0.00002
|
|
635
634
|
|
|
636
635
|
// Use case: Floating-point safe comparisons
|
|
637
636
|
if (Math.abs(order.size - expected) <= slack) {
|
|
@@ -907,7 +906,7 @@ convention marker — AsyncLock does not enforce it at runtime.
|
|
|
907
906
|
- Divergence checks (Level 1) nest inside fill processing
|
|
908
907
|
- Sync operations (Level 2) are acquired before grid mutations — the timeout-protected lock is inner, so a stuck sync releases the outer lock
|
|
909
908
|
- Grid mutations (Level 3) and fund operations (Level 4) are innermost
|
|
910
|
-
- All paths follow the same order
|
|
909
|
+
- All paths follow the same order
|
|
911
910
|
|
|
912
911
|
**`adjustTotalBalance` Locking Contract** (v1.4.7):
|
|
913
912
|
|
|
@@ -1240,11 +1239,9 @@ manager.accountant._verifyFundInvariants(
|
|
|
1240
1239
|
|
|
1241
1240
|
**2. Index Consistency Check**
|
|
1242
1241
|
```javascript
|
|
1243
|
-
//
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
manager._repairIndices();
|
|
1247
|
-
}
|
|
1242
|
+
// Index caches invalidate automatically via _gridVersion bumps — no manual
|
|
1243
|
+
// validation/repair API exists. For structural checks (e.g. in tests):
|
|
1244
|
+
assertOrdersStructurallySound(manager); // tests/helpers/order_test_helpers.ts
|
|
1248
1245
|
```
|
|
1249
1246
|
|
|
1250
1247
|
**3. Grid Diagnostics**
|
|
@@ -1499,9 +1496,10 @@ manager.logger.logFundsStatus(manager, 'CONTEXT');
|
|
|
1499
1496
|
console.log(manager.getMetrics());
|
|
1500
1497
|
```
|
|
1501
1498
|
|
|
1502
|
-
###
|
|
1499
|
+
### Check Order Map Integrity
|
|
1503
1500
|
```javascript
|
|
1504
|
-
|
|
1501
|
+
// Structural check (tests); index caches self-invalidate via _gridVersion
|
|
1502
|
+
assertOrdersStructurallySound(manager);
|
|
1505
1503
|
```
|
|
1506
1504
|
|
|
1507
1505
|
### Check Specific Order
|
|
@@ -1705,7 +1703,7 @@ console.log(' - Testing [action] updates [fund pool]...');
|
|
|
1705
1703
|
// Assert
|
|
1706
1704
|
const finalFunds = manager.funds[poolName][side];
|
|
1707
1705
|
assert.strictEqual(finalFunds, expectedValue);
|
|
1708
|
-
|
|
1706
|
+
assertOrdersStructurallySound(manager); // Order Map structurally sound?
|
|
1709
1707
|
}
|
|
1710
1708
|
```
|
|
1711
1709
|
|
|
@@ -1774,7 +1772,7 @@ try {
|
|
|
1774
1772
|
// Perform operation
|
|
1775
1773
|
await fundDependentOperation();
|
|
1776
1774
|
// Check state consistency
|
|
1777
|
-
|
|
1775
|
+
assertOrdersStructurallySound(manager);
|
|
1778
1776
|
} finally {
|
|
1779
1777
|
manager.unlockOrders(['order-1']);
|
|
1780
1778
|
}
|
|
@@ -1833,7 +1831,7 @@ manager.orders.forEach(order => {
|
|
|
1833
1831
|
});
|
|
1834
1832
|
|
|
1835
1833
|
// 4. Check index consistency
|
|
1836
|
-
|
|
1834
|
+
assertOrdersStructurallySound(manager); // throws if any order entry is corrupt
|
|
1837
1835
|
|
|
1838
1836
|
// 5. Examine specific fund pool
|
|
1839
1837
|
console.log('Virtual buy:', manager.funds.virtual.buy);
|
package/market_adapter/README.md
CHANGED
|
@@ -573,7 +573,6 @@ market_adapter/
|
|
|
573
573
|
|-- ama_signal_runner.ts one-cycle JSON signal CLI
|
|
574
574
|
|-- candle_utils.ts candle transforms, gap detection, pruning
|
|
575
575
|
|-- interval_utils.ts shared interval label helpers
|
|
576
|
-
|-- merge_lp_data.ts candle export merge utility
|
|
577
576
|
|-- lp_chart_core.ts chart HTML renderer
|
|
578
577
|
|-- lp_chart_strategy_loader.ts AMA strategy/profile resolver for charts
|
|
579
578
|
|-- lp_chart_runner.ts LP chart orchestration
|
|
@@ -612,7 +611,6 @@ market_adapter/
|
|
|
612
611
|
| |-- data_discovery.ts data directory auto-discovery
|
|
613
612
|
| |-- atomic_write.ts atomic file write utility
|
|
614
613
|
| |-- dynamic_grid_snapshot.ts dynamic grid snapshot helpers
|
|
615
|
-
| `-- paths.ts path resolution helpers
|
|
616
614
|
|-- data/ runtime candle caches and exports
|
|
617
615
|
`-- state/ runtime state, centers, and lock file
|
|
618
616
|
```
|
package/modules/README.md
CHANGED
|
@@ -127,7 +127,8 @@ modules/
|
|
|
127
127
|
└── utils/
|
|
128
128
|
├── base58check.ts Base58Check encoding
|
|
129
129
|
├── build_dir.ts BUILD_DIR constant helper
|
|
130
|
-
|
|
130
|
+
├── errors.ts getErrorMessage helper
|
|
131
|
+
└── sanitize_key.ts shared sanitizeKey helper
|
|
131
132
|
```
|
|
132
133
|
|
|
133
134
|
## Key Relationships
|
package/package.json
CHANGED
package/scripts/README.md
CHANGED
|
@@ -413,7 +413,7 @@ alias dbd='node dist/scripts/divergence-calc.js'
|
|
|
413
413
|
**Monitor live updates while running a script:**
|
|
414
414
|
```bash
|
|
415
415
|
# Tail the update log in a separate pane
|
|
416
|
-
tail -f profiles
|
|
416
|
+
tail -f <profiles>/logs/dexbot-update.log
|
|
417
417
|
```
|
|
418
418
|
|
|
419
419
|
**Run a specific bot dry-run from the CLI:**
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"id": "bitshares-claw",
|
|
3
|
-
"name": "BitShares Claw",
|
|
4
|
-
"description": "Native BitShares and DEXBot2 tools from the DEXBot2 claw integration",
|
|
5
|
-
"skills": [
|
|
6
|
-
"./runtimes/openclaw-plugin/skills"
|
|
7
|
-
],
|
|
8
|
-
"configSchema": {
|
|
9
|
-
"type": "object",
|
|
10
|
-
"additionalProperties": false,
|
|
11
|
-
"properties": {}
|
|
12
|
-
}
|
|
13
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"merge_lp_data.d.ts","sourceRoot":"","sources":["../../market_adapter/merge_lp_data.ts"],"names":[],"mappings":""}
|
|
@@ -1,125 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
'use strict';
|
|
3
|
-
/**
|
|
4
|
-
* MERGE LP DATA FILES
|
|
5
|
-
*
|
|
6
|
-
* Merges two JSON files produced by fetch_lp_data.ts into one,
|
|
7
|
-
* deduplicating candles by timestamp and sorting chronologically.
|
|
8
|
-
*
|
|
9
|
-
* Both files must have the same pool ID, interval, and asset pair.
|
|
10
|
-
*
|
|
11
|
-
* Usage:
|
|
12
|
-
* tsx market_adapter/merge_lp_data.ts <file1> <file2> --out <output>
|
|
13
|
-
*
|
|
14
|
-
* Example (2-year 1h dataset):
|
|
15
|
-
* tsx market_adapter/inputs/fetch_lp_data.ts --pool <poolId> --precA <precA> --precB <precB> --interval 1h --start 2024-03-06 --end 2025-03-06 --out market_adapter/data/lp/<pair>/lp_pool_<poolId>_1h_part1.json
|
|
16
|
-
* tsx market_adapter/inputs/fetch_lp_data.ts --pool <poolId> --precA <precA> --precB <precB> --interval 1h --start 2025-03-06 --end 2026-03-06 --out market_adapter/data/lp/<pair>/lp_pool_<poolId>_1h_part2.json
|
|
17
|
-
* tsx market_adapter/merge_lp_data.ts \
|
|
18
|
-
* market_adapter/data/lp/<pair>/lp_pool_<poolId>_1h_part1.json \
|
|
19
|
-
* market_adapter/data/lp/<pair>/lp_pool_<poolId>_1h_part2.json \
|
|
20
|
-
* --out market_adapter/data/lp/<pair>/lp_pool_<poolId>_1h.json
|
|
21
|
-
*/
|
|
22
|
-
import { path } from '../modules/path_api.js';
|
|
23
|
-
import { getStorage } from '../modules/storage/index.js';
|
|
24
|
-
import { mergeCandles } from './candle_utils.js';
|
|
25
|
-
import { getErrorMessage } from '../modules/utils/errors.js';
|
|
26
|
-
const storage = getStorage();
|
|
27
|
-
const { ensureDir, readJSON, writeJSON } = storage;
|
|
28
|
-
// ─── CLI ──────────────────────────────────────────────────────────────────────
|
|
29
|
-
function parseArgs() {
|
|
30
|
-
const args = process.argv.slice(2);
|
|
31
|
-
const files = [];
|
|
32
|
-
let out = null;
|
|
33
|
-
for (let i = 0; i < args.length; i++) {
|
|
34
|
-
if (args[i] === '--out' && args[i + 1]) {
|
|
35
|
-
out = args[++i];
|
|
36
|
-
}
|
|
37
|
-
else if (!args[i].startsWith('--')) {
|
|
38
|
-
files.push(args[i]);
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
if (files.length !== 2) {
|
|
42
|
-
console.error('Usage: merge_lp_data.ts <file1> <file2> --out <output>');
|
|
43
|
-
process.exit(1);
|
|
44
|
-
}
|
|
45
|
-
return { files, out };
|
|
46
|
-
}
|
|
47
|
-
// ─── Validation ───────────────────────────────────────────────────────────────
|
|
48
|
-
function validate(a, b) {
|
|
49
|
-
if (a.meta.pool !== b.meta.pool) {
|
|
50
|
-
throw new Error(`Pool mismatch: ${a.meta.pool} vs ${b.meta.pool}`);
|
|
51
|
-
}
|
|
52
|
-
if (a.meta.intervalSeconds !== b.meta.intervalSeconds) {
|
|
53
|
-
throw new Error(`Interval mismatch: ${a.meta.intervalSeconds}s vs ${b.meta.intervalSeconds}s`);
|
|
54
|
-
}
|
|
55
|
-
if (a.meta.assetA.id !== b.meta.assetA.id || a.meta.assetB.id !== b.meta.assetB.id) {
|
|
56
|
-
throw new Error(`Asset pair mismatch:\n` +
|
|
57
|
-
` file1: ${a.meta.assetA.id} / ${a.meta.assetB.id}\n` +
|
|
58
|
-
` file2: ${b.meta.assetA.id} / ${b.meta.assetB.id}`);
|
|
59
|
-
}
|
|
60
|
-
if (a.meta.assetA.precision !== b.meta.assetA.precision || a.meta.assetB.precision !== b.meta.assetB.precision) {
|
|
61
|
-
throw new Error(`Precision mismatch:\n` +
|
|
62
|
-
` file1: precA=${a.meta.assetA.precision} precB=${a.meta.assetB.precision}\n` +
|
|
63
|
-
` file2: precA=${b.meta.assetA.precision} precB=${b.meta.assetB.precision}`);
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
// ─── Merge ────────────────────────────────────────────────────────────────────
|
|
67
|
-
// ─── Main ─────────────────────────────────────────────────────────────────────
|
|
68
|
-
function run() {
|
|
69
|
-
const { files, out } = parseArgs();
|
|
70
|
-
console.log('');
|
|
71
|
-
console.log('══════════════════════════════════════════════');
|
|
72
|
-
console.log(' LP Data Merger');
|
|
73
|
-
console.log('══════════════════════════════════════════════');
|
|
74
|
-
const [dataA, dataB] = files.map((f, i) => {
|
|
75
|
-
const resolved = path.resolve(f);
|
|
76
|
-
if (!storage.exists(resolved))
|
|
77
|
-
throw new Error(`File not found: ${resolved}`);
|
|
78
|
-
const parsed = readJSON(resolved);
|
|
79
|
-
console.log(` file${i + 1}: ${path.relative(process.cwd(), resolved)} (${parsed.candles.length} candles)`);
|
|
80
|
-
return parsed;
|
|
81
|
-
});
|
|
82
|
-
validate(dataA, dataB);
|
|
83
|
-
const merged = mergeCandles(dataA.candles, dataB.candles, {
|
|
84
|
-
onCollision: (existing, incoming) => incoming[5] > existing[5] ? incoming : existing,
|
|
85
|
-
});
|
|
86
|
-
const firstTs = new Date(merged[0][0]).toISOString();
|
|
87
|
-
const lastTs = new Date(merged[merged.length - 1][0]).toISOString();
|
|
88
|
-
console.log('');
|
|
89
|
-
console.log(` file1 range: ${new Date(dataA.candles[0][0]).toISOString()} → ${new Date(dataA.candles[dataA.candles.length - 1][0]).toISOString()}`);
|
|
90
|
-
console.log(` file2 range: ${new Date(dataB.candles[0][0]).toISOString()} → ${new Date(dataB.candles[dataB.candles.length - 1][0]).toISOString()}`);
|
|
91
|
-
console.log(` merged: ${firstTs} → ${lastTs} (${merged.length} candles)`);
|
|
92
|
-
// Overlap check
|
|
93
|
-
const bTimestamps = new Set(dataB.candles.map((c) => c[0]));
|
|
94
|
-
const overlapCount = dataA.candles.filter((c) => bTimestamps.has(c[0])).length;
|
|
95
|
-
if (overlapCount > 0) {
|
|
96
|
-
console.log(` overlap: ${overlapCount} candles (deduplicated, higher-volume kept)`);
|
|
97
|
-
}
|
|
98
|
-
const output = {
|
|
99
|
-
meta: {
|
|
100
|
-
...dataA.meta,
|
|
101
|
-
fetchedAt: new Date().toISOString(),
|
|
102
|
-
mergedFrom: files.map(f => path.relative(process.cwd(), path.resolve(f))),
|
|
103
|
-
candleCount: merged.length,
|
|
104
|
-
lookbackHours: Math.round((merged[merged.length - 1][0] - merged[0][0]) / 3600000),
|
|
105
|
-
},
|
|
106
|
-
candles: merged,
|
|
107
|
-
};
|
|
108
|
-
const outPath = out
|
|
109
|
-
? path.resolve(out)
|
|
110
|
-
: path.join(path.dirname(path.resolve(files[1])), path.basename(files[1]));
|
|
111
|
-
ensureDir(path.dirname(outPath));
|
|
112
|
-
writeJSON(outPath, output);
|
|
113
|
-
const kb = (storage.stat(outPath).size / 1024).toFixed(1);
|
|
114
|
-
console.log('');
|
|
115
|
-
console.log(` Saved: ${path.relative(process.cwd(), outPath)} (${kb} KB)`);
|
|
116
|
-
console.log('');
|
|
117
|
-
}
|
|
118
|
-
try {
|
|
119
|
-
run();
|
|
120
|
-
}
|
|
121
|
-
catch (e) {
|
|
122
|
-
console.error('\n[error]', getErrorMessage(e));
|
|
123
|
-
process.exit(1);
|
|
124
|
-
}
|
|
125
|
-
//# sourceMappingURL=merge_lp_data.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"merge_lp_data.js","sourceRoot":"","sources":["../../market_adapter/merge_lp_data.ts"],"names":[],"mappings":";AACA,YAAY,CAAC;AAEb;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,EAAE,IAAI,EAAE,MAAM,wBAAwB,CAAC;AAC9C,OAAO,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAC;AACzD,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAC7D,MAAM,OAAO,GAAG,UAAU,EAAE,CAAC;AAC7B,MAAM,EAAE,SAAS,EAAE,QAAQ,EAAE,SAAS,EAAE,GAAG,OAAO,CAAC;AAEnD,iFAAiF;AAEjF,SAAS,SAAS;IACd,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IACnC,MAAM,KAAK,GAAa,EAAE,CAAC;IAC3B,IAAI,GAAG,GAAkB,IAAI,CAAC;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AAC;AAED,IAAI,CAAC;IACD,GAAG,EAAE,CAAC;AACV,CAAC;AAAC,OAAO,CAAM,EAAE,CAAC;IACd,OAAO,CAAC,KAAK,CAAC,WAAW,EAAE,eAAe,CAAC,CAAC,CAAC,CAAC,CAAC;IAC/C,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AACpB,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"paths.d.ts","sourceRoot":"","sources":["../../../market_adapter/utils/paths.ts"],"names":[],"mappings":"AAIA,QAAA,MAAM,YAAY,QAAqB,CAAC;AAExC,OAAO,EAAE,YAAY,EAAE,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"paths.js","sourceRoot":"","sources":["../../../market_adapter/utils/paths.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,MAAM,wBAAwB,CAAC;AAC/C,YAAY,CAAC;AAEb,MAAM,YAAY,GAAG,KAAK,CAAC,YAAY,CAAC;AAExC,OAAO,EAAE,YAAY,EAAE,CAAA"}
|