@clonegod/ttd-bsc-common 1.0.28 → 1.0.29
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.
|
@@ -18,7 +18,7 @@ export declare abstract class AbstractEvmDexTradePlus extends AbastrcatTrade {
|
|
|
18
18
|
protected getTokenContractWithWallet(tokenAddress: string, wallet: ethers.Wallet): ethers.Contract;
|
|
19
19
|
protected getGasPriceGwei(context: TradeContext): string;
|
|
20
20
|
protected getBuilderTipAmoutGwei(context: TradeContext): string;
|
|
21
|
-
preApproveAllWallets(token_list
|
|
21
|
+
preApproveAllWallets(token_list?: string[]): Promise<void>;
|
|
22
22
|
private approveTokenIfNeeded;
|
|
23
23
|
protected checkTradeTokenApprove(context: TradeContext, wallet: ethers.Wallet, routerAddress?: string): Promise<void>;
|
|
24
24
|
protected checkTokenApprove(tokenAddress: string, tokenSymbol: string, tokenContract: ethers.Contract, spenderAddress: string, wallet: ethers.Wallet): Promise<boolean>;
|
|
@@ -66,8 +66,8 @@ class AbstractEvmDexTradePlus extends dist_1.AbastrcatTrade {
|
|
|
66
66
|
(0, dist_1.log_info)(`getGasTipAmoutGwei: ${evm_tip_amount_gwei} Gwei`);
|
|
67
67
|
return evm_tip_amount_gwei.toString();
|
|
68
68
|
}
|
|
69
|
-
preApproveAllWallets(
|
|
70
|
-
return __awaiter(this,
|
|
69
|
+
preApproveAllWallets() {
|
|
70
|
+
return __awaiter(this, arguments, void 0, function* (token_list = []) {
|
|
71
71
|
if (!this.group_wallets || this.group_wallets.length === 0) {
|
|
72
72
|
(0, dist_1.log_info)('No wallets available for pre-approval');
|
|
73
73
|
return;
|
|
@@ -75,33 +75,30 @@ class AbstractEvmDexTradePlus extends dist_1.AbastrcatTrade {
|
|
|
75
75
|
if (!token_list || token_list.length === 0) {
|
|
76
76
|
token_list = Array.from(this.tokenContracts.keys());
|
|
77
77
|
}
|
|
78
|
-
(0, dist_1.log_info)(`
|
|
78
|
+
(0, dist_1.log_info)(`Pre-approve: ${this.group_wallets.length} wallets, ${token_list.length} tokens`, token_list);
|
|
79
79
|
const tokenAddresses = new Set();
|
|
80
80
|
for (const token_address of token_list) {
|
|
81
81
|
tokenAddresses.add(token_address.toLowerCase());
|
|
82
82
|
}
|
|
83
83
|
const tokens = Array.from(tokenAddresses);
|
|
84
|
-
(0, dist_1.log_info)(`Pre-approving ${tokens.length} tokens for all wallets`);
|
|
85
84
|
for (const wallet of this.group_wallets) {
|
|
86
85
|
try {
|
|
87
|
-
(0, dist_1.log_info)(`Pre-
|
|
86
|
+
(0, dist_1.log_info)(`Pre-approve: wallet ${wallet.address}`);
|
|
88
87
|
for (const tokenAddress of tokens) {
|
|
89
88
|
try {
|
|
90
89
|
yield this.approveTokenIfNeeded(wallet, tokenAddress);
|
|
91
|
-
(0, dist_1.log_info)(`Pre-approved token ${tokenAddress} for wallet ${wallet.address}`);
|
|
92
|
-
yield (0, dist_1.sleep)(1000);
|
|
93
90
|
}
|
|
94
91
|
catch (error) {
|
|
95
92
|
console.warn(`Failed to pre-approve token ${tokenAddress} for wallet ${wallet.address}:`, error);
|
|
96
93
|
}
|
|
97
94
|
}
|
|
98
|
-
(0, dist_1.log_info)(`
|
|
95
|
+
(0, dist_1.log_info)(`Pre-approve: wallet ${wallet.address} completed`);
|
|
99
96
|
}
|
|
100
97
|
catch (error) {
|
|
101
98
|
console.warn(`Failed to pre-approve tokens for wallet ${wallet.address}:`, error);
|
|
102
99
|
}
|
|
103
100
|
}
|
|
104
|
-
(0, dist_1.log_info)('Pre-
|
|
101
|
+
(0, dist_1.log_info)('Pre-approve: all wallets completed');
|
|
105
102
|
});
|
|
106
103
|
}
|
|
107
104
|
approveTokenIfNeeded(wallet, tokenAddress) {
|
|
@@ -111,14 +108,14 @@ class AbstractEvmDexTradePlus extends dist_1.AbastrcatTrade {
|
|
|
111
108
|
const routerAddress = this.dexConfig.routerAddress;
|
|
112
109
|
const currentAllowance = yield tokenContract.allowance(wallet.address, routerAddress);
|
|
113
110
|
if (currentAllowance.gt(0)) {
|
|
114
|
-
(0, dist_1.log_info)(`
|
|
111
|
+
(0, dist_1.log_info)(`Pre-approve: token ${tokenAddress} already approved`);
|
|
115
112
|
return;
|
|
116
113
|
}
|
|
117
114
|
const maxAllowance = ethers_1.ethers.constants.MaxUint256;
|
|
118
115
|
const approveTx = yield tokenContract.connect(wallet).approve(routerAddress, maxAllowance);
|
|
119
|
-
(0, dist_1.log_info)(`
|
|
116
|
+
(0, dist_1.log_info)(`Pre-approve: token ${tokenAddress} approve success, tx: ${approveTx.hash}`);
|
|
120
117
|
yield approveTx.wait();
|
|
121
|
-
(0, dist_1.log_info)(`
|
|
118
|
+
(0, dist_1.log_info)(`Pre-approve: token ${tokenAddress} approved successfully`);
|
|
122
119
|
}
|
|
123
120
|
catch (error) {
|
|
124
121
|
console.warn(`Failed to approve token ${tokenAddress} for wallet ${wallet.address}:`, error);
|