@xapy/orderbook 0.1.26 → 0.1.27
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/exchanges/edgex/index.cjs +39 -23
- package/dist/exchanges/edgex/index.cjs.map +1 -1
- package/dist/exchanges/edgex/index.d.cts +36 -2
- package/dist/exchanges/edgex/index.d.ts +36 -2
- package/dist/exchanges/edgex/index.js +37 -24
- package/dist/exchanges/edgex/index.js.map +1 -1
- package/dist/exchanges/lighter/index.cjs +1 -0
- package/dist/exchanges/lighter/index.cjs.map +1 -1
- package/dist/exchanges/lighter/index.d.cts +2 -1
- package/dist/exchanges/lighter/index.d.ts +2 -1
- package/dist/exchanges/lighter/index.js +1 -1
- package/dist/exchanges/lighter/index.js.map +1 -1
- package/dist/index.cjs +35 -23
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +35 -23
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -3200,13 +3200,16 @@ var LighterClient = class {
|
|
|
3200
3200
|
};
|
|
3201
3201
|
|
|
3202
3202
|
// src/exchanges/edgex/markets.ts
|
|
3203
|
-
var EDGEX_REST = "https://
|
|
3203
|
+
var EDGEX_REST = "https://cors.xapy.io/edgex";
|
|
3204
3204
|
var EDGEX_WS = "wss://edgex-quote-prod-v2.edgex.exchange";
|
|
3205
|
-
|
|
3206
|
-
|
|
3207
|
-
|
|
3205
|
+
function edgexRestBase(opts) {
|
|
3206
|
+
return (opts.restBase ?? EDGEX_REST).replace(/\/+$/, "");
|
|
3207
|
+
}
|
|
3208
|
+
var caches = /* @__PURE__ */ new Map();
|
|
3209
|
+
var inflights = /* @__PURE__ */ new Map();
|
|
3210
|
+
async function fetchContracts(opts, base) {
|
|
3208
3211
|
const res = await httpJson({
|
|
3209
|
-
url: `${
|
|
3212
|
+
url: `${base}/api/v2/public/meta/getMetaData`,
|
|
3210
3213
|
timeoutMs: opts.timeoutMs,
|
|
3211
3214
|
transformUrl: opts.transformUrl
|
|
3212
3215
|
});
|
|
@@ -3221,24 +3224,29 @@ async function fetchContracts(opts) {
|
|
|
3221
3224
|
for (const row of rows) map.set(row.contractName.toUpperCase(), row);
|
|
3222
3225
|
return map;
|
|
3223
3226
|
}
|
|
3224
|
-
function loadContracts(opts) {
|
|
3225
|
-
|
|
3226
|
-
|
|
3227
|
-
|
|
3228
|
-
|
|
3229
|
-
|
|
3230
|
-
|
|
3231
|
-
|
|
3232
|
-
|
|
3233
|
-
|
|
3234
|
-
|
|
3235
|
-
|
|
3236
|
-
|
|
3227
|
+
function loadContracts(opts, base) {
|
|
3228
|
+
let pending2 = inflights.get(base);
|
|
3229
|
+
if (!pending2) {
|
|
3230
|
+
pending2 = fetchContracts(opts, base).then(
|
|
3231
|
+
(m) => {
|
|
3232
|
+
caches.set(base, m);
|
|
3233
|
+
inflights.delete(base);
|
|
3234
|
+
return m;
|
|
3235
|
+
},
|
|
3236
|
+
(err) => {
|
|
3237
|
+
inflights.delete(base);
|
|
3238
|
+
throw err;
|
|
3239
|
+
}
|
|
3240
|
+
);
|
|
3241
|
+
inflights.set(base, pending2);
|
|
3242
|
+
}
|
|
3243
|
+
return pending2;
|
|
3237
3244
|
}
|
|
3238
3245
|
async function resolveEdgexContract(contractName, opts) {
|
|
3246
|
+
const base = edgexRestBase(opts);
|
|
3239
3247
|
const k = contractName.toUpperCase();
|
|
3240
|
-
const hit =
|
|
3241
|
-
const contract = hit ?? (await loadContracts(opts)).get(k);
|
|
3248
|
+
const hit = caches.get(base)?.get(k);
|
|
3249
|
+
const contract = hit ?? (await loadContracts(opts, base)).get(k);
|
|
3242
3250
|
if (!contract) {
|
|
3243
3251
|
throw new ExchangeError(
|
|
3244
3252
|
"edgex",
|
|
@@ -3280,7 +3288,7 @@ async function fetchEdgexOrderbook(opts) {
|
|
|
3280
3288
|
const contract = await resolveEdgexContract(contractName, opts);
|
|
3281
3289
|
const level = snapLevel(opts.depth ?? 50);
|
|
3282
3290
|
const res = await httpJson({
|
|
3283
|
-
url: `${
|
|
3291
|
+
url: `${edgexRestBase(opts)}/api/v2/public/quote/getDepth?contractId=${contract.contractId}&level=${level}`,
|
|
3284
3292
|
timeoutMs: opts.timeoutMs,
|
|
3285
3293
|
transformUrl: opts.transformUrl
|
|
3286
3294
|
});
|
|
@@ -3418,9 +3426,11 @@ var EdgexClient = class {
|
|
|
3418
3426
|
exchange = "edgex";
|
|
3419
3427
|
transformUrl;
|
|
3420
3428
|
timeoutMs;
|
|
3429
|
+
restBase;
|
|
3421
3430
|
constructor(opts = {}) {
|
|
3422
3431
|
this.transformUrl = opts.transformUrl;
|
|
3423
3432
|
this.timeoutMs = opts.timeoutMs;
|
|
3433
|
+
this.restBase = opts.restBase;
|
|
3424
3434
|
}
|
|
3425
3435
|
fetchOrderbook(symbol, opts = {}) {
|
|
3426
3436
|
const { pair, market } = parseSymbol(symbol);
|
|
@@ -3429,7 +3439,8 @@ var EdgexClient = class {
|
|
|
3429
3439
|
market,
|
|
3430
3440
|
depth: opts.depth,
|
|
3431
3441
|
timeoutMs: this.timeoutMs,
|
|
3432
|
-
transformUrl: this.transformUrl
|
|
3442
|
+
transformUrl: this.transformUrl,
|
|
3443
|
+
restBase: this.restBase
|
|
3433
3444
|
});
|
|
3434
3445
|
}
|
|
3435
3446
|
streamOrderbook(symbol, opts = {}) {
|
|
@@ -3439,7 +3450,8 @@ var EdgexClient = class {
|
|
|
3439
3450
|
market,
|
|
3440
3451
|
depth: opts.depth,
|
|
3441
3452
|
transformUrl: this.transformUrl,
|
|
3442
|
-
timeoutMs: this.timeoutMs
|
|
3453
|
+
timeoutMs: this.timeoutMs,
|
|
3454
|
+
restBase: this.restBase
|
|
3443
3455
|
});
|
|
3444
3456
|
}
|
|
3445
3457
|
};
|