ccxt 4.4.19 → 4.4.21

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.
Files changed (63) hide show
  1. package/README.md +3 -3
  2. package/dist/ccxt.browser.min.js +4 -4
  3. package/dist/cjs/ccxt.js +3 -1
  4. package/dist/cjs/src/base/Exchange.js +18 -0
  5. package/dist/cjs/src/base/ws/Future.js +3 -1
  6. package/dist/cjs/src/binance.js +0 -10
  7. package/dist/cjs/src/bingx.js +6 -1
  8. package/dist/cjs/src/bybit.js +67 -4
  9. package/dist/cjs/src/gate.js +1 -0
  10. package/dist/cjs/src/htx.js +28 -0
  11. package/dist/cjs/src/hyperliquid.js +7 -6
  12. package/dist/cjs/src/kucoin.js +16 -36
  13. package/dist/cjs/src/kucoinfutures.js +2 -2
  14. package/dist/cjs/src/lbank.js +3 -3
  15. package/dist/cjs/src/okx.js +8 -10
  16. package/dist/cjs/src/paradex.js +1 -2
  17. package/dist/cjs/src/phemex.js +75 -0
  18. package/dist/cjs/src/pro/coinbaseadvanced.js +17 -0
  19. package/dist/cjs/src/static_dependencies/noble-hashes/_sha2.js +1 -1
  20. package/dist/cjs/src/static_dependencies/noble-hashes/hmac.js +1 -1
  21. package/dist/cjs/src/static_dependencies/noble-hashes/sha3.js +1 -1
  22. package/dist/cjs/src/static_dependencies/watchable/src/unpromise.js +298 -0
  23. package/js/ccxt.d.ts +4 -1
  24. package/js/ccxt.js +3 -1
  25. package/js/src/abstract/bybit.d.ts +1 -0
  26. package/js/src/abstract/kucoin.d.ts +1 -0
  27. package/js/src/abstract/kucoinfutures.d.ts +1 -0
  28. package/js/src/abstract/okx.d.ts +3 -0
  29. package/js/src/base/Exchange.d.ts +3 -1
  30. package/js/src/base/Exchange.js +18 -0
  31. package/js/src/base/ws/Future.js +2 -1
  32. package/js/src/binance.d.ts +0 -1
  33. package/js/src/binance.js +0 -10
  34. package/js/src/bingx.js +6 -1
  35. package/js/src/bybit.d.ts +1 -0
  36. package/js/src/bybit.js +67 -4
  37. package/js/src/gate.js +1 -0
  38. package/js/src/htx.d.ts +2 -2
  39. package/js/src/htx.js +28 -0
  40. package/js/src/hyperliquid.js +7 -6
  41. package/js/src/kucoin.d.ts +0 -1
  42. package/js/src/kucoin.js +16 -36
  43. package/js/src/kucoinfutures.js +2 -2
  44. package/js/src/lbank.js +3 -3
  45. package/js/src/okx.d.ts +0 -1
  46. package/js/src/okx.js +9 -11
  47. package/js/src/paradex.js +1 -1
  48. package/js/src/phemex.d.ts +2 -0
  49. package/js/src/phemex.js +75 -0
  50. package/js/src/pro/coinbaseadvanced.d.ts +4 -0
  51. package/js/src/pro/coinbaseadvanced.js +18 -0
  52. package/js/src/static_dependencies/noble-hashes/_blake2.js +1 -1
  53. package/js/src/static_dependencies/noble-hashes/_sha2.js +1 -1
  54. package/js/src/static_dependencies/noble-hashes/hmac.js +1 -1
  55. package/js/src/static_dependencies/noble-hashes/sha3-addons.js +5 -5
  56. package/js/src/static_dependencies/noble-hashes/sha3.js +1 -1
  57. package/js/src/static_dependencies/watchable/src/index.d.ts +2 -0
  58. package/js/src/static_dependencies/watchable/src/index.js +7 -0
  59. package/js/src/static_dependencies/watchable/src/types.d.ts +28 -0
  60. package/js/src/static_dependencies/watchable/src/types.js +8 -0
  61. package/js/src/static_dependencies/watchable/src/unpromise.d.ts +120 -0
  62. package/js/src/static_dependencies/watchable/src/unpromise.js +297 -0
  63. package/package.json +1 -1
@@ -174,7 +174,7 @@ class Keccak extends utils.Hash {
174
174
  }
