@gainsnetwork/sdk 0.2.12-rc16 → 0.2.12-rc17

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.
@@ -263,6 +263,11 @@ export declare const pairs: {
263
263
  "SYN/USD": string;
264
264
  "AUCTION/USD": string;
265
265
  "ALICE/USD": string;
266
+ "SUN/USD": string;
267
+ "TRB/USD": string;
268
+ "DOGS/USD": string;
269
+ "SSV/USD": string;
270
+ "PONKE/USD": string;
266
271
  };
267
272
  export declare const getAssetClassFromGroupIndex: (groupIndex: number) => string | undefined;
268
273
  export declare const tickerChanges: {
package/lib/constants.js CHANGED
@@ -271,6 +271,11 @@ exports.pairs = {
271
271
  "SYN/USD": CRYPTO,
272
272
  "AUCTION/USD": CRYPTO,
273
273
  "ALICE/USD": CRYPTO,
274
+ "SUN/USD": CRYPTO,
275
+ "TRB/USD": CRYPTO,
276
+ "DOGS/USD": CRYPTO,
277
+ "SSV/USD": CRYPTO,
278
+ "PONKE/USD": CRYPTO,
274
279
  };
275
280
  const getAssetClassFromGroupIndex = (groupIndex) => {
276
281
  switch (groupIndex) {
@@ -369,4 +369,9 @@ const PAIR_INDEX_TO_DESCRIPTION = {
369
369
  [types_1.PairIndex.SYNUSD]: "Synapse to US Dollar",
370
370
  [types_1.PairIndex.AUCTIONUSD]: "Bounce to US Dollar",
371
371
  [types_1.PairIndex.ALICEUSD]: "My Neighbor Alice to US Dollar",
372
+ [types_1.PairIndex.SUNUSD]: "Sun to US Dollar",
373
+ [types_1.PairIndex.TRBUSD]: "Tellor tributes to US Dollar",
374
+ [types_1.PairIndex.DOGSUSD]: "DOGS to US Dollar",
375
+ [types_1.PairIndex.SSVUSD]: "ssv.network to US Dollar",
376
+ [types_1.PairIndex.PONKEUSD]: "Ponke to US Dollar",
372
377
  };
@@ -8,4 +8,4 @@ export type GetLiquidationPriceContext = GetBorrowingFeeContext & {
8
8
  contractsVersion: ContractsVersion | undefined;
9
9
  };
10
10
  export declare const getLiquidationPrice: (trade: Trade, fee: Fee, initialAccFees: BorrowingFee.InitialAccFees, context: GetLiquidationPriceContext) => number;
11
- export declare const getLiqPnlThresholdP: (liquidationParams: LiquidationParams | undefined, leverage: number | undefined, contractsVersion: ContractsVersion | undefined) => number;
11
+ export declare const getLiqPnlThresholdP: (liquidationParams: LiquidationParams | undefined, leverage: number | undefined) => number;
@@ -8,12 +8,13 @@ const getLiquidationPrice = (trade, fee, initialAccFees, context) => {
8
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
- const liqThresholdP = (0, exports.getLiqPnlThresholdP)(context.liquidationParams, trade.leverage, context.contractsVersion);
11
+ const liqThresholdP = (0, exports.getLiqPnlThresholdP)(context.liquidationParams, trade.leverage);
12
12
  let liqPriceDistance = (trade.openPrice *
13
13
  (trade.collateralAmount * liqThresholdP - (borrowingFee + closingFee))) /
14
14
  trade.collateralAmount /
15
15
  trade.leverage;
16
- if ((context === null || context === void 0 ? void 0 : context.contractsVersion) === types_1.ContractsVersion.V9_2 &&
16
+ if ((context === null || context === void 0 ? void 0 : context.contractsVersion) !== undefined &&
17
+ context.contractsVersion >= types_1.ContractsVersion.V9_2 &&
17
18
  ((_a = context === null || context === void 0 ? void 0 : context.liquidationParams) === null || _a === void 0 ? void 0 : _a.maxLiqSpreadP) !== undefined &&
18
19
  context.liquidationParams.maxLiqSpreadP > 0) {
19
20
  const closingSpreadP = (0, spread_1.getSpreadP)(context.pairSpreadP, true, context.liquidationParams);
@@ -24,10 +25,9 @@ const getLiquidationPrice = (trade, fee, initialAccFees, context) => {
24
25
  : Math.max(trade.openPrice + liqPriceDistance, 0);
25
26
  };
26
27
  exports.getLiquidationPrice = getLiquidationPrice;
27
- const getLiqPnlThresholdP = (liquidationParams, leverage, contractsVersion) => {
28
+ const getLiqPnlThresholdP = (liquidationParams, leverage) => {
28
29
  if (liquidationParams === undefined ||
29
30
  leverage === undefined ||
30
- contractsVersion === types_1.ContractsVersion.BEFORE_V9_2 ||
31
31
  liquidationParams.maxLiqSpreadP === 0 ||
32
32
  liquidationParams.startLiqThresholdP === 0 ||
33
33
  liquidationParams.endLiqThresholdP === 0 ||
package/lib/trade/pnl.js CHANGED
@@ -21,8 +21,7 @@ const getPnl = (price, trade, tradeInfo, initialAccFees, liquidationParams, useF
21
21
  let pnlPercentage = (pnlCollat / posCollat) * 100;
22
22
  // Can be liquidated
23
23
  if (pnlPercentage <=
24
- (0, liquidation_1.getLiqPnlThresholdP)(liquidationParams, leverage, context.contractsVersion) *
25
- -100) {
24
+ (0, liquidation_1.getLiqPnlThresholdP)(liquidationParams, leverage) * -100) {
26
25
  pnlPercentage = -100;
27
26
  }
28
27
  else {
@@ -469,5 +469,10 @@ export declare enum PairIndex {
469
469
  RSRUSD = 260,
470
470
  SYNUSD = 261,
471
471
  AUCTIONUSD = 262,
472
- ALICEUSD = 263
472
+ ALICEUSD = 263,
473
+ SUNUSD = 264,
474
+ TRBUSD = 265,
475
+ DOGSUSD = 266,
476
+ SSVUSD = 267,
477
+ PONKEUSD = 268
473
478
  }
@@ -293,4 +293,9 @@ var PairIndex;
293
293
  PairIndex[PairIndex["SYNUSD"] = 261] = "SYNUSD";
294
294
  PairIndex[PairIndex["AUCTIONUSD"] = 262] = "AUCTIONUSD";
295
295
  PairIndex[PairIndex["ALICEUSD"] = 263] = "ALICEUSD";
296
+ PairIndex[PairIndex["SUNUSD"] = 264] = "SUNUSD";
297
+ PairIndex[PairIndex["TRBUSD"] = 265] = "TRBUSD";
298
+ PairIndex[PairIndex["DOGSUSD"] = 266] = "DOGSUSD";
299
+ PairIndex[PairIndex["SSVUSD"] = 267] = "SSVUSD";
300
+ PairIndex[PairIndex["PONKEUSD"] = 268] = "PONKEUSD";
296
301
  })(PairIndex = exports.PairIndex || (exports.PairIndex = {}));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gainsnetwork/sdk",
3
- "version": "0.2.12-rc16",
3
+ "version": "0.2.12-rc17",
4
4
  "description": "Gains Network SDK",
5
5
  "main": "./lib/index.js",
6
6
  "files": [