@icgio/icg-utils 1.7.60 → 1.7.62

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.
Files changed (2) hide show
  1. package/lib/crypto-rates.js +147 -100
  2. package/package.json +1 -1
@@ -236,10 +236,10 @@ let get_crypto_rates = (cb, pair_or_pairs_or_cur_curs, type, source = 'coingecko
236
236
  }
237
237
  }
238
238
  coins_map = source === 'coingecko' ? process_coins_map_coingecko(coins_map_raw_coingecko) : process_coins_map_coinmarketcap(coins_map_raw_coinmarketcap)
239
- try {
240
- if (type === 'curs' && _.includes(pair_or_pairs_or_cur_curs, 'BBDC')) {
241
- let curs = _.without(pair_or_pairs_or_cur_curs, 'BBDC')
242
- needle('get', 'https://www.mexc.com/open/api/v2/market/depth?symbol=BBDC_USDT&depth=100').then((res) => {
239
+ if (type === 'curs' && _.includes(pair_or_pairs_or_cur_curs, 'BBDC')) {
240
+ let curs = _.without(pair_or_pairs_or_cur_curs, 'BBDC')
241
+ needle('get', 'https://www.mexc.com/open/api/v2/market/depth?symbol=BBDC_USDT&depth=100').then((res) => {
242
+ try {
243
243
  const { asks, bids } = res.body.data
244
244
  let rate = (parseFloat(asks[0].price) + parseFloat(bids[0].price)) / 2
245
245
  result.BBDC = {
@@ -247,10 +247,14 @@ let get_crypto_rates = (cb, pair_or_pairs_or_cur_curs, type, source = 'coingecko
247
247
  USDT: rate,
248
248
  }
249
249
  get_crypto_rates(cb, curs, type, source)
250
- })
251
- } else if (type === 'curs' && _.includes(pair_or_pairs_or_cur_curs, 'DARK')) {
252
- let curs = _.without(pair_or_pairs_or_cur_curs, 'DARK')
253
- needle('get', 'https://www.mexc.com/open/api/v2/market/depth?symbol=DARK_USDT&depth=100').then((res) => {
250
+ } catch (error) {
251
+ console.error(error)
252
+ }
253
+ })
254
+ } else if (type === 'curs' && _.includes(pair_or_pairs_or_cur_curs, 'DARK')) {
255
+ let curs = _.without(pair_or_pairs_or_cur_curs, 'DARK')
256
+ needle('get', 'https://www.mexc.com/open/api/v2/market/depth?symbol=DARK_USDT&depth=100').then((res) => {
257
+ try {
254
258
  const { asks, bids } = res.body.data
255
259
  let rate = (parseFloat(asks[0].price) + parseFloat(bids[0].price)) / 2
256
260
  result.DARK = {
@@ -258,10 +262,14 @@ let get_crypto_rates = (cb, pair_or_pairs_or_cur_curs, type, source = 'coingecko
258
262
  USDT: rate,
259
263
  }
260
264
  get_crypto_rates(cb, curs, type, source)
261
- })
262
- } else if (type === 'curs' && _.includes(pair_or_pairs_or_cur_curs, 'DMC')) {
263
- let curs = _.without(pair_or_pairs_or_cur_curs, 'DMC')
264
- needle('get', 'https://api.gateio.ws/api/v4/spot/order_book?currency_pair=DMC_USDT').then((res) => {
265
+ } catch (error) {
266
+ console.error(error)
267
+ }
268
+ })
269
+ } else if (type === 'curs' && _.includes(pair_or_pairs_or_cur_curs, 'DMC')) {
270
+ let curs = _.without(pair_or_pairs_or_cur_curs, 'DMC')
271
+ needle('get', 'https://api.gateio.ws/api/v4/spot/order_book?currency_pair=DMC_USDT').then((res) => {
272
+ try {
265
273
  const { asks, bids } = res.body
266
274
  let rate = (parseFloat(asks[0][0]) + parseFloat(bids[0][0])) / 2
267
275
  result.DMC = {
@@ -269,10 +277,14 @@ let get_crypto_rates = (cb, pair_or_pairs_or_cur_curs, type, source = 'coingecko
269
277
  USDT: rate,
270
278
  }
271
279
  get_crypto_rates(cb, curs, type, source)
272
- })
273
- } else if (type === 'curs' && _.includes(pair_or_pairs_or_cur_curs, 'DFI')) {
274
- let curs = _.without(pair_or_pairs_or_cur_curs, 'DFI')
275
- needle('get', 'https://api.coinstore.com/api/v1/market/depth/dfiusdt').then((res) => {
280
+ } catch (error) {
281
+ console.error(error)
282
+ }
283
+ })
284
+ } else if (type === 'curs' && _.includes(pair_or_pairs_or_cur_curs, 'DFI')) {
285
+ let curs = _.without(pair_or_pairs_or_cur_curs, 'DFI')
286
+ needle('get', 'https://api.coinstore.com/api/v1/market/depth/dfiusdt').then((res) => {
287
+ try {
276
288
  const asks = res.body.data.a
277
289
  const bids = res.body.data.b
278
290
  let rate = (parseFloat(asks[0][0]) + parseFloat(bids[0][0])) / 2
@@ -281,10 +293,14 @@ let get_crypto_rates = (cb, pair_or_pairs_or_cur_curs, type, source = 'coingecko
281
293
  USDT: rate,
282
294
  }
283
295
  get_crypto_rates(cb, curs, type, source)
284
- })
285
- } else if (type === 'curs' && _.includes(pair_or_pairs_or_cur_curs, 'ENIX')) {
286
- let curs = _.without(pair_or_pairs_or_cur_curs, 'ENIX')
287
- needle('get', 'https://www.mexc.com/open/api/v2/market/depth?symbol=ENIX_USDT&depth=100').then((res) => {
296
+ } catch (error) {
297
+ console.error(error)
298
+ }
299
+ })
300
+ } else if (type === 'curs' && _.includes(pair_or_pairs_or_cur_curs, 'ENIX')) {
301
+ let curs = _.without(pair_or_pairs_or_cur_curs, 'ENIX')
302
+ needle('get', 'https://www.mexc.com/open/api/v2/market/depth?symbol=ENIX_USDT&depth=100').then((res) => {
303
+ try {
288
304
  const { asks, bids } = res.body.data
289
305
  let rate = (parseFloat(asks[0].price) + parseFloat(bids[0].price)) / 2
290
306
  result.ENIX = {
@@ -292,30 +308,23 @@ let get_crypto_rates = (cb, pair_or_pairs_or_cur_curs, type, source = 'coingecko
292
308
  USDT: rate,
293
309
  }
294
310
  get_crypto_rates(cb, curs, type, source)
295
- })
296
- } else if (type === 'curs' && _.includes(pair_or_pairs_or_cur_curs, 'FIRM')) {
297
- let curs = _.without(pair_or_pairs_or_cur_curs, 'FIRM')
298
- needle('get', 'https://www.mexc.com/open/api/v2/market/depth?symbol=FIRM_USDT&depth=100').then((res) => {
299
- const { asks, bids } = res.body.data
300
- let rate = (parseFloat(asks[0].price) + parseFloat(bids[0].price)) / 2
301
- result.FIRM = {
302
- USD: rate,
303
- USDT: rate,
304
- }
305
- get_crypto_rates(cb, curs, type, source)
306
- })
307
- } else if (type === 'curs' && _.includes(pair_or_pairs_or_cur_curs, 'FREN')) {
308
- let curs = _.without(pair_or_pairs_or_cur_curs, 'FREN')
309
- dex_rate().then((res) => {
310
- result.FREN = {
311
- USD: res.FRENUSDT,
312
- USDT: res.FRENUSDT,
313
- }
314
- get_crypto_rates(cb, curs, type, source)
315
- })
316
- } else if (type === 'curs' && _.includes(pair_or_pairs_or_cur_curs, 'GLW')) {
317
- let curs = _.without(pair_or_pairs_or_cur_curs, 'GLW')
318
- needle('get', 'https://www.mexc.com/open/api/v2/market/depth?symbol=GLW_USDT&depth=100').then((res) => {
311
+ } catch (error) {
312
+ console.error(error)
313
+ }
314
+ })
315
+ } else if (type === 'curs' && _.includes(pair_or_pairs_or_cur_curs, 'FREN')) {
316
+ let curs = _.without(pair_or_pairs_or_cur_curs, 'FREN')
317
+ dex_rate().then((res) => {
318
+ result.FREN = {
319
+ USD: res.FRENUSDT,
320
+ USDT: res.FRENUSDT,
321
+ }
322
+ get_crypto_rates(cb, curs, type, source)
323
+ })
324
+ } else if (type === 'curs' && _.includes(pair_or_pairs_or_cur_curs, 'GLW')) {
325
+ let curs = _.without(pair_or_pairs_or_cur_curs, 'GLW')
326
+ needle('get', 'https://www.mexc.com/open/api/v2/market/depth?symbol=GLW_USDT&depth=100').then((res) => {
327
+ try {
319
328
  const { asks, bids } = res.body.data
320
329
  let rate = (parseFloat(asks[0].price) + parseFloat(bids[0].price)) / 2
321
330
  result.GLW = {
@@ -323,22 +332,30 @@ let get_crypto_rates = (cb, pair_or_pairs_or_cur_curs, type, source = 'coingecko
323
332
  USDT: rate,
324
333
  }
325
334
  get_crypto_rates(cb, curs, type, source)
326
- })
327
- } else if (type === 'curs' && _.includes(pair_or_pairs_or_cur_curs, 'GPT')) {
328
- let curs = _.without(pair_or_pairs_or_cur_curs, 'GPT')
329
- needle('get', 'https://api.coinstore.com/api/v1/market/depth/gptusdt').then((res) => {
335
+ } catch (error) {
336
+ console.error(error)
337
+ }
338
+ })
339
+ } else if (type === 'curs' && _.includes(pair_or_pairs_or_cur_curs, 'GPT')) {
340
+ let curs = _.without(pair_or_pairs_or_cur_curs, 'GPT')
341
+ needle('get', 'https://api.coinstore.com/api/v1/market/depth/gptusdt').then((res) => {
342
+ try {
330
343
  const asks = res.body.data.a
331
344
  const bids = res.body.data.b
332
- let rate = (parseFloat(asks[0][0]) + parseFloat(bids[0][0])) / 2
345
+ let rate = parseFloat(asks[0][0])
333
346
  result.GPT = {
334
347
  USD: rate,
335
348
  USDT: rate,
336
349
  }
337
350
  get_crypto_rates(cb, curs, type, source)
338
- })
339
- } else if (type === 'curs' && _.includes(pair_or_pairs_or_cur_curs, 'IUS')) {
340
- let curs = _.without(pair_or_pairs_or_cur_curs, 'IUS')
341
- needle('get', 'https://www.mexc.com/open/api/v2/market/depth?symbol=IUS_USDT&depth=100').then((res) => {
351
+ } catch (error) {
352
+ console.error(error)
353
+ }
354
+ })
355
+ } else if (type === 'curs' && _.includes(pair_or_pairs_or_cur_curs, 'IUS')) {
356
+ let curs = _.without(pair_or_pairs_or_cur_curs, 'IUS')
357
+ needle('get', 'https://www.mexc.com/open/api/v2/market/depth?symbol=IUS_USDT&depth=100').then((res) => {
358
+ try {
342
359
  const { asks, bids } = res.body.data
343
360
  let rate = (parseFloat(asks[0].price) + parseFloat(bids[0].price)) / 2
344
361
  result.IUS = {
@@ -346,10 +363,14 @@ let get_crypto_rates = (cb, pair_or_pairs_or_cur_curs, type, source = 'coingecko
346
363
  USDT: rate,
347
364
  }
348
365
  get_crypto_rates(cb, curs, type, source)
349
- })
350
- } else if (type === 'curs' && _.includes(pair_or_pairs_or_cur_curs, 'JD')) {
351
- let curs = _.without(pair_or_pairs_or_cur_curs, 'JD')
352
- needle('get', 'https://www.mexc.com/open/api/v2/market/depth?symbol=JD_USDT&depth=100').then((res) => {
366
+ } catch (error) {
367
+ console.error(error)
368
+ }
369
+ })
370
+ } else if (type === 'curs' && _.includes(pair_or_pairs_or_cur_curs, 'JD')) {
371
+ let curs = _.without(pair_or_pairs_or_cur_curs, 'JD')
372
+ needle('get', 'https://www.mexc.com/open/api/v2/market/depth?symbol=JD_USDT&depth=100').then((res) => {
373
+ try {
353
374
  const { asks, bids } = res.body.data
354
375
  let rate = (parseFloat(asks[0].price) + parseFloat(bids[0].price)) / 2
355
376
  result.JD = {
@@ -357,10 +378,14 @@ let get_crypto_rates = (cb, pair_or_pairs_or_cur_curs, type, source = 'coingecko
357
378
  USDT: rate,
358
379
  }
359
380
  get_crypto_rates(cb, curs, type, source)
360
- })
361
- } else if (type === 'curs' && _.includes(pair_or_pairs_or_cur_curs, 'KLC')) {
362
- let curs = _.without(pair_or_pairs_or_cur_curs, 'KLC')
363
- needle('get', 'https://www.mexc.com/open/api/v2/market/depth?symbol=KLC_USDT&depth=100').then((res) => {
381
+ } catch (error) {
382
+ console.error(error)
383
+ }
384
+ })
385
+ } else if (type === 'curs' && _.includes(pair_or_pairs_or_cur_curs, 'KLC')) {
386
+ let curs = _.without(pair_or_pairs_or_cur_curs, 'KLC')
387
+ needle('get', 'https://www.mexc.com/open/api/v2/market/depth?symbol=KLC_USDT&depth=100').then((res) => {
388
+ try {
364
389
  const { asks, bids } = res.body.data
365
390
  let rate = (parseFloat(asks[0].price) + parseFloat(bids[0].price)) / 2
366
391
  result.KLC = {
@@ -368,10 +393,14 @@ let get_crypto_rates = (cb, pair_or_pairs_or_cur_curs, type, source = 'coingecko
368
393
  USDT: rate,
369
394
  }
370
395
  get_crypto_rates(cb, curs, type, source)
371
- })
372
- } else if (type === 'curs' && _.includes(pair_or_pairs_or_cur_curs, 'MEGODS')) {
373
- let curs = _.without(pair_or_pairs_or_cur_curs, 'MEGODS')
374
- needle('get', 'https://www.mexc.com/open/api/v2/market/depth?symbol=MEGODS_USDT&depth=100').then((res) => {
396
+ } catch (error) {
397
+ console.error(error)
398
+ }
399
+ })
400
+ } else if (type === 'curs' && _.includes(pair_or_pairs_or_cur_curs, 'MEGODS')) {
401
+ let curs = _.without(pair_or_pairs_or_cur_curs, 'MEGODS')
402
+ needle('get', 'https://www.mexc.com/open/api/v2/market/depth?symbol=MEGODS_USDT&depth=100').then((res) => {
403
+ try {
375
404
  const { asks, bids } = res.body.data
376
405
  let rate = (parseFloat(asks[0].price) + parseFloat(bids[0].price)) / 2
377
406
  result.MEGODS = {
@@ -379,23 +408,29 @@ let get_crypto_rates = (cb, pair_or_pairs_or_cur_curs, type, source = 'coingecko
379
408
  USDT: rate,
380
409
  }
381
410
  get_crypto_rates(cb, curs, type, source)
382
- })
383
- } else if (type === 'curs' && _.includes(pair_or_pairs_or_cur_curs, 'MONE')) {
384
- let curs = _.without(pair_or_pairs_or_cur_curs, 'MONE')
385
- needle('get', 'https://www.bitforex.com/api/v1/market/depth?symbol=coin-usdt-mone').then((res) => {
386
- try {
387
- const { asks, bids } = JSON.parse(res.body).data
388
- let rate = (parseFloat(asks[0].price) + parseFloat(bids[0].price)) / 2
389
- result.MONE = {
390
- USD: rate,
391
- USDT: rate,
392
- }
393
- get_crypto_rates(cb, curs, type, source)
394
- } catch (error) {}
395
- })
396
- } else if (type === 'curs' && _.includes(pair_or_pairs_or_cur_curs, 'ROACHCOIN')) {
397
- let curs = _.without(pair_or_pairs_or_cur_curs, 'ROACHCOIN')
398
- needle('get', 'https://www.mexc.com/open/api/v2/market/depth?symbol=ROACHCOIN_USDT&depth=100').then((res) => {
411
+ } catch (error) {
412
+ console.error(error)
413
+ }
414
+ })
415
+ } else if (type === 'curs' && _.includes(pair_or_pairs_or_cur_curs, 'MONE')) {
416
+ let curs = _.without(pair_or_pairs_or_cur_curs, 'MONE')
417
+ needle('get', 'https://www.bitforex.com/api/v1/market/depth?symbol=coin-usdt-mone').then((res) => {
418
+ try {
419
+ const { asks, bids } = JSON.parse(res.body).data
420
+ let rate = (parseFloat(asks[0].price) + parseFloat(bids[0].price)) / 2
421
+ result.MONE = {
422
+ USD: rate,
423
+ USDT: rate,
424
+ }
425
+ get_crypto_rates(cb, curs, type, source)
426
+ } catch (error) {
427
+ console.error(error)
428
+ }
429
+ })
430
+ } else if (type === 'curs' && _.includes(pair_or_pairs_or_cur_curs, 'ROACHCOIN')) {
431
+ let curs = _.without(pair_or_pairs_or_cur_curs, 'ROACHCOIN')
432
+ needle('get', 'https://www.mexc.com/open/api/v2/market/depth?symbol=ROACHCOIN_USDT&depth=100').then((res) => {
433
+ try {
399
434
  const { asks, bids } = res.body.data
400
435
  let rate = (parseFloat(asks[0].price) + parseFloat(bids[0].price)) / 2
401
436
  result.ROACHCOIN = {
@@ -403,10 +438,14 @@ let get_crypto_rates = (cb, pair_or_pairs_or_cur_curs, type, source = 'coingecko
403
438
  USDT: rate,
404
439
  }
405
440
  get_crypto_rates(cb, curs, type, source)
406
- })
407
- } else if (type === 'curs' && _.includes(pair_or_pairs_or_cur_curs, 'SDP')) {
408
- let curs = _.without(pair_or_pairs_or_cur_curs, 'SDP')
409
- needle('get', 'https://www.mexc.com/open/api/v2/market/depth?symbol=SDP_USDT&depth=100').then((res) => {
441
+ } catch (error) {
442
+ console.error(error)
443
+ }
444
+ })
445
+ } else if (type === 'curs' && _.includes(pair_or_pairs_or_cur_curs, 'SDP')) {
446
+ let curs = _.without(pair_or_pairs_or_cur_curs, 'SDP')
447
+ needle('get', 'https://www.mexc.com/open/api/v2/market/depth?symbol=SDP_USDT&depth=100').then((res) => {
448
+ try {
410
449
  const { asks, bids } = res.body.data
411
450
  let rate = (parseFloat(asks[0].price) + parseFloat(bids[0].price)) / 2
412
451
  result.SDP = {
@@ -414,10 +453,14 @@ let get_crypto_rates = (cb, pair_or_pairs_or_cur_curs, type, source = 'coingecko
414
453
  USDT: rate,
415
454
  }
416
455
  get_crypto_rates(cb, curs, type, source)
417
- })
418
- } else if (type === 'curs' && _.includes(pair_or_pairs_or_cur_curs, 'SPAI')) {
419
- let curs = _.without(pair_or_pairs_or_cur_curs, 'SPAI')
420
- needle('get', 'https://www.mexc.com/open/api/v2/market/depth?symbol=SPAI_USDT&depth=100').then((res) => {
456
+ } catch (error) {
457
+ console.error(error)
458
+ }
459
+ })
460
+ } else if (type === 'curs' && _.includes(pair_or_pairs_or_cur_curs, 'SPAI')) {
461
+ let curs = _.without(pair_or_pairs_or_cur_curs, 'SPAI')
462
+ needle('get', 'https://www.mexc.com/open/api/v2/market/depth?symbol=SPAI_USDT&depth=100').then((res) => {
463
+ try {
421
464
  const { asks, bids } = res.body.data
422
465
  let rate = (parseFloat(asks[0].price) + parseFloat(bids[0].price)) / 2
423
466
  result.SPAI = {
@@ -425,10 +468,14 @@ let get_crypto_rates = (cb, pair_or_pairs_or_cur_curs, type, source = 'coingecko
425
468
  USDT: rate,
426
469
  }
427
470
  get_crypto_rates(cb, curs, type, source)
428
- })
429
- } else if (type === 'curs' && _.includes(pair_or_pairs_or_cur_curs, 'TIN')) {
430
- let curs = _.without(pair_or_pairs_or_cur_curs, 'TIN')
431
- needle('get', 'https://www.mexc.com/open/api/v2/market/depth?symbol=TIN_USDT&depth=100').then((res) => {
471
+ } catch (error) {
472
+ console.error(error)
473
+ }
474
+ })
475
+ } else if (type === 'curs' && _.includes(pair_or_pairs_or_cur_curs, 'TIN')) {
476
+ let curs = _.without(pair_or_pairs_or_cur_curs, 'TIN')
477
+ needle('get', 'https://www.mexc.com/open/api/v2/market/depth?symbol=TIN_USDT&depth=100').then((res) => {
478
+ try {
432
479
  const { asks, bids } = res.body.data
433
480
  let rate = (parseFloat(asks[0].price) + parseFloat(bids[0].price)) / 2
434
481
  result.TIN = {
@@ -436,12 +483,12 @@ let get_crypto_rates = (cb, pair_or_pairs_or_cur_curs, type, source = 'coingecko
436
483
  USDT: rate,
437
484
  }
438
485
  get_crypto_rates(cb, curs, type, source)
439
- })
440
- } else {
441
- get_crypto_rates_base(cb, pair_or_pairs_or_cur_curs, type)
442
- }
443
- } catch (error) {
444
- console.log('get_crypto_rates', error)
486
+ } catch (error) {
487
+ console.error(error)
488
+ }
489
+ })
490
+ } else {
491
+ get_crypto_rates_base(cb, pair_or_pairs_or_cur_curs, type)
445
492
  }
446
493
  }
447
494
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@icgio/icg-utils",
3
- "version": "1.7.60",
3
+ "version": "1.7.62",
4
4
  "description": "Utils package.",
5
5
  "main": "index.js",
6
6
  "directories": {