dexbot 1.6.12 → 1.6.14

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.
Files changed (213) hide show
  1. package/CHANGELOG.md +65 -1
  2. package/README.md +2 -2
  3. package/analysis/README.md +9 -11
  4. package/analysis/ama_fitting/README.md +5 -3
  5. package/claw/README.md +1 -0
  6. package/claw/docs/AI_BOT_LIBRARY_API.md +3 -1
  7. package/claw/docs/DEXBOT2_TUNING_CHEAT_SHEET.md +4 -4
  8. package/claw/modules/claw_bridge.ts +0 -3
  9. package/claw/modules/claw_catalog.ts +8 -4
  10. package/claw/modules/claw_skill_md.ts +1 -0
  11. package/claw/modules/dexbot_profiles.ts +59 -15
  12. package/claw/modules/types.ts +2 -1
  13. package/claw/package.json +3 -3
  14. package/claw/runtimes/openclaw-plugin/openclaw.plugin.json +1 -1
  15. package/claw/runtimes/openclaw-plugin/package.json +1 -1
  16. package/claw/skills/margin-trading/SKILL.md +1 -1
  17. package/claw/skills/margin-trading/references/position-management.md +1 -1
  18. package/claw/tsconfig.json +2 -2
  19. package/dist/analysis/ama_fitting/analyze_lambda_vs_slow.js +1 -14
  20. package/dist/analysis/ama_fitting/fetch_lp_candles.js +51 -41
  21. package/dist/analysis/ama_fitting/generate_unified_comparison_chart.d.ts +1 -24
  22. package/dist/analysis/ama_fitting/generate_unified_comparison_chart.js +36 -18
  23. package/dist/analysis/ama_fitting/optimizer_high_resolution.js +18 -66
  24. package/dist/analysis/analyze_args.d.ts +12 -0
  25. package/dist/analysis/analyze_args.js +20 -0
  26. package/dist/analysis/bot_fitting/backtest_ama_sweep.d.ts +1 -16
  27. package/dist/analysis/bot_fitting/backtest_ama_sweep.js +20 -101
  28. package/dist/analysis/bot_fitting/backtest_bot_fitting.js +26 -92
  29. package/dist/analysis/bot_fitting/backtest_lookback_drawdown.js +19 -34
  30. package/dist/analysis/bot_fitting/shared_utils.d.ts +71 -3
  31. package/dist/analysis/bot_fitting/shared_utils.js +124 -8
  32. package/dist/analysis/chart_ui.d.ts +30 -1
  33. package/dist/analysis/chart_ui.js +37 -1
  34. package/dist/analysis/fills_cache.d.ts +3 -23
  35. package/dist/analysis/fills_cache.js +3 -84
  36. package/dist/analysis/fills_source.d.ts +31 -1
  37. package/dist/analysis/fills_source.js +69 -1
  38. package/dist/analysis/grid_correction_check.d.ts +1 -23
  39. package/dist/analysis/grid_correction_check.js +15 -58
  40. package/dist/analysis/math_utils.d.ts +85 -1
  41. package/dist/analysis/math_utils.js +116 -1
  42. package/dist/analysis/price_sources.d.ts +22 -1
  43. package/dist/analysis/price_sources.js +23 -0
  44. package/dist/analysis/resolve_source.js +31 -10
  45. package/dist/analysis/trade_profitability.d.ts +6 -0
  46. package/dist/analysis/trade_profitability.js +23 -97
  47. package/dist/analysis/tradingview/analyze_tradingview.d.ts +1 -17
  48. package/dist/analysis/tradingview/analyze_tradingview.js +1 -1
  49. package/dist/analysis/tradingview/tradingview_uplot_chart_generator.js +27 -40
  50. package/dist/analysis/trend_detection/backtest_ama_slope_huber.d.ts +1 -101
  51. package/dist/analysis/trend_detection/backtest_ama_slope_huber.js +22 -80
  52. package/dist/analysis/trend_detection/dynamic_weight_chart_generator.js +11 -37
  53. package/dist/analysis/trend_detection/volatility_chart_generator.js +9 -10
  54. package/dist/analysis/worker_pool.d.ts +38 -0
  55. package/dist/analysis/worker_pool.js +67 -0
  56. package/dist/dexbot.js +67 -48
  57. package/dist/market_adapter/ama_signal_runner.js +21 -54
  58. package/dist/market_adapter/candle_utils.d.ts +7 -1
  59. package/dist/market_adapter/candle_utils.js +11 -1
  60. package/dist/market_adapter/cli_args.d.ts +22 -0
  61. package/dist/market_adapter/cli_args.js +30 -0
  62. package/dist/market_adapter/core/config_normalizers.js +11 -6
  63. package/dist/market_adapter/core/kibana_candles.d.ts +3 -1
  64. package/dist/market_adapter/core/kibana_candles.js +3 -2
  65. package/dist/market_adapter/core/market_adapter_service.d.ts +85 -85
  66. package/dist/market_adapter/core/market_adapter_service.js +93 -158
  67. package/dist/market_adapter/core/signals/hurst_analyzer.d.ts +1 -6
  68. package/dist/market_adapter/core/signals/hurst_analyzer.js +1 -1
  69. package/dist/market_adapter/core/signals/permutation_entropy_analyzer.d.ts +1 -11
  70. package/dist/market_adapter/core/signals/permutation_entropy_analyzer.js +1 -1
  71. package/dist/market_adapter/inputs/fetch_book_data.js +0 -1
  72. package/dist/market_adapter/inputs/fetch_cex_synthetic_data.js +63 -107
  73. package/dist/market_adapter/inputs/fetch_lp_data.d.ts +8 -1
  74. package/dist/market_adapter/inputs/fetch_lp_data.js +25 -7
  75. package/dist/market_adapter/inputs/kibana_feed_source.js +4 -26
  76. package/dist/market_adapter/inputs/window_cache.d.ts +4 -72
  77. package/dist/market_adapter/inputs/window_cache.js +52 -177
  78. package/dist/market_adapter/interval_utils.d.ts +11 -1
  79. package/dist/market_adapter/interval_utils.js +16 -1
  80. package/dist/market_adapter/lp_chart_runner.d.ts +3 -0
  81. package/dist/market_adapter/lp_chart_runner.js +37 -19
  82. package/dist/market_adapter/market_adapter.js +27 -72
  83. package/dist/market_adapter/utils/data_discovery.d.ts +45 -1
  84. package/dist/market_adapter/utils/data_discovery.js +220 -27
  85. package/dist/market_adapter/utils/month_shards.d.ts +84 -0
  86. package/dist/market_adapter/utils/month_shards.js +237 -0
  87. package/dist/modules/account_bots.d.ts +8 -6
  88. package/dist/modules/account_bots.js +112 -131
  89. package/dist/modules/account_orders.d.ts +49 -4
  90. package/dist/modules/account_orders.js +114 -49
  91. package/dist/modules/bitshares-native/chain_client.d.ts +1 -1
  92. package/dist/modules/bitshares-native/chain_client.js +14 -13
  93. package/dist/modules/bitshares-native/crypto/ecc_core.d.ts +1 -2
  94. package/dist/modules/bitshares-native/crypto/ecc_core.js +1 -1
  95. package/dist/modules/bitshares-native/resolvers.js +22 -25
  96. package/dist/modules/bitshares-native/serial/chain_constants.d.ts +1 -2
  97. package/dist/modules/bitshares-native/serial/chain_constants.js +1 -2
  98. package/dist/modules/bitshares-native/serial/types.js +22 -50
  99. package/dist/modules/bitshares-native/signing_client.d.ts +1 -1
  100. package/dist/modules/bot_defaults.d.ts +18 -3
  101. package/dist/modules/bot_defaults.js +34 -8
  102. package/dist/modules/bot_settings.d.ts +5 -1
  103. package/dist/modules/bot_settings.js +55 -21
  104. package/dist/modules/broadcast_failure.d.ts +2 -1
  105. package/dist/modules/chain_orders.d.ts +1 -1
  106. package/dist/modules/chain_orders.js +51 -96
  107. package/dist/modules/cli_start_onboarding.d.ts +2 -1
  108. package/dist/modules/config.js +6 -1
  109. package/dist/modules/constants.d.ts +14 -6
  110. package/dist/modules/constants.js +32 -6
  111. package/dist/modules/cr_planner.d.ts +1 -1
  112. package/dist/modules/cr_planner.js +1 -5
  113. package/dist/modules/credit_pricing.d.ts +2 -1
  114. package/dist/modules/credit_pricing.js +36 -40
  115. package/dist/modules/credit_runtime.d.ts +7 -0
  116. package/dist/modules/credit_runtime.js +45 -73
  117. package/dist/modules/daemon_node_health.d.ts +4 -3
  118. package/dist/modules/dexbot_class.d.ts +33 -17
  119. package/dist/modules/dexbot_class.js +113 -61
  120. package/dist/modules/dexbot_cow_runtime.d.ts +62 -181
  121. package/dist/modules/dexbot_cow_runtime.js +380 -69
  122. package/dist/modules/dexbot_credential_client.d.ts +1 -23
  123. package/dist/modules/dexbot_credential_client.js +2 -3
  124. package/dist/modules/dexbot_fill_runtime.d.ts +2 -3
  125. package/dist/modules/dexbot_fill_runtime.js +17 -7
  126. package/dist/modules/dexbot_maintenance_runtime.d.ts +36 -81
  127. package/dist/modules/dexbot_maintenance_runtime.js +137 -133
  128. package/dist/modules/dexbot_startup_runtime.d.ts +0 -1
  129. package/dist/modules/dexbot_startup_runtime.js +25 -14
  130. package/dist/modules/dexbot_state_recovery.js +16 -0
  131. package/dist/modules/general_settings.d.ts +1 -1
  132. package/dist/modules/graceful_shutdown.js +17 -11
  133. package/dist/modules/key_store.d.ts +0 -5
  134. package/dist/modules/key_store.js +1 -2
  135. package/dist/modules/lazy_shim.d.ts +11 -0
  136. package/dist/modules/lazy_shim.js +16 -0
  137. package/dist/modules/node_connect_policy.d.ts +3 -2
  138. package/dist/modules/node_failure_ledger.d.ts +6 -5
  139. package/dist/modules/order/accounting.js +11 -11
  140. package/dist/modules/order/export.js +2 -2
  141. package/dist/modules/order/format.d.ts +26 -3
  142. package/dist/modules/order/format.js +33 -3
  143. package/dist/modules/order/genesis_policy.d.ts +4 -4
  144. package/dist/modules/order/genesis_policy.js +6 -3
  145. package/dist/modules/order/grid.d.ts +26 -12
  146. package/dist/modules/order/grid.js +468 -80
  147. package/dist/modules/order/grid_reconcile.d.ts +1 -1
  148. package/dist/modules/order/grid_reconcile.js +5 -5
  149. package/dist/modules/order/grid_reconcile_internal.js +48 -40
  150. package/dist/modules/order/index.d.ts +35 -8
  151. package/dist/modules/order/logger.d.ts +1 -8
  152. package/dist/modules/order/logger.js +2 -11
  153. package/dist/modules/order/manager.d.ts +18 -15
  154. package/dist/modules/order/manager.js +91 -74
  155. package/dist/modules/order/strategy.d.ts +2 -2
  156. package/dist/modules/order/strategy.js +51 -21
  157. package/dist/modules/order/sync_engine.js +4 -0
  158. package/dist/modules/order/utils/math.d.ts +3 -3
  159. package/dist/modules/order/utils/math.js +38 -27
  160. package/dist/modules/order/utils/order.d.ts +58 -58
  161. package/dist/modules/order/utils/order.js +158 -137
  162. package/dist/modules/order/utils/system.d.ts +202 -35
  163. package/dist/modules/order/utils/system.js +409 -31
  164. package/dist/modules/order/utils/validate.js +28 -6
  165. package/dist/modules/order/utils/withPoolRef.d.ts +2 -1
  166. package/dist/modules/paths.js +32 -34
  167. package/dist/modules/runtime_settings.d.ts +3 -5
  168. package/dist/modules/runtime_settings.js +3 -3
  169. package/dist/modules/settings_merge.d.ts +2 -2
  170. package/dist/modules/socket_json_client.d.ts +2 -1
  171. package/dist/modules/types.d.ts +89 -30
  172. package/dist/modules/utils/errors.js +1 -3
  173. package/dist/modules/version_notice.d.ts +11 -10
  174. package/dist/pm2.d.ts +0 -1
  175. package/dist/pm2.js +56 -35
  176. package/dist/scripts/analyze-git.js +2 -15
  177. package/dist/scripts/analyze-orders.d.ts +1 -1
  178. package/dist/scripts/analyze-orders.js +4 -4
  179. package/dist/scripts/chart_command.js +2 -2
  180. package/dist/scripts/check_any.d.ts +4 -0
  181. package/dist/scripts/check_any.js +53 -21
  182. package/dist/scripts/diagnose-pool-history.js +1 -6
  183. package/dist/scripts/divergence-calc.js +6 -6
  184. package/dist/scripts/run-tests.js +0 -1
  185. package/dist/scripts/sync-version.js +0 -10
  186. package/dist/scripts/validate_bots.d.ts +1 -1
  187. package/dist/scripts/validate_bots.js +3 -3
  188. package/dist/unlock.js +7 -2
  189. package/docs/BITSHARES_ONBOARDING.md +8 -12
  190. package/docs/COPY_ON_WRITE_MASTER_PLAN.md +2 -3
  191. package/docs/COW_INVARIANTS.md +6 -6
  192. package/docs/DEXBOT_COMPARISON.md +7 -7
  193. package/docs/EVOLUTION.md +10 -8
  194. package/docs/FUND_MOVEMENT_AND_ACCOUNTING.md +8 -6
  195. package/docs/GRID_PRICE_INVARIANT.md +3 -3
  196. package/docs/GRID_RECALCULATION.md +4 -1
  197. package/docs/GRID_RECONCILE.md +4 -4
  198. package/docs/LIFECYCLE.md +11 -11
  199. package/docs/LOGGING.md +14 -0
  200. package/docs/MPA_CREDIT_USAGE.md +1 -1
  201. package/docs/ORDER_ENGINE_POST_1.0_RETROSPECTIVE.md +12 -4
  202. package/docs/README.md +3 -3
  203. package/docs/WORKFLOW.md +1 -0
  204. package/docs/architecture.md +25 -16
  205. package/docs/developer_guide.md +7 -2
  206. package/market_adapter/README.md +6 -4
  207. package/package.json +6 -9
  208. package/scripts/README.md +43 -38
  209. package/tests/README.md +26 -11
  210. package/dist/scripts/diagnose-kibana-candles.d.ts +0 -3
  211. package/dist/scripts/diagnose-kibana-candles.js +0 -82
  212. package/scripts/git-viewer.sh +0 -489
  213. package/scripts/postinstall.js +0 -16
