@icgio/icg-utils 1.7.52 → 1.7.54

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 +47 -56
  2. package/package.json +1 -1
@@ -237,16 +237,7 @@ let get_crypto_rates = (cb, pair_or_pairs_or_cur_curs, type, source = 'coingecko
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
239
  try {
240
- if (type === 'curs' && _.includes(pair_or_pairs_or_cur_curs, 'FREN')) {
241
- let curs = _.without(pair_or_pairs_or_cur_curs, 'FREN')
242
- dex_rate().then((res) => {
243
- result.FREN = {
244
- USD: res.FRENUSDT,
245
- USDT: res.FRENUSDT,
246
- }
247
- get_crypto_rates(cb, curs, type, source)
248
- })
249
- } else if (type === 'curs' && _.includes(pair_or_pairs_or_cur_curs, 'BBDC')) {
240
+ if (type === 'curs' && _.includes(pair_or_pairs_or_cur_curs, 'BBDC')) {
250
241
  let curs = _.without(pair_or_pairs_or_cur_curs, 'BBDC')
251
242
  needle('get', 'https://www.mexc.com/open/api/v2/market/depth?symbol=BBDC_USDT&depth=100').then((res) => {
252
243
  const { asks, bids } = res.body.data
@@ -257,17 +248,6 @@ let get_crypto_rates = (cb, pair_or_pairs_or_cur_curs, type, source = 'coingecko
257
248
  }
258
249
  get_crypto_rates(cb, curs, type, source)
259
250
  })
260
- } else if (type === 'curs' && _.includes(pair_or_pairs_or_cur_curs, 'CLOAK')) {
261
- let curs = _.without(pair_or_pairs_or_cur_curs, 'CLOAK')
262
- needle('get', 'https://www.mexc.com/open/api/v2/market/depth?symbol=CLOAK_USDT&depth=100').then((res) => {
263
- const { asks, bids } = res.body.data
264
- let rate = (parseFloat(asks[0].price) + parseFloat(bids[0].price)) / 2
265
- result.CLOAK = {
266
- USD: rate,
267
- USDT: rate,
268
- }
269
- get_crypto_rates(cb, curs, type, source)
270
- })
271
251
  } else if (type === 'curs' && _.includes(pair_or_pairs_or_cur_curs, 'DARK')) {
272
252
  let curs = _.without(pair_or_pairs_or_cur_curs, 'DARK')
273
253
  needle('get', 'https://www.mexc.com/open/api/v2/market/depth?symbol=DARK_USDT&depth=100').then((res) => {
@@ -301,14 +281,12 @@ let get_crypto_rates = (cb, pair_or_pairs_or_cur_curs, type, source = 'coingecko
301
281
  }
302
282
  get_crypto_rates(cb, curs, type, source)
303
283
  })
304
- } else if (type === 'curs' && _.includes(pair_or_pairs_or_cur_curs, 'FINU')) {
305
- let curs = _.without(pair_or_pairs_or_cur_curs, 'FINU')
306
- needle('get', 'https://www.mexc.com/open/api/v2/market/depth?symbol=FINU_USDT&depth=100').then((res) => {
307
- const { asks, bids } = res.body.data
308
- let rate = (parseFloat(asks[0].price) + parseFloat(bids[0].price)) / 2
309
- result.FINU = {
310
- USD: rate,
311
- USDT: rate,
284
+ } else if (type === 'curs' && _.includes(pair_or_pairs_or_cur_curs, 'FREN')) {
285
+ let curs = _.without(pair_or_pairs_or_cur_curs, 'FREN')
286
+ dex_rate().then((res) => {
287
+ result.FREN = {
288
+ USD: res.FRENUSDT,
289
+ USDT: res.FRENUSDT,
312
290
  }
313
291
  get_crypto_rates(cb, curs, type, source)
314
292
  })
@@ -323,6 +301,17 @@ let get_crypto_rates = (cb, pair_or_pairs_or_cur_curs, type, source = 'coingecko
323
301
  }
324
302
  get_crypto_rates(cb, curs, type, source)
325
303
  })
304
+ } else if (type === 'curs' && _.includes(pair_or_pairs_or_cur_curs, 'IUS')) {
305
+ let curs = _.without(pair_or_pairs_or_cur_curs, 'IUS')
306
+ needle('get', 'https://api.coinsbit.io/api/v1/public/depth/result?market=IUS_USDT&limit=10').then((res) => {
307
+ const { asks, bids } = res.body
308
+ let rate = (parseFloat(asks[0][0]) + parseFloat(bids.reverse()[0][0])) / 2
309
+ result.IUS = {
310
+ USD: rate,
311
+ USDT: rate,
312
+ }
313
+ get_crypto_rates(cb, curs, type, source)
314
+ })
326
315
  } else if (type === 'curs' && _.includes(pair_or_pairs_or_cur_curs, 'KLC')) {
327
316
  let curs = _.without(pair_or_pairs_or_cur_curs, 'KLC')
328
317
  needle('get', 'https://www.mexc.com/open/api/v2/market/depth?symbol=KLC_USDT&depth=100').then((res) => {
@@ -345,6 +334,19 @@ let get_crypto_rates = (cb, pair_or_pairs_or_cur_curs, type, source = 'coingecko
345
334
  }
346
335
  get_crypto_rates(cb, curs, type, source)
347
336
  })
337
+ } else if (type === 'curs' && _.includes(pair_or_pairs_or_cur_curs, 'MONE')) {
338
+ let curs = _.without(pair_or_pairs_or_cur_curs, 'MONE')
339
+ needle('get', 'https://www.bitforex.com/api/v1/market/depth?symbol=coin-usdt-mone').then((res) => {
340
+ try {
341
+ const { asks, bids } = JSON.parse(res.body).data
342
+ let rate = (parseFloat(asks[0].price) + parseFloat(bids[0].price)) / 2
343
+ result.MONE = {
344
+ USD: rate,
345
+ USDT: rate,
346
+ }
347
+ get_crypto_rates(cb, curs, type, source)
348
+ } catch (error) {}
349
+ })
348
350
  } else if (type === 'curs' && _.includes(pair_or_pairs_or_cur_curs, 'ROACHCOIN')) {
349
351
  let curs = _.without(pair_or_pairs_or_cur_curs, 'ROACHCOIN')
350
352
  needle('get', 'https://www.mexc.com/open/api/v2/market/depth?symbol=ROACHCOIN_USDT&depth=100').then((res) => {
@@ -367,34 +369,23 @@ let get_crypto_rates = (cb, pair_or_pairs_or_cur_curs, type, source = 'coingecko
367
369
  }
368
370
  get_crypto_rates(cb, curs, type, source)
369
371
  })
370
- } else if (type === 'curs' && _.includes(pair_or_pairs_or_cur_curs, 'TIN')) {
371
- let curs = _.without(pair_or_pairs_or_cur_curs, 'TIN')
372
- needle('get', 'https://www.mexc.com/open/api/v2/market/depth?symbol=TIN_USDT&depth=100').then((res) => {
372
+ } else if (type === 'curs' && _.includes(pair_or_pairs_or_cur_curs, 'SPAI')) {
373
+ let curs = _.without(pair_or_pairs_or_cur_curs, 'SPAI')
374
+ needle('get', 'https://www.mexc.com/open/api/v2/market/depth?symbol=SPAI_USDT&depth=100').then((res) => {
373
375
  const { asks, bids } = res.body.data
374
376
  let rate = (parseFloat(asks[0].price) + parseFloat(bids[0].price)) / 2
375
- result.TIN = {
377
+ result.SPAI = {
376
378
  USD: rate,
377
379
  USDT: rate,
378
380
  }
379
381
  get_crypto_rates(cb, curs, type, source)
380
382
  })
381
- } else if (type === 'curs' && _.includes(pair_or_pairs_or_cur_curs, 'UCF')) {
382
- let curs = _.without(pair_or_pairs_or_cur_curs, 'UCF')
383
- needle('get', 'https://www.mexc.com/open/api/v2/market/depth?symbol=UCF_USDT&depth=100').then((res) => {
384
- const { asks, bids } = res.body.data
385
- let rate = (parseFloat(asks[0].price) + parseFloat(bids[0].price)) / 2
386
- result.UCF = {
387
- USD: rate,
388
- USDT: rate,
389
- }
390
- get_crypto_rates(cb, curs, type, source)
391
- })
392
- } else if (type === 'curs' && _.includes(pair_or_pairs_or_cur_curs, 'WPAY')) {
393
- let curs = _.without(pair_or_pairs_or_cur_curs, 'WPAY')
394
- needle('get', 'https://www.mexc.com/open/api/v2/market/depth?symbol=WPAY_USDT&depth=100').then((res) => {
383
+ } else if (type === 'curs' && _.includes(pair_or_pairs_or_cur_curs, 'TIN')) {
384
+ let curs = _.without(pair_or_pairs_or_cur_curs, 'TIN')
385
+ needle('get', 'https://www.mexc.com/open/api/v2/market/depth?symbol=TIN_USDT&depth=100').then((res) => {
395
386
  const { asks, bids } = res.body.data
396
387
  let rate = (parseFloat(asks[0].price) + parseFloat(bids[0].price)) / 2
397
- result.WPAY = {
388
+ result.TIN = {
398
389
  USD: rate,
399
390
  USDT: rate,
400
391
  }
@@ -408,14 +399,14 @@ let get_crypto_rates = (cb, pair_or_pairs_or_cur_curs, type, source = 'coingecko
408
399
  }
409
400
  }
410
401
 
411
- // get_crypto_rates(
412
- // (res) => {
413
- // console.log(res)
414
- // },
415
- // ['BTC', 'ETH', 'ENIX', 'FINU', 'WPAY', 'FREN', 'DMC'],
416
- // 'curs',
417
- // 'coingecko'
418
- // )
402
+ get_crypto_rates(
403
+ (res) => {
404
+ console.log(res)
405
+ },
406
+ ['BTC', 'ETH', 'ENIX', 'FREN', 'DMC', 'IUS', 'MONE'],
407
+ 'curs',
408
+ 'coingecko'
409
+ )
419
410
 
420
411
  // dex_rate().then((res) => {
421
412
  // console.log(res)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@icgio/icg-utils",
3
- "version": "1.7.52",
3
+ "version": "1.7.54",
4
4
  "description": "Utils package.",
5
5
  "main": "index.js",
6
6
  "directories": {