@clonegod/ttd-core 3.1.86 → 3.1.88

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.
@@ -23,9 +23,8 @@ const fetchPriceFromCache = (token_address_list) => __awaiter(void 0, void 0, vo
23
23
  (0, __1.log_warn)('global_app_config is not set, skip get token price from cache');
24
24
  return result;
25
25
  }
26
- const map = global_app_config.arb_cache.token_address_map;
27
26
  for (const address of token_address_list) {
28
- const token = map.get(address.toLowerCase());
27
+ const token = global_app_config.arb_cache.getTokenByAddress(address);
29
28
  if (token === null || token === void 0 ? void 0 : token.market_price) {
30
29
  result.set(address, {
31
30
  address: token.address,
@@ -51,14 +50,13 @@ function cache_new_market_price_batch(hits) {
51
50
  (0, __1.log_warn)('global_app_config is not set, skip cache_new_market_price_batch');
52
51
  return;
53
52
  }
54
- const map = global_app_config.arb_cache.token_address_map;
55
53
  const updated = [];
56
54
  for (const { address, price, source } of hits) {
57
55
  if (!price || Number(price) <= 0) {
58
56
  (0, __1.log_warn)(`skip cache invalid market_price from ${source}`, { address, price });
59
57
  continue;
60
58
  }
61
- const tokenInfo = map.get(address.toLowerCase());
59
+ const tokenInfo = global_app_config.arb_cache.getTokenByAddress(address);
62
60
  if (!tokenInfo) {
63
61
  (0, __1.log_warn)(`tokenInfo not found in arb_cache.token_address_map: address=${address}`);
64
62
  continue;
@@ -90,10 +88,9 @@ function warnPriceCacheMiss(missed_addresses) {
90
88
  return;
91
89
  }
92
90
  const now = Date.now();
93
- const map = cfg.arb_cache.token_address_map;
94
91
  const to_warn = [];
95
92
  for (const addr of missed_addresses) {
96
- const known = map.has(addr.toLowerCase());
93
+ const known = cfg.arb_cache.getTokenByAddress(addr) !== undefined;
97
94
  if (!known)
98
95
  continue;
99
96
  const last = (_a = _priceMissLastWarnAt.get(addr)) !== null && _a !== void 0 ? _a : 0;
@@ -87,10 +87,19 @@ function createAxiosInstance() {
87
87
  return config;
88
88
  }
89
89
  const ip = (0, ip_util_1.getNextIP)();
90
- if (ip) {
91
- const url = config.url || '';
92
- const baseURL = config.baseURL || '';
93
- const fullUrl = url.startsWith('http') ? url : (baseURL + url);
90
+ const url = config.url || '';
91
+ const baseURL = config.baseURL || '';
92
+ const fullUrl = url.startsWith('http') ? url : (baseURL + url);
93
+ const isLoopbackTarget = (() => {
94
+ try {
95
+ const host = new URL(fullUrl).hostname;
96
+ return host === 'localhost' || host === '::1' || /^127\./.test(host);
97
+ }
98
+ catch (_a) {
99
+ return false;
100
+ }
101
+ })();
102
+ if (ip && !isLoopbackTarget) {
94
103
  const isHttps = fullUrl.startsWith('https:');
95
104
  if (isHttps) {
96
105
  config.httpsAgent = createHttpsAgent(ip);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@clonegod/ttd-core",
3
- "version": "3.1.86",
3
+ "version": "3.1.88",
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",