dexbot 1.4.15 → 1.4.17
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 +5013 -0
- package/README.md +18 -14
- package/analysis/README.md +468 -0
- package/analysis/ama_fitting/README.md +258 -0
- package/analysis/ama_fitting/analyze_ama_price_changes.ts +151 -0
- package/analysis/ama_fitting/analyze_lambda_vs_slow.ts +407 -0
- package/analysis/ama_fitting/calibrate_convergence_er.ts +199 -0
- package/analysis/ama_fitting/fetch_lp_candles.ts +187 -0
- package/analysis/ama_fitting/generate_unified_comparison_chart.ts +269 -0
- package/analysis/ama_fitting/optimizer_high_resolution.ts +792 -0
- package/analysis/ama_fitting/package.json +12 -0
- package/analysis/analyze_derivatives.ts +318 -0
- package/analysis/analyze_dynamic_weight.ts +219 -0
- package/analysis/analyze_kalman.ts +126 -0
- package/analysis/analyze_regime.ts +156 -0
- package/analysis/analyze_regime_windows.ts +460 -0
- package/analysis/analyze_risk_profile.ts +199 -0
- package/analysis/analyze_trade_heatmap.ts +362 -0
- package/analysis/analyze_volatility.ts +182 -0
- package/analysis/bot_fitting/README.md +124 -0
- package/analysis/bot_fitting/backtest_ama_sweep.ts +816 -0
- package/analysis/bot_fitting/backtest_bot_fitting.ts +421 -0
- package/analysis/bot_fitting/shared_utils.ts +46 -0
- package/analysis/bot_key_utils.ts +154 -0
- package/analysis/bot_usage/discover_bot_accounts.ts +579 -0
- package/analysis/bot_usage/kibana_bot_queries.ts +427 -0
- package/analysis/chart_css.ts +60 -0
- package/analysis/chart_ui.ts +106 -0
- package/{dist/analysis/chart_utils.js → analysis/chart_utils.ts} +21 -13
- package/analysis/derivative_chart_generator.ts +874 -0
- package/analysis/math_utils.ts +60 -0
- package/analysis/price_sources.ts +130 -0
- package/analysis/resolve_source.ts +89 -0
- package/analysis/trade_profitability.ts +1412 -0
- package/analysis/tradingview/README.md +161 -0
- package/analysis/tradingview/analyze_tradingview.ts +160 -0
- package/{dist/analysis/tradingview/tradingview_uplot_chart_generator.js → analysis/tradingview/tradingview_uplot_chart_generator.ts} +40 -36
- package/analysis/trend_detection/DYNAMIC_WEIGHT_RESEARCH.md +437 -0
- package/analysis/trend_detection/README.md +27 -0
- package/analysis/trend_detection/SIGNAL_DOCUMENTATION.md +403 -0
- package/analysis/trend_detection/derivative_analyzer.ts +1050 -0
- package/analysis/trend_detection/dynamic_weight_chart_generator.ts +1376 -0
- package/analysis/trend_detection/hurst_analyzer.ts +7 -0
- package/analysis/trend_detection/kalman_chart_generator.ts +371 -0
- package/analysis/trend_detection/kalman_trend_analyzer.ts +9 -0
- package/analysis/trend_detection/kalman_velocity_smoothing.ts +7 -0
- package/analysis/trend_detection/package.json +23 -0
- package/analysis/trend_detection/permutation_entropy_analyzer.ts +7 -0
- package/analysis/trend_detection/regime_chart_generator.ts +319 -0
- package/analysis/trend_detection/tests/test_kalman_trend.ts +153 -0
- package/analysis/trend_detection/tests/test_kalman_velocity_smoothing.ts +64 -0
- package/analysis/trend_detection/volatility_chart_generator.ts +655 -0
- package/analysis/tsconfig.json +29 -0
- package/analysis/uplot/index.d.ts +128 -0
- package/analysis/uplot/uPlot.iife.min.js +2 -0
- package/analysis/uplot/uPlot.min.css +1 -0
- package/claw/README.md +4 -0
- package/claw/examples/claw_profiles_example.ts +1 -1
- package/claw/examples/memu_integration_example.ts +1 -1
- package/claw/modules/bitshares_client.ts +47 -7
- package/claw/modules/chain_actions.ts +10 -1
- package/claw/modules/chain_broadcast.ts +4 -5
- package/claw/modules/claw_infra.ts +13 -3
- package/claw/modules/claw_launcher.ts +41 -7
- package/claw/modules/claw_manifest.ts +9 -1
- package/claw/modules/claw_skill_md.ts +34 -13
- package/claw/modules/credit_runtime_adapter.ts +30 -12
- package/claw/modules/decision_loop.ts +10 -2
- package/claw/modules/dexbot_profiles.ts +5 -25
- package/claw/modules/feed_price_source.ts +1 -1
- package/claw/modules/honest_ecosystem.ts +32 -8
- package/claw/modules/kibana_price_source.ts +6 -2
- package/claw/modules/launcher_mode_detector.ts +10 -13
- package/claw/modules/launcher_paths.ts +4 -1
- package/claw/modules/liquidity_pools.ts +2 -2
- package/claw/modules/mcp_utils.ts +46 -5
- package/claw/modules/memu_bridge.ts +17 -1
- package/claw/modules/position_discovery.ts +1 -1
- package/claw/modules/position_health.ts +1 -1
- package/claw/modules/position_manager.ts +39 -13
- package/claw/modules/skill_utils.ts +4 -8
- package/claw/modules/types.ts +20 -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/claw/scripts/claw_bridge.ts +22 -3
- package/claw/scripts/claw_mcp_server.ts +28 -13
- package/claw/scripts/honest_assets_report.ts +3 -1
- package/claw/scripts/memu_mcp_server.ts +15 -4
- package/claw/tests/test_claw_data_flow.ts +4 -2
- package/claw/tests/test_claw_mcp_transport.ts +2 -2
- package/claw/tests/test_claw_regressions.ts +5 -0
- package/claw/tests/test_claw_skill_generation.ts +3 -3
- package/claw/tests/test_nullclaw_tmp_integration.ts +1 -1
- package/claw/tsconfig.json +1 -2
- package/dist/bot.js +1 -1
- package/dist/bot.js.map +1 -1
- package/dist/credential-daemon.js +8 -8
- package/dist/credential-daemon.js.map +1 -1
- package/dist/market_adapter/core/market_adapter_service.d.ts.map +1 -1
- package/dist/market_adapter/core/market_adapter_service.js +9 -3
- package/dist/market_adapter/core/market_adapter_service.js.map +1 -1
- package/dist/market_adapter/core/signals/hurst_analyzer.js +1 -1
- package/dist/market_adapter/core/signals/kalman_trend_analyzer.js +1 -1
- package/dist/market_adapter/core/signals/permutation_entropy_analyzer.js +1 -1
- package/dist/market_adapter/core/strategies/ama_slope_model.js +1 -1
- package/dist/market_adapter/core/strategies/collateral_manager.js +1 -1
- package/dist/market_adapter/core/strategies/regime_gate.js +1 -1
- package/dist/market_adapter/inputs/fetch_cex_synthetic_data.js +1 -2
- package/dist/market_adapter/inputs/fetch_cex_synthetic_data.js.map +1 -1
- package/dist/market_adapter/inputs/fetch_lp_data.d.ts.map +1 -1
- package/dist/market_adapter/inputs/fetch_lp_data.js +2 -3
- package/dist/market_adapter/inputs/fetch_lp_data.js.map +1 -1
- package/dist/market_adapter/lp_chart_core.js +1 -1
- package/dist/market_adapter/market_adapter.d.ts.map +1 -1
- package/dist/market_adapter/market_adapter.js +3 -2
- package/dist/market_adapter/market_adapter.js.map +1 -1
- package/dist/market_adapter/utils/data_discovery.js +2 -2
- package/dist/market_adapter/utils/data_discovery.js.map +1 -1
- package/dist/modules/account_bots.d.ts.map +1 -1
- package/dist/modules/account_bots.js +7 -17
- package/dist/modules/account_bots.js.map +1 -1
- package/dist/modules/account_orders.d.ts +8 -1
- package/dist/modules/account_orders.d.ts.map +1 -1
- package/dist/modules/account_orders.js +3 -11
- package/dist/modules/account_orders.js.map +1 -1
- package/dist/modules/authority_resolver.js +1 -1
- package/dist/modules/authority_resolver.js.map +1 -1
- package/dist/modules/bitshares-native/crypto/ecc.browser.d.ts +1 -2
- package/dist/modules/bitshares-native/crypto/ecc.browser.d.ts.map +1 -1
- package/dist/modules/bitshares-native/crypto/ecc.browser.js +19 -58
- package/dist/modules/bitshares-native/crypto/ecc.browser.js.map +1 -1
- package/dist/modules/bitshares-native/crypto/ecc.d.ts +2 -9
- package/dist/modules/bitshares-native/crypto/ecc.d.ts.map +1 -1
- package/dist/modules/bitshares-native/crypto/ecc.js +6 -145
- package/dist/modules/bitshares-native/crypto/ecc.js.map +1 -1
- package/dist/modules/bitshares-native/serial/chain_constants.d.ts +1 -17
- package/dist/modules/bitshares-native/serial/chain_constants.d.ts.map +1 -1
- package/dist/modules/bitshares-native/serial/chain_constants.js +1 -30
- package/dist/modules/bitshares-native/serial/chain_constants.js.map +1 -1
- package/dist/modules/bitshares-native/serial/types.d.ts +1 -30
- package/dist/modules/bitshares-native/serial/types.d.ts.map +1 -1
- package/dist/modules/bitshares-native/serial/types.js +1 -169
- package/dist/modules/bitshares-native/serial/types.js.map +1 -1
- package/dist/modules/bitshares-native/signing_client.js +1 -1
- package/dist/modules/bitshares-native/signing_client.js.map +1 -1
- package/dist/modules/bitshares-native/subscriptions.js +7 -7
- package/dist/modules/bitshares-native/subscriptions.js.map +1 -1
- package/dist/modules/bitshares-native/transport.js +1 -1
- package/dist/modules/bitshares-native/transport.js.map +1 -1
- package/dist/modules/bitshares-native/tx/builder.d.ts +1 -6
- package/dist/modules/bitshares-native/tx/builder.d.ts.map +1 -1
- package/dist/modules/bitshares-native/tx/builder.js +2 -11
- package/dist/modules/bitshares-native/tx/builder.js.map +1 -1
- package/dist/modules/bitshares-native/tx/tx_cache.js +1 -1
- package/dist/modules/bitshares-native/tx/tx_cache.js.map +1 -1
- package/dist/modules/bitshares_client.js +1 -1
- package/dist/modules/bitshares_client.js.map +1 -1
- package/dist/modules/bot_settings.js +1 -1
- package/dist/modules/bot_settings.js.map +1 -1
- package/dist/modules/chain_keys.d.ts +2 -2
- package/dist/modules/chain_keys.d.ts.map +1 -1
- package/dist/modules/chain_keys.js +9 -3
- package/dist/modules/chain_keys.js.map +1 -1
- package/dist/modules/chain_orders.d.ts.map +1 -1
- package/dist/modules/chain_orders.js +7 -23
- package/dist/modules/chain_orders.js.map +1 -1
- package/dist/modules/constants.js +1 -1
- package/dist/modules/constants.js.map +1 -1
- package/dist/modules/cr_planner.js +3 -3
- package/dist/modules/cr_planner.js.map +1 -1
- package/dist/modules/credential_policy.d.ts.map +1 -1
- package/dist/modules/credential_policy.js +6 -12
- package/dist/modules/credential_policy.js.map +1 -1
- package/dist/modules/credential_runtime.d.ts +0 -3
- package/dist/modules/credential_runtime.d.ts.map +1 -1
- package/dist/modules/credential_runtime.js +5 -27
- package/dist/modules/credential_runtime.js.map +1 -1
- package/dist/modules/credit_runtime.d.ts.map +1 -1
- package/dist/modules/credit_runtime.js +18 -27
- package/dist/modules/credit_runtime.js.map +1 -1
- package/dist/modules/crypto/pure_secp256k1.d.ts +4 -1
- package/dist/modules/crypto/pure_secp256k1.d.ts.map +1 -1
- package/dist/modules/crypto/pure_secp256k1.js +1 -1
- package/dist/modules/crypto/pure_secp256k1.js.map +1 -1
- package/dist/modules/crypto/sync.d.ts +0 -3
- package/dist/modules/crypto/sync.d.ts.map +1 -1
- package/dist/modules/crypto/sync.js +0 -3
- package/dist/modules/crypto/sync.js.map +1 -1
- package/dist/modules/dexbot_class.d.ts +9 -9
- package/dist/modules/dexbot_class.js +9 -9
- package/dist/modules/dexbot_cow_runtime.d.ts +3 -3
- package/dist/modules/dexbot_cow_runtime.d.ts.map +1 -1
- package/dist/modules/dexbot_cow_runtime.js +4 -9
- package/dist/modules/dexbot_cow_runtime.js.map +1 -1
- package/dist/modules/dexbot_fill_runtime.d.ts +10 -10
- package/dist/modules/dexbot_fill_runtime.js +10 -10
- package/dist/modules/dexbot_maintenance_runtime.d.ts +7 -7
- package/dist/modules/dexbot_maintenance_runtime.d.ts.map +1 -1
- package/dist/modules/dexbot_maintenance_runtime.js +16 -15
- package/dist/modules/dexbot_maintenance_runtime.js.map +1 -1
- package/dist/modules/env.d.ts +0 -1
- package/dist/modules/env.d.ts.map +1 -1
- package/dist/modules/env.js +0 -34
- package/dist/modules/env.js.map +1 -1
- package/dist/modules/graceful_shutdown.js +1 -1
- package/dist/modules/graceful_shutdown.js.map +1 -1
- package/dist/modules/key_store.js +1 -1
- package/dist/modules/key_store.js.map +1 -1
- package/dist/modules/launcher/credential_daemon.d.ts.map +1 -1
- package/dist/modules/launcher/credential_daemon.js +3 -3
- package/dist/modules/launcher/credential_daemon.js.map +1 -1
- package/dist/modules/launcher/launch_modes.d.ts +1 -2
- package/dist/modules/launcher/launch_modes.d.ts.map +1 -1
- package/dist/modules/launcher/launch_modes.js +1 -2
- package/dist/modules/launcher/launch_modes.js.map +1 -1
- package/dist/modules/launcher/market_adapter_runtime.d.ts +1 -2
- package/dist/modules/launcher/market_adapter_runtime.d.ts.map +1 -1
- package/dist/modules/launcher/market_adapter_runtime.js +1 -4
- package/dist/modules/launcher/market_adapter_runtime.js.map +1 -1
- package/dist/modules/launcher/monolithic_runtime.d.ts +1 -2
- package/dist/modules/launcher/monolithic_runtime.d.ts.map +1 -1
- package/dist/modules/launcher/monolithic_runtime.js +3 -17
- package/dist/modules/launcher/monolithic_runtime.js.map +1 -1
- package/dist/modules/launcher/runtime_entry.d.ts +1 -2
- package/dist/modules/launcher/runtime_entry.d.ts.map +1 -1
- package/dist/modules/launcher/runtime_entry.js +1 -14
- package/dist/modules/launcher/runtime_entry.js.map +1 -1
- package/dist/modules/launcher/status_reporting.d.ts +1 -3
- package/dist/modules/launcher/status_reporting.d.ts.map +1 -1
- package/dist/modules/launcher/status_reporting.js +1 -10
- package/dist/modules/launcher/status_reporting.js.map +1 -1
- package/dist/modules/node_manager.d.ts.map +1 -1
- package/dist/modules/node_manager.js +4 -3
- package/dist/modules/node_manager.js.map +1 -1
- package/dist/modules/order/export.d.ts.map +1 -1
- package/dist/modules/order/export.js +4 -3
- package/dist/modules/order/export.js.map +1 -1
- package/dist/modules/order/format.d.ts +1 -10
- package/dist/modules/order/format.d.ts.map +1 -1
- package/dist/modules/order/format.js +1 -22
- package/dist/modules/order/format.js.map +1 -1
- package/dist/modules/order/grid.d.ts +19 -19
- package/dist/modules/order/grid.d.ts.map +1 -1
- package/dist/modules/order/grid.js +25 -25
- package/dist/modules/order/grid.js.map +1 -1
- package/dist/modules/order/grid_reconcile_internal.d.ts +1 -83
- package/dist/modules/order/grid_reconcile_internal.d.ts.map +1 -1
- package/dist/modules/order/grid_reconcile_internal.js +1 -1
- package/dist/modules/order/grid_reconcile_internal.js.map +1 -1
- package/dist/modules/order/manager.d.ts +15 -15
- package/dist/modules/order/manager.js +15 -15
- package/dist/modules/order/processed_fill_store.d.ts +1 -1
- package/dist/modules/order/processed_fill_store.js +1 -1
- package/dist/modules/order/sync_engine.d.ts +4 -4
- package/dist/modules/order/sync_engine.js +4 -4
- package/dist/modules/order/utils/math.d.ts +7 -2
- package/dist/modules/order/utils/math.d.ts.map +1 -1
- package/dist/modules/order/utils/math.js +10 -3
- package/dist/modules/order/utils/math.js.map +1 -1
- package/dist/modules/order/utils/order.js +3 -3
- package/dist/modules/order/utils/order.js.map +1 -1
- package/dist/modules/order/utils/system.d.ts +17 -1
- package/dist/modules/order/utils/system.d.ts.map +1 -1
- package/dist/modules/order/utils/system.js +56 -4
- package/dist/modules/order/utils/system.js.map +1 -1
- package/dist/modules/order/utils/validate.d.ts +3 -3
- package/dist/modules/order/utils/validate.d.ts.map +1 -1
- package/dist/modules/order/utils/validate.js +5 -5
- package/dist/modules/order/utils/validate.js.map +1 -1
- package/dist/modules/order/utils/withPoolRef.js +1 -1
- package/dist/modules/order/utils/withPoolRef.js.map +1 -1
- package/dist/modules/paths.d.ts +46 -15
- package/dist/modules/paths.d.ts.map +1 -1
- package/dist/modules/paths.js +145 -33
- package/dist/modules/paths.js.map +1 -1
- package/dist/modules/runtime.d.ts +1 -0
- package/dist/modules/runtime.d.ts.map +1 -1
- package/dist/modules/runtime_settings.d.ts.map +1 -1
- package/dist/modules/runtime_settings.js +26 -30
- package/dist/modules/runtime_settings.js.map +1 -1
- package/dist/modules/settings_merge.d.ts +7 -1
- package/dist/modules/settings_merge.d.ts.map +1 -1
- package/dist/modules/settings_merge.js +10 -6
- package/dist/modules/settings_merge.js.map +1 -1
- package/dist/modules/types.d.ts +0 -753
- package/dist/modules/types.d.ts.map +1 -1
- package/dist/modules/types.js +0 -15
- package/dist/modules/types.js.map +1 -1
- package/dist/modules/utils/base58check.js +4 -4
- package/dist/modules/utils/base58check.js.map +1 -1
- package/dist/modules/validate_profiles.d.ts +1 -11
- package/dist/modules/validate_profiles.d.ts.map +1 -1
- package/dist/modules/validate_profiles.js +1 -1
- package/dist/modules/validate_profiles.js.map +1 -1
- package/dist/pm2.js +3 -3
- package/dist/pm2.js.map +1 -1
- package/dist/scripts/update.d.ts +17 -5
- package/dist/scripts/update.d.ts.map +1 -1
- package/dist/scripts/update.js +420 -172
- package/dist/scripts/update.js.map +1 -1
- package/docs/BITSHARES_ONBOARDING.md +435 -0
- package/docs/COPY_ON_WRITE_MASTER_PLAN.md +514 -0
- package/docs/COW_INVARIANTS.md +309 -0
- package/docs/CREDENTIAL_SECURITY.md +450 -0
- package/docs/DEXBOT_COMPARISON.md +922 -0
- package/docs/EVOLUTION.md +210 -0
- package/docs/FUND_MOVEMENT_AND_ACCOUNTING.md +851 -0
- package/docs/GRID_RECALCULATION.md +624 -0
- package/docs/GRID_RECONCILE.md +259 -0
- package/docs/LOGGING.md +318 -0
- package/docs/MPA_CREDIT_USAGE.md +353 -0
- package/docs/README.md +199 -0
- package/docs/WORKFLOW.md +369 -0
- package/docs/architecture.md +1466 -0
- package/docs/developer_guide.md +1929 -0
- package/docs/docker.md +141 -0
- package/market_adapter/README.md +1003 -0
- package/modules/README.md +176 -0
- package/package.json +40 -5
- package/scripts/README.md +55 -32
- package/scripts/bots +18 -0
- package/scripts/clean-dist.js +9 -0
- package/scripts/create-bot-symlinks.sh +3 -3
- package/scripts/dexbot +17 -0
- package/scripts/git-viewer.sh +489 -0
- package/scripts/keys +18 -0
- package/scripts/lib/dexbot-paths.sh +71 -20
- package/scripts/pdev.sh +38 -0
- package/scripts/pm2 +17 -0
- package/scripts/pmain.sh +45 -0
- package/scripts/ptest.sh +26 -0
- package/scripts/repo-stats.html +480 -0
- package/scripts/unlock +17 -0
- package/scripts/update.js +13 -0
- package/tests/README.md +135 -0
- package/claw/data/positions.json +0 -148036
- package/claw/node_modules/.package-lock.json +0 -935
- package/claw/node_modules/@babel/runtime/LICENSE +0 -22
- package/claw/node_modules/@babel/runtime/README.md +0 -19
- package/claw/node_modules/@babel/runtime/helpers/AwaitValue.js +0 -4
- package/claw/node_modules/@babel/runtime/helpers/OverloadYield.js +0 -4
- package/claw/node_modules/@babel/runtime/helpers/applyDecoratedDescriptor.js +0 -9
- package/claw/node_modules/@babel/runtime/helpers/applyDecs.js +0 -236
- package/claw/node_modules/@babel/runtime/helpers/applyDecs2203.js +0 -184
- package/claw/node_modules/@babel/runtime/helpers/applyDecs2203R.js +0 -191
- package/claw/node_modules/@babel/runtime/helpers/applyDecs2301.js +0 -222
- package/claw/node_modules/@babel/runtime/helpers/applyDecs2305.js +0 -133
- package/claw/node_modules/@babel/runtime/helpers/applyDecs2311.js +0 -124
- package/claw/node_modules/@babel/runtime/helpers/arrayLikeToArray.js +0 -6
- package/claw/node_modules/@babel/runtime/helpers/arrayWithHoles.js +0 -4
- package/claw/node_modules/@babel/runtime/helpers/arrayWithoutHoles.js +0 -5
- package/claw/node_modules/@babel/runtime/helpers/assertClassBrand.js +0 -5
- package/claw/node_modules/@babel/runtime/helpers/assertThisInitialized.js +0 -5
- package/claw/node_modules/@babel/runtime/helpers/asyncGeneratorDelegate.js +0 -24
- package/claw/node_modules/@babel/runtime/helpers/asyncIterator.js +0 -45
- package/claw/node_modules/@babel/runtime/helpers/asyncToGenerator.js +0 -26
- package/claw/node_modules/@babel/runtime/helpers/awaitAsyncGenerator.js +0 -5
- package/claw/node_modules/@babel/runtime/helpers/callSuper.js +0 -7
- package/claw/node_modules/@babel/runtime/helpers/checkInRHS.js +0 -6
- package/claw/node_modules/@babel/runtime/helpers/checkPrivateRedeclaration.js +0 -4
- package/claw/node_modules/@babel/runtime/helpers/classApplyDescriptorDestructureSet.js +0 -10
- package/claw/node_modules/@babel/runtime/helpers/classApplyDescriptorGet.js +0 -4
- package/claw/node_modules/@babel/runtime/helpers/classApplyDescriptorSet.js +0 -7
- package/claw/node_modules/@babel/runtime/helpers/classCallCheck.js +0 -4
- package/claw/node_modules/@babel/runtime/helpers/classCheckPrivateStaticAccess.js +0 -5
- package/claw/node_modules/@babel/runtime/helpers/classCheckPrivateStaticFieldDescriptor.js +0 -4
- package/claw/node_modules/@babel/runtime/helpers/classExtractFieldDescriptor.js +0 -5
- package/claw/node_modules/@babel/runtime/helpers/classNameTDZError.js +0 -4
- package/claw/node_modules/@babel/runtime/helpers/classPrivateFieldDestructureSet.js +0 -7
- package/claw/node_modules/@babel/runtime/helpers/classPrivateFieldGet.js +0 -7
- package/claw/node_modules/@babel/runtime/helpers/classPrivateFieldGet2.js +0 -5
- package/claw/node_modules/@babel/runtime/helpers/classPrivateFieldInitSpec.js +0 -5
- package/claw/node_modules/@babel/runtime/helpers/classPrivateFieldLooseBase.js +0 -5
- package/claw/node_modules/@babel/runtime/helpers/classPrivateFieldLooseKey.js +0 -5
- package/claw/node_modules/@babel/runtime/helpers/classPrivateFieldSet.js +0 -7
- package/claw/node_modules/@babel/runtime/helpers/classPrivateFieldSet2.js +0 -5
- package/claw/node_modules/@babel/runtime/helpers/classPrivateGetter.js +0 -5
- package/claw/node_modules/@babel/runtime/helpers/classPrivateMethodGet.js +0 -5
- package/claw/node_modules/@babel/runtime/helpers/classPrivateMethodInitSpec.js +0 -5
- package/claw/node_modules/@babel/runtime/helpers/classPrivateMethodSet.js +0 -4
- package/claw/node_modules/@babel/runtime/helpers/classPrivateSetter.js +0 -5
- package/claw/node_modules/@babel/runtime/helpers/classStaticPrivateFieldDestructureSet.js +0 -7
- package/claw/node_modules/@babel/runtime/helpers/classStaticPrivateFieldSpecGet.js +0 -7
- package/claw/node_modules/@babel/runtime/helpers/classStaticPrivateFieldSpecSet.js +0 -7
- package/claw/node_modules/@babel/runtime/helpers/classStaticPrivateMethodGet.js +0 -5
- package/claw/node_modules/@babel/runtime/helpers/classStaticPrivateMethodSet.js +0 -4
- package/claw/node_modules/@babel/runtime/helpers/construct.js +0 -10
- package/claw/node_modules/@babel/runtime/helpers/createClass.js +0 -13
- package/claw/node_modules/@babel/runtime/helpers/createForOfIteratorHelper.js +0 -50
- package/claw/node_modules/@babel/runtime/helpers/createForOfIteratorHelperLoose.js +0 -19
- package/claw/node_modules/@babel/runtime/helpers/createSuper.js +0 -16
- package/claw/node_modules/@babel/runtime/helpers/decorate.js +0 -250
- package/claw/node_modules/@babel/runtime/helpers/defaults.js +0 -9
- package/claw/node_modules/@babel/runtime/helpers/defineAccessor.js +0 -8
- package/claw/node_modules/@babel/runtime/helpers/defineEnumerableProperties.js +0 -12
- package/claw/node_modules/@babel/runtime/helpers/defineProperty.js +0 -10
- package/claw/node_modules/@babel/runtime/helpers/dispose.js +0 -28
- package/claw/node_modules/@babel/runtime/helpers/esm/AwaitValue.js +0 -4
- package/claw/node_modules/@babel/runtime/helpers/esm/OverloadYield.js +0 -4
- package/claw/node_modules/@babel/runtime/helpers/esm/applyDecoratedDescriptor.js +0 -9
- package/claw/node_modules/@babel/runtime/helpers/esm/applyDecs.js +0 -236
- package/claw/node_modules/@babel/runtime/helpers/esm/applyDecs2203.js +0 -184
- package/claw/node_modules/@babel/runtime/helpers/esm/applyDecs2203R.js +0 -191
- package/claw/node_modules/@babel/runtime/helpers/esm/applyDecs2301.js +0 -222
- package/claw/node_modules/@babel/runtime/helpers/esm/applyDecs2305.js +0 -133
- package/claw/node_modules/@babel/runtime/helpers/esm/applyDecs2311.js +0 -124
- package/claw/node_modules/@babel/runtime/helpers/esm/arrayLikeToArray.js +0 -6
- package/claw/node_modules/@babel/runtime/helpers/esm/arrayWithHoles.js +0 -4
- package/claw/node_modules/@babel/runtime/helpers/esm/arrayWithoutHoles.js +0 -5
- package/claw/node_modules/@babel/runtime/helpers/esm/assertClassBrand.js +0 -5
- package/claw/node_modules/@babel/runtime/helpers/esm/assertThisInitialized.js +0 -5
- package/claw/node_modules/@babel/runtime/helpers/esm/asyncGeneratorDelegate.js +0 -24
- package/claw/node_modules/@babel/runtime/helpers/esm/asyncIterator.js +0 -45
- package/claw/node_modules/@babel/runtime/helpers/esm/asyncToGenerator.js +0 -26
- package/claw/node_modules/@babel/runtime/helpers/esm/awaitAsyncGenerator.js +0 -5
- package/claw/node_modules/@babel/runtime/helpers/esm/callSuper.js +0 -7
- package/claw/node_modules/@babel/runtime/helpers/esm/checkInRHS.js +0 -6
- package/claw/node_modules/@babel/runtime/helpers/esm/checkPrivateRedeclaration.js +0 -4
- package/claw/node_modules/@babel/runtime/helpers/esm/classApplyDescriptorDestructureSet.js +0 -10
- package/claw/node_modules/@babel/runtime/helpers/esm/classApplyDescriptorGet.js +0 -4
- package/claw/node_modules/@babel/runtime/helpers/esm/classApplyDescriptorSet.js +0 -7
- package/claw/node_modules/@babel/runtime/helpers/esm/classCallCheck.js +0 -4
- package/claw/node_modules/@babel/runtime/helpers/esm/classCheckPrivateStaticAccess.js +0 -5
- package/claw/node_modules/@babel/runtime/helpers/esm/classCheckPrivateStaticFieldDescriptor.js +0 -4
- package/claw/node_modules/@babel/runtime/helpers/esm/classExtractFieldDescriptor.js +0 -5
- package/claw/node_modules/@babel/runtime/helpers/esm/classNameTDZError.js +0 -4
- package/claw/node_modules/@babel/runtime/helpers/esm/classPrivateFieldDestructureSet.js +0 -7
- package/claw/node_modules/@babel/runtime/helpers/esm/classPrivateFieldGet.js +0 -7
- package/claw/node_modules/@babel/runtime/helpers/esm/classPrivateFieldGet2.js +0 -5
- package/claw/node_modules/@babel/runtime/helpers/esm/classPrivateFieldInitSpec.js +0 -5
- package/claw/node_modules/@babel/runtime/helpers/esm/classPrivateFieldLooseBase.js +0 -5
- package/claw/node_modules/@babel/runtime/helpers/esm/classPrivateFieldLooseKey.js +0 -5
- package/claw/node_modules/@babel/runtime/helpers/esm/classPrivateFieldSet.js +0 -7
- package/claw/node_modules/@babel/runtime/helpers/esm/classPrivateFieldSet2.js +0 -5
- package/claw/node_modules/@babel/runtime/helpers/esm/classPrivateGetter.js +0 -5
- package/claw/node_modules/@babel/runtime/helpers/esm/classPrivateMethodGet.js +0 -5
- package/claw/node_modules/@babel/runtime/helpers/esm/classPrivateMethodInitSpec.js +0 -5
- package/claw/node_modules/@babel/runtime/helpers/esm/classPrivateMethodSet.js +0 -4
- package/claw/node_modules/@babel/runtime/helpers/esm/classPrivateSetter.js +0 -5
- package/claw/node_modules/@babel/runtime/helpers/esm/classStaticPrivateFieldDestructureSet.js +0 -7
- package/claw/node_modules/@babel/runtime/helpers/esm/classStaticPrivateFieldSpecGet.js +0 -7
- package/claw/node_modules/@babel/runtime/helpers/esm/classStaticPrivateFieldSpecSet.js +0 -7
- package/claw/node_modules/@babel/runtime/helpers/esm/classStaticPrivateMethodGet.js +0 -5
- package/claw/node_modules/@babel/runtime/helpers/esm/classStaticPrivateMethodSet.js +0 -4
- package/claw/node_modules/@babel/runtime/helpers/esm/construct.js +0 -10
- package/claw/node_modules/@babel/runtime/helpers/esm/createClass.js +0 -13
- package/claw/node_modules/@babel/runtime/helpers/esm/createForOfIteratorHelper.js +0 -50
- package/claw/node_modules/@babel/runtime/helpers/esm/createForOfIteratorHelperLoose.js +0 -19
- package/claw/node_modules/@babel/runtime/helpers/esm/createSuper.js +0 -16
- package/claw/node_modules/@babel/runtime/helpers/esm/decorate.js +0 -250
- package/claw/node_modules/@babel/runtime/helpers/esm/defaults.js +0 -9
- package/claw/node_modules/@babel/runtime/helpers/esm/defineAccessor.js +0 -8
- package/claw/node_modules/@babel/runtime/helpers/esm/defineEnumerableProperties.js +0 -12
- package/claw/node_modules/@babel/runtime/helpers/esm/defineProperty.js +0 -10
- package/claw/node_modules/@babel/runtime/helpers/esm/dispose.js +0 -28
- package/claw/node_modules/@babel/runtime/helpers/esm/extends.js +0 -10
- package/claw/node_modules/@babel/runtime/helpers/esm/get.js +0 -11
- package/claw/node_modules/@babel/runtime/helpers/esm/getPrototypeOf.js +0 -6
- package/claw/node_modules/@babel/runtime/helpers/esm/identity.js +0 -4
- package/claw/node_modules/@babel/runtime/helpers/esm/importDeferProxy.js +0 -27
- package/claw/node_modules/@babel/runtime/helpers/esm/inherits.js +0 -14
- package/claw/node_modules/@babel/runtime/helpers/esm/inheritsLoose.js +0 -5
- package/claw/node_modules/@babel/runtime/helpers/esm/initializerDefineProperty.js +0 -9
- package/claw/node_modules/@babel/runtime/helpers/esm/initializerWarningHelper.js +0 -4
- package/claw/node_modules/@babel/runtime/helpers/esm/instanceof.js +0 -4
- package/claw/node_modules/@babel/runtime/helpers/esm/interopRequireDefault.js +0 -6
- package/claw/node_modules/@babel/runtime/helpers/esm/interopRequireWildcard.js +0 -22
- package/claw/node_modules/@babel/runtime/helpers/esm/isNativeFunction.js +0 -8
- package/claw/node_modules/@babel/runtime/helpers/esm/isNativeReflectConstruct.js +0 -9
- package/claw/node_modules/@babel/runtime/helpers/esm/iterableToArray.js +0 -4
- package/claw/node_modules/@babel/runtime/helpers/esm/iterableToArrayLimit.js +0 -28
- package/claw/node_modules/@babel/runtime/helpers/esm/jsx.js +0 -22
- package/claw/node_modules/@babel/runtime/helpers/esm/maybeArrayLike.js +0 -9
- package/claw/node_modules/@babel/runtime/helpers/esm/newArrowCheck.js +0 -4
- package/claw/node_modules/@babel/runtime/helpers/esm/nonIterableRest.js +0 -4
- package/claw/node_modules/@babel/runtime/helpers/esm/nonIterableSpread.js +0 -4
- package/claw/node_modules/@babel/runtime/helpers/esm/nullishReceiverError.js +0 -4
- package/claw/node_modules/@babel/runtime/helpers/esm/objectDestructuringEmpty.js +0 -4
- package/claw/node_modules/@babel/runtime/helpers/esm/objectSpread.js +0 -14
- package/claw/node_modules/@babel/runtime/helpers/esm/objectSpread2.js +0 -23
- package/claw/node_modules/@babel/runtime/helpers/esm/objectWithoutProperties.js +0 -13
- package/claw/node_modules/@babel/runtime/helpers/esm/objectWithoutPropertiesLoose.js +0 -10
- package/claw/node_modules/@babel/runtime/helpers/esm/package.json +0 -3
- package/claw/node_modules/@babel/runtime/helpers/esm/possibleConstructorReturn.js +0 -8
- package/claw/node_modules/@babel/runtime/helpers/esm/readOnlyError.js +0 -4
- package/claw/node_modules/@babel/runtime/helpers/esm/regenerator.js +0 -89
- package/claw/node_modules/@babel/runtime/helpers/esm/regeneratorAsync.js +0 -8
- package/claw/node_modules/@babel/runtime/helpers/esm/regeneratorAsyncGen.js +0 -6
- package/claw/node_modules/@babel/runtime/helpers/esm/regeneratorAsyncIterator.js +0 -33
- package/claw/node_modules/@babel/runtime/helpers/esm/regeneratorDefine.js +0 -22
- package/claw/node_modules/@babel/runtime/helpers/esm/regeneratorKeys.js +0 -10
- package/claw/node_modules/@babel/runtime/helpers/esm/regeneratorRuntime.js +0 -77
- package/claw/node_modules/@babel/runtime/helpers/esm/regeneratorValues.js +0 -19
- package/claw/node_modules/@babel/runtime/helpers/esm/set.js +0 -22
- package/claw/node_modules/@babel/runtime/helpers/esm/setFunctionName.js +0 -12
- package/claw/node_modules/@babel/runtime/helpers/esm/setPrototypeOf.js +0 -6
- package/claw/node_modules/@babel/runtime/helpers/esm/skipFirstGeneratorNext.js +0 -7
- package/claw/node_modules/@babel/runtime/helpers/esm/slicedToArray.js +0 -8
- package/claw/node_modules/@babel/runtime/helpers/esm/superPropBase.js +0 -6
- package/claw/node_modules/@babel/runtime/helpers/esm/superPropGet.js +0 -9
- package/claw/node_modules/@babel/runtime/helpers/esm/superPropSet.js +0 -6
- package/claw/node_modules/@babel/runtime/helpers/esm/taggedTemplateLiteral.js +0 -8
- package/claw/node_modules/@babel/runtime/helpers/esm/taggedTemplateLiteralLoose.js +0 -4
- package/claw/node_modules/@babel/runtime/helpers/esm/tdz.js +0 -4
- package/claw/node_modules/@babel/runtime/helpers/esm/temporalRef.js +0 -6
- package/claw/node_modules/@babel/runtime/helpers/esm/temporalUndefined.js +0 -2
- package/claw/node_modules/@babel/runtime/helpers/esm/toArray.js +0 -8
- package/claw/node_modules/@babel/runtime/helpers/esm/toConsumableArray.js +0 -8
- package/claw/node_modules/@babel/runtime/helpers/esm/toPrimitive.js +0 -12
- package/claw/node_modules/@babel/runtime/helpers/esm/toPropertyKey.js +0 -7
- package/claw/node_modules/@babel/runtime/helpers/esm/toSetter.js +0 -10
- package/claw/node_modules/@babel/runtime/helpers/esm/tsRewriteRelativeImportExtensions.js +0 -6
- package/claw/node_modules/@babel/runtime/helpers/esm/typeof.js +0 -10
- package/claw/node_modules/@babel/runtime/helpers/esm/unsupportedIterableToArray.js +0 -9
- package/claw/node_modules/@babel/runtime/helpers/esm/using.js +0 -12
- package/claw/node_modules/@babel/runtime/helpers/esm/usingCtx.js +0 -59
- package/claw/node_modules/@babel/runtime/helpers/esm/wrapAsyncGenerator.js +0 -56
- package/claw/node_modules/@babel/runtime/helpers/esm/wrapNativeSuper.js +0 -27
- package/claw/node_modules/@babel/runtime/helpers/esm/wrapRegExp.js +0 -52
- package/claw/node_modules/@babel/runtime/helpers/esm/writeOnlyError.js +0 -4
- package/claw/node_modules/@babel/runtime/helpers/extends.js +0 -10
- package/claw/node_modules/@babel/runtime/helpers/get.js +0 -11
- package/claw/node_modules/@babel/runtime/helpers/getPrototypeOf.js +0 -6
- package/claw/node_modules/@babel/runtime/helpers/identity.js +0 -4
- package/claw/node_modules/@babel/runtime/helpers/importDeferProxy.js +0 -27
- package/claw/node_modules/@babel/runtime/helpers/inherits.js +0 -14
- package/claw/node_modules/@babel/runtime/helpers/inheritsLoose.js +0 -5
- package/claw/node_modules/@babel/runtime/helpers/initializerDefineProperty.js +0 -9
- package/claw/node_modules/@babel/runtime/helpers/initializerWarningHelper.js +0 -4
- package/claw/node_modules/@babel/runtime/helpers/instanceof.js +0 -4
- package/claw/node_modules/@babel/runtime/helpers/interopRequireDefault.js +0 -6
- package/claw/node_modules/@babel/runtime/helpers/interopRequireWildcard.js +0 -22
- package/claw/node_modules/@babel/runtime/helpers/isNativeFunction.js +0 -8
- package/claw/node_modules/@babel/runtime/helpers/isNativeReflectConstruct.js +0 -9
- package/claw/node_modules/@babel/runtime/helpers/iterableToArray.js +0 -4
- package/claw/node_modules/@babel/runtime/helpers/iterableToArrayLimit.js +0 -28
- package/claw/node_modules/@babel/runtime/helpers/jsx.js +0 -22
- package/claw/node_modules/@babel/runtime/helpers/maybeArrayLike.js +0 -9
- package/claw/node_modules/@babel/runtime/helpers/newArrowCheck.js +0 -4
- package/claw/node_modules/@babel/runtime/helpers/nonIterableRest.js +0 -4
- package/claw/node_modules/@babel/runtime/helpers/nonIterableSpread.js +0 -4
- package/claw/node_modules/@babel/runtime/helpers/nullishReceiverError.js +0 -4
- package/claw/node_modules/@babel/runtime/helpers/objectDestructuringEmpty.js +0 -4
- package/claw/node_modules/@babel/runtime/helpers/objectSpread.js +0 -14
- package/claw/node_modules/@babel/runtime/helpers/objectSpread2.js +0 -23
- package/claw/node_modules/@babel/runtime/helpers/objectWithoutProperties.js +0 -13
- package/claw/node_modules/@babel/runtime/helpers/objectWithoutPropertiesLoose.js +0 -10
- package/claw/node_modules/@babel/runtime/helpers/possibleConstructorReturn.js +0 -8
- package/claw/node_modules/@babel/runtime/helpers/readOnlyError.js +0 -4
- package/claw/node_modules/@babel/runtime/helpers/regenerator.js +0 -89
- package/claw/node_modules/@babel/runtime/helpers/regeneratorAsync.js +0 -8
- package/claw/node_modules/@babel/runtime/helpers/regeneratorAsyncGen.js +0 -6
- package/claw/node_modules/@babel/runtime/helpers/regeneratorAsyncIterator.js +0 -33
- package/claw/node_modules/@babel/runtime/helpers/regeneratorDefine.js +0 -22
- package/claw/node_modules/@babel/runtime/helpers/regeneratorKeys.js +0 -10
- package/claw/node_modules/@babel/runtime/helpers/regeneratorRuntime.js +0 -77
- package/claw/node_modules/@babel/runtime/helpers/regeneratorValues.js +0 -19
- package/claw/node_modules/@babel/runtime/helpers/set.js +0 -22
- package/claw/node_modules/@babel/runtime/helpers/setFunctionName.js +0 -12
- package/claw/node_modules/@babel/runtime/helpers/setPrototypeOf.js +0 -6
- package/claw/node_modules/@babel/runtime/helpers/skipFirstGeneratorNext.js +0 -7
- package/claw/node_modules/@babel/runtime/helpers/slicedToArray.js +0 -8
- package/claw/node_modules/@babel/runtime/helpers/superPropBase.js +0 -6
- package/claw/node_modules/@babel/runtime/helpers/superPropGet.js +0 -9
- package/claw/node_modules/@babel/runtime/helpers/superPropSet.js +0 -6
- package/claw/node_modules/@babel/runtime/helpers/taggedTemplateLiteral.js +0 -8
- package/claw/node_modules/@babel/runtime/helpers/taggedTemplateLiteralLoose.js +0 -4
- package/claw/node_modules/@babel/runtime/helpers/tdz.js +0 -4
- package/claw/node_modules/@babel/runtime/helpers/temporalRef.js +0 -6
- package/claw/node_modules/@babel/runtime/helpers/temporalUndefined.js +0 -2
- package/claw/node_modules/@babel/runtime/helpers/toArray.js +0 -8
- package/claw/node_modules/@babel/runtime/helpers/toConsumableArray.js +0 -8
- package/claw/node_modules/@babel/runtime/helpers/toPrimitive.js +0 -12
- package/claw/node_modules/@babel/runtime/helpers/toPropertyKey.js +0 -7
- package/claw/node_modules/@babel/runtime/helpers/toSetter.js +0 -10
- package/claw/node_modules/@babel/runtime/helpers/tsRewriteRelativeImportExtensions.js +0 -6
- package/claw/node_modules/@babel/runtime/helpers/typeof.js +0 -10
- package/claw/node_modules/@babel/runtime/helpers/unsupportedIterableToArray.js +0 -9
- package/claw/node_modules/@babel/runtime/helpers/using.js +0 -12
- package/claw/node_modules/@babel/runtime/helpers/usingCtx.js +0 -59
- package/claw/node_modules/@babel/runtime/helpers/wrapAsyncGenerator.js +0 -56
- package/claw/node_modules/@babel/runtime/helpers/wrapNativeSuper.js +0 -27
- package/claw/node_modules/@babel/runtime/helpers/wrapRegExp.js +0 -52
- package/claw/node_modules/@babel/runtime/helpers/writeOnlyError.js +0 -4
- package/claw/node_modules/@babel/runtime/package.json +0 -1107
- package/claw/node_modules/@babel/runtime/regenerator/index.js +0 -15
- package/claw/node_modules/assert/.github/FUNDING.yml +0 -12
- package/claw/node_modules/assert/.github/SECURITY.md +0 -10
- package/claw/node_modules/assert/.travis.yml +0 -30
- package/claw/node_modules/assert/.zuul.yml +0 -13
- package/claw/node_modules/assert/CHANGELOG.md +0 -11
- package/claw/node_modules/assert/LICENSE +0 -18
- package/claw/node_modules/assert/README.md +0 -105
- package/claw/node_modules/assert/assert.js +0 -506
- package/claw/node_modules/assert/package.json +0 -32
- package/claw/node_modules/assert/test.js +0 -360
- package/claw/node_modules/async-limiter/.eslintignore +0 -2
- package/claw/node_modules/async-limiter/.nycrc +0 -10
- package/claw/node_modules/async-limiter/.travis.yml +0 -9
- package/claw/node_modules/async-limiter/LICENSE +0 -8
- package/claw/node_modules/async-limiter/index.js +0 -67
- package/claw/node_modules/async-limiter/package.json +0 -35
- package/claw/node_modules/async-limiter/readme.md +0 -132
- package/claw/node_modules/available-typed-arrays/.eslintrc +0 -5
- package/claw/node_modules/available-typed-arrays/.github/FUNDING.yml +0 -12
- package/claw/node_modules/available-typed-arrays/.nycrc +0 -9
- package/claw/node_modules/available-typed-arrays/CHANGELOG.md +0 -100
- package/claw/node_modules/available-typed-arrays/LICENSE +0 -21
- package/claw/node_modules/available-typed-arrays/README.md +0 -55
- package/claw/node_modules/available-typed-arrays/index.d.ts +0 -8
- package/claw/node_modules/available-typed-arrays/index.js +0 -17
- package/claw/node_modules/available-typed-arrays/package.json +0 -93
- package/claw/node_modules/available-typed-arrays/test/index.js +0 -18
- package/claw/node_modules/available-typed-arrays/tsconfig.json +0 -49
- package/claw/node_modules/base-x/LICENSE.md +0 -22
- package/claw/node_modules/base-x/README.md +0 -67
- package/claw/node_modules/base-x/package.json +0 -49
- package/claw/node_modules/base-x/src/index.d.ts +0 -10
- package/claw/node_modules/base-x/src/index.js +0 -123
- package/claw/node_modules/bigi/CHANGELOG.md +0 -85
- package/claw/node_modules/bigi/LICENSE.md +0 -30
- package/claw/node_modules/bigi/README.md +0 -14
- package/claw/node_modules/bigi/lib/bigi.js +0 -1509
- package/claw/node_modules/bigi/lib/convert.js +0 -91
- package/claw/node_modules/bigi/lib/index.js +0 -6
- package/claw/node_modules/bigi/package.json +0 -55
- package/claw/node_modules/bignumber.js/CHANGELOG.md +0 -222
- package/claw/node_modules/bignumber.js/LICENCE +0 -23
- package/claw/node_modules/bignumber.js/README.md +0 -266
- package/claw/node_modules/bignumber.js/bignumber.d.ts +0 -1797
- package/claw/node_modules/bignumber.js/bignumber.js +0 -2814
- package/claw/node_modules/bignumber.js/bignumber.js.map +0 -1
- package/claw/node_modules/bignumber.js/bignumber.min.js +0 -3
- package/claw/node_modules/bignumber.js/bignumber.mjs +0 -2793
- package/claw/node_modules/bignumber.js/bower.json +0 -36
- package/claw/node_modules/bignumber.js/doc/API.html +0 -2118
- package/claw/node_modules/bignumber.js/package.json +0 -39
- package/claw/node_modules/bs58/CHANGELOG.md +0 -61
- package/claw/node_modules/bs58/README.md +0 -71
- package/claw/node_modules/bs58/index.js +0 -4
- package/claw/node_modules/bs58/package.json +0 -37
- package/claw/node_modules/btsdex/.babelrc +0 -17
- package/claw/node_modules/btsdex/.github/workflows/check-style.yml +0 -16
- package/claw/node_modules/btsdex/LICENSE +0 -21
- package/claw/node_modules/btsdex/README.md +0 -467
- package/claw/node_modules/btsdex/cli.js +0 -165
- package/claw/node_modules/btsdex/lib/account.js +0 -60
- package/claw/node_modules/btsdex/lib/asset.js +0 -78
- package/claw/node_modules/btsdex/lib/bitshares.js +0 -363
- package/claw/node_modules/btsdex/lib/event.js +0 -137
- package/claw/node_modules/btsdex/lib/fees.js +0 -34
- package/claw/node_modules/btsdex/lib/index.js +0 -3
- package/claw/node_modules/btsdex/lib/transaction/TransactionBuilder.js +0 -797
- package/claw/node_modules/btsdex/lib/transaction/index.js +0 -64
- package/claw/node_modules/btsdex/package.json +0 -54
- package/claw/node_modules/btsdex/yarn-error.log +0 -3483
- package/claw/node_modules/btsdex-api/.babelrc +0 -14
- package/claw/node_modules/btsdex-api/README.md +0 -3
- package/claw/node_modules/btsdex-api/lib/apis.js +0 -59
- package/claw/node_modules/btsdex-api/lib/config.js +0 -39
- package/claw/node_modules/btsdex-api/lib/connection.js +0 -188
- package/claw/node_modules/btsdex-api/lib/index.js +0 -86
- package/claw/node_modules/btsdex-api/lib/logger.js +0 -45
- package/claw/node_modules/btsdex-api/lib/servers.js +0 -30
- package/claw/node_modules/btsdex-api/package.json +0 -29
- package/claw/node_modules/btsdex-ecc/.babelrc +0 -13
- package/claw/node_modules/btsdex-ecc/lib/BrainKey.js +0 -15
- package/claw/node_modules/btsdex-ecc/lib/KeyUtils.js +0 -205
- package/claw/node_modules/btsdex-ecc/lib/PrivateKey.js +0 -198
- package/claw/node_modules/btsdex-ecc/lib/PublicKey.js +0 -197
- package/claw/node_modules/btsdex-ecc/lib/address.js +0 -84
- package/claw/node_modules/btsdex-ecc/lib/addressPrefix.js +0 -15
- package/claw/node_modules/btsdex-ecc/lib/aes.js +0 -294
- package/claw/node_modules/btsdex-ecc/lib/ecdsa.js +0 -194
- package/claw/node_modules/btsdex-ecc/lib/ecsignature.js +0 -131
- package/claw/node_modules/btsdex-ecc/lib/enforce_types.js +0 -54
- package/claw/node_modules/btsdex-ecc/lib/hash.js +0 -60
- package/claw/node_modules/btsdex-ecc/lib/index.js +0 -84
- package/claw/node_modules/btsdex-ecc/lib/signature.js +0 -185
- package/claw/node_modules/btsdex-ecc/package.json +0 -37
- package/claw/node_modules/btsdex-serializer/.babelrc +0 -13
- package/claw/node_modules/btsdex-serializer/lib/ChainTypes.js +0 -154
- package/claw/node_modules/btsdex-serializer/lib/FastParser.js +0 -75
- package/claw/node_modules/btsdex-serializer/lib/ObjectId.js +0 -65
- package/claw/node_modules/btsdex-serializer/lib/SerializerValidation.js +0 -377
- package/claw/node_modules/btsdex-serializer/lib/convert.js +0 -54
- package/claw/node_modules/btsdex-serializer/lib/error_with_cause.js +0 -43
- package/claw/node_modules/btsdex-serializer/lib/index.js +0 -72
- package/claw/node_modules/btsdex-serializer/lib/operations.js +0 -1359
- package/claw/node_modules/btsdex-serializer/lib/precision.js +0 -108
- package/claw/node_modules/btsdex-serializer/lib/serializer.js +0 -205
- package/claw/node_modules/btsdex-serializer/lib/template.js +0 -23
- package/claw/node_modules/btsdex-serializer/lib/types.js +0 -1209
- package/claw/node_modules/btsdex-serializer/package-lock.json +0 -238
- package/claw/node_modules/btsdex-serializer/package.json +0 -32
- package/claw/node_modules/bytebuffer/.travis.yml +0 -5
- package/claw/node_modules/bytebuffer/LICENSE +0 -202
- package/claw/node_modules/bytebuffer/README.md +0 -64
- package/claw/node_modules/bytebuffer/bower.json +0 -12
- package/claw/node_modules/bytebuffer/bytebuffer.png +0 -0
- package/claw/node_modules/bytebuffer/dist/README.md +0 -47
- package/claw/node_modules/bytebuffer/dist/bytebuffer-dataview.js +0 -3461
- package/claw/node_modules/bytebuffer/dist/bytebuffer-dataview.min.js +0 -88
- package/claw/node_modules/bytebuffer/dist/bytebuffer-dataview.min.js.gz +0 -0
- package/claw/node_modules/bytebuffer/dist/bytebuffer-dataview.min.map +0 -8
- package/claw/node_modules/bytebuffer/dist/bytebuffer-node.js +0 -3454
- package/claw/node_modules/bytebuffer/dist/bytebuffer.js +0 -3746
- package/claw/node_modules/bytebuffer/dist/bytebuffer.min.js +0 -93
- package/claw/node_modules/bytebuffer/dist/bytebuffer.min.js.gz +0 -0
- package/claw/node_modules/bytebuffer/dist/bytebuffer.min.map +0 -8
- package/claw/node_modules/bytebuffer/donate.png +0 -0
- package/claw/node_modules/bytebuffer/externs/bytebuffer.js +0 -862
- package/claw/node_modules/bytebuffer/externs/minimal-env.js +0 -52
- package/claw/node_modules/bytebuffer/index.js +0 -1
- package/claw/node_modules/bytebuffer/jsdoc.json +0 -13
- package/claw/node_modules/bytebuffer/package.json +0 -51
- package/claw/node_modules/bytebuffer/scripts/build.js +0 -113
- package/claw/node_modules/bytebuffer/src/bower.json +0 -12
- package/claw/node_modules/bytebuffer/src/bytebuffer.js +0 -220
- package/claw/node_modules/bytebuffer/src/encodings/base64.js +0 -88
- package/claw/node_modules/bytebuffer/src/encodings/binary.js +0 -74
- package/claw/node_modules/bytebuffer/src/encodings/debug.js +0 -211
- package/claw/node_modules/bytebuffer/src/encodings/hex.js +0 -75
- package/claw/node_modules/bytebuffer/src/encodings/impl/base64.js +0 -3
- package/claw/node_modules/bytebuffer/src/encodings/impl/binary.js +0 -65
- package/claw/node_modules/bytebuffer/src/encodings/impl/debug.js +0 -3
- package/claw/node_modules/bytebuffer/src/encodings/impl/hex.js +0 -101
- package/claw/node_modules/bytebuffer/src/encodings/impl/utf8.js +0 -126
- package/claw/node_modules/bytebuffer/src/encodings/utf8.js +0 -71
- package/claw/node_modules/bytebuffer/src/helpers.js +0 -143
- package/claw/node_modules/bytebuffer/src/macros.js +0 -222
- package/claw/node_modules/bytebuffer/src/methods/append.js +0 -58
- package/claw/node_modules/bytebuffer/src/methods/assert.js +0 -12
- package/claw/node_modules/bytebuffer/src/methods/capacity.js +0 -8
- package/claw/node_modules/bytebuffer/src/methods/clear.js +0 -13
- package/claw/node_modules/bytebuffer/src/methods/clone.js +0 -34
- package/claw/node_modules/bytebuffer/src/methods/compact.js +0 -49
- package/claw/node_modules/bytebuffer/src/methods/copy.js +0 -73
- package/claw/node_modules/bytebuffer/src/methods/ensureCapacity.js +0 -15
- package/claw/node_modules/bytebuffer/src/methods/fill.js +0 -35
- package/claw/node_modules/bytebuffer/src/methods/flip.js +0 -11
- package/claw/node_modules/bytebuffer/src/methods/mark.js +0 -17
- package/claw/node_modules/bytebuffer/src/methods/order.js +0 -36
- package/claw/node_modules/bytebuffer/src/methods/prepend.js +0 -87
- package/claw/node_modules/bytebuffer/src/methods/printDebug.js +0 -16
- package/claw/node_modules/bytebuffer/src/methods/remaining.js +0 -9
- package/claw/node_modules/bytebuffer/src/methods/reset.js +0 -17
- package/claw/node_modules/bytebuffer/src/methods/resize.js +0 -39
- package/claw/node_modules/bytebuffer/src/methods/reverse.js +0 -25
- package/claw/node_modules/bytebuffer/src/methods/skip.js +0 -19
- package/claw/node_modules/bytebuffer/src/methods/slice.js +0 -18
- package/claw/node_modules/bytebuffer/src/methods/static/accessor.js +0 -13
- package/claw/node_modules/bytebuffer/src/methods/static/allocate.js +0 -14
- package/claw/node_modules/bytebuffer/src/methods/static/concat.js +0 -55
- package/claw/node_modules/bytebuffer/src/methods/static/isByteBuffer.js +0 -9
- package/claw/node_modules/bytebuffer/src/methods/static/type.js +0 -11
- package/claw/node_modules/bytebuffer/src/methods/static/wrap.js +0 -125
- package/claw/node_modules/bytebuffer/src/methods/toBuffer.js +0 -77
- package/claw/node_modules/bytebuffer/src/methods/toString.js +0 -43
- package/claw/node_modules/bytebuffer/src/types/bytes/bitset.js +0 -89
- package/claw/node_modules/bytebuffer/src/types/bytes/bytes.js +0 -34
- package/claw/node_modules/bytebuffer/src/types/floats/float32.js +0 -81
- package/claw/node_modules/bytebuffer/src/types/floats/float64.js +0 -77
- package/claw/node_modules/bytebuffer/src/types/floats/ieee754.js +0 -130
- package/claw/node_modules/bytebuffer/src/types/ints/int16.js +0 -167
- package/claw/node_modules/bytebuffer/src/types/ints/int32.js +0 -125
- package/claw/node_modules/bytebuffer/src/types/ints/int64.js +0 -194
- package/claw/node_modules/bytebuffer/src/types/ints/int8.js +0 -137
- package/claw/node_modules/bytebuffer/src/types/strings/cstring.js +0 -110
- package/claw/node_modules/bytebuffer/src/types/strings/istring.js +0 -81
- package/claw/node_modules/bytebuffer/src/types/strings/utf8string.js +0 -214
- package/claw/node_modules/bytebuffer/src/types/strings/vstring.js +0 -78
- package/claw/node_modules/bytebuffer/src/types/varints/varint32.js +0 -164
- package/claw/node_modules/bytebuffer/src/types/varints/varint64.js +0 -208
- package/claw/node_modules/bytebuffer/src/wrap-node.js +0 -50
- package/claw/node_modules/bytebuffer/src/wrap.js +0 -43
- package/claw/node_modules/bytebuffer/tests/bench.js +0 -99
- package/claw/node_modules/bytebuffer/tests/suite.js +0 -1005
- package/claw/node_modules/call-bind/.eslintignore +0 -1
- package/claw/node_modules/call-bind/.eslintrc +0 -16
- package/claw/node_modules/call-bind/.github/FUNDING.yml +0 -12
- package/claw/node_modules/call-bind/.nycrc +0 -9
- package/claw/node_modules/call-bind/CHANGELOG.md +0 -106
- package/claw/node_modules/call-bind/LICENSE +0 -21
- package/claw/node_modules/call-bind/README.md +0 -64
- package/claw/node_modules/call-bind/callBound.js +0 -15
- package/claw/node_modules/call-bind/index.js +0 -24
- package/claw/node_modules/call-bind/package.json +0 -93
- package/claw/node_modules/call-bind/test/callBound.js +0 -54
- package/claw/node_modules/call-bind/test/index.js +0 -74
- package/claw/node_modules/call-bind-apply-helpers/.eslintrc +0 -17
- package/claw/node_modules/call-bind-apply-helpers/.github/FUNDING.yml +0 -12
- package/claw/node_modules/call-bind-apply-helpers/.nycrc +0 -9
- package/claw/node_modules/call-bind-apply-helpers/CHANGELOG.md +0 -30
- package/claw/node_modules/call-bind-apply-helpers/LICENSE +0 -21
- package/claw/node_modules/call-bind-apply-helpers/README.md +0 -62
- package/claw/node_modules/call-bind-apply-helpers/actualApply.d.ts +0 -1
- package/claw/node_modules/call-bind-apply-helpers/actualApply.js +0 -10
- package/claw/node_modules/call-bind-apply-helpers/applyBind.d.ts +0 -19
- package/claw/node_modules/call-bind-apply-helpers/applyBind.js +0 -10
- package/claw/node_modules/call-bind-apply-helpers/functionApply.d.ts +0 -1
- package/claw/node_modules/call-bind-apply-helpers/functionApply.js +0 -4
- package/claw/node_modules/call-bind-apply-helpers/functionCall.d.ts +0 -1
- package/claw/node_modules/call-bind-apply-helpers/functionCall.js +0 -4
- package/claw/node_modules/call-bind-apply-helpers/index.d.ts +0 -64
- package/claw/node_modules/call-bind-apply-helpers/index.js +0 -15
- package/claw/node_modules/call-bind-apply-helpers/package.json +0 -85
- package/claw/node_modules/call-bind-apply-helpers/reflectApply.d.ts +0 -3
- package/claw/node_modules/call-bind-apply-helpers/reflectApply.js +0 -4
- package/claw/node_modules/call-bind-apply-helpers/test/index.js +0 -63
- package/claw/node_modules/call-bind-apply-helpers/tsconfig.json +0 -9
- package/claw/node_modules/call-bound/.eslintrc +0 -13
- package/claw/node_modules/call-bound/.github/FUNDING.yml +0 -12
- package/claw/node_modules/call-bound/.nycrc +0 -9
- package/claw/node_modules/call-bound/CHANGELOG.md +0 -42
- package/claw/node_modules/call-bound/LICENSE +0 -21
- package/claw/node_modules/call-bound/README.md +0 -53
- package/claw/node_modules/call-bound/index.d.ts +0 -94
- package/claw/node_modules/call-bound/index.js +0 -19
- package/claw/node_modules/call-bound/package.json +0 -99
- package/claw/node_modules/call-bound/test/index.js +0 -61
- package/claw/node_modules/call-bound/tsconfig.json +0 -10
- package/claw/node_modules/cipher-base/.eslintrc +0 -26
- package/claw/node_modules/cipher-base/.github/FUNDING.yml +0 -12
- package/claw/node_modules/cipher-base/CHANGELOG.md +0 -73
- package/claw/node_modules/cipher-base/LICENSE +0 -21
- package/claw/node_modules/cipher-base/README.md +0 -17
- package/claw/node_modules/cipher-base/index.js +0 -103
- package/claw/node_modules/cipher-base/package.json +0 -63
- package/claw/node_modules/cipher-base/test/index.js +0 -221
- package/claw/node_modules/core-util-is/LICENSE +0 -19
- package/claw/node_modules/core-util-is/README.md +0 -3
- package/claw/node_modules/core-util-is/lib/util.js +0 -107
- package/claw/node_modules/core-util-is/package.json +0 -38
- package/claw/node_modules/create-hash/.travis.yml +0 -17
- package/claw/node_modules/create-hash/LICENSE +0 -21
- package/claw/node_modules/create-hash/README.md +0 -19
- package/claw/node_modules/create-hash/browser.js +0 -30
- package/claw/node_modules/create-hash/index.js +0 -1
- package/claw/node_modules/create-hash/md5.js +0 -5
- package/claw/node_modules/create-hash/package.json +0 -39
- package/claw/node_modules/create-hash/test.js +0 -41
- package/claw/node_modules/create-hmac/LICENSE +0 -21
- package/claw/node_modules/create-hmac/README.md +0 -20
- package/claw/node_modules/create-hmac/browser.js +0 -62
- package/claw/node_modules/create-hmac/index.js +0 -1
- package/claw/node_modules/create-hmac/legacy.js +0 -46
- package/claw/node_modules/create-hmac/package.json +0 -45
- package/claw/node_modules/crypto-js/CONTRIBUTING.md +0 -28
- package/claw/node_modules/crypto-js/LICENSE +0 -24
- package/claw/node_modules/crypto-js/README.md +0 -241
- package/claw/node_modules/crypto-js/aes.js +0 -232
- package/claw/node_modules/crypto-js/bower.json +0 -35
- package/claw/node_modules/crypto-js/cipher-core.js +0 -880
- package/claw/node_modules/crypto-js/core.js +0 -760
- package/claw/node_modules/crypto-js/crypto-js.js +0 -5988
- package/claw/node_modules/crypto-js/docs/QuickStartGuide.wiki +0 -470
- package/claw/node_modules/crypto-js/enc-base64.js +0 -135
- package/claw/node_modules/crypto-js/enc-hex.js +0 -18
- package/claw/node_modules/crypto-js/enc-latin1.js +0 -18
- package/claw/node_modules/crypto-js/enc-utf16.js +0 -149
- package/claw/node_modules/crypto-js/enc-utf8.js +0 -18
- package/claw/node_modules/crypto-js/evpkdf.js +0 -132
- package/claw/node_modules/crypto-js/format-hex.js +0 -66
- package/claw/node_modules/crypto-js/format-openssl.js +0 -18
- package/claw/node_modules/crypto-js/hmac-md5.js +0 -18
- package/claw/node_modules/crypto-js/hmac-ripemd160.js +0 -18
- package/claw/node_modules/crypto-js/hmac-sha1.js +0 -18
- package/claw/node_modules/crypto-js/hmac-sha224.js +0 -18
- package/claw/node_modules/crypto-js/hmac-sha256.js +0 -18
- package/claw/node_modules/crypto-js/hmac-sha3.js +0 -18
- package/claw/node_modules/crypto-js/hmac-sha384.js +0 -18
- package/claw/node_modules/crypto-js/hmac-sha512.js +0 -18
- package/claw/node_modules/crypto-js/hmac.js +0 -143
- package/claw/node_modules/crypto-js/index.js +0 -18
- package/claw/node_modules/crypto-js/lib-typedarrays.js +0 -76
- package/claw/node_modules/crypto-js/md5.js +0 -268
- package/claw/node_modules/crypto-js/mode-cfb.js +0 -78
- package/claw/node_modules/crypto-js/mode-ctr-gladman.js +0 -116
- package/claw/node_modules/crypto-js/mode-ctr.js +0 -58
- package/claw/node_modules/crypto-js/mode-ecb.js +0 -40
- package/claw/node_modules/crypto-js/mode-ofb.js +0 -54
- package/claw/node_modules/crypto-js/package.json +0 -38
- package/claw/node_modules/crypto-js/pad-ansix923.js +0 -49
- package/claw/node_modules/crypto-js/pad-iso10126.js +0 -44
- package/claw/node_modules/crypto-js/pad-iso97971.js +0 -40
- package/claw/node_modules/crypto-js/pad-nopadding.js +0 -30
- package/claw/node_modules/crypto-js/pad-pkcs7.js +0 -18
- package/claw/node_modules/crypto-js/pad-zeropadding.js +0 -45
- package/claw/node_modules/crypto-js/pbkdf2.js +0 -145
- package/claw/node_modules/crypto-js/rabbit-legacy.js +0 -190
- package/claw/node_modules/crypto-js/rabbit.js +0 -192
- package/claw/node_modules/crypto-js/rc4.js +0 -139
- package/claw/node_modules/crypto-js/ripemd160.js +0 -267
- package/claw/node_modules/crypto-js/sha1.js +0 -150
- package/claw/node_modules/crypto-js/sha224.js +0 -80
- package/claw/node_modules/crypto-js/sha256.js +0 -199
- package/claw/node_modules/crypto-js/sha3.js +0 -323
- package/claw/node_modules/crypto-js/sha384.js +0 -83
- package/claw/node_modules/crypto-js/sha512.js +0 -323
- package/claw/node_modules/crypto-js/tripledes.js +0 -770
- package/claw/node_modules/crypto-js/x64-core.js +0 -304
- package/claw/node_modules/deep-equal/.editorconfig +0 -20
- package/claw/node_modules/deep-equal/.eslintrc +0 -28
- package/claw/node_modules/deep-equal/.nycrc +0 -17
- package/claw/node_modules/deep-equal/.travis.yml +0 -12
- package/claw/node_modules/deep-equal/CHANGELOG.md +0 -320
- package/claw/node_modules/deep-equal/LICENSE +0 -21
- package/claw/node_modules/deep-equal/assert.js +0 -3
- package/claw/node_modules/deep-equal/example/cmp.js +0 -11
- package/claw/node_modules/deep-equal/index.js +0 -112
- package/claw/node_modules/deep-equal/lib/is_arguments.js +0 -1
- package/claw/node_modules/deep-equal/lib/keys.js +0 -1
- package/claw/node_modules/deep-equal/package.json +0 -109
- package/claw/node_modules/deep-equal/readme.markdown +0 -73
- package/claw/node_modules/deep-equal/test/_tape.js +0 -42
- package/claw/node_modules/deep-equal/test/cmp.js +0 -1343
- package/claw/node_modules/define-data-property/.eslintrc +0 -24
- package/claw/node_modules/define-data-property/.github/FUNDING.yml +0 -12
- package/claw/node_modules/define-data-property/.nycrc +0 -13
- package/claw/node_modules/define-data-property/CHANGELOG.md +0 -70
- package/claw/node_modules/define-data-property/LICENSE +0 -21
- package/claw/node_modules/define-data-property/README.md +0 -67
- package/claw/node_modules/define-data-property/index.d.ts +0 -12
- package/claw/node_modules/define-data-property/index.js +0 -56
- package/claw/node_modules/define-data-property/package.json +0 -106
- package/claw/node_modules/define-data-property/test/index.js +0 -392
- package/claw/node_modules/define-data-property/tsconfig.json +0 -59
- package/claw/node_modules/define-properties/.editorconfig +0 -13
- package/claw/node_modules/define-properties/.eslintrc +0 -19
- package/claw/node_modules/define-properties/.github/FUNDING.yml +0 -12
- package/claw/node_modules/define-properties/.nycrc +0 -9
- package/claw/node_modules/define-properties/CHANGELOG.md +0 -91
- package/claw/node_modules/define-properties/LICENSE +0 -21
- package/claw/node_modules/define-properties/README.md +0 -84
- package/claw/node_modules/define-properties/index.js +0 -47
- package/claw/node_modules/define-properties/package.json +0 -88
- package/claw/node_modules/dunder-proto/.eslintrc +0 -5
- package/claw/node_modules/dunder-proto/.github/FUNDING.yml +0 -12
- package/claw/node_modules/dunder-proto/.nycrc +0 -13
- package/claw/node_modules/dunder-proto/CHANGELOG.md +0 -24
- package/claw/node_modules/dunder-proto/LICENSE +0 -21
- package/claw/node_modules/dunder-proto/README.md +0 -54
- package/claw/node_modules/dunder-proto/get.d.ts +0 -5
- package/claw/node_modules/dunder-proto/get.js +0 -30
- package/claw/node_modules/dunder-proto/package.json +0 -76
- package/claw/node_modules/dunder-proto/set.d.ts +0 -5
- package/claw/node_modules/dunder-proto/set.js +0 -35
- package/claw/node_modules/dunder-proto/test/get.js +0 -34
- package/claw/node_modules/dunder-proto/test/index.js +0 -4
- package/claw/node_modules/dunder-proto/test/set.js +0 -50
- package/claw/node_modules/dunder-proto/tsconfig.json +0 -9
- package/claw/node_modules/ecurve/.min-wd +0 -7
- package/claw/node_modules/ecurve/.travis.yml +0 -14
- package/claw/node_modules/ecurve/CHANGELOG.md +0 -154
- package/claw/node_modules/ecurve/README.md +0 -11
- package/claw/node_modules/ecurve/lib/curve.js +0 -77
- package/claw/node_modules/ecurve/lib/curves.json +0 -65
- package/claw/node_modules/ecurve/lib/index.js +0 -10
- package/claw/node_modules/ecurve/lib/names.js +0 -21
- package/claw/node_modules/ecurve/lib/point.js +0 -244
- package/claw/node_modules/ecurve/package.json +0 -32
- package/claw/node_modules/es-define-property/.eslintrc +0 -13
- package/claw/node_modules/es-define-property/.github/FUNDING.yml +0 -12
- package/claw/node_modules/es-define-property/.nycrc +0 -9
- package/claw/node_modules/es-define-property/CHANGELOG.md +0 -29
- package/claw/node_modules/es-define-property/LICENSE +0 -21
- package/claw/node_modules/es-define-property/README.md +0 -49
- package/claw/node_modules/es-define-property/index.d.ts +0 -3
- package/claw/node_modules/es-define-property/index.js +0 -14
- package/claw/node_modules/es-define-property/package.json +0 -81
- package/claw/node_modules/es-define-property/test/index.js +0 -56
- package/claw/node_modules/es-define-property/tsconfig.json +0 -10
- package/claw/node_modules/es-errors/.eslintrc +0 -5
- package/claw/node_modules/es-errors/.github/FUNDING.yml +0 -12
- package/claw/node_modules/es-errors/CHANGELOG.md +0 -40
- package/claw/node_modules/es-errors/LICENSE +0 -21
- package/claw/node_modules/es-errors/README.md +0 -55
- package/claw/node_modules/es-errors/eval.d.ts +0 -3
- package/claw/node_modules/es-errors/eval.js +0 -4
- package/claw/node_modules/es-errors/index.d.ts +0 -3
- package/claw/node_modules/es-errors/index.js +0 -4
- package/claw/node_modules/es-errors/package.json +0 -80
- package/claw/node_modules/es-errors/range.d.ts +0 -3
- package/claw/node_modules/es-errors/range.js +0 -4
- package/claw/node_modules/es-errors/ref.d.ts +0 -3
- package/claw/node_modules/es-errors/ref.js +0 -4
- package/claw/node_modules/es-errors/syntax.d.ts +0 -3
- package/claw/node_modules/es-errors/syntax.js +0 -4
- package/claw/node_modules/es-errors/test/index.js +0 -19
- package/claw/node_modules/es-errors/tsconfig.json +0 -49
- package/claw/node_modules/es-errors/type.d.ts +0 -3
- package/claw/node_modules/es-errors/type.js +0 -4
- package/claw/node_modules/es-errors/uri.d.ts +0 -3
- package/claw/node_modules/es-errors/uri.js +0 -4
- package/claw/node_modules/es-object-atoms/.eslintrc +0 -16
- package/claw/node_modules/es-object-atoms/.github/FUNDING.yml +0 -12
- package/claw/node_modules/es-object-atoms/CHANGELOG.md +0 -37
- package/claw/node_modules/es-object-atoms/LICENSE +0 -21
- package/claw/node_modules/es-object-atoms/README.md +0 -63
- package/claw/node_modules/es-object-atoms/RequireObjectCoercible.d.ts +0 -3
- package/claw/node_modules/es-object-atoms/RequireObjectCoercible.js +0 -11
- package/claw/node_modules/es-object-atoms/ToObject.d.ts +0 -7
- package/claw/node_modules/es-object-atoms/ToObject.js +0 -10
- package/claw/node_modules/es-object-atoms/index.d.ts +0 -3
- package/claw/node_modules/es-object-atoms/index.js +0 -4
- package/claw/node_modules/es-object-atoms/isObject.d.ts +0 -3
- package/claw/node_modules/es-object-atoms/isObject.js +0 -6
- package/claw/node_modules/es-object-atoms/package.json +0 -80
- package/claw/node_modules/es-object-atoms/test/index.js +0 -38
- package/claw/node_modules/es-object-atoms/tsconfig.json +0 -6
- package/claw/node_modules/for-each/.editorconfig +0 -20
- package/claw/node_modules/for-each/.eslintrc +0 -30
- package/claw/node_modules/for-each/.github/FUNDING.yml +0 -12
- package/claw/node_modules/for-each/.github/SECURITY.md +0 -3
- package/claw/node_modules/for-each/.nycrc +0 -8
- package/claw/node_modules/for-each/CHANGELOG.md +0 -107
- package/claw/node_modules/for-each/LICENSE +0 -22
- package/claw/node_modules/for-each/README.md +0 -39
- package/claw/node_modules/for-each/index.d.ts +0 -35
- package/claw/node_modules/for-each/index.js +0 -69
- package/claw/node_modules/for-each/package.json +0 -76
- package/claw/node_modules/for-each/test/test.js +0 -224
- package/claw/node_modules/for-each/tsconfig.json +0 -8
- package/claw/node_modules/function-bind/.eslintrc +0 -21
- package/claw/node_modules/function-bind/.github/FUNDING.yml +0 -12
- package/claw/node_modules/function-bind/.github/SECURITY.md +0 -3
- package/claw/node_modules/function-bind/.nycrc +0 -13
- package/claw/node_modules/function-bind/CHANGELOG.md +0 -136
- package/claw/node_modules/function-bind/LICENSE +0 -20
- package/claw/node_modules/function-bind/README.md +0 -46
- package/claw/node_modules/function-bind/implementation.js +0 -84
- package/claw/node_modules/function-bind/index.js +0 -5
- package/claw/node_modules/function-bind/package.json +0 -87
- package/claw/node_modules/function-bind/test/.eslintrc +0 -9
- package/claw/node_modules/function-bind/test/index.js +0 -252
- package/claw/node_modules/functions-have-names/.editorconfig +0 -20
- package/claw/node_modules/functions-have-names/.eslintrc +0 -19
- package/claw/node_modules/functions-have-names/.github/FUNDING.yml +0 -12
- package/claw/node_modules/functions-have-names/.nycrc +0 -9
- package/claw/node_modules/functions-have-names/CHANGELOG.md +0 -89
- package/claw/node_modules/functions-have-names/LICENSE +0 -21
- package/claw/node_modules/functions-have-names/README.md +0 -40
- package/claw/node_modules/functions-have-names/index.js +0 -31
- package/claw/node_modules/functions-have-names/package.json +0 -55
- package/claw/node_modules/functions-have-names/test/index.js +0 -65
- package/claw/node_modules/get-intrinsic/.eslintrc +0 -42
- package/claw/node_modules/get-intrinsic/.github/FUNDING.yml +0 -12
- package/claw/node_modules/get-intrinsic/.nycrc +0 -9
- package/claw/node_modules/get-intrinsic/CHANGELOG.md +0 -186
- package/claw/node_modules/get-intrinsic/LICENSE +0 -21
- package/claw/node_modules/get-intrinsic/README.md +0 -71
- package/claw/node_modules/get-intrinsic/index.js +0 -378
- package/claw/node_modules/get-intrinsic/package.json +0 -97
- package/claw/node_modules/get-intrinsic/test/GetIntrinsic.js +0 -274
- package/claw/node_modules/get-proto/.eslintrc +0 -10
- package/claw/node_modules/get-proto/.github/FUNDING.yml +0 -12
- package/claw/node_modules/get-proto/.nycrc +0 -9
- package/claw/node_modules/get-proto/CHANGELOG.md +0 -21
- package/claw/node_modules/get-proto/LICENSE +0 -21
- package/claw/node_modules/get-proto/Object.getPrototypeOf.d.ts +0 -5
- package/claw/node_modules/get-proto/Object.getPrototypeOf.js +0 -6
- package/claw/node_modules/get-proto/README.md +0 -50
- package/claw/node_modules/get-proto/Reflect.getPrototypeOf.d.ts +0 -3
- package/claw/node_modules/get-proto/Reflect.getPrototypeOf.js +0 -4
- package/claw/node_modules/get-proto/index.d.ts +0 -5
- package/claw/node_modules/get-proto/index.js +0 -27
- package/claw/node_modules/get-proto/package.json +0 -81
- package/claw/node_modules/get-proto/test/index.js +0 -68
- package/claw/node_modules/get-proto/tsconfig.json +0 -9
- package/claw/node_modules/gopd/.eslintrc +0 -16
- package/claw/node_modules/gopd/.github/FUNDING.yml +0 -12
- package/claw/node_modules/gopd/CHANGELOG.md +0 -45
- package/claw/node_modules/gopd/LICENSE +0 -21
- package/claw/node_modules/gopd/README.md +0 -40
- package/claw/node_modules/gopd/gOPD.d.ts +0 -1
- package/claw/node_modules/gopd/gOPD.js +0 -4
- package/claw/node_modules/gopd/index.d.ts +0 -5
- package/claw/node_modules/gopd/index.js +0 -15
- package/claw/node_modules/gopd/package.json +0 -77
- package/claw/node_modules/gopd/test/index.js +0 -36
- package/claw/node_modules/gopd/tsconfig.json +0 -9
- package/claw/node_modules/has-property-descriptors/.eslintrc +0 -13
- package/claw/node_modules/has-property-descriptors/.github/FUNDING.yml +0 -12
- package/claw/node_modules/has-property-descriptors/.nycrc +0 -9
- package/claw/node_modules/has-property-descriptors/CHANGELOG.md +0 -35
- package/claw/node_modules/has-property-descriptors/LICENSE +0 -21
- package/claw/node_modules/has-property-descriptors/README.md +0 -43
- package/claw/node_modules/has-property-descriptors/index.js +0 -22
- package/claw/node_modules/has-property-descriptors/package.json +0 -77
- package/claw/node_modules/has-property-descriptors/test/index.js +0 -57
- package/claw/node_modules/has-symbols/.eslintrc +0 -11
- package/claw/node_modules/has-symbols/.github/FUNDING.yml +0 -12
- package/claw/node_modules/has-symbols/.nycrc +0 -9
- package/claw/node_modules/has-symbols/CHANGELOG.md +0 -91
- package/claw/node_modules/has-symbols/LICENSE +0 -21
- package/claw/node_modules/has-symbols/README.md +0 -46
- package/claw/node_modules/has-symbols/index.d.ts +0 -3
- package/claw/node_modules/has-symbols/index.js +0 -14
- package/claw/node_modules/has-symbols/package.json +0 -111
- package/claw/node_modules/has-symbols/shams.d.ts +0 -3
- package/claw/node_modules/has-symbols/shams.js +0 -45
- package/claw/node_modules/has-symbols/test/index.js +0 -22
- package/claw/node_modules/has-symbols/test/shams/core-js.js +0 -29
- package/claw/node_modules/has-symbols/test/shams/get-own-property-symbols.js +0 -29
- package/claw/node_modules/has-symbols/test/tests.js +0 -58
- package/claw/node_modules/has-symbols/tsconfig.json +0 -10
- package/claw/node_modules/has-tostringtag/.eslintrc +0 -5
- package/claw/node_modules/has-tostringtag/.github/FUNDING.yml +0 -12
- package/claw/node_modules/has-tostringtag/.nycrc +0 -13
- package/claw/node_modules/has-tostringtag/CHANGELOG.md +0 -42
- package/claw/node_modules/has-tostringtag/LICENSE +0 -21
- package/claw/node_modules/has-tostringtag/README.md +0 -46
- package/claw/node_modules/has-tostringtag/index.d.ts +0 -3
- package/claw/node_modules/has-tostringtag/index.js +0 -8
- package/claw/node_modules/has-tostringtag/package.json +0 -108
- package/claw/node_modules/has-tostringtag/shams.d.ts +0 -3
- package/claw/node_modules/has-tostringtag/shams.js +0 -8
- package/claw/node_modules/has-tostringtag/test/index.js +0 -21
- package/claw/node_modules/has-tostringtag/test/shams/core-js.js +0 -31
- package/claw/node_modules/has-tostringtag/test/shams/get-own-property-symbols.js +0 -30
- package/claw/node_modules/has-tostringtag/test/tests.js +0 -15
- package/claw/node_modules/has-tostringtag/tsconfig.json +0 -49
- package/claw/node_modules/hash-base/.github/FUNDING.yml +0 -12
- package/claw/node_modules/hash-base/CHANGELOG.md +0 -166
- package/claw/node_modules/hash-base/LICENSE +0 -21
- package/claw/node_modules/hash-base/README.md +0 -48
- package/claw/node_modules/hash-base/index.js +0 -109
- package/claw/node_modules/hash-base/package.json +0 -64
- package/claw/node_modules/hash-base/to-buffer.js +0 -20
- package/claw/node_modules/hasown/.eslintrc +0 -5
- package/claw/node_modules/hasown/.github/FUNDING.yml +0 -12
- package/claw/node_modules/hasown/.nycrc +0 -13
- package/claw/node_modules/hasown/CHANGELOG.md +0 -40
- package/claw/node_modules/hasown/LICENSE +0 -21
- package/claw/node_modules/hasown/README.md +0 -40
- package/claw/node_modules/hasown/index.d.ts +0 -3
- package/claw/node_modules/hasown/index.js +0 -8
- package/claw/node_modules/hasown/package.json +0 -92
- package/claw/node_modules/hasown/tsconfig.json +0 -6
- package/claw/node_modules/inherits/LICENSE +0 -16
- package/claw/node_modules/inherits/README.md +0 -42
- package/claw/node_modules/inherits/inherits.js +0 -9
- package/claw/node_modules/inherits/inherits_browser.js +0 -27
- package/claw/node_modules/inherits/package.json +0 -29
- package/claw/node_modules/is-arguments/.editorconfig +0 -20
- package/claw/node_modules/is-arguments/.eslintrc +0 -9
- package/claw/node_modules/is-arguments/.github/FUNDING.yml +0 -12
- package/claw/node_modules/is-arguments/.nycrc +0 -9
- package/claw/node_modules/is-arguments/CHANGELOG.md +0 -201
- package/claw/node_modules/is-arguments/LICENSE +0 -20
- package/claw/node_modules/is-arguments/README.md +0 -47
- package/claw/node_modules/is-arguments/index.d.ts +0 -6
- package/claw/node_modules/is-arguments/index.js +0 -44
- package/claw/node_modules/is-arguments/package.json +0 -105
- package/claw/node_modules/is-arguments/test/index.js +0 -47
- package/claw/node_modules/is-arguments/tsconfig.json +0 -9
- package/claw/node_modules/is-callable/.editorconfig +0 -31
- package/claw/node_modules/is-callable/.eslintrc +0 -10
- package/claw/node_modules/is-callable/.github/FUNDING.yml +0 -12
- package/claw/node_modules/is-callable/.nycrc +0 -9
- package/claw/node_modules/is-callable/CHANGELOG.md +0 -158
- package/claw/node_modules/is-callable/LICENSE +0 -22
- package/claw/node_modules/is-callable/README.md +0 -83
- package/claw/node_modules/is-callable/index.js +0 -101
- package/claw/node_modules/is-callable/package.json +0 -106
- package/claw/node_modules/is-callable/test/index.js +0 -244
- package/claw/node_modules/is-date-object/.editorconfig +0 -20
- package/claw/node_modules/is-date-object/.eslintrc +0 -9
- package/claw/node_modules/is-date-object/.github/FUNDING.yml +0 -12
- package/claw/node_modules/is-date-object/.nycrc +0 -10
- package/claw/node_modules/is-date-object/CHANGELOG.md +0 -134
- package/claw/node_modules/is-date-object/LICENSE +0 -22
- package/claw/node_modules/is-date-object/README.md +0 -52
- package/claw/node_modules/is-date-object/index.d.ts +0 -3
- package/claw/node_modules/is-date-object/index.js +0 -27
- package/claw/node_modules/is-date-object/package.json +0 -99
- package/claw/node_modules/is-date-object/test/index.js +0 -38
- package/claw/node_modules/is-date-object/tsconfig.json +0 -6
- package/claw/node_modules/is-regex/.editorconfig +0 -23
- package/claw/node_modules/is-regex/.eslintrc +0 -10
- package/claw/node_modules/is-regex/.nycrc +0 -10
- package/claw/node_modules/is-regex/CHANGELOG.md +0 -233
- package/claw/node_modules/is-regex/LICENSE +0 -20
- package/claw/node_modules/is-regex/README.md +0 -52
- package/claw/node_modules/is-regex/index.d.ts +0 -3
- package/claw/node_modules/is-regex/index.js +0 -69
- package/claw/node_modules/is-regex/package.json +0 -104
- package/claw/node_modules/is-regex/test/index.js +0 -121
- package/claw/node_modules/is-regex/tsconfig.json +0 -9
- package/claw/node_modules/is-typed-array/.editorconfig +0 -20
- package/claw/node_modules/is-typed-array/.eslintrc +0 -13
- package/claw/node_modules/is-typed-array/.github/FUNDING.yml +0 -12
- package/claw/node_modules/is-typed-array/.nycrc +0 -9
- package/claw/node_modules/is-typed-array/CHANGELOG.md +0 -166
- package/claw/node_modules/is-typed-array/LICENSE +0 -22
- package/claw/node_modules/is-typed-array/README.md +0 -70
- package/claw/node_modules/is-typed-array/index.d.ts +0 -9
- package/claw/node_modules/is-typed-array/index.js +0 -8
- package/claw/node_modules/is-typed-array/package.json +0 -129
- package/claw/node_modules/is-typed-array/test/index.js +0 -111
- package/claw/node_modules/is-typed-array/tsconfig.json +0 -6
- package/claw/node_modules/isarray/.travis.yml +0 -4
- package/claw/node_modules/isarray/Makefile +0 -6
- package/claw/node_modules/isarray/README.md +0 -60
- package/claw/node_modules/isarray/component.json +0 -19
- package/claw/node_modules/isarray/index.js +0 -5
- package/claw/node_modules/isarray/package.json +0 -45
- package/claw/node_modules/isarray/test.js +0 -20
- package/claw/node_modules/isomorphic-ws/LICENSE +0 -21
- package/claw/node_modules/isomorphic-ws/README.md +0 -58
- package/claw/node_modules/isomorphic-ws/browser.js +0 -17
- package/claw/node_modules/isomorphic-ws/index.d.ts +0 -8
- package/claw/node_modules/isomorphic-ws/node.js +0 -3
- package/claw/node_modules/isomorphic-ws/package.json +0 -34
- package/claw/node_modules/long/.travis.yml +0 -5
- package/claw/node_modules/long/LICENSE +0 -202
- package/claw/node_modules/long/README.md +0 -513
- package/claw/node_modules/long/bower.json +0 -9
- package/claw/node_modules/long/dist/README.md +0 -16
- package/claw/node_modules/long/dist/long.js +0 -1209
- package/claw/node_modules/long/dist/long.min.js +0 -20
- package/claw/node_modules/long/dist/long.min.js.gz +0 -0
- package/claw/node_modules/long/dist/long.min.map +0 -8
- package/claw/node_modules/long/doco/INDEX.md +0 -6
- package/claw/node_modules/long/doco/Long.md +0 -473
- package/claw/node_modules/long/donate.png +0 -0
- package/claw/node_modules/long/externs/long.js +0 -416
- package/claw/node_modules/long/index.js +0 -1
- package/claw/node_modules/long/jsdoc.json +0 -13
- package/claw/node_modules/long/long.png +0 -0
- package/claw/node_modules/long/package.json +0 -33
- package/claw/node_modules/long/scripts/build.js +0 -28
- package/claw/node_modules/long/src/bower.json +0 -9
- package/claw/node_modules/long/src/long.js +0 -1172
- package/claw/node_modules/long/src/wrap.js +0 -38
- package/claw/node_modules/long/tests/goog.math.long.js +0 -807
- package/claw/node_modules/long/tests/suite.js +0 -195
- package/claw/node_modules/lzma/.travis.yml +0 -9
- package/claw/node_modules/lzma/LICENSE +0 -20
- package/claw/node_modules/lzma/THANKS +0 -7
- package/claw/node_modules/lzma/bin/lzma.js +0 -362
- package/claw/node_modules/lzma/index.js +0 -19
- package/claw/node_modules/lzma/package.json +0 -30
- package/claw/node_modules/lzma/readme.md +0 -149
- package/claw/node_modules/lzma/src/lzma-c-min.js +0 -1
- package/claw/node_modules/lzma/src/lzma-c.js +0 -2021
- package/claw/node_modules/lzma/src/lzma-d-min.js +0 -1
- package/claw/node_modules/lzma/src/lzma-d.js +0 -878
- package/claw/node_modules/lzma/src/lzma-min.js +0 -2
- package/claw/node_modules/lzma/src/lzma.js +0 -153
- package/claw/node_modules/lzma/src/lzma_worker-min.js +0 -2
- package/claw/node_modules/lzma/src/lzma_worker.js +0 -2668
- package/claw/node_modules/math-intrinsics/.eslintrc +0 -16
- package/claw/node_modules/math-intrinsics/.github/FUNDING.yml +0 -12
- package/claw/node_modules/math-intrinsics/CHANGELOG.md +0 -24
- package/claw/node_modules/math-intrinsics/LICENSE +0 -21
- package/claw/node_modules/math-intrinsics/README.md +0 -50
- package/claw/node_modules/math-intrinsics/abs.d.ts +0 -1
- package/claw/node_modules/math-intrinsics/abs.js +0 -4
- package/claw/node_modules/math-intrinsics/constants/maxArrayLength.d.ts +0 -3
- package/claw/node_modules/math-intrinsics/constants/maxArrayLength.js +0 -4
- package/claw/node_modules/math-intrinsics/constants/maxSafeInteger.d.ts +0 -3
- package/claw/node_modules/math-intrinsics/constants/maxSafeInteger.js +0 -5
- package/claw/node_modules/math-intrinsics/constants/maxValue.d.ts +0 -3
- package/claw/node_modules/math-intrinsics/constants/maxValue.js +0 -5
- package/claw/node_modules/math-intrinsics/floor.d.ts +0 -1
- package/claw/node_modules/math-intrinsics/floor.js +0 -4
- package/claw/node_modules/math-intrinsics/isFinite.d.ts +0 -3
- package/claw/node_modules/math-intrinsics/isFinite.js +0 -12
- package/claw/node_modules/math-intrinsics/isInteger.d.ts +0 -3
- package/claw/node_modules/math-intrinsics/isInteger.js +0 -16
- package/claw/node_modules/math-intrinsics/isNaN.d.ts +0 -1
- package/claw/node_modules/math-intrinsics/isNaN.js +0 -6
- package/claw/node_modules/math-intrinsics/isNegativeZero.d.ts +0 -3
- package/claw/node_modules/math-intrinsics/isNegativeZero.js +0 -6
- package/claw/node_modules/math-intrinsics/max.d.ts +0 -1
- package/claw/node_modules/math-intrinsics/max.js +0 -4
- package/claw/node_modules/math-intrinsics/min.d.ts +0 -1
- package/claw/node_modules/math-intrinsics/min.js +0 -4
- package/claw/node_modules/math-intrinsics/mod.d.ts +0 -3
- package/claw/node_modules/math-intrinsics/mod.js +0 -9
- package/claw/node_modules/math-intrinsics/package.json +0 -86
- package/claw/node_modules/math-intrinsics/pow.d.ts +0 -1
- package/claw/node_modules/math-intrinsics/pow.js +0 -4
- package/claw/node_modules/math-intrinsics/round.d.ts +0 -1
- package/claw/node_modules/math-intrinsics/round.js +0 -4
- package/claw/node_modules/math-intrinsics/sign.d.ts +0 -3
- package/claw/node_modules/math-intrinsics/sign.js +0 -11
- package/claw/node_modules/math-intrinsics/test/index.js +0 -192
- package/claw/node_modules/math-intrinsics/tsconfig.json +0 -3
- package/claw/node_modules/md5.js/LICENSE +0 -21
- package/claw/node_modules/md5.js/README.md +0 -29
- package/claw/node_modules/md5.js/index.js +0 -146
- package/claw/node_modules/md5.js/package.json +0 -38
- package/claw/node_modules/object-is/.eslintrc +0 -5
- package/claw/node_modules/object-is/.nycrc +0 -9
- package/claw/node_modules/object-is/CHANGELOG.md +0 -175
- package/claw/node_modules/object-is/LICENSE +0 -20
- package/claw/node_modules/object-is/README.md +0 -60
- package/claw/node_modules/object-is/auto.js +0 -3
- package/claw/node_modules/object-is/implementation.js +0 -19
- package/claw/node_modules/object-is/index.js +0 -18
- package/claw/node_modules/object-is/package.json +0 -96
- package/claw/node_modules/object-is/polyfill.js +0 -7
- package/claw/node_modules/object-is/shim.js +0 -14
- package/claw/node_modules/object-is/test/implementation.js +0 -12
- package/claw/node_modules/object-is/test/index.js +0 -12
- package/claw/node_modules/object-is/test/shimmed.js +0 -28
- package/claw/node_modules/object-is/test/tests.js +0 -57
- package/claw/node_modules/object-keys/.editorconfig +0 -13
- package/claw/node_modules/object-keys/.eslintrc +0 -17
- package/claw/node_modules/object-keys/.travis.yml +0 -277
- package/claw/node_modules/object-keys/CHANGELOG.md +0 -232
- package/claw/node_modules/object-keys/LICENSE +0 -21
- package/claw/node_modules/object-keys/README.md +0 -76
- package/claw/node_modules/object-keys/implementation.js +0 -122
- package/claw/node_modules/object-keys/index.js +0 -32
- package/claw/node_modules/object-keys/isArguments.js +0 -17
- package/claw/node_modules/object-keys/package.json +0 -88
- package/claw/node_modules/object-keys/test/index.js +0 -5
- package/claw/node_modules/object.assign/.editorconfig +0 -20
- package/claw/node_modules/object.assign/.eslintrc +0 -28
- package/claw/node_modules/object.assign/.github/FUNDING.yml +0 -12
- package/claw/node_modules/object.assign/.nycrc +0 -9
- package/claw/node_modules/object.assign/CHANGELOG.md +0 -246
- package/claw/node_modules/object.assign/LICENSE +0 -21
- package/claw/node_modules/object.assign/README.md +0 -136
- package/claw/node_modules/object.assign/auto.js +0 -3
- package/claw/node_modules/object.assign/dist/browser.js +0 -1304
- package/claw/node_modules/object.assign/hasSymbols.js +0 -43
- package/claw/node_modules/object.assign/implementation.js +0 -46
- package/claw/node_modules/object.assign/index.js +0 -22
- package/claw/node_modules/object.assign/package.json +0 -96
- package/claw/node_modules/object.assign/polyfill.js +0 -55
- package/claw/node_modules/object.assign/shim.js +0 -14
- package/claw/node_modules/object.assign/test/implementation.js +0 -19
- package/claw/node_modules/object.assign/test/index.js +0 -17
- package/claw/node_modules/object.assign/test/native.js +0 -49
- package/claw/node_modules/object.assign/test/ses-compat.js +0 -12
- package/claw/node_modules/object.assign/test/shimmed.js +0 -52
- package/claw/node_modules/object.assign/test/tests.js +0 -232
- package/claw/node_modules/possible-typed-array-names/.eslintrc +0 -5
- package/claw/node_modules/possible-typed-array-names/.github/FUNDING.yml +0 -12
- package/claw/node_modules/possible-typed-array-names/CHANGELOG.md +0 -29
- package/claw/node_modules/possible-typed-array-names/LICENSE +0 -21
- package/claw/node_modules/possible-typed-array-names/README.md +0 -50
- package/claw/node_modules/possible-typed-array-names/index.d.ts +0 -16
- package/claw/node_modules/possible-typed-array-names/index.js +0 -17
- package/claw/node_modules/possible-typed-array-names/package.json +0 -84
- package/claw/node_modules/possible-typed-array-names/test/index.js +0 -19
- package/claw/node_modules/possible-typed-array-names/tsconfig.json +0 -9
- package/claw/node_modules/process-nextick-args/index.js +0 -45
- package/claw/node_modules/process-nextick-args/license.md +0 -19
- package/claw/node_modules/process-nextick-args/package.json +0 -25
- package/claw/node_modules/process-nextick-args/readme.md +0 -18
- package/claw/node_modules/readable-stream/.travis.yml +0 -34
- package/claw/node_modules/readable-stream/CONTRIBUTING.md +0 -38
- package/claw/node_modules/readable-stream/GOVERNANCE.md +0 -136
- package/claw/node_modules/readable-stream/LICENSE +0 -47
- package/claw/node_modules/readable-stream/README.md +0 -58
- package/claw/node_modules/readable-stream/doc/wg-meetings/2015-01-30.md +0 -60
- package/claw/node_modules/readable-stream/duplex-browser.js +0 -1
- package/claw/node_modules/readable-stream/duplex.js +0 -1
- package/claw/node_modules/readable-stream/lib/_stream_duplex.js +0 -131
- package/claw/node_modules/readable-stream/lib/_stream_passthrough.js +0 -47
- package/claw/node_modules/readable-stream/lib/_stream_readable.js +0 -1019
- package/claw/node_modules/readable-stream/lib/_stream_transform.js +0 -214
- package/claw/node_modules/readable-stream/lib/_stream_writable.js +0 -685
- package/claw/node_modules/readable-stream/lib/internal/streams/BufferList.js +0 -78
- package/claw/node_modules/readable-stream/lib/internal/streams/destroy.js +0 -84
- package/claw/node_modules/readable-stream/lib/internal/streams/stream-browser.js +0 -1
- package/claw/node_modules/readable-stream/lib/internal/streams/stream.js +0 -1
- package/claw/node_modules/readable-stream/node_modules/safe-buffer/LICENSE +0 -21
- package/claw/node_modules/readable-stream/node_modules/safe-buffer/README.md +0 -584
- package/claw/node_modules/readable-stream/node_modules/safe-buffer/index.d.ts +0 -187
- package/claw/node_modules/readable-stream/node_modules/safe-buffer/index.js +0 -62
- package/claw/node_modules/readable-stream/node_modules/safe-buffer/package.json +0 -37
- package/claw/node_modules/readable-stream/package.json +0 -52
- package/claw/node_modules/readable-stream/passthrough.js +0 -1
- package/claw/node_modules/readable-stream/readable-browser.js +0 -7
- package/claw/node_modules/readable-stream/readable.js +0 -19
- package/claw/node_modules/readable-stream/transform.js +0 -1
- package/claw/node_modules/readable-stream/writable-browser.js +0 -1
- package/claw/node_modules/readable-stream/writable.js +0 -8
- package/claw/node_modules/regexp.prototype.flags/.editorconfig +0 -13
- package/claw/node_modules/regexp.prototype.flags/.eslintrc +0 -20
- package/claw/node_modules/regexp.prototype.flags/.nycrc +0 -9
- package/claw/node_modules/regexp.prototype.flags/CHANGELOG.md +0 -249
- package/claw/node_modules/regexp.prototype.flags/LICENSE +0 -22
- package/claw/node_modules/regexp.prototype.flags/README.md +0 -55
- package/claw/node_modules/regexp.prototype.flags/auto.js +0 -3
- package/claw/node_modules/regexp.prototype.flags/implementation.js +0 -39
- package/claw/node_modules/regexp.prototype.flags/index.js +0 -18
- package/claw/node_modules/regexp.prototype.flags/package.json +0 -105
- package/claw/node_modules/regexp.prototype.flags/polyfill.js +0 -39
- package/claw/node_modules/regexp.prototype.flags/shim.js +0 -26
- package/claw/node_modules/regexp.prototype.flags/test/builtin.js +0 -46
- package/claw/node_modules/regexp.prototype.flags/test/implementation.js +0 -20
- package/claw/node_modules/regexp.prototype.flags/test/index.js +0 -17
- package/claw/node_modules/regexp.prototype.flags/test/shimmed.js +0 -48
- package/claw/node_modules/regexp.prototype.flags/test/tests.js +0 -143
- package/claw/node_modules/ripemd160/.github/FUNDING.yml +0 -12
- package/claw/node_modules/ripemd160/CHANGELOG.md +0 -109
- package/claw/node_modules/ripemd160/LICENSE +0 -21
- package/claw/node_modules/ripemd160/README.md +0 -27
- package/claw/node_modules/ripemd160/index.js +0 -167
- package/claw/node_modules/ripemd160/package.json +0 -64
- package/claw/node_modules/safe-buffer/LICENSE +0 -21
- package/claw/node_modules/safe-buffer/README.md +0 -584
- package/claw/node_modules/safe-buffer/index.d.ts +0 -187
- package/claw/node_modules/safe-buffer/index.js +0 -65
- package/claw/node_modules/safe-buffer/package.json +0 -51
- package/claw/node_modules/secure-random/CHANGELOG.md +0 -51
- package/claw/node_modules/secure-random/Makefile +0 -8
- package/claw/node_modules/secure-random/README.md +0 -133
- package/claw/node_modules/secure-random/lib/secure-random.js +0 -83
- package/claw/node_modules/secure-random/package.json +0 -45
- package/claw/node_modules/set-function-length/.eslintrc +0 -27
- package/claw/node_modules/set-function-length/.github/FUNDING.yml +0 -12
- package/claw/node_modules/set-function-length/.nycrc +0 -13
- package/claw/node_modules/set-function-length/CHANGELOG.md +0 -70
- package/claw/node_modules/set-function-length/LICENSE +0 -21
- package/claw/node_modules/set-function-length/README.md +0 -56
- package/claw/node_modules/set-function-length/env.d.ts +0 -9
- package/claw/node_modules/set-function-length/env.js +0 -25
- package/claw/node_modules/set-function-length/index.d.ts +0 -7
- package/claw/node_modules/set-function-length/index.js +0 -42
- package/claw/node_modules/set-function-length/package.json +0 -102
- package/claw/node_modules/set-function-length/tsconfig.json +0 -9
- package/claw/node_modules/set-function-name/.eslintrc +0 -21
- package/claw/node_modules/set-function-name/.github/FUNDING.yml +0 -12
- package/claw/node_modules/set-function-name/CHANGELOG.md +0 -48
- package/claw/node_modules/set-function-name/LICENSE +0 -21
- package/claw/node_modules/set-function-name/README.md +0 -61
- package/claw/node_modules/set-function-name/index.d.ts +0 -5
- package/claw/node_modules/set-function-name/index.js +0 -23
- package/claw/node_modules/set-function-name/package.json +0 -99
- package/claw/node_modules/set-function-name/tsconfig.json +0 -59
- package/claw/node_modules/sha.js/.eslintrc +0 -76
- package/claw/node_modules/sha.js/CHANGELOG.md +0 -423
- package/claw/node_modules/sha.js/LICENSE +0 -49
- package/claw/node_modules/sha.js/README.md +0 -44
- package/claw/node_modules/sha.js/bin.js +0 -44
- package/claw/node_modules/sha.js/hash.js +0 -84
- package/claw/node_modules/sha.js/index.js +0 -19
- package/claw/node_modules/sha.js/package.json +0 -58
- package/claw/node_modules/sha.js/sha.js +0 -104
- package/claw/node_modules/sha.js/sha1.js +0 -109
- package/claw/node_modules/sha.js/sha224.js +0 -55
- package/claw/node_modules/sha.js/sha256.js +0 -189
- package/claw/node_modules/sha.js/sha384.js +0 -59
- package/claw/node_modules/sha.js/sha512.js +0 -382
- package/claw/node_modules/sha.js/test/hash.js +0 -80
- package/claw/node_modules/sha.js/test/test.js +0 -138
- package/claw/node_modules/sha.js/test/vectors.js +0 -72
- package/claw/node_modules/string_decoder/.travis.yml +0 -50
- package/claw/node_modules/string_decoder/LICENSE +0 -48
- package/claw/node_modules/string_decoder/README.md +0 -47
- package/claw/node_modules/string_decoder/lib/string_decoder.js +0 -296
- package/claw/node_modules/string_decoder/node_modules/safe-buffer/LICENSE +0 -21
- package/claw/node_modules/string_decoder/node_modules/safe-buffer/README.md +0 -584
- package/claw/node_modules/string_decoder/node_modules/safe-buffer/index.d.ts +0 -187
- package/claw/node_modules/string_decoder/node_modules/safe-buffer/index.js +0 -62
- package/claw/node_modules/string_decoder/node_modules/safe-buffer/package.json +0 -37
- package/claw/node_modules/string_decoder/package.json +0 -31
- package/claw/node_modules/to-buffer/.github/FUNDING.yml +0 -12
- package/claw/node_modules/to-buffer/CHANGELOG.md +0 -81
- package/claw/node_modules/to-buffer/LICENSE +0 -21
- package/claw/node_modules/to-buffer/README.md +0 -44
- package/claw/node_modules/to-buffer/index.js +0 -109
- package/claw/node_modules/to-buffer/node_modules/isarray/LICENSE +0 -21
- package/claw/node_modules/to-buffer/node_modules/isarray/README.md +0 -38
- package/claw/node_modules/to-buffer/node_modules/isarray/index.js +0 -5
- package/claw/node_modules/to-buffer/node_modules/isarray/package.json +0 -48
- package/claw/node_modules/to-buffer/package.json +0 -62
- package/claw/node_modules/typed-array-buffer/.eslintrc +0 -13
- package/claw/node_modules/typed-array-buffer/.github/FUNDING.yml +0 -12
- package/claw/node_modules/typed-array-buffer/.nycrc +0 -13
- package/claw/node_modules/typed-array-buffer/CHANGELOG.md +0 -50
- package/claw/node_modules/typed-array-buffer/LICENSE +0 -21
- package/claw/node_modules/typed-array-buffer/README.md +0 -42
- package/claw/node_modules/typed-array-buffer/index.d.ts +0 -9
- package/claw/node_modules/typed-array-buffer/index.js +0 -19
- package/claw/node_modules/typed-array-buffer/package.json +0 -82
- package/claw/node_modules/typed-array-buffer/test/index.js +0 -23
- package/claw/node_modules/typed-array-buffer/tsconfig.json +0 -9
- package/claw/node_modules/util/LICENSE +0 -18
- package/claw/node_modules/util/README.md +0 -15
- package/claw/node_modules/util/node_modules/inherits/LICENSE +0 -16
- package/claw/node_modules/util/node_modules/inherits/README.md +0 -42
- package/claw/node_modules/util/node_modules/inherits/inherits.js +0 -7
- package/claw/node_modules/util/node_modules/inherits/inherits_browser.js +0 -23
- package/claw/node_modules/util/node_modules/inherits/package.json +0 -29
- package/claw/node_modules/util/package.json +0 -35
- package/claw/node_modules/util/support/isBuffer.js +0 -3
- package/claw/node_modules/util/support/isBufferBrowser.js +0 -6
- package/claw/node_modules/util/util.js +0 -586
- package/claw/node_modules/util-deprecate/History.md +0 -16
- package/claw/node_modules/util-deprecate/LICENSE +0 -24
- package/claw/node_modules/util-deprecate/README.md +0 -53
- package/claw/node_modules/util-deprecate/browser.js +0 -67
- package/claw/node_modules/util-deprecate/node.js +0 -6
- package/claw/node_modules/util-deprecate/package.json +0 -27
- package/claw/node_modules/which-typed-array/.editorconfig +0 -20
- package/claw/node_modules/which-typed-array/.eslintrc +0 -10
- package/claw/node_modules/which-typed-array/.github/FUNDING.yml +0 -12
- package/claw/node_modules/which-typed-array/.nycrc +0 -13
- package/claw/node_modules/which-typed-array/CHANGELOG.md +0 -269
- package/claw/node_modules/which-typed-array/LICENSE +0 -22
- package/claw/node_modules/which-typed-array/README.md +0 -70
- package/claw/node_modules/which-typed-array/index.d.ts +0 -66
- package/claw/node_modules/which-typed-array/index.js +0 -122
- package/claw/node_modules/which-typed-array/package.json +0 -130
- package/claw/node_modules/which-typed-array/test/index.js +0 -105
- package/claw/node_modules/which-typed-array/tsconfig.json +0 -9
- package/claw/node_modules/ws/LICENSE +0 -21
- package/claw/node_modules/ws/README.md +0 -449
- package/claw/node_modules/ws/browser.js +0 -8
- package/claw/node_modules/ws/index.js +0 -9
- package/claw/node_modules/ws/lib/buffer-util.js +0 -144
- package/claw/node_modules/ws/lib/constants.js +0 -10
- package/claw/node_modules/ws/lib/event-target.js +0 -170
- package/claw/node_modules/ws/lib/extension.js +0 -222
- package/claw/node_modules/ws/lib/permessage-deflate.js +0 -502
- package/claw/node_modules/ws/lib/receiver.js +0 -492
- package/claw/node_modules/ws/lib/sender.js +0 -358
- package/claw/node_modules/ws/lib/validation.js +0 -30
- package/claw/node_modules/ws/lib/websocket-server.js +0 -415
- package/claw/node_modules/ws/lib/websocket.js +0 -895
- package/claw/node_modules/ws/package.json +0 -45
- package/dist/analysis/chart_utils.d.ts +0 -27
- package/dist/analysis/chart_utils.d.ts.map +0 -1
- package/dist/analysis/chart_utils.js.map +0 -1
- package/dist/analysis/math_utils.d.ts +0 -22
- package/dist/analysis/math_utils.d.ts.map +0 -1
- package/dist/analysis/math_utils.js +0 -43
- package/dist/analysis/math_utils.js.map +0 -1
- package/dist/analysis/tradingview/tradingview_uplot_chart_generator.d.ts +0 -5
- 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/modules/logger.d.ts +0 -4
- package/dist/modules/logger.d.ts.map +0 -1
- package/dist/modules/logger.js +0 -5
- package/dist/modules/logger.js.map +0 -1
- package/dist/modules/utils/math_utils.d.ts +0 -3
- package/dist/modules/utils/math_utils.d.ts.map +0 -1
- package/dist/modules/utils/math_utils.js +0 -3
- package/dist/modules/utils/math_utils.js.map +0 -1
|
@@ -0,0 +1,1929 @@
|
|
|
1
|
+
# DEXBot2 Developer Guide
|
|
2
|
+
|
|
3
|
+
Welcome to DEXBot2! This guide will help you understand the codebase, navigate key concepts, and contribute effectively.
|
|
4
|
+
|
|
5
|
+
> **For system design overview**, see [architecture.md](architecture.md) which provides high-level module relationships and data flows.
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## Quick Start: Where to Begin
|
|
10
|
+
|
|
11
|
+
### 1. **Start Here** (5 minutes)
|
|
12
|
+
Read these files in order to get oriented:
|
|
13
|
+
1. [README](../README.md) - User documentation and setup
|
|
14
|
+
2. [architecture.md](architecture.md) - System architecture and module relationships
|
|
15
|
+
3. [FUND_MOVEMENT_AND_ACCOUNTING.md](FUND_MOVEMENT_AND_ACCOUNTING.md) - Core algorithms and formulas
|
|
16
|
+
|
|
17
|
+
### 2. **Core Concepts** (15 minutes)
|
|
18
|
+
Understand these fundamental concepts before diving into code:
|
|
19
|
+
- **Grid Trading**: Placing orders at geometric price levels to profit from volatility
|
|
20
|
+
- **Order States**: VIRTUAL → ACTIVE → PARTIAL lifecycle
|
|
21
|
+
- **Fund Tracking**: Atomic accounting to prevent overdrafts
|
|
22
|
+
- **Boundary Crawl**: Dynamic order rotation following price movement
|
|
23
|
+
- **Copy-on-Write (COW)**: Master grid is immutable. All rebalancing runs on an isolated `WorkingGrid` clone; the master is replaced atomically only after blockchain success. See [COPY_ON_WRITE_MASTER_PLAN.md](COPY_ON_WRITE_MASTER_PLAN.md).
|
|
24
|
+
|
|
25
|
+
### 3. **Code Reading Roadmap** (30-40 minutes)
|
|
26
|
+
Follow this path through the codebase:
|
|
27
|
+
|
|
28
|
+
```
|
|
29
|
+
1. modules/constants.ts (5 min) - Configuration and tuning parameters
|
|
30
|
+
2. modules/order/manager.ts (10 min) - Central coordinator, read constructor + _updateOrder() + _applySafeRebalanceCOW() + _commitWorkingGrid()
|
|
31
|
+
3. modules/order/working_grid.ts (5 min) - COW working copy; read syncFromMaster() + buildDelta()
|
|
32
|
+
4. modules/order/accounting.ts (5 min) - Fund tracking, read recalculateFunds() and resetRecoveryState()
|
|
33
|
+
5. modules/order/strategy.ts (5 min) - Target grid calculation, read calculateTargetGrid()
|
|
34
|
+
6. modules/order/grid.ts (5 min) - Grid creation, read createOrderGrid()
|
|
35
|
+
7. modules/dexbot_fill_runtime.ts (5 min) - Fill batch processing pipeline and replay-safe accounting
|
|
36
|
+
8. modules/dexbot_maintenance_runtime.ts (5 min) - Sync loops, grid maintenance, trigger handling
|
|
37
|
+
9. modules/dexbot_class.ts (5 min) - Bot lifecycle, credit runtime startup, maintenance orchestration
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
**Additional Resources**:
|
|
41
|
+
- `modules/constants.ts::FILL_PROCESSING` - Batch configuration (`MAX_FILL_BATCH_SIZE`)
|
|
42
|
+
- `modules/constants.ts::PIPELINE_TIMING` - Recovery configuration (RECOVERY_RETRY_INTERVAL_MS, MAX_RECOVERY_ATTEMPTS)
|
|
43
|
+
- `modules/constants.ts::MARKET_ADAPTER` - AMA, dynamic weight, and regime detection defaults
|
|
44
|
+
- `modules/constants.ts::REGIME_TABLE` - Hurst/PE regime signal-strength table
|
|
45
|
+
- `modules/dexbot_class.ts::_handleBatchHardAbort()` - Hard-abort recovery handler
|
|
46
|
+
- `modules/dexbot_class.ts::_staleCleanedOrderIds` - Orphan-fill deduplication tracking
|
|
47
|
+
- `modules/dexbot_class.ts::_cancelDustOrders()` - Auto-cancel dust partials on-chain immediately (no timer)
|
|
48
|
+
- `modules/credit_runtime.ts` - Debt workflow executor (MPA and credit offer)
|
|
49
|
+
- `market_adapter/core/market_adapter_service.ts` - Signal pipeline (AMA, dynamic weights, collateral advisory)
|
|
50
|
+
|
|
51
|
+
---
|
|
52
|
+
|
|
53
|
+
## Glossary of Terms
|
|
54
|
+
|
|
55
|
+
### Order States
|
|
56
|
+
|
|
57
|
+
| Term | Meaning | Fund Impact |
|
|
58
|
+
|------|---------|-------------|
|
|
59
|
+
| **VIRTUAL** | Order planned but not on-chain | Funds reserved in `virtual` pool |
|
|
60
|
+
| **ACTIVE** | Order placed on blockchain | Funds locked in `committed.chain` |
|
|
61
|
+
| **PARTIAL** | Order partially filled | Reduced `committed`, proceeds added to `chainFree` |
|
|
62
|
+
| **SPREAD** | Placeholder for spread zone | Always VIRTUAL, no funds |
|
|
63
|
+
|
|
64
|
+
⚠️ **CRITICAL: Phantom Orders**
|
|
65
|
+
|
|
66
|
+
A **phantom order** is an order in ACTIVE/PARTIAL state WITHOUT a valid `orderId`. This is an illegal state that corrupts fund tracking. The system implements a three-layer defense to prevent phantoms (see **Phantom Orders Prevention** section). If encountered, the order is automatically downgraded to VIRTUAL with error logging.
|
|
67
|
+
|
|
68
|
+
### Pipeline Safety Features
|
|
69
|
+
|
|
70
|
+
#### Pipeline Timeout & Health
|
|
71
|
+
|
|
72
|
+
| Term | Meaning |
|
|
73
|
+
|------|---------|
|
|
74
|
+
| **Pipeline Timeout Safeguard** | 5-minute timeout preventing indefinite blocking on pipeline checks |
|
|
75
|
+
| **Stale Operation Clearing** | Non-destructive recovery clearing operation flags without touching orders |
|
|
76
|
+
|
|
77
|
+
#### Fill Batching & Recovery Retries
|
|
78
|
+
|
|
79
|
+
| Term | Meaning |
|
|
80
|
+
|------|---------|
|
|
81
|
+
| **Fixed-Cap Batch Fill Processing** | Groups fills with a hard cap using `MAX_FILL_BATCH_SIZE` (default 4): `<= cap` uses one unified batch; `> cap` chunks at cap size. In the documented 29-fill Feb 7 crash scenario, this reduces the estimated divergence window from ~90s to ~24s; see [`FUND_MOVEMENT_AND_ACCOUNTING.md`](FUND_MOVEMENT_AND_ACCOUNTING.md#14-fill-batch-processing--cache-fund-timeline). |
|
|
82
|
+
| **Recovery Retry System** | Count+time-based retry mechanism with periodic reset. Replaces one-shot `_recoveryAttempted` flag. Max 5 attempts per episode with 60s minimum interval between retries. |
|
|
83
|
+
| **Orphan-Fill Deduplication** | Map+TTL-based tracking of stale-cleaned order IDs to prevent double-crediting. Delayed orphan fill events are still blocked by checking `_staleCleanedOrderIds`. |
|
|
84
|
+
|
|
85
|
+
#### Cache & Stale-Order Handling
|
|
86
|
+
|
|
87
|
+
| Term | Meaning |
|
|
88
|
+
|------|---------|
|
|
89
|
+
| **Remainder Tracking** | Remainder derived from actual allocated sizes during capped grid resizes (not ideal sizes). Ensures accurate available fund calculations for next rebalance cycle. |
|
|
90
|
+
| **Stale-Order Fast-Path** | Stale-cancel logic applies to single-op batches for fast recovery without triggering full state syncs. Prevents unnecessary expensive resynchronization. |
|
|
91
|
+
| **Hard-Abort Cooldown Consistency** | Both primary and retry batch hard-abort paths explicitly arm `_maintenanceCooldownCycles` to prevent premature maintenance after recovery. |
|
|
92
|
+
|
|
93
|
+
### Fund Components
|
|
94
|
+
|
|
95
|
+
| Term | Meaning | Formula |
|
|
96
|
+
|------|---------|---------|
|
|
97
|
+
| **chainFree** | Unallocated blockchain balance | From `accountTotals.buyFree/sellFree` |
|
|
98
|
+
| **committed.chain** | Funds locked in on-chain orders | Sum of ACTIVE orders with `orderId` |
|
|
99
|
+
| **committed.grid** | Internal tracking of ACTIVE sizes | Sum of all ACTIVE order sizes |
|
|
100
|
+
| **virtual** | Reserved for VIRTUAL orders | Sum of VIRTUAL order sizes |
|
|
101
|
+
| **available** | Free funds for new orders | `max(0, chainFree - virtual - fees)` |
|
|
102
|
+
| **total.chain** | Total on-chain balance | `chainFree + committed.chain` |
|
|
103
|
+
| **total.grid** | Total grid allocation | `committed.grid + virtual` |
|
|
104
|
+
|
|
105
|
+
### Copy-on-Write (COW) Concepts
|
|
106
|
+
|
|
107
|
+
| Term | Meaning |
|
|
108
|
+
|------|---------|
|
|
109
|
+
| **Master Grid** (`manager.orders`) | The immutable source of truth. Frozen with `Object.freeze()`. Never mutated in place—replaced atomically via `_commitWorkingGrid()` only after blockchain success. |
|
|
110
|
+
| **WorkingGrid** | Mutable clone of the master grid used during planning. Created by `new WorkingGrid(masterGrid)`. Discarded on failure; committed on success. Lives in `modules/order/working_grid.ts`. |
|
|
111
|
+
| **COW Rebalance** | The full plan→broadcast→commit cycle: `_applySafeRebalanceCOW()` → `_updateOrdersOnChainBatchCOW()` → `_commitWorkingGrid()` |
|
|
112
|
+
| **Atomic Commit** | `_commitWorkingGrid(workingGrid, indexes, boundary, options = {})` swaps master to the working copy in a single operation, then increments `_gridVersion`. |
|
|
113
|
+
| **Staleness / Version Mismatch** | If a fill mutates the master grid while a rebalance is in progress, the working grid is marked stale. The commit guard rejects stale or version-mismatched working grids. |
|
|
114
|
+
| **`_gridVersion`** | Integer counter incremented on every master-grid mutation. Used by commit guards to detect concurrent master changes. |
|
|
115
|
+
| **`_gridLock`** | `AsyncLock` that serializes all master-grid mutations to prevent races. |
|
|
116
|
+
| **`syncFromMaster()`** | WorkingGrid method that selectively syncs one order from the master into the working copy during fills, avoiding a full abort. |
|
|
117
|
+
| **Delta / COW Action** | A `{ type, id, ... }` object describing a single Create / Update / Cancel operation derived by comparing master vs. working grid. Only deltas are sent to the blockchain. |
|
|
118
|
+
| **Rebalance States** | `NORMAL → REBALANCING → BROADCASTING → NORMAL`. Fills during REBALANCING sync into working grid. Fills during BROADCASTING mark it stale. |
|
|
119
|
+
|
|
120
|
+
### Signal & Market Adapter Concepts
|
|
121
|
+
|
|
122
|
+
| Term | Meaning |
|
|
123
|
+
|------|---------|
|
|
124
|
+
| **Dynamic Weight** | Live buy/sell weight bias computed from AMA slope + Kalman confirmation + ATR volatility penalty |
|
|
125
|
+
| **Regime Detection** | Hurst Exponent + Permutation Entropy classification of market structure (trending, mean-reverting, noisy) |
|
|
126
|
+
| **Regime Table** | Signal-strength lookup table in `constants.ts` that dampens or preserves dynamic weight based on regime |
|
|
127
|
+
| **AMA Slope** | Filtered measure of AMA velocity used to derive directional weight offset |
|
|
128
|
+
| **Kalman Confirmation** | Kalman-filtered trend signal blended with AMA slope for smoother weight transitions |
|
|
129
|
+
| **Symmetric Shift** | Volatility-driven downward weight penalty applied equally to both sides (ATR-based) |
|
|
130
|
+
| **Asymmetric Offset** | Directional weight shift (buy-heavy or sell-heavy) driven by AMA/Kalman trend |
|
|
131
|
+
| **Derivative Signal** | SMA/MACD/RSI-based entry bias and momentum gate for optional strategy filtering |
|
|
132
|
+
| **Momentum Gate** | N-bar commitment tracking that confirms derivative signals before acting |
|
|
133
|
+
| **Grid Price** | Price anchor for grid math; can be numeric, `"pool"`, `"book"`, or AMA keyword (`"ama"`, `"ama1"`–`"ama4"`) |
|
|
134
|
+
|
|
135
|
+
### Grid Concepts
|
|
136
|
+
|
|
137
|
+
| Term | Meaning |
|
|
138
|
+
|------|---------|
|
|
139
|
+
| **Master Rail** | Unified array of price levels (not separate buy/sell rails) |
|
|
140
|
+
| **Boundary Index** | Pivot point separating BUY/SPREAD/SELL zones |
|
|
141
|
+
| **Spread Gap** | Buffer of empty slots between best buy and best sell |
|
|
142
|
+
| **Crawl Candidate** | Furthest active order eligible for rotation |
|
|
143
|
+
| **Shortage** | Empty slot in the active window that needs an order |
|
|
144
|
+
| **Surplus** | Order outside the active window that can be rotated |
|
|
145
|
+
| **Hard Surplus** | Order beyond the configured `activeOrders` count |
|
|
146
|
+
| **Dust** | Partial order < 5% of ideal size |
|
|
147
|
+
| **Dust Cancel** | Immediate on-chain cancel of dust partials on detection (no delay, no timer). Slot freed for a fresh counter-order. |
|
|
148
|
+
|
|
149
|
+
### Credit/Debt Runtime Concepts
|
|
150
|
+
|
|
151
|
+
| Term | Meaning |
|
|
152
|
+
|------|---------|
|
|
153
|
+
| **Debt Policy** | Per-bot configuration block (`debtPolicy.lending` array) governing borrowing behavior. Each item declares its own `collateralAsset`. |
|
|
154
|
+
| **MPA Borrow** | Market-pegged asset call-order update (debt-first CR planning) |
|
|
155
|
+
| **Credit Offer** | On-chain peer-to-peer lending offer acceptance and repayment |
|
|
156
|
+
| **Auto-Reborrow** | Bot-side flag allowing a new credit offer accept after successful repay |
|
|
157
|
+
| **CR Planner** | Shared collateral-ratio math layer in `modules/cr_planner.ts` |
|
|
158
|
+
| **Credit Runtime** | Bot-scoped executor in `modules/credit_runtime.ts` for debt operations and grid-reset requests |
|
|
159
|
+
| **LP-Backed Collateral** | Liquidity-pool share tokens used as collateral, valued from underlying reserves |
|
|
160
|
+
|
|
161
|
+
### Operations
|
|
162
|
+
|
|
163
|
+
| Term | Meaning |
|
|
164
|
+
|------|---------|
|
|
165
|
+
| **Rotation** | Moving an order from one price level to another |
|
|
166
|
+
| **Consolidation** | Absorbing dust partials into the next grid rebuild cycle. All slots are treated uniformly—no side-specific flags or bonuses. |
|
|
167
|
+
| **Rebalancing** | Adjusting order sizes based on current funds |
|
|
168
|
+
| **Global Side Capping** | Scaling order sizes when insufficient funds |
|
|
169
|
+
| **Atomic Check-and-Deduct** | Verify funds + deduct in single operation |
|
|
170
|
+
| **Divergence Detection** | Comparing ideal grid vs. persisted grid |
|
|
171
|
+
| **Invariant Verification** | Checking fund accounting consistency |
|
|
172
|
+
| **Batch Processing** | Grouping multiple fills into a single rebalance cycle instead of one-at-a-time. Fixed-cap sizing: `<= MAX_FILL_BATCH_SIZE` unified, otherwise chunked at cap size (default max 4). |
|
|
173
|
+
| **Fixed-Cap Batch Sizing** | Deterministic chunking model with hard upper bound per broadcast. Keeps throughput high while avoiding tier-lookup complexity. |
|
|
174
|
+
| **Stale-Order Recovery** | Fast-path recovery for single-operation batches that encounter stale orders on-chain. Executes cleanup without full state sync. |
|
|
175
|
+
| **Orphan-Fill Prevention** | Deduplication mechanism that prevents double-crediting fills from stale-cleaned orders using timestamp-based ID tracking (TTL pruning). |
|
|
176
|
+
|
|
177
|
+
### Price Orientation and Derivation
|
|
178
|
+
|
|
179
|
+
**Critical Concept**: All prices in DEXBot2 use **B/A orientation** (how much of asset B per 1 unit of asset A).
|
|
180
|
+
|
|
181
|
+
| Term | Meaning | Example |
|
|
182
|
+
|------|---------|---------|
|
|
183
|
+
| **B/A Orientation** | Price format representing "how much B per 1 A" | XRP/BTS: 1350 means 1 XRP = 1350 BTS |
|
|
184
|
+
| **A/B Orientation** | Price format representing "how much A per 1 B" (NOT used in bot) | XRP/BTS: 0.00074 means 0.00074 XRP per 1 BTS |
|
|
185
|
+
|
|
186
|
+
#### Price Sources and Conversions
|
|
187
|
+
|
|
188
|
+
| Source | Raw Format | Conversion | Final Format |
|
|
189
|
+
|--------|-----------|-----------|-------------|
|
|
190
|
+
| **BitShares `get_order_book(A, B)`** | A/B (base/quote) | `1 / mid` | B/A ✓ |
|
|
191
|
+
| **BitShares `get_ticker(A, B)`** | A/B (base/quote) | `1 / value` | B/A ✓ |
|
|
192
|
+
| **Liquidity Pool Reserves** | `reserve_A / reserve_B` | `floatB / floatA` | B/A ✓ |
|
|
193
|
+
|
|
194
|
+
#### Implementation (`modules/order/utils/system.ts`)
|
|
195
|
+
|
|
196
|
+
**`deriveMarketPrice(BitShares, symA, symB)`**:
|
|
197
|
+
```javascript
|
|
198
|
+
// BitShares get_order_book(A, B) returns prices in A/B format
|
|
199
|
+
const mid = (bestBid + bestAsk) / 2; // e.g., 0.00074 (XRP per BTS)
|
|
200
|
+
return 1 / mid; // Convert to B/A: 1/0.00074 ≈ 1350 (BTS per XRP)
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
**`derivePoolPrice(BitShares, symA, symB)`**:
|
|
204
|
+
```javascript
|
|
205
|
+
// Pool reserves come from blockchain in order [reserve_A, reserve_B]
|
|
206
|
+
const floatA = safeBlockchainToFloat(amtA, aMeta.precision);
|
|
207
|
+
const floatB = safeBlockchainToFloat(amtB, bMeta.precision);
|
|
208
|
+
return floatB / floatA; // Already B/A: 3000000 BTS / 20000 XRP = 150 (BTS/XRP)
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
#### Why This Matters
|
|
212
|
+
|
|
213
|
+
- **Grid Placement**: `startPrice` determines where BUY orders (below) and SELL orders (above) are placed
|
|
214
|
+
- **Consistency**: Both market and pool prices use B/A so they're directly comparable
|
|
215
|
+
- **Debugging**: Inverted prices cause bot to place orders on the wrong side of the market (e.g., massive sells when market rises)
|
|
216
|
+
|
|
217
|
+
#### Common Debugging Pattern
|
|
218
|
+
|
|
219
|
+
If you see prices like `0.000795` when expecting `1350`:
|
|
220
|
+
1. This is likely A/B format (raw from API)
|
|
221
|
+
2. Check if inversion (`1 / price`) is being applied
|
|
222
|
+
3. Verify which function is missing the conversion
|
|
223
|
+
|
|
224
|
+
---
|
|
225
|
+
|
|
226
|
+
## Precision & Quantization Best Practices
|
|
227
|
+
|
|
228
|
+
**Problem**: Floating-point arithmetic accumulates rounding errors over many calculations. After repeated price derivations, fund allocations, and order sizing, float values drift from their true blockchain precision.
|
|
229
|
+
|
|
230
|
+
**Solution**: Use centralized quantization utilities from `modules/order/utils/math.ts` to eliminate accumulation.
|
|
231
|
+
|
|
232
|
+
### When to Quantize
|
|
233
|
+
|
|
234
|
+
| Situation | Use Function | Why |
|
|
235
|
+
|-----------|--------------|-----|
|
|
236
|
+
| **Calculating order sizes** | `quantizeFloat()` | Geometric weighting produces float errors; snap to satoshi precision |
|
|
237
|
+
| **Fund allocation** | `quantizeFloat()` | After dividing total by weights, accumulation errors occur |
|
|
238
|
+
| **Price derivations** | `quantizeFloat()` | Pool/market calculations prone to float drift |
|
|
239
|
+
| **Comparing sizes** | `normalizeInt()` | Ensure both values use same integer representation before == |
|
|
240
|
+
| **Validating blockchain match** | `normalizeInt()` | Check internal ≈ chain by normalizing both sides |
|
|
241
|
+
|
|
242
|
+
### Code Example: Correct vs Incorrect
|
|
243
|
+
|
|
244
|
+
```javascript
|
|
245
|
+
// ❌ WRONG - Float accumulation errors
|
|
246
|
+
const sizes = [];
|
|
247
|
+
const base = 0.995;
|
|
248
|
+
const totalFunds = 100.12345678;
|
|
249
|
+
for (let i = 0; i < 5; i++) {
|
|
250
|
+
const weight = Math.pow(base, i);
|
|
251
|
+
sizes.push((weight / sumWeights) * totalFunds); // Drift accumulates!
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
// ✅ CORRECT - Quantized to precision
|
|
255
|
+
import { quantizeFloat } from '../order/utils/math';
|
|
256
|
+
const sizes = [];
|
|
257
|
+
const precision = 8;
|
|
258
|
+
const base = 0.995;
|
|
259
|
+
const totalFunds = 100.12345678;
|
|
260
|
+
for (let i = 0; i < 5; i++) {
|
|
261
|
+
const weight = Math.pow(base, i);
|
|
262
|
+
const size = (weight / sumWeights) * totalFunds;
|
|
263
|
+
sizes.push(quantizeFloat(size, precision)); // Snap to satoshi
|
|
264
|
+
}
|
|
265
|
+
// Result: All sizes align to 8 decimal places, no drift
|
|
266
|
+
```
|
|
267
|
+
|
|
268
|
+
### Import Pattern
|
|
269
|
+
|
|
270
|
+
```javascript
|
|
271
|
+
import { quantizeFloat, normalizeInt } from '../order/utils/math';
|
|
272
|
+
|
|
273
|
+
// Quantize a float value (e.g., 45.123456789 → 45.12345679)
|
|
274
|
+
const correctedPrice = quantizeFloat(derivedPrice, 8);
|
|
275
|
+
|
|
276
|
+
// Normalize an integer (e.g., ensure consistency in comparisons)
|
|
277
|
+
const normalized = normalizeInt(currentSizeInt, assetPrecision);
|
|
278
|
+
```
|
|
279
|
+
|
|
280
|
+
**See [FUND_MOVEMENT_AND_ACCOUNTING.md § 5.5](FUND_MOVEMENT_AND_ACCOUNTING.md#55-precision--quantization-patch-14) for complete quantization guide and edge case handling.**
|
|
281
|
+
|
|
282
|
+
---
|
|
283
|
+
|
|
284
|
+
## Module Deep Dive
|
|
285
|
+
|
|
286
|
+
### OrderManager (`modules/order/manager.ts`)
|
|
287
|
+
|
|
288
|
+
**Role**: Central coordinator for all order operations
|
|
289
|
+
|
|
290
|
+
**Key Responsibilities**:
|
|
291
|
+
- Maintain **immutable** master grid (`orders` Map, frozen via `Object.freeze()`)
|
|
292
|
+
- Enforce Copy-on-Write rebalancing via `WorkingGrid` and atomic commits
|
|
293
|
+
- Coordinate specialized engines (Accountant, Strategy, Sync, Grid)
|
|
294
|
+
- Manage order indices for fast lookups
|
|
295
|
+
- Handle order locking to prevent race conditions
|
|
296
|
+
|
|
297
|
+
**Critical Methods**:
|
|
298
|
+
```javascript
|
|
299
|
+
// Central state update - ALWAYS use this, never modify orders Map directly
|
|
300
|
+
// Signature: _updateOrder(order, context = 'updateOrder', options = {})
|
|
301
|
+
_updateOrder(order, context, { skipAccounting, fee })
|
|
302
|
+
|
|
303
|
+
// COW rebalance pipeline
|
|
304
|
+
performSafeRebalance(fills, excludeIds) // Entry point; delegates to COW
|
|
305
|
+
_applySafeRebalanceCOW(fills, excludeIds) // Creates WorkingGrid, runs planning
|
|
306
|
+
_reconcileGridCOW(targetGrid, boundary, wg) // Computes delta against working copy
|
|
307
|
+
_commitWorkingGrid(workingGrid, indexes, boundary, { skipRecalc }) // Atomic swap: working → master
|
|
308
|
+
|
|
309
|
+
// COW state tracking
|
|
310
|
+
_setRebalanceState(state) // NORMAL | REBALANCING | BROADCASTING
|
|
311
|
+
_currentWorkingGrid // Reference to active WorkingGrid (for fill sync)
|
|
312
|
+
|
|
313
|
+
// Fast lookups using indices
|
|
314
|
+
getOrdersByTypeAndState(type, state)
|
|
315
|
+
|
|
316
|
+
// Concurrency control
|
|
317
|
+
lockOrders([orderId])
|
|
318
|
+
unlockOrders([orderId])
|
|
319
|
+
isOrderLocked(orderId)
|
|
320
|
+
|
|
321
|
+
// Batch optimization
|
|
322
|
+
pauseFundRecalc()
|
|
323
|
+
resumeFundRecalc()
|
|
324
|
+
```
|
|
325
|
+
|
|
326
|
+
> **COW Rule**: The `orders` Map is frozen. Never call `manager.orders.set()` directly. All mutations go through `_applyOrderUpdate()` (for master changes) or the WorkingGrid (for planning). The master is only replaced inside `_commitWorkingGrid()` after blockchain success.
|
|
327
|
+
|
|
328
|
+
**Common Patterns**:
|
|
329
|
+
```javascript
|
|
330
|
+
// Pattern 1: Simple order state update (uses defaults)
|
|
331
|
+
manager._updateOrder({
|
|
332
|
+
id: 'buy-5',
|
|
333
|
+
state: ORDER_STATES.ACTIVE,
|
|
334
|
+
type: ORDER_TYPES.BUY,
|
|
335
|
+
price: 0.5,
|
|
336
|
+
size: 100,
|
|
337
|
+
orderId: '1.7.12345'
|
|
338
|
+
});
|
|
339
|
+
|
|
340
|
+
// Pattern 2: Update with context and fee (for blockchain operations)
|
|
341
|
+
manager._updateOrder(
|
|
342
|
+
{ id: 'buy-5', state: ORDER_STATES.VIRTUAL, orderId: null },
|
|
343
|
+
'cancel-order', // context for logging
|
|
344
|
+
{ skipAccounting: false, fee: 0 } // update balances, no cancel fee
|
|
345
|
+
);
|
|
346
|
+
|
|
347
|
+
// Pattern 3: Batch updates with pause/resume
|
|
348
|
+
manager.pauseFundRecalc();
|
|
349
|
+
for (const order of orders) {
|
|
350
|
+
manager._updateOrder(order, 'rebalance-batch', { skipAccounting: false, fee: 0 });
|
|
351
|
+
}
|
|
352
|
+
manager.resumeFundRecalc(); // Recalculates once at end
|
|
353
|
+
|
|
354
|
+
// Pattern 4: Safe async operations
|
|
355
|
+
manager.lockOrders([orderId]);
|
|
356
|
+
try {
|
|
357
|
+
await chainOperation();
|
|
358
|
+
} finally {
|
|
359
|
+
manager.unlockOrders([orderId]);
|
|
360
|
+
}
|
|
361
|
+
```
|
|
362
|
+
|
|
363
|
+
---
|
|
364
|
+
|
|
365
|
+
## Phantom Orders Prevention (Defense-in-Depth)
|
|
366
|
+
|
|
367
|
+
### Why This Matters
|
|
368
|
+
|
|
369
|
+
**Phantom orders** are orders that exist in memory as ACTIVE/PARTIAL state but lack a corresponding blockchain `orderId`. This causes fund tracking corruption:
|
|
370
|
+
- Memory shows orders locked in `committed.grid` but blockchain has no such orders
|
|
371
|
+
- Leads to "doubled funds" warnings where `trackedTotal >> blockchainTotal`
|
|
372
|
+
- Causes high RMS divergence with many unmatched orders
|
|
373
|
+
- Can lock funds indefinitely if not detected
|
|
374
|
+
|
|
375
|
+
### Three-Layer Prevention System
|
|
376
|
+
|
|
377
|
+
#### Layer 1: Primary Guard in `OrderManager._updateOrder()` (manager.ts)
|
|
378
|
+
|
|
379
|
+
**The Critical Validation**:
|
|
380
|
+
```javascript
|
|
381
|
+
// Centralized check - ALL state transitions go through here
|
|
382
|
+
if ((order.state === ORDER_STATES.ACTIVE || order.state === ORDER_STATES.PARTIAL) && !order.orderId) {
|
|
383
|
+
logger.log(
|
|
384
|
+
`ILLEGAL STATE: Refusing to set order ${id} to ${order.state} without orderId. ` +
|
|
385
|
+
`Context: ${context}. This would create a phantom order that doubles fund tracking. ` +
|
|
386
|
+
`Downgrading to VIRTUAL instead.`,
|
|
387
|
+
'error'
|
|
388
|
+
);
|
|
389
|
+
order.state = ORDER_STATES.VIRTUAL; // Auto-correct
|
|
390
|
+
}
|
|
391
|
+
```
|
|
392
|
+
|
|
393
|
+
**Why It Works**:
|
|
394
|
+
- Every order state change must call `_updateOrder()` (enforced throughout codebase)
|
|
395
|
+
- Cannot be bypassed - direct state assignments are not used for order state
|
|
396
|
+
- Applies to ALL modules: grid, sync, strategy, dexbot_class
|
|
397
|
+
- Auto-correction with logging provides audit trail
|
|
398
|
+
|
|
399
|
+
#### Layer 2: Grid Resize Protection (grid.ts)
|
|
400
|
+
|
|
401
|
+
**Before (Vulnerable)**:
|
|
402
|
+
```javascript
|
|
403
|
+
manager._updateOrder({ ...order, size: newSize, state: ORDER_STATES.ACTIVE }, 'grid-resize', ...);
|
|
404
|
+
```
|
|
405
|
+
|
|
406
|
+
**After (Safe)**:
|
|
407
|
+
```javascript
|
|
408
|
+
manager._updateOrder({ ...order, size: newSize, state: order.state }, 'grid-resize', ...);
|
|
409
|
+
```
|
|
410
|
+
|
|
411
|
+
**Why It Matters**: Preserves order's current state instead of forcing ACTIVE, preventing VIRTUAL → ACTIVE phantom creation during grid resizing.
|
|
412
|
+
|
|
413
|
+
#### Layer 3: Sync Cleanup (sync_engine.ts)
|
|
414
|
+
|
|
415
|
+
**Phantom Detection & Prevention**:
|
|
416
|
+
```javascript
|
|
417
|
+
// If order has no ID OR its ID is not on chain, it's a phantom/filled order
|
|
418
|
+
if (!currentGridOrder?.orderId || !parsedChainOrders.has(currentGridOrder.orderId)) {
|
|
419
|
+
const spreadOrder = convertToSpreadPlaceholder(currentGridOrder);
|
|
420
|
+
mgr._updateOrder(spreadOrder, 'sync-cleanup-phantom', ...);
|
|
421
|
+
|
|
422
|
+
// CRITICAL: Only trigger fill processing for GENUINE fills (had orderId)
|
|
423
|
+
// Phantoms (never had orderId) should NOT trigger rotations/rebalancing
|
|
424
|
+
if (currentGridOrder?.orderId) {
|
|
425
|
+
filledOrders.push({ ...currentGridOrder });
|
|
426
|
+
}
|
|
427
|
+
}
|
|
428
|
+
```
|
|
429
|
+
|
|
430
|
+
**Why It Matters**:
|
|
431
|
+
- Detects phantoms on every sync
|
|
432
|
+
- Converts to SPREAD placeholders (releases locked funds)
|
|
433
|
+
- Prevents phantom fills from triggering unwarranted rotations/rebalancing
|
|
434
|
+
|
|
435
|
+
### Additional Hardening
|
|
436
|
+
|
|
437
|
+
**Strategy Module** (strategy.ts):
|
|
438
|
+
```javascript
|
|
439
|
+
// Only upgrade to ACTIVE if order has valid orderId
|
|
440
|
+
const newState = partial.orderId ? ORDER_STATES.ACTIVE : ORDER_STATES.VIRTUAL;
|
|
441
|
+
```
|
|
442
|
+
|
|
443
|
+
**Fallback Placements** (dexbot_class.ts):
|
|
444
|
+
```javascript
|
|
445
|
+
const fallbackPlacements = unmetRotations.map(r => ({
|
|
446
|
+
id: r.newGridId,
|
|
447
|
+
price: r.newPrice,
|
|
448
|
+
size: r.newSize,
|
|
449
|
+
type: r.type,
|
|
450
|
+
state: ORDER_STATES.VIRTUAL // Start VIRTUAL, become ACTIVE after blockchain confirmation
|
|
451
|
+
}));
|
|
452
|
+
```
|
|
453
|
+
|
|
454
|
+
### Testing
|
|
455
|
+
|
|
456
|
+
See `tests/repro_phantom_orders.ts` for comprehensive test coverage:
|
|
457
|
+
- Direct phantom creation attempt (blocked)
|
|
458
|
+
- Grid resize phantom prevention (verified)
|
|
459
|
+
- Sync cleanup of orphaned ACTIVE orders (verified)
|
|
460
|
+
- Valid ACTIVE order preservation (verified)
|
|
461
|
+
|
|
462
|
+
---
|
|
463
|
+
|
|
464
|
+
## Copy-on-Write (COW) Development Rules
|
|
465
|
+
|
|
466
|
+
The COW architecture is the **single standard** for grid mutations. All new rebalancing code must follow these rules.
|
|
467
|
+
|
|
468
|
+
### The Golden Rule
|
|
469
|
+
|
|
470
|
+
> The master grid (`manager.orders`) is **read-only** for strategy code. Only `_applyOrderUpdate()` (internal) and `_commitWorkingGrid()` (COW commit) may replace it.
|
|
471
|
+
|
|
472
|
+
### Rebalance Pipeline (Required Pattern)
|
|
473
|
+
|
|
474
|
+
```javascript
|
|
475
|
+
// 1. Entry: performSafeRebalance() creates WorkingGrid automatically
|
|
476
|
+
// → calls _applySafeRebalanceCOW(fills, excludeIds)
|
|
477
|
+
|
|
478
|
+
// 2. Planning: Work on the working copy ONLY
|
|
479
|
+
const workingGrid = new WorkingGrid(manager.orders, { baseVersion: manager._gridVersion });
|
|
480
|
+
workingGrid.set(orderId, updatedOrder); // OK - modifies clone, not master
|
|
481
|
+
|
|
482
|
+
// 3. Broadcast: _updateOrdersOnChainBatchCOW() sends ops to chain
|
|
483
|
+
// → On success: _commitWorkingGrid() atomically replaces master
|
|
484
|
+
// → On failure: workingGrid discarded (master unchanged)
|
|
485
|
+
```
|
|
486
|
+
|
|
487
|
+
### What New Code Must NOT Do
|
|
488
|
+
|
|
489
|
+
```javascript
|
|
490
|
+
// ❌ WRONG: Direct master mutation
|
|
491
|
+
manager.orders.set('buy-5', order); // Throws (frozen Map)
|
|
492
|
+
manager.orders.get('buy-5').size = 100; // Throws (deepFrozen object)
|
|
493
|
+
|
|
494
|
+
// ❌ WRONG: Bypassing _applyOrderUpdate for blockchain-confirmed changes
|
|
495
|
+
manager.orders = new Map([...manager.orders]); // Breaks version + index tracking
|
|
496
|
+
|
|
497
|
+
// ✅ CORRECT: State changes for confirmed blockchain events
|
|
498
|
+
manager._applyOrderUpdate(order, 'my-context'); // Updates master + increments version
|
|
499
|
+
|
|
500
|
+
// ✅ CORRECT: Planning changes during rebalance
|
|
501
|
+
workingGrid.set(orderId, newOrderState); // Safe - working copy only
|
|
502
|
+
```
|
|
503
|
+
|
|
504
|
+
### Fill Handling During Rebalance
|
|
505
|
+
|
|
506
|
+
| COW State | Fill Arrives | Action |
|
|
507
|
+
|-----------|-------------|--------|
|
|
508
|
+
| `NORMAL` | Individual fill | Process immediately, update master |
|
|
509
|
+
| `REBALANCING` | Individual fill | Update master + `workingGrid.syncFromMaster(master, id)` |
|
|
510
|
+
| `BROADCASTING` | Individual fill | Update master + mark working grid stale; commit guard will reject |
|
|
511
|
+
| `REBALANCING`/`BROADCASTING` | Full side update | Block until fills = 0 or abort |
|
|
512
|
+
|
|
513
|
+
For full details see [COPY_ON_WRITE_MASTER_PLAN.md](COPY_ON_WRITE_MASTER_PLAN.md).
|
|
514
|
+
|
|
515
|
+
---
|
|
516
|
+
|
|
517
|
+
## Order State Helper Functions
|
|
518
|
+
|
|
519
|
+
**Location**: `modules/order/utils/order.ts`
|
|
520
|
+
|
|
521
|
+
**Purpose**: Single source of truth for order state logic, replacing 34+ inline checks scattered across the codebase.
|
|
522
|
+
|
|
523
|
+
**Benefit**: Semantic function names, centralized phantom detection, consistent patterns across all modules.
|
|
524
|
+
|
|
525
|
+
### Core State Checkers
|
|
526
|
+
|
|
527
|
+
#### `isOrderOnChain(order)`
|
|
528
|
+
```javascript
|
|
529
|
+
// Check if order exists on blockchain
|
|
530
|
+
// Returns true for ACTIVE or PARTIAL orders
|
|
531
|
+
if (isOrderOnChain(order)) {
|
|
532
|
+
// Order has presence on blockchain
|
|
533
|
+
}
|
|
534
|
+
```
|
|
535
|
+
|
|
536
|
+
#### `isOrderVirtual(order)`
|
|
537
|
+
```javascript
|
|
538
|
+
// Check if order is planned but not yet placed
|
|
539
|
+
// Returns true for VIRTUAL orders
|
|
540
|
+
if (isOrderVirtual(order)) {
|
|
541
|
+
// Order is reserved capital but not on-chain yet
|
|
542
|
+
}
|
|
543
|
+
```
|
|
544
|
+
|
|
545
|
+
#### `hasOnChainId(order)`
|
|
546
|
+
```javascript
|
|
547
|
+
// Check if order has a valid blockchain orderId
|
|
548
|
+
// Returns true if orderId is non-null and non-empty
|
|
549
|
+
if (hasOnChainId(order)) {
|
|
550
|
+
// Order has been successfully placed and confirmed
|
|
551
|
+
}
|
|
552
|
+
```
|
|
553
|
+
|
|
554
|
+
#### `isOrderPlaced(order)`
|
|
555
|
+
```javascript
|
|
556
|
+
// Check if order is safely placed (on-chain with ID)
|
|
557
|
+
// Combines: state === ACTIVE/PARTIAL AND orderId exists
|
|
558
|
+
if (isOrderPlaced(order)) {
|
|
559
|
+
// Safe to use in calculations requiring blockchain confirmation
|
|
560
|
+
}
|
|
561
|
+
```
|
|
562
|
+
|
|
563
|
+
#### `isPhantomOrder(order)`
|
|
564
|
+
```javascript
|
|
565
|
+
// Detect phantom orders (on-chain state without ID - error state)
|
|
566
|
+
// Returns true for ACTIVE/PARTIAL orders WITHOUT orderId
|
|
567
|
+
if (isPhantomOrder(order)) {
|
|
568
|
+
// ERROR: This order shouldn't exist - fund tracking is corrupt
|
|
569
|
+
logger.error(`Phantom order detected: ${order.id}`);
|
|
570
|
+
}
|
|
571
|
+
```
|
|
572
|
+
|
|
573
|
+
#### `isSlotAvailable(order)`
|
|
574
|
+
```javascript
|
|
575
|
+
// Check if slot can be reused (VIRTUAL + no ID)
|
|
576
|
+
// Returns true for VIRTUAL orders without orderId
|
|
577
|
+
if (isSlotAvailable(order)) {
|
|
578
|
+
// Can overwrite this slot with a new order
|
|
579
|
+
}
|
|
580
|
+
```
|
|
581
|
+
|
|
582
|
+
### State Transition Helpers
|
|
583
|
+
|
|
584
|
+
#### `virtualizeOrder(order)`
|
|
585
|
+
```javascript
|
|
586
|
+
// Transition order to VIRTUAL state and clear blockchain metadata
|
|
587
|
+
// Preserves the order's type (BUY/SELL) and size — use when the order
|
|
588
|
+
// should remain pickable on its original rail (e.g. reservation keep).
|
|
589
|
+
const virtualizedOrder = virtualizeOrder(order);
|
|
590
|
+
// Result: {
|
|
591
|
+
// ...order,
|
|
592
|
+
// state: ORDER_STATES.VIRTUAL,
|
|
593
|
+
// orderId: null,
|
|
594
|
+
// filledSize: 0
|
|
595
|
+
// }
|
|
596
|
+
```
|
|
597
|
+
|
|
598
|
+
#### `convertToSpreadPlaceholder(order)`
|
|
599
|
+
```javascript
|
|
600
|
+
// Transition order to a side-neutral SPREAD placeholder.
|
|
601
|
+
// Zeroes size AND sets type to SPREAD — use when the slot becomes an
|
|
602
|
+
// empty reusable placeholder that may be activated on either rail.
|
|
603
|
+
const placeholder = convertToSpreadPlaceholder(order);
|
|
604
|
+
// Result: {
|
|
605
|
+
// ...order,
|
|
606
|
+
// state: ORDER_STATES.VIRTUAL,
|
|
607
|
+
// type: ORDER_TYPES.SPREAD,
|
|
608
|
+
// orderId: null,
|
|
609
|
+
// size: 0
|
|
610
|
+
// }
|
|
611
|
+
```
|
|
612
|
+
|
|
613
|
+
### Order Health Validation
|
|
614
|
+
|
|
615
|
+
#### `isOrderHealthy(order, minSize)`
|
|
616
|
+
```javascript
|
|
617
|
+
// Comprehensive validation: size > 0 AND not dust-threshold
|
|
618
|
+
// Prevents undersized orders that cause blockchain failures
|
|
619
|
+
const minHealthySize = getMinOrderSize(ORDER_TYPES.BUY, assets, 1.0);
|
|
620
|
+
if (isOrderHealthy(order, minHealthySize)) {
|
|
621
|
+
// Order is valid for placement/rotation
|
|
622
|
+
} else {
|
|
623
|
+
// Order is dust - consolidate or skip
|
|
624
|
+
}
|
|
625
|
+
```
|
|
626
|
+
|
|
627
|
+
### Precision Helpers
|
|
628
|
+
|
|
629
|
+
#### `getPrecisionSlack(precision, factor)`
|
|
630
|
+
```javascript
|
|
631
|
+
// Calculate float comparison tolerance for given precision
|
|
632
|
+
// Returns: 10^(-precision) * factor (typically factor = 0.001 = 0.1%)
|
|
633
|
+
const slack = getPrecisionSlack(5, 0.001); // Returns 0.00001 * 0.001 = 0.00000001
|
|
634
|
+
|
|
635
|
+
// Use case: Floating-point safe comparisons
|
|
636
|
+
if (Math.abs(order.size - expected) <= slack) {
|
|
637
|
+
// Sizes match within precision tolerance
|
|
638
|
+
}
|
|
639
|
+
```
|
|
640
|
+
|
|
641
|
+
**Eliminates duplications in**:
|
|
642
|
+
- `accounting.ts::recalculateFunds()`
|
|
643
|
+
- `manager.ts::_updateOrder()`
|
|
644
|
+
|
|
645
|
+
### Common Usage Patterns
|
|
646
|
+
|
|
647
|
+
**Pattern 1: Type-safe Order Placement**
|
|
648
|
+
```javascript
|
|
649
|
+
// Only place orders that are truly safe
|
|
650
|
+
const ordersToPlace = orders.filter(o =>
|
|
651
|
+
isOrderHealthy(o, minSize) && !isOrderPlaced(o)
|
|
652
|
+
);
|
|
653
|
+
```
|
|
654
|
+
|
|
655
|
+
**Pattern 2: Phantom Detection During Sync**
|
|
656
|
+
```javascript
|
|
657
|
+
// Detect and cleanup phantoms during blockchain sync
|
|
658
|
+
for (const order of allOrders) {
|
|
659
|
+
if (isPhantomOrder(order)) {
|
|
660
|
+
const placeholder = convertToSpreadPlaceholder(order);
|
|
661
|
+
mgr._updateOrder(placeholder, 'sync-cleanup-phantom', { skipAccounting: false, fee: 0 });
|
|
662
|
+
}
|
|
663
|
+
}
|
|
664
|
+
```
|
|
665
|
+
|
|
666
|
+
**Pattern 3: Reusable Slot Identification**
|
|
667
|
+
```javascript
|
|
668
|
+
// Find slots available for overwriting
|
|
669
|
+
const reusableSlots = grid.filter(isSlotAvailable);
|
|
670
|
+
for (const slot of reusableSlots) {
|
|
671
|
+
slot = createNewOrder(slot.index, newPrice);
|
|
672
|
+
}
|
|
673
|
+
```
|
|
674
|
+
|
|
675
|
+
---
|
|
676
|
+
|
|
677
|
+
### Accountant (`modules/order/accounting.ts`)
|
|
678
|
+
|
|
679
|
+
**Role**: Fund tracking and fee management
|
|
680
|
+
|
|
681
|
+
**Key Responsibilities**:
|
|
682
|
+
- Calculate available funds for each side
|
|
683
|
+
- Verify fund invariants
|
|
684
|
+
- Manage BTS transaction fees
|
|
685
|
+
- Atomic fund deduction
|
|
686
|
+
|
|
687
|
+
**Critical Methods**:
|
|
688
|
+
```javascript
|
|
689
|
+
// Master fund calculation - called after every state change
|
|
690
|
+
recalculateFunds()
|
|
691
|
+
|
|
692
|
+
// Atomic fund operations
|
|
693
|
+
tryDeductFromChainFree(orderType, size, operation)
|
|
694
|
+
addToChainFree(orderType, size, operation)
|
|
695
|
+
|
|
696
|
+
// Fee management
|
|
697
|
+
deductBtsFees(requestedSide)
|
|
698
|
+
|
|
699
|
+
// Safety checks
|
|
700
|
+
_verifyFundInvariants(mgr, chainFreeBuy, chainFreeSell, chainBuy, chainSell, actualBuy, actualSell)
|
|
701
|
+
```
|
|
702
|
+
|
|
703
|
+
**Fund Calculation Flow**:
|
|
704
|
+
```javascript
|
|
705
|
+
// 1. Reset all fund pools
|
|
706
|
+
resetFunds()
|
|
707
|
+
|
|
708
|
+
// 2. Iterate all orders and accumulate
|
|
709
|
+
for (const order of orders) {
|
|
710
|
+
if (order.state === VIRTUAL) {
|
|
711
|
+
funds.virtual[side] += order.size
|
|
712
|
+
} else if (order.state === ACTIVE || order.state === PARTIAL) {
|
|
713
|
+
funds.committed.grid[side] += order.size
|
|
714
|
+
if (order.orderId) {
|
|
715
|
+
funds.committed.chain[side] += order.size
|
|
716
|
+
}
|
|
717
|
+
}
|
|
718
|
+
}
|
|
719
|
+
|
|
720
|
+
// 3. Calculate available
|
|
721
|
+
funds.available[side] = max(0,
|
|
722
|
+
chainFree - virtual - btsFeesOwed - btsFeesReservation
|
|
723
|
+
)
|
|
724
|
+
|
|
725
|
+
// 4. Verify invariants (signature: mgr, chainFreeBuy, chainFreeSell, chainBuy, chainSell, actualBuy, actualSell)
|
|
726
|
+
_verifyFundInvariants(...)
|
|
727
|
+
```
|
|
728
|
+
|
|
729
|
+
---
|
|
730
|
+
|
|
731
|
+
### StrategyEngine (`modules/order/strategy.ts`)
|
|
732
|
+
|
|
733
|
+
**Role**: Grid rebalancing and order rotation
|
|
734
|
+
|
|
735
|
+
**Key Responsibilities**:
|
|
736
|
+
- Process filled orders
|
|
737
|
+
- Identify shortages and surpluses
|
|
738
|
+
- Execute order rotations
|
|
739
|
+
- Handle partial order consolidation
|
|
740
|
+
|
|
741
|
+
**Critical Methods**:
|
|
742
|
+
```javascript
|
|
743
|
+
// Pure target grid calculation — no side effects
|
|
744
|
+
calculateTargetGrid(params)
|
|
745
|
+
|
|
746
|
+
// Fill processing (fund updates only, no rebalance trigger)
|
|
747
|
+
processFillsOnly(filledOrders, excludeOrderIds)
|
|
748
|
+
|
|
749
|
+
// Dust detection
|
|
750
|
+
hasAnyDust(partials, side)
|
|
751
|
+
```
|
|
752
|
+
|
|
753
|
+
**Rebalancing Algorithm**:
|
|
754
|
+
```javascript
|
|
755
|
+
// 1. Determine reference price from fills or market
|
|
756
|
+
// 2. Calculate gap slots for spread zone
|
|
757
|
+
// 3. Determine split index (boundary location in sorted prices)
|
|
758
|
+
// 4. Assign roles: BUY below boundary, SPREAD within gap, SELL above
|
|
759
|
+
// 5. Calculate order sizes from budget
|
|
760
|
+
// 6. Return { targetGrid: Map, boundaryIdx: number }
|
|
761
|
+
```
|
|
762
|
+
|
|
763
|
+
---
|
|
764
|
+
|
|
765
|
+
### Grid (`modules/order/grid.ts`)
|
|
766
|
+
|
|
767
|
+
**Role**: Grid creation, sizing, and divergence detection
|
|
768
|
+
|
|
769
|
+
**Key Responsibilities**:
|
|
770
|
+
- Create geometric price grids
|
|
771
|
+
- Calculate spread gap size
|
|
772
|
+
- Detect grid divergence
|
|
773
|
+
- Update order sizes from blockchain
|
|
774
|
+
|
|
775
|
+
**Critical Methods**:
|
|
776
|
+
```javascript
|
|
777
|
+
// Create initial grid
|
|
778
|
+
createOrderGrid(config)
|
|
779
|
+
|
|
780
|
+
// Initialize with blockchain balances
|
|
781
|
+
initializeGrid(manager)
|
|
782
|
+
|
|
783
|
+
// Detect divergence and trigger updates
|
|
784
|
+
checkAndUpdateGridIfNeeded(manager)
|
|
785
|
+
|
|
786
|
+
// Compare ideal vs. persisted grid
|
|
787
|
+
compareGrids(calculatedGrid, persistedGrid, manager)
|
|
788
|
+
```
|
|
789
|
+
|
|
790
|
+
**Grid Creation Flow**:
|
|
791
|
+
```javascript
|
|
792
|
+
// 1. Calculate spread gap size
|
|
793
|
+
const stepFactor = 1 + (incrementPercent / 100);
|
|
794
|
+
const minSteps = MIN_SPREAD_FACTOR; // 2
|
|
795
|
+
const targetSteps = ceil(ln(1 + targetSpread/100) / ln(stepFactor));
|
|
796
|
+
const gapSlots = max(minSteps, targetSteps - 1); // Account for naturally occurring center gap
|
|
797
|
+
|
|
798
|
+
// 2. Generate price levels
|
|
799
|
+
const prices = [];
|
|
800
|
+
let price = startPrice;
|
|
801
|
+
for (let i = 0; i < totalLevels; i++) {
|
|
802
|
+
prices.push(price);
|
|
803
|
+
price *= stepFactor;
|
|
804
|
+
}
|
|
805
|
+
|
|
806
|
+
// 3. Assign roles based on boundary
|
|
807
|
+
for (let i = 0; i < prices.length; i++) {
|
|
808
|
+
if (i <= boundaryIdx) {
|
|
809
|
+
type = BUY;
|
|
810
|
+
} else if (i <= boundaryIdx + gapSlots) {
|
|
811
|
+
type = SPREAD;
|
|
812
|
+
} else {
|
|
813
|
+
type = SELL;
|
|
814
|
+
}
|
|
815
|
+
}
|
|
816
|
+
```
|
|
817
|
+
|
|
818
|
+
---
|
|
819
|
+
|
|
820
|
+
### SyncEngine (`modules/order/sync_engine.ts`)
|
|
821
|
+
|
|
822
|
+
**Role**: Blockchain synchronization and fill detection
|
|
823
|
+
|
|
824
|
+
**Key Responsibilities**:
|
|
825
|
+
- Sync grid state with blockchain
|
|
826
|
+
- Detect filled orders
|
|
827
|
+
- Update account balances
|
|
828
|
+
- Match chain orders to grid orders
|
|
829
|
+
|
|
830
|
+
**Critical Methods**:
|
|
831
|
+
```javascript
|
|
832
|
+
// Main sync entry point
|
|
833
|
+
synchronizeWithChain(data, source)
|
|
834
|
+
|
|
835
|
+
// Sync from open orders
|
|
836
|
+
syncFromOpenOrders(openOrders, syncInfo)
|
|
837
|
+
|
|
838
|
+
// Sync from fill history
|
|
839
|
+
syncFromFillHistory(operation)
|
|
840
|
+
|
|
841
|
+
// Fetch account balances
|
|
842
|
+
fetchAccountBalancesAndSetTotals()
|
|
843
|
+
```
|
|
844
|
+
|
|
845
|
+
---
|
|
846
|
+
|
|
847
|
+
## Startup Sequence & Lock Ordering
|
|
848
|
+
|
|
849
|
+
### Unified Startup Flow
|
|
850
|
+
|
|
851
|
+
The bot startup has been consolidated into a shared sequence used by all entry points (`start()`, `startWithPrivateKey()`, CLI, PM2). This ensures identical behavior and eliminates maintenance burden from duplicate code.
|
|
852
|
+
|
|
853
|
+
#### Startup Phases (In Order)
|
|
854
|
+
|
|
855
|
+
```javascript
|
|
856
|
+
// Phase 1: Initialize state
|
|
857
|
+
_initializeStartupState()
|
|
858
|
+
├─ Verify account configuration
|
|
859
|
+
└─ Load existing or generate new grid state
|
|
860
|
+
|
|
861
|
+
// Phase 2: Set up account context
|
|
862
|
+
_setupAccountContext()
|
|
863
|
+
├─ Resolve account ID
|
|
864
|
+
├─ Load fund balances
|
|
865
|
+
└─ Initialize AccountOrders subscription
|
|
866
|
+
|
|
867
|
+
// Phase 3: Create order manager
|
|
868
|
+
// (OrderManager spawned with initial state)
|
|
869
|
+
|
|
870
|
+
// Phase 4: Run grid maintenance
|
|
871
|
+
_runGridMaintenance()
|
|
872
|
+
├─ Acquire _fillProcessingLock
|
|
873
|
+
└─ Execute maintenance logic:
|
|
874
|
+
├─ Threshold check (cache ratio)
|
|
875
|
+
├─ Divergence check (if threshold fails)
|
|
876
|
+
├─ Spread check (out-of-spread recovery)
|
|
877
|
+
└─ Health check (invariant verification)
|
|
878
|
+
|
|
879
|
+
// Phase 5: Finish startup
|
|
880
|
+
_finishStartupSequence()
|
|
881
|
+
├─ Mark bootstrap complete
|
|
882
|
+
├─ Begin fill processing
|
|
883
|
+
└─ Start periodic maintenance timer
|
|
884
|
+
```
|
|
885
|
+
|
|
886
|
+
### Lock Ordering for Deadlock Prevention
|
|
887
|
+
|
|
888
|
+
**Critical Rule: Always acquire locks in ascending level order**
|
|
889
|
+
|
|
890
|
+
The canonical 5-level hierarchy (defined at `manager.ts`):
|
|
891
|
+
|
|
892
|
+
```
|
|
893
|
+
Level 0: _fillProcessingLock (fill processing — outermost)
|
|
894
|
+
Level 1: _divergenceLock (divergence checks)
|
|
895
|
+
Level 2: _syncLock (sync operations — timeout-protected)
|
|
896
|
+
Level 3: _gridLock (grid mutations)
|
|
897
|
+
Level 4: _fundLock (fund operations — innermost)
|
|
898
|
+
```
|
|
899
|
+
|
|
900
|
+
All five locks live on the `OrderManager` instance. The `level` property is a
|
|
901
|
+
convention marker — AsyncLock does not enforce it at runtime.
|
|
902
|
+
|
|
903
|
+
**Why This Order?**
|
|
904
|
+
|
|
905
|
+
- Fill processing (Level 0) is the most frequent operation (high contention) — outermost so it serializes all inner work
|
|
906
|
+
- Divergence checks (Level 1) nest inside fill processing
|
|
907
|
+
- Sync operations (Level 2) are acquired before grid mutations — the timeout-protected lock is inner, so a stuck sync releases the outer lock
|
|
908
|
+
- Grid mutations (Level 3) and fund operations (Level 4) are innermost
|
|
909
|
+
- All paths follow the same order — the historical `gridLockAlreadyHeld` workaround flag has been eliminated
|
|
910
|
+
|
|
911
|
+
**`adjustTotalBalance` Locking Contract** (v1.4.7):
|
|
912
|
+
|
|
913
|
+
The public `adjustTotalBalance()` (Level 4) is now async and **acquires `_fundLock` internally**. Callers that already hold `_fundLock` (e.g. `recordFillBalances`) must use the private `_adjustTotalBalanceLocked()` sync helper instead to avoid redundant nested re-entrancy. Callers outside any `_fundLock` region (e.g. `_applyBalanceAdjustments`, fee settlement, rollback) should continue using `adjustTotalBalance()` with `await`.
|
|
914
|
+
|
|
915
|
+
**Example: Safe Pattern**
|
|
916
|
+
|
|
917
|
+
```javascript
|
|
918
|
+
// ✅ CORRECT: Fill lock acquired, then divergence lock
|
|
919
|
+
async processFill(fill) {
|
|
920
|
+
await this._fillProcessingLock.acquire();
|
|
921
|
+
try {
|
|
922
|
+
// Do fill processing...
|
|
923
|
+
|
|
924
|
+
// If divergence check needed:
|
|
925
|
+
await this._divergenceLock.acquire();
|
|
926
|
+
try {
|
|
927
|
+
// Check divergence...
|
|
928
|
+
} finally {
|
|
929
|
+
this._divergenceLock.release();
|
|
930
|
+
}
|
|
931
|
+
} finally {
|
|
932
|
+
this._fillProcessingLock.release();
|
|
933
|
+
}
|
|
934
|
+
}
|
|
935
|
+
|
|
936
|
+
// ❌ WRONG: Would deadlock if fill arrives during divergence check
|
|
937
|
+
async checkDivergence() {
|
|
938
|
+
await this._divergenceLock.acquire(); // Level 1 without Level 0!
|
|
939
|
+
try {
|
|
940
|
+
// ...
|
|
941
|
+
}
|
|
942
|
+
}
|
|
943
|
+
```
|
|
944
|
+
|
|
945
|
+
**Lock Scope in Startup**
|
|
946
|
+
|
|
947
|
+
The startup sequence uses a re-entrant async lock to ensure atomic operations. `AsyncLock` is re-entrant, so nested `acquire()` from within the same execution context runs the callback directly instead of queueing:
|
|
948
|
+
|
|
949
|
+
```javascript
|
|
950
|
+
async _runGridMaintenance() {
|
|
951
|
+
await this._fillProcessingLock.acquire();
|
|
952
|
+
try {
|
|
953
|
+
// All maintenance operations run atomically
|
|
954
|
+
// Fills cannot arrive mid-startup
|
|
955
|
+
} finally {
|
|
956
|
+
this._fillProcessingLock.release();
|
|
957
|
+
}
|
|
958
|
+
}
|
|
959
|
+
```
|
|
960
|
+
|
|
961
|
+
**Bootstrap Flag Safety**
|
|
962
|
+
|
|
963
|
+
The `isBootstrapping` flag is guaranteed to be cleared using try-finally:
|
|
964
|
+
|
|
965
|
+
```javascript
|
|
966
|
+
async start() {
|
|
967
|
+
manager.startBootstrap();
|
|
968
|
+
try {
|
|
969
|
+
// All startup phases...
|
|
970
|
+
} finally {
|
|
971
|
+
manager.finishBootstrap(); // Always cleared, even on error
|
|
972
|
+
}
|
|
973
|
+
}
|
|
974
|
+
```
|
|
975
|
+
|
|
976
|
+
### Zero-Amount Order Prevention
|
|
977
|
+
|
|
978
|
+
All new orders pass through two validation gates:
|
|
979
|
+
|
|
980
|
+
1. **Strategy/Grid Logic** (`strategy.ts`, `grid.ts`):
|
|
981
|
+
- Check: `size >= getMinOrderSize(type, assets, factor)`
|
|
982
|
+
- Double-dust threshold: `size >= minHealthySize`
|
|
983
|
+
- Prevents undersized placement attempts
|
|
984
|
+
|
|
985
|
+
2. **Broadcast Validation** (`dexbot_class.ts`):
|
|
986
|
+
- Check: `amount > 0` for each order
|
|
987
|
+
- Rejects zero-amount operations before blockchain transmission
|
|
988
|
+
- Triggers recovery sync on validation failure
|
|
989
|
+
|
|
990
|
+
**Recovery from Failed Batches**
|
|
991
|
+
|
|
992
|
+
If a batch broadcast fails, the bot performs recovery:
|
|
993
|
+
|
|
994
|
+
```javascript
|
|
995
|
+
try {
|
|
996
|
+
await broadcastBatch(orders); // Broadcasting
|
|
997
|
+
} catch (error) {
|
|
998
|
+
// Fresh balance fetch resets optimistic drift
|
|
999
|
+
await this.manager.fetchAccountTotals(this.accountId);
|
|
1000
|
+
|
|
1001
|
+
// Full sync aligns grid with blockchain reality
|
|
1002
|
+
const openOrders = await chainOrders.readOpenOrders(this.accountId);
|
|
1003
|
+
await this.manager.syncFromOpenOrders(openOrders, { skipAccounting: true });
|
|
1004
|
+
}
|
|
1005
|
+
```
|
|
1006
|
+
|
|
1007
|
+
---
|
|
1008
|
+
|
|
1009
|
+
## Managing Bot Configuration
|
|
1010
|
+
|
|
1011
|
+
### The `bots.json` Source of Truth
|
|
1012
|
+
|
|
1013
|
+
The bot's operational parameters are defined in `profiles/bots.json`. While most settings are loaded at startup, the system is designed to pick up manual changes to critical valuation parameters during its runtime.
|
|
1014
|
+
|
|
1015
|
+
#### Handling `startPrice`
|
|
1016
|
+
|
|
1017
|
+
The `startPrice` is the anchor for valuation (calculating the relative value of Asset A and Asset B). It can be configured in three ways:
|
|
1018
|
+
|
|
1019
|
+
1. **Fixed Numeric Price** (e.g., `105.5`):
|
|
1020
|
+
* The bot treats this as a **fixed anchor**.
|
|
1021
|
+
* Automatic price derivation from the market is **disabled**.
|
|
1022
|
+
* Used as the base for all grid math during a **Grid Reset**.
|
|
1023
|
+
|
|
1024
|
+
2. **"pool"**:
|
|
1025
|
+
* The bot fetches the current BitShares Liquidity Pool price.
|
|
1026
|
+
* Updated periodically every 4 hours.
|
|
1027
|
+
* Optional `poolRef` field pins the pool directly (e.g. `"poolRef": "1.19.48"`), bypassing pool discovery. Useful when the trading pair has no native pool — the bot prices from a proxy pool instead.
|
|
1028
|
+
|
|
1029
|
+
3. **"book"**:
|
|
1030
|
+
* The bot derives the price from the current order book.
|
|
1031
|
+
* Updated periodically every 4 hours.
|
|
1032
|
+
|
|
1033
|
+
### Numeric `startPrice` - Fixed Anchor
|
|
1034
|
+
|
|
1035
|
+
When you set a **numeric value** like `"startPrice": 105.5` in `bots.json`:
|
|
1036
|
+
|
|
1037
|
+
**Behavior**:
|
|
1038
|
+
- ✅ Auto-refresh is **DISABLED** - numeric value is treated as absolute anchor
|
|
1039
|
+
- ✅ Grid valuation uses this fixed price for all calculations
|
|
1040
|
+
- ✅ Grid remains stable during market moves (fund-driven rebalancing only)
|
|
1041
|
+
- ❌ Auto-derivation never happens - market/pool price is ignored
|
|
1042
|
+
|
|
1043
|
+
**Use Case**: You want absolute control over grid positioning regardless of current market conditions.
|
|
1044
|
+
|
|
1045
|
+
### Runtime Updates (The 4h Refresh)
|
|
1046
|
+
|
|
1047
|
+
The bot performs a **Periodic Configuration Refresh** (every 4 hours by default).
|
|
1048
|
+
|
|
1049
|
+
**For Dynamic Pricing** (`startPrice: "book"` or `startPrice: "pool"`):
|
|
1050
|
+
* **Valuation Update**: Fetches latest market/pool price and updates grid anchor
|
|
1051
|
+
* **Grid Reposition**: Subsequent grid resets use updated valuation
|
|
1052
|
+
* **Operational Stability**: During normal operation, the bot remains "fund-driven" and doesn't move orders on-chain
|
|
1053
|
+
|
|
1054
|
+
**For Numeric Pricing** (`startPrice: 105.5`):
|
|
1055
|
+
* **No Changes**: Fixed value is never updated
|
|
1056
|
+
* **Valuation locked**: All calculations use the configured numeric value
|
|
1057
|
+
* **Manual Override Required**: To change numeric anchor, edit `bots.json` and use the bot's reset trigger file.
|
|
1058
|
+
|
|
1059
|
+
* **Applying Changes**: To force the bot to move orders to a new `startPrice` immediately, create `profiles/recalculate.<botKey>.trigger` to perform a full grid reset. Empty or malformed trigger files are treated as manual/legacy resets; for AMA bots the runtime refreshes `gridCenterPrice` from the latest `amaCenterPrice` before rebuilding.
|
|
1060
|
+
|
|
1061
|
+
---
|
|
1062
|
+
|
|
1063
|
+
## Debt Policy Configuration
|
|
1064
|
+
|
|
1065
|
+
Bots can declare a `debtPolicy` block for native MPA and credit-offer workflows.
|
|
1066
|
+
|
|
1067
|
+
### Example `debtPolicy`
|
|
1068
|
+
|
|
1069
|
+
```json
|
|
1070
|
+
{
|
|
1071
|
+
"name": "credit-bot-1",
|
|
1072
|
+
"debtPolicy": {
|
|
1073
|
+
"lending": [
|
|
1074
|
+
{
|
|
1075
|
+
"asset": "HONEST.USD",
|
|
1076
|
+
"collateralAsset": "BTS",
|
|
1077
|
+
"type": "mpa",
|
|
1078
|
+
"maxBorrowAmount": 1000,
|
|
1079
|
+
"maxCollateralAmount": 25000,
|
|
1080
|
+
"minCollateralRatio": 2.0,
|
|
1081
|
+
"maxCollateralRatio": 2.5,
|
|
1082
|
+
"targetCollateralRatio": 2.2,
|
|
1083
|
+
"minCollateralIncreaseThreshold": 5
|
|
1084
|
+
},
|
|
1085
|
+
{
|
|
1086
|
+
"asset": "HONEST.CNY",
|
|
1087
|
+
"collateralAsset": "BTS",
|
|
1088
|
+
"type": "creditOffer",
|
|
1089
|
+
"allowedOfferIds": ["1.18.42"],
|
|
1090
|
+
"disallowedDealIds": ["1.22.5", "1.22.12"],
|
|
1091
|
+
"maxBorrowAmount": 1000,
|
|
1092
|
+
"maxCollateralAmount": 25000,
|
|
1093
|
+
"maxFeeRatePerDay": 0.001,
|
|
1094
|
+
"maxCollateralRatio": 2.5,
|
|
1095
|
+
"minCollateralIncreaseThreshold": "5%",
|
|
1096
|
+
"autoReborrow": true,
|
|
1097
|
+
"autoRepay": 2
|
|
1098
|
+
}
|
|
1099
|
+
]
|
|
1100
|
+
}
|
|
1101
|
+
}
|
|
1102
|
+
```
|
|
1103
|
+
|
|
1104
|
+
### Key Rules
|
|
1105
|
+
- No separate runtime switch — active when `debtPolicy.lending` is present, non-empty, and each item declares `collateralAsset`
|
|
1106
|
+
- Credit and MPA checks run from the dedicated credit watchdog interval
|
|
1107
|
+
- Every successful CR adjustment triggers a grid rebuild via `requestGridReset()`
|
|
1108
|
+
- Runtime policy enforces `maxFeeRatePerDay`, `maxCollateralRatio`, `allowedOfferIds`, `disallowedDealIds` (reborrow only), `maxBorrowAmountPerOperation` (per-op cap with oversized-deal splitter), and allowed assets before broadcasting
|
|
1109
|
+
- **Collateral switching**: Changing `lendingItem.collateralAsset` on a `creditOffer` item causes the proactive expiry reborrow to switch the deal's collateral to the new asset (requires the offer to accept it). MPA collateral is fixed.
|
|
1110
|
+
- Full usage details live in [MPA and Credit Usage](MPA_CREDIT_USAGE.md)
|
|
1111
|
+
|
|
1112
|
+
---
|
|
1113
|
+
|
|
1114
|
+
## How to Add New Features
|
|
1115
|
+
|
|
1116
|
+
### Example: Adding a New Order Type
|
|
1117
|
+
|
|
1118
|
+
**1. Update Constants**
|
|
1119
|
+
```javascript
|
|
1120
|
+
// modules/constants.ts
|
|
1121
|
+
ORDER_TYPES: {
|
|
1122
|
+
BUY: 'buy',
|
|
1123
|
+
SELL: 'sell',
|
|
1124
|
+
SPREAD: 'spread',
|
|
1125
|
+
LIMIT: 'limit' // NEW
|
|
1126
|
+
}
|
|
1127
|
+
```
|
|
1128
|
+
|
|
1129
|
+
**2. Update Manager Indices**
|
|
1130
|
+
```javascript
|
|
1131
|
+
// modules/order/manager.ts - constructor
|
|
1132
|
+
this._ordersByType = {
|
|
1133
|
+
[ORDER_TYPES.BUY]: new Set(),
|
|
1134
|
+
[ORDER_TYPES.SELL]: new Set(),
|
|
1135
|
+
[ORDER_TYPES.SPREAD]: new Set(),
|
|
1136
|
+
[ORDER_TYPES.LIMIT]: new Set() // NEW
|
|
1137
|
+
};
|
|
1138
|
+
```
|
|
1139
|
+
|
|
1140
|
+
**3. Update Fund Calculation**
|
|
1141
|
+
```javascript
|
|
1142
|
+
// modules/order/accounting.ts - recalculateFunds()
|
|
1143
|
+
for (const order of orders.values()) {
|
|
1144
|
+
if (order.type === ORDER_TYPES.LIMIT) {
|
|
1145
|
+
// Handle new type
|
|
1146
|
+
funds.committed.grid[order.side] += order.size;
|
|
1147
|
+
}
|
|
1148
|
+
}
|
|
1149
|
+
```
|
|
1150
|
+
|
|
1151
|
+
**4. Update Strategy Logic**
|
|
1152
|
+
```javascript
|
|
1153
|
+
// modules/order/strategy.ts - rebalance()
|
|
1154
|
+
const limitOrders = manager.getOrdersByTypeAndState(ORDER_TYPES.LIMIT, null);
|
|
1155
|
+
// Process limit orders...
|
|
1156
|
+
```
|
|
1157
|
+
|
|
1158
|
+
**5. Add Tests**
|
|
1159
|
+
```javascript
|
|
1160
|
+
// tests/test_manager_logic.ts
|
|
1161
|
+
const assert = require('assert');
|
|
1162
|
+
|
|
1163
|
+
async function runTests() {
|
|
1164
|
+
console.log(' - Testing LIMIT order type tracking...');
|
|
1165
|
+
|
|
1166
|
+
// Test: should track LIMIT orders in indices
|
|
1167
|
+
{
|
|
1168
|
+
const manager = createManager();
|
|
1169
|
+
await manager._updateOrder({
|
|
1170
|
+
id: 'limit-1',
|
|
1171
|
+
state: ORDER_STATES.VIRTUAL,
|
|
1172
|
+
type: ORDER_TYPES.LIMIT,
|
|
1173
|
+
size: 100,
|
|
1174
|
+
price: 50
|
|
1175
|
+
});
|
|
1176
|
+
const limitOrders = manager.getOrdersByTypeAndState(ORDER_TYPES.LIMIT, null);
|
|
1177
|
+
assert.strictEqual(limitOrders.length, 1, 'LIMIT order should be tracked in indices');
|
|
1178
|
+
}
|
|
1179
|
+
|
|
1180
|
+
console.log('LIMIT order type tests passed.');
|
|
1181
|
+
}
|
|
1182
|
+
|
|
1183
|
+
runTests();
|
|
1184
|
+
```
|
|
1185
|
+
|
|
1186
|
+
**6. Update Documentation**
|
|
1187
|
+
```markdown
|
|
1188
|
+
// docs/architecture.md
|
|
1189
|
+
### Order Types
|
|
1190
|
+
- **LIMIT**: User-defined limit orders outside the grid
|
|
1191
|
+
```
|
|
1192
|
+
|
|
1193
|
+
**7. Ensure COW Compliance**
|
|
1194
|
+
- Any new strategy or rebalancing logic must operate on a `WorkingGrid`, not `manager.orders` directly.
|
|
1195
|
+
- New blockchain-confirmed state updates must go through `_applyOrderUpdate()`.
|
|
1196
|
+
- If a new operation can race with fills, verify the rebalance state (`_setRebalanceState`) gates it correctly.
|
|
1197
|
+
- Add tests for master-unchanged-on-failure and commit-only-on-success scenarios.
|
|
1198
|
+
|
|
1199
|
+
---
|
|
1200
|
+
|
|
1201
|
+
## Testing Strategy
|
|
1202
|
+
|
|
1203
|
+
### Test Files
|
|
1204
|
+
Located in `tests/` (with `helpers/` subdirectory):
|
|
1205
|
+
- `test_accounting_logic.ts` - Fund calculation and accounting tests
|
|
1206
|
+
- `test_grid_logic.ts` - Grid creation, sizing, and divergence tests
|
|
1207
|
+
- `test_manager.ts` / `test_manager_logic.ts` - State management and COW tests
|
|
1208
|
+
- `test_sync_logic.ts` - Blockchain synchronization tests
|
|
1209
|
+
- `test_strategy_logic.ts` - Rebalancing and rotation logic
|
|
1210
|
+
- `test_bts_fee_logic.ts` - BTS fee deduction and settlement
|
|
1211
|
+
- `test_market_adapter_signal_gates.ts` - Market adapter signal validation
|
|
1212
|
+
- `test_dynamic_weight_override_wiring.ts` - Dynamic weight config wiring
|
|
1213
|
+
- `test_derivative_signal_trap_regression.ts` - Derivative signal trap tests
|
|
1214
|
+
- `test_derivative_momentum_gate.ts` - Momentum gate tests
|
|
1215
|
+
- `test_cr_planner.ts` - Collateral ratio planner tests
|
|
1216
|
+
- `test_dexbot_credit_wiring.ts` - Credit runtime integration tests
|
|
1217
|
+
- `test_credential_daemon.ts` / `test_credential_session_cache.ts` - Credential security tests
|
|
1218
|
+
|
|
1219
|
+
**Run tests**:
|
|
1220
|
+
```bash
|
|
1221
|
+
npm test
|
|
1222
|
+
```
|
|
1223
|
+
|
|
1224
|
+
### Manual Verification
|
|
1225
|
+
|
|
1226
|
+
**1. Fund Invariant Check**
|
|
1227
|
+
```javascript
|
|
1228
|
+
// After any operation
|
|
1229
|
+
manager.accountant._verifyFundInvariants(
|
|
1230
|
+
manager,
|
|
1231
|
+
chainFreeBuy,
|
|
1232
|
+
chainFreeSell,
|
|
1233
|
+
chainBuy,
|
|
1234
|
+
chainSell,
|
|
1235
|
+
mgr.accountTotals?.buy,
|
|
1236
|
+
mgr.accountTotals?.sell
|
|
1237
|
+
);
|
|
1238
|
+
```
|
|
1239
|
+
|
|
1240
|
+
**2. Index Consistency Check**
|
|
1241
|
+
```javascript
|
|
1242
|
+
// Periodically
|
|
1243
|
+
const isValid = manager.validateIndices();
|
|
1244
|
+
if (!isValid) {
|
|
1245
|
+
manager._repairIndices();
|
|
1246
|
+
}
|
|
1247
|
+
```
|
|
1248
|
+
|
|
1249
|
+
**3. Grid Diagnostics**
|
|
1250
|
+
```javascript
|
|
1251
|
+
// After fills or rotations — use logFundsStatus for structured fund/order summaries
|
|
1252
|
+
manager.logger.logFundsStatus(manager, 'AFTER FILL');
|
|
1253
|
+
```
|
|
1254
|
+
|
|
1255
|
+
---
|
|
1256
|
+
|
|
1257
|
+
## Code Style Guidelines
|
|
1258
|
+
|
|
1259
|
+
### 0. **Respect the COW Boundary**
|
|
1260
|
+
```javascript
|
|
1261
|
+
// ✅ CORRECT - Planning on working copy (during rebalance)
|
|
1262
|
+
workingGrid.set(orderId, { ...order, size: newSize });
|
|
1263
|
+
|
|
1264
|
+
// ✅ CORRECT - Confirmed blockchain event goes through _updateOrder()
|
|
1265
|
+
manager._updateOrder({ ...order, state: ORDER_STATES.ACTIVE }, 'placed');
|
|
1266
|
+
|
|
1267
|
+
// ❌ WRONG - Direct master mutation (throws: Map is frozen)
|
|
1268
|
+
manager.orders.set(orderId, order);
|
|
1269
|
+
```
|
|
1270
|
+
|
|
1271
|
+
### 1. **Always Use _updateOrder()**
|
|
1272
|
+
```javascript
|
|
1273
|
+
// ✅ CORRECT - Uses proper signature with context
|
|
1274
|
+
manager._updateOrder({
|
|
1275
|
+
id: 'buy-5',
|
|
1276
|
+
state: ORDER_STATES.ACTIVE,
|
|
1277
|
+
type: ORDER_TYPES.BUY,
|
|
1278
|
+
price: 0.5,
|
|
1279
|
+
size: 100
|
|
1280
|
+
}, 'order-update', { skipAccounting: false, fee: 0 });
|
|
1281
|
+
|
|
1282
|
+
// ✅ ALSO CORRECT - Using defaults (context='updateOrder', options={})
|
|
1283
|
+
manager._updateOrder({
|
|
1284
|
+
id: 'buy-5',
|
|
1285
|
+
state: ORDER_STATES.ACTIVE,
|
|
1286
|
+
type: ORDER_TYPES.BUY,
|
|
1287
|
+
price: 0.5,
|
|
1288
|
+
size: 100
|
|
1289
|
+
});
|
|
1290
|
+
|
|
1291
|
+
// ❌ WRONG - Breaks indices
|
|
1292
|
+
manager.orders.set('buy-5', order);
|
|
1293
|
+
```
|
|
1294
|
+
|
|
1295
|
+
### 2. **Batch Fund Recalculation**
|
|
1296
|
+
```javascript
|
|
1297
|
+
// ✅ CORRECT - Recalculates once, with context for logging
|
|
1298
|
+
manager.pauseFundRecalc();
|
|
1299
|
+
for (const order of orders) {
|
|
1300
|
+
manager._updateOrder(order, 'rebalance-batch', { skipAccounting: false, fee: 0 });
|
|
1301
|
+
}
|
|
1302
|
+
manager.resumeFundRecalc();
|
|
1303
|
+
|
|
1304
|
+
// ⚠️ ACCEPTABLE - Uses defaults but less ideal for debugging
|
|
1305
|
+
manager.pauseFundRecalc();
|
|
1306
|
+
for (const order of orders) {
|
|
1307
|
+
manager._updateOrder(order);
|
|
1308
|
+
}
|
|
1309
|
+
manager.resumeFundRecalc();
|
|
1310
|
+
|
|
1311
|
+
// ❌ WRONG - Recalculates N times
|
|
1312
|
+
for (const order of orders) {
|
|
1313
|
+
manager._updateOrder(order); // Triggers recalc each time
|
|
1314
|
+
}
|
|
1315
|
+
```
|
|
1316
|
+
|
|
1317
|
+
### 3. **Lock During Async Operations**
|
|
1318
|
+
```javascript
|
|
1319
|
+
// ✅ CORRECT
|
|
1320
|
+
manager.lockOrders([orderId]);
|
|
1321
|
+
try {
|
|
1322
|
+
await chainOperation();
|
|
1323
|
+
} finally {
|
|
1324
|
+
manager.unlockOrders([orderId]);
|
|
1325
|
+
}
|
|
1326
|
+
|
|
1327
|
+
// ❌ WRONG - Race condition possible
|
|
1328
|
+
await chainOperation();
|
|
1329
|
+
```
|
|
1330
|
+
|
|
1331
|
+
### 4. **Use Atomic Fund Operations**
|
|
1332
|
+
```javascript
|
|
1333
|
+
// ✅ CORRECT
|
|
1334
|
+
if (manager.accountant.tryDeductFromChainFree(type, size)) {
|
|
1335
|
+
// Funds deducted atomically
|
|
1336
|
+
placeOrder();
|
|
1337
|
+
} else {
|
|
1338
|
+
// Insufficient funds
|
|
1339
|
+
}
|
|
1340
|
+
|
|
1341
|
+
// ❌ WRONG - Race condition
|
|
1342
|
+
if (manager.funds.available[type] >= size) {
|
|
1343
|
+
manager.funds.available[type] -= size; // Not atomic!
|
|
1344
|
+
placeOrder();
|
|
1345
|
+
}
|
|
1346
|
+
```
|
|
1347
|
+
|
|
1348
|
+
---
|
|
1349
|
+
|
|
1350
|
+
## Performance Tips
|
|
1351
|
+
|
|
1352
|
+
### 1. **Use Index Lookups**
|
|
1353
|
+
```javascript
|
|
1354
|
+
// ✅ FAST - O(1) lookup
|
|
1355
|
+
const activeBuys = manager.getOrdersByTypeAndState(ORDER_TYPES.BUY, ORDER_STATES.ACTIVE);
|
|
1356
|
+
|
|
1357
|
+
// ❌ SLOW - O(n) iteration
|
|
1358
|
+
const activeBuys = Array.from(manager.orders.values())
|
|
1359
|
+
.filter(o => o.type === ORDER_TYPES.BUY && o.state === ORDER_STATES.ACTIVE);
|
|
1360
|
+
```
|
|
1361
|
+
|
|
1362
|
+
### 2. **Batch Operations**
|
|
1363
|
+
```javascript
|
|
1364
|
+
// ✅ EFFICIENT - One recalc
|
|
1365
|
+
manager.pauseFundRecalc();
|
|
1366
|
+
// ... many updates ...
|
|
1367
|
+
manager.resumeFundRecalc();
|
|
1368
|
+
|
|
1369
|
+
// ❌ INEFFICIENT - N recalcs
|
|
1370
|
+
// ... many updates without pausing ...
|
|
1371
|
+
```
|
|
1372
|
+
|
|
1373
|
+
### 3. **Cache Blockchain Calls**
|
|
1374
|
+
```javascript
|
|
1375
|
+
// ✅ GOOD - Uses fee cache (no amount = returns fee info object)
|
|
1376
|
+
const feeInfo = getAssetFees('BTS');
|
|
1377
|
+
console.log(feeInfo.createFee, feeInfo.updateFee);
|
|
1378
|
+
|
|
1379
|
+
// ✅ GOOD - With amount = returns net proceeds (number)
|
|
1380
|
+
const netProceeds = getAssetFees('IOB.XRP', 100);
|
|
1381
|
+
|
|
1382
|
+
// ❌ BAD - Fetches every time
|
|
1383
|
+
const fees = await BitShares.db.get_global_properties();
|
|
1384
|
+
```
|
|
1385
|
+
|
|
1386
|
+
### 4. **Leverage Pool ID Caching**
|
|
1387
|
+
|
|
1388
|
+
When deriving pool prices, the bot caches Liquidity Pool IDs to avoid repeated blockchain scans.
|
|
1389
|
+
|
|
1390
|
+
```javascript
|
|
1391
|
+
// ✅ GOOD - Uses cached pool IDs
|
|
1392
|
+
const price = await derivePoolPrice(assetA.symbol, assetB.symbol);
|
|
1393
|
+
// First call: scans blockchain for pool
|
|
1394
|
+
// Subsequent calls: uses cached ID if assets match
|
|
1395
|
+
|
|
1396
|
+
// Smart fallback: Cache miss triggers fresh scan
|
|
1397
|
+
if (cachedPoolId.assets !== requestedAssets) {
|
|
1398
|
+
// Cache invalidated - rescan blockchain
|
|
1399
|
+
const newPoolId = await scanBlockchainForPool(assetA, assetB);
|
|
1400
|
+
}
|
|
1401
|
+
|
|
1402
|
+
// ✅ Transparent: No manual cache management needed
|
|
1403
|
+
```
|
|
1404
|
+
|
|
1405
|
+
**How It Works**:
|
|
1406
|
+
- Cache validated against requested assets before use
|
|
1407
|
+
- Stale pool IDs automatically detected and refreshed
|
|
1408
|
+
- Concurrent access safe via lock protection
|
|
1409
|
+
|
|
1410
|
+
**Performance Impact**:
|
|
1411
|
+
- Eliminates redundant blockchain scans during startup and config refresh
|
|
1412
|
+
- Particularly effective during periodic 4-hour price refresh cycles
|
|
1413
|
+
|
|
1414
|
+
### 5. **Pin a Pool with `poolRef`**
|
|
1415
|
+
|
|
1416
|
+
When a trading pair has no native liquidity pool (e.g. `BTS/XBTSX.USDC`), set `poolRef` in `bots.json` to pin a proxy pool for price derivation:
|
|
1417
|
+
|
|
1418
|
+
```json
|
|
1419
|
+
{
|
|
1420
|
+
"name": "BTS-USDC",
|
|
1421
|
+
"assetA": "BTS",
|
|
1422
|
+
"assetB": "XBTSX.USDC",
|
|
1423
|
+
"startPrice": "pool",
|
|
1424
|
+
"poolRef": "1.19.48",
|
|
1425
|
+
"gridPrice": "ama1"
|
|
1426
|
+
}
|
|
1427
|
+
```
|
|
1428
|
+
|
|
1429
|
+
The decorator (`withPoolRef`) intercepts pool price queries and fetches the pinned pool directly by ID via `get_objects`, bypassing all discovery, caching, and the `poolIdCache`. The ID can be a full form (`"1.19.48"`) or a short suffix (`"48"`). When unset, the original discovery path runs unchanged — zero overhead.
|
|
1430
|
+
|
|
1431
|
+
---
|
|
1432
|
+
|
|
1433
|
+
## Common Pitfalls
|
|
1434
|
+
|
|
1435
|
+
### 1. **Forgetting to Unlock Orders**
|
|
1436
|
+
```javascript
|
|
1437
|
+
// ❌ BAD - Lock never released if error
|
|
1438
|
+
manager.lockOrders([id]);
|
|
1439
|
+
await operation(); // Might throw
|
|
1440
|
+
manager.unlockOrders([id]); // Never reached
|
|
1441
|
+
|
|
1442
|
+
// ✅ GOOD - Always unlocks
|
|
1443
|
+
manager.lockOrders([id]);
|
|
1444
|
+
try {
|
|
1445
|
+
await operation();
|
|
1446
|
+
} finally {
|
|
1447
|
+
manager.unlockOrders([id]);
|
|
1448
|
+
}
|
|
1449
|
+
```
|
|
1450
|
+
|
|
1451
|
+
### 2. **Direct Map Modification**
|
|
1452
|
+
```javascript
|
|
1453
|
+
// ❌ BAD - Breaks indices
|
|
1454
|
+
manager.orders.set(id, order);
|
|
1455
|
+
|
|
1456
|
+
// ✅ GOOD - Updates indices
|
|
1457
|
+
manager._updateOrder(order);
|
|
1458
|
+
```
|
|
1459
|
+
|
|
1460
|
+
### 3. **Ignoring State Transition Rules**
|
|
1461
|
+
```javascript
|
|
1462
|
+
// ❌ BAD - Invalid transition
|
|
1463
|
+
order.state = ORDER_STATES.VIRTUAL; // Was PARTIAL
|
|
1464
|
+
manager._updateOrder(order); // Error logged
|
|
1465
|
+
|
|
1466
|
+
// ✅ GOOD - Valid transition
|
|
1467
|
+
order.state = ORDER_STATES.ACTIVE; // PARTIAL → ACTIVE is valid
|
|
1468
|
+
manager._updateOrder(order);
|
|
1469
|
+
```
|
|
1470
|
+
|
|
1471
|
+
### 4. **Not Checking Lock Status**
|
|
1472
|
+
```javascript
|
|
1473
|
+
// ❌ BAD - Might process locked order
|
|
1474
|
+
processOrder(order);
|
|
1475
|
+
|
|
1476
|
+
// ✅ GOOD - Skip if locked
|
|
1477
|
+
if (!manager.isOrderLocked(order.id)) {
|
|
1478
|
+
processOrder(order);
|
|
1479
|
+
}
|
|
1480
|
+
```
|
|
1481
|
+
|
|
1482
|
+
---
|
|
1483
|
+
|
|
1484
|
+
## Useful Debugging Commands
|
|
1485
|
+
|
|
1486
|
+
### Enable Debug Logging
|
|
1487
|
+
```javascript
|
|
1488
|
+
manager.logger.level = 'debug';
|
|
1489
|
+
```
|
|
1490
|
+
|
|
1491
|
+
### View Fund Status
|
|
1492
|
+
```javascript
|
|
1493
|
+
manager.logger.logFundsStatus(manager, 'CONTEXT');
|
|
1494
|
+
```
|
|
1495
|
+
|
|
1496
|
+
### View Metrics
|
|
1497
|
+
```javascript
|
|
1498
|
+
console.log(manager.getMetrics());
|
|
1499
|
+
```
|
|
1500
|
+
|
|
1501
|
+
### Validate Indices
|
|
1502
|
+
```javascript
|
|
1503
|
+
const isValid = manager.validateIndices();
|
|
1504
|
+
```
|
|
1505
|
+
|
|
1506
|
+
### Check Specific Order
|
|
1507
|
+
```javascript
|
|
1508
|
+
const order = manager.orders.get('buy-5');
|
|
1509
|
+
console.log('State:', order.state);
|
|
1510
|
+
console.log('Type:', order.type);
|
|
1511
|
+
console.log('Locked?', manager.isOrderLocked(order.id));
|
|
1512
|
+
```
|
|
1513
|
+
|
|
1514
|
+
---
|
|
1515
|
+
|
|
1516
|
+
## Resources
|
|
1517
|
+
|
|
1518
|
+
### Documentation
|
|
1519
|
+
- [Architecture](architecture.md) - System design and module relationships
|
|
1520
|
+
- [Copy-on-Write Master Plan](COPY_ON_WRITE_MASTER_PLAN.md) - COW architecture, phases, state machine, and test results
|
|
1521
|
+
- [COW Invariants](COW_INVARIANTS.md) - Stable theory contract for COW pipeline
|
|
1522
|
+
- [Fund Movement Logic](FUND_MOVEMENT_AND_ACCOUNTING.md) - Algorithms and formulas
|
|
1523
|
+
- [Market Adapter](../market_adapter/README.md) - Signal pipeline and AMA integration
|
|
1524
|
+
- [MPA and Credit Usage](MPA_CREDIT_USAGE.md) - MPA and credit offer workflows
|
|
1525
|
+
- [README](../README.md) - User documentation
|
|
1526
|
+
- [WORKFLOW](WORKFLOW.md) - Git branch workflow
|
|
1527
|
+
|
|
1528
|
+
### Code Entry Points
|
|
1529
|
+
- `dexbot.ts` - CLI entry point
|
|
1530
|
+
- `modules/dexbot_class.ts` - Core bot class
|
|
1531
|
+
- `modules/dexbot_fill_runtime.ts` - Fill processing runtime
|
|
1532
|
+
- `modules/dexbot_maintenance_runtime.ts` - Maintenance runtime
|
|
1533
|
+
- `modules/order/manager.ts` - Order management hub
|
|
1534
|
+
|
|
1535
|
+
### Key Modules
|
|
1536
|
+
|
|
1537
|
+
**Order Management** (`modules/order/`):
|
|
1538
|
+
- `manager.ts` - Order lifecycle and state management
|
|
1539
|
+
- `accounting.ts` - Fund tracking
|
|
1540
|
+
- `strategy.ts` - Rebalancing logic
|
|
1541
|
+
- `grid.ts` - Grid creation
|
|
1542
|
+
- `grid_reconcile.ts` - Startup grid reconciliation ([docs](GRID_RECONCILE.md))
|
|
1543
|
+
- `grid_reconcile_internal.ts` - Internal grid reconciliation helpers
|
|
1544
|
+
- `sync_engine.ts` - Blockchain sync
|
|
1545
|
+
- `logger.ts` - Order logging
|
|
1546
|
+
- `working_grid.ts` - COW working copy (clone/delta/commit)
|
|
1547
|
+
- `processed_fill_store.ts` - Fill dedupe persistence
|
|
1548
|
+
- `utils/order.ts` - Order state predicates and helpers
|
|
1549
|
+
- `utils/math.ts` - Precision, quantization, fund math
|
|
1550
|
+
- `utils/validate.ts` - Validation and COW action building
|
|
1551
|
+
- `utils/system.ts` - Price derivation, deduplication
|
|
1552
|
+
|
|
1553
|
+
**Core Bot & Blockchain**:
|
|
1554
|
+
- `modules/dexbot_class.ts` - Core bot class, lifecycle orchestration, shared runtime wiring
|
|
1555
|
+
- `modules/dexbot_fill_runtime.ts` - Fill processing runtime and replay-safe accounting
|
|
1556
|
+
- `modules/dexbot_maintenance_runtime.ts` - Sync loops, grid maintenance, trigger handling
|
|
1557
|
+
- `modules/constants.ts` - Centralized configuration and tuning parameters
|
|
1558
|
+
- `modules/bitshares_client.ts` - BitShares connection and node management
|
|
1559
|
+
- `modules/node_manager.ts` - Multi-node health checking and failover
|
|
1560
|
+
- `modules/fund_registry.ts` - Shared-account fund registry with cross-bot invariants
|
|
1561
|
+
- `modules/settings_merge.ts` - Consolidated settings merge (single source of truth)
|
|
1562
|
+
- `modules/chain_orders.ts` - Blockchain order operations
|
|
1563
|
+
- `modules/account_orders.ts` - Account order queries
|
|
1564
|
+
|
|
1565
|
+
**Credit & Market Adapter**:
|
|
1566
|
+
- `modules/credit_runtime.ts` - Debt workflow executor (MPA and credit offer)
|
|
1567
|
+
- `modules/cr_planner.ts` - Collateral ratio math layer
|
|
1568
|
+
- `market_adapter/core/market_adapter_service.ts` - Signal pipeline (AMA, dynamic weights)
|
|
1569
|
+
- `market_adapter/market_adapter.ts` - AMA delta threshold, grid price offset, recalc triggers
|
|
1570
|
+
|
|
1571
|
+
**Claw Integration** (`claw/`):
|
|
1572
|
+
- `claw/index.ts` - Main export combining all claw modules
|
|
1573
|
+
- `claw/modules/chain_actions.ts` - Chain operations (reads/writes/broadcast)
|
|
1574
|
+
- `claw/modules/chain_queries.ts` - Blockchain queries
|
|
1575
|
+
- `claw/modules/chain_broadcast.ts` - Broadcast layer
|
|
1576
|
+
- `claw/modules/claw_bridge.ts` - JSON bridge + command dispatch
|
|
1577
|
+
- `claw/modules/claw_launcher.ts` - Launcher orchestration (PM2, Docker)
|
|
1578
|
+
- `claw/modules/dexbot_bridge.ts` - DEXBot2 integration bridge
|
|
1579
|
+
- `claw/modules/credit_runtime_adapter.ts` - Credit runtime lifecycle bridge
|
|
1580
|
+
- `claw/modules/position_manager.ts` - Position tracking and health
|
|
1581
|
+
- `claw/modules/short_mpa_strategy.ts` - High-level MPA strategy
|
|
1582
|
+
|
|
1583
|
+
---
|
|
1584
|
+
|
|
1585
|
+
## Testing Fund Calculations
|
|
1586
|
+
|
|
1587
|
+
Fund calculations are critical to system stability. This section covers how the test suite validates fund logic and how to add tests for new features.
|
|
1588
|
+
|
|
1589
|
+
### What Gets Tested
|
|
1590
|
+
|
|
1591
|
+
The test suite validates the following fund-related behaviors:
|
|
1592
|
+
|
|
1593
|
+
**Order State Transitions:**
|
|
1594
|
+
```javascript
|
|
1595
|
+
✓ VIRTUAL → ACTIVE → PARTIAL lifecycle
|
|
1596
|
+
✓ Fund movement between pools during transitions
|
|
1597
|
+
✓ Index consistency during state changes
|
|
1598
|
+
✓ Invariant preservation during transitions
|
|
1599
|
+
```
|
|
1600
|
+
|
|
1601
|
+
**Fund Pool Integrity:**
|
|
1602
|
+
```javascript
|
|
1603
|
+
✓ virtual.buy + virtual.sell = sum of all VIRTUAL orders
|
|
1604
|
+
✓ committed.chain.buy = sum of ACTIVE orders with orderId
|
|
1605
|
+
✓ committed.grid.buy = sum of ACTIVE + PARTIAL orders
|
|
1606
|
+
✓ available.buy = max(0, chainFree - virtual - cache - fees)
|
|
1607
|
+
```
|
|
1608
|
+
|
|
1609
|
+
**Critical Invariants:**
|
|
1610
|
+
```javascript
|
|
1611
|
+
✓ Invariant 1: chainTotal = chainFree + chainCommitted
|
|
1612
|
+
✓ Invariant 2: available ≤ chainFree
|
|
1613
|
+
✓ Invariant 3: gridCommitted ≤ chainTotal
|
|
1614
|
+
```
|
|
1615
|
+
|
|
1616
|
+
**Edge Cases:**
|
|
1617
|
+
```javascript
|
|
1618
|
+
✓ Zero-size orders
|
|
1619
|
+
✓ Very large orders (precision handling)
|
|
1620
|
+
✓ Multiple concurrent state changes (atomicity)
|
|
1621
|
+
✓ Fund deductions and additions
|
|
1622
|
+
```
|
|
1623
|
+
|
|
1624
|
+
### Running Tests
|
|
1625
|
+
|
|
1626
|
+
```bash
|
|
1627
|
+
# All tests (native assert)
|
|
1628
|
+
npm test
|
|
1629
|
+
|
|
1630
|
+
# Specific logic area
|
|
1631
|
+
tsx tests/test_accounting_logic.ts
|
|
1632
|
+
|
|
1633
|
+
# Specific integration test
|
|
1634
|
+
tsx tests/test_fills.ts
|
|
1635
|
+
```
|
|
1636
|
+
|
|
1637
|
+
### Understanding Test Structure
|
|
1638
|
+
|
|
1639
|
+
Tests use a consistent pattern for fund validation. They use native `assert` with `console.log` blocks (no Jest dependency):
|
|
1640
|
+
|
|
1641
|
+
```javascript
|
|
1642
|
+
const assert = require('assert');
|
|
1643
|
+
async function runTests() {
|
|
1644
|
+
console.log(' - Testing virtual funds from VIRTUAL orders...');
|
|
1645
|
+
|
|
1646
|
+
// Setup manager with known initial state
|
|
1647
|
+
const manager = new OrderManager(config);
|
|
1648
|
+
await manager.setAccountTotals({ buy: 10000, sell: 100 });
|
|
1649
|
+
manager.resetFunds();
|
|
1650
|
+
|
|
1651
|
+
{
|
|
1652
|
+
// Add VIRTUAL order
|
|
1653
|
+
await manager._updateOrder({
|
|
1654
|
+
id: 'virtual-1',
|
|
1655
|
+
state: ORDER_STATES.VIRTUAL,
|
|
1656
|
+
type: ORDER_TYPES.BUY,
|
|
1657
|
+
size: 500,
|
|
1658
|
+
price: 100
|
|
1659
|
+
});
|
|
1660
|
+
|
|
1661
|
+
// Assert fund pool updated
|
|
1662
|
+
assert.strictEqual(manager.funds.virtual.buy, 500);
|
|
1663
|
+
assert(manager.funds.total.grid.buy >= 500);
|
|
1664
|
+
}
|
|
1665
|
+
|
|
1666
|
+
console.log('Virtual funds tests passed.');
|
|
1667
|
+
}
|
|
1668
|
+
```
|
|
1669
|
+
|
|
1670
|
+
### Key Test Files
|
|
1671
|
+
|
|
1672
|
+
| File | Purpose |
|
|
1673
|
+
|------|---------|
|
|
1674
|
+
| `tests/test_strategy_logic.ts` | Rebalancing, placement, rotation |
|
|
1675
|
+
| `tests/test_accounting_logic.ts` | Fund tracking, fees, precision |
|
|
1676
|
+
| `tests/test_grid_logic.ts` | Grid creation, sizing, divergence |
|
|
1677
|
+
| `tests/test_manager_logic.ts` | State machine, indexing |
|
|
1678
|
+
| `tests/test_sync_logic.ts` | Blockchain reconciliation | Startup reconcile is `tests/test_grid_reconcile*.ts` |
|
|
1679
|
+
|
|
1680
|
+
### Adding Tests for Fund-Related Features
|
|
1681
|
+
|
|
1682
|
+
When adding features that affect funds, follow this checklist:
|
|
1683
|
+
|
|
1684
|
+
**1. Identify Fund Impact**
|
|
1685
|
+
```javascript
|
|
1686
|
+
// What fund pools are affected?
|
|
1687
|
+
// - virtual (VIRTUAL orders)
|
|
1688
|
+
// - committed.chain (ACTIVE orders with orderId)
|
|
1689
|
+
// - committed.grid (ACTIVE + PARTIAL orders)
|
|
1690
|
+
// - available (available pool)
|
|
1691
|
+
// - available (spending power)
|
|
1692
|
+
```
|
|
1693
|
+
|
|
1694
|
+
**2. Create Test Case**
|
|
1695
|
+
```javascript
|
|
1696
|
+
console.log(' - Testing [action] updates [fund pool]...');
|
|
1697
|
+
{
|
|
1698
|
+
// Setup
|
|
1699
|
+
const initialFunds = manager.funds[poolName][side];
|
|
1700
|
+
|
|
1701
|
+
// Action
|
|
1702
|
+
await performAction();
|
|
1703
|
+
|
|
1704
|
+
// Assert
|
|
1705
|
+
const finalFunds = manager.funds[poolName][side];
|
|
1706
|
+
assert.strictEqual(finalFunds, expectedValue);
|
|
1707
|
+
assert.strictEqual(manager.validateIndices(), true); // Indices OK?
|
|
1708
|
+
}
|
|
1709
|
+
```
|
|
1710
|
+
|
|
1711
|
+
**3. Verify Invariants**
|
|
1712
|
+
```javascript
|
|
1713
|
+
// After your action, verify invariants
|
|
1714
|
+
assert(
|
|
1715
|
+
manager.funds.total.chain.buy ===
|
|
1716
|
+
manager.funds.chainFree.buy + manager.funds.committed.chain.buy
|
|
1717
|
+
);
|
|
1718
|
+
```
|
|
1719
|
+
|
|
1720
|
+
**4. Test Edge Cases**
|
|
1721
|
+
```javascript
|
|
1722
|
+
// Test with:
|
|
1723
|
+
✓ Zero funds available
|
|
1724
|
+
✓ Very large orders (precision)
|
|
1725
|
+
✓ Multiple concurrent updates
|
|
1726
|
+
✓ State transitions
|
|
1727
|
+
```
|
|
1728
|
+
|
|
1729
|
+
### Common Test Patterns
|
|
1730
|
+
|
|
1731
|
+
**Pattern 1: Batch Fund Updates**
|
|
1732
|
+
```javascript
|
|
1733
|
+
manager.pauseFundRecalc(); // Batch mode
|
|
1734
|
+
await manager._updateOrder(order1, 'test-batch', { skipAccounting: false, fee: 0 });
|
|
1735
|
+
await manager._updateOrder(order2, 'test-batch', { skipAccounting: false, fee: 0 });
|
|
1736
|
+
await manager._updateOrder(order3, 'test-batch', { skipAccounting: false, fee: 0 });
|
|
1737
|
+
manager.resumeFundRecalc(); // Recalc once
|
|
1738
|
+
|
|
1739
|
+
// Verify final state
|
|
1740
|
+
assert.strictEqual(manager.funds.total.grid.buy, order1.size + order2.size + order3.size);
|
|
1741
|
+
```
|
|
1742
|
+
|
|
1743
|
+
**Pattern 2: Fund Transitions**
|
|
1744
|
+
```javascript
|
|
1745
|
+
// VIRTUAL → ACTIVE
|
|
1746
|
+
await manager._updateOrder({
|
|
1747
|
+
id: 'order-1',
|
|
1748
|
+
state: ORDER_STATES.VIRTUAL,
|
|
1749
|
+
size: 500,
|
|
1750
|
+
price: 100
|
|
1751
|
+
}, 'test-setup');
|
|
1752
|
+
|
|
1753
|
+
const virtualBefore = manager.funds.virtual.buy;
|
|
1754
|
+
|
|
1755
|
+
await manager._updateOrder({
|
|
1756
|
+
id: 'order-1',
|
|
1757
|
+
state: ORDER_STATES.ACTIVE,
|
|
1758
|
+
orderId: 'chain-001',
|
|
1759
|
+
size: 500,
|
|
1760
|
+
price: 100
|
|
1761
|
+
}, 'test-transition');
|
|
1762
|
+
|
|
1763
|
+
// Verify movement
|
|
1764
|
+
assert(manager.funds.virtual.buy < virtualBefore);
|
|
1765
|
+
assert(manager.funds.committed.chain.buy > 0);
|
|
1766
|
+
```
|
|
1767
|
+
|
|
1768
|
+
**Pattern 3: Atomicity Check**
|
|
1769
|
+
```javascript
|
|
1770
|
+
// Verify operation is atomic (no partial state)
|
|
1771
|
+
manager.lockOrders(['order-1']);
|
|
1772
|
+
try {
|
|
1773
|
+
// Perform operation
|
|
1774
|
+
await fundDependentOperation();
|
|
1775
|
+
// Check state consistency
|
|
1776
|
+
assert.strictEqual(manager.validateIndices(), true);
|
|
1777
|
+
} finally {
|
|
1778
|
+
manager.unlockOrders(['order-1']);
|
|
1779
|
+
}
|
|
1780
|
+
```
|
|
1781
|
+
|
|
1782
|
+
### Recent Test Coverage
|
|
1783
|
+
|
|
1784
|
+
The test suite provides comprehensive coverage of fund calculations and rebalancing logic:
|
|
1785
|
+
|
|
1786
|
+
**Key Areas Tested:**
|
|
1787
|
+
- ✅ VIRTUAL order placement with zero available pool
|
|
1788
|
+
- ✅ PARTIAL order updates during rebalancing
|
|
1789
|
+
- ✅ Grid divergence detection with stale cache
|
|
1790
|
+
- ✅ BoundaryIdx persistence and recovery
|
|
1791
|
+
- ✅ BUY side geometric weighting
|
|
1792
|
+
- ✅ Real-time commitment accounting (CacheFunds removed)
|
|
1793
|
+
- ✅ Rotation completion and skip prevention
|
|
1794
|
+
- ✅ Fee calculation with isMaker parameter
|
|
1795
|
+
- ✅ Market and blockchain taker fees
|
|
1796
|
+
- ✅ Fund precision and delta validation
|
|
1797
|
+
|
|
1798
|
+
**Running Tests**:
|
|
1799
|
+
```bash
|
|
1800
|
+
# Test strategy rebalancing
|
|
1801
|
+
tsx tests/test_strategy_logic.ts
|
|
1802
|
+
|
|
1803
|
+
# Test grid divergence
|
|
1804
|
+
tsx tests/test_grid_logic.ts
|
|
1805
|
+
|
|
1806
|
+
# Test accounting precision
|
|
1807
|
+
tsx tests/test_accounting_logic.ts
|
|
1808
|
+
|
|
1809
|
+
# Run full suite
|
|
1810
|
+
npm test
|
|
1811
|
+
```
|
|
1812
|
+
|
|
1813
|
+
See [tests/README.md](../tests/README.md) for detailed test coverage documentation.
|
|
1814
|
+
|
|
1815
|
+
### Debugging Fund Issues in Tests
|
|
1816
|
+
|
|
1817
|
+
If a test fails due to fund calculation issues:
|
|
1818
|
+
|
|
1819
|
+
```javascript
|
|
1820
|
+
// 1. Print fund state
|
|
1821
|
+
console.log('Fund state:', JSON.stringify(manager.funds, null, 2));
|
|
1822
|
+
|
|
1823
|
+
// 2. Check invariants
|
|
1824
|
+
console.log('Invariants valid?', manager.accountant._verifyFundInvariants(
|
|
1825
|
+
manager,
|
|
1826
|
+
...values
|
|
1827
|
+
));
|
|
1828
|
+
|
|
1829
|
+
// 3. Trace order state
|
|
1830
|
+
manager.orders.forEach(order => {
|
|
1831
|
+
console.log(`Order ${order.id}: state=${order.state}, size=${order.size}`);
|
|
1832
|
+
});
|
|
1833
|
+
|
|
1834
|
+
// 4. Check index consistency
|
|
1835
|
+
console.log('Indices valid?', manager.validateIndices());
|
|
1836
|
+
|
|
1837
|
+
// 5. Examine specific fund pool
|
|
1838
|
+
console.log('Virtual buy:', manager.funds.virtual.buy);
|
|
1839
|
+
console.log('Committed buy:', manager.funds.committed.grid.buy);
|
|
1840
|
+
console.log('Available buy:', manager.funds.available.buy);
|
|
1841
|
+
```
|
|
1842
|
+
|
|
1843
|
+
---
|
|
1844
|
+
|
|
1845
|
+
## Getting Help
|
|
1846
|
+
|
|
1847
|
+
### Common Questions
|
|
1848
|
+
|
|
1849
|
+
**Q: Where do I start reading the code?**
|
|
1850
|
+
A: Follow the Code Reading Roadmap above, starting with `constants.ts` and `manager.ts`.
|
|
1851
|
+
|
|
1852
|
+
**Q: How do I debug fund issues?**
|
|
1853
|
+
A: Use `manager.logger.logFundsStatus(manager)` and check invariants with `_verifyFundInvariants()`.
|
|
1854
|
+
|
|
1855
|
+
**Q: Why is my order not rotating?**
|
|
1856
|
+
A: Check if it's locked (`isOrderLocked()`), in exclusion list, or below dust threshold.
|
|
1857
|
+
|
|
1858
|
+
**Q: How do I add a new feature?**
|
|
1859
|
+
A: Follow the "How to Add New Features" section above.
|
|
1860
|
+
|
|
1861
|
+
**Q: Where are the tests?**
|
|
1862
|
+
A: All tests are in the `tests/` directory. Run `npm test` for the full suite, or `tsx tests/<file>.ts` for individual test files.
|
|
1863
|
+
|
|
1864
|
+
---
|
|
1865
|
+
|
|
1866
|
+
## Contributing
|
|
1867
|
+
|
|
1868
|
+
### Branch Workflow
|
|
1869
|
+
```
|
|
1870
|
+
test → dev → main
|
|
1871
|
+
```
|
|
1872
|
+
|
|
1873
|
+
See [WORKFLOW.md](WORKFLOW.md) for detailed branching strategy.
|
|
1874
|
+
|
|
1875
|
+
### Before Submitting PR
|
|
1876
|
+
1. Run tests: `npm test`
|
|
1877
|
+
2. Verify fund invariants
|
|
1878
|
+
3. Check index consistency
|
|
1879
|
+
4. Update documentation
|
|
1880
|
+
5. Add inline comments for complex logic
|
|
1881
|
+
|
|
1882
|
+
---
|
|
1883
|
+
|
|
1884
|
+
## Next Steps
|
|
1885
|
+
|
|
1886
|
+
1. **Read the Architecture**: [architecture.md](architecture.md)
|
|
1887
|
+
2. **Understand Fund Logic**: [FUND_MOVEMENT_AND_ACCOUNTING.md](FUND_MOVEMENT_AND_ACCOUNTING.md)
|
|
1888
|
+
3. **Follow Code Roadmap**: Start with `constants.ts` → `manager.ts`
|
|
1889
|
+
4. **Try Debugging**: Enable debug logging and explore fund status
|
|
1890
|
+
5. **Run Tests**: `npm test` to see how components work
|
|
1891
|
+
|
|
1892
|
+
Happy coding! 🚀
|
|
1893
|
+
|
|
1894
|
+
---
|
|
1895
|
+
|
|
1896
|
+
## Environment Variables
|
|
1897
|
+
|
|
1898
|
+
Control bot behavior via environment variables (useful for advanced setups):
|
|
1899
|
+
|
|
1900
|
+
| Variable | Description |
|
|
1901
|
+
|----------|-------------|
|
|
1902
|
+
| `BOT_NAME` / `LIVE_BOT_NAME` | Select a specific bot from `profiles/bots.json` by name |
|
|
1903
|
+
| `PREFERRED_ACCOUNT` | Override the preferred account for the selected bot |
|
|
1904
|
+
| `OPEN_ORDERS_SYNC_LOOP_MS` | Open-orders sync polling interval in ms (default: `300000` / 5 minutes) |
|
|
1905
|
+
| `CALC_CYCLES` | Calculation passes for standalone grid calculator (default: `3`) |
|
|
1906
|
+
| `CALC_DELAY_MS` | Delay between calculator cycles in ms (default: `500`) |
|
|
1907
|
+
| `DEXBOT_PROFILE_ROOT` | Override the profiles directory (default: `~/.config/dexbot2/profiles` for all installs; a source checkout keeps `<install-root>/profiles` while a populated profiles dir exists there — `bots.json`, `keys.json`, settings, or launcher config) |
|
|
1908
|
+
| `DEXBOT2_ROOT` | Base directory whose `profiles/` subdirectory is used (legacy; overridden by `DEXBOT_PROFILE_ROOT`) |
|
|
1909
|
+
| `DEXBOT_MARKET_ADAPTER_DATA_DIR` | Override the market adapter candle/data directory (default: `<install-root>/market_adapter/data` when profiles resolve to the install root, else `<profiles>/market_adapter/data`) |
|
|
1910
|
+
| `DEXBOT_MARKET_ADAPTER_STATE_DIR` | Override the market adapter state directory (default: `<install-root>/market_adapter/state` when profiles resolve to the install root, else `<profiles>/market_adapter/state`) |
|
|
1911
|
+
| `DEXBOT_CLAW_DATA_DIR` | Override the claw data directory — positions, watcher health, memu (default: `<install-root>/claw/data` when profiles resolve to the install root, else `<profiles>/claw/data`) |
|
|
1912
|
+
|
|
1913
|
+
User state (profiles, market-adapter data/state, and claw data) defaults to
|
|
1914
|
+
`~/.config/dexbot2/profiles` for all installs, so it lives outside the
|
|
1915
|
+
repo/package tree, survives re-clones and `npm update -g`, and is never wiped
|
|
1916
|
+
by package reinstalls. A source checkout with an existing populated `profiles/`
|
|
1917
|
+
dir (any well-known profile file: `bots.json`, `keys.json`, settings, or launcher
|
|
1918
|
+
config — not just bots) keeps its current `<install-root>/profiles` layout until
|
|
1919
|
+
a home config exists (or a `DEXBOT_PROFILE_ROOT` override is set). The
|
|
1920
|
+
`dexbot clear*` / `dexbot default` CLI commands and the shipped
|
|
1921
|
+
`scripts/clear-*.sh` resolve the same directories via
|
|
1922
|
+
`scripts/lib/dexbot-paths.sh`. If market-adapter/claw state is relocated away
|
|
1923
|
+
from a repo that still holds old files, a startup notice points at the new
|
|
1924
|
+
location and the env overrides to migrate.
|
|
1925
|
+
|
|
1926
|
+
Example — run a specific bot with a custom sync interval:
|
|
1927
|
+
```bash
|
|
1928
|
+
BOT_NAME=my-bot OPEN_ORDERS_SYNC_LOOP_MS=30000 dexbot start
|
|
1929
|
+
```
|