@gainsnetwork/sdk 0.2.67-rc8 → 0.2.69
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/contracts/addresses.json +20 -0
- package/lib/{trade/fees/borrowingV2/fetcher.d.ts → contracts/fetch/fees/borrowingFeesV2.d.ts} +3 -2
- package/lib/{trade/fees/borrowingV2/fetcher.js → contracts/fetch/fees/borrowingFeesV2.js} +14 -6
- package/lib/{trade/fees/fundingFees/fetcher.d.ts → contracts/fetch/fees/fundingFees.d.ts} +2 -2
- package/lib/{trade/priceImpact/skew/fetcher.d.ts → contracts/fetch/priceImpact/skew.d.ts} +2 -2
- package/lib/{trade/priceImpact/skew/fetcher.js → contracts/fetch/priceImpact/skew.js} +6 -6
- package/lib/contracts/index.js +3 -1
- package/lib/contracts/types/generated/GNSMultiCollatDiamond.d.ts +258 -2112
- package/lib/contracts/types/generated/GToken.d.ts +107 -78
- package/lib/contracts/types/generated/factories/GNSMultiCollatDiamond__factory.d.ts +53 -90
- package/lib/contracts/types/generated/factories/GNSMultiCollatDiamond__factory.js +421 -4496
- package/lib/contracts/types/generated/factories/GToken__factory.js +142 -65
- package/lib/contracts/types/index.d.ts +2 -1
- package/lib/contracts/types/index.js +1 -0
- package/lib/trade/fees/borrowingV2/converter.d.ts +3 -12
- package/lib/trade/fees/borrowingV2/converter.js +18 -29
- package/lib/trade/fees/borrowingV2/index.d.ts +17 -6
- package/lib/trade/fees/borrowingV2/index.js +37 -10
- package/lib/trade/fees/borrowingV2/types.d.ts +6 -22
- package/lib/trade/fees/fundingFees/index.d.ts +2 -13
- package/lib/trade/fees/fundingFees/index.js +3 -27
- package/lib/trade/fees/trading/index.d.ts +2 -30
- package/lib/trade/fees/trading/index.js +1 -52
- package/lib/trade/fees/trading/types.d.ts +0 -9
- package/lib/trade/priceImpact/index.d.ts +2 -6
- package/lib/trade/priceImpact/index.js +3 -30
- package/lib/trade/priceImpact/skew/index.d.ts +0 -1
- package/lib/trade/priceImpact/skew/index.js +0 -4
- package/package.json +1 -1
- package/lib/backend/globalTrades/index.d.ts +0 -11
- package/lib/backend/globalTrades/index.js +0 -69
- package/lib/backend/index.d.ts +0 -3
- package/lib/backend/index.js +0 -28
- package/lib/backend/tradingVariables/backend.types.d.ts +0 -312
- package/lib/backend/tradingVariables/backend.types.js +0 -2
- package/lib/backend/tradingVariables/converter.d.ts +0 -31
- package/lib/backend/tradingVariables/converter.js +0 -330
- package/lib/backend/tradingVariables/index.d.ts +0 -5
- package/lib/backend/tradingVariables/index.js +0 -95
- package/lib/backend/tradingVariables/types.d.ts +0 -109
- package/lib/backend/tradingVariables/types.js +0 -14
- 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/GTokenV6_3_2.d.ts +0 -1838
- package/lib/contracts/types/generated/GTokenV6_3_2.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/contracts/types/generated/factories/GTokenV6_3_2__factory.d.ts +0 -110
- package/lib/contracts/types/generated/factories/GTokenV6_3_2__factory.js +0 -2682
- package/lib/contracts/utils/openLimitOrders.d.ts +0 -8
- package/lib/contracts/utils/openLimitOrders.js +0 -88
- package/lib/markets/collateral/converter.d.ts +0 -5
- package/lib/markets/collateral/converter.js +0 -11
- package/lib/markets/collateral/index.d.ts +0 -1
- package/lib/markets/collateral/index.js +0 -17
- package/lib/markets/collateral/types.d.ts +0 -7
- package/lib/markets/collateral/types.js +0 -2
- package/lib/markets/oi/converter.d.ts +0 -63
- package/lib/markets/oi/converter.js +0 -103
- package/lib/markets/oi/fetcher.d.ts +0 -58
- package/lib/markets/oi/fetcher.js +0 -181
- package/lib/markets/oi/index.d.ts +0 -10
- package/lib/markets/oi/index.js +0 -37
- package/lib/markets/oi/types.d.ts +0 -82
- package/lib/markets/oi/types.js +0 -6
- package/lib/markets/oi/validation.d.ts +0 -80
- package/lib/markets/oi/validation.js +0 -172
- package/lib/trade/fees/borrowing/builder.d.ts +0 -14
- package/lib/trade/fees/borrowing/builder.js +0 -33
- package/lib/trade/fees/borrowingV2/builder.d.ts +0 -6
- package/lib/trade/fees/borrowingV2/builder.js +0 -24
- package/lib/trade/fees/converter.d.ts +0 -48
- package/lib/trade/fees/converter.js +0 -110
- package/lib/trade/fees/fundingFees/builder.d.ts +0 -9
- package/lib/trade/fees/fundingFees/builder.js +0 -35
- package/lib/trade/fees/fundingFees/pairContext.d.ts +0 -33
- package/lib/trade/fees/fundingFees/pairContext.js +0 -17
- package/lib/trade/fees/tiers/converter.d.ts +0 -54
- package/lib/trade/fees/tiers/converter.js +0 -81
- package/lib/trade/fees/trading/builder.d.ts +0 -18
- package/lib/trade/fees/trading/builder.js +0 -20
- package/lib/trade/liquidation/builder.d.ts +0 -25
- package/lib/trade/liquidation/builder.js +0 -59
- package/lib/trade/liquidation/converter.d.ts +0 -23
- package/lib/trade/liquidation/converter.js +0 -46
- package/lib/trade/liquidation/index.d.ts +0 -26
- package/lib/trade/liquidation/index.js +0 -142
- package/lib/trade/liquidation/types.d.ts +0 -59
- package/lib/trade/liquidation/types.js +0 -2
- package/lib/trade/openLimitOrder.d.ts +0 -2
- package/lib/trade/openLimitOrder.js +0 -23
- package/lib/trade/pnl/builder.d.ts +0 -16
- package/lib/trade/pnl/builder.js +0 -44
- package/lib/trade/pnl/converter.d.ts +0 -47
- package/lib/trade/pnl/converter.js +0 -72
- package/lib/trade/pnl/index.d.ts +0 -77
- package/lib/trade/pnl/index.js +0 -270
- package/lib/trade/pnl/types.d.ts +0 -114
- package/lib/trade/pnl/types.js +0 -5
- package/lib/trade/priceImpact/close/index.d.ts +0 -21
- package/lib/trade/priceImpact/close/index.js +0 -131
- package/lib/trade/priceImpact/close/types.d.ts +0 -43
- package/lib/trade/priceImpact/close/types.js +0 -5
- package/lib/trade/priceImpact/cumulVol/converter.d.ts +0 -31
- package/lib/trade/priceImpact/cumulVol/converter.js +0 -59
- package/lib/trade/priceImpact/cumulVol/index.d.ts +0 -107
- package/lib/trade/priceImpact/cumulVol/index.js +0 -228
- package/lib/trade/priceImpact/open/index.d.ts +0 -22
- package/lib/trade/priceImpact/open/index.js +0 -76
- package/lib/trade/priceImpact/open/types.d.ts +0 -41
- package/lib/trade/priceImpact/open/types.js +0 -5
- /package/lib/{trade/fees/fundingFees/fetcher.js → contracts/fetch/fees/fundingFees.js} +0 -0
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { ContestLeaderboardBackendEntry, ContestLeaderboardEntry } from "@gainsnetwork/contests";
|
|
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";
|
|
4
|
-
import { TradingVariablesCollateral } from "./types";
|
|
5
|
-
export declare const convertFees: (fees: FeeBackend[]) => Fee[];
|
|
6
|
-
export declare const convertCollaterals: (collaterals: CollateralBackend[]) => TradingVariablesCollateral[];
|
|
7
|
-
export declare const convertOpenInterests: (interests: OpenInterestBackend[]) => OpenInterest[];
|
|
8
|
-
export declare const convertPairDepths: (pairDepths: PairDepthBackend[]) => PairDepth[];
|
|
9
|
-
export declare const convertPairBorrowingFees: (pairParams: PairParamsBorrowingFeesBackend) => BorrowingFee.Pair[];
|
|
10
|
-
export declare const convertGroupBorrowingFees: (pairParams: PairParamsBorrowingFeesBackend) => BorrowingFee.Group[];
|
|
11
|
-
export declare const convertTradingGroups: (groups: TradingGroupBackend[]) => TradingGroup[];
|
|
12
|
-
export declare const convertTradingPairs: (pairs: PairBackend[]) => Pair[];
|
|
13
|
-
export declare const convertTradesAndLimitOrders: (allItems: TradeContainerBackend[], collaterals: TradingVariablesCollateral[]) => TradeContainer[];
|
|
14
|
-
export declare const convertTradeContainer: (tradeContainer: TradeContainerBackend, collaterals: TradingVariablesCollateral[]) => TradeContainer;
|
|
15
|
-
export declare const convertPairFactor: (pairFactor: PairFactorBackend) => PairFactor;
|
|
16
|
-
export declare const convertTrade: (trade: TradeBackend, collaterals: TradingVariablesCollateral[]) => Trade;
|
|
17
|
-
export declare const convertTradeInfo: (tradeInfo: TradeInfoBackend) => TradeInfo;
|
|
18
|
-
export declare const convertTradeInitialAccFees: (initialAccFees: TradeInitialAccFeesBackend) => TradeInitialAccFees;
|
|
19
|
-
export declare const generateStockPairToActiveStockSplit: (pairs?: PairBackend[]) => Map<string, string>;
|
|
20
|
-
export declare const convertContestLeaderboardEntry: (entry: ContestLeaderboardBackendEntry) => ContestLeaderboardEntry;
|
|
21
|
-
export declare const convertPairOi: (collateral: PairOiBackend) => PairOi;
|
|
22
|
-
export declare const convertOiWindows: (oiWindows: OiWindowsBackend[]) => OiWindows[];
|
|
23
|
-
export declare const convertOiWindowsSettings: (oiWindowsSettings: OiWindowsSettingsBackend) => OiWindowsSettings;
|
|
24
|
-
export declare const convertCollateralConfig: (collateral: CollateralBackend) => CollateralConfig;
|
|
25
|
-
export declare const convertFeeTiers: (feeTiersBackend: FeeTiersBackend) => FeeTiers;
|
|
26
|
-
export declare const convertTraderFeeTiers: (traderFeeTiers: TraderFeeTiersBackend) => TraderFeeTiers;
|
|
27
|
-
export declare const convertGlobalTradeFeeParams: (fee: GlobalTradeFeeParamsBackend) => GlobalTradeFeeParams;
|
|
28
|
-
export declare const convertMaxLeverages: (maxLeverages: string[]) => number[];
|
|
29
|
-
export declare const convertFeePerBlockCap: (feeCap: BorrowingFeePerBlockCapBackend | undefined) => BorrowingFee.BorrowingFeePerBlockCap;
|
|
30
|
-
export declare const convertPairName: (pair?: PairBackend) => string;
|
|
31
|
-
export { convertLiquidationParams };
|
|
@@ -1,330 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
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.convertPairDepths = exports.convertOpenInterests = exports.convertCollaterals = exports.convertFees = void 0;
|
|
4
|
-
const __1 = require("../../");
|
|
5
|
-
Object.defineProperty(exports, "convertLiquidationParams", { enumerable: true, get: function () { return __1.convertLiquidationParams; } });
|
|
6
|
-
const convertFees = (fees) => fees === null || fees === void 0 ? void 0 : fees.map(fee => convertFee(fee));
|
|
7
|
-
exports.convertFees = convertFees;
|
|
8
|
-
const convertCollateral = (collateral) => {
|
|
9
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
10
|
-
return ({
|
|
11
|
-
pairBorrowingFees: ((_a = collateral.borrowingFees) === null || _a === void 0 ? void 0 : _a.v1) !== undefined
|
|
12
|
-
? (0, exports.convertPairBorrowingFees)(collateral.borrowingFees.v1)
|
|
13
|
-
: [],
|
|
14
|
-
groupBorrowingFees: ((_b = collateral.borrowingFees) === null || _b === void 0 ? void 0 : _b.v1) !== undefined
|
|
15
|
-
? (0, exports.convertGroupBorrowingFees)(collateral.borrowingFees.v1)
|
|
16
|
-
: [],
|
|
17
|
-
collateral: collateral.collateral,
|
|
18
|
-
collateralConfig: (0, exports.convertCollateralConfig)(collateral),
|
|
19
|
-
collateralIndex: collateral.collateralIndex,
|
|
20
|
-
gToken: collateral.gToken,
|
|
21
|
-
isActive: true,
|
|
22
|
-
prices: collateral.prices,
|
|
23
|
-
symbol: collateral.symbol,
|
|
24
|
-
pairBorrowingFeesV2: {
|
|
25
|
-
params: (0, __1.convertBorrowingFeeParamsArrayV2)((_d = (_c = collateral.borrowingFees) === null || _c === void 0 ? void 0 : _c.v2) === null || _d === void 0 ? void 0 : _d.pairParams),
|
|
26
|
-
data: (0, __1.convertPairBorrowingFeeDataArrayV2)((_f = (_e = collateral.borrowingFees) === null || _e === void 0 ? void 0 : _e.v2) === null || _f === void 0 ? void 0 : _f.pairData),
|
|
27
|
-
},
|
|
28
|
-
pairFundingFees: {
|
|
29
|
-
globalParams: (0, __1.convertPairGlobalParamsArray)((_g = collateral.fundingFees) === null || _g === void 0 ? void 0 : _g.pairGlobalParams),
|
|
30
|
-
params: (0, __1.convertFundingFeeParamsArray)((_h = collateral.fundingFees) === null || _h === void 0 ? void 0 : _h.pairParams),
|
|
31
|
-
data: (0, __1.convertPairFundingFeeDataArray)((_j = collateral.fundingFees) === null || _j === void 0 ? void 0 : _j.pairData),
|
|
32
|
-
},
|
|
33
|
-
pairOis: (0, __1.convertPairOiArray)(collateral.pairOis, collateral.collateralConfig.decimals),
|
|
34
|
-
});
|
|
35
|
-
};
|
|
36
|
-
const convertCollaterals = (collaterals) => collaterals === null || collaterals === void 0 ? void 0 : collaterals.map(collateral => convertCollateral(collateral));
|
|
37
|
-
exports.convertCollaterals = convertCollaterals;
|
|
38
|
-
const convertFee = (fee) => ({
|
|
39
|
-
totalPositionSizeFeeP: parseFloat(fee.totalPositionSizeFeeP) / 1e12,
|
|
40
|
-
totalLiqCollateralFeeP: parseFloat(fee.totalLiqCollateralFeeP) / 1e12,
|
|
41
|
-
oraclePositionSizeFeeP: parseFloat(fee.oraclePositionSizeFeeP) / 1e12,
|
|
42
|
-
minPositionSizeUsd: parseFloat(fee.minPositionSizeUsd) / 1e3,
|
|
43
|
-
});
|
|
44
|
-
const convertOpenInterests = (interests) => interests === null || interests === void 0 ? void 0 : interests.map(interest => convertOpenInterest(interest));
|
|
45
|
-
exports.convertOpenInterests = convertOpenInterests;
|
|
46
|
-
const convertOpenInterest = (interest) => ({
|
|
47
|
-
long: parseFloat(interest.beforeV10.long) / 1e10,
|
|
48
|
-
short: parseFloat(interest.beforeV10.short) / 1e10,
|
|
49
|
-
max: parseFloat(interest.beforeV10.max) / 1e10,
|
|
50
|
-
});
|
|
51
|
-
const convertPairDepths = (pairDepths) => pairDepths === null || pairDepths === void 0 ? void 0 : pairDepths.map(pairDepth => convertPairDepth(pairDepth));
|
|
52
|
-
exports.convertPairDepths = convertPairDepths;
|
|
53
|
-
const convertPairDepth = (pairDepth) => ({
|
|
54
|
-
onePercentDepthAboveUsd: parseInt(pairDepth.onePercentDepthAboveUsd),
|
|
55
|
-
onePercentDepthBelowUsd: parseInt(pairDepth.onePercentDepthBelowUsd),
|
|
56
|
-
});
|
|
57
|
-
const convertPairBorrowingFees = (pairParams) => pairParams === null || pairParams === void 0 ? void 0 : pairParams.pairs.map(pairParam => convertPairBorrowingFee(pairParam));
|
|
58
|
-
exports.convertPairBorrowingFees = convertPairBorrowingFees;
|
|
59
|
-
const convertPairGroupBorrowingFee = (pairParam) => ({
|
|
60
|
-
groupIndex: parseInt(pairParam.groupIndex),
|
|
61
|
-
initialAccFeeLong: parseFloat(pairParam.initialAccFeeLong) / 1e10,
|
|
62
|
-
initialAccFeeShort: parseFloat(pairParam.initialAccFeeShort) / 1e10,
|
|
63
|
-
pairAccFeeLong: parseFloat(pairParam.pairAccFeeLong) / 1e10,
|
|
64
|
-
pairAccFeeShort: parseFloat(pairParam.pairAccFeeShort) / 1e10,
|
|
65
|
-
prevGroupAccFeeLong: parseFloat(pairParam.prevGroupAccFeeLong) / 1e10,
|
|
66
|
-
prevGroupAccFeeShort: parseFloat(pairParam.prevGroupAccFeeShort) / 1e10,
|
|
67
|
-
block: parseInt(pairParam.block),
|
|
68
|
-
});
|
|
69
|
-
const convertPairBorrowingFee = (pairParams) => ({
|
|
70
|
-
groups: pairParams.groups.map(pairParam => convertPairGroupBorrowingFee(pairParam)),
|
|
71
|
-
feePerBlock: parseFloat(pairParams.feePerBlock) / 1e10,
|
|
72
|
-
accFeeLong: parseFloat(pairParams.accFeeLong) / 1e10,
|
|
73
|
-
accFeeShort: parseFloat(pairParams.accFeeShort) / 1e10,
|
|
74
|
-
accLastUpdatedBlock: parseInt(pairParams.accLastUpdatedBlock),
|
|
75
|
-
oi: {
|
|
76
|
-
max: parseFloat(pairParams.oi.beforeV10.max) / 1e10 || 0,
|
|
77
|
-
long: parseFloat(pairParams.oi.beforeV10.long) / 1e10 || 0,
|
|
78
|
-
short: parseFloat(pairParams.oi.beforeV10.short) / 1e10 || 0,
|
|
79
|
-
},
|
|
80
|
-
feeExponent: parseInt(pairParams.feeExponent) || 0,
|
|
81
|
-
feePerBlockCap: (0, exports.convertFeePerBlockCap)(pairParams === null || pairParams === void 0 ? void 0 : pairParams.feePerBlockCap),
|
|
82
|
-
});
|
|
83
|
-
const convertGroupBorrowingFees = (pairParams) => pairParams === null || pairParams === void 0 ? void 0 : pairParams.groups.map(pairParam => convertGroupBorrowingFee(pairParam));
|
|
84
|
-
exports.convertGroupBorrowingFees = convertGroupBorrowingFees;
|
|
85
|
-
const convertGroupBorrowingFee = (pairParams) => ({
|
|
86
|
-
oi: {
|
|
87
|
-
long: parseFloat(pairParams.oi.long) / 1e10,
|
|
88
|
-
short: parseFloat(pairParams.oi.short) / 1e10,
|
|
89
|
-
max: parseFloat(pairParams.oi.max) / 1e10 || 0,
|
|
90
|
-
},
|
|
91
|
-
feePerBlock: parseFloat(pairParams.feePerBlock) / 1e10,
|
|
92
|
-
accFeeLong: parseFloat(pairParams.accFeeLong) / 1e10,
|
|
93
|
-
accFeeShort: parseFloat(pairParams.accFeeShort) / 1e10,
|
|
94
|
-
accLastUpdatedBlock: parseInt(pairParams.accLastUpdatedBlock),
|
|
95
|
-
feeExponent: parseInt(pairParams.feeExponent) || 0,
|
|
96
|
-
});
|
|
97
|
-
const convertTradingGroups = (groups) => groups === null || groups === void 0 ? void 0 : groups.map(group => convertTradingGroup(group));
|
|
98
|
-
exports.convertTradingGroups = convertTradingGroups;
|
|
99
|
-
const convertTradingGroup = (group) => ({
|
|
100
|
-
maxLeverage: parseFloat(group.maxLeverage) / 1e3,
|
|
101
|
-
minLeverage: parseFloat(group.minLeverage) / 1e3,
|
|
102
|
-
name: group.name,
|
|
103
|
-
});
|
|
104
|
-
const convertTradingPairs = (pairs) => pairs === null || pairs === void 0 ? void 0 : pairs.filter(pair => pair.from !== "").map((pair, index) => convertTradingPair(pair, index));
|
|
105
|
-
exports.convertTradingPairs = convertTradingPairs;
|
|
106
|
-
const convertTradingPair = (pair, index) => ({
|
|
107
|
-
name: (0, exports.convertPairName)(pair),
|
|
108
|
-
description: (0, __1.getPairDescription)(index),
|
|
109
|
-
from: pair.from,
|
|
110
|
-
to: pair.to,
|
|
111
|
-
pairIndex: index,
|
|
112
|
-
feeIndex: parseInt(pair.feeIndex),
|
|
113
|
-
groupIndex: parseInt(pair.groupIndex),
|
|
114
|
-
spreadP: parseFloat(pair.spreadP) / 1e10 / 100,
|
|
115
|
-
});
|
|
116
|
-
const convertTradesAndLimitOrders = (allItems, collaterals) => allItems === null || allItems === void 0 ? void 0 : allItems.map(item => {
|
|
117
|
-
return (0, exports.convertTradeContainer)(item, collaterals);
|
|
118
|
-
});
|
|
119
|
-
exports.convertTradesAndLimitOrders = convertTradesAndLimitOrders;
|
|
120
|
-
const convertTradeContainer = (tradeContainer, collaterals) => {
|
|
121
|
-
const trade = (0, exports.convertTrade)(tradeContainer.trade, collaterals);
|
|
122
|
-
const collateralIndex = trade.collateralIndex;
|
|
123
|
-
return {
|
|
124
|
-
trade,
|
|
125
|
-
tradeInfo: (0, exports.convertTradeInfo)(tradeContainer.tradeInfo),
|
|
126
|
-
initialAccFees: tradeContainer.initialAccFees === undefined
|
|
127
|
-
? {
|
|
128
|
-
accPairFee: 0,
|
|
129
|
-
accGroupFee: 0,
|
|
130
|
-
block: 0,
|
|
131
|
-
}
|
|
132
|
-
: (0, exports.convertTradeInitialAccFees)(tradeContainer.initialAccFees),
|
|
133
|
-
liquidationParams: tradeContainer.liquidationParams === undefined
|
|
134
|
-
? {
|
|
135
|
-
maxLiqSpreadP: 0,
|
|
136
|
-
startLiqThresholdP: 0,
|
|
137
|
-
endLiqThresholdP: 0,
|
|
138
|
-
startLeverage: 0,
|
|
139
|
-
endLeverage: 0,
|
|
140
|
-
}
|
|
141
|
-
: (0, __1.convertLiquidationParams)(tradeContainer.liquidationParams),
|
|
142
|
-
tradeFeesData: tradeContainer.tradeFeesData
|
|
143
|
-
? // eslint-disable-next-line @typescript-eslint/no-unsafe-argument, @typescript-eslint/no-unsafe-call
|
|
144
|
-
(0, __1.convertTradeFeesData)(tradeContainer.tradeFeesData, collaterals[collateralIndex - 1].collateralConfig)
|
|
145
|
-
: undefined,
|
|
146
|
-
uiRealizedPnlData: tradeContainer.uiRealizedPnlData
|
|
147
|
-
? // eslint-disable-next-line @typescript-eslint/no-unsafe-argument, @typescript-eslint/no-unsafe-call
|
|
148
|
-
(0, __1.convertUiRealizedPnlData)(tradeContainer.uiRealizedPnlData, collaterals[collateralIndex - 1].collateralConfig)
|
|
149
|
-
: undefined,
|
|
150
|
-
};
|
|
151
|
-
};
|
|
152
|
-
exports.convertTradeContainer = convertTradeContainer;
|
|
153
|
-
const convertPairFactor = (pairFactor) => ({
|
|
154
|
-
cumulativeFactor: parseFloat(pairFactor.cumulativeFactor) / 1e10,
|
|
155
|
-
protectionCloseFactor: parseFloat(pairFactor.protectionCloseFactor) / 1e10,
|
|
156
|
-
protectionCloseFactorBlocks: parseInt(pairFactor.protectionCloseFactorBlocks),
|
|
157
|
-
exemptOnOpen: pairFactor.exemptOnOpen,
|
|
158
|
-
exemptAfterProtectionCloseFactor: pairFactor.exemptAfterProtectionCloseFactor,
|
|
159
|
-
});
|
|
160
|
-
exports.convertPairFactor = convertPairFactor;
|
|
161
|
-
const convertTrade = (trade, collaterals) => {
|
|
162
|
-
var _a;
|
|
163
|
-
const { long, user } = trade;
|
|
164
|
-
const collateralIndex = parseInt(trade.collateralIndex);
|
|
165
|
-
const collateral = collaterals[collateralIndex - 1];
|
|
166
|
-
const decimals = ((_a = collateral === null || collateral === void 0 ? void 0 : collateral.collateralConfig) === null || _a === void 0 ? void 0 : _a.decimals) || 18;
|
|
167
|
-
return {
|
|
168
|
-
user,
|
|
169
|
-
index: parseInt(trade.index),
|
|
170
|
-
pairIndex: parseInt(trade.pairIndex),
|
|
171
|
-
leverage: parseInt(trade.leverage) / 1e3,
|
|
172
|
-
long,
|
|
173
|
-
isOpen: trade.isOpen,
|
|
174
|
-
collateralIndex,
|
|
175
|
-
tradeType: parseInt(trade.tradeType),
|
|
176
|
-
collateralAmount: parseFloat(trade.collateralAmount) / Math.pow(10, decimals),
|
|
177
|
-
openPrice: parseFloat(trade.openPrice) / 1e10,
|
|
178
|
-
sl: parseFloat(trade.sl) / 1e10,
|
|
179
|
-
tp: parseFloat(trade.tp) / 1e10,
|
|
180
|
-
isCounterTrade: trade.isCounterTrade,
|
|
181
|
-
positionSizeToken: trade.positionSizeToken
|
|
182
|
-
? parseFloat(trade.positionSizeToken) / Math.pow(10, decimals)
|
|
183
|
-
: undefined,
|
|
184
|
-
};
|
|
185
|
-
};
|
|
186
|
-
exports.convertTrade = convertTrade;
|
|
187
|
-
const convertTradeInfo = (tradeInfo) => ({
|
|
188
|
-
createdBlock: parseInt(tradeInfo.createdBlock),
|
|
189
|
-
tpLastUpdatedBlock: parseInt(tradeInfo.tpLastUpdatedBlock),
|
|
190
|
-
slLastUpdatedBlock: parseInt(tradeInfo.slLastUpdatedBlock),
|
|
191
|
-
maxSlippageP: parseFloat(tradeInfo.maxSlippageP) / 1e3 || 1,
|
|
192
|
-
lastOiUpdateTs: tradeInfo.lastOiUpdateTs,
|
|
193
|
-
collateralPriceUsd: tradeInfo.collateralPriceUsd && tradeInfo.collateralPriceUsd !== "0"
|
|
194
|
-
? parseFloat(tradeInfo.collateralPriceUsd) / 1e8
|
|
195
|
-
: 1,
|
|
196
|
-
contractsVersion: parseInt(tradeInfo.contractsVersion),
|
|
197
|
-
lastPosIncreaseBlock: parseInt(tradeInfo.lastPosIncreaseBlock),
|
|
198
|
-
});
|
|
199
|
-
exports.convertTradeInfo = convertTradeInfo;
|
|
200
|
-
const convertTradeInitialAccFees = (initialAccFees) => ({
|
|
201
|
-
accPairFee: parseFloat(initialAccFees.accPairFee || "0") / 1e10,
|
|
202
|
-
accGroupFee: parseFloat(initialAccFees.accGroupFee || "0") / 1e10,
|
|
203
|
-
block: parseInt(initialAccFees.block || "0"),
|
|
204
|
-
});
|
|
205
|
-
exports.convertTradeInitialAccFees = convertTradeInitialAccFees;
|
|
206
|
-
const generateStockPairToActiveStockSplit = (pairs) => {
|
|
207
|
-
const result = new Map();
|
|
208
|
-
if (!pairs) {
|
|
209
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
|
|
210
|
-
return result;
|
|
211
|
-
}
|
|
212
|
-
const basePairFroms = new Set();
|
|
213
|
-
const splitPairFroms = new Set();
|
|
214
|
-
pairs.forEach(p => {
|
|
215
|
-
const from = p.from;
|
|
216
|
-
if (from.includes("_")) {
|
|
217
|
-
splitPairFroms.add(from);
|
|
218
|
-
}
|
|
219
|
-
else {
|
|
220
|
-
basePairFroms.add(from);
|
|
221
|
-
}
|
|
222
|
-
});
|
|
223
|
-
splitPairFroms.forEach(splitFrom => {
|
|
224
|
-
const [potentialSplitPairFromBase, potentialSplitPairFromSplitId] = splitFrom.split("_");
|
|
225
|
-
const currentHighestSplitPairIdForBasePair = result.get(potentialSplitPairFromBase);
|
|
226
|
-
if ((currentHighestSplitPairIdForBasePair &&
|
|
227
|
-
+potentialSplitPairFromSplitId >
|
|
228
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-call
|
|
229
|
-
+currentHighestSplitPairIdForBasePair.split("_")[1]) ||
|
|
230
|
-
(!currentHighestSplitPairIdForBasePair &&
|
|
231
|
-
basePairFroms.has(potentialSplitPairFromBase))) {
|
|
232
|
-
result.set(potentialSplitPairFromBase, splitFrom);
|
|
233
|
-
}
|
|
234
|
-
});
|
|
235
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
|
|
236
|
-
return result;
|
|
237
|
-
};
|
|
238
|
-
exports.generateStockPairToActiveStockSplit = generateStockPairToActiveStockSplit;
|
|
239
|
-
const convertContestLeaderboardEntry = (entry) => {
|
|
240
|
-
const [trader, numWins, numLosses, avgWin, avgLoss, daiProfit, pctProfit, daiVolume,] = entry;
|
|
241
|
-
return {
|
|
242
|
-
trader,
|
|
243
|
-
numWins,
|
|
244
|
-
numLosses,
|
|
245
|
-
avgWin,
|
|
246
|
-
avgLoss,
|
|
247
|
-
daiProfit,
|
|
248
|
-
pctProfit,
|
|
249
|
-
daiVolume,
|
|
250
|
-
};
|
|
251
|
-
};
|
|
252
|
-
exports.convertContestLeaderboardEntry = convertContestLeaderboardEntry;
|
|
253
|
-
// OiWindow values are normalized to USD 1e18
|
|
254
|
-
const convertPairOi = (collateral) => ({
|
|
255
|
-
oiLongUsd: parseFloat(collateral.oiLongUsd) / 1e18,
|
|
256
|
-
oiShortUsd: parseFloat(collateral.oiShortUsd) / 1e18,
|
|
257
|
-
});
|
|
258
|
-
exports.convertPairOi = convertPairOi;
|
|
259
|
-
const convertOiWindows = (oiWindows) => {
|
|
260
|
-
return oiWindows === null || oiWindows === void 0 ? void 0 : oiWindows.map(pairWindows => {
|
|
261
|
-
const converted = {};
|
|
262
|
-
for (const [key, oiWindow] of Object.entries(pairWindows)) {
|
|
263
|
-
converted[key] = (0, exports.convertPairOi)(oiWindow);
|
|
264
|
-
}
|
|
265
|
-
return converted;
|
|
266
|
-
});
|
|
267
|
-
};
|
|
268
|
-
exports.convertOiWindows = convertOiWindows;
|
|
269
|
-
const convertOiWindowsSettings = (oiWindowsSettings) => ({
|
|
270
|
-
startTs: oiWindowsSettings.startTs,
|
|
271
|
-
windowsDuration: oiWindowsSettings.windowsDuration,
|
|
272
|
-
windowsCount: oiWindowsSettings.windowsCount,
|
|
273
|
-
});
|
|
274
|
-
exports.convertOiWindowsSettings = convertOiWindowsSettings;
|
|
275
|
-
const convertCollateralConfig = (collateral) => ({
|
|
276
|
-
collateral: collateral.collateral,
|
|
277
|
-
isActive: collateral.isActive,
|
|
278
|
-
precision: parseInt(collateral.collateralConfig.precision),
|
|
279
|
-
precisionDelta: parseInt(collateral.collateralConfig.precisionDelta),
|
|
280
|
-
decimals: collateral.collateralConfig.decimals,
|
|
281
|
-
});
|
|
282
|
-
exports.convertCollateralConfig = convertCollateralConfig;
|
|
283
|
-
const convertFeeTiers = (feeTiersBackend) => {
|
|
284
|
-
var _a;
|
|
285
|
-
return ({
|
|
286
|
-
tiers: feeTiersBackend === null || feeTiersBackend === void 0 ? void 0 : feeTiersBackend.tiers.map(tier => ({
|
|
287
|
-
feeMultiplier: Number(tier.feeMultiplier) / 1e3,
|
|
288
|
-
pointsThreshold: parseFloat(tier.pointsThreshold),
|
|
289
|
-
})),
|
|
290
|
-
multipliers: ((_a = feeTiersBackend === null || feeTiersBackend === void 0 ? void 0 : feeTiersBackend.multipliers) === null || _a === void 0 ? void 0 : _a.map(mult => parseFloat(mult) / 1e3)) || [],
|
|
291
|
-
currentDay: (feeTiersBackend === null || feeTiersBackend === void 0 ? void 0 : feeTiersBackend.currentDay) || 0,
|
|
292
|
-
});
|
|
293
|
-
};
|
|
294
|
-
exports.convertFeeTiers = convertFeeTiers;
|
|
295
|
-
const convertTraderFeeTiers = (traderFeeTiers) => ({
|
|
296
|
-
traderEnrollment: {
|
|
297
|
-
status: traderFeeTiers.traderEnrollment.status,
|
|
298
|
-
},
|
|
299
|
-
traderInfo: {
|
|
300
|
-
lastDayUpdated: traderFeeTiers.traderInfo.lastDayUpdated,
|
|
301
|
-
trailingPoints: parseFloat(traderFeeTiers.traderInfo.trailingPoints) / 1e18,
|
|
302
|
-
},
|
|
303
|
-
inboundPoints: parseFloat(traderFeeTiers.inboundPoints) / 1e18,
|
|
304
|
-
outboundPoints: parseFloat(traderFeeTiers.outboundPoints) / 1e18,
|
|
305
|
-
lastDayUpdatedPoints: parseFloat(traderFeeTiers.lastDayUpdatedPoints) / 1e18,
|
|
306
|
-
expiredPoints: traderFeeTiers.expiredPoints.map(point => parseFloat(point) / 1e18),
|
|
307
|
-
unclaimedPoints: parseFloat(traderFeeTiers.unclaimedPoints) / 1e18,
|
|
308
|
-
});
|
|
309
|
-
exports.convertTraderFeeTiers = convertTraderFeeTiers;
|
|
310
|
-
const convertGlobalTradeFeeParams = (fee) => ({
|
|
311
|
-
referralFeeP: parseFloat(fee.referralFeeP) / 1e5,
|
|
312
|
-
govFeeP: parseFloat(fee.govFeeP) / 1e5,
|
|
313
|
-
triggerOrderFeeP: parseFloat(fee.triggerOrderFeeP) / 1e5,
|
|
314
|
-
gnsOtcFeeP: parseFloat(fee.gnsOtcFeeP) / 1e5,
|
|
315
|
-
gTokenFeeP: parseFloat(fee.gTokenFeeP) / 1e5,
|
|
316
|
-
});
|
|
317
|
-
exports.convertGlobalTradeFeeParams = convertGlobalTradeFeeParams;
|
|
318
|
-
const convertMaxLeverages = (maxLeverages) => maxLeverages === null || maxLeverages === void 0 ? void 0 : maxLeverages.map(maxLeverage => parseFloat(maxLeverage) / 1e3);
|
|
319
|
-
exports.convertMaxLeverages = convertMaxLeverages;
|
|
320
|
-
const convertFeePerBlockCap = (feeCap) => ({
|
|
321
|
-
minP: (feeCap === null || feeCap === void 0 ? void 0 : feeCap.minP) ? parseFloat(feeCap.minP.toString()) / 1e3 / 100 : 0,
|
|
322
|
-
maxP: (feeCap === null || feeCap === void 0 ? void 0 : feeCap.maxP) ? parseFloat(feeCap.maxP.toString()) / 1e3 / 100 : 1,
|
|
323
|
-
});
|
|
324
|
-
exports.convertFeePerBlockCap = convertFeePerBlockCap;
|
|
325
|
-
const convertPairName = (pair) => {
|
|
326
|
-
if (!pair)
|
|
327
|
-
return "";
|
|
328
|
-
return pair.from.split("_")[0] + "/" + pair.to;
|
|
329
|
-
};
|
|
330
|
-
exports.convertPairName = convertPairName;
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import { TransformedGlobalTradingVariables } from "./types";
|
|
2
|
-
import { GlobalTradingVariablesBackend } from "./backend.types";
|
|
3
|
-
export declare const transformGlobalTradingVariables: (rawData: GlobalTradingVariablesBackend) => TransformedGlobalTradingVariables;
|
|
4
|
-
export * from "./backend.types";
|
|
5
|
-
export * from "./types";
|
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.transformGlobalTradingVariables = void 0;
|
|
18
|
-
const converter_1 = require("./converter");
|
|
19
|
-
const trade_1 = require("../../trade");
|
|
20
|
-
const transformGlobalTradingVariables = (rawData) => {
|
|
21
|
-
var _a, _b, _c, _d, _e, _f, _g;
|
|
22
|
-
const globalTradingVariables = {
|
|
23
|
-
collaterals: (0, converter_1.convertCollaterals)(rawData.collaterals),
|
|
24
|
-
pairs: (0, converter_1.convertTradingPairs)(rawData.pairs),
|
|
25
|
-
stockPairToActiveStockSplit: (0, converter_1.generateStockPairToActiveStockSplit)(rawData.pairs),
|
|
26
|
-
groups: (0, converter_1.convertTradingGroups)(rawData.groups),
|
|
27
|
-
fees: (0, converter_1.convertFees)(rawData.fees),
|
|
28
|
-
orderTimeout: rawData.marketOrdersTimeoutBlocks,
|
|
29
|
-
blockConfirmations: rawData.blockConfirmations,
|
|
30
|
-
forexClosed: !rawData.isForexOpen,
|
|
31
|
-
stocksClosed: !rawData.isStocksOpen,
|
|
32
|
-
indicesClosed: !rawData.isIndicesOpen,
|
|
33
|
-
commoditiesClosed: !rawData.isCommoditiesOpen,
|
|
34
|
-
pairDepths: ((_a = rawData.pairInfos) === null || _a === void 0 ? void 0 : _a.pairDepths) !== undefined
|
|
35
|
-
? (0, converter_1.convertPairDepths)(rawData.pairInfos.pairDepths)
|
|
36
|
-
: [],
|
|
37
|
-
pairMaxLeverages: ((_b = rawData.pairInfos) === null || _b === void 0 ? void 0 : _b.maxLeverages) !== undefined
|
|
38
|
-
? (0, converter_1.convertMaxLeverages)(rawData.pairInfos.maxLeverages)
|
|
39
|
-
: [],
|
|
40
|
-
maxNegativePnlOnOpenP: (rawData.maxNegativePnlOnOpenP && rawData.maxNegativePnlOnOpenP / 1e10) ||
|
|
41
|
-
undefined,
|
|
42
|
-
oiWindowsSettings: rawData.oiWindowsSettings !== undefined
|
|
43
|
-
? (0, converter_1.convertOiWindowsSettings)(rawData.oiWindowsSettings)
|
|
44
|
-
: { startTs: 0, windowsDuration: 0, windowsCount: 0 },
|
|
45
|
-
oiWindows: rawData.oiWindows !== undefined
|
|
46
|
-
? (0, converter_1.convertOiWindows)(rawData.oiWindows)
|
|
47
|
-
: [],
|
|
48
|
-
feeTiers: (0, converter_1.convertFeeTiers)(rawData.feeTiers),
|
|
49
|
-
liquidationParams: {
|
|
50
|
-
groups: ((_c = rawData.liquidationParams) === null || _c === void 0 ? void 0 : _c.groups.map(liqParams => (0, trade_1.convertLiquidationParams)(liqParams))) || [],
|
|
51
|
-
pairs: ((_d = rawData.liquidationParams) === null || _d === void 0 ? void 0 : _d.pairs.map(liqParams => (0, trade_1.convertLiquidationParams)(liqParams))) || [],
|
|
52
|
-
},
|
|
53
|
-
pairFactors: ((_f = (_e = rawData.pairInfos) === null || _e === void 0 ? void 0 : _e.pairFactors) === null || _f === void 0 ? void 0 : _f.map(factor => (0, converter_1.convertPairFactor)(factor))) || [],
|
|
54
|
-
globalTradeFeeParams: rawData.globalTradeFeeParams
|
|
55
|
-
? (0, converter_1.convertGlobalTradeFeeParams)(rawData.globalTradeFeeParams)
|
|
56
|
-
: undefined,
|
|
57
|
-
congestionLevels: rawData.congestionLevels,
|
|
58
|
-
};
|
|
59
|
-
const currentBlock = (rawData.currentBlock > -1 && rawData.currentBlock) || undefined;
|
|
60
|
-
const l1BlockNumber = (rawData.currentL1Block > -1 && rawData.currentL1Block) || undefined;
|
|
61
|
-
const pairIndexes = {};
|
|
62
|
-
for (let i = 0; i < ((_g = rawData.pairs) === null || _g === void 0 ? void 0 : _g.length); i++) {
|
|
63
|
-
pairIndexes[rawData.pairs[i].from + "/" + rawData.pairs[i].to] = i;
|
|
64
|
-
}
|
|
65
|
-
if (globalTradingVariables.collaterals !== undefined) {
|
|
66
|
-
const { collaterals } = globalTradingVariables;
|
|
67
|
-
for (let i = 0; i < collaterals.length; i++) {
|
|
68
|
-
collaterals[i].tradingPairs = getTradingPairs(globalTradingVariables.pairs, collaterals);
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
return {
|
|
72
|
-
globalTradingVariables,
|
|
73
|
-
pairIndexes,
|
|
74
|
-
blockNumber: currentBlock,
|
|
75
|
-
l1BlockNumber,
|
|
76
|
-
};
|
|
77
|
-
};
|
|
78
|
-
exports.transformGlobalTradingVariables = transformGlobalTradingVariables;
|
|
79
|
-
// Orphaned function
|
|
80
|
-
const getTradingPairs = (pairs, collaterals) => {
|
|
81
|
-
const tradingPairs = new Map();
|
|
82
|
-
if (pairs) {
|
|
83
|
-
for (let j = 0; j < pairs.length; j++) {
|
|
84
|
-
const pair = pairs[j];
|
|
85
|
-
// pair is tradeable if any collateral is enabled (max oi > 0)
|
|
86
|
-
if (collaterals.some((collat) => collat.pairOis[j].maxCollateral > 0)) {
|
|
87
|
-
tradingPairs.set(j, pair);
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
return tradingPairs;
|
|
92
|
-
};
|
|
93
|
-
// Re-export everything from backend.types
|
|
94
|
-
__exportStar(require("./backend.types"), exports);
|
|
95
|
-
__exportStar(require("./types"), exports);
|
|
@@ -1,109 +0,0 @@
|
|
|
1
|
-
import { CollateralConfig } from "src/markets/collateral";
|
|
2
|
-
import { BorrowingFee, BorrowingFeeV2, Fee, FeeTiers, FundingFees, GlobalTradeFeeParams, LeaderboardTrader, LiquidationParams, OiWindows, OiWindowsSettings, Pair, PairDepth, PairFactor, PairIndexes, TradingGroup } from "../../trade";
|
|
3
|
-
import { UnifiedPairOi } from "src/markets";
|
|
4
|
-
export type TransformedGlobalTradingVariables = {
|
|
5
|
-
globalTradingVariables: GlobalTradingVariablesType;
|
|
6
|
-
pairIndexes: PairIndexes;
|
|
7
|
-
blockNumber: number | undefined;
|
|
8
|
-
l1BlockNumber: number | undefined;
|
|
9
|
-
};
|
|
10
|
-
/**
|
|
11
|
-
* @dev Processed collateral data from backend (wrapper of contract data)
|
|
12
|
-
*/
|
|
13
|
-
export type TradingVariablesCollateral = {
|
|
14
|
-
pairBorrowingFees: BorrowingFee.Pair[];
|
|
15
|
-
groupBorrowingFees: BorrowingFee.Group[];
|
|
16
|
-
pairBorrowingFeesV2: {
|
|
17
|
-
params: BorrowingFeeV2.BorrowingFeeParams[];
|
|
18
|
-
data: BorrowingFeeV2.PairBorrowingFeeData[];
|
|
19
|
-
};
|
|
20
|
-
pairFundingFees: {
|
|
21
|
-
globalParams: FundingFees.PairGlobalParams[];
|
|
22
|
-
params: FundingFees.FundingFeeParams[];
|
|
23
|
-
data: FundingFees.PairFundingFeeData[];
|
|
24
|
-
};
|
|
25
|
-
collateral: string;
|
|
26
|
-
collateralIndex: number;
|
|
27
|
-
collateralConfig: CollateralConfig;
|
|
28
|
-
gToken: {
|
|
29
|
-
address: string;
|
|
30
|
-
currentBalanceCollateral: string;
|
|
31
|
-
marketCap: string;
|
|
32
|
-
maxBalanceCollateral: string;
|
|
33
|
-
};
|
|
34
|
-
tradingPairs?: Map<number, Pair>;
|
|
35
|
-
isActive: boolean;
|
|
36
|
-
prices: TokenPrices;
|
|
37
|
-
symbol: string;
|
|
38
|
-
pairOis: UnifiedPairOi[];
|
|
39
|
-
};
|
|
40
|
-
export type TokenPrices = {
|
|
41
|
-
collateralPriceUsd: number;
|
|
42
|
-
gnsPriceCollateral: number;
|
|
43
|
-
gnsPriceUsd: number;
|
|
44
|
-
};
|
|
45
|
-
export type GlobalTradingVariablesType = {
|
|
46
|
-
collaterals: TradingVariablesCollateral[];
|
|
47
|
-
paused?: boolean;
|
|
48
|
-
pairs?: Pair[];
|
|
49
|
-
stockPairToActiveStockSplit?: Map<string, string>;
|
|
50
|
-
groups?: TradingGroup[];
|
|
51
|
-
fees?: Fee[];
|
|
52
|
-
orderTimeout?: number;
|
|
53
|
-
crypto?: string[];
|
|
54
|
-
forex?: string[];
|
|
55
|
-
forexClosed?: boolean;
|
|
56
|
-
stocks?: string[];
|
|
57
|
-
stocksClosed?: boolean;
|
|
58
|
-
indices?: string[];
|
|
59
|
-
indicesClosed?: boolean;
|
|
60
|
-
commodities?: string[];
|
|
61
|
-
commoditiesClosed?: boolean;
|
|
62
|
-
blockConfirmations?: number;
|
|
63
|
-
pairDepths?: PairDepth[];
|
|
64
|
-
pairMaxLeverages?: number[];
|
|
65
|
-
maxNegativePnlOnOpenP?: number;
|
|
66
|
-
oiWindowsSettings?: OiWindowsSettings;
|
|
67
|
-
oiWindows?: OiWindows[];
|
|
68
|
-
collateralConfig?: CollateralConfig;
|
|
69
|
-
feeTiers?: FeeTiers;
|
|
70
|
-
liquidationParams: {
|
|
71
|
-
groups: LiquidationParams[];
|
|
72
|
-
pairs: LiquidationParams[];
|
|
73
|
-
};
|
|
74
|
-
pairFactors: PairFactor[];
|
|
75
|
-
globalTradeFeeParams?: GlobalTradeFeeParams;
|
|
76
|
-
congestionLevels: {
|
|
77
|
-
low: number;
|
|
78
|
-
high: number;
|
|
79
|
-
};
|
|
80
|
-
};
|
|
81
|
-
export interface LeaderboardTraderWithWinsLosses extends LeaderboardTrader {
|
|
82
|
-
wins?: number;
|
|
83
|
-
losses?: number;
|
|
84
|
-
}
|
|
85
|
-
export interface ILeaderboard {
|
|
86
|
-
ready: boolean;
|
|
87
|
-
bestTraders: LeaderboardTraderWithWinsLosses[];
|
|
88
|
-
}
|
|
89
|
-
export declare enum ORDER_TYPE {
|
|
90
|
-
LIMIT = "LIMIT",
|
|
91
|
-
STOP = "STOP",
|
|
92
|
-
MARKET = "MARKET"
|
|
93
|
-
}
|
|
94
|
-
export declare enum TRADE_TYPE {
|
|
95
|
-
LONG = "LONG",
|
|
96
|
-
SHORT = "SHORT"
|
|
97
|
-
}
|
|
98
|
-
export interface ActiveNews {
|
|
99
|
-
desc: string;
|
|
100
|
-
from: number;
|
|
101
|
-
to: number;
|
|
102
|
-
}
|
|
103
|
-
export interface BorrowingFeePerBlock {
|
|
104
|
-
pairFee: number;
|
|
105
|
-
minPairFee: number;
|
|
106
|
-
groupFee: number;
|
|
107
|
-
pairLong: boolean;
|
|
108
|
-
groupLong: boolean;
|
|
109
|
-
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.TRADE_TYPE = exports.ORDER_TYPE = void 0;
|
|
4
|
-
var ORDER_TYPE;
|
|
5
|
-
(function (ORDER_TYPE) {
|
|
6
|
-
ORDER_TYPE["LIMIT"] = "LIMIT";
|
|
7
|
-
ORDER_TYPE["STOP"] = "STOP";
|
|
8
|
-
ORDER_TYPE["MARKET"] = "MARKET";
|
|
9
|
-
})(ORDER_TYPE = exports.ORDER_TYPE || (exports.ORDER_TYPE = {}));
|
|
10
|
-
var TRADE_TYPE;
|
|
11
|
-
(function (TRADE_TYPE) {
|
|
12
|
-
TRADE_TYPE["LONG"] = "LONG";
|
|
13
|
-
TRADE_TYPE["SHORT"] = "SHORT";
|
|
14
|
-
})(TRADE_TYPE = exports.TRADE_TYPE || (exports.TRADE_TYPE = {}));
|