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,739 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const assert = require('assert');
|
|
4
|
-
const { runEsmMockStages, defineEsmMockAbs } = require('../../tests/helpers/esm_mocks');
|
|
5
|
-
|
|
6
|
-
// Compiled ESM graphs cannot be mocked via require.cache; the helper installs
|
|
7
|
-
// loader hooks (one child process per stage so fresh module instances load).
|
|
8
|
-
function clearModule(_modulePath: string) {
|
|
9
|
-
/* no-op under ESM hooks */
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
function registerMock(modulePath: string, exports: any) {
|
|
13
|
-
defineEsmMockAbs(modulePath, Object.keys(exports), exports);
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
const { clone } = require('../modules/utils');
|
|
17
|
-
|
|
18
|
-
function createQueriesHarness() {
|
|
19
|
-
const queriesPath = require.resolve('../modules/chain_queries');
|
|
20
|
-
const bitsharesClientPath = require.resolve('../modules/bitshares_client');
|
|
21
|
-
const dexbotBridgePath = require.resolve('../modules/dexbot_bridge');
|
|
22
|
-
|
|
23
|
-
const calls = {
|
|
24
|
-
dbCall: [] as Array<{ args: unknown; method: string }>,
|
|
25
|
-
lookupAsset: [] as string[],
|
|
26
|
-
waitForConnected: 0
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
const assets = {
|
|
30
|
-
'1.3.0': { id: '1.3.0', precision: 5, symbol: 'BTS' },
|
|
31
|
-
'1.3.100': {
|
|
32
|
-
bitasset_data_id: '2.4.100',
|
|
33
|
-
id: '1.3.100',
|
|
34
|
-
precision: 5,
|
|
35
|
-
symbol: 'HONEST.USD'
|
|
36
|
-
},
|
|
37
|
-
'1.3.101': {
|
|
38
|
-
bitasset_data_id: '2.4.101',
|
|
39
|
-
id: '1.3.101',
|
|
40
|
-
precision: 5,
|
|
41
|
-
symbol: 'FALLBACK.ASSET'
|
|
42
|
-
}
|
|
43
|
-
};
|
|
44
|
-
|
|
45
|
-
const objects = {
|
|
46
|
-
'2.4.100': {
|
|
47
|
-
current_feed_publication_time: '2026-03-31T00:00:00',
|
|
48
|
-
options: { short_backing_asset: '1.3.0' }
|
|
49
|
-
},
|
|
50
|
-
'2.4.101': {
|
|
51
|
-
current_feed_publication_time: '2026-03-31T00:00:00',
|
|
52
|
-
options: { short_backing_asset: '1.3.0' }
|
|
53
|
-
}
|
|
54
|
-
};
|
|
55
|
-
|
|
56
|
-
const account = {
|
|
57
|
-
account: { id: '1.2.345', name: 'alice' },
|
|
58
|
-
balances: [
|
|
59
|
-
{ asset_type: '1.3.100', balance: 1234000 },
|
|
60
|
-
{ asset_type: '1.3.0', balance: 500000 }
|
|
61
|
-
],
|
|
62
|
-
call_orders: [
|
|
63
|
-
{
|
|
64
|
-
call_price: { quote: { asset_id: '1.3.100' } },
|
|
65
|
-
collateral: 2500000,
|
|
66
|
-
debt: 1000000
|
|
67
|
-
}
|
|
68
|
-
],
|
|
69
|
-
limit_orders: [{ id: '1.7.1' }]
|
|
70
|
-
};
|
|
71
|
-
|
|
72
|
-
registerMock(bitsharesClientPath, {
|
|
73
|
-
BitShares: {
|
|
74
|
-
db: {
|
|
75
|
-
get_dynamic_global_properties: async () => ({
|
|
76
|
-
head_block_number: 100
|
|
77
|
-
}),
|
|
78
|
-
get_assets: async (ids: any[]) => ids.map((id: any) => assets[id as keyof typeof assets]).filter((x: any) => x),
|
|
79
|
-
get_objects: async (ids: any[]) => ids.map((id: any) => objects[id as keyof typeof objects] || null),
|
|
80
|
-
call: async (method: string, args: any) => {
|
|
81
|
-
calls.dbCall.push({ args: clone(args), method });
|
|
82
|
-
|
|
83
|
-
if (method === 'lookup_asset_symbols') {
|
|
84
|
-
return args[0].map((symbol: any) => {
|
|
85
|
-
if (symbol === 'FALLBACK') {
|
|
86
|
-
return assets['1.3.101'];
|
|
87
|
-
}
|
|
88
|
-
return null;
|
|
89
|
-
}).filter((x: any) => x);
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
if (method === 'get_full_accounts') {
|
|
93
|
-
return [[args[0][0], account]];
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
if (method === 'get_ticker') {
|
|
97
|
-
return { args, method, source: 'ticker' };
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
throw new Error(`Unexpected db call: ${method}`);
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
},
|
|
104
|
-
waitForConnected: async () => {
|
|
105
|
-
calls.waitForConnected += 1;
|
|
106
|
-
}
|
|
107
|
-
});
|
|
108
|
-
|
|
109
|
-
registerMock(dexbotBridgePath, {
|
|
110
|
-
loadDexbotOrderSystemUtils: () => ({
|
|
111
|
-
lookupAsset: async (_bitshares: any, symbolOrId: string) => {
|
|
112
|
-
calls.lookupAsset.push(symbolOrId);
|
|
113
|
-
if (symbolOrId === 'FALLBACK') {
|
|
114
|
-
throw new Error('lookup failure');
|
|
115
|
-
}
|
|
116
|
-
if (symbolOrId === 'HONEST.USD') {
|
|
117
|
-
return assets['1.3.100'];
|
|
118
|
-
}
|
|
119
|
-
if (symbolOrId === 'BTS') {
|
|
120
|
-
return assets['1.3.0'];
|
|
121
|
-
}
|
|
122
|
-
return null;
|
|
123
|
-
}
|
|
124
|
-
}),
|
|
125
|
-
loadDexbotOrderUtils: () => ({
|
|
126
|
-
blockchainToFloat: (amount: number, precision: number) => Number(amount) / (10 ** precision)
|
|
127
|
-
})
|
|
128
|
-
});
|
|
129
|
-
|
|
130
|
-
clearModule(queriesPath);
|
|
131
|
-
const queries = require('../modules/chain_queries');
|
|
132
|
-
|
|
133
|
-
return {
|
|
134
|
-
calls,
|
|
135
|
-
cleanup() {
|
|
136
|
-
clearModule(queriesPath);
|
|
137
|
-
clearModule(bitsharesClientPath);
|
|
138
|
-
clearModule(dexbotBridgePath);
|
|
139
|
-
},
|
|
140
|
-
queries
|
|
141
|
-
};
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
async function testChainQueries() {
|
|
145
|
-
console.log(' chain_queries...');
|
|
146
|
-
|
|
147
|
-
const { calls, cleanup, queries } = createQueriesHarness();
|
|
148
|
-
|
|
149
|
-
try {
|
|
150
|
-
const props = await queries.getDynamicGlobalProperties();
|
|
151
|
-
assert.strictEqual(props.head_block_number, 100);
|
|
152
|
-
assert.strictEqual(calls.waitForConnected, 1);
|
|
153
|
-
|
|
154
|
-
const ticker = await queries.getTicker('HONEST.USD', 'BTS');
|
|
155
|
-
assert.strictEqual(ticker.source, 'ticker');
|
|
156
|
-
assert.ok(calls.dbCall.some((entry) => entry.method === 'get_ticker'));
|
|
157
|
-
|
|
158
|
-
const byId = await queries.getAsset('1.3.100');
|
|
159
|
-
assert.strictEqual(byId.symbol, 'HONEST.USD');
|
|
160
|
-
|
|
161
|
-
const bySymbol = await queries.getAsset('HONEST.USD');
|
|
162
|
-
assert.strictEqual(bySymbol.id, '1.3.100');
|
|
163
|
-
|
|
164
|
-
const fallbackAsset = await queries.getAsset('FALLBACK');
|
|
165
|
-
assert.strictEqual(fallbackAsset.id, '1.3.101');
|
|
166
|
-
assert.ok(calls.lookupAsset.includes('FALLBACK'));
|
|
167
|
-
|
|
168
|
-
const precision = await queries.getAssetPrecision('HONEST.USD');
|
|
169
|
-
assert.strictEqual(precision, 5);
|
|
170
|
-
|
|
171
|
-
const backing = await queries.getBackingAsset('HONEST.USD');
|
|
172
|
-
assert.strictEqual(backing.symbol, 'BTS');
|
|
173
|
-
|
|
174
|
-
const balances = await queries.getBalances('alice');
|
|
175
|
-
assert.deepStrictEqual(balances, {
|
|
176
|
-
BTS: 5,
|
|
177
|
-
'HONEST.USD': 12.34
|
|
178
|
-
});
|
|
179
|
-
|
|
180
|
-
assert.strictEqual(await queries.resolveAccountId('alice'), '1.2.345');
|
|
181
|
-
assert.strictEqual(await queries.resolveAccountId('1.2.345'), '1.2.345');
|
|
182
|
-
assert.strictEqual(await queries.resolveAccountName('1.2.345'), 'alice');
|
|
183
|
-
assert.strictEqual(await queries.resolveAccountName('alice'), 'alice');
|
|
184
|
-
assert.deepStrictEqual(await queries.readOpenOrders('alice'), [{ id: '1.7.1' }]);
|
|
185
|
-
} finally {
|
|
186
|
-
cleanup();
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
console.log(' PASS');
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
function createBroadcastHarness() {
|
|
193
|
-
const broadcastPath = require.resolve('../modules/chain_broadcast');
|
|
194
|
-
const bitsharesClientPath = require.resolve('../modules/bitshares_client');
|
|
195
|
-
const credentialClientPath = require.resolve('../modules/dexbot_credential_client');
|
|
196
|
-
|
|
197
|
-
const calls = {
|
|
198
|
-
accountClient: [] as Array<{ accountName: any; privateKey: any }>,
|
|
199
|
-
broadcasts: [] as any[],
|
|
200
|
-
daemon: {
|
|
201
|
-
broadcast: [] as Array<{ accountName: any; operation: any; options: any }>,
|
|
202
|
-
execute: [] as Array<{ accountName: any; operations: any; options: any }>,
|
|
203
|
-
wait: [] as Array<{ timeoutMs: any; options: any }>
|
|
204
|
-
},
|
|
205
|
-
daemonReady: false,
|
|
206
|
-
newTx: 0,
|
|
207
|
-
txOps: [] as Array<{ opData: any; opName: string }>
|
|
208
|
-
};
|
|
209
|
-
|
|
210
|
-
const tx = {
|
|
211
|
-
asset_settle: (opData: any) => {
|
|
212
|
-
calls.txOps.push({ opData, opName: 'asset_settle' });
|
|
213
|
-
return tx;
|
|
214
|
-
},
|
|
215
|
-
call_order_update: (opData: any) => {
|
|
216
|
-
calls.txOps.push({ opData, opName: 'call_order_update' });
|
|
217
|
-
return tx;
|
|
218
|
-
},
|
|
219
|
-
limit_order_cancel: (opData: any) => {
|
|
220
|
-
calls.txOps.push({ opData, opName: 'limit_order_cancel' });
|
|
221
|
-
return tx;
|
|
222
|
-
},
|
|
223
|
-
limit_order_create: (opData: any) => {
|
|
224
|
-
calls.txOps.push({ opData, opName: 'limit_order_create' });
|
|
225
|
-
return tx;
|
|
226
|
-
},
|
|
227
|
-
broadcast: async () => ({
|
|
228
|
-
trx: {
|
|
229
|
-
operation_results: [[0, '1.7.77']]
|
|
230
|
-
},
|
|
231
|
-
source: 'tx-broadcast'
|
|
232
|
-
})
|
|
233
|
-
};
|
|
234
|
-
|
|
235
|
-
registerMock(bitsharesClientPath, {
|
|
236
|
-
createAccountClient: (accountName: any, privateKey: any) => {
|
|
237
|
-
calls.accountClient.push({ accountName, privateKey });
|
|
238
|
-
return {
|
|
239
|
-
broadcast: async (operation: any) => {
|
|
240
|
-
calls.broadcasts.push(operation);
|
|
241
|
-
return {
|
|
242
|
-
operation,
|
|
243
|
-
source: 'raw-broadcast'
|
|
244
|
-
};
|
|
245
|
-
},
|
|
246
|
-
initPromise: Promise.resolve(),
|
|
247
|
-
newTx: () => {
|
|
248
|
-
calls.newTx += 1;
|
|
249
|
-
return tx;
|
|
250
|
-
}
|
|
251
|
-
};
|
|
252
|
-
}
|
|
253
|
-
});
|
|
254
|
-
|
|
255
|
-
// ESM hooks turn mock keys into synthetic named re-exports, so every name
|
|
256
|
-
// chain_broadcast statically imports must exist here. The error class is a
|
|
257
|
-
// minimal inline replica of the real one (requiring the real module would
|
|
258
|
-
// poison the module cache and bypass the mock).
|
|
259
|
-
class BroadcastUncertainError extends Error {
|
|
260
|
-
code: string;
|
|
261
|
-
constructor(message: string) {
|
|
262
|
-
super(message);
|
|
263
|
-
this.name = 'BroadcastUncertainError';
|
|
264
|
-
this.code = 'BROADCAST_UNCERTAIN';
|
|
265
|
-
}
|
|
266
|
-
}
|
|
267
|
-
|
|
268
|
-
registerMock(credentialClientPath, {
|
|
269
|
-
BroadcastUncertainError,
|
|
270
|
-
DEFAULT_BROADCAST_TIMEOUT_MS: 30000,
|
|
271
|
-
isCredentialDaemonReady: () => calls.daemonReady,
|
|
272
|
-
broadcastOperationViaCredentialDaemon: async (accountName: any, operation: any, options: any) => {
|
|
273
|
-
calls.daemon.broadcast.push({ accountName, operation, options });
|
|
274
|
-
return {
|
|
275
|
-
operation,
|
|
276
|
-
operation_results: [[0, '1.7.88']],
|
|
277
|
-
raw: { source: 'daemon-broadcast' },
|
|
278
|
-
source: 'daemon-broadcast'
|
|
279
|
-
};
|
|
280
|
-
},
|
|
281
|
-
executeOperationsViaCredentialDaemon: async (accountName: any, operations: any, options: any) => {
|
|
282
|
-
calls.daemon.execute.push({ accountName, operations, options });
|
|
283
|
-
return {
|
|
284
|
-
operation_results: [[0, '1.7.77']],
|
|
285
|
-
raw: { source: 'daemon-execute' },
|
|
286
|
-
source: 'daemon-execute'
|
|
287
|
-
};
|
|
288
|
-
},
|
|
289
|
-
waitForCredentialDaemon: async (timeoutMs: any, options: any) => {
|
|
290
|
-
calls.daemon.wait.push({ options, timeoutMs });
|
|
291
|
-
}
|
|
292
|
-
});
|
|
293
|
-
|
|
294
|
-
clearModule(broadcastPath);
|
|
295
|
-
const broadcast = require('../modules/chain_broadcast');
|
|
296
|
-
|
|
297
|
-
return {
|
|
298
|
-
broadcast,
|
|
299
|
-
calls,
|
|
300
|
-
cleanup() {
|
|
301
|
-
clearModule(broadcastPath);
|
|
302
|
-
clearModule(bitsharesClientPath);
|
|
303
|
-
clearModule(credentialClientPath);
|
|
304
|
-
}
|
|
305
|
-
};
|
|
306
|
-
}
|
|
307
|
-
|
|
308
|
-
async function testChainBroadcast() {
|
|
309
|
-
console.log(' chain_broadcast...');
|
|
310
|
-
|
|
311
|
-
const { broadcast, calls, cleanup } = createBroadcastHarness();
|
|
312
|
-
|
|
313
|
-
try {
|
|
314
|
-
const emptyResult = await broadcast.executeOperations([], {
|
|
315
|
-
accountName: 'alice',
|
|
316
|
-
privateKey: 'secret'
|
|
317
|
-
});
|
|
318
|
-
assert.deepStrictEqual(emptyResult, {
|
|
319
|
-
operation_results: [],
|
|
320
|
-
raw: null,
|
|
321
|
-
success: true
|
|
322
|
-
});
|
|
323
|
-
|
|
324
|
-
const txResult = await broadcast.executeOperations([
|
|
325
|
-
{
|
|
326
|
-
op_data: { amount: 1 },
|
|
327
|
-
op_name: 'limit_order_create'
|
|
328
|
-
}
|
|
329
|
-
], {
|
|
330
|
-
accountName: 'alice',
|
|
331
|
-
privateKey: 'secret'
|
|
332
|
-
});
|
|
333
|
-
|
|
334
|
-
assert.strictEqual(calls.accountClient[0].accountName, 'alice');
|
|
335
|
-
assert.strictEqual(calls.accountClient[0].privateKey, 'secret');
|
|
336
|
-
assert.strictEqual(calls.newTx, 1);
|
|
337
|
-
assert.deepStrictEqual(calls.txOps[0], {
|
|
338
|
-
opData: { amount: 1 },
|
|
339
|
-
opName: 'limit_order_create'
|
|
340
|
-
});
|
|
341
|
-
assert.deepStrictEqual(txResult.operation_results, [[0, '1.7.77']]);
|
|
342
|
-
assert.strictEqual(txResult.raw.source, 'tx-broadcast');
|
|
343
|
-
|
|
344
|
-
await assert.rejects(
|
|
345
|
-
broadcast.getSigningClient({ accountName: 'alice' }),
|
|
346
|
-
/Credential daemon is not ready/
|
|
347
|
-
);
|
|
348
|
-
assert.strictEqual(calls.daemon.wait.length, 0);
|
|
349
|
-
|
|
350
|
-
calls.daemonReady = true;
|
|
351
|
-
const daemonTxResult = await broadcast.executeOperations([
|
|
352
|
-
{
|
|
353
|
-
op_data: { amount: 2 },
|
|
354
|
-
op_name: 'limit_order_create'
|
|
355
|
-
}
|
|
356
|
-
], {
|
|
357
|
-
accountName: 'alice'
|
|
358
|
-
});
|
|
359
|
-
|
|
360
|
-
assert.strictEqual(calls.daemon.execute.length, 1, 'daemon-backed execute should use the daemon RPC');
|
|
361
|
-
assert.strictEqual(calls.daemon.execute[0].options.requestType, 'broadcast');
|
|
362
|
-
assert.strictEqual(daemonTxResult.raw.source, 'daemon-execute');
|
|
363
|
-
|
|
364
|
-
const rawResult = await broadcast.broadcastOperation(
|
|
365
|
-
{ object_id: '1.7.88' },
|
|
366
|
-
{ accountName: 'alice' }
|
|
367
|
-
);
|
|
368
|
-
|
|
369
|
-
assert.strictEqual(calls.daemon.wait.length, 2);
|
|
370
|
-
assert.strictEqual(calls.daemon.broadcast.length, 1, 'daemon-backed raw broadcast should use the daemon RPC');
|
|
371
|
-
assert.strictEqual(calls.accountClient[1], undefined, 'daemon-backed raw broadcast should not create a local account client');
|
|
372
|
-
assert.strictEqual(rawResult.raw.source, 'daemon-broadcast');
|
|
373
|
-
|
|
374
|
-
assert.strictEqual(broadcast.resolveAccountName({ accountName: 'alice' }), 'alice');
|
|
375
|
-
assert.strictEqual(broadcast.resolveAccountName({}), null);
|
|
376
|
-
|
|
377
|
-
await assert.rejects(
|
|
378
|
-
broadcast.executeOperations([{ op_name: 'limit_order_create' }], {
|
|
379
|
-
accountName: 'alice',
|
|
380
|
-
privateKey: 'secret'
|
|
381
|
-
}),
|
|
382
|
-
/Each operation requires op_name and op_data/
|
|
383
|
-
);
|
|
384
|
-
|
|
385
|
-
await assert.rejects(
|
|
386
|
-
broadcast.executeOperations([{ op_data: { amount: 1 }, op_name: 'unsupported_operation' }], {
|
|
387
|
-
accountName: 'alice',
|
|
388
|
-
privateKey: 'secret'
|
|
389
|
-
}),
|
|
390
|
-
/Transaction builder does not support unsupported_operation/
|
|
391
|
-
);
|
|
392
|
-
|
|
393
|
-
await assert.rejects(
|
|
394
|
-
broadcast.executeOperations([{ op_data: { amount: 1 }, op_name: 'limit_order_create' }], {
|
|
395
|
-
privateKey: 'secret'
|
|
396
|
-
}),
|
|
397
|
-
/accountName is required/
|
|
398
|
-
);
|
|
399
|
-
} finally {
|
|
400
|
-
cleanup();
|
|
401
|
-
}
|
|
402
|
-
|
|
403
|
-
console.log(' PASS');
|
|
404
|
-
}
|
|
405
|
-
|
|
406
|
-
function createActionsHarness() {
|
|
407
|
-
const actionsPath = require.resolve('../modules/chain_actions');
|
|
408
|
-
const bitsharesClientPath = require.resolve('../modules/bitshares_client');
|
|
409
|
-
const chainBroadcastPath = require.resolve('../modules/chain_broadcast');
|
|
410
|
-
const chainQueriesPath = require.resolve('../modules/chain_queries');
|
|
411
|
-
const dexbotBridgePath = require.resolve('../modules/dexbot_bridge');
|
|
412
|
-
|
|
413
|
-
const calls = {
|
|
414
|
-
buildUpdateOrderOp: [] as string[],
|
|
415
|
-
executeOperations: [] as any[],
|
|
416
|
-
resolveAccountId: [] as string[],
|
|
417
|
-
resolveAccountName: [] as string[],
|
|
418
|
-
subscribe: [] as any[],
|
|
419
|
-
unsubscribe: [] as any[],
|
|
420
|
-
getAsset: [] as string[],
|
|
421
|
-
getBackingAsset: [] as string[],
|
|
422
|
-
getFullAccount: [] as string[],
|
|
423
|
-
getOpenOrders: [] as string[],
|
|
424
|
-
getMpaPosition: [] as any[],
|
|
425
|
-
listenCallbacks: [] as any[]
|
|
426
|
-
};
|
|
427
|
-
|
|
428
|
-
const assets = {
|
|
429
|
-
BTS: { id: '1.3.0', precision: 5, symbol: 'BTS' },
|
|
430
|
-
'1.3.0': { id: '1.3.0', precision: 5, symbol: 'BTS' },
|
|
431
|
-
'1.3.100': {
|
|
432
|
-
bitasset_data_id: '2.4.100',
|
|
433
|
-
id: '1.3.100',
|
|
434
|
-
precision: 5,
|
|
435
|
-
symbol: 'HONEST.USD'
|
|
436
|
-
},
|
|
437
|
-
'HONEST.USD': {
|
|
438
|
-
bitasset_data_id: '2.4.100',
|
|
439
|
-
id: '1.3.100',
|
|
440
|
-
precision: 5,
|
|
441
|
-
symbol: 'HONEST.USD'
|
|
442
|
-
}
|
|
443
|
-
};
|
|
444
|
-
|
|
445
|
-
const account = {
|
|
446
|
-
account: { id: '1.2.345', name: 'alice' },
|
|
447
|
-
call_orders: [
|
|
448
|
-
{
|
|
449
|
-
call_price: { quote: { asset_id: '1.3.100' } },
|
|
450
|
-
collateral: 2500000,
|
|
451
|
-
debt: 1000000
|
|
452
|
-
}
|
|
453
|
-
],
|
|
454
|
-
limit_orders: [
|
|
455
|
-
{ id: '1.7.1', for_sale: 500000 }
|
|
456
|
-
]
|
|
457
|
-
};
|
|
458
|
-
|
|
459
|
-
const subscribeHandlers: any[] = [];
|
|
460
|
-
|
|
461
|
-
registerMock(bitsharesClientPath, {
|
|
462
|
-
BitShares: {
|
|
463
|
-
subscribe: (topic: any, callback: any, accountName: any) => {
|
|
464
|
-
calls.subscribe.push({ accountName, topic });
|
|
465
|
-
subscribeHandlers.push(callback);
|
|
466
|
-
},
|
|
467
|
-
unsubscribe: (topic: any, callback: any, accountName: any) => {
|
|
468
|
-
calls.unsubscribe.push({ accountName, topic });
|
|
469
|
-
return Promise.resolve();
|
|
470
|
-
}
|
|
471
|
-
}
|
|
472
|
-
});
|
|
473
|
-
|
|
474
|
-
registerMock(chainBroadcastPath, {
|
|
475
|
-
executeOperations: async (operations: any, options: any) => {
|
|
476
|
-
calls.executeOperations.push({ options: clone(options), operations: clone(operations) });
|
|
477
|
-
return {
|
|
478
|
-
operation_results: [[0, '1.7.500']],
|
|
479
|
-
source: 'executeOperations'
|
|
480
|
-
};
|
|
481
|
-
}
|
|
482
|
-
});
|
|
483
|
-
|
|
484
|
-
registerMock(chainQueriesPath, {
|
|
485
|
-
getAsset: async (symbolOrId: string) => {
|
|
486
|
-
calls.getAsset.push(symbolOrId);
|
|
487
|
-
return assets[symbolOrId as keyof typeof assets] || null;
|
|
488
|
-
},
|
|
489
|
-
getBackingAsset: async (symbolOrId: string) => {
|
|
490
|
-
calls.getBackingAsset.push(symbolOrId);
|
|
491
|
-
return assets.BTS;
|
|
492
|
-
},
|
|
493
|
-
getFullAccount: async (accountNameOrId: string) => {
|
|
494
|
-
calls.getFullAccount.push(accountNameOrId);
|
|
495
|
-
return account;
|
|
496
|
-
},
|
|
497
|
-
readOpenOrders: async (accountNameOrId: string) => {
|
|
498
|
-
calls.getOpenOrders.push(accountNameOrId);
|
|
499
|
-
return account.limit_orders;
|
|
500
|
-
},
|
|
501
|
-
resolveAccountId: async (accountNameOrId: string) => {
|
|
502
|
-
calls.resolveAccountId.push(accountNameOrId);
|
|
503
|
-
return accountNameOrId === 'alice' ? '1.2.345' : accountNameOrId;
|
|
504
|
-
},
|
|
505
|
-
resolveAccountName: async (accountNameOrId: string) => {
|
|
506
|
-
calls.resolveAccountName.push(accountNameOrId);
|
|
507
|
-
if (accountNameOrId === '1.2.345') {
|
|
508
|
-
return 'alice';
|
|
509
|
-
}
|
|
510
|
-
return accountNameOrId;
|
|
511
|
-
}
|
|
512
|
-
});
|
|
513
|
-
|
|
514
|
-
registerMock(dexbotBridgePath, {
|
|
515
|
-
loadDexbotOrderConstants: () => ({
|
|
516
|
-
FEE_PARAMETERS: { GRAPHENE_COLLATERAL_RATIO_DENOM: 1000 }
|
|
517
|
-
}),
|
|
518
|
-
loadDexbotOrderUtils: () => ({
|
|
519
|
-
floatToBlockchainInt: (value: number, precision: number) => Math.round(Number(value) * (10 ** precision))
|
|
520
|
-
}),
|
|
521
|
-
requireDexbot2Module: (modulePath: string) => {
|
|
522
|
-
calls.buildUpdateOrderOp.push(modulePath);
|
|
523
|
-
return {
|
|
524
|
-
buildUpdateOrderOp: async (accountName: string, orderId: string, newParams: any, cachedOrder: any) => ({
|
|
525
|
-
op: {
|
|
526
|
-
op_data: {
|
|
527
|
-
accountName,
|
|
528
|
-
cachedOrder: clone(cachedOrder),
|
|
529
|
-
newParams: clone(newParams),
|
|
530
|
-
orderId
|
|
531
|
-
},
|
|
532
|
-
op_name: 'limit_order_update'
|
|
533
|
-
}
|
|
534
|
-
})
|
|
535
|
-
};
|
|
536
|
-
}
|
|
537
|
-
});
|
|
538
|
-
|
|
539
|
-
clearModule(actionsPath);
|
|
540
|
-
const actions = require('../modules/chain_actions');
|
|
541
|
-
|
|
542
|
-
return {
|
|
543
|
-
actions,
|
|
544
|
-
calls,
|
|
545
|
-
cleanup() {
|
|
546
|
-
clearModule(actionsPath);
|
|
547
|
-
clearModule(bitsharesClientPath);
|
|
548
|
-
clearModule(chainBroadcastPath);
|
|
549
|
-
clearModule(chainQueriesPath);
|
|
550
|
-
clearModule(dexbotBridgePath);
|
|
551
|
-
},
|
|
552
|
-
subscribeHandlers
|
|
553
|
-
};
|
|
554
|
-
}
|
|
555
|
-
|
|
556
|
-
async function testChainActions() {
|
|
557
|
-
console.log(' chain_actions...');
|
|
558
|
-
|
|
559
|
-
const { actions, calls, cleanup, subscribeHandlers } = createActionsHarness();
|
|
560
|
-
|
|
561
|
-
try {
|
|
562
|
-
const createOp = await actions.buildCreateLimitOrderOperation({
|
|
563
|
-
accountName: 'alice',
|
|
564
|
-
amountToSell: 1.25,
|
|
565
|
-
expiration: '2026-01-01T00:00:00',
|
|
566
|
-
fillOrKill: true,
|
|
567
|
-
minToReceive: 2.5,
|
|
568
|
-
receiveAsset: 'BTS',
|
|
569
|
-
sellAsset: 'HONEST.USD'
|
|
570
|
-
});
|
|
571
|
-
|
|
572
|
-
assert.strictEqual(createOp.op_name, 'limit_order_create');
|
|
573
|
-
assert.strictEqual(createOp.op_data.seller, '1.2.345');
|
|
574
|
-
assert.strictEqual(createOp.op_data.amount_to_sell.amount, 125000);
|
|
575
|
-
assert.strictEqual(createOp.op_data.min_to_receive.amount, 250000);
|
|
576
|
-
assert.strictEqual(createOp.op_data.expiration, '2026-01-01T00:00:00');
|
|
577
|
-
assert.strictEqual(createOp.op_data.fill_or_kill, true);
|
|
578
|
-
|
|
579
|
-
await assert.rejects(
|
|
580
|
-
actions.buildCreateLimitOrderOperation({
|
|
581
|
-
accountName: 'alice',
|
|
582
|
-
amountToSell: 0.000001,
|
|
583
|
-
minToReceive: 2,
|
|
584
|
-
receiveAsset: 'BTS',
|
|
585
|
-
sellAsset: 'HONEST.USD'
|
|
586
|
-
}),
|
|
587
|
-
/Limit order amounts must round to positive blockchain integers/
|
|
588
|
-
);
|
|
589
|
-
|
|
590
|
-
const borrowOp = await actions.buildBorrowMpaOperation({
|
|
591
|
-
accountName: 'alice',
|
|
592
|
-
collateralDelta: 3.4,
|
|
593
|
-
debtDelta: 1.2,
|
|
594
|
-
mpaAsset: 'HONEST.USD',
|
|
595
|
-
targetCollateralRatio: 2.2
|
|
596
|
-
});
|
|
597
|
-
|
|
598
|
-
assert.strictEqual(borrowOp.op_name, 'call_order_update');
|
|
599
|
-
assert.strictEqual(borrowOp.op_data.funding_account, '1.2.345');
|
|
600
|
-
assert.strictEqual(borrowOp.op_data.delta_debt.amount, 120000);
|
|
601
|
-
assert.strictEqual(borrowOp.op_data.delta_collateral.amount, 340000);
|
|
602
|
-
assert.strictEqual(borrowOp.op_data.extensions.target_collateral_ratio, 2200);
|
|
603
|
-
|
|
604
|
-
await assert.rejects(
|
|
605
|
-
actions.buildBorrowMpaOperation({
|
|
606
|
-
accountName: 'alice',
|
|
607
|
-
collateralDelta: 0,
|
|
608
|
-
debtDelta: 0,
|
|
609
|
-
mpaAsset: 'HONEST.USD'
|
|
610
|
-
}),
|
|
611
|
-
/At least one of debtDelta or collateralDelta must be non-zero/
|
|
612
|
-
);
|
|
613
|
-
|
|
614
|
-
const settleOp = await actions.buildSettleMpaOperation({
|
|
615
|
-
accountName: 'alice',
|
|
616
|
-
amount: 1.5,
|
|
617
|
-
mpaAsset: 'HONEST.USD'
|
|
618
|
-
});
|
|
619
|
-
|
|
620
|
-
assert.strictEqual(settleOp.op_name, 'asset_settle');
|
|
621
|
-
assert.strictEqual(settleOp.op_data.account, '1.2.345');
|
|
622
|
-
assert.strictEqual(settleOp.op_data.amount.amount, 150000);
|
|
623
|
-
|
|
624
|
-
const updateOp = await actions.buildUpdateLimitOrderOperation({
|
|
625
|
-
accountName: 'alice',
|
|
626
|
-
cachedOrder: { id: '1.7.9' },
|
|
627
|
-
newParams: { newPrice: 2.5 },
|
|
628
|
-
orderId: '1.7.9'
|
|
629
|
-
});
|
|
630
|
-
|
|
631
|
-
assert.strictEqual(calls.buildUpdateOrderOp[0], 'modules/chain_orders.js');
|
|
632
|
-
assert.strictEqual(updateOp.op.op_name, 'limit_order_update');
|
|
633
|
-
assert.strictEqual(updateOp.op.op_data.orderId, '1.7.9');
|
|
634
|
-
assert.deepStrictEqual(updateOp.op.op_data.newParams, { newPrice: 2.5 });
|
|
635
|
-
|
|
636
|
-
await actions.createLimitOrder({
|
|
637
|
-
accountName: 'alice',
|
|
638
|
-
amountToSell: 1,
|
|
639
|
-
minToReceive: 2,
|
|
640
|
-
receiveAsset: 'BTS',
|
|
641
|
-
sellAsset: 'HONEST.USD'
|
|
642
|
-
});
|
|
643
|
-
assert.strictEqual(calls.executeOperations[0].operations[0].op_name, 'limit_order_create');
|
|
644
|
-
|
|
645
|
-
await actions.executeBatch({
|
|
646
|
-
operations: [
|
|
647
|
-
{
|
|
648
|
-
op_data: { foo: 'bar' },
|
|
649
|
-
op_name: 'limit_order_cancel'
|
|
650
|
-
}
|
|
651
|
-
]
|
|
652
|
-
});
|
|
653
|
-
assert.strictEqual(calls.executeOperations[1].operations[0].op_name, 'limit_order_cancel');
|
|
654
|
-
|
|
655
|
-
const openOrders = await actions.getOpenOrders('alice');
|
|
656
|
-
assert.deepStrictEqual(openOrders, [{ id: '1.7.1', for_sale: 500000 }]);
|
|
657
|
-
|
|
658
|
-
const mpaPosition = await actions.getMpaPosition('alice', 'HONEST.USD');
|
|
659
|
-
assert.strictEqual(mpaPosition.call_price.quote.asset_id, '1.3.100');
|
|
660
|
-
|
|
661
|
-
const received: any[] = [];
|
|
662
|
-
const unsubscribeFirst = await actions.listenForFills('alice', async (fills: any) => {
|
|
663
|
-
received.push({ fills, source: 'first' });
|
|
664
|
-
});
|
|
665
|
-
const unsubscribeSecond = await actions.listenForFills('1.2.345', async (fills: any) => {
|
|
666
|
-
received.push({ fills, source: 'second' });
|
|
667
|
-
});
|
|
668
|
-
|
|
669
|
-
assert.strictEqual(calls.subscribe.length, 1);
|
|
670
|
-
assert.strictEqual(subscribeHandlers.length, 1);
|
|
671
|
-
|
|
672
|
-
subscribeHandlers[0]([
|
|
673
|
-
{
|
|
674
|
-
op: [
|
|
675
|
-
4,
|
|
676
|
-
{
|
|
677
|
-
order_id: '1.7.1',
|
|
678
|
-
pays: { asset_id: '1.3.100', amount: 100000 },
|
|
679
|
-
receives: { asset_id: '1.3.0', amount: 200000 }
|
|
680
|
-
}
|
|
681
|
-
]
|
|
682
|
-
},
|
|
683
|
-
{
|
|
684
|
-
op: [
|
|
685
|
-
1,
|
|
686
|
-
{
|
|
687
|
-
order_id: 'ignored'
|
|
688
|
-
}
|
|
689
|
-
]
|
|
690
|
-
}
|
|
691
|
-
]);
|
|
692
|
-
|
|
693
|
-
assert.strictEqual(received.length, 2);
|
|
694
|
-
assert.strictEqual(received[0].fills.length, 1);
|
|
695
|
-
assert.strictEqual(received[0].fills[0].op[1].order_id, '1.7.1');
|
|
696
|
-
|
|
697
|
-
await unsubscribeFirst();
|
|
698
|
-
assert.strictEqual(calls.unsubscribe.length, 0);
|
|
699
|
-
await unsubscribeSecond();
|
|
700
|
-
assert.strictEqual(calls.unsubscribe.length, 1);
|
|
701
|
-
|
|
702
|
-
subscribeHandlers[0]([
|
|
703
|
-
{
|
|
704
|
-
op: [
|
|
705
|
-
4,
|
|
706
|
-
{
|
|
707
|
-
order_id: '1.7.1',
|
|
708
|
-
pays: { asset_id: '1.3.100', amount: 100000 },
|
|
709
|
-
receives: { asset_id: '1.3.0', amount: 200000 }
|
|
710
|
-
}
|
|
711
|
-
]
|
|
712
|
-
}
|
|
713
|
-
]);
|
|
714
|
-
assert.strictEqual(received.length, 2);
|
|
715
|
-
} finally {
|
|
716
|
-
cleanup();
|
|
717
|
-
}
|
|
718
|
-
|
|
719
|
-
console.log(' PASS');
|
|
720
|
-
}
|
|
721
|
-
|
|
722
|
-
runEsmMockStages(
|
|
723
|
-
['chain-queries', 'chain-broadcast', 'chain-actions'],
|
|
724
|
-
async (stage: string) => {
|
|
725
|
-
if (stage === 'chain-queries') {
|
|
726
|
-
await testChainQueries();
|
|
727
|
-
return;
|
|
728
|
-
}
|
|
729
|
-
if (stage === 'chain-broadcast') {
|
|
730
|
-
await testChainBroadcast();
|
|
731
|
-
return;
|
|
732
|
-
}
|
|
733
|
-
if (stage === 'chain-actions') {
|
|
734
|
-
await testChainActions();
|
|
735
|
-
return;
|
|
736
|
-
}
|
|
737
|
-
throw new Error(`Unknown stage: ${stage}`);
|
|
738
|
-
}
|
|
739
|
-
);
|