@gainsnetwork/sdk 0.0.30-rc6 → 0.0.30-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 (113) hide show
  1. package/README.md +11 -11
  2. package/lib/constants.d.ts +140 -140
  3. package/lib/constants.js +151 -151
  4. package/lib/contracts/addresses.d.ts +2 -2
  5. package/lib/contracts/addresses.js +15 -15
  6. package/lib/contracts/addresses.json +35 -35
  7. package/lib/contracts/index.d.ts +6 -6
  8. package/lib/contracts/index.js +35 -35
  9. package/lib/contracts/types/generated/GFarmTradingStorageV5.d.ts +1911 -1911
  10. package/lib/contracts/types/generated/GFarmTradingStorageV5.js +2 -2
  11. package/lib/contracts/types/generated/GNSBorrowingFeesV6_3_2.d.ts +979 -0
  12. package/lib/contracts/types/generated/GNSBorrowingFeesV6_3_2.js +2 -0
  13. package/lib/contracts/types/generated/GNSBorrowingFeesV6_4.d.ts +1058 -1058
  14. package/lib/contracts/types/generated/GNSBorrowingFeesV6_4.js +2 -2
  15. package/lib/contracts/types/generated/GNSNftRewardsV6.d.ts +533 -533
  16. package/lib/contracts/types/generated/GNSNftRewardsV6.js +2 -2
  17. package/lib/contracts/types/generated/GNSNftRewardsV6_3_1.d.ts +613 -613
  18. package/lib/contracts/types/generated/GNSNftRewardsV6_3_1.js +2 -2
  19. package/lib/contracts/types/generated/GNSPairInfosV6_1.d.ts +911 -911
  20. package/lib/contracts/types/generated/GNSPairInfosV6_1.js +2 -2
  21. package/lib/contracts/types/generated/GNSPairsStorageV6.d.ts +660 -660
  22. package/lib/contracts/types/generated/GNSPairsStorageV6.js +2 -2
  23. package/lib/contracts/types/generated/GNSTradingCallbacksV6_3_2.d.ts +806 -0
  24. package/lib/contracts/types/generated/GNSTradingCallbacksV6_3_2.js +2 -0
  25. package/lib/contracts/types/generated/GNSTradingCallbacksV6_4.d.ts +821 -821
  26. package/lib/contracts/types/generated/GNSTradingCallbacksV6_4.js +2 -2
  27. package/lib/contracts/types/generated/GTokenOpenPnlFeed.d.ts +557 -557
  28. package/lib/contracts/types/generated/GTokenOpenPnlFeed.js +2 -2
  29. package/lib/contracts/types/generated/GTokenV6_3_2.d.ts +1838 -1838
  30. package/lib/contracts/types/generated/GTokenV6_3_2.js +2 -2
  31. package/lib/contracts/types/generated/common.d.ts +22 -22
  32. package/lib/contracts/types/generated/common.js +2 -2
  33. package/lib/contracts/types/generated/factories/GFarmTradingStorageV5__factory.d.ts +83 -83
  34. package/lib/contracts/types/generated/factories/GFarmTradingStorageV5__factory.js +2691 -2691
  35. package/lib/contracts/types/generated/factories/GNSBorrowingFeesV6_3_2__factory.d.ts +88 -0
  36. package/lib/contracts/types/generated/factories/GNSBorrowingFeesV6_3_2__factory.js +1654 -0
  37. package/lib/contracts/types/generated/factories/GNSBorrowingFeesV6_4__factory.d.ts +113 -113
  38. package/lib/contracts/types/generated/factories/GNSBorrowingFeesV6_4__factory.js +1742 -1742
  39. package/lib/contracts/types/generated/factories/GNSNftRewardsV6_3_1__factory.d.ts +100 -100
  40. package/lib/contracts/types/generated/factories/GNSNftRewardsV6_3_1__factory.js +1116 -1116
  41. package/lib/contracts/types/generated/factories/GNSNftRewardsV6__factory.d.ts +100 -100
  42. package/lib/contracts/types/generated/factories/GNSNftRewardsV6__factory.js +1003 -1003
  43. package/lib/contracts/types/generated/factories/GNSPairInfosV6_1__factory.d.ts +98 -98
  44. package/lib/contracts/types/generated/factories/GNSPairInfosV6_1__factory.js +1485 -1485
  45. package/lib/contracts/types/generated/factories/GNSPairsStorageV6__factory.d.ts +117 -117
  46. package/lib/contracts/types/generated/factories/GNSPairsStorageV6__factory.js +1265 -1265
  47. package/lib/contracts/types/generated/factories/GNSTradingCallbacksV6_3_2__factory.d.ts +82 -0
  48. package/lib/contracts/types/generated/factories/GNSTradingCallbacksV6_3_2__factory.js +1273 -0
  49. package/lib/contracts/types/generated/factories/GNSTradingCallbacksV6_4__factory.d.ts +82 -82
  50. package/lib/contracts/types/generated/factories/GNSTradingCallbacksV6_4__factory.js +1326 -1326
  51. package/lib/contracts/types/generated/factories/GTokenOpenPnlFeed__factory.d.ts +59 -59
  52. package/lib/contracts/types/generated/factories/GTokenOpenPnlFeed__factory.js +765 -765
  53. package/lib/contracts/types/generated/factories/GTokenV6_3_2__factory.d.ts +110 -110
  54. package/lib/contracts/types/generated/factories/GTokenV6_3_2__factory.js +2682 -2682
  55. package/lib/contracts/types/generated/factories/index.d.ts +9 -9
  56. package/lib/contracts/types/generated/factories/index.js +24 -24
  57. package/lib/contracts/types/generated/index.d.ts +19 -19
  58. package/lib/contracts/types/generated/index.js +45 -45
  59. package/lib/contracts/types/index.d.ts +23 -23
  60. package/lib/contracts/types/index.js +2 -2
  61. package/lib/contracts/utils/borrowingFees.d.ts +8 -8
  62. package/lib/contracts/utils/borrowingFees.js +28 -28
  63. package/lib/contracts/utils/index.d.ts +4 -4
  64. package/lib/contracts/utils/index.js +20 -20
  65. package/lib/contracts/utils/openLimitOrders.d.ts +8 -8
  66. package/lib/contracts/utils/openLimitOrders.js +88 -88
  67. package/lib/contracts/utils/openTrades.d.ts +9 -9
  68. package/lib/contracts/utils/openTrades.js +172 -172
  69. package/lib/contracts/utils/pairs.d.ts +7 -7
  70. package/lib/contracts/utils/pairs.js +115 -115
  71. package/lib/index.d.ts +7 -7
  72. package/lib/index.js +24 -24
  73. package/lib/markets/commodities.d.ts +1 -1
  74. package/lib/markets/commodities.js +31 -31
  75. package/lib/markets/crypto.d.ts +1 -1
  76. package/lib/markets/crypto.js +6 -6
  77. package/lib/markets/forex.d.ts +2 -2
  78. package/lib/markets/forex.js +38 -38
  79. package/lib/markets/index.d.ts +5 -5
  80. package/lib/markets/index.js +21 -21
  81. package/lib/markets/indices.d.ts +1 -1
  82. package/lib/markets/indices.js +6 -6
  83. package/lib/markets/stocks.d.ts +3 -3
  84. package/lib/markets/stocks.js +54 -54
  85. package/lib/trade/fees/borrowing/converter.d.ts +13 -13
  86. package/lib/trade/fees/borrowing/converter.js +41 -41
  87. package/lib/trade/fees/borrowing/index.d.ts +55 -55
  88. package/lib/trade/fees/borrowing/index.js +171 -171
  89. package/lib/trade/fees/borrowing/types.d.ts +36 -36
  90. package/lib/trade/fees/borrowing/types.js +2 -2
  91. package/lib/trade/fees/index.d.ts +16 -16
  92. package/lib/trade/fees/index.js +60 -60
  93. package/lib/trade/index.d.ts +7 -7
  94. package/lib/trade/index.js +23 -23
  95. package/lib/trade/liquidation.d.ts +7 -7
  96. package/lib/trade/liquidation.js +18 -18
  97. package/lib/trade/openLimitOrder.d.ts +2 -2
  98. package/lib/trade/openLimitOrder.js +24 -24
  99. package/lib/trade/pnl.d.ts +9 -9
  100. package/lib/trade/pnl.js +44 -44
  101. package/lib/trade/spread.d.ts +3 -3
  102. package/lib/trade/spread.js +30 -30
  103. package/lib/trade/types.d.ts +176 -176
  104. package/lib/trade/types.js +14 -14
  105. package/lib/utils/index.d.ts +1 -1
  106. package/lib/utils/index.js +17 -17
  107. package/lib/utils/packing.d.ts +2 -2
  108. package/lib/utils/packing.js +39 -39
  109. package/lib/vault/index.d.ts +7 -7
  110. package/lib/vault/index.js +11 -11
  111. package/package.json +104 -104
  112. package/lib/trade/fees.d.ts +0 -15
  113. package/lib/trade/fees.js +0 -45
