@clonegod/ttd-bsc-common 1.0.23 → 1.0.25
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.
|
@@ -4,6 +4,7 @@ import { DexConfig, EvmChainConfig } from "../types";
|
|
|
4
4
|
export declare abstract class AbstractEvmDexTrade extends AbastrcatTrade {
|
|
5
5
|
protected appConfig: AppConfig;
|
|
6
6
|
protected wallet: ethers.Wallet;
|
|
7
|
+
protected group_wallets: ethers.Wallet[];
|
|
7
8
|
protected provider: ethers.providers.JsonRpcProvider;
|
|
8
9
|
protected approvedTokens: Map<string, boolean>;
|
|
9
10
|
protected pairContracts: Map<string, ethers.Contract>;
|
|
@@ -23,5 +24,5 @@ export declare abstract class AbstractEvmDexTrade extends AbastrcatTrade {
|
|
|
23
24
|
protected isNativeCurrency(symbol: string): boolean;
|
|
24
25
|
protected getWrappedNativeAddress(): string;
|
|
25
26
|
abstract execute(context: TradeContext, retryCount?: number): Promise<string>;
|
|
26
|
-
protected buildTipTransferTx(to: string, transfer_amount_gwei: string, gas_price_gwei: string, transfer_nonce: number): Promise<string>;
|
|
27
|
+
protected buildTipTransferTx(to: string, transfer_amount_gwei: string, gas_price_gwei: string, transfer_nonce: number, wallet?: ethers.Wallet): Promise<string>;
|
|
27
28
|
}
|
|
@@ -27,9 +27,15 @@ class AbstractEvmDexTrade extends dist_1.AbastrcatTrade {
|
|
|
27
27
|
}
|
|
28
28
|
init() {
|
|
29
29
|
return __awaiter(this, void 0, void 0, function* () {
|
|
30
|
+
var _a;
|
|
30
31
|
this.provider = new ethers_1.ethers.providers.JsonRpcProvider(this.chainConfig.rpcEndpoint);
|
|
31
32
|
this.wallet = new ethers_1.ethers.Wallet(this.appConfig.trade_runtime.wallet.private_key, this.provider);
|
|
32
33
|
(0, dist_1.log_info)(`钱包已初始化,地址: ${this.wallet.address}`);
|
|
34
|
+
if (process.env.WALLET_GROUP_IDS) {
|
|
35
|
+
let wallet_infos = (0, dist_1.load_wallet_multi)(((_a = process.env.WALLET_GROUP_IDS) === null || _a === void 0 ? void 0 : _a.split(',')) || [], false);
|
|
36
|
+
this.group_wallets = wallet_infos.map(info => new ethers_1.ethers.Wallet(info.private_key, this.provider));
|
|
37
|
+
(0, dist_1.log_info)(`组钱包已初始化,数量: ${this.group_wallets.length}`, this.group_wallets.map(e => e.address));
|
|
38
|
+
}
|
|
33
39
|
this.routerContract = new ethers_1.ethers.Contract(this.dexConfig.routerAddress, this.dexConfig.routerAbi, this.wallet);
|
|
34
40
|
(0, dist_1.log_info)(`${this.dexConfig.dexName} Router已初始化, 地址: ${this.dexConfig.routerAddress}`);
|
|
35
41
|
});
|
|
@@ -130,12 +136,13 @@ class AbstractEvmDexTrade extends dist_1.AbastrcatTrade {
|
|
|
130
136
|
getWrappedNativeAddress() {
|
|
131
137
|
return this.chainConfig.wrappedNativeCurrencyAddress;
|
|
132
138
|
}
|
|
133
|
-
buildTipTransferTx(to, transfer_amount_gwei, gas_price_gwei, transfer_nonce) {
|
|
139
|
+
buildTipTransferTx(to, transfer_amount_gwei, gas_price_gwei, transfer_nonce, wallet) {
|
|
134
140
|
return __awaiter(this, void 0, void 0, function* () {
|
|
141
|
+
const targetWallet = wallet || this.wallet;
|
|
135
142
|
let real_transfer_amount_gwei = Math.min(Number(transfer_amount_gwei), this.chainConfig.gasOptions.maxTipAmountGwei).toString();
|
|
136
143
|
let real_gas_price_gwei = Math.min(Number(gas_price_gwei), this.chainConfig.gasOptions.maxGasPriceGwei).toString();
|
|
137
144
|
let tx_data = {
|
|
138
|
-
from:
|
|
145
|
+
from: targetWallet.address,
|
|
139
146
|
to,
|
|
140
147
|
value: ethers_1.ethers.utils.parseUnits(real_transfer_amount_gwei, 'gwei'),
|
|
141
148
|
gasLimit: 21000,
|
|
@@ -143,7 +150,7 @@ class AbstractEvmDexTrade extends dist_1.AbastrcatTrade {
|
|
|
143
150
|
nonce: transfer_nonce,
|
|
144
151
|
chainId: this.chainConfig.chainId
|
|
145
152
|
};
|
|
146
|
-
let signedTx = yield
|
|
153
|
+
let signedTx = yield targetWallet.signTransaction(tx_data);
|
|
147
154
|
(0, dist_1.log_info)(`构建转账交易: `, Object.assign(Object.assign({}, tx_data), { real_transfer_amount_gwei,
|
|
148
155
|
real_gas_price_gwei, txhash: ethers_1.ethers.utils.keccak256(signedTx) }));
|
|
149
156
|
return signedTx;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@clonegod/ttd-bsc-common",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.25",
|
|
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.
|
|
17
|
+
"@clonegod/ttd-core": "2.0.36",
|
|
18
18
|
"axios": "^1.8.4",
|
|
19
19
|
"dotenv": "^16.4.7",
|
|
20
20
|
"ethers": "^5.8.0"
|