@gainsnetwork/sdk 0.2.33-rc4 → 0.2.35-rc1

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.
Files changed (39) hide show
  1. package/lib/constants.d.ts +8 -0
  2. package/lib/constants.js +9 -1
  3. package/lib/contracts/types/generated/GNSMultiCollatDiamond.d.ts +312 -673
  4. package/lib/contracts/types/generated/factories/GNSMultiCollatDiamond__factory.js +538 -1443
  5. package/lib/contracts/utils/pairs.js +12 -4
  6. package/lib/trade/fees/index.js +2 -3
  7. package/lib/trade/spread.d.ts +5 -3
  8. package/lib/trade/spread.js +2 -7
  9. package/lib/trade/types.d.ts +11 -13
  10. package/lib/trade/types.js +8 -0
  11. package/package.json +1 -1
  12. package/lib/contracts/types/generated/GFarmTradingStorageV5.d.ts +0 -1911
  13. package/lib/contracts/types/generated/GFarmTradingStorageV5.js +0 -2
  14. package/lib/contracts/types/generated/GNSBorrowingFees.d.ts +0 -1067
  15. package/lib/contracts/types/generated/GNSBorrowingFees.js +0 -2
  16. package/lib/contracts/types/generated/GNSNftRewardsV6.d.ts +0 -533
  17. package/lib/contracts/types/generated/GNSNftRewardsV6.js +0 -2
  18. package/lib/contracts/types/generated/GNSNftRewardsV6_3_1.d.ts +0 -613
  19. package/lib/contracts/types/generated/GNSNftRewardsV6_3_1.js +0 -2
  20. package/lib/contracts/types/generated/GNSTrading.d.ts +0 -758
  21. package/lib/contracts/types/generated/GNSTrading.js +0 -2
  22. package/lib/contracts/types/generated/GNSTradingCallbacks.d.ts +0 -875
  23. package/lib/contracts/types/generated/GNSTradingCallbacks.js +0 -2
  24. package/lib/contracts/types/generated/GNSTradingStorage.d.ts +0 -1387
  25. package/lib/contracts/types/generated/GNSTradingStorage.js +0 -2
  26. package/lib/contracts/types/generated/factories/GFarmTradingStorageV5__factory.d.ts +0 -83
  27. package/lib/contracts/types/generated/factories/GFarmTradingStorageV5__factory.js +0 -2691
  28. package/lib/contracts/types/generated/factories/GNSBorrowingFees__factory.d.ts +0 -124
  29. package/lib/contracts/types/generated/factories/GNSBorrowingFees__factory.js +0 -1784
  30. package/lib/contracts/types/generated/factories/GNSNftRewardsV6_3_1__factory.d.ts +0 -100
  31. package/lib/contracts/types/generated/factories/GNSNftRewardsV6_3_1__factory.js +0 -1116
  32. package/lib/contracts/types/generated/factories/GNSNftRewardsV6__factory.d.ts +0 -100
  33. package/lib/contracts/types/generated/factories/GNSNftRewardsV6__factory.js +0 -1003
  34. package/lib/contracts/types/generated/factories/GNSTradingCallbacks__factory.d.ts +0 -113
  35. package/lib/contracts/types/generated/factories/GNSTradingCallbacks__factory.js +0 -1428
  36. package/lib/contracts/types/generated/factories/GNSTradingStorage__factory.d.ts +0 -96
  37. package/lib/contracts/types/generated/factories/GNSTradingStorage__factory.js +0 -2241
  38. package/lib/contracts/types/generated/factories/GNSTrading__factory.d.ts +0 -95
  39. package/lib/contracts/types/generated/factories/GNSTrading__factory.js +0 -1071
@@ -69,10 +69,10 @@ const fetchFees = (contracts, feeIxs) => __awaiter(void 0, void 0, void 0, funct
69
69
  const fees = yield Promise.all(feeIxs.map(pairIndex => multiCollatContract.fees(pairIndex)));
70
70
  return fees.map(fee => {
71
71
  return {
72
- totalPositionSizeFeeP: parseFloat(fee.totalPositionSizeFeeP.toString()) / 1e12,
73
- totalLiqCollateralFeeP: parseFloat(fee.totalLiqCollateralFeeP.toString()) / 1e12,
74
- oraclePositionSizeFeeP: parseFloat(fee.oraclePositionSizeFeeP.toString()) / 1e12,
75
- minPositionSizeUsd: parseFloat(fee.minPositionSizeUsd.toString()) / 1e3,
72
+ openFeeP: parseFloat(fee.openFeeP.toString()) / 1e12,
73
+ closeFeeP: parseFloat(fee.closeFeeP.toString()) / 1e12,
74
+ triggerOrderFeeP: parseFloat(fee.triggerOrderFeeP.toString()) / 1e12,
75
+ minPositionSizeUsd: parseFloat(fee.minPositionSizeUsd.toString()) / 1e18,
76
76
  };
77
77
  });
78
78
  }
