@gainsnetwork/sdk 0.2.33-rc2 → 0.2.33-rc3

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.
@@ -1,16 +1,14 @@
1
- import { LiquidationParams, OiWindows, OiWindowsSettings, PairDepth } 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;
5
5
  isPnlPositive?: boolean;
6
- protectionCloseFactor?: number;
7
- protectionCloseFactorBlocks?: number;
8
- cumulativeFactor?: number;
9
6
  createdBlock?: number;
10
7
  liquidationParams?: LiquidationParams | undefined;
11
8
  currentBlock?: number | undefined;
12
9
  contractsVersion?: ContractsVersion | undefined;
13
- };
10
+ protectionCloseFactorWhitelist?: boolean;
11
+ } & Partial<PairFactor>;
14
12
  export declare const getProtectionCloseFactor: (spreadCtx: SpreadContext | undefined) => number;
15
13
  export declare const getCumulativeFactor: (spreadCtx: SpreadContext | undefined) => number;
16
14
  export declare const getLegacyFactor: (spreadCtx: SpreadContext | undefined) => number;
@@ -12,7 +12,8 @@ const getProtectionCloseFactor = (spreadCtx) => {
12
12
  spreadCtx.protectionCloseFactor === undefined ||
13
13
  spreadCtx.protectionCloseFactorBlocks === undefined ||
14
14
  spreadCtx.createdBlock === undefined ||
15
- spreadCtx.currentBlock === undefined)
15
+ spreadCtx.currentBlock === undefined ||
16
+ spreadCtx.protectionCloseFactorWhitelist === true)
16
17
  return constants_1.DEFAULT_PROTECTION_CLOSE_FACTOR;
17
18
  if (spreadCtx.isPnlPositive &&
18
19
  !spreadCtx.isOpen &&
@@ -37,6 +38,7 @@ const getLegacyFactor = (spreadCtx) => {
37
38
  return (spreadCtx === null || spreadCtx === void 0 ? void 0 : spreadCtx.contractsVersion) === types_1.ContractsVersion.BEFORE_V9_2 ? 1 : 2;
38
39
  };
39
40
  exports.getLegacyFactor = getLegacyFactor;
41
+ // @todo
40
42
  const getSpreadWithPriceImpactP = (pairSpreadP, buy, collateral, leverage, pairDepth, oiWindowsSettings, oiWindows, spreadCtx) => {
41
43
  if (pairSpreadP === undefined) {
42
44
  return 0;
@@ -62,6 +64,7 @@ const getSpreadWithPriceImpactP = (pairSpreadP, buy, collateral, leverage, pairD
62
64
  if (!onePercentDepth || activeOi === undefined || collateral === undefined) {
63
65
  return pairSpreadP / 2;
64
66
  }
67
+ // @todo implement exemptOnOpen && exemptAfterProtectionCloseFactor
65
68
  return ((0, exports.getSpreadP)(pairSpreadP) +
66
69
  ((activeOi * (0, exports.getCumulativeFactor)(spreadCtx) + (collateral * leverage) / 2) /
67
70
  onePercentDepth /
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gainsnetwork/sdk",
3
- "version": "0.2.33-rc2",
3
+ "version": "0.2.33-rc3",
4
4
  "description": "Gains Network SDK",
5
5
  "main": "./lib/index.js",
6
6
  "files": [