@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.
@@ -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 (pair.endsWith('USDT') || pair.endsWith('USDC') || pair.endsWith('TUSD') || pair.endsWith('BUSD') || pair.endsWith('USDS') || pair.endsWith('DKKT') || pair.endsWith('CNYT'))
704
- result = [pair.substr(0, pair.length - 4), pair.substr(pair.length - 4, pair.length)]
705
- else if (pair.endsWith('QC') || pair.endsWith('ZB')) result = [pair.substr(0, pair.length - 2), pair.substr(pair.length - 2, pair.length)]
706
- else result = [pair.substr(0, pair.length - 3), pair.substr(pair.length - 3, pair.length)]
707
- if (time) result[1] += '_' + time
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
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@icgio/icg-utils",
3
- "version": "1.7.35",
3
+ "version": "1.7.37",
4
4
  "description": "Utils package.",
5
5
  "main": "index.js",
6
6
  "directories": {