@clonegod/ttd-core 2.0.13 → 2.0.15
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.
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { CHAIN_ID, DEX_ID } from "..";
|
|
2
2
|
export declare class EnvArgs {
|
|
3
|
+
app_name: string;
|
|
4
|
+
app_base_dir: string;
|
|
3
5
|
chain_id: CHAIN_ID;
|
|
4
6
|
dex_id: DEX_ID;
|
|
5
|
-
app_base_dir: string;
|
|
6
|
-
app_name: string;
|
|
7
7
|
redis_host: string;
|
|
8
8
|
redis_port: string;
|
|
9
9
|
config_center_host: string;
|
|
@@ -23,4 +23,5 @@ export declare class EnvArgs {
|
|
|
23
23
|
trade_pair: string;
|
|
24
24
|
token_price_cache_seconds: number;
|
|
25
25
|
constructor(chain_id?: CHAIN_ID, dex_id?: DEX_ID);
|
|
26
|
+
print(): void;
|
|
26
27
|
}
|
|
@@ -6,6 +6,7 @@ class EnvArgs {
|
|
|
6
6
|
constructor(chain_id, dex_id) {
|
|
7
7
|
var _a, _b;
|
|
8
8
|
this.app_name = process.env.APP_NAME || '';
|
|
9
|
+
this.app_base_dir = process.env.APP_BASE_DIR || '';
|
|
9
10
|
this.chain_id = chain_id || ((_a = process.env.CHAIN_ID) === null || _a === void 0 ? void 0 : _a.toUpperCase());
|
|
10
11
|
if ((0, __1.isEmpty)(this.chain_id)) {
|
|
11
12
|
throw new Error(`environment: CHAIN_ID is empty!!!`);
|
|
@@ -13,26 +14,27 @@ class EnvArgs {
|
|
|
13
14
|
this.dex_id = dex_id || ((_b = process.env.DEX_ID) === null || _b === void 0 ? void 0 : _b.toUpperCase());
|
|
14
15
|
if ((0, __1.isEmpty)(this.dex_id)) {
|
|
15
16
|
}
|
|
16
|
-
this.
|
|
17
|
-
this.
|
|
18
|
-
this.
|
|
19
|
-
this.
|
|
20
|
-
this.
|
|
21
|
-
this.
|
|
22
|
-
this.
|
|
23
|
-
this.
|
|
24
|
-
this.grpc_token = process.env.GRPC_TOKEN;
|
|
17
|
+
this.redis_host = process.env.REDIS_HOST || '127.0.0.1';
|
|
18
|
+
this.redis_port = process.env.REDIS_PORT || '6379';
|
|
19
|
+
this.config_center_host = process.env.CONFIG_CENTER_HOST || '';
|
|
20
|
+
this.trade_analyze_url = process.env.TRADE_ANALYZE_URL || '';
|
|
21
|
+
this.rpc_endpoint = process.env.RPC_ENDPOINT || '';
|
|
22
|
+
this.ws_endpoint = process.env.WS_ENDPOINT || '';
|
|
23
|
+
this.grpc_endpoint = process.env.GRPC_ENDPOINT || '';
|
|
24
|
+
this.grpc_token = process.env.GRPC_TOKEN || '';
|
|
25
25
|
this.auto_quote_enable = process.env.AUTO_QUOTE_ENABLE === 'true';
|
|
26
26
|
this.auto_quote_interval_mills = parseInt(process.env.AUTO_QUOTE_INTERVAL_MILLS || '60000');
|
|
27
|
-
this.quote_pair = process.env.QUOTE_PAIR;
|
|
27
|
+
this.quote_pair = process.env.QUOTE_PAIR || '';
|
|
28
28
|
this.quote_amount_usd = parseInt(process.env.QUOTE_AMOUNT_USD || '100');
|
|
29
|
-
this.quote_pool_address = process.env.QUOTE_POOL_ADDRESS;
|
|
30
|
-
this.quote_pool_name = process.env.QUOTE_POOL_NAME;
|
|
31
|
-
this.quote_pool_fee_rate = parseInt(process.env.QUOTE_POOL_FEE_RATE || '
|
|
32
|
-
this.trade_group_id = process.env.TRADE_GROUP_ID;
|
|
33
|
-
this.trade_pair = process.env.TRADE_PAIR;
|
|
29
|
+
this.quote_pool_address = process.env.QUOTE_POOL_ADDRESS || '';
|
|
30
|
+
this.quote_pool_name = process.env.QUOTE_POOL_NAME || '';
|
|
31
|
+
this.quote_pool_fee_rate = parseInt(process.env.QUOTE_POOL_FEE_RATE || '0');
|
|
32
|
+
this.trade_group_id = process.env.TRADE_GROUP_ID || '';
|
|
33
|
+
this.trade_pair = process.env.TRADE_PAIR || '';
|
|
34
34
|
this.token_price_cache_seconds = parseInt(process.env.TOKEN_PRICE_CACHE_SECONDS || '600');
|
|
35
|
-
|
|
35
|
+
}
|
|
36
|
+
print() {
|
|
37
|
+
console.log('>>> EnvArgs', this);
|
|
36
38
|
}
|
|
37
39
|
}
|
|
38
40
|
exports.EnvArgs = EnvArgs;
|
package/dist/cache/arb_cache.js
CHANGED
|
@@ -115,7 +115,7 @@ class ArbCache {
|
|
|
115
115
|
}
|
|
116
116
|
refresh_local_cache_group_map(trade_config) {
|
|
117
117
|
let group_id = trade_config.group.id;
|
|
118
|
-
let group_id_set_in_env = process.env.GROUP_ID;
|
|
118
|
+
let group_id_set_in_env = process.env.GROUP_ID || process.env.TRADE_GROUP_ID;
|
|
119
119
|
if (group_id_set_in_env && group_id !== group_id_set_in_env) {
|
|
120
120
|
(0, index_1.log_warn)(`skip set trade group in local cache! group_id not match to current trader process:`, {
|
|
121
121
|
group_id_set_in_env,
|
|
@@ -625,7 +625,6 @@ class ArbCache {
|
|
|
625
625
|
}
|
|
626
626
|
create_trade_runtime(chain_id, group_id, dex_id, pair_name) {
|
|
627
627
|
return __awaiter(this, void 0, void 0, function* () {
|
|
628
|
-
var _a;
|
|
629
628
|
let args = { group_id, dex_id, pair_name };
|
|
630
629
|
if ((0, index_1.isEmpty)(chain_id)) {
|
|
631
630
|
throw new Error(`Check chain_id: failed! chain_id is empty or null!!! check .env file`);
|
|
@@ -642,10 +641,6 @@ class ArbCache {
|
|
|
642
641
|
if ((0, index_1.isEmpty)(dex_id)) {
|
|
643
642
|
throw new Error(`check failed! dex_id is empty or null! \n${(0, index_1.to_json_str)(args)}`);
|
|
644
643
|
}
|
|
645
|
-
let dex_id_list = ((_a = process.env.DEX_ID_LIST) === null || _a === void 0 ? void 0 : _a.split(',')) || [];
|
|
646
|
-
if (!dex_id_list.includes(dex_id)) {
|
|
647
|
-
throw new Error(`check failed! dex_id not support! \n ${(0, index_1.to_json_str)({ dex_id, dex_id_list })}`);
|
|
648
|
-
}
|
|
649
644
|
(0, index_1.log_trace)(`create_trade_runtime, start`, args);
|
|
650
645
|
let wallet = (0, index_1.load_wallet)(group_id, false);
|
|
651
646
|
if ((0, index_1.isEmpty)(wallet.public_key) || (0, index_1.isEmpty)(wallet.private_key)) {
|