@icgio/icg-utils 1.7.7 → 1.7.9

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/lib/coingecko.js CHANGED
@@ -14,29 +14,7 @@ const options = {
14
14
  }
15
15
  }
16
16
 
17
- function determine_type(pair_or_pairs_or_cur_curs) {
18
- if (!pair_or_pairs_or_cur_curs || pair_or_pairs_or_cur_curs.length === 0) {
19
- return 'null'
20
- } else if (Array.isArray(pair_or_pairs_or_cur_curs)) {
21
- let pairs_or_curs = pair_or_pairs_or_cur_curs[0]
22
- let [cur, base_cur] = parse_pair(pairs_or_curs)
23
- if (!base_cur || !cur) {
24
- return 'curs'
25
- } else {
26
- return 'pairs'
27
- }
28
- } else {
29
- let [cur, base_cur] = parse_pair(pair_or_pairs_or_cur_curs)
30
- if (!base_cur || !cur) {
31
- return 'cur'
32
- } else {
33
- return 'pair'
34
- }
35
- }
36
- }
37
-
38
- let get_coingecko_rates = (cb, pair_or_pairs_or_cur_curs) => {
39
- let type = determine_type(pair_or_pairs_or_cur_curs)
17
+ let get_coingecko_rates = (cb, pair_or_pairs_or_cur_curs, type) => {
40
18
  if (type === 'pair') {
41
19
  let pair = pair_or_pairs_or_cur_curs
42
20
  let [cur, base_cur] = parse_pair(pair)
@@ -69,6 +47,12 @@ let get_coingecko_rates = (cb, pair_or_pairs_or_cur_curs) => {
69
47
  delete temp['usd']
70
48
  result[cur_id_map[cur_id]] = body[cur_id]
71
49
  }
50
+ for (let stable of stablecoins) {
51
+ result[stable] = {
52
+ USD: 1,
53
+ USDT: 1
54
+ }
55
+ }
72
56
  cb(result)
73
57
  })
74
58
  } else if (type === 'cur') {
@@ -101,6 +85,12 @@ let get_coingecko_rates = (cb, pair_or_pairs_or_cur_curs) => {
101
85
  delete temp['usd']
102
86
  result[cur_id_map[cur_id]] = body[cur_id]
103
87
  }
88
+ for (let stable of stablecoins) {
89
+ result[stable] = {
90
+ USD: 1,
91
+ USDT: 1
92
+ }
93
+ }
104
94
  cb(result)
105
95
  })
106
96
  } else {
@@ -167,10 +157,10 @@ let get_coingecko_rates = (cb, pair_or_pairs_or_cur_curs) => {
167
157
 
168
158
  // get_coingecko_rates((res) => {
169
159
  // console.log(res)
170
- // // // }, ['BTCUSD', 'ETHUSD'])
171
- // // // }, ['BTC', 'ETH'])
172
- // // // }, 'BTCUSDT')
173
- // // // }, 'BTC')
160
+ // // }, ['BTCUSD', 'ETHUSD'])
161
+ // }, ['SWFTC', 'BTC', 'ETH'], 'curs')
162
+ // }, 'ETHUSDC', 'pair')
163
+ // }, 'BTC')
174
164
  // })
175
165
 
176
166
  // https://api.coingecko.com/api/v3/coins/list
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@icgio/icg-utils",
3
- "version": "1.7.7",
3
+ "version": "1.7.9",
4
4
  "description": "Utils package.",
5
5
  "main": "index.js",
6
6
  "directories": {