@clonegod/ttd-bsc-common 3.1.89 → 3.1.91

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.
Files changed (46) hide show
  1. package/dist/appconfig/bsc_env_args.js +1 -1
  2. package/dist/quote/abstract_dex_quote.d.ts +1 -0
  3. package/dist/quote/abstract_dex_quote.js +7 -0
  4. package/dist/quote/depth/index.d.ts +1 -0
  5. package/dist/quote/depth/index.js +29 -8
  6. package/dist/quote/hook_fee_monitor.d.ts +10 -0
  7. package/dist/quote/hook_fee_monitor.js +32 -0
  8. package/dist/quote/index.d.ts +1 -0
  9. package/dist/quote/index.js +1 -0
  10. package/dist/quote/token_tax.d.ts +17 -0
  11. package/dist/quote/token_tax.js +30 -0
  12. package/package.json +2 -2
  13. package/dist/config/bsc_env_args.d.ts +0 -11
  14. package/dist/config/bsc_env_args.js +0 -19
  15. package/dist/config/index.d.ts +0 -1
  16. package/dist/config/index.js +0 -17
  17. package/dist/quote/event/verify_clmm_swap_event.d.ts +0 -1
  18. package/dist/quote/event/verify_clmm_swap_event.js +0 -178
  19. package/dist/quote/pricing/token_price_cache.d.ts +0 -9
  20. package/dist/quote/pricing/token_price_cache.js +0 -40
  21. package/dist/redis/index.d.ts +0 -1
  22. package/dist/redis/index.js +0 -17
  23. package/dist/redis/redis_client.d.ts +0 -21
  24. package/dist/redis/redis_client.js +0 -155
  25. package/dist/trade/abstract_dex_trade_plus.d.ts +0 -30
  26. package/dist/trade/abstract_dex_trade_plus.js +0 -227
  27. package/dist/trade/check/tx_websocket_manager.d.ts +0 -23
  28. package/dist/trade/check/tx_websocket_manager.js +0 -119
  29. package/dist/trade/send/48club.d.ts +0 -18
  30. package/dist/trade/send/48club.js +0 -97
  31. package/dist/trade/send/blockrazor.d.ts +0 -7
  32. package/dist/trade/send/blockrazor.js +0 -79
  33. package/dist/trade/send/bsc_rpc.d.ts +0 -6
  34. package/dist/trade/send/bsc_rpc.js +0 -43
  35. package/dist/trade/send/index.d.ts +0 -5
  36. package/dist/trade/send/index.js +0 -23
  37. package/dist/trade/send/send_tx.d.ts +0 -8
  38. package/dist/trade/send/send_tx.js +0 -91
  39. package/dist/ws/event_filter.d.ts +0 -8
  40. package/dist/ws/event_filter.js +0 -36
  41. package/dist/ws/index.d.ts +0 -2
  42. package/dist/ws/index.js +0 -18
  43. package/dist/ws/subscribe_v2_events.d.ts +0 -14
  44. package/dist/ws/subscribe_v2_events.js +0 -174
  45. package/dist/ws/subscribe_v3_events.d.ts +0 -16
  46. package/dist/ws/subscribe_v3_events.js +0 -177
