coinrayjs 2.0.25 → 2.0.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/coinrayjs.es.js +156 -140
- package/dist/coinrayjs.es.js.map +1 -1
- package/dist/coinrayjs.js +2 -2
- package/dist/coinrayjs.js.map +1 -1
- package/dist/types/coinray.d.ts +2 -1
- package/dist/types/coinray.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/coinrayjs.es.js
CHANGED
|
@@ -9915,7 +9915,7 @@ function _m(e, t) {
|
|
|
9915
9915
|
}
|
|
9916
9916
|
//#endregion
|
|
9917
9917
|
//#region lib/coinray.ts
|
|
9918
|
-
var vm = (e) => om(e) ? encodeURIComponent(e) : e, ym = "2.0.
|
|
9918
|
+
var vm = (e) => om(e) ? encodeURIComponent(e) : e, ym = "2.0.26", bm = class extends Error {
|
|
9919
9919
|
errorCode;
|
|
9920
9920
|
errorMessage;
|
|
9921
9921
|
exchange;
|
|
@@ -9923,7 +9923,7 @@ var vm = (e) => om(e) ? encodeURIComponent(e) : e, ym = "2.0.25", bm = class ext
|
|
|
9923
9923
|
constructor({ code: e, message: t, exchange: n }) {
|
|
9924
9924
|
super("Request failed"), this.name = "CoinrayError", this.errorCode = e, this.errorMessage = t, this.exchange = n;
|
|
9925
9925
|
}
|
|
9926
|
-
}, xm = class e {
|
|
9926
|
+
}, xm = 3e3, Sm = class e {
|
|
9927
9927
|
static I18n = em;
|
|
9928
9928
|
config;
|
|
9929
9929
|
_token;
|
|
@@ -10172,7 +10172,11 @@ var vm = (e) => om(e) ? encodeURIComponent(e) : e, ym = "2.0.25", bm = class ext
|
|
|
10172
10172
|
};
|
|
10173
10173
|
subscribeCandles = async ({ coinraySymbol: t, resolution: n, lastCandle: r }, i) => {
|
|
10174
10174
|
let a = `${t}-${n}`;
|
|
10175
|
-
if (this._candleListeners[a] && this._candleListeners[a].length > 0) return this._candleListeners[a].push(i),
|
|
10175
|
+
if (this._candleListeners[a] && this._candleListeners[a].length > 0) return this._candleListeners[a].push(i), this.replayCandleSnapshot({
|
|
10176
|
+
coinraySymbol: t,
|
|
10177
|
+
resolution: n,
|
|
10178
|
+
candleId: a
|
|
10179
|
+
}, i), i;
|
|
10176
10180
|
this._candleListeners[a] = [i];
|
|
10177
10181
|
let o = ({ type: t, coinraySymbol: r, trades: i }) => {
|
|
10178
10182
|
let o = Object.values(this._candleListeners[a]), s = e._tradesToLastCandle(n, i), c = s[s.length - 1];
|
|
@@ -10189,13 +10193,25 @@ var vm = (e) => om(e) ? encodeURIComponent(e) : e, ym = "2.0.25", bm = class ext
|
|
|
10189
10193
|
coinraySymbol: t
|
|
10190
10194
|
}), i;
|
|
10191
10195
|
};
|
|
10196
|
+
replayCandleSnapshot = ({ coinraySymbol: t, resolution: n, candleId: r }, i) => {
|
|
10197
|
+
queueMicrotask(() => {
|
|
10198
|
+
if (!this._candleListeners[r]?.includes(i)) return;
|
|
10199
|
+
let a = [...this._tradeSnapshots[t] || []], o = e._tradesToLastCandle(n, a);
|
|
10200
|
+
o.length !== 0 && this._candles[r] && i({
|
|
10201
|
+
coinraySymbol: t,
|
|
10202
|
+
resolution: n,
|
|
10203
|
+
candle: this._candles[r],
|
|
10204
|
+
previousCandles: o
|
|
10205
|
+
});
|
|
10206
|
+
});
|
|
10207
|
+
};
|
|
10192
10208
|
startNewCandleTimer = ({ candleId: e, resolution: t, coinraySymbol: n }) => {
|
|
10193
10209
|
this._timers[e] && clearTimeout(this._timers[e]);
|
|
10194
|
-
let r = Zp(0, t, /* @__PURE__ */ new Date()) - (/* @__PURE__ */ new Date()).getTime() / 1e3
|
|
10210
|
+
let r = Zp(0, t, /* @__PURE__ */ new Date()) - (/* @__PURE__ */ new Date()).getTime() / 1e3;
|
|
10195
10211
|
this._timers[e] = setTimeout(() => {
|
|
10196
|
-
let r = Zp(1, t, /* @__PURE__ */ new Date()) * 1e3, a = this._candles[e];
|
|
10197
|
-
a &&
|
|
10198
|
-
time: new Date(
|
|
10212
|
+
let r = Object.values(this._candleListeners[e] || []), i = Zp(1, t, /* @__PURE__ */ new Date()) * 1e3, a = this._candles[e];
|
|
10213
|
+
a && i > a.time.getTime() && (this._candles[e] = {
|
|
10214
|
+
time: new Date(i),
|
|
10199
10215
|
open: a.close,
|
|
10200
10216
|
high: a.close,
|
|
10201
10217
|
low: a.close,
|
|
@@ -10203,7 +10219,7 @@ var vm = (e) => om(e) ? encodeURIComponent(e) : e, ym = "2.0.25", bm = class ext
|
|
|
10203
10219
|
baseVolume: 0,
|
|
10204
10220
|
quoteVolume: 0,
|
|
10205
10221
|
numTrades: 0
|
|
10206
|
-
},
|
|
10222
|
+
}, r.map((r) => r({
|
|
10207
10223
|
coinraySymbol: n,
|
|
10208
10224
|
resolution: t,
|
|
10209
10225
|
candle: this._candles[e],
|
|
@@ -10230,7 +10246,7 @@ var vm = (e) => om(e) ? encodeURIComponent(e) : e, ym = "2.0.25", bm = class ext
|
|
|
10230
10246
|
return n;
|
|
10231
10247
|
};
|
|
10232
10248
|
fetchCandles = async ({ coinraySymbol: e, resolution: t, start: n, end: r, useWebSocket: i }) => {
|
|
10233
|
-
if (this.flushCache(), t.endsWith("S")) return (await this.getWebsocketCandles(e, t)).filter((e) => {
|
|
10249
|
+
if (this.flushCache(), t.endsWith("S")) return (await this.getWebsocketCandles(e, t, xm)).filter((e) => {
|
|
10234
10250
|
let t = e.time.getTime() / 1e3;
|
|
10235
10251
|
return t >= n && t <= r;
|
|
10236
10252
|
});
|
|
@@ -10271,22 +10287,22 @@ var vm = (e) => om(e) ? encodeURIComponent(e) : e, ym = "2.0.25", bm = class ext
|
|
|
10271
10287
|
let e = (/* @__PURE__ */ new Date()).getTime() / 1e3;
|
|
10272
10288
|
(!this._candleCacheCreatedAt || e - this._candleCacheCreatedAt > 600) && (this._candleCacheCreatedAt = e, this._candleCache = /* @__PURE__ */ new Map());
|
|
10273
10289
|
};
|
|
10274
|
-
getWebsocketCandles = async (e, t) => await new Promise((
|
|
10275
|
-
let
|
|
10290
|
+
getWebsocketCandles = async (e, t, n = 0) => await new Promise((r) => {
|
|
10291
|
+
let i = setTimeout(() => {
|
|
10276
10292
|
this.unsubscribeCandles({
|
|
10277
10293
|
coinraySymbol: e,
|
|
10278
10294
|
resolution: t
|
|
10279
|
-
},
|
|
10280
|
-
},
|
|
10281
|
-
clearTimeout(
|
|
10295
|
+
}, a), r([]);
|
|
10296
|
+
}, n), a = ({ previousCandles: n }) => {
|
|
10297
|
+
n?.length && (clearTimeout(i), this.unsubscribeCandles({
|
|
10282
10298
|
coinraySymbol: e,
|
|
10283
10299
|
resolution: t
|
|
10284
|
-
},
|
|
10300
|
+
}, a), r(n));
|
|
10285
10301
|
};
|
|
10286
10302
|
this.subscribeCandles({
|
|
10287
10303
|
coinraySymbol: e,
|
|
10288
10304
|
resolution: t
|
|
10289
|
-
},
|
|
10305
|
+
}, a);
|
|
10290
10306
|
});
|
|
10291
10307
|
getOpenCandles = async (t, n) => {
|
|
10292
10308
|
let r = this.candleCacheKey({
|
|
@@ -10777,7 +10793,7 @@ var vm = (e) => om(e) ? encodeURIComponent(e) : e, ym = "2.0.25", bm = class ext
|
|
|
10777
10793
|
static _resolutionToSeconds(e) {
|
|
10778
10794
|
return e.indexOf("W") > 0 || e.indexOf("D") > 0 ? parseInt(e) * 24 * 60 * 60 * 1e3 : e.indexOf("S") > 0 ? parseInt(e) * 1e3 : e === "D" ? 864e5 : parseInt(e) * 60 * 1e3;
|
|
10779
10795
|
}
|
|
10780
|
-
},
|
|
10796
|
+
}, Cm = class {
|
|
10781
10797
|
listeners;
|
|
10782
10798
|
constructor() {
|
|
10783
10799
|
this.listeners = {};
|
|
@@ -10797,7 +10813,7 @@ var vm = (e) => om(e) ? encodeURIComponent(e) : e, ym = "2.0.25", bm = class ext
|
|
|
10797
10813
|
data: t
|
|
10798
10814
|
}));
|
|
10799
10815
|
};
|
|
10800
|
-
},
|
|
10816
|
+
}, wm = class e extends Cm {
|
|
10801
10817
|
getExchange;
|
|
10802
10818
|
api;
|
|
10803
10819
|
id;
|
|
@@ -10962,7 +10978,7 @@ var vm = (e) => om(e) ? encodeURIComponent(e) : e, ym = "2.0.25", bm = class ext
|
|
|
10962
10978
|
}, n = new e(t, this.api, this.getExchange());
|
|
10963
10979
|
return n.getPriceOverrides = this.getPriceOverrides, n.listeners = this.listeners, n;
|
|
10964
10980
|
}
|
|
10965
|
-
},
|
|
10981
|
+
}, Tm = class e {
|
|
10966
10982
|
api;
|
|
10967
10983
|
id;
|
|
10968
10984
|
name;
|
|
@@ -11032,9 +11048,9 @@ var vm = (e) => om(e) ? encodeURIComponent(e) : e, ym = "2.0.25", bm = class ext
|
|
|
11032
11048
|
async loadMarkets(e = void 0) {
|
|
11033
11049
|
let t = await this.api.fetchMarkets(this, e), n = t.map((e) => {
|
|
11034
11050
|
try {
|
|
11035
|
-
return
|
|
11051
|
+
return wm.Create(e, this.api, this);
|
|
11036
11052
|
} catch {
|
|
11037
|
-
return new
|
|
11053
|
+
return new wm(e, this.api, this);
|
|
11038
11054
|
}
|
|
11039
11055
|
});
|
|
11040
11056
|
return n.length > 0 && (this.markets = L.default.keyBy(n, "coinraySymbol"), this.exchangeSymbols = L.default.keyBy(n, "symbol")), t;
|
|
@@ -11049,7 +11065,7 @@ var vm = (e) => om(e) ? encodeURIComponent(e) : e, ym = "2.0.25", bm = class ext
|
|
|
11049
11065
|
for (let n of e) {
|
|
11050
11066
|
let e = this.markets[n.coinraySymbol];
|
|
11051
11067
|
try {
|
|
11052
|
-
e ? (e.assignStatic(n), r[n.coinraySymbol] = e) : (
|
|
11068
|
+
e ? (e.assignStatic(n), r[n.coinraySymbol] = e) : (wm.checkStatic(n), r[n.coinraySymbol] = new wm(n, this.api, this), t.push(n.coinraySymbol));
|
|
11053
11069
|
} catch (t) {
|
|
11054
11070
|
console.error(t), e && (r[n.coinraySymbol] = e);
|
|
11055
11071
|
}
|
|
@@ -11079,7 +11095,7 @@ var vm = (e) => om(e) ? encodeURIComponent(e) : e, ym = "2.0.25", bm = class ext
|
|
|
11079
11095
|
getMarket(e) {
|
|
11080
11096
|
return this.markets[e];
|
|
11081
11097
|
}
|
|
11082
|
-
},
|
|
11098
|
+
}, Em = class {
|
|
11083
11099
|
subscriptions;
|
|
11084
11100
|
pendingAdditions;
|
|
11085
11101
|
pendingRemovals;
|
|
@@ -11120,7 +11136,7 @@ var vm = (e) => om(e) ? encodeURIComponent(e) : e, ym = "2.0.25", bm = class ext
|
|
|
11120
11136
|
}
|
|
11121
11137
|
this.pendingAdditions.clear(), this.pendingRemovals.clear();
|
|
11122
11138
|
}
|
|
11123
|
-
},
|
|
11139
|
+
}, Dm = class extends Cm {
|
|
11124
11140
|
isFormula = !0;
|
|
11125
11141
|
coinraySymbol;
|
|
11126
11142
|
legs;
|
|
@@ -11180,14 +11196,14 @@ var vm = (e) => om(e) ? encodeURIComponent(e) : e, ym = "2.0.25", bm = class ext
|
|
|
11180
11196
|
let r = um(this.node, (e) => n[e]);
|
|
11181
11197
|
return Number.isFinite(r) ? new d(r) : void 0;
|
|
11182
11198
|
}
|
|
11183
|
-
},
|
|
11199
|
+
}, Om = 12e4, km = 6e5, Am = 6e5, jm = 6e5, Mm = 250, Nm = 10, Pm = (e) => L.default.uniq(e.flatMap((e) => {
|
|
11184
11200
|
if (!om(e)) return [e];
|
|
11185
11201
|
try {
|
|
11186
11202
|
return lm(cm(e));
|
|
11187
11203
|
} catch {
|
|
11188
11204
|
return [];
|
|
11189
11205
|
}
|
|
11190
|
-
})),
|
|
11206
|
+
})), Fm = (e) => L.default.uniq(Pm(Array.isArray(e) ? e : [e]).map((e) => `${e}`.split("_")[0])), Im = class extends Cm {
|
|
11191
11207
|
rootApi;
|
|
11192
11208
|
apis;
|
|
11193
11209
|
exchanges;
|
|
@@ -11228,7 +11244,7 @@ var vm = (e) => om(e) ? encodeURIComponent(e) : e, ym = "2.0.25", bm = class ext
|
|
|
11228
11244
|
static: 0
|
|
11229
11245
|
};
|
|
11230
11246
|
constructor(e, t, n = 3e4, r = void 0) {
|
|
11231
|
-
super(), this.rootApi = new
|
|
11247
|
+
super(), this.rootApi = new Sm(e, t), this.apis = /* @__PURE__ */ new Map(), this.exchanges = {}, this.initialized = !1, this.refreshRate = n, this.tickerSubscriptions = new Em(), this.tickerSubscriptionRefeshTimer = null, this.rootApi.onTokenExpired(this.refreshToken), this.onStoreCache = r?.onStoreCache, this.apiCache = r?.apiCache;
|
|
11232
11248
|
}
|
|
11233
11249
|
async initialize() {
|
|
11234
11250
|
this.initialized ||= (await this.start(), !0);
|
|
@@ -11277,7 +11293,7 @@ var vm = (e) => om(e) ? encodeURIComponent(e) : e, ym = "2.0.25", bm = class ext
|
|
|
11277
11293
|
this.recomputeActive(), this.loopsStarted = !0;
|
|
11278
11294
|
let e = Date.now();
|
|
11279
11295
|
for (let t of Object.keys(this.exchanges)) this.staticCheckedAt.set(t, e);
|
|
11280
|
-
this.loop("tickersTimer", this.tickersTick, this.refreshRate), this.loop("staticTimer", this.staticTick,
|
|
11296
|
+
this.loop("tickersTimer", this.tickersTick, this.refreshRate), this.loop("staticTimer", this.staticTick, km), this.loop("exchangesTimer", this.refreshExchangeList, Am);
|
|
11281
11297
|
}
|
|
11282
11298
|
loop(e, t, n) {
|
|
11283
11299
|
this.destroyed || (this[e] = setTimeout(async () => {
|
|
@@ -11310,7 +11326,7 @@ var vm = (e) => om(e) ? encodeURIComponent(e) : e, ym = "2.0.25", bm = class ext
|
|
|
11310
11326
|
let t = {
|
|
11311
11327
|
exchanges: [],
|
|
11312
11328
|
markets: {}
|
|
11313
|
-
}, n = await this.rootApi.fetchExchanges((e) => (t.exchanges.push(e), this.apis.has(e.code) || this.apis.set(e.code, this.rootApi),
|
|
11329
|
+
}, n = await this.rootApi.fetchExchanges((e) => (t.exchanges.push(e), this.apis.has(e.code) || this.apis.set(e.code, this.rootApi), Tm.Create(e, this.apis.get(e.code))), e?.exchanges), r = await Promise.all(n.map(async (t) => ({ [t.code]: await t.loadMarkets(e?.markets?.[t.code]) })));
|
|
11314
11330
|
this.destroyed || (t.markets = r.reduce((e, t) => ({
|
|
11315
11331
|
...e,
|
|
11316
11332
|
...t
|
|
@@ -11320,10 +11336,10 @@ var vm = (e) => om(e) ? encodeURIComponent(e) : e, ym = "2.0.25", bm = class ext
|
|
|
11320
11336
|
this.onStoreCache && this.onStoreCache(this.rawCache);
|
|
11321
11337
|
}
|
|
11322
11338
|
setActiveExchanges(e) {
|
|
11323
|
-
this.pinned = new Set(
|
|
11339
|
+
this.pinned = new Set(Fm(e)), this.recomputeActive();
|
|
11324
11340
|
}
|
|
11325
11341
|
touchExchange(e) {
|
|
11326
|
-
let t =
|
|
11342
|
+
let t = Fm(e);
|
|
11327
11343
|
for (let e of t) this.leases.set(e, (this.leases.get(e) || 0) + 1);
|
|
11328
11344
|
this.recomputeActive();
|
|
11329
11345
|
let n = !1;
|
|
@@ -11339,7 +11355,7 @@ var vm = (e) => om(e) ? encodeURIComponent(e) : e, ym = "2.0.25", bm = class ext
|
|
|
11339
11355
|
};
|
|
11340
11356
|
}
|
|
11341
11357
|
async ensureFresh(e) {
|
|
11342
|
-
let t =
|
|
11358
|
+
let t = Fm(e).filter((e) => this.exchanges[e]);
|
|
11343
11359
|
if (t.length === 0) return;
|
|
11344
11360
|
let n = this.touchExchange(t);
|
|
11345
11361
|
try {
|
|
@@ -11371,7 +11387,7 @@ var vm = (e) => om(e) ? encodeURIComponent(e) : e, ym = "2.0.25", bm = class ext
|
|
|
11371
11387
|
...this.tickerSubscriptions.exchangeCodes()
|
|
11372
11388
|
]);
|
|
11373
11389
|
for (let e of t) this.graceUntil.delete(e);
|
|
11374
|
-
for (let n of this.active) !t.has(n) && !this.graceUntil.has(n) && this.graceUntil.set(n, e +
|
|
11390
|
+
for (let n of this.active) !t.has(n) && !this.graceUntil.has(n) && this.graceUntil.set(n, e + Om);
|
|
11375
11391
|
for (let [n, r] of this.graceUntil) r <= e ? this.graceUntil.delete(n) : t.add(n);
|
|
11376
11392
|
let n = new Set([...t].filter((e) => this.exchanges[e]));
|
|
11377
11393
|
if (this.loopsStarted) {
|
|
@@ -11389,13 +11405,13 @@ var vm = (e) => om(e) ? encodeURIComponent(e) : e, ym = "2.0.25", bm = class ext
|
|
|
11389
11405
|
this.pendingActivation.clear(), this.activationPromise = null;
|
|
11390
11406
|
try {
|
|
11391
11407
|
await this.fetchTickers(t);
|
|
11392
|
-
let e = Date.now(), n = t.filter((t) => e - (this.staticCheckedAt.get(t) || 0) >=
|
|
11408
|
+
let e = Date.now(), n = t.filter((t) => e - (this.staticCheckedAt.get(t) || 0) >= km);
|
|
11393
11409
|
Promise.all(n.map(this.revalidateStatic)).then((e) => e.some(Boolean) && this.storeCache()), this.destroyed || this.dispatchEvent("marketsUpdated", { exchangeCodes: t });
|
|
11394
11410
|
} catch (e) {
|
|
11395
11411
|
console.error(e);
|
|
11396
11412
|
}
|
|
11397
11413
|
e();
|
|
11398
|
-
},
|
|
11414
|
+
}, Mm);
|
|
11399
11415
|
}), this.activationPromise;
|
|
11400
11416
|
}
|
|
11401
11417
|
tickersTick = async () => {
|
|
@@ -11406,7 +11422,7 @@ var vm = (e) => om(e) ? encodeURIComponent(e) : e, ym = "2.0.25", bm = class ext
|
|
|
11406
11422
|
(await Promise.all([...this.recomputeActive()].map(this.revalidateStatic))).some(Boolean) && this.storeCache();
|
|
11407
11423
|
};
|
|
11408
11424
|
fetchTickers = async (e) => {
|
|
11409
|
-
this.destroyed || await Promise.all(L.default.chunk([...e].sort(),
|
|
11425
|
+
this.destroyed || await Promise.all(L.default.chunk([...e].sort(), Nm).map(async (e) => {
|
|
11410
11426
|
if (Date.now() < this.endpointDownUntil.tickers) return Promise.all(e.map(this.refreshMarkets));
|
|
11411
11427
|
try {
|
|
11412
11428
|
let t = await this.rootApi.fetchTickers(e);
|
|
@@ -11438,7 +11454,7 @@ var vm = (e) => om(e) ? encodeURIComponent(e) : e, ym = "2.0.25", bm = class ext
|
|
|
11438
11454
|
}
|
|
11439
11455
|
};
|
|
11440
11456
|
markEndpointDown(e, t) {
|
|
11441
|
-
return t?.status === 404 || t?.isAxiosError && !t.response ? (this.endpointDownUntil[e] || console.warn(`CoinrayCache: ${e} endpoint unavailable (${t?.message}), falling back to /markets`), this.endpointDownUntil[e] = Date.now() +
|
|
11457
|
+
return t?.status === 404 || t?.isAxiosError && !t.response ? (this.endpointDownUntil[e] || console.warn(`CoinrayCache: ${e} endpoint unavailable (${t?.message}), falling back to /markets`), this.endpointDownUntil[e] = Date.now() + jm, !0) : !1;
|
|
11442
11458
|
}
|
|
11443
11459
|
refreshExchangeList = async () => {
|
|
11444
11460
|
let e = await this.rootApi.fetchExchanges((e) => e, void 0);
|
|
@@ -11448,7 +11464,7 @@ var vm = (e) => om(e) ? encodeURIComponent(e) : e, ym = "2.0.25", bm = class ext
|
|
|
11448
11464
|
this.apis.has(r.code) || this.apis.set(r.code, this.rootApi);
|
|
11449
11465
|
let e = this.exchanges[r.code];
|
|
11450
11466
|
try {
|
|
11451
|
-
e ? (e.update(r), t[r.code] = e) : (t[r.code] =
|
|
11467
|
+
e ? (e.update(r), t[r.code] = e) : (t[r.code] = Tm.Create(r, this.apis.get(r.code)), n.push(r.code));
|
|
11452
11468
|
} catch (n) {
|
|
11453
11469
|
console.error(n), e && (t[r.code] = e);
|
|
11454
11470
|
}
|
|
@@ -11464,7 +11480,7 @@ var vm = (e) => om(e) ? encodeURIComponent(e) : e, ym = "2.0.25", bm = class ext
|
|
|
11464
11480
|
return this.exchanges;
|
|
11465
11481
|
}
|
|
11466
11482
|
getExchange(e) {
|
|
11467
|
-
return this.getExchanges()[e] ||
|
|
11483
|
+
return this.getExchanges()[e] || Tm.Create({
|
|
11468
11484
|
id: -1,
|
|
11469
11485
|
name: e,
|
|
11470
11486
|
code: e,
|
|
@@ -11564,12 +11580,12 @@ var vm = (e) => om(e) ? encodeURIComponent(e) : e, ym = "2.0.25", bm = class ext
|
|
|
11564
11580
|
this.updateRequestedTickers(e, (e) => {
|
|
11565
11581
|
n && e.clear();
|
|
11566
11582
|
for (let n of t) e.add(n);
|
|
11567
|
-
}), this.tickerSubscriptions.subscribe(e,
|
|
11583
|
+
}), this.tickerSubscriptions.subscribe(e, Pm(t)), this.scheduleTickerRefresh();
|
|
11568
11584
|
}
|
|
11569
11585
|
updateRequestedTickers(e, t) {
|
|
11570
|
-
let n = this.requestedTickers.get(e) ?? /* @__PURE__ */ new Set(), r =
|
|
11586
|
+
let n = this.requestedTickers.get(e) ?? /* @__PURE__ */ new Set(), r = Pm([...n]);
|
|
11571
11587
|
t(n), n.size ? this.requestedTickers.set(e, n) : this.requestedTickers.delete(e);
|
|
11572
|
-
let i = L.default.difference(r,
|
|
11588
|
+
let i = L.default.difference(r, Pm([...n]));
|
|
11573
11589
|
i.length && this.tickerSubscriptions.unsubscribe(e, i);
|
|
11574
11590
|
}
|
|
11575
11591
|
scheduleTickerRefresh() {
|
|
@@ -11671,7 +11687,7 @@ var vm = (e) => om(e) ? encodeURIComponent(e) : e, ym = "2.0.25", bm = class ext
|
|
|
11671
11687
|
let t = this.formulaMarkets.get(e);
|
|
11672
11688
|
if (!t) {
|
|
11673
11689
|
try {
|
|
11674
|
-
t = new
|
|
11690
|
+
t = new Dm(e, this.getMarket);
|
|
11675
11691
|
} catch {
|
|
11676
11692
|
return;
|
|
11677
11693
|
}
|
|
@@ -11703,11 +11719,11 @@ var vm = (e) => om(e) ? encodeURIComponent(e) : e, ym = "2.0.25", bm = class ext
|
|
|
11703
11719
|
let n = t[0];
|
|
11704
11720
|
return this.apis.get(n);
|
|
11705
11721
|
}
|
|
11706
|
-
},
|
|
11722
|
+
}, Lm = class extends Error {
|
|
11707
11723
|
constructor(e) {
|
|
11708
11724
|
super(e), this.name = "MarketNotFoundError";
|
|
11709
11725
|
}
|
|
11710
|
-
},
|
|
11726
|
+
}, Rm = class extends Cm {
|
|
11711
11727
|
coinrayCache;
|
|
11712
11728
|
getPriceOverrides;
|
|
11713
11729
|
coinraySymbol;
|
|
@@ -11741,7 +11757,7 @@ var vm = (e) => om(e) ? encodeURIComponent(e) : e, ym = "2.0.25", bm = class ext
|
|
|
11741
11757
|
let e = this.coinrayCache.getMarket(this.coinraySymbol);
|
|
11742
11758
|
return e?.overridePrices(this.getPriceOverrides), e;
|
|
11743
11759
|
}
|
|
11744
|
-
throw new
|
|
11760
|
+
throw new Lm(`Market not found: ${this.coinraySymbol}`);
|
|
11745
11761
|
}
|
|
11746
11762
|
subscribeCoinraySymbolWillChange(e) {
|
|
11747
11763
|
return this.on("coinraySymbolWillChange", e);
|
|
@@ -11888,7 +11904,7 @@ var vm = (e) => om(e) ? encodeURIComponent(e) : e, ym = "2.0.25", bm = class ext
|
|
|
11888
11904
|
unsubscribeTradesDelayed = (e) => {
|
|
11889
11905
|
this.off("tradesDelayed", e);
|
|
11890
11906
|
};
|
|
11891
|
-
},
|
|
11907
|
+
}, zm = {
|
|
11892
11908
|
"en-US": { validation: {
|
|
11893
11909
|
notGreaterThanOrEqualTo: "Can't be less than {{min}}",
|
|
11894
11910
|
insufficientFunds: "Insufficient funds"
|
|
@@ -11901,7 +11917,7 @@ var vm = (e) => om(e) ? encodeURIComponent(e) : e, ym = "2.0.25", bm = class ext
|
|
|
11901
11917
|
notGreaterThanOrEqualTo: "Не может быть меньше {{min}}",
|
|
11902
11918
|
insufficientFunds: "Недостаточно средств"
|
|
11903
11919
|
} }
|
|
11904
|
-
},
|
|
11920
|
+
}, Bm = /* @__PURE__ */ l((/* @__PURE__ */ o(((e, t) => {
|
|
11905
11921
|
(function(e, t, n) {
|
|
11906
11922
|
var r = function(e, t, n) {
|
|
11907
11923
|
n = i.extend({}, i.options, n);
|
|
@@ -12339,63 +12355,63 @@ var vm = (e) => om(e) ? encodeURIComponent(e) : e, ym = "2.0.25", bm = class ext
|
|
|
12339
12355
|
}, r.exposeModule(r, this, e, t, n);
|
|
12340
12356
|
}).call(e, e === void 0 ? null : /* istanbul ignore next */ e, t === void 0 ? null : /* istanbul ignore next */ t, typeof define < "u" ? /* istanbul ignore next */ define : null);
|
|
12341
12357
|
})))(), 1);
|
|
12342
|
-
|
|
12343
|
-
var
|
|
12344
|
-
BalanceLimit: () =>
|
|
12345
|
-
ExchangeFeatures: () =>
|
|
12346
|
-
IpWhiteList: () =>
|
|
12347
|
-
MarginType: () =>
|
|
12348
|
-
OrderSide: () =>
|
|
12349
|
-
OrderStatus: () =>
|
|
12350
|
-
OrderType: () =>
|
|
12351
|
-
TimeInForce: () =>
|
|
12352
|
-
}),
|
|
12358
|
+
Bm.default.validators.bigNumericality = (e, t, n, r) => Bm.default.validators.numericality(e && e.toNumber(), t, r);
|
|
12359
|
+
var Vm = Bm.default, Hm = /* @__PURE__ */ s({
|
|
12360
|
+
BalanceLimit: () => Xm,
|
|
12361
|
+
ExchangeFeatures: () => Wm,
|
|
12362
|
+
IpWhiteList: () => Gm,
|
|
12363
|
+
MarginType: () => Km,
|
|
12364
|
+
OrderSide: () => Jm,
|
|
12365
|
+
OrderStatus: () => qm,
|
|
12366
|
+
OrderType: () => Um,
|
|
12367
|
+
TimeInForce: () => Ym
|
|
12368
|
+
}), Um = /* @__PURE__ */ function(e) {
|
|
12353
12369
|
return e.MARKET = "MARKET", e.LIMIT = "LIMIT", e.LIMIT_LADDER = "LIMIT_LADDER", e.STOP_LOSS = "STOP_LOSS", e.OCO = "OCO", e.STOP_LOSS_LIMIT = "STOP_LOSS_LIMIT", e.STOP_LOSS_MARKET = "STOP_LOSS_MARKET", e.TAKE_PROFIT = "TAKE_PROFIT", e.TAKE_PROFIT_LIMIT = "TAKE_PROFIT_LIMIT", e.TAKE_PROFIT_MARKET = "TAKE_PROFIT_MARKET", e;
|
|
12354
|
-
}({}), Um = /* @__PURE__ */ function(e) {
|
|
12355
|
-
return e.HEDGE_MODE = "hedgeMode", e.HEDGE_MODE_ONLY = "hedgeModeOnly", e.ORDER_QUOTE_AMOUNT = "orderQuoteAmount", e.MARKET_BUY_QUOTE_ONLY = "marketBuyQuoteOnly", e.UPDATE_LEVERAGE_ONLY_ON_OPEN_POSITIONS = "updateLeverageOnlyOnOpenPositions", e.IGNORE_LEVERAGE_ON_QUICK_SYNC = "ignoreLeverageOnQuickSync", e.MULTIPLE_MARGIN_TYPE_POSITIONS = "multipleMarginTypePositions", e.SET_LEVERAGE_NOT_AVAILABLE = "setLeverageNotAvailable", e.SET_MARGIN_TYPE_NOT_AVAILABLE = "setMarginTypeNotAvailable", e.FIXED_CROSSED_LEVERAGE = "fixedCrossedLeverage", e.FAST_CONNECT = "fastConnect", e.UNIFIED_BALANCE = "unifiedBalance", e.NO_API_KEY_LINK = "noApiKeyLink", e;
|
|
12356
12370
|
}({}), Wm = /* @__PURE__ */ function(e) {
|
|
12357
|
-
return e.
|
|
12371
|
+
return e.HEDGE_MODE = "hedgeMode", e.HEDGE_MODE_ONLY = "hedgeModeOnly", e.ORDER_QUOTE_AMOUNT = "orderQuoteAmount", e.MARKET_BUY_QUOTE_ONLY = "marketBuyQuoteOnly", e.UPDATE_LEVERAGE_ONLY_ON_OPEN_POSITIONS = "updateLeverageOnlyOnOpenPositions", e.IGNORE_LEVERAGE_ON_QUICK_SYNC = "ignoreLeverageOnQuickSync", e.MULTIPLE_MARGIN_TYPE_POSITIONS = "multipleMarginTypePositions", e.SET_LEVERAGE_NOT_AVAILABLE = "setLeverageNotAvailable", e.SET_MARGIN_TYPE_NOT_AVAILABLE = "setMarginTypeNotAvailable", e.FIXED_CROSSED_LEVERAGE = "fixedCrossedLeverage", e.FAST_CONNECT = "fastConnect", e.UNIFIED_BALANCE = "unifiedBalance", e.NO_API_KEY_LINK = "noApiKeyLink", e;
|
|
12358
12372
|
}({}), Gm = /* @__PURE__ */ function(e) {
|
|
12359
|
-
return e.
|
|
12373
|
+
return e.NONE = "NONE", e.LIST = "LIST", e.COMMA = "COMMA", e.COMMA_SPACE = "COMMA_SPACE", e.SPACE = "SPACE", e;
|
|
12360
12374
|
}({}), Km = /* @__PURE__ */ function(e) {
|
|
12361
|
-
return e.
|
|
12375
|
+
return e.CROSSED = "CROSSED", e.ISOLATED = "ISOLATED", e;
|
|
12362
12376
|
}({}), qm = /* @__PURE__ */ function(e) {
|
|
12363
|
-
return e.
|
|
12377
|
+
return e.OPEN = "open", e.CLOSED = "closed", e.CANCELED = "canceled", e;
|
|
12364
12378
|
}({}), Jm = /* @__PURE__ */ function(e) {
|
|
12365
|
-
return e.
|
|
12379
|
+
return e.BUY = "buy", e.SELL = "sell", e;
|
|
12366
12380
|
}({}), Ym = /* @__PURE__ */ function(e) {
|
|
12381
|
+
return e.GTC = "gtc", e.FOK = "fok", e.IOC = "ioc", e;
|
|
12382
|
+
}({}), Xm = /* @__PURE__ */ function(e) {
|
|
12367
12383
|
return e.QUOTE = "quote", e.BASE = "base", e.NONE = "none", e;
|
|
12368
|
-
}({}),
|
|
12369
|
-
for (let e = 0; e < 256; ++e)
|
|
12370
|
-
function
|
|
12371
|
-
return (
|
|
12384
|
+
}({}), Zm = [];
|
|
12385
|
+
for (let e = 0; e < 256; ++e) Zm.push((e + 256).toString(16).slice(1));
|
|
12386
|
+
function Qm(e, t = 0) {
|
|
12387
|
+
return (Zm[e[t + 0]] + Zm[e[t + 1]] + Zm[e[t + 2]] + Zm[e[t + 3]] + "-" + Zm[e[t + 4]] + Zm[e[t + 5]] + "-" + Zm[e[t + 6]] + Zm[e[t + 7]] + "-" + Zm[e[t + 8]] + Zm[e[t + 9]] + "-" + Zm[e[t + 10]] + Zm[e[t + 11]] + Zm[e[t + 12]] + Zm[e[t + 13]] + Zm[e[t + 14]] + Zm[e[t + 15]]).toLowerCase();
|
|
12372
12388
|
}
|
|
12373
12389
|
//#endregion
|
|
12374
12390
|
//#region node_modules/uuid/dist/rng.js
|
|
12375
|
-
var
|
|
12376
|
-
function
|
|
12377
|
-
return crypto.getRandomValues(
|
|
12391
|
+
var $m = /* @__PURE__ */ new Uint8Array(16);
|
|
12392
|
+
function eh() {
|
|
12393
|
+
return crypto.getRandomValues($m);
|
|
12378
12394
|
}
|
|
12379
12395
|
//#endregion
|
|
12380
12396
|
//#region node_modules/uuid/dist/v4.js
|
|
12381
|
-
function eh(e, t, n) {
|
|
12382
|
-
return !t && !e && crypto.randomUUID ? crypto.randomUUID() : th(e, t, n);
|
|
12383
|
-
}
|
|
12384
12397
|
function th(e, t, n) {
|
|
12398
|
+
return !t && !e && crypto.randomUUID ? crypto.randomUUID() : nh(e, t, n);
|
|
12399
|
+
}
|
|
12400
|
+
function nh(e, t, n) {
|
|
12385
12401
|
e ||= {};
|
|
12386
|
-
let r = e.random ?? e.rng?.() ??
|
|
12402
|
+
let r = e.random ?? e.rng?.() ?? eh();
|
|
12387
12403
|
if (r.length < 16) throw Error("Random bytes length must be >= 16");
|
|
12388
12404
|
if (r[6] = r[6] & 15 | 64, r[8] = r[8] & 63 | 128, t) {
|
|
12389
12405
|
if (n ||= 0, n < 0 || n + 16 > t.length) throw RangeError(`UUID byte range ${n}:${n + 15} is out of buffer bounds`);
|
|
12390
12406
|
for (let e = 0; e < 16; ++e) t[n + e] = r[e];
|
|
12391
12407
|
return t;
|
|
12392
12408
|
}
|
|
12393
|
-
return
|
|
12409
|
+
return Qm(r);
|
|
12394
12410
|
}
|
|
12395
12411
|
//#endregion
|
|
12396
12412
|
//#region lib/orders/base.ts
|
|
12397
|
-
var
|
|
12398
|
-
id =
|
|
12413
|
+
var rh = class {
|
|
12414
|
+
id = th();
|
|
12399
12415
|
coinraySymbol;
|
|
12400
12416
|
precisionBase;
|
|
12401
12417
|
precisionQuote;
|
|
@@ -12414,7 +12430,7 @@ var nh = class {
|
|
|
12414
12430
|
postOnly;
|
|
12415
12431
|
timeInForce;
|
|
12416
12432
|
constructor(e) {
|
|
12417
|
-
this.coinraySymbol = e.coinraySymbol, this.precisionBase = Hp(e.precisionBase), this.precisionQuote = Hp(e.precisionQuote), this.precisionPrice = Hp(e.precisionPrice), this.minBase = $(e.minBase), this.minQuote = $(e.minQuote), this.makerFee = $(e.makerFee), this.takerFee = $(e.takerFee), this.balances = e.balances, this.balanceLimit = e.balanceLimit ||
|
|
12433
|
+
this.coinraySymbol = e.coinraySymbol, this.precisionBase = Hp(e.precisionBase), this.precisionQuote = Hp(e.precisionQuote), this.precisionPrice = Hp(e.precisionPrice), this.minBase = $(e.minBase), this.minQuote = $(e.minQuote), this.makerFee = $(e.makerFee), this.takerFee = $(e.takerFee), this.balances = e.balances, this.balanceLimit = e.balanceLimit || Xm.NONE, this.side = e.side, this.orderExternalId = e.externalId, this.errors = {}, this.isValid = !0, this.reduceOnly = e.reduceOnly, this.postOnly = e.postOnly, this.timeInForce = e.timeInForce;
|
|
12418
12434
|
}
|
|
12419
12435
|
startEdit(e) {
|
|
12420
12436
|
this.orderExternalId = e;
|
|
@@ -12424,29 +12440,29 @@ var nh = class {
|
|
|
12424
12440
|
this.errors = {}, this.isValid = !0;
|
|
12425
12441
|
}
|
|
12426
12442
|
validate() {
|
|
12427
|
-
let e =
|
|
12443
|
+
let e = Vm(this, this.constraints());
|
|
12428
12444
|
return e ? (this.errors = e, this.isValid = !1) : this.resetError(), !e;
|
|
12429
12445
|
}
|
|
12430
|
-
},
|
|
12446
|
+
}, ih = class extends rh {
|
|
12431
12447
|
baseAmount;
|
|
12432
12448
|
quoteAmount;
|
|
12433
12449
|
price;
|
|
12434
12450
|
lockedOn;
|
|
12435
|
-
orderType =
|
|
12451
|
+
orderType = Um.LIMIT;
|
|
12436
12452
|
constraints() {
|
|
12437
12453
|
let e, t;
|
|
12438
|
-
return this.balanceLimit ===
|
|
12454
|
+
return this.balanceLimit === Xm.QUOTE ? t = this.balances.quote || 0 : this.balanceLimit === Xm.BASE && (e = this.balances.base || 0), {
|
|
12439
12455
|
baseAmount: { bigNumericality: {
|
|
12440
12456
|
greaterThanOrEqualTo: this.minBase.toNumber(),
|
|
12441
|
-
notGreaterThanOrEqualTo: `^${
|
|
12457
|
+
notGreaterThanOrEqualTo: `^${Sm.I18n.t("validation.notGreaterThanOrEqualTo", { min: Bp(this.precisionBase, this.minBase) })}`,
|
|
12442
12458
|
lessThanOrEqualTo: e ? e.toNumber() : void 0,
|
|
12443
|
-
notLessThanOrEqualTo: `^${
|
|
12459
|
+
notLessThanOrEqualTo: `^${Sm.I18n.t("validation.insufficientFunds")}`
|
|
12444
12460
|
} },
|
|
12445
12461
|
quoteAmount: { bigNumericality: {
|
|
12446
12462
|
greaterThanOrEqualTo: this.minQuote.toNumber(),
|
|
12447
|
-
notGreaterThanOrEqualTo: `^${
|
|
12463
|
+
notGreaterThanOrEqualTo: `^${Sm.I18n.t("validation.notGreaterThanOrEqualTo", { min: Bp(this.precisionQuote, this.minQuote) })}`,
|
|
12448
12464
|
lessThanOrEqualTo: t ? t.toNumber() : void 0,
|
|
12449
|
-
notLessThanOrEqualTo: `^${
|
|
12465
|
+
notLessThanOrEqualTo: `^${Sm.I18n.t("validation.insufficientFunds")}`
|
|
12450
12466
|
} },
|
|
12451
12467
|
price: { bigNumericality: { greaterThan: 0 } }
|
|
12452
12468
|
};
|
|
@@ -12472,25 +12488,25 @@ var nh = class {
|
|
|
12472
12488
|
getOrders() {
|
|
12473
12489
|
return [this];
|
|
12474
12490
|
}
|
|
12475
|
-
},
|
|
12491
|
+
}, ah = class extends rh {
|
|
12476
12492
|
baseAmount;
|
|
12477
12493
|
quoteAmount;
|
|
12478
12494
|
price;
|
|
12479
|
-
orderType =
|
|
12495
|
+
orderType = Um.MARKET;
|
|
12480
12496
|
constraints = () => {
|
|
12481
12497
|
let e, t;
|
|
12482
|
-
return this.balanceLimit ===
|
|
12498
|
+
return this.balanceLimit === Xm.QUOTE ? t = this.balances.quote || 0 : this.balanceLimit === Xm.BASE && (e = this.balances.base || 0), {
|
|
12483
12499
|
baseAmount: { bigNumericality: {
|
|
12484
12500
|
greaterThanOrEqualTo: e ? this.minBase.toNumber() : void 0,
|
|
12485
|
-
notGreaterThanOrEqualTo: `^${
|
|
12501
|
+
notGreaterThanOrEqualTo: `^${Sm.I18n.t("validation.notGreaterThanOrEqualTo", { min: Bp(this.precisionBase, this.minBase) })}`,
|
|
12486
12502
|
lessThanOrEqualTo: e ? e.toNumber() : void 0,
|
|
12487
|
-
notLessThanOrEqualTo: `^${
|
|
12503
|
+
notLessThanOrEqualTo: `^${Sm.I18n.t("validation.insufficientFunds")}`
|
|
12488
12504
|
} },
|
|
12489
12505
|
quoteAmount: { bigNumericality: {
|
|
12490
12506
|
greaterThanOrEqualTo: t ? this.minQuote.toNumber() : void 0,
|
|
12491
|
-
notGreaterThanOrEqualTo: `^${
|
|
12507
|
+
notGreaterThanOrEqualTo: `^${Sm.I18n.t("validation.notGreaterThanOrEqualTo", { min: Bp(this.precisionQuote, this.minQuote) })}`,
|
|
12492
12508
|
lessThanOrEqualTo: t ? t.toNumber() : void 0,
|
|
12493
|
-
notLessThanOrEqualTo: `^${
|
|
12509
|
+
notLessThanOrEqualTo: `^${Sm.I18n.t("validation.insufficientFunds")}`
|
|
12494
12510
|
} }
|
|
12495
12511
|
};
|
|
12496
12512
|
};
|
|
@@ -12509,17 +12525,17 @@ var nh = class {
|
|
|
12509
12525
|
getOrders() {
|
|
12510
12526
|
return [this];
|
|
12511
12527
|
}
|
|
12512
|
-
},
|
|
12528
|
+
}, oh = /* @__PURE__ */ function(e) {
|
|
12513
12529
|
return e.LINEAR = "LINEAR", e.EXPONENTIAL = "EXPONENTIAL", e.FIBONACCI = "FIBONACCI", e.CUSTOM = "CUSTOM", e;
|
|
12514
|
-
}({}),
|
|
12530
|
+
}({}), sh = /* @__PURE__ */ function(e) {
|
|
12515
12531
|
return e.EQUAL = "EQUAL", e.LINEAR = "LINEAR", e.LINEAR_REVERSE = "LINEAR_REVERSE", e.EXPONENTIAL = "EXPONENTIAL", e.EXPONENTIAL_REVERSE = "EXPONENTIAL_REVERSE", e.CUSTOM = "CUSTOM", e;
|
|
12516
|
-
}({}),
|
|
12517
|
-
[
|
|
12518
|
-
[
|
|
12532
|
+
}({}), ch = {
|
|
12533
|
+
[oh.LINEAR]: (e) => L.default.times(e, (t) => 1 / (e - 1) * t),
|
|
12534
|
+
[oh.EXPONENTIAL]: (e) => {
|
|
12519
12535
|
let t = 2 ** (e - 1);
|
|
12520
12536
|
return L.default.times(e, (e) => e == 0 ? 0 : 2 ** e / t);
|
|
12521
12537
|
},
|
|
12522
|
-
[
|
|
12538
|
+
[oh.FIBONACCI]: (e) => [
|
|
12523
12539
|
0,
|
|
12524
12540
|
.09,
|
|
12525
12541
|
.146,
|
|
@@ -12530,21 +12546,21 @@ var nh = class {
|
|
|
12530
12546
|
.788,
|
|
12531
12547
|
.886
|
|
12532
12548
|
].slice(0, e - 1).concat([1]),
|
|
12533
|
-
[
|
|
12534
|
-
},
|
|
12549
|
+
[oh.CUSTOM]: (e) => []
|
|
12550
|
+
}, lh = (e) => {
|
|
12535
12551
|
let t = L.default.sum(e);
|
|
12536
12552
|
return e.map((e) => e / t);
|
|
12537
|
-
},
|
|
12538
|
-
[
|
|
12539
|
-
[
|
|
12540
|
-
[
|
|
12553
|
+
}, uh = {
|
|
12554
|
+
[sh.EQUAL]: (e) => lh(L.default.times(e, () => 1)),
|
|
12555
|
+
[sh.LINEAR]: (e) => lh(L.default.times(e, (t) => 1 / e * (t + 1))),
|
|
12556
|
+
[sh.EXPONENTIAL]: (e) => {
|
|
12541
12557
|
let t = 2 ** e - 1;
|
|
12542
|
-
return
|
|
12558
|
+
return lh(L.default.times(e, (e) => 2 ** e / t));
|
|
12543
12559
|
},
|
|
12544
|
-
[
|
|
12545
|
-
[
|
|
12546
|
-
[
|
|
12547
|
-
},
|
|
12560
|
+
[sh.LINEAR_REVERSE]: (e) => uh[sh.LINEAR](e).reverse(),
|
|
12561
|
+
[sh.EXPONENTIAL_REVERSE]: (e) => uh[sh.EXPONENTIAL](e).reverse(),
|
|
12562
|
+
[sh.CUSTOM]: (e) => []
|
|
12563
|
+
}, dh = class extends rh {
|
|
12548
12564
|
baseAmount;
|
|
12549
12565
|
quoteAmount;
|
|
12550
12566
|
price;
|
|
@@ -12555,21 +12571,21 @@ var nh = class {
|
|
|
12555
12571
|
sizeScale;
|
|
12556
12572
|
priceScales;
|
|
12557
12573
|
sizeScales;
|
|
12558
|
-
orderType =
|
|
12574
|
+
orderType = Um.LIMIT_LADDER;
|
|
12559
12575
|
constraints() {
|
|
12560
12576
|
let e, t;
|
|
12561
|
-
return this.balanceLimit ===
|
|
12577
|
+
return this.balanceLimit === Xm.QUOTE ? t = this.balances.quote : this.balanceLimit === Xm.BASE && (e = this.balances.base), {
|
|
12562
12578
|
baseAmount: { bigNumericality: {
|
|
12563
12579
|
greaterThanOrEqualTo: this.minBase.toNumber(),
|
|
12564
|
-
notGreaterThanOrEqualTo: `^${
|
|
12580
|
+
notGreaterThanOrEqualTo: `^${Sm.I18n.t("validation.notGreaterThanOrEqualTo", { min: Bp(this.precisionBase, this.minBase) })}`,
|
|
12565
12581
|
lessThanOrEqualTo: e ? e.toNumber() : void 0,
|
|
12566
|
-
notLessThanOrEqualTo: `^${
|
|
12582
|
+
notLessThanOrEqualTo: `^${Sm.I18n.t("validation.insufficientFunds")}`
|
|
12567
12583
|
} },
|
|
12568
12584
|
quoteAmount: { bigNumericality: {
|
|
12569
12585
|
greaterThanOrEqualTo: this.minQuote.toNumber(),
|
|
12570
|
-
notGreaterThanOrEqualTo: `^${
|
|
12586
|
+
notGreaterThanOrEqualTo: `^${Sm.I18n.t("validation.notGreaterThanOrEqualTo", { min: Bp(this.precisionQuote, this.minQuote) })}`,
|
|
12571
12587
|
lessThanOrEqualTo: t ? t.toNumber() : void 0,
|
|
12572
|
-
notLessThanOrEqualTo: `^${
|
|
12588
|
+
notLessThanOrEqualTo: `^${Sm.I18n.t("validation.insufficientFunds")}`
|
|
12573
12589
|
} },
|
|
12574
12590
|
price: { bigNumericality: { greaterThan: 0 } },
|
|
12575
12591
|
otherPrice: { bigNumericality: { greaterThan: 0 } },
|
|
@@ -12577,36 +12593,36 @@ var nh = class {
|
|
|
12577
12593
|
};
|
|
12578
12594
|
}
|
|
12579
12595
|
constructor(e) {
|
|
12580
|
-
super(e), this.otherPrice = $(e.otherPrice), this.numOrders = Hp(e.numOrders), this.priceScale = e.priceScale ||
|
|
12596
|
+
super(e), this.otherPrice = $(e.otherPrice), this.numOrders = Hp(e.numOrders), this.priceScale = e.priceScale || oh.CUSTOM, this.sizeScale = e.sizeScale || sh.CUSTOM, this.price = $(e.price || "0"), this.lockedOn = e.lockedOn, this.baseAmount = $(e.baseAmount || "0"), this.quoteAmount = $(e.quoteAmount || "0"), this.priceScales = e.priceScales || ch[this.priceScale](this.numOrders), this.sizeScales = e.sizeScales || uh[this.sizeScale](this.numOrders), this.quoteAmount.gt(0) && this.lockedOn === "quoteAmount" ? this.updateQuoteAmount(this.quoteAmount) : this.updateBaseAmount(this.baseAmount);
|
|
12581
12597
|
}
|
|
12582
12598
|
updateNumOrders(e) {
|
|
12583
12599
|
this.numOrders = e;
|
|
12584
12600
|
}
|
|
12585
12601
|
updatePrice(e, t = .05) {
|
|
12586
12602
|
if (this.price = e.decimalPlaces(this.precisionPrice), e && this.otherPrice.eq(0)) {
|
|
12587
|
-
let n = this.side ===
|
|
12603
|
+
let n = this.side === Jm.BUY ? 1 + t : 1 - t;
|
|
12588
12604
|
this.otherPrice = e.multipliedBy(n).decimalPlaces(this.precisionPrice > 0 ? this.precisionPrice : 0);
|
|
12589
12605
|
}
|
|
12590
12606
|
this.recalculate();
|
|
12591
12607
|
}
|
|
12592
12608
|
updateOtherPrice(e, t = .05) {
|
|
12593
12609
|
if (this.otherPrice = e.decimalPlaces(this.precisionPrice), e && this.price.eq(0)) {
|
|
12594
|
-
let n = this.side ===
|
|
12610
|
+
let n = this.side === Jm.BUY ? 1 - t : 1 + t;
|
|
12595
12611
|
this.price = e.multipliedBy(n).decimalPlaces(this.precisionPrice > 0 ? this.precisionPrice : 0);
|
|
12596
12612
|
}
|
|
12597
12613
|
this.recalculate();
|
|
12598
12614
|
}
|
|
12599
12615
|
updatePriceScales(e) {
|
|
12600
|
-
this.priceScales = e, this.priceScale =
|
|
12616
|
+
this.priceScales = e, this.priceScale = oh.CUSTOM, this.recalculate();
|
|
12601
12617
|
}
|
|
12602
12618
|
updatePriceScale(e) {
|
|
12603
|
-
this.priceScales =
|
|
12619
|
+
this.priceScales = ch[e](this.numOrders), this.priceScale = e, this.recalculate();
|
|
12604
12620
|
}
|
|
12605
12621
|
updateSizeScales(e) {
|
|
12606
|
-
this.sizeScales = e, this.sizeScale =
|
|
12622
|
+
this.sizeScales = e, this.sizeScale = sh.CUSTOM, this.recalculate();
|
|
12607
12623
|
}
|
|
12608
12624
|
updateSizeScale(e) {
|
|
12609
|
-
this.sizeScales =
|
|
12625
|
+
this.sizeScales = uh[e](this.numOrders), this.sizeScale = e, this.recalculate();
|
|
12610
12626
|
}
|
|
12611
12627
|
updateLockedOn(e) {
|
|
12612
12628
|
this.lockedOn = e;
|
|
@@ -12630,7 +12646,7 @@ var nh = class {
|
|
|
12630
12646
|
let r = this.priceScales.slice(0, this.numOrders), i = this.sizeScales.slice(0, this.numOrders), a = this.otherPrice.minus(this.price), o = t;
|
|
12631
12647
|
return L.default.times(this.numOrders, (s) => {
|
|
12632
12648
|
let c = t.multipliedBy(i[s]).decimalPlaces(n > 0 ? n : 0, d.ROUND_DOWN);
|
|
12633
|
-
return o = o.minus(c), s === this.numOrders - 1 && (c = c.plus(o)), new
|
|
12649
|
+
return o = o.minus(c), s === this.numOrders - 1 && (c = c.plus(o)), new ih({
|
|
12634
12650
|
...this,
|
|
12635
12651
|
[e]: c,
|
|
12636
12652
|
lockedOn: e,
|
|
@@ -12638,9 +12654,9 @@ var nh = class {
|
|
|
12638
12654
|
});
|
|
12639
12655
|
});
|
|
12640
12656
|
}
|
|
12641
|
-
},
|
|
12657
|
+
}, fh = class extends ih {
|
|
12642
12658
|
stopPrice;
|
|
12643
|
-
orderType =
|
|
12659
|
+
orderType = Um.STOP_LOSS_LIMIT;
|
|
12644
12660
|
constraints() {
|
|
12645
12661
|
return {
|
|
12646
12662
|
...super.constraints(),
|
|
@@ -12652,21 +12668,21 @@ var nh = class {
|
|
|
12652
12668
|
}
|
|
12653
12669
|
updatePrice(e, t = .05) {
|
|
12654
12670
|
if (super.updatePrice(e), e && this.stopPrice.eq(0)) {
|
|
12655
|
-
let n = this.side ===
|
|
12671
|
+
let n = this.side === Jm.BUY ? 1 - t : 1 + t;
|
|
12656
12672
|
this.stopPrice = e.multipliedBy(n).decimalPlaces(this.precisionPrice > 0 ? this.precisionPrice : 0);
|
|
12657
12673
|
}
|
|
12658
12674
|
}
|
|
12659
12675
|
updateStopPrice(e, t = .05) {
|
|
12660
12676
|
if (this.stopPrice = e.decimalPlaces(this.precisionPrice), e && this.price.eq(0)) {
|
|
12661
|
-
let n = this.side ===
|
|
12677
|
+
let n = this.side === Jm.BUY ? 1 + t : 1 - t;
|
|
12662
12678
|
this.price = e.multipliedBy(n).decimalPlaces(this.precisionPrice > 0 ? this.precisionPrice : 0);
|
|
12663
12679
|
}
|
|
12664
12680
|
}
|
|
12665
|
-
},
|
|
12681
|
+
}, ph = class extends ih {
|
|
12666
12682
|
linkedOrderId;
|
|
12667
12683
|
otherPrice;
|
|
12668
12684
|
stopPrice;
|
|
12669
|
-
orderType =
|
|
12685
|
+
orderType = Um.OCO;
|
|
12670
12686
|
constraints() {
|
|
12671
12687
|
return {
|
|
12672
12688
|
...super.constraints(),
|
|
@@ -12679,29 +12695,29 @@ var nh = class {
|
|
|
12679
12695
|
}
|
|
12680
12696
|
updateQuoteAmount(e) {
|
|
12681
12697
|
this.quoteAmount = e;
|
|
12682
|
-
let t = this.side ===
|
|
12698
|
+
let t = this.side === Jm.BUY ? this.otherPrice : this.price;
|
|
12683
12699
|
this.baseAmount = e.dividedBy(t).decimalPlaces(this.precisionBase > 0 ? this.precisionBase : 0, d.ROUND_DOWN), this.validate();
|
|
12684
12700
|
}
|
|
12685
12701
|
updateBaseAmount(e) {
|
|
12686
12702
|
this.baseAmount = e;
|
|
12687
|
-
let t = this.side ===
|
|
12703
|
+
let t = this.side === Jm.BUY ? this.otherPrice : this.price;
|
|
12688
12704
|
this.quoteAmount = t.multipliedBy(this.baseAmount).decimalPlaces(this.precisionQuote > 0 ? this.precisionQuote : 0, d.ROUND_DOWN), this.validate();
|
|
12689
12705
|
}
|
|
12690
12706
|
updatePrice(e, t = .05) {
|
|
12691
12707
|
if (super.updatePrice(e), e && this.otherPrice.eq(0)) {
|
|
12692
|
-
let n = this.side ===
|
|
12708
|
+
let n = this.side === Jm.BUY ? 1 + t * 2 : 1 - t * 2, r = this.side === Jm.BUY ? 1 + t : 1 - t;
|
|
12693
12709
|
this.otherPrice = e.multipliedBy(n).decimalPlaces(this.precisionPrice > 0 ? this.precisionPrice : 0), this.stopPrice = e.multipliedBy(r).decimalPlaces(this.precisionPrice > 0 ? this.precisionPrice : 0);
|
|
12694
12710
|
}
|
|
12695
12711
|
}
|
|
12696
12712
|
updateOtherPrice(e, t = .05) {
|
|
12697
12713
|
if (this.otherPrice = e.decimalPlaces(this.precisionPrice), e && this.price.eq(0)) {
|
|
12698
|
-
let n = this.side ===
|
|
12714
|
+
let n = this.side === Jm.BUY ? 1 - t * 2 : 1 + t * 2, r = this.side === Jm.BUY ? 1 - t : 1 + t;
|
|
12699
12715
|
this.price = e.multipliedBy(n).decimalPlaces(this.precisionPrice > 0 ? this.precisionPrice : 0), this.stopPrice = e.multipliedBy(r).decimalPlaces(this.precisionPrice > 0 ? this.precisionPrice : 0);
|
|
12700
12716
|
}
|
|
12701
12717
|
}
|
|
12702
12718
|
updateStopPrice(e, t = .05) {
|
|
12703
12719
|
if (this.stopPrice = e.decimalPlaces(this.precisionPrice), e && this.price.eq(0)) {
|
|
12704
|
-
let n = this.side ===
|
|
12720
|
+
let n = this.side === Jm.BUY ? 1 - t : 1 + t, r = this.side === Jm.BUY ? 1 + t : 1 - t;
|
|
12705
12721
|
this.price = e.multipliedBy(n).decimalPlaces(this.precisionPrice > 0 ? this.precisionPrice : 0), this.otherPrice = e.multipliedBy(r).decimalPlaces(this.precisionPrice > 0 ? this.precisionPrice : 0);
|
|
12706
12722
|
}
|
|
12707
12723
|
}
|
|
@@ -12709,8 +12725,8 @@ var nh = class {
|
|
|
12709
12725
|
//#endregion
|
|
12710
12726
|
//#region lib/index.ts
|
|
12711
12727
|
d.set({ STRICT: !1 });
|
|
12712
|
-
var
|
|
12728
|
+
var mh = Sm;
|
|
12713
12729
|
//#endregion
|
|
12714
|
-
export {
|
|
12730
|
+
export { Xm as BalanceLimit, Im as CoinrayCache, Rm as CurrentMarket, _p as DAYS, Wm as ExchangeFeatures, Dm as FormulaMarket, gp as HOURS, Gm as IpWhiteList, dh as LimitLadderOrder, ih as LimitOrder, hp as MINUTES, Km as MarginType, ah as MarketOrder, ph as OcoOrder, Jm as OrderSide, qm as OrderStatus, Um as OrderType, oh as PriceScales, sh as SizeScales, fh as StopLimitOrder, Ym as TimeInForce, vp as WEEK, pm as alignCandles, Sp as base64UrlDecode, xp as base64UrlEncode, kp as camelize, Zp as candleTime, Pp as checkArray, Ip as checkBigNumber, Lp as checkBoolean, Rp as checkNull, Fp as checkNumber, Q as checkString, fm as combineCandles, Bp as correctNumberPrecision, Tp as createJWT, mh as default, Op as encryptPayload, zp as errorHelper, um as evalFormula, Qp as filterMarkets, mm as formulaCandles, lm as formulaLegs, gm as formulaPrecision, _m as formulaSymbolInfo, Xp as getBucketStartDates, Yp as getTimeParams, om as isFormula, Dp as jwkToPublicKey, Ap as jwtExpired, hm as latestFormulaCandle, zm as locales, cm as parseFormula, Ep as parseJWT, Jp as resolutionToBucketType, Wp as resolutionToDuration, $ as safeBigNumber, Vp as safeFloat, Hp as safeInteger, Up as safeTime, Cp as sha256hexdigest, wp as signHMAC, bp as strToArray, Np as throwIsArray, Mp as throwNotObject, jp as throwNull2NonNull, Kp as toBucketEnd, qp as toBucketStart, Gp as toSafeDate, Hm as types, yp as unix };
|
|
12715
12731
|
|
|
12716
12732
|
//# sourceMappingURL=coinrayjs.es.js.map
|