@clonegod/ttd-bsc-common 3.0.28 → 3.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.
|
@@ -28,6 +28,7 @@ export declare abstract class AbstractDexTrade extends AbastrcatTrade {
|
|
|
28
28
|
abstract encodeTradeData(context: TradeContext): TradeCalldata;
|
|
29
29
|
init(transactionSender?: ITransactionSender): Promise<void>;
|
|
30
30
|
execute(context: TradeContext): Promise<string>;
|
|
31
|
+
private scanCallerFiles;
|
|
31
32
|
protected getGasPriceGwei(context: TradeContext): string;
|
|
32
33
|
protected getBuilderTipAmoutGwei(context: TradeContext): string;
|
|
33
34
|
protected buildTipTransferTx(to: string, transfer_amount_gwei: string, gas_price_gwei: string, nonce: number, wallet: ethers.Wallet): Promise<string>;
|
|
@@ -1,4 +1,37 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
2
35
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
36
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
37
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -15,6 +48,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
15
48
|
exports.AbstractDexTrade = void 0;
|
|
16
49
|
exports.buildTradeConfig = buildTradeConfig;
|
|
17
50
|
const ttd_core_1 = require("@clonegod/ttd-core");
|
|
51
|
+
const fs = __importStar(require("fs"));
|
|
52
|
+
const path = __importStar(require("path"));
|
|
18
53
|
const caller_manager_1 = require("./caller_manager");
|
|
19
54
|
const send_tx_1 = require("../send-tx");
|
|
20
55
|
const base_tx_result_checker_1 = require("./check/base_tx_result_checker");
|
|
@@ -55,12 +90,19 @@ class AbstractDexTrade extends ttd_core_1.AbastrcatTrade {
|
|
|
55
90
|
}
|
|
56
91
|
init(transactionSender) {
|
|
57
92
|
return __awaiter(this, void 0, void 0, function* () {
|
|
93
|
+
var _a, _b;
|
|
58
94
|
this.provider = new ethers_compat_1.ethersCompat.JsonRpcProvider(this.chainConfig.rpcEndpoint);
|
|
59
95
|
if (transactionSender) {
|
|
60
96
|
this.transactionSender = transactionSender;
|
|
61
97
|
}
|
|
62
|
-
const
|
|
63
|
-
|
|
98
|
+
const groupId = (_b = (_a = this.appConfig.trade_runtime) === null || _a === void 0 ? void 0 : _a.group) === null || _b === void 0 ? void 0 : _b.id;
|
|
99
|
+
if (!groupId) {
|
|
100
|
+
throw new Error('trade_runtime.group.id 未初始化,请确保 init_trade_runtime() 已调用');
|
|
101
|
+
}
|
|
102
|
+
const callerGroupIds = this.scanCallerFiles(groupId);
|
|
103
|
+
if (callerGroupIds.length === 0) {
|
|
104
|
+
throw new Error(`未找到分组 ${groupId} 的 Caller 钱包文件(${groupId}-CALLER-*.json)`);
|
|
105
|
+
}
|
|
64
106
|
this.callerManager = new caller_manager_1.CallerManager({
|
|
65
107
|
chainName: this.chainNameLower,
|
|
66
108
|
provider: this.provider,
|
|
@@ -184,6 +226,14 @@ class AbstractDexTrade extends ttd_core_1.AbastrcatTrade {
|
|
|
184
226
|
return txid;
|
|
185
227
|
});
|
|
186
228
|
}
|
|
229
|
+
scanCallerFiles(groupId) {
|
|
230
|
+
const walletDir = process.env.WALLET_DIR || path.join((0, ttd_core_1.home_dir)(), 'data', 'keypairs');
|
|
231
|
+
const prefix = `${groupId}-CALLER-`;
|
|
232
|
+
const files = fs.readdirSync(walletDir)
|
|
233
|
+
.filter(f => f.startsWith(prefix) && f.endsWith('.json'))
|
|
234
|
+
.sort();
|
|
235
|
+
return files.map(f => f.replace('.json', ''));
|
|
236
|
+
}
|
|
187
237
|
getGasPriceGwei(context) {
|
|
188
238
|
let { evm_gas_price_gwei } = context.trade_runtime.settings.strategy;
|
|
189
239
|
if (!evm_gas_price_gwei || evm_gas_price_gwei <= 0) {
|