@gainsnetwork/sdk 0.1.19-rc5 → 0.1.19-rc8

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/constants.js CHANGED
@@ -257,9 +257,9 @@ exports.stockSplits = {
257
257
  "TSLA_1/USD": { date: "8/25/2022", split: 3 },
258
258
  };
259
259
  exports.delistedPairIxs = new Set([
260
- 6, 31, 36, 42, 45, 48, 50, 51, 54, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68,
261
- 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87,
262
- 88, 89, 97, 99, 101, 106, 107, 108, 52, 131, 147, 157, 160, 179, 182, 183,
263
- 190, 194, 215, 216, 217, 218
260
+ 6, 31, 36, 42, 45, 48, 51, 54, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69,
261
+ 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88,
262
+ 89, 97, 99, 101, 106, 107, 108, 52, 131, 147, 160, 179, 182, 183, 190, 194,
263
+ 218,
264
264
  ]);
265
265
  exports.delistedGroupsIxs = new Set([6, 7]);
@@ -5,6 +5,7 @@ export declare const FEE_MULTIPLIER_SCALE = 1;
5
5
  export declare const MAX_FEE_TIERS = 8;
6
6
  export declare const getCurrentDay: () => number;
7
7
  export declare const getFeeTiersCount: (feeTiers: FeeTier[]) => number;
8
+ export declare const getFeeMultiplier: (trailingPoints: number, tiers: FeeTier[]) => number;
8
9
  export declare const computeFeeMultiplier: (feeTiers: FeeTiers, traderFeeTiers: TraderFeeTiers) => {
9
10
  feeMultiplier: number;
10
11
  trailingPoints: number;
@@ -1,20 +1,33 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.computeFeeMultiplier = exports.getFeeTiersCount = exports.getCurrentDay = exports.MAX_FEE_TIERS = exports.FEE_MULTIPLIER_SCALE = exports.TRAILING_PERIOD_DAYS = void 0;
3
+ exports.computeFeeMultiplier = exports.getFeeMultiplier = exports.getFeeTiersCount = exports.getCurrentDay = exports.MAX_FEE_TIERS = exports.FEE_MULTIPLIER_SCALE = exports.TRAILING_PERIOD_DAYS = void 0;
4
4
  exports.TRAILING_PERIOD_DAYS = 30;
5
5
  exports.FEE_MULTIPLIER_SCALE = 1;
6
6
  exports.MAX_FEE_TIERS = 8;
7
7
  const getCurrentDay = () => Math.floor(Date.now() / 1000 / 60 / 60 / 24);
8
8
  exports.getCurrentDay = getCurrentDay;
9
9
  const getFeeTiersCount = (feeTiers) => {
10
+ var _a;
10
11
  for (let i = exports.MAX_FEE_TIERS; i > 0; --i) {
11
- if (feeTiers[i - 1].feeMultiplier > 0) {
12
+ if (((_a = feeTiers[i - 1]) === null || _a === void 0 ? void 0 : _a.feeMultiplier) > 0) {
12
13
  return i;
13
14
  }
14
15
  }
15
16
  return 0;
16
17
  };
17
18
  exports.getFeeTiersCount = getFeeTiersCount;
19
+ const getFeeMultiplier = (trailingPoints, tiers) => {
20
+ let feeMultiplier = exports.FEE_MULTIPLIER_SCALE;
21
+ for (let i = (0, exports.getFeeTiersCount)(tiers); i > 0; --i) {
22
+ const feeTier = tiers[i - 1];
23
+ if (trailingPoints >= feeTier.pointsThreshold) {
24
+ feeMultiplier = feeTier.feeMultiplier;
25
+ break;
26
+ }
27
+ }
28
+ return feeMultiplier;
29
+ };
30
+ exports.getFeeMultiplier = getFeeMultiplier;
18
31
  const computeFeeMultiplier = (feeTiers, traderFeeTiers) => {
19
32
  const { currentDay, tiers } = feeTiers;
20
33
  const { traderInfo, expiredPoints, lastDayUpdatedPoints } = traderFeeTiers;
@@ -29,21 +42,10 @@ const computeFeeMultiplier = (feeTiers, traderFeeTiers) => {
29
42
  curTrailingPoints -= expiredTrailingPoints;
30
43
  }
31
44
  }
32
- let newFeeMultiplier = exports.FEE_MULTIPLIER_SCALE;
33
- for (let i = (0, exports.getFeeTiersCount)(tiers); i > 0; --i) {
34
- const feeTier = tiers[i - 1];
35
- if (curTrailingPoints >= feeTier.pointsThreshold) {
36
- newFeeMultiplier = feeTier.feeMultiplier;
37
- break;
38
- }
39
- }
45
+ const feeMultiplier = (0, exports.getFeeMultiplier)(curTrailingPoints, tiers);
40
46
  return {
41
- feeMultiplier: newFeeMultiplier,
47
+ feeMultiplier,
42
48
  trailingPoints: curTrailingPoints,
43
49
  };
44
- return {
45
- feeMultiplier: exports.FEE_MULTIPLIER_SCALE,
46
- trailingPoints,
47
- };
48
50
  };
49
51
  exports.computeFeeMultiplier = computeFeeMultiplier;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gainsnetwork/sdk",
3
- "version": "0.1.19-rc5",
3
+ "version": "0.1.19-rc8",
4
4
  "description": "Gains Network SDK",
5
5
  "main": "./lib/index.js",
6
6
  "files": [