@clonegod/ttd-core 2.0.83 → 2.0.84

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.
@@ -8,13 +8,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
8
8
  step((generator = generator.apply(thisArg, _arguments || [])).next());
9
9
  });
10
10
  };
11
- var __importDefault = (this && this.__importDefault) || function (mod) {
12
- return (mod && mod.__esModule) ? mod : { "default": mod };
13
- };
14
11
  Object.defineProperty(exports, "__esModule", { value: true });
15
12
  exports.get_bsc_token_price_info = get_bsc_token_price_info;
16
13
  require('dotenv').config();
17
- const axios_1 = __importDefault(require("axios"));
18
14
  const index_1 = require("../../index");
19
15
  const gecko_terminal_1 = require("./gecko_terminal");
20
16
  const price_cache_1 = require("./price_cache");
@@ -34,20 +30,20 @@ function get_bsc_token_price_info(addresses) {
34
30
  name: 'DefiLlama',
35
31
  fetchFn: (address_list) => (0, defi_llama_1.fetchPriceFromDefiLlama)(index_1.CHAIN_ID.BSC, address_list),
36
32
  batchSize: 10,
37
- batchDelay: 2000,
33
+ batchDelay: 1000,
38
34
  },
39
35
  {
40
36
  name: 'GeckoTerminal',
41
37
  fetchFn: (address_list) => (0, gecko_terminal_1.fetchPriceFromGeckoTerminal)(index_1.CHAIN_ID.BSC, address_list),
42
38
  batchSize: 10,
43
- batchDelay: 2000,
39
+ batchDelay: 1000,
44
40
  },
45
41
  ];
46
42
  try {
47
43
  for (const channel of PRICE_CHANNELS) {
48
44
  if (addresses.length === 0)
49
45
  break;
50
- (0, index_1.log_debug)(`[get_token_price_info] Processing ${addresses.length} tokens using ${channel.name}`);
46
+ (0, index_1.log_info)(`[get_token_price_info] Processing ${addresses.length} tokens using ${channel.name}`);
51
47
  const batches = (0, index_1.chunkArray)(addresses, channel.batchSize);
52
48
  (0, index_1.log_debug)(`[get_token_price_info] Split into ${batches.length} batches of size ${channel.batchSize}`);
53
49
  let remainingAddresses = [...addresses];
@@ -93,53 +89,6 @@ function get_bsc_token_price_info(addresses) {
93
89
  }
94
90
  });
95
91
  }
96
- function fetchPriceFromPancakeSwap(addresses) {
97
- return __awaiter(this, void 0, void 0, function* () {
98
- const result = new Map();
99
- const currentTime = (0, index_1.getCurDateTime)();
100
- const timeout = 10000;
101
- const maxRetries = 2;
102
- const retrysleepMs = 500;
103
- const addressString = addresses.map(addr => `56:${addr}`).join('%2C');
104
- const url = `https://wallet-api.pancakeswap.com/v1/prices/list/${addressString}`;
105
- console.log(url);
106
- (0, index_1.log_debug)(`[fetchPriceFromPancakeSwap] Requesting PancakeSwap API for ${addresses.length} tokens`);
107
- let retryCount = 0;
108
- while (retryCount <= maxRetries) {
109
- try {
110
- const response = yield axios_1.default.get(url, { timeout });
111
- if (response.data) {
112
- for (const address of addresses) {
113
- const key = `56:${address}`;
114
- if (response.data[key] !== undefined) {
115
- result.set(address, {
116
- symbol: '',
117
- address: address,
118
- price: response.data[key].toString(),
119
- update_time: currentTime
120
- });
121
- }
122
- }
123
- (0, index_1.log_debug)(`[fetchPriceFromPancakeSwap] Retrieved prices for ${result.size}/${addresses.length} tokens`);
124
- }
125
- else {
126
- (0, index_1.log_debug)(`[fetchPriceFromPancakeSwap] Invalid response from PancakeSwap for ${addresses.length} tokens`);
127
- }
128
- break;
129
- }
130
- catch (error) {
131
- retryCount++;
132
- (0, index_1.log_warn)(`[fetchPriceFromPancakeSwap] Request failed (attempt ${retryCount}/${maxRetries}): ${error instanceof Error ? error.message : String(error)}`);
133
- if (retryCount <= maxRetries) {
134
- const currentRetrysleep = retrysleepMs * retryCount;
135
- (0, index_1.log_debug)(`[fetchPriceFromPancakeSwap] Retrying in ${currentRetrysleep}ms...`);
136
- yield (0, index_1.sleep)(currentRetrysleep);
137
- }
138
- }
139
- }
140
- return result;
141
- });
142
- }
143
92
  if (require.main === module) {
144
93
  (() => __awaiter(void 0, void 0, void 0, function* () {
145
94
  (() => __awaiter(void 0, void 0, void 0, function* () {
@@ -149,7 +98,6 @@ if (require.main === module) {
149
98
  "0x0e09fabb73bd3ade0a17ecc321fd13a19e81ce82",
150
99
  "0x8263CD1601FE73C066bf49cc09841f35348e3be0",
151
100
  ];
152
- console.log(yield (0, gecko_terminal_1.fetchPriceFromGeckoTerminal)(index_1.CHAIN_ID.BSC, addresses));
153
101
  }))();
154
102
  }))();
155
103
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@clonegod/ttd-core",
3
- "version": "2.0.83",
3
+ "version": "2.0.84",
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": "types/index.d.ts",