dexbot 1.6.7 → 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 +49 -1
- package/README.md +3 -3
- 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 +22 -6
- 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 +10 -0
- package/dist/modules/account_orders.d.ts +24 -2
- package/dist/modules/account_orders.js +41 -4
- package/dist/modules/bot_settings.js +10 -1
- package/dist/modules/config.d.ts +1 -0
- package/dist/modules/config.js +1 -0
- package/dist/modules/constants.d.ts +11 -3
- package/dist/modules/constants.js +116 -37
- 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 +4 -87
- package/dist/modules/dexbot_maintenance_runtime.d.ts +15 -1
- package/dist/modules/dexbot_maintenance_runtime.js +59 -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 +21 -0
- 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 +76 -134
- 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 +2 -2
- package/dist/modules/order/manager.d.ts +4 -0
- package/dist/modules/order/manager.js +14 -1
- 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 +220 -197
- package/dist/modules/order/utils/system.js +8 -1
- package/dist/modules/paths.d.ts +1 -0
- package/dist/modules/paths.js +1 -0
- package/dist/modules/version_notice.d.ts +165 -0
- package/dist/modules/version_notice.js +364 -0
- package/dist/pm2.js +9 -0
- package/dist/unlock.js +28 -0
- package/docs/BITSHARES_ONBOARDING.md +8 -1
- package/docs/COW_INVARIANTS.md +3 -2
- package/docs/DEXBOT_COMPARISON.md +4 -4
- package/docs/EVOLUTION.md +20 -19
- package/docs/FUND_MOVEMENT_AND_ACCOUNTING.md +1 -1
- package/docs/GRID_PRICE_INVARIANT.md +149 -31
- package/docs/GRID_RECALCULATION.md +12 -0
- 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 +13 -5
- 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/cli_start_onboarding.d.ts.map +0 -1
- package/dist/modules/cli_start_onboarding.js.map +0 -1
- package/dist/modules/cli_start_output.d.ts.map +0 -1
- package/dist/modules/cli_start_output.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/utils/text_width.d.ts.map +0 -1
- package/dist/modules/utils/text_width.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,635 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
'use strict';
|
|
3
|
-
import { getStorage } from '../../modules/storage/index.js';
|
|
4
|
-
import { withReadOnlyClient } from '../chain_pool.js';
|
|
5
|
-
const { writeJSON } = getStorage();
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* DEXBOT ACCOUNT DISCOVERY
|
|
9
|
-
*
|
|
10
|
-
* Scans all active BitShares accounts across the last N days to find
|
|
11
|
-
* which accounts are running DEXBot or DEXBot2 staggered-orders strategy.
|
|
12
|
-
*
|
|
13
|
-
* Pipeline:
|
|
14
|
-
* 1. Kibana (parallel):
|
|
15
|
-
* Q1 — top 100 accounts by limit_order_create count
|
|
16
|
-
* Q2 — top 100 accounts by limit_order_cancel count
|
|
17
|
-
* Q3 — top 100 accounts by fill_order count
|
|
18
|
-
* Q4 — top 200 accounts by limit_order_update count (op 77, DEXBot2 fingerprint)
|
|
19
|
-
* 2. Merge & pre-filter:
|
|
20
|
-
* creates ≥ MIN_CREATES (grid analysis determines DEXBot candidacy)
|
|
21
|
-
* 3. Grid analysis (parallel, batches of 5):
|
|
22
|
-
* Fetch 200 raw orders per candidate → per-session geometric spacing test
|
|
23
|
-
* 4. BitShares: resolve account IDs → names (batch db.get_objects call)
|
|
24
|
-
* 5. Rank by DEX score and print table.
|
|
25
|
-
* HIGH tier (80+) is split by op-77 usage:
|
|
26
|
-
* updates ≥ 1 → DEXBot2 (native limit_order_update in-place re-price)
|
|
27
|
-
* updates = 0 → DEXBot1-style (cancel-only, cancel + recreate)
|
|
28
|
-
*
|
|
29
|
-
* Usage:
|
|
30
|
-
* node dist/analysis/bot_usage/discover_bot_accounts.js
|
|
31
|
-
* node dist/analysis/bot_usage/discover_bot_accounts.js --days 14
|
|
32
|
-
* node dist/analysis/bot_usage/discover_bot_accounts.js --days 7 --min-creates 10 --top 50
|
|
33
|
-
* node dist/analysis/bot_usage/discover_bot_accounts.js --no-grid (fast: counts only)
|
|
34
|
-
* node dist/analysis/bot_usage/discover_bot_accounts.js --output-json results.json
|
|
35
|
-
* node dist/analysis/bot_usage/discover_bot_accounts.js --cv-threshold 0.25
|
|
36
|
-
*
|
|
37
|
-
* Options:
|
|
38
|
-
* --days <n> Lookback window in days (default: 14)
|
|
39
|
-
* --min-creates <n> Minimum limit_order_create count (default: 20)
|
|
40
|
-
* --top <n> Top N candidates for grid analysis (default: 30)
|
|
41
|
-
* --no-grid Skip grid spacing analysis (fast, counts only)
|
|
42
|
-
* --output-json <f> Export full results as JSON to <f>
|
|
43
|
-
* --cv-threshold <n> CV threshold for grid detection (default: 0.35, lower = stricter)
|
|
44
|
-
* --retries <n> Max retry attempts per Kibana query (default: 3)
|
|
45
|
-
* --verbose Print extra debug/diagnostic info
|
|
46
|
-
* --help, -h Show this help
|
|
47
|
-
*/
|
|
48
|
-
|
|
49
|
-
import {
|
|
50
|
-
kibanaSearch,
|
|
51
|
-
buildOrderPriceQuery,
|
|
52
|
-
buildTopSellerAccountsQuery,
|
|
53
|
-
buildTopCancellerAccountsQuery,
|
|
54
|
-
buildTopFilledAccountsQuery,
|
|
55
|
-
buildTopUpdaterAccountsQuery,
|
|
56
|
-
DEFAULT_CONFIG,
|
|
57
|
-
} from './kibana_bot_queries.js';
|
|
58
|
-
|
|
59
|
-
// ─── Types ────────────────────────────────────────────────────────────────────
|
|
60
|
-
|
|
61
|
-
interface AccountCounts {
|
|
62
|
-
creates: number;
|
|
63
|
-
cancels: number;
|
|
64
|
-
fills: number;
|
|
65
|
-
updates: number;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
interface CandidateInfo {
|
|
69
|
-
id: string;
|
|
70
|
-
creates: number;
|
|
71
|
-
cancels: number;
|
|
72
|
-
fills: number;
|
|
73
|
-
updates: number;
|
|
74
|
-
flavor: 'DEXBot2' | 'DEXBot1' | '';
|
|
75
|
-
cancelRatio: number;
|
|
76
|
-
fillRate: number;
|
|
77
|
-
gridScore: number;
|
|
78
|
-
impliedInc: number | null;
|
|
79
|
-
maxBatch: number;
|
|
80
|
-
dexScore: number;
|
|
81
|
-
cv: number | null;
|
|
82
|
-
name: string;
|
|
83
|
-
ordersFetched: number;
|
|
84
|
-
buyCount: number;
|
|
85
|
-
sellCount: number;
|
|
86
|
-
pairAssets: string[];
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
// ─── Configuration ────────────────────────────────────────────────────────────
|
|
90
|
-
|
|
91
|
-
// Node pool from central node management (failover-capable) instead of a
|
|
92
|
-
// single hardcoded WSS endpoint.
|
|
93
|
-
// Single retry budget lives in withRetry below (honoring --retries), so the
|
|
94
|
-
// client-level retry is disabled here — otherwise the two budgets would
|
|
95
|
-
// stack (wrapper attempts x client attempts). Same convention as the paged
|
|
96
|
-
// production fetchers, which pass kibanaSearchRetries: 1 and own their
|
|
97
|
-
// page budget.
|
|
98
|
-
const KIBANA_CFG = { ...DEFAULT_CONFIG, timeout: 30000, kibanaSearchRetries: 1 };
|
|
99
|
-
|
|
100
|
-
const ASSET_PRECISION = {
|
|
101
|
-
'1.3.0': 5, // BTS
|
|
102
|
-
'1.3.5537': 4, // IOB.XRP
|
|
103
|
-
'1.3.5969': 4, // XBTSX.XRP
|
|
104
|
-
};
|
|
105
|
-
const DEFAULT_PRECISION = 8;
|
|
106
|
-
|
|
107
|
-
function getPrec(id: string): number { return ASSET_PRECISION[id as keyof typeof ASSET_PRECISION] ?? DEFAULT_PRECISION; }
|
|
108
|
-
|
|
109
|
-
// ─── CLI ──────────────────────────────────────────────────────────────────────
|
|
110
|
-
|
|
111
|
-
function parseArgs() {
|
|
112
|
-
const args = process.argv.slice(2);
|
|
113
|
-
const opts: {
|
|
114
|
-
days: number; minCreates: number; top: number; skipGrid: boolean;
|
|
115
|
-
cvThreshold: number; maxRetries: number; outputJson: string | null; verbose: boolean;
|
|
116
|
-
} = {
|
|
117
|
-
days: 14, minCreates: 20, top: 30, skipGrid: false,
|
|
118
|
-
cvThreshold: 0.35, maxRetries: 3, outputJson: null, verbose: false,
|
|
119
|
-
};
|
|
120
|
-
for (let i = 0; i < args.length; i++) {
|
|
121
|
-
if (args[i] === '--help' || args[i] === '-h') printHelpAndExit();
|
|
122
|
-
else if (args[i] === '--days' && args[i + 1]) opts.days = parseInt(args[++i], 10);
|
|
123
|
-
else if (args[i] === '--min-creates' && args[i + 1]) opts.minCreates = parseInt(args[++i], 10);
|
|
124
|
-
else if (args[i] === '--top' && args[i + 1]) opts.top = parseInt(args[++i], 10);
|
|
125
|
-
else if (args[i] === '--no-grid') opts.skipGrid = true;
|
|
126
|
-
else if (args[i] === '--cv-threshold' && args[i + 1]) opts.cvThreshold = parseFloat(args[++i]);
|
|
127
|
-
else if (args[i] === '--retries' && args[i + 1]) opts.maxRetries = parseInt(args[++i], 10);
|
|
128
|
-
else if (args[i] === '--output-json' && args[i + 1]) opts.outputJson = args[++i];
|
|
129
|
-
else if (args[i] === '--verbose') opts.verbose = true;
|
|
130
|
-
}
|
|
131
|
-
return opts;
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
function printHelpAndExit() {
|
|
135
|
-
console.log(`\
|
|
136
|
-
Usage: node dist/analysis/bot_usage/discover_bot_accounts.js [options]
|
|
137
|
-
|
|
138
|
-
Scans BitShares chain activity via Kibana to identify likely DEXBot/DEXBot2
|
|
139
|
-
staggered-orders strategy accounts. Works in phases: discovery queries ->
|
|
140
|
-
pre-filter -> grid spacing analysis -> name resolution -> ranked output.
|
|
141
|
-
|
|
142
|
-
Options:
|
|
143
|
-
--days <n> Lookback window in days (default: 14)
|
|
144
|
-
--min-creates <n> Minimum limit_order_create count (default: 20)
|
|
145
|
-
--top <n> Top N candidates for grid analysis (default: 30)
|
|
146
|
-
--no-grid Skip grid spacing analysis (fast, counts only)
|
|
147
|
-
--output-json <f> Export full results as JSON to <f>
|
|
148
|
-
--cv-threshold <n> CV threshold for grid detection (default: 0.35)
|
|
149
|
-
Lower = stricter grid matching.
|
|
150
|
-
--retries <n> Max retry attempts per Kibana query (default: 3)
|
|
151
|
-
--verbose Print extra debug/diagnostic info
|
|
152
|
-
--help, -h Show this help
|
|
153
|
-
|
|
154
|
-
Examples:
|
|
155
|
-
node dist/analysis/bot_usage/discover_bot_accounts.js
|
|
156
|
-
node dist/analysis/bot_usage/discover_bot_accounts.js --days 30 --top 50
|
|
157
|
-
node dist/analysis/bot_usage/discover_bot_accounts.js --no-grid
|
|
158
|
-
node dist/analysis/bot_usage/discover_bot_accounts.js --output-json results.json`);
|
|
159
|
-
process.exit(0);
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
// ─── Retry wrapper ────────────────────────────────────────────────────────────
|
|
163
|
-
|
|
164
|
-
async function withRetry<T>(fn: () => Promise<T>, label: string, maxRetries = 3, baseDelayMs = 1000): Promise<T> {
|
|
165
|
-
for (let attempt = 1; attempt <= maxRetries; attempt++) {
|
|
166
|
-
try {
|
|
167
|
-
return await fn();
|
|
168
|
-
} catch (e: any) {
|
|
169
|
-
if (attempt < maxRetries) {
|
|
170
|
-
const delay = baseDelayMs * Math.pow(2, attempt - 1);
|
|
171
|
-
console.warn(` [warn] ${label} attempt ${attempt}/${maxRetries} failed: ${e.message}`);
|
|
172
|
-
console.warn(` retrying in ${delay}ms...`);
|
|
173
|
-
await new Promise(r => setTimeout(r, delay));
|
|
174
|
-
} else {
|
|
175
|
-
throw new Error(`${label} failed after ${maxRetries} attempts: ${e.message}`);
|
|
176
|
-
}
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
throw new Error('Unreachable');
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
// ─── Grid analysis helpers (self-contained, no external import) ───────────────
|
|
183
|
-
|
|
184
|
-
function hitPrice(hit: any, sellPrec: number, recvPrec: number): number | null {
|
|
185
|
-
const op = hit._source?.operation_history?.op_object;
|
|
186
|
-
const sell = op?.amount_to_sell?.amount;
|
|
187
|
-
const recv = op?.min_to_receive?.amount;
|
|
188
|
-
if (!sell || !recv || sell <= 0 || recv <= 0) return null;
|
|
189
|
-
return (recv / Math.pow(10, recvPrec)) / (sell / Math.pow(10, sellPrec));
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
function spacingStats(prices: number[], cvThreshold = 0.35) {
|
|
193
|
-
if (prices.length < 3) return { isGrid: false, score: 0, count: prices.length };
|
|
194
|
-
const s = [...prices].sort((a, b) => a - b);
|
|
195
|
-
const u = [s[0]];
|
|
196
|
-
for (let i = 1; i < s.length; i++) {
|
|
197
|
-
if (Math.abs((s[i] - s[i - 1]) / s[i - 1]) > 1e-5) u.push(s[i]);
|
|
198
|
-
}
|
|
199
|
-
if (u.length < 3) return { isGrid: false, score: 0, count: prices.length };
|
|
200
|
-
const lr: number[] = [];
|
|
201
|
-
for (let i = 1; i < u.length; i++) lr.push(Math.log(u[i] / u[i - 1]));
|
|
202
|
-
const mean = lr.reduce((a, b) => a + b, 0) / lr.length;
|
|
203
|
-
const vari = lr.reduce((s, r) => s + (r - mean) ** 2, 0) / lr.length;
|
|
204
|
-
const cv = mean > 1e-10 ? Math.sqrt(vari) / mean : Infinity;
|
|
205
|
-
const isGrid = cv < cvThreshold && u.length >= 4;
|
|
206
|
-
return {
|
|
207
|
-
count: prices.length,
|
|
208
|
-
uniqueCount: u.length,
|
|
209
|
-
impliedIncrementPct: (Math.exp(mean) - 1) * 100,
|
|
210
|
-
minPrice: u[0], maxPrice: u[u.length - 1],
|
|
211
|
-
cv, isGrid,
|
|
212
|
-
score: isGrid ? Math.max(0, Math.min(100, Math.round((1 - cv) * 100))) : 0,
|
|
213
|
-
};
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
/**
|
|
217
|
-
* Session-aware grid spacing analysis.
|
|
218
|
-
* Groups hits by 2-minute proximity, finds the best-scoring session.
|
|
219
|
-
*/
|
|
220
|
-
function analyzeGrid(hits: any[], sellPrec: number, recvPrec: number, cvThreshold = 0.35) {
|
|
221
|
-
if (!hits || hits.length < 3) return { isGrid: false, score: 0, count: hits?.length ?? 0 };
|
|
222
|
-
const SESSION_GAP = 2 * 60 * 1000;
|
|
223
|
-
|
|
224
|
-
const entries = hits.map(h => {
|
|
225
|
-
const p = hitPrice(h, sellPrec, recvPrec);
|
|
226
|
-
const t = h._source?.block_data?.block_time
|
|
227
|
-
? new Date(h._source.block_data.block_time).getTime() : null;
|
|
228
|
-
return p && t ? { p, t } : null;
|
|
229
|
-
}).filter((x): x is { p: number; t: number } => x !== null).sort((a, b) => a.t - b.t);
|
|
230
|
-
|
|
231
|
-
if (entries.length < 3) return { isGrid: false, score: 0, count: entries.length };
|
|
232
|
-
|
|
233
|
-
const sessions: { p: number; t: number }[][] = [[entries[0]]];
|
|
234
|
-
for (let i = 1; i < entries.length; i++) {
|
|
235
|
-
if (entries[i].t - entries[i - 1].t > SESSION_GAP) sessions.push([]);
|
|
236
|
-
sessions[sessions.length - 1].push(entries[i]);
|
|
237
|
-
}
|
|
238
|
-
|
|
239
|
-
let best: any = null;
|
|
240
|
-
for (const sess of sessions) {
|
|
241
|
-
if (sess.length < 4) continue;
|
|
242
|
-
const stats = spacingStats(sess.map(e => e.p), cvThreshold);
|
|
243
|
-
if (!best || stats.score > best.score || (stats.score === best.score && (stats as any).cv < (best as any).cv)) {
|
|
244
|
-
best = stats;
|
|
245
|
-
}
|
|
246
|
-
}
|
|
247
|
-
|
|
248
|
-
if (!best) best = spacingStats(entries.map(e => e.p), cvThreshold);
|
|
249
|
-
return { ...best, totalOrders: entries.length, sessionCount: sessions.length };
|
|
250
|
-
}
|
|
251
|
-
|
|
252
|
-
function analyzeBatching(hits: any[]) {
|
|
253
|
-
if (!hits.length) return { maxBatch: 0, avgBatch: 0 };
|
|
254
|
-
const counts: Record<string, number> = {};
|
|
255
|
-
for (const h of hits) {
|
|
256
|
-
const t = h._source?.block_data?.block_time;
|
|
257
|
-
if (t) counts[t] = (counts[t] ?? 0) + 1;
|
|
258
|
-
}
|
|
259
|
-
const vals = Object.values(counts);
|
|
260
|
-
return {
|
|
261
|
-
maxBatch: Math.max(...vals),
|
|
262
|
-
avgBatch: vals.reduce((a, b) => a + b, 0) / vals.length,
|
|
263
|
-
};
|
|
264
|
-
}
|
|
265
|
-
|
|
266
|
-
// ─── DEXBot score ─────────────────────────────────────────────────────────────
|
|
267
|
-
|
|
268
|
-
function dexScore(creates: number, fills: number, _cancels: number, gridScore: number, maxBatch: number): number {
|
|
269
|
-
let s = 0;
|
|
270
|
-
s += Math.round(gridScore * 0.4); // grid quality (0–40)
|
|
271
|
-
if (maxBatch >= 4) s += 20; // batch size (0–20)
|
|
272
|
-
else if (maxBatch >= 2) s += 10;
|
|
273
|
-
if (creates >= 50) s += 20; else if (creates >= 20) s += 10; // volume (0–20)
|
|
274
|
-
const fr = creates > 0 ? fills / creates : 0;
|
|
275
|
-
if (fr >= 0.03 && fr <= 0.95) s += 20; // fill rate (0–20)
|
|
276
|
-
return Math.min(100, s);
|
|
277
|
-
}
|
|
278
|
-
|
|
279
|
-
// ─── Account resolution ───────────────────────────────────────────────────────
|
|
280
|
-
|
|
281
|
-
async function resolveNames(ids: string[]): Promise<Record<string, string>> {
|
|
282
|
-
const map: Record<string, any> = {};
|
|
283
|
-
try {
|
|
284
|
-
// Ephemeral read-only client over the built-in node pool (shared helper).
|
|
285
|
-
await withReadOnlyClient(async (client) => {
|
|
286
|
-
// BitShares db.get_objects accepts an array of IDs
|
|
287
|
-
const objects = await client.db('get_objects', [ids]);
|
|
288
|
-
for (const obj of (objects ?? [])) {
|
|
289
|
-
if (obj?.id && obj?.name) map[obj.id] = obj.name;
|
|
290
|
-
}
|
|
291
|
-
|
|
292
|
-
// Resolve extra asset precisions while connected
|
|
293
|
-
const toCheck = ['IOB.XRP', 'HONEST.MONEY', 'XBTSX.XRP', 'XBTSX.USDT', 'USD', 'CNY'];
|
|
294
|
-
for (const sym of toCheck) {
|
|
295
|
-
try {
|
|
296
|
-
const assets = await client.db('lookup_asset_symbols', [[sym]]);
|
|
297
|
-
const a = Array.isArray(assets) ? assets[0] : null;
|
|
298
|
-
if (a?.id && !(a.id in ASSET_PRECISION)) {
|
|
299
|
-
(ASSET_PRECISION as Record<string, any>)[a.id] = a.precision;
|
|
300
|
-
}
|
|
301
|
-
} catch (_) {}
|
|
302
|
-
}
|
|
303
|
-
});
|
|
304
|
-
} catch (e: any) {
|
|
305
|
-
console.warn(` [warn] Name resolution failed: ${e.message}`);
|
|
306
|
-
}
|
|
307
|
-
return map;
|
|
308
|
-
}
|
|
309
|
-
|
|
310
|
-
// ─── Main ─────────────────────────────────────────────────────────────────────
|
|
311
|
-
|
|
312
|
-
async function run() {
|
|
313
|
-
const opts = parseArgs();
|
|
314
|
-
const lookbackH = opts.days * 24;
|
|
315
|
-
|
|
316
|
-
console.log('');
|
|
317
|
-
console.log('════════════════════════════════════════════════════════════════════');
|
|
318
|
-
console.log(' DEXBot Account Discovery Scan');
|
|
319
|
-
console.log('════════════════════════════════════════════════════════════════════');
|
|
320
|
-
console.log(` Kibana: https://kibana.bitshares.dev`);
|
|
321
|
-
console.log(` Lookback: ${opts.days} days`);
|
|
322
|
-
console.log(` Min creates: ${opts.minCreates}`);
|
|
323
|
-
console.log(` Top N: ${opts.top} candidates for grid analysis`);
|
|
324
|
-
console.log(` Grid scan: ${opts.skipGrid ? 'disabled' : 'enabled'}`);
|
|
325
|
-
console.log(` Timestamp: ${new Date().toISOString().replace('T', ' ').slice(0, 19)} UTC`);
|
|
326
|
-
console.log('');
|
|
327
|
-
|
|
328
|
-
// ── Phase 1: Discovery queries ─────────────────────────────────────────────
|
|
329
|
-
|
|
330
|
-
console.log('Phase 1: Querying Kibana for top active accounts...');
|
|
331
|
-
|
|
332
|
-
const [createRes, cancelRes, fillRes, updateRes]: any[] = await Promise.all([
|
|
333
|
-
withRetry(() => kibanaSearch(KIBANA_CFG, buildTopSellerAccountsQuery(lookbackH, 200, opts.minCreates)),
|
|
334
|
-
'top-seller query', opts.maxRetries),
|
|
335
|
-
withRetry(() => kibanaSearch(KIBANA_CFG, buildTopCancellerAccountsQuery(lookbackH, 200, 5)),
|
|
336
|
-
'top-canceller query', opts.maxRetries),
|
|
337
|
-
withRetry(() => kibanaSearch(KIBANA_CFG, buildTopFilledAccountsQuery(lookbackH, 200, 3)),
|
|
338
|
-
'top-fills query', opts.maxRetries),
|
|
339
|
-
withRetry(() => kibanaSearch(KIBANA_CFG, buildTopUpdaterAccountsQuery(lookbackH, 200, 1)),
|
|
340
|
-
'top-updater query', opts.maxRetries),
|
|
341
|
-
]);
|
|
342
|
-
|
|
343
|
-
const createBuckets = createRes?.aggregations?.by_account?.buckets ?? [];
|
|
344
|
-
const cancelBuckets = cancelRes?.aggregations?.by_account?.buckets ?? [];
|
|
345
|
-
const fillBuckets = fillRes?.aggregations?.by_account?.buckets ?? [];
|
|
346
|
-
const updateBuckets = updateRes?.aggregations?.by_account?.buckets ?? [];
|
|
347
|
-
|
|
348
|
-
if (opts.verbose) {
|
|
349
|
-
console.log(` [verbose] createRes keys: ${Object.keys(createRes ?? {}).join(', ')}`);
|
|
350
|
-
console.log(` [verbose] createRes took: ${createRes?.took ?? '?'}ms`);
|
|
351
|
-
}
|
|
352
|
-
|
|
353
|
-
console.log(` Creates: ${createBuckets.length} accounts with ≥${opts.minCreates} creates`);
|
|
354
|
-
console.log(` Cancels: ${cancelBuckets.length} accounts with ≥5 cancels`);
|
|
355
|
-
console.log(` Fills: ${fillBuckets.length} accounts with ≥3 fills`);
|
|
356
|
-
console.log(` Updates: ${updateBuckets.length} accounts with ≥1 limit_order_update (op 77)`);
|
|
357
|
-
|
|
358
|
-
if (createBuckets.length === 0) {
|
|
359
|
-
console.log('');
|
|
360
|
-
console.log(' No accounts found. Try a larger --days window or lower --min-creates.');
|
|
361
|
-
if (opts.outputJson) {
|
|
362
|
-
writeJSON(opts.outputJson, { results: [], note: 'No accounts found', opts });
|
|
363
|
-
console.log(` Wrote empty results to ${opts.outputJson}`);
|
|
364
|
-
}
|
|
365
|
-
return;
|
|
366
|
-
}
|
|
367
|
-
|
|
368
|
-
// ── Phase 2: Merge & pre-filter ────────────────────────────────────────────
|
|
369
|
-
|
|
370
|
-
console.log('\nPhase 2: Merging and filtering candidates...');
|
|
371
|
-
|
|
372
|
-
const accounts: Record<string, AccountCounts> = {};
|
|
373
|
-
for (const b of createBuckets) accounts[b.key] = { creates: b.doc_count, cancels: 0, fills: 0, updates: 0 };
|
|
374
|
-
for (const b of cancelBuckets) {
|
|
375
|
-
if (!accounts[b.key]) accounts[b.key] = { creates: 0, cancels: 0, fills: 0, updates: 0 };
|
|
376
|
-
accounts[b.key].cancels = b.doc_count;
|
|
377
|
-
}
|
|
378
|
-
for (const b of fillBuckets) {
|
|
379
|
-
if (!accounts[b.key]) accounts[b.key] = { creates: 0, cancels: 0, fills: 0, updates: 0 };
|
|
380
|
-
accounts[b.key].fills = b.doc_count;
|
|
381
|
-
}
|
|
382
|
-
for (const b of updateBuckets) {
|
|
383
|
-
if (!accounts[b.key]) accounts[b.key] = { creates: 0, cancels: 0, fills: 0, updates: 0 };
|
|
384
|
-
accounts[b.key].updates = b.doc_count;
|
|
385
|
-
}
|
|
386
|
-
|
|
387
|
-
// Pre-filter: must have creates ≥ minCreates (grid analysis determines DEXBot candidacy)
|
|
388
|
-
// Flavor: any limit_order_update (op 77) in-window → DEXBot2 (native in-place
|
|
389
|
-
// re-price); zero updates → DEXBot1-style (cancel-only: cancel + recreate).
|
|
390
|
-
const candidates: CandidateInfo[] = (Object.entries(accounts) as [string, AccountCounts][])
|
|
391
|
-
.filter(([, s]) => s.creates >= opts.minCreates)
|
|
392
|
-
.map(([id, s]) => ({
|
|
393
|
-
id,
|
|
394
|
-
creates: s.creates,
|
|
395
|
-
cancels: s.cancels,
|
|
396
|
-
fills: s.fills,
|
|
397
|
-
updates: s.updates,
|
|
398
|
-
flavor: (s.updates >= 1 ? 'DEXBot2' : 'DEXBot1') as 'DEXBot2' | 'DEXBot1',
|
|
399
|
-
cancelRatio: s.cancels / Math.max(s.creates, 1),
|
|
400
|
-
fillRate: s.creates > 0 ? (s.fills / s.creates * 100) : 0,
|
|
401
|
-
} as CandidateInfo))
|
|
402
|
-
.sort((a, b) => b.creates - a.creates);
|
|
403
|
-
|
|
404
|
-
console.log(` Total unique accounts: ${Object.keys(accounts).length}`);
|
|
405
|
-
console.log(` After filter: ${candidates.length} candidates`);
|
|
406
|
-
console.log(` Will analyze top: ${Math.min(opts.top, candidates.length)}`);
|
|
407
|
-
|
|
408
|
-
const toAnalyze = candidates.slice(0, opts.top);
|
|
409
|
-
|
|
410
|
-
// ── Phase 3: Grid analysis ─────────────────────────────────────────────────
|
|
411
|
-
|
|
412
|
-
const results: CandidateInfo[] = toAnalyze.map(c => ({
|
|
413
|
-
...c,
|
|
414
|
-
gridScore: 0, impliedInc: null, maxBatch: 0, dexScore: 0,
|
|
415
|
-
cv: null, name: '', ordersFetched: 0, buyCount: 0, sellCount: 0, pairAssets: [],
|
|
416
|
-
}));
|
|
417
|
-
|
|
418
|
-
if (!opts.skipGrid) {
|
|
419
|
-
console.log('\nPhase 3: Grid analysis (batches of 5)...');
|
|
420
|
-
|
|
421
|
-
const BATCH = 5;
|
|
422
|
-
for (let i = 0; i < results.length; i += BATCH) {
|
|
423
|
-
const slice = results.slice(i, i + BATCH);
|
|
424
|
-
process.stdout.write(` [${i + 1}–${Math.min(i + BATCH, results.length)}/${results.length}] `);
|
|
425
|
-
|
|
426
|
-
const priceResults: any[] = await Promise.all(
|
|
427
|
-
slice.map(r => withRetry(
|
|
428
|
-
() => kibanaSearch(KIBANA_CFG, buildOrderPriceQuery(r.id, lookbackH, null, 200)),
|
|
429
|
-
`price-query for ${r.id}`,
|
|
430
|
-
opts.maxRetries
|
|
431
|
-
))
|
|
432
|
-
);
|
|
433
|
-
|
|
434
|
-
for (let j = 0; j < slice.length; j++) {
|
|
435
|
-
const r = slice[j];
|
|
436
|
-
const hits = priceResults[j]?.hits?.hits ?? [];
|
|
437
|
-
|
|
438
|
-
const buyHits = hits.filter((h: any) =>
|
|
439
|
-
h._source?.operation_history?.op_object?.amount_to_sell?.asset_id === '1.3.0'
|
|
440
|
-
);
|
|
441
|
-
const sellHits = hits.filter((h: any) =>
|
|
442
|
-
h._source?.operation_history?.op_object?.amount_to_sell?.asset_id !== '1.3.0'
|
|
443
|
-
);
|
|
444
|
-
|
|
445
|
-
const sellAssetId = sellHits[0]
|
|
446
|
-
?._source?.operation_history?.op_object?.amount_to_sell?.asset_id
|
|
447
|
-
?? buyHits[0]?._source?.operation_history?.op_object?.min_to_receive?.asset_id;
|
|
448
|
-
|
|
449
|
-
const btsPrc = getPrec('1.3.0');
|
|
450
|
-
const aPrc = getPrec(sellAssetId ?? '');
|
|
451
|
-
|
|
452
|
-
const primaryHits = buyHits.length >= sellHits.length ? buyHits : sellHits;
|
|
453
|
-
const [pSell, pRecv] = buyHits.length >= sellHits.length
|
|
454
|
-
? [btsPrc, aPrc] : [aPrc, btsPrc];
|
|
455
|
-
|
|
456
|
-
const grid = analyzeGrid(primaryHits, pSell, pRecv, opts.cvThreshold);
|
|
457
|
-
const batch = analyzeBatching(hits);
|
|
458
|
-
|
|
459
|
-
const pairAssets = new Set(hits.flatMap((h: any) => {
|
|
460
|
-
const op = h._source?.operation_history?.op_object;
|
|
461
|
-
return [op?.amount_to_sell?.asset_id, op?.min_to_receive?.asset_id].filter(Boolean);
|
|
462
|
-
}) as string[]);
|
|
463
|
-
r.pairAssets = [...pairAssets];
|
|
464
|
-
|
|
465
|
-
r.gridScore = grid.score;
|
|
466
|
-
r.impliedInc = (grid as any).impliedIncrementPct ?? null;
|
|
467
|
-
r.cv = (grid as any).cv ?? null;
|
|
468
|
-
r.maxBatch = batch.maxBatch;
|
|
469
|
-
r.dexScore = dexScore(r.creates, r.fills, r.cancels, grid.score, batch.maxBatch);
|
|
470
|
-
r.ordersFetched = hits.length;
|
|
471
|
-
r.buyCount = buyHits.length;
|
|
472
|
-
r.sellCount = sellHits.length;
|
|
473
|
-
|
|
474
|
-
if (opts.verbose && hits.length > 0) {
|
|
475
|
-
process.stdout.write(`\n [verbose] ${r.id}: ${hits.length} orders (${buyHits.length} buy/${sellHits.length} sell), ` +
|
|
476
|
-
`grid=${grid.score} cv=${(grid as any).cv?.toFixed(4) ?? '?'} sessions=${(grid as any).sessionCount}`);
|
|
477
|
-
process.stdout.write(`\n`);
|
|
478
|
-
} else {
|
|
479
|
-
process.stdout.write('.');
|
|
480
|
-
}
|
|
481
|
-
}
|
|
482
|
-
if (!opts.verbose) console.log('');
|
|
483
|
-
}
|
|
484
|
-
} else {
|
|
485
|
-
// Without grid: assign a simpler heuristic score
|
|
486
|
-
for (const r of results) {
|
|
487
|
-
const fr = r.fillRate / 100;
|
|
488
|
-
r.dexScore = Math.round(Math.min(70,
|
|
489
|
-
(Math.min(r.creates, 100) / 100 * 20) +
|
|
490
|
-
(Math.min(r.cancelRatio, 1.5) / 1.5 * 30) +
|
|
491
|
-
(fr >= 0.03 && fr <= 0.95 ? 20 : 0)
|
|
492
|
-
));
|
|
493
|
-
}
|
|
494
|
-
}
|
|
495
|
-
|
|
496
|
-
// Sort by DEX score
|
|
497
|
-
results.sort((a, b) => b.dexScore - a.dexScore || b.creates - a.creates);
|
|
498
|
-
|
|
499
|
-
// ── Phase 4: Resolve account names ────────────────────────────────────────
|
|
500
|
-
|
|
501
|
-
console.log('\nPhase 4: Resolving account names...');
|
|
502
|
-
const allIds = results.map(r => r.id);
|
|
503
|
-
const nameMap = await resolveNames(allIds);
|
|
504
|
-
for (const r of results) r.name = nameMap[r.id] ?? r.id;
|
|
505
|
-
|
|
506
|
-
// ── Phase 5: Output ───────────────────────────────────────────────────────
|
|
507
|
-
|
|
508
|
-
console.log('');
|
|
509
|
-
console.log('════════════════════════════════════════════════════════════════════════════════════');
|
|
510
|
-
console.log(' Discovery Results — Ranked by DEX Score');
|
|
511
|
-
console.log('════════════════════════════════════════════════════════════════════════════════════');
|
|
512
|
-
console.log('');
|
|
513
|
-
|
|
514
|
-
// Print by DEX score tier. HIGH tier (80+) splits by update-order usage:
|
|
515
|
-
// DEXBot2 — broadcast limit_order_update (op 77) in-window (in-place re-price)
|
|
516
|
-
// DEXBot1-style — cancel-only, no op 77 (cancel + recreate)
|
|
517
|
-
const highV2 = results.filter(r => r.dexScore >= 80 && r.updates >= 1);
|
|
518
|
-
const highV1 = results.filter(r => r.dexScore >= 80 && r.updates < 1);
|
|
519
|
-
|
|
520
|
-
const hdrHigh = ' # Name ID Creates Fills Cancel Fill% C/C MaxBatch Incr% Grid DEX Updates';
|
|
521
|
-
function printHighGroup(label: string, rows: CandidateInfo[]) {
|
|
522
|
-
if (!rows.length) return;
|
|
523
|
-
console.log(` ── ${label}`);
|
|
524
|
-
console.log('');
|
|
525
|
-
console.log(hdrHigh);
|
|
526
|
-
console.log(' ' + '─'.repeat(hdrHigh.length - 1));
|
|
527
|
-
for (const r of rows) {
|
|
528
|
-
const rank = String(results.indexOf(r) + 1).padStart(2);
|
|
529
|
-
const name = r.name.padEnd(22).slice(0, 22);
|
|
530
|
-
const id = r.id.padEnd(14);
|
|
531
|
-
const creates = String(r.creates).padStart(7);
|
|
532
|
-
const fills = String(r.fills).padStart(6);
|
|
533
|
-
const cancels = String(r.cancels).padStart(7);
|
|
534
|
-
const fr = (r.fillRate.toFixed(1) + '%').padStart(5);
|
|
535
|
-
const cr = r.cancelRatio.toFixed(2).padStart(4);
|
|
536
|
-
const batch = String(r.maxBatch || '-').padStart(9);
|
|
537
|
-
const inc = (r.impliedInc != null ? r.impliedInc.toFixed(2) + '%' : 'n/a').padStart(6);
|
|
538
|
-
const grid = String(r.gridScore).padStart(5);
|
|
539
|
-
const dex = String(r.dexScore).padStart(4);
|
|
540
|
-
const upd = String(r.updates).padStart(7);
|
|
541
|
-
console.log(` ${rank} ${name} ${id} ${creates} ${fills} ${cancels} ${fr} ${cr} ${batch} ${inc} ${grid} ${dex} ${upd}`);
|
|
542
|
-
}
|
|
543
|
-
console.log('');
|
|
544
|
-
}
|
|
545
|
-
printHighGroup('HIGH confidence — DEXBot2 (80+, uses limit_order_update op 77)', highV2);
|
|
546
|
-
printHighGroup('HIGH confidence — DEXBot1-style (80+, cancel-only, no op 77)', highV1);
|
|
547
|
-
|
|
548
|
-
const tiers = [
|
|
549
|
-
{ label: 'MEDIUM confidence (50–79) — likely a grid bot', min: 50, max: 80 },
|
|
550
|
-
{ label: 'LOW confidence (25–49) — some automation detected', min: 25, max: 50 },
|
|
551
|
-
{ label: 'WEAK signal (<25) — create/cancel pattern, no grid', min: 0, max: 25 },
|
|
552
|
-
];
|
|
553
|
-
|
|
554
|
-
for (const tier of tiers) {
|
|
555
|
-
const group = results.filter(r => r.dexScore >= tier.min && r.dexScore < tier.max);
|
|
556
|
-
if (!group.length) continue;
|
|
557
|
-
|
|
558
|
-
console.log(` ── ${tier.label}`);
|
|
559
|
-
console.log('');
|
|
560
|
-
|
|
561
|
-
const hdr = ' # Name ID Creates Fills Cancel Fill% C/C MaxBatch Incr% Grid DEX';
|
|
562
|
-
console.log(hdr);
|
|
563
|
-
console.log(' ' + '─'.repeat(hdr.length - 1));
|
|
564
|
-
|
|
565
|
-
group.forEach((r, _i) => {
|
|
566
|
-
const rank = String(results.indexOf(r) + 1).padStart(2);
|
|
567
|
-
const name = r.name.padEnd(22).slice(0, 22);
|
|
568
|
-
const id = r.id.padEnd(14);
|
|
569
|
-
const creates = String(r.creates).padStart(7);
|
|
570
|
-
const fills = String(r.fills).padStart(6);
|
|
571
|
-
const cancels = String(r.cancels).padStart(7);
|
|
572
|
-
const fr = (r.fillRate.toFixed(1) + '%').padStart(5);
|
|
573
|
-
const cr = r.cancelRatio.toFixed(2).padStart(4);
|
|
574
|
-
const batch = String(r.maxBatch || '-').padStart(9);
|
|
575
|
-
const inc = (r.impliedInc != null ? r.impliedInc.toFixed(2) + '%' : 'n/a').padStart(6);
|
|
576
|
-
const grid = String(r.gridScore).padStart(5);
|
|
577
|
-
const dex = String(r.dexScore).padStart(4);
|
|
578
|
-
console.log(` ${rank} ${name} ${id} ${creates} ${fills} ${cancels} ${fr} ${cr} ${batch} ${inc} ${grid} ${dex}`);
|
|
579
|
-
});
|
|
580
|
-
console.log('');
|
|
581
|
-
}
|
|
582
|
-
|
|
583
|
-
// ── Summary ───────────────────────────────────────────────────────────────
|
|
584
|
-
|
|
585
|
-
const high = highV2.length + highV1.length;
|
|
586
|
-
const medium = results.filter(r => r.dexScore >= 50 && r.dexScore < 80).length;
|
|
587
|
-
const low = results.filter(r => r.dexScore >= 25 && r.dexScore < 50).length;
|
|
588
|
-
|
|
589
|
-
console.log('════════════════════════════════════════════════════════════════════════════════════');
|
|
590
|
-
console.log(` Total candidates scanned: ${results.length}`);
|
|
591
|
-
console.log(` HIGH (80+): ${high} accounts — DEXBot2: ${highV2.length} (op 77 updates) / DEXBot1-style: ${highV1.length} (cancel-only)`);
|
|
592
|
-
console.log(` MEDIUM (50+): ${medium} accounts — likely grid bots`);
|
|
593
|
-
console.log(` LOW (25+): ${low} accounts — weak signal`);
|
|
594
|
-
console.log('');
|
|
595
|
-
console.log(' Columns:');
|
|
596
|
-
console.log(' C/C = cancel/create ratio (grid bots: ~1.0)');
|
|
597
|
-
console.log(' Incr% = implied grid increment from price spacing');
|
|
598
|
-
console.log(' Grid = grid quality 0-100 | DEX = DEXBot confidence 0-100');
|
|
599
|
-
console.log(' Updates = limit_order_update (op 77) count — DEXBot2 only; 0 = cancel-only (DEXBot1-style)');
|
|
600
|
-
console.log('');
|
|
601
|
-
|
|
602
|
-
// ── Export JSON ────────────────────────────────────────────────────────────
|
|
603
|
-
|
|
604
|
-
if (opts.outputJson) {
|
|
605
|
-
const exportData = results.map(r => ({
|
|
606
|
-
id: r.id,
|
|
607
|
-
name: r.name,
|
|
608
|
-
flavor: r.flavor,
|
|
609
|
-
creates: r.creates,
|
|
610
|
-
fills: r.fills,
|
|
611
|
-
cancels: r.cancels,
|
|
612
|
-
updates: r.updates,
|
|
613
|
-
fillPct: r.fillRate,
|
|
614
|
-
cancelRatio: r.cancelRatio,
|
|
615
|
-
maxBatch: r.maxBatch,
|
|
616
|
-
gridScore: r.gridScore,
|
|
617
|
-
impliedInc: r.impliedInc,
|
|
618
|
-
cv: r.cv,
|
|
619
|
-
dexScore: r.dexScore,
|
|
620
|
-
ordersFetched: r.ordersFetched,
|
|
621
|
-
buyCount: r.buyCount,
|
|
622
|
-
sellCount: r.sellCount,
|
|
623
|
-
pairAssets: r.pairAssets,
|
|
624
|
-
}));
|
|
625
|
-
writeJSON(opts.outputJson, { results: exportData, opts: { days: opts.days, minCreates: opts.minCreates, cvThreshold: opts.cvThreshold, skipGrid: opts.skipGrid, timestamp: new Date().toISOString() } });
|
|
626
|
-
console.log(` Results exported to ${opts.outputJson}`);
|
|
627
|
-
console.log('');
|
|
628
|
-
}
|
|
629
|
-
}
|
|
630
|
-
|
|
631
|
-
run().then(() => process.exit(0)).catch((e: any) => {
|
|
632
|
-
console.error('\n[fatal]', e.message);
|
|
633
|
-
if (process.env.DEBUG) console.error(e.stack);
|
|
634
|
-
process.exit(1);
|
|
635
|
-
});
|