@clonegod/ttd-bsc-common 3.0.20 → 3.0.22

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.
@@ -10,7 +10,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.PoolEventListener = void 0;
13
- const ethers_1 = require("ethers");
13
+ const ethers_compat_1 = require("../../utils/ethers_compat");
14
14
  const ttd_core_1 = require("@clonegod/ttd-core");
15
15
  const common_1 = require("../../common");
16
16
  const CONFIG = {
@@ -46,7 +46,7 @@ class PoolEventListener {
46
46
  }
47
47
  init(poolList) {
48
48
  return __awaiter(this, void 0, void 0, function* () {
49
- this.poolList = poolList.filter(pool => ethers_1.ethers.utils.isAddress(pool.pool_address));
49
+ this.poolList = poolList.filter(pool => ethers_compat_1.ethersCompat.isAddress(pool.pool_address));
50
50
  if (this.poolList.length !== poolList.length) {
51
51
  (0, ttd_core_1.log_warn)(`Found ${poolList.length - this.poolList.length} invalid pool addresses, filtered out`, '');
52
52
  }
@@ -79,7 +79,7 @@ class PoolEventListener {
79
79
  for (let i = 0; i < CONFIG.MAX_RETRIES; i++) {
80
80
  try {
81
81
  (0, ttd_core_1.log_info)(`Connecting to WebSocket: ${this.ws_endpoint} (Attempt ${i + 1}/${CONFIG.MAX_RETRIES})`);
82
- this.wsProvider = new ethers_1.ethers.providers.WebSocketProvider(this.ws_endpoint);
82
+ this.wsProvider = new ethers_compat_1.ethersCompat.WebSocketProvider(this.ws_endpoint);
83
83
  const wsPromise = this.wsProvider.ready;
84
84
  const timeoutPromise = new Promise((_, reject) => {
85
85
  setTimeout(() => reject(new Error('WebSocket connection timeout')), CONFIG.CONNECTION_TIMEOUT);
@@ -11,25 +11,16 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
11
11
  var __importDefault = (this && this.__importDefault) || function (mod) {
12
12
  return (mod && mod.__esModule) ? mod : { "default": mod };
13
13
  };
14
- var _a, _b, _c, _d, _e, _f;
15
14
  Object.defineProperty(exports, "__esModule", { value: true });
16
15
  exports.AbstractDexTrade = void 0;
17
16
  exports.buildTradeConfig = buildTradeConfig;
18
17
  const ttd_core_1 = require("@clonegod/ttd-core");
19
- const ethers_1 = require("ethers");
20
18
  const caller_manager_1 = require("./caller_manager");
21
19
  const ttd_bsc_send_tx_1 = require("@clonegod/ttd-bsc-send-tx");
22
20
  const redis_1 = require("../redis");
23
21
  const trade_direction_1 = require("../utils/trade_direction");
22
+ const ethers_compat_1 = require("../utils/ethers_compat");
24
23
  const decimal_js_1 = __importDefault(require("decimal.js"));
25
- const ethersCompat = {
26
- Interface: ((_a = ethers_1.ethers.utils) === null || _a === void 0 ? void 0 : _a.Interface) || ethers_1.ethers.Interface,
27
- JsonRpcProvider: ((_b = ethers_1.ethers.providers) === null || _b === void 0 ? void 0 : _b.JsonRpcProvider) || ethers_1.ethers.JsonRpcProvider,
28
- id: ((_c = ethers_1.ethers.utils) === null || _c === void 0 ? void 0 : _c.id) || ethers_1.ethers.id,
29
- formatUnits: ((_d = ethers_1.ethers.utils) === null || _d === void 0 ? void 0 : _d.formatUnits) || ethers_1.ethers.formatUnits,
30
- parseUnits: ((_e = ethers_1.ethers.utils) === null || _e === void 0 ? void 0 : _e.parseUnits) || ethers_1.ethers.parseUnits,
31
- keccak256: ((_f = ethers_1.ethers.utils) === null || _f === void 0 ? void 0 : _f.keccak256) || ethers_1.ethers.keccak256,
32
- };
33
24
  function buildTradeConfig() {
34
25
  const vaultGroupId = process.env.TRADE_GROUP_ID || process.env.VAULT_GROUP_ID;
35
26
  if (!vaultGroupId) {
@@ -44,8 +35,8 @@ function buildTradeConfig() {
44
35
  return {
45
36
  vaultAddress: vaultWallet.public_key,
46
37
  executorIds: {
47
- pancake: ethersCompat.id(pancakeIdName),
48
- uniswap: ethersCompat.id(uniswapIdName),
38
+ pancake: ethers_compat_1.ethersCompat.id(pancakeIdName),
39
+ uniswap: ethers_compat_1.ethersCompat.id(uniswapIdName),
49
40
  },
50
41
  };
51
42
  }
@@ -59,11 +50,11 @@ class AbstractDexTrade extends ttd_core_1.AbastrcatTrade {
59
50
  this.initConfigs();
60
51
  this.chainNameLower = this.appConfig.env_args.chain_id.toLowerCase();
61
52
  this.redisClient = new redis_1.SimpleRedisClient(`${this.chainNameLower}:tx`);
62
- this.vaultInterface = new ethersCompat.Interface(VAULT_ABI);
53
+ this.vaultInterface = new ethers_compat_1.ethersCompat.Interface(VAULT_ABI);
63
54
  }
64
55
  init() {
65
56
  return __awaiter(this, void 0, void 0, function* () {
66
- this.provider = new ethersCompat.JsonRpcProvider(this.chainConfig.rpcEndpoint);
57
+ this.provider = new ethers_compat_1.ethersCompat.JsonRpcProvider(this.chainConfig.rpcEndpoint);
67
58
  this.transactionSender = new ttd_bsc_send_tx_1.TransactionSender(this.appConfig);
68
59
  const defaultCallerId = `${this.chainNameLower.toUpperCase()}-CALLER`;
69
60
  const callerGroupIds = (process.env.CALLER_GROUP_IDS || defaultCallerId).trim().split(',').filter(Boolean);
@@ -90,7 +81,7 @@ class AbstractDexTrade extends ttd_core_1.AbastrcatTrade {
90
81
  pair,
91
82
  direction: isBuy ? 'BUY' : 'SELL',
92
83
  input: `${amount} ${inputToken.symbol}`,
93
- outputMin: `${ethersCompat.formatUnits(amountOutMin, outputToken.decimals)} ${outputToken.symbol}`,
84
+ outputMin: `${ethers_compat_1.ethersCompat.formatUnits(amountOutMin, outputToken.decimals)} ${outputToken.symbol}`,
94
85
  slippage: `${slippage_bps / 100}%`,
95
86
  });
96
87
  let maxAttempts = Math.min(Math.max(parseInt(process.env.NONCE_LOCK_MAX_RETRIES || '3'), 1), 3);
@@ -121,10 +112,11 @@ class AbstractDexTrade extends ttd_core_1.AbastrcatTrade {
121
112
  const transfer_amount_gwei = this.getBuilderTipAmoutGwei(context);
122
113
  context.ui_tip_amount = new decimal_js_1.default(transfer_amount_gwei).div(Math.pow(10, 9)).toNumber();
123
114
  const mainTx = {
115
+ type: 0,
124
116
  to: this.tradeConfig.vaultAddress,
125
117
  data: vaultCalldata,
126
118
  gasLimit: this.chainConfig.gasOptions.gasLimit,
127
- gasPrice: ethersCompat.parseUnits(realGasPriceGwei, 'gwei'),
119
+ gasPrice: ethers_compat_1.ethersCompat.parseUnits(realGasPriceGwei, 'gwei'),
128
120
  nonce,
129
121
  chainId: this.chainConfig.chainId,
130
122
  value: 0,
@@ -138,7 +130,7 @@ class AbstractDexTrade extends ttd_core_1.AbastrcatTrade {
138
130
  caller.signTransaction(mainTx),
139
131
  ...builderAddresses.map(addr => this.buildTipTransferTx(addr, transfer_amount_gwei, realGasPriceGwei, tipNonce, caller)),
140
132
  ]);
141
- txid = ethersCompat.keccak256(signedMainTx);
133
+ txid = ethers_compat_1.ethersCompat.keccak256(signedMainTx);
142
134
  const tipTxMap = new Map();
143
135
  builderAddresses.forEach((addr, idx) => tipTxMap.set(addr, signedTips[idx]));
144
136
  (0, ttd_core_1.log_info)(`交易已签名`, { txid, nonce, caller: caller.address, gasPriceGwei: realGasPriceGwei }, order_trace_id);
@@ -202,11 +194,12 @@ class AbstractDexTrade extends ttd_core_1.AbastrcatTrade {
202
194
  const real_transfer_amount_gwei = Math.min(Number(transfer_amount_gwei), this.chainConfig.gasOptions.maxTipAmountGwei).toString();
203
195
  const real_gas_price_gwei = Math.min(Number(gas_price_gwei), this.chainConfig.gasOptions.maxGasPriceGwei).toString();
204
196
  const tx_data = {
197
+ type: 0,
205
198
  from: wallet.address,
206
199
  to,
207
- value: ethersCompat.parseUnits(real_transfer_amount_gwei, 'gwei'),
200
+ value: ethers_compat_1.ethersCompat.parseUnits(real_transfer_amount_gwei, 'gwei'),
208
201
  gasLimit: 42000,
209
- gasPrice: ethersCompat.parseUnits(real_gas_price_gwei, 'gwei'),
202
+ gasPrice: ethers_compat_1.ethersCompat.parseUnits(real_gas_price_gwei, 'gwei'),
210
203
  nonce,
211
204
  chainId: this.chainConfig.chainId
212
205
  };
@@ -214,7 +207,7 @@ class AbstractDexTrade extends ttd_core_1.AbastrcatTrade {
214
207
  (0, ttd_core_1.log_info)(`构建 tip 转账交易`, {
215
208
  to, nonce,
216
209
  tipGwei: real_transfer_amount_gwei,
217
- txhash: ethersCompat.keccak256(signedTx)
210
+ txhash: ethers_compat_1.ethersCompat.keccak256(signedTx)
218
211
  });
219
212
  return signedTx;
220
213
  });
@@ -238,7 +231,7 @@ class AbstractDexTrade extends ttd_core_1.AbastrcatTrade {
238
231
  expectedOut = inputAmount.mul(price);
239
232
  }
240
233
  const minOutput = expectedOut.mul(new decimal_js_1.default(1).sub(new decimal_js_1.default(slippage)));
241
- return ethersCompat.parseUnits(minOutput.toFixed(outputToken.decimals), outputToken.decimals);
234
+ return ethers_compat_1.ethersCompat.parseUnits(minOutput.toFixed(outputToken.decimals), outputToken.decimals);
242
235
  }
243
236
  extractNonceFromErrorMsg(errorMessage) {
244
237
  try {
@@ -5,7 +5,7 @@ export interface CallerHandle {
5
5
  }
6
6
  export interface CallerManagerConfig {
7
7
  chainName: string;
8
- provider: ethers.providers.JsonRpcProvider;
8
+ provider: any;
9
9
  callerGroupIds: string[];
10
10
  chainId: number;
11
11
  }
@@ -1,9 +1,8 @@
1
1
  import { EnvArgs } from '@clonegod/ttd-core';
2
2
  import { AbstractTransactionResultCheck } from "@clonegod/ttd-core/dist/trade";
3
- import { ethers } from 'ethers';
4
3
  import { EventEmitter } from 'events';
5
4
  export declare abstract class BaseTxResultChecker extends AbstractTransactionResultCheck {
6
- protected provider: ethers.providers.JsonRpcProvider;
5
+ protected provider: any;
7
6
  constructor(env_args: EnvArgs, event_emitter: EventEmitter);
8
7
  protected abstract createParser(): {
9
8
  parseTransaction(txReceipt: any, poolInfo: any): Promise<any>;
@@ -12,7 +12,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.BaseTxResultChecker = void 0;
13
13
  const ttd_core_1 = require("@clonegod/ttd-core");
14
14
  const trade_1 = require("@clonegod/ttd-core/dist/trade");
15
- const ethers_1 = require("ethers");
15
+ const ethers_compat_1 = require("../../utils/ethers_compat");
16
16
  class TradeResultSubscriber {
17
17
  constructor() {
18
18
  this.ws = null;
@@ -73,7 +73,7 @@ TradeResultSubscriber.instance = null;
73
73
  class BaseTxResultChecker extends trade_1.AbstractTransactionResultCheck {
74
74
  constructor(env_args, event_emitter) {
75
75
  super(env_args, event_emitter);
76
- this.provider = new ethers_1.ethers.providers.JsonRpcProvider(this.env_args.rpc_endpoint);
76
+ this.provider = new ethers_compat_1.ethersCompat.JsonRpcProvider(this.env_args.rpc_endpoint);
77
77
  }
78
78
  check_tx_result_interval() {
79
79
  return __awaiter(this, void 0, void 0, function* () {
@@ -1,11 +1,10 @@
1
1
  import { StandardPoolInfoType, StandardSwapDetailType } from "@clonegod/ttd-core";
2
2
  import { TransactionReceipt } from '@ethersproject/providers';
3
- import { ethers } from 'ethers';
4
3
  import { ITxParser } from "./abstract_parser";
5
4
  import { ParserConfig } from "../../types";
6
5
  export declare abstract class BaseTxParser implements ITxParser {
7
6
  protected config: ParserConfig;
8
- protected provider: ethers.providers.JsonRpcProvider;
7
+ protected provider: any;
9
8
  protected blockTimeCache: Map<number, number>;
10
9
  protected readonly CACHE_EXPIRY: number;
11
10
  constructor(config: ParserConfig);
@@ -12,12 +12,13 @@ Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.BaseTxParser = void 0;
13
13
  const ttd_core_1 = require("@clonegod/ttd-core");
14
14
  const ethers_1 = require("ethers");
15
+ const ethers_compat_1 = require("../../utils/ethers_compat");
15
16
  class BaseTxParser {
16
17
  constructor(config) {
17
18
  this.blockTimeCache = new Map();
18
19
  this.CACHE_EXPIRY = 1000 * 60 * 60;
19
20
  this.config = config;
20
- this.provider = new ethers_1.ethers.providers.JsonRpcProvider(config.rpcEndpoint);
21
+ this.provider = new ethers_compat_1.ethersCompat.JsonRpcProvider(config.rpcEndpoint);
21
22
  }
22
23
  getBlockTime(blockNumber) {
23
24
  return __awaiter(this, void 0, void 0, function* () {
@@ -56,7 +57,7 @@ class BaseTxParser {
56
57
  const gasUsed = toBN(txReceipt.gasUsed);
57
58
  const effectiveGasPrice = toBN(txReceipt.effectiveGasPrice || txReceipt.gasPrice);
58
59
  const gasFeeBN = gasUsed.mul(effectiveGasPrice);
59
- const base_fee = Number(ethers_1.ethers.utils.formatEther(gasFeeBN));
60
+ const base_fee = Number(ethers_compat_1.ethersCompat.formatEther(gasFeeBN));
60
61
  const priority_fee = 0;
61
62
  const total_fee = base_fee + priority_fee;
62
63
  return {
@@ -13,9 +13,9 @@ export interface EvmContractEventData {
13
13
  eventSignature: string;
14
14
  args: any;
15
15
  removeListener: () => void;
16
- getBlock: () => Promise<ethers.providers.Block>;
17
- getTransaction: () => Promise<ethers.providers.TransactionResponse>;
18
- getTransactionReceipt: () => Promise<ethers.providers.TransactionReceipt>;
16
+ getBlock: () => Promise<any>;
17
+ getTransaction: () => Promise<any>;
18
+ getTransactionReceipt: () => Promise<any>;
19
19
  decode: (data: string, topics?: string[]) => any;
20
20
  }
21
21
  export interface AmmPoolSyncEventData extends EvmContractEventData {
@@ -0,0 +1,13 @@
1
+ export declare const ethersCompat: {
2
+ Interface: any;
3
+ JsonRpcProvider: any;
4
+ WebSocketProvider: any;
5
+ id: any;
6
+ formatUnits: any;
7
+ parseUnits: any;
8
+ formatEther: any;
9
+ parseEther: any;
10
+ keccak256: any;
11
+ isAddress: any;
12
+ Zero: any;
13
+ };
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.ethersCompat = void 0;
5
+ const ethers_1 = require("ethers");
6
+ const _ethers = ethers_1.ethers;
7
+ exports.ethersCompat = {
8
+ Interface: ((_a = _ethers.utils) === null || _a === void 0 ? void 0 : _a.Interface) || _ethers.Interface,
9
+ JsonRpcProvider: ((_b = _ethers.providers) === null || _b === void 0 ? void 0 : _b.JsonRpcProvider) || _ethers.JsonRpcProvider,
10
+ WebSocketProvider: ((_c = _ethers.providers) === null || _c === void 0 ? void 0 : _c.WebSocketProvider) || _ethers.WebSocketProvider,
11
+ id: ((_d = _ethers.utils) === null || _d === void 0 ? void 0 : _d.id) || _ethers.id,
12
+ formatUnits: ((_e = _ethers.utils) === null || _e === void 0 ? void 0 : _e.formatUnits) || _ethers.formatUnits,
13
+ parseUnits: ((_f = _ethers.utils) === null || _f === void 0 ? void 0 : _f.parseUnits) || _ethers.parseUnits,
14
+ formatEther: ((_g = _ethers.utils) === null || _g === void 0 ? void 0 : _g.formatEther) || _ethers.formatEther,
15
+ parseEther: ((_h = _ethers.utils) === null || _h === void 0 ? void 0 : _h.parseEther) || _ethers.parseEther,
16
+ keccak256: ((_j = _ethers.utils) === null || _j === void 0 ? void 0 : _j.keccak256) || _ethers.keccak256,
17
+ isAddress: ((_k = _ethers.utils) === null || _k === void 0 ? void 0 : _k.isAddress) || _ethers.isAddress,
18
+ Zero: ((_l = _ethers.constants) === null || _l === void 0 ? void 0 : _l.Zero) || BigInt(0),
19
+ };
@@ -1,5 +1,5 @@
1
1
  import { ethers } from 'ethers';
2
2
  export declare class EVMGasHelper {
3
- static wrapNativeToken(provider: ethers.providers.Provider, wallet: ethers.Wallet, wrappedTokenAddress: string, amount: string, minReserve?: string, tokenSymbol?: string): Promise<string>;
4
- static checkNativeBalance(provider: ethers.providers.Provider, walletAddress: string): Promise<ethers.BigNumber>;
3
+ static wrapNativeToken(provider: any, wallet: ethers.Wallet, wrappedTokenAddress: string, amount: string, minReserve?: string, tokenSymbol?: string): Promise<string>;
4
+ static checkNativeBalance(provider: any, walletAddress: string): Promise<ethers.BigNumber>;
5
5
  }
@@ -11,16 +11,17 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.EVMGasHelper = void 0;
13
13
  const ethers_1 = require("ethers");
14
+ const ethers_compat_1 = require("./ethers_compat");
14
15
  const ttd_core_1 = require("@clonegod/ttd-core");
15
16
  class EVMGasHelper {
16
17
  static wrapNativeToken(provider_1, wallet_1, wrappedTokenAddress_1, amount_1) {
17
18
  return __awaiter(this, arguments, void 0, function* (provider, wallet, wrappedTokenAddress, amount, minReserve = "0.1", tokenSymbol = "ETH") {
18
19
  const nativeBalance = yield provider.getBalance(wallet.address);
19
- const nativeBalanceEth = ethers_1.ethers.utils.formatEther(nativeBalance);
20
+ const nativeBalanceEth = ethers_compat_1.ethersCompat.formatEther(nativeBalance);
20
21
  (0, ttd_core_1.log_info)(`当前${tokenSymbol}余额: ${nativeBalanceEth} ${tokenSymbol}`);
21
22
  let wrapAmount;
22
23
  if (amount === "max") {
23
- const minReserveBN = ethers_1.ethers.utils.parseEther(minReserve);
24
+ const minReserveBN = ethers_compat_1.ethersCompat.parseEther(minReserve);
24
25
  if (nativeBalance.lte(minReserveBN)) {
25
26
  (0, ttd_core_1.log_info)(`${tokenSymbol}余额不足最小保留额 ${minReserve} ${tokenSymbol},不执行转换`);
26
27
  return null;
@@ -28,14 +29,14 @@ class EVMGasHelper {
28
29
  wrapAmount = nativeBalance.sub(minReserveBN);
29
30
  }
30
31
  else {
31
- wrapAmount = ethers_1.ethers.utils.parseEther(amount);
32
- const minReserveBN = ethers_1.ethers.utils.parseEther(minReserve);
32
+ wrapAmount = ethers_compat_1.ethersCompat.parseEther(amount);
33
+ const minReserveBN = ethers_compat_1.ethersCompat.parseEther(minReserve);
33
34
  if (nativeBalance.sub(wrapAmount).lt(minReserveBN)) {
34
35
  (0, ttd_core_1.log_info)(`转换后${tokenSymbol}余额将低于最小保留额 ${minReserve} ${tokenSymbol},调整转换金额`);
35
36
  wrapAmount = nativeBalance.sub(minReserveBN);
36
37
  }
37
38
  }
38
- if (wrapAmount.lte(ethers_1.ethers.constants.Zero)) {
39
+ if (wrapAmount.lte(ethers_compat_1.ethersCompat.Zero)) {
39
40
  (0, ttd_core_1.log_info)(`计算的转换金额为0或负数,不执行转换`);
40
41
  return null;
41
42
  }
@@ -43,7 +44,7 @@ class EVMGasHelper {
43
44
  "function deposit() external payable",
44
45
  "function withdraw(uint wad) external"
45
46
  ], wallet);
46
- (0, ttd_core_1.log_info)(`准备将 ${ethers_1.ethers.utils.formatEther(wrapAmount)} ${tokenSymbol} 转换为 W${tokenSymbol}`);
47
+ (0, ttd_core_1.log_info)(`准备将 ${ethers_compat_1.ethersCompat.formatEther(wrapAmount)} ${tokenSymbol} 转换为 W${tokenSymbol}`);
47
48
  const gasPrice = yield provider.getGasPrice();
48
49
  const txOptions = {
49
50
  value: wrapAmount,
@@ -1,9 +1,9 @@
1
- import { ethers } from "ethers";
2
1
  import Decimal from "decimal.js";
3
2
  export * from './gas_helper';
4
3
  export * from './trade_direction';
5
4
  export * from './pool_filter';
5
+ export * from './ethers_compat';
6
6
  export declare const sleep: (ms: number) => Promise<void>;
7
7
  export declare const formatPrice: (price: number, precision?: number) => string;
8
- export declare const formatUnits: (value: ethers.BigNumber, decimals: number) => Decimal;
8
+ export declare const formatUnits: (value: any, decimals: number) => Decimal;
9
9
  export declare const formatNumberHighPrecision: (numStr: string, precision?: number) => string;
@@ -18,11 +18,12 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
18
18
  };
19
19
  Object.defineProperty(exports, "__esModule", { value: true });
20
20
  exports.formatNumberHighPrecision = exports.formatUnits = exports.formatPrice = exports.sleep = void 0;
21
- const ethers_1 = require("ethers");
22
21
  const decimal_js_1 = __importDefault(require("decimal.js"));
22
+ const ethers_compat_1 = require("./ethers_compat");
23
23
  __exportStar(require("./gas_helper"), exports);
24
24
  __exportStar(require("./trade_direction"), exports);
25
25
  __exportStar(require("./pool_filter"), exports);
26
+ __exportStar(require("./ethers_compat"), exports);
26
27
  const sleep = (ms) => {
27
28
  return new Promise(resolve => setTimeout(resolve, ms));
28
29
  };
@@ -32,7 +33,7 @@ const formatPrice = (price, precision = 10) => {
32
33
  };
33
34
  exports.formatPrice = formatPrice;
34
35
  const formatUnits = (value, decimals) => {
35
- return new decimal_js_1.default(ethers_1.ethers.utils.formatUnits(value, decimals).toString());
36
+ return new decimal_js_1.default(ethers_compat_1.ethersCompat.formatUnits(value, decimals).toString());
36
37
  };
37
38
  exports.formatUnits = formatUnits;
38
39
  const formatNumberHighPrecision = (numStr, precision = 12) => {
@@ -11,6 +11,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.PancakeV2AmmPoolEventsSubscriber = void 0;
13
13
  const ethers_1 = require("ethers");
14
+ const ethers_compat_1 = require("../utils/ethers_compat");
14
15
  const event_filter_1 = require("./event_filter");
15
16
  const PANCAKE_V2_POOL_ABI = [
16
17
  'event Sync(uint112 reserve0, uint112 reserve1)',
@@ -36,7 +37,7 @@ class PancakeV2AmmPoolEventsSubscriber {
36
37
  if (!this.wsUrl || !this.poolAddress) {
37
38
  throw new Error(`wsUrl and poolAddress are required! wsUrl=${this.wsUrl} poolAddress=${this.poolAddress}`);
38
39
  }
39
- this.provider = new ethers_1.ethers.providers.WebSocketProvider(this.wsUrl);
40
+ this.provider = new ethers_compat_1.ethersCompat.WebSocketProvider(this.wsUrl);
40
41
  this.poolContract = new ethers_1.ethers.Contract(this.poolAddress, PANCAKE_V2_POOL_ABI, this.provider);
41
42
  this.isConnected = true;
42
43
  console.log(`Connected to WebSocket: ${this.wsUrl} for pool: ${this.poolAddress}`);
@@ -11,6 +11,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.UniswapV3PoolEventsSubscriber = exports.PancakeV3PoolEventsSubscriber = void 0;
13
13
  const ethers_1 = require("ethers");
14
+ const ethers_compat_1 = require("../utils/ethers_compat");
14
15
  const event_filter_1 = require("./event_filter");
15
16
  const PANCAKE_V3_POOL_ABI = [
16
17
  'event Swap(address indexed sender, address indexed recipient, int256 amount0, int256 amount1, uint160 sqrtPriceX96, uint128 liquidity, int24 tick, uint128 protocolFeesToken0, uint128 protocolFeesToken1)',
@@ -36,7 +37,7 @@ class PancakeV3PoolEventsSubscriber {
36
37
  if (!this.wsUrl || !this.poolAddress) {
37
38
  throw new Error(`wsUrl and poolAddress are required! wsUrl=${this.wsUrl} poolAddress=${this.poolAddress}`);
38
39
  }
39
- this.provider = new ethers_1.ethers.providers.WebSocketProvider(this.wsUrl);
40
+ this.provider = new ethers_compat_1.ethersCompat.WebSocketProvider(this.wsUrl);
40
41
  this.poolContract = new ethers_1.ethers.Contract(this.poolAddress, PANCAKE_V3_POOL_ABI, this.provider);
41
42
  this.isConnected = true;
42
43
  console.log(`Connected to WebSocket: ${this.wsUrl} for pool: ${this.poolAddress}`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@clonegod/ttd-bsc-common",
3
- "version": "3.0.20",
3
+ "version": "3.0.22",
4
4
  "description": "BSC common library",
5
5
  "license": "UNLICENSED",
6
6
  "main": "dist/index.js",