@gainsnetwork/sdk 0.1.18-rc1 → 0.1.18-rc2
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,
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
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]);
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { FeeTiers, TraderFeeTiers } from "../../types";
|
|
2
|
+
import { FeeTier } from "./types";
|
|
3
|
+
export declare const TRAILING_PERIOD_DAYS = 30;
|
|
4
|
+
export declare const FEE_MULTIPLIER_SCALE = 1;
|
|
5
|
+
export declare const MAX_FEE_TIERS = 8;
|
|
6
|
+
export declare const getCurrentDay: () => number;
|
|
7
|
+
export declare const getFeeTiersCount: (feeTiers: FeeTier[]) => number;
|
|
8
|
+
export declare const computeFeeMultiplier: (feeTiers: FeeTiers, traderFeeTiers: TraderFeeTiers) => {
|
|
9
|
+
feeMultiplier: number;
|
|
10
|
+
trailingPoints: number;
|
|
11
|
+
};
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
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;
|
|
4
|
+
exports.TRAILING_PERIOD_DAYS = 30;
|
|
5
|
+
exports.FEE_MULTIPLIER_SCALE = 1;
|
|
6
|
+
exports.MAX_FEE_TIERS = 8;
|
|
7
|
+
const getCurrentDay = () => Math.floor(Date.now() / 1000 / 60 / 60 / 24);
|
|
8
|
+
exports.getCurrentDay = getCurrentDay;
|
|
9
|
+
const getFeeTiersCount = (feeTiers) => {
|
|
10
|
+
for (let i = exports.MAX_FEE_TIERS; i > 0; --i) {
|
|
11
|
+
if (feeTiers[i - 1].feeMultiplier > 0) {
|
|
12
|
+
return i;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
return 0;
|
|
16
|
+
};
|
|
17
|
+
exports.getFeeTiersCount = getFeeTiersCount;
|
|
18
|
+
const computeFeeMultiplier = (feeTiers, traderFeeTiers) => {
|
|
19
|
+
const { currentDay, tiers } = feeTiers;
|
|
20
|
+
const { traderInfo, expiredPoints, lastDayUpdatedPoints } = traderFeeTiers;
|
|
21
|
+
const { lastDayUpdated, trailingPoints } = traderInfo;
|
|
22
|
+
let curTrailingPoints = trailingPoints;
|
|
23
|
+
if (currentDay > lastDayUpdated) {
|
|
24
|
+
curTrailingPoints = 0;
|
|
25
|
+
const earliestActiveDay = currentDay - exports.TRAILING_PERIOD_DAYS;
|
|
26
|
+
if (lastDayUpdated >= earliestActiveDay) {
|
|
27
|
+
curTrailingPoints = trailingPoints + lastDayUpdatedPoints;
|
|
28
|
+
const expiredTrailingPoints = expiredPoints.reduce((acc, points) => acc + points, 0);
|
|
29
|
+
curTrailingPoints -= expiredTrailingPoints;
|
|
30
|
+
}
|
|
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;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
return {
|
|
41
|
+
feeMultiplier: newFeeMultiplier,
|
|
42
|
+
trailingPoints: curTrailingPoints,
|
|
43
|
+
};
|
|
44
|
+
return {
|
|
45
|
+
feeMultiplier: exports.FEE_MULTIPLIER_SCALE,
|
|
46
|
+
trailingPoints,
|
|
47
|
+
};
|
|
48
|
+
};
|
|
49
|
+
exports.computeFeeMultiplier = computeFeeMultiplier;
|