@gainsnetwork/sdk 0.2.12-rc3 → 0.2.12-rc5

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.
@@ -110,9 +110,9 @@ const _prepareTradeContainer = (trade, tradeInfo, tradeLiquidationParams, tradeI
110
110
  collateralPriceUsd: parseFloat(tradeInfo.collateralPriceUsd.toString()) / 1e8,
111
111
  },
112
112
  liquidationParams: {
113
- maxLiqSpreadP: parseFloat(tradeLiquidationParams.maxLiqSpreadP.toString()) / 1e10,
114
- startLiqThresholdP: parseFloat(tradeLiquidationParams.startLiqThresholdP.toString()) / 1e10,
115
- endLiqThresholdP: parseFloat(tradeLiquidationParams.endLiqThresholdP.toString()) / 1e10,
113
+ maxLiqSpreadP: parseFloat(tradeLiquidationParams.maxLiqSpreadP.toString()) / 1e12,
114
+ startLiqThresholdP: parseFloat(tradeLiquidationParams.startLiqThresholdP.toString()) / 1e12,
115
+ endLiqThresholdP: parseFloat(tradeLiquidationParams.endLiqThresholdP.toString()) / 1e12,
116
116
  startLeverage: parseFloat(tradeLiquidationParams.startLeverage.toString()) / 1e3,
117
117
  endLeverage: parseFloat(tradeLiquidationParams.endLeverage.toString()) / 1e3,
118
118
  },
@@ -2,7 +2,6 @@ import { Pair, Fee, OpenInterest, PairDepth, PairIndex } from "../../trade/types
2
2
  import { Contracts } from "../../contracts/types";
3
3
  export declare const fetchPairs: (contracts: Contracts, pairIxs: PairIndex[]) => Promise<Pair[]>;
4
4
  export declare const fetchPairDepths: (contracts: Contracts, pairIxs: number[]) => Promise<PairDepth[]>;
5
- export declare const fetchProtectionCloseFactors: (contracts: Contracts, pairIxs: number[]) => Promise<number[]>;
6
5
  export declare const fetchFees: (contracts: Contracts, feeIxs: PairIndex[]) => Promise<Fee[]>;
7
6
  export declare const fetchOpenInterest: (contracts: Contracts, collateralIndex: number, pairIxs: number[]) => Promise<OpenInterest[]>;
8
7
  export declare const getPairDescription: (pairIndex: PairIndex) => string;
@@ -9,7 +9,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
9
9
  });
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.getPairDescription = exports.fetchOpenInterest = exports.fetchFees = exports.fetchProtectionCloseFactors = exports.fetchPairDepths = exports.fetchPairs = void 0;
12
+ exports.getPairDescription = exports.fetchOpenInterest = exports.fetchFees = exports.fetchPairDepths = exports.fetchPairs = void 0;
13
13
  /* eslint-disable @typescript-eslint/no-unsafe-call */
14
14
  /* eslint-disable @typescript-eslint/no-unsafe-return */
15
15
  /* eslint-disable @typescript-eslint/no-unsafe-member-access */
@@ -60,23 +60,6 @@ const fetchPairDepths = (contracts, pairIxs) => __awaiter(void 0, void 0, void 0
60
60
  }
61
61
  });
62
62
  exports.fetchPairDepths = fetchPairDepths;
63
- const fetchProtectionCloseFactors = (contracts, pairIxs) => __awaiter(void 0, void 0, void 0, function* () {
64
- if (!contracts) {
65
- return [];
66
- }
67
- const { gnsMultiCollatDiamond: multiCollatContract } = contracts;
68
- try {
69
- const protectionCloseFactors = yield multiCollatContract.getProtectionCloseFactors(pairIxs);
70
- return protectionCloseFactors.map(protectionCloseFactor => {
71
- return protectionCloseFactor.toNumber();
72
- });
73
- }
74
- catch (error) {
75
- console.error(`Unexpected error while fetching pairs!`);
76
- throw error;
77
- }
78
- });
79
- exports.fetchProtectionCloseFactors = fetchProtectionCloseFactors;
80
63
  const fetchFees = (contracts, feeIxs) => __awaiter(void 0, void 0, void 0, function* () {
81
64
  if (!contracts) {
82
65
  return [];
@@ -15,7 +15,7 @@ const getLiquidationPrice = (trade, fee, initialAccFees, context) => {
15
15
  if (((_a = context === null || context === void 0 ? void 0 : context.liquidationParams) === null || _a === void 0 ? void 0 : _a.maxLiqSpreadP) !== undefined &&
16
16
  context.liquidationParams.maxLiqSpreadP > 0) {
17
17
  const closingSpreadP = (0, spread_1.getSpreadP)(context.pairSpreadP, true, context.liquidationParams);
18
- liqPriceDistance += trade.openPrice * closingSpreadP;
18
+ liqPriceDistance -= trade.openPrice * closingSpreadP;
19
19
  }
20
20
  return trade.long
21
21
  ? Math.max(trade.openPrice - liqPriceDistance, 0)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gainsnetwork/sdk",
3
- "version": "0.2.12-rc3",
3
+ "version": "0.2.12-rc5",
4
4
  "description": "Gains Network SDK",
5
5
  "main": "./lib/index.js",
6
6
  "files": [