@gainsnetwork/sdk 0.2.60-rc1 → 0.2.61-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.
@@ -458,4 +458,15 @@ const PAIR_INDEX_TO_DESCRIPTION = {
458
458
  [types_1.PairIndex.PIUSD]: "Pi Network to US Dollar",
459
459
  [types_1.PairIndex.SHELLUSD]: "MyShell to US Dollar",
460
460
  [types_1.PairIndex.BMTUSD]: "Bubblemaps to US Dollar",
461
+ [types_1.PairIndex.BROCCOLIUSD]: "CZ'S Dog to US Dollar",
462
+ [types_1.PairIndex.TUTUSD]: "Tutorial to US Dollar",
463
+ [types_1.PairIndex.GPSUSD]: "GoPlus Security to US Dollar",
464
+ [types_1.PairIndex.REDUSD]: "RedStone to US Dollar",
465
+ [types_1.PairIndex.MUBARAKUSD]: "Mubarak to US Dollar",
466
+ [types_1.PairIndex.FORMUSD]: "Four to US Dollar",
467
+ [types_1.PairIndex.WALUSD]: "Walrus to US Dollar",
468
+ [types_1.PairIndex.NILUSD]: "Nillion to US Dollar",
469
+ [types_1.PairIndex.PARTIUSD]: "Particle Network to US Dollar",
470
+ [types_1.PairIndex.SIRENUSD]: "Siren to US Dollar",
471
+ [types_1.PairIndex.BANANAS31]: "Banana For Scale to US Dollar",
461
472
  };
@@ -1,12 +1,11 @@
1
1
  import { GetBorrowingFeeContext, BorrowingFee } from "./fees";
2
- import { Fee, LiquidationParams, Trade, UserPriceImpact } from "./types";
2
+ import { Fee, LiquidationParams, Trade } from "./types";
3
3
  import { ContractsVersion } from "../contracts/types";
4
4
  export type GetLiquidationPriceContext = GetBorrowingFeeContext & {
5
5
  liquidationParams: LiquidationParams | undefined;
6
6
  pairSpreadP: number | undefined;
7
7
  collateralPriceUsd: number | undefined;
8
8
  contractsVersion: ContractsVersion | undefined;
9
- userPriceImpact?: UserPriceImpact | undefined;
10
9
  };
11
10
  export declare const getLiquidationPrice: (trade: Trade, fee: Fee, initialAccFees: BorrowingFee.InitialAccFees, context: GetLiquidationPriceContext) => number;
12
11
  export declare const getLiqPnlThresholdP: (liquidationParams: LiquidationParams | undefined, leverage: number | undefined) => number;
@@ -5,7 +5,7 @@ const fees_1 = require("./fees");
5
5
  const spread_1 = require("./spread");
6
6
  const types_1 = require("../contracts/types");
