@icgio/clients-config 1.0.288 → 1.0.290
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.
- package/.gitsecret/keys/crls.d/DIR.txt +1 -1
- package/.gitsecret/paths/mapping.cfg +1 -1
- package/config.js +167 -18
- package/config.json +22 -0
- package/data-source.js.secret +0 -0
- package/index.js +18 -18
- package/package.json +27 -27
- package/secretread.js.secret +0 -0
- package/update-config-json.js +278 -278
|
@@ -1 +1 @@
|
|
|
1
|
-
v:1:
|
|
1
|
+
v:1:
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
secretread.js:
|
|
1
|
+
secretread.js:cca1c79388d5f4f5f718a32f52654e3c1bc9f4389f7d0e66a52a3c3f2e097ee7
|
|
2
2
|
data-source.js:440e328f62856d665e4b66a66f55406e0c9f3a974d2be3c000041fd1c552652b
|
package/config.js
CHANGED
|
@@ -1,23 +1,86 @@
|
|
|
1
1
|
const _ = require('lodash')
|
|
2
2
|
const config_data = require('./config.json')
|
|
3
3
|
|
|
4
|
+
/*
|
|
5
|
+
{
|
|
6
|
+
"JYAI": {
|
|
7
|
+
"Mexc": ["JYAIUSDT"],
|
|
8
|
+
"Bitmart": ["JYAIUSDC", "JYAIUSDT"]
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
*/
|
|
4
12
|
const client_exchange_pairs = config_data.client_exchange_pairs
|
|
5
13
|
module.exports.client_exchange_pairs = client_exchange_pairs
|
|
6
14
|
|
|
15
|
+
/*
|
|
16
|
+
{
|
|
17
|
+
"ARMY": [],
|
|
18
|
+
"JYAI": []
|
|
19
|
+
}
|
|
20
|
+
*/
|
|
7
21
|
const client_not_include_exchanges = config_data.client_not_include_exchanges
|
|
8
22
|
module.exports.client_not_include_exchanges = client_not_include_exchanges
|
|
9
23
|
|
|
24
|
+
/*
|
|
25
|
+
{
|
|
26
|
+
"JYAI": {
|
|
27
|
+
"JYAIUSDT": ["Mexc"],
|
|
28
|
+
"JYAIUSDC": ["Bitmart", "Xt"]
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
*/
|
|
10
32
|
const client_pair_main_exchanges = config_data.client_pair_main_exchanges
|
|
11
33
|
module.exports.client_pair_main_exchanges = client_pair_main_exchanges
|
|
12
34
|
|
|
35
|
+
/*
|
|
36
|
+
{
|
|
37
|
+
"JYAIUSDT": Set(["Mexc"]),
|
|
38
|
+
"OPULUSDT": Set(["Gate", "Kucoin"])
|
|
39
|
+
}
|
|
40
|
+
*/
|
|
41
|
+
const pair_main_exchanges_map = {}
|
|
42
|
+
for (const client in client_pair_main_exchanges) {
|
|
43
|
+
for (const pair in client_pair_main_exchanges[client]) {
|
|
44
|
+
if (!pair_main_exchanges_map[pair]) pair_main_exchanges_map[pair] = new Set()
|
|
45
|
+
client_pair_main_exchanges[client][pair].forEach((ex) => pair_main_exchanges_map[pair].add(ex))
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
module.exports.pair_main_exchanges_map = pair_main_exchanges_map
|
|
49
|
+
|
|
50
|
+
/*
|
|
51
|
+
Set(["Mexc", "Gate", "Kucoin", "Bitmart", ...])
|
|
52
|
+
*/
|
|
53
|
+
const all_main_exchanges = new Set()
|
|
54
|
+
for (const pair in pair_main_exchanges_map) {
|
|
55
|
+
pair_main_exchanges_map[pair].forEach((ex) => all_main_exchanges.add(ex))
|
|
56
|
+
}
|
|
57
|
+
module.exports.all_main_exchanges = all_main_exchanges
|
|
58
|
+
|
|
59
|
+
/*
|
|
60
|
+
["BTC", "ETH", "BNB", "USD", "USDC", "USDT", "HKD", "KRW", "THB"]
|
|
61
|
+
*/
|
|
62
|
+
const forex_rate_currencies = ['BTC', 'ETH', 'BNB', 'USD', 'USDC', 'USDT', 'HKD', 'KRW', 'THB']
|
|
63
|
+
module.exports.forex_rate_currencies = forex_rate_currencies
|
|
64
|
+
|
|
65
|
+
// Build regex pattern from forex_rate_currencies (sorted by length desc to match longer first)
|
|
66
|
+
const quotePattern = [...forex_rate_currencies].sort((a, b) => b.length - a.length).join('|')
|
|
67
|
+
const pairRegex = new RegExp(`^([A-Z0-9]+?)(${quotePattern})$`)
|
|
68
|
+
|
|
69
|
+
/*
|
|
70
|
+
{
|
|
71
|
+
"JYAI": {
|
|
72
|
+
"Mexc": ["JYAI", "USDT"],
|
|
73
|
+
"Bitmart": ["JYAI", "USDC", "USDT"]
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
*/
|
|
13
77
|
let client_exchange_currencies = {}
|
|
14
78
|
for (let client in client_exchange_pairs) {
|
|
15
79
|
for (let exchange in client_exchange_pairs[client]) {
|
|
16
80
|
const pairs = client_exchange_pairs[client][exchange]
|
|
17
|
-
|
|
18
81
|
const currencies = new Set()
|
|
19
82
|
pairs.forEach((pair) => {
|
|
20
|
-
let match = pair.match(
|
|
83
|
+
let match = pair.match(pairRegex)
|
|
21
84
|
if (match) {
|
|
22
85
|
currencies.add(match[1])
|
|
23
86
|
currencies.add(match[2])
|
|
@@ -25,9 +88,7 @@ for (let client in client_exchange_pairs) {
|
|
|
25
88
|
currencies.add(pair.replace(client, ''))
|
|
26
89
|
}
|
|
27
90
|
})
|
|
28
|
-
|
|
29
91
|
currencies.add(client)
|
|
30
|
-
|
|
31
92
|
_.set(client_exchange_currencies, [client, exchange], Array.from(currencies))
|
|
32
93
|
}
|
|
33
94
|
}
|
|
@@ -35,8 +96,9 @@ module.exports.client_exchange_currencies = client_exchange_currencies
|
|
|
35
96
|
|
|
36
97
|
/*
|
|
37
98
|
{
|
|
38
|
-
|
|
39
|
-
|
|
99
|
+
"JYAI": {
|
|
100
|
+
"JYAIUSDT": ["Biconomy", "Bingx", "Bitmart", "Lbank", "Mexc", "Xt"]
|
|
101
|
+
}
|
|
40
102
|
}
|
|
41
103
|
*/
|
|
42
104
|
let client_pair_exchanges = {}
|
|
@@ -54,8 +116,8 @@ module.exports.client_pair_exchanges = client_pair_exchanges
|
|
|
54
116
|
|
|
55
117
|
/*
|
|
56
118
|
{
|
|
57
|
-
|
|
58
|
-
|
|
119
|
+
"Mexc": ["ARMYUSDT", "B3TRUSDT", "JYAIUSDT"],
|
|
120
|
+
"Gate": ["OPULUSDT", "SWFTCUSDT"]
|
|
59
121
|
}
|
|
60
122
|
*/
|
|
61
123
|
let exchange_pairs = {}
|
|
@@ -64,68 +126,155 @@ module.exports.exchange_pairs = exchange_pairs
|
|
|
64
126
|
|
|
65
127
|
/*
|
|
66
128
|
{
|
|
67
|
-
|
|
68
|
-
|
|
129
|
+
"JYAI": ["JYAIBTC", "JYAIUSDC", "JYAIUSDT"],
|
|
130
|
+
"OPUL": ["OPULUSDT"]
|
|
69
131
|
}
|
|
70
132
|
*/
|
|
71
133
|
module.exports.client_pairs = _.fromPairs(Object.keys(client_exchange_pairs).map((cur) => [cur, _.union(..._.values(client_exchange_pairs[cur]))]))
|
|
72
134
|
|
|
73
135
|
/*
|
|
74
136
|
{
|
|
75
|
-
|
|
76
|
-
|
|
137
|
+
"JYAI": ["Biconomy", "Bingx", "Bitmart", "Lbank", "Mexc", "Xt"],
|
|
138
|
+
"OPUL": ["Ascendex", "Gate", "Kucoin"]
|
|
77
139
|
}
|
|
78
140
|
*/
|
|
79
141
|
module.exports.client_exchanges = _.fromPairs(Object.keys(client_exchange_pairs).map((cur) => [cur, _.keys(client_exchange_pairs[cur])]))
|
|
80
142
|
|
|
81
143
|
/*
|
|
82
144
|
{
|
|
83
|
-
|
|
84
|
-
|
|
145
|
+
"JYAI": ["JYAI", "BTC", "ETH", "BNB", "USD", "USDC", "USDT", "HKD", "KRW", "THB"],
|
|
146
|
+
"HKBITEX-BTC": ["HKBITEX", "BTC", "ETH", "BNB", "USD", "USDC", "USDT", "HKD", "KRW", "THB"]
|
|
85
147
|
}
|
|
86
148
|
*/
|
|
87
|
-
// Currencies that use forex rate directly (not from orderbook pairs)
|
|
88
|
-
const forex_rate_currencies = ['BTC', 'ETH', 'BNB', 'USD', 'USDC', 'USDT', 'HKD', 'KRW', 'THB']
|
|
89
|
-
module.exports.forex_rate_currencies = forex_rate_currencies
|
|
90
|
-
|
|
91
149
|
module.exports.client_currencies_with_stables = _.fromPairs(_.keys(client_exchange_pairs).map((cur) => [cur, _.uniq([..._.split(cur, '-'), ...forex_rate_currencies])]))
|
|
92
150
|
|
|
151
|
+
/*
|
|
152
|
+
{
|
|
153
|
+
"JYAI": {
|
|
154
|
+
"balance": 1,
|
|
155
|
+
"trades": 1,
|
|
156
|
+
"orderbook": 1,
|
|
157
|
+
"deposits_withdrawals": 1
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
*/
|
|
93
161
|
const clients_reporter_interval = config_data.clients_reporter_interval
|
|
94
162
|
module.exports.clients_reporter_interval = clients_reporter_interval
|
|
95
163
|
|
|
164
|
+
/*
|
|
165
|
+
{
|
|
166
|
+
"SWFTC": {
|
|
167
|
+
"coinbase_1": {
|
|
168
|
+
"SWFTC": 5000000,
|
|
169
|
+
"USDC": 15000
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
*/
|
|
96
174
|
const balance_premium = config_data.balance_premium
|
|
97
175
|
module.exports.balance_premium = balance_premium
|
|
98
176
|
|
|
177
|
+
/*
|
|
178
|
+
{
|
|
179
|
+
"balance": { "JYAI": true, "OPUL": true },
|
|
180
|
+
"trades": { "JYAI": true, "OPUL": true },
|
|
181
|
+
"deposits_withdrawals": { "JYAI": true }
|
|
182
|
+
}
|
|
183
|
+
*/
|
|
99
184
|
const client_enabled = config_data.client_enabled
|
|
100
185
|
module.exports.client_enabled = client_enabled
|
|
101
186
|
|
|
187
|
+
/*
|
|
188
|
+
{
|
|
189
|
+
"JYAI": [1, 2, 5, 10, 20, 50, 100],
|
|
190
|
+
"OPUL": [1, 2, 5, 10, 20, 50, 100]
|
|
191
|
+
}
|
|
192
|
+
*/
|
|
102
193
|
const client_levels = config_data.client_levels
|
|
103
194
|
module.exports.client_levels = client_levels
|
|
104
195
|
|
|
196
|
+
/*
|
|
197
|
+
{
|
|
198
|
+
"JYAI": ["BTC", "ETH"],
|
|
199
|
+
"OPUL": ["BTC", "ETH"]
|
|
200
|
+
}
|
|
201
|
+
*/
|
|
105
202
|
const client_price_index_curs = config_data.client_price_index_curs
|
|
106
203
|
module.exports.client_price_index_curs = client_price_index_curs
|
|
107
204
|
|
|
205
|
+
/*
|
|
206
|
+
{
|
|
207
|
+
"JYAI": "-4787448589",
|
|
208
|
+
"OPUL": "-4581926908"
|
|
209
|
+
}
|
|
210
|
+
*/
|
|
108
211
|
const client_telegram_ids = config_data.client_telegram_ids
|
|
109
212
|
module.exports.client_telegram_ids = client_telegram_ids
|
|
213
|
+
|
|
214
|
+
/*
|
|
215
|
+
{
|
|
216
|
+
"-4787448589": ["JYAI"],
|
|
217
|
+
"-4581926908": ["OPUL"]
|
|
218
|
+
}
|
|
219
|
+
*/
|
|
110
220
|
module.exports.telegram_id_clients = _.invertBy(client_telegram_ids)
|
|
111
221
|
|
|
222
|
+
/*
|
|
223
|
+
{
|
|
224
|
+
"JYAI": ["987654321", "111222333"]
|
|
225
|
+
}
|
|
226
|
+
*/
|
|
112
227
|
const client_additional_telegram_ids = config_data.client_additional_telegram_ids
|
|
113
228
|
module.exports.client_additional_telegram_ids = client_additional_telegram_ids
|
|
114
229
|
|
|
230
|
+
/*
|
|
231
|
+
{
|
|
232
|
+
"JYAI": "icg",
|
|
233
|
+
"OPUL": "icg"
|
|
234
|
+
}
|
|
235
|
+
*/
|
|
115
236
|
const client_telegram_sender = config_data.client_telegram_sender
|
|
116
237
|
module.exports.client_telegram_sender = client_telegram_sender
|
|
117
238
|
|
|
239
|
+
/*
|
|
240
|
+
{
|
|
241
|
+
"JYAI": { "username": "jyai@icg.io" },
|
|
242
|
+
"ADMIN": { "username": "admin@icg.io" }
|
|
243
|
+
}
|
|
244
|
+
*/
|
|
118
245
|
const dashboard_users = config_data.dashboard_users
|
|
119
246
|
module.exports.dashboard_users = dashboard_users
|
|
120
247
|
|
|
248
|
+
/*
|
|
249
|
+
{
|
|
250
|
+
"JYAI": "https://api.geckoterminal.com/api/v2/networks/eth/pools/0x2623edc6008d057786a6bf9dd34185dcddebbf2f"
|
|
251
|
+
}
|
|
252
|
+
*/
|
|
121
253
|
const dex_pool_links = config_data.dex_pool_links
|
|
122
254
|
module.exports.dex_pool_links = dex_pool_links
|
|
123
255
|
|
|
256
|
+
/*
|
|
257
|
+
{
|
|
258
|
+
"FREEZONE": true,
|
|
259
|
+
"HKBITEX-BTC": true
|
|
260
|
+
}
|
|
261
|
+
*/
|
|
124
262
|
const server_config_enabled = config_data.server_config_enabled
|
|
125
263
|
module.exports.server_config_enabled = server_config_enabled
|
|
126
264
|
|
|
265
|
+
/*
|
|
266
|
+
{
|
|
267
|
+
"JYAI": ["192.168.1.1", "10.0.0.1"]
|
|
268
|
+
}
|
|
269
|
+
*/
|
|
127
270
|
const server_config_whitelist_ips = config_data.server_config_whitelist_ips
|
|
128
271
|
module.exports.server_config_whitelist_ips = server_config_whitelist_ips
|
|
129
272
|
|
|
273
|
+
/*
|
|
274
|
+
{
|
|
275
|
+
"JYAI": ["172.105.237.102", "139.162.123.194"],
|
|
276
|
+
"OPUL": ["172.105.237.102", "172.104.127.200"]
|
|
277
|
+
}
|
|
278
|
+
*/
|
|
130
279
|
const server_config_admin_whitelist_ips = config_data.server_config_admin_whitelist_ips
|
|
131
280
|
module.exports.server_config_admin_whitelist_ips = server_config_admin_whitelist_ips
|
package/config.json
CHANGED
|
@@ -59,6 +59,9 @@
|
|
|
59
59
|
"SHRAP": {
|
|
60
60
|
"Lbank": ["SHRAPUSDT"]
|
|
61
61
|
},
|
|
62
|
+
"SWAGG": {
|
|
63
|
+
"Biconomy": ["SWAGGUSDT"]
|
|
64
|
+
},
|
|
62
65
|
"SWFTC": {
|
|
63
66
|
"Gate": ["SWFTCUSDT"],
|
|
64
67
|
"Htx": ["SWFTCUSDT"],
|
|
@@ -84,6 +87,7 @@
|
|
|
84
87
|
"OPUL": [],
|
|
85
88
|
"SARA": [],
|
|
86
89
|
"SHRAP": [],
|
|
90
|
+
"SWAGG": [],
|
|
87
91
|
"SWFTC": [],
|
|
88
92
|
"SWFTC-COINBASE": []
|
|
89
93
|
},
|
|
@@ -135,6 +139,9 @@
|
|
|
135
139
|
"SHRAP": {
|
|
136
140
|
"SHRAPUSDT": ["Lbank"]
|
|
137
141
|
},
|
|
142
|
+
"SWAGG": {
|
|
143
|
+
"SWAGGUSDT": ["Biconomy"]
|
|
144
|
+
},
|
|
138
145
|
"SWFTC": {
|
|
139
146
|
"SWFTCUSDT": ["Okx"]
|
|
140
147
|
},
|
|
@@ -227,6 +234,12 @@
|
|
|
227
234
|
"orderbook": 1,
|
|
228
235
|
"deposits_withdrawals": 1
|
|
229
236
|
},
|
|
237
|
+
"SWAGG": {
|
|
238
|
+
"balance": 1,
|
|
239
|
+
"trades": 1,
|
|
240
|
+
"orderbook": 1,
|
|
241
|
+
"deposits_withdrawals": 1
|
|
242
|
+
},
|
|
230
243
|
"SWFTC": {
|
|
231
244
|
"balance": 1,
|
|
232
245
|
"trades": 1,
|
|
@@ -256,6 +269,7 @@
|
|
|
256
269
|
"OPUL": true,
|
|
257
270
|
"SARA": true,
|
|
258
271
|
"SHRAP": true,
|
|
272
|
+
"SWAGG": true,
|
|
259
273
|
"SWFTC": true,
|
|
260
274
|
"SWFTC-COINBASE": true
|
|
261
275
|
},
|
|
@@ -275,6 +289,7 @@
|
|
|
275
289
|
"OPUL": true,
|
|
276
290
|
"SARA": true,
|
|
277
291
|
"SHRAP": true,
|
|
292
|
+
"SWAGG": true,
|
|
278
293
|
"SWFTC": true,
|
|
279
294
|
"SWFTC-COINBASE": true
|
|
280
295
|
},
|
|
@@ -297,6 +312,7 @@
|
|
|
297
312
|
"OPUL": true,
|
|
298
313
|
"SARA": true,
|
|
299
314
|
"SHRAP": true,
|
|
315
|
+
"SWAGG": true,
|
|
300
316
|
"SWFTC": true,
|
|
301
317
|
"SWFTC-COINBASE": true
|
|
302
318
|
},
|
|
@@ -317,6 +333,7 @@
|
|
|
317
333
|
"OPUL": [1, 2, 5, 10, 20, 50, 100],
|
|
318
334
|
"SARA": [1, 2, 5, 10, 20, 50, 100],
|
|
319
335
|
"SHRAP": [1, 2, 5, 10, 20, 50, 100],
|
|
336
|
+
"SWAGG": [1, 2, 5, 10, 20, 50, 100],
|
|
320
337
|
"SWFTC": [1, 2, 5, 10, 20, 50, 100],
|
|
321
338
|
"SWFTC-COINBASE": [1, 2, 5, 10, 20, 50, 100]
|
|
322
339
|
},
|
|
@@ -335,6 +352,7 @@
|
|
|
335
352
|
"OPUL": ["BTC", "ETH"],
|
|
336
353
|
"SARA": ["BTC", "ETH"],
|
|
337
354
|
"SHRAP": ["BTC", "ETH"],
|
|
355
|
+
"SWAGG": ["BTC", "ETH"],
|
|
338
356
|
"SWFTC": ["BTC", "ETH"],
|
|
339
357
|
"SWFTC-COINBASE": ["BTC", "ETH"]
|
|
340
358
|
},
|
|
@@ -353,6 +371,7 @@
|
|
|
353
371
|
"OPUL": "-4581926908",
|
|
354
372
|
"SARA": "-4660700305",
|
|
355
373
|
"SHRAP": "-1001996867582",
|
|
374
|
+
"SWAGG": "-5249219564",
|
|
356
375
|
"SWFTC": "-1002067948127",
|
|
357
376
|
"SWFTC-COINBASE": "-1002067948127"
|
|
358
377
|
},
|
|
@@ -386,6 +405,7 @@
|
|
|
386
405
|
"OPUL": "icg",
|
|
387
406
|
"SARA": "icg",
|
|
388
407
|
"SHRAP": "icg",
|
|
408
|
+
"SWAGG": "icg",
|
|
389
409
|
"SWFTC": "icg",
|
|
390
410
|
"SWFTC-COINBASE": "icg"
|
|
391
411
|
},
|
|
@@ -406,6 +426,7 @@
|
|
|
406
426
|
"SARA": { "username": "sara@icg.io" },
|
|
407
427
|
"SHRAP": { "username": "shrap@icg.io" },
|
|
408
428
|
"SUPERADMIN": { "username": "superadmin@icg.io" },
|
|
429
|
+
"SWAGG": { "username": "swagg@icg.io" },
|
|
409
430
|
"SWFTC": { "username": "swftc@icg.io" },
|
|
410
431
|
"SWFTC-COINBASE": { "username": "swftc-coinbase@icg.io" }
|
|
411
432
|
},
|
|
@@ -440,6 +461,7 @@
|
|
|
440
461
|
"OPUL": ["172.105.237.102", "172.104.127.200"],
|
|
441
462
|
"SARA": ["172.105.237.102", "139.162.86.213"],
|
|
442
463
|
"SHRAP": ["172.105.237.102", "172.105.226.67"],
|
|
464
|
+
"SWAGG": ["172.105.237.102", "172.104.97.165", "172.105.209.170"],
|
|
443
465
|
"SWFTC": ["172.105.237.102", "172.105.208.166"],
|
|
444
466
|
"SWFTC-COINBASE": ["172.105.237.102", "18.207.216.57"]
|
|
445
467
|
}
|
package/data-source.js.secret
CHANGED
|
Binary file
|
package/index.js
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
function safe_require(path) {
|
|
2
|
-
try {
|
|
3
|
-
return require(path)
|
|
4
|
-
} catch (error) {
|
|
5
|
-
if (error.code === 'MODULE_NOT_FOUND') {
|
|
6
|
-
return {}
|
|
7
|
-
} else {
|
|
8
|
-
throw error
|
|
9
|
-
}
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
module.exports = {
|
|
14
|
-
config: safe_require('./config.js'),
|
|
15
|
-
secretread: safe_require('./secretread.js').secret,
|
|
16
|
-
secretread_shared: safe_require('./secretread.js').shared,
|
|
17
|
-
'data-source': safe_require('./data-source.js'),
|
|
18
|
-
}
|
|
1
|
+
function safe_require(path) {
|
|
2
|
+
try {
|
|
3
|
+
return require(path)
|
|
4
|
+
} catch (error) {
|
|
5
|
+
if (error.code === 'MODULE_NOT_FOUND') {
|
|
6
|
+
return {}
|
|
7
|
+
} else {
|
|
8
|
+
throw error
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
module.exports = {
|
|
14
|
+
config: safe_require('./config.js'),
|
|
15
|
+
secretread: safe_require('./secretread.js').secret,
|
|
16
|
+
secretread_shared: safe_require('./secretread.js').shared,
|
|
17
|
+
'data-source': safe_require('./data-source.js'),
|
|
18
|
+
}
|
package/package.json
CHANGED
|
@@ -1,27 +1,27 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@icgio/clients-config",
|
|
3
|
-
"version": "1.0.
|
|
4
|
-
"description": "",
|
|
5
|
-
"main": "index.js",
|
|
6
|
-
"scripts": {
|
|
7
|
-
"test": "echo \"Error: no test specified\" && exit 1"
|
|
8
|
-
},
|
|
9
|
-
"repository": {
|
|
10
|
-
"type": "git",
|
|
11
|
-
"url": "git+https://github.com/icgio/clients-config.git"
|
|
12
|
-
},
|
|
13
|
-
"author": "",
|
|
14
|
-
"license": "ISC",
|
|
15
|
-
"bugs": {
|
|
16
|
-
"url": "https://github.com/icgio/clients-config/issues"
|
|
17
|
-
},
|
|
18
|
-
"homepage": "https://github.com/icgio/clients-config#readme",
|
|
19
|
-
"dependencies": {
|
|
20
|
-
"lodash": "^4.17.20"
|
|
21
|
-
},
|
|
22
|
-
"devDependencies": {
|
|
23
|
-
"fs-extra": "^11.2.0",
|
|
24
|
-
"node-cmd": "^5.0.0",
|
|
25
|
-
"prompt": "^1.3.0"
|
|
26
|
-
}
|
|
27
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@icgio/clients-config",
|
|
3
|
+
"version": "1.0.290",
|
|
4
|
+
"description": "",
|
|
5
|
+
"main": "index.js",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"test": "echo \"Error: no test specified\" && exit 1"
|
|
8
|
+
},
|
|
9
|
+
"repository": {
|
|
10
|
+
"type": "git",
|
|
11
|
+
"url": "git+https://github.com/icgio/clients-config.git"
|
|
12
|
+
},
|
|
13
|
+
"author": "",
|
|
14
|
+
"license": "ISC",
|
|
15
|
+
"bugs": {
|
|
16
|
+
"url": "https://github.com/icgio/clients-config/issues"
|
|
17
|
+
},
|
|
18
|
+
"homepage": "https://github.com/icgio/clients-config#readme",
|
|
19
|
+
"dependencies": {
|
|
20
|
+
"lodash": "^4.17.20"
|
|
21
|
+
},
|
|
22
|
+
"devDependencies": {
|
|
23
|
+
"fs-extra": "^11.2.0",
|
|
24
|
+
"node-cmd": "^5.0.0",
|
|
25
|
+
"prompt": "^1.3.0"
|
|
26
|
+
}
|
|
27
|
+
}
|
package/secretread.js.secret
CHANGED
|
Binary file
|
package/update-config-json.js
CHANGED
|
@@ -1,278 +1,278 @@
|
|
|
1
|
-
const fs = require('fs')
|
|
2
|
-
const prompt = require('prompt')
|
|
3
|
-
|
|
4
|
-
const config_file_path = './config.json'
|
|
5
|
-
const config_archive_file_path = './config-archive.json'
|
|
6
|
-
|
|
7
|
-
prompt.start()
|
|
8
|
-
|
|
9
|
-
function read_config_file(path) {
|
|
10
|
-
return new Promise((resolve, reject) => {
|
|
11
|
-
fs.readFile(path, 'utf8', (err, data) => {
|
|
12
|
-
if (err) reject(err)
|
|
13
|
-
else resolve(data)
|
|
14
|
-
})
|
|
15
|
-
})
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
function write_config_file(data, path) {
|
|
19
|
-
return new Promise((resolve, reject) => {
|
|
20
|
-
fs.writeFile(path, JSON.stringify(data, null, 2), 'utf8', (err) => {
|
|
21
|
-
if (err) return reject(err)
|
|
22
|
-
else resolve()
|
|
23
|
-
})
|
|
24
|
-
})
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
function process_config() {
|
|
28
|
-
try {
|
|
29
|
-
const schema = {
|
|
30
|
-
properties: {
|
|
31
|
-
action: {
|
|
32
|
-
description: 'Enter the action ( add, delete )',
|
|
33
|
-
pattern: /^(add|delete)$/,
|
|
34
|
-
message: 'Action must be one of "add", "delete"',
|
|
35
|
-
required: true,
|
|
36
|
-
},
|
|
37
|
-
client_name: {
|
|
38
|
-
description: 'Enter the client name you want to perform the action on',
|
|
39
|
-
required: true,
|
|
40
|
-
},
|
|
41
|
-
},
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
prompt.get(schema, (err, result) => {
|
|
45
|
-
if (err) {
|
|
46
|
-
console.error(err)
|
|
47
|
-
return
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
switch (result.action) {
|
|
51
|
-
case 'add':
|
|
52
|
-
add_client(result.client_name)
|
|
53
|
-
break
|
|
54
|
-
case 'delete':
|
|
55
|
-
delete_client(result.client_name)
|
|
56
|
-
break
|
|
57
|
-
default:
|
|
58
|
-
console.log('Invalid action')
|
|
59
|
-
break
|
|
60
|
-
}
|
|
61
|
-
})
|
|
62
|
-
} catch (error) {
|
|
63
|
-
console.error(`Error processing the config file: ${error}`)
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
function delete_client(client_name) {
|
|
68
|
-
read_config_file(config_file_path)
|
|
69
|
-
.then((config_file_data) => {
|
|
70
|
-
config_file_data = JSON.parse(config_file_data)
|
|
71
|
-
|
|
72
|
-
update_config_archive(config_file_data, client_name)
|
|
73
|
-
.then(() => {
|
|
74
|
-
delete config_file_data.client_exchange_pairs[client_name]
|
|
75
|
-
delete config_file_data.client_pair_main_exchanges[client_name]
|
|
76
|
-
delete config_file_data.client_not_include_exchanges[client_name]
|
|
77
|
-
delete config_file_data.client_levels[client_name]
|
|
78
|
-
delete config_file_data.client_price_index_curs[client_name]
|
|
79
|
-
delete config_file_data.client_telegram_ids[client_name]
|
|
80
|
-
delete config_file_data.clients_reporter_interval[client_name]
|
|
81
|
-
|
|
82
|
-
for (let key in config_file_data.client_enabled) {
|
|
83
|
-
if (config_file_data.client_enabled.hasOwnProperty(key)) {
|
|
84
|
-
delete config_file_data.client_enabled[key][client_name]
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
write_config_file(config_file_data, config_file_path)
|
|
89
|
-
.then(() => {
|
|
90
|
-
console.log(`Client '${client_name}' has been deleted successfully.`)
|
|
91
|
-
})
|
|
92
|
-
.catch((err) => {
|
|
93
|
-
console.error(`Error writing to config file: ${err}`)
|
|
94
|
-
})
|
|
95
|
-
})
|
|
96
|
-
.catch((err) => {
|
|
97
|
-
console.error(`Error updating config archive: ${err}`)
|
|
98
|
-
})
|
|
99
|
-
})
|
|
100
|
-
.catch((err) => {
|
|
101
|
-
console.error(`Error reading config file: ${err}`)
|
|
102
|
-
})
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
function add_client(client_name) {
|
|
106
|
-
const schema = {
|
|
107
|
-
properties: {
|
|
108
|
-
client_exchange_pairs: {
|
|
109
|
-
description: 'Enter client exchange pairs (JSON format i.e { "Mexc": ["RWXUSDT"], "Bitget": ["RWXUSDT"] } )',
|
|
110
|
-
required: true,
|
|
111
|
-
pattern: /^\{.*\}$/,
|
|
112
|
-
message: 'Please enter a valid JSON object.',
|
|
113
|
-
},
|
|
114
|
-
client_not_include_exchanges: {
|
|
115
|
-
description: 'Enter client not include exchanges (Comma-separated values, e.g., Jubi, Lbank)',
|
|
116
|
-
required: false,
|
|
117
|
-
},
|
|
118
|
-
client_pair_main_exchanges: {
|
|
119
|
-
description: 'Enter client pair main exchanges (JSON format i.e {"ETHUSDT": ["Bitget", "Gate"]} )',
|
|
120
|
-
required: true,
|
|
121
|
-
pattern: /^\{.*\}$/,
|
|
122
|
-
message: 'Please enter a valid JSON object.',
|
|
123
|
-
},
|
|
124
|
-
clients_reporter_interval: {
|
|
125
|
-
description: 'Enter clients reporter interval (JSON format i.e { "balance": 1, "trades": 1, "orderbook": 1} )',
|
|
126
|
-
required: true,
|
|
127
|
-
pattern: /^\{.*\}$/,
|
|
128
|
-
message: 'Please enter a valid JSON object.',
|
|
129
|
-
},
|
|
130
|
-
client_levels: {
|
|
131
|
-
description: 'Enter client levels (Comma-separated values, e.g. 2, 5, 10 ) ',
|
|
132
|
-
required: true,
|
|
133
|
-
},
|
|
134
|
-
client_price_index_curs: {
|
|
135
|
-
description: 'Enter client benchmarks (Comma-separated values, e.g., BTC,ETH)',
|
|
136
|
-
required: false,
|
|
137
|
-
},
|
|
138
|
-
client_telegram_ids: {
|
|
139
|
-
description: 'Enter client telegram ids i.e 1233457 ',
|
|
140
|
-
required: true,
|
|
141
|
-
},
|
|
142
|
-
},
|
|
143
|
-
}
|
|
144
|
-
read_config_file(config_file_path)
|
|
145
|
-
.then((config_file_data) => {
|
|
146
|
-
prompt.get(schema, (err, result) => {
|
|
147
|
-
if (err) {
|
|
148
|
-
console.error(err)
|
|
149
|
-
return
|
|
150
|
-
}
|
|
151
|
-
config_file_data = JSON.parse(config_file_data)
|
|
152
|
-
|
|
153
|
-
let exchange_pairs = result.client_exchange_pairs.trim()
|
|
154
|
-
exchange_pairs = JSON.parse(exchange_pairs)
|
|
155
|
-
|
|
156
|
-
let pair_exchanges = result.client_pair_main_exchanges.trim()
|
|
157
|
-
pair_exchanges = JSON.parse(pair_exchanges)
|
|
158
|
-
|
|
159
|
-
let reporter_interval = result.clients_reporter_interval.trim()
|
|
160
|
-
reporter_interval = JSON.parse(reporter_interval)
|
|
161
|
-
|
|
162
|
-
let not_include_exchanges = []
|
|
163
|
-
if (result.client_not_include_exchanges) {
|
|
164
|
-
not_include_exchanges = result.client_not_include_exchanges.split(',').map((value) => value.trim())
|
|
165
|
-
not_include_exchanges.sort()
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
let benchmarks = []
|
|
169
|
-
if (result.client_price_index_curs) {
|
|
170
|
-
benchmarks = result.client_price_index_curs.split(',').map((value) => value.trim())
|
|
171
|
-
benchmarks.sort()
|
|
172
|
-
}
|
|
173
|
-
let levels = result.client_levels.split(',').map((value) => Number(value.trim()))
|
|
174
|
-
|
|
175
|
-
config_file_data.client_exchange_pairs[client_name] = exchange_pairs
|
|
176
|
-
config_file_data.client_pair_main_exchanges[client_name] = pair_exchanges
|
|
177
|
-
|
|
178
|
-
config_file_data.clients_reporter_interval[client_name] = reporter_interval
|
|
179
|
-
|
|
180
|
-
config_file_data.client_not_include_exchanges[client_name] = not_include_exchanges
|
|
181
|
-
config_file_data.client_levels[client_name] = levels
|
|
182
|
-
config_file_data.client_price_index_curs[client_name] = benchmarks
|
|
183
|
-
|
|
184
|
-
config_file_data.client_telegram_ids[client_name] = result.client_telegram_ids
|
|
185
|
-
|
|
186
|
-
config_file_data.client_exchange_pairs = sort(config_file_data.client_exchange_pairs)
|
|
187
|
-
config_file_data.client_pair_main_exchanges = sort(config_file_data.client_pair_main_exchanges)
|
|
188
|
-
config_file_data.clients_reporter_interval = sort(config_file_data.clients_reporter_interval)
|
|
189
|
-
config_file_data.client_not_include_exchanges = sort(config_file_data.client_not_include_exchanges)
|
|
190
|
-
config_file_data.client_levels = sort(config_file_data.client_levels)
|
|
191
|
-
config_file_data.client_price_index_curs = sort(config_file_data.client_price_index_curs)
|
|
192
|
-
config_file_data.client_telegram_ids = sort(config_file_data.client_telegram_ids)
|
|
193
|
-
|
|
194
|
-
write_config_file(config_file_data, config_file_path)
|
|
195
|
-
.then(() => {
|
|
196
|
-
console.log(`Client '${client_name}' has been added successfully.`)
|
|
197
|
-
})
|
|
198
|
-
.catch((err) => {
|
|
199
|
-
console.error(`Error writing to config file: ${err}`)
|
|
200
|
-
})
|
|
201
|
-
})
|
|
202
|
-
})
|
|
203
|
-
.catch((err) => {
|
|
204
|
-
console.error(`Error reading config file: ${err}`)
|
|
205
|
-
})
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
function update_config_archive(config_file_data, client_name) {
|
|
209
|
-
return new Promise((resolve, reject) => {
|
|
210
|
-
read_config_file(config_archive_file_path)
|
|
211
|
-
.then((config_archive_data) => {
|
|
212
|
-
try {
|
|
213
|
-
config_archive_data = JSON.parse(config_archive_data)
|
|
214
|
-
} catch (error) {
|
|
215
|
-
console.error(`Error parsing config archive data: ${error}`)
|
|
216
|
-
reject(error)
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
config_archive_data.client_exchange_pairs[client_name] = config_file_data.client_exchange_pairs[client_name]
|
|
220
|
-
config_archive_data.client_pair_main_exchanges[client_name] = config_file_data.client_pair_main_exchanges[client_name]
|
|
221
|
-
config_archive_data.clients_reporter_interval[client_name] = config_file_data.clients_reporter_interval[client_name]
|
|
222
|
-
config_archive_data.client_not_include_exchanges[client_name] = config_file_data.client_not_include_exchanges[client_name]
|
|
223
|
-
config_archive_data.client_levels[client_name] = config_file_data.client_levels[client_name]
|
|
224
|
-
config_archive_data.client_price_index_curs[client_name] = config_file_data.client_price_index_curs[client_name]
|
|
225
|
-
config_archive_data.client_telegram_ids[client_name] = config_file_data.client_telegram_ids[client_name]
|
|
226
|
-
|
|
227
|
-
if (!config_archive_data.client_enabled) {
|
|
228
|
-
config_archive_data.client_enabled = {}
|
|
229
|
-
}
|
|
230
|
-
for (let key in config_file_data.client_enabled) {
|
|
231
|
-
if (config_file_data.client_enabled.hasOwnProperty(key)) {
|
|
232
|
-
if (!config_archive_data.client_enabled[key]) {
|
|
233
|
-
config_archive_data.client_enabled[key] = {}
|
|
234
|
-
}
|
|
235
|
-
config_archive_data.client_enabled[key][client_name] = config_file_data.client_enabled[key][client_name]
|
|
236
|
-
}
|
|
237
|
-
}
|
|
238
|
-
|
|
239
|
-
config_archive_data.client_exchange_pairs = sort(config_archive_data.client_exchange_pairs)
|
|
240
|
-
config_archive_data.client_pair_main_exchanges = sort(config_archive_data.client_pair_main_exchanges)
|
|
241
|
-
config_archive_data.clients_reporter_interval = sort(config_archive_data.clients_reporter_interval)
|
|
242
|
-
config_archive_data.client_not_include_exchanges = sort(config_archive_data.client_not_include_exchanges)
|
|
243
|
-
config_archive_data.client_levels = sort(config_archive_data.client_levels)
|
|
244
|
-
config_archive_data.client_price_index_curs = sort(config_archive_data.client_price_index_curs)
|
|
245
|
-
config_archive_data.client_telegram_ids = sort(config_archive_data.client_telegram_ids)
|
|
246
|
-
|
|
247
|
-
for (let key in config_archive_data.client_enabled) {
|
|
248
|
-
if (config_archive_data.client_enabled.hasOwnProperty(key)) {
|
|
249
|
-
config_archive_data.client_enabled[key] = sort(config_archive_data.client_enabled[key])
|
|
250
|
-
}
|
|
251
|
-
}
|
|
252
|
-
|
|
253
|
-
write_config_file(config_archive_data, config_archive_file_path)
|
|
254
|
-
.then(() => {
|
|
255
|
-
resolve()
|
|
256
|
-
})
|
|
257
|
-
.catch((err) => {
|
|
258
|
-
console.error(`Error writing to config file: ${err}`)
|
|
259
|
-
reject(err)
|
|
260
|
-
})
|
|
261
|
-
})
|
|
262
|
-
.catch((err) => {
|
|
263
|
-
console.error(`Error reading config archive file: ${err}`)
|
|
264
|
-
reject(err)
|
|
265
|
-
})
|
|
266
|
-
})
|
|
267
|
-
}
|
|
268
|
-
|
|
269
|
-
function sort(obj) {
|
|
270
|
-
return Object.keys(obj)
|
|
271
|
-
.sort()
|
|
272
|
-
.reduce((result, key) => {
|
|
273
|
-
result[key] = obj[key]
|
|
274
|
-
return result
|
|
275
|
-
}, {})
|
|
276
|
-
}
|
|
277
|
-
|
|
278
|
-
process_config()
|
|
1
|
+
const fs = require('fs')
|
|
2
|
+
const prompt = require('prompt')
|
|
3
|
+
|
|
4
|
+
const config_file_path = './config.json'
|
|
5
|
+
const config_archive_file_path = './config-archive.json'
|
|
6
|
+
|
|
7
|
+
prompt.start()
|
|
8
|
+
|
|
9
|
+
function read_config_file(path) {
|
|
10
|
+
return new Promise((resolve, reject) => {
|
|
11
|
+
fs.readFile(path, 'utf8', (err, data) => {
|
|
12
|
+
if (err) reject(err)
|
|
13
|
+
else resolve(data)
|
|
14
|
+
})
|
|
15
|
+
})
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
function write_config_file(data, path) {
|
|
19
|
+
return new Promise((resolve, reject) => {
|
|
20
|
+
fs.writeFile(path, JSON.stringify(data, null, 2), 'utf8', (err) => {
|
|
21
|
+
if (err) return reject(err)
|
|
22
|
+
else resolve()
|
|
23
|
+
})
|
|
24
|
+
})
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function process_config() {
|
|
28
|
+
try {
|
|
29
|
+
const schema = {
|
|
30
|
+
properties: {
|
|
31
|
+
action: {
|
|
32
|
+
description: 'Enter the action ( add, delete )',
|
|
33
|
+
pattern: /^(add|delete)$/,
|
|
34
|
+
message: 'Action must be one of "add", "delete"',
|
|
35
|
+
required: true,
|
|
36
|
+
},
|
|
37
|
+
client_name: {
|
|
38
|
+
description: 'Enter the client name you want to perform the action on',
|
|
39
|
+
required: true,
|
|
40
|
+
},
|
|
41
|
+
},
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
prompt.get(schema, (err, result) => {
|
|
45
|
+
if (err) {
|
|
46
|
+
console.error(err)
|
|
47
|
+
return
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
switch (result.action) {
|
|
51
|
+
case 'add':
|
|
52
|
+
add_client(result.client_name)
|
|
53
|
+
break
|
|
54
|
+
case 'delete':
|
|
55
|
+
delete_client(result.client_name)
|
|
56
|
+
break
|
|
57
|
+
default:
|
|
58
|
+
console.log('Invalid action')
|
|
59
|
+
break
|
|
60
|
+
}
|
|
61
|
+
})
|
|
62
|
+
} catch (error) {
|
|
63
|
+
console.error(`Error processing the config file: ${error}`)
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
function delete_client(client_name) {
|
|
68
|
+
read_config_file(config_file_path)
|
|
69
|
+
.then((config_file_data) => {
|
|
70
|
+
config_file_data = JSON.parse(config_file_data)
|
|
71
|
+
|
|
72
|
+
update_config_archive(config_file_data, client_name)
|
|
73
|
+
.then(() => {
|
|
74
|
+
delete config_file_data.client_exchange_pairs[client_name]
|
|
75
|
+
delete config_file_data.client_pair_main_exchanges[client_name]
|
|
76
|
+
delete config_file_data.client_not_include_exchanges[client_name]
|
|
77
|
+
delete config_file_data.client_levels[client_name]
|
|
78
|
+
delete config_file_data.client_price_index_curs[client_name]
|
|
79
|
+
delete config_file_data.client_telegram_ids[client_name]
|
|
80
|
+
delete config_file_data.clients_reporter_interval[client_name]
|
|
81
|
+
|
|
82
|
+
for (let key in config_file_data.client_enabled) {
|
|
83
|
+
if (config_file_data.client_enabled.hasOwnProperty(key)) {
|
|
84
|
+
delete config_file_data.client_enabled[key][client_name]
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
write_config_file(config_file_data, config_file_path)
|
|
89
|
+
.then(() => {
|
|
90
|
+
console.log(`Client '${client_name}' has been deleted successfully.`)
|
|
91
|
+
})
|
|
92
|
+
.catch((err) => {
|
|
93
|
+
console.error(`Error writing to config file: ${err}`)
|
|
94
|
+
})
|
|
95
|
+
})
|
|
96
|
+
.catch((err) => {
|
|
97
|
+
console.error(`Error updating config archive: ${err}`)
|
|
98
|
+
})
|
|
99
|
+
})
|
|
100
|
+
.catch((err) => {
|
|
101
|
+
console.error(`Error reading config file: ${err}`)
|
|
102
|
+
})
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
function add_client(client_name) {
|
|
106
|
+
const schema = {
|
|
107
|
+
properties: {
|
|
108
|
+
client_exchange_pairs: {
|
|
109
|
+
description: 'Enter client exchange pairs (JSON format i.e { "Mexc": ["RWXUSDT"], "Bitget": ["RWXUSDT"] } )',
|
|
110
|
+
required: true,
|
|
111
|
+
pattern: /^\{.*\}$/,
|
|
112
|
+
message: 'Please enter a valid JSON object.',
|
|
113
|
+
},
|
|
114
|
+
client_not_include_exchanges: {
|
|
115
|
+
description: 'Enter client not include exchanges (Comma-separated values, e.g., Jubi, Lbank)',
|
|
116
|
+
required: false,
|
|
117
|
+
},
|
|
118
|
+
client_pair_main_exchanges: {
|
|
119
|
+
description: 'Enter client pair main exchanges (JSON format i.e {"ETHUSDT": ["Bitget", "Gate"]} )',
|
|
120
|
+
required: true,
|
|
121
|
+
pattern: /^\{.*\}$/,
|
|
122
|
+
message: 'Please enter a valid JSON object.',
|
|
123
|
+
},
|
|
124
|
+
clients_reporter_interval: {
|
|
125
|
+
description: 'Enter clients reporter interval (JSON format i.e { "balance": 1, "trades": 1, "orderbook": 1} )',
|
|
126
|
+
required: true,
|
|
127
|
+
pattern: /^\{.*\}$/,
|
|
128
|
+
message: 'Please enter a valid JSON object.',
|
|
129
|
+
},
|
|
130
|
+
client_levels: {
|
|
131
|
+
description: 'Enter client levels (Comma-separated values, e.g. 2, 5, 10 ) ',
|
|
132
|
+
required: true,
|
|
133
|
+
},
|
|
134
|
+
client_price_index_curs: {
|
|
135
|
+
description: 'Enter client benchmarks (Comma-separated values, e.g., BTC,ETH)',
|
|
136
|
+
required: false,
|
|
137
|
+
},
|
|
138
|
+
client_telegram_ids: {
|
|
139
|
+
description: 'Enter client telegram ids i.e 1233457 ',
|
|
140
|
+
required: true,
|
|
141
|
+
},
|
|
142
|
+
},
|
|
143
|
+
}
|
|
144
|
+
read_config_file(config_file_path)
|
|
145
|
+
.then((config_file_data) => {
|
|
146
|
+
prompt.get(schema, (err, result) => {
|
|
147
|
+
if (err) {
|
|
148
|
+
console.error(err)
|
|
149
|
+
return
|
|
150
|
+
}
|
|
151
|
+
config_file_data = JSON.parse(config_file_data)
|
|
152
|
+
|
|
153
|
+
let exchange_pairs = result.client_exchange_pairs.trim()
|
|
154
|
+
exchange_pairs = JSON.parse(exchange_pairs)
|
|
155
|
+
|
|
156
|
+
let pair_exchanges = result.client_pair_main_exchanges.trim()
|
|
157
|
+
pair_exchanges = JSON.parse(pair_exchanges)
|
|
158
|
+
|
|
159
|
+
let reporter_interval = result.clients_reporter_interval.trim()
|
|
160
|
+
reporter_interval = JSON.parse(reporter_interval)
|
|
161
|
+
|
|
162
|
+
let not_include_exchanges = []
|
|
163
|
+
if (result.client_not_include_exchanges) {
|
|
164
|
+
not_include_exchanges = result.client_not_include_exchanges.split(',').map((value) => value.trim())
|
|
165
|
+
not_include_exchanges.sort()
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
let benchmarks = []
|
|
169
|
+
if (result.client_price_index_curs) {
|
|
170
|
+
benchmarks = result.client_price_index_curs.split(',').map((value) => value.trim())
|
|
171
|
+
benchmarks.sort()
|
|
172
|
+
}
|
|
173
|
+
let levels = result.client_levels.split(',').map((value) => Number(value.trim()))
|
|
174
|
+
|
|
175
|
+
config_file_data.client_exchange_pairs[client_name] = exchange_pairs
|
|
176
|
+
config_file_data.client_pair_main_exchanges[client_name] = pair_exchanges
|
|
177
|
+
|
|
178
|
+
config_file_data.clients_reporter_interval[client_name] = reporter_interval
|
|
179
|
+
|
|
180
|
+
config_file_data.client_not_include_exchanges[client_name] = not_include_exchanges
|
|
181
|
+
config_file_data.client_levels[client_name] = levels
|
|
182
|
+
config_file_data.client_price_index_curs[client_name] = benchmarks
|
|
183
|
+
|
|
184
|
+
config_file_data.client_telegram_ids[client_name] = result.client_telegram_ids
|
|
185
|
+
|
|
186
|
+
config_file_data.client_exchange_pairs = sort(config_file_data.client_exchange_pairs)
|
|
187
|
+
config_file_data.client_pair_main_exchanges = sort(config_file_data.client_pair_main_exchanges)
|
|
188
|
+
config_file_data.clients_reporter_interval = sort(config_file_data.clients_reporter_interval)
|
|
189
|
+
config_file_data.client_not_include_exchanges = sort(config_file_data.client_not_include_exchanges)
|
|
190
|
+
config_file_data.client_levels = sort(config_file_data.client_levels)
|
|
191
|
+
config_file_data.client_price_index_curs = sort(config_file_data.client_price_index_curs)
|
|
192
|
+
config_file_data.client_telegram_ids = sort(config_file_data.client_telegram_ids)
|
|
193
|
+
|
|
194
|
+
write_config_file(config_file_data, config_file_path)
|
|
195
|
+
.then(() => {
|
|
196
|
+
console.log(`Client '${client_name}' has been added successfully.`)
|
|
197
|
+
})
|
|
198
|
+
.catch((err) => {
|
|
199
|
+
console.error(`Error writing to config file: ${err}`)
|
|
200
|
+
})
|
|
201
|
+
})
|
|
202
|
+
})
|
|
203
|
+
.catch((err) => {
|
|
204
|
+
console.error(`Error reading config file: ${err}`)
|
|
205
|
+
})
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
function update_config_archive(config_file_data, client_name) {
|
|
209
|
+
return new Promise((resolve, reject) => {
|
|
210
|
+
read_config_file(config_archive_file_path)
|
|
211
|
+
.then((config_archive_data) => {
|
|
212
|
+
try {
|
|
213
|
+
config_archive_data = JSON.parse(config_archive_data)
|
|
214
|
+
} catch (error) {
|
|
215
|
+
console.error(`Error parsing config archive data: ${error}`)
|
|
216
|
+
reject(error)
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
config_archive_data.client_exchange_pairs[client_name] = config_file_data.client_exchange_pairs[client_name]
|
|
220
|
+
config_archive_data.client_pair_main_exchanges[client_name] = config_file_data.client_pair_main_exchanges[client_name]
|
|
221
|
+
config_archive_data.clients_reporter_interval[client_name] = config_file_data.clients_reporter_interval[client_name]
|
|
222
|
+
config_archive_data.client_not_include_exchanges[client_name] = config_file_data.client_not_include_exchanges[client_name]
|
|
223
|
+
config_archive_data.client_levels[client_name] = config_file_data.client_levels[client_name]
|
|
224
|
+
config_archive_data.client_price_index_curs[client_name] = config_file_data.client_price_index_curs[client_name]
|
|
225
|
+
config_archive_data.client_telegram_ids[client_name] = config_file_data.client_telegram_ids[client_name]
|
|
226
|
+
|
|
227
|
+
if (!config_archive_data.client_enabled) {
|
|
228
|
+
config_archive_data.client_enabled = {}
|
|
229
|
+
}
|
|
230
|
+
for (let key in config_file_data.client_enabled) {
|
|
231
|
+
if (config_file_data.client_enabled.hasOwnProperty(key)) {
|
|
232
|
+
if (!config_archive_data.client_enabled[key]) {
|
|
233
|
+
config_archive_data.client_enabled[key] = {}
|
|
234
|
+
}
|
|
235
|
+
config_archive_data.client_enabled[key][client_name] = config_file_data.client_enabled[key][client_name]
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
config_archive_data.client_exchange_pairs = sort(config_archive_data.client_exchange_pairs)
|
|
240
|
+
config_archive_data.client_pair_main_exchanges = sort(config_archive_data.client_pair_main_exchanges)
|
|
241
|
+
config_archive_data.clients_reporter_interval = sort(config_archive_data.clients_reporter_interval)
|
|
242
|
+
config_archive_data.client_not_include_exchanges = sort(config_archive_data.client_not_include_exchanges)
|
|
243
|
+
config_archive_data.client_levels = sort(config_archive_data.client_levels)
|
|
244
|
+
config_archive_data.client_price_index_curs = sort(config_archive_data.client_price_index_curs)
|
|
245
|
+
config_archive_data.client_telegram_ids = sort(config_archive_data.client_telegram_ids)
|
|
246
|
+
|
|
247
|
+
for (let key in config_archive_data.client_enabled) {
|
|
248
|
+
if (config_archive_data.client_enabled.hasOwnProperty(key)) {
|
|
249
|
+
config_archive_data.client_enabled[key] = sort(config_archive_data.client_enabled[key])
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
write_config_file(config_archive_data, config_archive_file_path)
|
|
254
|
+
.then(() => {
|
|
255
|
+
resolve()
|
|
256
|
+
})
|
|
257
|
+
.catch((err) => {
|
|
258
|
+
console.error(`Error writing to config file: ${err}`)
|
|
259
|
+
reject(err)
|
|
260
|
+
})
|
|
261
|
+
})
|
|
262
|
+
.catch((err) => {
|
|
263
|
+
console.error(`Error reading config archive file: ${err}`)
|
|
264
|
+
reject(err)
|
|
265
|
+
})
|
|
266
|
+
})
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
function sort(obj) {
|
|
270
|
+
return Object.keys(obj)
|
|
271
|
+
.sort()
|
|
272
|
+
.reduce((result, key) => {
|
|
273
|
+
result[key] = obj[key]
|
|
274
|
+
return result
|
|
275
|
+
}, {})
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
process_config()
|