dexbot 1.4.13 → 1.4.14
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 +58 -34
- package/claw/data/positions.json +2487 -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 +37 -34
- 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/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/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/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 +3 -1
- package/scripts/README.md +4 -4
- 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
|
@@ -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,
|
|
@@ -23,34 +23,34 @@ function createBridgeHarness() {
|
|
|
23
23
|
const shortStrategyPath = require.resolve('../modules/short_mpa_strategy');
|
|
24
24
|
|
|
25
25
|
const calls = {
|
|
26
|
-
createClawInfrastructure: [],
|
|
26
|
+
createClawInfrastructure: [] as any[],
|
|
27
27
|
chainActions: {
|
|
28
|
-
adjustMpaCollateral: [],
|
|
29
|
-
borrowMpa: [],
|
|
30
|
-
buildUpdateLimitOrderOperation: [],
|
|
31
|
-
cancelLimitOrder: [],
|
|
32
|
-
createLimitOrder: [],
|
|
33
|
-
executeBatch: [],
|
|
34
|
-
getMpaPosition: [],
|
|
35
|
-
getOpenOrders: [],
|
|
36
|
-
repayMpaDebt: [],
|
|
37
|
-
settleMpa: [],
|
|
38
|
-
updateLimitOrder: []
|
|
28
|
+
adjustMpaCollateral: [] as any[],
|
|
29
|
+
borrowMpa: [] as any[],
|
|
30
|
+
buildUpdateLimitOrderOperation: [] as any[],
|
|
31
|
+
cancelLimitOrder: [] as any[],
|
|
32
|
+
createLimitOrder: [] as any[],
|
|
33
|
+
executeBatch: [] as any[],
|
|
34
|
+
getMpaPosition: [] as any[],
|
|
35
|
+
getOpenOrders: [] as any[],
|
|
36
|
+
repayMpaDebt: [] as any[],
|
|
37
|
+
settleMpa: [] as any[],
|
|
38
|
+
updateLimitOrder: [] as any[]
|
|
39
39
|
},
|
|
40
40
|
shortStrategy: {
|
|
41
|
-
buildCloseShortPlan: [],
|
|
42
|
-
buildOpenShortPlan: [],
|
|
43
|
-
buildTakeProfitPlan: [],
|
|
44
|
-
closeShortOnBts: [],
|
|
45
|
-
openShortOnBts: [],
|
|
46
|
-
placeTakeProfitBuyOrderOnBts: []
|
|
41
|
+
buildCloseShortPlan: [] as any[],
|
|
42
|
+
buildOpenShortPlan: [] as any[],
|
|
43
|
+
buildTakeProfitPlan: [] as any[],
|
|
44
|
+
closeShortOnBts: [] as any[],
|
|
45
|
+
openShortOnBts: [] as any[],
|
|
46
|
+
placeTakeProfitBuyOrderOnBts: [] as any[]
|
|
47
47
|
},
|
|
48
48
|
profiles: {
|
|
49
|
-
getBotSettings: [],
|
|
50
|
-
previewBotSettingsUpdate: [],
|
|
51
|
-
applyBotSettingsPatch: []
|
|
49
|
+
getBotSettings: [] as any[],
|
|
50
|
+
previewBotSettingsUpdate: [] as any[],
|
|
51
|
+
applyBotSettingsPatch: [] as any[]
|
|
52
52
|
},
|
|
53
|
-
memu: []
|
|
53
|
+
memu: [] as any[]
|
|
54
54
|
};
|
|
55
55
|
|
|
56
56
|
const bridgeRuntime = {
|
|
@@ -60,21 +60,21 @@ function createBridgeHarness() {
|
|
|
60
60
|
};
|
|
61
61
|
|
|
62
62
|
registerMock(infraPath, {
|
|
63
|
-
createClawInfrastructure: (options) => {
|
|
63
|
+
createClawInfrastructure: (options: any) => {
|
|
64
64
|
calls.createClawInfrastructure.push(options);
|
|
65
65
|
return {
|
|
66
66
|
honest: {
|
|
67
|
-
buildContext: async (options) => ({
|
|
67
|
+
buildContext: async (options: any) => ({
|
|
68
68
|
source: 'honest-context',
|
|
69
69
|
options
|
|
70
70
|
}),
|
|
71
|
-
resolvePairContext: async (assetA, assetB, options) => ({
|
|
71
|
+
resolvePairContext: async (assetA: any, assetB: any, options: any) => ({
|
|
72
72
|
assetA,
|
|
73
73
|
assetB,
|
|
74
74
|
options,
|
|
75
75
|
source: 'honest-pair'
|
|
76
76
|
}),
|
|
77
|
-
resolvePairPrice: async (assetA, assetB, options) => ({
|
|
77
|
+
resolvePairPrice: async (assetA: any, assetB: any, options: any) => ({
|
|
78
78
|
assetA,
|
|
79
79
|
assetB,
|
|
80
80
|
options,
|
|
@@ -82,11 +82,11 @@ function createBridgeHarness() {
|
|
|
82
82
|
})
|
|
83
83
|
},
|
|
84
84
|
market: {
|
|
85
|
-
readAccountSnapshot: async (accountName) => ({
|
|
85
|
+
readAccountSnapshot: async (accountName: any) => ({
|
|
86
86
|
accountName,
|
|
87
87
|
source: 'account-snapshot'
|
|
88
88
|
}),
|
|
89
|
-
readMarketSnapshot: async (baseSymbol, quoteSymbol, limit) => ({
|
|
89
|
+
readMarketSnapshot: async (baseSymbol: any, quoteSymbol: any, limit: any) => ({
|
|
90
90
|
baseSymbol,
|
|
91
91
|
limit,
|
|
92
92
|
quoteSymbol,
|
|
@@ -94,12 +94,12 @@ function createBridgeHarness() {
|
|
|
94
94
|
})
|
|
95
95
|
},
|
|
96
96
|
profiles: {
|
|
97
|
-
getClawProfileContext: async (ref, options) => ({
|
|
97
|
+
getClawProfileContext: async (ref: any, options: any) => ({
|
|
98
98
|
options,
|
|
99
99
|
ref,
|
|
100
100
|
selectedBot: { botId: ref, source: 'profile-context' }
|
|
101
101
|
}),
|
|
102
|
-
getBotSettings: async (ref, forceReload) => {
|
|
102
|
+
getBotSettings: async (ref: any, forceReload: any) => {
|
|
103
103
|
calls.profiles.getBotSettings.push({ forceReload, ref });
|
|
104
104
|
return {
|
|
105
105
|
forceReload,
|
|
@@ -107,7 +107,7 @@ function createBridgeHarness() {
|
|
|
107
107
|
source: 'bot-settings'
|
|
108
108
|
};
|
|
109
109
|
},
|
|
110
|
-
previewBotSettingsUpdate: async (ref, patch, options) => {
|
|
110
|
+
previewBotSettingsUpdate: async (ref: any, patch: any, options: any) => {
|
|
111
111
|
calls.profiles.previewBotSettingsUpdate.push({ options, patch, ref });
|
|
112
112
|
return {
|
|
113
113
|
options,
|
|
@@ -116,7 +116,7 @@ function createBridgeHarness() {
|
|
|
116
116
|
source: 'bot-settings-preview'
|
|
117
117
|
};
|
|
118
118
|
},
|
|
119
|
-
applyBotSettingsPatch: async (ref, patch, options) => {
|
|
119
|
+
applyBotSettingsPatch: async (ref: any, patch: any, options: any) => {
|
|
120
120
|
calls.profiles.applyBotSettingsPatch.push({ options, patch, ref });
|
|
121
121
|
return {
|
|
122
122
|
options,
|
|
@@ -136,8 +136,8 @@ function createBridgeHarness() {
|
|
|
136
136
|
}
|
|
137
137
|
});
|
|
138
138
|
|
|
139
|
-
const stubbedChainAction = (name) => async (options) => {
|
|
140
|
-
calls.chainActions[name].push(options);
|
|
139
|
+
const stubbedChainAction = (name: string) => async (options: any) => {
|
|
140
|
+
calls.chainActions[name as keyof typeof calls.chainActions].push(options);
|
|
141
141
|
return {
|
|
142
142
|
options,
|
|
143
143
|
source: name
|
|
@@ -147,7 +147,7 @@ function createBridgeHarness() {
|
|
|
147
147
|
registerMock(chainActionsPath, {
|
|
148
148
|
adjustMpaCollateral: stubbedChainAction('adjustMpaCollateral'),
|
|
149
149
|
borrowMpa: stubbedChainAction('borrowMpa'),
|
|
150
|
-
buildUpdateLimitOrderOperation: async (options) => {
|
|
150
|
+
buildUpdateLimitOrderOperation: async (options: any) => {
|
|
151
151
|
calls.chainActions.buildUpdateLimitOrderOperation.push(options);
|
|
152
152
|
return {
|
|
153
153
|
op: {
|
|
@@ -160,7 +160,7 @@ function createBridgeHarness() {
|
|
|
160
160
|
cancelLimitOrder: stubbedChainAction('cancelLimitOrder'),
|
|
161
161
|
createLimitOrder: stubbedChainAction('createLimitOrder'),
|
|
162
162
|
executeBatch: stubbedChainAction('executeBatch'),
|
|
163
|
-
getMpaPosition: async (accountNameOrId, mpaAsset) => {
|
|
163
|
+
getMpaPosition: async (accountNameOrId: any, mpaAsset: any) => {
|
|
164
164
|
calls.chainActions.getMpaPosition.push({ accountNameOrId, mpaAsset });
|
|
165
165
|
return {
|
|
166
166
|
accountNameOrId,
|
|
@@ -168,7 +168,7 @@ function createBridgeHarness() {
|
|
|
168
168
|
source: 'mpa-position'
|
|
169
169
|
};
|
|
170
170
|
},
|
|
171
|
-
getOpenOrders: async (accountNameOrId) => {
|
|
171
|
+
getOpenOrders: async (accountNameOrId: any) => {
|
|
172
172
|
calls.chainActions.getOpenOrders.push(accountNameOrId);
|
|
173
173
|
return {
|
|
174
174
|
accountNameOrId,
|
|
@@ -181,42 +181,42 @@ function createBridgeHarness() {
|
|
|
181
181
|
});
|
|
182
182
|
|
|
183
183
|
registerMock(shortStrategyPath, {
|
|
184
|
-
buildCloseShortPlan: async (options) => {
|
|
184
|
+
buildCloseShortPlan: async (options: any) => {
|
|
185
185
|
calls.shortStrategy.buildCloseShortPlan.push(options);
|
|
186
186
|
return {
|
|
187
187
|
options,
|
|
188
188
|
source: 'buildCloseShortPlan'
|
|
189
189
|
};
|
|
190
190
|
},
|
|
191
|
-
buildOpenShortPlan: async (options) => {
|
|
191
|
+
buildOpenShortPlan: async (options: any) => {
|
|
192
192
|
calls.shortStrategy.buildOpenShortPlan.push(options);
|
|
193
193
|
return {
|
|
194
194
|
options,
|
|
195
195
|
source: 'buildOpenShortPlan'
|
|
196
196
|
};
|
|
197
197
|
},
|
|
198
|
-
buildTakeProfitPlan: async (options) => {
|
|
198
|
+
buildTakeProfitPlan: async (options: any) => {
|
|
199
199
|
calls.shortStrategy.buildTakeProfitPlan.push(options);
|
|
200
200
|
return {
|
|
201
201
|
options,
|
|
202
202
|
source: 'buildTakeProfitPlan'
|
|
203
203
|
};
|
|
204
204
|
},
|
|
205
|
-
closeShortOnBts: async (options) => {
|
|
205
|
+
closeShortOnBts: async (options: any) => {
|
|
206
206
|
calls.shortStrategy.closeShortOnBts.push(options);
|
|
207
207
|
return {
|
|
208
208
|
options,
|
|
209
209
|
source: 'closeShortOnBts'
|
|
210
210
|
};
|
|
211
211
|
},
|
|
212
|
-
openShortOnBts: async (options) => {
|
|
212
|
+
openShortOnBts: async (options: any) => {
|
|
213
213
|
calls.shortStrategy.openShortOnBts.push(options);
|
|
214
214
|
return {
|
|
215
215
|
options,
|
|
216
216
|
source: 'openShortOnBts'
|
|
217
217
|
};
|
|
218
218
|
},
|
|
219
|
-
placeTakeProfitBuyOrderOnBts: async (options) => {
|
|
219
|
+
placeTakeProfitBuyOrderOnBts: async (options: any) => {
|
|
220
220
|
calls.shortStrategy.placeTakeProfitBuyOrderOnBts.push(options);
|
|
221
221
|
return {
|
|
222
222
|
options,
|
|
@@ -226,12 +226,12 @@ function createBridgeHarness() {
|
|
|
226
226
|
});
|
|
227
227
|
|
|
228
228
|
registerMock(memuBridgePath, {
|
|
229
|
-
describeMemuBridge: (options) => ({
|
|
229
|
+
describeMemuBridge: (options: any) => ({
|
|
230
230
|
options,
|
|
231
231
|
runtime: 'memu',
|
|
232
232
|
source: 'describeMemuBridge'
|
|
233
233
|
}),
|
|
234
|
-
runMemuCommand: async (command, options) => {
|
|
234
|
+
runMemuCommand: async (command: any, options: any) => {
|
|
235
235
|
calls.memu.push({ command, options });
|
|
236
236
|
return {
|
|
237
237
|
command,
|
|
@@ -6,15 +6,15 @@ const net = require('net');
|
|
|
6
6
|
const { EventEmitter } = require('events');
|
|
7
7
|
const path = require('path');
|
|
8
8
|
|
|
9
|
-
function clearModule(modulePath) {
|
|
9
|
+
function clearModule(modulePath: string) {
|
|
10
10
|
delete require.cache[modulePath];
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
-
function createMockConnection(script) {
|
|
14
|
-
return (socketPath, onConnect) => {
|
|
13
|
+
function createMockConnection(script: any) {
|
|
14
|
+
return (socketPath: string, onConnect: any) => {
|
|
15
15
|
const socket = new EventEmitter();
|
|
16
16
|
socket.socketPath = socketPath;
|
|
17
|
-
socket.write = (payload) => {
|
|
17
|
+
socket.write = (payload: any) => {
|
|
18
18
|
socket.payload = payload;
|
|
19
19
|
};
|
|
20
20
|
socket.end = () => {
|
|
@@ -55,8 +55,8 @@ function testClawCatalog() {
|
|
|
55
55
|
assert.notStrictEqual(catalog.getClawToolCatalog()[0].command, 'mutated');
|
|
56
56
|
|
|
57
57
|
const examples = catalog.buildClawCommandExamples('tsx scripts/claw_bridge.ts');
|
|
58
|
-
assert.ok(examples.some((line) => line.startsWith('tsx scripts/claw_bridge.ts manifest')));
|
|
59
|
-
assert.ok(examples.some((line) => line.includes('bot-settings-apply')));
|
|
58
|
+
assert.ok(examples.some((line: any) => line.startsWith('tsx scripts/claw_bridge.ts manifest')));
|
|
59
|
+
assert.ok(examples.some((line: any) => line.includes('bot-settings-apply')));
|
|
60
60
|
}
|
|
61
61
|
|
|
62
62
|
async function testCredentialDaemonClient() {
|
|
@@ -71,7 +71,7 @@ async function testCredentialDaemonClient() {
|
|
|
71
71
|
const originalLstatSync = fs.lstatSync;
|
|
72
72
|
const originalCreateConnection = net.createConnection;
|
|
73
73
|
|
|
74
|
-
const credStatFor = (filePath) => ({
|
|
74
|
+
const credStatFor = (filePath: any) => ({
|
|
75
75
|
isSymbolicLink: () => false,
|
|
76
76
|
isFile: () => !String(filePath).endsWith('.sock'),
|
|
77
77
|
isSocket: () => String(filePath).endsWith('.sock'),
|
|
@@ -80,7 +80,7 @@ async function testCredentialDaemonClient() {
|
|
|
80
80
|
mode: 0o100600,
|
|
81
81
|
});
|
|
82
82
|
|
|
83
|
-
fs.lstatSync = (filePath) => {
|
|
83
|
+
fs.lstatSync = (filePath: any) => {
|
|
84
84
|
if (String(filePath).includes('cred')) return credStatFor(filePath);
|
|
85
85
|
return originalLstatSync.call(fs, filePath);
|
|
86
86
|
};
|
|
@@ -90,7 +90,7 @@ async function testCredentialDaemonClient() {
|
|
|
90
90
|
assert.strictEqual(client.DEFAULT_READY_FILE, runtime.getCredentialReadyFilePath());
|
|
91
91
|
|
|
92
92
|
let readyChecks = 0;
|
|
93
|
-
fs.existsSync = (filePath) => {
|
|
93
|
+
fs.existsSync = (filePath: any) => {
|
|
94
94
|
if (String(filePath).includes('cred')) {
|
|
95
95
|
readyChecks += 1;
|
|
96
96
|
return readyChecks >= 2;
|
|
@@ -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,
|
|
@@ -23,8 +23,8 @@ function createQueriesHarness() {
|
|
|
23
23
|
const dexbotBridgePath = require.resolve('../modules/dexbot_bridge');
|
|
24
24
|
|
|
25
25
|
const calls = {
|
|
26
|
-
dbCall: []
|
|
27
|
-
lookupAsset: [],
|
|
26
|
+
dbCall: [] as Array<{ args: unknown; method: string }>,
|
|
27
|
+
lookupAsset: [] as string[],
|
|
28
28
|
waitForConnected: 0
|
|
29
29
|
};
|
|
30
30
|
|
|
@@ -77,13 +77,13 @@ function createQueriesHarness() {
|
|
|
77
77
|
get_dynamic_global_properties: async () => ({
|
|
78
78
|
head_block_number: 100
|
|
79
79
|
}),
|
|
80
|
-
get_assets: async (ids) => ids.map((id) => assets[id]).filter((x: any) => x),
|
|
81
|
-
get_objects: async (ids) => ids.map((id) => objects[id] || null),
|
|
82
|
-
call: async (method, args) => {
|
|
80
|
+
get_assets: async (ids: any[]) => ids.map((id: any) => assets[id as keyof typeof assets]).filter((x: any) => x),
|
|
81
|
+
get_objects: async (ids: any[]) => ids.map((id: any) => objects[id as keyof typeof objects] || null),
|
|
82
|
+
call: async (method: string, args: any) => {
|
|
83
83
|
calls.dbCall.push({ args: clone(args), method });
|
|
84
84
|
|
|
85
85
|
if (method === 'lookup_asset_symbols') {
|
|
86
|
-
return args[0].map((symbol) => {
|
|
86
|
+
return args[0].map((symbol: any) => {
|
|
87
87
|
if (symbol === 'FALLBACK') {
|
|
88
88
|
return assets['1.3.101'];
|
|
89
89
|
}
|
|
@@ -110,7 +110,7 @@ function createQueriesHarness() {
|
|
|
110
110
|
|
|
111
111
|
registerMock(dexbotBridgePath, {
|
|
112
112
|
loadDexbotOrderSystemUtils: () => ({
|
|
113
|
-
lookupAsset: async (_bitshares, symbolOrId) => {
|
|
113
|
+
lookupAsset: async (_bitshares: any, symbolOrId: string) => {
|
|
114
114
|
calls.lookupAsset.push(symbolOrId);
|
|
115
115
|
if (symbolOrId === 'FALLBACK') {
|
|
116
116
|
throw new Error('lookup failure');
|
|
@@ -125,7 +125,7 @@ function createQueriesHarness() {
|
|
|
125
125
|
}
|
|
126
126
|
}),
|
|
127
127
|
loadDexbotOrderUtils: () => ({
|
|
128
|
-
blockchainToFloat: (amount, precision) => Number(amount) / (10 ** precision)
|
|
128
|
+
blockchainToFloat: (amount: number, precision: number) => Number(amount) / (10 ** precision)
|
|
129
129
|
})
|
|
130
130
|
});
|
|
131
131
|
|
|
@@ -197,32 +197,32 @@ function createBroadcastHarness() {
|
|
|
197
197
|
const credentialClientPath = require.resolve('../modules/dexbot_credential_client');
|
|
198
198
|
|
|
199
199
|
const calls = {
|
|
200
|
-
accountClient: []
|
|
201
|
-
broadcasts: [],
|
|
200
|
+
accountClient: [] as Array<{ accountName: any; privateKey: any }>,
|
|
201
|
+
broadcasts: [] as any[],
|
|
202
202
|
daemon: {
|
|
203
|
-
broadcast: []
|
|
204
|
-
execute: []
|
|
205
|
-
wait: []
|
|
203
|
+
broadcast: [] as Array<{ accountName: any; operation: any; options: any }>,
|
|
204
|
+
execute: [] as Array<{ accountName: any; operations: any; options: any }>,
|
|
205
|
+
wait: [] as Array<{ timeoutMs: any; options: any }>
|
|
206
206
|
},
|
|
207
207
|
daemonReady: false,
|
|
208
208
|
newTx: 0,
|
|
209
|
-
txOps: []
|
|
209
|
+
txOps: [] as Array<{ opData: any; opName: string }>
|
|
210
210
|
};
|
|
211
211
|
|
|
212
212
|
const tx = {
|
|
213
|
-
asset_settle: (opData) => {
|
|
213
|
+
asset_settle: (opData: any) => {
|
|
214
214
|
calls.txOps.push({ opData, opName: 'asset_settle' });
|
|
215
215
|
return tx;
|
|
216
216
|
},
|
|
217
|
-
call_order_update: (opData) => {
|
|
217
|
+
call_order_update: (opData: any) => {
|
|
218
218
|
calls.txOps.push({ opData, opName: 'call_order_update' });
|
|
219
219
|
return tx;
|
|
220
220
|
},
|
|
221
|
-
limit_order_cancel: (opData) => {
|
|
221
|
+
limit_order_cancel: (opData: any) => {
|
|
222
222
|
calls.txOps.push({ opData, opName: 'limit_order_cancel' });
|
|
223
223
|
return tx;
|
|
224
224
|
},
|
|
225
|
-
limit_order_create: (opData) => {
|
|
225
|
+
limit_order_create: (opData: any) => {
|
|
226
226
|
calls.txOps.push({ opData, opName: 'limit_order_create' });
|
|
227
227
|
return tx;
|
|
228
228
|
},
|
|
@@ -235,10 +235,10 @@ function createBroadcastHarness() {
|
|
|
235
235
|
};
|
|
236
236
|
|
|
237
237
|
registerMock(bitsharesClientPath, {
|
|
238
|
-
createAccountClient: (accountName, privateKey) => {
|
|
238
|
+
createAccountClient: (accountName: any, privateKey: any) => {
|
|
239
239
|
calls.accountClient.push({ accountName, privateKey });
|
|
240
240
|
return {
|
|
241
|
-
broadcast: async (operation) => {
|
|
241
|
+
broadcast: async (operation: any) => {
|
|
242
242
|
calls.broadcasts.push(operation);
|
|
243
243
|
return {
|
|
244
244
|
operation,
|
|
@@ -256,7 +256,7 @@ function createBroadcastHarness() {
|
|
|
256
256
|
|
|
257
257
|
registerMock(credentialClientPath, {
|
|
258
258
|
isCredentialDaemonReady: () => calls.daemonReady,
|
|
259
|
-
broadcastOperationViaCredentialDaemon: async (accountName, operation, options) => {
|
|
259
|
+
broadcastOperationViaCredentialDaemon: async (accountName: any, operation: any, options: any) => {
|
|
260
260
|
calls.daemon.broadcast.push({ accountName, operation, options });
|
|
261
261
|
return {
|
|
262
262
|
operation,
|
|
@@ -265,7 +265,7 @@ function createBroadcastHarness() {
|
|
|
265
265
|
source: 'daemon-broadcast'
|
|
266
266
|
};
|
|
267
267
|
},
|
|
268
|
-
executeOperationsViaCredentialDaemon: async (accountName, operations, options) => {
|
|
268
|
+
executeOperationsViaCredentialDaemon: async (accountName: any, operations: any, options: any) => {
|
|
269
269
|
calls.daemon.execute.push({ accountName, operations, options });
|
|
270
270
|
return {
|
|
271
271
|
operation_results: [[0, '1.7.77']],
|
|
@@ -273,7 +273,7 @@ function createBroadcastHarness() {
|
|
|
273
273
|
source: 'daemon-execute'
|
|
274
274
|
};
|
|
275
275
|
},
|
|
276
|
-
waitForCredentialDaemon: async (timeoutMs, options) => {
|
|
276
|
+
waitForCredentialDaemon: async (timeoutMs: any, options: any) => {
|
|
277
277
|
calls.daemon.wait.push({ options, timeoutMs });
|
|
278
278
|
}
|
|
279
279
|
});
|
|
@@ -398,18 +398,18 @@ function createActionsHarness() {
|
|
|
398
398
|
const dexbotBridgePath = require.resolve('../modules/dexbot_bridge');
|
|
399
399
|
|
|
400
400
|
const calls = {
|
|
401
|
-
buildUpdateOrderOp: [],
|
|
402
|
-
executeOperations: [],
|
|
403
|
-
resolveAccountId: [],
|
|
404
|
-
resolveAccountName: [],
|
|
405
|
-
subscribe: [],
|
|
406
|
-
unsubscribe: [],
|
|
407
|
-
getAsset: [],
|
|
408
|
-
getBackingAsset: [],
|
|
409
|
-
getFullAccount: [],
|
|
410
|
-
getOpenOrders: [],
|
|
411
|
-
getMpaPosition: [],
|
|
412
|
-
listenCallbacks: []
|
|
401
|
+
buildUpdateOrderOp: [] as string[],
|
|
402
|
+
executeOperations: [] as any[],
|
|
403
|
+
resolveAccountId: [] as string[],
|
|
404
|
+
resolveAccountName: [] as string[],
|
|
405
|
+
subscribe: [] as any[],
|
|
406
|
+
unsubscribe: [] as any[],
|
|
407
|
+
getAsset: [] as string[],
|
|
408
|
+
getBackingAsset: [] as string[],
|
|
409
|
+
getFullAccount: [] as string[],
|
|
410
|
+
getOpenOrders: [] as string[],
|
|
411
|
+
getMpaPosition: [] as any[],
|
|
412
|
+
listenCallbacks: [] as any[]
|
|
413
413
|
};
|
|
414
414
|
|
|
415
415
|
const assets = {
|
|
@@ -443,15 +443,15 @@ function createActionsHarness() {
|
|
|
443
443
|
]
|
|
444
444
|
};
|
|
445
445
|
|
|
446
|
-
const subscribeHandlers = [];
|
|
446
|
+
const subscribeHandlers: any[] = [];
|
|
447
447
|
|
|
448
448
|
registerMock(bitsharesClientPath, {
|
|
449
449
|
BitShares: {
|
|
450
|
-
subscribe: (topic, callback, accountName) => {
|
|
450
|
+
subscribe: (topic: any, callback: any, accountName: any) => {
|
|
451
451
|
calls.subscribe.push({ accountName, topic });
|
|
452
452
|
subscribeHandlers.push(callback);
|
|
453
453
|
},
|
|
454
|
-
unsubscribe: (topic, callback, accountName) => {
|
|
454
|
+
unsubscribe: (topic: any, callback: any, accountName: any) => {
|
|
455
455
|
calls.unsubscribe.push({ accountName, topic });
|
|
456
456
|
return Promise.resolve();
|
|
457
457
|
}
|
|
@@ -459,7 +459,7 @@ function createActionsHarness() {
|
|
|
459
459
|
});
|
|
460
460
|
|
|
461
461
|
registerMock(chainBroadcastPath, {
|
|
462
|
-
executeOperations: async (operations, options) => {
|
|
462
|
+
executeOperations: async (operations: any, options: any) => {
|
|
463
463
|
calls.executeOperations.push({ options: clone(options), operations: clone(operations) });
|
|
464
464
|
return {
|
|
465
465
|
operation_results: [[0, '1.7.500']],
|
|
@@ -469,27 +469,27 @@ function createActionsHarness() {
|
|
|
469
469
|
});
|
|
470
470
|
|
|
471
471
|
registerMock(chainQueriesPath, {
|
|
472
|
-
getAsset: async (symbolOrId) => {
|
|
472
|
+
getAsset: async (symbolOrId: string) => {
|
|
473
473
|
calls.getAsset.push(symbolOrId);
|
|
474
|
-
return assets[symbolOrId] || null;
|
|
474
|
+
return assets[symbolOrId as keyof typeof assets] || null;
|
|
475
475
|
},
|
|
476
|
-
getBackingAsset: async (symbolOrId) => {
|
|
476
|
+
getBackingAsset: async (symbolOrId: string) => {
|
|
477
477
|
calls.getBackingAsset.push(symbolOrId);
|
|
478
478
|
return assets.BTS;
|
|
479
479
|
},
|
|
480
|
-
getFullAccount: async (accountNameOrId) => {
|
|
480
|
+
getFullAccount: async (accountNameOrId: string) => {
|
|
481
481
|
calls.getFullAccount.push(accountNameOrId);
|
|
482
482
|
return account;
|
|
483
483
|
},
|
|
484
|
-
readOpenOrders: async (accountNameOrId) => {
|
|
484
|
+
readOpenOrders: async (accountNameOrId: string) => {
|
|
485
485
|
calls.getOpenOrders.push(accountNameOrId);
|
|
486
486
|
return account.limit_orders;
|
|
487
487
|
},
|
|
488
|
-
resolveAccountId: async (accountNameOrId) => {
|
|
488
|
+
resolveAccountId: async (accountNameOrId: string) => {
|
|
489
489
|
calls.resolveAccountId.push(accountNameOrId);
|
|
490
490
|
return accountNameOrId === 'alice' ? '1.2.345' : accountNameOrId;
|
|
491
491
|
},
|
|
492
|
-
resolveAccountName: async (accountNameOrId) => {
|
|
492
|
+
resolveAccountName: async (accountNameOrId: string) => {
|
|
493
493
|
calls.resolveAccountName.push(accountNameOrId);
|
|
494
494
|
if (accountNameOrId === '1.2.345') {
|
|
495
495
|
return 'alice';
|
|
@@ -503,12 +503,12 @@ function createActionsHarness() {
|
|
|
503
503
|
FEE_PARAMETERS: { GRAPHENE_COLLATERAL_RATIO_DENOM: 1000 }
|
|
504
504
|
}),
|
|
505
505
|
loadDexbotOrderUtils: () => ({
|
|
506
|
-
floatToBlockchainInt: (value, precision) => Math.round(Number(value) * (10 ** precision))
|
|
506
|
+
floatToBlockchainInt: (value: number, precision: number) => Math.round(Number(value) * (10 ** precision))
|
|
507
507
|
}),
|
|
508
|
-
requireDexbot2Module: (modulePath) => {
|
|
508
|
+
requireDexbot2Module: (modulePath: string) => {
|
|
509
509
|
calls.buildUpdateOrderOp.push(modulePath);
|
|
510
510
|
return {
|
|
511
|
-
buildUpdateOrderOp: async (accountName, orderId, newParams, cachedOrder) => ({
|
|
511
|
+
buildUpdateOrderOp: async (accountName: string, orderId: string, newParams: any, cachedOrder: any) => ({
|
|
512
512
|
op: {
|
|
513
513
|
op_data: {
|
|
514
514
|
accountName,
|
|
@@ -645,11 +645,11 @@ async function testChainActions() {
|
|
|
645
645
|
const mpaPosition = await actions.getMpaPosition('alice', 'HONEST.USD');
|
|
646
646
|
assert.strictEqual(mpaPosition.call_price.quote.asset_id, '1.3.100');
|
|
647
647
|
|
|
648
|
-
const received = [];
|
|
649
|
-
const unsubscribeFirst = await actions.listenForFills('alice', async (fills) => {
|
|
648
|
+
const received: any[] = [];
|
|
649
|
+
const unsubscribeFirst = await actions.listenForFills('alice', async (fills: any) => {
|
|
650
650
|
received.push({ fills, source: 'first' });
|
|
651
651
|
});
|
|
652
|
-
const unsubscribeSecond = await actions.listenForFills('1.2.345', async (fills) => {
|
|
652
|
+
const unsubscribeSecond = await actions.listenForFills('1.2.345', async (fills: any) => {
|
|
653
653
|
received.push({ fills, source: 'second' });
|
|
654
654
|
});
|
|
655
655
|
|