7
7
  const getLiquidationPrice = (trade, fee, initialAccFees, context) => {
8
- var _a, _b;
8
+ var _a;
9
9
  const closingFee = (0, fees_1.getClosingFee)(trade.collateralAmount, trade.leverage, trade.pairIndex, fee, context.collateralPriceUsd);
10
10
  const borrowingFee = (0, fees_1.getBorrowingFee)(trade.collateralAmount * trade.leverage, trade.pairIndex, trade.long, initialAccFees, context);
11
11
  const liqThresholdP = (0, exports.getLiqPnlThresholdP)(context.liquidationParams, trade.leverage);
@@ -15,11 +15,9 @@ const getLiquidationPrice = (trade, fee, initialAccFees, context) => {
15
15
  trade.leverage;
16
16
  if ((context === null || context === void 0 ? void 0 : context.contractsVersion) !== undefined &&
17
17
  context.contractsVersion >= types_1.ContractsVersion.V9_2 &&
18
- ((((_a = context === null || context === void 0 ? void 0 : context.liquidationParams) === null || _a === void 0 ? void 0 : _a.maxLiqSpreadP) !== undefined &&
19
- context.liquidationParams.maxLiqSpreadP > 0) ||
20
- (((_b = context === null || context === void 0 ? void 0 : context.userPriceImpact) === null || _b === void 0 ? void 0 : _b.fixedSpreadP) !== undefined &&
21
- context.userPriceImpact.fixedSpreadP > 0))) {
22
- const closingSpreadP = (0, spread_1.getSpreadP)(context.pairSpreadP, true, context.liquidationParams, context.userPriceImpact);
18
+ ((_a = context === null || context === void 0 ? void 0 : context.liquidationParams) === null || _a === void 0 ? void 0 : _a.maxLiqSpreadP) !== undefined &&
19
+ context.liquidationParams.maxLiqSpreadP > 0) {
20
+ const closingSpreadP = (0, spread_1.getSpreadP)(context.pairSpreadP, true, context.liquidationParams);
23
21
  liqPriceDistance -= trade.openPrice * closingSpreadP;
24
22
  }
25
23
  return trade.long
@@ -1,4 +1,4 @@
1
- import { LiquidationParams, OiWindows, OiWindowsSettings, PairDepth, PairFactor, UserPriceImpact } from "./types";
1
+ import { LiquidationParams, OiWindows, OiWindowsSettings, PairDepth, PairFactor } from "./types";
2
2
  import { ContractsVersion } from "../contracts/types";
3
3
  export type SpreadContext = {
4
4
  isOpen?: boolean;
@@ -8,11 +8,10 @@ export type SpreadContext = {
8
8
  currentBlock?: number | undefined;
9
9
  contractsVersion?: ContractsVersion | undefined;
10
10
  protectionCloseFactorWhitelist?: boolean;
11
- userPriceImpact?: UserPriceImpact | undefined;
12
11
  } & Partial<PairFactor>;
13
12
  export declare const getProtectionCloseFactor: (spreadCtx: SpreadContext | undefined) => number;
14
13
  export declare const isProtectionCloseFactorActive: (spreadCtx: SpreadContext | undefined) => boolean | undefined;
15
14
  export declare const getCumulativeFactor: (spreadCtx: SpreadContext | undefined) => number;
16
15
  export declare const getLegacyFactor: (spreadCtx: SpreadContext | undefined) => number;
17
16
  export declare const getSpreadWithPriceImpactP: (pairSpreadP: number, buy: boolean, collateral: number, leverage: number, pairDepth: PairDepth | undefined, oiWindowsSettings?: OiWindowsSettings | undefined, oiWindows?: OiWindows | undefined, spreadCtx?: SpreadContext | undefined) => number;
18
- export declare const getSpreadP: (pairSpreadP: number | undefined, isLiquidation?: boolean | undefined, liquidationParams?: LiquidationParams | undefined, userPriceImpact?: UserPriceImpact | undefined) => number;
17
+ export declare const getSpreadP: (pairSpreadP: number | undefined, isLiquidation?: boolean | undefined, liquidationParams?: LiquidationParams | undefined) => number;
@@ -5,20 +5,14 @@ const oiWindows_1 = require("./oiWindows");
5
5
  const constants_1 = require("../constants");
6
6
  const types_1 = require("../contracts/types");
7
7
  const getProtectionCloseFactor = (spreadCtx) => {
8
- var _a;
9
- const protectionCloseFactor = spreadCtx === undefined ||
8
+ if (spreadCtx === undefined ||
10
9
  spreadCtx.contractsVersion === types_1.ContractsVersion.BEFORE_V9_2 ||
11
10
  spreadCtx.isOpen === undefined ||
12
11
  spreadCtx.isPnlPositive === undefined ||
13
- spreadCtx.protectionCloseFactor === undefined ||
14
- (0, exports.isProtectionCloseFactorActive)(spreadCtx) !== true
15
- ? constants_1.DEFAULT_PROTECTION_CLOSE_FACTOR
16
- : spreadCtx.protectionCloseFactor;
17
- const protectionCloseFactorMultiplier = ((_a = spreadCtx === null || spreadCtx === void 0 ? void 0 : spreadCtx.userPriceImpact) === null || _a === void 0 ? void 0 : _a.cumulVolPriceImpactMultiplier) !== undefined &&
18
- spreadCtx.userPriceImpact.cumulVolPriceImpactMultiplier > 0
19
- ? spreadCtx.userPriceImpact.cumulVolPriceImpactMultiplier
20
- : 1;
21
- return protectionCloseFactor * protectionCloseFactorMultiplier;
12
+ (0, exports.isProtectionCloseFactorActive)(spreadCtx) !== true)
13
+ return constants_1.DEFAULT_PROTECTION_CLOSE_FACTOR;
14
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
15
+ return spreadCtx.protectionCloseFactor;
22
16
  };
23
17
  exports.getProtectionCloseFactor = getProtectionCloseFactor;
24
18
  const isProtectionCloseFactorActive = (spreadCtx) => {
@@ -83,7 +77,7 @@ const getSpreadWithPriceImpactP = (pairSpreadP, buy, collateral, leverage, pairD
83
77
  if (!onePercentDepth || activeOi === undefined || collateral === undefined) {
84
78
  return pairSpreadP / 2;
85
79
  }
86
- return ((0, exports.getSpreadP)(pairSpreadP, undefined, undefined, spreadCtx === null || spreadCtx === void 0 ? void 0 : spreadCtx.userPriceImpact) +
80
+ return ((0, exports.getSpreadP)(pairSpreadP) +
87
81
  ((activeOi * (0, exports.getCumulativeFactor)(spreadCtx) + (collateral * leverage) / 2) /
88
82
  onePercentDepth /
89
83
  100 /
@@ -91,13 +85,11 @@ const getSpreadWithPriceImpactP = (pairSpreadP, buy, collateral, leverage, pairD
91
85
  (0, exports.getProtectionCloseFactor)(spreadCtx));
92
86
  };
93
87
  exports.getSpreadWithPriceImpactP = getSpreadWithPriceImpactP;
94
- const getSpreadP = (pairSpreadP, isLiquidation, liquidationParams, userPriceImpact) => {
95
- var _a;
96
- const fixedSpreadP = (_a = userPriceImpact === null || userPriceImpact === void 0 ? void 0 : userPriceImpact.fixedSpreadP) !== null && _a !== void 0 ? _a : 0;
97
- if (pairSpreadP === undefined || (pairSpreadP === 0 && fixedSpreadP === 0)) {
88
+ const getSpreadP = (pairSpreadP, isLiquidation, liquidationParams) => {
89
+ if (pairSpreadP === undefined || pairSpreadP === 0) {
98
90
  return 0;
99
91
  }
100
- const spreadP = pairSpreadP / 2 + fixedSpreadP;
92
+ const spreadP = pairSpreadP / 2;
101
93
  return isLiquidation === true &&
102
94
  liquidationParams !== undefined &&
103
95
  liquidationParams.maxLiqSpreadP > 0 &&
@@ -185,10 +185,6 @@ export type PairFactor = {
185
185
  exemptOnOpen: boolean;
186
186
  exemptAfterProtectionCloseFactor: boolean;
187
187
  };
188
- export type UserPriceImpact = {
189
- cumulVolPriceImpactMultiplier: number;
190
- fixedSpreadP: number;
191
- };
192
188
  export declare enum PendingOrderType {
193
189
  MARKET_OPEN = 0,
194
190
  MARKET_CLOSE = 1,
@@ -575,5 +571,16 @@ export declare enum PairIndex {
575
571
  ELXUSD = 349,
576
572
  PIUSD = 350,
577
573
  SHELLUSD = 351,
578
- BMTUSD = 352
574
+ BMTUSD = 352,
575
+ BROCCOLIUSD = 353,
576
+ TUTUSD = 354,
577
+ GPSUSD = 355,
578
+ REDUSD = 356,
579
+ MUBARAKUSD = 357,
580
+ FORMUSD = 358,
581
+ WALUSD = 359,
582
+ NILUSD = 360,
583
+ PARTIUSD = 361,
584
+ SIRENUSD = 362,
585
+ BANANAS31 = 363
579
586
  }
@@ -382,4 +382,15 @@ var PairIndex;
382
382
  PairIndex[PairIndex["PIUSD"] = 350] = "PIUSD";
383
383
  PairIndex[PairIndex["SHELLUSD"] = 351] = "SHELLUSD";
384
384
  PairIndex[PairIndex["BMTUSD"] = 352] = "BMTUSD";
385
+ PairIndex[PairIndex["BROCCOLIUSD"] = 353] = "BROCCOLIUSD";
386
+ PairIndex[PairIndex["TUTUSD"] = 354] = "TUTUSD";
387
+ PairIndex[PairIndex["GPSUSD"] = 355] = "GPSUSD";
388
+ PairIndex[PairIndex["REDUSD"] = 356] = "REDUSD";
389
+ PairIndex[PairIndex["MUBARAKUSD"] = 357] = "MUBARAKUSD";
390
+ PairIndex[PairIndex["FORMUSD"] = 358] = "FORMUSD";
391
+ PairIndex[PairIndex["WALUSD"] = 359] = "WALUSD";
392
+ PairIndex[PairIndex["NILUSD"] = 360] = "NILUSD";
393
+ PairIndex[PairIndex["PARTIUSD"] = 361] = "PARTIUSD";
394
+ PairIndex[PairIndex["SIRENUSD"] = 362] = "SIRENUSD";
395
+ PairIndex[PairIndex["BANANAS31"] = 363] = "BANANAS31";
385
396
  })(PairIndex = exports.PairIndex || (exports.PairIndex = {}));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gainsnetwork/sdk",
3
- "version": "0.2.60-rc1",
3
+ "version": "0.2.61-rc1",
4
4
  "description": "Gains Network SDK",
5
5
  "main": "./lib/index.js",
6
6
  "files": [