dexbot 1.4.13 → 1.4.15
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/README.md +77 -68
- package/claw/data/positions.json +3391 -1
- package/claw/docs/AI_BOT_LIBRARY_API.md +1 -1
- package/claw/docs/POSITION_HEALTH.md +2 -2
- package/claw/modules/claw_catalog.ts +1 -3
- package/claw/modules/claw_launcher.ts +2 -3
- package/claw/modules/claw_skill_md.ts +1 -1
- package/claw/modules/decision_loop.ts +1 -1
- package/claw/modules/dexbot_profiles.ts +2 -33
- package/claw/modules/feed_price_source.ts +3 -32
- package/claw/modules/launcher_mode_detector.ts +1 -1
- package/claw/modules/mcp_utils.ts +1 -1
- package/claw/modules/mpa_utils.ts +36 -1
- package/claw/modules/position_discovery.ts +1 -28
- package/claw/modules/position_health.ts +1 -20
- package/claw/modules/position_manager.ts +3 -28
- package/claw/modules/skill_utils.ts +1 -1
- package/claw/modules/types.ts +0 -53
- 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/skills/margin-trading/references/honest-assets.md +1 -1
- package/claw/skills/margin-trading/references/position-management.md +2 -2
- package/claw/skills/shared/references/js-automation-overview.md +2 -2
- package/claw/skills/trend-detection/references/service.md +24 -17
- package/claw/tests/test_claw_bridge.ts +47 -47
- package/claw/tests/test_claw_catalog_and_credentials.ts +9 -9
- package/claw/tests/test_claw_chain_layer.ts +54 -54
- package/claw/tests/test_claw_data_flow.ts +41 -41
- package/claw/tests/test_claw_domain_logic.ts +26 -26
- package/claw/tests/test_claw_manifest_and_matrix.ts +1 -1
- package/claw/tests/test_claw_mcp_transport.ts +16 -16
- package/claw/tests/test_claw_regressions.ts +43 -43
- package/claw/tests/test_claw_skill_generation.ts +1 -1
- package/claw/tests/test_claw_state_store.ts +2 -2
- package/claw/tests/test_dexbot_profiles.ts +4 -4
- package/claw/tests/test_memu_bridge.ts +3 -3
- package/claw/tests/test_nullclaw_tmp_integration.ts +1 -1
- package/claw/tests/test_position_health.ts +2 -2
- package/claw/tests/test_position_manager.ts +18 -18
- package/claw/tests/test_position_manager_watch_health.ts +2 -2
- package/claw/tests/test_short_mpa_strategy.ts +12 -12
- package/dist/analysis/chart_utils.d.ts +13 -1
- package/dist/analysis/chart_utils.d.ts.map +1 -1
- package/dist/analysis/chart_utils.js +16 -1
- package/dist/analysis/chart_utils.js.map +1 -1
- package/dist/analysis/math_utils.d.ts +8 -12
- package/dist/analysis/math_utils.d.ts.map +1 -1
- package/dist/analysis/math_utils.js +9 -75
- package/dist/analysis/math_utils.js.map +1 -1
- package/dist/analysis/tradingview/tradingview_uplot_chart_generator.js +4 -4
- package/dist/dexbot.d.ts.map +1 -1
- package/dist/dexbot.js +54 -35
- package/dist/dexbot.js.map +1 -1
- package/dist/market_adapter/candle_utils.d.ts +18 -1
- package/dist/market_adapter/candle_utils.d.ts.map +1 -1
- package/dist/market_adapter/candle_utils.js +50 -1
- package/dist/market_adapter/candle_utils.js.map +1 -1
- package/dist/market_adapter/core/config_normalizers.js +1 -1
- package/dist/market_adapter/core/config_normalizers.js.map +1 -1
- package/dist/market_adapter/core/kibana_client.d.ts +2 -2
- package/dist/market_adapter/core/kibana_client.js +2 -2
- package/dist/market_adapter/core/kibana_market_candles.d.ts +1 -87
- package/dist/market_adapter/core/kibana_market_candles.d.ts.map +1 -1
- package/dist/market_adapter/core/kibana_market_candles.js +1 -80
- package/dist/market_adapter/core/kibana_market_candles.js.map +1 -1
- package/dist/market_adapter/core/market_adapter_service.d.ts +0 -8
- package/dist/market_adapter/core/market_adapter_service.d.ts.map +1 -1
- package/dist/market_adapter/core/market_adapter_service.js +28 -115
- package/dist/market_adapter/core/market_adapter_service.js.map +1 -1
- package/dist/market_adapter/core/signals/hurst_analyzer.d.ts.map +1 -0
- package/dist/{analysis/trend_detection → market_adapter/core/signals}/hurst_analyzer.js +2 -2
- package/dist/market_adapter/core/signals/hurst_analyzer.js.map +1 -0
- package/dist/{analysis/trend_detection → market_adapter/core/signals}/kalman_trend_analyzer.d.ts +0 -1
- package/dist/market_adapter/core/signals/kalman_trend_analyzer.d.ts.map +1 -0
- package/dist/{analysis/trend_detection → market_adapter/core/signals}/kalman_trend_analyzer.js +2 -4
- package/dist/market_adapter/core/signals/kalman_trend_analyzer.js.map +1 -0
- package/dist/{analysis/trend_detection → market_adapter/core/signals}/kalman_velocity_smoothing.d.ts +25 -4
- package/dist/market_adapter/core/signals/kalman_velocity_smoothing.d.ts.map +1 -0
- package/dist/{analysis/trend_detection → market_adapter/core/signals}/kalman_velocity_smoothing.js +41 -19
- package/dist/market_adapter/core/signals/kalman_velocity_smoothing.js.map +1 -0
- package/dist/market_adapter/core/signals/permutation_entropy_analyzer.d.ts.map +1 -0
- package/dist/{analysis/trend_detection → market_adapter/core/signals}/permutation_entropy_analyzer.js +2 -2
- package/dist/market_adapter/core/signals/permutation_entropy_analyzer.js.map +1 -0
- package/dist/market_adapter/core/strategies/ama.d.ts +1 -19
- package/dist/market_adapter/core/strategies/ama.d.ts.map +1 -1
- package/dist/market_adapter/core/strategies/ama.js +1 -1
- package/dist/market_adapter/core/strategies/ama.js.map +1 -1
- package/dist/market_adapter/core/strategies/ama_slope_model.d.ts +2 -13
- package/dist/market_adapter/core/strategies/ama_slope_model.d.ts.map +1 -1
- package/dist/market_adapter/core/strategies/ama_slope_model.js +15 -26
- package/dist/market_adapter/core/strategies/ama_slope_model.js.map +1 -1
- package/dist/market_adapter/core/strategies/atr/calculator.d.ts +38 -3
- package/dist/market_adapter/core/strategies/atr/calculator.d.ts.map +1 -1
- package/dist/market_adapter/core/strategies/atr/calculator.js +84 -24
- package/dist/market_adapter/core/strategies/atr/calculator.js.map +1 -1
- package/dist/market_adapter/core/strategies/collateral_manager.d.ts +1 -1
- package/dist/market_adapter/core/strategies/collateral_manager.js +1 -1
- package/dist/market_adapter/core/strategies/dynamic_weight_series.d.ts +32 -0
- package/dist/market_adapter/core/strategies/dynamic_weight_series.d.ts.map +1 -0
- package/dist/market_adapter/core/strategies/dynamic_weight_series.js +136 -0
- package/dist/market_adapter/core/strategies/dynamic_weight_series.js.map +1 -0
- package/dist/market_adapter/core/strategies/regime_gate.d.ts +6 -21
- package/dist/market_adapter/core/strategies/regime_gate.d.ts.map +1 -1
- package/dist/market_adapter/core/strategies/regime_gate.js +11 -74
- package/dist/market_adapter/core/strategies/regime_gate.js.map +1 -1
- package/dist/market_adapter/core/strategies/regime_interp.d.ts +13 -0
- package/dist/market_adapter/core/strategies/regime_interp.d.ts.map +1 -0
- package/dist/market_adapter/core/strategies/regime_interp.js +74 -0
- package/dist/market_adapter/core/strategies/regime_interp.js.map +1 -0
- package/dist/market_adapter/core/strategies/volatility_shift.d.ts +22 -0
- package/dist/market_adapter/core/strategies/volatility_shift.d.ts.map +1 -0
- package/dist/market_adapter/core/strategies/volatility_shift.js +37 -0
- package/dist/market_adapter/core/strategies/volatility_shift.js.map +1 -0
- package/dist/market_adapter/inputs/fetch_cex_synthetic_data.js +3 -4
- package/dist/market_adapter/inputs/fetch_cex_synthetic_data.js.map +1 -1
- package/dist/market_adapter/inputs/fetch_lp_data.d.ts +1 -10
- package/dist/market_adapter/inputs/fetch_lp_data.d.ts.map +1 -1
- package/dist/market_adapter/inputs/fetch_lp_data.js +1 -1
- package/dist/market_adapter/inputs/fetch_lp_data.js.map +1 -1
- package/dist/market_adapter/lp_chart_core.d.ts.map +1 -1
- package/dist/market_adapter/lp_chart_core.js +0 -10
- package/dist/market_adapter/lp_chart_core.js.map +1 -1
- package/dist/market_adapter/lp_chart_runner.d.ts +1 -16
- package/dist/market_adapter/lp_chart_runner.d.ts.map +1 -1
- package/dist/market_adapter/lp_chart_runner.js +1 -15
- package/dist/market_adapter/lp_chart_runner.js.map +1 -1
- package/dist/market_adapter/market_adapter.d.ts +3 -3
- package/dist/market_adapter/market_adapter.d.ts.map +1 -1
- package/dist/market_adapter/market_adapter.js +6 -8
- package/dist/market_adapter/market_adapter.js.map +1 -1
- package/dist/market_adapter/merge_lp_data.js +5 -5
- package/dist/market_adapter/utils/adapter_client.d.ts +1 -3
- package/dist/market_adapter/utils/adapter_client.d.ts.map +1 -1
- package/dist/market_adapter/utils/adapter_client.js +1 -14
- package/dist/market_adapter/utils/adapter_client.js.map +1 -1
- package/dist/market_adapter/utils/data_discovery.d.ts.map +1 -1
- package/dist/market_adapter/utils/data_discovery.js +1 -2
- package/dist/market_adapter/utils/data_discovery.js.map +1 -1
- package/dist/market_adapter/utils/dynamic_grid_snapshot.d.ts +1 -3
- package/dist/market_adapter/utils/dynamic_grid_snapshot.d.ts.map +1 -1
- package/dist/market_adapter/utils/dynamic_grid_snapshot.js +1 -1
- package/dist/market_adapter/utils/dynamic_grid_snapshot.js.map +1 -1
- package/dist/market_adapter/utils/file_lock.d.ts +10 -2
- package/dist/market_adapter/utils/file_lock.d.ts.map +1 -1
- package/dist/market_adapter/utils/file_lock.js +171 -102
- package/dist/market_adapter/utils/file_lock.js.map +1 -1
- package/dist/market_adapter/utils/native_history.d.ts +1 -9
- package/dist/market_adapter/utils/native_history.d.ts.map +1 -1
- package/dist/market_adapter/utils/native_history.js +1 -21
- package/dist/market_adapter/utils/native_history.js.map +1 -1
- package/dist/modules/account_bots.d.ts +16 -38
- package/dist/modules/account_bots.d.ts.map +1 -1
- package/dist/modules/account_bots.js +16 -38
- package/dist/modules/account_bots.js.map +1 -1
- package/dist/modules/account_orders.d.ts +11 -11
- package/dist/modules/account_orders.d.ts.map +1 -1
- package/dist/modules/account_orders.js +11 -18
- package/dist/modules/account_orders.js.map +1 -1
- package/dist/modules/bitshares_client.d.ts +5 -8
- package/dist/modules/bitshares_client.d.ts.map +1 -1
- package/dist/modules/bitshares_client.js +6 -10
- package/dist/modules/bitshares_client.js.map +1 -1
- package/dist/modules/bots_file_lock.d.ts +8 -5
- package/dist/modules/bots_file_lock.d.ts.map +1 -1
- package/dist/modules/bots_file_lock.js +8 -5
- package/dist/modules/bots_file_lock.js.map +1 -1
- package/dist/modules/chain_keys.d.ts +31 -22
- package/dist/modules/chain_keys.d.ts.map +1 -1
- package/dist/modules/chain_keys.js +31 -22
- package/dist/modules/chain_keys.js.map +1 -1
- package/dist/modules/chain_orders.d.ts +52 -48
- package/dist/modules/chain_orders.d.ts.map +1 -1
- package/dist/modules/chain_orders.js +124 -49
- package/dist/modules/chain_orders.js.map +1 -1
- package/dist/modules/config.d.ts +3 -0
- package/dist/modules/config.d.ts.map +1 -1
- package/dist/modules/config.js +3 -0
- package/dist/modules/config.js.map +1 -1
- package/dist/modules/constants.d.ts +17 -13
- package/dist/modules/constants.d.ts.map +1 -1
- package/dist/modules/constants.js +42 -21
- package/dist/modules/constants.js.map +1 -1
- package/dist/modules/cr_planner.d.ts +2 -1
- package/dist/modules/cr_planner.d.ts.map +1 -1
- package/dist/modules/cr_planner.js +1 -1
- package/dist/modules/cr_planner.js.map +1 -1
- package/dist/modules/credential_policy.d.ts +6 -4
- package/dist/modules/credential_policy.d.ts.map +1 -1
- package/dist/modules/credential_policy.js +6 -4
- package/dist/modules/credential_policy.js.map +1 -1
- package/dist/modules/credit_runtime.d.ts.map +1 -1
- package/dist/modules/credit_runtime.js +4 -8
- package/dist/modules/credit_runtime.js.map +1 -1
- package/dist/modules/dexbot_class.d.ts +33 -88
- package/dist/modules/dexbot_class.d.ts.map +1 -1
- package/dist/modules/dexbot_class.js +36 -68
- package/dist/modules/dexbot_class.js.map +1 -1
- package/dist/modules/dexbot_cow_runtime.d.ts +7 -7
- package/dist/modules/dexbot_cow_runtime.d.ts.map +1 -1
- package/dist/modules/dexbot_cow_runtime.js +7 -7
- package/dist/modules/dexbot_cow_runtime.js.map +1 -1
- package/dist/modules/dexbot_credential_client.d.ts +3 -3
- package/dist/modules/dexbot_credential_client.js +3 -3
- package/dist/modules/dexbot_credential_client.js.map +1 -1
- package/dist/modules/dexbot_fill_runtime.d.ts +1 -7
- package/dist/modules/dexbot_fill_runtime.d.ts.map +1 -1
- package/dist/modules/dexbot_fill_runtime.js +1 -9
- package/dist/modules/dexbot_fill_runtime.js.map +1 -1
- package/dist/modules/dexbot_maintenance_runtime.d.ts.map +1 -1
- package/dist/modules/dexbot_maintenance_runtime.js +3 -1
- package/dist/modules/dexbot_maintenance_runtime.js.map +1 -1
- package/dist/modules/dexbot_state_recovery.d.ts.map +1 -1
- package/dist/modules/dexbot_state_recovery.js +99 -1
- package/dist/modules/dexbot_state_recovery.js.map +1 -1
- package/dist/modules/graceful_shutdown.d.ts +4 -2
- package/dist/modules/graceful_shutdown.d.ts.map +1 -1
- package/dist/modules/graceful_shutdown.js +4 -2
- package/dist/modules/graceful_shutdown.js.map +1 -1
- package/dist/modules/launcher/bot_supervisor.d.ts +1 -1
- package/dist/modules/launcher/bot_supervisor.d.ts.map +1 -1
- package/dist/modules/launcher/bot_supervisor.js +1 -4
- package/dist/modules/launcher/bot_supervisor.js.map +1 -1
- package/dist/modules/launcher/child_env.d.ts.map +1 -1
- package/dist/modules/launcher/child_env.js +3 -0
- package/dist/modules/launcher/child_env.js.map +1 -1
- package/dist/modules/market_adapter_whitelist.d.ts +1 -2
- package/dist/modules/market_adapter_whitelist.d.ts.map +1 -1
- package/dist/modules/market_adapter_whitelist.js +1 -4
- package/dist/modules/market_adapter_whitelist.js.map +1 -1
- package/dist/modules/node_health_cache.d.ts +12 -4
- package/dist/modules/node_health_cache.d.ts.map +1 -1
- package/dist/modules/node_health_cache.js +13 -13
- package/dist/modules/node_health_cache.js.map +1 -1
- package/dist/modules/node_manager.d.ts.map +1 -1
- package/dist/modules/node_manager.js +3 -6
- package/dist/modules/node_manager.js.map +1 -1
- package/dist/modules/order/accounting.d.ts +2 -37
- package/dist/modules/order/accounting.d.ts.map +1 -1
- package/dist/modules/order/accounting.js +2 -64
- package/dist/modules/order/accounting.js.map +1 -1
- package/dist/modules/order/export.d.ts +1 -37
- package/dist/modules/order/export.d.ts.map +1 -1
- package/dist/modules/order/export.js +1 -1
- package/dist/modules/order/export.js.map +1 -1
- package/dist/modules/order/format.d.ts +28 -14
- package/dist/modules/order/format.d.ts.map +1 -1
- package/dist/modules/order/format.js +73 -18
- package/dist/modules/order/format.js.map +1 -1
- package/dist/modules/order/grid.d.ts +11 -5
- package/dist/modules/order/grid.d.ts.map +1 -1
- package/dist/modules/order/grid.js +79 -37
- package/dist/modules/order/grid.js.map +1 -1
- package/dist/modules/order/grid_reconcile_internal.js +2 -2
- package/dist/modules/order/grid_reconcile_internal.js.map +1 -1
- package/dist/modules/order/logger_state.d.ts +3 -45
- package/dist/modules/order/logger_state.d.ts.map +1 -1
- package/dist/modules/order/logger_state.js +3 -55
- package/dist/modules/order/logger_state.js.map +1 -1
- package/dist/modules/order/manager.d.ts +0 -4
- package/dist/modules/order/manager.d.ts.map +1 -1
- package/dist/modules/order/manager.js +3 -9
- package/dist/modules/order/manager.js.map +1 -1
- package/dist/modules/order/sync_engine.d.ts +0 -2
- package/dist/modules/order/sync_engine.d.ts.map +1 -1
- package/dist/modules/order/sync_engine.js +1 -4
- package/dist/modules/order/sync_engine.js.map +1 -1
- package/dist/modules/order/utils/math.d.ts +2 -11
- package/dist/modules/order/utils/math.d.ts.map +1 -1
- package/dist/modules/order/utils/math.js +3 -14
- package/dist/modules/order/utils/math.js.map +1 -1
- package/dist/modules/order/utils/order.d.ts +1 -17
- package/dist/modules/order/utils/order.d.ts.map +1 -1
- package/dist/modules/order/utils/order.js +3 -21
- package/dist/modules/order/utils/order.js.map +1 -1
- package/dist/modules/order/utils/system.d.ts +1 -11
- package/dist/modules/order/utils/system.d.ts.map +1 -1
- package/dist/modules/order/utils/system.js +3 -3
- package/dist/modules/order/utils/system.js.map +1 -1
- package/dist/modules/order/utils/validate.d.ts +1 -26
- package/dist/modules/order/utils/validate.d.ts.map +1 -1
- package/dist/modules/order/utils/validate.js +1 -1
- package/dist/modules/order/utils/validate.js.map +1 -1
- package/dist/modules/order/working_grid.d.ts +3 -9
- package/dist/modules/order/working_grid.d.ts.map +1 -1
- package/dist/modules/order/working_grid.js +3 -11
- package/dist/modules/order/working_grid.js.map +1 -1
- package/dist/modules/paths.d.ts +43 -2
- package/dist/modules/paths.d.ts.map +1 -1
- package/dist/modules/paths.js +81 -21
- package/dist/modules/paths.js.map +1 -1
- package/dist/modules/runtime_settings.js +1 -1
- package/dist/modules/runtime_settings.js.map +1 -1
- package/dist/pm2.d.ts +1 -1
- package/dist/pm2.d.ts.map +1 -1
- package/dist/pm2.js +1 -4
- package/dist/pm2.js.map +1 -1
- package/dist/scripts/analyze-orders.d.ts.map +1 -1
- package/dist/scripts/analyze-orders.js +36 -45
- package/dist/scripts/analyze-orders.js.map +1 -1
- package/dist/scripts/sync-version.js +22 -0
- package/dist/scripts/sync-version.js.map +1 -1
- package/ecosystem.config.cjs +32 -0
- package/package.json +4 -1
- package/scripts/README.md +24 -8
- package/scripts/clear-all.sh +39 -12
- package/scripts/clear-logs.sh +1 -1
- package/scripts/clear-market-adapter.sh +3 -3
- package/scripts/clear-orders.sh +1 -1
- package/scripts/create-bot-symlinks.sh +4 -2
- package/scripts/lib/dexbot-paths.sh +63 -0
- package/scripts/reset-settings.sh +1 -1
- package/dist/analysis/trend_detection/hurst_analyzer.d.ts.map +0 -1
- package/dist/analysis/trend_detection/hurst_analyzer.js.map +0 -1
- package/dist/analysis/trend_detection/kalman_trend_analyzer.d.ts.map +0 -1
- package/dist/analysis/trend_detection/kalman_trend_analyzer.js.map +0 -1
- package/dist/analysis/trend_detection/kalman_velocity_smoothing.d.ts.map +0 -1
- package/dist/analysis/trend_detection/kalman_velocity_smoothing.js.map +0 -1
- package/dist/analysis/trend_detection/permutation_entropy_analyzer.d.ts.map +0 -1
- package/dist/analysis/trend_detection/permutation_entropy_analyzer.js.map +0 -1
- package/dist/market_adapter/index.d.ts +0 -32
- package/dist/market_adapter/index.d.ts.map +0 -1
- package/dist/market_adapter/index.js +0 -39
- package/dist/market_adapter/index.js.map +0 -1
- package/dist/scripts/fix-err-message.d.ts +0 -3
- package/dist/scripts/fix-err-message.d.ts.map +0 -1
- package/dist/scripts/fix-err-message.js +0 -193
- package/dist/scripts/fix-err-message.js.map +0 -1
- /package/dist/{analysis/trend_detection → market_adapter/core/signals}/hurst_analyzer.d.ts +0 -0
- /package/dist/{analysis/trend_detection → market_adapter/core/signals}/permutation_entropy_analyzer.d.ts +0 -0
|
@@ -3,7 +3,7 @@ const Module = require('module');
|
|
|
3
3
|
const path = require('path');
|
|
4
4
|
const { setCachedModule, restoreCachedModule } = require('../../tests/helpers/module_cache_stub');
|
|
5
5
|
|
|
6
|
-
function clearModule(modulePath) {
|
|
6
|
+
function clearModule(modulePath: string) {
|
|
7
7
|
delete require.cache[modulePath];
|
|
8
8
|
}
|
|
9
9
|
|
|
@@ -28,11 +28,11 @@ async function testClawBitsharesClientWaitForConnectedTriggersNativeConnect() {
|
|
|
28
28
|
const clawBitsharesPath = require.resolve('../modules/bitshares_client');
|
|
29
29
|
const nativePath = require.resolve('../../modules/bitshares-native');
|
|
30
30
|
let connectCalls = 0;
|
|
31
|
-
let nodes = [];
|
|
31
|
+
let nodes: any[] = [];
|
|
32
32
|
let connected = false;
|
|
33
33
|
|
|
34
34
|
const originalNativeEntry = setCachedModule(nativePath, {
|
|
35
|
-
createChainClient: ({ onStatusChange }) => ({
|
|
35
|
+
createChainClient: ({ onStatusChange }: any) => ({
|
|
36
36
|
connect: async () => {
|
|
37
37
|
connectCalls += 1;
|
|
38
38
|
connected = true;
|
|
@@ -43,7 +43,7 @@ async function testClawBitsharesClientWaitForConnectedTriggersNativeConnect() {
|
|
|
43
43
|
if (typeof onStatusChange === 'function') onStatusChange('closed');
|
|
44
44
|
},
|
|
45
45
|
getStatus: () => connected ? 'connected' : 'closed',
|
|
46
|
-
setNodes: (nextNodes) => { nodes = Array.isArray(nextNodes) ? nextNodes.slice() : []; },
|
|
46
|
+
setNodes: (nextNodes: any[]) => { nodes = Array.isArray(nextNodes) ? nextNodes.slice() : []; },
|
|
47
47
|
getNodes: () => nodes.slice(),
|
|
48
48
|
getCoreAsset: () => '1.3.0',
|
|
49
49
|
db: {},
|
|
@@ -86,22 +86,22 @@ function testClawRootExportsAvoidSilentCollisions() {
|
|
|
86
86
|
assert.strictEqual(hermesManifest.compatibility.name, 'Hermes');
|
|
87
87
|
assert.strictEqual(openclawManifest.options.runtimeName, 'openclaw');
|
|
88
88
|
assert.strictEqual(openclawManifest.compatibility.name, 'OpenClaw');
|
|
89
|
-
assert.strictEqual(openclawManifest.commandExamples.some((example) => example.includes('scripts/claw_bridge.ts')), true);
|
|
89
|
+
assert.strictEqual(openclawManifest.commandExamples.some((example: any) => example.includes('scripts/claw_bridge.ts')), true);
|
|
90
90
|
assert.strictEqual(openfangManifest.options.runtimeName, 'openfang');
|
|
91
|
-
assert.strictEqual(openfangManifest.commandExamples.some((example) => example.includes('claw_bridge.ts')), true);
|
|
91
|
+
assert.strictEqual(openfangManifest.commandExamples.some((example: any) => example.includes('claw_bridge.ts')), true);
|
|
92
92
|
assert.strictEqual(nullManifest.options.runtimeName, 'nullclaw');
|
|
93
|
-
assert.strictEqual(nullManifest.commandExamples.some((example) => example.includes('claw_bridge.ts')), true);
|
|
93
|
+
assert.strictEqual(nullManifest.commandExamples.some((example: any) => example.includes('claw_bridge.ts')), true);
|
|
94
94
|
assert.strictEqual(manifest.options.runtimeName, 'zeroclaw');
|
|
95
|
-
assert.strictEqual(manifest.commandExamples.some((example) => example.includes('claw_bridge.ts')), true);
|
|
95
|
+
assert.strictEqual(manifest.commandExamples.some((example: any) => example.includes('claw_bridge.ts')), true);
|
|
96
96
|
}
|
|
97
97
|
|
|
98
98
|
function testClawCommandInjectsRuntimeNameViaOption() {
|
|
99
99
|
const clawBridgePath = require.resolve('../modules/claw_bridge');
|
|
100
100
|
const clawInfraPath = require.resolve('../modules/claw_infra');
|
|
101
101
|
|
|
102
|
-
let capturedOptions = null;
|
|
102
|
+
let capturedOptions: any = null;
|
|
103
103
|
const originalClawInfra = setCachedModule(clawInfraPath, {
|
|
104
|
-
createClawInfrastructure: (opts) => {
|
|
104
|
+
createClawInfrastructure: (opts: any) => {
|
|
105
105
|
capturedOptions = opts;
|
|
106
106
|
return {
|
|
107
107
|
runtime: { name: opts.runtime?.name || 'claw-bridge', accountName: null },
|
|
@@ -152,13 +152,13 @@ function testLiquidityPoolWrapperInjectsSharedBitSharesClient() {
|
|
|
152
152
|
const originalDexbotBridge = setCachedModule(dexbotBridgePath, {
|
|
153
153
|
getDexbot2Root: () => '/tmp',
|
|
154
154
|
loadDexbotOrderSystemUtils: () => ({
|
|
155
|
-
cloneMap: (value) => value,
|
|
156
|
-
deepFreeze: (value) => value,
|
|
157
|
-
derivePoolPrice: (...args) => {
|
|
155
|
+
cloneMap: (value: any) => value,
|
|
156
|
+
deepFreeze: (value: any) => value,
|
|
157
|
+
derivePoolPrice: (...args: any[]) => {
|
|
158
158
|
capturedPoolArgs = args;
|
|
159
159
|
return 'pool-price';
|
|
160
160
|
},
|
|
161
|
-
derivePrice: (...args) => {
|
|
161
|
+
derivePrice: (...args: any[]) => {
|
|
162
162
|
capturedPriceArgs = args;
|
|
163
163
|
return 'derived-price';
|
|
164
164
|
},
|
|
@@ -195,12 +195,12 @@ async function testDecisionLoopReusesAnalyzerStateForDuplicateMarkets() {
|
|
|
195
195
|
const discoveryPath = require.resolve('../modules/position_discovery');
|
|
196
196
|
const healthPath = require.resolve('../modules/position_health');
|
|
197
197
|
const feedPriceSourcePath = require.resolve('../modules/feed_price_source');
|
|
198
|
-
const trendAnalyzerPath = require.resolve('../../
|
|
198
|
+
const trendAnalyzerPath = require.resolve('../../market_adapter/core/signals/kalman_trend_analyzer');
|
|
199
199
|
let trendFetchCount = 0;
|
|
200
200
|
|
|
201
201
|
class FakeTrendAnalyzer {
|
|
202
202
|
[key: string]: any;
|
|
203
|
-
update(marketPrice, feedPrice) {
|
|
203
|
+
update(marketPrice: number, feedPrice: number) {
|
|
204
204
|
this.analysis = {
|
|
205
205
|
confidence: 77,
|
|
206
206
|
isReady: true,
|
|
@@ -232,7 +232,7 @@ async function testDecisionLoopReusesAnalyzerStateForDuplicateMarkets() {
|
|
|
232
232
|
])
|
|
233
233
|
} as any);
|
|
234
234
|
const originalHealth = setCachedModule(healthPath, {
|
|
235
|
-
assessPosition: (position, trendSignal) => ({
|
|
235
|
+
assessPosition: (position: any, trendSignal: any) => ({
|
|
236
236
|
actions: [],
|
|
237
237
|
positionId: position.id,
|
|
238
238
|
trend: trendSignal
|
|
@@ -273,17 +273,17 @@ async function testDecisionLoopReplacesAnalyzerOnConfigChange() {
|
|
|
273
273
|
const discoveryPath = require.resolve('../modules/position_discovery');
|
|
274
274
|
const healthPath = require.resolve('../modules/position_health');
|
|
275
275
|
const feedPriceSourcePath = require.resolve('../modules/feed_price_source');
|
|
276
|
-
const trendAnalyzerPath = require.resolve('../../
|
|
276
|
+
const trendAnalyzerPath = require.resolve('../../market_adapter/core/signals/kalman_trend_analyzer');
|
|
277
277
|
let constructionCount = 0;
|
|
278
278
|
|
|
279
279
|
class ConfigTrackingAnalyzer {
|
|
280
280
|
[key: string]: any;
|
|
281
|
-
constructor(config) {
|
|
281
|
+
constructor(config: any) {
|
|
282
282
|
constructionCount += 1;
|
|
283
283
|
this.config = config;
|
|
284
284
|
}
|
|
285
285
|
|
|
286
|
-
update(marketPrice, feedPrice) {
|
|
286
|
+
update(marketPrice: number, feedPrice: number) {
|
|
287
287
|
return { confidence: 50, isReady: true, trend: 'NEUTRAL' };
|
|
288
288
|
}
|
|
289
289
|
|
|
@@ -298,7 +298,7 @@ async function testDecisionLoopReplacesAnalyzerOnConfigChange() {
|
|
|
298
298
|
])
|
|
299
299
|
} as any);
|
|
300
300
|
const originalHealth = setCachedModule(healthPath, {
|
|
301
|
-
assessPosition: (position, trendSignal) => ({ actions: [], positionId: position.id, trend: trendSignal })
|
|
301
|
+
assessPosition: (position: any, trendSignal: any) => ({ actions: [], positionId: position.id, trend: trendSignal })
|
|
302
302
|
} as any);
|
|
303
303
|
const originalFeedPriceSource = setCachedModule(feedPriceSourcePath, {
|
|
304
304
|
fetchTrendInput: async () => ({ feedPrice: 100, marketPrice: 95, premium: -5 })
|
|
@@ -330,7 +330,7 @@ async function testPositionManagerEntryExposesSellPriceInBts() {
|
|
|
330
330
|
const mpaUtilsPath = require.resolve('../modules/mpa_utils');
|
|
331
331
|
|
|
332
332
|
const originalMpaUtils = setCachedModule(mpaUtilsPath, {
|
|
333
|
-
requireBtsBackedMpa: async (sym) => ({
|
|
333
|
+
requireBtsBackedMpa: async (sym: string) => ({
|
|
334
334
|
backingAsset: { id: '1.3.0', symbol: 'BTS', precision: 5 },
|
|
335
335
|
mpaAsset: { id: `1.3.${sym.length}`, symbol: sym, precision: 5, bitasset_data_id: '2.4.1' }
|
|
336
336
|
})
|
|
@@ -342,7 +342,7 @@ async function testPositionManagerEntryExposesSellPriceInBts() {
|
|
|
342
342
|
const savedState: any = {};
|
|
343
343
|
const pm = new PositionManager({
|
|
344
344
|
loadState: async () => savedState.data || { positions: [] },
|
|
345
|
-
saveState: async (state) => { savedState.data = state; }
|
|
345
|
+
saveState: async (state: any) => { savedState.data = state; }
|
|
346
346
|
});
|
|
347
347
|
|
|
348
348
|
const position = await pm.createShortPosition({
|
|
@@ -364,9 +364,9 @@ function testClawBridgeRespectsRuntimeNameOption() {
|
|
|
364
364
|
const clawBridgePath = require.resolve('../modules/claw_bridge');
|
|
365
365
|
const clawInfraPath = require.resolve('../modules/claw_infra');
|
|
366
366
|
|
|
367
|
-
let capturedOptions = null;
|
|
367
|
+
let capturedOptions: any = null;
|
|
368
368
|
const originalClawInfra = setCachedModule(clawInfraPath, {
|
|
369
|
-
createClawInfrastructure: (opts) => {
|
|
369
|
+
createClawInfrastructure: (opts: any) => {
|
|
370
370
|
capturedOptions = opts;
|
|
371
371
|
return {
|
|
372
372
|
runtime: { name: opts.runtime?.name || 'claw-bridge' },
|
|
@@ -400,43 +400,43 @@ function testClawBridgeScriptManifestUsesRuntimeSpecificDescriptors() {
|
|
|
400
400
|
|
|
401
401
|
const hermesManifest = describeRuntimeManifest('hermes', {});
|
|
402
402
|
assert.strictEqual(hermesManifest.compatibility.name, 'Hermes');
|
|
403
|
-
assert.strictEqual(hermesManifest.commandExamples.some((example) => example.includes('scripts/claw_bridge.ts')), true);
|
|
403
|
+
assert.strictEqual(hermesManifest.commandExamples.some((example: any) => example.includes('scripts/claw_bridge.ts')), true);
|
|
404
404
|
|
|
405
405
|
const openclawManifest = describeRuntimeManifest('openclaw', {});
|
|
406
406
|
assert.strictEqual(openclawManifest.compatibility.name, 'OpenClaw');
|
|
407
|
-
assert.strictEqual(openclawManifest.commandExamples.some((example) => example.includes('scripts/claw_bridge.ts')), true);
|
|
407
|
+
assert.strictEqual(openclawManifest.commandExamples.some((example: any) => example.includes('scripts/claw_bridge.ts')), true);
|
|
408
408
|
|
|
409
409
|
const openfangManifest = describeRuntimeManifest('openfang', {});
|
|
410
410
|
assert.strictEqual(openfangManifest.compatibility.name, 'OpenFang');
|
|
411
|
-
assert.strictEqual(openfangManifest.commandExamples.some((example) => example.includes('claw_bridge.ts')), true);
|
|
411
|
+
assert.strictEqual(openfangManifest.commandExamples.some((example: any) => example.includes('claw_bridge.ts')), true);
|
|
412
412
|
|
|
413
413
|
const nanoclawManifest = describeRuntimeManifest('nanoclaw', {});
|
|
414
414
|
assert.strictEqual(nanoclawManifest.compatibility.name, 'NanoClaw');
|
|
415
|
-
assert.strictEqual(nanoclawManifest.commandExamples.some((example) => example.includes('claw_bridge.ts')), true);
|
|
415
|
+
assert.strictEqual(nanoclawManifest.commandExamples.some((example: any) => example.includes('claw_bridge.ts')), true);
|
|
416
416
|
|
|
417
417
|
const nullclawManifest = describeRuntimeManifest('nullclaw', {});
|
|
418
418
|
assert.strictEqual(nullclawManifest.compatibility.name, 'NullClaw');
|
|
419
|
-
assert.strictEqual(nullclawManifest.commandExamples.some((example) => example.includes('claw_bridge.ts')), true);
|
|
419
|
+
assert.strictEqual(nullclawManifest.commandExamples.some((example: any) => example.includes('claw_bridge.ts')), true);
|
|
420
420
|
|
|
421
421
|
const zeroclawManifest = describeRuntimeManifest('zeroclaw', {});
|
|
422
422
|
assert.strictEqual(zeroclawManifest.compatibility.name, 'ZeroClaw');
|
|
423
|
-
assert.strictEqual(zeroclawManifest.commandExamples.some((example) => example.includes('claw_bridge.ts')), true);
|
|
423
|
+
assert.strictEqual(zeroclawManifest.commandExamples.some((example: any) => example.includes('claw_bridge.ts')), true);
|
|
424
424
|
|
|
425
425
|
const genericManifest = describeRuntimeManifest(null, {});
|
|
426
426
|
assert.strictEqual(genericManifest.compatibility.name, 'Claw');
|
|
427
|
-
assert.strictEqual(genericManifest.commandExamples.some((example) => example.includes('scripts/claw_bridge.ts')), true);
|
|
427
|
+
assert.strictEqual(genericManifest.commandExamples.some((example: any) => example.includes('scripts/claw_bridge.ts')), true);
|
|
428
428
|
|
|
429
429
|
const payloadSelectedManifest = describeRuntimeManifest(null, { runtimeName: 'openfang' });
|
|
430
430
|
assert.strictEqual(payloadSelectedManifest.compatibility.name, 'OpenFang');
|
|
431
|
-
assert.strictEqual(payloadSelectedManifest.commandExamples.some((example) => example.includes('claw_bridge.ts')), true);
|
|
431
|
+
assert.strictEqual(payloadSelectedManifest.commandExamples.some((example: any) => example.includes('claw_bridge.ts')), true);
|
|
432
432
|
|
|
433
433
|
const normalizedPayloadManifest = describeRuntimeManifest(null, { runtimeName: ' OpenFang ' });
|
|
434
434
|
assert.strictEqual(normalizedPayloadManifest.compatibility.name, 'OpenFang');
|
|
435
|
-
assert.strictEqual(normalizedPayloadManifest.commandExamples.some((example) => example.includes('claw_bridge.ts')), true);
|
|
435
|
+
assert.strictEqual(normalizedPayloadManifest.commandExamples.some((example: any) => example.includes('claw_bridge.ts')), true);
|
|
436
436
|
|
|
437
437
|
const hermesPayloadManifest = describeRuntimeManifest(null, { runtimeName: ' Hermes ' });
|
|
438
438
|
assert.strictEqual(hermesPayloadManifest.compatibility.name, 'Hermes');
|
|
439
|
-
assert.strictEqual(hermesPayloadManifest.commandExamples.some((example) => example.includes('scripts/claw_bridge.ts')), true);
|
|
439
|
+
assert.strictEqual(hermesPayloadManifest.commandExamples.some((example: any) => example.includes('scripts/claw_bridge.ts')), true);
|
|
440
440
|
|
|
441
441
|
clearModule(scriptPath);
|
|
442
442
|
}
|
|
@@ -451,19 +451,19 @@ async function testRuntimeCommandManifestUsesRuntimeSpecificDescriptors() {
|
|
|
451
451
|
|
|
452
452
|
const openfangManifest = await runClawCommand('manifest', { runtimeName: 'openfang' });
|
|
453
453
|
assert.strictEqual(openfangManifest.compatibility.name, 'OpenFang');
|
|
454
|
-
assert.strictEqual(openfangManifest.commandExamples.some((example) => example.includes('claw_bridge.ts')), true);
|
|
454
|
+
assert.strictEqual(openfangManifest.commandExamples.some((example: any) => example.includes('claw_bridge.ts')), true);
|
|
455
455
|
|
|
456
456
|
const nanoclawManifest = await runClawCommand('manifest', { runtimeName: 'nanoclaw' });
|
|
457
457
|
assert.strictEqual(nanoclawManifest.compatibility.name, 'NanoClaw');
|
|
458
|
-
assert.strictEqual(nanoclawManifest.commandExamples.some((example) => example.includes('claw_bridge.ts')), true);
|
|
458
|
+
assert.strictEqual(nanoclawManifest.commandExamples.some((example: any) => example.includes('claw_bridge.ts')), true);
|
|
459
459
|
|
|
460
460
|
const nullclawManifest = await runClawCommand('manifest', { runtimeName: 'nullclaw' });
|
|
461
461
|
assert.strictEqual(nullclawManifest.compatibility.name, 'NullClaw');
|
|
462
|
-
assert.strictEqual(nullclawManifest.commandExamples.some((example) => example.includes('claw_bridge.ts')), true);
|
|
462
|
+
assert.strictEqual(nullclawManifest.commandExamples.some((example: any) => example.includes('claw_bridge.ts')), true);
|
|
463
463
|
|
|
464
464
|
const zeroclawManifest = await runClawCommand('manifest', { runtimeName: 'zeroclaw' });
|
|
465
465
|
assert.strictEqual(zeroclawManifest.compatibility.name, 'ZeroClaw');
|
|
466
|
-
assert.strictEqual(zeroclawManifest.commandExamples.some((example) => example.includes('claw_bridge.ts')), true);
|
|
466
|
+
assert.strictEqual(zeroclawManifest.commandExamples.some((example: any) => example.includes('claw_bridge.ts')), true);
|
|
467
467
|
}
|
|
468
468
|
|
|
469
469
|
function testAccountOrdersBotKeyFallsBackToAssetIds() {
|
|
@@ -508,11 +508,11 @@ function testBuildQueryScopesAnyPoolByReceivedAsset() {
|
|
|
508
508
|
});
|
|
509
509
|
const poolFilters = poolScoped.query.bool.filter;
|
|
510
510
|
assert.ok(
|
|
511
|
-
poolFilters.some((f) => f.term?.['operation_history.op_object.pool.keyword'] === '1.19.133'),
|
|
511
|
+
poolFilters.some((f: any) => f.term?.['operation_history.op_object.pool.keyword'] === '1.19.133'),
|
|
512
512
|
'pool-scoped query should filter by pool'
|
|
513
513
|
);
|
|
514
514
|
assert.ok(
|
|
515
|
-
!poolFilters.some((f) => f.term?.['operation_history.op_object.min_to_receive.asset_id.keyword']),
|
|
515
|
+
!poolFilters.some((f: any) => f.term?.['operation_history.op_object.min_to_receive.asset_id.keyword']),
|
|
516
516
|
'pool-scoped query should not add receivedAssetId filter'
|
|
517
517
|
);
|
|
518
518
|
|
|
@@ -528,11 +528,11 @@ function testBuildQueryScopesAnyPoolByReceivedAsset() {
|
|
|
528
528
|
});
|
|
529
529
|
const pairFilters = pairScoped.query.bool.filter;
|
|
530
530
|
assert.ok(
|
|
531
|
-
!pairFilters.some((f) => f.term?.['operation_history.op_object.pool.keyword']),
|
|
531
|
+
!pairFilters.some((f: any) => f.term?.['operation_history.op_object.pool.keyword']),
|
|
532
532
|
'any-pool query should not have pool filter'
|
|
533
533
|
);
|
|
534
534
|
assert.ok(
|
|
535
|
-
pairFilters.some((f) => f.term?.['operation_history.op_object.min_to_receive.asset_id.keyword'] === '1.3.1'),
|
|
535
|
+
pairFilters.some((f: any) => f.term?.['operation_history.op_object.min_to_receive.asset_id.keyword'] === '1.3.1'),
|
|
536
536
|
'any-pool query should filter by received asset ID'
|
|
537
537
|
);
|
|
538
538
|
}
|
|
@@ -5,7 +5,7 @@ const fs = require('fs/promises');
|
|
|
5
5
|
const os = require('os');
|
|
6
6
|
const path = require('path');
|
|
7
7
|
|
|
8
|
-
function countOccurrences(text, needle) {
|
|
8
|
+
function countOccurrences(text: string, needle: string) {
|
|
9
9
|
return (text.match(new RegExp(needle.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'), 'g')) || []).length;
|
|
10
10
|
}
|
|
11
11
|
|
|
@@ -15,14 +15,14 @@ async function testConcurrentUpdatesPreserveBothWrites() {
|
|
|
15
15
|
const secondStore = createStateStore({ filePath, defaultValue: {} });
|
|
16
16
|
|
|
17
17
|
await Promise.all([
|
|
18
|
-
firstStore.update(async (state) => {
|
|
18
|
+
firstStore.update(async (state: any) => {
|
|
19
19
|
await new Promise((resolve) => setTimeout(resolve, 60));
|
|
20
20
|
return {
|
|
21
21
|
...(state || {}),
|
|
22
22
|
alpha: 1
|
|
23
23
|
};
|
|
24
24
|
}),
|
|
25
|
-
secondStore.update(async (state) => ({
|
|
25
|
+
secondStore.update(async (state: any) => ({
|
|
26
26
|
...(state || {}),
|
|
27
27
|
beta: 1
|
|
28
28
|
}))
|
|
@@ -15,11 +15,11 @@ const {
|
|
|
15
15
|
} = require('../modules/dexbot_profiles');
|
|
16
16
|
|
|
17
17
|
function createCaptureLogger() {
|
|
18
|
-
const messages = [];
|
|
18
|
+
const messages: any[] = [];
|
|
19
19
|
return {
|
|
20
20
|
logger: {
|
|
21
|
-
log: (msg) => messages.push(String(msg)),
|
|
22
|
-
warn: (msg) => messages.push(String(msg))
|
|
21
|
+
log: (msg: any) => messages.push(String(msg)),
|
|
22
|
+
warn: (msg: any) => messages.push(String(msg))
|
|
23
23
|
},
|
|
24
24
|
messages
|
|
25
25
|
};
|
|
@@ -459,7 +459,7 @@ async function testNestedPatchValidationDoesNotDuplicateErrors() {
|
|
|
459
459
|
forceReload: true
|
|
460
460
|
});
|
|
461
461
|
|
|
462
|
-
const sellErrors = preview.errors.filter((entry) => entry === 'weightDistribution.sell must be a finite number');
|
|
462
|
+
const sellErrors = preview.errors.filter((entry: any) => entry === 'weightDistribution.sell must be a finite number');
|
|
463
463
|
assert.strictEqual(sellErrors.length, 1, 'nested patch validation should not duplicate the same field error');
|
|
464
464
|
}
|
|
465
465
|
|
|
@@ -8,7 +8,7 @@ const { spawnSync } = require('child_process');
|
|
|
8
8
|
const { getStorage } = require('../../modules/storage');
|
|
9
9
|
const { ensureDir } = getStorage();
|
|
10
10
|
|
|
11
|
-
function writeFakeMemuPackage(tmpRoot) {
|
|
11
|
+
function writeFakeMemuPackage(tmpRoot: string) {
|
|
12
12
|
const memuDir = path.join(tmpRoot, 'memu');
|
|
13
13
|
ensureDir(memuDir);
|
|
14
14
|
fs.writeFileSync(path.join(memuDir, '__init__.py'), `
|
|
@@ -94,7 +94,7 @@ class MemoryService:
|
|
|
94
94
|
`);
|
|
95
95
|
}
|
|
96
96
|
|
|
97
|
-
function runMemuRunner(args) {
|
|
97
|
+
function runMemuRunner(args: any[]) {
|
|
98
98
|
const tmpRoot = fs.mkdtempSync(path.join(os.tmpdir(), 'dexbot2-memu-test-'));
|
|
99
99
|
const candidatePaths = [
|
|
100
100
|
path.resolve(__dirname, '..', 'scripts', 'memu_runner.py'),
|
|
@@ -122,7 +122,7 @@ function runMemuRunner(args) {
|
|
|
122
122
|
}
|
|
123
123
|
}
|
|
124
124
|
|
|
125
|
-
function parseRun(run, label) {
|
|
125
|
+
function parseRun(run: any, label: string) {
|
|
126
126
|
assert.strictEqual(run.code, 0, `${label} failed:\nSTDERR:\n${run.stderr}\nSTDOUT:\n${run.stdout}`);
|
|
127
127
|
return JSON.parse(run.stdout.trim());
|
|
128
128
|
}
|
|
@@ -42,7 +42,7 @@ async function main() {
|
|
|
42
42
|
assert.strictEqual(manifest.options.runtimeName, 'nullclaw');
|
|
43
43
|
assert.strictEqual(manifest.options.profileRoot, dexbotRoot);
|
|
44
44
|
assert.strictEqual(manifest.compatibility.recommendedTransport, 'skill-toml-or-mcp');
|
|
45
|
-
assert.ok(manifest.commandExamples.some((example) => example.includes('claw_bridge.ts')));
|
|
45
|
+
assert.ok(manifest.commandExamples.some((example: any) => example.includes('claw_bridge.ts')));
|
|
46
46
|
assert.ok(Array.isArray(manifest.tools.catalog));
|
|
47
47
|
assert.strictEqual(runtime.name, 'nullclaw');
|
|
48
48
|
assert.strictEqual(runtime.profileRoot, dexbotRoot);
|
|
@@ -85,7 +85,7 @@ function testTrendAlignment() {
|
|
|
85
85
|
|
|
86
86
|
// --- assessPosition: two-layer actions ---
|
|
87
87
|
|
|
88
|
-
function makePosition(cr, debtAmount = 100) {
|
|
88
|
+
function makePosition(cr: any, debtAmount: any = 100) {
|
|
89
89
|
return {
|
|
90
90
|
id: 'test_pos',
|
|
91
91
|
status: 'debt_open',
|
|
@@ -160,7 +160,7 @@ function testAssessTrendOpposed() {
|
|
|
160
160
|
const trend = { trend: 'UP', confidence: 70, premium: 1.5 };
|
|
161
161
|
const result = assessPosition(makePosition(2.2), trend);
|
|
162
162
|
assert.strictEqual(result.trend.alignment, 'opposed');
|
|
163
|
-
const reviewAction = result.actions.find(a => a.action === 'review_direction');
|
|
163
|
+
const reviewAction = result.actions.find((a: any) => a.action === 'review_direction');
|
|
164
164
|
assert.ok(reviewAction, 'should have review_direction action');
|
|
165
165
|
assert.strictEqual(reviewAction.priority, 'evaluate');
|
|
166
166
|
|
|
@@ -5,11 +5,11 @@ const fs = require('fs/promises');
|
|
|
5
5
|
const os = require('os');
|
|
6
6
|
const path = require('path');
|
|
7
7
|
|
|
8
|
-
function clearModule(modulePath) {
|
|
8
|
+
function clearModule(modulePath: string) {
|
|
9
9
|
delete require.cache[modulePath];
|
|
10
10
|
}
|
|
11
11
|
|
|
12
|
-
function registerMock(modulePath, exports) {
|
|
12
|
+
function registerMock(modulePath: string, exports: any) {
|
|
13
13
|
require.cache[modulePath] = {
|
|
14
14
|
id: modulePath,
|
|
15
15
|
filename: modulePath,
|
|
@@ -31,11 +31,11 @@ async function createHarness() {
|
|
|
31
31
|
const statePath = path.join(tempDir, 'positions.json');
|
|
32
32
|
|
|
33
33
|
const calls = {
|
|
34
|
-
closeShortOnBts: [],
|
|
35
|
-
listenForFills: [],
|
|
36
|
-
openShortOnBts: [],
|
|
37
|
-
placeTakeProfitBuyOrderOnBts: [],
|
|
38
|
-
savedStates: []
|
|
34
|
+
closeShortOnBts: [] as any[],
|
|
35
|
+
listenForFills: [] as any[],
|
|
36
|
+
openShortOnBts: [] as any[],
|
|
37
|
+
placeTakeProfitBuyOrderOnBts: [] as any[],
|
|
38
|
+
savedStates: [] as any[]
|
|
39
39
|
};
|
|
40
40
|
|
|
41
41
|
const coreAsset = { id: '1.3.0', precision: 5, symbol: 'BTS' };
|
|
@@ -46,7 +46,7 @@ async function createHarness() {
|
|
|
46
46
|
symbol: 'HONEST.USD'
|
|
47
47
|
};
|
|
48
48
|
|
|
49
|
-
let accountSnapshot = {
|
|
49
|
+
let accountSnapshot: any = {
|
|
50
50
|
balances: [{ asset_type: '1.3.0', balance: 500000 }],
|
|
51
51
|
call_orders: [],
|
|
52
52
|
limit_orders: []
|
|
@@ -54,19 +54,19 @@ async function createHarness() {
|
|
|
54
54
|
|
|
55
55
|
registerMock(bridgePath, {
|
|
56
56
|
loadDexbotOrderUtils: () => ({
|
|
57
|
-
blockchainToFloat: (amount, precision) => Number(amount) / (10 ** precision)
|
|
57
|
+
blockchainToFloat: (amount: number, precision: number) => Number(amount) / (10 ** precision)
|
|
58
58
|
})
|
|
59
59
|
});
|
|
60
60
|
|
|
61
61
|
registerMock(profilesPath, {
|
|
62
|
-
writeJsonFileAtomic: async (filePath, state) => {
|
|
62
|
+
writeJsonFileAtomic: async (filePath: string, state: any) => {
|
|
63
63
|
calls.savedStates.push({ filePath, state: clone(state) });
|
|
64
64
|
await fs.writeFile(filePath, JSON.stringify(state, null, 2));
|
|
65
65
|
}
|
|
66
66
|
});
|
|
67
67
|
|
|
68
68
|
registerMock(shortStrategyPath, {
|
|
69
|
-
closeShortOnBts: async (options) => {
|
|
69
|
+
closeShortOnBts: async (options: any) => {
|
|
70
70
|
calls.closeShortOnBts.push(options);
|
|
71
71
|
accountSnapshot = {
|
|
72
72
|
...accountSnapshot,
|
|
@@ -79,7 +79,7 @@ async function createHarness() {
|
|
|
79
79
|
}
|
|
80
80
|
};
|
|
81
81
|
},
|
|
82
|
-
openShortOnBts: async (options) => {
|
|
82
|
+
openShortOnBts: async (options: any) => {
|
|
83
83
|
calls.openShortOnBts.push(options);
|
|
84
84
|
accountSnapshot = {
|
|
85
85
|
...accountSnapshot,
|
|
@@ -106,7 +106,7 @@ async function createHarness() {
|
|
|
106
106
|
}
|
|
107
107
|
};
|
|
108
108
|
},
|
|
109
|
-
placeTakeProfitBuyOrderOnBts: async (options) => {
|
|
109
|
+
placeTakeProfitBuyOrderOnBts: async (options: any) => {
|
|
110
110
|
calls.placeTakeProfitBuyOrderOnBts.push(options);
|
|
111
111
|
accountSnapshot = {
|
|
112
112
|
...accountSnapshot,
|
|
@@ -131,7 +131,7 @@ async function createHarness() {
|
|
|
131
131
|
});
|
|
132
132
|
|
|
133
133
|
registerMock(actionsPath, {
|
|
134
|
-
listenForFills: async (accountName, callback) => {
|
|
134
|
+
listenForFills: async (accountName: string, callback: any) => {
|
|
135
135
|
calls.listenForFills.push({ accountName, callback });
|
|
136
136
|
return async () => {
|
|
137
137
|
calls.listenForFills.push({ accountName, type: 'unsubscribe' });
|
|
@@ -140,7 +140,7 @@ async function createHarness() {
|
|
|
140
140
|
});
|
|
141
141
|
|
|
142
142
|
registerMock(queriesPath, {
|
|
143
|
-
getAsset: async (symbolOrId) => {
|
|
143
|
+
getAsset: async (symbolOrId: string) => {
|
|
144
144
|
if (symbolOrId === 'BTS' || symbolOrId === coreAsset.id) {
|
|
145
145
|
return coreAsset;
|
|
146
146
|
}
|
|
@@ -177,7 +177,7 @@ async function createHarness() {
|
|
|
177
177
|
clearModule(shortStrategyPath);
|
|
178
178
|
},
|
|
179
179
|
manager: new PositionManager({ statePath }),
|
|
180
|
-
setAccountSnapshot(nextSnapshot) {
|
|
180
|
+
setAccountSnapshot(nextSnapshot: any) {
|
|
181
181
|
accountSnapshot = clone(nextSnapshot);
|
|
182
182
|
},
|
|
183
183
|
statePath
|
|
@@ -224,7 +224,7 @@ async function testPositionManagerLifecycle() {
|
|
|
224
224
|
|
|
225
225
|
const watchedPositionId = planned.id;
|
|
226
226
|
const state = await manager.loadState();
|
|
227
|
-
const watchedPosition = state.positions.find((entry) => entry.id === watchedPositionId);
|
|
227
|
+
const watchedPosition = state.positions.find((entry: any) => entry.id === watchedPositionId);
|
|
228
228
|
watchedPosition.entry.orderId = '1.7.500';
|
|
229
229
|
watchedPosition.entry.orderOpen = true;
|
|
230
230
|
watchedPosition.status = 'entry_order_open';
|
|
@@ -251,7 +251,7 @@ async function testPositionManagerLifecycle() {
|
|
|
251
251
|
const accountState = await manager.getPosition(watchedPositionId);
|
|
252
252
|
assert.strictEqual(accountState.entry.orderId, '1.7.500');
|
|
253
253
|
|
|
254
|
-
const unsubscribe = await manager.watchAccount('alice', async (position, fill) => {
|
|
254
|
+
const unsubscribe = await manager.watchAccount('alice', async (position: any, fill: any) => {
|
|
255
255
|
calls.listenForFills.push({ accountName: 'alice', fill, type: 'onFill', positionId: position.id });
|
|
256
256
|
});
|
|
257
257
|
|
|
@@ -11,12 +11,12 @@ const watcherModulePath = require.resolve('../modules/position_manager_watch');
|
|
|
11
11
|
const positionManagerPath = require.resolve('../modules/position_manager');
|
|
12
12
|
const bitsharesClientPath = require.resolve('../modules/bitshares_client');
|
|
13
13
|
|
|
14
|
-
function loadWatcherModule(mockPositionManager, waitForConnected) {
|
|
14
|
+
function loadWatcherModule(mockPositionManager: any, waitForConnected: any) {
|
|
15
15
|
delete require.cache[watcherModulePath];
|
|
16
16
|
delete require.cache[positionManagerPath];
|
|
17
17
|
delete require.cache[bitsharesClientPath];
|
|
18
18
|
|
|
19
|
-
Module._load = function(request, parent, isMain) {
|
|
19
|
+
Module._load = function(request: any, parent: any, isMain: any) {
|
|
20
20
|
if (['./position_manager', './position_manager.js'].includes(request) && parent?.filename === watcherModulePath) {
|
|
21
21
|
return {
|
|
22
22
|
DEFAULT_STATE_PATH: path.join(os.tmpdir(), 'unused-positions.json'),
|
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
|
|
3
3
|
const assert = require('assert');
|
|
4
4
|
|
|
5
|
-
function clearModule(modulePath) {
|
|
5
|
+
function clearModule(modulePath: string) {
|
|
6
6
|
delete require.cache[modulePath];
|
|
7
7
|
}
|
|
8
8
|
|
|
9
|
-
function registerMock(modulePath, exports) {
|
|
9
|
+
function registerMock(modulePath: string, exports: any) {
|
|
10
10
|
require.cache[modulePath] = {
|
|
11
11
|
id: modulePath,
|
|
12
12
|
filename: modulePath,
|
|
@@ -21,29 +21,29 @@ function createStrategyHarness() {
|
|
|
21
21
|
const chainQueriesPath = require.resolve('../modules/chain_queries');
|
|
22
22
|
|
|
23
23
|
const calls = {
|
|
24
|
-
borrowMpa: [],
|
|
25
|
-
createLimitOrder: [],
|
|
26
|
-
getAsset: [],
|
|
27
|
-
getBackingAsset: [],
|
|
28
|
-
repayMpaDebt: []
|
|
24
|
+
borrowMpa: [] as any[],
|
|
25
|
+
createLimitOrder: [] as any[],
|
|
26
|
+
getAsset: [] as string[],
|
|
27
|
+
getBackingAsset: [] as string[],
|
|
28
|
+
repayMpaDebt: [] as any[]
|
|
29
29
|
};
|
|
30
30
|
|
|
31
31
|
registerMock(chainActionsPath, {
|
|
32
|
-
borrowMpa: async (options) => {
|
|
32
|
+
borrowMpa: async (options: any) => {
|
|
33
33
|
calls.borrowMpa.push(options);
|
|
34
34
|
return {
|
|
35
35
|
options,
|
|
36
36
|
source: 'borrowMpa'
|
|
37
37
|
};
|
|
38
38
|
},
|
|
39
|
-
createLimitOrder: async (options) => {
|
|
39
|
+
createLimitOrder: async (options: any) => {
|
|
40
40
|
calls.createLimitOrder.push(options);
|
|
41
41
|
return {
|
|
42
42
|
options,
|
|
43
43
|
source: 'createLimitOrder'
|
|
44
44
|
};
|
|
45
45
|
},
|
|
46
|
-
repayMpaDebt: async (options) => {
|
|
46
|
+
repayMpaDebt: async (options: any) => {
|
|
47
47
|
calls.repayMpaDebt.push(options);
|
|
48
48
|
return {
|
|
49
49
|
options,
|
|
@@ -53,7 +53,7 @@ function createStrategyHarness() {
|
|
|
53
53
|
});
|
|
54
54
|
|
|
55
55
|
registerMock(chainQueriesPath, {
|
|
56
|
-
getAsset: async (symbolOrId) => {
|
|
56
|
+
getAsset: async (symbolOrId: string) => {
|
|
57
57
|
calls.getAsset.push(symbolOrId);
|
|
58
58
|
return {
|
|
59
59
|
bitasset_data_id: '2.4.100',
|
|
@@ -62,7 +62,7 @@ function createStrategyHarness() {
|
|
|
62
62
|
symbol: 'HONEST.USD'
|
|
63
63
|
};
|
|
64
64
|
},
|
|
65
|
-
getBackingAsset: async (assetId) => {
|
|
65
|
+
getBackingAsset: async (assetId: string) => {
|
|
66
66
|
calls.getBackingAsset.push(assetId);
|
|
67
67
|
return {
|
|
68
68
|
id: '1.3.0',
|
|
@@ -5,11 +5,23 @@ declare function escapeHtml(str: string): string;
|
|
|
5
5
|
declare function serializeJsonForScript(value: any): string;
|
|
6
6
|
declare function toEpochSeconds(ts: any, fallbackIdx: any): number;
|
|
7
7
|
declare function writeChartFile(filePath: any, html: any): void;
|
|
8
|
+
/**
|
|
9
|
+
* Serialize the exact source of the given pure functions for injection into a
|
|
10
|
+
* generated HTML <script> block. Each function is emitted as a top-level
|
|
11
|
+
* function declaration (Function.prototype.toString()), so browser-embedded
|
|
12
|
+
* charts run the same logic as the Node-side modules instead of a hand-copied
|
|
13
|
+
* copy. Functions must be self-contained (no imports or module-level constants
|
|
14
|
+
* referenced from their bodies); callers pass all config values explicitly.
|
|
15
|
+
*
|
|
16
|
+
* The emitted block is wrapped in marker comments so test harnesses can extract
|
|
17
|
+
* the embedded sources reliably regardless of the function list or ordering.
|
|
18
|
+
*/
|
|
19
|
+
declare function embedFunctionSources(fns: Array<Function>): string;
|
|
8
20
|
/**
|
|
9
21
|
* Shared uPlot interaction boilerplate for embedded browser scripts.
|
|
10
22
|
* Consumers must define `xMin`, `xMax`, `charts`, `pendingRange`, and `pendingRangeRaf`
|
|
11
23
|
* before embedding this script block.
|
|
12
24
|
*/
|
|
13
25
|
declare const UPLOT_SHARED_SCRIPT = "\nfunction clampXRange(min, max) {\n let nextMin = min, nextMax = max;\n if (!Number.isFinite(nextMin) || !Number.isFinite(nextMax) || nextMax <= nextMin) {\n return { min: xMin, max: xMax };\n }\n if (nextMin < xMin) { nextMax += xMin - nextMin; nextMin = xMin; }\n if (nextMax > xMax) { nextMin -= nextMax - xMax; nextMax = xMax; }\n if (nextMin < xMin) nextMin = xMin;\n if (nextMax > xMax) nextMax = xMax;\n if (nextMax <= nextMin) return { min: xMin, max: xMax };\n return { min: nextMin, max: nextMax };\n}\n\nfunction syncXRange(min, max) {\n pendingRange = clampXRange(min, max);\n if (pendingRangeRaf) return;\n const raf = typeof requestAnimationFrame !== 'undefined' ? requestAnimationFrame.bind(window) : (fn) => setTimeout(fn, 0);\n pendingRangeRaf = raf(() => {\n const next = pendingRange;\n pendingRange = null;\n pendingRangeRaf = 0;\n if (!next) return;\n charts.forEach(c => c && c.batch(() => c.setScale('x', next)));\n });\n}\n\nfunction bindWheelZoom(chart) {\n chart.root.addEventListener('wheel', (e) => {\n if (e.ctrlKey || e.metaKey || e.altKey) return;\n e.preventDefault();\n e.stopPropagation();\n const rect = chart.root.getBoundingClientRect();\n \n // Correctly calculate plot-relative 'left' for accurate centering\n const left = e.clientX - rect.left - (chart.bbox.left / (chart.pxRatio || 1));\n const center = chart.posToVal(left, 'x');\n \n const s = chart.scales.x || {};\n const currMin = Number.isFinite(s.min) ? s.min : xMin;\n const currMax = Number.isFinite(s.max) ? s.max : xMax;\n const span = currMax - currMin;\n if (!Number.isFinite(span) || span <= 0) return;\n const factor = e.deltaY < 0 ? 0.85 : 1.15;\n const nextSpan = Math.max(1, Math.min(xMax - xMin, span * factor));\n const ratio = (center - currMin) / span;\n syncXRange(center - nextSpan * ratio, center - nextSpan * ratio + nextSpan);\n }, { passive: false });\n}\n\nfunction bindPan(chart) {\n let dragging = false, startClientX = 0, startClientY = 0, startMin = xMin, startMax = xMax, xUnitsPerPx = 0;\n const getScale = () => {\n const s = chart.scales.x || {};\n return { currMin: Number.isFinite(s.min) ? s.min : xMin, currMax: Number.isFinite(s.max) ? s.max : xMax };\n };\n const onMouseMove = (e) => {\n if (!dragging) return;\n \n // Ignore if vertical movement is dominant (likely scrolling)\n if (Math.abs(e.clientY - startClientY) > 20) return;\n \n e.preventDefault();\n const deltaPx = e.clientX - startClientX;\n const deltaVal = deltaPx * xUnitsPerPx;\n syncXRange(startMin - deltaVal, startMax - deltaVal);\n };\n const endDrag = () => {\n if (!dragging) return;\n dragging = false;\n document.body.style.cursor = '';\n window.removeEventListener('mousemove', onMouseMove);\n window.removeEventListener('mouseup', endDrag);\n };\n chart.root.addEventListener('mousedown', (e) => {\n if (!e || e.button !== 0 || e.ctrlKey || e.metaKey || e.altKey) return;\n const rect = chart.root.getBoundingClientRect();\n if (e.clientX < rect.left || e.clientX > rect.right || e.clientY < rect.top || e.clientY > rect.bottom) return;\n \n e.preventDefault();\n e.stopPropagation();\n \n dragging = true;\n startClientX = e.clientX;\n startClientY = e.clientY;\n const cur = getScale();\n startMin = cur.currMin; startMax = cur.currMax;\n \n // Calculate units per pixel once at start of drag to avoid sliding bug\n // chart.bbox.width is in device pixels; divide by pxRatio for CSS pixels\n xUnitsPerPx = (cur.currMax - cur.currMin) / (chart.bbox.width / (chart.pxRatio || 1));\n \n document.body.style.cursor = 'grabbing';\n window.addEventListener('mousemove', onMouseMove);\n window.addEventListener('mouseup', endDrag, { once: true });\n });\n}\n";
|
|
14
|
-
export { escapeHtml, serializeJsonForScript, toEpochSeconds, writeChartFile, UPLOT_SHARED_SCRIPT };
|
|
26
|
+
export { escapeHtml, serializeJsonForScript, toEpochSeconds, writeChartFile, embedFunctionSources, UPLOT_SHARED_SCRIPT };
|
|
15
27
|
//# sourceMappingURL=chart_utils.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chart_utils.d.ts","sourceRoot":"","sources":["../../analysis/chart_utils.ts"],"names":[],"mappings":"AAOA;;GAEG;AAGH,iBAAS,UAAU,CAAC,GAAG,EAAE,MAAM,UAS9B;AAED,iBAAS,sBAAsB,CAAC,KAAK,EAAE,GAAG,UAEzC;AAED,iBAAS,cAAc,CAAC,EAAE,EAAE,GAAG,EAAE,WAAW,EAAE,GAAG,UAIhD;AAED,iBAAS,cAAc,CAAC,QAAQ,EAAE,GAAG,EAAE,IAAI,EAAE,GAAG,QAI/C;AAED;;;;GAIG;AACH,QAAA,MAAM,mBAAmB,okIAiGxB,CAAC;AAEF,OAAO,EAAE,UAAU,EAAE,sBAAsB,EAAE,cAAc,EAAE,cAAc,EAAE,mBAAmB,EAAE,CAAA"}
|
|
1
|
+
{"version":3,"file":"chart_utils.d.ts","sourceRoot":"","sources":["../../analysis/chart_utils.ts"],"names":[],"mappings":"AAOA;;GAEG;AAGH,iBAAS,UAAU,CAAC,GAAG,EAAE,MAAM,UAS9B;AAED,iBAAS,sBAAsB,CAAC,KAAK,EAAE,GAAG,UAEzC;AAED,iBAAS,cAAc,CAAC,EAAE,EAAE,GAAG,EAAE,WAAW,EAAE,GAAG,UAIhD;AAED,iBAAS,cAAc,CAAC,QAAQ,EAAE,GAAG,EAAE,IAAI,EAAE,GAAG,QAI/C;AAED;;;;;;;;;;GAUG;AACH,iBAAS,oBAAoB,CAAC,GAAG,EAAE,KAAK,CAAC,QAAQ,CAAC,GAAG,MAAM,CAG1D;AAED;;;;GAIG;AACH,QAAA,MAAM,mBAAmB,okIAiGxB,CAAC;AAEF,OAAO,EAAE,UAAU,EAAE,sBAAsB,EAAE,cAAc,EAAE,cAAc,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,CAAA"}
|
|
@@ -31,6 +31,21 @@ function writeChartFile(filePath, html) {
|
|
|
31
31
|
ensureDir(chartDir);
|
|
32
32
|
fs.writeFileSync(filePath, html, 'utf8');
|
|
33
33
|
}
|
|
34
|
+
/**
|
|
35
|
+
* Serialize the exact source of the given pure functions for injection into a
|
|
36
|
+
* generated HTML <script> block. Each function is emitted as a top-level
|
|
37
|
+
* function declaration (Function.prototype.toString()), so browser-embedded
|
|
38
|
+
* charts run the same logic as the Node-side modules instead of a hand-copied
|
|
39
|
+
* copy. Functions must be self-contained (no imports or module-level constants
|
|
40
|
+
* referenced from their bodies); callers pass all config values explicitly.
|
|
41
|
+
*
|
|
42
|
+
* The emitted block is wrapped in marker comments so test harnesses can extract
|
|
43
|
+
* the embedded sources reliably regardless of the function list or ordering.
|
|
44
|
+
*/
|
|
45
|
+
function embedFunctionSources(fns) {
|
|
46
|
+
const sources = fns.map((fn) => fn.toString()).join('\n\n');
|
|
47
|
+
return `/* EMBEDDED_FUNCS_START */\n${sources}\n/* EMBEDDED_FUNCS_END */`;
|
|
48
|
+
}
|
|
34
49
|
/**
|
|
35
50
|
* Shared uPlot interaction boilerplate for embedded browser scripts.
|
|
36
51
|
* Consumers must define `xMin`, `xMax`, `charts`, `pendingRange`, and `pendingRangeRaf`
|
|
@@ -134,5 +149,5 @@ function bindPan(chart) {
|
|
|
134
149
|
});
|
|
135
150
|
}
|
|
136
151
|
`;
|
|
137
|
-
export { escapeHtml, serializeJsonForScript, toEpochSeconds, writeChartFile, UPLOT_SHARED_SCRIPT };
|
|
152
|
+
export { escapeHtml, serializeJsonForScript, toEpochSeconds, writeChartFile, embedFunctionSources, UPLOT_SHARED_SCRIPT };
|
|
138
153
|
//# sourceMappingURL=chart_utils.js.map
|