@gainsnetwork/sdk 0.0.51-multi-collat-rc4 → 0.0.51-multi-collat-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.
- package/lib/constants.js +2 -2
- package/lib/contracts/addresses.d.ts +1 -0
- package/lib/contracts/addresses.js +14 -2
- package/lib/contracts/addresses.json +17 -29
- package/lib/contracts/index.d.ts +1 -0
- package/lib/contracts/index.js +5 -1
- package/lib/contracts/types/generated/factories/GNSBorrowingFees__factory.js +0 -5
- package/lib/contracts/utils/openTrades.js +5 -3
- package/package.json +1 -1
package/lib/constants.js
CHANGED
|
@@ -231,7 +231,7 @@ exports.stockSplits = {
|
|
|
231
231
|
exports.delistedPairIxs = new Set([
|
|
232
232
|
6, 31, 36, 42, 45, 48, 50, 54, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69,
|
|
233
233
|
70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88,
|
|
234
|
-
89, 97, 99, 101, 106, 107, 108, 52, 131, 147, 157,
|
|
235
|
-
|
|
234
|
+
89, 97, 99, 101, 106, 107, 108, 52, 131, 147, 157, 160, 179, 182, 183, 188,
|
|
235
|
+
189, 190,
|
|
236
236
|
]);
|
|
237
237
|
exports.delistedGroupsIxs = new Set([6, 7]);
|
|
@@ -1,2 +1,3 @@
|
|
|
1
1
|
import { CollateralTypes, ContractAddresses } from "./types";
|
|
2
2
|
export declare const getContractAddressesForChain: (chainId: number, collateral?: CollateralTypes) => ContractAddresses;
|
|
3
|
+
export declare const getCollateralByAddressForChain: (chainId: number, address: string) => CollateralTypes;
|
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.getContractAddressesForChain = void 0;
|
|
6
|
+
exports.getCollateralByAddressForChain = exports.getContractAddressesForChain = void 0;
|
|
7
7
|
const types_1 = require("./types");
|
|
8
8
|
const addresses_json_1 = __importDefault(require("./addresses.json"));
|
|
9
9
|
const getContractAddressesForChain = (chainId, collateral = types_1.CollateralTypes.DAI) => {
|
|
@@ -12,8 +12,20 @@ const getContractAddressesForChain = (chainId, collateral = types_1.CollateralTy
|
|
|
12
12
|
throw new Error(`Unknown chain id (${chainId}). No known contracts have been deployed on this chain.`);
|
|
13
13
|
}
|
|
14
14
|
if (!_addresses[chainId][collateral]) {
|
|
15
|
-
throw new Error(`Unknown collateral (${collateral}) for chain id (${chainId}). No known contracts have been deployed
|
|
15
|
+
throw new Error(`Unknown collateral (${collateral}) for chain id (${chainId}). No known contracts have been deployed for this collateral.`);
|
|
16
16
|
}
|
|
17
17
|
return _addresses[chainId][collateral];
|
|
18
18
|
};
|
|
19
19
|
exports.getContractAddressesForChain = getContractAddressesForChain;
|
|
20
|
+
const getCollateralByAddressForChain = (chainId, address) => {
|
|
21
|
+
const _addresses = addresses_json_1.default;
|
|
22
|
+
if (!_addresses[chainId]) {
|
|
23
|
+
throw new Error(`Unknown chain id (${chainId}). No known contracts have been deployed on this chain.`);
|
|
24
|
+
}
|
|
25
|
+
for (const collateral in types_1.CollateralTypes) {
|
|
26
|
+
if (Object.values(_addresses[chainId][collateral] || {}).some(contract => contract.toLowerCase() === address.toLowerCase()))
|
|
27
|
+
return collateral;
|
|
28
|
+
}
|
|
29
|
+
throw new Error(`Unable to find collateral for address (${address}) and chain id (${chainId}). No known contracts match requested address.`);
|
|
30
|
+
};
|
|
31
|
+
exports.getCollateralByAddressForChain = getCollateralByAddressForChain;
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"137": {
|
|
3
3
|
"DAI": {
|
|
4
4
|
"gfarmTradingStorageV5": "0xaee4d11a16B2bc65EDD6416Fb626EB404a6D65BD",
|
|
5
|
-
"gnsMultiCollatDiamond": "
|
|
5
|
+
"gnsMultiCollatDiamond": "0x209A9A01980377916851af2cA075C2b170452018",
|
|
6
6
|
"gTokenOpenPnlFeed": "0x8d687276543b92819F2f2B5C3faad4AD27F4440c",
|
|
7
7
|
"gnsNftRewardsV6": "0x3470756E5B490a974Bc25FeEeEb24c11102f5268",
|
|
8
8
|
"gnsNftRewardsV6_3_1": "0x8103C0665A544201BBF606d90845d1B2D8005F1c",
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
"42161": {
|
|
15
15
|
"DAI": {
|
|
16
16
|
"gfarmTradingStorageV5": "0xcFa6ebD475d89dB04cAd5A756fff1cb2BC5bE33c",
|
|
17
|
-
"gnsMultiCollatDiamond": "
|
|
17
|
+
"gnsMultiCollatDiamond": "0xFF162c694eAA571f685030649814282eA457f169",
|
|
18
18
|
"gTokenOpenPnlFeed": "0x990BA9Edd8a9615A23E4c452E63A80e519A4a23D",
|
|
19
19
|
"gnsNftRewardsV6": "0xc2d107e870927E3fb1127E6c1a33De5C863505b8",
|
|
20
20
|
"gnsNftRewardsV6_3_1": "0xde5750071CacA8db173FC6543D23d0BCACACFEC3",
|
|
@@ -35,36 +35,24 @@
|
|
|
35
35
|
"gDai": "0x5215C8B3e76D493c8bcb9A7352F7afe18A6bb091"
|
|
36
36
|
},
|
|
37
37
|
"ETH": {
|
|
38
|
-
"gfarmTradingStorageV5": "
|
|
38
|
+
"gfarmTradingStorageV5": "0x989DF13f4feE478cAc463CCCDB784Aa36108aB37",
|
|
39
39
|
"gnsMultiCollatDiamond": "0xDee93dD1Cb54ce80D690eC07a20CB0ce9d7F741C",
|
|
40
|
-
"gTokenOpenPnlFeed": "
|
|
40
|
+
"gTokenOpenPnlFeed": "0xC8D8d6efBC343604f8B6288a20C00a9D7f697A38",
|
|
41
41
|
"gnsNftRewardsV6": "0x820781b85F446eDc4165C1c1D1e273B33d0B57aB",
|
|
42
|
-
"gnsNftRewardsV6_3_1": "
|
|
43
|
-
"gnsBorrowingFees": "
|
|
44
|
-
"gnsTradingCallbacks": "
|
|
45
|
-
"gDai": "
|
|
46
|
-
}
|
|
47
|
-
},
|
|
48
|
-
"421613": {
|
|
49
|
-
"ETH": {
|
|
50
|
-
"gfarmTradingStorageV5": "0xcFa6ebD475d89dB04cAd5A756fff1cb2BC5bE33c",
|
|
51
|
-
"gnsMultiCollatDiamond": "0xf67Df2a4339eC1591615d94599081Dd037960d4b",
|
|
52
|
-
"gTokenOpenPnlFeed": "0x990BA9Edd8a9615A23E4c452E63A80e519A4a23D",
|
|
53
|
-
"gnsNftRewardsV6": "0xc2d107e870927E3fb1127E6c1a33De5C863505b8",
|
|
54
|
-
"gnsNftRewardsV6_3_1": "0xde5750071CacA8db173FC6543D23d0BCACACFEC3",
|
|
55
|
-
"gnsBorrowingFees": "0xA03e32a42C75FDdDc9a39973ddd082F147393154",
|
|
56
|
-
"gnsTradingCallbacks": "0x298a695906e16aea0a184a2815a76ead1a0b7522",
|
|
57
|
-
"gDai": "0xd85E038593d7A098614721EaE955EC2022B9B91B"
|
|
42
|
+
"gnsNftRewardsV6_3_1": "0xa974360d916877D97635d7595565CBBF1776D2Cc",
|
|
43
|
+
"gnsBorrowingFees": "0x61bd04984adde83Baa904eC70885038c66459e48",
|
|
44
|
+
"gnsTradingCallbacks": "0x0Bb7f01c3808Ec9B7af16E20d71eCb7a27C7ECf5",
|
|
45
|
+
"gDai": "0x71A52242f7430cF4a290854d93f6719a8C35F287"
|
|
58
46
|
},
|
|
59
|
-
"
|
|
60
|
-
"gfarmTradingStorageV5": "
|
|
61
|
-
"gnsMultiCollatDiamond": "
|
|
62
|
-
"gTokenOpenPnlFeed": "
|
|
63
|
-
"gnsNftRewardsV6": "
|
|
64
|
-
"gnsNftRewardsV6_3_1": "
|
|
65
|
-
"gnsBorrowingFees": "
|
|
66
|
-
"gnsTradingCallbacks": "
|
|
67
|
-
"gDai": "
|
|
47
|
+
"USDC": {
|
|
48
|
+
"gfarmTradingStorageV5": "0x13ed64798DfC826f6384F226913509e18662ab0B",
|
|
49
|
+
"gnsMultiCollatDiamond": "0xDee93dD1Cb54ce80D690eC07a20CB0ce9d7F741C",
|
|
50
|
+
"gTokenOpenPnlFeed": "0x540E381b5Aef048D317A715667b12ec999D397Bc",
|
|
51
|
+
"gnsNftRewardsV6": "0x820781b85F446eDc4165C1c1D1e273B33d0B57aB",
|
|
52
|
+
"gnsNftRewardsV6_3_1": "0x9b19727268CF23E1874b8681694CAE7F66E40aE3",
|
|
53
|
+
"gnsBorrowingFees": "0xcC160C98eC5dad51021266284048F59a2535b329",
|
|
54
|
+
"gnsTradingCallbacks": "0x0c8C70eF2744A9376195855C63B59A3360FEEbBe",
|
|
55
|
+
"gDai": "0xd7F8D728414a6aD18476B5a72a0C20be5704f868"
|
|
68
56
|
}
|
|
69
57
|
}
|
|
70
58
|
}
|
package/lib/contracts/index.d.ts
CHANGED
|
@@ -2,5 +2,6 @@ import type { Signer } from "ethers";
|
|
|
2
2
|
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
|
+
export declare const getContractsForChainByRequester: (chainId: number, requester: string, signerOrProvider?: Signer | Provider) => Contracts;
|
|
5
6
|
export * from "./utils";
|
|
6
7
|
export * from "./addresses";
|
package/lib/contracts/index.js
CHANGED
|
@@ -14,7 +14,7 @@ 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.getContractsForChain = void 0;
|
|
17
|
+
exports.getContractsForChainByRequester = exports.getContractsForChain = void 0;
|
|
18
18
|
const addresses_1 = require("./addresses");
|
|
19
19
|
const factories_1 = require("./types/generated/factories");
|
|
20
20
|
const getContractsForChain = (chainId, signerOrProvider, collateral) => {
|
|
@@ -30,5 +30,9 @@ const getContractsForChain = (chainId, signerOrProvider, collateral) => {
|
|
|
30
30
|
};
|
|
31
31
|
};
|
|
32
32
|
exports.getContractsForChain = getContractsForChain;
|
|
33
|
+
const getContractsForChainByRequester = (chainId, requester, signerOrProvider) => {
|
|
34
|
+
return (0, exports.getContractsForChain)(chainId, signerOrProvider, (0, addresses_1.getCollateralByAddressForChain)(chainId, requester));
|
|
35
|
+
};
|
|
36
|
+
exports.getContractsForChainByRequester = getContractsForChainByRequester;
|
|
33
37
|
__exportStar(require("./utils"), exports);
|
|
34
38
|
__exportStar(require("./addresses"), exports);
|
|
@@ -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
|
},
|