@clonegod/ttd-bsc-common 3.1.92 → 3.1.93

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.
@@ -30,6 +30,7 @@ class BscDexEnvArgs extends bsc_env_args_1.BscEnvArgs {
30
30
  this.gas_price_gwei = cfg.gas_price_gwei;
31
31
  this.gas_limit = cfg.gas_limit;
32
32
  this.tip_amount_gwei = cfg.tip_amount_gwei;
33
+ this.gas_max_limit = cfg.gas_max_limit;
33
34
  this.gas_max_price_gwei = cfg.gas_max_price_gwei;
34
35
  this.gas_max_fee_per_gas_gwei = cfg.gas_max_fee_per_gas_gwei;
35
36
  this.gas_max_priority_fee_gwei = cfg.gas_max_priority_fee_gwei;
@@ -1,5 +1,6 @@
1
1
  import { StandardPoolInfoType, StandardSwapDetailType } from "@clonegod/ttd-core";
2
2
  import { TransactionReceipt } from '@ethersproject/providers';
3
+ import { ethers } from 'ethers';
3
4
  import { ITxParser } from "./abstract_parser";
4
5
  import { ParserConfig } from "../../types";
5
6
  export declare abstract class BaseTxParser implements ITxParser {
@@ -9,6 +10,12 @@ export declare abstract class BaseTxParser implements ITxParser {
9
10
  protected readonly CACHE_EXPIRY: number;
10
11
  constructor(config: ParserConfig);
11
12
  abstract parseTransaction(txReceipt: TransactionReceipt, poolInfo: StandardPoolInfoType): Promise<StandardSwapDetailType>;
13
+ protected parseTradeResultEvent(logs: any[]): {
14
+ tokenIn: string;
15
+ amountIn: ethers.BigNumber;
16
+ tokenOut: string;
17
+ amountOut: ethers.BigNumber;
18
+ } | null;
12
19
  protected getBlockTime(blockNumber: number): Promise<number>;
13
20
  protected calculateGasFee(txReceipt: TransactionReceipt): {
14
21
  base_fee: number;
@@ -12,6 +12,27 @@ class BaseTxParser {
12
12
  this.config = config;
13
13
  this.provider = new ethers_compat_1.ethersCompat.JsonRpcProvider(config.rpcEndpoint);
14
14
  }
15
+ parseTradeResultEvent(logs) {
16
+ try {
17
+ const TOPIC = ethers_1.ethers.utils.id('TradeResult(address,uint256,address,uint256)');
18
+ const vault = (this.config.walletAddress || '').toLowerCase();
19
+ const candidates = (logs || []).filter(l => l?.topics?.[0] === TOPIC);
20
+ if (candidates.length === 0)
21
+ return null;
22
+ const log = candidates.find(l => vault && (l.address || '').toLowerCase() === vault) ?? candidates[0];
23
+ const data = log.data.startsWith('0x') ? log.data.slice(2) : log.data;
24
+ return {
25
+ tokenIn: ('0x' + log.topics[1].slice(26)).toLowerCase(),
26
+ tokenOut: ('0x' + log.topics[2].slice(26)).toLowerCase(),
27
+ amountIn: ethers_1.ethers.BigNumber.from('0x' + data.slice(0, 64)),
28
+ amountOut: ethers_1.ethers.BigNumber.from('0x' + data.slice(64, 128)),
29
+ };
30
+ }
31
+ catch (error) {
32
+ logger.error('parseTradeResultEvent error:', error);
33
+ return null;
34
+ }
35
+ }
15
36
  async getBlockTime(blockNumber) {
16
37
  if (!(0, ttd_core_1.getCoreEnv)().trade_parse_fetch_block_time) {
17
38
  return 0;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@clonegod/ttd-bsc-common",
3
- "version": "3.1.92",
3
+ "version": "3.1.93",
4
4
  "description": "BSC common library",
5
5
  "license": "UNLICENSED",
6
6
  "main": "dist/index.js",