@gainsnetwork/sdk 0.2.67-rc8 → 0.2.69

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 (136) hide show
  1. package/lib/contracts/addresses.json +20 -0
  2. package/lib/{trade/fees/borrowingV2/fetcher.d.ts → contracts/fetch/fees/borrowingFeesV2.d.ts} +3 -2
  3. package/lib/{trade/fees/borrowingV2/fetcher.js → contracts/fetch/fees/borrowingFeesV2.js} +14 -6
  4. package/lib/{trade/fees/fundingFees/fetcher.d.ts → contracts/fetch/fees/fundingFees.d.ts} +2 -2
  5. package/lib/{trade/priceImpact/skew/fetcher.d.ts → contracts/fetch/priceImpact/skew.d.ts} +2 -2
  6. package/lib/{trade/priceImpact/skew/fetcher.js → contracts/fetch/priceImpact/skew.js} +6 -6
  7. package/lib/contracts/index.js +3 -1
  8. package/lib/contracts/types/generated/GNSMultiCollatDiamond.d.ts +258 -2112
  9. package/lib/contracts/types/generated/GToken.d.ts +107 -78
  10. package/lib/contracts/types/generated/factories/GNSMultiCollatDiamond__factory.d.ts +53 -90
  11. package/lib/contracts/types/generated/factories/GNSMultiCollatDiamond__factory.js +421 -4496
  12. package/lib/contracts/types/generated/factories/GToken__factory.js +142 -65
  13. package/lib/contracts/types/index.d.ts +2 -1
  14. package/lib/contracts/types/index.js +1 -0
  15. package/lib/trade/fees/borrowingV2/converter.d.ts +3 -12
  16. package/lib/trade/fees/borrowingV2/converter.js +18 -29
  17. package/lib/trade/fees/borrowingV2/index.d.ts +17 -6
  18. package/lib/trade/fees/borrowingV2/index.js +37 -10
  19. package/lib/trade/fees/borrowingV2/types.d.ts +6 -22
  20. package/lib/trade/fees/fundingFees/index.d.ts +2 -13
  21. package/lib/trade/fees/fundingFees/index.js +3 -27
  22. package/lib/trade/fees/trading/index.d.ts +2 -30
  23. package/lib/trade/fees/trading/index.js +1 -52
  24. package/lib/trade/fees/trading/types.d.ts +0 -9
  25. package/lib/trade/priceImpact/index.d.ts +2 -6
  26. package/lib/trade/priceImpact/index.js +3 -30
  27. package/lib/trade/priceImpact/skew/index.d.ts +0 -1
  28. package/lib/trade/priceImpact/skew/index.js +0 -4
  29. package/package.json +1 -1
  30. package/lib/backend/globalTrades/index.d.ts +0 -11
  31. package/lib/backend/globalTrades/index.js +0 -69
  32. package/lib/backend/index.d.ts +0 -3
  33. package/lib/backend/index.js +0 -28
  34. package/lib/backend/tradingVariables/backend.types.d.ts +0 -312
  35. package/lib/backend/tradingVariables/backend.types.js +0 -2
  36. package/lib/backend/tradingVariables/converter.d.ts +0 -31
  37. package/lib/backend/tradingVariables/converter.js +0 -330
  38. package/lib/backend/tradingVariables/index.d.ts +0 -5
  39. package/lib/backend/tradingVariables/index.js +0 -95
  40. package/lib/backend/tradingVariables/types.d.ts +0 -109
  41. package/lib/backend/tradingVariables/types.js +0 -14
  42. package/lib/contracts/types/generated/GFarmTradingStorageV5.d.ts +0 -1911
  43. package/lib/contracts/types/generated/GFarmTradingStorageV5.js +0 -2
  44. package/lib/contracts/types/generated/GNSBorrowingFees.d.ts +0 -1067
  45. package/lib/contracts/types/generated/GNSBorrowingFees.js +0 -2
  46. package/lib/contracts/types/generated/GNSNftRewardsV6.d.ts +0 -533
  47. package/lib/contracts/types/generated/GNSNftRewardsV6.js +0 -2
  48. package/lib/contracts/types/generated/GNSNftRewardsV6_3_1.d.ts +0 -613
  49. package/lib/contracts/types/generated/GNSNftRewardsV6_3_1.js +0 -2
  50. package/lib/contracts/types/generated/GNSTrading.d.ts +0 -758
  51. package/lib/contracts/types/generated/GNSTrading.js +0 -2
  52. package/lib/contracts/types/generated/GNSTradingCallbacks.d.ts +0 -875
  53. package/lib/contracts/types/generated/GNSTradingCallbacks.js +0 -2
  54. package/lib/contracts/types/generated/GNSTradingStorage.d.ts +0 -1387
  55. package/lib/contracts/types/generated/GNSTradingStorage.js +0 -2
  56. package/lib/contracts/types/generated/GTokenV6_3_2.d.ts +0 -1838
  57. package/lib/contracts/types/generated/GTokenV6_3_2.js +0 -2
  58. package/lib/contracts/types/generated/factories/GFarmTradingStorageV5__factory.d.ts +0 -83
  59. package/lib/contracts/types/generated/factories/GFarmTradingStorageV5__factory.js +0 -2691
  60. package/lib/contracts/types/generated/factories/GNSBorrowingFees__factory.d.ts +0 -124
  61. package/lib/contracts/types/generated/factories/GNSBorrowingFees__factory.js +0 -1784
  62. package/lib/contracts/types/generated/factories/GNSNftRewardsV6_3_1__factory.d.ts +0 -100
  63. package/lib/contracts/types/generated/factories/GNSNftRewardsV6_3_1__factory.js +0 -1116
  64. package/lib/contracts/types/generated/factories/GNSNftRewardsV6__factory.d.ts +0 -100
  65. package/lib/contracts/types/generated/factories/GNSNftRewardsV6__factory.js +0 -1003
  66. package/lib/contracts/types/generated/factories/GNSTradingCallbacks__factory.d.ts +0 -113
  67. package/lib/contracts/types/generated/factories/GNSTradingCallbacks__factory.js +0 -1428
  68. package/lib/contracts/types/generated/factories/GNSTradingStorage__factory.d.ts +0 -96
  69. package/lib/contracts/types/generated/factories/GNSTradingStorage__factory.js +0 -2241
  70. package/lib/contracts/types/generated/factories/GNSTrading__factory.d.ts +0 -95
  71. package/lib/contracts/types/generated/factories/GNSTrading__factory.js +0 -1071
  72. package/lib/contracts/types/generated/factories/GTokenV6_3_2__factory.d.ts +0 -110
  73. package/lib/contracts/types/generated/factories/GTokenV6_3_2__factory.js +0 -2682
  74. package/lib/contracts/utils/openLimitOrders.d.ts +0 -8
  75. package/lib/contracts/utils/openLimitOrders.js +0 -88
  76. package/lib/markets/collateral/converter.d.ts +0 -5
  77. package/lib/markets/collateral/converter.js +0 -11
  78. package/lib/markets/collateral/index.d.ts +0 -1
  79. package/lib/markets/collateral/index.js +0 -17
  80. package/lib/markets/collateral/types.d.ts +0 -7
  81. package/lib/markets/collateral/types.js +0 -2
  82. package/lib/markets/oi/converter.d.ts +0 -63
  83. package/lib/markets/oi/converter.js +0 -103
  84. package/lib/markets/oi/fetcher.d.ts +0 -58
  85. package/lib/markets/oi/fetcher.js +0 -181
  86. package/lib/markets/oi/index.d.ts +0 -10
  87. package/lib/markets/oi/index.js +0 -37
  88. package/lib/markets/oi/types.d.ts +0 -82
  89. package/lib/markets/oi/types.js +0 -6
  90. package/lib/markets/oi/validation.d.ts +0 -80
  91. package/lib/markets/oi/validation.js +0 -172
  92. package/lib/trade/fees/borrowing/builder.d.ts +0 -14
  93. package/lib/trade/fees/borrowing/builder.js +0 -33
  94. package/lib/trade/fees/borrowingV2/builder.d.ts +0 -6
  95. package/lib/trade/fees/borrowingV2/builder.js +0 -24
  96. package/lib/trade/fees/converter.d.ts +0 -48
  97. package/lib/trade/fees/converter.js +0 -110
  98. package/lib/trade/fees/fundingFees/builder.d.ts +0 -9
  99. package/lib/trade/fees/fundingFees/builder.js +0 -35
  100. package/lib/trade/fees/fundingFees/pairContext.d.ts +0 -33
  101. package/lib/trade/fees/fundingFees/pairContext.js +0 -17
  102. package/lib/trade/fees/tiers/converter.d.ts +0 -54
  103. package/lib/trade/fees/tiers/converter.js +0 -81
  104. package/lib/trade/fees/trading/builder.d.ts +0 -18
  105. package/lib/trade/fees/trading/builder.js +0 -20
  106. package/lib/trade/liquidation/builder.d.ts +0 -25
  107. package/lib/trade/liquidation/builder.js +0 -59
  108. package/lib/trade/liquidation/converter.d.ts +0 -23
  109. package/lib/trade/liquidation/converter.js +0 -46
  110. package/lib/trade/liquidation/index.d.ts +0 -26
  111. package/lib/trade/liquidation/index.js +0 -142
  112. package/lib/trade/liquidation/types.d.ts +0 -59
  113. package/lib/trade/liquidation/types.js +0 -2
  114. package/lib/trade/openLimitOrder.d.ts +0 -2
  115. package/lib/trade/openLimitOrder.js +0 -23
  116. package/lib/trade/pnl/builder.d.ts +0 -16
  117. package/lib/trade/pnl/builder.js +0 -44
  118. package/lib/trade/pnl/converter.d.ts +0 -47
  119. package/lib/trade/pnl/converter.js +0 -72
  120. package/lib/trade/pnl/index.d.ts +0 -77
  121. package/lib/trade/pnl/index.js +0 -270
  122. package/lib/trade/pnl/types.d.ts +0 -114
  123. package/lib/trade/pnl/types.js +0 -5
  124. package/lib/trade/priceImpact/close/index.d.ts +0 -21
  125. package/lib/trade/priceImpact/close/index.js +0 -131
  126. package/lib/trade/priceImpact/close/types.d.ts +0 -43
  127. package/lib/trade/priceImpact/close/types.js +0 -5
  128. package/lib/trade/priceImpact/cumulVol/converter.d.ts +0 -31
  129. package/lib/trade/priceImpact/cumulVol/converter.js +0 -59
  130. package/lib/trade/priceImpact/cumulVol/index.d.ts +0 -107
  131. package/lib/trade/priceImpact/cumulVol/index.js +0 -228
  132. package/lib/trade/priceImpact/open/index.d.ts +0 -22
  133. package/lib/trade/priceImpact/open/index.js +0 -76
  134. package/lib/trade/priceImpact/open/types.d.ts +0 -41
  135. package/lib/trade/priceImpact/open/types.js +0 -5
  136. /package/lib/{trade/fees/fundingFees/fetcher.js → contracts/fetch/fees/fundingFees.js} +0 -0