@@ -391,4 +391,12 @@ const PAIR_INDEX_TO_DESCRIPTION = {
391
391
  [types_1.PairIndex.POLYXUSD]: "Polymesh to US Dollar",
392
392
  [types_1.PairIndex.MOODENGUSD]: "Moo Deng to US Dollar",
393
393
  [types_1.PairIndex.MOTHERUSD]: "Mother Iggy to US Dollar",
394
+ [types_1.PairIndex.AEROUSD]: "Aerodrome Finance to US Dollar",
395
+ [types_1.PairIndex.CVCUSD]: "Civic to US Dollar",
396
+ [types_1.PairIndex.NEIROCTOUSD]: "Neiro CTO to US Dollar",
397
+ [types_1.PairIndex.ARKUSD]: "Ark to US Dollar",
398
+ [types_1.PairIndex.NPCUSD]: "Non-Playable Coin to US Dollar",
399
+ [types_1.PairIndex.ORBSUSD]: "ORBS to US Dollar",
400
+ [types_1.PairIndex.APUUSD]: "Apu Apustaja to US Dollar",
401
+ [types_1.PairIndex.BSVUSD]: "Bitcoin SV to US Dollar",
394
402
  };
@@ -22,9 +22,8 @@ const getClosingFee = (posDai, leverage, pairIndex, pairFee, collateralPriceUsd
22
22
  pairFee === undefined) {
23
23
  return 0;
24
24
  }
