coinrayjs 2.0.20 → 2.0.22
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 +42 -24
- package/dist/coinrayjs.es.js.map +1 -1
- package/dist/coinrayjs.js +1 -1
- package/dist/coinrayjs.js.map +1 -1
- package/dist/types/coinray.d.ts +2 -0
- package/dist/types/coinray.d.ts.map +1 -1
- package/dist/types/exchange.d.ts +1 -0
- package/dist/types/exchange.d.ts.map +1 -1
- package/dist/types/market.d.ts +1 -0
- package/dist/types/market.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/coinrayjs.es.js
CHANGED
|
@@ -9748,7 +9748,7 @@ var $p = void 0, em = class {
|
|
|
9748
9748
|
$p = e, console.log("Coinray I18n initialized");
|
|
9749
9749
|
};
|
|
9750
9750
|
static t = (e, t) => $p ? $p.t(`coinray:${e}`, t) : `i18n uninitialized. Set the Coinray.I18n.instance. Key: ${e}`;
|
|
9751
|
-
}, tm = "2.0.
|
|
9751
|
+
}, tm = "2.0.21", nm = class extends Error {
|
|
9752
9752
|
errorCode;
|
|
9753
9753
|
errorMessage;
|
|
9754
9754
|
exchange;
|
|
@@ -9807,7 +9807,7 @@ var $p = void 0, em = class {
|
|
|
9807
9807
|
this._credential = e, this._sessionKey = t;
|
|
9808
9808
|
};
|
|
9809
9809
|
destroy = () => {
|
|
9810
|
-
this._tradeListeners = {}, this._orderbookListeners = {}, this._tickerListeners = /* @__PURE__ */ new Map(), this._tickerSymbols = /* @__PURE__ */ new Map(), this._channels = {}, this._timeOffsetTimeout && clearTimeout(this._timeOffsetTimeout), this._tokenCheckTimeout && clearInterval(this._tokenCheckTimeout), this.disconnect();
|
|
9810
|
+
this._tradeListeners = {}, this._orderbookListeners = {}, this._tickerListeners = /* @__PURE__ */ new Map(), this._tickerSymbols = /* @__PURE__ */ new Map(), this.tickerSnapshots = /* @__PURE__ */ new Map(), this._channels = {}, this._timeOffsetTimeout && clearTimeout(this._timeOffsetTimeout), this._tokenCheckTimeout && clearInterval(this._tokenCheckTimeout), this.disconnect();
|
|
9811
9811
|
};
|
|
9812
9812
|
checkToken = async (e = !0) => {
|
|
9813
9813
|
try {
|
|
@@ -10162,12 +10162,20 @@ var $p = void 0, em = class {
|
|
|
10162
10162
|
params: { exchange: e.code }
|
|
10163
10163
|
})), n;
|
|
10164
10164
|
};
|
|
10165
|
-
fetchTickers = async (
|
|
10166
|
-
let { result: { tickers:
|
|
10165
|
+
fetchTickers = async (e) => {
|
|
10166
|
+
let { result: { tickers: t } } = await this.get("tickers", {
|
|
10167
10167
|
version: "v1",
|
|
10168
|
-
params: { exchanges: [...
|
|
10168
|
+
params: { exchanges: [...e].sort().join(",") }
|
|
10169
10169
|
});
|
|
10170
|
-
return mo.default.mapValues(
|
|
10170
|
+
return mo.default.mapValues(t || {}, (e) => e.map(this.parseTickerSnapshotReusing));
|
|
10171
|
+
};
|
|
10172
|
+
tickerSnapshots = /* @__PURE__ */ new Map();
|
|
10173
|
+
parseTickerSnapshotReusing = (t) => {
|
|
10174
|
+
let n = e._parseTickerSnapshot(t, this.tickerSnapshots.get(t.s));
|
|
10175
|
+
return this.tickerSnapshots.set(t.s, {
|
|
10176
|
+
raw: t,
|
|
10177
|
+
parsed: n
|
|
10178
|
+
}), n;
|
|
10171
10179
|
};
|
|
10172
10180
|
fetchStaticMarkets = async (e, t) => {
|
|
10173
10181
|
let { result: n, _headers: r, _status: i } = await this.get("markets/static", {
|
|
@@ -10539,22 +10547,23 @@ var $p = void 0, em = class {
|
|
|
10539
10547
|
usdVolume: $(e.U)
|
|
10540
10548
|
};
|
|
10541
10549
|
}
|
|
10542
|
-
static _parseTickerSnapshot(e) {
|
|
10550
|
+
static _parseTickerSnapshot(e, t) {
|
|
10551
|
+
let n = (n, r) => t && t.raw[n] === e[n] ? t.parsed[r] : $(e[n]);
|
|
10543
10552
|
return {
|
|
10544
10553
|
coinraySymbol: e.s,
|
|
10545
|
-
lastPrice:
|
|
10546
|
-
askPrice:
|
|
10547
|
-
bidPrice:
|
|
10548
|
-
openPrice24h:
|
|
10549
|
-
highPrice24h:
|
|
10550
|
-
lowPrice24h:
|
|
10551
|
-
baseVolume:
|
|
10552
|
-
quoteVolume:
|
|
10553
|
-
btcVolume:
|
|
10554
|
-
usdVolume:
|
|
10555
|
-
baseToUsd:
|
|
10556
|
-
quoteToUsd:
|
|
10557
|
-
marketCap:
|
|
10554
|
+
lastPrice: n("c", "lastPrice"),
|
|
10555
|
+
askPrice: n("a", "askPrice"),
|
|
10556
|
+
bidPrice: n("b", "bidPrice"),
|
|
10557
|
+
openPrice24h: n("O", "openPrice24h"),
|
|
10558
|
+
highPrice24h: n("H", "highPrice24h"),
|
|
10559
|
+
lowPrice24h: n("L", "lowPrice24h"),
|
|
10560
|
+
baseVolume: n("BV", "baseVolume"),
|
|
10561
|
+
quoteVolume: n("QV", "quoteVolume"),
|
|
10562
|
+
btcVolume: n("B", "btcVolume"),
|
|
10563
|
+
usdVolume: n("U", "usdVolume"),
|
|
10564
|
+
baseToUsd: n("bu", "baseToUsd"),
|
|
10565
|
+
quoteToUsd: n("qu", "quoteToUsd"),
|
|
10566
|
+
marketCap: n("mc", "marketCap")
|
|
10558
10567
|
};
|
|
10559
10568
|
}
|
|
10560
10569
|
static _parseBalance(e) {
|
|
@@ -10743,8 +10752,11 @@ var $p = void 0, em = class {
|
|
|
10743
10752
|
this.getPriceOverrides = e;
|
|
10744
10753
|
};
|
|
10745
10754
|
updateLastPrice = (e) => {
|
|
10746
|
-
this._lastPrice = e, this.
|
|
10755
|
+
this._lastPrice = e, this.recomputeChange(), this.dispatchEvent("price");
|
|
10747
10756
|
};
|
|
10757
|
+
recomputeChange() {
|
|
10758
|
+
this.change = this.openPrice.isZero() ? 0 : this.lastPrice.minus(this.openPrice).dividedBy(this.openPrice).multipliedBy(100).toNumber();
|
|
10759
|
+
}
|
|
10748
10760
|
updateBidAsk = (e, t) => {
|
|
10749
10761
|
this._bidPrice = e, this._askPrice = t, this.dispatchEvent("bidask");
|
|
10750
10762
|
};
|
|
@@ -10752,7 +10764,11 @@ var $p = void 0, em = class {
|
|
|
10752
10764
|
this.openPrice = e.openPrice24h, this.highPrice = e.highPrice24h, this.lowPrice = e.lowPrice24h, this.volume = e.baseVolume, this.quoteVolume = e.quoteVolume, this.btcVolume = e.btcVolume, this.usdVolume = e.usdVolume, this.updateBidAsk(e.bidPrice, e.askPrice), this.updateLastPrice(e.lastPrice), this.dispatchEvent("ticker");
|
|
10753
10765
|
};
|
|
10754
10766
|
applySnapshot = (e, t = !1) => {
|
|
10755
|
-
|
|
10767
|
+
if (!t) {
|
|
10768
|
+
let t = e.lastPrice !== this._lastPrice || e.openPrice24h !== this.openPrice;
|
|
10769
|
+
this._lastPrice = e.lastPrice, this._bidPrice = e.bidPrice, this._askPrice = e.askPrice, this.openPrice = e.openPrice24h, this.highPrice = e.highPrice24h, this.lowPrice = e.lowPrice24h, t && this.recomputeChange();
|
|
10770
|
+
}
|
|
10771
|
+
this.volume = e.baseVolume, this.quoteVolume = e.quoteVolume, this.btcVolume = e.btcVolume, this.usdVolume = e.usdVolume, this.baseToUsd = e.baseToUsd, this.quoteToUsd = e.quoteToUsd, this.marketCap = e.marketCap, this.dispatchEvent("ticker");
|
|
10756
10772
|
};
|
|
10757
10773
|
clone() {
|
|
10758
10774
|
let t = {
|
|
@@ -10791,6 +10807,7 @@ var $p = void 0, em = class {
|
|
|
10791
10807
|
tradingEnabledFrom;
|
|
10792
10808
|
isFutures;
|
|
10793
10809
|
isDex;
|
|
10810
|
+
virtual;
|
|
10794
10811
|
logo;
|
|
10795
10812
|
btcVolume;
|
|
10796
10813
|
usdVolume;
|
|
@@ -10809,7 +10826,7 @@ var $p = void 0, em = class {
|
|
|
10809
10826
|
return e.check(t), new e(t, n);
|
|
10810
10827
|
}
|
|
10811
10828
|
static check(e) {
|
|
10812
|
-
if (e == null ? jp(e) : typeof e == "object" ? Array.isArray(e) && Np(e, !1) : Mp(e, !1), Fp(e.id, !1, "id"), Q(e.name, !1, "name"), Q(e.code, !1, "code"), Lp(e.websocket, !1, "websocket"), Lp(e.active, !1, "active"), Lp(e.tradingEnabled, !1, "tradingEnabled"), Q(e.tradingEnabledFrom, !1, "tradingEnabledFrom"), Lp(e.isFutures, !0, "isFutures"), Lp(e.isDex, !0, "isDex"), Q(e.logo, !1, "logo"), Q(e.btcVolume, !1, "btcVolume"), Q(e.usdVolume, !1, "usdVolume"), Fp(e.totalMarkets, !1, "totalMarkets"), Pp(e.quoteCurrencies, "quoteCurrencies"), Q(e.apiEndpoint, !0, "apiEndpoint"), Q(e.websocketEndpoint, !0, "websocketEndpoint"), Q(e.aliasedTo, !0, "aliasedTo"), e.quoteCurrencies) for (let t = 0; t < e.quoteCurrencies.length; t++) Q(e.quoteCurrencies[t], !1, "quoteCurrencies[" + t + "]");
|
|
10829
|
+
if (e == null ? jp(e) : typeof e == "object" ? Array.isArray(e) && Np(e, !1) : Mp(e, !1), Fp(e.id, !1, "id"), Q(e.name, !1, "name"), Q(e.code, !1, "code"), Lp(e.websocket, !1, "websocket"), Lp(e.active, !1, "active"), Lp(e.tradingEnabled, !1, "tradingEnabled"), Q(e.tradingEnabledFrom, !1, "tradingEnabledFrom"), Lp(e.isFutures, !0, "isFutures"), Lp(e.isDex, !0, "isDex"), Lp(e.virtual, !0, "virtual"), Q(e.logo, !1, "logo"), Q(e.btcVolume, !1, "btcVolume"), Q(e.usdVolume, !1, "usdVolume"), Fp(e.totalMarkets, !1, "totalMarkets"), Pp(e.quoteCurrencies, "quoteCurrencies"), Q(e.apiEndpoint, !0, "apiEndpoint"), Q(e.websocketEndpoint, !0, "websocketEndpoint"), Q(e.aliasedTo, !0, "aliasedTo"), e.quoteCurrencies) for (let t = 0; t < e.quoteCurrencies.length; t++) Q(e.quoteCurrencies[t], !1, "quoteCurrencies[" + t + "]");
|
|
10813
10830
|
if (e.quoteCurrencies === void 0 && (e.quoteCurrencies = null), Pp(e.supportedResolutions, "supportedResolutions"), Pp(e.supportedFeatures, "supportedFeatures"), e.supportedResolutions) for (let t = 0; t < e.supportedResolutions.length; t++) Q(e.supportedResolutions[t], !1, "supportedResolutions[" + t + "]");
|
|
10814
10831
|
e.supportedResolutions === void 0 && (e.supportedResolutions = null);
|
|
10815
10832
|
}
|
|
@@ -10821,7 +10838,7 @@ var $p = void 0, em = class {
|
|
|
10821
10838
|
}
|
|
10822
10839
|
_assign(e) {
|
|
10823
10840
|
let t = this.api;
|
|
10824
|
-
this.id = e.id, this.name = e.name, this.code = e.code, this.websocket = e.websocket, this.isFutures = !!e.isFutures, this.isDex = !!e.isDex, this.active = e.active, this.tradingEnabled = e.tradingEnabled, this.tradingEnabledFrom = e.tradingEnabledFrom, this.logo = e.logo, this.btcVolume = $(e.btcVolume), this.usdVolume = $(e.usdVolume), this.totalMarkets = Hp(e.totalMarkets), this.quoteCurrencies = e.quoteCurrencies, this.supportedResolutions = e.supportedResolutions, this.supportedFeatures = e.supportedFeatures, this.supportedOrderTypes = e.supportedOrderTypes, this.baseCurrencyDominance = e.baseCurrencyDominance, this.apiKeySettings = e.apiKeySettings, this.apiEndpoint = e.apiEndpoint || t.config.apiEndpoint, this.websocketEndpoint = e.websocketEndpoint || t.config.websocketEndpoint, this.aliasedTo = e.aliasedTo;
|
|
10841
|
+
this.id = e.id, this.name = e.name, this.code = e.code, this.websocket = e.websocket, this.isFutures = !!e.isFutures, this.isDex = !!e.isDex, this.virtual = !!e.virtual, this.active = e.active, this.tradingEnabled = e.tradingEnabled, this.tradingEnabledFrom = e.tradingEnabledFrom, this.logo = e.logo, this.btcVolume = $(e.btcVolume), this.usdVolume = $(e.usdVolume), this.totalMarkets = Hp(e.totalMarkets), this.quoteCurrencies = e.quoteCurrencies, this.supportedResolutions = e.supportedResolutions, this.supportedFeatures = e.supportedFeatures, this.supportedOrderTypes = e.supportedOrderTypes, this.baseCurrencyDominance = e.baseCurrencyDominance, this.apiKeySettings = e.apiKeySettings, this.apiEndpoint = e.apiEndpoint || t.config.apiEndpoint, this.websocketEndpoint = e.websocketEndpoint || t.config.websocketEndpoint, this.aliasedTo = e.aliasedTo;
|
|
10825
10842
|
}
|
|
10826
10843
|
clone() {
|
|
10827
10844
|
return new e({
|
|
@@ -10832,6 +10849,7 @@ var $p = void 0, em = class {
|
|
|
10832
10849
|
websocket: this.websocket,
|
|
10833
10850
|
isFutures: this.isFutures,
|
|
10834
10851
|
isDex: this.isDex,
|
|
10852
|
+
virtual: this.virtual,
|
|
10835
10853
|
logo: this.logo,
|
|
10836
10854
|
btcVolume: this.btcVolume,
|
|
10837
10855
|
usdVolume: this.usdVolume,
|