@@ -22,6 +22,10 @@
22
22
  "GNS": {
23
23
  "gTokenOpenPnlFeed": "0x0000000000000000000000000000000000000000",
24
24
  "gToken": "0x0000000000000000000000000000000000000000"
25
+ },
26
+ "BTCUSD": {
27
+ "gTokenOpenPnlFeed": "0x0000000000000000000000000000000000000000",
28
+ "gToken": "0x0000000000000000000000000000000000000000"
25
29
  }
26
30
  },
27
31
  "42161": {
@@ -47,6 +51,10 @@
47
51
  "GNS": {
48
52
  "gTokenOpenPnlFeed": "0x4ca1638754Be8060E544Aca4A4F43702Be30E0D1",
49
53
  "gToken": "0x4BeeF1113F968326905224D2Ca272f3032A9a9F4"
54
+ },
55
+ "BTCUSD": {
56
+ "gTokenOpenPnlFeed": "0x0000000000000000000000000000000000000000",
57
+ "gToken": "0x0000000000000000000000000000000000000000"
50
58
  }
51
59
  },
52
60
  "421614": {
@@ -72,6 +80,10 @@
72
80
  "GNS": {
73
81
  "gTokenOpenPnlFeed": "0x68F8D4ec2EF23a15e61e1642E730b6f69fB9A5De",
74
82
  "gToken": "0x5ed4bEA869300DB39bE2a92a8B42e53453742a43"
83
+ },
84
+ "BTCUSD": {
85
+ "gTokenOpenPnlFeed": "0x0000000000000000000000000000000000000000",
86
+ "gToken": "0x0000000000000000000000000000000000000000"
75
87
  }
76
88
  },
