@d8x/perpetuals-sdk 2.4.4 → 2.4.5
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/dist/cjs/config/priceFeedConfig.json +155 -11
- package/dist/cjs/marketData.d.ts +2 -2
- package/dist/cjs/marketData.js +53 -34
- package/dist/cjs/marketData.js.map +1 -1
- package/dist/cjs/nodeSDKTypes.d.ts +1 -1
- package/dist/cjs/nodeSDKTypes.js.map +1 -1
- package/dist/cjs/perpetualDataHandler.d.ts +2 -0
- package/dist/cjs/perpetualDataHandler.js +23 -5
- package/dist/cjs/perpetualDataHandler.js.map +1 -1
- package/dist/cjs/priceFeeds.d.ts +5 -6
- package/dist/cjs/priceFeeds.js +6 -7
- package/dist/cjs/priceFeeds.js.map +1 -1
- package/dist/cjs/version.d.ts +1 -1
- package/dist/cjs/version.js +1 -1
- package/dist/esm/config/priceFeedConfig.json +155 -11
- package/dist/esm/marketData.d.ts +2 -2
- package/dist/esm/marketData.js +54 -35
- package/dist/esm/marketData.js.map +1 -1
- package/dist/esm/nodeSDKTypes.d.ts +1 -1
- package/dist/esm/nodeSDKTypes.js.map +1 -1
- package/dist/esm/perpetualDataHandler.d.ts +2 -0
- package/dist/esm/perpetualDataHandler.js +23 -5
- package/dist/esm/perpetualDataHandler.js.map +1 -1
- package/dist/esm/priceFeeds.d.ts +5 -6
- package/dist/esm/priceFeeds.js +6 -7
- package/dist/esm/priceFeeds.js.map +1 -1
- package/dist/esm/version.d.ts +1 -1
- package/dist/esm/version.js +1 -1
- package/doc/d8x-perpetuals-sdk.md +3 -3
- package/package.json +1 -1
- package/src/config/priceFeedConfig.json +155 -11
- package/src/marketData.ts +53 -35
- package/src/nodeSDKTypes.ts +2 -1
- package/src/perpetualDataHandler.ts +24 -5
- package/src/priceFeeds.ts +10 -9
- package/src/version.ts +1 -1
|
@@ -2,6 +2,60 @@
|
|
|
2
2
|
{
|
|
3
3
|
"network": "mainnet",
|
|
4
4
|
"ids": [
|
|
5
|
+
{
|
|
6
|
+
"symbol": "FED25BPS-USD",
|
|
7
|
+
"id": "0x199326ac3436c8a01052155eec8d85c5092c9c3c56e0f3590c5d96d89dceec2c",
|
|
8
|
+
"type": "polymarket",
|
|
9
|
+
"origin": "0xa11a9c66032cbe8c607bf1b21591f65dfee9d5eb65d73cc8ad5009c1f9826fa3"
|
|
10
|
+
},
|
|
11
|
+
{
|
|
12
|
+
"symbol": "TRMPUKR-USD",
|
|
13
|
+
"id": "0xbbad52c7a569d729424c917dd3181149d59b5f4fc3115d510b91197c4368c22a",
|
|
14
|
+
"type": "polymarket",
|
|
15
|
+
"origin": "0xa5ac4cdcfff44ddfb0d332d33575f766414465786fb7d4350782db40d5e9da11"
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
"symbol": "MANCITY-USD",
|
|
19
|
+
"id": "0x99949191c4996cfb75262a15ee1ecc16c1cd07b8f0561694db177636b58321d4",
|
|
20
|
+
"type": "polymarket",
|
|
21
|
+
"origin": "0x586e7ee86609bd6ea5b71bddff7ea7877100c03d22ece5a336baa98aadacdb1a"
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
"symbol": "BTCNOV90-USD",
|
|
25
|
+
"id": "0x3c711064722ff96741641b5b54f055874bbfb478042888fd4121a145c852060b",
|
|
26
|
+
"type": "polymarket",
|
|
27
|
+
"origin": "0x952e8d6dcd67c7d28720491a798e96a2729a57598cb04b4de6f6c2e6f75fd12b"
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
"symbol": "BTC24100-USD",
|
|
31
|
+
"id": "0x8f7dd95917a1bcf74cd5964c9a779c267d38d4c6a87e8c7a66fae7fe30ada9a6",
|
|
32
|
+
"type": "polymarket",
|
|
33
|
+
"origin": "0x9c66114d2dfe2139325cc7a408a5cd5d2e73b55d919e2141b3a0ed83fc15895d"
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
"symbol": "MCLAREN24-USD",
|
|
37
|
+
"id": "0xa54c8b0fca58649775eece82cf6bf4aea245a431bdff4dfba40f01a17e4c1248",
|
|
38
|
+
"type": "polymarket",
|
|
39
|
+
"origin": "0x6154df852fac6dd9748b97883c03220bb267ad2be71fa215c8df1431995db74d"
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
"symbol": "HARRIS24P-USD",
|
|
43
|
+
"id": "0x2f06f5a323466c1ad9a9a8afb19a21dd3fe0f39853a16ae58637086e8ff5838d",
|
|
44
|
+
"type": "polymarket",
|
|
45
|
+
"origin": "0x265366ede72d73e137b2b9095a6cdc9be6149290caa295738a95e3d881ad0865"
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
"symbol": "SUPBWL49-USD",
|
|
49
|
+
"id": "0x7eea0b94fc1916efdd031978918abba566b9aef7f12b3d5a5b0f7141fd8e0b33",
|
|
50
|
+
"type": "polymarket",
|
|
51
|
+
"origin": "0x67e68c5eee8ac767dd1177de8c653b20642fee48f0f2a56d784e4856b130749d"
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
"symbol": "INSOUT2-USD",
|
|
55
|
+
"id": "0x6ec8114a0dba99a037c7122c93a68f2ab905c3e42e2b82e1ce659aef96de58f2",
|
|
56
|
+
"type": "polymarket",
|
|
57
|
+
"origin": "0x1ab07117f9f698f28490f57754d6fe5309374230c95867a7eba572892a11d710"
|
|
58
|
+
},
|
|
5
59
|
{
|
|
6
60
|
"symbol": "USDC-USD",
|
|
7
61
|
"id": "0xeaa020c61cc479712813461ce153894a96a6c00b21ed0cfc2798d1f9a9e9c94a",
|
|
@@ -92,6 +146,18 @@
|
|
|
92
146
|
"type": "pyth",
|
|
93
147
|
"origin": "Crypto.DOGE/USD"
|
|
94
148
|
},
|
|
149
|
+
{
|
|
150
|
+
"symbol": "GOAT-USD",
|
|
151
|
+
"id": "0xf7731dc812590214d3eb4343bfb13d1b4cfa9b1d4e020644b5d5d8e07d60c66c",
|
|
152
|
+
"type": "pyth",
|
|
153
|
+
"origin": "Crypto.GOAT/USD"
|
|
154
|
+
},
|
|
155
|
+
{
|
|
156
|
+
"symbol": "PNUT-USD",
|
|
157
|
+
"id": "0x116da895807f81f6b5c5f01b109376e7f6834dc8b51365ab7cdfa66634340e54",
|
|
158
|
+
"type": "pyth",
|
|
159
|
+
"origin": "Crypto.PNUT/USD"
|
|
160
|
+
},
|
|
95
161
|
{
|
|
96
162
|
"symbol": "WIF-USD",
|
|
97
163
|
"id": "0x4ca4beeca86f0d164160323817a4e42b10010a724c2217c6ee41b54cd4cc61fc",
|
|
@@ -101,6 +167,7 @@
|
|
|
101
167
|
{
|
|
102
168
|
"symbol": "PEPE-USD",
|
|
103
169
|
"id": "0xd69731a2e74ac1ce884fc3890f7ee324b6deb66147055249568869ed700882e4",
|
|
170
|
+
"pxMultiplier": 1000,
|
|
104
171
|
"type": "pyth",
|
|
105
172
|
"origin": "Crypto.PEPE/USD"
|
|
106
173
|
},
|
|
@@ -133,6 +200,30 @@
|
|
|
133
200
|
"id": "0x9a4df90b25497f66b1afb012467e316e801ca3d839456db028892fe8c70c8016",
|
|
134
201
|
"type": "pyth",
|
|
135
202
|
"origin": "Crypto.PENDLE/USD"
|
|
203
|
+
},
|
|
204
|
+
{
|
|
205
|
+
"symbol": "TON-USD",
|
|
206
|
+
"id": "0x8963217838ab4cf5cadc172203c1f0b763fbaa45f346d8ee50ba994bbcac3026",
|
|
207
|
+
"type": "pyth",
|
|
208
|
+
"origin": "Crypto.TON/USD"
|
|
209
|
+
},
|
|
210
|
+
{
|
|
211
|
+
"symbol": "BNB-USD",
|
|
212
|
+
"id": "0x2f95862b045670cd22bee3114c39763a4a08beeb663b145d283c31d7d1101c4f",
|
|
213
|
+
"type": "pyth",
|
|
214
|
+
"origin": "Crypto.BNB/USD"
|
|
215
|
+
},
|
|
216
|
+
{
|
|
217
|
+
"symbol": "SHIB-USD",
|
|
218
|
+
"id": "0xf0d57deca57b3da2fe63a493f4c25925fdfd8edf834b20f93e1f84dbd1504d4a",
|
|
219
|
+
"type": "pyth",
|
|
220
|
+
"origin": "Crypto.SHIB/USD"
|
|
221
|
+
},
|
|
222
|
+
{
|
|
223
|
+
"symbol": "POL-USD",
|
|
224
|
+
"id": "0xffd11c5a1cfd42f80afb2df4d9f264c15f956d68153335374ec10722edd70472",
|
|
225
|
+
"type": "pyth",
|
|
226
|
+
"origin": "Crypto.POL/USD"
|
|
136
227
|
}
|
|
137
228
|
],
|
|
138
229
|
"endpoints": [
|
|
@@ -142,23 +233,52 @@
|
|
|
142
233
|
"writeEndpoints": ["https://hermes.pyth.network"]
|
|
143
234
|
},
|
|
144
235
|
{ "type": "onchain", "endpoints": [], "writeEndpoints": [] },
|
|
145
|
-
{
|
|
236
|
+
{
|
|
237
|
+
"type": "polymarket",
|
|
238
|
+
"endpoints": [],
|
|
239
|
+
"writeEndpoints": ["https://odin-poly.d8x.xyz"]
|
|
240
|
+
}
|
|
146
241
|
]
|
|
147
242
|
},
|
|
148
243
|
{
|
|
149
244
|
"network": "odin",
|
|
150
245
|
"ids": [
|
|
151
246
|
{
|
|
152
|
-
"symbol": "
|
|
153
|
-
"
|
|
154
|
-
"
|
|
155
|
-
"
|
|
247
|
+
"symbol": "HONEY-USDC",
|
|
248
|
+
"origin": "Crypto.HONEY/USDC",
|
|
249
|
+
"comment": "DAI price for temporary feed honey-usdc",
|
|
250
|
+
"id": "0xb0948a5e5313200c632b51bb5ca32f6de0d36e9950a942d19751e833f70dabfd",
|
|
251
|
+
"type": "odin"
|
|
156
252
|
},
|
|
157
253
|
{
|
|
158
|
-
"symbol": "
|
|
159
|
-
"id": "
|
|
160
|
-
"type": "
|
|
161
|
-
"origin": "
|
|
254
|
+
"symbol": "DIRAC-HONEY",
|
|
255
|
+
"id": "0xebd937fe18c8122f35e2fb280f4b70343a8403dc848f02511d6791ae1db5a25f",
|
|
256
|
+
"type": "low-liq",
|
|
257
|
+
"origin": ""
|
|
258
|
+
},
|
|
259
|
+
{
|
|
260
|
+
"symbol": "BUDS-HONEY",
|
|
261
|
+
"id": "0xb859493d77dc52043bbeaa6aa090ebd24ae913a707b330a34e4f168b5d8dd58c",
|
|
262
|
+
"type": "low-liq",
|
|
263
|
+
"origin": ""
|
|
264
|
+
},
|
|
265
|
+
{
|
|
266
|
+
"symbol": "IBGT-HONEY",
|
|
267
|
+
"id": "0x2cb8e3da2690aee73a495107a849e58989d73c1151719920b06bbdf1bb1a0150",
|
|
268
|
+
"type": "low-liq",
|
|
269
|
+
"origin": ""
|
|
270
|
+
},
|
|
271
|
+
{
|
|
272
|
+
"symbol": "BDEG-HONEY",
|
|
273
|
+
"id": "0x0becdebd3154dfe6c06b952800b379f091374a16a8ee09aba0e503092479bfca",
|
|
274
|
+
"type": "low-liq",
|
|
275
|
+
"origin": ""
|
|
276
|
+
},
|
|
277
|
+
{
|
|
278
|
+
"symbol": "BEARTIC-HONEY",
|
|
279
|
+
"id": "0x617bbf5a0cb37d312fe6b1021fa42ab1502746cfe9eae37b5ff9f3d9eb71ae36",
|
|
280
|
+
"type": "low-liq",
|
|
281
|
+
"origin": ""
|
|
162
282
|
},
|
|
163
283
|
{
|
|
164
284
|
"symbol": "USDC-USD",
|
|
@@ -228,8 +348,32 @@
|
|
|
228
348
|
}
|
|
229
349
|
],
|
|
230
350
|
"endpoints": [
|
|
231
|
-
{
|
|
232
|
-
|
|
351
|
+
{
|
|
352
|
+
"type": "odin",
|
|
353
|
+
"endpoints": ["https://hermes.pyth.network"],
|
|
354
|
+
"writeEndpoints": ["https://odin.d8x.xyz/"]
|
|
355
|
+
},
|
|
356
|
+
{
|
|
357
|
+
"type": "low-liq",
|
|
358
|
+
"comment": "legacy",
|
|
359
|
+
"endpoints": ["https://odin-lowliq.d8x.xyz/"],
|
|
360
|
+
"writeEndpoints": ["https://odin-lowliq.d8x.xyz/"]
|
|
361
|
+
},
|
|
362
|
+
{
|
|
363
|
+
"type": "v2",
|
|
364
|
+
"endpoints": ["https://odin-lowliq.d8x.xyz/"],
|
|
365
|
+
"writeEndpoints": ["https://odin-lowliq.d8x.xyz/"]
|
|
366
|
+
},
|
|
367
|
+
{
|
|
368
|
+
"type": "v3",
|
|
369
|
+
"endpoints": ["https://odin-lowliq.d8x.xyz/"],
|
|
370
|
+
"writeEndpoints": ["https://odin-lowliq.d8x.xyz/"]
|
|
371
|
+
},
|
|
372
|
+
{
|
|
373
|
+
"type": "polymarket",
|
|
374
|
+
"endpoints": [""],
|
|
375
|
+
"writeEndpoints": ["https://odin-poly.d8x.xyz"]
|
|
376
|
+
}
|
|
233
377
|
]
|
|
234
378
|
}
|
|
235
379
|
]
|
package/dist/cjs/marketData.d.ts
CHANGED
|
@@ -661,13 +661,13 @@ export default class MarketData extends PerpetualDataHandler {
|
|
|
661
661
|
*/
|
|
662
662
|
getTraderLoyalityScore(traderAddr: string, overrides?: Overrides): Promise<number>;
|
|
663
663
|
/**
|
|
664
|
-
* Get all off-chain prices
|
|
664
|
+
* Get all off-chain prices for normal perps
|
|
665
665
|
* @param _symbolToPerpStaticInfo mapping: PerpetualStaticInfo for each perpetual
|
|
666
666
|
* @param _priceFeedGetter priceFeed class from which we can get offchain price data
|
|
667
667
|
* @returns mapping of symbol-pair (e.g. BTC-USD) to price/isMarketClosed
|
|
668
668
|
* @ignore
|
|
669
669
|
*/
|
|
670
|
-
private static
|
|
670
|
+
private static _getAllActivePerpIndexPrices;
|
|
671
671
|
/**
|
|
672
672
|
* Get market open/closed status
|
|
673
673
|
* @param {string} symbol Perpetual symbol of the form ETH-USD-MATIC
|
package/dist/cjs/marketData.js
CHANGED
|
@@ -1105,7 +1105,9 @@ class MarketData extends perpetualDataHandler_1.default {
|
|
|
1105
1105
|
if (!this.proxyContract) {
|
|
1106
1106
|
throw Error("no proxy contract initialized. Use createProxyInstance().");
|
|
1107
1107
|
}
|
|
1108
|
-
|
|
1108
|
+
const baseBytes = (0, ethers_1.hexlify)(Uint8Array.from((0, utils_1.toBytes4)(base)));
|
|
1109
|
+
const quoteBytes = (0, ethers_1.hexlify)(Uint8Array.from((0, utils_1.toBytes4)(quote)));
|
|
1110
|
+
return await this.proxyContract.getOraclePrice([baseBytes, quoteBytes], overrides || {});
|
|
1109
1111
|
}
|
|
1110
1112
|
/**
|
|
1111
1113
|
* Get the status of an order given a symbol and order Id
|
|
@@ -1514,17 +1516,20 @@ class MarketData extends perpetualDataHandler_1.default {
|
|
|
1514
1516
|
return 5 - rank4;
|
|
1515
1517
|
}
|
|
1516
1518
|
/**
|
|
1517
|
-
* Get all off-chain prices
|
|
1519
|
+
* Get all off-chain prices for normal perps
|
|
1518
1520
|
* @param _symbolToPerpStaticInfo mapping: PerpetualStaticInfo for each perpetual
|
|
1519
1521
|
* @param _priceFeedGetter priceFeed class from which we can get offchain price data
|
|
1520
1522
|
* @returns mapping of symbol-pair (e.g. BTC-USD) to price/isMarketClosed
|
|
1521
1523
|
* @ignore
|
|
1522
1524
|
*/
|
|
1523
|
-
static async
|
|
1525
|
+
static async _getAllActivePerpIndexPrices(_symbolToPerpStaticInfo, _priceFeedGetter) {
|
|
1524
1526
|
// get all prices from off-chain price-sources
|
|
1525
1527
|
let allSym = new Set();
|
|
1526
1528
|
for (let perpSymbol of _symbolToPerpStaticInfo.keys()) {
|
|
1527
1529
|
let sInfo = _symbolToPerpStaticInfo.get(perpSymbol);
|
|
1530
|
+
if (sInfo?.state == "INVALID" || sInfo?.state == "INITIALIZING") {
|
|
1531
|
+
continue;
|
|
1532
|
+
}
|
|
1528
1533
|
allSym.add(sInfo.S2Symbol);
|
|
1529
1534
|
if (sInfo.S3Symbol != "") {
|
|
1530
1535
|
allSym.add(sInfo.S3Symbol);
|
|
@@ -1598,9 +1603,11 @@ class MarketData extends perpetualDataHandler_1.default {
|
|
|
1598
1603
|
// prepare calls
|
|
1599
1604
|
const proxyCalls = [];
|
|
1600
1605
|
let midPriceMap = new Map();
|
|
1606
|
+
const collectedPerpIds = [];
|
|
1601
1607
|
for (let k = 0; k < perpetualIDChunks.length; k++) {
|
|
1602
1608
|
let indexPrices = [];
|
|
1603
1609
|
// collect/order all index prices
|
|
1610
|
+
const collectedIds = [];
|
|
1604
1611
|
for (let j = 0; j < perpetualIDChunks[k].length; j++) {
|
|
1605
1612
|
let id = perpetualIDChunks[k][j];
|
|
1606
1613
|
const poolId = Math.floor(id / 100000);
|
|
@@ -1609,6 +1616,10 @@ class MarketData extends perpetualDataHandler_1.default {
|
|
|
1609
1616
|
}
|
|
1610
1617
|
let symbol3s = _perpetualIdToSymbol.get(id);
|
|
1611
1618
|
let info = _symbolToPerpStaticInfo.get(symbol3s);
|
|
1619
|
+
if (info?.state == "INVALID" || info?.state == "INITIALIZING") {
|
|
1620
|
+
continue;
|
|
1621
|
+
}
|
|
1622
|
+
collectedIds.push(id);
|
|
1612
1623
|
let S2 = (0, d8XMath_1.floatToABK64x64)(_idxPriceMap.get(info.S2Symbol)[0]);
|
|
1613
1624
|
let S3 = 0n;
|
|
1614
1625
|
if (info.S3Symbol != "") {
|
|
@@ -1617,21 +1628,24 @@ class MarketData extends perpetualDataHandler_1.default {
|
|
|
1617
1628
|
indexPrices.push(S2);
|
|
1618
1629
|
indexPrices.push(S3);
|
|
1619
1630
|
}
|
|
1631
|
+
collectedPerpIds.push(collectedIds);
|
|
1620
1632
|
proxyCalls.push({
|
|
1621
1633
|
target: _proxyContract.target,
|
|
1622
1634
|
allowFailure: false,
|
|
1623
|
-
callData: _proxyContract.interface.encodeFunctionData("queryMidPrices", [
|
|
1635
|
+
callData: _proxyContract.interface.encodeFunctionData("queryMidPrices", [collectedIds, indexPrices]),
|
|
1624
1636
|
});
|
|
1625
1637
|
}
|
|
1626
1638
|
// multicall
|
|
1627
1639
|
const encodedResults = await _multicall.aggregate3.staticCall(proxyCalls, overrides || {});
|
|
1628
1640
|
// apply results
|
|
1629
|
-
for (let k = 0; k <
|
|
1641
|
+
for (let k = 0; k < collectedPerpIds.length; k++) {
|
|
1630
1642
|
let fMidPrice = _proxyContract.interface.decodeFunctionResult("queryMidPrices", encodedResults[k].returnData)[0];
|
|
1631
1643
|
for (let j = 0; j < fMidPrice.length; j++) {
|
|
1632
|
-
let id =
|
|
1644
|
+
let id = collectedPerpIds[k][j];
|
|
1633
1645
|
let symbol3s = _perpetualIdToSymbol.get(id);
|
|
1634
|
-
|
|
1646
|
+
if (symbol3s != undefined) {
|
|
1647
|
+
midPriceMap.set(symbol3s, (0, d8XMath_1.ABK64x64ToFloat)(fMidPrice[j]));
|
|
1648
|
+
}
|
|
1635
1649
|
}
|
|
1636
1650
|
}
|
|
1637
1651
|
return midPriceMap;
|
|
@@ -1772,7 +1786,7 @@ class MarketData extends perpetualDataHandler_1.default {
|
|
|
1772
1786
|
proxyAddr: _proxyContract.target.toString(),
|
|
1773
1787
|
};
|
|
1774
1788
|
// get all prices from off-chain price-sources: no RPC calls
|
|
1775
|
-
let idxPriceMap = await MarketData.
|
|
1789
|
+
let idxPriceMap = await MarketData._getAllActivePerpIndexPrices(_symbolToPerpStaticInfo, _priceFeedGetter);
|
|
1776
1790
|
// query mid-prices from on-chain conditional on the off-chain prices
|
|
1777
1791
|
let midPriceMap = await MarketData._queryMidPrices(_proxyContract, _poolStaticInfos, _multicall, _nestedPerpetualIDs, _symbolToPerpStaticInfo, _perpetualIdToSymbol, idxPriceMap, overrides);
|
|
1778
1792
|
const { pools: poolStateInfos, perpetuals: perpStateInfos } = await MarketData._queryPoolAndPerpetualStates(_proxyContract, _multicall, _poolStaticInfos, _symbolList, _nestedPerpetualIDs, overrides);
|
|
@@ -1780,35 +1794,40 @@ class MarketData extends perpetualDataHandler_1.default {
|
|
|
1780
1794
|
for (const perp of perpStateInfos) {
|
|
1781
1795
|
let symbol3s = _perpetualIdToSymbol.get(perp.id);
|
|
1782
1796
|
let info = _symbolToPerpStaticInfo.get(symbol3s);
|
|
1783
|
-
|
|
1784
|
-
|
|
1785
|
-
perp.isMarketClosed = idxPriceS2Pair[1];
|
|
1786
|
-
if (info.S3Symbol != "") {
|
|
1787
|
-
idxPriceS3Pair = idxPriceMap.get(info.S3Symbol);
|
|
1788
|
-
perp.isMarketClosed = perp.isMarketClosed || idxPriceS3Pair[1];
|
|
1789
|
-
}
|
|
1790
|
-
perp.indexPrice = idxPriceS2Pair[0];
|
|
1791
|
-
let indexS3 = 1;
|
|
1792
|
-
if (info.collateralCurrencyType == constants_1.COLLATERAL_CURRENCY_BASE) {
|
|
1793
|
-
indexS3 = idxPriceS2Pair[0];
|
|
1794
|
-
}
|
|
1795
|
-
else if (info.collateralCurrencyType == constants_1.COLLATERAL_CURRENCY_QUANTO) {
|
|
1796
|
-
indexS3 = idxPriceS3Pair[0];
|
|
1797
|
-
}
|
|
1798
|
-
perp.collToQuoteIndexPrice = indexS3;
|
|
1799
|
-
const emaKey = info.S2Symbol + ":ema";
|
|
1800
|
-
let markPrice;
|
|
1801
|
-
if (idxPriceMap.has(emaKey)) {
|
|
1802
|
-
let ema;
|
|
1803
|
-
let res = idxPriceMap.get(emaKey);
|
|
1804
|
-
ema = res[0];
|
|
1805
|
-
markPrice = Math.min(Math.max(ema + perp.markPremium, 1), 2);
|
|
1797
|
+
if (info?.state == "INVALID" || info?.state == "INITIALIZING") {
|
|
1798
|
+
perp.isMarketClosed = true;
|
|
1806
1799
|
}
|
|
1807
1800
|
else {
|
|
1808
|
-
|
|
1801
|
+
const idxPriceS2Pair = idxPriceMap.get(info.S2Symbol);
|
|
1802
|
+
let idxPriceS3Pair = [0, false];
|
|
1803
|
+
perp.isMarketClosed = idxPriceS2Pair[1];
|
|
1804
|
+
if (info.S3Symbol != "") {
|
|
1805
|
+
idxPriceS3Pair = idxPriceMap.get(info.S3Symbol);
|
|
1806
|
+
perp.isMarketClosed = perp.isMarketClosed || idxPriceS3Pair[1];
|
|
1807
|
+
}
|
|
1808
|
+
perp.indexPrice = idxPriceS2Pair[0];
|
|
1809
|
+
let indexS3 = 1;
|
|
1810
|
+
if (info.collateralCurrencyType == constants_1.COLLATERAL_CURRENCY_BASE) {
|
|
1811
|
+
indexS3 = idxPriceS2Pair[0];
|
|
1812
|
+
}
|
|
1813
|
+
else if (info.collateralCurrencyType == constants_1.COLLATERAL_CURRENCY_QUANTO) {
|
|
1814
|
+
indexS3 = idxPriceS3Pair[0];
|
|
1815
|
+
}
|
|
1816
|
+
perp.collToQuoteIndexPrice = indexS3;
|
|
1817
|
+
const emaKey = info.S2Symbol + ":ema";
|
|
1818
|
+
let markPrice;
|
|
1819
|
+
if (idxPriceMap.has(emaKey)) {
|
|
1820
|
+
let ema;
|
|
1821
|
+
let res = idxPriceMap.get(emaKey);
|
|
1822
|
+
ema = res[0];
|
|
1823
|
+
markPrice = Math.min(Math.max(ema + perp.markPremium, 1), 2);
|
|
1824
|
+
}
|
|
1825
|
+
else {
|
|
1826
|
+
markPrice = perp.indexPrice * (1 + perp.markPremium);
|
|
1827
|
+
}
|
|
1828
|
+
perp.markPrice = markPrice;
|
|
1829
|
+
perp.midPrice = midPriceMap.get(symbol3s);
|
|
1809
1830
|
}
|
|
1810
|
-
perp.markPrice = markPrice;
|
|
1811
|
-
perp.midPrice = midPriceMap.get(symbol3s);
|
|
1812
1831
|
// which pool?
|
|
1813
1832
|
const poolId = info.poolId;
|
|
1814
1833
|
poolStateInfos[poolId - 1].perpetuals.push(perp);
|