@clonegod/ttd-core 3.1.27 → 3.1.29

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.
@@ -45,7 +45,7 @@ registerEnvVars({
45
45
  encryption_key: { env: 'ENCRYPTION_KEY', type: 'string', default: '', sensitive: true, desc: '对称加密密钥(用于钱包文件等)' },
46
46
  trade_analyze_url: { env: 'TRADE_ANALYZE_URL', type: 'string', default: '', desc: 'analyze HTTP 基址(旧 EnvArgs;未配则 analyze 上报走默认拼接)' },
47
47
  providers_file_path: { env: 'PROVIDERS_FILE_PATH', type: 'string', default: '', desc: 'stream-quote providers.json 绝对路径;留空则仅写 Redis' },
48
- token_price_refresh_interval_seconds: { env: 'TOKEN_PRICE_REFRESH_INTERVAL_SECONDS', type: 'number', default: 600, desc: 'TokenPriceSyncer 刷价周期(s):market-data 拉价并推送给 config-center token_list 的频率' },
48
+ token_price_refresh_interval_seconds: { env: 'TOKEN_PRICE_REFRESH_INTERVAL_SECONDS', type: 'number', default: 600, desc: 'TokenPriceSyncer 刷价周期(s):market-data 通过 force_fetch 拉外部价(DefiLlama→Gecko→...)并直接批量写入 Redis + 发 TOKEN_CONFIG_CHANGE 事件的频率' },
49
49
  token_market_price_url: { env: 'TOKEN_MARKET_PRICE_URL', type: 'string', default: '', desc: '【使用方: ttd-core estimate_token_amount】config-center 市价估算 HTTP 基址;为空则跳过远程回退' },
50
50
  fixed_symbol_address_file: { env: 'FIXED_SYMBOL_ADDRESS_FILE', type: 'string', default: '', desc: '固定 symbol/address 映射文件路径(覆盖默认按 CHAIN_ID 推断的路径)' },
51
51
  zh_pinyin_map_file: { env: 'ZH_PINYIN_MAP_FILE', type: 'string', default: '', desc: '中文拼音映射文件路径(覆盖默认路径)' },
@@ -24,6 +24,7 @@ export declare class ArbCache {
24
24
  init_configs(): Promise<void>;
25
25
  get_config_filepath(suffix: string): string;
26
26
  refresh_local_cache_token_list(token_list: StandardTokenInfoType[]): void;
27
+ getTokenByAddress(address: string): StandardTokenInfoType | undefined;
27
28
  refresh_local_cache_pool_list(pool_list: StandardPoolInfoType[]): void;
28
29
  refresh_local_cache_group_map(trade_config: TradeServiceConfigType): void;
29
30
  cache_token_list(): Promise<void>;
@@ -72,6 +72,15 @@ class ArbCache {
72
72
  (0, index_1.log_trace)(`init cache start`);
73
73
  yield this.cache_token_list();
74
74
  yield this.cache_pool_list();
75
+ const fixed_list = (0, fixed_symbol_address_1.get_fixed_symbol_address)();
76
+ if (fixed_list.length > 0) {
77
+ try {
78
+ yield this.resolve_duplicate_address(fixed_list.map(f => ({ address: f.address, symbol: f.symbol })));
79
+ }
80
+ catch (err) {
81
+ (0, index_1.log_warn)(`[init] auto resolve_duplicate_address failed (non-fatal)`, err);
82
+ }
83
+ }
75
84
  yield this.cache_trade_group();
76
85
  (0, index_1.log_trace)(`init cache finish`);
77
86
  });
@@ -108,6 +117,20 @@ class ArbCache {
108
117
  token_address_map_szie: this.token_address_map.size,
109
118
  });
110
119
  }
120
+ getTokenByAddress(address) {
121
+ var _a;
122
+ if (!address)
123
+ return undefined;
124
+ const exact = this.token_address_map.get(address);
125
+ if (exact)
126
+ return exact;
127
+ const lc = address.toLowerCase();
128
+ for (const m of this.token_address_map.values()) {
129
+ if (((_a = m.address) === null || _a === void 0 ? void 0 : _a.toLowerCase()) === lc)
130
+ return m;
131
+ }
132
+ return undefined;
133
+ }
111
134
  refresh_local_cache_pool_list(pool_list) {
112
135
  this.pool_list = pool_list;
113
136
  this.pool_address_map.clear();
@@ -1038,8 +1061,18 @@ class ArbCache {
1038
1061
  }
1039
1062
  }
1040
1063
  let token_list = [];
1064
+ const missed = [];
1041
1065
  for (let token_address of token_address_set) {
1042
- token_list.push(this.token_address_map.get(token_address));
1066
+ const token = this.getTokenByAddress(token_address);
1067
+ if (token) {
1068
+ token_list.push(token);
1069
+ }
1070
+ else {
1071
+ missed.push(token_address);
1072
+ }
1073
+ }
1074
+ if (missed.length > 0) {
1075
+ (0, index_1.log_warn)(`get_all_trade_tokens: ${missed.length} pool token(s) not found in token_address_map (likely case mismatch or stale config)`, missed);
1043
1076
  }
1044
1077
  return token_list;
1045
1078
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@clonegod/ttd-core",
3
- "version": "3.1.27",
3
+ "version": "3.1.29",
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",