@gainsnetwork/sdk 0.1.19-rc3 → 0.1.19-rc5
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.
|
@@ -5,7 +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
|
|
8
|
+
export declare const computeFeeMultiplier: (feeTiers: FeeTiers, traderFeeTiers: TraderFeeTiers) => {
|
|
9
9
|
feeMultiplier: number;
|
|
10
10
|
trailingPoints: number;
|
|
11
11
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.computeFeeMultiplier = 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;
|
|
@@ -15,34 +15,35 @@ const getFeeTiersCount = (feeTiers) => {
|
|
|
15
15
|
return 0;
|
|
16
16
|
};
|
|
17
17
|
exports.getFeeTiersCount = getFeeTiersCount;
|
|
18
|
-
const
|
|
18
|
+
const computeFeeMultiplier = (feeTiers, traderFeeTiers) => {
|
|
19
19
|
const { currentDay, tiers } = feeTiers;
|
|
20
20
|
const { traderInfo, expiredPoints, lastDayUpdatedPoints } = traderFeeTiers;
|
|
21
21
|
const { lastDayUpdated, trailingPoints } = traderInfo;
|
|
22
|
+
let curTrailingPoints = trailingPoints;
|
|
22
23
|
if (currentDay > lastDayUpdated) {
|
|
23
|
-
|
|
24
|
+
curTrailingPoints = 0;
|
|
24
25
|
const earliestActiveDay = currentDay - exports.TRAILING_PERIOD_DAYS;
|
|
25
26
|
if (lastDayUpdated >= earliestActiveDay) {
|
|
26
27
|
curTrailingPoints = trailingPoints + lastDayUpdatedPoints;
|
|
27
28
|
const expiredTrailingPoints = expiredPoints.reduce((acc, points) => acc + points, 0);
|
|
28
29
|
curTrailingPoints -= expiredTrailingPoints;
|
|
29
30
|
}
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
31
|
+
}
|
|
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;
|
|
37
38
|
}
|
|
38
|
-
return {
|
|
39
|
-
feeMultiplier: newFeeMultiplier,
|
|
40
|
-
trailingPoints: curTrailingPoints,
|
|
41
|
-
};
|
|
42
39
|
}
|
|
40
|
+
return {
|
|
41
|
+
feeMultiplier: newFeeMultiplier,
|
|
42
|
+
trailingPoints: curTrailingPoints,
|
|
43
|
+
};
|
|
43
44
|
return {
|
|
44
45
|
feeMultiplier: exports.FEE_MULTIPLIER_SCALE,
|
|
45
46
|
trailingPoints,
|
|
46
47
|
};
|
|
47
48
|
};
|
|
48
|
-
exports.
|
|
49
|
+
exports.computeFeeMultiplier = computeFeeMultiplier;
|