@gainsnetwork/sdk 0.2.12-rc14 → 0.2.12-rc15

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.
@@ -4,7 +4,6 @@ export type GetBorrowingFeeContext = {
4
4
  currentBlock: number;
5
5
  groups: BorrowingFee.Group[];
6
6
  pairs: BorrowingFee.Pair[];
7
- openInterest: OpenInterest;
8
7
  };
9
8
  export declare const getBorrowingFee: (posDai: number, pairIndex: PairIndex, long: boolean, initialAccFees: BorrowingFee.InitialAccFees, context: GetBorrowingFeeContext) => number;
10
9
  export declare const withinMaxGroupOi: (pairIndex: PairIndex, long: boolean, positionSizeCollateral: number, context: {
@@ -28,10 +28,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
28
28
  Object.defineProperty(exports, "__esModule", { value: true });
29
29
  exports.BorrowingFee = exports.borrowingFeeUtils = exports.withinMaxGroupOi = exports.getBorrowingFee = void 0;
30
30
  const getBorrowingFee = (posDai, pairIndex, long, initialAccFees, context) => {
31
- if (!context.groups ||
32
- !context.pairs ||
33
- !context.openInterest ||
34
- !context.pairs[pairIndex]) {
31
+ if (!context.groups || !context.pairs || !context.pairs[pairIndex]) {
35
32
  return 0;
36
33
  }
37
34
  const { pairs } = context;
@@ -39,9 +36,13 @@ const getBorrowingFee = (posDai, pairIndex, long, initialAccFees, context) => {
39
36
  const firstPairGroup = (pairGroups === null || pairGroups === void 0 ? void 0 : pairGroups.length) > 0 ? pairGroups[0] : undefined;
40
37
  let fee = 0;
41
38
  if (!firstPairGroup || firstPairGroup.block > initialAccFees.block) {
39
+ const openInterest = pairs[pairIndex].oi;
42
40
  fee =
43
41
  (!firstPairGroup
44
- ? getPairPendingAccFee(pairIndex, context.currentBlock, long, context)
42
+ ? getPairPendingAccFee(pairIndex, context.currentBlock, long, {
43
+ pairs,
44
+ openInterest,
45
+ })
45
46
  : long
46
47
  ? firstPairGroup.pairAccFeeLong
47
48
  : firstPairGroup.pairAccFeeShort) - initialAccFees.accPairFee;
@@ -96,13 +97,14 @@ const getPairGroupAccFeesDeltas = (i, pairGroups, initialFees, pairIndex, long,
96
97
  const beforeTradeOpen = group.block < initialFees.block;
97
98
  let deltaGroup, deltaPair;
98
99
  if (i == pairGroups.length - 1) {
99
- const { currentBlock, groups, pairs, openInterest } = context;
100
+ const { currentBlock, groups, pairs } = context;
101
+ const openInterest = pairs[pairIndex].oi;
100
102
  deltaGroup = getGroupPendingAccFee(group.groupIndex, currentBlock, long, {
101
103
  groups,
102
104
  });
103
105
  deltaPair = getPairPendingAccFee(pairIndex, currentBlock, long, {
104
106
  pairs,
105
- openInterest: openInterest,
107
+ openInterest,
106
108
  });
107
109
  }
108
110
  else {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gainsnetwork/sdk",
3
- "version": "0.2.12-rc14",
3
+ "version": "0.2.12-rc15",
4
4
  "description": "Gains Network SDK",
5
5
  "main": "./lib/index.js",
6
6
  "files": [