dexbot 1.6.6 → 1.6.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +89 -1
- package/README.md +8 -5
- package/analysis/README.md +2 -3
- package/analysis/tradingview/README.md +78 -1
- package/analysis/trend_detection/DYNAMIC_WEIGHT_RESEARCH.md +1 -1
- package/claw/package.json +1 -1
- package/claw/runtimes/openclaw-plugin/openclaw.plugin.json +1 -1
- package/claw/runtimes/openclaw-plugin/package.json +1 -1
- package/dist/analysis/tradingview/analyze_tradingview.d.ts +4 -0
- package/dist/analysis/tradingview/analyze_tradingview.js +55 -0
- package/dist/analysis/tradingview/grid_reset_config.d.ts +61 -0
- package/dist/analysis/tradingview/grid_reset_config.js +235 -0
- package/dist/analysis/tradingview/grid_reset_sim.d.ts +67 -0
- package/dist/analysis/tradingview/grid_reset_sim.js +307 -0
- package/dist/analysis/tradingview/tradingview_uplot_chart_generator.js +419 -3
- package/dist/dexbot.js +44 -15
- package/dist/market_adapter/core/market_adapter_service.js +14 -2
- package/dist/market_adapter/core/strategies/dynamic_weight_series.d.ts +8 -1
- package/dist/market_adapter/core/strategies/dynamic_weight_series.js +5 -1
- package/dist/market_adapter/inputs/window_cache.d.ts +97 -19
- package/dist/market_adapter/inputs/window_cache.js +302 -48
- package/dist/market_adapter/market_adapter.d.ts +8 -1
- package/dist/market_adapter/market_adapter.js +22 -4
- package/dist/modules/account_bots.js +20 -9
- package/dist/modules/account_orders.d.ts +44 -4
- package/dist/modules/account_orders.js +104 -7
- package/dist/modules/bitshares-native/chain_client.d.ts +10 -0
- package/dist/modules/bitshares-native/chain_client.js +197 -28
- package/dist/modules/bitshares-native/subscriptions.js +312 -10
- package/dist/modules/bitshares-native/transport.d.ts +1 -0
- package/dist/modules/bitshares-native/transport.js +97 -3
- package/dist/modules/bitshares_client.d.ts +20 -0
- package/dist/modules/bitshares_client.js +29 -0
- package/dist/modules/bot_settings.js +10 -1
- package/dist/modules/chain_keys.d.ts +37 -22
- package/dist/modules/chain_keys.js +145 -44
- package/dist/modules/cli_start_onboarding.d.ts +10 -0
- package/dist/modules/cli_start_onboarding.js +15 -0
- package/dist/modules/cli_start_output.d.ts +6 -0
- package/dist/modules/cli_start_output.js +8 -0
- package/dist/modules/config.d.ts +1 -0
- package/dist/modules/config.js +1 -0
- package/dist/modules/constants.d.ts +23 -2
- package/dist/modules/constants.js +196 -15
- package/dist/modules/dexbot_class.d.ts +6 -76
- package/dist/modules/dexbot_class.js +0 -32
- package/dist/modules/dexbot_cow_runtime.d.ts +3 -58
- package/dist/modules/dexbot_cow_runtime.js +53 -96
- package/dist/modules/dexbot_fill_runtime.d.ts +6 -1
- package/dist/modules/dexbot_fill_runtime.js +22 -3
- package/dist/modules/dexbot_maintenance_runtime.d.ts +38 -1
- package/dist/modules/dexbot_maintenance_runtime.js +103 -11
- package/dist/modules/dexbot_startup_runtime.js +73 -20
- package/dist/modules/dexbot_state_recovery.d.ts +6 -0
- package/dist/modules/dexbot_state_recovery.js +34 -1
- package/dist/modules/order/async_lock.d.ts +8 -0
- package/dist/modules/order/async_lock.js +15 -0
- package/dist/modules/order/genesis_policy.d.ts +162 -0
- package/dist/modules/order/genesis_policy.js +267 -0
- package/dist/modules/order/grid.js +109 -135
- package/dist/modules/order/grid_reconcile.d.ts +9 -0
- package/dist/modules/order/grid_reconcile.js +13 -4
- package/dist/modules/order/grid_reconcile_internal.js +13 -2
- package/dist/modules/order/logger.d.ts +12 -2
- package/dist/modules/order/logger.js +29 -7
- package/dist/modules/order/manager.d.ts +53 -0
- package/dist/modules/order/manager.js +86 -25
- package/dist/modules/order/sync_engine.d.ts +19 -0
- package/dist/modules/order/sync_engine.js +284 -344
- package/dist/modules/order/utils/math.d.ts +22 -1
- package/dist/modules/order/utils/math.js +64 -1
- package/dist/modules/order/utils/order.d.ts +43 -58
- package/dist/modules/order/utils/order.js +302 -194
- package/dist/modules/order/utils/system.d.ts +97 -0
- package/dist/modules/order/utils/system.js +282 -3
- package/dist/modules/paths.d.ts +8 -1
- package/dist/modules/paths.js +11 -3
- package/dist/modules/utils/text_width.d.ts +19 -0
- package/dist/modules/utils/text_width.js +97 -0
- package/dist/modules/version_notice.d.ts +165 -0
- package/dist/modules/version_notice.js +364 -0
- package/dist/pm2.js +104 -18
- package/dist/scripts/update.js +62 -13
- package/dist/unlock.d.ts +14 -2
- package/dist/unlock.js +101 -4
- package/docs/BITSHARES_ONBOARDING.md +8 -1
- package/docs/COW_INVARIANTS.md +11 -2
- package/docs/CREDENTIAL_SECURITY.md +26 -0
- package/docs/DEXBOT_COMPARISON.md +4 -4
- package/docs/EVOLUTION.md +20 -18
- package/docs/FUND_MOVEMENT_AND_ACCOUNTING.md +1 -1
- package/docs/GRID_PRICE_INVARIANT.md +204 -31
- package/docs/GRID_RECALCULATION.md +12 -0
- package/docs/LOGGING.md +17 -2
- package/docs/ORDER_ENGINE_POST_1.0_RETROSPECTIVE.md +6 -7
- package/docs/README.md +3 -1
- package/docs/WORKFLOW.md +16 -5
- package/market_adapter/README.md +1 -1
- package/modules/README.md +18 -1
- package/package.json +14 -6
- package/scripts/README.md +28 -2
- package/scripts/clear-all.sh +13 -4
- package/scripts/clear-logs.sh +13 -4
- package/scripts/clear-market-adapter.sh +6 -0
- package/scripts/clear-orders.sh +5 -0
- package/scripts/lib/dexbot-paths.sh +108 -0
- package/tests/README.md +11 -3
- package/analysis/account_resolver.ts +0 -161
- package/analysis/ama_fitting/analyze_ama_price_changes.ts +0 -155
- package/analysis/ama_fitting/analyze_lambda_vs_slow.ts +0 -404
- package/analysis/ama_fitting/calibrate_convergence_er.ts +0 -201
- package/analysis/ama_fitting/fetch_lp_candles.ts +0 -184
- package/analysis/ama_fitting/generate_unified_comparison_chart.ts +0 -232
- package/analysis/ama_fitting/optimizer_high_resolution.ts +0 -802
- package/analysis/analyze_dynamic_weight.ts +0 -243
- package/analysis/analyze_kalman.ts +0 -157
- package/analysis/analyze_regime.ts +0 -158
- package/analysis/analyze_regime_windows.ts +0 -470
- package/analysis/analyze_risk_profile.ts +0 -199
- package/analysis/analyze_trade_heatmap.ts +0 -362
- package/analysis/analyze_volatility.ts +0 -182
- package/analysis/bot_fitting/backtest_ama_sweep.ts +0 -934
- package/analysis/bot_fitting/backtest_bot_fitting.ts +0 -861
- package/analysis/bot_fitting/shared_utils.ts +0 -52
- package/analysis/bot_key_utils.ts +0 -426
- package/analysis/bot_usage/discover_bot_accounts.ts +0 -635
- package/analysis/bot_usage/kibana_bot_queries.ts +0 -211
- package/analysis/chain_pool.ts +0 -47
- package/analysis/chart_css.ts +0 -62
- package/analysis/chart_ui.ts +0 -105
- package/analysis/chart_utils.ts +0 -210
- package/analysis/fills_source.ts +0 -228
- package/analysis/grid_correction_check.ts +0 -786
- package/analysis/math_utils.ts +0 -53
- package/analysis/price_sources.ts +0 -136
- package/analysis/resolve_bot_accounts.ts +0 -199
- package/analysis/resolve_source.ts +0 -99
- package/analysis/results/ama_sweep_results_lp_pool_133_1h.json +0 -2455
- package/analysis/results/bot_fitting_results_lp_pool_133_1h.json +0 -218
- package/analysis/trade_profitability.ts +0 -1335
- package/analysis/tradingview/analyze_tradingview.ts +0 -280
- package/analysis/tradingview/h-bts_tradingview.html +0 -1570
- package/analysis/tradingview/t-bts_tradingview.html +0 -1570
- package/analysis/tradingview/tradingview_uplot_chart_generator.ts +0 -3268
- package/analysis/trend_detection/dynamic_weight_chart_generator.ts +0 -1481
- package/analysis/trend_detection/hurst_analyzer.ts +0 -7
- package/analysis/trend_detection/kalman_chart_generator.ts +0 -398
- package/analysis/trend_detection/kalman_trend_analyzer.ts +0 -9
- package/analysis/trend_detection/kalman_velocity_smoothing.ts +0 -7
- package/analysis/trend_detection/package.json +0 -23
- package/analysis/trend_detection/permutation_entropy_analyzer.ts +0 -7
- package/analysis/trend_detection/regime_chart_generator.ts +0 -338
- package/analysis/trend_detection/tests/test_kalman_trend.ts +0 -153
- package/analysis/trend_detection/tests/test_kalman_velocity_smoothing.ts +0 -64
- package/analysis/trend_detection/volatility_chart_generator.ts +0 -654
- package/analysis/tsconfig.json +0 -29
- package/claw/tests/package.json +0 -3
- package/claw/tests/test_claw_bridge.ts +0 -570
- package/claw/tests/test_claw_catalog_and_credentials.ts +0 -156
- package/claw/tests/test_claw_chain_layer.ts +0 -739
- package/claw/tests/test_claw_data_flow.ts +0 -525
- package/claw/tests/test_claw_domain_logic.ts +0 -471
- package/claw/tests/test_claw_manifest_and_matrix.ts +0 -222
- package/claw/tests/test_claw_mcp_transport.ts +0 -243
- package/claw/tests/test_claw_regressions.ts +0 -711
- package/claw/tests/test_claw_skill_generation.ts +0 -103
- package/claw/tests/test_claw_state_store.ts +0 -44
- package/claw/tests/test_dexbot_profiles.ts +0 -654
- package/claw/tests/test_memu_bridge.ts +0 -189
- package/claw/tests/test_nullclaw_tmp_integration.ts +0 -57
- package/claw/tests/test_position_health.ts +0 -343
- package/claw/tests/test_position_manager.ts +0 -429
- package/claw/tests/test_position_manager_watch_health.ts +0 -100
- package/claw/tests/test_short_mpa_strategy.ts +0 -232
- package/dist/analysis/account_resolver.d.ts.map +0 -1
- package/dist/analysis/account_resolver.js.map +0 -1
- package/dist/analysis/ama_fitting/analyze_ama_price_changes.d.ts.map +0 -1
- package/dist/analysis/ama_fitting/analyze_ama_price_changes.js.map +0 -1
- package/dist/analysis/ama_fitting/analyze_lambda_vs_slow.d.ts.map +0 -1
- package/dist/analysis/ama_fitting/analyze_lambda_vs_slow.js.map +0 -1
- package/dist/analysis/ama_fitting/calibrate_convergence_er.d.ts.map +0 -1
- package/dist/analysis/ama_fitting/calibrate_convergence_er.js.map +0 -1
- package/dist/analysis/ama_fitting/fetch_lp_candles.d.ts.map +0 -1
- package/dist/analysis/ama_fitting/fetch_lp_candles.js.map +0 -1
- package/dist/analysis/ama_fitting/generate_unified_comparison_chart.d.ts.map +0 -1
- package/dist/analysis/ama_fitting/generate_unified_comparison_chart.js.map +0 -1
- package/dist/analysis/ama_fitting/optimizer_high_resolution.d.ts.map +0 -1
- package/dist/analysis/ama_fitting/optimizer_high_resolution.js.map +0 -1
- package/dist/analysis/analyze_dynamic_weight.d.ts.map +0 -1
- package/dist/analysis/analyze_dynamic_weight.js.map +0 -1
- package/dist/analysis/analyze_kalman.d.ts.map +0 -1
- package/dist/analysis/analyze_kalman.js.map +0 -1
- package/dist/analysis/analyze_regime.d.ts.map +0 -1
- package/dist/analysis/analyze_regime.js.map +0 -1
- package/dist/analysis/analyze_regime_windows.d.ts.map +0 -1
- package/dist/analysis/analyze_regime_windows.js.map +0 -1
- package/dist/analysis/analyze_risk_profile.d.ts.map +0 -1
- package/dist/analysis/analyze_risk_profile.js.map +0 -1
- package/dist/analysis/analyze_trade_heatmap.d.ts.map +0 -1
- package/dist/analysis/analyze_trade_heatmap.js.map +0 -1
- package/dist/analysis/analyze_volatility.d.ts.map +0 -1
- package/dist/analysis/analyze_volatility.js.map +0 -1
- package/dist/analysis/bot_fitting/backtest_ama_sweep.d.ts.map +0 -1
- package/dist/analysis/bot_fitting/backtest_ama_sweep.js.map +0 -1
- package/dist/analysis/bot_fitting/backtest_bot_fitting.d.ts.map +0 -1
- package/dist/analysis/bot_fitting/backtest_bot_fitting.js.map +0 -1
- package/dist/analysis/bot_fitting/shared_utils.d.ts.map +0 -1
- package/dist/analysis/bot_fitting/shared_utils.js.map +0 -1
- package/dist/analysis/bot_key_utils.d.ts.map +0 -1
- package/dist/analysis/bot_key_utils.js.map +0 -1
- package/dist/analysis/bot_usage/discover_bot_accounts.d.ts.map +0 -1
- package/dist/analysis/bot_usage/discover_bot_accounts.js.map +0 -1
- package/dist/analysis/bot_usage/kibana_bot_queries.d.ts.map +0 -1
- package/dist/analysis/bot_usage/kibana_bot_queries.js.map +0 -1
- package/dist/analysis/chain_pool.d.ts.map +0 -1
- package/dist/analysis/chain_pool.js.map +0 -1
- package/dist/analysis/chart_css.d.ts.map +0 -1
- package/dist/analysis/chart_css.js.map +0 -1
- package/dist/analysis/chart_ui.d.ts.map +0 -1
- package/dist/analysis/chart_ui.js.map +0 -1
- package/dist/analysis/chart_utils.d.ts.map +0 -1
- package/dist/analysis/chart_utils.js.map +0 -1
- package/dist/analysis/fills_source.d.ts.map +0 -1
- package/dist/analysis/fills_source.js.map +0 -1
- package/dist/analysis/grid_correction_check.d.ts.map +0 -1
- package/dist/analysis/grid_correction_check.js.map +0 -1
- package/dist/analysis/math_utils.d.ts.map +0 -1
- package/dist/analysis/math_utils.js.map +0 -1
- package/dist/analysis/price_sources.d.ts.map +0 -1
- package/dist/analysis/price_sources.js.map +0 -1
- package/dist/analysis/resolve_bot_accounts.d.ts.map +0 -1
- package/dist/analysis/resolve_bot_accounts.js.map +0 -1
- package/dist/analysis/resolve_source.d.ts.map +0 -1
- package/dist/analysis/resolve_source.js.map +0 -1
- package/dist/analysis/trade_profitability.d.ts.map +0 -1
- package/dist/analysis/trade_profitability.js.map +0 -1
- package/dist/analysis/tradingview/analyze_tradingview.d.ts.map +0 -1
- package/dist/analysis/tradingview/analyze_tradingview.js.map +0 -1
- package/dist/analysis/tradingview/tradingview_uplot_chart_generator.d.ts.map +0 -1
- package/dist/analysis/tradingview/tradingview_uplot_chart_generator.js.map +0 -1
- package/dist/analysis/trend_detection/dynamic_weight_chart_generator.d.ts.map +0 -1
- package/dist/analysis/trend_detection/dynamic_weight_chart_generator.js.map +0 -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_chart_generator.d.ts.map +0 -1
- package/dist/analysis/trend_detection/kalman_chart_generator.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/analysis/trend_detection/regime_chart_generator.d.ts.map +0 -1
- package/dist/analysis/trend_detection/regime_chart_generator.js.map +0 -1
- package/dist/analysis/trend_detection/tests/test_kalman_trend.d.ts +0 -2
- package/dist/analysis/trend_detection/tests/test_kalman_trend.d.ts.map +0 -1
- package/dist/analysis/trend_detection/tests/test_kalman_trend.js +0 -128
- package/dist/analysis/trend_detection/tests/test_kalman_trend.js.map +0 -1
- package/dist/analysis/trend_detection/tests/test_kalman_velocity_smoothing.d.ts +0 -2
- package/dist/analysis/trend_detection/tests/test_kalman_velocity_smoothing.d.ts.map +0 -1
- package/dist/analysis/trend_detection/tests/test_kalman_velocity_smoothing.js +0 -37
- package/dist/analysis/trend_detection/tests/test_kalman_velocity_smoothing.js.map +0 -1
- package/dist/analysis/trend_detection/volatility_chart_generator.d.ts.map +0 -1
- package/dist/analysis/trend_detection/volatility_chart_generator.js.map +0 -1
- package/dist/bot.d.ts.map +0 -1
- package/dist/bot.js.map +0 -1
- package/dist/credential-daemon.d.ts.map +0 -1
- package/dist/credential-daemon.js.map +0 -1
- package/dist/dexbot.d.ts.map +0 -1
- package/dist/dexbot.js.map +0 -1
- package/dist/market_adapter/ama_signal_runner.d.ts.map +0 -1
- package/dist/market_adapter/ama_signal_runner.js.map +0 -1
- package/dist/market_adapter/candle_utils.d.ts.map +0 -1
- package/dist/market_adapter/candle_utils.js.map +0 -1
- package/dist/market_adapter/core/asymmetric_bounds.d.ts.map +0 -1
- package/dist/market_adapter/core/asymmetric_bounds.js.map +0 -1
- package/dist/market_adapter/core/config_normalizers.d.ts.map +0 -1
- package/dist/market_adapter/core/config_normalizers.js.map +0 -1
- package/dist/market_adapter/core/kibana_candles.d.ts.map +0 -1
- package/dist/market_adapter/core/kibana_candles.js.map +0 -1
- package/dist/market_adapter/core/kibana_client.d.ts.map +0 -1
- package/dist/market_adapter/core/kibana_client.js.map +0 -1
- package/dist/market_adapter/core/kibana_market_candles.d.ts.map +0 -1
- package/dist/market_adapter/core/kibana_market_candles.js.map +0 -1
- package/dist/market_adapter/core/market_adapter_service.d.ts.map +0 -1
- package/dist/market_adapter/core/market_adapter_service.js.map +0 -1
- package/dist/market_adapter/core/signals/hurst_analyzer.d.ts.map +0 -1
- package/dist/market_adapter/core/signals/hurst_analyzer.js.map +0 -1
- package/dist/market_adapter/core/signals/kalman_trend_analyzer.d.ts.map +0 -1
- package/dist/market_adapter/core/signals/kalman_trend_analyzer.js.map +0 -1
- package/dist/market_adapter/core/signals/kalman_velocity_smoothing.d.ts.map +0 -1
- package/dist/market_adapter/core/signals/kalman_velocity_smoothing.js.map +0 -1
- package/dist/market_adapter/core/signals/permutation_entropy_analyzer.d.ts.map +0 -1
- package/dist/market_adapter/core/signals/permutation_entropy_analyzer.js.map +0 -1
- package/dist/market_adapter/core/strategies/ama.d.ts.map +0 -1
- package/dist/market_adapter/core/strategies/ama.js.map +0 -1
- package/dist/market_adapter/core/strategies/ama_slope_model.d.ts.map +0 -1
- package/dist/market_adapter/core/strategies/ama_slope_model.js.map +0 -1
- package/dist/market_adapter/core/strategies/atr/calculator.d.ts.map +0 -1
- package/dist/market_adapter/core/strategies/atr/calculator.js.map +0 -1
- package/dist/market_adapter/core/strategies/collateral_manager.d.ts.map +0 -1
- package/dist/market_adapter/core/strategies/collateral_manager.js.map +0 -1
- package/dist/market_adapter/core/strategies/dynamic_weight_series.d.ts.map +0 -1
- package/dist/market_adapter/core/strategies/dynamic_weight_series.js.map +0 -1
- package/dist/market_adapter/core/strategies/regime_gate.d.ts.map +0 -1
- package/dist/market_adapter/core/strategies/regime_gate.js.map +0 -1
- package/dist/market_adapter/core/strategies/regime_interp.d.ts.map +0 -1
- package/dist/market_adapter/core/strategies/regime_interp.js.map +0 -1
- package/dist/market_adapter/core/strategies/volatility_shift.d.ts.map +0 -1
- package/dist/market_adapter/core/strategies/volatility_shift.js.map +0 -1
- package/dist/market_adapter/inputs/fetch_book_data.d.ts.map +0 -1
- package/dist/market_adapter/inputs/fetch_book_data.js.map +0 -1
- package/dist/market_adapter/inputs/fetch_cex_synthetic_data.d.ts.map +0 -1
- package/dist/market_adapter/inputs/fetch_cex_synthetic_data.js.map +0 -1
- package/dist/market_adapter/inputs/fetch_lp_data.d.ts.map +0 -1
- package/dist/market_adapter/inputs/fetch_lp_data.js.map +0 -1
- package/dist/market_adapter/inputs/kibana_feed_source.d.ts.map +0 -1
- package/dist/market_adapter/inputs/kibana_feed_source.js.map +0 -1
- package/dist/market_adapter/inputs/kibana_source.d.ts.map +0 -1
- package/dist/market_adapter/inputs/kibana_source.js.map +0 -1
- package/dist/market_adapter/inputs/window_cache.d.ts.map +0 -1
- package/dist/market_adapter/inputs/window_cache.js.map +0 -1
- package/dist/market_adapter/interval_utils.d.ts.map +0 -1
- package/dist/market_adapter/interval_utils.js.map +0 -1
- package/dist/market_adapter/log_format.d.ts.map +0 -1
- package/dist/market_adapter/log_format.js.map +0 -1
- package/dist/market_adapter/lp_chart_core.d.ts.map +0 -1
- package/dist/market_adapter/lp_chart_core.js.map +0 -1
- package/dist/market_adapter/lp_chart_runner.d.ts.map +0 -1
- package/dist/market_adapter/lp_chart_runner.js.map +0 -1
- package/dist/market_adapter/lp_chart_strategy_loader.d.ts.map +0 -1
- package/dist/market_adapter/lp_chart_strategy_loader.js.map +0 -1
- package/dist/market_adapter/market_adapter.d.ts.map +0 -1
- package/dist/market_adapter/market_adapter.js.map +0 -1
- package/dist/market_adapter/test_helpers.d.ts.map +0 -1
- package/dist/market_adapter/test_helpers.js.map +0 -1
- package/dist/market_adapter/utils/adapter_client.d.ts.map +0 -1
- package/dist/market_adapter/utils/adapter_client.js.map +0 -1
- package/dist/market_adapter/utils/atomic_write.d.ts.map +0 -1
- package/dist/market_adapter/utils/atomic_write.js.map +0 -1
- package/dist/market_adapter/utils/chain.d.ts.map +0 -1
- package/dist/market_adapter/utils/chain.js.map +0 -1
- package/dist/market_adapter/utils/data_discovery.d.ts.map +0 -1
- package/dist/market_adapter/utils/data_discovery.js.map +0 -1
- package/dist/market_adapter/utils/dynamic_grid_snapshot.d.ts.map +0 -1
- package/dist/market_adapter/utils/dynamic_grid_snapshot.js.map +0 -1
- package/dist/market_adapter/utils/file_lock.d.ts.map +0 -1
- package/dist/market_adapter/utils/file_lock.js.map +0 -1
- package/dist/market_adapter/utils/native_history.d.ts.map +0 -1
- package/dist/market_adapter/utils/native_history.js.map +0 -1
- package/dist/modules/account_bots.d.ts.map +0 -1
- package/dist/modules/account_bots.js.map +0 -1
- package/dist/modules/account_orders.d.ts.map +0 -1
- package/dist/modules/account_orders.js.map +0 -1
- package/dist/modules/authority_resolver.d.ts.map +0 -1
- package/dist/modules/authority_resolver.js.map +0 -1
- package/dist/modules/bitshares-native/chain_client.d.ts.map +0 -1
- package/dist/modules/bitshares-native/chain_client.js.map +0 -1
- package/dist/modules/bitshares-native/crypto/ecc.browser.d.ts.map +0 -1
- package/dist/modules/bitshares-native/crypto/ecc.browser.js.map +0 -1
- package/dist/modules/bitshares-native/crypto/ecc.d.ts.map +0 -1
- package/dist/modules/bitshares-native/crypto/ecc.js.map +0 -1
- package/dist/modules/bitshares-native/crypto/ecc_selector.d.ts.map +0 -1
- package/dist/modules/bitshares-native/crypto/ecc_selector.js.map +0 -1
- package/dist/modules/bitshares-native/index.d.ts.map +0 -1
- package/dist/modules/bitshares-native/index.js.map +0 -1
- package/dist/modules/bitshares-native/lru_cache.d.ts.map +0 -1
- package/dist/modules/bitshares-native/lru_cache.js.map +0 -1
- package/dist/modules/bitshares-native/resolvers.d.ts.map +0 -1
- package/dist/modules/bitshares-native/resolvers.js.map +0 -1
- package/dist/modules/bitshares-native/serial/chain_constants.d.ts.map +0 -1
- package/dist/modules/bitshares-native/serial/chain_constants.js.map +0 -1
- package/dist/modules/bitshares-native/serial/index.d.ts.map +0 -1
- package/dist/modules/bitshares-native/serial/index.js.map +0 -1
- package/dist/modules/bitshares-native/serial/operations.d.ts.map +0 -1
- package/dist/modules/bitshares-native/serial/operations.js.map +0 -1
- package/dist/modules/bitshares-native/serial/serializer.d.ts.map +0 -1
- package/dist/modules/bitshares-native/serial/serializer.js.map +0 -1
- package/dist/modules/bitshares-native/serial/types.d.ts.map +0 -1
- package/dist/modules/bitshares-native/serial/types.js.map +0 -1
- package/dist/modules/bitshares-native/signing_client.d.ts.map +0 -1
- package/dist/modules/bitshares-native/signing_client.js.map +0 -1
- package/dist/modules/bitshares-native/subscriptions.d.ts.map +0 -1
- package/dist/modules/bitshares-native/subscriptions.js.map +0 -1
- package/dist/modules/bitshares-native/transport.d.ts.map +0 -1
- package/dist/modules/bitshares-native/transport.js.map +0 -1
- package/dist/modules/bitshares-native/tx/builder.d.ts.map +0 -1
- package/dist/modules/bitshares-native/tx/builder.js.map +0 -1
- package/dist/modules/bitshares-native/tx/tx_cache.d.ts.map +0 -1
- package/dist/modules/bitshares-native/tx/tx_cache.js.map +0 -1
- package/dist/modules/bitshares_client.d.ts.map +0 -1
- package/dist/modules/bitshares_client.js.map +0 -1
- package/dist/modules/bot_defaults.d.ts.map +0 -1
- package/dist/modules/bot_defaults.js.map +0 -1
- package/dist/modules/bot_settings.d.ts.map +0 -1
- package/dist/modules/bot_settings.js.map +0 -1
- package/dist/modules/bots_file_lock.d.ts.map +0 -1
- package/dist/modules/bots_file_lock.js.map +0 -1
- package/dist/modules/broadcast_failure.d.ts.map +0 -1
- package/dist/modules/broadcast_failure.js.map +0 -1
- package/dist/modules/chain_keys.d.ts.map +0 -1
- package/dist/modules/chain_keys.js.map +0 -1
- package/dist/modules/chain_orders.d.ts.map +0 -1
- package/dist/modules/chain_orders.js.map +0 -1
- package/dist/modules/cli_colors.d.ts.map +0 -1
- package/dist/modules/cli_colors.js.map +0 -1
- package/dist/modules/config.d.ts.map +0 -1
- package/dist/modules/config.js.map +0 -1
- package/dist/modules/constants.d.ts.map +0 -1
- package/dist/modules/constants.js.map +0 -1
- package/dist/modules/cr_planner.d.ts.map +0 -1
- package/dist/modules/cr_planner.js.map +0 -1
- package/dist/modules/credential_policy.d.ts.map +0 -1
- package/dist/modules/credential_policy.js.map +0 -1
- package/dist/modules/credential_runtime.d.ts.map +0 -1
- package/dist/modules/credential_runtime.js.map +0 -1
- package/dist/modules/credential_session_cache.d.ts.map +0 -1
- package/dist/modules/credential_session_cache.js.map +0 -1
- package/dist/modules/credit_pricing.d.ts.map +0 -1
- package/dist/modules/credit_pricing.js.map +0 -1
- package/dist/modules/credit_runtime.d.ts.map +0 -1
- package/dist/modules/credit_runtime.js.map +0 -1
- package/dist/modules/crypto/browser_provider.d.ts.map +0 -1
- package/dist/modules/crypto/browser_provider.js.map +0 -1
- package/dist/modules/crypto/index.d.ts.map +0 -1
- package/dist/modules/crypto/index.js.map +0 -1
- package/dist/modules/crypto/node_provider.d.ts.map +0 -1
- package/dist/modules/crypto/node_provider.js.map +0 -1
- package/dist/modules/crypto/provider.d.ts.map +0 -1
- package/dist/modules/crypto/provider.js.map +0 -1
- package/dist/modules/crypto/pure_ripemd160.d.ts.map +0 -1
- package/dist/modules/crypto/pure_ripemd160.js.map +0 -1
- package/dist/modules/crypto/pure_scrypt.d.ts.map +0 -1
- package/dist/modules/crypto/pure_scrypt.js.map +0 -1
- package/dist/modules/crypto/pure_secp256k1.d.ts.map +0 -1
- package/dist/modules/crypto/pure_secp256k1.js.map +0 -1
- package/dist/modules/crypto/sync.d.ts.map +0 -1
- package/dist/modules/crypto/sync.js.map +0 -1
- package/dist/modules/daemon_node_health.d.ts.map +0 -1
- package/dist/modules/daemon_node_health.js.map +0 -1
- package/dist/modules/dexbot_class.d.ts.map +0 -1
- package/dist/modules/dexbot_class.js.map +0 -1
- package/dist/modules/dexbot_cow_runtime.d.ts.map +0 -1
- package/dist/modules/dexbot_cow_runtime.js.map +0 -1
- package/dist/modules/dexbot_credential_client.d.ts.map +0 -1
- package/dist/modules/dexbot_credential_client.js.map +0 -1
- package/dist/modules/dexbot_fill_runtime.d.ts.map +0 -1
- package/dist/modules/dexbot_fill_runtime.js.map +0 -1
- package/dist/modules/dexbot_maintenance_runtime.d.ts.map +0 -1
- package/dist/modules/dexbot_maintenance_runtime.js.map +0 -1
- package/dist/modules/dexbot_startup_runtime.d.ts.map +0 -1
- package/dist/modules/dexbot_startup_runtime.js.map +0 -1
- package/dist/modules/dexbot_state_recovery.d.ts.map +0 -1
- package/dist/modules/dexbot_state_recovery.js.map +0 -1
- package/dist/modules/env.d.ts.map +0 -1
- package/dist/modules/env.js.map +0 -1
- package/dist/modules/fund_registry.d.ts.map +0 -1
- package/dist/modules/fund_registry.js.map +0 -1
- package/dist/modules/general_settings.d.ts.map +0 -1
- package/dist/modules/general_settings.js.map +0 -1
- package/dist/modules/graceful_shutdown.d.ts.map +0 -1
- package/dist/modules/graceful_shutdown.js.map +0 -1
- package/dist/modules/grid_price_source.d.ts.map +0 -1
- package/dist/modules/grid_price_source.js.map +0 -1
- package/dist/modules/key_store.d.ts.map +0 -1
- package/dist/modules/key_store.js.map +0 -1
- package/dist/modules/launcher/adapter_requirement.d.ts.map +0 -1
- package/dist/modules/launcher/adapter_requirement.js.map +0 -1
- package/dist/modules/launcher/bot_supervisor.d.ts.map +0 -1
- package/dist/modules/launcher/bot_supervisor.js.map +0 -1
- package/dist/modules/launcher/child_env.d.ts.map +0 -1
- package/dist/modules/launcher/child_env.js.map +0 -1
- package/dist/modules/launcher/credential_bootstrap.d.ts.map +0 -1
- package/dist/modules/launcher/credential_bootstrap.js.map +0 -1
- package/dist/modules/launcher/credential_daemon.d.ts.map +0 -1
- package/dist/modules/launcher/credential_daemon.js.map +0 -1
- package/dist/modules/launcher/credential_secret.d.ts.map +0 -1
- package/dist/modules/launcher/credential_secret.js.map +0 -1
- package/dist/modules/launcher/foreign_cred_daemon.d.ts.map +0 -1
- package/dist/modules/launcher/foreign_cred_daemon.js.map +0 -1
- package/dist/modules/launcher/headless_password.d.ts.map +0 -1
- package/dist/modules/launcher/headless_password.js.map +0 -1
- package/dist/modules/launcher/launch_modes.d.ts.map +0 -1
- package/dist/modules/launcher/launch_modes.js.map +0 -1
- package/dist/modules/launcher/market_adapter_runtime.d.ts.map +0 -1
- package/dist/modules/launcher/market_adapter_runtime.js.map +0 -1
- package/dist/modules/launcher/market_adapter_watchdog.d.ts.map +0 -1
- package/dist/modules/launcher/market_adapter_watchdog.js.map +0 -1
- package/dist/modules/launcher/monolithic_runtime.d.ts.map +0 -1
- package/dist/modules/launcher/monolithic_runtime.js.map +0 -1
- package/dist/modules/launcher/runtime_entry.d.ts.map +0 -1
- package/dist/modules/launcher/runtime_entry.js.map +0 -1
- package/dist/modules/launcher/status_reporting.d.ts.map +0 -1
- package/dist/modules/launcher/status_reporting.js.map +0 -1
- package/dist/modules/launcher/supervisor_control.d.ts.map +0 -1
- package/dist/modules/launcher/supervisor_control.js.map +0 -1
- package/dist/modules/market_adapter_whitelist.d.ts.map +0 -1
- package/dist/modules/market_adapter_whitelist.js.map +0 -1
- package/dist/modules/node_connect_policy.d.ts.map +0 -1
- package/dist/modules/node_connect_policy.js.map +0 -1
- package/dist/modules/node_failure_ledger.d.ts.map +0 -1
- package/dist/modules/node_failure_ledger.js.map +0 -1
- package/dist/modules/node_health_cache.d.ts.map +0 -1
- package/dist/modules/node_health_cache.js.map +0 -1
- package/dist/modules/node_manager.d.ts.map +0 -1
- package/dist/modules/node_manager.js.map +0 -1
- package/dist/modules/order/accounting.d.ts.map +0 -1
- package/dist/modules/order/accounting.js.map +0 -1
- package/dist/modules/order/async_lock.d.ts.map +0 -1
- package/dist/modules/order/async_lock.js.map +0 -1
- package/dist/modules/order/export.d.ts.map +0 -1
- package/dist/modules/order/export.js.map +0 -1
- package/dist/modules/order/format.d.ts.map +0 -1
- package/dist/modules/order/format.js.map +0 -1
- package/dist/modules/order/grid.d.ts.map +0 -1
- package/dist/modules/order/grid.js.map +0 -1
- package/dist/modules/order/grid_reconcile.d.ts.map +0 -1
- package/dist/modules/order/grid_reconcile.js.map +0 -1
- package/dist/modules/order/grid_reconcile_internal.d.ts.map +0 -1
- package/dist/modules/order/grid_reconcile_internal.js.map +0 -1
- package/dist/modules/order/index.d.ts.map +0 -1
- package/dist/modules/order/index.js.map +0 -1
- package/dist/modules/order/logger.d.ts.map +0 -1
- package/dist/modules/order/logger.js.map +0 -1
- package/dist/modules/order/logger_state.d.ts.map +0 -1
- package/dist/modules/order/logger_state.js.map +0 -1
- package/dist/modules/order/manager.d.ts.map +0 -1
- package/dist/modules/order/manager.js.map +0 -1
- package/dist/modules/order/processed_fill_store.d.ts.map +0 -1
- package/dist/modules/order/processed_fill_store.js.map +0 -1
- package/dist/modules/order/strategy.d.ts.map +0 -1
- package/dist/modules/order/strategy.js.map +0 -1
- package/dist/modules/order/sync_engine.d.ts.map +0 -1
- package/dist/modules/order/sync_engine.js.map +0 -1
- package/dist/modules/order/utils/math.d.ts.map +0 -1
- package/dist/modules/order/utils/math.js.map +0 -1
- package/dist/modules/order/utils/order.d.ts.map +0 -1
- package/dist/modules/order/utils/order.js.map +0 -1
- package/dist/modules/order/utils/slot.d.ts.map +0 -1
- package/dist/modules/order/utils/slot.js.map +0 -1
- package/dist/modules/order/utils/system.d.ts.map +0 -1
- package/dist/modules/order/utils/system.js.map +0 -1
- package/dist/modules/order/utils/timeout.d.ts.map +0 -1
- package/dist/modules/order/utils/timeout.js.map +0 -1
- package/dist/modules/order/utils/validate.d.ts.map +0 -1
- package/dist/modules/order/utils/validate.js.map +0 -1
- package/dist/modules/order/utils/withPoolRef.d.ts.map +0 -1
- package/dist/modules/order/utils/withPoolRef.js.map +0 -1
- package/dist/modules/order/working_grid.d.ts.map +0 -1
- package/dist/modules/order/working_grid.js.map +0 -1
- package/dist/modules/path_api.d.ts.map +0 -1
- package/dist/modules/path_api.js.map +0 -1
- package/dist/modules/paths.d.ts.map +0 -1
- package/dist/modules/paths.js.map +0 -1
- package/dist/modules/process_discovery.d.ts.map +0 -1
- package/dist/modules/process_discovery.js.map +0 -1
- package/dist/modules/runtime.d.ts.map +0 -1
- package/dist/modules/runtime.js.map +0 -1
- package/dist/modules/runtime_settings.d.ts.map +0 -1
- package/dist/modules/runtime_settings.js.map +0 -1
- package/dist/modules/settings_merge.d.ts.map +0 -1
- package/dist/modules/settings_merge.js.map +0 -1
- package/dist/modules/socket_json_client.d.ts.map +0 -1
- package/dist/modules/socket_json_client.js.map +0 -1
- package/dist/modules/storage/browser_adapter.d.ts.map +0 -1
- package/dist/modules/storage/browser_adapter.js.map +0 -1
- package/dist/modules/storage/index.d.ts.map +0 -1
- package/dist/modules/storage/index.js.map +0 -1
- package/dist/modules/storage/node_adapter.d.ts.map +0 -1
- package/dist/modules/storage/node_adapter.js.map +0 -1
- package/dist/modules/storage/types.d.ts.map +0 -1
- package/dist/modules/storage/types.js.map +0 -1
- package/dist/modules/types.d.ts.map +0 -1
- package/dist/modules/types.js.map +0 -1
- package/dist/modules/utils/base58check.d.ts.map +0 -1
- package/dist/modules/utils/base58check.js.map +0 -1
- package/dist/modules/utils/build_dir.d.ts.map +0 -1
- package/dist/modules/utils/build_dir.js.map +0 -1
- package/dist/modules/utils/chain_logs.d.ts.map +0 -1
- package/dist/modules/utils/chain_logs.js.map +0 -1
- package/dist/modules/utils/errors.d.ts.map +0 -1
- package/dist/modules/utils/errors.js.map +0 -1
- package/dist/modules/utils/sanitize_key.d.ts.map +0 -1
- package/dist/modules/utils/sanitize_key.js.map +0 -1
- package/dist/modules/validate_profiles.d.ts.map +0 -1
- package/dist/modules/validate_profiles.js.map +0 -1
- package/dist/pm2.d.ts.map +0 -1
- package/dist/pm2.js.map +0 -1
- package/dist/scripts/analyze-credit.d.ts.map +0 -1
- package/dist/scripts/analyze-credit.js.map +0 -1
- package/dist/scripts/analyze-git.d.ts.map +0 -1
- package/dist/scripts/analyze-git.js.map +0 -1
- package/dist/scripts/analyze-orders.d.ts.map +0 -1
- package/dist/scripts/analyze-orders.js.map +0 -1
- package/dist/scripts/chart_command.d.ts.map +0 -1
- package/dist/scripts/chart_command.js.map +0 -1
- package/dist/scripts/diagnose-kibana-candles.d.ts.map +0 -1
- package/dist/scripts/diagnose-kibana-candles.js.map +0 -1
- package/dist/scripts/diagnose-pool-history.d.ts.map +0 -1
- package/dist/scripts/diagnose-pool-history.js.map +0 -1
- package/dist/scripts/divergence-calc.d.ts.map +0 -1
- package/dist/scripts/divergence-calc.js.map +0 -1
- package/dist/scripts/dw.d.ts.map +0 -1
- package/dist/scripts/dw.js.map +0 -1
- package/dist/scripts/generate_lp_chart.d.ts.map +0 -1
- package/dist/scripts/generate_lp_chart.js.map +0 -1
- package/dist/scripts/generate_mainnet_corpus_report.d.ts.map +0 -1
- package/dist/scripts/generate_mainnet_corpus_report.js.map +0 -1
- package/dist/scripts/native_release_gates.d.ts.map +0 -1
- package/dist/scripts/native_release_gates.js.map +0 -1
- package/dist/scripts/print_grid.d.ts.map +0 -1
- package/dist/scripts/print_grid.js.map +0 -1
- package/dist/scripts/run-tests.d.ts.map +0 -1
- package/dist/scripts/run-tests.js.map +0 -1
- package/dist/scripts/runner.d.ts.map +0 -1
- package/dist/scripts/runner.js.map +0 -1
- package/dist/scripts/sync-version.d.ts.map +0 -1
- package/dist/scripts/sync-version.js.map +0 -1
- package/dist/scripts/test-credit-renewal.d.ts.map +0 -1
- package/dist/scripts/test-credit-renewal.js.map +0 -1
- package/dist/scripts/tv.d.ts.map +0 -1
- package/dist/scripts/tv.js.map +0 -1
- package/dist/scripts/update.d.ts.map +0 -1
- package/dist/scripts/update.js.map +0 -1
- package/dist/scripts/update_dist_freshness.d.ts.map +0 -1
- package/dist/scripts/update_dist_freshness.js.map +0 -1
- package/dist/scripts/validate_bots.d.ts.map +0 -1
- package/dist/scripts/validate_bots.js.map +0 -1
- package/dist/scripts/verify-browser-bundle.d.ts.map +0 -1
- package/dist/scripts/verify-browser-bundle.js.map +0 -1
- package/dist/unlock.d.ts.map +0 -1
- package/dist/unlock.js.map +0 -1
|
@@ -1,429 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const assert = require('assert');
|
|
4
|
-
const fs = require('fs/promises');
|
|
5
|
-
const os = require('os');
|
|
6
|
-
const path = require('path');
|
|
7
|
-
const { runEsmMockStages, defineEsmMockAbs } = require('../../tests/helpers/esm_mocks');
|
|
8
|
-
|
|
9
|
-
// Compiled ESM graphs cannot be mocked via require.cache; the helper installs
|
|
10
|
-
// loader hooks (one child process per stage so fresh module instances load).
|
|
11
|
-
function clearModule(_modulePath: string) {
|
|
12
|
-
/* no-op under ESM hooks */
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
function registerMock(modulePath: string, exports: any) {
|
|
16
|
-
defineEsmMockAbs(modulePath, Object.keys(exports), exports);
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
const { clone } = require('../modules/utils');
|
|
20
|
-
|
|
21
|
-
async function createHarness() {
|
|
22
|
-
const managerPath = require.resolve('../modules/position_manager');
|
|
23
|
-
const actionsPath = require.resolve('../modules/chain_actions');
|
|
24
|
-
const queriesPath = require.resolve('../modules/chain_queries');
|
|
25
|
-
const profilesPath = require.resolve('../modules/dexbot_profiles');
|
|
26
|
-
const bridgePath = require.resolve('../modules/dexbot_bridge');
|
|
27
|
-
const shortStrategyPath = require.resolve('../modules/short_mpa_strategy');
|
|
28
|
-
const tempDir = await fs.mkdtemp(path.join(os.tmpdir(), 'claw-position-manager-'));
|
|
29
|
-
const statePath = path.join(tempDir, 'positions.json');
|
|
30
|
-
|
|
31
|
-
const calls = {
|
|
32
|
-
closeShortOnBts: [] as any[],
|
|
33
|
-
listenForFills: [] as any[],
|
|
34
|
-
openShortOnBts: [] as any[],
|
|
35
|
-
placeTakeProfitBuyOrderOnBts: [] as any[],
|
|
36
|
-
savedStates: [] as any[]
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
const coreAsset = { id: '1.3.0', precision: 5, symbol: 'BTS' };
|
|
40
|
-
const mpaAsset = {
|
|
41
|
-
bitasset_data_id: '2.4.100',
|
|
42
|
-
id: '1.3.100',
|
|
43
|
-
precision: 5,
|
|
44
|
-
symbol: 'HONEST.USD'
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
let accountSnapshot: any = {
|
|
48
|
-
balances: [{ asset_type: '1.3.0', balance: 500000 }],
|
|
49
|
-
call_orders: [],
|
|
50
|
-
limit_orders: []
|
|
51
|
-
};
|
|
52
|
-
|
|
53
|
-
registerMock(bridgePath, {
|
|
54
|
-
loadDexbotOrderUtils: () => ({
|
|
55
|
-
blockchainToFloat: (amount: number, precision: number) => Number(amount) / (10 ** precision)
|
|
56
|
-
})
|
|
57
|
-
});
|
|
58
|
-
|
|
59
|
-
registerMock(profilesPath, {
|
|
60
|
-
writeJsonFileAtomic: async (filePath: string, state: any) => {
|
|
61
|
-
calls.savedStates.push({ filePath, state: clone(state) });
|
|
62
|
-
await fs.writeFile(filePath, JSON.stringify(state, null, 2));
|
|
63
|
-
}
|
|
64
|
-
});
|
|
65
|
-
|
|
66
|
-
registerMock(shortStrategyPath, {
|
|
67
|
-
closeShortOnBts: async (options: any) => {
|
|
68
|
-
calls.closeShortOnBts.push(options);
|
|
69
|
-
accountSnapshot = {
|
|
70
|
-
...accountSnapshot,
|
|
71
|
-
call_orders: [],
|
|
72
|
-
limit_orders: []
|
|
73
|
-
};
|
|
74
|
-
return {
|
|
75
|
-
repayResult: {
|
|
76
|
-
raw: { source: 'close-short' }
|
|
77
|
-
}
|
|
78
|
-
};
|
|
79
|
-
},
|
|
80
|
-
openShortOnBts: async (options: any) => {
|
|
81
|
-
calls.openShortOnBts.push(options);
|
|
82
|
-
accountSnapshot = {
|
|
83
|
-
...accountSnapshot,
|
|
84
|
-
call_orders: [
|
|
85
|
-
{
|
|
86
|
-
borrower: '1.2.345',
|
|
87
|
-
call_price: { quote: { asset_id: mpaAsset.id } },
|
|
88
|
-
collateral: 2500000,
|
|
89
|
-
debt: 1000000,
|
|
90
|
-
id: '2.7.1'
|
|
91
|
-
}
|
|
92
|
-
],
|
|
93
|
-
limit_orders: [
|
|
94
|
-
{
|
|
95
|
-
for_sale: 1000000,
|
|
96
|
-
id: '1.7.100'
|
|
97
|
-
}
|
|
98
|
-
]
|
|
99
|
-
};
|
|
100
|
-
return {
|
|
101
|
-
sellOrderResult: {
|
|
102
|
-
operation_results: [[0, '1.7.100']],
|
|
103
|
-
raw: { source: 'open-short' }
|
|
104
|
-
}
|
|
105
|
-
};
|
|
106
|
-
},
|
|
107
|
-
placeTakeProfitBuyOrderOnBts: async (options: any) => {
|
|
108
|
-
calls.placeTakeProfitBuyOrderOnBts.push(options);
|
|
109
|
-
accountSnapshot = {
|
|
110
|
-
...accountSnapshot,
|
|
111
|
-
limit_orders: [
|
|
112
|
-
{
|
|
113
|
-
for_sale: 1000000,
|
|
114
|
-
id: '1.7.100'
|
|
115
|
-
},
|
|
116
|
-
{
|
|
117
|
-
for_sale: 2250000,
|
|
118
|
-
id: '1.7.200'
|
|
119
|
-
}
|
|
120
|
-
]
|
|
121
|
-
};
|
|
122
|
-
return {
|
|
123
|
-
rebuyOrderResult: {
|
|
124
|
-
operation_results: [[0, '1.7.200']],
|
|
125
|
-
raw: { source: 'take-profit' }
|
|
126
|
-
}
|
|
127
|
-
};
|
|
128
|
-
}
|
|
129
|
-
});
|
|
130
|
-
|
|
131
|
-
registerMock(actionsPath, {
|
|
132
|
-
listenForFills: async (accountName: string, callback: any) => {
|
|
133
|
-
calls.listenForFills.push({ accountName, callback });
|
|
134
|
-
return async () => {
|
|
135
|
-
calls.listenForFills.push({ accountName, type: 'unsubscribe' });
|
|
136
|
-
};
|
|
137
|
-
}
|
|
138
|
-
});
|
|
139
|
-
|
|
140
|
-
registerMock(queriesPath, {
|
|
141
|
-
getAsset: async (symbolOrId: string) => {
|
|
142
|
-
if (symbolOrId === 'BTS' || symbolOrId === coreAsset.id) {
|
|
143
|
-
return coreAsset;
|
|
144
|
-
}
|
|
145
|
-
if (symbolOrId === 'HONEST.USD' || symbolOrId === mpaAsset.id) {
|
|
146
|
-
return mpaAsset;
|
|
147
|
-
}
|
|
148
|
-
return null;
|
|
149
|
-
},
|
|
150
|
-
getBackingAsset: async () => coreAsset,
|
|
151
|
-
getBalances: async () => ({ BTS: 5 }),
|
|
152
|
-
getBitassetData: async () => ({
|
|
153
|
-
current_feed: {
|
|
154
|
-
settlement_price: {
|
|
155
|
-
base: { asset_id: coreAsset.id, amount: 200000 },
|
|
156
|
-
quote: { asset_id: mpaAsset.id, amount: 100000 }
|
|
157
|
-
}
|
|
158
|
-
},
|
|
159
|
-
current_feed_publication_time: '2026-03-31T00:00:00'
|
|
160
|
-
}),
|
|
161
|
-
getFullAccount: async () => clone(accountSnapshot)
|
|
162
|
-
});
|
|
163
|
-
|
|
164
|
-
clearModule(managerPath);
|
|
165
|
-
const { PositionManager } = require('../modules/position_manager');
|
|
166
|
-
|
|
167
|
-
return {
|
|
168
|
-
calls,
|
|
169
|
-
cleanup() {
|
|
170
|
-
clearModule(managerPath);
|
|
171
|
-
clearModule(actionsPath);
|
|
172
|
-
clearModule(queriesPath);
|
|
173
|
-
clearModule(profilesPath);
|
|
174
|
-
clearModule(bridgePath);
|
|
175
|
-
clearModule(shortStrategyPath);
|
|
176
|
-
},
|
|
177
|
-
manager: new PositionManager({ statePath }),
|
|
178
|
-
setAccountSnapshot(nextSnapshot: any) {
|
|
179
|
-
accountSnapshot = clone(nextSnapshot);
|
|
180
|
-
},
|
|
181
|
-
statePath
|
|
182
|
-
};
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
async function testPositionManagerLifecycle() {
|
|
186
|
-
console.log(' position_manager lifecycle...');
|
|
187
|
-
|
|
188
|
-
const { calls, cleanup, manager, setAccountSnapshot, statePath } = await createHarness();
|
|
189
|
-
|
|
190
|
-
try {
|
|
191
|
-
const planned = await manager.createShortPosition({
|
|
192
|
-
accountName: 'alice',
|
|
193
|
-
collateralAmount: 25,
|
|
194
|
-
debtAmount: 10,
|
|
195
|
-
mpaAsset: 'HONEST.USD',
|
|
196
|
-
sellPriceInBts: 2.5,
|
|
197
|
-
targetCollateralRatio: 2.2
|
|
198
|
-
});
|
|
199
|
-
|
|
200
|
-
assert.strictEqual(planned.status, 'planned');
|
|
201
|
-
assert.strictEqual(planned.entry.sellPriceInBts, 2.5);
|
|
202
|
-
assert.strictEqual(planned.entry.targetSellAmount, 10);
|
|
203
|
-
assert.strictEqual(planned.entry.targetReceiveAmount, 25);
|
|
204
|
-
assert.ok(planned.id.startsWith('pos_'));
|
|
205
|
-
assert.strictEqual(calls.savedStates.length, 1);
|
|
206
|
-
assert.strictEqual((await manager.listPositions()).length, 1);
|
|
207
|
-
|
|
208
|
-
const loadClone = await manager.listPositions();
|
|
209
|
-
loadClone[0].status = 'mutated';
|
|
210
|
-
assert.strictEqual((await manager.getPosition(planned.id)).status, 'planned');
|
|
211
|
-
|
|
212
|
-
const opened = await manager.openShort(planned.id, {
|
|
213
|
-
expiration: '2026-04-01T00:00:00',
|
|
214
|
-
fillOrKill: true,
|
|
215
|
-
privateKey: 'secret'
|
|
216
|
-
});
|
|
217
|
-
assert.strictEqual(opened.status, 'entry_order_open');
|
|
218
|
-
assert.strictEqual(opened.entry.orderId, '1.7.100');
|
|
219
|
-
assert.strictEqual(opened.onChain.collateralRatio, 1.25);
|
|
220
|
-
assert.strictEqual(calls.openShortOnBts[0].accountName, 'alice');
|
|
221
|
-
assert.strictEqual(calls.openShortOnBts[0].sellPriceInBts, 2.5);
|
|
222
|
-
|
|
223
|
-
const watchedPositionId = planned.id;
|
|
224
|
-
const state = await manager.loadState();
|
|
225
|
-
const watchedPosition = state.positions.find((entry: any) => entry.id === watchedPositionId);
|
|
226
|
-
watchedPosition.entry.orderId = '1.7.500';
|
|
227
|
-
watchedPosition.entry.orderOpen = true;
|
|
228
|
-
watchedPosition.status = 'entry_order_open';
|
|
229
|
-
await manager.saveState();
|
|
230
|
-
setAccountSnapshot({
|
|
231
|
-
balances: [{ asset_type: '1.3.0', balance: 500000 }],
|
|
232
|
-
call_orders: [
|
|
233
|
-
{
|
|
234
|
-
borrower: '1.2.345',
|
|
235
|
-
call_price: { quote: { asset_id: '1.3.100' } },
|
|
236
|
-
collateral: 2500000,
|
|
237
|
-
debt: 1000000,
|
|
238
|
-
id: '2.7.1'
|
|
239
|
-
}
|
|
240
|
-
],
|
|
241
|
-
limit_orders: [
|
|
242
|
-
{
|
|
243
|
-
for_sale: 900000,
|
|
244
|
-
id: '1.7.500'
|
|
245
|
-
}
|
|
246
|
-
]
|
|
247
|
-
});
|
|
248
|
-
|
|
249
|
-
const accountState = await manager.getPosition(watchedPositionId);
|
|
250
|
-
assert.strictEqual(accountState.entry.orderId, '1.7.500');
|
|
251
|
-
|
|
252
|
-
const unsubscribe = await manager.watchAccount('alice', async (position: any, fill: any) => {
|
|
253
|
-
calls.listenForFills.push({ accountName: 'alice', fill, type: 'onFill', positionId: position.id });
|
|
254
|
-
});
|
|
255
|
-
|
|
256
|
-
await calls.listenForFills.find((entry) => entry.callback)?.callback([
|
|
257
|
-
{
|
|
258
|
-
op: [
|
|
259
|
-
4,
|
|
260
|
-
{
|
|
261
|
-
order_id: '1.7.500',
|
|
262
|
-
pays: { asset_id: '1.3.100', amount: 100000 },
|
|
263
|
-
receives: { asset_id: '1.3.0', amount: 250000 }
|
|
264
|
-
}
|
|
265
|
-
]
|
|
266
|
-
}
|
|
267
|
-
]);
|
|
268
|
-
|
|
269
|
-
const filled = await manager.getPosition(watchedPositionId);
|
|
270
|
-
assert.strictEqual(filled.entry.fillCount, 1);
|
|
271
|
-
assert.strictEqual(filled.entry.filledSellAmount, 1);
|
|
272
|
-
assert.strictEqual(filled.entry.filledReceiveAmount, 2.5);
|
|
273
|
-
assert.strictEqual(filled.entry.fillStatus, 'partially_filled');
|
|
274
|
-
assert.strictEqual(calls.listenForFills.some((entry) => entry.type === 'onFill'), true);
|
|
275
|
-
|
|
276
|
-
const takeProfit = await manager.placeTakeProfit(planned.id, {
|
|
277
|
-
amountToCover: 10,
|
|
278
|
-
buyPriceInBts: 2.25,
|
|
279
|
-
privateKey: 'secret'
|
|
280
|
-
});
|
|
281
|
-
assert.strictEqual(takeProfit.status, 'take_profit_order_open');
|
|
282
|
-
assert.strictEqual(takeProfit.exit.orderId, '1.7.200');
|
|
283
|
-
assert.strictEqual(takeProfit.exit.maxBtsToSpend, 22.5);
|
|
284
|
-
assert.strictEqual(calls.placeTakeProfitBuyOrderOnBts[0].accountName, 'alice');
|
|
285
|
-
|
|
286
|
-
const closed = await manager.closePosition(planned.id, {
|
|
287
|
-
amountToRepay: 10,
|
|
288
|
-
privateKey: 'secret'
|
|
289
|
-
});
|
|
290
|
-
assert.strictEqual(closed.status, 'closed');
|
|
291
|
-
assert.strictEqual(closed.lastCloseTx.source, 'close-short');
|
|
292
|
-
assert.strictEqual(calls.closeShortOnBts[0].amountToRepay, 10);
|
|
293
|
-
|
|
294
|
-
const stored = JSON.parse(await fs.readFile(statePath, 'utf8'));
|
|
295
|
-
assert.strictEqual(stored.positions.length >= 1, true);
|
|
296
|
-
} finally {
|
|
297
|
-
cleanup();
|
|
298
|
-
}
|
|
299
|
-
|
|
300
|
-
console.log(' PASS');
|
|
301
|
-
}
|
|
302
|
-
|
|
303
|
-
async function testPositionManagerExitFillAndSyncTransitions() {
|
|
304
|
-
console.log(' position_manager exit fill + sync transitions...');
|
|
305
|
-
|
|
306
|
-
const { calls, cleanup, manager, setAccountSnapshot } = await createHarness();
|
|
307
|
-
|
|
308
|
-
try {
|
|
309
|
-
const planned = await manager.createShortPosition({
|
|
310
|
-
accountName: 'alice',
|
|
311
|
-
collateralAmount: 25,
|
|
312
|
-
debtAmount: 10,
|
|
313
|
-
mpaAsset: 'HONEST.USD',
|
|
314
|
-
sellPriceInBts: 2.5,
|
|
315
|
-
targetCollateralRatio: 2.2
|
|
316
|
-
});
|
|
317
|
-
|
|
318
|
-
await manager.openShort(planned.id, {
|
|
319
|
-
expiration: '2026-04-01T00:00:00',
|
|
320
|
-
privateKey: 'secret'
|
|
321
|
-
});
|
|
322
|
-
|
|
323
|
-
const unsubscribe = await manager.watchAccount('alice');
|
|
324
|
-
const fillListener = calls.listenForFills.find((entry) => typeof entry.callback === 'function');
|
|
325
|
-
|
|
326
|
-
setAccountSnapshot({
|
|
327
|
-
balances: [{ asset_type: '1.3.0', balance: 500000 }],
|
|
328
|
-
call_orders: [
|
|
329
|
-
{
|
|
330
|
-
borrower: '1.2.345',
|
|
331
|
-
call_price: { quote: { asset_id: '1.3.100' } },
|
|
332
|
-
collateral: 2500000,
|
|
333
|
-
debt: 1000000,
|
|
334
|
-
id: '2.7.1'
|
|
335
|
-
}
|
|
336
|
-
],
|
|
337
|
-
limit_orders: []
|
|
338
|
-
});
|
|
339
|
-
|
|
340
|
-
await fillListener.callback([
|
|
341
|
-
{
|
|
342
|
-
op: [
|
|
343
|
-
4,
|
|
344
|
-
{
|
|
345
|
-
order_id: '1.7.100',
|
|
346
|
-
pays: { asset_id: '1.3.100', amount: 1000000 },
|
|
347
|
-
receives: { asset_id: '1.3.0', amount: 2500000 }
|
|
348
|
-
}
|
|
349
|
-
]
|
|
350
|
-
}
|
|
351
|
-
]);
|
|
352
|
-
|
|
353
|
-
await manager.placeTakeProfit(planned.id, {
|
|
354
|
-
amountToCover: 10,
|
|
355
|
-
buyPriceInBts: 2.25,
|
|
356
|
-
privateKey: 'secret'
|
|
357
|
-
});
|
|
358
|
-
|
|
359
|
-
await fillListener.callback([
|
|
360
|
-
{
|
|
361
|
-
op: [
|
|
362
|
-
4,
|
|
363
|
-
{
|
|
364
|
-
order_id: '1.7.200',
|
|
365
|
-
pays: { asset_id: '1.3.0', amount: 1125000 },
|
|
366
|
-
receives: { asset_id: '1.3.100', amount: 500000 }
|
|
367
|
-
}
|
|
368
|
-
]
|
|
369
|
-
}
|
|
370
|
-
]);
|
|
371
|
-
|
|
372
|
-
const afterExitFill = await manager.getPosition(planned.id);
|
|
373
|
-
assert.strictEqual(afterExitFill.exit.fillCount, 1);
|
|
374
|
-
assert.strictEqual(afterExitFill.exit.filledSellAmount, 11.25);
|
|
375
|
-
assert.strictEqual(afterExitFill.exit.filledReceiveAmount, 5);
|
|
376
|
-
assert.strictEqual(afterExitFill.exit.fillStatus, 'partially_filled');
|
|
377
|
-
assert.strictEqual(afterExitFill.pnl.averageExitPriceInBts, 2.25);
|
|
378
|
-
assert.strictEqual(afterExitFill.pnl.realizedCoverAmount, 5);
|
|
379
|
-
assert.strictEqual(afterExitFill.pnl.realizedGrossPnlInBts, 1.25);
|
|
380
|
-
|
|
381
|
-
setAccountSnapshot({
|
|
382
|
-
balances: [{ asset_type: '1.3.0', balance: 500000 }],
|
|
383
|
-
call_orders: [],
|
|
384
|
-
limit_orders: [
|
|
385
|
-
{
|
|
386
|
-
for_sale: 1125000,
|
|
387
|
-
id: '1.7.200'
|
|
388
|
-
}
|
|
389
|
-
]
|
|
390
|
-
});
|
|
391
|
-
|
|
392
|
-
const withoutDebt = await manager.syncPosition(planned.id);
|
|
393
|
-
assert.strictEqual(withoutDebt.status, 'orders_open_without_debt');
|
|
394
|
-
assert.strictEqual(withoutDebt.onChain.openOrderIds.includes('1.7.200'), true);
|
|
395
|
-
|
|
396
|
-
setAccountSnapshot({
|
|
397
|
-
balances: [{ asset_type: '1.3.0', balance: 500000 }],
|
|
398
|
-
call_orders: [],
|
|
399
|
-
limit_orders: []
|
|
400
|
-
});
|
|
401
|
-
|
|
402
|
-
const closed = await manager.syncPosition(planned.id);
|
|
403
|
-
assert.strictEqual(closed.status, 'closed');
|
|
404
|
-
assert.strictEqual(closed.exit.fillStatus, 'filled_or_closed');
|
|
405
|
-
assert.strictEqual(closed.exit.orderOpen, false);
|
|
406
|
-
assert.strictEqual(closed.pnl.realizedGrossPnlInBts, 1.25);
|
|
407
|
-
|
|
408
|
-
await unsubscribe();
|
|
409
|
-
} finally {
|
|
410
|
-
cleanup();
|
|
411
|
-
}
|
|
412
|
-
|
|
413
|
-
console.log(' PASS');
|
|
414
|
-
}
|
|
415
|
-
|
|
416
|
-
runEsmMockStages(
|
|
417
|
-
['lifecycle', 'exit-fill-and-sync-transitions'],
|
|
418
|
-
async (stage: string) => {
|
|
419
|
-
if (stage === 'lifecycle') {
|
|
420
|
-
await testPositionManagerLifecycle();
|
|
421
|
-
return;
|
|
422
|
-
}
|
|
423
|
-
if (stage === 'exit-fill-and-sync-transitions') {
|
|
424
|
-
await testPositionManagerExitFillAndSyncTransitions();
|
|
425
|
-
return;
|
|
426
|
-
}
|
|
427
|
-
throw new Error(`Unknown stage: ${stage}`);
|
|
428
|
-
}
|
|
429
|
-
);
|
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const assert = require('assert');
|
|
4
|
-
const fs = require('fs/promises');
|
|
5
|
-
const os = require('os');
|
|
6
|
-
const path = require('path');
|
|
7
|
-
const { runEsmMockStages, defineEsmMockAbs } = require('../../tests/helpers/esm_mocks');
|
|
8
|
-
|
|
9
|
-
// Compiled ESM graphs cannot be mocked via require.cache or Module._load; the
|
|
10
|
-
// helper installs loader hooks so position_manager_watch links against the
|
|
11
|
-
// mock exports instead of running real chain code.
|
|
12
|
-
function clearModule(_modulePath: string) {
|
|
13
|
-
/* no-op under ESM hooks */
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
function registerMock(modulePath: string, exports: any) {
|
|
17
|
-
defineEsmMockAbs(modulePath, Object.keys(exports), exports);
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
async function testHealthWritesStayOrdered() {
|
|
21
|
-
const watcherModulePath = require.resolve('../modules/position_manager_watch');
|
|
22
|
-
const positionManagerPath = require.resolve('../modules/position_manager');
|
|
23
|
-
const bitsharesClientPath = require.resolve('../modules/bitshares_client');
|
|
24
|
-
|
|
25
|
-
const tmpDir = await fs.mkdtemp(path.join(os.tmpdir(), 'pm-watch-'));
|
|
26
|
-
const healthPath = path.join(tmpDir, 'watcher-health.json');
|
|
27
|
-
|
|
28
|
-
let syncCount = 0;
|
|
29
|
-
class MockPositionManager {
|
|
30
|
-
[key: string]: any;
|
|
31
|
-
constructor() {}
|
|
32
|
-
|
|
33
|
-
async syncAllPositions() {
|
|
34
|
-
syncCount += 1;
|
|
35
|
-
if (syncCount === 1) {
|
|
36
|
-
return { ok: true };
|
|
37
|
-
}
|
|
38
|
-
if (syncCount === 2) {
|
|
39
|
-
throw new Error('timer failure');
|
|
40
|
-
}
|
|
41
|
-
return { ok: true };
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
async watchAccount() {
|
|
45
|
-
return async () => {};
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
// ESM hooks turn mock keys into synthetic named re-exports, so every name
|
|
50
|
-
// position_manager_watch statically imports must exist here.
|
|
51
|
-
registerMock(positionManagerPath, {
|
|
52
|
-
DEFAULT_STATE_PATH: path.join(os.tmpdir(), 'unused-positions.json'),
|
|
53
|
-
PositionManager: MockPositionManager
|
|
54
|
-
});
|
|
55
|
-
|
|
56
|
-
registerMock(bitsharesClientPath, {
|
|
57
|
-
waitForConnected: async () => {}
|
|
58
|
-
});
|
|
59
|
-
|
|
60
|
-
clearModule(watcherModulePath);
|
|
61
|
-
const { createPositionManagerWatcher } = require('../modules/position_manager_watch');
|
|
62
|
-
|
|
63
|
-
try {
|
|
64
|
-
const watcher = createPositionManagerWatcher({
|
|
65
|
-
accountName: 'tester',
|
|
66
|
-
healthPath,
|
|
67
|
-
maxConsecutiveFailures: 1,
|
|
68
|
-
logger: {
|
|
69
|
-
error: () => {},
|
|
70
|
-
info: () => {},
|
|
71
|
-
warn: () => {}
|
|
72
|
-
},
|
|
73
|
-
syncIntervalMs: 20
|
|
74
|
-
});
|
|
75
|
-
|
|
76
|
-
const started = await watcher.start();
|
|
77
|
-
await new Promise((resolve) => setTimeout(resolve, 180));
|
|
78
|
-
await started.stop();
|
|
79
|
-
|
|
80
|
-
const health = JSON.parse(await fs.readFile(healthPath, 'utf8'));
|
|
81
|
-
assert.strictEqual(health.status, 'healthy', 'latest health write should win');
|
|
82
|
-
assert.strictEqual(health.consecutiveFailures, 0, 'health should reset after a later success');
|
|
83
|
-
assert.ok(syncCount >= 3, 'test should exercise the initial sync plus failure and recovery');
|
|
84
|
-
} finally {
|
|
85
|
-
clearModule(watcherModulePath);
|
|
86
|
-
clearModule(positionManagerPath);
|
|
87
|
-
clearModule(bitsharesClientPath);
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
runEsmMockStages(
|
|
92
|
-
['health-writes-stay-ordered'],
|
|
93
|
-
async (stage: string) => {
|
|
94
|
-
if (stage === 'health-writes-stay-ordered') {
|
|
95
|
-
await testHealthWritesStayOrdered();
|
|
96
|
-
return;
|
|
97
|
-
}
|
|
98
|
-
throw new Error(`Unknown stage: ${stage}`);
|
|
99
|
-
}
|
|
100
|
-
);
|