@icgio/icg-utils 1.8.4 → 1.9.0

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.
@@ -69,9 +69,9 @@ let get_crypto_rates = (cb, pair_or_pairs_or_cur_curs, type, source = 'coingecko
69
69
  function get_crypto_rates_base(cb, pair_or_pairs_or_cur_curs, type) {
70
70
  if (type === 'pair') {
71
71
  let pair = pair_or_pairs_or_cur_curs
72
- let [cur, base_cur] = parse_pair(pair)
72
+ let [cur, quote_cur] = parse_pair(pair)
73
73
  let cur_id = coins_map[cur],
74
- vs_cur = stablecoins.indexOf(base_cur) > -1 ? 'usd' : base_cur.toLowerCase()
74
+ vs_cur = stablecoins.indexOf(quote_cur) > -1 ? 'usd' : quote_cur.toLowerCase()
75
75
  limiter.process(needle.get, `https://api.coingecko.com/api/v3/simple/price?ids=${cur_id}&vs_currencies=${vs_cur}`, (err, res, body) => {
76
76
  if (err) {
77
77
  console.error(pair, err)
@@ -84,7 +84,7 @@ let get_crypto_rates = (cb, pair_or_pairs_or_cur_curs, type, source = 'coingecko
84
84
  let pairs = pair_or_pairs_or_cur_curs
85
85
  let cur_id_map = _.fromPairs(
86
86
  pairs.map((pair) => {
87
- let [cur, base_cur] = parse_pair(pair)
87
+ let [cur, quote_cur] = parse_pair(pair)
88
88
  return [coins_map[cur], cur]
89
89
  })
90
90
  )
@@ -212,7 +212,7 @@ let get_crypto_rates = (cb, pair_or_pairs_or_cur_curs, type, source = 'coingecko
212
212
  })
213
213
  } else if (exchange === 'bitmart') {
214
214
  let pair = cur + '_USDT'
215
- if ((pair = 'ELON_USDT')) {
215
+ if (pair === 'ELON_USDT') {
216
216
  pair = '$ELONSOL_USDT'
217
217
  }
218
218
  let url = `https://api-cloud.bitmart.com/spot/v1/symbols/book?symbol=${pair}`
@@ -526,7 +526,7 @@ let get_crypto_rates = (cb, pair_or_pairs_or_cur_curs, type, source = 'coingecko
526
526
  // },
527
527
  // {
528
528
  // AXL: 'coingecko',
529
- // ELON: 'bitmart',
529
+ // ROBIE: 'bitmart',
530
530
  // POLY: 'ascendex',
531
531
  // },
532
532
  // 'curs_dict'
package/lib/forex-rate.js CHANGED
@@ -2,10 +2,10 @@ const needle = require('needle')
2
2
  const utils = require('./utils.js')
3
3
 
4
4
  let get_forex_rate = function (pair, cb) {
5
- let [cur, base_cur] = utils.parse_pair(pair)
5
+ let [cur, quote_cur] = utils.parse_pair(pair)
6
6
  needle.get(`https://api.exchangerate.host/latest?base=USD`, (err, res, body) => {
7
7
  if (body.rates) {
8
- cb(body.rates[base_cur])
8
+ cb(body.rates[quote_cur])
9
9
  }
10
10
  })
11
11
  }
package/lib/utils.js CHANGED
@@ -793,8 +793,8 @@ module.exports.parse_pair = function (pair) {
793
793
  }
794
794
 
795
795
  module.exports.reverse_pair = function (pair) {
796
- let [cur, base_cur] = module.exports.parse_pair(pair)
797
- return base_cur + cur
796
+ let [cur, quote_cur] = module.exports.parse_pair(pair)
797
+ return quote_cur + cur
798
798
  }
799
799
 
800
800
  module.exports.cur_dict_to_pair_list = function (cur_dict) {
@@ -816,9 +816,9 @@ module.exports.exchange_basecur_curs_converter = (exchange_basecur_curs) => {
816
816
  for (let exchange in exchange_basecur_curs) {
817
817
  _.set(exchange_pairs, [exchange], [])
818
818
  _.set(exchange_curs, [exchange], [])
819
- for (let base_cur in exchange_basecur_curs[exchange]) {
820
- exchange_pairs[exchange] = exchange_pairs[exchange].concat(_.map(exchange_basecur_curs[exchange][base_cur], (cur) => cur + base_cur))
821
- exchange_curs[exchange] = _.union(exchange_curs[exchange], _.union(exchange_basecur_curs[exchange][base_cur], [base_cur]))
819
+ for (let quote_cur in exchange_basecur_curs[exchange]) {
820
+ exchange_pairs[exchange] = exchange_pairs[exchange].concat(_.map(exchange_basecur_curs[exchange][quote_cur], (cur) => cur + quote_cur))
821
+ exchange_curs[exchange] = _.union(exchange_curs[exchange], _.union(exchange_basecur_curs[exchange][quote_cur], [quote_cur]))
822
822
  }
823
823
  }
824
824
  let pair_exchanges = {}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@icgio/icg-utils",
3
- "version": "1.8.4",
3
+ "version": "1.9.0",
4
4
  "description": "Utils package.",
5
5
  "main": "index.js",
6
6
  "directories": {