dexbot 1.1.10
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/LICENSE +21 -0
- package/README.md +287 -0
- package/claw/README.md +513 -0
- package/claw/scripts/memu_runner.py +385 -0
- package/claw/skills/bitshares-guide/SKILL.md +14 -0
- package/claw/skills/bitshares-guide/references/example-skill-shells.md +18 -0
- package/claw/skills/bitshares-guide/references/presentation-patterns.md +19 -0
- package/claw/skills/bitshares-guide/references/scope-guardrails.md +9 -0
- package/claw/skills/launcher-ops/SKILL.md +18 -0
- package/claw/skills/launcher-ops/references/launcher-workflow.md +23 -0
- package/claw/skills/margin-trading/SKILL.md +23 -0
- package/claw/skills/margin-trading/references/honest-asset-list.md +74 -0
- package/claw/skills/margin-trading/references/honest-assets.md +44 -0
- package/claw/skills/margin-trading/references/position-management.md +203 -0
- package/claw/skills/margin-trading/references/trading-concepts.md +80 -0
- package/claw/skills/memu-memory/SKILL.md +218 -0
- package/claw/skills/shared/references/js-automation-overview.md +24 -0
- package/claw/skills/shared/references/safety-and-staleness.md +11 -0
- package/claw/skills/shared/references/skill-boundaries.md +17 -0
- package/claw/skills/trend-detection/SKILL.md +33 -0
- package/claw/skills/trend-detection/agents/openai.yaml +3 -0
- package/claw/skills/trend-detection/references/service.md +45 -0
- package/dist/analysis/ama_fitting/analyze_ama_price_changes.d.ts +3 -0
- package/dist/analysis/ama_fitting/analyze_ama_price_changes.d.ts.map +1 -0
- package/dist/analysis/ama_fitting/analyze_ama_price_changes.js +149 -0
- package/dist/analysis/ama_fitting/analyze_ama_price_changes.js.map +1 -0
- package/dist/analysis/ama_fitting/analyze_lambda_vs_slow.d.ts +3 -0
- package/dist/analysis/ama_fitting/analyze_lambda_vs_slow.d.ts.map +1 -0
- package/dist/analysis/ama_fitting/analyze_lambda_vs_slow.js +387 -0
- package/dist/analysis/ama_fitting/analyze_lambda_vs_slow.js.map +1 -0
- package/dist/analysis/ama_fitting/calibrate_convergence_er.d.ts +3 -0
- package/dist/analysis/ama_fitting/calibrate_convergence_er.d.ts.map +1 -0
- package/dist/analysis/ama_fitting/calibrate_convergence_er.js +200 -0
- package/dist/analysis/ama_fitting/calibrate_convergence_er.js.map +1 -0
- package/dist/analysis/ama_fitting/fetch_lp_candles.d.ts +3 -0
- package/dist/analysis/ama_fitting/fetch_lp_candles.d.ts.map +1 -0
- package/dist/analysis/ama_fitting/fetch_lp_candles.js +212 -0
- package/dist/analysis/ama_fitting/fetch_lp_candles.js.map +1 -0
- package/dist/analysis/ama_fitting/generate_unified_comparison_chart.d.ts +31 -0
- package/dist/analysis/ama_fitting/generate_unified_comparison_chart.d.ts.map +1 -0
- package/dist/analysis/ama_fitting/generate_unified_comparison_chart.js +249 -0
- package/dist/analysis/ama_fitting/generate_unified_comparison_chart.js.map +1 -0
- package/dist/analysis/ama_fitting/optimizer_high_resolution.d.ts +2 -0
- package/dist/analysis/ama_fitting/optimizer_high_resolution.d.ts.map +1 -0
- package/dist/analysis/ama_fitting/optimizer_high_resolution.js +782 -0
- package/dist/analysis/ama_fitting/optimizer_high_resolution.js.map +1 -0
- package/dist/analysis/analyze_derivatives.d.ts +95 -0
- package/dist/analysis/analyze_derivatives.d.ts.map +1 -0
- package/dist/analysis/analyze_derivatives.js +295 -0
- package/dist/analysis/analyze_derivatives.js.map +1 -0
- package/dist/analysis/analyze_dynamic_weight.d.ts +14 -0
- package/dist/analysis/analyze_dynamic_weight.d.ts.map +1 -0
- package/dist/analysis/analyze_dynamic_weight.js +208 -0
- package/dist/analysis/analyze_dynamic_weight.js.map +1 -0
- package/dist/analysis/analyze_kalman.d.ts +13 -0
- package/dist/analysis/analyze_kalman.d.ts.map +1 -0
- package/dist/analysis/analyze_kalman.js +123 -0
- package/dist/analysis/analyze_kalman.js.map +1 -0
- package/dist/analysis/analyze_regime.d.ts +20 -0
- package/dist/analysis/analyze_regime.d.ts.map +1 -0
- package/dist/analysis/analyze_regime.js +139 -0
- package/dist/analysis/analyze_regime.js.map +1 -0
- package/dist/analysis/analyze_regime_windows.d.ts +19 -0
- package/dist/analysis/analyze_regime_windows.d.ts.map +1 -0
- package/dist/analysis/analyze_regime_windows.js +413 -0
- package/dist/analysis/analyze_regime_windows.js.map +1 -0
- package/dist/analysis/analyze_risk_profile.d.ts +3 -0
- package/dist/analysis/analyze_risk_profile.d.ts.map +1 -0
- package/dist/analysis/analyze_risk_profile.js +159 -0
- package/dist/analysis/analyze_risk_profile.js.map +1 -0
- package/dist/analysis/analyze_trade_heatmap.d.ts +3 -0
- package/dist/analysis/analyze_trade_heatmap.d.ts.map +1 -0
- package/dist/analysis/analyze_trade_heatmap.js +367 -0
- package/dist/analysis/analyze_trade_heatmap.js.map +1 -0
- package/dist/analysis/analyze_volatility.d.ts +22 -0
- package/dist/analysis/analyze_volatility.d.ts.map +1 -0
- package/dist/analysis/analyze_volatility.js +172 -0
- package/dist/analysis/analyze_volatility.js.map +1 -0
- package/dist/analysis/bot_fitting/backtest_ama_sweep.d.ts +99 -0
- package/dist/analysis/bot_fitting/backtest_ama_sweep.d.ts.map +1 -0
- package/dist/analysis/bot_fitting/backtest_ama_sweep.js +804 -0
- package/dist/analysis/bot_fitting/backtest_ama_sweep.js.map +1 -0
- package/dist/analysis/bot_fitting/backtest_bot_fitting.d.ts +2 -0
- package/dist/analysis/bot_fitting/backtest_bot_fitting.d.ts.map +1 -0
- package/dist/analysis/bot_fitting/backtest_bot_fitting.js +347 -0
- package/dist/analysis/bot_fitting/backtest_bot_fitting.js.map +1 -0
- package/dist/analysis/bot_fitting/shared_utils.d.ts +15 -0
- package/dist/analysis/bot_fitting/shared_utils.d.ts.map +1 -0
- package/dist/analysis/bot_fitting/shared_utils.js +48 -0
- package/dist/analysis/bot_fitting/shared_utils.js.map +1 -0
- package/dist/analysis/bot_key_utils.d.ts +16 -0
- package/dist/analysis/bot_key_utils.d.ts.map +1 -0
- package/dist/analysis/bot_key_utils.js +61 -0
- package/dist/analysis/bot_key_utils.js.map +1 -0
- package/dist/analysis/bot_usage/discover_bot_accounts.d.ts +3 -0
- package/dist/analysis/bot_usage/discover_bot_accounts.d.ts.map +1 -0
- package/dist/analysis/bot_usage/discover_bot_accounts.js +498 -0
- package/dist/analysis/bot_usage/discover_bot_accounts.js.map +1 -0
- package/dist/analysis/bot_usage/kibana_bot_queries.d.ts +546 -0
- package/dist/analysis/bot_usage/kibana_bot_queries.d.ts.map +1 -0
- package/dist/analysis/bot_usage/kibana_bot_queries.js +427 -0
- package/dist/analysis/bot_usage/kibana_bot_queries.js.map +1 -0
- package/dist/analysis/chart_utils.d.ts +13 -0
- package/dist/analysis/chart_utils.d.ts.map +1 -0
- package/dist/analysis/chart_utils.js +142 -0
- package/dist/analysis/chart_utils.js.map +1 -0
- package/dist/analysis/derivative_chart_generator.d.ts +18 -0
- package/dist/analysis/derivative_chart_generator.d.ts.map +1 -0
- package/dist/analysis/derivative_chart_generator.js +896 -0
- package/dist/analysis/derivative_chart_generator.js.map +1 -0
- package/dist/analysis/math_utils.d.ts +35 -0
- package/dist/analysis/math_utils.d.ts.map +1 -0
- package/dist/analysis/math_utils.js +121 -0
- package/dist/analysis/math_utils.js.map +1 -0
- package/dist/analysis/price_sources.d.ts +34 -0
- package/dist/analysis/price_sources.d.ts.map +1 -0
- package/dist/analysis/price_sources.js +103 -0
- package/dist/analysis/price_sources.js.map +1 -0
- package/dist/analysis/trade_profitability.d.ts +115 -0
- package/dist/analysis/trade_profitability.d.ts.map +1 -0
- package/dist/analysis/trade_profitability.js +1247 -0
- package/dist/analysis/trade_profitability.js.map +1 -0
- package/dist/analysis/tradingview/analyze_tradingview.d.ts +38 -0
- package/dist/analysis/tradingview/analyze_tradingview.d.ts.map +1 -0
- package/dist/analysis/tradingview/analyze_tradingview.js +212 -0
- package/dist/analysis/tradingview/analyze_tradingview.js.map +1 -0
- package/dist/analysis/tradingview/tradingview_uplot_chart_generator.d.ts +9 -0
- package/dist/analysis/tradingview/tradingview_uplot_chart_generator.d.ts.map +1 -0
- package/dist/analysis/tradingview/tradingview_uplot_chart_generator.js +1717 -0
- package/dist/analysis/tradingview/tradingview_uplot_chart_generator.js.map +1 -0
- package/dist/analysis/trend_detection/derivative_analyzer.d.ts +250 -0
- package/dist/analysis/trend_detection/derivative_analyzer.d.ts.map +1 -0
- package/dist/analysis/trend_detection/derivative_analyzer.js +903 -0
- package/dist/analysis/trend_detection/derivative_analyzer.js.map +1 -0
- package/dist/analysis/trend_detection/dynamic_weight_chart_generator.d.ts +6 -0
- package/dist/analysis/trend_detection/dynamic_weight_chart_generator.d.ts.map +1 -0
- package/dist/analysis/trend_detection/dynamic_weight_chart_generator.js +1449 -0
- package/dist/analysis/trend_detection/dynamic_weight_chart_generator.js.map +1 -0
- package/dist/analysis/trend_detection/hurst_analyzer.d.ts +42 -0
- package/dist/analysis/trend_detection/hurst_analyzer.d.ts.map +1 -0
- package/dist/analysis/trend_detection/hurst_analyzer.js +159 -0
- package/dist/analysis/trend_detection/hurst_analyzer.js.map +1 -0
- package/dist/analysis/trend_detection/kalman_chart_generator.d.ts +6 -0
- package/dist/analysis/trend_detection/kalman_chart_generator.d.ts.map +1 -0
- package/dist/analysis/trend_detection/kalman_chart_generator.js +408 -0
- package/dist/analysis/trend_detection/kalman_chart_generator.js.map +1 -0
- package/dist/analysis/trend_detection/kalman_trend_analyzer.d.ts +103 -0
- package/dist/analysis/trend_detection/kalman_trend_analyzer.d.ts.map +1 -0
- package/dist/analysis/trend_detection/kalman_trend_analyzer.js +229 -0
- package/dist/analysis/trend_detection/kalman_trend_analyzer.js.map +1 -0
- package/dist/analysis/trend_detection/kalman_velocity_smoothing.d.ts +34 -0
- package/dist/analysis/trend_detection/kalman_velocity_smoothing.d.ts.map +1 -0
- package/dist/analysis/trend_detection/kalman_velocity_smoothing.js +89 -0
- package/dist/analysis/trend_detection/kalman_velocity_smoothing.js.map +1 -0
- package/dist/analysis/trend_detection/permutation_entropy_analyzer.d.ts +39 -0
- package/dist/analysis/trend_detection/permutation_entropy_analyzer.d.ts.map +1 -0
- package/dist/analysis/trend_detection/permutation_entropy_analyzer.js +132 -0
- package/dist/analysis/trend_detection/permutation_entropy_analyzer.js.map +1 -0
- package/dist/analysis/trend_detection/regime_chart_generator.d.ts +6 -0
- package/dist/analysis/trend_detection/regime_chart_generator.d.ts.map +1 -0
- package/dist/analysis/trend_detection/regime_chart_generator.js +345 -0
- package/dist/analysis/trend_detection/regime_chart_generator.js.map +1 -0
- package/dist/analysis/trend_detection/tests/test_kalman_trend.d.ts +2 -0
- package/dist/analysis/trend_detection/tests/test_kalman_trend.d.ts.map +1 -0
- package/dist/analysis/trend_detection/tests/test_kalman_trend.js +130 -0
- package/dist/analysis/trend_detection/tests/test_kalman_trend.js.map +1 -0
- package/dist/analysis/trend_detection/tests/test_kalman_velocity_smoothing.d.ts +2 -0
- package/dist/analysis/trend_detection/tests/test_kalman_velocity_smoothing.d.ts.map +1 -0
- package/dist/analysis/trend_detection/tests/test_kalman_velocity_smoothing.js +38 -0
- package/dist/analysis/trend_detection/tests/test_kalman_velocity_smoothing.js.map +1 -0
- package/dist/analysis/trend_detection/volatility_chart_generator.d.ts +6 -0
- package/dist/analysis/trend_detection/volatility_chart_generator.d.ts.map +1 -0
- package/dist/analysis/trend_detection/volatility_chart_generator.js +732 -0
- package/dist/analysis/trend_detection/volatility_chart_generator.js.map +1 -0
- package/dist/bot.d.ts +49 -0
- package/dist/bot.d.ts.map +1 -0
- package/dist/bot.js +221 -0
- package/dist/bot.js.map +1 -0
- package/dist/credential-daemon.d.ts +64 -0
- package/dist/credential-daemon.d.ts.map +1 -0
- package/dist/credential-daemon.js +987 -0
- package/dist/credential-daemon.js.map +1 -0
- package/dist/dexbot.d.ts +87 -0
- package/dist/dexbot.d.ts.map +1 -0
- package/dist/dexbot.js +1222 -0
- package/dist/dexbot.js.map +1 -0
- package/dist/market_adapter/ama_signal_runner.d.ts +3 -0
- package/dist/market_adapter/ama_signal_runner.d.ts.map +1 -0
- package/dist/market_adapter/ama_signal_runner.js +175 -0
- package/dist/market_adapter/ama_signal_runner.js.map +1 -0
- package/dist/market_adapter/candle_utils.d.ts +57 -0
- package/dist/market_adapter/candle_utils.d.ts.map +1 -0
- package/dist/market_adapter/candle_utils.js +252 -0
- package/dist/market_adapter/candle_utils.js.map +1 -0
- package/dist/market_adapter/core/asymmetric_bounds.d.ts +20 -0
- package/dist/market_adapter/core/asymmetric_bounds.d.ts.map +1 -0
- package/dist/market_adapter/core/asymmetric_bounds.js +88 -0
- package/dist/market_adapter/core/asymmetric_bounds.js.map +1 -0
- package/dist/market_adapter/core/config_normalizers.d.ts +10 -0
- package/dist/market_adapter/core/config_normalizers.d.ts.map +1 -0
- package/dist/market_adapter/core/config_normalizers.js +24 -0
- package/dist/market_adapter/core/config_normalizers.js.map +1 -0
- package/dist/market_adapter/core/kibana_candles.d.ts +74 -0
- package/dist/market_adapter/core/kibana_candles.d.ts.map +1 -0
- package/dist/market_adapter/core/kibana_candles.js +249 -0
- package/dist/market_adapter/core/kibana_candles.js.map +1 -0
- package/dist/market_adapter/core/kibana_client.d.ts +27 -0
- package/dist/market_adapter/core/kibana_client.d.ts.map +1 -0
- package/dist/market_adapter/core/kibana_client.js +120 -0
- package/dist/market_adapter/core/kibana_client.js.map +1 -0
- package/dist/market_adapter/core/kibana_market_candles.d.ts +143 -0
- package/dist/market_adapter/core/kibana_market_candles.d.ts.map +1 -0
- package/dist/market_adapter/core/kibana_market_candles.js +170 -0
- package/dist/market_adapter/core/kibana_market_candles.js.map +1 -0
- package/dist/market_adapter/core/market_adapter_service.d.ts +210 -0
- package/dist/market_adapter/core/market_adapter_service.d.ts.map +1 -0
- package/dist/market_adapter/core/market_adapter_service.js +2328 -0
- package/dist/market_adapter/core/market_adapter_service.js.map +1 -0
- package/dist/market_adapter/core/strategies/ama.d.ts +2 -0
- package/dist/market_adapter/core/strategies/ama.d.ts.map +1 -0
- package/dist/market_adapter/core/strategies/ama.js +138 -0
- package/dist/market_adapter/core/strategies/ama.js.map +1 -0
- package/dist/market_adapter/core/strategies/ama_slope_model.d.ts +50 -0
- package/dist/market_adapter/core/strategies/ama_slope_model.d.ts.map +1 -0
- package/dist/market_adapter/core/strategies/ama_slope_model.js +143 -0
- package/dist/market_adapter/core/strategies/ama_slope_model.js.map +1 -0
- package/dist/market_adapter/core/strategies/atr/calculator.d.ts +12 -0
- package/dist/market_adapter/core/strategies/atr/calculator.d.ts.map +1 -0
- package/dist/market_adapter/core/strategies/atr/calculator.js +47 -0
- package/dist/market_adapter/core/strategies/atr/calculator.js.map +1 -0
- package/dist/market_adapter/core/strategies/collateral_manager.d.ts +32 -0
- package/dist/market_adapter/core/strategies/collateral_manager.d.ts.map +1 -0
- package/dist/market_adapter/core/strategies/collateral_manager.js +68 -0
- package/dist/market_adapter/core/strategies/collateral_manager.js.map +1 -0
- package/dist/market_adapter/core/strategies/regime_gate.d.ts +66 -0
- package/dist/market_adapter/core/strategies/regime_gate.d.ts.map +1 -0
- package/dist/market_adapter/core/strategies/regime_gate.js +189 -0
- package/dist/market_adapter/core/strategies/regime_gate.js.map +1 -0
- package/dist/market_adapter/index.d.ts +10 -0
- package/dist/market_adapter/index.d.ts.map +1 -0
- package/dist/market_adapter/index.js +71 -0
- package/dist/market_adapter/index.js.map +1 -0
- package/dist/market_adapter/inputs/fetch_cex_synthetic_data.d.ts +3 -0
- package/dist/market_adapter/inputs/fetch_cex_synthetic_data.d.ts.map +1 -0
- package/dist/market_adapter/inputs/fetch_cex_synthetic_data.js +1165 -0
- package/dist/market_adapter/inputs/fetch_cex_synthetic_data.js.map +1 -0
- package/dist/market_adapter/inputs/fetch_lp_data.d.ts +54 -0
- package/dist/market_adapter/inputs/fetch_lp_data.d.ts.map +1 -0
- package/dist/market_adapter/inputs/fetch_lp_data.js +743 -0
- package/dist/market_adapter/inputs/fetch_lp_data.js.map +1 -0
- package/dist/market_adapter/inputs/kibana_source.d.ts +68 -0
- package/dist/market_adapter/inputs/kibana_source.d.ts.map +1 -0
- package/dist/market_adapter/inputs/kibana_source.js +143 -0
- package/dist/market_adapter/inputs/kibana_source.js.map +1 -0
- package/dist/market_adapter/interval_utils.d.ts +6 -0
- package/dist/market_adapter/interval_utils.d.ts.map +1 -0
- package/dist/market_adapter/interval_utils.js +14 -0
- package/dist/market_adapter/interval_utils.js.map +1 -0
- package/dist/market_adapter/log_format.d.ts +16 -0
- package/dist/market_adapter/log_format.d.ts.map +1 -0
- package/dist/market_adapter/log_format.js +72 -0
- package/dist/market_adapter/log_format.js.map +1 -0
- package/dist/market_adapter/lp_chart_core.d.ts +6 -0
- package/dist/market_adapter/lp_chart_core.d.ts.map +1 -0
- package/dist/market_adapter/lp_chart_core.js +874 -0
- package/dist/market_adapter/lp_chart_core.js.map +1 -0
- package/dist/market_adapter/lp_chart_runner.d.ts +135 -0
- package/dist/market_adapter/lp_chart_runner.d.ts.map +1 -0
- package/dist/market_adapter/lp_chart_runner.js +337 -0
- package/dist/market_adapter/lp_chart_runner.js.map +1 -0
- package/dist/market_adapter/lp_chart_strategy_loader.d.ts +23 -0
- package/dist/market_adapter/lp_chart_strategy_loader.d.ts.map +1 -0
- package/dist/market_adapter/lp_chart_strategy_loader.js +169 -0
- package/dist/market_adapter/lp_chart_strategy_loader.js.map +1 -0
- package/dist/market_adapter/market_adapter.d.ts +133 -0
- package/dist/market_adapter/market_adapter.d.ts.map +1 -0
- package/dist/market_adapter/market_adapter.js +1331 -0
- package/dist/market_adapter/market_adapter.js.map +1 -0
- package/dist/market_adapter/merge_lp_data.d.ts +3 -0
- package/dist/market_adapter/merge_lp_data.d.ts.map +1 -0
- package/dist/market_adapter/merge_lp_data.js +125 -0
- package/dist/market_adapter/merge_lp_data.js.map +1 -0
- package/dist/market_adapter/test_helpers.d.ts +14 -0
- package/dist/market_adapter/test_helpers.d.ts.map +1 -0
- package/dist/market_adapter/test_helpers.js +22 -0
- package/dist/market_adapter/test_helpers.js.map +1 -0
- package/dist/market_adapter/utils/adapter_client.d.ts +20 -0
- package/dist/market_adapter/utils/adapter_client.d.ts.map +1 -0
- package/dist/market_adapter/utils/adapter_client.js +88 -0
- package/dist/market_adapter/utils/adapter_client.js.map +1 -0
- package/dist/market_adapter/utils/atomic_write.d.ts +9 -0
- package/dist/market_adapter/utils/atomic_write.d.ts.map +1 -0
- package/dist/market_adapter/utils/atomic_write.js +13 -0
- package/dist/market_adapter/utils/atomic_write.js.map +1 -0
- package/dist/market_adapter/utils/chain.d.ts +50 -0
- package/dist/market_adapter/utils/chain.d.ts.map +1 -0
- package/dist/market_adapter/utils/chain.js +196 -0
- package/dist/market_adapter/utils/chain.js.map +1 -0
- package/dist/market_adapter/utils/data_discovery.d.ts +6 -0
- package/dist/market_adapter/utils/data_discovery.d.ts.map +1 -0
- package/dist/market_adapter/utils/data_discovery.js +35 -0
- package/dist/market_adapter/utils/data_discovery.js.map +1 -0
- package/dist/market_adapter/utils/dynamic_grid_snapshot.d.ts +15 -0
- package/dist/market_adapter/utils/dynamic_grid_snapshot.d.ts.map +1 -0
- package/dist/market_adapter/utils/dynamic_grid_snapshot.js +60 -0
- package/dist/market_adapter/utils/dynamic_grid_snapshot.js.map +1 -0
- package/dist/market_adapter/utils/file_lock.d.ts +19 -0
- package/dist/market_adapter/utils/file_lock.d.ts.map +1 -0
- package/dist/market_adapter/utils/file_lock.js +191 -0
- package/dist/market_adapter/utils/file_lock.js.map +1 -0
- package/dist/market_adapter/utils/native_history.d.ts +19 -0
- package/dist/market_adapter/utils/native_history.d.ts.map +1 -0
- package/dist/market_adapter/utils/native_history.js +172 -0
- package/dist/market_adapter/utils/native_history.js.map +1 -0
- package/dist/market_adapter/utils/paths.d.ts +5 -0
- package/dist/market_adapter/utils/paths.d.ts.map +1 -0
- package/dist/market_adapter/utils/paths.js +7 -0
- package/dist/market_adapter/utils/paths.js.map +1 -0
- package/dist/modules/account_bots.d.ts +112 -0
- package/dist/modules/account_bots.d.ts.map +1 -0
- package/dist/modules/account_bots.js +1259 -0
- package/dist/modules/account_bots.js.map +1 -0
- package/dist/modules/account_orders.d.ts +273 -0
- package/dist/modules/account_orders.d.ts.map +1 -0
- package/dist/modules/account_orders.js +662 -0
- package/dist/modules/account_orders.js.map +1 -0
- package/dist/modules/authority_resolver.d.ts +2 -0
- package/dist/modules/authority_resolver.d.ts.map +1 -0
- package/dist/modules/authority_resolver.js +231 -0
- package/dist/modules/authority_resolver.js.map +1 -0
- package/dist/modules/bitshares-native/chain_client.d.ts +38 -0
- package/dist/modules/bitshares-native/chain_client.d.ts.map +1 -0
- package/dist/modules/bitshares-native/chain_client.js +322 -0
- package/dist/modules/bitshares-native/chain_client.js.map +1 -0
- package/dist/modules/bitshares-native/crypto/ecc.browser.d.ts +59 -0
- package/dist/modules/bitshares-native/crypto/ecc.browser.d.ts.map +1 -0
- package/dist/modules/bitshares-native/crypto/ecc.browser.js +456 -0
- package/dist/modules/bitshares-native/crypto/ecc.browser.js.map +1 -0
- package/dist/modules/bitshares-native/crypto/ecc.d.ts +66 -0
- package/dist/modules/bitshares-native/crypto/ecc.d.ts.map +1 -0
- package/dist/modules/bitshares-native/crypto/ecc.js +557 -0
- package/dist/modules/bitshares-native/crypto/ecc.js.map +1 -0
- package/dist/modules/bitshares-native/crypto/ecc_selector.d.ts +2 -0
- package/dist/modules/bitshares-native/crypto/ecc_selector.d.ts.map +1 -0
- package/dist/modules/bitshares-native/crypto/ecc_selector.js +20 -0
- package/dist/modules/bitshares-native/crypto/ecc_selector.js.map +1 -0
- package/dist/modules/bitshares-native/index.d.ts +3 -0
- package/dist/modules/bitshares-native/index.d.ts.map +1 -0
- package/dist/modules/bitshares-native/index.js +32 -0
- package/dist/modules/bitshares-native/index.js.map +1 -0
- package/dist/modules/bitshares-native/resolvers.d.ts +40 -0
- package/dist/modules/bitshares-native/resolvers.d.ts.map +1 -0
- package/dist/modules/bitshares-native/resolvers.js +161 -0
- package/dist/modules/bitshares-native/resolvers.js.map +1 -0
- package/dist/modules/bitshares-native/serial/chain_constants.d.ts +56 -0
- package/dist/modules/bitshares-native/serial/chain_constants.d.ts.map +1 -0
- package/dist/modules/bitshares-native/serial/chain_constants.js +92 -0
- package/dist/modules/bitshares-native/serial/chain_constants.js.map +1 -0
- package/dist/modules/bitshares-native/serial/index.d.ts +10 -0
- package/dist/modules/bitshares-native/serial/index.d.ts.map +1 -0
- package/dist/modules/bitshares-native/serial/index.js +14 -0
- package/dist/modules/bitshares-native/serial/index.js.map +1 -0
- package/dist/modules/bitshares-native/serial/operations.d.ts +102 -0
- package/dist/modules/bitshares-native/serial/operations.d.ts.map +1 -0
- package/dist/modules/bitshares-native/serial/operations.js +615 -0
- package/dist/modules/bitshares-native/serial/operations.js.map +1 -0
- package/dist/modules/bitshares-native/serial/serializer.d.ts +64 -0
- package/dist/modules/bitshares-native/serial/serializer.d.ts.map +1 -0
- package/dist/modules/bitshares-native/serial/serializer.js +252 -0
- package/dist/modules/bitshares-native/serial/serializer.js.map +1 -0
- package/dist/modules/bitshares-native/serial/types.d.ts +120 -0
- package/dist/modules/bitshares-native/serial/types.d.ts.map +1 -0
- package/dist/modules/bitshares-native/serial/types.js +837 -0
- package/dist/modules/bitshares-native/serial/types.js.map +1 -0
- package/dist/modules/bitshares-native/signing_client.d.ts +6 -0
- package/dist/modules/bitshares-native/signing_client.d.ts.map +1 -0
- package/dist/modules/bitshares-native/signing_client.js +141 -0
- package/dist/modules/bitshares-native/signing_client.js.map +1 -0
- package/dist/modules/bitshares-native/subscriptions.d.ts +6 -0
- package/dist/modules/bitshares-native/subscriptions.d.ts.map +1 -0
- package/dist/modules/bitshares-native/subscriptions.js +865 -0
- package/dist/modules/bitshares-native/subscriptions.js.map +1 -0
- package/dist/modules/bitshares-native/transport.d.ts +51 -0
- package/dist/modules/bitshares-native/transport.d.ts.map +1 -0
- package/dist/modules/bitshares-native/transport.js +447 -0
- package/dist/modules/bitshares-native/transport.js.map +1 -0
- package/dist/modules/bitshares-native/tx/builder.d.ts +30 -0
- package/dist/modules/bitshares-native/tx/builder.d.ts.map +1 -0
- package/dist/modules/bitshares-native/tx/builder.js +262 -0
- package/dist/modules/bitshares-native/tx/builder.js.map +1 -0
- package/dist/modules/bitshares_client.d.ts +129 -0
- package/dist/modules/bitshares_client.d.ts.map +1 -0
- package/dist/modules/bitshares_client.js +627 -0
- package/dist/modules/bitshares_client.js.map +1 -0
- package/dist/modules/bot_settings.d.ts +33 -0
- package/dist/modules/bot_settings.d.ts.map +1 -0
- package/dist/modules/bot_settings.js +328 -0
- package/dist/modules/bot_settings.js.map +1 -0
- package/dist/modules/bots_file_lock.d.ts +88 -0
- package/dist/modules/bots_file_lock.d.ts.map +1 -0
- package/dist/modules/bots_file_lock.js +161 -0
- package/dist/modules/bots_file_lock.js.map +1 -0
- package/dist/modules/chain_keys.d.ts +302 -0
- package/dist/modules/chain_keys.d.ts.map +1 -0
- package/dist/modules/chain_keys.js +1095 -0
- package/dist/modules/chain_keys.js.map +1 -0
- package/dist/modules/chain_orders.d.ts +423 -0
- package/dist/modules/chain_orders.d.ts.map +1 -0
- package/dist/modules/chain_orders.js +1201 -0
- package/dist/modules/chain_orders.js.map +1 -0
- package/dist/modules/cli_whitelist_args.d.ts +6 -0
- package/dist/modules/cli_whitelist_args.d.ts.map +1 -0
- package/dist/modules/cli_whitelist_args.js +13 -0
- package/dist/modules/cli_whitelist_args.js.map +1 -0
- package/dist/modules/config.d.ts +57 -0
- package/dist/modules/config.d.ts.map +1 -0
- package/dist/modules/config.js +107 -0
- package/dist/modules/config.js.map +1 -0
- package/dist/modules/constants.d.ts +635 -0
- package/dist/modules/constants.d.ts.map +1 -0
- package/dist/modules/constants.js +1464 -0
- package/dist/modules/constants.js.map +1 -0
- package/dist/modules/cr_planner.d.ts +51 -0
- package/dist/modules/cr_planner.d.ts.map +1 -0
- package/dist/modules/cr_planner.js +299 -0
- package/dist/modules/cr_planner.js.map +1 -0
- package/dist/modules/credential_policy.d.ts +188 -0
- package/dist/modules/credential_policy.d.ts.map +1 -0
- package/dist/modules/credential_policy.js +1452 -0
- package/dist/modules/credential_policy.js.map +1 -0
- package/dist/modules/credential_runtime.d.ts +42 -0
- package/dist/modules/credential_runtime.d.ts.map +1 -0
- package/dist/modules/credential_runtime.js +148 -0
- package/dist/modules/credential_runtime.js.map +1 -0
- package/dist/modules/credential_session_cache.d.ts +36 -0
- package/dist/modules/credential_session_cache.d.ts.map +1 -0
- package/dist/modules/credential_session_cache.js +106 -0
- package/dist/modules/credential_session_cache.js.map +1 -0
- package/dist/modules/credit_runtime.d.ts +412 -0
- package/dist/modules/credit_runtime.d.ts.map +1 -0
- package/dist/modules/credit_runtime.js +2866 -0
- package/dist/modules/credit_runtime.js.map +1 -0
- package/dist/modules/crypto/browser_provider.d.ts +15 -0
- package/dist/modules/crypto/browser_provider.d.ts.map +1 -0
- package/dist/modules/crypto/browser_provider.js +113 -0
- package/dist/modules/crypto/browser_provider.js.map +1 -0
- package/dist/modules/crypto/index.d.ts +9 -0
- package/dist/modules/crypto/index.d.ts.map +1 -0
- package/dist/modules/crypto/index.js +44 -0
- package/dist/modules/crypto/index.js.map +1 -0
- package/dist/modules/crypto/node_provider.d.ts +15 -0
- package/dist/modules/crypto/node_provider.d.ts.map +1 -0
- package/dist/modules/crypto/node_provider.js +74 -0
- package/dist/modules/crypto/node_provider.js.map +1 -0
- package/dist/modules/crypto/provider.d.ts +34 -0
- package/dist/modules/crypto/provider.d.ts.map +1 -0
- package/dist/modules/crypto/provider.js +3 -0
- package/dist/modules/crypto/provider.js.map +1 -0
- package/dist/modules/crypto/pure_ripemd160.d.ts +8 -0
- package/dist/modules/crypto/pure_ripemd160.d.ts.map +1 -0
- package/dist/modules/crypto/pure_ripemd160.js +142 -0
- package/dist/modules/crypto/pure_ripemd160.js.map +1 -0
- package/dist/modules/crypto/pure_scrypt.d.ts +23 -0
- package/dist/modules/crypto/pure_scrypt.d.ts.map +1 -0
- package/dist/modules/crypto/pure_scrypt.js +161 -0
- package/dist/modules/crypto/pure_scrypt.js.map +1 -0
- package/dist/modules/crypto/pure_secp256k1.d.ts +29 -0
- package/dist/modules/crypto/pure_secp256k1.d.ts.map +1 -0
- package/dist/modules/crypto/pure_secp256k1.js +195 -0
- package/dist/modules/crypto/pure_secp256k1.js.map +1 -0
- package/dist/modules/crypto/sync.d.ts +13 -0
- package/dist/modules/crypto/sync.d.ts.map +1 -0
- package/dist/modules/crypto/sync.js +37 -0
- package/dist/modules/crypto/sync.js.map +1 -0
- package/dist/modules/dexbot_class.d.ts +1074 -0
- package/dist/modules/dexbot_class.d.ts.map +1 -0
- package/dist/modules/dexbot_class.js +4613 -0
- package/dist/modules/dexbot_class.js.map +1 -0
- package/dist/modules/dexbot_credential_client.d.ts +71 -0
- package/dist/modules/dexbot_credential_client.d.ts.map +1 -0
- package/dist/modules/dexbot_credential_client.js +224 -0
- package/dist/modules/dexbot_credential_client.js.map +1 -0
- package/dist/modules/dexbot_fill_runtime.d.ts +173 -0
- package/dist/modules/dexbot_fill_runtime.d.ts.map +1 -0
- package/dist/modules/dexbot_fill_runtime.js +217 -0
- package/dist/modules/dexbot_fill_runtime.js.map +1 -0
- package/dist/modules/dexbot_maintenance_runtime.d.ts +279 -0
- package/dist/modules/dexbot_maintenance_runtime.d.ts.map +1 -0
- package/dist/modules/dexbot_maintenance_runtime.js +1613 -0
- package/dist/modules/dexbot_maintenance_runtime.js.map +1 -0
- package/dist/modules/env.d.ts +12 -0
- package/dist/modules/env.d.ts.map +1 -0
- package/dist/modules/env.js +57 -0
- package/dist/modules/env.js.map +1 -0
- package/dist/modules/fund_registry.d.ts +96 -0
- package/dist/modules/fund_registry.d.ts.map +1 -0
- package/dist/modules/fund_registry.js +261 -0
- package/dist/modules/fund_registry.js.map +1 -0
- package/dist/modules/general_settings.d.ts +36 -0
- package/dist/modules/general_settings.d.ts.map +1 -0
- package/dist/modules/general_settings.js +63 -0
- package/dist/modules/general_settings.js.map +1 -0
- package/dist/modules/graceful_shutdown.d.ts +86 -0
- package/dist/modules/graceful_shutdown.d.ts.map +1 -0
- package/dist/modules/graceful_shutdown.js +164 -0
- package/dist/modules/graceful_shutdown.js.map +1 -0
- package/dist/modules/key_store.d.ts +60 -0
- package/dist/modules/key_store.d.ts.map +1 -0
- package/dist/modules/key_store.js +215 -0
- package/dist/modules/key_store.js.map +1 -0
- package/dist/modules/launcher/bot_supervisor.d.ts +84 -0
- package/dist/modules/launcher/bot_supervisor.d.ts.map +1 -0
- package/dist/modules/launcher/bot_supervisor.js +1067 -0
- package/dist/modules/launcher/bot_supervisor.js.map +1 -0
- package/dist/modules/launcher/child_env.d.ts +9 -0
- package/dist/modules/launcher/child_env.d.ts.map +1 -0
- package/dist/modules/launcher/child_env.js +78 -0
- package/dist/modules/launcher/child_env.js.map +1 -0
- package/dist/modules/launcher/credential_bootstrap.d.ts +22 -0
- package/dist/modules/launcher/credential_bootstrap.d.ts.map +1 -0
- package/dist/modules/launcher/credential_bootstrap.js +303 -0
- package/dist/modules/launcher/credential_bootstrap.js.map +1 -0
- package/dist/modules/launcher/credential_daemon.d.ts +32 -0
- package/dist/modules/launcher/credential_daemon.d.ts.map +1 -0
- package/dist/modules/launcher/credential_daemon.js +173 -0
- package/dist/modules/launcher/credential_daemon.js.map +1 -0
- package/dist/modules/launcher/credential_secret.d.ts +6 -0
- package/dist/modules/launcher/credential_secret.d.ts.map +1 -0
- package/dist/modules/launcher/credential_secret.js +15 -0
- package/dist/modules/launcher/credential_secret.js.map +1 -0
- package/dist/modules/launcher/foreign_cred_daemon.d.ts +2 -0
- package/dist/modules/launcher/foreign_cred_daemon.d.ts.map +1 -0
- package/dist/modules/launcher/foreign_cred_daemon.js +166 -0
- package/dist/modules/launcher/foreign_cred_daemon.js.map +1 -0
- package/dist/modules/launcher/headless_password.d.ts +8 -0
- package/dist/modules/launcher/headless_password.d.ts.map +1 -0
- package/dist/modules/launcher/headless_password.js +33 -0
- package/dist/modules/launcher/headless_password.js.map +1 -0
- package/dist/modules/launcher/launch_modes.d.ts +36 -0
- package/dist/modules/launcher/launch_modes.d.ts.map +1 -0
- package/dist/modules/launcher/launch_modes.js +129 -0
- package/dist/modules/launcher/launch_modes.js.map +1 -0
- package/dist/modules/launcher/market_adapter_runtime.d.ts +43 -0
- package/dist/modules/launcher/market_adapter_runtime.d.ts.map +1 -0
- package/dist/modules/launcher/market_adapter_runtime.js +217 -0
- package/dist/modules/launcher/market_adapter_runtime.js.map +1 -0
- package/dist/modules/launcher/market_adapter_watchdog.d.ts +26 -0
- package/dist/modules/launcher/market_adapter_watchdog.d.ts.map +1 -0
- package/dist/modules/launcher/market_adapter_watchdog.js +214 -0
- package/dist/modules/launcher/market_adapter_watchdog.js.map +1 -0
- package/dist/modules/launcher/monolithic_runtime.d.ts +89 -0
- package/dist/modules/launcher/monolithic_runtime.d.ts.map +1 -0
- package/dist/modules/launcher/monolithic_runtime.js +425 -0
- package/dist/modules/launcher/monolithic_runtime.js.map +1 -0
- package/dist/modules/launcher/runtime_entry.d.ts +26 -0
- package/dist/modules/launcher/runtime_entry.d.ts.map +1 -0
- package/dist/modules/launcher/runtime_entry.js +49 -0
- package/dist/modules/launcher/runtime_entry.js.map +1 -0
- package/dist/modules/launcher/status_reporting.d.ts +48 -0
- package/dist/modules/launcher/status_reporting.d.ts.map +1 -0
- package/dist/modules/launcher/status_reporting.js +113 -0
- package/dist/modules/launcher/status_reporting.js.map +1 -0
- package/dist/modules/launcher/supervisor_control.d.ts +6 -0
- package/dist/modules/launcher/supervisor_control.d.ts.map +1 -0
- package/dist/modules/launcher/supervisor_control.js +59 -0
- package/dist/modules/launcher/supervisor_control.js.map +1 -0
- package/dist/modules/logger.d.ts +2 -0
- package/dist/modules/logger.d.ts.map +1 -0
- package/dist/modules/logger.js +71 -0
- package/dist/modules/logger.js.map +1 -0
- package/dist/modules/market_adapter_whitelist.d.ts +22 -0
- package/dist/modules/market_adapter_whitelist.d.ts.map +1 -0
- package/dist/modules/market_adapter_whitelist.js +82 -0
- package/dist/modules/market_adapter_whitelist.js.map +1 -0
- package/dist/modules/node_health_cache.d.ts +55 -0
- package/dist/modules/node_health_cache.d.ts.map +1 -0
- package/dist/modules/node_health_cache.js +134 -0
- package/dist/modules/node_health_cache.js.map +1 -0
- package/dist/modules/node_manager.d.ts +215 -0
- package/dist/modules/node_manager.d.ts.map +1 -0
- package/dist/modules/node_manager.js +628 -0
- package/dist/modules/node_manager.js.map +1 -0
- package/dist/modules/order/accounting.d.ts +349 -0
- package/dist/modules/order/accounting.d.ts.map +1 -0
- package/dist/modules/order/accounting.js +1191 -0
- package/dist/modules/order/accounting.js.map +1 -0
- package/dist/modules/order/async_lock.d.ts +126 -0
- package/dist/modules/order/async_lock.d.ts.map +1 -0
- package/dist/modules/order/async_lock.js +195 -0
- package/dist/modules/order/async_lock.js.map +1 -0
- package/dist/modules/order/export.d.ts +129 -0
- package/dist/modules/order/export.d.ts.map +1 -0
- package/dist/modules/order/export.js +316 -0
- package/dist/modules/order/export.js.map +1 -0
- package/dist/modules/order/format.d.ts +158 -0
- package/dist/modules/order/format.d.ts.map +1 -0
- package/dist/modules/order/format.js +232 -0
- package/dist/modules/order/format.js.map +1 -0
- package/dist/modules/order/grid.d.ts +549 -0
- package/dist/modules/order/grid.d.ts.map +1 -0
- package/dist/modules/order/grid.js +1746 -0
- package/dist/modules/order/grid.js.map +1 -0
- package/dist/modules/order/grid_reconcile.d.ts +154 -0
- package/dist/modules/order/grid_reconcile.d.ts.map +1 -0
- package/dist/modules/order/grid_reconcile.js +1192 -0
- package/dist/modules/order/grid_reconcile.js.map +1 -0
- package/dist/modules/order/index.d.ts +55 -0
- package/dist/modules/order/index.d.ts.map +1 -0
- package/dist/modules/order/index.js +79 -0
- package/dist/modules/order/index.js.map +1 -0
- package/dist/modules/order/logger.d.ts +136 -0
- package/dist/modules/order/logger.d.ts.map +1 -0
- package/dist/modules/order/logger.js +614 -0
- package/dist/modules/order/logger.js.map +1 -0
- package/dist/modules/order/logger_state.d.ts +133 -0
- package/dist/modules/order/logger_state.d.ts.map +1 -0
- package/dist/modules/order/logger_state.js +170 -0
- package/dist/modules/order/logger_state.js.map +1 -0
- package/dist/modules/order/manager.d.ts +413 -0
- package/dist/modules/order/manager.d.ts.map +1 -0
- package/dist/modules/order/manager.js +1605 -0
- package/dist/modules/order/manager.js.map +1 -0
- package/dist/modules/order/processed_fill_store.d.ts +135 -0
- package/dist/modules/order/processed_fill_store.d.ts.map +1 -0
- package/dist/modules/order/processed_fill_store.js +288 -0
- package/dist/modules/order/processed_fill_store.js.map +1 -0
- package/dist/modules/order/runner.d.ts +70 -0
- package/dist/modules/order/runner.d.ts.map +1 -0
- package/dist/modules/order/runner.js +140 -0
- package/dist/modules/order/runner.js.map +1 -0
- package/dist/modules/order/strategy.d.ts +196 -0
- package/dist/modules/order/strategy.d.ts.map +1 -0
- package/dist/modules/order/strategy.js +398 -0
- package/dist/modules/order/strategy.js.map +1 -0
- package/dist/modules/order/sync_engine.d.ts +386 -0
- package/dist/modules/order/sync_engine.d.ts.map +1 -0
- package/dist/modules/order/sync_engine.js +1459 -0
- package/dist/modules/order/sync_engine.js.map +1 -0
- package/dist/modules/order/utils/math.d.ts +677 -0
- package/dist/modules/order/utils/math.d.ts.map +1 -0
- package/dist/modules/order/utils/math.js +1172 -0
- package/dist/modules/order/utils/math.js.map +1 -0
- package/dist/modules/order/utils/order.d.ts +572 -0
- package/dist/modules/order/utils/order.d.ts.map +1 -0
- package/dist/modules/order/utils/order.js +1145 -0
- package/dist/modules/order/utils/order.js.map +1 -0
- package/dist/modules/order/utils/system.d.ts +268 -0
- package/dist/modules/order/utils/system.d.ts.map +1 -0
- package/dist/modules/order/utils/system.js +1261 -0
- package/dist/modules/order/utils/system.js.map +1 -0
- package/dist/modules/order/utils/validate.d.ts +280 -0
- package/dist/modules/order/utils/validate.d.ts.map +1 -0
- package/dist/modules/order/utils/validate.js +918 -0
- package/dist/modules/order/utils/validate.js.map +1 -0
- package/dist/modules/order/working_grid.d.ts +212 -0
- package/dist/modules/order/working_grid.d.ts.map +1 -0
- package/dist/modules/order/working_grid.js +279 -0
- package/dist/modules/order/working_grid.js.map +1 -0
- package/dist/modules/path_api.d.ts +32 -0
- package/dist/modules/path_api.d.ts.map +1 -0
- package/dist/modules/path_api.js +148 -0
- package/dist/modules/path_api.js.map +1 -0
- package/dist/modules/paths.d.ts +58 -0
- package/dist/modules/paths.d.ts.map +1 -0
- package/dist/modules/paths.js +82 -0
- package/dist/modules/paths.js.map +1 -0
- package/dist/modules/process_discovery.d.ts +58 -0
- package/dist/modules/process_discovery.d.ts.map +1 -0
- package/dist/modules/process_discovery.js +265 -0
- package/dist/modules/process_discovery.js.map +1 -0
- package/dist/modules/runtime.d.ts +34 -0
- package/dist/modules/runtime.d.ts.map +1 -0
- package/dist/modules/runtime.js +98 -0
- package/dist/modules/runtime.js.map +1 -0
- package/dist/modules/runtime_settings.d.ts +12 -0
- package/dist/modules/runtime_settings.d.ts.map +1 -0
- package/dist/modules/runtime_settings.js +122 -0
- package/dist/modules/runtime_settings.js.map +1 -0
- package/dist/modules/settings_merge.d.ts +38 -0
- package/dist/modules/settings_merge.d.ts.map +1 -0
- package/dist/modules/settings_merge.js +246 -0
- package/dist/modules/settings_merge.js.map +1 -0
- package/dist/modules/storage/browser_adapter.d.ts +56 -0
- package/dist/modules/storage/browser_adapter.d.ts.map +1 -0
- package/dist/modules/storage/browser_adapter.js +231 -0
- package/dist/modules/storage/browser_adapter.js.map +1 -0
- package/dist/modules/storage/index.d.ts +28 -0
- package/dist/modules/storage/index.d.ts.map +1 -0
- package/dist/modules/storage/index.js +52 -0
- package/dist/modules/storage/index.js.map +1 -0
- package/dist/modules/storage/node_adapter.d.ts +49 -0
- package/dist/modules/storage/node_adapter.d.ts.map +1 -0
- package/dist/modules/storage/node_adapter.js +167 -0
- package/dist/modules/storage/node_adapter.js.map +1 -0
- package/dist/modules/storage/types.d.ts +92 -0
- package/dist/modules/storage/types.d.ts.map +1 -0
- package/dist/modules/storage/types.js +3 -0
- package/dist/modules/storage/types.js.map +1 -0
- package/dist/modules/types.d.ts +1382 -0
- package/dist/modules/types.d.ts.map +1 -0
- package/dist/modules/types.js +11 -0
- package/dist/modules/types.js.map +1 -0
- package/dist/modules/utils/base58check.d.ts +12 -0
- package/dist/modules/utils/base58check.d.ts.map +1 -0
- package/dist/modules/utils/base58check.js +112 -0
- package/dist/modules/utils/base58check.js.map +1 -0
- package/dist/modules/utils/build_dir.d.ts +7 -0
- package/dist/modules/utils/build_dir.d.ts.map +1 -0
- package/dist/modules/utils/build_dir.js +8 -0
- package/dist/modules/utils/build_dir.js.map +1 -0
- package/dist/modules/utils/fs_utils.d.ts +25 -0
- package/dist/modules/utils/fs_utils.d.ts.map +1 -0
- package/dist/modules/utils/fs_utils.js +27 -0
- package/dist/modules/utils/fs_utils.js.map +1 -0
- package/dist/modules/utils/math_utils.d.ts +10 -0
- package/dist/modules/utils/math_utils.d.ts.map +1 -0
- package/dist/modules/utils/math_utils.js +17 -0
- package/dist/modules/utils/math_utils.js.map +1 -0
- package/dist/modules/validate_profiles.d.ts +37 -0
- package/dist/modules/validate_profiles.d.ts.map +1 -0
- package/dist/modules/validate_profiles.js +369 -0
- package/dist/modules/validate_profiles.js.map +1 -0
- package/dist/pm2.d.ts +167 -0
- package/dist/pm2.d.ts.map +1 -0
- package/dist/pm2.js +998 -0
- package/dist/pm2.js.map +1 -0
- package/dist/scripts/analyze-git.d.ts +11 -0
- package/dist/scripts/analyze-git.d.ts.map +1 -0
- package/dist/scripts/analyze-git.js +851 -0
- package/dist/scripts/analyze-git.js.map +1 -0
- package/dist/scripts/analyze-orders.d.ts +17 -0
- package/dist/scripts/analyze-orders.d.ts.map +1 -0
- package/dist/scripts/analyze-orders.js +1568 -0
- package/dist/scripts/analyze-orders.js.map +1 -0
- package/dist/scripts/diagnose-kibana-candles.d.ts +3 -0
- package/dist/scripts/diagnose-kibana-candles.d.ts.map +1 -0
- package/dist/scripts/diagnose-kibana-candles.js +82 -0
- package/dist/scripts/diagnose-kibana-candles.js.map +1 -0
- package/dist/scripts/diagnose-pool-history.d.ts +3 -0
- package/dist/scripts/diagnose-pool-history.d.ts.map +1 -0
- package/dist/scripts/diagnose-pool-history.js +296 -0
- package/dist/scripts/diagnose-pool-history.js.map +1 -0
- package/dist/scripts/divergence-calc.d.ts +26 -0
- package/dist/scripts/divergence-calc.d.ts.map +1 -0
- package/dist/scripts/divergence-calc.js +119 -0
- package/dist/scripts/divergence-calc.js.map +1 -0
- package/dist/scripts/generate_lp_chart.d.ts +31 -0
- package/dist/scripts/generate_lp_chart.d.ts.map +1 -0
- package/dist/scripts/generate_lp_chart.js +92 -0
- package/dist/scripts/generate_lp_chart.js.map +1 -0
- package/dist/scripts/generate_mainnet_corpus_report.d.ts +24 -0
- package/dist/scripts/generate_mainnet_corpus_report.d.ts.map +1 -0
- package/dist/scripts/generate_mainnet_corpus_report.js +237 -0
- package/dist/scripts/generate_mainnet_corpus_report.js.map +1 -0
- package/dist/scripts/generate_market_adapter_whitelist.d.ts +2 -0
- package/dist/scripts/generate_market_adapter_whitelist.d.ts.map +1 -0
- package/dist/scripts/generate_market_adapter_whitelist.js +111 -0
- package/dist/scripts/generate_market_adapter_whitelist.js.map +1 -0
- package/dist/scripts/migrate_bot_keys.d.ts +6 -0
- package/dist/scripts/migrate_bot_keys.d.ts.map +1 -0
- package/dist/scripts/migrate_bot_keys.js +301 -0
- package/dist/scripts/migrate_bot_keys.js.map +1 -0
- package/dist/scripts/native_release_gates.d.ts +3 -0
- package/dist/scripts/native_release_gates.d.ts.map +1 -0
- package/dist/scripts/native_release_gates.js +52 -0
- package/dist/scripts/native_release_gates.js.map +1 -0
- package/dist/scripts/print_grid.d.ts +16 -0
- package/dist/scripts/print_grid.d.ts.map +1 -0
- package/dist/scripts/print_grid.js +80 -0
- package/dist/scripts/print_grid.js.map +1 -0
- package/dist/scripts/run-tests.d.ts +2 -0
- package/dist/scripts/run-tests.d.ts.map +1 -0
- package/dist/scripts/run-tests.js +49 -0
- package/dist/scripts/run-tests.js.map +1 -0
- package/dist/scripts/sync-version.d.ts +14 -0
- package/dist/scripts/sync-version.d.ts.map +1 -0
- package/dist/scripts/sync-version.js +158 -0
- package/dist/scripts/sync-version.js.map +1 -0
- package/dist/scripts/test-credit-renewal.d.ts +2 -0
- package/dist/scripts/test-credit-renewal.d.ts.map +1 -0
- package/dist/scripts/test-credit-renewal.js +329 -0
- package/dist/scripts/test-credit-renewal.js.map +1 -0
- package/dist/scripts/update.d.ts +24 -0
- package/dist/scripts/update.d.ts.map +1 -0
- package/dist/scripts/update.js +650 -0
- package/dist/scripts/update.js.map +1 -0
- package/dist/scripts/validate_bots.d.ts +16 -0
- package/dist/scripts/validate_bots.d.ts.map +1 -0
- package/dist/scripts/validate_bots.js +106 -0
- package/dist/scripts/validate_bots.js.map +1 -0
- package/dist/scripts/verify-browser-bundle.d.ts +22 -0
- package/dist/scripts/verify-browser-bundle.d.ts.map +1 -0
- package/dist/scripts/verify-browser-bundle.js +339 -0
- package/dist/scripts/verify-browser-bundle.js.map +1 -0
- package/dist/unlock.d.ts +48 -0
- package/dist/unlock.d.ts.map +1 -0
- package/dist/unlock.js +925 -0
- package/dist/unlock.js.map +1 -0
- package/package.json +112 -0
- package/scripts/README.md +356 -0
- package/scripts/clear-all.sh +195 -0
- package/scripts/clear-logs.sh +95 -0
- package/scripts/clear-market-adapter.sh +196 -0
- package/scripts/clear-orders.sh +113 -0
- package/scripts/create-bot-symlinks.sh +51 -0
- package/scripts/postinstall.js +9 -0
- package/scripts/reset-settings.sh +118 -0
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
declare function loadSettingsFile(filePath: string, { silent, exitOnError }?: {
|
|
2
|
+
silent?: boolean;
|
|
3
|
+
exitOnError?: boolean;
|
|
4
|
+
}): {
|
|
5
|
+
config: any;
|
|
6
|
+
filePath: string;
|
|
7
|
+
};
|
|
8
|
+
declare function saveSettingsFile(config: any, filePath: string): void;
|
|
9
|
+
declare function resolveRawBotEntries(settings: any): any[];
|
|
10
|
+
declare function normalizeBotEntry(entry: any, index?: number): any;
|
|
11
|
+
declare function normalizeBotEntries(rawEntries: any[]): any[];
|
|
12
|
+
declare function selectBotEntry(settings: any, botName: string): any;
|
|
13
|
+
declare function selectActiveBotEntries(settings: any): any[];
|
|
14
|
+
declare function validateBotEntry(b: any, i: number, src: string): string | null;
|
|
15
|
+
declare function collectValidationIssues(entries: any[], sourceName: string): {
|
|
16
|
+
errors: string[];
|
|
17
|
+
warnings: string[];
|
|
18
|
+
};
|
|
19
|
+
declare function assertNoDuplicateBotKeys(entries: any[], sourceName: string): void;
|
|
20
|
+
declare const _default: {
|
|
21
|
+
assertNoDuplicateBotKeys: typeof assertNoDuplicateBotKeys;
|
|
22
|
+
collectValidationIssues: typeof collectValidationIssues;
|
|
23
|
+
loadSettingsFile: typeof loadSettingsFile;
|
|
24
|
+
normalizeBotEntry: typeof normalizeBotEntry;
|
|
25
|
+
normalizeBotEntries: typeof normalizeBotEntries;
|
|
26
|
+
resolveRawBotEntries: typeof resolveRawBotEntries;
|
|
27
|
+
saveSettingsFile: typeof saveSettingsFile;
|
|
28
|
+
selectActiveBotEntries: typeof selectActiveBotEntries;
|
|
29
|
+
selectBotEntry: typeof selectBotEntry;
|
|
30
|
+
validateBotEntry: typeof validateBotEntry;
|
|
31
|
+
};
|
|
32
|
+
export = _default;
|
|
33
|
+
//# sourceMappingURL=bot_settings.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bot_settings.d.ts","sourceRoot":"","sources":["../../modules/bot_settings.ts"],"names":[],"mappings":"AASA,iBAAS,gBAAgB,CAAC,QAAQ,EAAE,MAAM,EAAE,EAAE,MAAc,EAAE,WAAkB,EAAE,GAAE;IAAE,MAAM,CAAC,EAAE,OAAO,CAAC;IAAC,WAAW,CAAC,EAAE,OAAO,CAAA;CAAO,GAAG;IAAE,MAAM,EAAE,GAAG,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,CAoBvK;AAED,iBAAS,gBAAgB,CAAC,MAAM,EAAE,GAAG,EAAE,QAAQ,EAAE,MAAM,GAAG,IAAI,CAO7D;AAED,iBAAS,oBAAoB,CAAC,QAAQ,EAAE,GAAG,GAAG,GAAG,EAAE,CAKlD;AAED,iBAAS,iBAAiB,CAAC,KAAK,EAAE,GAAG,EAAE,KAAK,GAAE,MAAU,GAAG,GAAG,CAG7D;AAED,iBAAS,mBAAmB,CAAC,UAAU,EAAE,GAAG,EAAE,GAAG,GAAG,EAAE,CAErD;AAED,iBAAS,cAAc,CAAC,QAAQ,EAAE,GAAG,EAAE,OAAO,EAAE,MAAM,GAAG,GAAG,CAI3D;AAED,iBAAS,sBAAsB,CAAC,QAAQ,EAAE,GAAG,GAAG,GAAG,EAAE,CAEpD;AAID,iBAAS,gBAAgB,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CA+KvE;AAED,iBAAS,uBAAuB,CAAC,OAAO,EAAE,GAAG,EAAE,EAAE,UAAU,EAAE,MAAM,GAAG;IAAE,MAAM,EAAE,MAAM,EAAE,CAAC;IAAC,QAAQ,EAAE,MAAM,EAAE,CAAA;CAAE,CA2D7G;AAED,iBAAS,wBAAwB,CAAC,OAAO,EAAE,GAAG,EAAE,EAAE,UAAU,EAAE,MAAM,GAAG,IAAI,CAmB1E;;;;;;;;;;;;;AAED,kBAWE"}
|
|
@@ -0,0 +1,328 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
const { getStorage } = require('./storage');
|
|
3
|
+
const storage = getStorage();
|
|
4
|
+
const { readBotsFileSync } = require('./bots_file_lock');
|
|
5
|
+
const { parseJsonWithComments } = require('./order/utils/system');
|
|
6
|
+
const { createBotKey } = require('./account_orders');
|
|
7
|
+
const { isPositiveNumber, isPositiveNumberOrPercent, toDecimal } = require('./order/utils/math');
|
|
8
|
+
const { resolveMinCollateralIncreaseThreshold } = require('./cr_planner');
|
|
9
|
+
const { writeJSON } = require('./utils/fs_utils');
|
|
10
|
+
function loadSettingsFile(filePath, { silent = false, exitOnError = true } = {}) {
|
|
11
|
+
if (!storage.exists(filePath)) {
|
|
12
|
+
if (!silent) {
|
|
13
|
+
console.error(`${filePath} not found. Run: dexbot bots`);
|
|
14
|
+
}
|
|
15
|
+
return { config: {}, filePath };
|
|
16
|
+
}
|
|
17
|
+
try {
|
|
18
|
+
const { config } = readBotsFileSync(filePath, parseJsonWithComments);
|
|
19
|
+
return { config, filePath };
|
|
20
|
+
}
|
|
21
|
+
catch (err) {
|
|
22
|
+
console.error('Failed to parse bot settings from', filePath);
|
|
23
|
+
console.error('Error:', err.message);
|
|
24
|
+
console.error('Please check the JSON syntax in profiles/bots.json and try again.');
|
|
25
|
+
if (exitOnError) {
|
|
26
|
+
throw err;
|
|
27
|
+
}
|
|
28
|
+
throw err;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
function saveSettingsFile(config, filePath) {
|
|
32
|
+
try {
|
|
33
|
+
writeJSON(filePath, config);
|
|
34
|
+
}
|
|
35
|
+
catch (err) {
|
|
36
|
+
console.error('Failed to save bot settings to', filePath, '-', err.message);
|
|
37
|
+
throw err;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
function resolveRawBotEntries(settings) {
|
|
41
|
+
if (!settings || typeof settings !== 'object')
|
|
42
|
+
return [];
|
|
43
|
+
if (Array.isArray(settings.bots))
|
|
44
|
+
return settings.bots;
|
|
45
|
+
if (Object.keys(settings).length > 0)
|
|
46
|
+
return [settings];
|
|
47
|
+
return [];
|
|
48
|
+
}
|
|
49
|
+
function normalizeBotEntry(entry, index = 0) {
|
|
50
|
+
const normalized = { active: entry.active === undefined ? true : !!entry.active, ...entry };
|
|
51
|
+
return { ...normalized, botIndex: index, botKey: createBotKey(normalized, index) };
|
|
52
|
+
}
|
|
53
|
+
function normalizeBotEntries(rawEntries) {
|
|
54
|
+
return rawEntries.map((entry, index) => normalizeBotEntry(entry, index));
|
|
55
|
+
}
|
|
56
|
+
function selectBotEntry(settings, botName) {
|
|
57
|
+
const entries = resolveRawBotEntries(settings);
|
|
58
|
+
if (!botName)
|
|
59
|
+
return null;
|
|
60
|
+
return entries.find((b) => b && b.name === botName) || null;
|
|
61
|
+
}
|
|
62
|
+
function selectActiveBotEntries(settings) {
|
|
63
|
+
return resolveRawBotEntries(settings).filter((entry) => entry && entry.active !== false);
|
|
64
|
+
}
|
|
65
|
+
function validateBotEntry(b, i, src) {
|
|
66
|
+
const problems = [];
|
|
67
|
+
const required = ['assetA', 'assetB', 'activeOrders', 'botFunds'];
|
|
68
|
+
for (const k of required) {
|
|
69
|
+
if (!(k in b))
|
|
70
|
+
problems.push(`missing '${k}'`);
|
|
71
|
+
}
|
|
72
|
+
if ('activeOrders' in b) {
|
|
73
|
+
if (typeof b.activeOrders !== 'object' || b.activeOrders === null)
|
|
74
|
+
problems.push("'activeOrders' must be an object");
|
|
75
|
+
else {
|
|
76
|
+
if (!('buy' in b.activeOrders))
|
|
77
|
+
problems.push("activeOrders missing 'buy'");
|
|
78
|
+
if (!('sell' in b.activeOrders))
|
|
79
|
+
problems.push("activeOrders missing 'sell'");
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
if ('botFunds' in b) {
|
|
83
|
+
if (typeof b.botFunds !== 'object' || b.botFunds === null)
|
|
84
|
+
problems.push("'botFunds' must be an object");
|
|
85
|
+
else {
|
|
86
|
+
if (!('buy' in b.botFunds))
|
|
87
|
+
problems.push("botFunds missing 'buy'");
|
|
88
|
+
if (!('sell' in b.botFunds))
|
|
89
|
+
problems.push("botFunds missing 'sell'");
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
if ('debtPolicy' in b) {
|
|
93
|
+
if (typeof b.debtPolicy !== 'object' || b.debtPolicy === null) {
|
|
94
|
+
problems.push("'debtPolicy' must be an object");
|
|
95
|
+
}
|
|
96
|
+
else {
|
|
97
|
+
const dp = b.debtPolicy;
|
|
98
|
+
if (!Array.isArray(dp.lending) || dp.lending.length === 0) {
|
|
99
|
+
problems.push("debtPolicy.lending must be a non-empty array");
|
|
100
|
+
}
|
|
101
|
+
else {
|
|
102
|
+
dp.lending.forEach((item, idx) => {
|
|
103
|
+
if (typeof item !== 'object' || item === null) {
|
|
104
|
+
problems.push(`debtPolicy.lending[${idx}] must be an object`);
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
107
|
+
if (!item.collateralAsset || typeof item.collateralAsset !== 'string') {
|
|
108
|
+
problems.push(`debtPolicy.lending[${idx}].collateralAsset must be a non-empty string`);
|
|
109
|
+
}
|
|
110
|
+
if (!item.asset || typeof item.asset !== 'string') {
|
|
111
|
+
problems.push(`debtPolicy.lending[${idx}].asset must be a non-empty string`);
|
|
112
|
+
}
|
|
113
|
+
if (!['mpa', 'creditOffer'].includes(item.type)) {
|
|
114
|
+
problems.push(`debtPolicy.lending[${idx}].type must be 'mpa' or 'creditOffer'`);
|
|
115
|
+
}
|
|
116
|
+
// outputWeight: canonical field, ratio: deprecated alias
|
|
117
|
+
const hasRatio = 'ratio' in item;
|
|
118
|
+
const hasOutputWeight = 'outputWeight' in item;
|
|
119
|
+
if (hasRatio && hasOutputWeight && item.ratio !== item.outputWeight) {
|
|
120
|
+
problems.push(`debtPolicy.lending[${idx}]: both 'ratio' (deprecated) and 'outputWeight' are set with conflicting values`);
|
|
121
|
+
}
|
|
122
|
+
else if (hasRatio && !hasOutputWeight) {
|
|
123
|
+
console.warn(`[deprecated] debtPolicy.lending[${idx}].ratio is deprecated; use outputWeight instead`);
|
|
124
|
+
}
|
|
125
|
+
else if (hasRatio && hasOutputWeight) {
|
|
126
|
+
console.warn(`[deprecated] debtPolicy.lending[${idx}].ratio is a deprecated alias of outputWeight; safe to remove`);
|
|
127
|
+
}
|
|
128
|
+
const weightVal = item.outputWeight ?? item.ratio;
|
|
129
|
+
if (weightVal !== undefined) {
|
|
130
|
+
if (!Number.isFinite(weightVal) || weightVal < 0) {
|
|
131
|
+
problems.push(`debtPolicy.lending[${idx}].${hasOutputWeight ? 'outputWeight' : 'ratio'} must be a non-negative number`);
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
// maxBorrowAmount: optional, must be a fixed positive number (no percentage)
|
|
135
|
+
if ('maxBorrowAmount' in item) {
|
|
136
|
+
if (!isPositiveNumber(item.maxBorrowAmount)) {
|
|
137
|
+
problems.push(`debtPolicy.lending[${idx}].maxBorrowAmount must be a positive number (fixed amount, not percentage)`);
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
// maxBorrowAmountPerOperation: optional, must be a fixed positive number
|
|
141
|
+
if ('maxBorrowAmountPerOperation' in item) {
|
|
142
|
+
if (!isPositiveNumber(item.maxBorrowAmountPerOperation)) {
|
|
143
|
+
problems.push(`debtPolicy.lending[${idx}].maxBorrowAmountPerOperation must be a positive number`);
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
// maxCollateralAmount: optional, positive number or percentage
|
|
147
|
+
if ('maxCollateralAmount' in item && !isPositiveNumberOrPercent(item.maxCollateralAmount)) {
|
|
148
|
+
problems.push(`debtPolicy.lending[${idx}].maxCollateralAmount must be a positive number or percentage`);
|
|
149
|
+
}
|
|
150
|
+
if ('minCollateralIncreaseThreshold' in item) {
|
|
151
|
+
const referenceAmount = typeof item.minCollateralIncreaseThreshold === 'string' && item.minCollateralIncreaseThreshold.trim().endsWith('%')
|
|
152
|
+
? 1
|
|
153
|
+
: null;
|
|
154
|
+
if (resolveMinCollateralIncreaseThreshold(item.minCollateralIncreaseThreshold, referenceAmount) === null) {
|
|
155
|
+
problems.push(`debtPolicy.lending[${idx}].minCollateralIncreaseThreshold must be a non-negative number or percentage`);
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
if (item.type === 'mpa') {
|
|
159
|
+
// MPA-specific validation (maxCollateralRatio is optional for MPA)
|
|
160
|
+
if ('targetCollateralRatio' in item) {
|
|
161
|
+
const tcr = Number(item.targetCollateralRatio);
|
|
162
|
+
if (!Number.isFinite(tcr) || tcr <= 0) {
|
|
163
|
+
problems.push(`debtPolicy.lending[${idx}].targetCollateralRatio must be a positive number`);
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
if ('minCollateralRatio' in item) {
|
|
167
|
+
const mcr = Number(item.minCollateralRatio);
|
|
168
|
+
if (!Number.isFinite(mcr) || mcr <= 0) {
|
|
169
|
+
problems.push(`debtPolicy.lending[${idx}].minCollateralRatio must be a positive number`);
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
if ('maxCollateralRatio' in item) {
|
|
173
|
+
const mxcr = Number(item.maxCollateralRatio);
|
|
174
|
+
if (!Number.isFinite(mxcr) || mxcr <= 0) {
|
|
175
|
+
problems.push(`debtPolicy.lending[${idx}].maxCollateralRatio must be a positive number`);
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
if ('minCollateralRatio' in item && 'maxCollateralRatio' in item) {
|
|
179
|
+
const mcr = Number(item.minCollateralRatio);
|
|
180
|
+
const mxcr = Number(item.maxCollateralRatio);
|
|
181
|
+
if (Number.isFinite(mcr) && Number.isFinite(mxcr) && mcr > mxcr) {
|
|
182
|
+
problems.push(`debtPolicy.lending[${idx}].minCollateralRatio (${mcr}) cannot exceed maxCollateralRatio (${mxcr})`);
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
if ('debtOnly' in item && typeof item.debtOnly !== 'boolean') {
|
|
186
|
+
problems.push(`debtPolicy.lending[${idx}].debtOnly must be a boolean`);
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
else if (item.type === 'creditOffer') {
|
|
190
|
+
// Credit offer-specific validation (maxCollateralRatio is required)
|
|
191
|
+
if (!('maxCollateralRatio' in item)) {
|
|
192
|
+
problems.push(`debtPolicy.lending[${idx}].maxCollateralRatio is required for creditOffer`);
|
|
193
|
+
}
|
|
194
|
+
else {
|
|
195
|
+
const mxcr = Number(item.maxCollateralRatio);
|
|
196
|
+
if (!Number.isFinite(mxcr) || mxcr <= 0) {
|
|
197
|
+
problems.push(`debtPolicy.lending[${idx}].maxCollateralRatio must be a positive number`);
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
if ('maxFeeRatePerDay' in item) {
|
|
201
|
+
const fr = Number(item.maxFeeRatePerDay);
|
|
202
|
+
if (!Number.isFinite(fr) || fr < 0) {
|
|
203
|
+
problems.push(`debtPolicy.lending[${idx}].maxFeeRatePerDay must be a non-negative number`);
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
if ('autoRepay' in item) {
|
|
207
|
+
const ar = Number(item.autoRepay);
|
|
208
|
+
if (![0, 1, 2].includes(ar)) {
|
|
209
|
+
problems.push(`debtPolicy.lending[${idx}].autoRepay must be 0, 1, or 2`);
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
if ('renewOnly' in item && typeof item.renewOnly !== 'boolean') {
|
|
213
|
+
problems.push(`debtPolicy.lending[${idx}].renewOnly must be a boolean`);
|
|
214
|
+
}
|
|
215
|
+
if ('allowedOfferIds' in item) {
|
|
216
|
+
if (!Array.isArray(item.allowedOfferIds)) {
|
|
217
|
+
problems.push(`debtPolicy.lending[${idx}].allowedOfferIds must be an array`);
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
if ('disallowedDealIds' in item) {
|
|
221
|
+
if (!Array.isArray(item.disallowedDealIds)) {
|
|
222
|
+
problems.push(`debtPolicy.lending[${idx}].disallowedDealIds must be an array`);
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
});
|
|
227
|
+
}
|
|
228
|
+
// Global maxCollateralAmount: optional, caps total collateral across all lending items
|
|
229
|
+
if ('maxCollateralAmount' in dp && !isPositiveNumberOrPercent(dp.maxCollateralAmount)) {
|
|
230
|
+
problems.push("debtPolicy.maxCollateralAmount must be a positive number or percentage");
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
if (problems.length) {
|
|
235
|
+
const name = b.name || `<unnamed-${i}>`;
|
|
236
|
+
return `Bot[${i}] '${name}' (${src}) -> ${problems.join('; ')}`;
|
|
237
|
+
}
|
|
238
|
+
return null;
|
|
239
|
+
}
|
|
240
|
+
function collectValidationIssues(entries, sourceName) {
|
|
241
|
+
const errors = [];
|
|
242
|
+
const warnings = [];
|
|
243
|
+
entries.forEach((entry, index) => {
|
|
244
|
+
const issue = validateBotEntry(entry, index, sourceName);
|
|
245
|
+
if (issue) {
|
|
246
|
+
if (entry.active)
|
|
247
|
+
errors.push(issue);
|
|
248
|
+
else
|
|
249
|
+
warnings.push(issue);
|
|
250
|
+
}
|
|
251
|
+
});
|
|
252
|
+
// Cross-bot validation: check for duplicate botKeys (sanitized names)
|
|
253
|
+
const seenKeys = new Map();
|
|
254
|
+
entries.forEach((entry, index) => {
|
|
255
|
+
if (!entry.name)
|
|
256
|
+
return;
|
|
257
|
+
const key = createBotKey(entry, index);
|
|
258
|
+
const existing = seenKeys.get(key);
|
|
259
|
+
if (existing !== undefined) {
|
|
260
|
+
errors.push(`Bot[${existing}] '${entries[existing].name}' and Bot[${index}] '${entry.name}' ` +
|
|
261
|
+
`both produce botKey '${key}' — bot names must be unique.`);
|
|
262
|
+
}
|
|
263
|
+
else {
|
|
264
|
+
seenKeys.set(key, index);
|
|
265
|
+
}
|
|
266
|
+
});
|
|
267
|
+
// Cross-bot validation: check if botFunds percentages sum > 100% per account
|
|
268
|
+
const accountFunds = {};
|
|
269
|
+
for (const entry of entries) {
|
|
270
|
+
if (!entry.active || !entry.preferredAccount || !entry.botFunds)
|
|
271
|
+
continue;
|
|
272
|
+
if (!accountFunds[entry.preferredAccount]) {
|
|
273
|
+
accountFunds[entry.preferredAccount] = { buy: 0, sell: 0, botNames: [] };
|
|
274
|
+
}
|
|
275
|
+
const acc = accountFunds[entry.preferredAccount];
|
|
276
|
+
acc.buy += toDecimal(entry.botFunds.buy);
|
|
277
|
+
acc.sell += toDecimal(entry.botFunds.sell);
|
|
278
|
+
acc.botNames.push(entry.name || entry.botKey || `bot-${entries.indexOf(entry)}`);
|
|
279
|
+
}
|
|
280
|
+
for (const [account, funds] of Object.entries(accountFunds)) {
|
|
281
|
+
if (funds.botNames.length > 1) {
|
|
282
|
+
if (funds.buy > 1) {
|
|
283
|
+
warnings.push(`[SHARED ACCOUNT] '${account}': bots [${funds.botNames.join(', ')}] allocate ` +
|
|
284
|
+
`${(funds.buy * 100).toFixed(0)}% of BUY funds (>100%). ` +
|
|
285
|
+
`Each bot will receive a proportional share (myPct / totalPct × chainBalance).`);
|
|
286
|
+
}
|
|
287
|
+
if (funds.sell > 1) {
|
|
288
|
+
warnings.push(`[SHARED ACCOUNT] '${account}': bots [${funds.botNames.join(', ')}] allocate ` +
|
|
289
|
+
`${(funds.sell * 100).toFixed(0)}% of SELL funds (>100%). ` +
|
|
290
|
+
`Each bot will receive a proportional share (myPct / totalPct × chainBalance).`);
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
return { errors, warnings };
|
|
295
|
+
}
|
|
296
|
+
function assertNoDuplicateBotKeys(entries, sourceName) {
|
|
297
|
+
const seenKeys = new Map();
|
|
298
|
+
const duplicates = [];
|
|
299
|
+
for (const [index, entry] of entries.entries()) {
|
|
300
|
+
if (!entry.name)
|
|
301
|
+
continue;
|
|
302
|
+
const key = createBotKey(entry, index);
|
|
303
|
+
const existing = seenKeys.get(key);
|
|
304
|
+
if (existing !== undefined) {
|
|
305
|
+
duplicates.push(`Bot[${existing}] '${entries[existing].name}' and Bot[${index}] '${entry.name}' ` +
|
|
306
|
+
`both produce botKey '${key}' — bot names must be unique.`);
|
|
307
|
+
}
|
|
308
|
+
else {
|
|
309
|
+
seenKeys.set(key, index);
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
if (duplicates.length > 0) {
|
|
313
|
+
throw new Error(`Duplicate bot name(s) in ${sourceName}:\n${duplicates.map((e) => ` - ${e}`).join('\n')}`);
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
module.exports = {
|
|
317
|
+
assertNoDuplicateBotKeys,
|
|
318
|
+
collectValidationIssues,
|
|
319
|
+
loadSettingsFile,
|
|
320
|
+
normalizeBotEntry,
|
|
321
|
+
normalizeBotEntries,
|
|
322
|
+
resolveRawBotEntries,
|
|
323
|
+
saveSettingsFile,
|
|
324
|
+
selectActiveBotEntries,
|
|
325
|
+
selectBotEntry,
|
|
326
|
+
validateBotEntry
|
|
327
|
+
};
|
|
328
|
+
//# sourceMappingURL=bot_settings.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bot_settings.js","sourceRoot":"","sources":["../../modules/bot_settings.ts"],"names":[],"mappings":";AAAA,MAAM,EAAE,UAAU,EAAE,GAAG,OAAO,CAAC,WAAW,CAAC,CAAC;AAC5C,MAAM,OAAO,GAAG,UAAU,EAAE,CAAC;AAC7B,MAAM,EAAE,gBAAgB,EAAE,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAAC;AACzD,MAAM,EAAE,qBAAqB,EAAE,GAAG,OAAO,CAAC,sBAAsB,CAAC,CAAC;AAClE,MAAM,EAAE,YAAY,EAAE,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAAC;AACrD,MAAM,EAAE,gBAAgB,EAAE,yBAAyB,EAAE,SAAS,EAAE,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAAC;AACjG,MAAM,EAAE,qCAAqC,EAAE,GAAG,OAAO,CAAC,cAAc,CAAC,CAAC;AAC1E,MAAM,EAAE,SAAS,EAAE,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAAC;AAElD,SAAS,gBAAgB,CAAC,QAAgB,EAAE,EAAE,MAAM,GAAG,KAAK,EAAE,WAAW,GAAG,IAAI,KAAkD,EAAE;IAChI,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAC;QAC5B,IAAI,CAAC,MAAM,EAAE,CAAC;YACV,OAAO,CAAC,KAAK,CAAC,GAAG,QAAQ,8BAA8B,CAAC,CAAC;QAC7D,CAAC;QACD,OAAO,EAAE,MAAM,EAAE,EAAE,EAAE,QAAQ,EAAE,CAAC;IACpC,CAAC;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GAAG,YAAY,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;QACvC,MAAM,QAAQ,GAAG,QAAQ,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QACnC,IAAI,QAAQ,KAAK,SAAS,EAAE,CAAC;YACzB,UAAU,CAAC,IAAI,CACX,OAAO,QAAQ,MAAM,OAAO,CAAC,QAAQ,CAAC,CAAC,IAAI,aAAa,KAAK,MAAM,KAAK,CAAC,IAAI,IAAI;gBACjF,wBAAwB,GAAG,+BAA+B,CAC7D,CAAC;QACN,CAAC;aAAM,CAAC;YACJ,QAAQ,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;QAC7B,CAAC;IACL,CAAC;IACD,IAAI,UAAU,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACxB,MAAM,IAAI,KAAK,CAAC,4BAA4B,UAAU,MAAM,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IAChH,CAAC;AACL,CAAC;AAED,iBAAS;IACL,wBAAwB;IACxB,uBAAuB;IACvB,gBAAgB;IAChB,iBAAiB;IACjB,mBAAmB;IACnB,oBAAoB;IACpB,gBAAgB;IAChB,sBAAsB;IACtB,cAAc;IACd,gBAAgB;CACnB,CAAC"}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* modules/bots_file_lock.ts - File Synchronization Lock
|
|
3
|
+
*
|
|
4
|
+
* Thread-safe reading of bots.json with in-memory locking.
|
|
5
|
+
* Prevents race conditions when multiple processes access file simultaneously.
|
|
6
|
+
*
|
|
7
|
+
* Locking Strategy:
|
|
8
|
+
* - Mutex-based mechanism (exclusive access)
|
|
9
|
+
* - Only one operation (read or write) at a time
|
|
10
|
+
* - Queues operations during conflicts
|
|
11
|
+
*
|
|
12
|
+
* ===============================================================================
|
|
13
|
+
* EXPORTS (4 functions)
|
|
14
|
+
* ===============================================================================
|
|
15
|
+
*
|
|
16
|
+
* 1. readBotsFileWithLock(botsJsonPath, parseFunction) - Lock-protected async file read
|
|
17
|
+
* Returns: Promise<{content: string, config: Object}>
|
|
18
|
+
* Acquires lock, reads and parses file, releases lock
|
|
19
|
+
*
|
|
20
|
+
* 2. writeBotsFileWithLock(botsJsonPath, config) - Lock-protected async file write
|
|
21
|
+
* Returns: Promise<void>
|
|
22
|
+
* Acquires lock, writes JSON, releases lock
|
|
23
|
+
*
|
|
24
|
+
* 3. readBotsFileSync(botsJsonPath, parseFunction) - Synchronous file read (startup only)
|
|
25
|
+
* Returns: {content: string, config: Object}
|
|
26
|
+
* WARNING: Blocks event loop — only use before event loop is active
|
|
27
|
+
*
|
|
28
|
+
* 4. writeJsonFileAtomic(filePath, data) - Atomically write JSON via tmp file + rename
|
|
29
|
+
* Returns: Promise<void>
|
|
30
|
+
* Stages to temp file in same directory, then renames into place
|
|
31
|
+
*
|
|
32
|
+
* ===============================================================================
|
|
33
|
+
*
|
|
34
|
+
* USAGE:
|
|
35
|
+
* const { readBotsFileWithLock, writeBotsFileWithLock, readBotsFileSync } = require('./bots_file_lock');
|
|
36
|
+
* const { config } = await readBotsFileWithLock('./profiles/bots.json', JSON.parse);
|
|
37
|
+
* await writeBotsFileWithLock('./profiles/bots.json', updatedConfig);
|
|
38
|
+
*
|
|
39
|
+
* ===============================================================================
|
|
40
|
+
*/
|
|
41
|
+
/**
|
|
42
|
+
* Write a JSON document atomically — delegates to the unified StorageAdapter
|
|
43
|
+
* which uses tmp-file + rename (atomic on POSIX and Windows).
|
|
44
|
+
*
|
|
45
|
+
* @param {string} targetPath - Path of the final JSON file.
|
|
46
|
+
* @param {*} data - Anything `JSON.stringify` accepts.
|
|
47
|
+
*/
|
|
48
|
+
declare function writeJsonFileAtomic(targetPath: any, data: any): void;
|
|
49
|
+
/**
|
|
50
|
+
* Safely read bots.json with lock protection
|
|
51
|
+
* @param {string} botsJsonPath - Path to bots.json file
|
|
52
|
+
* @param {Function} parseFunction - JSON parser function (e.g., parseJsonWithComments)
|
|
53
|
+
* @returns {Promise<{content: string, config: Object}>} File content and parsed config
|
|
54
|
+
* @throws {Error} If file doesn't exist or JSON is invalid
|
|
55
|
+
*/
|
|
56
|
+
declare function readBotsFileWithLock(botsJsonPath: any, parseFunction: any): Promise<{
|
|
57
|
+
content: any;
|
|
58
|
+
config: any;
|
|
59
|
+
}>;
|
|
60
|
+
/**
|
|
61
|
+
* Safely write bots.json with lock protection
|
|
62
|
+
* @param {string} botsJsonPath - Path to bots.json file
|
|
63
|
+
* @param {Object} config - Configuration object to write
|
|
64
|
+
* @returns {Promise<void>}
|
|
65
|
+
* @throws {Error} If write fails
|
|
66
|
+
*/
|
|
67
|
+
declare function writeBotsFileWithLock(botsJsonPath: any, config: any): Promise<void>;
|
|
68
|
+
/**
|
|
69
|
+
* Synchronously read bots.json with lock protection
|
|
70
|
+
* WARNING: This blocks the event loop. Use async version when possible.
|
|
71
|
+
* Only use this for startup initialization before event loop is active.
|
|
72
|
+
* @param {string} botsJsonPath - Path to bots.json file
|
|
73
|
+
* @param {Function} parseFunction - JSON parser function
|
|
74
|
+
* @returns {{content: string, config: Object}} File content and parsed config
|
|
75
|
+
* @throws {Error} If file doesn't exist or JSON is invalid
|
|
76
|
+
*/
|
|
77
|
+
declare function readBotsFileSync(botsJsonPath: any, parseFunction: any): {
|
|
78
|
+
content: any;
|
|
79
|
+
config: any;
|
|
80
|
+
};
|
|
81
|
+
declare const _default: {
|
|
82
|
+
readBotsFileWithLock: typeof readBotsFileWithLock;
|
|
83
|
+
writeBotsFileWithLock: typeof writeBotsFileWithLock;
|
|
84
|
+
readBotsFileSync: typeof readBotsFileSync;
|
|
85
|
+
writeJsonFileAtomic: typeof writeJsonFileAtomic;
|
|
86
|
+
};
|
|
87
|
+
export = _default;
|
|
88
|
+
//# sourceMappingURL=bots_file_lock.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bots_file_lock.d.ts","sourceRoot":"","sources":["../../modules/bots_file_lock.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AAKH;;;;;;GAMG;AACH,iBAAS,mBAAmB,CAAC,UAAU,KAAA,EAAE,IAAI,KAAA,QAE5C;AA4CD;;;;;;GAMG;AACH,iBAAe,oBAAoB,CAAC,YAAY,KAAA,EAAE,aAAa,KAAA;;;GAiB9D;AAED;;;;;;GAMG;AACH,iBAAe,qBAAqB,CAAC,YAAY,KAAA,EAAE,MAAM,KAAA,iBAWxD;AAED;;;;;;;;GAQG;AACH,iBAAS,gBAAgB,CAAC,YAAY,KAAA,EAAE,aAAa,KAAA;;;EAYpD;;;;;;;AAED,kBAKE"}
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* modules/bots_file_lock.ts - File Synchronization Lock
|
|
4
|
+
*
|
|
5
|
+
* Thread-safe reading of bots.json with in-memory locking.
|
|
6
|
+
* Prevents race conditions when multiple processes access file simultaneously.
|
|
7
|
+
*
|
|
8
|
+
* Locking Strategy:
|
|
9
|
+
* - Mutex-based mechanism (exclusive access)
|
|
10
|
+
* - Only one operation (read or write) at a time
|
|
11
|
+
* - Queues operations during conflicts
|
|
12
|
+
*
|
|
13
|
+
* ===============================================================================
|
|
14
|
+
* EXPORTS (4 functions)
|
|
15
|
+
* ===============================================================================
|
|
16
|
+
*
|
|
17
|
+
* 1. readBotsFileWithLock(botsJsonPath, parseFunction) - Lock-protected async file read
|
|
18
|
+
* Returns: Promise<{content: string, config: Object}>
|
|
19
|
+
* Acquires lock, reads and parses file, releases lock
|
|
20
|
+
*
|
|
21
|
+
* 2. writeBotsFileWithLock(botsJsonPath, config) - Lock-protected async file write
|
|
22
|
+
* Returns: Promise<void>
|
|
23
|
+
* Acquires lock, writes JSON, releases lock
|
|
24
|
+
*
|
|
25
|
+
* 3. readBotsFileSync(botsJsonPath, parseFunction) - Synchronous file read (startup only)
|
|
26
|
+
* Returns: {content: string, config: Object}
|
|
27
|
+
* WARNING: Blocks event loop — only use before event loop is active
|
|
28
|
+
*
|
|
29
|
+
* 4. writeJsonFileAtomic(filePath, data) - Atomically write JSON via tmp file + rename
|
|
30
|
+
* Returns: Promise<void>
|
|
31
|
+
* Stages to temp file in same directory, then renames into place
|
|
32
|
+
*
|
|
33
|
+
* ===============================================================================
|
|
34
|
+
*
|
|
35
|
+
* USAGE:
|
|
36
|
+
* const { readBotsFileWithLock, writeBotsFileWithLock, readBotsFileSync } = require('./bots_file_lock');
|
|
37
|
+
* const { config } = await readBotsFileWithLock('./profiles/bots.json', JSON.parse);
|
|
38
|
+
* await writeBotsFileWithLock('./profiles/bots.json', updatedConfig);
|
|
39
|
+
*
|
|
40
|
+
* ===============================================================================
|
|
41
|
+
*/
|
|
42
|
+
const { getStorage } = require('./storage');
|
|
43
|
+
const storage = getStorage();
|
|
44
|
+
/**
|
|
45
|
+
* Write a JSON document atomically — delegates to the unified StorageAdapter
|
|
46
|
+
* which uses tmp-file + rename (atomic on POSIX and Windows).
|
|
47
|
+
*
|
|
48
|
+
* @param {string} targetPath - Path of the final JSON file.
|
|
49
|
+
* @param {*} data - Anything `JSON.stringify` accepts.
|
|
50
|
+
*/
|
|
51
|
+
function writeJsonFileAtomic(targetPath, data) {
|
|
52
|
+
storage.writeJSON(targetPath, data);
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Semaphore for synchronizing access to bots.json.
|
|
56
|
+
* @class
|
|
57
|
+
*/
|
|
58
|
+
class FileLock {
|
|
59
|
+
isLocked = false;
|
|
60
|
+
queue = [];
|
|
61
|
+
constructor() {
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Acquires the lock. If already locked, waits in queue.
|
|
65
|
+
* @returns {Promise<void>}
|
|
66
|
+
*/
|
|
67
|
+
async acquire() {
|
|
68
|
+
if (!this.isLocked) {
|
|
69
|
+
this.isLocked = true;
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
await new Promise(resolve => {
|
|
73
|
+
this.queue.push(resolve);
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Releases the lock and allows the next waiting operation to proceed.
|
|
78
|
+
*/
|
|
79
|
+
release() {
|
|
80
|
+
const next = this.queue.shift();
|
|
81
|
+
if (next) {
|
|
82
|
+
next();
|
|
83
|
+
}
|
|
84
|
+
else {
|
|
85
|
+
this.isLocked = false;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
// Global lock instance for bots.json
|
|
90
|
+
const botsFileLock = new FileLock();
|
|
91
|
+
/**
|
|
92
|
+
* Safely read bots.json with lock protection
|
|
93
|
+
* @param {string} botsJsonPath - Path to bots.json file
|
|
94
|
+
* @param {Function} parseFunction - JSON parser function (e.g., parseJsonWithComments)
|
|
95
|
+
* @returns {Promise<{content: string, config: Object}>} File content and parsed config
|
|
96
|
+
* @throws {Error} If file doesn't exist or JSON is invalid
|
|
97
|
+
*/
|
|
98
|
+
async function readBotsFileWithLock(botsJsonPath, parseFunction) {
|
|
99
|
+
await botsFileLock.acquire();
|
|
100
|
+
try {
|
|
101
|
+
if (!storage.exists(botsJsonPath)) {
|
|
102
|
+
throw new Error(`bots.json not found at ${botsJsonPath}`);
|
|
103
|
+
}
|
|
104
|
+
const content = storage.readFile(botsJsonPath);
|
|
105
|
+
if (!content || !content.trim()) {
|
|
106
|
+
return { content: '', config: { bots: [] } };
|
|
107
|
+
}
|
|
108
|
+
const config = parseFunction(content);
|
|
109
|
+
return { content, config };
|
|
110
|
+
}
|
|
111
|
+
finally {
|
|
112
|
+
botsFileLock.release();
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Safely write bots.json with lock protection
|
|
117
|
+
* @param {string} botsJsonPath - Path to bots.json file
|
|
118
|
+
* @param {Object} config - Configuration object to write
|
|
119
|
+
* @returns {Promise<void>}
|
|
120
|
+
* @throws {Error} If write fails
|
|
121
|
+
*/
|
|
122
|
+
async function writeBotsFileWithLock(botsJsonPath, config) {
|
|
123
|
+
await botsFileLock.acquire();
|
|
124
|
+
try {
|
|
125
|
+
// Atomic write prevents readers (in this process or another) from
|
|
126
|
+
// seeing a truncated file mid-write. The in-process semaphore here
|
|
127
|
+
// serializes concurrent writers within the same process; the
|
|
128
|
+
// tmp+rename is the cross-process safety net.
|
|
129
|
+
writeJsonFileAtomic(botsJsonPath, config);
|
|
130
|
+
}
|
|
131
|
+
finally {
|
|
132
|
+
botsFileLock.release();
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Synchronously read bots.json with lock protection
|
|
137
|
+
* WARNING: This blocks the event loop. Use async version when possible.
|
|
138
|
+
* Only use this for startup initialization before event loop is active.
|
|
139
|
+
* @param {string} botsJsonPath - Path to bots.json file
|
|
140
|
+
* @param {Function} parseFunction - JSON parser function
|
|
141
|
+
* @returns {{content: string, config: Object}} File content and parsed config
|
|
142
|
+
* @throws {Error} If file doesn't exist or JSON is invalid
|
|
143
|
+
*/
|
|
144
|
+
function readBotsFileSync(botsJsonPath, parseFunction) {
|
|
145
|
+
if (!storage.exists(botsJsonPath)) {
|
|
146
|
+
throw new Error(`bots.json not found at ${botsJsonPath}`);
|
|
147
|
+
}
|
|
148
|
+
const content = storage.readFile(botsJsonPath);
|
|
149
|
+
if (!content || !content.trim()) {
|
|
150
|
+
return { content: '', config: { bots: [] } };
|
|
151
|
+
}
|
|
152
|
+
const config = parseFunction(content);
|
|
153
|
+
return { content, config };
|
|
154
|
+
}
|
|
155
|
+
module.exports = {
|
|
156
|
+
readBotsFileWithLock,
|
|
157
|
+
writeBotsFileWithLock,
|
|
158
|
+
readBotsFileSync,
|
|
159
|
+
writeJsonFileAtomic,
|
|
160
|
+
};
|
|
161
|
+
//# sourceMappingURL=bots_file_lock.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
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