ccxt 4.4.20 → 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.
- package/README.md +3 -3
- package/dist/ccxt.browser.min.js +4 -4
- package/dist/cjs/ccxt.js +1 -1
- package/dist/cjs/src/base/Exchange.js +13 -0
- package/dist/cjs/src/base/ws/Future.js +3 -1
- package/dist/cjs/src/binance.js +0 -10
- package/dist/cjs/src/bingx.js +6 -1
- package/dist/cjs/src/bybit.js +65 -3
- package/dist/cjs/src/htx.js +28 -0
- package/dist/cjs/src/hyperliquid.js +7 -6
- package/dist/cjs/src/kucoin.js +16 -36
- package/dist/cjs/src/kucoinfutures.js +2 -2
- package/dist/cjs/src/okx.js +8 -10
- package/dist/cjs/src/paradex.js +1 -2
- package/dist/cjs/src/static_dependencies/noble-hashes/_sha2.js +1 -1
- package/dist/cjs/src/static_dependencies/noble-hashes/hmac.js +1 -1
- package/dist/cjs/src/static_dependencies/noble-hashes/sha3.js +1 -1
- package/dist/cjs/src/static_dependencies/watchable/src/unpromise.js +298 -0
- package/js/ccxt.d.ts +1 -1
- package/js/ccxt.js +1 -1
- package/js/src/abstract/bybit.d.ts +1 -0
- package/js/src/abstract/kucoin.d.ts +1 -0
- package/js/src/abstract/kucoinfutures.d.ts +1 -0
- package/js/src/abstract/okx.d.ts +3 -0
- package/js/src/base/Exchange.d.ts +3 -1
- package/js/src/base/Exchange.js +13 -0
- package/js/src/base/ws/Future.js +2 -1
- package/js/src/binance.d.ts +0 -1
- package/js/src/binance.js +0 -10
- package/js/src/bingx.js +6 -1
- package/js/src/bybit.d.ts +1 -0
- package/js/src/bybit.js +65 -3
- package/js/src/htx.d.ts +2 -2
- package/js/src/htx.js +28 -0
- package/js/src/hyperliquid.js +7 -6
- package/js/src/kucoin.d.ts +0 -1
- package/js/src/kucoin.js +16 -36
- package/js/src/kucoinfutures.js +2 -2
- package/js/src/okx.d.ts +0 -1
- package/js/src/okx.js +9 -11
- package/js/src/paradex.js +1 -1
- package/js/src/static_dependencies/noble-hashes/_blake2.js +1 -1
- package/js/src/static_dependencies/noble-hashes/_sha2.js +1 -1
- package/js/src/static_dependencies/noble-hashes/hmac.js +1 -1
- package/js/src/static_dependencies/noble-hashes/sha3-addons.js +5 -5
- package/js/src/static_dependencies/noble-hashes/sha3.js +1 -1
- package/js/src/static_dependencies/watchable/src/index.d.ts +2 -0
- package/js/src/static_dependencies/watchable/src/index.js +7 -0
- package/js/src/static_dependencies/watchable/src/types.d.ts +28 -0
- package/js/src/static_dependencies/watchable/src/types.js +8 -0
- package/js/src/static_dependencies/watchable/src/unpromise.d.ts +120 -0
- package/js/src/static_dependencies/watchable/src/unpromise.js +297 -0
- package/package.json +1 -1
|
@@ -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.
|
|
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';
|
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.
|
|
41
|
+
const version = '4.4.21';
|
|
42
42
|
Exchange.ccxtVersion = version;
|
|
43
43
|
//-----------------------------------------------------------------------------
|
|
44
44
|
import ace from './src/ace.js';
|
|
@@ -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>;
|
package/js/src/abstract/okx.d.ts
CHANGED
|
@@ -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):
|
|
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;
|
package/js/src/base/Exchange.js
CHANGED
|
@@ -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++) {
|
package/js/src/base/ws/Future.js
CHANGED
|
@@ -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(
|
|
35
|
+
Future.race = (futures) => wrapFuture(Unpromise.race(futures));
|
package/js/src/binance.d.ts
CHANGED
|
@@ -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/#/
|
|
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,
|
|
@@ -7320,12 +7321,22 @@ export default class bybit extends Exchange {
|
|
|
7320
7321
|
// "timestamp": 1666734490778
|
|
7321
7322
|
// }
|
|
7322
7323
|
//
|
|
7324
|
+
// fetchBorrowRateHistory
|
|
7325
|
+
// {
|
|
7326
|
+
// "timestamp": 1721469600000,
|
|
7327
|
+
// "currency": "USDC",
|
|
7328
|
+
// "hourlyBorrowRate": "0.000014621596",
|
|
7329
|
+
// "vipLevel": "No VIP"
|
|
7330
|
+
// }
|
|
7331
|
+
//
|
|
7323
7332
|
const timestamp = this.safeInteger(info, 'timestamp');
|
|
7324
|
-
const currencyId = this.
|
|
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
|
|
7325
7336
|
return {
|
|
7326
7337
|
'currency': this.safeCurrencyCode(currencyId, currency),
|
|
7327
|
-
'rate': this.safeNumber(info, 'interestRate'),
|
|
7328
|
-
'period':
|
|
7338
|
+
'rate': this.safeNumber(info, 'interestRate', hourlyBorrowRate),
|
|
7339
|
+
'period': period,
|
|
7329
7340
|
'timestamp': timestamp,
|
|
7330
7341
|
'datetime': this.iso8601(timestamp),
|
|
7331
7342
|
'info': info,
|
|
@@ -7377,6 +7388,57 @@ export default class bybit extends Exchange {
|
|
|
7377
7388
|
const interest = this.parseBorrowInterests(rows, undefined);
|
|
7378
7389
|
return this.filterByCurrencySinceLimit(interest, code, since, limit);
|
|
7379
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
|
+
}
|
|
7380
7442
|
parseBorrowInterest(info, market = undefined) {
|
|
7381
7443
|
//
|
|
7382
7444
|
// {
|
package/js/src/htx.d.ts
CHANGED
|
@@ -37,7 +37,7 @@ export default class htx extends Exchange {
|
|
|
37
37
|
};
|
|
38
38
|
costToPrecision(symbol: any, cost: any): string;
|
|
39
39
|
fetchMarkets(params?: {}): Promise<Market[]>;
|
|
40
|
-
fetchMarketsByTypeAndSubType(type:
|
|
40
|
+
fetchMarketsByTypeAndSubType(type: Str, subType: Str, params?: {}): Promise<any[]>;
|
|
41
41
|
tryGetSymbolFromFutureMarkets(symbolOrMarketId: string): any;
|
|
42
42
|
parseTicker(ticker: Dict, market?: Market): Ticker;
|
|
43
43
|
fetchTicker(symbol: string, params?: {}): Promise<Ticker>;
|
|
@@ -66,7 +66,7 @@ export default class htx extends Exchange {
|
|
|
66
66
|
type: any;
|
|
67
67
|
code: any;
|
|
68
68
|
};
|
|
69
|
-
fetchAccountIdByType(type:
|
|
69
|
+
fetchAccountIdByType(type: string, marginMode?: Str, symbol?: Str, params?: {}): Promise<any>;
|
|
70
70
|
fetchCurrencies(params?: {}): Promise<Currencies>;
|
|
71
71
|
networkIdToCode(networkId?: Str, currencyCode?: Str): string;
|
|
72
72
|
networkCodeToId(networkCode: string, currencyCode?: Str): any;
|
package/js/src/htx.js
CHANGED
|
@@ -1639,6 +1639,10 @@ export default class htx extends Exchange {
|
|
|
1639
1639
|
* @method
|
|
1640
1640
|
* @name htx#fetchMarkets
|
|
1641
1641
|
* @description retrieves data on all markets for huobi
|
|
1642
|
+
* @see https://huobiapi.github.io/docs/spot/v1/en/#get-all-supported-trading-symbol-v1-deprecated
|
|
1643
|
+
* @see https://huobiapi.github.io/docs/dm/v1/en/#get-contract-info
|
|
1644
|
+
* @see https://huobiapi.github.io/docs/coin_margined_swap/v1/en/#query-swap-info
|
|
1645
|
+
* @see https://huobiapi.github.io/docs/usdt_swap/v1/en/#general-query-swap-info
|
|
1642
1646
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
1643
1647
|
* @returns {object[]} an array of objects representing market data
|
|
1644
1648
|
*/
|
|
@@ -1669,6 +1673,20 @@ export default class htx extends Exchange {
|
|
|
1669
1673
|
return allMarkets;
|
|
1670
1674
|
}
|
|
1671
1675
|
async fetchMarketsByTypeAndSubType(type, subType, params = {}) {
|
|
1676
|
+
/**
|
|
1677
|
+
* @ignore
|
|
1678
|
+
* @method
|
|
1679
|
+
* @name htx#fetchMarketsByTypeAndSubType
|
|
1680
|
+
* @description retrieves data on all markets of a certain type and/or subtype
|
|
1681
|
+
* @see https://huobiapi.github.io/docs/spot/v1/en/#get-all-supported-trading-symbol-v1-deprecated
|
|
1682
|
+
* @see https://huobiapi.github.io/docs/dm/v1/en/#get-contract-info
|
|
1683
|
+
* @see https://huobiapi.github.io/docs/coin_margined_swap/v1/en/#query-swap-info
|
|
1684
|
+
* @see https://huobiapi.github.io/docs/usdt_swap/v1/en/#general-query-swap-info
|
|
1685
|
+
* @param {string} [type] 'spot', 'swap' or 'future'
|
|
1686
|
+
* @param {string} [subType] 'linear' or 'inverse'
|
|
1687
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
1688
|
+
* @returns {object[]} an array of objects representing market data
|
|
1689
|
+
*/
|
|
1672
1690
|
const isSpot = (type === 'spot');
|
|
1673
1691
|
const request = {};
|
|
1674
1692
|
let response = undefined;
|
|
@@ -3191,6 +3209,16 @@ export default class htx extends Exchange {
|
|
|
3191
3209
|
};
|
|
3192
3210
|
}
|
|
3193
3211
|
async fetchAccountIdByType(type, marginMode = undefined, symbol = undefined, params = {}) {
|
|
3212
|
+
/**
|
|
3213
|
+
* @method
|
|
3214
|
+
* @name htx#fetchAccountIdByType
|
|
3215
|
+
* @description fetch all the accounts by a type and marginModeassociated with a profile
|
|
3216
|
+
* @see https://huobiapi.github.io/docs/spot/v1/en/#get-all-accounts-of-the-current-user
|
|
3217
|
+
* @param {string} type 'spot', 'swap' or 'future
|
|
3218
|
+
* @param {string} [marginMode] 'cross' or 'isolated'
|
|
3219
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
3220
|
+
* @returns {object} a dictionary of [account structures]{@link https://docs.ccxt.com/#/?id=account-structure} indexed by the account type
|
|
3221
|
+
*/
|
|
3194
3222
|
const accounts = await this.loadAccounts();
|
|
3195
3223
|
const accountId = this.safeValue2(params, 'accountId', 'account-id');
|
|
3196
3224
|
if (accountId !== undefined) {
|