@gainsnetwork/sdk 0.2.0-rc4 → 0.2.0-rc6

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.
@@ -220,8 +220,17 @@ export declare const pairs: {
220
220
  "RONIN/USD": string;
221
221
  "ENA/USD": string;
222
222
  "W/USD": string;
223
- "TNSR/USD": string;
224
223
  "ZEUS/USD": string;
224
+ "TNSR/USD": string;
225
+ "TAO/USD": string;
226
+ "OMNI/USD": string;
227
+ "PRCL/USD": string;
228
+ "MERL/USD": string;
229
+ "SAFE/USD": string;
230
+ "SAGA/USD": string;
231
+ "LL/USD": string;
232
+ "MSN/USD": string;
233
+ "REZ/USD": string;
225
234
  };
226
235
  export declare const getAssetClassFromGroupIndex: (groupIndex: number) => string | undefined;
227
236
  export declare const tickerChanges: {
package/lib/constants.js CHANGED
@@ -228,8 +228,17 @@ exports.pairs = {
228
228
  "RONIN/USD": CRYPTO,
229
229
  "ENA/USD": CRYPTO,
230
230
  "W/USD": CRYPTO,
231
- "TNSR/USD": CRYPTO,
232
231
  "ZEUS/USD": CRYPTO,
232
+ "TNSR/USD": CRYPTO,
233
+ "TAO/USD": CRYPTO,
234
+ "OMNI/USD": CRYPTO,
235
+ "PRCL/USD": CRYPTO,
236
+ "MERL/USD": CRYPTO,
237
+ "SAFE/USD": CRYPTO,
238
+ "SAGA/USD": CRYPTO,
239
+ "LL/USD": CRYPTO,
240
+ "MSN/USD": CRYPTO,
241
+ "REZ/USD": CRYPTO,
233
242
  };
234
243
  const getAssetClassFromGroupIndex = (groupIndex) => {
235
244
  switch (groupIndex) {
@@ -263,7 +272,6 @@ exports.stockSplits = {
263
272
  exports.delistedPairIxs = new Set([
264
273
  6, 31, 36, 42, 45, 48, 51, 54, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69,
265
274
  70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88,
266
- 89, 97, 99, 101, 106, 107, 108, 52, 131, 147, 160, 179, 182, 183, 190, 194,
267
- 221, 222,
275
+ 89, 97, 99, 101, 106, 108, 52, 131, 147, 160, 179, 182, 183, 190, 229,
268
276
  ]);
269
277
  exports.delistedGroupsIxs = new Set([6, 7]);
@@ -33,21 +33,21 @@
33
33
  "gToken": "0xd3443ee1e91aF28e5FB858Fbd0D72A63bA8046E0"
34
34
  }
35
35
  },
36
- "80001": {
36
+ "421614": {
37
37
  "global": {
38
- "gnsMultiCollatDiamond": "0xDee93dD1Cb54ce80D690eC07a20CB0ce9d7F741C"
38
+ "gnsMultiCollatDiamond": "0xd659a15812064C79E189fd950A189b15c75d3186"
39
39
  },
40
40
  "DAI": {
41
- "gTokenOpenPnlFeed": "0xA7C829CB2346E12DC49Fd5ea8002Abaf48E9396C",
42
- "gToken": "0x5215C8B3e76D493c8bcb9A7352F7afe18A6bb091"
41
+ "gTokenOpenPnlFeed": "0x371a924C2DC433D0C83b67Ff71A4CBd2013b5046",
42
+ "gToken": "0xD6e33C7560009D60052d7A5E0476A8Db295bF8C7"
43
43
  },
44
44
  "ETH": {
45
- "gTokenOpenPnlFeed": "0xC8D8d6efBC343604f8B6288a20C00a9D7f697A38",
46
- "gToken": "0x71A52242f7430cF4a290854d93f6719a8C35F287"
45
+ "gTokenOpenPnlFeed": "0xab1042C2767461D59ABC9547b3B717ccae3Eb7C9",
46
+ "gToken": "0xfd7E69042812f3416C18261673b55eD005F67E01"
47
47
  },
48
48
  "USDC": {
49
- "gTokenOpenPnlFeed": "0x540E381b5Aef048D317A715667b12ec999D397Bc",
50
- "gToken": "0xd7F8D728414a6aD18476B5a72a0C20be5704f868"
49
+ "gTokenOpenPnlFeed": "0x38e6cEFcE96bdB65D64Fce8f4736b3763A5F9eD2",
50
+ "gToken": "0xb0C25646774Ad985B4f9ccD262623bA6D6F64677"
51
51
  }
52
52
  }
53
53
  }
@@ -3,6 +3,11 @@ import type { Provider } from "@ethersproject/providers";
3
3
  import { CollateralTypes, Contracts } from "./types";
4
4
  export declare const getContractsForChain: (chainId: number, signerOrProvider?: Signer | Provider, collateral?: CollateralTypes) => Contracts;
5
5
  export declare const getContractsForChainByRequester: (chainId: number, requester: string, signerOrProvider?: Signer | Provider) => Contracts;
6
+ export declare const getCollateralIndexAndContractsForChainByRequester: (chainId: number, requester: string, signerOrProvider?: Signer | Provider) => {
7
+ contracts: Contracts;
8
+ collateralIndex: number;
9
+ };
10
+ export declare const COLLATERAL_TO_COLLATERAL_INDEX: Record<CollateralTypes, number>;
6
11
  export * from "./utils";
7
12
  export * from "./addresses";
8
13
  export { CollateralTypes } from "./types";
@@ -14,9 +14,10 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- exports.CollateralTypes = exports.getContractsForChainByRequester = exports.getContractsForChain = void 0;
17
+ exports.CollateralTypes = exports.COLLATERAL_TO_COLLATERAL_INDEX = exports.getCollateralIndexAndContractsForChainByRequester = exports.getContractsForChainByRequester = exports.getContractsForChain = void 0;
18
18
  const addresses_1 = require("./addresses");
19
19
  const factories_1 = require("./types/generated/factories");
20
+ const types_1 = require("./types");
20
21
  // @todo rework this to return all
21
22
  const getContractsForChain = (chainId, signerOrProvider, collateral) => {
22
23
  const addresses = (0, addresses_1.getContractAddressesForChain)(chainId, collateral);
@@ -28,10 +29,25 @@ const getContractsForChain = (chainId, signerOrProvider, collateral) => {
28
29
  };
29
30
  exports.getContractsForChain = getContractsForChain;
30
31
  const getContractsForChainByRequester = (chainId, requester, signerOrProvider) => {
31
- return (0, exports.getContractsForChain)(chainId, signerOrProvider, (0, addresses_1.getCollateralByAddressForChain)(chainId, requester));
32
+ const { contracts } = (0, exports.getCollateralIndexAndContractsForChainByRequester)(chainId, requester, signerOrProvider);
33
+ return contracts;
32
34
  };
33
35
  exports.getContractsForChainByRequester = getContractsForChainByRequester;
36
+ const getCollateralIndexAndContractsForChainByRequester = (chainId, requester, signerOrProvider) => {
37
+ const collateral = (0, addresses_1.getCollateralByAddressForChain)(chainId, requester);
38
+ return {
39
+ contracts: (0, exports.getContractsForChain)(chainId, signerOrProvider, collateral),
40
+ collateralIndex: exports.COLLATERAL_TO_COLLATERAL_INDEX[collateral],
41
+ };
42
+ };
43
+ exports.getCollateralIndexAndContractsForChainByRequester = getCollateralIndexAndContractsForChainByRequester;
44
+ exports.COLLATERAL_TO_COLLATERAL_INDEX = {
45
+ [types_1.CollateralTypes.DAI]: 1,
46
+ [types_1.CollateralTypes.ETH]: 2,
47
+ [types_1.CollateralTypes.USDC]: 3,
48
+ [types_1.CollateralTypes.ARB]: 0, // not in use
49
+ };
34
50
  __exportStar(require("./utils"), exports);
35
51
  __exportStar(require("./addresses"), exports);
36
- var types_1 = require("./types");
37
- Object.defineProperty(exports, "CollateralTypes", { enumerable: true, get: function () { return types_1.CollateralTypes; } });
52
+ var types_2 = require("./types");
53
+ Object.defineProperty(exports, "CollateralTypes", { enumerable: true, get: function () { return types_2.CollateralTypes; } });
@@ -3,5 +3,5 @@ import { Contracts } from "../../contracts/types";
3
3
  export declare const fetchPairs: (contracts: Contracts, pairIxs: PairIndex[]) => Promise<Pair[]>;
4
4
  export declare const fetchPairDepths: (contracts: Contracts, pairIxs: number[]) => Promise<PairDepth[]>;
5
5
  export declare const fetchFees: (contracts: Contracts, feeIxs: PairIndex[]) => Promise<Fee[]>;
6
- export declare const fetchOpenInterest: (collateralIndex: number, contracts: Contracts, pairIxs: number[]) => Promise<OpenInterest[]>;
6
+ export declare const fetchOpenInterest: (contracts: Contracts, collateralIndex: number, pairIxs: number[]) => Promise<OpenInterest[]>;
7
7
  export declare const getPairDescription: (pairIndex: PairIndex) => string;
@@ -82,14 +82,10 @@ const fetchFees = (contracts, feeIxs) => __awaiter(void 0, void 0, void 0, funct
82
82
  }
83
83
  });
84
84
  exports.fetchFees = fetchFees;
85
- // @todo test
86
- const fetchOpenInterest = (collateralIndex, contracts, pairIxs) => __awaiter(void 0, void 0, void 0, function* () {
85
+ const fetchOpenInterest = (contracts, collateralIndex, pairIxs) => __awaiter(void 0, void 0, void 0, function* () {
87
86
  if (pairIxs.length === 0) {
88
87
  return [];
89
88
  }
90
- const { precision: collateralPrecision, precisionDelta: collateralPrecisionDelta, } = yield contracts.gnsMultiCollatDiamond.getCollateral(collateralIndex);
91
- const precision = parseFloat(collateralPrecision.toString());
92
- const precisionDelta = parseFloat(collateralPrecisionDelta.toString());
93
89
  const openInterests = (yield contracts.gnsMultiCollatDiamond.getAllBorrowingPairs(collateralIndex))[1];
94
90
  return pairIxs.map(pairIndex => {
95
91
  const openInterest = openInterests[pairIndex];
@@ -97,12 +93,8 @@ const fetchOpenInterest = (collateralIndex, contracts, pairIxs) => __awaiter(voi
97
93
  return { long: 0, short: 0, max: 0 };
98
94
  }
99
95
  return {
100
- long: (parseFloat(openInterest[0].toString()) * precisionDelta) /
101
- 1e10 /
102
- precision,
103
- short: (parseFloat(openInterest[1].toString()) * precisionDelta) /
104
- 1e10 /
105
- precision,
96
+ long: parseFloat(openInterest[0].toString()) / 1e10,
97
+ short: parseFloat(openInterest[1].toString()) / 1e10,
106
98
  max: parseFloat(openInterest[2].toString()) / 1e10,
107
99
  };
108
100
  });
@@ -334,6 +326,15 @@ const PAIR_INDEX_TO_DESCRIPTION = {
334
326
  [types_1.PairIndex.RONINUSD]: "Ronin to US Dollar",
335
327
  [types_1.PairIndex.ENAUSD]: "Ethena to US Dollar",
336
328
  [types_1.PairIndex.WUSD]: "Wormhole to US Dollar",
337
- [types_1.PairIndex.TNSRUSD]: "Tensor to US Dollar",
338
329
  [types_1.PairIndex.ZEUSUSD]: "Zeus to US Dollar",
330
+ [types_1.PairIndex.TNSRUSD]: "Tensor to US Dollar",
331
+ [types_1.PairIndex.TAOUSD]: "Bittensor to US Dollar",
332
+ [types_1.PairIndex.OMNIUSD]: "Omni Network to US Dollar",
333
+ [types_1.PairIndex.PRCLUSD]: "Parcl to US Dollar",
334
+ [types_1.PairIndex.MERLUSD]: "Merlin Chain to US Dollar",
335
+ [types_1.PairIndex.SAFEUSD]: "Safe to US Dollar",
336
+ [types_1.PairIndex.SAGAUSD]: "Saga to US Dollar",
337
+ [types_1.PairIndex.LLUSD]: "Light Link to US Dollar",
338
+ [types_1.PairIndex.MSNUSD]: "Meson Network to US Dollar",
339
+ [types_1.PairIndex.REZUSD]: "Renzo to US Dollar",
339
340
  };
@@ -408,6 +408,15 @@ export declare enum PairIndex {
408
408
  RONINUSD = 218,
409
409
  ENAUSD = 219,
410
410
  WUSD = 220,
411
- TNSRUSD = 221,
412
- ZEUSUSD = 222
411
+ ZEUSUSD = 221,
412
+ TNSRUSD = 222,
413
+ TAOUSD = 223,
414
+ OMNIUSD = 224,
415
+ PRCLUSD = 225,
416
+ MERLUSD = 226,
417
+ SAFEUSD = 227,
418
+ SAGAUSD = 228,
419
+ LLUSD = 229,
420
+ MSNUSD = 230,
421
+ REZUSD = 231
413
422
  }
@@ -250,6 +250,15 @@ var PairIndex;
250
250
  PairIndex[PairIndex["RONINUSD"] = 218] = "RONINUSD";
251
251
  PairIndex[PairIndex["ENAUSD"] = 219] = "ENAUSD";
252
252
  PairIndex[PairIndex["WUSD"] = 220] = "WUSD";
253
- PairIndex[PairIndex["TNSRUSD"] = 221] = "TNSRUSD";
254
- PairIndex[PairIndex["ZEUSUSD"] = 222] = "ZEUSUSD";
253
+ PairIndex[PairIndex["ZEUSUSD"] = 221] = "ZEUSUSD";
254
+ PairIndex[PairIndex["TNSRUSD"] = 222] = "TNSRUSD";
255
+ PairIndex[PairIndex["TAOUSD"] = 223] = "TAOUSD";
256
+ PairIndex[PairIndex["OMNIUSD"] = 224] = "OMNIUSD";
257
+ PairIndex[PairIndex["PRCLUSD"] = 225] = "PRCLUSD";
258
+ PairIndex[PairIndex["MERLUSD"] = 226] = "MERLUSD";
259
+ PairIndex[PairIndex["SAFEUSD"] = 227] = "SAFEUSD";
260
+ PairIndex[PairIndex["SAGAUSD"] = 228] = "SAGAUSD";
261
+ PairIndex[PairIndex["LLUSD"] = 229] = "LLUSD";
262
+ PairIndex[PairIndex["MSNUSD"] = 230] = "MSNUSD";
263
+ PairIndex[PairIndex["REZUSD"] = 231] = "REZUSD";
255
264
  })(PairIndex = exports.PairIndex || (exports.PairIndex = {}));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gainsnetwork/sdk",
3
- "version": "0.2.0-rc4",
3
+ "version": "0.2.0-rc6",
4
4
  "description": "Gains Network SDK",
5
5
  "main": "./lib/index.js",
6
6
  "files": [