@@ -41,6 +41,24 @@ function sortOperation(array, st_operation) {
41
41
  return strCmp(String(fa), String(fb));
42
42
  });
43
43
  }
44
+ /**
45
+ * Build a SerType for a bounded integer. `read`/`write` are the codec hooks;
46
+ * `min`/`max` drive requireRange in every direction. Shared by the
47
+ * uint8/uint16/uint32/varint32 definitions, which differ only by codec+range.
48
+ */
49
+ function makeIntType(name, min, max, read, write) {
50
+ return {
51
+ fromByteBuffer(b) { return read(b); },
52
+ appendByteBuffer(b, v) { requireRange(min, max, v, name); write(b, v); },
53
+ fromObject(v) { requireRange(min, max, v, name); return v; },
54
+ toObject(v, debug) {
55
+ if (debug && debug.use_default && v === undefined)
56
+ return 0;
57
+ requireRange(min, max, v, name);
58
+ return parseInt(String(v), 10);
59
+ },
60
+ };
61
+ }
44
62
  const void_type = {
45
63
  fromByteBuffer() { return undefined; },
46
64
  appendByteBuffer() { },
@@ -51,56 +69,10 @@ const void_type = {
51
69
  return undefined;
52
70
  },
53
71
  };
54
- const uint8 = {
55
- fromByteBuffer(b) { return b.readUint8(); },
56
- appendByteBuffer(b, v) { requireRange(0, 0xFF, v, 'uint8'); b.writeUint8(v); },
57
- fromObject(v) { requireRange(0, 0xFF, v, 'uint8'); return v; },
58
- toObject(v, debug) {
59
- if (debug && debug.use_default && v === undefined)
60
- return 0;
61
- requireRange(0, 0xFF, v, 'uint8');
62
- return parseInt(String(v), 10);
63
- },
64
- };
65
- const uint16 = {
66
- fromByteBuffer(b) { return b.readUint16(); },
67
- appendByteBuffer(b, v) { requireRange(0, 0xFFFF, v, 'uint16'); b.writeUint16(v); },
68
- fromObject(v) { requireRange(0, 0xFFFF, v, 'uint16'); return v; },
69
- toObject(v, debug) {
70
- if (debug && debug.use_default && v === undefined)
71
- return 0;
72
- requireRange(0, 0xFFFF, v, 'uint16');
73
- return parseInt(String(v), 10);
74
- },
75
- };
76
- const uint32 = {
77
- fromByteBuffer(b) { return b.readUint32(); },
78
- appendByteBuffer(b, v) { requireRange(0, 0xFFFFFFFF, v, 'uint32'); b.writeUint32(v); },
79
- fromObject(v) { requireRange(0, 0xFFFFFFFF, v, 'uint32'); return v; },
80
- toObject(v, debug) {
81
- if (debug && debug.use_default && v === undefined)
82
- return 0;
83
- requireRange(0, 0xFFFFFFFF, v, 'uint32');
84
- return parseInt(String(v), 10);
85
- },
86
- };
87
- const varint32 = {
88
- fromByteBuffer(b) { return b.readVarint32(); },
89
- appendByteBuffer(b, v) {
90
- requireRange(-2147483648, 2147483647, v, 'varint32');
91
- b.writeVarint32(v);
92
- },
93
- fromObject(v) {
94
- requireRange(-2147483648, 2147483647, v, 'varint32');
95
- return v;
96
- },
97
- toObject(v, debug) {
98
- if (debug && debug.use_default && v === undefined)
99
- return 0;
100
- requireRange(-2147483648, 2147483647, v, 'varint32');
101
- return parseInt(String(v), 10);
102
- },
103
- };
72
+ const uint8 = makeIntType('uint8', 0, 0xFF, (b) => b.readUint8(), (b, v) => b.writeUint8(v));
73
+ const uint16 = makeIntType('uint16', 0, 0xFFFF, (b) => b.readUint16(), (b, v) => b.writeUint16(v));
74
+ const uint32 = makeIntType('uint32', 0, 0xFFFFFFFF, (b) => b.readUint32(), (b, v) => b.writeUint32(v));
75
+ const varint32 = makeIntType('varint32', -2147483648, 2147483647, (b) => b.readVarint32(), (b, v) => b.writeVarint32(v));
104
76
  const int64 = {
105
77
  fromByteBuffer(b) { return b.readInt64(); },
106
78
  appendByteBuffer(b, v) {
@@ -14,7 +14,7 @@ export interface BtsdexTx {
14
14
  getOperationCount(): number;
15
15
  [key: string]: unknown;
16
16
  }
17
- export interface SigningClient {
17
+ interface SigningClient {
18
18
  client: {
19
19
  initPromise: Promise<void> | null;
20
20
  newTx(): BtsdexTx;
@@ -19,7 +19,7 @@
19
19
  * tests/test_bot_defaults_parity.ts — update them together with this file.
20
20
  */
21
21
  import type { UnknownRecord } from './types.js';
22
- export interface SeedOptions {
22
+ interface SeedOptions {
23
23
  /** Defaults source; omit to use the merged DEFAULT_CONFIG. */
24
24
  defaults?: UnknownRecord;
25
25
  }
@@ -47,14 +47,28 @@ export declare const DRAFT_SEED_ORDER: string[];
47
47
  * @returns {boolean}
48
48
  */
49
49
  export declare function isUnsetGridPrice(value: unknown): boolean;
50
+ /**
51
+ * Legacy bot-config key aliases: `activeOrders` → `coreOrders` and
52
+ * `reserveOrders` → `edgeOrders`. Applied at every read/seed funnel so a
53
+ * pre-rename or hand-edited `bots.json` keeps working: the new key wins when
54
+ * both are present, the legacy key is dropped, and a later save rewrites the
55
+ * entry in canonical form. Mutates and returns the passed object.
56
+ *
57
+ * Must run BEFORE fingerprinting and the live-config allowlist so both see the
58
+ * canonical key (the maintained-key list and the raw-key fingerprint would
59
+ * otherwise miss a legacy entry).
60
+ * @param {Object} data - Bot entry or runtime config.
61
+ * @returns {Object} The same object, aliased in place.
62
+ */
63
+ export declare function migrateLegacyOrderKeys<T extends UnknownRecord>(data: T): T;
50
64
  /**
51
65
  * Editor draft seed (formerly the `normalizeBotDraft` if-chain in
52
66
  * modules/account_bots.ts). Deep-clones the input, then applies defaults:
53
67
  *
54
- * * count objects (`weightDistribution`/`botFunds`/`activeOrders`): falsy
68
+ * * count objects (`weightDistribution`/`botFunds`/`coreOrders`): falsy
55
69
  * input → default clone; truthy input (including partials) kept verbatim —
56
70
  * never deep-filled;
57
- * * `reserveOrders`: number migration / invalid → default (see seedReserveOrders);
71
+ * * `edgeOrders`: number migration / invalid → default (see seedEdgeOrders);
58
72
  * * `startPrice`: undefined → `default || 'pool'` (falsy defaults fall back);
59
73
  * * `gridPrice`: undefined → `DEFAULT_CONFIG.gridPrice` ("ama3" today),
60
74
  * falling back to null only when the default itself is null (Phase 2:
@@ -86,4 +100,5 @@ export declare function seedBotEntry<T extends UnknownRecord>(entry: T, options?
86
100
  * (the historical shallow spread aliased every nested default object).
87
101
  */
88
102
  export declare function seedBotRuntimeConfig(config?: UnknownRecord, options?: SeedOptions): UnknownRecord;
103
+ export {};
89
104
  //# sourceMappingURL=bot_defaults.d.ts.map
@@ -33,7 +33,7 @@ export const DRAFT_EXCLUDED_KEYS = ['assetA', 'assetB', 'creditOnly', 'min_BTS_v
33
33
  * fails when a new DEFAULT_CONFIG key is added without classifying it here.
34
34
  */
35
35
  export const DRAFT_SEED_ORDER = [
36
- 'weightDistribution', 'botFunds', 'activeOrders', 'reserveOrders',
36
+ 'weightDistribution', 'botFunds', 'coreOrders', 'edgeOrders',
37
37
  'active', 'dryRun', 'minPrice', 'maxPrice', 'incrementPercent',
38
38
  'targetSpreadPercent', 'startPrice', 'gridPrice',
39
39
  ];
@@ -68,10 +68,35 @@ function clone(value) {
68
68
  return value;
69
69
  return JSON.parse(JSON.stringify(value));
70
70
  }
71
+ /**
72
+ * Legacy bot-config key aliases: `activeOrders` → `coreOrders` and
73
+ * `reserveOrders` → `edgeOrders`. Applied at every read/seed funnel so a
74
+ * pre-rename or hand-edited `bots.json` keeps working: the new key wins when
75
+ * both are present, the legacy key is dropped, and a later save rewrites the
76
+ * entry in canonical form. Mutates and returns the passed object.
77
+ *
78
+ * Must run BEFORE fingerprinting and the live-config allowlist so both see the
79
+ * canonical key (the maintained-key list and the raw-key fingerprint would
80
+ * otherwise miss a legacy entry).
81
+ * @param {Object} data - Bot entry or runtime config.
82
+ * @returns {Object} The same object, aliased in place.
83
+ */
84
+ export function migrateLegacyOrderKeys(data) {
85
+ const record = data;
86
+ if (record.coreOrders === undefined && record.activeOrders !== undefined) {
87
+ record.coreOrders = record.activeOrders;
88
+ }
89
+ if (record.edgeOrders === undefined && record.reserveOrders !== undefined) {
90
+ record.edgeOrders = record.reserveOrders;
91
+ }
92
+ delete record.activeOrders;
93
+ delete record.reserveOrders;
94
+ return data;
95
+ }
71
96
  /** Numbers migrate to `{ buy, sell: 0 }` (floored, clamped at 0); anything
72
97
  * that is not a plain object becomes the default; plain objects — including
73
98
  * partial ones — are kept verbatim. */
74
- function seedReserveOrders(value, def) {
99
+ function seedEdgeOrders(value, def) {
75
100
  if (typeof value === 'number') {
76
101
  return { buy: Math.max(0, Math.floor(value)), sell: 0 };
77
102
  }
@@ -84,10 +109,10 @@ function seedReserveOrders(value, def) {
84
109
  * Editor draft seed (formerly the `normalizeBotDraft` if-chain in
85
110
  * modules/account_bots.ts). Deep-clones the input, then applies defaults:
86
111
  *
87
- * * count objects (`weightDistribution`/`botFunds`/`activeOrders`): falsy
112
+ * * count objects (`weightDistribution`/`botFunds`/`coreOrders`): falsy
88
113
  * input → default clone; truthy input (including partials) kept verbatim —
89
114
  * never deep-filled;
90
- * * `reserveOrders`: number migration / invalid → default (see seedReserveOrders);
115
+ * * `edgeOrders`: number migration / invalid → default (see seedEdgeOrders);
91
116
  * * `startPrice`: undefined → `default || 'pool'` (falsy defaults fall back);
92
117
  * * `gridPrice`: undefined → `DEFAULT_CONFIG.gridPrice` ("ama3" today),
93
118
  * falling back to null only when the default itself is null (Phase 2:
@@ -96,11 +121,11 @@ function seedReserveOrders(value, def) {
96
121
  */
97
122
  export function seedBotDraft(base, options = {}) {
98
123
  const defaults = options.defaults ?? DEFAULT_CONFIG;
99
- const data = JSON.parse(JSON.stringify(base ?? {}));
124
+ const data = migrateLegacyOrderKeys(JSON.parse(JSON.stringify(base ?? {})));
100
125
  for (const key of DRAFT_SEED_ORDER) {
101
126
  const def = defaults[key];
102
- if (key === 'reserveOrders') {
103
- data.reserveOrders = seedReserveOrders(data.reserveOrders, def);
127
+ if (key === 'edgeOrders') {
128
+ data.edgeOrders = seedEdgeOrders(data.edgeOrders, def);
104
129
  }
105
130
  else if (key === 'startPrice') {
106
131
  if (data.startPrice === undefined)
@@ -139,7 +164,8 @@ export function seedBotDraft(base, options = {}) {
139
164
  */
140
165
  export function seedBotEntry(entry, options = {}) {
141
166
  const defaults = options.defaults ?? DEFAULT_CONFIG;
142
- return { active: entry.active === undefined ? defaults.active : entry.active, ...entry };
167
+ const data = migrateLegacyOrderKeys({ ...entry });
168
+ return { active: data.active === undefined ? defaults.active : data.active, ...data };
143
169
  }
144
170
  /**
145
171
  * Runtime config seed (formerly `{ ...DEFAULT_CONFIG, ...config }` in the
@@ -6,7 +6,7 @@ export interface BotLendingEntry extends UnknownRecord {
6
6
  type?: unknown;
7
7
  }
8
8
  /** `debtPolicy` block of a bot entry. */
9
- export interface BotDebtPolicy extends UnknownRecord {
9
+ interface BotDebtPolicy extends UnknownRecord {
10
10
  lending?: BotLendingEntry[];
11
11
  maxCollateralAmount?: unknown;
12
12
  }
@@ -20,7 +20,11 @@ export interface BotEntry extends UnknownRecord {
20
20
  botKey?: string;
21
21
  botIndex?: number;
22
22
  preferredAccount?: string;
23
+ coreOrders?: UnknownRecord;
24
+ edgeOrders?: number | UnknownRecord;
25
+ /** @deprecated legacy key, migrated to `coreOrders` at read time. */
23
26
  activeOrders?: UnknownRecord;
27
+ /** @deprecated legacy key, migrated to `edgeOrders` at read time. */
24
28
  reserveOrders?: number | UnknownRecord;
25
29
  botFunds?: {
26
30
  buy?: unknown;
@@ -1,8 +1,8 @@
1
1
  import { getStorage } from './storage/index.js';
2
- import { readBotsFileSync } from './bots_file_lock.js';
2
+ import { readBotsFileSync, writeJsonFileAtomic } from './bots_file_lock.js';
3
3
  import { parseJsonWithComments } from './order/utils/system.js';
4
4
  import { createBotKey } from './account_orders.js';
5
- import { seedBotEntry } from './bot_defaults.js';
5
+ import { seedBotEntry, migrateLegacyOrderKeys } from './bot_defaults.js';
6
6
  import { isSameBotName } from './utils/sanitize_key.js';
7
7
  import { isPositiveNumber, isPositiveNumberOrPercent, toDecimal } from './order/utils/math.js';
8
8
  import { resolveMinCollateralIncreaseThreshold } from './cr_planner.js';
@@ -20,6 +20,11 @@ function loadSettingsFile(filePath, { silent = false, exitOnError = true } = {})
20
20
  }
21
21
  try {
22
22
  const { config } = readBotsFileSync(filePath, parseJsonWithComments);
23
+ // Upgrade a pre-rename file in place: legacy `activeOrders`/
24
+ // `reserveOrders` keys become `coreOrders`/`edgeOrders` and the file is
25
+ // rewritten in canonical form. Idempotent; a failed write is
26
+ // non-fatal because the in-memory config is already canonical.
27
+ migratePersistedOrderKeys(filePath, config);
23
28
  return { config, filePath };
24
29
  }
25
30
  catch (err) {
@@ -50,6 +55,32 @@ function resolveRawBotEntries(settings) {
50
55
  return [settings];
51
56
  return [];
52
57
  }
58
+ /**
59
+ * Persist the user-settings key upgrade: rewrite bots.json in canonical form
60
+ * when any entry still carries the legacy `activeOrders`/`reserveOrders` keys.
61
+ * Runs at the read funnel so an old file is transparently migrated.
62
+ * @param {string} filePath - bots.json path
63
+ * @param {unknown} config - Parsed bots.json document (mutated in place)
64
+ * @returns {boolean} True when a legacy key was found and upgraded
65
+ */
66
+ function migratePersistedOrderKeys(filePath, config) {
67
+ let changed = false;
68
+ for (const entry of resolveRawBotEntries(config)) {
69
+ if (isUnknownRecord(entry) && ('activeOrders' in entry || 'reserveOrders' in entry)) {
70
+ migrateLegacyOrderKeys(entry);
71
+ changed = true;
72
+ }
73
+ }
74
+ if (changed) {
75
+ try {
76
+ writeJsonFileAtomic(filePath, config);
77
+ }
78
+ catch (err) {
79
+ console.error('Failed to persist upgraded bot settings to', filePath, '-', getErrorMessage(err));
80
+ }
81
+ }
82
+ return changed;
83
+ }
53
84
  function normalizeBotEntry(entry, index = 0) {
54
85
  // active default + raw passthrough live in modules/bot_defaults.ts
55
86
  // (shared with the claw copy — one semantics for both).
@@ -81,40 +112,43 @@ function selectActiveBotEntries(settings) {
81
112
  }
82
113
  function validateBotEntry(b, i, src) {
83
114
  const problems = [];
115
+ // Legacy `activeOrders`/`reserveOrders` keys are accepted and validated
116
+ // under their canonical names so a pre-rename bots.json is not rejected.
117
+ const entry = migrateLegacyOrderKeys({ ...b });
84
118
  const isCreditOnly = b.creditOnly === true;
85
- const required = isCreditOnly ? [] : ['assetA', 'assetB', 'activeOrders', 'botFunds'];
119
+ const required = isCreditOnly ? [] : ['assetA', 'assetB', 'coreOrders', 'botFunds'];
86
120
  for (const k of required) {
87
- if (!(k in b))
121
+ if (!(k in entry))
88
122
  problems.push(`missing '${k}'`);
89
123
  }
90
- if ('activeOrders' in b) {
91
- if (typeof b.activeOrders !== 'object' || b.activeOrders === null)
92
- problems.push("'activeOrders' must be an object");
124
+ if ('coreOrders' in entry) {
125
+ if (typeof entry.coreOrders !== 'object' || entry.coreOrders === null)
126
+ problems.push("'coreOrders' must be an object");
93
127
  else {
94
- if (!('buy' in b.activeOrders))
95
- problems.push("activeOrders missing 'buy'");
96
- if (!('sell' in b.activeOrders))
97
- problems.push("activeOrders missing 'sell'");
128
+ if (!('buy' in entry.coreOrders))
129
+ problems.push("coreOrders missing 'buy'");
130
+ if (!('sell' in entry.coreOrders))
131
+ problems.push("coreOrders missing 'sell'");
98
132
  }
99
133
  }
100
- if ('reserveOrders' in b && b.reserveOrders !== undefined && b.reserveOrders !== null) {
101
- if (typeof b.reserveOrders === 'number') {
102
- // Legacy numeric form migrates at read time (resolveReserveCount):
134
+ if ('edgeOrders' in entry && entry.edgeOrders !== undefined && entry.edgeOrders !== null) {
135
+ if (typeof entry.edgeOrders === 'number') {
136
+ // Legacy numeric form migrates at read time (resolveEdgeCount):
103
137
  // { buy: n, sell: 0 }. Accept it here so a hand-edited bots.json
104
138
  // that bypassed the editor is not rejected for a form the runtime
105
139
  // still understands.
106
- if (!Number.isInteger(b.reserveOrders) || b.reserveOrders < 0)
107
- problems.push("'reserveOrders' numeric form must be a non-negative integer");
140
+ if (!Number.isInteger(entry.edgeOrders) || entry.edgeOrders < 0)
141
+ problems.push("'edgeOrders' numeric form must be a non-negative integer");
108
142
  }
109
- else if (typeof b.reserveOrders !== 'object' || Array.isArray(b.reserveOrders)) {
110
- problems.push("'reserveOrders' must be an object {buy, sell}");
143
+ else if (typeof entry.edgeOrders !== 'object' || Array.isArray(entry.edgeOrders)) {
144
+ problems.push("'edgeOrders' must be an object {buy, sell}");
111
145
  }
112
146
  else {
113
147
  for (const side of ['buy', 'sell']) {
114
- const reserveOrders = b.reserveOrders;
115
- const v = reserveOrders[side];
148
+ const edgeOrders = entry.edgeOrders;
149
+ const v = edgeOrders[side];
116
150
  if (v !== undefined && (!Number.isInteger(Number(v)) || Number(v) < 0))
117
- problems.push(`'reserveOrders.${side}' must be a non-negative integer`);
151
+ problems.push(`'edgeOrders.${side}' must be a non-negative integer`);
118
152
  }
119
153
  }
120
154
  }
@@ -11,7 +11,7 @@
11
11
  * Mirrors the failure modes produced by modules/bitshares-native/transport.ts
12
12
  * call() and the signing client (modules/bitshares-native/signing_client.ts).
13
13
  */
14
- export type BroadcastFailureClass = 'retryable' | 'uncertain' | 'definite';
14
+ type BroadcastFailureClass = 'retryable' | 'uncertain' | 'definite';
15
15
  /**
16
16
  * Classify a broadcast-phase failure.
17
17
  *
@@ -30,4 +30,5 @@ export type BroadcastFailureClass = 'retryable' | 'uncertain' | 'definite';
30
30
  * @returns {BroadcastFailureClass}
31
31
  */
32
32
  export declare function classifyBroadcastFailure(err: unknown): BroadcastFailureClass;
33
+ export {};
33
34
  //# sourceMappingURL=broadcast_failure.d.ts.map
@@ -493,7 +493,7 @@ declare function findOverReducingUpdateOpError(operations: unknown): Promise<Err
493
493
  * @param {string} accountName - Account paying fees (usually the bot account)
494
494
  * @param {string|Object} privateKey - Private key for signing (or daemon signing token)
495
495
  * @param {Array} operations - Array of operation objects { op_name, op_data } returned by build helpers
496
- * @param {Object} [extraOptions] - Optional parameters (fallbackNodes, etc.)
496
+ * @param {Object} [extraOptions] - Optional parameters (nodeUrl, onNodeFailed, etc.)
497
497
  * @returns {Promise<Object>} Transaction result
498
498
  */
499
499
  declare function executeBatch(accountName: string | null | undefined, privateKey: unknown, operations: OperationLike[], extraOptions?: Record<string, unknown>): Promise<import("./key_store.js").SigningResult | {
@@ -229,33 +229,38 @@ async function getPreferredAccount() {
229
229
  });
230
230
  }
231
231
  /**
232
- * Resolve an account ID to its human-readable name via chain lookup.
233
- * Results are cached to prevent repeated lookups (fixes Issue #4).
234
- * @param {string} accountRef - Account ID (e.g., '1.2.12345') or name
235
- * @returns {Promise<string|null>} Account name or null if not found
232
+ * Resolve an account reference against the shared name<->id cache under the
233
+ * resolution lock. `direction` picks which field is looked up and returned:
234
+ * 'to-name' resolves an id to a name, 'to-id' a name to an id. A reference
235
+ * already shaped as the target (id for 'to-name', non-id for 'to-id') is
236
+ * returned untouched, and the reverse mapping is cached alongside the result.
237
+ * @param {string} accountRef - Account id or name
238
+ * @param {'to-name'|'to-id'} direction - Direction of resolution
239
+ * @returns {Promise<string|null>} Resolved value or null if not found
236
240
  */
237
- async function resolveAccountName(accountRef) {
241
+ async function resolveAccount(accountRef, direction) {
238
242
  if (!accountRef)
239
243
  return null;
240
244
  if (typeof accountRef !== 'string')
241
245
  return null;
242
- if (!/^1\.2\./.test(accountRef))
246
+ if (direction === 'to-name' ? !/^1\.2\./.test(accountRef) : /^1\.2\.\d+$/.test(accountRef))
243
247
  return accountRef;
244
248
  return await _resolutionLock.acquire(async () => {
245
249
  // Check cache first
246
- const cacheKey = `id->${accountRef}`;
250
+ const cacheKey = `${direction === 'to-name' ? 'id->' : 'name->'}${accountRef}`;
247
251
  if (_accountResolutionCache.has(cacheKey)) {
248
252
  return _accountResolutionCache.get(cacheKey) ?? null;
249
253
  }
250
254
  try {
251
255
  await waitForConnected();
252
256
  const full = await BitShares.db.get_full_accounts([accountRef], false);
253
- if (full && full[0] && full[0][1] && full[0][1].account && full[0][1].account.name) {
254
- const name = full[0][1].account.name;
255
- _accountResolutionCache.set(cacheKey, name);
257
+ const account = full && full[0] && full[0][1] && full[0][1].account;
258
+ const result = direction === 'to-name' ? account?.name : account?.id;
259
+ if (result) {
260
+ _accountResolutionCache.set(cacheKey, result);
256
261
  // Also cache reverse mapping
257
- _accountResolutionCache.set(`name->${name}`, accountRef);
258
- return name;
262
+ _accountResolutionCache.set(`${direction === 'to-name' ? 'name' : 'id'}->${result}`, accountRef);
263
+ return result;
259
264
  }
260
265
  }
261
266
  catch (err) {
@@ -264,6 +269,15 @@ async function resolveAccountName(accountRef) {
264
269
  return null;
265
270
  });
266
271
  }
272
+ /**
273
+ * Resolve an account ID to its human-readable name via chain lookup.
274
+ * Results are cached to prevent repeated lookups (fixes Issue #4).
275
+ * @param {string} accountRef - Account ID (e.g., '1.2.12345') or name
276
+ * @returns {Promise<string|null>} Account name or null if not found
277
+ */
278
+ async function resolveAccountName(accountRef) {
279
+ return resolveAccount(accountRef, 'to-name');
280
+ }
267
281
  /**
268
282
  * Resolve an account name to its ID via chain lookup.
269
283
  * Results are cached to prevent repeated lookups (fixes Issue #4).
@@ -271,36 +285,7 @@ async function resolveAccountName(accountRef) {
271
285
  * @returns {Promise<string|null>} Account ID or null if not found
272
286
  */
273
287
  async function resolveAccountId(accountName) {
274
- if (!accountName)
275
- return null;
276
- if (typeof accountName !== 'string')
277
- return null;
278
- // If already in ID format, return as-is
279
- if (/^1\.2\.\d+$/.test(accountName))
280
- return accountName;
281
- return await _resolutionLock.acquire(async () => {
282
- // Check cache first
283
- const cacheKey = `name->${accountName}`;
284
- if (_accountResolutionCache.has(cacheKey)) {
285
- return _accountResolutionCache.get(cacheKey) ?? null;
286
- }
287
- try {
288
- await waitForConnected();
289
- const full = await BitShares.db.get_full_accounts([accountName], false);
290
- // full[0][0] is the account name (key), full[0][1] contains account data
291
- if (full && full[0] && full[0][1] && full[0][1].account && full[0][1].account.id) {
292
- const id = full[0][1].account.id;
293
- _accountResolutionCache.set(cacheKey, id);
294
- // Also cache reverse mapping
295
- _accountResolutionCache.set(`id->${id}`, accountName);
296
- return id;
297
- }
298
- }
299
- catch (err) {
300
- // ignore resolution failures
301
- }
302
- return null;
303
- });
288
+ return resolveAccount(accountName, 'to-id');
304
289
  }
305
290
  // Track active account subscriptions so we avoid duplicate listeners per account
306
291
  // Map accountName -> { userCallbacks: Set<Function>, bsCallback: Function }
@@ -439,11 +424,9 @@ function isDaemonSigningToken(value) {
439
424
  async function executeViaDaemonToken(accountName, signingToken, operations, extraOptions = {}) {
440
425
  const nodeManager = getNodeManager();
441
426
  const healthyNodes = nodeManager?.getHealthyNodes() ?? [];
442
- const fallbackNodes = healthyNodes.length > 1 ? healthyNodes.slice(1) : undefined;
443
427
  const opts = extraOptions;
444
- if (healthyNodes.length > 0 && nodeManager && !opts.fallbackNodes && !opts.nodeUrl) {
428
+ if (healthyNodes.length > 0 && nodeManager && !opts.nodeUrl) {
445
429
  opts.nodeUrl = healthyNodes[0];
446
- opts.fallbackNodes = fallbackNodes;
447
430
  opts.onNodeFailed = (nodeUrl) => nodeManager.reportNodeFailure(nodeUrl, DAEMON_CODES.BROADCAST_DEADLINE, 'broadcast');
448
431
  }
449
432
  return getKeyStore().executeOperations(accountName, operations, signingToken, opts);
@@ -737,6 +720,25 @@ async function listenForFills(accountRef, callback) {
737
720
  }
738
721
  };
739
722
  }
723
+ /**
724
+ * Receive amount for a limit_order_update. Policy:
725
+ * - minToReceive provided: absolute override.
726
+ * - newPrice provided: `sellFloat` scaled by the price (multiply for a sell,
727
+ * divide for a buy).
728
+ * - otherwise: keep the existing on-chain price ratio (`sellInt * quote/base`).
729
+ * Shared by the pre- and post-delta computations so both agree.
730
+ */
731
+ function computeOrderReceiveInt(newParams, receivePrecision, sellInt, sellFloat, priceRatioBase, priceRatioQuote) {
732
+ if (newParams.minToReceive !== undefined && newParams.minToReceive !== null) {
733
+ return floatToBlockchainInt(newParams.minToReceive, receivePrecision);
734
+ }
735
+ if (newParams.newPrice !== undefined && newParams.newPrice !== null) {
736
+ const price = toFiniteNumber(newParams.newPrice);
737
+ const receiveFloat = newParams.orderType === 'sell' ? sellFloat * price : sellFloat / price;
738
+ return floatToBlockchainInt(receiveFloat, receivePrecision);
739
+ }
740
+ return Math.round((sellInt * priceRatioQuote) / priceRatioBase);
741
+ }
740
742
  /**
741
743
  * Build a limit_order_update operation.
742
744
  * @param {string} accountName - The name of the account.
@@ -784,7 +786,6 @@ async function buildUpdateOrderOp(accountName, orderId, newParams, cachedOrder =
784
786
  const sellPrecision = await _getAssetPrecision(sellAssetId);
785
787
  const receivePrecision = await _getAssetPrecision(receiveAssetId);
786
788
  const currentSellInt = toFiniteNumber(order.for_sale);
787
- const currentSellFloat = blockchainToFloat(currentSellInt, sellPrecision);
788
789
  const priceRatioBase = toFiniteNumber(order.sell_price.base.amount);
789
790
  const priceRatioQuote = toFiniteNumber(order.sell_price.quote.amount);
790
791
  const currentReceiveInt = Math.round((currentSellInt * priceRatioQuote) / priceRatioBase);
@@ -803,25 +804,7 @@ async function buildUpdateOrderOp(accountName, orderId, newParams, cachedOrder =
803
804
  newSellFloat = blockchainToFloat(currentSellInt, sellPrecision);
804
805
  }
805
806
  // Determine an initial receive amount for price-change detection.
806
- // Policy:
807
- // - If minToReceive is provided: use it as an absolute override.
808
- // - Else if newPrice is provided: compute receive from the (new or current) sell amount.
809
- // - Else: keep the existing on-chain price by scaling receive with sell.
810
- let candidateReceiveInt;
811
- if (newParams.minToReceive !== undefined && newParams.minToReceive !== null) {
812
- candidateReceiveInt = floatToBlockchainInt(newParams.minToReceive, receivePrecision);
813
- }
814
- else if (newParams.newPrice !== undefined && newParams.newPrice !== null) {
815
- const price = toFiniteNumber(newParams.newPrice);
816
- const sellFloat = (newParams.amountToSell !== undefined && newParams.amountToSell !== null) ? newParams.amountToSell : currentSellFloat;
817
- const receiveFloat = (newParams.orderType === 'sell')
818
- ? (sellFloat * price)
819
- : (sellFloat / price);
820
- candidateReceiveInt = floatToBlockchainInt(receiveFloat, receivePrecision);
821
- }
822
- else {
823
- candidateReceiveInt = Math.round((newSellInt * priceRatioQuote) / priceRatioBase);
824
- }
807
+ const candidateReceiveInt = computeOrderReceiveInt(newParams, receivePrecision, newSellInt, newSellFloat, priceRatioBase, priceRatioQuote);
825
808
  // Validate amounts before converting to blockchain integers / computing deltas
826
809
  const candidateReceiveFloat = blockchainToFloat(candidateReceiveInt, receivePrecision);
827
810
  if (!validateOrderAmountsWithinLimits(newSellFloat, candidateReceiveFloat, sellPrecision, receivePrecision)) {
@@ -848,21 +831,7 @@ async function buildUpdateOrderOp(accountName, orderId, newParams, cachedOrder =
848
831
  }
849
832
  }
850
833
  // First, compute the receive amount with the current delta (not adjusted yet)
851
- let newReceiveInt;
852
- if (newParams.minToReceive !== undefined && newParams.minToReceive !== null) {
853
- newReceiveInt = floatToBlockchainInt(newParams.minToReceive, receivePrecision);
854
- }
855
- else if (newParams.newPrice !== undefined && newParams.newPrice !== null) {
856
- const price = toFiniteNumber(newParams.newPrice);
857
- const receiveFloat = (newParams.orderType === 'sell')
858
- ? (newSellFloat * price)
859
- : (newSellFloat / price);
860
- newReceiveInt = floatToBlockchainInt(receiveFloat, receivePrecision);
861
- }
862
- else {
863
- // Keep existing on-chain price ratio.
864
- newReceiveInt = Math.round((newSellInt * priceRatioQuote) / priceRatioBase);
865
- }
834
+ let newReceiveInt = computeOrderReceiveInt(newParams, receivePrecision, newSellInt, newSellFloat, priceRatioBase, priceRatioQuote);
866
835
  // Check if price or amount is actually changing
867
836
  const priceChanged = newReceiveInt !== currentReceiveInt;
868
837
  const amountChanged = deltaSellInt !== 0;
@@ -876,21 +845,7 @@ async function buildUpdateOrderOp(accountName, orderId, newParams, cachedOrder =
876
845
  // Adjust newSellInt to strict logic: current + delta
877
846
  const adjustedSellInt = currentSellInt + deltaSellInt;
878
847
  // Recompute the final receive amount with the adjusted sell amount
879
- if (newParams.minToReceive !== undefined && newParams.minToReceive !== null) {
880
- newReceiveInt = floatToBlockchainInt(newParams.minToReceive, receivePrecision);
881
- }
882
- else if (newParams.newPrice !== undefined && newParams.newPrice !== null) {
883
- const price = toFiniteNumber(newParams.newPrice);
884
- const adjustedSellFloat = blockchainToFloat(adjustedSellInt, sellPrecision);
885
- const receiveFloat = (newParams.orderType === 'sell')
886
- ? (adjustedSellFloat * price)
887
- : (adjustedSellFloat / price);
888
- newReceiveInt = floatToBlockchainInt(receiveFloat, receivePrecision);
889
- }
890
- else {
891
- // Keep existing on-chain price ratio.
892
- newReceiveInt = Math.round((adjustedSellInt * priceRatioQuote) / priceRatioBase);
893
- }
848
+ newReceiveInt = computeOrderReceiveInt(newParams, receivePrecision, adjustedSellInt, blockchainToFloat(adjustedSellInt, sellPrecision), priceRatioBase, priceRatioQuote);
894
849
  const adjustedSellFloat = blockchainToFloat(adjustedSellInt, sellPrecision);
895
850
  const finalReceiveFloat = blockchainToFloat(newReceiveInt, receivePrecision);
896
851
  if (!validateOrderAmountsWithinLimits(adjustedSellFloat, finalReceiveFloat, sellPrecision, receivePrecision)) {
@@ -1246,7 +1201,7 @@ async function findOverReducingUpdateOpError(operations) {
1246
1201
  * @param {string} accountName - Account paying fees (usually the bot account)
1247
1202
  * @param {string|Object} privateKey - Private key for signing (or daemon signing token)
1248
1203
  * @param {Array} operations - Array of operation objects { op_name, op_data } returned by build helpers
1249
- * @param {Object} [extraOptions] - Optional parameters (fallbackNodes, etc.)
1204
+ * @param {Object} [extraOptions] - Optional parameters (nodeUrl, onNodeFailed, etc.)
1250
1205
  * @returns {Promise<Object>} Transaction result
1251
1206
  */
1252
1207
  async function executeBatch(accountName, privateKey, operations, extraOptions = {}) {
@@ -1,4 +1,4 @@
1
- export type StartOnboardingCommand = 'key' | 'bot' | null;
1
+ type StartOnboardingCommand = 'key' | 'bot' | null;
2
2
  /**
3
3
  * Select the setup editor that should handle an otherwise-normal start
4
4
  * command (`start` or its `unlock` alias).
@@ -7,4 +7,5 @@ export type StartOnboardingCommand = 'key' | 'bot' | null;
7
7
  * definitions proceeds to the bot editor.
8
8
  */
9
9
  export declare function selectStartOnboardingCommand(hasKeySetup: boolean, botCount: number): StartOnboardingCommand;
10
+ export {};
10
11
  //# sourceMappingURL=cli_start_onboarding.d.ts.map
@@ -120,8 +120,13 @@ function getTxBuilderFeeCacheTtl() {
120
120
  : undefined;
121
121
  }
122
122
  function setUmask(mode) {
123
+ // Worker threads cannot set the process-wide umask, so skip gracefully
124
+ // there (matches Runtime.umask()'s try/catch guard).
123
125
  if (hasProcess()) {
124
- process.umask(mode);
126
+ try {
127
+ process.umask(mode);
128
+ }
129
+ catch { /* not supported in workers */ }
125
130
  }
126
131
  }
127
132
  // Make path-related env keys live (ESM cache not invalidated via require.cache in tests)