@clonegod/ttd-core 3.1.46 → 3.1.48

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.
@@ -15,11 +15,18 @@ const index_1 = require("../../index");
15
15
  const defi_llama_1 = require("./defi_llama");
16
16
  const gecko_terminal_1 = require("./gecko_terminal");
17
17
  const price_cache_1 = require("./price_cache");
18
+ const ZERO_ADDR = '0x0000000000000000000000000000000000000000';
19
+ const WBNB_ADDR = '0xbb4cdb9cbd36b01bd1cbaebf2de08d9173bc095c';
18
20
  function get_bsc_token_price_info(addresses, opts) {
19
21
  return __awaiter(this, void 0, void 0, function* () {
20
22
  var _a;
21
23
  const source = (_a = opts === null || opts === void 0 ? void 0 : opts.source) !== null && _a !== void 0 ? _a : 'cache_only';
22
24
  addresses = addresses.map(addr => addr.toLowerCase());
25
+ const wantsNativeBnb = addresses.includes(ZERO_ADDR);
26
+ if (wantsNativeBnb) {
27
+ addresses = addresses.map(a => a === ZERO_ADDR ? WBNB_ADDR : a);
28
+ addresses = Array.from(new Set(addresses));
29
+ }
23
30
  const result = new Map();
24
31
  const cachedChannel = {
25
32
  name: 'CachedPrice',
@@ -93,6 +100,11 @@ function get_bsc_token_price_info(addresses, opts) {
93
100
  if (source !== 'cache_only' && addresses.length > 0) {
94
101
  (0, index_1.log_warn)(`[get_token_price_info] Failed to get prices for ${addresses.length} tokens after trying all channels: ${addresses.join(', ')}`);
95
102
  }
103
+ if (wantsNativeBnb) {
104
+ const wbnbInfo = result.get(WBNB_ADDR);
105
+ if (wbnbInfo)
106
+ result.set(ZERO_ADDR, wbnbInfo);
107
+ }
96
108
  (0, index_1.log_debug)(`[get_token_price_info] Completed price fetching for ${result.size} tokens`);
97
109
  return result;
98
110
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@clonegod/ttd-core",
3
- "version": "3.1.46",
3
+ "version": "3.1.48",
4
4
  "description": "Common types and utilities for trading systems - use `npm run push` to publish",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
package/types/index.d.ts CHANGED
@@ -943,6 +943,13 @@ export interface PostTradeType {
943
943
 
944
944
  /** 完整 OnTrade 记录:时间线 / 成交结果 / 盘口快照 / 偏差 — 给 UI 渲染时间线和滑点归因用 */
945
945
  ontrade?: OnTradeType
946
+
947
+ /**
948
+ * 降级模式标识:
949
+ * - false / undefined:完整数据(OnTrade 在)
950
+ * - true:仅 OrderMessage 在(trader 上报 OnTrade 前 crash),部分字段缺失
951
+ */
952
+ partial_replay?: boolean
946
953
  }
947
954
 
948
955
  export interface AnalyzeQuoteSnapshotType {