@gainsnetwork/sdk 0.2.0-rc1 → 0.2.0-rc4
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/types/generated/GFarmTradingStorageV5.d.ts +1911 -0
- package/lib/contracts/types/generated/GFarmTradingStorageV5.js +2 -0
- package/lib/contracts/types/generated/GNSBorrowingFees.d.ts +1067 -0
- package/lib/contracts/types/generated/GNSBorrowingFees.js +2 -0
- package/lib/contracts/types/generated/GNSNftRewardsV6.d.ts +533 -0
- package/lib/contracts/types/generated/GNSNftRewardsV6.js +2 -0
- package/lib/contracts/types/generated/GNSNftRewardsV6_3_1.d.ts +613 -0
- package/lib/contracts/types/generated/GNSNftRewardsV6_3_1.js +2 -0
- package/lib/contracts/types/generated/GNSTrading.d.ts +758 -0
- package/lib/contracts/types/generated/GNSTrading.js +2 -0
- package/lib/contracts/types/generated/GNSTradingCallbacks.d.ts +875 -0
- package/lib/contracts/types/generated/GNSTradingCallbacks.js +2 -0
- package/lib/contracts/types/generated/GNSTradingStorage.d.ts +1387 -0
- package/lib/contracts/types/generated/GNSTradingStorage.js +2 -0
- package/lib/contracts/types/generated/factories/GFarmTradingStorageV5__factory.d.ts +83 -0
- package/lib/contracts/types/generated/factories/GFarmTradingStorageV5__factory.js +2691 -0
- package/lib/contracts/types/generated/factories/GNSBorrowingFees__factory.d.ts +124 -0
- package/lib/contracts/types/generated/factories/GNSBorrowingFees__factory.js +1784 -0
- package/lib/contracts/types/generated/factories/GNSNftRewardsV6_3_1__factory.d.ts +100 -0
- package/lib/contracts/types/generated/factories/GNSNftRewardsV6_3_1__factory.js +1116 -0
- package/lib/contracts/types/generated/factories/GNSNftRewardsV6__factory.d.ts +100 -0
- package/lib/contracts/types/generated/factories/GNSNftRewardsV6__factory.js +1003 -0
- package/lib/contracts/types/generated/factories/GNSTradingCallbacks__factory.d.ts +113 -0
- package/lib/contracts/types/generated/factories/GNSTradingCallbacks__factory.js +1428 -0
- package/lib/contracts/types/generated/factories/GNSTradingStorage__factory.d.ts +96 -0
- package/lib/contracts/types/generated/factories/GNSTradingStorage__factory.js +2241 -0
- package/lib/contracts/types/generated/factories/GNSTrading__factory.d.ts +95 -0
- package/lib/contracts/types/generated/factories/GNSTrading__factory.js +1071 -0
- package/lib/contracts/utils/openTrades.d.ts +1 -0
- package/lib/contracts/utils/openTrades.js +30 -295
- package/lib/trade/types.d.ts +23 -1
- package/lib/trade/types.js +16 -1
- package/package.json +1 -1
|
@@ -3,6 +3,7 @@ import { Contracts, BlockTag } from "../../contracts/types";
|
|
|
3
3
|
export type FetchOpenPairTradesOverrides = {
|
|
4
4
|
batchSize?: number;
|
|
5
5
|
useMulticall?: boolean;
|
|
6
|
+
includeLimits?: boolean;
|
|
6
7
|
blockTag?: BlockTag;
|
|
7
8
|
};
|
|
8
9
|
export declare const fetchOpenPairTrades: (contracts: Contracts, overrides?: FetchOpenPairTradesOverrides) => Promise<TradeContainer[]>;
|
|
@@ -10,6 +10,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.fetchOpenPairTradesRaw = exports.fetchOpenPairTrades = void 0;
|
|
13
|
+
const ethcall_1 = require("ethcall");
|
|
13
14
|
const fetchOpenPairTrades = (contracts, overrides = {}) => __awaiter(void 0, void 0, void 0, function* () {
|
|
14
15
|
const rawTrades = yield (0, exports.fetchOpenPairTradesRaw)(contracts, overrides);
|
|
15
16
|
const collateralPrecisions = (yield contracts.gnsMultiCollatDiamond.getCollaterals()).map(({ precision }) => precision);
|
|
@@ -21,23 +22,29 @@ const fetchOpenPairTradesRaw = (contracts, overrides = {}) => __awaiter(void 0,
|
|
|
21
22
|
if (!contracts) {
|
|
22
23
|
return [];
|
|
23
24
|
}
|
|
24
|
-
const { batchSize = 50,
|
|
25
|
-
// useMulticall = false,
|
|
26
|
-
// blockTag = "latest",
|
|
27
|
-
} = overrides;
|
|
25
|
+
const { batchSize = 50, includeLimits = true, useMulticall = false, } = overrides;
|
|
28
26
|
const { gnsMultiCollatDiamond: multiCollatDiamondContract } = contracts;
|
|
29
27
|
try {
|
|
28
|
+
const multicallCtx = {
|
|
29
|
+
provider: new ethcall_1.Provider(),
|
|
30
|
+
diamond: new ethcall_1.Contract(multiCollatDiamondContract.address, [
|
|
31
|
+
...multiCollatDiamondContract.interface.fragments,
|
|
32
|
+
]),
|
|
33
|
+
};
|
|
34
|
+
if (useMulticall) {
|
|
35
|
+
yield multicallCtx.provider.init(multiCollatDiamondContract.provider);
|
|
36
|
+
}
|
|
30
37
|
let allOpenPairTrades = [];
|
|
31
38
|
let running = true;
|
|
32
39
|
let offset = 0;
|
|
33
40
|
while (running) {
|
|
34
|
-
console.log("fetching with", offset, batchSize);
|
|
35
41
|
const trades = yield multiCollatDiamondContract.getAllTrades(offset, offset + batchSize);
|
|
36
42
|
const tradeInfos = yield multiCollatDiamondContract.getAllTradeInfos(offset, offset + batchSize);
|
|
37
43
|
// Array is always of length `batchSize`
|
|
38
44
|
// so we need to filter out the empty trades, indexes are reliable
|
|
39
45
|
const openTrades = trades
|
|
40
|
-
.filter(t => t.collateralIndex > 0
|
|
46
|
+
.filter(t => t.collateralIndex > 0 &&
|
|
47
|
+
(includeLimits || (!includeLimits && t.tradeType === 0)))
|
|
41
48
|
.map((trade, ix) => ({
|
|
42
49
|
trade,
|
|
43
50
|
tradeInfo: tradeInfos[ix],
|
|
@@ -46,8 +53,23 @@ const fetchOpenPairTradesRaw = (contracts, overrides = {}) => __awaiter(void 0,
|
|
|
46
53
|
accGroupFee: 0,
|
|
47
54
|
block: 0,
|
|
48
55
|
__placeholder: 0,
|
|
49
|
-
},
|
|
56
|
+
},
|
|
50
57
|
}));
|
|
58
|
+
const initialAccFeesPromises = openTrades
|
|
59
|
+
.map(({ trade }) => ({
|
|
60
|
+
collateralIndex: trade.collateralIndex,
|
|
61
|
+
user: trade.user,
|
|
62
|
+
index: trade.index,
|
|
63
|
+
}))
|
|
64
|
+
.map(({ collateralIndex, user, index }) => (useMulticall
|
|
65
|
+
? multicallCtx.diamond
|
|
66
|
+
: multiCollatDiamondContract).getBorrowingInitialAccFees(collateralIndex, user, index));
|
|
67
|
+
const initialAccFees = yield (useMulticall
|
|
68
|
+
? multicallCtx.provider.all(initialAccFeesPromises)
|
|
69
|
+
: Promise.all(initialAccFeesPromises));
|
|
70
|
+
initialAccFees.forEach((accFees, ix) => {
|
|
71
|
+
openTrades[ix].initialAccFees = accFees;
|
|
72
|
+
});
|
|
51
73
|
allOpenPairTrades = allOpenPairTrades.concat(openTrades);
|
|
52
74
|
offset += batchSize + 1;
|
|
53
75
|
running =
|
|
@@ -61,293 +83,6 @@ const fetchOpenPairTradesRaw = (contracts, overrides = {}) => __awaiter(void 0,
|
|
|
61
83
|
}
|
|
62
84
|
});
|
|
63
85
|
exports.fetchOpenPairTradesRaw = fetchOpenPairTradesRaw;
|
|
64
|
-
// @todo deprecate
|
|
65
|
-
/*
|
|
66
|
-
const fetchOpenPairTradesBatch = async (
|
|
67
|
-
contracts: Contracts,
|
|
68
|
-
startPairIndex: number,
|
|
69
|
-
endPairIndex: number
|
|
70
|
-
): Promise<TradeContainerRaw[]> => {
|
|
71
|
-
const {
|
|
72
|
-
gfarmTradingStorageV5: storageContract,
|
|
73
|
-
gnsBorrowingFees: borrowingFeesContract,
|
|
74
|
-
gnsTradingCallbacks: callbacksContract,
|
|
75
|
-
} = contracts;
|
|
76
|
-
|
|
77
|
-
const maxTradesPerPair = (
|
|
78
|
-
await storageContract.maxTradesPerPair()
|
|
79
|
-
).toNumber();
|
|
80
|
-
|
|
81
|
-
const pairIndexesToFetch = Array.from(
|
|
82
|
-
{ length: endPairIndex - startPairIndex + 1 },
|
|
83
|
-
(_, i) => i + startPairIndex
|
|
84
|
-
);
|
|
85
|
-
|
|
86
|
-
const rawTrades = await Promise.all(
|
|
87
|
-
pairIndexesToFetch.map(async pairIndex => {
|
|
88
|
-
const pairTraderAddresses = await storageContract.pairTradersArray(
|
|
89
|
-
pairIndex
|
|
90
|
-
);
|
|
91
|
-
|
|
92
|
-
if (pairTraderAddresses.length === 0) {
|
|
93
|
-
return [];
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
const openTradesForPairTraders = await Promise.all(
|
|
97
|
-
pairTraderAddresses.map(async pairTraderAddress => {
|
|
98
|
-
const openTradesCalls = new Array(maxTradesPerPair);
|
|
99
|
-
for (
|
|
100
|
-
let pairTradeIndex = 0;
|
|
101
|
-
pairTradeIndex < maxTradesPerPair;
|
|
102
|
-
pairTradeIndex++
|
|
103
|
-
) {
|
|
104
|
-
openTradesCalls[pairTradeIndex] = storageContract.openTrades(
|
|
105
|
-
pairTraderAddress,
|
|
106
|
-
pairIndex,
|
|
107
|
-
pairTradeIndex
|
|
108
|
-
);
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
const openTradesForTraderAddress = await Promise.all(openTradesCalls);
|
|
112
|
-
|
|
113
|
-
// Filter out any of the trades that aren't *really* open (NOTE: these will have an empty trader address, so just test against that)
|
|
114
|
-
const actualOpenTradesForTrader = openTradesForTraderAddress.filter(
|
|
115
|
-
openTrade => openTrade.trader === pairTraderAddress
|
|
116
|
-
);
|
|
117
|
-
|
|
118
|
-
const [
|
|
119
|
-
actualOpenTradesTradeInfos,
|
|
120
|
-
actualOpenTradesInitialAccFees,
|
|
121
|
-
actualOpenTradesTradeData,
|
|
122
|
-
] = await Promise.all([
|
|
123
|
-
Promise.all(
|
|
124
|
-
actualOpenTradesForTrader.map(aot =>
|
|
125
|
-
storageContract.openTradesInfo(
|
|
126
|
-
aot.trader,
|
|
127
|
-
aot.pairIndex,
|
|
128
|
-
aot.index
|
|
129
|
-
)
|
|
130
|
-
)
|
|
131
|
-
),
|
|
132
|
-
Promise.all(
|
|
133
|
-
actualOpenTradesForTrader.map(aot =>
|
|
134
|
-
borrowingFeesContract.initialAccFees(
|
|
135
|
-
aot.trader,
|
|
136
|
-
aot.pairIndex,
|
|
137
|
-
aot.index
|
|
138
|
-
)
|
|
139
|
-
)
|
|
140
|
-
),
|
|
141
|
-
Promise.all(
|
|
142
|
-
actualOpenTradesForTrader.map(aot =>
|
|
143
|
-
callbacksContract.tradeData(
|
|
144
|
-
aot.trader,
|
|
145
|
-
aot.pairIndex,
|
|
146
|
-
aot.index,
|
|
147
|
-
0
|
|
148
|
-
)
|
|
149
|
-
)
|
|
150
|
-
),
|
|
151
|
-
]);
|
|
152
|
-
|
|
153
|
-
const finalOpenTradesForTrader = new Array(
|
|
154
|
-
actualOpenTradesForTrader.length
|
|
155
|
-
);
|
|
156
|
-
|
|
157
|
-
for (
|
|
158
|
-
let tradeIndex = 0;
|
|
159
|
-
tradeIndex < actualOpenTradesForTrader.length;
|
|
160
|
-
tradeIndex++
|
|
161
|
-
) {
|
|
162
|
-
const tradeInfo = actualOpenTradesTradeInfos[tradeIndex];
|
|
163
|
-
|
|
164
|
-
if (tradeInfo === undefined) {
|
|
165
|
-
continue;
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
if (actualOpenTradesInitialAccFees[tradeIndex] === undefined) {
|
|
169
|
-
continue;
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
const trade = actualOpenTradesForTrader[tradeIndex];
|
|
173
|
-
const tradeData = actualOpenTradesTradeData[tradeIndex];
|
|
174
|
-
|
|
175
|
-
finalOpenTradesForTrader[tradeIndex] = {
|
|
176
|
-
trade,
|
|
177
|
-
tradeInfo,
|
|
178
|
-
initialAccFees: {
|
|
179
|
-
borrowing: actualOpenTradesInitialAccFees[tradeIndex],
|
|
180
|
-
},
|
|
181
|
-
tradeData,
|
|
182
|
-
};
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
return finalOpenTradesForTrader;
|
|
186
|
-
})
|
|
187
|
-
);
|
|
188
|
-
|
|
189
|
-
return openTradesForPairTraders;
|
|
190
|
-
})
|
|
191
|
-
);
|
|
192
|
-
|
|
193
|
-
const perPairTrades = rawTrades.reduce((a, b) => a.concat(b), []);
|
|
194
|
-
return perPairTrades.reduce((a, b) => a.concat(b), []);
|
|
195
|
-
};
|
|
196
|
-
*/
|
|
197
|
-
// @todo deprecate
|
|
198
|
-
/*
|
|
199
|
-
const fetchOpenPairTradesBatchMulticall = async (
|
|
200
|
-
contracts: Contracts,
|
|
201
|
-
startPairIndex: number,
|
|
202
|
-
endPairIndex: number,
|
|
203
|
-
blockTag: BlockTag
|
|
204
|
-
): Promise<TradeContainerRaw[]> => {
|
|
205
|
-
const {
|
|
206
|
-
gfarmTradingStorageV5: storageContract,
|
|
207
|
-
gnsBorrowingFees: borrowingFeesContract,
|
|
208
|
-
gnsTradingCallbacks: callbacksContract,
|
|
209
|
-
} = contracts;
|
|
210
|
-
|
|
211
|
-
// Convert to Multicall for efficient RPC usage
|
|
212
|
-
const multicallProvider = new Provider();
|
|
213
|
-
await multicallProvider.init(storageContract.provider);
|
|
214
|
-
const storageContractMulticall = new Contract(storageContract.address, [
|
|
215
|
-
...storageContract.interface.fragments,
|
|
216
|
-
]);
|
|
217
|
-
const borrowingFeesContractMulticall = new Contract(
|
|
218
|
-
borrowingFeesContract.address,
|
|
219
|
-
[...borrowingFeesContract.interface.fragments]
|
|
220
|
-
);
|
|
221
|
-
const callbacksContractMulticall = new Contract(callbacksContract.address, [
|
|
222
|
-
...callbacksContract.interface.fragments,
|
|
223
|
-
]);
|
|
224
|
-
|
|
225
|
-
const maxTradesPerPair = (
|
|
226
|
-
await storageContract.maxTradesPerPair()
|
|
227
|
-
).toNumber();
|
|
228
|
-
|
|
229
|
-
const pairIndexesToFetch = Array.from(
|
|
230
|
-
{ length: endPairIndex - startPairIndex + 1 },
|
|
231
|
-
(_, i) => i + startPairIndex
|
|
232
|
-
);
|
|
233
|
-
|
|
234
|
-
const mcPairTraderAddresses: string[][] = await multicallProvider.all(
|
|
235
|
-
pairIndexesToFetch.map(pairIndex =>
|
|
236
|
-
storageContractMulticall.pairTradersArray(pairIndex)
|
|
237
|
-
),
|
|
238
|
-
blockTag
|
|
239
|
-
);
|
|
240
|
-
|
|
241
|
-
const mcFlatOpenTrades: any[] = await multicallProvider.all(
|
|
242
|
-
mcPairTraderAddresses
|
|
243
|
-
.map((pairTraderAddresses, _ix) => {
|
|
244
|
-
return pairTraderAddresses
|
|
245
|
-
.map((pairTraderAddress: string) => {
|
|
246
|
-
const openTradesCalls: Call[] = new Array(maxTradesPerPair);
|
|
247
|
-
for (
|
|
248
|
-
let pairTradeIndex = 0;
|
|
249
|
-
pairTradeIndex < maxTradesPerPair;
|
|
250
|
-
pairTradeIndex++
|
|
251
|
-
) {
|
|
252
|
-
openTradesCalls[pairTradeIndex] =
|
|
253
|
-
storageContractMulticall.openTrades(
|
|
254
|
-
pairTraderAddress,
|
|
255
|
-
_ix + startPairIndex,
|
|
256
|
-
pairTradeIndex
|
|
257
|
-
);
|
|
258
|
-
}
|
|
259
|
-
return openTradesCalls;
|
|
260
|
-
})
|
|
261
|
-
.reduce((acc, val) => acc.concat(val), []);
|
|
262
|
-
})
|
|
263
|
-
.reduce((acc, val) => acc.concat(val), [] as Call[]),
|
|
264
|
-
blockTag
|
|
265
|
-
);
|
|
266
|
-
|
|
267
|
-
const openTrades = mcFlatOpenTrades.filter(
|
|
268
|
-
openTrade => openTrade[0] !== "0x0000000000000000000000000000000000000000"
|
|
269
|
-
);
|
|
270
|
-
|
|
271
|
-
const [openTradesTradeInfos, openTradesInitialAccFees, openTradesTradeData] =
|
|
272
|
-
await Promise.all([
|
|
273
|
-
multicallProvider.all(
|
|
274
|
-
openTrades.map(openTrade =>
|
|
275
|
-
storageContractMulticall.openTradesInfo(
|
|
276
|
-
openTrade.trader,
|
|
277
|
-
openTrade.pairIndex,
|
|
278
|
-
openTrade.index
|
|
279
|
-
)
|
|
280
|
-
),
|
|
281
|
-
blockTag
|
|
282
|
-
),
|
|
283
|
-
multicallProvider.all<
|
|
284
|
-
Awaited<ReturnType<typeof borrowingFeesContract.initialAccFees>>
|
|
285
|
-
>(
|
|
286
|
-
openTrades.map(openTrade =>
|
|
287
|
-
borrowingFeesContractMulticall.initialAccFees(
|
|
288
|
-
openTrade.trader,
|
|
289
|
-
openTrade.pairIndex,
|
|
290
|
-
openTrade.index
|
|
291
|
-
)
|
|
292
|
-
),
|
|
293
|
-
blockTag
|
|
294
|
-
),
|
|
295
|
-
multicallProvider.all(
|
|
296
|
-
openTrades.map(openTrade =>
|
|
297
|
-
callbacksContractMulticall.tradeData(
|
|
298
|
-
openTrade.trader,
|
|
299
|
-
openTrade.pairIndex,
|
|
300
|
-
openTrade.index,
|
|
301
|
-
0
|
|
302
|
-
)
|
|
303
|
-
),
|
|
304
|
-
blockTag
|
|
305
|
-
),
|
|
306
|
-
]);
|
|
307
|
-
|
|
308
|
-
const finalTrades = new Array(openTrades.length);
|
|
309
|
-
|
|
310
|
-
for (
|
|
311
|
-
let tradeIndex = 0;
|
|
312
|
-
tradeIndex < openTradesTradeInfos.length;
|
|
313
|
-
tradeIndex++
|
|
314
|
-
) {
|
|
315
|
-
const tradeInfo = openTradesTradeInfos[tradeIndex];
|
|
316
|
-
|
|
317
|
-
if (tradeInfo === undefined) {
|
|
318
|
-
console.error(
|
|
319
|
-
"No trade info found for open trade while fetching open trades!",
|
|
320
|
-
{ trade: openTradesTradeInfos[tradeIndex] }
|
|
321
|
-
);
|
|
322
|
-
|
|
323
|
-
continue;
|
|
324
|
-
}
|
|
325
|
-
|
|
326
|
-
if (openTradesInitialAccFees[tradeIndex] === undefined) {
|
|
327
|
-
console.error(
|
|
328
|
-
"No initial fees found for open trade while fetching open trades!",
|
|
329
|
-
{ trade: openTrades[tradeIndex] }
|
|
330
|
-
);
|
|
331
|
-
|
|
332
|
-
continue;
|
|
333
|
-
}
|
|
334
|
-
|
|
335
|
-
const trade = openTrades[tradeIndex];
|
|
336
|
-
const tradeData = openTradesTradeData[tradeIndex];
|
|
337
|
-
|
|
338
|
-
finalTrades[tradeIndex] = {
|
|
339
|
-
trade,
|
|
340
|
-
tradeInfo,
|
|
341
|
-
initialAccFees: {
|
|
342
|
-
borrowing: openTradesInitialAccFees[tradeIndex],
|
|
343
|
-
},
|
|
344
|
-
tradeData,
|
|
345
|
-
};
|
|
346
|
-
}
|
|
347
|
-
|
|
348
|
-
return finalTrades.filter(trade => trade !== undefined);
|
|
349
|
-
};
|
|
350
|
-
*/
|
|
351
86
|
const _prepareTradeContainer = (trade, tradeInfo, tradeInitialAccFees, collateralPrecision) => ({
|
|
352
87
|
trade: {
|
|
353
88
|
user: trade.user,
|
|
@@ -368,7 +103,7 @@ const _prepareTradeContainer = (trade, tradeInfo, tradeInitialAccFees, collatera
|
|
|
368
103
|
createdBlock: parseInt(tradeInfo.createdBlock.toString()),
|
|
369
104
|
tpLastUpdatedBlock: parseInt(tradeInfo.tpLastUpdatedBlock.toString()),
|
|
370
105
|
slLastUpdatedBlock: parseInt(tradeInfo.slLastUpdatedBlock.toString()),
|
|
371
|
-
maxSlippageP: parseFloat(tradeInfo.maxSlippageP.toString()) /
|
|
106
|
+
maxSlippageP: parseFloat(tradeInfo.maxSlippageP.toString()) / 1e3,
|
|
372
107
|
lastOiUpdateTs: parseFloat(tradeInfo.lastOiUpdateTs),
|
|
373
108
|
collateralPriceUsd: parseFloat(tradeInfo.collateralPriceUsd.toString()) / 1e8,
|
|
374
109
|
},
|
package/lib/trade/types.d.ts
CHANGED
|
@@ -64,7 +64,7 @@ export type Pair = {
|
|
|
64
64
|
export type TradeHistoryRecord = {
|
|
65
65
|
action: string;
|
|
66
66
|
address: string;
|
|
67
|
-
|
|
67
|
+
long: number;
|
|
68
68
|
collateralPriceUsd: number;
|
|
69
69
|
collateralIndex: number;
|
|
70
70
|
date: string;
|
|
@@ -153,6 +153,19 @@ export type TraderFeeTiers = {
|
|
|
153
153
|
lastDayUpdatedPoints: number;
|
|
154
154
|
expiredPoints: number[];
|
|
155
155
|
};
|
|
156
|
+
export declare enum PendingOrderType {
|
|
157
|
+
MARKET_OPEN = 0,
|
|
158
|
+
MARKET_CLOSE = 1,
|
|
159
|
+
LIMIT_OPEN = 2,
|
|
160
|
+
STOP_OPEN = 3,
|
|
161
|
+
TP_CLOSE = 4,
|
|
162
|
+
SL_CLOSE = 5,
|
|
163
|
+
LIQ_CLOSE = 6
|
|
164
|
+
}
|
|
165
|
+
export declare enum CounterType {
|
|
166
|
+
TRADE = 0,
|
|
167
|
+
PENDING_ORDER = 1
|
|
168
|
+
}
|
|
156
169
|
export declare enum TradeType {
|
|
157
170
|
TRADE = 0,
|
|
158
171
|
LIMIT = 1,
|
|
@@ -163,6 +176,15 @@ export type OpenInterest = {
|
|
|
163
176
|
short: number;
|
|
164
177
|
max: number;
|
|
165
178
|
};
|
|
179
|
+
export type PendingOrder = {
|
|
180
|
+
trade: Trade;
|
|
181
|
+
user: string;
|
|
182
|
+
index: string;
|
|
183
|
+
isOpen: boolean;
|
|
184
|
+
orderType: PendingOrderType;
|
|
185
|
+
createdBlock: string;
|
|
186
|
+
maxSlippageP: string;
|
|
187
|
+
};
|
|
166
188
|
export type TradeInitialAccFees = BorrowingFee.InitialAccFees;
|
|
167
189
|
export declare enum PairIndex {
|
|
168
190
|
BTCUSD = 0,
|
package/lib/trade/types.js
CHANGED
|
@@ -1,11 +1,26 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.PairIndex = exports.TradeType = exports.PositionType = void 0;
|
|
3
|
+
exports.PairIndex = exports.TradeType = exports.CounterType = exports.PendingOrderType = exports.PositionType = void 0;
|
|
4
4
|
var PositionType;
|
|
5
5
|
(function (PositionType) {
|
|
6
6
|
PositionType["LONG"] = "LONG";
|
|
7
7
|
PositionType["SHORT"] = "SHORT";
|
|
8
8
|
})(PositionType = exports.PositionType || (exports.PositionType = {}));
|
|
9
|
+
var PendingOrderType;
|
|
10
|
+
(function (PendingOrderType) {
|
|
11
|
+
PendingOrderType[PendingOrderType["MARKET_OPEN"] = 0] = "MARKET_OPEN";
|
|
12
|
+
PendingOrderType[PendingOrderType["MARKET_CLOSE"] = 1] = "MARKET_CLOSE";
|
|
13
|
+
PendingOrderType[PendingOrderType["LIMIT_OPEN"] = 2] = "LIMIT_OPEN";
|
|
14
|
+
PendingOrderType[PendingOrderType["STOP_OPEN"] = 3] = "STOP_OPEN";
|
|
15
|
+
PendingOrderType[PendingOrderType["TP_CLOSE"] = 4] = "TP_CLOSE";
|
|
16
|
+
PendingOrderType[PendingOrderType["SL_CLOSE"] = 5] = "SL_CLOSE";
|
|
17
|
+
PendingOrderType[PendingOrderType["LIQ_CLOSE"] = 6] = "LIQ_CLOSE";
|
|
18
|
+
})(PendingOrderType = exports.PendingOrderType || (exports.PendingOrderType = {}));
|
|
19
|
+
var CounterType;
|
|
20
|
+
(function (CounterType) {
|
|
21
|
+
CounterType[CounterType["TRADE"] = 0] = "TRADE";
|
|
22
|
+
CounterType[CounterType["PENDING_ORDER"] = 1] = "PENDING_ORDER";
|
|
23
|
+
})(CounterType = exports.CounterType || (exports.CounterType = {}));
|
|
9
24
|
var TradeType;
|
|
10
25
|
(function (TradeType) {
|
|
11
26
|
TradeType[TradeType["TRADE"] = 0] = "TRADE";
|