@@ -1,177 +0,0 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.UniswapV3PoolEventsSubscriber = exports.PancakeV3PoolEventsSubscriber = void 0;
13
- const ethers_1 = require("ethers");
14
- const event_filter_1 = require("./event_filter");
15
- const PANCAKE_V3_POOL_ABI = [
16
- 'event Swap(address indexed sender, address indexed recipient, int256 amount0, int256 amount1, uint160 sqrtPriceX96, uint128 liquidity, int24 tick, uint128 protocolFeesToken0, uint128 protocolFeesToken1)',
17
- 'event Mint(address sender, address indexed owner, int24 indexed tickLower, int24 indexed tickUpper, uint128 amount, uint256 amount0, uint256 amount1)',
18
- 'event Burn(address indexed owner, int24 indexed tickLower, int24 indexed tickUpper, uint128 amount, uint256 amount0, uint256 amount1)'
19
- ];
20
- class PancakeV3PoolEventsSubscriber {
21
- constructor(wsUrl, poolAddress) {
22
- this.wsUrl = wsUrl;
23
- this.poolAddress = poolAddress;
24
- this.provider = null;
25
- this.poolContract = null;
26
- this.eventCallbacks = {
27
- swap: null,
28
- mint: null,
29
- burn: null
30
- };
31
- this.isConnected = false;
32
- }
33
- initialize() {
34
- return __awaiter(this, void 0, void 0, function* () {
35
- try {
36
- if (!this.wsUrl || !this.poolAddress) {
37
- throw new Error(`wsUrl and poolAddress are required! wsUrl=${this.wsUrl} poolAddress=${this.poolAddress}`);
38
- }
39
- this.provider = new ethers_1.ethers.providers.WebSocketProvider(this.wsUrl);
40
- this.poolContract = new ethers_1.ethers.Contract(this.poolAddress, PANCAKE_V3_POOL_ABI, this.provider);
41
- this.isConnected = true;
42
- console.log(`Connected to WebSocket: ${this.wsUrl} for pool: ${this.poolAddress}`);
43
- this.provider._websocket.on('error', (error) => {
44
- console.error('WebSocket Error:', error);
45
- this.isConnected = false;
46
- this._reconnect();
47
- });
48
- this.provider._websocket.on('close', (code, reason) => {
49
- console.error('WebSocket Closed:', code, reason);
50
- this.isConnected = false;
51
- this._reconnect();
52
- });
53
- }
54
- catch (error) {
55
- console.error('Initialization Error:', error);
56
- this.isConnected = false;
57
- this._reconnect();
58
- }
59
- });
60
- }
61
- subscribe(eventType, callback) {
62
- if (!this.poolContract) {
63
- throw new Error('Contract not initialized. Call initialize() first.');
64
- }
65
- if (!['swap', 'mint', 'burn'].includes(eventType.toLowerCase())) {
66
- throw new Error('Invalid event type. Use "swap", "mint", or "burn".');
67
- }
68
- this.eventCallbacks[eventType.toLowerCase()] = callback;
69
- if (eventType.toLowerCase() === 'swap') {
70
- this.poolContract.on('Swap', (sender, recipient, amount0, amount1, sqrtPriceX96, liquidity, tick, protocolFeesToken0, protocolFeesToken1, event) => {
71
- const data = {
72
- pool_address: this.poolAddress,
73
- type: 'swap',
74
- event_time: Date.now(),
75
- data: {
76
- blockNumber: event.blockNumber,
77
- transactionIndex: event.transactionIndex,
78
- transactionHash: event.transactionHash,
79
- amount0: amount0.toString(),
80
- amount1: amount1.toString(),
81
- reserve0: BigInt(0),
82
- reserve1: BigInt(0),
83
- tick,
84
- sqrtPriceX96: sqrtPriceX96.toString(),
85
- liquidity: liquidity.toString(),
86
- }
87
- };
88
- callback(data);
89
- });
90
- }
91
- else if (eventType.toLowerCase() === 'mint') {
92
- this.poolContract.on('Mint', (sender, owner, tickLower, tickUpper, amount, amount0, amount1, event) => {
93
- const data = {
94
- pool_address: this.poolAddress,
95
- type: 'mint',
96
- event_time: Date.now(),
97
- data: {
98
- blockNumber: event.blockNumber,
99
- transactionIndex: event.transactionIndex,
100
- transactionHash: event.transactionHash,
101
- amount0: amount0.toString(),
102
- amount1: amount1.toString(),
103
- reserve0: BigInt(0),
104
- reserve1: BigInt(0),
105
- tick: 0,
106
- sqrtPriceX96: BigInt(0),
107
- liquidity: BigInt(0),
108
- }
109
- };
110
- event_filter_1.EventFilter.filterEvent(this.poolAddress, event.blockNumber, 'mint', callback, data);
111
- });
112
- }
113
- else if (eventType.toLowerCase() === 'burn') {
114
- this.poolContract.on('Burn', (owner, tickLower, tickUpper, amount, amount0, amount1, event) => {
115
- const data = {
116
- pool_address: this.poolAddress,
117
- type: 'burn',
118
- event_time: Date.now(),
119
- data: {
120
- blockNumber: event.blockNumber,
121
- transactionIndex: event.transactionIndex,
122
- transactionHash: event.transactionHash,
123
- amount0: amount0.toString(),
124
- amount1: amount1.toString(),
125
- reserve0: BigInt(0),
126
- reserve1: BigInt(0),
127
- tick: 0,
128
- sqrtPriceX96: BigInt(0),
129
- liquidity: BigInt(0),
130
- }
131
- };
132
- event_filter_1.EventFilter.filterEvent(this.poolAddress, event.blockNumber, 'burn', callback, data);
133
- });
134
- }
135
- }
136
- unsubscribe(eventType) {
137
- return __awaiter(this, void 0, void 0, function* () {
138
- if (!this.poolContract) {
139
- throw new Error('Contract not initialized.');
140
- }
141
- if (!['swap', 'mint', 'burn'].includes(eventType.toLowerCase())) {
142
- throw new Error('Invalid event type. Use "swap", "mint", or "burn".');
143
- }
144
- this.poolContract.removeAllListeners(eventType);
145
- this.eventCallbacks[eventType.toLowerCase()] = null;
146
- console.log(`Unsubscribed from ${eventType} events`);
147
- });
148
- }
149
- disconnect() {
150
- return __awaiter(this, void 0, void 0, function* () {
151
- if (this.provider) {
152
- yield this.provider.destroy();
153
- this.provider = null;
154
- this.poolContract = null;
155
- this.isConnected = false;
156
- console.log('Disconnected from WebSocket');
157
- }
158
- });
159
- }
160
- _reconnect() {
161
- if (!this.isConnected) {
162
- console.log('Attempting to reconnect...');
163
- setTimeout(() => __awaiter(this, void 0, void 0, function* () {
164
- yield this.initialize();
165
- for (const [eventType, callback] of Object.entries(this.eventCallbacks)) {
166
- if (callback) {
167
- this.subscribe(eventType, callback);
168
- }
169
- }
170
- }), 2000);
171
- }
172
- }
173
- }
174
- exports.PancakeV3PoolEventsSubscriber = PancakeV3PoolEventsSubscriber;
175
- class UniswapV3PoolEventsSubscriber extends PancakeV3PoolEventsSubscriber {
176
- }
177
- exports.UniswapV3PoolEventsSubscriber = UniswapV3PoolEventsSubscriber;