@icgio/icg-utils 1.7.71 → 1.7.72

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.
@@ -184,8 +184,7 @@ let get_crypto_rates = (cb, pair_or_pairs_or_cur_curs, type, source = 'coingecko
184
184
  let length = _.keys(curs_dict).length
185
185
  for (let cur in curs_dict) {
186
186
  let exchange = curs_dict[cur]
187
- if (exchange === 'bitforex') {
188
- } else if (exchange === 'bitmart') {
187
+ if (exchange === 'bitmart') {
189
188
  let pair = cur + '_USDT'
190
189
  let url = `https://api-cloud.bitmart.com/spot/v1/symbols/book?symbol=${pair}`
191
190
  limiter.process(needle.get, url, (err, res, body) => {
@@ -312,6 +311,32 @@ let get_crypto_rates = (cb, pair_or_pairs_or_cur_curs, type, source = 'coingecko
312
311
  console.error(pair, error)
313
312
  }
314
313
  })
314
+ } else if (exchange === 'p2b') {
315
+ let pair = cur + '_USDT'
316
+ let url = `https://api.p2pb2b.com/api/v2/public/depth/result?market=${pair}`
317
+ limiter.process(needle.get, url, (err, res, body) => {
318
+ try {
319
+ const asks = body.result.asks
320
+ const bids = body.result.bids
321
+ let rate = (parseFloat(asks[0][0]) + parseFloat(bids[0][0])) / 2
322
+ result[cur] = {
323
+ USD: rate,
324
+ USDT: rate,
325
+ }
326
+ let result_length = _.keys(result).length
327
+ if (result_length === length) {
328
+ for (let stable of stablecoins) {
329
+ result[stable] = {
330
+ USD: 1,
331
+ USDT: 1,
332
+ }
333
+ }
334
+ cb(result)
335
+ }
336
+ } catch (error) {
337
+ console.error(pair, error)
338
+ }
339
+ })
315
340
  } else if (exchange === 'xt') {
316
341
  let pair = cur.toLowerCase() + '_usdt'
317
342
  let url = `https://sapi.xt.com/v4/public/depth?symbol=${pair}&limit=20`
@@ -446,10 +471,7 @@ let get_crypto_rates = (cb, pair_or_pairs_or_cur_curs, type, source = 'coingecko
446
471
  // },
447
472
  // {
448
473
  // AXL: 'coingecko',
449
- // BDCC: 'lbank',
450
- // DMC: 'gate',
451
- // SHRAP: 'lbank',
452
- // SST: 'mexc',
474
+ // OPULENCE: 'p2b',
453
475
  // },
454
476
  // 'curs_dict'
455
477
  // )
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@icgio/icg-utils",
3
- "version": "1.7.71",
3
+ "version": "1.7.72",
4
4
  "description": "Utils package.",
5
5
  "main": "index.js",
6
6
  "directories": {