@icgio/icg-utils 1.7.66 → 1.7.67
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/crypto-rates.js +27 -0
- package/package.json +1 -1
package/lib/crypto-rates.js
CHANGED
|
@@ -208,6 +208,32 @@ let get_crypto_rates = (cb, pair_or_pairs_or_cur_curs, type, source = 'coingecko
|
|
|
208
208
|
console.error(error)
|
|
209
209
|
}
|
|
210
210
|
})
|
|
211
|
+
} else if (exchange === 'bitmart') {
|
|
212
|
+
let pair = cur + '_USDT'
|
|
213
|
+
let url = `https://api-cloud.bitmart.com/spot/v1/symbols/book?symbol=${pair}`
|
|
214
|
+
limiter.process(needle.get, url, (err, res, body) => {
|
|
215
|
+
try {
|
|
216
|
+
const asks = body.data.sells
|
|
217
|
+
const bids = body.data.buys
|
|
218
|
+
let rate = (parseFloat(asks[0].price) + parseFloat(bids[0].price)) / 2
|
|
219
|
+
result[cur] = {
|
|
220
|
+
USD: rate,
|
|
221
|
+
USDT: rate,
|
|
222
|
+
}
|
|
223
|
+
let result_length = _.keys(result).length
|
|
224
|
+
if (result_length === length) {
|
|
225
|
+
for (let stable of stablecoins) {
|
|
226
|
+
result[stable] = {
|
|
227
|
+
USD: 1,
|
|
228
|
+
USDT: 1,
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
cb(result)
|
|
232
|
+
}
|
|
233
|
+
} catch (error) {
|
|
234
|
+
console.error(error)
|
|
235
|
+
}
|
|
236
|
+
})
|
|
211
237
|
} else if (exchange === 'gate') {
|
|
212
238
|
let pair = cur + '_USDT'
|
|
213
239
|
let url = `https://api.gateio.ws/api/v4/spot/order_book?currency_pair=${pair}`
|
|
@@ -371,6 +397,7 @@ let get_crypto_rates = (cb, pair_or_pairs_or_cur_curs, type, source = 'coingecko
|
|
|
371
397
|
// console.log(res)
|
|
372
398
|
// },
|
|
373
399
|
// {
|
|
400
|
+
// AICB: 'bitmart',
|
|
374
401
|
// ENIX: 'mexc',
|
|
375
402
|
// FREN: 'pancakeswap',
|
|
376
403
|
// RWX: 'pancakeswap',
|