@clonegod/ttd-bsc-common 1.0.64 → 1.0.66

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.
@@ -36,6 +36,7 @@ export declare abstract class AbstractEvmDexTradePlus extends AbastrcatTrade {
36
36
  abstract execute(context: TradeContext, retryCount?: number): Promise<string>;
37
37
  protected buildTipTransferTx(to: string, transfer_amount_gwei: string, gas_price_gwei: string, transfer_nonce: number, wallet: ethers.Wallet): Promise<string>;
38
38
  protected chooseWallet(context: TradeContext): Promise<ethers.Wallet>;
39
+ protected getWalletNextNonce(walletAddress: string): Promise<any>;
39
40
  protected determineInputOutputTokens(order_msg: any, pool_info: any): {
40
41
  inputToken: any;
41
42
  outputToken: any;
@@ -412,6 +412,22 @@ class AbstractEvmDexTradePlus extends dist_1.AbastrcatTrade {
412
412
  }
413
413
  });
414
414
  }
415
+ getWalletNextNonce(walletAddress) {
416
+ return __awaiter(this, void 0, void 0, function* () {
417
+ try {
418
+ const wallet_assets = yield this.redisClient.hgetvalue(`${this.chainNameLower}:wallet:assets`, walletAddress);
419
+ if (!wallet_assets) {
420
+ return 0;
421
+ }
422
+ const wallet_assets_map = JSON.parse(wallet_assets);
423
+ return wallet_assets_map.nonce;
424
+ }
425
+ catch (error) {
426
+ console.warn(`获取钱包下一个nonce失败: ${walletAddress}`, error);
427
+ return 0;
428
+ }
429
+ });
430
+ }
415
431
  determineInputOutputTokens(order_msg, pool_info) {
416
432
  const { aToB } = order_msg;
417
433
  const { tokenA, tokenB, quote_token } = pool_info;
@@ -49,10 +49,11 @@ class BaseTxParser {
49
49
  ? ethers_1.ethers.BigNumber.from(txReceipt.gasUsed)
50
50
  : txReceipt.gasUsed)
51
51
  : ethers_1.ethers.BigNumber.from(0);
52
- const effectiveGasPrice = txReceipt.effectiveGasPrice
53
- ? (typeof txReceipt.effectiveGasPrice === 'string' || typeof txReceipt.effectiveGasPrice === 'number'
54
- ? ethers_1.ethers.BigNumber.from(txReceipt.effectiveGasPrice)
55
- : txReceipt.effectiveGasPrice)
52
+ const gasPriceValue = txReceipt.effectiveGasPrice || txReceipt.gasPrice;
53
+ const effectiveGasPrice = gasPriceValue
54
+ ? (typeof gasPriceValue === 'string' || typeof gasPriceValue === 'number'
55
+ ? ethers_1.ethers.BigNumber.from(gasPriceValue)
56
+ : gasPriceValue)
56
57
  : ethers_1.ethers.BigNumber.from(0);
57
58
  const gasFeeBN = gasUsed.mul(effectiveGasPrice);
58
59
  const base_fee = Number(ethers_1.ethers.utils.formatEther(gasFeeBN));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@clonegod/ttd-bsc-common",
3
- "version": "1.0.64",
3
+ "version": "1.0.66",
4
4
  "description": "BSC common library",
5
5
  "license": "UNLICENSED",
6
6
  "main": "dist/index.js",
@@ -14,7 +14,7 @@
14
14
  "push": "npm run build && npm publish"
15
15
  },
16
16
  "dependencies": {
17
- "@clonegod/ttd-core": "2.0.89",
17
+ "@clonegod/ttd-core": "2.0.90",
18
18
  "axios": "^1.12.0",
19
19
  "dotenv": "^16.4.7",
20
20
  "ethers": "^5.8.0"