25
- // @todo check
26
- const { totalPositionSizeFeeP, minPositionSizeUsd } = pairFee;
27
- return (totalPositionSizeFeeP *
25
+ const { closeFeeP, triggerOrderFeeP, minPositionSizeUsd } = pairFee;
26
+ return ((closeFeeP + triggerOrderFeeP) *
28
27
  feeMultiplier *
29
28
  Math.max(collateralPriceUsd && collateralPriceUsd > 0
30
29
  ? minPositionSizeUsd / collateralPriceUsd
@@ -1,14 +1,16 @@
1
- import { LiquidationParams, OiWindows, OiWindowsSettings, PairDepth, PairFactor } from "./types";
1
+ import { LiquidationParams, OiWindows, OiWindowsSettings, PairDepth } from "./types";
2
2
  import { ContractsVersion } from "../contracts/types";
3
3
  export type SpreadContext = {
4
4
  isOpen?: boolean;
5
5
  isPnlPositive?: boolean;
6
+ protectionCloseFactor?: number;
7
+ protectionCloseFactorBlocks?: number;
8
+ cumulativeFactor?: number;
6
9
  createdBlock?: number;
7
10
  liquidationParams?: LiquidationParams | undefined;
8
11
  currentBlock?: number | undefined;
9
12
  contractsVersion?: ContractsVersion | undefined;
10
- protectionCloseFactorWhitelist?: boolean;
11
- } & Partial<PairFactor>;
13
+ };
12
14
  export declare const getProtectionCloseFactor: (spreadCtx: SpreadContext | undefined) => number;
13
15
  export declare const getCumulativeFactor: (spreadCtx: SpreadContext | undefined) => number;
14
16
  export declare const getLegacyFactor: (spreadCtx: SpreadContext | undefined) => number;
@@ -12,8 +12,7 @@ const getProtectionCloseFactor = (spreadCtx) => {
12
12
  spreadCtx.protectionCloseFactor === undefined ||
13
13
  spreadCtx.protectionCloseFactorBlocks === undefined ||
14
14
  spreadCtx.createdBlock === undefined ||
15
- spreadCtx.currentBlock === undefined ||
16
- spreadCtx.protectionCloseFactorWhitelist === true)
15
+ spreadCtx.currentBlock === undefined)
17
16
  return constants_1.DEFAULT_PROTECTION_CLOSE_FACTOR;
18
17
  if (spreadCtx.isPnlPositive &&
19
18
  !spreadCtx.isOpen &&
@@ -26,9 +25,7 @@ const getProtectionCloseFactor = (spreadCtx) => {
26
25
  };
27
26
  exports.getProtectionCloseFactor = getProtectionCloseFactor;
28
27
  const getCumulativeFactor = (spreadCtx) => {
29
- if (spreadCtx === undefined ||
30
- spreadCtx.cumulativeFactor === undefined ||
31
- spreadCtx.cumulativeFactor === 0) {
28
+ if (spreadCtx === undefined || spreadCtx.cumulativeFactor === undefined || spreadCtx.cumulativeFactor === 0) {
32
29
  return constants_1.DEFAULT_CUMULATIVE_FACTOR;
33
30
  }
34
31
  return spreadCtx.cumulativeFactor;
@@ -38,7 +35,6 @@ const getLegacyFactor = (spreadCtx) => {
38
35
  return (spreadCtx === null || spreadCtx === void 0 ? void 0 : spreadCtx.contractsVersion) === types_1.ContractsVersion.BEFORE_V9_2 ? 1 : 2;
39
36
  };
40
37
  exports.getLegacyFactor = getLegacyFactor;
41
- // @todo
42
38
  const getSpreadWithPriceImpactP = (pairSpreadP, buy, collateral, leverage, pairDepth, oiWindowsSettings, oiWindows, spreadCtx) => {
43
39
  if (pairSpreadP === undefined) {
44
40
  return 0;
@@ -64,7 +60,6 @@ const getSpreadWithPriceImpactP = (pairSpreadP, buy, collateral, leverage, pairD
64
60
  if (!onePercentDepth || activeOi === undefined || collateral === undefined) {
65
61
  return pairSpreadP / 2;
66
62
  }
67
- // @todo implement exemptOnOpen && exemptAfterProtectionCloseFactor
68
63
  return ((0, exports.getSpreadP)(pairSpreadP) +
69
64
  ((activeOi * (0, exports.getCumulativeFactor)(spreadCtx) + (collateral * leverage) / 2) /
70
65
  onePercentDepth /
@@ -48,17 +48,10 @@ export type TradingGroup = {
48
48
  name: string;
49
49
  };
50
50
  export type Fee = {
51
- totalPositionSizeFeeP: number;
52
- totalLiqCollateralFeeP: number;
53
- oraclePositionSizeFeeP: number;
51
+ openFeeP: number;
52
+ closeFeeP: number;
54
53
  minPositionSizeUsd: number;
55
- };
56
- export type GlobalTradeFeeParams = {
57
- referralFeeP: number;
58
- govFeeP: number;
59
54
  triggerOrderFeeP: number;
60
- gnsOtcFeeP: number;
61
- gTokenFeeP: number;
62
55
  };
63
56
  export type PairDepth = {
64
57
  onePercentDepthAboveUsd: number;
@@ -176,14 +169,11 @@ export type TraderFeeTiers = {
176
169
  outboundPoints: number;
177
170
  lastDayUpdatedPoints: number;
178
171
  expiredPoints: number[];
179
- unclaimedPoints: number;
180
172
  };
181
173
  export type PairFactor = {
182
174
  cumulativeFactor: number;
183
175
  protectionCloseFactor: number;
184
176
  protectionCloseFactorBlocks: number;
185
- exemptOnOpen: boolean;
186
- exemptAfterProtectionCloseFactor: boolean;
187
177
  };
188
178
  export declare enum PendingOrderType {
189
179
  MARKET_OPEN = 0,
@@ -504,5 +494,13 @@ export declare enum PairIndex {
504
494
  EIGENUSD = 282,
505
495
  POLYXUSD = 283,
506
496
  MOODENGUSD = 284,
507
- MOTHERUSD = 285
497
+ MOTHERUSD = 285,
498
+ AEROUSD = 286,
499
+ CVCUSD = 287,
500
+ NEIROCTOUSD = 288,
501
+ ARKUSD = 289,
502
+ NPCUSD = 290,
503
+ ORBSUSD = 291,
504
+ APUUSD = 292,
505
+ BSVUSD = 293
508
506
  }
@@ -315,4 +315,12 @@ var PairIndex;
315
315
  PairIndex[PairIndex["POLYXUSD"] = 283] = "POLYXUSD";
316
316
  PairIndex[PairIndex["MOODENGUSD"] = 284] = "MOODENGUSD";
317
317
  PairIndex[PairIndex["MOTHERUSD"] = 285] = "MOTHERUSD";
318
+ PairIndex[PairIndex["AEROUSD"] = 286] = "AEROUSD";
319
+ PairIndex[PairIndex["CVCUSD"] = 287] = "CVCUSD";
320
+ PairIndex[PairIndex["NEIROCTOUSD"] = 288] = "NEIROCTOUSD";
321
+ PairIndex[PairIndex["ARKUSD"] = 289] = "ARKUSD";
322
+ PairIndex[PairIndex["NPCUSD"] = 290] = "NPCUSD";
323
+ PairIndex[PairIndex["ORBSUSD"] = 291] = "ORBSUSD";
324
+ PairIndex[PairIndex["APUUSD"] = 292] = "APUUSD";
325
+ PairIndex[PairIndex["BSVUSD"] = 293] = "BSVUSD";
318
326
  })(PairIndex = exports.PairIndex || (exports.PairIndex = {}));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gainsnetwork/sdk",
3
- "version": "0.2.33-rc4",
3
+ "version": "0.2.35-rc1",
4
4
  "description": "Gains Network SDK",
5
5
  "main": "./lib/index.js",
6
6
  "files": [