77
89
  "8453": {
@@ -97,6 +109,10 @@
97
109
  "GNS": {
98
110
  "gTokenOpenPnlFeed": "0x0000000000000000000000000000000000000000",
99
111
  "gToken": "0x0000000000000000000000000000000000000000"
112
+ },
113
+ "BTCUSD": {
114
+ "gTokenOpenPnlFeed": "0xA22F7b92d81Dd74bE5ca5758DF3FccF0A4CB19cc",
115
+ "gToken": "0xB7Cb7cB7C3cD96e251c9bF8800B9631134BbAdc6"
100
116
  }
101
117
  },
102
118
  "33139": {
@@ -122,6 +138,10 @@
122
138
  "GNS": {
123
139
  "gTokenOpenPnlFeed": "0x0000000000000000000000000000000000000000",
124
140
  "gToken": "0x0000000000000000000000000000000000000000"
141
+ },
142
+ "BTCUSD": {
143
+ "gTokenOpenPnlFeed": "0x0000000000000000000000000000000000000000",
144
+ "gToken": "0x0000000000000000000000000000000000000000"
125
145
  }
126
146
  }
127
147
  }
@@ -1,5 +1,6 @@
1
- import type { GNSMultiCollatDiamond } from "../../../contracts/types/generated";
2
- import { BorrowingFeeV2 } from ".";
1
+ /// <reference types="mocha" />
2
+ import type { GNSMultiCollatDiamond } from "../../types/generated";
3
+ import { BorrowingFeeV2 } from "../../../trade/fees/borrowingV2";
3
4
  /**
4
5
  * @dev Fetches borrowing fee parameters v2 for specific pairs
5
6
  * @param contract GNSMultiCollatDiamond contract instance
@@ -10,7 +10,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.fetchBorrowingV2DataForPairs = exports.createBorrowingV2ContextFromArrays = exports.createBorrowingV2ContextFromContract = exports.fetchAllBorrowingV2Data = exports.fetchPairPendingAccBorrowingFeesV2 = exports.fetchTradeBorrowingFeesCollateralV2 = exports.fetchPairBorrowingFeeDataV2 = exports.fetchBorrowingFeeParamsV2 = void 0;
13
- const converter_1 = require("./converter");
13
+ const converter_1 = require("../../../trade/fees/borrowingV2/converter");
14
14
  /**
15
15
  * @dev Fetches borrowing fee parameters v2 for specific pairs
16
16
  * @param contract GNSMultiCollatDiamond contract instance
@@ -147,12 +147,20 @@ const createBorrowingV2ContextFromArrays = (collateralIndices, pairIndices, para
147
147
  borrowingParams: {},
148
148
  borrowingData: {},
149
149
  };
150
- // Build objects indexed by pairIndex (collateral-scoped)
151
- for (let i = 0; i < pairIndices.length; i++) {
150
+ // Build nested objects indexed by collateralIndex and pairIndex
151
+ for (let i = 0; i < collateralIndices.length; i++) {
152
+ const collateralIndex = collateralIndices[i];
152
153
  const pairIndex = pairIndices[i];
153
- // Store data indexed by pairIndex
154
- context.borrowingParams[pairIndex] = params[i];
155
- context.borrowingData[pairIndex] = data[i];
154
+ // Initialize collateral index objects if they don't exist
155
+ if (!context.borrowingParams[collateralIndex]) {
156
+ context.borrowingParams[collateralIndex] = {};
157
+ }
158
+ if (!context.borrowingData[collateralIndex]) {
159
+ context.borrowingData[collateralIndex] = {};
160
+ }
161
+ // Store data
162
+ context.borrowingParams[collateralIndex][pairIndex] = params[i];
163
+ context.borrowingData[collateralIndex][pairIndex] = data[i];
156
164
  }
157
165
  return context;
158
166
  };
@@ -1,5 +1,5 @@
1
- import type { GNSMultiCollatDiamond } from "../../../contracts/types/generated";
2
- import type { TradeInitialAccFees } from ".";
1
+ import type { GNSMultiCollatDiamond } from "../../types/generated";
2
+ import type { TradeInitialAccFees } from "../../../trade/fees/fundingFees";
3
3
  /**
4
4
  * @dev Fetches pending accumulated funding fees for a specific pair
5
5
  * @param contract GNSMultiCollatDiamond contract instance
@@ -1,5 +1,5 @@
1
- import type { GNSMultiCollatDiamond } from "../../../contracts/types/generated";
2
- import type { PairOiToken, SkewPriceImpactContext } from "..";
1
+ import type { GNSMultiCollatDiamond } from "../../types/generated";
2
+ import type { PairOiToken, SkewPriceImpactContext } from "../../../trade/priceImpact";
3
3
  /**
4
4
  * @dev Fetches pair open interest in tokens for a specific pair
5
5
  * @param contract GNSMultiCollatDiamond contract instance
@@ -10,7 +10,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.calculateTradeSkewPriceImpact = exports.fetchCollateralDecimals = exports.fetchSkewPriceImpactContext = exports.fetchPairSkewDepths = exports.fetchPairSkewDepth = exports.fetchPairOisAfterV10Token = exports.fetchPairOiAfterV10Token = void 0;
13
- const __1 = require("..");
13
+ const priceImpact_1 = require("../../../trade/priceImpact");
14
14
  /**
15
15
  * @dev Fetches pair open interest in tokens for a specific pair
16
16
  * @param contract GNSMultiCollatDiamond contract instance
@@ -21,7 +21,7 @@ const __1 = require("..");
21
21
  const fetchPairOiAfterV10Token = (contract, collateralIndex, pairIndex) => __awaiter(void 0, void 0, void 0, function* () {
22
22
  try {
23
23
  const contractData = yield contract.getPairOiAfterV10Token(collateralIndex, pairIndex);
24
- return (0, __1.convertPairOiToken)(contractData);
24
+ return (0, priceImpact_1.convertPairOiToken)(contractData);
25
25
  }
26
26
  catch (error) {
27
27
  console.error("Error fetching pair OI token:", error);
@@ -42,7 +42,7 @@ const fetchPairOisAfterV10Token = (contract, collateralIndices, pairIndices) =>
42
42
  }
43
43
  try {
44
44
  const contractDataArray = yield contract.getPairOisAfterV10Token(collateralIndices, pairIndices);
45
- return contractDataArray.map(__1.convertPairOiToken);
45
+ return contractDataArray.map(priceImpact_1.convertPairOiToken);
46
46
  }
47
47
  catch (error) {
48
48
  console.error("Error fetching pair OIs token:", error);
@@ -61,7 +61,7 @@ exports.fetchPairOisAfterV10Token = fetchPairOisAfterV10Token;
61
61
  const fetchPairSkewDepth = (contract, collateralIndex, pairIndex, collateralDecimals) => __awaiter(void 0, void 0, void 0, function* () {
62
62
  try {
63
63
  const contractDepth = yield contract.getPairSkewDepth(collateralIndex, pairIndex);
64
- return (0, __1.normalizeSkewDepth)(contractDepth.toBigInt(), collateralDecimals);
64
+ return (0, priceImpact_1.normalizeSkewDepth)(contractDepth.toBigInt(), collateralDecimals);
65
65
  }
66
66
  catch (error) {
67
67
  console.error("Error fetching skew depth:", error);
@@ -84,7 +84,7 @@ const fetchPairSkewDepths = (contract, collateralIndices, pairIndices, collatera
84
84
  }
85
85
  try {
86
86
  const contractDepths = yield contract.getPairSkewDepths(collateralIndices, pairIndices);
87
- return contractDepths.map((depth, i) => (0, __1.normalizeSkewDepth)(depth.toBigInt(), collateralDecimals[i]));
87
+ return contractDepths.map((depth, i) => (0, priceImpact_1.normalizeSkewDepth)(depth.toBigInt(), collateralDecimals[i]));
88
88
  }
89
89
  catch (error) {
90
90
  console.error("Error fetching skew depths:", error);
@@ -107,7 +107,7 @@ const fetchSkewPriceImpactContext = (contract, collateralIndices, pairIndices, c
107
107
  (0, exports.fetchPairOisAfterV10Token)(contract, collateralIndices, pairIndices),
108
108
  (0, exports.fetchPairSkewDepths)(contract, collateralIndices, pairIndices, collateralDecimals),
109
109
  ]);
110
- return (0, __1.createSkewPriceImpactContext)(collateralIndices, pairIndices, skewDepths, pairOiTokens);
110
+ return (0, priceImpact_1.createSkewPriceImpactContext)(collateralIndices, pairIndices, skewDepths, pairOiTokens);
111
111
  }
112
112
  catch (error) {
113
113
  console.error("Error fetching skew price impact context:", error);
@@ -63,6 +63,7 @@ exports.COLLATERAL_TO_CHAIN_COLLATERAL_INDEX = {
63
63
  },
64
64
  [types_1.ChainId.BASE]: {
65
65
  [types_1.CollateralTypes.USDC]: 1,
66
+ [types_1.CollateralTypes.BTCUSD]: 2,
66
67
  },
67
68
  [types_1.ChainId.APECHAIN]: {
68
69
  [types_1.CollateralTypes.APE]: 1,
@@ -75,7 +76,8 @@ exports.COLLATERAL_TO_COLLATERAL_INDEX = {
75
76
  [types_1.CollateralTypes.USDC]: 3,
76
77
  [types_1.CollateralTypes.ARB]: 0,
77
78
  [types_1.CollateralTypes.APE]: 0,
78
- [types_1.CollateralTypes.GNS]: 0, // not in use
79
+ [types_1.CollateralTypes.GNS]: 0,
80
+ [types_1.CollateralTypes.BTCUSD]: 0,
79
81
  };
80
82
  __exportStar(require("./utils"), exports);
81
83
  __exportStar(require("./addresses"), exports);