dexbot 1.6.10 → 1.6.12
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 +50 -3
- package/README.md +3 -1
- package/analysis/README.md +51 -11
- package/analysis/bot_fitting/README.md +12 -0
- package/analysis/tradingview/README.md +3 -3
- package/analysis/trend_detection/DYNAMIC_WEIGHT_RESEARCH.md +11 -37
- package/analysis/trend_detection/README.md +31 -0
- package/claw/docs/DEXBOT2_TUNING_CHEAT_SHEET.md +4 -3
- package/claw/modules/chain_broadcast.ts +7 -1
- package/claw/modules/claw_launcher.ts +1 -1
- package/claw/modules/launcher_mode_detector.ts +9 -2
- 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/account_resolver.d.ts +1 -1
- package/dist/analysis/account_resolver.js +15 -2
- package/dist/analysis/ama_fitting/analyze_ama_price_changes.js +3 -4
- package/dist/analysis/ama_fitting/analyze_lambda_vs_slow.js +2 -7
- package/dist/analysis/ama_fitting/calibrate_convergence_er.js +0 -1
- package/dist/analysis/ama_fitting/fetch_lp_candles.js +4 -4
- package/dist/analysis/ama_fitting/generate_unified_comparison_chart.d.ts +20 -4
- package/dist/analysis/ama_fitting/generate_unified_comparison_chart.js +9 -6
- package/dist/analysis/ama_fitting/optimizer_high_resolution.js +16 -12
- package/dist/analysis/analyze_args.d.ts +31 -0
- package/dist/analysis/analyze_args.js +41 -0
- package/dist/analysis/analyze_dynamic_weight.js +7 -20
- package/dist/analysis/analyze_kalman.js +7 -17
- package/dist/analysis/analyze_regime.js +7 -17
- package/dist/analysis/analyze_regime_windows.js +8 -18
- package/dist/analysis/analyze_risk_profile.js +8 -18
- package/dist/analysis/analyze_trade_heatmap.js +7 -17
- package/dist/analysis/analyze_volatility.js +7 -17
- package/dist/analysis/bot_fitting/backtest_ama_sweep.d.ts +220 -12
- package/dist/analysis/bot_fitting/backtest_ama_sweep.js +55 -10
- package/dist/analysis/bot_fitting/backtest_bot_fitting.d.ts +34 -4
- package/dist/analysis/bot_fitting/backtest_bot_fitting.js +72 -66
- package/dist/analysis/bot_fitting/backtest_lookback_drawdown.d.ts +21 -0
- package/dist/analysis/bot_fitting/backtest_lookback_drawdown.js +315 -0
- package/dist/analysis/bot_fitting/shared_utils.d.ts +7 -7
- package/dist/analysis/bot_fitting/shared_utils.js +2 -2
- package/dist/analysis/bot_key_utils.d.ts +18 -10
- package/dist/analysis/bot_key_utils.js +10 -17
- package/dist/analysis/bot_usage/discover_bot_accounts.js +44 -47
- package/dist/analysis/bot_usage/kibana_bot_queries.d.ts +1 -21
- package/dist/analysis/chain_pool.d.ts +3 -1
- package/dist/analysis/chart_ui.d.ts +5 -2
- package/dist/analysis/chart_ui.js +6 -3
- package/dist/analysis/chart_utils.d.ts +5 -5
- package/dist/analysis/chart_utils.js +9 -0
- package/dist/analysis/fills_cache.d.ts +64 -0
- package/dist/analysis/fills_cache.js +254 -0
- package/dist/analysis/fills_source.d.ts +2 -2
- package/dist/analysis/fills_source.js +19 -14
- package/dist/analysis/grid_correction_check.d.ts +1 -1
- package/dist/analysis/grid_correction_check.js +12 -11
- package/dist/analysis/math_utils.d.ts +7 -6
- package/dist/analysis/math_utils.js +5 -8
- package/dist/analysis/pnl_report.d.ts +39 -0
- package/dist/analysis/pnl_report.js +325 -0
- package/dist/analysis/price_sources.d.ts +8 -8
- package/dist/analysis/price_sources.js +5 -4
- package/dist/analysis/resolve_bot_accounts.js +2 -2
- package/dist/analysis/resolve_source.d.ts +1 -2
- package/dist/analysis/trade_profitability.d.ts +32 -2
- package/dist/analysis/trade_profitability.js +232 -106
- package/dist/analysis/tradingview/analyze_tradingview.d.ts +17 -6
- package/dist/analysis/tradingview/analyze_tradingview.js +9 -10
- package/dist/analysis/tradingview/grid_reset_config.d.ts +42 -31
- package/dist/analysis/tradingview/grid_reset_config.js +35 -6
- package/dist/analysis/tradingview/grid_reset_sim.d.ts +75 -8
- package/dist/analysis/tradingview/grid_reset_sim.js +42 -5
- package/dist/analysis/tradingview/tradingview_uplot_chart_generator.d.ts +69 -4
- package/dist/analysis/tradingview/tradingview_uplot_chart_generator.js +20 -20
- package/dist/analysis/trend_detection/backtest_ama_slope_huber.d.ts +102 -0
- package/dist/analysis/trend_detection/backtest_ama_slope_huber.js +725 -0
- package/dist/analysis/trend_detection/dynamic_weight_chart_generator.d.ts +63 -1
- package/dist/analysis/trend_detection/dynamic_weight_chart_generator.js +27 -112
- package/dist/analysis/trend_detection/huber_scale_variants.d.ts +40 -0
- package/dist/analysis/trend_detection/huber_scale_variants.js +176 -0
- package/dist/analysis/trend_detection/kalman_chart_generator.d.ts +30 -1
- package/dist/analysis/trend_detection/kalman_chart_generator.js +3 -3
- package/dist/analysis/trend_detection/regime_chart_generator.d.ts +31 -1
- package/dist/analysis/trend_detection/regime_chart_generator.js +2 -2
- package/dist/analysis/trend_detection/volatility_chart_generator.d.ts +33 -1
- package/dist/credential-daemon.js +34 -20
- package/dist/dexbot.js +17 -14
- package/dist/market_adapter/candle_utils.d.ts +22 -18
- package/dist/market_adapter/candle_utils.js +24 -20
- package/dist/market_adapter/core/asymmetric_bounds.d.ts +13 -4
- package/dist/market_adapter/core/config_normalizers.d.ts +3 -3
- package/dist/market_adapter/core/kibana_candles.d.ts +53 -18
- package/dist/market_adapter/core/kibana_candles.js +9 -7
- package/dist/market_adapter/core/kibana_client.d.ts +9 -1
- package/dist/market_adapter/core/kibana_client.js +8 -7
- package/dist/market_adapter/core/kibana_market_candles.d.ts +3 -2
- package/dist/market_adapter/core/market_adapter_service.d.ts +297 -115
- package/dist/market_adapter/core/market_adapter_service.js +184 -101
- package/dist/market_adapter/core/strategies/ama.d.ts +10 -2
- package/dist/market_adapter/core/strategies/ama.js +7 -32
- package/dist/market_adapter/core/strategies/ama_slope_model.d.ts +14 -1
- package/dist/market_adapter/core/strategies/ama_slope_model.js +12 -34
- package/dist/market_adapter/core/strategies/atr/calculator.d.ts +7 -2
- package/dist/market_adapter/core/strategies/atr/calculator.js +2 -34
- package/dist/market_adapter/core/strategies/collateral_manager.d.ts +7 -1
- package/dist/market_adapter/core/strategies/collateral_manager.js +0 -22
- package/dist/market_adapter/core/strategies/dynamic_weight_series.d.ts +36 -8
- package/dist/market_adapter/core/strategies/dynamic_weight_series.js +9 -9
- package/dist/market_adapter/core/strategies/regime_gate.d.ts +24 -15
- package/dist/market_adapter/core/strategies/regime_gate.js +4 -31
- package/dist/market_adapter/core/strategies/regime_interp.d.ts +7 -1
- package/dist/market_adapter/core/strategies/regime_interp.js +14 -22
- package/dist/market_adapter/core/strategies/volatility_shift.d.ts +11 -1
- package/dist/market_adapter/core/strategies/volatility_shift.js +0 -13
- package/dist/market_adapter/inputs/cex_candle_parsing.d.ts +29 -0
- package/dist/market_adapter/inputs/cex_candle_parsing.js +52 -0
- package/dist/market_adapter/inputs/fetch_book_data.d.ts +20 -4
- package/dist/market_adapter/inputs/fetch_book_data.js +3 -1
- package/dist/market_adapter/inputs/fetch_cex_synthetic_data.js +97 -226
- package/dist/market_adapter/inputs/fetch_lp_data.d.ts +42 -7
- package/dist/market_adapter/inputs/fetch_lp_data.js +22 -15
- package/dist/market_adapter/inputs/kibana_feed_source.d.ts +74 -15
- package/dist/market_adapter/inputs/kibana_feed_source.js +29 -22
- package/dist/market_adapter/inputs/kibana_source.d.ts +25 -3
- package/dist/market_adapter/inputs/kibana_source.js +2 -2
- package/dist/market_adapter/inputs/window_cache.d.ts +99 -94
- package/dist/market_adapter/inputs/window_cache.js +8 -8
- package/dist/market_adapter/interval_utils.d.ts +4 -4
- package/dist/market_adapter/log_format.d.ts +6 -6
- package/dist/market_adapter/log_format.js +28 -22
- package/dist/market_adapter/lp_chart_core.d.ts +22 -1
- package/dist/market_adapter/lp_chart_core.js +26 -192
- package/dist/market_adapter/lp_chart_runner.d.ts +7 -7
- package/dist/market_adapter/lp_chart_strategy_loader.d.ts +41 -6
- package/dist/market_adapter/lp_chart_strategy_loader.js +8 -7
- package/dist/market_adapter/market_adapter.d.ts +94 -33
- package/dist/market_adapter/market_adapter.js +69 -75
- package/dist/market_adapter/utils/adapter_client.d.ts +3 -3
- package/dist/market_adapter/utils/adapter_client.js +2 -2
- package/dist/market_adapter/utils/atomic_write.d.ts +8 -1
- package/dist/market_adapter/utils/chain.d.ts +50 -41
- package/dist/market_adapter/utils/chain.js +40 -46
- package/dist/market_adapter/utils/data_discovery.d.ts +4 -1
- package/dist/market_adapter/utils/dynamic_grid_snapshot.d.ts +12 -3
- package/dist/market_adapter/utils/file_json_cache.d.ts +2 -2
- package/dist/market_adapter/utils/file_lock.d.ts +28 -14
- package/dist/market_adapter/utils/file_lock.js +36 -32
- package/dist/market_adapter/utils/native_history.d.ts +9 -2
- package/dist/market_adapter/utils/native_history.js +35 -28
- package/dist/modules/account_bots.d.ts +577 -21
- package/dist/modules/account_bots.js +182 -158
- package/dist/modules/account_orders.d.ts +66 -30
- package/dist/modules/account_orders.js +22 -20
- package/dist/modules/authority_resolver.d.ts +12 -2
- package/dist/modules/authority_resolver.js +15 -8
- package/dist/modules/bitshares-native/chain_client.d.ts +38 -3
- package/dist/modules/bitshares-native/chain_client.js +45 -46
- package/dist/modules/bitshares-native/crypto/ecc.browser.js +11 -171
- package/dist/modules/bitshares-native/crypto/ecc.js +13 -176
- package/dist/modules/bitshares-native/crypto/ecc_core.d.ts +33 -0
- package/dist/modules/bitshares-native/crypto/ecc_core.js +213 -0
- package/dist/modules/bitshares-native/crypto/ecc_selector.d.ts +2 -1
- package/dist/modules/bitshares-native/crypto/ecc_selector.js +1 -13
- package/dist/modules/bitshares-native/index.d.ts +1 -1
- package/dist/modules/bitshares-native/lru_cache.d.ts +7 -7
- package/dist/modules/bitshares-native/resolvers.d.ts +18 -6
- package/dist/modules/bitshares-native/serial/lazy_buffer.d.ts +4 -0
- package/dist/modules/bitshares-native/serial/lazy_buffer.js +21 -0
- package/dist/modules/bitshares-native/serial/operations.d.ts +1 -1
- package/dist/modules/bitshares-native/serial/serializer.d.ts +16 -12
- package/dist/modules/bitshares-native/serial/serializer.js +7 -13
- package/dist/modules/bitshares-native/serial/types.d.ts +25 -16
- package/dist/modules/bitshares-native/serial/types.js +55 -62
- package/dist/modules/bitshares-native/signing_client.d.ts +32 -2
- package/dist/modules/bitshares-native/signing_client.js +19 -14
- package/dist/modules/bitshares-native/subscriptions.d.ts +81 -1
- package/dist/modules/bitshares-native/subscriptions.js +12 -12
- package/dist/modules/bitshares-native/transport.d.ts +5 -4
- package/dist/modules/bitshares-native/transport.js +5 -4
- package/dist/modules/bitshares-native/tx/builder.d.ts +40 -5
- package/dist/modules/bitshares-native/tx/builder.js +4 -3
- package/dist/modules/bitshares-native/tx/tx_cache.d.ts +4 -4
- package/dist/modules/bitshares_client.d.ts +45 -13
- package/dist/modules/bitshares_client.js +28 -19
- package/dist/modules/bot_defaults.d.ts +6 -15
- package/dist/modules/bot_defaults.js +1 -5
- package/dist/modules/bot_settings.d.ts +44 -10
- package/dist/modules/bot_settings.js +11 -8
- package/dist/modules/bots_file_lock.d.ts +6 -6
- package/dist/modules/bots_file_lock.js +16 -12
- package/dist/modules/broadcast_failure.d.ts +2 -2
- package/dist/modules/broadcast_failure.js +5 -4
- package/dist/modules/chain_keys.d.ts +42 -40
- package/dist/modules/chain_keys.js +53 -45
- package/dist/modules/chain_orders.d.ts +93 -59
- package/dist/modules/chain_orders.js +31 -23
- package/dist/modules/constants.d.ts +530 -32
- package/dist/modules/constants.js +52 -60
- package/dist/modules/cr_planner.d.ts +40 -2
- package/dist/modules/credential_policy.d.ts +68 -8
- package/dist/modules/credential_policy.js +37 -31
- package/dist/modules/credential_session_cache.d.ts +2 -2
- package/dist/modules/credit_pricing.d.ts +42 -6
- package/dist/modules/credit_pricing.js +44 -30
- package/dist/modules/credit_runtime.d.ts +276 -118
- package/dist/modules/credit_runtime.js +462 -165
- package/dist/modules/crypto/browser_provider.js +6 -4
- package/dist/modules/crypto/node_provider.js +1 -1
- package/dist/modules/crypto/pure_scrypt.js +35 -4
- package/dist/modules/crypto/pure_secp256k1.js +72 -26
- package/dist/modules/crypto/sync.d.ts +9 -9
- package/dist/modules/crypto/sync.js +16 -9
- package/dist/modules/dexbot_class.d.ts +195 -139
- package/dist/modules/dexbot_class.js +78 -28
- package/dist/modules/dexbot_cow_runtime.d.ts +167 -87
- package/dist/modules/dexbot_cow_runtime.js +248 -206
- package/dist/modules/dexbot_credential_client.d.ts +19 -11
- package/dist/modules/dexbot_fill_runtime.d.ts +63 -48
- package/dist/modules/dexbot_fill_runtime.js +48 -41
- package/dist/modules/dexbot_maintenance_runtime.d.ts +109 -70
- package/dist/modules/dexbot_maintenance_runtime.js +117 -80
- package/dist/modules/dexbot_startup_runtime.d.ts +11 -10
- package/dist/modules/dexbot_startup_runtime.js +43 -43
- package/dist/modules/dexbot_state_recovery.d.ts +13 -12
- package/dist/modules/dexbot_state_recovery.js +18 -13
- package/dist/modules/fund_registry.d.ts +4 -2
- package/dist/modules/fund_registry.js +10 -10
- package/dist/modules/general_settings.d.ts +30 -4
- package/dist/modules/graceful_shutdown.d.ts +3 -3
- package/dist/modules/graceful_shutdown.js +2 -2
- package/dist/modules/grid_price_source.d.ts +1 -1
- package/dist/modules/key_store.d.ts +14 -8
- package/dist/modules/key_store.js +7 -6
- package/dist/modules/launcher/adapter_requirement.d.ts +11 -5
- package/dist/modules/launcher/adapter_requirement.js +5 -5
- package/dist/modules/launcher/bot_supervisor.d.ts +106 -24
- package/dist/modules/launcher/bot_supervisor.js +12 -11
- package/dist/modules/launcher/credential_bootstrap.d.ts +1 -1
- package/dist/modules/launcher/credential_bootstrap.js +1 -1
- package/dist/modules/launcher/credential_daemon.d.ts +4 -4
- package/dist/modules/launcher/credential_daemon.js +2 -2
- package/dist/modules/launcher/credential_secret.d.ts +1 -1
- package/dist/modules/launcher/foreign_cred_daemon.d.ts +2 -2
- package/dist/modules/launcher/market_adapter_runtime.d.ts +61 -6
- package/dist/modules/launcher/market_adapter_watchdog.d.ts +10 -2
- package/dist/modules/launcher/market_adapter_watchdog.js +4 -0
- package/dist/modules/launcher/monolithic_runtime.d.ts +18 -16
- package/dist/modules/launcher/status_reporting.d.ts +22 -14
- package/dist/modules/launcher/supervisor_control.d.ts +8 -1
- package/dist/modules/launcher/supervisor_control.js +4 -2
- package/dist/modules/market_adapter_whitelist.d.ts +9 -3
- package/dist/modules/market_adapter_whitelist.js +15 -3
- package/dist/modules/node_manager.d.ts +41 -11
- package/dist/modules/node_manager.js +5 -4
- package/dist/modules/order/accounting.d.ts +53 -24
- package/dist/modules/order/accounting.js +40 -14
- package/dist/modules/order/async_lock.d.ts +5 -2
- package/dist/modules/order/async_lock.js +1 -1
- package/dist/modules/order/export.d.ts +7 -6
- package/dist/modules/order/export.js +1 -7
- package/dist/modules/order/format.d.ts +39 -19
- package/dist/modules/order/format.js +62 -16
- package/dist/modules/order/genesis_policy.d.ts +21 -18
- package/dist/modules/order/genesis_policy.js +12 -8
- package/dist/modules/order/grid.d.ts +142 -36
- package/dist/modules/order/grid.js +148 -123
- package/dist/modules/order/grid_reconcile.d.ts +21 -20
- package/dist/modules/order/grid_reconcile.js +13 -12
- package/dist/modules/order/grid_reconcile_internal.d.ts +85 -72
- package/dist/modules/order/grid_reconcile_internal.js +28 -19
- package/dist/modules/order/index.d.ts +263 -1
- package/dist/modules/order/logger.d.ts +45 -11
- package/dist/modules/order/logger.js +38 -40
- package/dist/modules/order/logger_state.d.ts +4 -4
- package/dist/modules/order/manager.d.ts +226 -180
- package/dist/modules/order/manager.js +101 -83
- package/dist/modules/order/processed_fill_store.d.ts +18 -3
- package/dist/modules/order/processed_fill_store.js +16 -27
- package/dist/modules/order/strategy.d.ts +21 -13
- package/dist/modules/order/strategy.js +5 -6
- package/dist/modules/order/sync_engine.d.ts +91 -33
- package/dist/modules/order/sync_engine.js +99 -54
- package/dist/modules/order/utils/math.d.ts +157 -102
- package/dist/modules/order/utils/math.js +77 -38
- package/dist/modules/order/utils/order.d.ts +326 -106
- package/dist/modules/order/utils/order.js +200 -99
- package/dist/modules/order/utils/slot.d.ts +1 -1
- package/dist/modules/order/utils/system.d.ts +176 -26
- package/dist/modules/order/utils/system.js +86 -69
- package/dist/modules/order/utils/validate.d.ts +89 -41
- package/dist/modules/order/utils/validate.js +24 -22
- package/dist/modules/order/utils/withPoolRef.d.ts +4 -3
- package/dist/modules/order/utils/withPoolRef.js +18 -12
- package/dist/modules/order/working_grid.d.ts +14 -13
- package/dist/modules/paths.d.ts +3 -4
- package/dist/modules/paths.js +3 -27
- package/dist/modules/process_discovery.d.ts +1 -1
- package/dist/modules/process_discovery.js +2 -1
- package/dist/modules/runtime.d.ts +7 -3
- package/dist/modules/runtime.js +4 -3
- package/dist/modules/runtime_settings.d.ts +15 -10
- package/dist/modules/runtime_settings.js +30 -24
- package/dist/modules/settings_merge.d.ts +29 -3
- package/dist/modules/settings_merge.js +56 -78
- package/dist/modules/socket_json_client.d.ts +7 -4
- package/dist/modules/storage/browser_adapter.d.ts +38 -53
- package/dist/modules/storage/browser_adapter.js +7 -30
- package/dist/modules/storage/index.d.ts +1 -1
- package/dist/modules/storage/node_adapter.d.ts +45 -27
- package/dist/modules/storage/node_adapter.js +9 -9
- package/dist/modules/storage/types.d.ts +5 -4
- package/dist/modules/types.d.ts +1071 -2
- package/dist/modules/types.js +4 -1
- package/dist/modules/utils/asset_symbols.d.ts +2 -1
- package/dist/modules/utils/asset_symbols.js +2 -1
- package/dist/modules/utils/errors.d.ts +9 -0
- package/dist/modules/utils/errors.js +23 -1
- package/dist/modules/utils/time_range.d.ts +4 -0
- package/dist/modules/utils/time_range.js +18 -0
- package/dist/modules/validate_profiles.js +53 -43
- package/dist/modules/version_notice.d.ts +14 -3
- package/dist/modules/version_notice.js +6 -4
- package/dist/pm2.d.ts +29 -27
- package/dist/pm2.js +5 -5
- package/dist/scripts/analyze-credit.d.ts +2 -1
- package/dist/scripts/analyze-credit.js +23 -24
- package/dist/scripts/analyze-orders.d.ts +77 -9
- package/dist/scripts/analyze-orders.js +66 -84
- package/dist/scripts/chart_command.d.ts +27 -18
- package/dist/scripts/chart_command.js +16 -15
- package/dist/scripts/check_any.d.ts +18 -0
- package/dist/scripts/check_any.js +126 -0
- package/dist/scripts/diagnose-pool-history.js +12 -7
- package/dist/scripts/pnl.d.ts +3 -0
- package/dist/scripts/pnl.js +40 -0
- package/dist/scripts/print_grid.js +0 -1
- package/dist/scripts/run-tests.js +39 -7
- package/dist/scripts/runner.js +1 -1
- package/dist/scripts/test-credit-renewal.js +30 -21
- package/dist/scripts/update.d.ts +10 -5
- package/dist/scripts/update.js +168 -103
- package/dist/scripts/update_dist_freshness.js +1 -0
- package/dist/scripts/update_layout.d.ts +61 -0
- package/dist/scripts/update_layout.js +180 -0
- package/dist/scripts/validate_bots.js +2 -1
- package/dist/scripts/verify-browser-bundle.js +8 -0
- package/dist/unlock.d.ts +28 -3
- package/dist/unlock.js +72 -10
- package/docs/BITSHARES_ONBOARDING.md +2 -0
- package/docs/COPY_ON_WRITE_MASTER_PLAN.md +1 -1
- package/docs/COW_INVARIANTS.md +13 -6
- package/docs/DEXBOT_COMPARISON.md +8 -8
- package/docs/EVOLUTION.md +12 -10
- package/docs/FUND_MOVEMENT_AND_ACCOUNTING.md +5 -5
- package/docs/GRID_RECALCULATION.md +15 -16
- package/docs/GRID_RECONCILE.md +14 -3
- package/docs/LIFECYCLE.md +11 -11
- package/docs/MPA_CREDIT_USAGE.md +22 -3
- package/docs/README.md +15 -4
- package/docs/WORKFLOW.md +1 -0
- package/docs/architecture.md +12 -9
- package/docs/developer_guide.md +6 -6
- package/market_adapter/README.md +9 -26
- package/modules/README.md +4 -1
- package/package.json +4 -1
- package/scripts/README.md +14 -0
|
@@ -71,6 +71,45 @@
|
|
|
71
71
|
*
|
|
72
72
|
* ===============================================================================
|
|
73
73
|
*/
|
|
74
|
+
import type { OrderManagerLike, AccountTotals, ManagerFunds, ActiveOrdersConfig, GridFeeParams, ManagedOrder, AssetPair, GridConfig, GridLimitsLike, WeightDistributionConfig } from '../../types.js';
|
|
75
|
+
interface FeeCacheEntry {
|
|
76
|
+
limitOrderCreate: {
|
|
77
|
+
bts: number;
|
|
78
|
+
};
|
|
79
|
+
limitOrderUpdate: {
|
|
80
|
+
bts: number;
|
|
81
|
+
};
|
|
82
|
+
limitOrderCancel?: {
|
|
83
|
+
bts?: number;
|
|
84
|
+
};
|
|
85
|
+
makerFeeDiscountPercent?: number;
|
|
86
|
+
chargesMarketFees?: boolean;
|
|
87
|
+
marketFee?: {
|
|
88
|
+
percent?: number;
|
|
89
|
+
};
|
|
90
|
+
takerFee?: {
|
|
91
|
+
percent?: number;
|
|
92
|
+
};
|
|
93
|
+
maxMarketFee?: {
|
|
94
|
+
float?: number;
|
|
95
|
+
};
|
|
96
|
+
[key: string]: unknown;
|
|
97
|
+
}
|
|
98
|
+
type PricedOrder = {
|
|
99
|
+
price: number;
|
|
100
|
+
};
|
|
101
|
+
interface CollisionItem {
|
|
102
|
+
id?: string;
|
|
103
|
+
price?: number;
|
|
104
|
+
size?: number;
|
|
105
|
+
type?: string;
|
|
106
|
+
order?: {
|
|
107
|
+
price?: number;
|
|
108
|
+
size?: number;
|
|
109
|
+
type?: string;
|
|
110
|
+
} | null;
|
|
111
|
+
[key: string]: unknown;
|
|
112
|
+
}
|
|
74
113
|
/**
|
|
75
114
|
* Check if a value is explicitly set to zero (number 0, string "0", or "0%").
|
|
76
115
|
* Used to distinguish between "not set" and "explicitly disabled".
|
|
@@ -78,35 +117,35 @@
|
|
|
78
117
|
* @param {*} value - Value to check
|
|
79
118
|
* @returns {boolean} True if value is explicitly zero
|
|
80
119
|
*/
|
|
81
|
-
declare function isExplicitZeroAllocation(value:
|
|
120
|
+
declare function isExplicitZeroAllocation(value: unknown): boolean;
|
|
82
121
|
/**
|
|
83
122
|
* Check if a value is a percentage string (ends with '%').
|
|
84
123
|
*
|
|
85
124
|
* @param {*} v - Value to test
|
|
86
125
|
* @returns {boolean} True if v is a string ending with '%'
|
|
87
126
|
*/
|
|
88
|
-
declare function isPercentageString(v:
|
|
127
|
+
declare function isPercentageString(v: unknown): v is string;
|
|
89
128
|
/**
|
|
90
129
|
* Check if a value is a positive number.
|
|
91
130
|
*
|
|
92
131
|
* @param {*} value - Value to test
|
|
93
132
|
* @returns {boolean} True if the value is a finite number greater than 0
|
|
94
133
|
*/
|
|
95
|
-
declare function isPositiveNumber(value:
|
|
134
|
+
declare function isPositiveNumber(value: unknown): boolean;
|
|
96
135
|
/**
|
|
97
136
|
* Check if a value is a positive number or a positive percentage string.
|
|
98
137
|
*
|
|
99
138
|
* @param {*} value - Value to test
|
|
100
139
|
* @returns {boolean} True if the value is a positive number or a percentage string like "25%"
|
|
101
140
|
*/
|
|
102
|
-
declare function isPositiveNumberOrPercent(value:
|
|
141
|
+
declare function isPositiveNumberOrPercent(value: unknown): boolean;
|
|
103
142
|
/**
|
|
104
143
|
* Check if a value is a positive integer.
|
|
105
144
|
*
|
|
106
145
|
* @param {*} value - Value to test
|
|
107
146
|
* @returns {boolean} True if the value is an integer greater than 0
|
|
108
147
|
*/
|
|
109
|
-
declare function isPositiveInt(value:
|
|
148
|
+
declare function isPositiveInt(value: unknown): boolean;
|
|
110
149
|
/**
|
|
111
150
|
* Parse a percentage string to decimal form.
|
|
112
151
|
* Extracts numeric value before '%' and divides by 100.
|
|
@@ -114,7 +153,7 @@ declare function isPositiveInt(value: any): boolean;
|
|
|
114
153
|
* @param {string} v - Percentage string (e.g., "50%")
|
|
115
154
|
* @returns {number|null} Decimal form (e.g., 0.5) or null if invalid
|
|
116
155
|
*/
|
|
117
|
-
declare function parsePercentageString(v:
|
|
156
|
+
declare function parsePercentageString(v: unknown): number | null;
|
|
118
157
|
/**
|
|
119
158
|
* Convert a value (number, percentage string, or numeric string) to its
|
|
120
159
|
* decimal form. Unlike parsePercentageString which only handles '%' strings,
|
|
@@ -122,7 +161,7 @@ declare function parsePercentageString(v: any): number | null;
|
|
|
122
161
|
* @param {*} value - Number (100 = 100), "100%" (= 1.0), or "100" (= 100)
|
|
123
162
|
* @returns {number} Decimal value, 0 if unparseable
|
|
124
163
|
*/
|
|
125
|
-
declare function toDecimal(value:
|
|
164
|
+
declare function toDecimal(value: unknown): number;
|
|
126
165
|
/**
|
|
127
166
|
* Parse a relative multiplier expression (e.g. "3x", " 1.5X ").
|
|
128
167
|
* Single source of truth for the x-multiplier syntax, shared by price-bound
|
|
@@ -131,7 +170,7 @@ declare function toDecimal(value: any): number;
|
|
|
131
170
|
* @param {*} value - Candidate value
|
|
132
171
|
* @returns {number|null} Multiplier number, or null if not a valid expression
|
|
133
172
|
*/
|
|
134
|
-
declare function parseRelativeMultiplier(value:
|
|
173
|
+
declare function parseRelativeMultiplier(value: unknown): number | null;
|
|
135
174
|
/**
|
|
136
175
|
* Resolve a relative price expression (multiplier format) to absolute price.
|
|
137
176
|
* Supports expressions like "3x" to mean 3 times the reference price.
|
|
@@ -141,7 +180,7 @@ declare function parseRelativeMultiplier(value: any): number | null;
|
|
|
141
180
|
* @param {string} [mode='min'] - "min" divides (price/multiplier), "max" multiplies (price*multiplier)
|
|
142
181
|
* @returns {number|null} Resolved price or null if value is not a relative expression
|
|
143
182
|
*/
|
|
144
|
-
declare function resolveRelativePrice(value:
|
|
183
|
+
declare function resolveRelativePrice(value: unknown, startPrice: unknown, mode?: string): number | null;
|
|
145
184
|
/**
|
|
146
185
|
* Validate that resolved price bounds strictly bracket the grid center.
|
|
147
186
|
*
|
|
@@ -156,7 +195,7 @@ declare function resolveRelativePrice(value: any, startPrice: any, mode?: any):
|
|
|
156
195
|
* @param {number} centerPrice - Grid center used as the multiplier reference
|
|
157
196
|
* @throws {Error} If bounds do not strictly bracket the center
|
|
158
197
|
*/
|
|
159
|
-
declare function validateGridPriceBounds(minPrice:
|
|
198
|
+
declare function validateGridPriceBounds(minPrice: unknown, maxPrice: unknown, centerPrice: unknown): void;
|
|
160
199
|
/**
|
|
161
200
|
* Calculate chain fund totals from account balances and committed orders.
|
|
162
201
|
* Reconciles free/locked balances with committed capital to produce fund summary.
|
|
@@ -166,7 +205,10 @@ declare function validateGridPriceBounds(minPrice: any, maxPrice: any, centerPri
|
|
|
166
205
|
* @returns {Object} Summary object with chainFreeBuy, chainFreeSell, committedChainBuy,
|
|
167
206
|
* committedChainSell, freePlusLockedBuy, freePlusLockedSell, chainTotalBuy, chainTotalSell
|
|
168
207
|
*/
|
|
169
|
-
declare function computeChainFundTotals(accountTotals:
|
|
208
|
+
declare function computeChainFundTotals(accountTotals: AccountTotals | null | undefined, committedChain: {
|
|
209
|
+
buy?: number;
|
|
210
|
+
sell?: number;
|
|
211
|
+
} | null | undefined): {
|
|
170
212
|
chainFreeBuy: number;
|
|
171
213
|
chainFreeSell: number;
|
|
172
214
|
committedChainBuy: number;
|
|
@@ -185,7 +227,7 @@ declare function computeChainFundTotals(accountTotals: any, committedChain: any)
|
|
|
185
227
|
* @param {number} precision - Asset precision (satoshis)
|
|
186
228
|
* @returns {number} Quantized float value
|
|
187
229
|
*/
|
|
188
|
-
declare function quantizeFloat(value:
|
|
230
|
+
declare function quantizeFloat(value: number, precision: number): number;
|
|
189
231
|
/**
|
|
190
232
|
* Normalize an integer value by round-tripping through float representation.
|
|
191
233
|
* Converts int → float (readable format) → blockchain int.
|
|
@@ -196,14 +238,14 @@ declare function quantizeFloat(value: any, precision: any): number;
|
|
|
196
238
|
* @param {number} precision - Asset precision (satoshis)
|
|
197
239
|
* @returns {number} Normalized integer value
|
|
198
240
|
*/
|
|
199
|
-
declare function normalizeInt(value:
|
|
241
|
+
declare function normalizeInt(value: number, precision: number): number;
|
|
200
242
|
/**
|
|
201
243
|
* @private Set the fee cache (called by system.js::initializeFeeCache).
|
|
202
244
|
*
|
|
203
245
|
* @param {Object} cache - Fee cache object keyed by asset symbol
|
|
204
246
|
* @returns {void}
|
|
205
247
|
*/
|
|
206
|
-
declare function _setFeeCache(cache:
|
|
248
|
+
declare function _setFeeCache(cache: Record<string, FeeCacheEntry>): void;
|
|
207
249
|
/**
|
|
208
250
|
* Get fee information for an asset.
|
|
209
251
|
|
|
@@ -215,11 +257,11 @@ declare function _setFeeCache(cache: any): void;
|
|
|
215
257
|
* @returns {Object} Fee structure with create/update/net fees or net proceeds if amount provided
|
|
216
258
|
* @throws {Error} If fees not cached (call initializeFeeCache first)
|
|
217
259
|
*/
|
|
218
|
-
declare function getAssetFees(assetSymbol:
|
|
260
|
+
declare function getAssetFees(assetSymbol: string, assetAmount?: number | null, isMaker?: boolean): {
|
|
219
261
|
netProceeds: number;
|
|
220
262
|
total: number;
|
|
221
263
|
refund: number;
|
|
222
|
-
isMaker:
|
|
264
|
+
isMaker: boolean;
|
|
223
265
|
createFee?: undefined;
|
|
224
266
|
updateFee?: undefined;
|
|
225
267
|
cancelFee?: undefined;
|
|
@@ -233,15 +275,15 @@ declare function getAssetFees(assetSymbol: any, assetAmount?: any, isMaker?: any
|
|
|
233
275
|
takerFee?: undefined;
|
|
234
276
|
percent?: undefined;
|
|
235
277
|
} | {
|
|
236
|
-
total:
|
|
237
|
-
createFee:
|
|
238
|
-
updateFee:
|
|
239
|
-
cancelFee:
|
|
278
|
+
total: number;
|
|
279
|
+
createFee: number;
|
|
280
|
+
updateFee: number;
|
|
281
|
+
cancelFee: number;
|
|
240
282
|
makerFeeDiscountPercent: number;
|
|
241
283
|
makerNetFee: number;
|
|
242
284
|
takerNetFee: number;
|
|
243
285
|
netFee: number;
|
|
244
|
-
isMaker:
|
|
286
|
+
isMaker: boolean;
|
|
245
287
|
netProceeds?: undefined;
|
|
246
288
|
refund?: undefined;
|
|
247
289
|
feeAmount?: undefined;
|
|
@@ -253,8 +295,8 @@ declare function getAssetFees(assetSymbol: any, assetAmount?: any, isMaker?: any
|
|
|
253
295
|
netProceeds: number;
|
|
254
296
|
total: number;
|
|
255
297
|
feeAmount: number;
|
|
256
|
-
feePercent:
|
|
257
|
-
isMaker:
|
|
298
|
+
feePercent: number;
|
|
299
|
+
isMaker: boolean;
|
|
258
300
|
refund?: undefined;
|
|
259
301
|
createFee?: undefined;
|
|
260
302
|
updateFee?: undefined;
|
|
@@ -267,9 +309,9 @@ declare function getAssetFees(assetSymbol: any, assetAmount?: any, isMaker?: any
|
|
|
267
309
|
takerFee?: undefined;
|
|
268
310
|
percent?: undefined;
|
|
269
311
|
} | {
|
|
270
|
-
marketFee:
|
|
271
|
-
takerFee:
|
|
272
|
-
percent:
|
|
312
|
+
marketFee: number;
|
|
313
|
+
takerFee: number;
|
|
314
|
+
percent: number;
|
|
273
315
|
netProceeds?: undefined;
|
|
274
316
|
total?: undefined;
|
|
275
317
|
refund?: undefined;
|
|
@@ -293,11 +335,11 @@ declare function getAssetFees(assetSymbol: any, assetAmount?: any, isMaker?: any
|
|
|
293
335
|
* @param {boolean} [isMaker=true] - Whether this is a maker or taker
|
|
294
336
|
* @returns {Object|null} Fee structure or null when fees are not cached
|
|
295
337
|
*/
|
|
296
|
-
declare function getAssetFeesSafe(assetSymbol:
|
|
338
|
+
declare function getAssetFeesSafe(assetSymbol: string, assetAmount?: number | null, isMaker?: boolean): {
|
|
297
339
|
netProceeds: number;
|
|
298
340
|
total: number;
|
|
299
341
|
refund: number;
|
|
300
|
-
isMaker:
|
|
342
|
+
isMaker: boolean;
|
|
301
343
|
createFee?: undefined;
|
|
302
344
|
updateFee?: undefined;
|
|
303
345
|
cancelFee?: undefined;
|
|
@@ -311,15 +353,15 @@ declare function getAssetFeesSafe(assetSymbol: any, assetAmount?: any, isMaker?:
|
|
|
311
353
|
takerFee?: undefined;
|
|
312
354
|
percent?: undefined;
|
|
313
355
|
} | {
|
|
314
|
-
total:
|
|
315
|
-
createFee:
|
|
316
|
-
updateFee:
|
|
317
|
-
cancelFee:
|
|
356
|
+
total: number;
|
|
357
|
+
createFee: number;
|
|
358
|
+
updateFee: number;
|
|
359
|
+
cancelFee: number;
|
|
318
360
|
makerFeeDiscountPercent: number;
|
|
319
361
|
makerNetFee: number;
|
|
320
362
|
takerNetFee: number;
|
|
321
363
|
netFee: number;
|
|
322
|
-
isMaker:
|
|
364
|
+
isMaker: boolean;
|
|
323
365
|
netProceeds?: undefined;
|
|
324
366
|
refund?: undefined;
|
|
325
367
|
feeAmount?: undefined;
|
|
@@ -331,8 +373,8 @@ declare function getAssetFeesSafe(assetSymbol: any, assetAmount?: any, isMaker?:
|
|
|
331
373
|
netProceeds: number;
|
|
332
374
|
total: number;
|
|
333
375
|
feeAmount: number;
|
|
334
|
-
feePercent:
|
|
335
|
-
isMaker:
|
|
376
|
+
feePercent: number;
|
|
377
|
+
isMaker: boolean;
|
|
336
378
|
refund?: undefined;
|
|
337
379
|
createFee?: undefined;
|
|
338
380
|
updateFee?: undefined;
|
|
@@ -345,9 +387,9 @@ declare function getAssetFeesSafe(assetSymbol: any, assetAmount?: any, isMaker?:
|
|
|
345
387
|
takerFee?: undefined;
|
|
346
388
|
percent?: undefined;
|
|
347
389
|
} | {
|
|
348
|
-
marketFee:
|
|
349
|
-
takerFee:
|
|
350
|
-
percent:
|
|
390
|
+
marketFee: number;
|
|
391
|
+
takerFee: number;
|
|
392
|
+
percent: number;
|
|
351
393
|
netProceeds?: undefined;
|
|
352
394
|
total?: undefined;
|
|
353
395
|
refund?: undefined;
|
|
@@ -374,13 +416,13 @@ declare function getAssetFeesSafe(assetSymbol: any, assetAmount?: any, isMaker?:
|
|
|
374
416
|
* @param {Object} [activeOrders=null] - Active order counts {buy, sell} for BTS reservation calculation
|
|
375
417
|
* @returns {number} Available funds for the side (0 if side invalid or insufficient funds)
|
|
376
418
|
*/
|
|
377
|
-
declare function calculateAvailableFundsValue(side:
|
|
419
|
+
declare function calculateAvailableFundsValue(side: string, accountTotals: AccountTotals | null | undefined, funds: ManagerFunds, assetA: string | undefined, assetB: string | undefined, activeOrders?: ActiveOrdersConfig | null, configMinBtsValue?: number | null, feeParams?: GridFeeParams | null): number;
|
|
378
420
|
/**
|
|
379
421
|
* Adjust an allocated budget for BTS fee reservation.
|
|
380
422
|
* Uses computeBtsFeeImpact for proportional deduction; falls back to 0.5
|
|
381
423
|
* split when totalFree is exhausted (legacy sizing-path behavior).
|
|
382
424
|
*/
|
|
383
|
-
declare function adjustBudgetForBtsFees(allocated:
|
|
425
|
+
declare function adjustBudgetForBtsFees(allocated: number, isBtsSide: boolean, formulaBudget: number, minBtsValue: number, btsFree: number, sideFree: number, totalFree: number): number;
|
|
384
426
|
/**
|
|
385
427
|
* Find the best (highest) buy price and best (lowest) sell price from active orders.
|
|
386
428
|
*
|
|
@@ -388,7 +430,7 @@ declare function adjustBudgetForBtsFees(allocated: any, isBtsSide: any, formulaB
|
|
|
388
430
|
* @param {Array<Object>} activeSells - Active sell orders with price property
|
|
389
431
|
* @returns {{bestBuy: number|null, bestSell: number|null}} Best prices or null if no orders
|
|
390
432
|
*/
|
|
391
|
-
declare function getGridBestPrices(activeBuys:
|
|
433
|
+
declare function getGridBestPrices(activeBuys: PricedOrder[], activeSells: PricedOrder[]): {
|
|
392
434
|
bestBuy: number | null;
|
|
393
435
|
bestSell: number | null;
|
|
394
436
|
};
|
|
@@ -404,7 +446,7 @@ declare function getGridBestPrices(activeBuys: any, activeSells: any): {
|
|
|
404
446
|
* (shouldFlagOutOfSpread) take the empty-side branch before touching this
|
|
405
447
|
* value; display callers must handle non-finite (see logger status line).
|
|
406
448
|
*/
|
|
407
|
-
declare function calculateSpreadFromOrders(activeBuys:
|
|
449
|
+
declare function calculateSpreadFromOrders(activeBuys: PricedOrder[], activeSells: PricedOrder[]): number;
|
|
408
450
|
/**
|
|
409
451
|
* Resolve a config value to a numeric amount.
|
|
410
452
|
* Interprets percentage strings, numeric strings, or direct numbers.
|
|
@@ -413,7 +455,7 @@ declare function calculateSpreadFromOrders(activeBuys: any, activeSells: any): n
|
|
|
413
455
|
* @param {number} total - Total amount for percentage calculations
|
|
414
456
|
* @returns {number} Resolved numeric value or 0 if uninterpretable
|
|
415
457
|
*/
|
|
416
|
-
declare function resolveConfigValue(value:
|
|
458
|
+
declare function resolveConfigValue(value: unknown, total: unknown): number;
|
|
417
459
|
/**
|
|
418
460
|
* Resolve a config value to a numeric amount, accounting for shared-account
|
|
419
461
|
* fund registry. If the bot has a registry entry, returns the proportional
|
|
@@ -427,7 +469,7 @@ declare function resolveConfigValue(value: any, total: any): number;
|
|
|
427
469
|
* @param {'buy'|'sell'} side - Trade side
|
|
428
470
|
* @returns {number} Resolved numeric value or 0 if uninterpretable
|
|
429
471
|
*/
|
|
430
|
-
declare function resolveConfigValueWithRegistry(value:
|
|
472
|
+
declare function resolveConfigValueWithRegistry(value: unknown, chainTotal: number, account: string | undefined, botName: string | undefined, side: string): number;
|
|
431
473
|
/**
|
|
432
474
|
* Check if account totals contain valid buy/sell balance data.
|
|
433
475
|
*
|
|
@@ -435,7 +477,7 @@ declare function resolveConfigValueWithRegistry(value: any, chainTotal: any, acc
|
|
|
435
477
|
* @param {boolean} [checkFree=true] - Check free balances if true, else check total balances
|
|
436
478
|
* @returns {boolean} True if both buy and sell values are valid finite numbers
|
|
437
479
|
*/
|
|
438
|
-
declare function hasValidAccountTotals(accountTotals:
|
|
480
|
+
declare function hasValidAccountTotals(accountTotals: AccountTotals | null | undefined, checkFree?: boolean): boolean;
|
|
439
481
|
/**
|
|
440
482
|
* Convert blockchain integer to float using asset precision.
|
|
441
483
|
* Divides by 10^precision to convert satoshi-level units to human-readable float.
|
|
@@ -446,7 +488,7 @@ declare function hasValidAccountTotals(accountTotals: any, checkFree?: any): boo
|
|
|
446
488
|
* @returns {number} Float representation in human-readable units
|
|
447
489
|
* @throws {Error} If precision is invalid
|
|
448
490
|
*/
|
|
449
|
-
declare function blockchainToFloat(intValue:
|
|
491
|
+
declare function blockchainToFloat(intValue: unknown, precision: number | null | undefined): number;
|
|
450
492
|
/**
|
|
451
493
|
* Convert float to blockchain integer using asset precision.
|
|
452
494
|
* Multiplies by 10^precision and rounds to satoshi-level units.
|
|
@@ -461,7 +503,21 @@ declare function blockchainToFloat(intValue: any, precision: any): number;
|
|
|
461
503
|
* @returns {number} Blockchain integer representation (satoshi units)
|
|
462
504
|
* @throws {Error} If precision is invalid
|
|
463
505
|
*/
|
|
464
|
-
declare function floatToBlockchainInt(floatValue:
|
|
506
|
+
declare function floatToBlockchainInt(floatValue: unknown, precision: number | null | undefined): number;
|
|
507
|
+
/**
|
|
508
|
+
* Convert float to a blockchain integer by flooring (never rounding up) at the
|
|
509
|
+
* asset precision. Use whenever a value is a ceiling that must not over-state
|
|
510
|
+
* an available budget (for example a released-collateral allowance).
|
|
511
|
+
*
|
|
512
|
+
* A tiny epsilon counteracts binary-float underflow, e.g. 206 / 1.03 evaluates
|
|
513
|
+
* to 199.99999999999997 at precision 0 but is meant to be 200.
|
|
514
|
+
* Formula: blockchain_int = floor(float * 10^precision + 1e-9)
|
|
515
|
+
*
|
|
516
|
+
* @param {number} floatValue - Float value in human-readable units
|
|
517
|
+
* @param {number} precision - Asset precision exponent (5, 8, 4, ...)
|
|
518
|
+
* @returns {number} Floored blockchain integer representation
|
|
519
|
+
*/
|
|
520
|
+
declare function floorToBlockchainInt(floatValue: unknown, precision: number | null | undefined): number;
|
|
465
521
|
/**
|
|
466
522
|
* Get asset precision for a specific order type (BUY or SELL).
|
|
467
523
|
* BUY orders size in assetB, SELL orders size in assetA.
|
|
@@ -471,7 +527,7 @@ declare function floatToBlockchainInt(floatValue: any, precision: any): number;
|
|
|
471
527
|
* @returns {number} Asset precision
|
|
472
528
|
* @throws {Error} If precision missing for the required asset
|
|
473
529
|
*/
|
|
474
|
-
declare function getPrecisionByOrderType(assets:
|
|
530
|
+
declare function getPrecisionByOrderType(assets: AssetPair | null | undefined, orderType: string): number;
|
|
475
531
|
/**
|
|
476
532
|
* Get asset precisions for both assetA and assetB.
|
|
477
533
|
*
|
|
@@ -479,15 +535,15 @@ declare function getPrecisionByOrderType(assets: any, orderType: any): any;
|
|
|
479
535
|
* @returns {Object} Object with A and B precision properties
|
|
480
536
|
* @throws {Error} If precision missing for either asset
|
|
481
537
|
*/
|
|
482
|
-
declare function getPrecisionsForManager(assets:
|
|
483
|
-
A:
|
|
484
|
-
B:
|
|
538
|
+
declare function getPrecisionsForManager(assets: AssetPair | null | undefined): {
|
|
539
|
+
A: number;
|
|
540
|
+
B: number;
|
|
485
541
|
};
|
|
486
542
|
/**
|
|
487
543
|
* Compute the quantum (smallest representable unit) for a given asset precision.
|
|
488
544
|
* quantum = 10^-precision (e.g., 8 decimals → 1e-8).
|
|
489
545
|
*/
|
|
490
|
-
declare function quantumForPrecision(precision:
|
|
546
|
+
declare function quantumForPrecision(precision: number | undefined): number;
|
|
491
547
|
/**
|
|
492
548
|
* Calculate precision slack (rounding tolerance) for a given precision level.
|
|
493
549
|
* Used for safe comparison of blockchain values that may differ by rounding.
|
|
@@ -496,7 +552,7 @@ declare function quantumForPrecision(precision: any): number;
|
|
|
496
552
|
* @param {number} [factor=2] - Multiplier for slack (default 2)
|
|
497
553
|
* @returns {number} Tolerance value (e.g., 2 * 10^-8 for 8-decimal precision)
|
|
498
554
|
*/
|
|
499
|
-
declare function getPrecisionSlack(precision:
|
|
555
|
+
declare function getPrecisionSlack(precision: number | undefined, factor?: number): number;
|
|
500
556
|
/**
|
|
501
557
|
* Unified precision lookup for assets.
|
|
502
558
|
*
|
|
@@ -504,16 +560,16 @@ declare function getPrecisionSlack(precision: any, factor?: any): number;
|
|
|
504
560
|
* @param {Object} [options={}] - Lookup options { type, side, proceeds }
|
|
505
561
|
* @returns {number} Asset precision
|
|
506
562
|
*/
|
|
507
|
-
declare function getPrecision(assets:
|
|
563
|
+
declare function getPrecision(assets: AssetPair | null | undefined, { type, side, proceeds }?: {
|
|
508
564
|
type?: string;
|
|
509
565
|
side?: string;
|
|
510
566
|
proceeds?: boolean;
|
|
511
|
-
}):
|
|
567
|
+
}): number;
|
|
512
568
|
/**
|
|
513
569
|
* Determine which side holds BTS for a trading pair.
|
|
514
570
|
* Returns ORDER_TYPES.SELL if assetA is BTS, ORDER_TYPES.BUY if assetB is BTS, null otherwise.
|
|
515
571
|
*/
|
|
516
|
-
declare function getBtsSide(assetA: string, assetB: string): string | null;
|
|
572
|
+
declare function getBtsSide(assetA: string | undefined, assetB: string | undefined): string | null;
|
|
517
573
|
/**
|
|
518
574
|
* Calculate price tolerance for order matching on-chain.
|
|
519
575
|
* Accounts for precision limits of both assets to determine acceptable price deviation.
|
|
@@ -531,7 +587,7 @@ declare function getBtsSide(assetA: string, assetB: string): string | null;
|
|
|
531
587
|
* @returns {number|null} Price tolerance value or null if invalid inputs
|
|
532
588
|
* @throws {Error} If assets missing or precisions invalid
|
|
533
589
|
*/
|
|
534
|
-
declare function calculatePriceTolerance(gridPrice:
|
|
590
|
+
declare function calculatePriceTolerance(gridPrice: unknown, orderSize: unknown, orderType: string, assets?: AssetPair | null): number | null;
|
|
535
591
|
/**
|
|
536
592
|
* Scan an iterable of candidate items for a price collision with the target order.
|
|
537
593
|
* Each candidate must have `id` and a price accessible via `item.price ?? item.order?.price`.
|
|
@@ -545,7 +601,7 @@ declare function calculatePriceTolerance(gridPrice: any, orderSize: any, orderTy
|
|
|
545
601
|
* @param {Function} [isValid] - Optional predicate; candidate must return true to be considered
|
|
546
602
|
* @returns {object|null} The colliding item, or null
|
|
547
603
|
*/
|
|
548
|
-
declare function findPriceCollision(items: Iterable<
|
|
604
|
+
declare function findPriceCollision(items: Iterable<CollisionItem>, excludeId: string, targetPrice: number, targetSize: number, targetType: string, assets: AssetPair | null, isValid?: ((item: CollisionItem) => boolean) | null): CollisionItem | null;
|
|
549
605
|
/**
|
|
550
606
|
* Find an opposite-side order that a candidate placement would CROSS.
|
|
551
607
|
*
|
|
@@ -567,11 +623,11 @@ declare function findPriceCollision(items: Iterable<any>, excludeId: string, tar
|
|
|
567
623
|
* @param {Iterable<any>} items - Candidate orders (e.g. manager.orders.values())
|
|
568
624
|
* @param {number} price - Candidate placement price
|
|
569
625
|
* @param {string} type - Candidate placement type (ORDER_TYPES.BUY / SELL)
|
|
570
|
-
* @param {
|
|
626
|
+
* @param {unknown} assets - Asset metadata (precisions) for tolerance
|
|
571
627
|
* @param {((item: any) => boolean)|null} [isValid] - Optional filter
|
|
572
628
|
* @returns {any|null} The first crossed order, or null when the placement crosses nothing
|
|
573
629
|
*/
|
|
574
|
-
declare function findCrossedOrder(items: Iterable<
|
|
630
|
+
declare function findCrossedOrder(items: Iterable<CollisionItem>, price: number, type: string, assets: AssetPair | null, isValid?: ((item: CollisionItem) => boolean) | null): CollisionItem | null;
|
|
575
631
|
/**
|
|
576
632
|
* Validate order amounts are within blockchain limits (0 < INT64_MAX).
|
|
577
633
|
* Converts floats to blockchain integers and checks they fit in signed 64-bit integers.
|
|
@@ -582,7 +638,7 @@ declare function findCrossedOrder(items: Iterable<any>, price: number, type: str
|
|
|
582
638
|
* @param {number} receivePrecision - Precision of receive asset
|
|
583
639
|
* @returns {boolean} True if both amounts are valid and within limits
|
|
584
640
|
*/
|
|
585
|
-
declare function validateOrderAmountsWithinLimits(amountToSell:
|
|
641
|
+
declare function validateOrderAmountsWithinLimits(amountToSell: number, minToReceive: number, sellPrecision: number, receivePrecision: number): boolean;
|
|
586
642
|
/**
|
|
587
643
|
* Calculate minimum absolute order size for an order type.
|
|
588
644
|
* Returns factor * 10^-precision (e.g., 50 * 10^-8 for 8-decimal asset).
|
|
@@ -593,14 +649,14 @@ declare function validateOrderAmountsWithinLimits(amountToSell: any, minToReceiv
|
|
|
593
649
|
* @returns {number} Minimum order size in asset units
|
|
594
650
|
* @throws {Error} If precision cannot be determined
|
|
595
651
|
*/
|
|
596
|
-
declare function getMinOrderSize(orderType:
|
|
652
|
+
declare function getMinOrderSize(orderType: string, assets: AssetPair | null | undefined, factor?: number): number;
|
|
597
653
|
/**
|
|
598
654
|
* Calculate dust threshold factor as decimal fraction.
|
|
599
655
|
*
|
|
600
656
|
* @param {number} [dustThresholdPercent=5] - Dust threshold percentage (default 5%)
|
|
601
657
|
* @returns {number} Dust factor (e.g., 0.05 for 5%)
|
|
602
658
|
*/
|
|
603
|
-
declare function getDustThresholdFactor(dustThresholdPercent?:
|
|
659
|
+
declare function getDustThresholdFactor(dustThresholdPercent?: number): number;
|
|
604
660
|
/**
|
|
605
661
|
* Calculate single dust threshold for an ideal order size.
|
|
606
662
|
* Returns idealSize * (dustThresholdPercent / 100).
|
|
@@ -609,7 +665,7 @@ declare function getDustThresholdFactor(dustThresholdPercent?: any): number;
|
|
|
609
665
|
* @param {number} [dustThresholdPercent=5] - Threshold percentage (default 5%)
|
|
610
666
|
* @returns {number} Single dust threshold (0 if idealSize invalid)
|
|
611
667
|
*/
|
|
612
|
-
declare function getSingleDustThreshold(idealSize:
|
|
668
|
+
declare function getSingleDustThreshold(idealSize: number, dustThresholdPercent?: number): number;
|
|
613
669
|
/**
|
|
614
670
|
* Calculate double dust threshold for an ideal order size.
|
|
615
671
|
* Returns idealSize * (dustThresholdPercent / 100) * 2.
|
|
@@ -619,7 +675,7 @@ declare function getSingleDustThreshold(idealSize: any, dustThresholdPercent?: a
|
|
|
619
675
|
* @param {number} [dustThresholdPercent=5] - Threshold percentage (default 5%)
|
|
620
676
|
* @returns {number} Double dust threshold (0 if idealSize invalid)
|
|
621
677
|
*/
|
|
622
|
-
declare function getDoubleDustThreshold(idealSize:
|
|
678
|
+
declare function getDoubleDustThreshold(idealSize: number, dustThresholdPercent?: number): number;
|
|
623
679
|
/**
|
|
624
680
|
* Validate an order size against minimum absolute and dust thresholds.
|
|
625
681
|
* Returns detailed validation result with reasons if invalid.
|
|
@@ -632,16 +688,11 @@ declare function getDoubleDustThreshold(idealSize: any, dustThresholdPercent?: a
|
|
|
632
688
|
* @param {number} [dustThresholdPercent=5] - Dust threshold percentage (default 5%)
|
|
633
689
|
* @returns {Object} Validation result {isValid, reason, minAbsoluteSize, minDustSize}
|
|
634
690
|
*/
|
|
635
|
-
declare function validateOrderSize(orderSize:
|
|
691
|
+
declare function validateOrderSize(orderSize: number, orderType: string, assets: AssetPair | null | undefined, minFactor?: number, idealSize?: number | null, dustThresholdPercent?: number): {
|
|
636
692
|
isValid: boolean;
|
|
637
|
-
reason: string;
|
|
693
|
+
reason: string | null;
|
|
638
694
|
minAbsoluteSize: number;
|
|
639
|
-
minDustSize:
|
|
640
|
-
} | {
|
|
641
|
-
isValid: boolean;
|
|
642
|
-
reason: null;
|
|
643
|
-
minAbsoluteSize: number;
|
|
644
|
-
minDustSize: any;
|
|
695
|
+
minDustSize: number | null;
|
|
645
696
|
};
|
|
646
697
|
/**
|
|
647
698
|
* Allocate total funds across n orders using exponential weight distribution.
|
|
@@ -657,7 +708,7 @@ declare function validateOrderSize(orderSize: any, orderType: any, assets: any,
|
|
|
657
708
|
* @param {number} [precision=null] - Asset precision; if provided, quantize to blockchain integers
|
|
658
709
|
* @returns {Array<number>} Array of n allocation sizes
|
|
659
710
|
*/
|
|
660
|
-
declare function allocateFundsByWeights(totalFunds:
|
|
711
|
+
declare function allocateFundsByWeights(totalFunds: number, n: number, weight: unknown, incrementFactor: number, reverse?: boolean, _minSize?: number, precision?: number | null): number[];
|
|
661
712
|
/**
|
|
662
713
|
* Calculate order sizes for a list of orders using weighted fund allocation.
|
|
663
714
|
* Allocates buy and sell funds separately using weight distribution from config.
|
|
@@ -673,7 +724,7 @@ declare function allocateFundsByWeights(totalFunds: any, n: any, weight: any, in
|
|
|
673
724
|
* @param {number} [precisionB=null] - Precision for assetB (BUY asset)
|
|
674
725
|
* @returns {Array<Object>} Orders array with size property added to each
|
|
675
726
|
*/
|
|
676
|
-
declare function calculateOrderSizes(orders:
|
|
727
|
+
declare function calculateOrderSizes(orders: ManagedOrder[], config: GridConfig, sellFunds: number, buyFunds: number, minSellSize?: number, minBuySize?: number, precisionA?: number | null, precisionB?: number | null): ManagedOrder[];
|
|
677
728
|
/**
|
|
678
729
|
* Calculate order sizes for rotation operations.
|
|
679
730
|
* Combines available funds with existing grid allocation for sizing.
|
|
@@ -688,7 +739,7 @@ declare function calculateOrderSizes(orders: any, config: any, sellFunds: any, b
|
|
|
688
739
|
* @param {number} [precision=null] - Asset precision for quantization
|
|
689
740
|
* @returns {Array<number>} Array of order sizes
|
|
690
741
|
*/
|
|
691
|
-
declare function calculateRotationOrderSizes(availableFunds:
|
|
742
|
+
declare function calculateRotationOrderSizes(availableFunds: number, totalGridAllocation: number, orderCount: number, orderType: string, config: GridConfig, minSize?: number, precision?: number | null): number[];
|
|
692
743
|
/**
|
|
693
744
|
* Calculate RMS (Root Mean Square) divergence between calculated and persisted grids.
|
|
694
745
|
* Measures how much the current grid differs from the calculated ideal.
|
|
@@ -703,7 +754,7 @@ declare function calculateRotationOrderSizes(availableFunds: any, totalGridAlloc
|
|
|
703
754
|
* @param {string} [sideName='unknown'] - Side name for logging (buy/sell)
|
|
704
755
|
* @returns {number} RMS divergence metric (0 = perfect match, higher = more divergence)
|
|
705
756
|
*/
|
|
706
|
-
declare function calculateGridSideDivergenceMetric(calculatedOrders:
|
|
757
|
+
declare function calculateGridSideDivergenceMetric(calculatedOrders: ManagedOrder[], persistedOrders: ManagedOrder[], _sideName?: string): number;
|
|
707
758
|
/**
|
|
708
759
|
* Calculate estimated BTS order creation fees for a number of orders.
|
|
709
760
|
* Works for all pairs — returns the BTS fee budget needed for order operations.
|
|
@@ -714,7 +765,7 @@ declare function calculateGridSideDivergenceMetric(calculatedOrders: any, persis
|
|
|
714
765
|
* @param {number} [feeMultiplier=BTS_RESERVATION_MULTIPLIER] - Multiplier for reservation (typically 5x)
|
|
715
766
|
* @returns {number} Total fee amount (fallback BTS_FALLBACK_FEE if fee lookup fails; warning logged)
|
|
716
767
|
*/
|
|
717
|
-
declare function calculateOrderCreationFees(assetA:
|
|
768
|
+
declare function calculateOrderCreationFees(assetA: string | undefined, assetB: string | undefined, totalOrders: number, feeMultiplier?: number): number;
|
|
718
769
|
/**
|
|
719
770
|
* Calculate how much input asset to swap into a constant-product AMM pool
|
|
720
771
|
* to receive a target amount of output asset.
|
|
@@ -731,7 +782,7 @@ declare function calculateOrderCreationFees(assetA: any, assetB: any, totalOrder
|
|
|
731
782
|
* @param {number} poolReserveIn - Pool reserve of input asset
|
|
732
783
|
* @returns {number} Amount of input asset to sell
|
|
733
784
|
*/
|
|
734
|
-
declare function calculateSwapInAmount(targetReceive:
|
|
785
|
+
declare function calculateSwapInAmount(targetReceive: number, poolReserveOut: number, poolReserveIn: number): number;
|
|
735
786
|
/**
|
|
736
787
|
* Calculate the spread gap size (number of empty slots between BUY and SELL rails).
|
|
737
788
|
* Used by both grid creation and strategy rebalancing to keep spread math consistent.
|
|
@@ -741,15 +792,12 @@ declare function calculateSwapInAmount(targetReceive: any, poolReserveOut: any,
|
|
|
741
792
|
* @param {Object} GRID_LIMITS - Grid limits constants (optional, uses defaults)
|
|
742
793
|
* @returns {number} Number of gap slots
|
|
743
794
|
*/
|
|
744
|
-
declare function calculateGapSlots(incrementPercent:
|
|
745
|
-
MIN_SPREAD_FACTOR?: number;
|
|
746
|
-
MIN_SPREAD_ORDERS?: number;
|
|
747
|
-
}): number;
|
|
795
|
+
declare function calculateGapSlots(incrementPercent: number | undefined, targetSpreadPercent: number | undefined, gridLimits?: GridLimitsLike): number;
|
|
748
796
|
/**
|
|
749
797
|
* Calculate sell start index from boundary index and gap slots.
|
|
750
798
|
* sellStartIdx = boundaryIdx + gapSlots + 1
|
|
751
799
|
*/
|
|
752
|
-
declare function getSellStartIdx(boundaryIdx:
|
|
800
|
+
declare function getSellStartIdx(boundaryIdx: number | null, gapSlots: number | null): number;
|
|
753
801
|
/**
|
|
754
802
|
* Resolve the configured gap-slot count for a manager-like object.
|
|
755
803
|
* Single source of truth for the `_gapSlots ?? calculateGapSlots(config)`
|
|
@@ -757,8 +805,8 @@ declare function getSellStartIdx(boundaryIdx: any, gapSlots: any): number;
|
|
|
757
805
|
* two can never disagree on band width.
|
|
758
806
|
*/
|
|
759
807
|
declare function resolveGapSlots(manager: {
|
|
760
|
-
_gapSlots?:
|
|
761
|
-
config?:
|
|
808
|
+
_gapSlots?: number | null;
|
|
809
|
+
config?: GridConfig | null;
|
|
762
810
|
}): number;
|
|
763
811
|
/**
|
|
764
812
|
* Resolve gap-band geometry from a manager-like object.
|
|
@@ -773,9 +821,9 @@ declare function resolveGapSlots(manager: {
|
|
|
773
821
|
* boundary restored yet" and skip geometry-based filtering.
|
|
774
822
|
*/
|
|
775
823
|
declare function resolveGapBand(manager: {
|
|
776
|
-
_gapSlots?:
|
|
777
|
-
boundaryIdx?:
|
|
778
|
-
config?:
|
|
824
|
+
_gapSlots?: number | null;
|
|
825
|
+
boundaryIdx?: number | null;
|
|
826
|
+
config?: GridConfig | null;
|
|
779
827
|
}): {
|
|
780
828
|
gapSlots: number;
|
|
781
829
|
boundaryIdx: number | null;
|
|
@@ -832,7 +880,7 @@ declare const BOUNDARY_REJECT_PLACED_IN_BAND = "placed_order_in_band";
|
|
|
832
880
|
* @returns `{ ok: true }`, or `{ ok: false, reason, detail }` where `reason`
|
|
833
881
|
* is a stable short code and `detail` carries indices/prices for logs.
|
|
834
882
|
*/
|
|
835
|
-
declare function validateBoundaryCommit(proposedBoundary:
|
|
883
|
+
declare function validateBoundaryCommit(proposedBoundary: number | null | undefined, orders: Iterable<unknown>, gapSlots: number, options?: {
|
|
836
884
|
rejectInBandPlacements?: boolean;
|
|
837
885
|
}): {
|
|
838
886
|
ok: boolean;
|
|
@@ -867,7 +915,7 @@ declare function validateBoundaryCommit(proposedBoundary: any, orders: Iterable<
|
|
|
867
915
|
* in-progress evacuation; true poison still refuses and structural resync
|
|
868
916
|
* falls through to the clean full-grid reset instead of re-ingesting damage.
|
|
869
917
|
*/
|
|
870
|
-
declare function validatePersistedBoundary(proposedBoundary:
|
|
918
|
+
declare function validatePersistedBoundary(proposedBoundary: number | null | undefined, orders: Iterable<unknown>, gapSlots: number): {
|
|
871
919
|
ok: boolean;
|
|
872
920
|
reason?: string;
|
|
873
921
|
detail?: string;
|
|
@@ -893,7 +941,11 @@ declare function validatePersistedBoundary(proposedBoundary: any, orders: Iterab
|
|
|
893
941
|
* @param check - validatePersistedBoundary / validateBoundaryCommit result
|
|
894
942
|
* @returns True when the check is pure in-band placement (transient).
|
|
895
943
|
*/
|
|
896
|
-
declare function isTransientInBandRejection(check:
|
|
944
|
+
declare function isTransientInBandRejection(check: {
|
|
945
|
+
ok?: boolean;
|
|
946
|
+
reason?: string;
|
|
947
|
+
[key: string]: unknown;
|
|
948
|
+
} | null | undefined): boolean;
|
|
897
949
|
/**
|
|
898
950
|
* Count SPREAD-typed slots strictly inside the gap band
|
|
899
951
|
* (`boundaryIdx < idx < sellStartIdx`). Empty slots are normalized to SPREAD
|
|
@@ -909,7 +961,7 @@ declare function isTransientInBandRejection(check: any): boolean;
|
|
|
909
961
|
* @returns Count of SPREAD slots inside the gap band, or — when no usable
|
|
910
962
|
* boundary is restored — the total count of SPREAD-typed slots (fallback).
|
|
911
963
|
*/
|
|
912
|
-
declare function countGapBandSpread(manager:
|
|
964
|
+
declare function countGapBandSpread(manager: OrderManagerLike, orders: Iterable<ManagedOrder>, resolveIndex: (order: ManagedOrder, arrayIndex: number) => number | null): number;
|
|
913
965
|
/**
|
|
914
966
|
* Pure geometric rail-membership test for a grid slot.
|
|
915
967
|
*
|
|
@@ -932,7 +984,7 @@ declare function countGapBandSpread(manager: any, orders: Iterable<any>, resolve
|
|
|
932
984
|
* @param {number} gapSlots - Spread gap slot count. A non-finite value means
|
|
933
985
|
* the SELL start cannot be derived, so the slot is not excluded.
|
|
934
986
|
* @param {string} orderType - ORDER_TYPES.BUY or ORDER_TYPES.SELL.
|
|
935
|
-
* @param {
|
|
987
|
+
* @param {unknown} slot - Grid slot (or any object exposing an id like `slot-3`);
|
|
936
988
|
* slots with an unparseable id are admitted (returns true): geometry cannot
|
|
937
989
|
* identify the gap for legacy ids, so windowing falls back to the stored
|
|
938
990
|
* slot type exactly as pre-1.4.25 did (fail-open; consumers still reject
|
|
@@ -941,7 +993,9 @@ declare function countGapBandSpread(manager: any, orders: Iterable<any>, resolve
|
|
|
941
993
|
* geometry cannot be determined (fail-open), false only when a parseable id
|
|
942
994
|
* sits provably outside the rail.
|
|
943
995
|
*/
|
|
944
|
-
declare function isSlotInRail(boundaryIdx:
|
|
996
|
+
declare function isSlotInRail(boundaryIdx: number | null, gapSlots: number | null, orderType: string, slot: {
|
|
997
|
+
id?: string;
|
|
998
|
+
} | null | undefined): boolean;
|
|
945
999
|
/**
|
|
946
1000
|
* Whether a slot index sits inside the gap (spread) band: strictly between
|
|
947
1001
|
* the last BUY index (boundary) and the first SELL index. Geometry-only —
|
|
@@ -953,7 +1007,7 @@ declare function isSlotInRail(boundaryIdx: any, gapSlots: any, orderType: any, s
|
|
|
953
1007
|
* @param {number} gapSlots - Spread gap slot count
|
|
954
1008
|
* @returns {boolean} True when the index is inside the gap band
|
|
955
1009
|
*/
|
|
956
|
-
declare function isSlotIndexInGapBand(idx:
|
|
1010
|
+
declare function isSlotIndexInGapBand(idx: number | string | null | undefined, boundaryIdx: number | string | null | undefined, gapSlots: number): boolean;
|
|
957
1011
|
/**
|
|
958
1012
|
* Pure stamped-evacuation size re-proof: a B-stamped (plan-build-proven)
|
|
959
1013
|
* evacuation bypasses the live probe, but the plan was built against the
|
|
@@ -974,7 +1028,7 @@ declare function isSlotIndexInGapBand(idx: any, boundaryIdx: any, gapSlots: any)
|
|
|
974
1028
|
* @param {number} [precision] - Asset precision for bit-exact int compare
|
|
975
1029
|
* @returns {boolean} True when the planned size is still covered by the booking
|
|
976
1030
|
*/
|
|
977
|
-
declare function isEvacuationSizeStillValid(newSize:
|
|
1031
|
+
declare function isEvacuationSizeStillValid(newSize: number, bookedRemaining: number, precision?: number | null): boolean;
|
|
978
1032
|
/**
|
|
979
1033
|
* Pure gap-evacuation rotation allowance: decides whether a slot-to-slot
|
|
980
1034
|
* rotation (UPDATE with newGridId) reduces the violation surface enough to
|
|
@@ -1000,7 +1054,7 @@ declare function isEvacuationSizeStillValid(newSize: any, bookedRemaining: any,
|
|
|
1000
1054
|
* @param {number} [precision] - Asset precision for bit-exact int compare
|
|
1001
1055
|
* @returns {{allowed: boolean, reason: string}}
|
|
1002
1056
|
*/
|
|
1003
|
-
declare function isEvacuationRotationAllowed(oldPrice:
|
|
1057
|
+
declare function isEvacuationRotationAllowed(oldPrice: unknown, oldSize: unknown, newPrice: unknown, newSize: unknown, type: string, precision?: number | null): {
|
|
1004
1058
|
allowed: boolean;
|
|
1005
1059
|
reason: string;
|
|
1006
1060
|
};
|
|
@@ -1027,7 +1081,7 @@ declare function slotIdForPrice(price: number, genesis: GridGenesis): string;
|
|
|
1027
1081
|
* cancel as a duplicate.
|
|
1028
1082
|
*/
|
|
1029
1083
|
declare function isChainPriceOutOfGrid(price: number, genesis: GridGenesis, precision: number): boolean;
|
|
1030
|
-
declare function assertSlotPriceInvariant(slot:
|
|
1084
|
+
declare function assertSlotPriceInvariant(slot: unknown, genesis: GridGenesis): void;
|
|
1031
1085
|
declare function priceSlotEqual(a: number, b: number, precision: number): boolean;
|
|
1032
1086
|
/**
|
|
1033
1087
|
* Derive the geometric price ladder (the "rail") from a live config.
|
|
@@ -1051,7 +1105,8 @@ declare function priceSlotEqual(a: number, b: number, precision: number): boolea
|
|
|
1051
1105
|
*/
|
|
1052
1106
|
declare function derivePriceLevels(startPrice: number, minPrice: number, maxPrice: number, incrementPercent: number): number[];
|
|
1053
1107
|
declare function buildGenesisFromPriceLevels(startPrice: number, incrementPercent: number, gapSlots: number, priceLevels: number[]): GridGenesis;
|
|
1054
|
-
export {
|
|
1108
|
+
export type { FeeCacheEntry };
|
|
1109
|
+
export { getBtsSide, getSellStartIdx, resolveGapBand, countGapBandSpread, calculateGapSlots, isSlotInRail, isSlotIndexInGapBand, isEvacuationRotationAllowed, isEvacuationSizeStillValid, validateBoundaryCommit, validatePersistedBoundary, isTransientInBandRejection, BOUNDARY_REJECT_PLACED_IN_BAND, resolveGapSlots, isPercentageString, isPositiveNumber, isPositiveNumberOrPercent, isPositiveInt, parsePercentageString, toDecimal, resolveRelativePrice, parseRelativeMultiplier, validateGridPriceBounds, isExplicitZeroAllocation, getPrecision, computeChainFundTotals, calculateAvailableFundsValue, adjustBudgetForBtsFees, getGridBestPrices, calculateSpreadFromOrders, resolveConfigValue, resolveConfigValueWithRegistry, hasValidAccountTotals, blockchainToFloat, floatToBlockchainInt, floorToBlockchainInt, quantizeFloat, normalizeInt, getPrecisionByOrderType, getPrecisionsForManager, getPrecisionSlack, quantumForPrecision, calculatePriceTolerance, findPriceCollision, findCrossedOrder, validateOrderAmountsWithinLimits, getMinOrderSize, getDustThresholdFactor, getSingleDustThreshold, getDoubleDustThreshold, validateOrderSize, getAssetFees, getAssetFeesSafe, allocateFundsByWeights, calculateOrderSizes, calculateRotationOrderSizes, calculateGridSideDivergenceMetric, calculateOrderCreationFees, calculateSwapInAmount, _setFeeCache, cloneWeightDistribution, clamp, roundTo, fixedTo, roundToDecimals, priceLevelsForGenesis, priceForSlot, slotIndexForPrice, slotIdForPrice, assertSlotPriceInvariant, priceSlotEqual, derivePriceLevels, buildGenesisFromPriceLevels, hashPriceLevels, isChainPriceOutOfGrid };
|
|
1055
1110
|
/**
|
|
1056
1111
|
* Round a value to a given factor.
|
|
1057
1112
|
* @param {number} value - Value to round
|
|
@@ -1080,7 +1135,7 @@ declare function roundToDecimals(value: number, decimals: number): number;
|
|
|
1080
1135
|
* @param {number} max - Upper bound
|
|
1081
1136
|
* @returns {number}
|
|
1082
1137
|
*/
|
|
1083
|
-
declare function clamp(value:
|
|
1138
|
+
declare function clamp(value: number, min: number, max: number): number;
|
|
1084
1139
|
/**
|
|
1085
1140
|
* Safely clone a weight distribution object.
|
|
1086
1141
|
* Validates numeric sell/buy values and falls back to a base object if provided.
|
|
@@ -1090,7 +1145,7 @@ declare function clamp(value: any, min: any, max: any): number;
|
|
|
1090
1145
|
* @param {Object|null} base - Fallback weights if primary is missing/invalid
|
|
1091
1146
|
* @returns {{sell:number,buy:number}|null}
|
|
1092
1147
|
*/
|
|
1093
|
-
declare function cloneWeightDistribution(weightDistribution:
|
|
1148
|
+
declare function cloneWeightDistribution(weightDistribution: WeightDistributionConfig | null | undefined, base?: WeightDistributionConfig | null): {
|
|
1094
1149
|
sell: number;
|
|
1095
1150
|
buy: number;
|
|
1096
1151
|
} | null;
|