175
175
  _cloneInto(to) {
176
176
  const { blockLen, suffix, outputLen, rounds, enableXOF } = this;
177
- to || (to = new Keccak(blockLen, suffix, outputLen, enableXOF, rounds));
177
+ to ||= new Keccak(blockLen, suffix, outputLen, enableXOF, rounds);
178
178
  to.state32.set(this.state32);
179
179
  to.pos = this.pos;
180
180
  to.posOut = this.posOut;
@@ -0,0 +1,298 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ /* eslint-disable @typescript-eslint/unbound-method */
6
+ /* eslint-disable @typescript-eslint/return-await */
7
+ /* eslint-disable @typescript-eslint/promise-function-async */
8
+ var _a;
9
+ /** Memory safe (weakmapped) cache of the ProxyPromise for each Promise,
10
+ * which is retained for the lifetime of the original Promise.
11
+ */
12
+ const subscribableCache = new WeakMap();
13
+ /** A NOOP function allowing a consistent interface for settled
14
+ * SubscribedPromises (settled promises are not subscribed - they resolve
15
+ * immediately). */
16
+ const NOOP = () => { };
17
+ /**
18
+ * Every `Promise<T>` can be shadowed by a single `ProxyPromise<T>`. It is
19
+ * created once, cached and reused throughout the lifetime of the Promise. Get a
20
+ * Promise's ProxyPromise using `Unpromise.proxy(promise)`.
21
+ *
22
+ * The `ProxyPromise<T>` attaches handlers to the original `Promise<T>`
23
+ * `.then()` and `.catch()` just once. Promises derived from it use a
24
+ * subscription- (and unsubscription-) based mechanism that monitors these
25
+ * handlers.
26
+ *
27
+ * Every time you call `.subscribe()`, `.then()` `.catch()` or `.finally()` on a
28
+ * `ProxyPromise<T>` it returns a `SubscribedPromise<T>` having an additional
29
+ * `unsubscribe()` method. Calling `unsubscribe()` detaches reference chains
30
+ * from the original, potentially long-lived Promise, eliminating memory leaks.
31
+ *
32
+ * This approach can eliminate the memory leaks that otherwise come about from
33
+ * repeated `race()` or `any()` calls invoking `.then()` and `.catch()` multiple
34
+ * times on the same long-lived native Promise (subscriptions which can never be
35
+ * cleaned up).
36
+ *
37
+ * `Unpromise.race(promises)` is a reference implementation of `Promise.race`
38
+ * avoiding memory leaks when using long-lived unsettled Promises.
39
+ *
40
+ * `Unpromise.any(promises)` is a reference implementation of `Promise.any`
41
+ * avoiding memory leaks when using long-lived unsettled Promises.
42
+ *
43
+ * `Unpromise.resolve(promise)` returns an ephemeral `SubscribedPromise<T>` for
44
+ * any given `Promise<T>` facilitating arbitrary async/await patterns. Behind
45
+ * the scenes, `resolve` is implemented simply as
46
+ * `Unpromise.proxy(promise).subscribe()`. Don't forget to call `.unsubscribe()`
47
+ * to tidy up!
48
+ *
49
+ */
50
+ class Unpromise {
51
+ constructor(arg) {
52
+ /** Promises expecting eventual settlement (unless unsubscribed first). This list is deleted
53
+ * after the original promise settles - no further notifications will be issued. */
54
+ this.subscribers = [];
55
+ /** The Promise's settlement (recorded when it fulfils or rejects). This is consulted when
56
+ * calling .subscribe() .then() .catch() .finally() to see if an immediately-resolving Promise
57
+ * can be returned, and therefore subscription can be bypassed. */
58
+ this.settlement = null;
59
+ /** TOSTRING SUPPORT */
60
+ this[_a] = "Unpromise";
61
+ // handle either a Promise or a Promise executor function
62
+ if (typeof arg === "function") {
63
+ this.promise = new Promise(arg);
64
+ }
65
+ else {
66
+ this.promise = arg;
67
+ }
68
+ // subscribe for eventual fulfilment and rejection
69
+ // handle PromiseLike objects (that at least have .then)
70
+ const thenReturn = this.promise.then((value) => {
71
+ // atomically record fulfilment and detach subscriber list
72
+ const { subscribers } = this;
73
+ this.subscribers = null;
74
+ this.settlement = {
75
+ status: "fulfilled",
76
+ value,
77
+ };
78
+ // notify fulfilment to subscriber list
79
+ subscribers?.forEach(({ resolve }) => {
80
+ resolve(value);
81
+ });
82
+ });
83
+ // handle Promise (that also have a .catch behaviour)
84
+ if ("catch" in thenReturn) {
85
+ thenReturn.catch((reason) => {
86
+ // atomically record rejection and detach subscriber list
87
+ const { subscribers } = this;
88
+ this.subscribers = null;
89
+ this.settlement = {
90
+ status: "rejected",
91
+ reason,
92
+ };
93
+ // notify rejection to subscriber list
94
+ subscribers?.forEach(({ reject }) => {
95
+ reject(reason);
96
+ });
97
+ });
98
+ }
99
+ }
100
+ /** Create a promise that mitigates uncontrolled subscription to a long-lived
101
+ * Promise via .then() and .catch() - otherwise a source of memory leaks.
102
+ *
103
+ * The returned promise has an `unsubscribe()` method which can be called when
104
+ * the Promise is no longer being tracked by application logic, and which
105
+ * ensures that there is no reference chain from the original promise to the
106
+ * new one, and therefore no memory leak.
107
+ *
108
+ * If original promise has not yet settled, this adds a new unique promise
109
+ * that listens to then/catch events, along with an `unsubscribe()` method to
110
+ * detach it.
111
+ *
112
+ * If original promise has settled, then creates a new Promise.resolve() or
113
+ * Promise.reject() and provided unsubscribe is a noop.
114
+ *
115
+ * If you call `unsubscribe()` before the returned Promise has settled, it
116
+ * will never settle.
117
+ */
118
+ subscribe() {
119
+ // in all cases we will combine some promise with its unsubscribe function
120
+ let promise;
121
+ let unsubscribe;
122
+ const { settlement } = this;
123
+ if (settlement === null) {
124
+ // not yet settled - subscribe new promise. Expect eventual settlement
125
+ if (this.subscribers === null) {
126
+ // invariant - it is not settled, so it must have subscribers
127
+ throw new Error("Unpromise settled but still has subscribers");
128
+ }
129
+ const subscriber = withResolvers();
130
+ this.subscribers = listWithMember(this.subscribers, subscriber);
131
+ promise = subscriber.promise;
132
+ unsubscribe = () => {
133
+ if (this.subscribers !== null) {
134
+ this.subscribers = listWithoutMember(this.subscribers, subscriber);
135
+ }
136
+ };
137
+ }
138
+ else {
139
+ // settled - don't create subscribed promise. Just resolve or reject
140
+ const { status } = settlement;
141
+ if (status === "fulfilled") {
142
+ promise = Promise.resolve(settlement.value);
143
+ }
144
+ else {
145
+ promise = Promise.reject(settlement.reason);
146
+ }
147
+ unsubscribe = NOOP;
148
+ }
149
+ // extend promise signature with the extra method
150
+ return Object.assign(promise, { unsubscribe });
151
+ }
152
+ /** STANDARD PROMISE METHODS (but returning a SubscribedPromise) */
153
+ then(onfulfilled, onrejected) {
154
+ const subscribed = this.subscribe();
155
+ const { unsubscribe } = subscribed;
156
+ return Object.assign(subscribed.then(onfulfilled, onrejected), {
157
+ unsubscribe,
158
+ });
159
+ }
160
+ catch(onrejected) {
161
+ const subscribed = this.subscribe();
162
+ const { unsubscribe } = subscribed;
163
+ return Object.assign(subscribed.catch(onrejected), {
164
+ unsubscribe,
165
+ });
166
+ }
167
+ finally(onfinally) {
168
+ const subscribed = this.subscribe();
169
+ const { unsubscribe } = subscribed;
170
+ return Object.assign(subscribed.finally(onfinally), {
171
+ unsubscribe,
172
+ });
173
+ }
174
+ /** Unpromise STATIC METHODS */
175
+ /** Create or Retrieve the proxy Unpromise (a re-used Unpromise for the VM lifetime
176
+ * of the provided Promise reference) */
177
+ static proxy(promise) {
178
+ const cached = Unpromise.getSubscribablePromise(promise);
179
+ return typeof cached !== "undefined"
180
+ ? cached
181
+ : Unpromise.createSubscribablePromise(promise);
182
+ }
183
+ /** Create and store an Unpromise keyed by an original Promise. */
184
+ static createSubscribablePromise(promise) {
185
+ const created = new Unpromise(promise);
186
+ subscribableCache.set(promise, created); // resolve promise to unpromise
187
+ subscribableCache.set(created, created); // resolve the unpromise to itself
188
+ return created;
189
+ }
190
+ /** Retrieve a previously-created Unpromise keyed by an original Promise. */
191
+ static getSubscribablePromise(promise) {
192
+ return subscribableCache.get(promise);
193
+ }
194
+ /** Promise STATIC METHODS */
195
+ /** Lookup the Unpromise for this promise, and derive a SubscribedPromise from
196
+ * it (that can be later unsubscribed to eliminate Memory leaks) */
197
+ static resolve(value) {
198
+ const promise = typeof value === "object" &&
199
+ value !== null &&
200
+ "then" in value &&
201
+ typeof value.then === "function"
202
+ ? value
203
+ : Promise.resolve(value);
204
+ return Unpromise.proxy(promise).subscribe();
205
+ }
206
+ static async any(values) {
207
+ const valuesArray = Array.isArray(values) ? values : [...values];
208
+ const subscribedPromises = valuesArray.map(Unpromise.resolve);
209
+ try {
210
+ return await Promise.any(subscribedPromises);
211
+ }
212
+ finally {
213
+ subscribedPromises.forEach(({ unsubscribe }) => {
214
+ unsubscribe();
215
+ });
216
+ }
217
+ }
218
+ static async race(values) {
219
+ const valuesArray = Array.isArray(values) ? values : [...values];
220
+ const subscribedPromises = valuesArray.map(Unpromise.resolve);
221
+ try {
222
+ return await Promise.race(subscribedPromises);
223
+ }
224
+ finally {
225
+ subscribedPromises.forEach(({ unsubscribe }) => {
226
+ unsubscribe();
227
+ });
228
+ }
229
+ }
230
+ /** Create a race of SubscribedPromises that will fulfil to a single winning
231
+ * Promise (in a 1-Tuple). Eliminates memory leaks from long-lived promises
232
+ * accumulating .then() and .catch() subscribers. Allows simple logic to
233
+ * consume the result, like...
234
+ * ```ts
235
+ * const [ winner ] = await Unpromise.race([ promiseA, promiseB ]);
236
+ * if(winner === promiseB){
237
+ * const result = await promiseB;
238
+ * // do the thing
239
+ * }
240
+ * ```
241
+ * */
242
+ static async raceReferences(promises) {
243
+ // map each promise to an eventual 1-tuple containing itself
244
+ const selfPromises = promises.map(resolveSelfTuple);
245
+ // now race them. They will fulfil to a readonly [P] or reject.
246
+ try {
247
+ return await Promise.race(selfPromises);
248
+ }
249
+ finally {
250
+ for (const promise of selfPromises) {
251
+ // unsubscribe proxy promises when the race is over to mitigate memory leaks
252
+ promise.unsubscribe();
253
+ }
254
+ }
255
+ }
256
+ }
257
+ _a = Symbol.toStringTag;
258
+ /** Promises a 1-tuple containing the original promise when it resolves. Allows
259
+ * awaiting the eventual Promise ***reference*** (easy to destructure and
260
+ * exactly compare with ===). Avoids resolving to the Promise ***value*** (which
261
+ * may be ambiguous and therefore hard to identify as the winner of a race).
262
+ * You can call unsubscribe on the Promise to mitigate memory leaks.
263
+ * */
264
+ function resolveSelfTuple(promise) {
265
+ return Unpromise.proxy(promise).then(() => [promise]);
266
+ }
267
+ /** VENDORED (Future) PROMISE UTILITIES */
268
+ /** Reference implementation of https://github.com/tc39/proposal-promise-with-resolvers */
269
+ function withResolvers() {
270
+ let resolve;
271
+ let reject;
272
+ const promise = new Promise((_resolve, _reject) => {
273
+ resolve = _resolve;
274
+ reject = _reject;
275
+ });
276
+ return {
277
+ promise,
278
+ resolve,
279
+ reject,
280
+ };
281
+ }
282
+ /** IMMUTABLE LIST OPERATIONS */
283
+ function listWithMember(arr, member) {
284
+ return [...arr, member];
285
+ }
286
+ function listWithoutIndex(arr, index) {
287
+ return [...arr.slice(0, index), ...arr.slice(index + 1)];
288
+ }
289
+ function listWithoutMember(arr, member) {
290
+ const index = arr.indexOf(member);
291
+ if (index !== -1) {
292
+ return listWithoutIndex(arr, index);
293
+ }
294
+ return arr;
295
+ }
296
+
297
+ exports.Unpromise = Unpromise;
298
+ exports.resolveSelfTuple = resolveSelfTuple;
package/js/ccxt.d.ts CHANGED
@@ -4,7 +4,7 @@ import * as functions from './src/base/functions.js';
4
4
  import * as errors from './src/base/errors.js';
5
5
  import type { Int, int, Str, Strings, Num, Bool, IndexType, OrderSide, OrderType, MarketType, SubType, Dict, NullableDict, List, NullableList, Fee, OHLCV, OHLCVC, implicitReturnType, Market, Currency, Dictionary, MinMax, FeeInterface, TradingFeeInterface, MarketInterface, Trade, Order, OrderBook, Ticker, Transaction, Tickers, CurrencyInterface, Balance, BalanceAccount, Account, PartialBalances, Balances, DepositAddress, WithdrawalResponse, DepositAddressResponse, FundingRate, FundingRates, Position, BorrowInterest, LeverageTier, LedgerEntry, DepositWithdrawFeeNetwork, DepositWithdrawFee, TransferEntry, CrossBorrowRate, IsolatedBorrowRate, FundingRateHistory, OpenInterest, Liquidation, OrderRequest, CancellationRequest, FundingHistory, MarketMarginModes, MarginMode, Greeks, Conversion, Option, LastPrice, Leverage, MarginModification, Leverages, LastPrices, Currencies, TradingFees, MarginModes, OptionChain, IsolatedBorrowRates, CrossBorrowRates, LeverageTiers } from './src/base/types.js';
6
6
  import { BaseError, ExchangeError, AuthenticationError, PermissionDenied, AccountNotEnabled, AccountSuspended, ArgumentsRequired, BadRequest, BadSymbol, OperationRejected, NoChange, MarginModeAlreadySet, MarketClosed, ManualInteractionNeeded, InsufficientFunds, InvalidAddress, AddressPending, InvalidOrder, OrderNotFound, OrderNotCached, OrderImmediatelyFillable, OrderNotFillable, DuplicateOrderId, ContractUnavailable, NotSupported, InvalidProxySettings, ExchangeClosedByUser, OperationFailed, NetworkError, DDoSProtection, RateLimitExceeded, ExchangeNotAvailable, OnMaintenance, InvalidNonce, ChecksumError, RequestTimeout, BadResponse, NullResponse, CancelPending, UnsubscribeError } from './src/base/errors.js';
7
- declare const version = "4.4.18";
7
+ declare const version = "4.4.20";
8
8
  import ace from './src/ace.js';
9
9
  import alpaca from './src/alpaca.js';
10
10
  import ascendex from './src/ascendex.js';
@@ -138,6 +138,7 @@ import blofinPro from './src/pro/blofin.js';
138
138
  import bybitPro from './src/pro/bybit.js';
139
139
  import cexPro from './src/pro/cex.js';
140
140
  import coinbasePro from './src/pro/coinbase.js';
141
+ import coinbaseadvancedPro from './src/pro/coinbaseadvanced.js';
141
142
  import coinbaseexchangePro from './src/pro/coinbaseexchange.js';
142
143
  import coinbaseinternationalPro from './src/pro/coinbaseinternational.js';
143
144
  import coincheckPro from './src/pro/coincheck.js';
@@ -320,6 +321,7 @@ declare const pro: {
320
321
  bybit: typeof bybitPro;
321
322
  cex: typeof cexPro;
322
323
  coinbase: typeof coinbasePro;
324
+ coinbaseadvanced: typeof coinbaseadvancedPro;
323
325
  coinbaseexchange: typeof coinbaseexchangePro;
324
326
  coinbaseinternational: typeof coinbaseinternationalPro;
325
327
  coincheck: typeof coincheckPro;
@@ -398,6 +400,7 @@ declare const ccxt: {
398
400
  bybit: typeof bybitPro;
399
401
  cex: typeof cexPro;
400
402
  coinbase: typeof coinbasePro;
403
+ coinbaseadvanced: typeof coinbaseadvancedPro;
401
404
  coinbaseexchange: typeof coinbaseexchangePro;
402
405
  coinbaseinternational: typeof coinbaseinternationalPro;
403
406
  coincheck: typeof coincheckPro;
package/js/ccxt.js CHANGED
@@ -38,7 +38,7 @@ import * as errors from './src/base/errors.js';
38
38
  import { BaseError, ExchangeError, AuthenticationError, PermissionDenied, AccountNotEnabled, AccountSuspended, ArgumentsRequired, BadRequest, BadSymbol, OperationRejected, NoChange, MarginModeAlreadySet, MarketClosed, ManualInteractionNeeded, InsufficientFunds, InvalidAddress, AddressPending, InvalidOrder, OrderNotFound, OrderNotCached, OrderImmediatelyFillable, OrderNotFillable, DuplicateOrderId, ContractUnavailable, NotSupported, InvalidProxySettings, ExchangeClosedByUser, OperationFailed, NetworkError, DDoSProtection, RateLimitExceeded, ExchangeNotAvailable, OnMaintenance, InvalidNonce, ChecksumError, RequestTimeout, BadResponse, NullResponse, CancelPending, UnsubscribeError } from './src/base/errors.js';
39
39
  //-----------------------------------------------------------------------------
40
40
  // this is updated by vss.js when building
41
- const version = '4.4.19';
41
+ const version = '4.4.21';
42
42
  Exchange.ccxtVersion = version;
43
43
  //-----------------------------------------------------------------------------
44
44
  import ace from './src/ace.js';
@@ -175,6 +175,7 @@ import blofinPro from './src/pro/blofin.js';
175
175
  import bybitPro from './src/pro/bybit.js';
176
176
  import cexPro from './src/pro/cex.js';
177
177
  import coinbasePro from './src/pro/coinbase.js';
178
+ import coinbaseadvancedPro from './src/pro/coinbaseadvanced.js';
178
179
  import coinbaseexchangePro from './src/pro/coinbaseexchange.js';
179
180
  import coinbaseinternationalPro from './src/pro/coinbaseinternational.js';
180
181
  import coincheckPro from './src/pro/coincheck.js';
@@ -357,6 +358,7 @@ const pro = {
357
358
  'bybit': bybitPro,
358
359
  'cex': cexPro,
359
360
  'coinbase': coinbasePro,
361
+ 'coinbaseadvanced': coinbaseadvancedPro,
360
362
  'coinbaseexchange': coinbaseexchangePro,
361
363
  'coinbaseinternational': coinbaseinternationalPro,
362
364
  'coincheck': coincheckPro,
@@ -162,6 +162,7 @@ interface Exchange {
162
162
  privateGetV5UserDelSubmember(params?: {}): Promise<implicitReturnType>;
163
163
  privateGetV5UserSubmembers(params?: {}): Promise<implicitReturnType>;
164
164
  privateGetV5SpotLeverTokenOrderRecord(params?: {}): Promise<implicitReturnType>;
165
+ privateGetV5SpotMarginTradeInterestRateHistory(params?: {}): Promise<implicitReturnType>;
165
166
  privateGetV5SpotMarginTradeState(params?: {}): Promise<implicitReturnType>;
166
167
  privateGetV5SpotCrossMarginTradeLoanInfo(params?: {}): Promise<implicitReturnType>;
167
168
  privateGetV5SpotCrossMarginTradeAccount(params?: {}): Promise<implicitReturnType>;
@@ -19,6 +19,7 @@ interface Exchange {
19
19
  publicGetMarkPriceSymbolCurrent(params?: {}): Promise<implicitReturnType>;
20
20
  publicGetMarkPriceAllSymbols(params?: {}): Promise<implicitReturnType>;
21
21
  publicGetMarginConfig(params?: {}): Promise<implicitReturnType>;
22
+ publicGetAnnouncements(params?: {}): Promise<implicitReturnType>;
22
23
  publicPostBulletPublic(params?: {}): Promise<implicitReturnType>;
23
24
  privateGetUserInfo(params?: {}): Promise<implicitReturnType>;
24
25
  privateGetAccounts(params?: {}): Promise<implicitReturnType>;
@@ -19,6 +19,7 @@ interface kucoin {
19
19
  publicGetMarkPriceSymbolCurrent(params?: {}): Promise<implicitReturnType>;
20
20
  publicGetMarkPriceAllSymbols(params?: {}): Promise<implicitReturnType>;
21
21
  publicGetMarginConfig(params?: {}): Promise<implicitReturnType>;
22
+ publicGetAnnouncements(params?: {}): Promise<implicitReturnType>;
22
23
  publicPostBulletPublic(params?: {}): Promise<implicitReturnType>;
23
24
  privateGetUserInfo(params?: {}): Promise<implicitReturnType>;
24
25
  privateGetAccounts(params?: {}): Promise<implicitReturnType>;
@@ -152,6 +152,9 @@ interface Exchange {
152
152
  privateGetAccountFixedLoanBorrowingLimit(params?: {}): Promise<implicitReturnType>;
153
153
  privateGetAccountFixedLoanBorrowingQuote(params?: {}): Promise<implicitReturnType>;
154
154
  privateGetAccountFixedLoanBorrowingOrdersList(params?: {}): Promise<implicitReturnType>;
155
+ privateGetAccountSpotManualBorrowRepay(params?: {}): Promise<implicitReturnType>;
156
+ privateGetAccountSetAutoRepay(params?: {}): Promise<implicitReturnType>;
157
+ privateGetAccountSpotBorrowRepayHistory(params?: {}): Promise<implicitReturnType>;
155
158
  privateGetUsersSubaccountList(params?: {}): Promise<implicitReturnType>;
156
159
  privateGetAccountSubaccountBalances(params?: {}): Promise<implicitReturnType>;
157
160
  privateGetAssetSubaccountBalances(params?: {}): Promise<implicitReturnType>;
@@ -366,7 +366,7 @@ export default class Exchange {
366
366
  getProperty(obj: any, property: any, defaultValue?: any): any;
367
367
  setProperty(obj: any, property: any, defaultValue?: any): void;
368
368
  axolotl(payload: any, hexKey: any, ed25519: any): string;
369
- fixStringifiedJsonMembers(content: string): any;
369
+ fixStringifiedJsonMembers(content: string): string;
370
370
  ethAbiEncode(types: any, args: any): Uint8Array;
371
371
  ethEncodeStructuredData(domain: any, messageTypes: any, messageData: any): Uint8Array;
372
372
  retrieveStarkAccount(signature: any, accountClassHash: any, accountProxyClassHash: any): {
@@ -1094,6 +1094,8 @@ export default class Exchange {
1094
1094
  parseTickers(tickers: any, symbols?: Strings, params?: {}): Tickers;
1095
1095
  parseDepositAddresses(addresses: any, codes?: Strings, indexed?: boolean, params?: {}): DepositAddress[];
1096
1096
  parseBorrowInterests(response: any, market?: Market): any[];
1097
+ parseBorrowRate(info: any, currency?: Currency): Dict;
1098
+ parseBorrowRateHistory(response: any, code: Str, since: Int, limit: Int): any;
1097
1099
  parseIsolatedBorrowRates(info: any): IsolatedBorrowRates;
1098
1100
  parseFundingRateHistories(response: any, market?: any, since?: Int, limit?: Int): FundingRateHistory[];
1099
1101
  safeSymbol(marketId: Str, market?: Market, delimiter?: Str, marketType?: Str): string;
@@ -5507,6 +5507,19 @@ export default class Exchange {
5507
5507
  }
5508
5508
  return interests;
5509
5509
  }
5510
+ parseBorrowRate(info, currency = undefined) {
5511
+ throw new NotSupported(this.id + ' parseBorrowRate() is not supported yet');
5512
+ }
5513
+ parseBorrowRateHistory(response, code, since, limit) {
5514
+ const result = [];
5515
+ for (let i = 0; i < response.length; i++) {
5516
+ const item = response[i];
5517
+ const borrowRate = this.parseBorrowRate(item);
5518
+ result.push(borrowRate);
5519
+ }
5520
+ const sorted = this.sortBy(result, 'timestamp');
5521
+ return this.filterByCurrencySinceLimit(sorted, code, since, limit);
5522
+ }
5510
5523
  parseIsolatedBorrowRates(info) {
5511
5524
  const result = {};
5512
5525
  for (let i = 0; i < info.length; i++) {
@@ -6148,6 +6161,8 @@ export default class Exchange {
6148
6161
  let i = 0;
6149
6162
  let errors = 0;
6150
6163
  let result = [];
6164
+ const timeframe = this.safeString(params, 'timeframe');
6165
+ params = this.omit(params, 'timeframe'); // reading the timeframe from the method arguments to avoid changing the signature
6151
6166
  while (i < maxCalls) {
6152
6167
  try {
6153
6168
  if (cursorValue !== undefined) {
@@ -6163,6 +6178,9 @@ export default class Exchange {
6163
6178
  else if (method === 'getLeverageTiersPaginated' || method === 'fetchPositions') {
6164
6179
  response = await this[method](symbol, params);
6165
6180
  }
6181
+ else if (method === 'fetchOpenInterestHistory') {
6182
+ response = await this[method](symbol, timeframe, since, maxEntriesPerRequest, params);
6183
+ }
6166
6184
  else {
6167
6185
  response = await this[method](symbol, since, maxEntriesPerRequest, params);
6168
6186
  }
@@ -5,6 +5,7 @@
5
5
  // EDIT THE CORRESPONDENT .ts FILE INSTEAD
6
6
 
7
7
  // @ts-nocheck
8
+ import { Unpromise } from "../../static_dependencies/watchable/src/unpromise.js";
8
9
  export function Future() {
9
10
  let resolve = undefined, reject = undefined;
10
11
  const p = new Promise((resolve_, reject_) => {
@@ -31,4 +32,4 @@ function wrapFuture(aggregatePromise) {
31
32
  aggregatePromise.then(p.resolve, p.reject);
32
33
  return p;
33
34
  }
34
- Future.race = (futures) => wrapFuture(Promise.race(futures));
35
+ Future.race = (futures) => wrapFuture(Unpromise.race(futures));
@@ -229,7 +229,6 @@ export default class binance extends Exchange {
229
229
  fetchIsolatedBorrowRate(symbol: string, params?: {}): Promise<IsolatedBorrowRate>;
230
230
  fetchIsolatedBorrowRates(params?: {}): Promise<IsolatedBorrowRates>;
231
231
  fetchBorrowRateHistory(code: string, since?: Int, limit?: Int, params?: {}): Promise<any>;
232
- parseBorrowRateHistory(response: any, code: any, since: any, limit: any): any;
233
232
  parseBorrowRate(info: any, currency?: Currency): {
234
233
  currency: string;
235
234
  rate: number;
package/js/src/binance.js CHANGED
@@ -12118,16 +12118,6 @@ export default class binance extends Exchange {
12118
12118
  //
12119
12119
  return this.parseBorrowRateHistory(response, code, since, limit);
12120
12120
  }
12121
- parseBorrowRateHistory(response, code, since, limit) {
12122
- const result = [];
12123
- for (let i = 0; i < response.length; i++) {
12124
- const item = response[i];
12125
- const borrowRate = this.parseBorrowRate(item);
12126
- result.push(borrowRate);
12127
- }
12128
- const sorted = this.sortBy(result, 'timestamp');
12129
- return this.filterByCurrencySinceLimit(sorted, code, since, limit);
12130
- }
12131
12121
  parseBorrowRate(info, currency = undefined) {
12132
12122
  //
12133
12123
  // {
package/js/src/bingx.js CHANGED
@@ -5319,7 +5319,7 @@ export default class bingx extends Exchange {
5319
5319
  * @method
5320
5320
  * @name bingx#withdraw
5321
5321
  * @description make a withdrawal
5322
- * @see https://bingx-api.github.io/docs/#/common/account-api.html#Withdraw
5322
+ * @see https://bingx-api.github.io/docs/#/en-us/spot/wallet-api.html#Withdraw
5323
5323
  * @param {string} code unified currency code
5324
5324
  * @param {float} amount the amount to withdraw
5325
5325
  * @param {string} address the address to withdraw to
@@ -5328,6 +5328,8 @@ export default class bingx extends Exchange {
5328
5328
  * @param {int} [params.walletType] 1 fund account, 2 standard account, 3 perpetual account
5329
5329
  * @returns {object} a [transaction structure]{@link https://docs.ccxt.com/#/?id=transaction-structure}
5330
5330
  */
5331
+ [tag, params] = this.handleWithdrawTagAndParams(tag, params);
5332
+ this.checkAddress(address);
5331
5333
  await this.loadMarkets();
5332
5334
  const currency = this.currency(code);
5333
5335
  let walletType = this.safeInteger(params, 'walletType');
@@ -5347,6 +5349,9 @@ export default class bingx extends Exchange {
5347
5349
  if (network !== undefined) {
5348
5350
  request['network'] = this.networkCodeToId(network);
5349
5351
  }
5352
+ if (tag !== undefined) {
5353
+ request['addressTag'] = tag;
5354
+ }
5350
5355
  params = this.omit(params, ['walletType', 'network']);
5351
5356
  const response = await this.walletsV1PrivatePostCapitalWithdrawApply(this.extend(request, params));
5352
5357
  const data = this.safeValue(response, 'data');
package/js/src/bybit.d.ts CHANGED
@@ -106,6 +106,7 @@ export default class bybit extends Exchange {
106
106
  info: any;
107
107
  };
108
108
  fetchBorrowInterest(code?: Str, symbol?: Str, since?: Int, limit?: Int, params?: {}): Promise<any>;
109
+ fetchBorrowRateHistory(code: string, since?: Int, limit?: Int, params?: {}): Promise<any>;
109
110
  parseBorrowInterest(info: Dict, market?: Market): {
110
111
  symbol: any;
111
112
  marginMode: string;
package/js/src/bybit.js CHANGED
@@ -371,6 +371,7 @@ export default class bybit extends Exchange {
371
371
  // spot leverage token
372
372
  'v5/spot-lever-token/order-record': 1,
373
373
  // spot margin trade
374
+ 'v5/spot-margin-trade/interest-rate-history': 5,
374
375
  'v5/spot-margin-trade/state': 5,
375
376
  'v5/spot-cross-margin-trade/loan-info': 1,
376
377
  'v5/spot-cross-margin-trade/account': 1,
@@ -7242,7 +7243,8 @@ export default class bybit extends Exchange {
7242
7243
  const paginate = this.safeBool(params, 'paginate');
7243
7244
  if (paginate) {
7244
7245
  params = this.omit(params, 'paginate');
7245
- return await this.fetchPaginatedCallDeterministic('fetchOpenInterestHistory', symbol, since, limit, timeframe, params, 500);
7246
+ params['timeframe'] = timeframe;
7247
+ return await this.fetchPaginatedCallCursor('fetchOpenInterestHistory', symbol, since, limit, params, 'nextPageCursor', 'cursor', undefined, 200);
7246
7248
  }
7247
7249
  const market = this.market(symbol);
7248
7250
  if (market['spot'] || market['option']) {
@@ -7319,12 +7321,22 @@ export default class bybit extends Exchange {
7319
7321
  // "timestamp": 1666734490778
7320
7322
  // }
7321
7323
  //
7324
+ // fetchBorrowRateHistory
7325
+ // {
7326
+ // "timestamp": 1721469600000,
7327
+ // "currency": "USDC",
7328
+ // "hourlyBorrowRate": "0.000014621596",
7329
+ // "vipLevel": "No VIP"
7330
+ // }
7331
+ //
7322
7332
  const timestamp = this.safeInteger(info, 'timestamp');
7323
- const currencyId = this.safeString(info, 'coin');
7333
+ const currencyId = this.safeString2(info, 'coin', 'currency');
7334
+ const hourlyBorrowRate = this.safeNumber(info, 'hourlyBorrowRate');
7335
+ const period = (hourlyBorrowRate !== undefined) ? 3600000 : 86400000; // 1h or 1d
7324
7336
  return {
7325
7337
  'currency': this.safeCurrencyCode(currencyId, currency),
7326
- 'rate': this.safeNumber(info, 'interestRate'),
7327
- 'period': 86400000,
7338
+ 'rate': this.safeNumber(info, 'interestRate', hourlyBorrowRate),
7339
+ 'period': period,
7328
7340
  'timestamp': timestamp,
7329
7341
  'datetime': this.iso8601(timestamp),
7330
7342
  'info': info,
@@ -7376,6 +7388,57 @@ export default class bybit extends Exchange {
7376
7388
  const interest = this.parseBorrowInterests(rows, undefined);
7377
7389
  return this.filterByCurrencySinceLimit(interest, code, since, limit);
7378
7390
  }
7391
+ async fetchBorrowRateHistory(code, since = undefined, limit = undefined, params = {}) {
7392
+ /**
7393
+ * @method
7394
+ * @name bybit#fetchBorrowRateHistory
7395
+ * @description retrieves a history of a currencies borrow interest rate at specific time slots
7396
+ * @see https://bybit-exchange.github.io/docs/v5/spot-margin-uta/historical-interest
7397
+ * @param {string} code unified currency code
7398
+ * @param {int} [since] timestamp for the earliest borrow rate
7399
+ * @param {int} [limit] the maximum number of [borrow rate structures]{@link https://docs.ccxt.com/#/?id=borrow-rate-structure} to retrieve
7400
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
7401
+ * @param {int} [params.until] the latest time in ms to fetch entries for
7402
+ * @returns {object[]} an array of [borrow rate structures]{@link https://docs.ccxt.com/#/?id=borrow-rate-structure}
7403
+ */
7404
+ await this.loadMarkets();
7405
+ const currency = this.currency(code);
7406
+ const request = {
7407
+ 'currency': currency['id'],
7408
+ };
7409
+ if (since === undefined) {
7410
+ since = this.milliseconds() - 86400000 * 30; // last 30 days
7411
+ }
7412
+ request['startTime'] = since;
7413
+ let endTime = this.safeInteger2(params, 'until', 'endTime');
7414
+ params = this.omit(params, ['until']);
7415
+ if (endTime === undefined) {
7416
+ endTime = since + 86400000 * 30; // since + 30 days
7417
+ }
7418
+ request['endTime'] = endTime;
7419
+ const response = await this.privateGetV5SpotMarginTradeInterestRateHistory(this.extend(request, params));
7420
+ //
7421
+ // {
7422
+ // "retCode": 0,
7423
+ // "retMsg": "OK",
7424
+ // "result": {
7425
+ // "list": [
7426
+ // {
7427
+ // "timestamp": 1721469600000,
7428
+ // "currency": "USDC",
7429
+ // "hourlyBorrowRate": "0.000014621596",
7430
+ // "vipLevel": "No VIP"
7431
+ // }
7432
+ // ]
7433
+ // },
7434
+ // "retExtInfo": "{}",
7435
+ // "time": 1721899048991
7436
+ // }
7437
+ //
7438
+ const data = this.safeDict(response, 'result');
7439
+ const rows = this.safeList(data, 'list', []);
7440
+ return this.parseBorrowRateHistory(rows, code, since, limit);
7441
+ }
7379
7442
  parseBorrowInterest(info, market = undefined) {
7380
7443
  //
7381
7444
  // {
package/js/src/gate.js CHANGED
@@ -4737,6 +4737,7 @@ export default class gate extends Exchange {
4737
4737
  * @name gate#fetchOpenOrders
4738
4738
  * @description fetch all unfilled currently open orders
4739
4739
  * @see https://www.gate.io/docs/developers/apiv4/en/#list-all-open-orders
4740
+ * @see https://www.gate.io/docs/developers/apiv4/en/#retrieve-running-auto-order-list
4740
4741
  * @param {string} symbol unified market symbol
4741
4742
  * @param {int} [since] the earliest time in ms to fetch open orders for
4742
4743
  * @param {int} [limit] the maximum number of open orders structures to retrieve