@gainsnetwork/sdk 0.2.33-rc6 → 0.2.33-rc7

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 (2) hide show
  1. package/lib/trade/spread.js +10 -16
  2. package/package.json +1 -1
@@ -9,31 +9,25 @@ const getProtectionCloseFactor = (spreadCtx) => {
9
9
  spreadCtx.contractsVersion === types_1.ContractsVersion.BEFORE_V9_2 ||
10
10
  spreadCtx.isOpen === undefined ||
11
11
  spreadCtx.isPnlPositive === undefined ||
12
- spreadCtx.protectionCloseFactor === undefined ||
13
- spreadCtx.protectionCloseFactorBlocks === undefined ||
14
- spreadCtx.createdBlock === undefined ||
15
- spreadCtx.currentBlock === undefined ||
16
- spreadCtx.protectionCloseFactorWhitelist === true // if trader is whitelisted, protection close factor is always 1
17
- )
12
+ (0, exports.isProtectionCloseFactorActive)(spreadCtx) !== true)
18
13
  return constants_1.DEFAULT_PROTECTION_CLOSE_FACTOR;
19
- if (spreadCtx.isPnlPositive &&
20
- !spreadCtx.isOpen &&
21
- spreadCtx.protectionCloseFactor > 0 &&
22
- (0, exports.isProtectionCloseFactorActive)(spreadCtx) === true) {
23
- return spreadCtx.protectionCloseFactor;
24
- }
25
- return constants_1.DEFAULT_PROTECTION_CLOSE_FACTOR;
14
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
15
+ return spreadCtx.protectionCloseFactor;
26
16
  };
27
17
  exports.getProtectionCloseFactor = getProtectionCloseFactor;
28
18
  const isProtectionCloseFactorActive = (spreadCtx) => {
29
19
  if (spreadCtx === undefined ||
30
20
  spreadCtx.currentBlock === undefined ||
31
21
  spreadCtx.createdBlock === undefined ||
32
- spreadCtx.protectionCloseFactorBlocks === undefined) {
22
+ spreadCtx.protectionCloseFactorBlocks === undefined ||
23
+ spreadCtx.protectionCloseFactor === undefined) {
33
24
  return undefined;
34
25
  }
35
- return (spreadCtx.currentBlock <=
36
- spreadCtx.createdBlock + spreadCtx.protectionCloseFactorBlocks &&
26
+ return (spreadCtx.isPnlPositive === true &&
27
+ spreadCtx.isOpen === false &&
28
+ spreadCtx.protectionCloseFactor > 0 &&
29
+ spreadCtx.currentBlock <=
30
+ spreadCtx.createdBlock + spreadCtx.protectionCloseFactorBlocks &&
37
31
  spreadCtx.protectionCloseFactorWhitelist !== true);
38
32
  };
39
33
  exports.isProtectionCloseFactorActive = isProtectionCloseFactorActive;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gainsnetwork/sdk",
3
- "version": "0.2.33-rc6",
3
+ "version": "0.2.33-rc7",
4
4
  "description": "Gains Network SDK",
5
5
  "main": "./lib/index.js",
6
6
  "files": [