@gainsnetwork/sdk 1.1.0-rc1 → 1.1.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/backend/tradingVariables/backend.types.d.ts +4 -11
- package/lib/backend/tradingVariables/converter.d.ts +3 -7
- package/lib/backend/tradingVariables/converter.js +7 -14
- package/lib/backend/tradingVariables/index.js +2 -5
- package/lib/backend/tradingVariables/types.d.ts +2 -4
- package/lib/contracts/addresses.d.ts +1 -0
- package/lib/contracts/addresses.js +9 -1
- package/lib/contracts/addresses.json +29 -0
- package/lib/contracts/types/generated/GNSMultiCollatDiamond.d.ts +299 -608
- package/lib/contracts/types/generated/factories/GNSMultiCollatDiamond__factory.js +313 -1996
- package/lib/contracts/utils/pairs.d.ts +2 -13
- package/lib/contracts/utils/pairs.js +11 -70
- package/lib/index.d.ts +0 -1
- package/lib/index.js +0 -1
- package/lib/trade/fees/trading/builder.d.ts +2 -1
- package/lib/trade/fees/trading/builder.js +2 -1
- package/lib/trade/fees/trading/types.d.ts +1 -3
- package/lib/trade/liquidation/builder.js +1 -1
- package/lib/trade/liquidation/types.d.ts +2 -7
- package/lib/trade/pnl/index.js +2 -0
- package/lib/trade/priceImpact/cumulVol/builder.js +7 -8
- package/lib/trade/priceImpact/cumulVol/converter.d.ts +0 -63
- package/lib/trade/priceImpact/cumulVol/converter.js +1 -97
- package/lib/trade/priceImpact/cumulVol/index.d.ts +0 -3
- package/lib/trade/priceImpact/cumulVol/index.js +4 -107
- package/package.json +1 -1
|
@@ -96,15 +96,9 @@ export interface GroupOpenInterestBackend {
|
|
|
96
96
|
short: string;
|
|
97
97
|
max: string;
|
|
98
98
|
}
|
|
99
|
-
export interface
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
belowSlot1: string;
|
|
103
|
-
belowSlot2: string;
|
|
104
|
-
}
|
|
105
|
-
export interface DepthBandsMappingBackend {
|
|
106
|
-
slot1: string;
|
|
107
|
-
slot2: string;
|
|
99
|
+
export interface PairDepthBackend {
|
|
100
|
+
onePercentDepthAboveUsd: string;
|
|
101
|
+
onePercentDepthBelowUsd: string;
|
|
108
102
|
}
|
|
109
103
|
export interface PairBorrowingFeesBackendPairGroup {
|
|
110
104
|
groupIndex: string;
|
|
@@ -165,7 +159,6 @@ export interface GlobalTradingVariablesBackend {
|
|
|
165
159
|
groups: TradingGroupBackend[];
|
|
166
160
|
fees: FeeBackend[];
|
|
167
161
|
pairInfos: PairInfosBackend;
|
|
168
|
-
depthBandsMapping: DepthBandsMappingBackend;
|
|
169
162
|
collaterals: CollateralBackend[];
|
|
170
163
|
sssTokenBalance: string;
|
|
171
164
|
sssLegacyTokenBalance: string;
|
|
@@ -246,7 +239,7 @@ export interface CollateralBackend {
|
|
|
246
239
|
}
|
|
247
240
|
export interface PairInfosBackend {
|
|
248
241
|
maxLeverages: string[];
|
|
249
|
-
|
|
242
|
+
pairDepths: PairDepthBackend[];
|
|
250
243
|
pairFactors: PairFactorBackend[];
|
|
251
244
|
}
|
|
252
245
|
export type TraderInfoBackend = {
|
|
@@ -1,15 +1,11 @@
|
|
|
1
1
|
import { ContestLeaderboardBackendEntry, ContestLeaderboardEntry } from "@gainsnetwork/contests";
|
|
2
|
-
import { BorrowingFee, CollateralConfig, Fee, FeeTiers, GlobalTradeFeeParams, OiWindows, OiWindowsSettings, OpenInterest, Pair, PairOi, Trade, TradeContainer, TradeInfo, TradeInitialAccFees, TraderFeeTiers, TradingGroup, PairFactor, convertLiquidationParams } from "../../";
|
|
3
|
-
import {
|
|
4
|
-
import { BorrowingFeePerBlockCapBackend, CollateralBackend, FeeBackend, FeeTiersBackend, GlobalTradeFeeParamsBackend, OiWindowsBackend, OiWindowsSettingsBackend, OpenInterestBackend, PairBackend, PairDepthBandsBackend, DepthBandsMappingBackend, PairFactorBackend, PairOiBackend, PairParamsBorrowingFeesBackend, TradeBackend, TradeContainerBackend, TradeInfoBackend, TradeInitialAccFeesBackend, TraderFeeTiersBackend, TradingGroupBackend } from "./backend.types";
|
|
2
|
+
import { BorrowingFee, CollateralConfig, Fee, FeeTiers, GlobalTradeFeeParams, OiWindows, OiWindowsSettings, OpenInterest, Pair, PairDepth, PairOi, Trade, TradeContainer, TradeInfo, TradeInitialAccFees, TraderFeeTiers, TradingGroup, PairFactor, convertLiquidationParams } from "../../";
|
|
3
|
+
import { BorrowingFeePerBlockCapBackend, CollateralBackend, FeeBackend, FeeTiersBackend, GlobalTradeFeeParamsBackend, OiWindowsBackend, OiWindowsSettingsBackend, OpenInterestBackend, PairBackend, PairDepthBackend, PairFactorBackend, PairOiBackend, PairParamsBorrowingFeesBackend, TradeBackend, TradeContainerBackend, TradeInfoBackend, TradeInitialAccFeesBackend, TraderFeeTiersBackend, TradingGroupBackend } from "./backend.types";
|
|
5
4
|
import { TradingVariablesCollateral } from "./types";
|
|
6
5
|
export declare const convertFees: (fees: FeeBackend[]) => Fee[];
|
|
7
6
|
export declare const convertCollaterals: (collaterals: CollateralBackend[]) => TradingVariablesCollateral[];
|
|
8
7
|
export declare const convertOpenInterests: (interests: OpenInterestBackend[]) => OpenInterest[];
|
|
9
|
-
export declare const
|
|
10
|
-
export declare const convertDepthBandsMapping: (mapping: DepthBandsMappingBackend) => {
|
|
11
|
-
bands: number[];
|
|
12
|
-
};
|
|
8
|
+
export declare const convertPairDepths: (pairDepths: PairDepthBackend[]) => PairDepth[];
|
|
13
9
|
export declare const convertPairSkewDepths: (pairSkewDepths: string[] | undefined) => {
|
|
14
10
|
[pairIndex: number]: number;
|
|
15
11
|
};
|
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.convertLiquidationParams = exports.convertPairName = exports.convertFeePerBlockCap = exports.convertMaxLeverages = exports.convertGlobalTradeFeeParams = exports.convertTraderFeeTiers = exports.convertFeeTiers = exports.convertCollateralConfig = exports.convertOiWindowsSettings = exports.convertOiWindows = exports.convertPairOi = exports.convertContestLeaderboardEntry = exports.generateStockPairToActiveStockSplit = exports.convertTradeInitialAccFees = exports.convertTradeInfo = exports.convertTrade = exports.convertPairFactor = exports.convertTradeContainer = exports.convertTradesAndLimitOrders = exports.convertTradingPairs = exports.convertTradingGroups = exports.convertGroupBorrowingFees = exports.convertPairBorrowingFees = exports.convertPairSkewDepths = exports.
|
|
3
|
+
exports.convertLiquidationParams = exports.convertPairName = exports.convertFeePerBlockCap = exports.convertMaxLeverages = exports.convertGlobalTradeFeeParams = exports.convertTraderFeeTiers = exports.convertFeeTiers = exports.convertCollateralConfig = exports.convertOiWindowsSettings = exports.convertOiWindows = exports.convertPairOi = exports.convertContestLeaderboardEntry = exports.generateStockPairToActiveStockSplit = exports.convertTradeInitialAccFees = exports.convertTradeInfo = exports.convertTrade = exports.convertPairFactor = exports.convertTradeContainer = exports.convertTradesAndLimitOrders = exports.convertTradingPairs = exports.convertTradingGroups = exports.convertGroupBorrowingFees = exports.convertPairBorrowingFees = exports.convertPairSkewDepths = exports.convertPairDepths = exports.convertOpenInterests = exports.convertCollaterals = exports.convertFees = void 0;
|
|
4
4
|
const __1 = require("../../");
|
|
5
5
|
Object.defineProperty(exports, "convertLiquidationParams", { enumerable: true, get: function () { return __1.convertLiquidationParams; } });
|
|
6
6
|
const converter_1 = require("../../trade/priceImpact/skew/converter");
|
|
7
|
-
const converter_2 = require("../../trade/priceImpact/cumulVol/converter");
|
|
8
|
-
const depthBands_1 = require("../../pricing/depthBands");
|
|
9
7
|
const convertFees = (fees) => fees === null || fees === void 0 ? void 0 : fees.map(fee => convertFee(fee));
|
|
10
8
|
exports.convertFees = convertFees;
|
|
11
9
|
const convertCollateral = (collateral) => {
|
|
@@ -52,17 +50,12 @@ const convertOpenInterest = (interest) => ({
|
|
|
52
50
|
short: parseFloat(interest.beforeV10.short) / 1e10,
|
|
53
51
|
max: parseFloat(interest.beforeV10.max) / 1e10,
|
|
54
52
|
});
|
|
55
|
-
const
|
|
56
|
-
exports.
|
|
57
|
-
const
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
return {
|
|
62
|
-
bands: bandsBps.map(bps => bps / 10000),
|
|
63
|
-
};
|
|
64
|
-
};
|
|
65
|
-
exports.convertDepthBandsMapping = convertDepthBandsMapping;
|
|
53
|
+
const convertPairDepths = (pairDepths) => pairDepths === null || pairDepths === void 0 ? void 0 : pairDepths.map(pairDepth => convertPairDepth(pairDepth));
|
|
54
|
+
exports.convertPairDepths = convertPairDepths;
|
|
55
|
+
const convertPairDepth = (pairDepth) => ({
|
|
56
|
+
onePercentDepthAboveUsd: parseInt(pairDepth.onePercentDepthAboveUsd),
|
|
57
|
+
onePercentDepthBelowUsd: parseInt(pairDepth.onePercentDepthBelowUsd),
|
|
58
|
+
});
|
|
66
59
|
const convertPairSkewDepths = (pairSkewDepths) => {
|
|
67
60
|
if (!pairSkewDepths)
|
|
68
61
|
return {};
|
|
@@ -31,12 +31,9 @@ const transformGlobalTradingVariables = (rawData) => {
|
|
|
31
31
|
stocksClosed: !rawData.isStocksOpen,
|
|
32
32
|
indicesClosed: !rawData.isIndicesOpen,
|
|
33
33
|
commoditiesClosed: !rawData.isCommoditiesOpen,
|
|
34
|
-
|
|
35
|
-
? (0, converter_1.
|
|
34
|
+
pairDepths: ((_a = rawData.pairInfos) === null || _a === void 0 ? void 0 : _a.pairDepths) !== undefined
|
|
35
|
+
? (0, converter_1.convertPairDepths)(rawData.pairInfos.pairDepths)
|
|
36
36
|
: [],
|
|
37
|
-
depthBandsMapping: rawData.depthBandsMapping !== undefined
|
|
38
|
-
? (0, converter_1.convertDepthBandsMapping)(rawData.depthBandsMapping)
|
|
39
|
-
: { bands: [] },
|
|
40
37
|
pairMaxLeverages: ((_b = rawData.pairInfos) === null || _b === void 0 ? void 0 : _b.maxLeverages) !== undefined
|
|
41
38
|
? (0, converter_1.convertMaxLeverages)(rawData.pairInfos.maxLeverages)
|
|
42
39
|
: [],
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { CollateralConfig } from "src/markets/collateral";
|
|
2
|
-
import { BorrowingFee, BorrowingFeeV2, CounterTradeSettings, Fee, FeeTiers, FundingFees, GlobalTradeFeeParams, LeaderboardTrader, LiquidationParams, OiWindows, OiWindowsSettings, Pair, PairFactor, PairIndexes, TradingGroup } from "../../trade";
|
|
3
|
-
import { PairDepthBands, DepthBandsMapping } from "../../trade/priceImpact/cumulVol/types";
|
|
2
|
+
import { BorrowingFee, BorrowingFeeV2, CounterTradeSettings, Fee, FeeTiers, FundingFees, GlobalTradeFeeParams, LeaderboardTrader, LiquidationParams, OiWindows, OiWindowsSettings, Pair, PairDepth, PairFactor, PairIndexes, TradingGroup } from "../../trade";
|
|
4
3
|
import { UnifiedPairOi } from "src/markets";
|
|
5
4
|
export type TransformedGlobalTradingVariables = {
|
|
6
5
|
globalTradingVariables: GlobalTradingVariablesType;
|
|
@@ -64,8 +63,7 @@ export type GlobalTradingVariablesType = {
|
|
|
64
63
|
commodities?: string[];
|
|
65
64
|
commoditiesClosed?: boolean;
|
|
66
65
|
blockConfirmations?: number;
|
|
67
|
-
|
|
68
|
-
depthBandsMapping?: DepthBandsMapping;
|
|
66
|
+
pairDepths?: PairDepth[];
|
|
69
67
|
pairMaxLeverages?: number[];
|
|
70
68
|
maxNegativePnlOnOpenP?: number;
|
|
71
69
|
oiWindowsSettings?: OiWindowsSettings;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
import { CollateralTypes, ContractAddresses } from "./types";
|
|
2
2
|
export declare const getContractAddressesForChain: (chainId: number, collateral?: CollateralTypes) => ContractAddresses;
|
|
3
3
|
export declare const getCollateralByAddressForChain: (chainId: number, address: string) => CollateralTypes;
|
|
4
|
+
export declare const getContractAddressesForTestnetRelease: () => ContractAddresses;
|
|
@@ -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.getCollateralByAddressForChain = exports.getContractAddressesForChain = void 0;
|
|
6
|
+
exports.getContractAddressesForTestnetRelease = 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) => {
|
|
@@ -29,3 +29,11 @@ const getCollateralByAddressForChain = (chainId, address) => {
|
|
|
29
29
|
throw new Error(`Unable to find collateral for address (${address}) and chain id (${chainId}). No known contracts match requested address.`);
|
|
30
30
|
};
|
|
31
31
|
exports.getCollateralByAddressForChain = getCollateralByAddressForChain;
|
|
32
|
+
const getContractAddressesForTestnetRelease = () => {
|
|
33
|
+
const _addresses = addresses_json_1.default;
|
|
34
|
+
if (!_addresses["421614-release"]) {
|
|
35
|
+
throw new Error(`Unknown chain id (${"421614-release"}). No known contracts have been deployed on this chain.`);
|
|
36
|
+
}
|
|
37
|
+
return Object.assign(Object.assign({}, _addresses["421614-release"]["global"]), _addresses["421614-release"][types_1.CollateralTypes.DAI]);
|
|
38
|
+
};
|
|
39
|
+
exports.getContractAddressesForTestnetRelease = getContractAddressesForTestnetRelease;
|
|
@@ -143,5 +143,34 @@
|
|
|
143
143
|
"gTokenOpenPnlFeed": "0x0000000000000000000000000000000000000000",
|
|
144
144
|
"gToken": "0x0000000000000000000000000000000000000000"
|
|
145
145
|
}
|
|
146
|
+
},
|
|
147
|
+
"421614-release": {
|
|
148
|
+
"global": {
|
|
149
|
+
"gnsMultiCollatDiamond": "0xB4F1B18b5679B42F2956dCBff3D7823A61F347C9"
|
|
150
|
+
},
|
|
151
|
+
"DAI": {
|
|
152
|
+
"gTokenOpenPnlFeed": "0xFcF76e2620eB6C32786e32620187A0FbF2844d68",
|
|
153
|
+
"gToken": "0x47CA7Fa22086CD63DBa92Dce23a75aEA9227a9DC"
|
|
154
|
+
},
|
|
155
|
+
"ETH": {
|
|
156
|
+
"gTokenOpenPnlFeed": "0x0000000000000000000000000000000000000000",
|
|
157
|
+
"gToken": "0x0000000000000000000000000000000000000000"
|
|
158
|
+
},
|
|
159
|
+
"USDC": {
|
|
160
|
+
"gTokenOpenPnlFeed": "0x0000000000000000000000000000000000000000",
|
|
161
|
+
"gToken": "0x0000000000000000000000000000000000000000"
|
|
162
|
+
},
|
|
163
|
+
"APE": {
|
|
164
|
+
"gTokenOpenPnlFeed": "0x0000000000000000000000000000000000000000",
|
|
165
|
+
"gToken": "0x0000000000000000000000000000000000000000"
|
|
166
|
+
},
|
|
167
|
+
"GNS": {
|
|
168
|
+
"gTokenOpenPnlFeed": "0x0000000000000000000000000000000000000000",
|
|
169
|
+
"gToken": "0x0000000000000000000000000000000000000000"
|
|
170
|
+
},
|
|
171
|
+
"BTCUSD": {
|
|
172
|
+
"gTokenOpenPnlFeed": "0x0000000000000000000000000000000000000000",
|
|
173
|
+
"gToken": "0x0000000000000000000000000000000000000000"
|
|
174
|
+
}
|
|
146
175
|
}
|
|
147
176
|
}
|