@clonegod/ttd-sol-common 1.0.160 → 1.0.162

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.
@@ -42,7 +42,7 @@ class TradeContext {
42
42
  this.order_msg.amount = uiAmount;
43
43
  (0, dist_1.log_warn)(`Fix input token's amount decimal: from ${amount} to ${uiAmount}`);
44
44
  }
45
- this.slippage_bps = Math.min(300, Math.max(50, this.trade_runtime.settings.slippage_bps));
45
+ this.slippage_bps = Math.min(300, Math.max(0, this.trade_runtime.settings.slippage_bps));
46
46
  this.aToB = this.pool_info.is_reverse_token ? !this.order_msg.aToB : this.order_msg.aToB;
47
47
  this.solana_trade_runtime = yield (0, send_tx_1.create_solana_trade_runtime)(this.connection, this.trade_runtime, this.pool_info);
48
48
  });
@@ -31,7 +31,7 @@ const get_token_price_info = (mints) => __awaiter(void 0, void 0, void 0, functi
31
31
  }
32
32
  not_found_arr = mints.filter(address => !price_map.has(address));
33
33
  if (not_found_arr.length > 0) {
34
- let _price_map = yield (0, exports.get_token_price_info_from_jupiter)(not_found_arr);
34
+ let _price_map = yield (0, exports.get_token_price_info_from_coingecko)(not_found_arr);
35
35
  for (let [key, value] of _price_map) {
36
36
  if (value) {
37
37
  price_map.set(key, value);
@@ -81,21 +81,26 @@ const get_token_price_info_from_jupiter = (mints) => __awaiter(void 0, void 0, v
81
81
  for (let ids of ids_list) {
82
82
  try {
83
83
  let url = `https://api.jup.ag/price/v2?ids=${ids.join(',')}`;
84
- const { id, success, data } = (yield axios_1.default.get(url)).data;
85
- (0, dist_1.log_debug)('get_token_price_info_from_jupiter, res=', data);
84
+ const res = (yield axios_1.default.get(url)).data;
85
+ (0, dist_1.log_debug)(`get_token_price_info_from_jupiter, res=`, res);
86
+ let failed_mints = [];
86
87
  for (let address of ids) {
87
- let price = data[address]['price'];
88
- if (price) {
89
- price_map.set(address, {
90
- symbol: '',
91
- address,
92
- price,
93
- update_time: (0, dist_1.getCurDateTime)()
94
- });
95
- }
96
- else {
97
- (0, dist_1.log_warn)(`get_token_price_info_from_jupiter failed! address=${address}, price=${price}`);
88
+ let price_obj = res.data[address];
89
+ if (!price_obj || !price_obj['price']) {
90
+ failed_mints.push(address);
91
+ continue;
98
92
  }
93
+ let price = price_obj['price'];
94
+ price_map.set(address, {
95
+ symbol: '',
96
+ address,
97
+ price,
98
+ update_time: (0, dist_1.getCurDateTime)()
99
+ });
100
+ }
101
+ let failed_count = failed_mints.length;
102
+ if (failed_mints.length > 0) {
103
+ (0, dist_1.log_warn)(`get_token_price_info_from_jupiter failed! failed_count=${failed_count}, failed_mints: `, failed_mints);
99
104
  }
100
105
  }
101
106
  catch (err) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@clonegod/ttd-sol-common",
3
- "version": "1.0.160",
3
+ "version": "1.0.162",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "types": "types/index.d.ts",