@icgio/icg-utils 1.7.35 → 1.7.36
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/stablecoins.js +1 -1
- package/lib/utils.js +13 -6
- package/package.json +1 -1
package/constants/stablecoins.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
module.exports = ['USDT', 'TUSD', 'PAX', 'BUSD', 'USDK', 'USDC', 'HUSD', 'DAI', 'IUSD', 'USDD', 'FEI', 'FRAX']
|
|
1
|
+
module.exports = ['USDT', 'TUSD', 'PAX', 'BUSD', 'USDK', 'USDC', 'HUSD', 'DAI', 'IUSD', 'USDD', 'FEI', 'FRAX', 'CUSD']
|
package/lib/utils.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
const _ = require('lodash')
|
|
2
2
|
|
|
3
|
+
const stablecoins = require('../constants/stablecoins')
|
|
4
|
+
|
|
3
5
|
// Number.prototype.toFixed_old = Number.prototype.toFixed
|
|
4
6
|
|
|
5
7
|
// Number.prototype.toFixed = function(s) {
|
|
@@ -699,12 +701,17 @@ module.exports.parse_pair = function (pair) {
|
|
|
699
701
|
pair = pair.toUpperCase()
|
|
700
702
|
let time
|
|
701
703
|
;[pair, time] = _.split(pair, '_')
|
|
702
|
-
let result
|
|
703
|
-
if (
|
|
704
|
-
result = [pair.substr(0, pair.length -
|
|
705
|
-
else if (pair.endsWith('QC')
|
|
706
|
-
|
|
707
|
-
|
|
704
|
+
let result = ''
|
|
705
|
+
if (stablecoins.some((c) => pair.endsWith(c))) {
|
|
706
|
+
result = [pair.substr(0, pair.length - c.length), pair.substr(pair.length - 4, pair.length)]
|
|
707
|
+
} else if (pair.endsWith('QC')) {
|
|
708
|
+
result = [pair.substr(0, pair.length - 2), pair.substr(pair.length - 2, pair.length)]
|
|
709
|
+
} else {
|
|
710
|
+
result = [pair.substr(0, pair.length - 3), pair.substr(pair.length - 3, pair.length)]
|
|
711
|
+
}
|
|
712
|
+
if (time) {
|
|
713
|
+
result[1] += '_' + time
|
|
714
|
+
}
|
|
708
715
|
return result
|
|
709
716
|
}
|
|
710
717
|
|