@clonegod/ttd-core 3.0.4 → 3.0.6

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.
@@ -420,21 +420,27 @@ class ArbCache {
420
420
  }
421
421
  }
422
422
  for (let pair of pair_set) {
423
- let [base_symbol, quote_symbol] = pair.split('/');
424
- let tokenA = yield this.get_one_token_info_by_symbol(base_symbol);
425
- let tokenB = yield this.get_one_token_info_by_symbol(quote_symbol);
426
- let price_decimals = pair_price_decimals.get(pair);
427
- if (!price_decimals || price_decimals <= 0) {
428
- price_decimals = 12;
423
+ try {
424
+ let [base_symbol, quote_symbol] = pair.split('/');
425
+ let tokenA = yield this.get_one_token_info_by_symbol(base_symbol);
426
+ let tokenB = yield this.get_one_token_info_by_symbol(quote_symbol);
427
+ let price_decimals = pair_price_decimals.get(pair);
428
+ if (!price_decimals || price_decimals <= 0) {
429
+ price_decimals = 12;
430
+ }
431
+ let pool_list = (yield this.get_pool_list_by_pair(pair)).filter(e => e.enable).map(e => e.pool_address);
432
+ pair_list.push({
433
+ pair,
434
+ tokenA,
435
+ tokenB,
436
+ price_decimals,
437
+ pool_list
438
+ });
439
+ }
440
+ catch (err) {
441
+ (0, index_1.log_warn)(`get_pair_list, failed! input_pair=${input_pair}, err=${err.message}`);
442
+ continue;
429
443
  }
430
- let pool_list = (yield this.get_pool_list_by_pair(pair)).filter(e => e.enable).map(e => e.pool_address);
431
- pair_list.push({
432
- pair,
433
- tokenA,
434
- tokenB,
435
- price_decimals,
436
- pool_list
437
- });
438
444
  }
439
445
  pair_list = pair_list.sort((a, b) => a.pair.localeCompare(b.pair));
440
446
  if (index_1.LOG.debug) {
@@ -702,7 +708,8 @@ class ArbCache {
702
708
  return __awaiter(this, arguments, void 0, function* (token_with_price, ttl = -1) {
703
709
  (0, index_1.log_trace)(`cache_market_price, start`);
704
710
  if ((0, index_1.isEmpty)(token_with_price.market_price)) {
705
- throw new Error(`token market price is null or empty!`);
711
+ (0, index_1.log_warn)(`cache_token_market_price skip: empty market_price, symbol=${token_with_price.symbol}, address=${token_with_price.address}`);
712
+ return;
706
713
  }
707
714
  let { symbol } = token_with_price;
708
715
  let field = (0, index_1.format_symbol_name)(symbol);
@@ -48,8 +48,13 @@ function get_quote_token(pair, pool_name) {
48
48
  function valid_fetch_pool_data(formatted_pool, min_tvl, min_vol, native_token) {
49
49
  let { pool_name, pool_address, tokenA, tokenB, tvl, vol_24h } = formatted_pool;
50
50
  let symbols = [tokenA.symbol, tokenB.symbol];
51
- if ((tvl < min_tvl || vol_24h < min_vol)) {
52
- throw new Error(`pool is too small: ${pool_name}, ${pool_address}, tvl=${tvl}, vol_24h=${vol_24h}`);
51
+ if (tvl < min_tvl || vol_24h < min_vol) {
52
+ const reasons = [];
53
+ if (tvl < min_tvl)
54
+ reasons.push(`tvl=${tvl} < minTvl=${min_tvl}`);
55
+ if (vol_24h < min_vol)
56
+ reasons.push(`vol_24h=${vol_24h} < minVol=${min_vol}`);
57
+ throw new Error(`pool is too small: ${pool_name}, ${pool_address}, ${reasons.join(', ')}`);
53
58
  }
54
59
  if (!symbols.includes(native_token) && !symbols.includes('USDC') && !symbols.includes('USDT') && !symbols.includes('USD1')) {
55
60
  throw new Error(`pool don't contains: SOL, USDC, USDT, USD1, ${pool_name}, ${pool_address}`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@clonegod/ttd-core",
3
- "version": "3.0.4",
3
+ "version": "3.0.6",
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",