@gainsnetwork/sdk 0.1.17-rc2 → 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.
@@ -214,6 +214,10 @@ export declare const pairs: {
214
214
  "ETHFI/USD": string;
215
215
  "METIS/USD": string;
216
216
  "AEVO/USD": string;
217
+ "ONDO/USD": string;
218
+ "MNT/USD": string;
219
+ "KAS/USD": string;
220
+ "RON/USD": string;
217
221
  };
218
222
  export declare const getAssetClassFromGroupIndex: (groupIndex: number) => string | undefined;
219
223
  export declare const tickerChanges: {
package/lib/constants.js CHANGED
@@ -222,6 +222,10 @@ exports.pairs = {
222
222
  "ETHFI/USD": CRYPTO,
223
223
  "METIS/USD": CRYPTO,
224
224
  "AEVO/USD": CRYPTO,
225
+ "ONDO/USD": CRYPTO,
226
+ "MNT/USD": CRYPTO,
227
+ "KAS/USD": CRYPTO,
228
+ "RON/USD": CRYPTO,
225
229
  };
226
230
  const getAssetClassFromGroupIndex = (groupIndex) => {
227
231
  switch (groupIndex) {
@@ -253,9 +257,9 @@ exports.stockSplits = {
253
257
  "TSLA_1/USD": { date: "8/25/2022", split: 3 },
254
258
  };
255
259
  exports.delistedPairIxs = new Set([
256
- 6, 31, 36, 42, 45, 48, 50, 51, 54, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68,
257
- 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87,
258
- 88, 89, 97, 99, 101, 106, 107, 108, 52, 131, 147, 157, 160, 179, 182, 183,
259
- 190, 194,
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,
260
264
  ]);
261
265
  exports.delistedGroupsIxs = new Set([6, 7]);
@@ -317,4 +317,8 @@ const PAIR_INDEX_TO_DESCRIPTION = {
317
317
  [types_1.PairIndex.ETHFIUSD]: "EtherFi to US Dollar",
318
318
  [types_1.PairIndex.METISUSD]: "Metis to US Dollar",
319
319
  [types_1.PairIndex.AEVOUSD]: "Aevo to US Dollar",
320
+ [types_1.PairIndex.ONDOUSD]: "Ondo to US Dollar",
321
+ [types_1.PairIndex.MNTUSD]: "Mantle to US Dollar",
322
+ [types_1.PairIndex.KASUSD]: "Kaspa to US Dollar",
323
+ [types_1.PairIndex.RONUSD]: "Ronin to US Dollar",
320
324
  };
@@ -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;
@@ -0,0 +1,8 @@
1
+ export type FeeTier = {
2
+ feeMultiplier: number;
3
+ pointsThreshold: number;
4
+ };
5
+ export type TraderInfo = {
6
+ lastDayUpdated: number;
7
+ trailingPoints: number;
8
+ };
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -395,5 +395,9 @@ export declare enum PairIndex {
395
395
  BOMEUSD = 211,
396
396
  ETHFIUSD = 212,
397
397
  METISUSD = 213,
398
- AEVOUSD = 214
398
+ AEVOUSD = 214,
399
+ ONDOUSD = 215,
400
+ MNTUSD = 216,
401
+ KASUSD = 217,
402
+ RONUSD = 218
399
403
  }
@@ -229,4 +229,8 @@ var PairIndex;
229
229
  PairIndex[PairIndex["ETHFIUSD"] = 212] = "ETHFIUSD";
230
230
  PairIndex[PairIndex["METISUSD"] = 213] = "METISUSD";
231
231
  PairIndex[PairIndex["AEVOUSD"] = 214] = "AEVOUSD";
232
+ PairIndex[PairIndex["ONDOUSD"] = 215] = "ONDOUSD";
233
+ PairIndex[PairIndex["MNTUSD"] = 216] = "MNTUSD";
234
+ PairIndex[PairIndex["KASUSD"] = 217] = "KASUSD";
235
+ PairIndex[PairIndex["RONUSD"] = 218] = "RONUSD";
232
236
  })(PairIndex = exports.PairIndex || (exports.PairIndex = {}));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gainsnetwork/sdk",
3
- "version": "0.1.17-rc2",
3
+ "version": "0.1.18-rc2",
4
4
  "description": "Gains Network SDK",
5
5
  "main": "./lib/index.js",
6
6
  "files": [