@clonegod/ttd-core 3.1.84 → 3.1.86

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.
@@ -1,2 +1,3 @@
1
1
  import { CHAIN_ID, DEX_ID, FormattedPoolInfo, FormattedTokenInfo } from "../index";
2
2
  export declare const cache_pool_config: (chain_id: CHAIN_ID, tokens_map: Map<string, FormattedTokenInfo>, pools_map: Map<DEX_ID, FormattedPoolInfo[]>) => Promise<void>;
3
+ export declare function assert_cache_pool_fields(pools_map: Map<DEX_ID, FormattedPoolInfo[]>): void;
@@ -13,6 +13,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
13
13
  };
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
15
  exports.cache_pool_config = void 0;
16
+ exports.assert_cache_pool_fields = assert_cache_pool_fields;
16
17
  const axios_1 = __importDefault(require("axios"));
17
18
  const core_env_1 = require("../appconfig/core_env");
18
19
  const index_1 = require("../index");
@@ -36,7 +37,7 @@ const cache_pool_config = (chain_id, tokens_map, pools_map) => __awaiter(void 0,
36
37
  continue;
37
38
  }
38
39
  valid_pool_list.push({
39
- _id: (pool.pool_address || '').toLowerCase(),
40
+ _id: pool._id,
40
41
  program_id: pool.program_id,
41
42
  authority: pool.authority,
42
43
  subscribe_type: 'grpc',
@@ -113,3 +114,13 @@ function get_cu_limit(dex_id) {
113
114
  }
114
115
  return cu_limit;
115
116
  }
117
+ function assert_cache_pool_fields(pools_map) {
118
+ var _a, _b;
119
+ for (const [dex_id, pools] of pools_map) {
120
+ for (const p of pools) {
121
+ if (!(p === null || p === void 0 ? void 0 : p._id) || !p.pool_address || !p.pair || !((_a = p.tokenA) === null || _a === void 0 ? void 0 : _a._id) || !((_b = p.tokenB) === null || _b === void 0 ? void 0 : _b._id)) {
122
+ throw new Error(`assert_cache_pool_fields: pool 字段不全(须含 _id/pool_address/pair/tokenA._id/tokenB._id): dex=${dex_id} name=${p === null || p === void 0 ? void 0 : p.pool_name} addr=${p === null || p === void 0 ? void 0 : p.pool_address}`);
123
+ }
124
+ }
125
+ }
126
+ }
@@ -1,2 +1,3 @@
1
1
  import { CHAIN_ID, FormattedTokenInfo } from "../index";
2
2
  export declare const cache_token_config: (chain_id: CHAIN_ID, tokens_map: Map<string, FormattedTokenInfo>) => Promise<void>;
3
+ export declare function assert_cache_token_fields(tokens_map: Map<string, FormattedTokenInfo>): void;
@@ -13,6 +13,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
13
13
  };
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
15
  exports.cache_token_config = void 0;
16
+ exports.assert_cache_token_fields = assert_cache_token_fields;
16
17
  const axios_1 = __importDefault(require("axios"));
17
18
  const core_env_1 = require("../appconfig/core_env");
18
19
  const index_1 = require("../index");
@@ -30,7 +31,7 @@ const cache_token_config = (chain_id, tokens_map) => __awaiter(void 0, void 0, v
30
31
  if ((0, is_not_arb_token_1.is_not_arb_token)(token.symbol))
31
32
  continue;
32
33
  valid_tokens.push({
33
- _id: (token.address || '').toLowerCase(),
34
+ _id: token._id,
34
35
  symbol: token.symbol,
35
36
  raw_symbol: token.raw_symbol,
36
37
  address: token.address,
@@ -58,3 +59,10 @@ const cache_token_config = (chain_id, tokens_map) => __awaiter(void 0, void 0, v
58
59
  });
59
60
  });
60
61
  exports.cache_token_config = cache_token_config;
62
+ function assert_cache_token_fields(tokens_map) {
63
+ for (const t of tokens_map.values()) {
64
+ if (!(t === null || t === void 0 ? void 0 : t._id) || !t.symbol || !t.address) {
65
+ throw new Error(`assert_cache_token_fields: token 字段不全(须含 _id/symbol/address): ${JSON.stringify({ _id: t === null || t === void 0 ? void 0 : t._id, symbol: t === null || t === void 0 ? void 0 : t.symbol, address: t === null || t === void 0 ? void 0 : t.address })}`);
66
+ }
67
+ }
68
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@clonegod/ttd-core",
3
- "version": "3.1.84",
3
+ "version": "3.1.86",
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",