@icgio/icg-utils 1.7.35 → 1.7.37
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 +14 -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,18 @@ 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
|
-
|
|
705
|
-
|
|
706
|
-
else
|
|
707
|
-
|
|
704
|
+
let result = ''
|
|
705
|
+
if (stablecoins.some((c) => pair.endsWith(c))) {
|
|
706
|
+
let stablecoin = stablecoins.find((c) => pair.endsWith(c))
|
|
707
|
+
result = [pair.substr(0, pair.length - stablecoin.length), pair.substr(pair.length - stablecoin.length, pair.length)]
|
|
708
|
+
} else if (pair.endsWith('QC')) {
|
|
709
|
+
result = [pair.substr(0, pair.length - 2), pair.substr(pair.length - 2, pair.length)]
|
|
710
|
+
} else {
|
|
711
|
+
result = [pair.substr(0, pair.length - 3), pair.substr(pair.length - 3, pair.length)]
|
|
712
|
+
}
|
|
713
|
+
if (time) {
|
|
714
|
+
result[1] += '_' + time
|
|
715
|
+
}
|
|
708
716
|
return result
|
|
709
717
|
}
|
|
710
718
|
|