@gainsnetwork/sdk 0.2.0-rc5 → 0.2.1-rc1
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.
- package/lib/constants.d.ts +1 -0
- package/lib/constants.js +2 -1
- package/lib/contracts/index.d.ts +5 -0
- package/lib/contracts/index.js +20 -4
- package/lib/contracts/utils/pairs.d.ts +1 -1
- package/lib/contracts/utils/pairs.js +4 -10
- package/lib/trade/types.d.ts +2 -1
- package/lib/trade/types.js +1 -0
- package/package.json +1 -1
- package/lib/contracts/types/generated/GFarmTradingStorageV5.d.ts +0 -1911
- package/lib/contracts/types/generated/GFarmTradingStorageV5.js +0 -2
- package/lib/contracts/types/generated/GNSBorrowingFees.d.ts +0 -1067
- package/lib/contracts/types/generated/GNSBorrowingFees.js +0 -2
- package/lib/contracts/types/generated/GNSNftRewardsV6.d.ts +0 -533
- package/lib/contracts/types/generated/GNSNftRewardsV6.js +0 -2
- package/lib/contracts/types/generated/GNSNftRewardsV6_3_1.d.ts +0 -613
- package/lib/contracts/types/generated/GNSNftRewardsV6_3_1.js +0 -2
- package/lib/contracts/types/generated/GNSTrading.d.ts +0 -758
- package/lib/contracts/types/generated/GNSTrading.js +0 -2
- package/lib/contracts/types/generated/GNSTradingCallbacks.d.ts +0 -875
- package/lib/contracts/types/generated/GNSTradingCallbacks.js +0 -2
- package/lib/contracts/types/generated/GNSTradingStorage.d.ts +0 -1387
- package/lib/contracts/types/generated/GNSTradingStorage.js +0 -2
- package/lib/contracts/types/generated/factories/GFarmTradingStorageV5__factory.d.ts +0 -83
- package/lib/contracts/types/generated/factories/GFarmTradingStorageV5__factory.js +0 -2691
- package/lib/contracts/types/generated/factories/GNSBorrowingFees__factory.d.ts +0 -124
- package/lib/contracts/types/generated/factories/GNSBorrowingFees__factory.js +0 -1784
- package/lib/contracts/types/generated/factories/GNSNftRewardsV6_3_1__factory.d.ts +0 -100
- package/lib/contracts/types/generated/factories/GNSNftRewardsV6_3_1__factory.js +0 -1116
- package/lib/contracts/types/generated/factories/GNSNftRewardsV6__factory.d.ts +0 -100
- package/lib/contracts/types/generated/factories/GNSNftRewardsV6__factory.js +0 -1003
- package/lib/contracts/types/generated/factories/GNSTradingCallbacks__factory.d.ts +0 -113
- package/lib/contracts/types/generated/factories/GNSTradingCallbacks__factory.js +0 -1428
- package/lib/contracts/types/generated/factories/GNSTradingStorage__factory.d.ts +0 -96
- package/lib/contracts/types/generated/factories/GNSTradingStorage__factory.js +0 -2241
- package/lib/contracts/types/generated/factories/GNSTrading__factory.d.ts +0 -95
- package/lib/contracts/types/generated/factories/GNSTrading__factory.js +0 -1071
package/lib/constants.d.ts
CHANGED
|
@@ -231,6 +231,7 @@ export declare const pairs: {
|
|
|
231
231
|
"LL/USD": string;
|
|
232
232
|
"MSN/USD": string;
|
|
233
233
|
"REZ/USD": string;
|
|
234
|
+
"NOT/USD": string;
|
|
234
235
|
};
|
|
235
236
|
export declare const getAssetClassFromGroupIndex: (groupIndex: number) => string | undefined;
|
|
236
237
|
export declare const tickerChanges: {
|
package/lib/constants.js
CHANGED
|
@@ -239,6 +239,7 @@ exports.pairs = {
|
|
|
239
239
|
"LL/USD": CRYPTO,
|
|
240
240
|
"MSN/USD": CRYPTO,
|
|
241
241
|
"REZ/USD": CRYPTO,
|
|
242
|
+
"NOT/USD": CRYPTO,
|
|
242
243
|
};
|
|
243
244
|
const getAssetClassFromGroupIndex = (groupIndex) => {
|
|
244
245
|
switch (groupIndex) {
|
|
@@ -272,6 +273,6 @@ exports.stockSplits = {
|
|
|
272
273
|
exports.delistedPairIxs = new Set([
|
|
273
274
|
6, 31, 36, 42, 45, 48, 51, 54, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69,
|
|
274
275
|
70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88,
|
|
275
|
-
89, 97, 99, 101, 106, 108, 52, 131, 147, 160, 179, 182, 183, 190, 229,
|
|
276
|
+
89, 97, 99, 101, 106, 108, 52, 131, 147, 160, 179, 182, 183, 190, 229, 232,
|
|
276
277
|
]);
|
|
277
278
|
exports.delistedGroupsIxs = new Set([6, 7]);
|
package/lib/contracts/index.d.ts
CHANGED
|
@@ -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";
|
package/lib/contracts/index.js
CHANGED
|
@@ -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
|
-
|
|
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
|
|
37
|
-
Object.defineProperty(exports, "CollateralTypes", { enumerable: true, get: function () { return
|
|
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: (
|
|
6
|
+
export declare const fetchOpenInterest: (contracts: Contracts, collateralIndex: number, pairIxs: number[]) => Promise<OpenInterest[]>;
|
|
7
7
|
export declare const getPairDescription: (pairIndex: PairIndex) => string;
|
|
@@ -82,13 +82,10 @@ const fetchFees = (contracts, feeIxs) => __awaiter(void 0, void 0, void 0, funct
|
|
|
82
82
|
}
|
|
83
83
|
});
|
|
84
84
|
exports.fetchFees = fetchFees;
|
|
85
|
-
const fetchOpenInterest = (
|
|
85
|
+
const fetchOpenInterest = (contracts, collateralIndex, pairIxs) => __awaiter(void 0, void 0, void 0, function* () {
|
|
86
86
|
if (pairIxs.length === 0) {
|
|
87
87
|
return [];
|
|
88
88
|
}
|
|
89
|
-
const { precision: collateralPrecision, precisionDelta: collateralPrecisionDelta, } = yield contracts.gnsMultiCollatDiamond.getCollateral(collateralIndex);
|
|
90
|
-
const precision = parseFloat(collateralPrecision.toString());
|
|
91
|
-
const precisionDelta = parseFloat(collateralPrecisionDelta.toString());
|
|
92
89
|
const openInterests = (yield contracts.gnsMultiCollatDiamond.getAllBorrowingPairs(collateralIndex))[1];
|
|
93
90
|
return pairIxs.map(pairIndex => {
|
|
94
91
|
const openInterest = openInterests[pairIndex];
|
|
@@ -96,12 +93,8 @@ const fetchOpenInterest = (collateralIndex, contracts, pairIxs) => __awaiter(voi
|
|
|
96
93
|
return { long: 0, short: 0, max: 0 };
|
|
97
94
|
}
|
|
98
95
|
return {
|
|
99
|
-
long:
|
|
100
|
-
|
|
101
|
-
precision,
|
|
102
|
-
short: (parseFloat(openInterest[1].toString()) * precisionDelta) /
|
|
103
|
-
1e10 /
|
|
104
|
-
precision,
|
|
96
|
+
long: parseFloat(openInterest[0].toString()) / 1e10,
|
|
97
|
+
short: parseFloat(openInterest[1].toString()) / 1e10,
|
|
105
98
|
max: parseFloat(openInterest[2].toString()) / 1e10,
|
|
106
99
|
};
|
|
107
100
|
});
|
|
@@ -344,4 +337,5 @@ const PAIR_INDEX_TO_DESCRIPTION = {
|
|
|
344
337
|
[types_1.PairIndex.LLUSD]: "Light Link to US Dollar",
|
|
345
338
|
[types_1.PairIndex.MSNUSD]: "Meson Network to US Dollar",
|
|
346
339
|
[types_1.PairIndex.REZUSD]: "Renzo to US Dollar",
|
|
340
|
+
[types_1.PairIndex.NOTUSD]: "Notcoin to US Dollar",
|
|
347
341
|
};
|
package/lib/trade/types.d.ts
CHANGED
package/lib/trade/types.js
CHANGED
|
@@ -261,4 +261,5 @@ var PairIndex;
|
|
|
261
261
|
PairIndex[PairIndex["LLUSD"] = 229] = "LLUSD";
|
|
262
262
|
PairIndex[PairIndex["MSNUSD"] = 230] = "MSNUSD";
|
|
263
263
|
PairIndex[PairIndex["REZUSD"] = 231] = "REZUSD";
|
|
264
|
+
PairIndex[PairIndex["NOTUSD"] = 232] = "NOTUSD";
|
|
264
265
|
})(PairIndex = exports.PairIndex || (exports.PairIndex = {}));
|