@clonegod/ttd-bsc-common 3.0.15 → 3.0.17
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.
|
@@ -22,14 +22,18 @@ const redis_1 = require("../redis");
|
|
|
22
22
|
const trade_direction_1 = require("../utils/trade_direction");
|
|
23
23
|
const decimal_js_1 = __importDefault(require("decimal.js"));
|
|
24
24
|
function buildTradeConfig() {
|
|
25
|
-
const
|
|
26
|
-
if (!
|
|
27
|
-
throw new Error('环境变量
|
|
25
|
+
const vaultGroupId = process.env.TRADE_GROUP_ID;
|
|
26
|
+
if (!vaultGroupId) {
|
|
27
|
+
throw new Error('环境变量 TRADE_GROUP_ID 未配置');
|
|
28
|
+
}
|
|
29
|
+
const vaultWallet = (0, ttd_core_1.load_wallet)(vaultGroupId, true);
|
|
30
|
+
if (!vaultWallet.public_key) {
|
|
31
|
+
throw new Error(`load_wallet(${vaultGroupId}) 未返回 public_key`);
|
|
28
32
|
}
|
|
29
33
|
const pancakeIdName = process.env.PANCAKE_EXECUTOR_ID || 'PANCAKE';
|
|
30
34
|
const uniswapIdName = process.env.UNISWAP_EXECUTOR_ID || 'UNISWAP';
|
|
31
35
|
return {
|
|
32
|
-
vaultAddress,
|
|
36
|
+
vaultAddress: vaultWallet.public_key,
|
|
33
37
|
executorIds: {
|
|
34
38
|
pancake: ethers_1.ethers.utils.id(pancakeIdName),
|
|
35
39
|
uniswap: ethers_1.ethers.utils.id(uniswapIdName),
|
|
@@ -44,9 +44,12 @@ class TradeResultSubscriber {
|
|
|
44
44
|
this.ws = new ttd_core_1.WebSocketClient(wsUrl);
|
|
45
45
|
this.ws.onOpen(() => {
|
|
46
46
|
this.connected = true;
|
|
47
|
-
const
|
|
48
|
-
for (const
|
|
49
|
-
|
|
47
|
+
const groupIds = (process.env.TRADE_GROUP_ID || '').split(',').map(s => s.trim()).filter(Boolean);
|
|
48
|
+
for (const gid of groupIds) {
|
|
49
|
+
const w = (0, ttd_core_1.load_wallet)(gid, true);
|
|
50
|
+
if (w.public_key) {
|
|
51
|
+
this.ws.send(JSON.stringify({ address: w.public_key }));
|
|
52
|
+
}
|
|
50
53
|
}
|
|
51
54
|
(0, ttd_core_1.log_info)(`TradeResultSubscriber connected: ${wsUrl}`);
|
|
52
55
|
});
|