@gainsnetwork/sdk 0.0.51-multi-collat-rc4 → 0.0.51-multi-collat-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.
- package/lib/constants.js +2 -2
- package/lib/contracts/addresses.d.ts +1 -0
- package/lib/contracts/addresses.js +15 -3
- package/lib/contracts/addresses.json +60 -41
- package/lib/contracts/index.d.ts +1 -0
- package/lib/contracts/index.js +6 -2
- package/lib/contracts/types/generated/GToken.d.ts +1946 -0
- package/lib/contracts/types/generated/GToken.js +2 -0
- package/lib/contracts/types/generated/factories/GNSBorrowingFees__factory.js +0 -5
- package/lib/contracts/types/generated/factories/GToken__factory.d.ts +121 -0
- package/lib/contracts/types/generated/factories/GToken__factory.js +2944 -0
- package/lib/contracts/types/generated/factories/index.d.ts +1 -1
- package/lib/contracts/types/generated/factories/index.js +3 -3
- package/lib/contracts/types/generated/index.d.ts +2 -2
- package/lib/contracts/types/generated/index.js +3 -3
- package/lib/contracts/types/index.d.ts +4 -4
- package/lib/contracts/utils/openTrades.js +5 -3
- package/package.json +1 -1
|
@@ -6,5 +6,5 @@ export { GNSNftRewardsV6_3_1__factory } from "./GNSNftRewardsV6_3_1__factory";
|
|
|
6
6
|
export { GNSTrading__factory } from "./GNSTrading__factory";
|
|
7
7
|
export { GNSTradingCallbacks__factory } from "./GNSTradingCallbacks__factory";
|
|
8
8
|
export { GNSTradingStorage__factory } from "./GNSTradingStorage__factory";
|
|
9
|
+
export { GToken__factory } from "./GToken__factory";
|
|
9
10
|
export { GTokenOpenPnlFeed__factory } from "./GTokenOpenPnlFeed__factory";
|
|
10
|
-
export { GTokenV6_3_2__factory } from "./GTokenV6_3_2__factory";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.GTokenOpenPnlFeed__factory = exports.GToken__factory = exports.GNSTradingStorage__factory = exports.GNSTradingCallbacks__factory = exports.GNSTrading__factory = exports.GNSNftRewardsV6_3_1__factory = exports.GNSNftRewardsV6__factory = exports.GNSMultiCollatDiamond__factory = exports.GNSBorrowingFees__factory = exports.GFarmTradingStorageV5__factory = void 0;
|
|
4
4
|
/* Autogenerated file. Do not edit manually. */
|
|
5
5
|
/* tslint:disable */
|
|
6
6
|
/* eslint-disable */
|
|
@@ -20,7 +20,7 @@ var GNSTradingCallbacks__factory_1 = require("./GNSTradingCallbacks__factory");
|
|
|
20
20
|
Object.defineProperty(exports, "GNSTradingCallbacks__factory", { enumerable: true, get: function () { return GNSTradingCallbacks__factory_1.GNSTradingCallbacks__factory; } });
|
|
21
21
|
var GNSTradingStorage__factory_1 = require("./GNSTradingStorage__factory");
|
|
22
22
|
Object.defineProperty(exports, "GNSTradingStorage__factory", { enumerable: true, get: function () { return GNSTradingStorage__factory_1.GNSTradingStorage__factory; } });
|
|
23
|
+
var GToken__factory_1 = require("./GToken__factory");
|
|
24
|
+
Object.defineProperty(exports, "GToken__factory", { enumerable: true, get: function () { return GToken__factory_1.GToken__factory; } });
|
|
23
25
|
var GTokenOpenPnlFeed__factory_1 = require("./GTokenOpenPnlFeed__factory");
|
|
24
26
|
Object.defineProperty(exports, "GTokenOpenPnlFeed__factory", { enumerable: true, get: function () { return GTokenOpenPnlFeed__factory_1.GTokenOpenPnlFeed__factory; } });
|
|
25
|
-
var GTokenV6_3_2__factory_1 = require("./GTokenV6_3_2__factory");
|
|
26
|
-
Object.defineProperty(exports, "GTokenV6_3_2__factory", { enumerable: true, get: function () { return GTokenV6_3_2__factory_1.GTokenV6_3_2__factory; } });
|
|
@@ -6,8 +6,8 @@ export type { GNSNftRewardsV6_3_1 } from "./GNSNftRewardsV6_3_1";
|
|
|
6
6
|
export type { GNSTrading } from "./GNSTrading";
|
|
7
7
|
export type { GNSTradingCallbacks } from "./GNSTradingCallbacks";
|
|
8
8
|
export type { GNSTradingStorage } from "./GNSTradingStorage";
|
|
9
|
+
export type { GToken } from "./GToken";
|
|
9
10
|
export type { GTokenOpenPnlFeed } from "./GTokenOpenPnlFeed";
|
|
10
|
-
export type { GTokenV6_3_2 } from "./GTokenV6_3_2";
|
|
11
11
|
export * as factories from "./factories";
|
|
12
12
|
export { GFarmTradingStorageV5__factory } from "./factories/GFarmTradingStorageV5__factory";
|
|
13
13
|
export { GNSBorrowingFees__factory } from "./factories/GNSBorrowingFees__factory";
|
|
@@ -17,5 +17,5 @@ export { GNSNftRewardsV6_3_1__factory } from "./factories/GNSNftRewardsV6_3_1__f
|
|
|
17
17
|
export { GNSTrading__factory } from "./factories/GNSTrading__factory";
|
|
18
18
|
export { GNSTradingCallbacks__factory } from "./factories/GNSTradingCallbacks__factory";
|
|
19
19
|
export { GNSTradingStorage__factory } from "./factories/GNSTradingStorage__factory";
|
|
20
|
+
export { GToken__factory } from "./factories/GToken__factory";
|
|
20
21
|
export { GTokenOpenPnlFeed__factory } from "./factories/GTokenOpenPnlFeed__factory";
|
|
21
|
-
export { GTokenV6_3_2__factory } from "./factories/GTokenV6_3_2__factory";
|
|
@@ -23,7 +23,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
23
23
|
return result;
|
|
24
24
|
};
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.
|
|
26
|
+
exports.GTokenOpenPnlFeed__factory = exports.GToken__factory = exports.GNSTradingStorage__factory = exports.GNSTradingCallbacks__factory = exports.GNSTrading__factory = exports.GNSNftRewardsV6_3_1__factory = exports.GNSNftRewardsV6__factory = exports.GNSMultiCollatDiamond__factory = exports.GNSBorrowingFees__factory = exports.GFarmTradingStorageV5__factory = exports.factories = void 0;
|
|
27
27
|
exports.factories = __importStar(require("./factories"));
|
|
28
28
|
var GFarmTradingStorageV5__factory_1 = require("./factories/GFarmTradingStorageV5__factory");
|
|
29
29
|
Object.defineProperty(exports, "GFarmTradingStorageV5__factory", { enumerable: true, get: function () { return GFarmTradingStorageV5__factory_1.GFarmTradingStorageV5__factory; } });
|
|
@@ -41,7 +41,7 @@ var GNSTradingCallbacks__factory_1 = require("./factories/GNSTradingCallbacks__f
|
|
|
41
41
|
Object.defineProperty(exports, "GNSTradingCallbacks__factory", { enumerable: true, get: function () { return GNSTradingCallbacks__factory_1.GNSTradingCallbacks__factory; } });
|
|
42
42
|
var GNSTradingStorage__factory_1 = require("./factories/GNSTradingStorage__factory");
|
|
43
43
|
Object.defineProperty(exports, "GNSTradingStorage__factory", { enumerable: true, get: function () { return GNSTradingStorage__factory_1.GNSTradingStorage__factory; } });
|
|
44
|
+
var GToken__factory_1 = require("./factories/GToken__factory");
|
|
45
|
+
Object.defineProperty(exports, "GToken__factory", { enumerable: true, get: function () { return GToken__factory_1.GToken__factory; } });
|
|
44
46
|
var GTokenOpenPnlFeed__factory_1 = require("./factories/GTokenOpenPnlFeed__factory");
|
|
45
47
|
Object.defineProperty(exports, "GTokenOpenPnlFeed__factory", { enumerable: true, get: function () { return GTokenOpenPnlFeed__factory_1.GTokenOpenPnlFeed__factory; } });
|
|
46
|
-
var GTokenV6_3_2__factory_1 = require("./factories/GTokenV6_3_2__factory");
|
|
47
|
-
Object.defineProperty(exports, "GTokenV6_3_2__factory", { enumerable: true, get: function () { return GTokenV6_3_2__factory_1.GTokenV6_3_2__factory; } });
|
|
@@ -1,22 +1,21 @@
|
|
|
1
|
-
import { GFarmTradingStorageV5, GTokenOpenPnlFeed, GNSNftRewardsV6_3_1, GNSBorrowingFees, GNSTradingCallbacks,
|
|
1
|
+
import { GFarmTradingStorageV5, GTokenOpenPnlFeed, GNSNftRewardsV6_3_1, GNSBorrowingFees, GNSTradingCallbacks, GToken, GNSMultiCollatDiamond } from "./generated";
|
|
2
2
|
export type Contracts = {
|
|
3
3
|
gfarmTradingStorageV5: GFarmTradingStorageV5;
|
|
4
4
|
gTokenOpenPnlFeed: GTokenOpenPnlFeed;
|
|
5
5
|
gnsNftRewards: GNSNftRewardsV6_3_1;
|
|
6
6
|
gnsBorrowingFees: GNSBorrowingFees;
|
|
7
7
|
gnsTradingCallbacks: GNSTradingCallbacks;
|
|
8
|
-
|
|
8
|
+
gToken: GToken;
|
|
9
9
|
gnsMultiCollatDiamond: GNSMultiCollatDiamond;
|
|
10
10
|
};
|
|
11
11
|
export type ContractAddresses = {
|
|
12
12
|
gfarmTradingStorageV5: string;
|
|
13
13
|
gnsMultiCollatDiamond: string;
|
|
14
14
|
gTokenOpenPnlFeed: string;
|
|
15
|
-
gnsNftRewardsV6: string;
|
|
16
15
|
gnsNftRewardsV6_3_1: string;
|
|
17
16
|
gnsBorrowingFees: string;
|
|
18
17
|
gnsTradingCallbacks: string;
|
|
19
|
-
|
|
18
|
+
gToken: string;
|
|
20
19
|
};
|
|
21
20
|
export type BlockTag = number | "latest" | "pending";
|
|
22
21
|
export declare enum CollateralTypes {
|
|
@@ -25,3 +24,4 @@ export declare enum CollateralTypes {
|
|
|
25
24
|
ARB = "ARB",
|
|
26
25
|
USDC = "USDC"
|
|
27
26
|
}
|
|
27
|
+
export type ContractAddressList = Record<string, Partial<Record<CollateralTypes | "global", Partial<ContractAddresses>>>>;
|
|
@@ -16,7 +16,8 @@ exports.fetchOpenPairTradesRaw = exports.fetchOpenPairTrades = void 0;
|
|
|
16
16
|
const ethcall_1 = require("ethcall");
|
|
17
17
|
const fetchOpenPairTrades = (contracts, overrides = {}) => __awaiter(void 0, void 0, void 0, function* () {
|
|
18
18
|
const rawTrades = yield (0, exports.fetchOpenPairTradesRaw)(contracts, overrides);
|
|
19
|
-
|
|
19
|
+
const { precision: collateralPrecision } = yield contracts.gnsBorrowingFees.collateralConfig();
|
|
20
|
+
return rawTrades.map(rawTrade => _prepareTradeContainer(rawTrade.trade, rawTrade.tradeInfo, rawTrade.initialAccFees, rawTrade.tradeData, collateralPrecision));
|
|
20
21
|
});
|
|
21
22
|
exports.fetchOpenPairTrades = fetchOpenPairTrades;
|
|
22
23
|
const fetchOpenPairTradesRaw = (contracts, overrides = {}) => __awaiter(void 0, void 0, void 0, function* () {
|
|
@@ -152,7 +153,7 @@ const fetchOpenPairTradesBatchMulticall = (contracts, startPairIndex, endPairInd
|
|
|
152
153
|
}
|
|
153
154
|
return finalTrades.filter(trade => trade !== undefined);
|
|
154
155
|
});
|
|
155
|
-
const _prepareTradeContainer = (trade, tradeInfo, tradeInitialAccFees, tradeData) => ({
|
|
156
|
+
const _prepareTradeContainer = (trade, tradeInfo, tradeInitialAccFees, tradeData, collateralPrecision) => ({
|
|
156
157
|
trade: {
|
|
157
158
|
trader: trade.trader,
|
|
158
159
|
pairIndex: parseInt(trade.pairIndex.toString()),
|
|
@@ -167,7 +168,8 @@ const _prepareTradeContainer = (trade, tradeInfo, tradeInitialAccFees, tradeData
|
|
|
167
168
|
tradeInfo: {
|
|
168
169
|
beingMarketClosed: tradeInfo.beingMarketClosed.toString() === "true",
|
|
169
170
|
tokenPriceDai: parseFloat(tradeInfo.tokenPriceDai.toString()) / 1e10,
|
|
170
|
-
openInterestDai: parseFloat(tradeInfo.openInterestDai.toString()) /
|
|
171
|
+
openInterestDai: parseFloat(tradeInfo.openInterestDai.toString()) /
|
|
172
|
+
parseFloat(collateralPrecision.toString()),
|
|
171
173
|
tpLastUpdated: tradeInfo.tpLastUpdated,
|
|
172
174
|
slLastUpdated: tradeInfo.slLastUpdated,
|
|
173
175
|
},
|