@icgio/icg-utils 1.8.2 → 1.8.4
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/constants/forex-rate.js +3 -3
- package/constants/stablecoins.js +1 -1
- package/lib/crypto-rates.js +32 -2
- package/package.json +1 -1
package/constants/forex-rate.js
CHANGED
package/constants/stablecoins.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
module.exports = ['BUSD', 'CUSD', 'DAI', 'FEI', 'FRAX', 'GUSD', '
|
|
1
|
+
module.exports = ['BUSD', 'CUSD', 'DAI', 'FEI', 'FRAX', 'GUSD', 'PAX', 'SUSD', 'TUSD', 'USDC', 'USDD', 'USDJ', 'USDK', 'USDP', 'USDT']
|
package/lib/crypto-rates.js
CHANGED
|
@@ -184,8 +184,37 @@ 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 === '
|
|
187
|
+
if (exchange === 'ascendex') {
|
|
188
|
+
let pair = cur + '/USDT'
|
|
189
|
+
let url = `https://ascendex.com/api/pro/v1/depth?symbol=${pair}`
|
|
190
|
+
limiter.process(needle.get, url, (err, res, body) => {
|
|
191
|
+
try {
|
|
192
|
+
const asks = body.data.data.asks
|
|
193
|
+
const bids = body.data.data.bids
|
|
194
|
+
let rate = (parseFloat(asks[0][0]) + parseFloat(bids[0][0])) / 2
|
|
195
|
+
result[cur] = {
|
|
196
|
+
USD: rate,
|
|
197
|
+
USDT: rate,
|
|
198
|
+
}
|
|
199
|
+
let result_length = _.keys(result).length
|
|
200
|
+
if (result_length === length) {
|
|
201
|
+
for (let stable of stablecoins) {
|
|
202
|
+
result[stable] = {
|
|
203
|
+
USD: 1,
|
|
204
|
+
USDT: 1,
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
cb(result)
|
|
208
|
+
}
|
|
209
|
+
} catch (error) {
|
|
210
|
+
console.error(pair, error)
|
|
211
|
+
}
|
|
212
|
+
})
|
|
213
|
+
} else if (exchange === 'bitmart') {
|
|
188
214
|
let pair = cur + '_USDT'
|
|
215
|
+
if ((pair = 'ELON_USDT')) {
|
|
216
|
+
pair = '$ELONSOL_USDT'
|
|
217
|
+
}
|
|
189
218
|
let url = `https://api-cloud.bitmart.com/spot/v1/symbols/book?symbol=${pair}`
|
|
190
219
|
limiter.process(needle.get, url, (err, res, body) => {
|
|
191
220
|
try {
|
|
@@ -497,7 +526,8 @@ let get_crypto_rates = (cb, pair_or_pairs_or_cur_curs, type, source = 'coingecko
|
|
|
497
526
|
// },
|
|
498
527
|
// {
|
|
499
528
|
// AXL: 'coingecko',
|
|
500
|
-
//
|
|
529
|
+
// ELON: 'bitmart',
|
|
530
|
+
// POLY: 'ascendex',
|
|
501
531
|
// },
|
|
502
532
|
// 'curs_dict'
|
|
503
533
|
// )
|