@@ -1,14 +1,14 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.OpenLimitOrderType = exports.PositionType = void 0;
4
- var PositionType;
5
- (function (PositionType) {
6
- PositionType["LONG"] = "LONG";
7
- PositionType["SHORT"] = "SHORT";
8
- })(PositionType = exports.PositionType || (exports.PositionType = {}));
9
- var OpenLimitOrderType;
10
- (function (OpenLimitOrderType) {
11
- OpenLimitOrderType[OpenLimitOrderType["LEGACY"] = 0] = "LEGACY";
12
- OpenLimitOrderType[OpenLimitOrderType["REVERSAL"] = 1] = "REVERSAL";
13
- OpenLimitOrderType[OpenLimitOrderType["MOMENTUM"] = 2] = "MOMENTUM";
14
- })(OpenLimitOrderType = exports.OpenLimitOrderType || (exports.OpenLimitOrderType = {}));
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.OpenLimitOrderType = exports.PositionType = void 0;
4
+ var PositionType;
5
+ (function (PositionType) {
6
+ PositionType["LONG"] = "LONG";
7
+ PositionType["SHORT"] = "SHORT";
8
+ })(PositionType = exports.PositionType || (exports.PositionType = {}));
9
+ var OpenLimitOrderType;
10
+ (function (OpenLimitOrderType) {
11
+ OpenLimitOrderType[OpenLimitOrderType["LEGACY"] = 0] = "LEGACY";
12
+ OpenLimitOrderType[OpenLimitOrderType["REVERSAL"] = 1] = "REVERSAL";
13
+ OpenLimitOrderType[OpenLimitOrderType["MOMENTUM"] = 2] = "MOMENTUM";
14
+ })(OpenLimitOrderType = exports.OpenLimitOrderType || (exports.OpenLimitOrderType = {}));
@@ -1 +1 @@
1
- export * from "./packing";
1
+ export * from "./packing";
@@ -1,17 +1,17 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./packing"), exports);
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./packing"), exports);
@@ -1,2 +1,2 @@
1
- export declare const pack: (values: bigint[], bitLengths: bigint[]) => bigint;
2
- export declare const unpack: (packed: bigint, bitLengths: bigint[]) => bigint[];
1
+ export declare const pack: (values: bigint[], bitLengths: bigint[]) => bigint;
2
+ export declare const unpack: (packed: bigint, bitLengths: bigint[]) => bigint[];
@@ -1,39 +1,39 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.unpack = exports.pack = void 0;
4
- const pack = (values, bitLengths) => {
5
- if (values.length !== bitLengths.length) {
6
- throw new Error("Mismatch in the lengths of values and bitLengths arrays");
7
- }
8
- let packed = BigInt(0);
9
- let currentShift = BigInt(0);
10
- for (let i = 0; i < values.length; i++) {
11
- if (currentShift + bitLengths[i] > BigInt(256)) {
12
- throw new Error("Packed value exceeds 256 bits");
13
- }
14
- const maxValue = (BigInt(1) << bitLengths[i]) - BigInt(1);
15
- if (values[i] > maxValue) {
16
- throw new Error("Value too large for specified bit length");
17
- }
18
- const maskedValue = values[i] & maxValue;
19
- packed |= maskedValue << currentShift;
20
- currentShift += bitLengths[i];
21
- }
22
- return packed;
23
- };
24
- exports.pack = pack;
25
- const unpack = (packed, bitLengths) => {
26
- const values = [];
27
- let currentShift = BigInt(0);
28
- for (let i = 0; i < bitLengths.length; i++) {
29
- if (currentShift + bitLengths[i] > BigInt(256)) {
30
- throw new Error("Unpacked value exceeds 256 bits");
31
- }
32
- const maxValue = (BigInt(1) << bitLengths[i]) - BigInt(1);
33
- const mask = maxValue << currentShift;
34
- values[i] = (packed & mask) >> currentShift;
35
- currentShift += bitLengths[i];
36
- }
37
- return values;
38
- };
39
- exports.unpack = unpack;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.unpack = exports.pack = void 0;
4
+ const pack = (values, bitLengths) => {
5
+ if (values.length !== bitLengths.length) {
6
+ throw new Error("Mismatch in the lengths of values and bitLengths arrays");
7
+ }
8
+ let packed = BigInt(0);
9
+ let currentShift = BigInt(0);
10
+ for (let i = 0; i < values.length; i++) {
11
+ if (currentShift + bitLengths[i] > BigInt(256)) {
12
+ throw new Error("Packed value exceeds 256 bits");
13
+ }
14
+ const maxValue = (BigInt(1) << bitLengths[i]) - BigInt(1);
15
+ if (values[i] > maxValue) {
16
+ throw new Error("Value too large for specified bit length");
17
+ }
18
+ const maskedValue = values[i] & maxValue;
19
+ packed |= maskedValue << currentShift;
20
+ currentShift += bitLengths[i];
21
+ }
22
+ return packed;
23
+ };
24
+ exports.pack = pack;
25
+ const unpack = (packed, bitLengths) => {
26
+ const values = [];
27
+ let currentShift = BigInt(0);
28
+ for (let i = 0; i < bitLengths.length; i++) {
29
+ if (currentShift + bitLengths[i] > BigInt(256)) {
30
+ throw new Error("Unpacked value exceeds 256 bits");
31
+ }
32
+ const maxValue = (BigInt(1) << bitLengths[i]) - BigInt(1);
33
+ const mask = maxValue << currentShift;
34
+ values[i] = (packed & mask) >> currentShift;
35
+ currentShift += bitLengths[i];
36
+ }
37
+ return values;
38
+ };
39
+ exports.unpack = unpack;
@@ -1,7 +1,7 @@
1
- type GetPendingAccBlockWeightedMarketCap = {
2
- marketCap: number;
3
- accBlockWeightedMarketCap: number;
4
- accBlockWeightedMarketCapLastStored: number;
5
- };
6
- export declare const getPendingAccBlockWeightedMarketCap: (currentBlock: number, context: GetPendingAccBlockWeightedMarketCap) => number;
7
- export {};
1
+ type GetPendingAccBlockWeightedMarketCap = {
2
+ marketCap: number;
3
+ accBlockWeightedMarketCap: number;
4
+ accBlockWeightedMarketCapLastStored: number;
5
+ };
6
+ export declare const getPendingAccBlockWeightedMarketCap: (currentBlock: number, context: GetPendingAccBlockWeightedMarketCap) => number;
7
+ export {};
@@ -1,11 +1,11 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getPendingAccBlockWeightedMarketCap = void 0;
4
- const MC_PRECISION = 1e18;
5
- const getPendingAccBlockWeightedMarketCap = (currentBlock, context) => {
6
- const { marketCap, accBlockWeightedMarketCap, accBlockWeightedMarketCapLastStored, } = context;
7
- return (accBlockWeightedMarketCap +
8
- (currentBlock - accBlockWeightedMarketCapLastStored) /
9
- Math.max(marketCap * MC_PRECISION, 1));
10
- };
11
- exports.getPendingAccBlockWeightedMarketCap = getPendingAccBlockWeightedMarketCap;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getPendingAccBlockWeightedMarketCap = void 0;
4
+ const MC_PRECISION = 1e18;
5
+ const getPendingAccBlockWeightedMarketCap = (currentBlock, context) => {
6
+ const { marketCap, accBlockWeightedMarketCap, accBlockWeightedMarketCapLastStored, } = context;
7
+ return (accBlockWeightedMarketCap +
8
+ (currentBlock - accBlockWeightedMarketCapLastStored) /
9
+ Math.max(marketCap * MC_PRECISION, 1));
10
+ };
11
+ exports.getPendingAccBlockWeightedMarketCap = getPendingAccBlockWeightedMarketCap;
package/package.json CHANGED
@@ -1,104 +1,104 @@
1
- {
2
- "name": "@gainsnetwork/sdk",
3
- "version": "0.0.30-rc6",
4
- "description": "Gains Network SDK",
5
- "main": "./lib/index.js",
6
- "files": [
7
- "lib/**/*"
8
- ],
9
- "scripts": {
10
- "build": "tsc --project tsconfig.build.json",
11
- "clean": "rm -rf ./lib/",
12
- "cm": "cz",
13
- "lint": "eslint ./src/ --fix",
14
- "prepare": "husky install",
15
- "semantic-release": "semantic-release",
16
- "test:watch": "jest --watch",
17
- "test": "jest --coverage",
18
- "typecheck": "tsc --noEmit",
19
- "generate-types": "typechain --target=ethers-v5 --out-dir ./src/contracts/types/generated ./abi/*.json"
20
- },
21
- "repository": {
22
- "type": "git",
23
- "url": "git+git@github.com:GainsNetwork-org/sdk.git"
24
- },
25
- "engines": {
26
- "node": ">=12.0"
27
- },
28
- "devDependencies": {
29
- "@typechain/ethers-v5": "^10.1.1",
30
- "@types/jest": "^27.5.2",
31
- "@types/luxon": "^3.2.0",
32
- "@types/node": "^12.20.11",
33
- "@typescript-eslint/eslint-plugin": "^4.22.0",
34
- "@typescript-eslint/parser": "^4.22.0",
35
- "conventional-changelog-conventionalcommits": "^5.0.0",
36
- "eslint": "^7.25.0",
37
- "eslint-config-prettier": "^8.3.0",
38
- "eslint-plugin-node": "^11.1.0",
39
- "eslint-plugin-prettier": "^3.4.0",
40
- "husky": "^6.0.0",
41
- "jest": "^27.2.0",
42
- "lint-staged": "^10.5.4",
43
- "prettier": "^2.2.1",
44
- "semantic-release": "^19.0.2",
45
- "ts-jest": "^27.1.5",
46
- "ts-node": "^10.2.1",
47
- "typechain": "^8.1.1",
48
- "typescript": "^4.2.4"
49
- },
50
- "lint-staged": {
51
- "*.ts": "eslint --cache --cache-location .eslintcache --fix"
52
- },
53
- "release": {
54
- "branches": [
55
- "main"
56
- ],
57
- "plugins": [
58
- [
59
- "@semantic-release/commit-analyzer",
60
- {
61
- "preset": "conventionalcommits",
62
- "releaseRules": [
63
- {
64
- "type": "build",
65
- "scope": "deps",
66
- "release": "patch"
67
- }
68
- ]
69
- }
70
- ],
71
- [
72
- "@semantic-release/release-notes-generator",
73
- {
74
- "preset": "conventionalcommits",
75
- "presetConfig": {
76
- "types": [
77
- {
78
- "type": "feat",
79
- "section": "Features"
80
- },
81
- {
82
- "type": "fix",
83
- "section": "Bug Fixes"
84
- },
85
- {
86
- "type": "build",
87
- "section": "Dependencies and Other Build Updates",
88
- "hidden": false
89
- }
90
- ]
91
- }
92
- }
93
- ],
94
- "@semantic-release/npm",
95
- "@semantic-release/github"
96
- ]
97
- },
98
- "dependencies": {
99
- "@ethersproject/providers": "^5.7.2",
100
- "ethcall": "^4.8.13",
101
- "ethers": "^5.7.2",
102
- "luxon": "^3.2.0"
103
- }
104
- }
1
+ {
2
+ "name": "@gainsnetwork/sdk",
3
+ "version": "0.0.30-rc7",
4
+ "description": "Gains Network SDK",
5
+ "main": "./lib/index.js",
6
+ "files": [
7
+ "lib/**/*"
8
+ ],
9
+ "scripts": {
10
+ "build": "tsc --project tsconfig.build.json",
11
+ "clean": "rm -rf ./lib/",
12
+ "cm": "cz",
13
+ "lint": "eslint ./src/ --fix",
14
+ "prepare": "husky install",
15
+ "semantic-release": "semantic-release",
16
+ "test:watch": "jest --watch",
17
+ "test": "jest --coverage",
18
+ "typecheck": "tsc --noEmit",
19
+ "generate-types": "typechain --target=ethers-v5 --out-dir ./src/contracts/types/generated ./abi/*.json"
20
+ },
21
+ "repository": {
22
+ "type": "git",
23
+ "url": "git+git@github.com:GainsNetwork-org/sdk.git"
24
+ },
25
+ "engines": {
26
+ "node": ">=12.0"
27
+ },
28
+ "devDependencies": {
29
+ "@typechain/ethers-v5": "^10.1.1",
30
+ "@types/jest": "^27.5.2",
31
+ "@types/luxon": "^3.2.0",
32
+ "@types/node": "^12.20.11",
33
+ "@typescript-eslint/eslint-plugin": "^4.22.0",
34
+ "@typescript-eslint/parser": "^4.22.0",
35
+ "conventional-changelog-conventionalcommits": "^5.0.0",
36
+ "eslint": "^7.25.0",
37
+ "eslint-config-prettier": "^8.3.0",
38
+ "eslint-plugin-node": "^11.1.0",
39
+ "eslint-plugin-prettier": "^3.4.0",
40
+ "husky": "^6.0.0",
41
+ "jest": "^27.2.0",
42
+ "lint-staged": "^10.5.4",
43
+ "prettier": "^2.2.1",
44
+ "semantic-release": "^19.0.2",
45
+ "ts-jest": "^27.1.5",
46
+ "ts-node": "^10.2.1",
47
+ "typechain": "^8.1.1",
48
+ "typescript": "^4.2.4"
49
+ },
50
+ "lint-staged": {
51
+ "*.ts": "eslint --cache --cache-location .eslintcache --fix"
52
+ },
53
+ "release": {
54
+ "branches": [
55
+ "main"
56
+ ],
57
+ "plugins": [
58
+ [
59
+ "@semantic-release/commit-analyzer",
60
+ {
61
+ "preset": "conventionalcommits",
62
+ "releaseRules": [
63
+ {
64
+ "type": "build",
65
+ "scope": "deps",
66
+ "release": "patch"
67
+ }
68
+ ]
69
+ }
70
+ ],
71
+ [
72
+ "@semantic-release/release-notes-generator",
73
+ {
74
+ "preset": "conventionalcommits",
75
+ "presetConfig": {
76
+ "types": [
77
+ {
78
+ "type": "feat",
79
+ "section": "Features"
80
+ },
81
+ {
82
+ "type": "fix",
83
+ "section": "Bug Fixes"
84
+ },
85
+ {
86
+ "type": "build",
87
+ "section": "Dependencies and Other Build Updates",
88
+ "hidden": false
89
+ }
90
+ ]
91
+ }
92
+ }
93
+ ],
94
+ "@semantic-release/npm",
95
+ "@semantic-release/github"
96
+ ]
97
+ },
98
+ "dependencies": {
99
+ "@ethersproject/providers": "^5.7.2",
100
+ "ethcall": "^4.8.13",
101
+ "ethers": "^5.7.2",
102
+ "luxon": "^3.2.0"
103
+ }
104
+ }
@@ -1,15 +0,0 @@
1
- import { Fee, OpenInterest, PairFundingFees, PairParams, PairRolloverFees } from "./types";
2
- export declare const getClosingFee: (posDai: number, leverage: number, pairIndex: number, pairFee: Fee | undefined) => number;
3
- export type GetFundingFeeContext = {
4
- currentBlock?: number;
5
- pairParams?: PairParams;
6
- pairFundingFees?: PairFundingFees;
7
- openInterest?: OpenInterest;
8
- };
9
- export declare const getFundingFee: (leveragedPosDai: number, initialAccFundingFees: number, buy: boolean, openedAfterUpdate: boolean, context: GetFundingFeeContext) => number;
10
- export type GetRolloverFeeContext = {
11
- currentBlock?: number;
12
- pairParams?: PairParams;
13
- pairRolloverFees?: PairRolloverFees;
14
- };
15
- export declare const getRolloverFee: (posDai: number, initialAccRolloverFees: number, openedAfterUpdate: boolean, context: GetRolloverFeeContext) => number;
package/lib/trade/fees.js DELETED
@@ -1,45 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getRolloverFee = exports.getFundingFee = exports.getClosingFee = void 0;
4
- const getClosingFee = (posDai, leverage, pairIndex, pairFee) => {
5
- if (posDai === undefined ||
6
- leverage === undefined ||
7
- pairIndex === undefined ||
8
- pairFee === undefined) {
9
- return 0;
10
- }
11
- const { closeFeeP, nftLimitOrderFeeP } = pairFee;
12
- return (closeFeeP + nftLimitOrderFeeP) * posDai * leverage;
13
- };
14
- exports.getClosingFee = getClosingFee;
15
- const getFundingFee = (leveragedPosDai, initialAccFundingFees, buy, openedAfterUpdate, context) => {
16
- const { pairParams, pairFundingFees, openInterest, currentBlock } = context;
17
- if (!currentBlock ||
18
- !openedAfterUpdate ||
19
- pairParams === undefined ||
20
- pairFundingFees === undefined ||
21
- openInterest === undefined)
22
- return 0;
23
- const { accPerOiLong, accPerOiShort, lastUpdateBlock } = pairFundingFees;
24
- const { fundingFeePerBlockP } = pairParams;
25
- const { long: longOi, short: shortOi } = openInterest;
26
- const fundingFeesPaidByLongs = (longOi - shortOi) * fundingFeePerBlockP * (currentBlock - lastUpdateBlock);
27
- const pendingAccFundingFees = buy
28
- ? accPerOiLong + fundingFeesPaidByLongs / longOi
29
- : accPerOiShort + (fundingFeesPaidByLongs * -1) / shortOi;
30
- return leveragedPosDai * (pendingAccFundingFees - initialAccFundingFees);
31
- };
32
- exports.getFundingFee = getFundingFee;
33
- const getRolloverFee = (posDai, initialAccRolloverFees, openedAfterUpdate, context) => {
34
- const { pairParams, pairRolloverFees, currentBlock } = context;
35
- if (!currentBlock ||
36
- !openedAfterUpdate ||
37
- pairParams === undefined ||
38
- pairRolloverFees === undefined)
39
- return 0;
40
- const { accPerCollateral, lastUpdateBlock } = pairRolloverFees;
41
- const { rolloverFeePerBlockP } = pairParams;
42
- const pendingAccRolloverFees = accPerCollateral + (currentBlock - lastUpdateBlock) * rolloverFeePerBlockP;
43
- return posDai * (pendingAccRolloverFees - initialAccRolloverFees);
44
- };
45
- exports.getRolloverFee = getRolloverFee;