@clonegod/ttd-sol-common 1.0.49 → 1.0.53

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.
@@ -33,6 +33,13 @@ class TradeContext {
33
33
  if (!this.pool_info) {
34
34
  throw new Error(`Not found pool_info! pool_id=${this.pool_id}, pool_info_list=${JSON.stringify(this.trade_runtime.pair_dex.pool_info_list)}`);
35
35
  }
36
+ let { inputToken, outputToken } = (0, dist_1.get_input_out_token)(this.pool_info, this.order_msg.aToB);
37
+ let { amount } = this.order_msg;
38
+ let uiAmount = (Number(this.order_msg.amount).toFixed(inputToken.decimals));
39
+ if (amount !== uiAmount) {
40
+ (0, dist_1.log_warn)(`Fix input token's amount decimal: from ${amount} to ${uiAmount}`);
41
+ this.order_msg.amount = uiAmount;
42
+ }
36
43
  this.slippage_bps = Math.min(100, Math.max(30, this.trade_runtime.settings.slippage_bps));
37
44
  this.aToB = this.pool_info.is_reverse_token ? !this.order_msg.aToB : this.order_msg.aToB;
38
45
  this.solana_trade_runtime = (0, send_tx_1.create_solana_trade_runtime)(this.connection, this.trade_runtime, this.pool_info);
@@ -423,7 +423,7 @@ class RpcClient {
423
423
  });
424
424
  instructions.unshift(computeBudgetIx);
425
425
  setTimeout(() => __awaiter(this, void 0, void 0, function* () {
426
- if (Math.random() > 0.15)
426
+ if (Math.random() > 0)
427
427
  return;
428
428
  (0, dist_1.log_info)(`>>> getComputeUnits, start`);
429
429
  const units = yield this.getComputeUnits(instructions, payerKey, isVersioned ? lookupTables : [], signers);
@@ -6,8 +6,8 @@ const constants_1 = require("../common/constants");
6
6
  function create_solana_trade_runtime(connection, trade_runtime, pool_info) {
7
7
  let trade_strategy = trade_runtime.settings.strategy;
8
8
  let { cu_limit } = pool_info;
9
- if (isNaN(cu_limit) || cu_limit < 50000) {
10
- cu_limit = 50000;
9
+ if (isNaN(cu_limit) || cu_limit < 35000) {
10
+ cu_limit = 35000;
11
11
  }
12
12
  let priority_fee = calculate_gas_fee(trade_strategy);
13
13
  let cu_price = Math.ceil(priority_fee * constants_1.ONE_MILLION / cu_limit);
@@ -80,6 +80,7 @@ class TransactionResultChecker {
80
80
  }
81
81
  }
82
82
  catch (err) {
83
+ clearInterval(intervalId);
83
84
  (0, dist_1.log_error)('parse transaction error!', err);
84
85
  }
85
86
  }), check_interval);
@@ -10,7 +10,7 @@ class TransactionResultParser {
10
10
  }
11
11
  parse_transaction_data(txData, pool_info) {
12
12
  let success = true;
13
- let error_code = '';
13
+ let error_code = undefined;
14
14
  let { blockTime, meta, transaction, slot } = txData;
15
15
  if (meta.err) {
16
16
  success = false;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@clonegod/ttd-sol-common",
3
- "version": "1.0.49",
3
+ "version": "1.0.53",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "types": "types/index.d.ts",
@@ -13,7 +13,7 @@
13
13
  "push": "npm run build && npm publish"
14
14
  },
15
15
  "dependencies": {
16
- "@clonegod/ttd-common": "^1.0.149",
16
+ "@clonegod/ttd-common": "^1.0.150",
17
17
  "@solana/web3.js": "1.91.6",
18
18
  "@irys/sdk": "^0.2.10",
19
19
  "@metaplex-foundation/mpl-token-metadata": "^2.5.2",