ccxt 4.2.86 → 4.2.87
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/build.sh +1 -1
- package/dist/ccxt.browser.js +671 -130
- package/dist/ccxt.browser.min.js +3 -3
- package/dist/cjs/ccxt.js +1 -1
- package/dist/cjs/src/ascendex.js +11 -1
- package/dist/cjs/src/binance.js +14 -1
- package/dist/cjs/src/bingx.js +37 -1
- package/dist/cjs/src/bitfinex.js +3 -0
- package/dist/cjs/src/bitfinex2.js +16 -1
- package/dist/cjs/src/bitflyer.js +19 -0
- package/dist/cjs/src/bitget.js +15 -1
- package/dist/cjs/src/bitopro.js +3 -0
- package/dist/cjs/src/bitrue.js +13 -7
- package/dist/cjs/src/bitvavo.js +3 -0
- package/dist/cjs/src/btcmarkets.js +1 -1
- package/dist/cjs/src/btcturk.js +2 -1
- package/dist/cjs/src/coinex.js +182 -54
- package/dist/cjs/src/currencycom.js +1 -1
- package/dist/cjs/src/delta.js +3 -1
- package/dist/cjs/src/digifinex.js +4 -2
- package/dist/cjs/src/exmo.js +11 -12
- package/dist/cjs/src/gate.js +5 -2
- package/dist/cjs/src/hitbtc.js +26 -2
- package/dist/cjs/src/htx.js +2 -2
- package/dist/cjs/src/huobijp.js +1 -1
- package/dist/cjs/src/hyperliquid.js +249 -12
- package/dist/cjs/src/idex.js +1 -1
- package/dist/cjs/src/krakenfutures.js +2 -6
- package/dist/cjs/src/lbank.js +3 -0
- package/dist/cjs/src/oceanex.js +1 -1
- package/dist/cjs/src/okx.js +24 -10
- package/dist/cjs/src/phemex.js +3 -1
- package/dist/cjs/src/pro/kucoin.js +11 -6
- package/dist/cjs/src/wazirx.js +1 -1
- package/dist/cjs/src/zonda.js +3 -0
- package/examples/js/benchmark.js +104 -0
- package/examples/ts/benchmark.ts +134 -0
- package/js/ccxt.d.ts +1 -1
- package/js/ccxt.js +1 -1
- package/js/src/ascendex.d.ts +5 -12
- package/js/src/ascendex.js +11 -1
- package/js/src/base/Exchange.d.ts +4 -4
- package/js/src/base/types.d.ts +11 -0
- package/js/src/binance.d.ts +4 -11
- package/js/src/binance.js +14 -1
- package/js/src/bingx.d.ts +5 -2
- package/js/src/bingx.js +37 -1
- package/js/src/bitfinex.js +3 -0
- package/js/src/bitfinex2.d.ts +3 -17
- package/js/src/bitfinex2.js +16 -1
- package/js/src/bitflyer.d.ts +1 -0
- package/js/src/bitflyer.js +20 -1
- package/js/src/bitget.d.ts +5 -12
- package/js/src/bitget.js +15 -1
- package/js/src/bitopro.js +3 -0
- package/js/src/bitrue.d.ts +3 -17
- package/js/src/bitrue.js +13 -7
- package/js/src/bitvavo.js +3 -0
- package/js/src/btcmarkets.js +1 -1
- package/js/src/btcturk.js +2 -1
- package/js/src/coinex.d.ts +4 -11
- package/js/src/coinex.js +182 -54
- package/js/src/currencycom.js +1 -1
- package/js/src/delta.d.ts +5 -37
- package/js/src/delta.js +3 -1
- package/js/src/digifinex.d.ts +5 -13
- package/js/src/digifinex.js +4 -2
- package/js/src/exmo.d.ts +5 -37
- package/js/src/exmo.js +11 -12
- package/js/src/gate.d.ts +5 -33
- package/js/src/gate.js +5 -2
- package/js/src/hitbtc.d.ts +5 -12
- package/js/src/hitbtc.js +26 -2
- package/js/src/htx.js +2 -2
- package/js/src/huobijp.js +1 -1
- package/js/src/hyperliquid.d.ts +7 -4
- package/js/src/hyperliquid.js +249 -12
- package/js/src/idex.js +1 -1
- package/js/src/krakenfutures.js +2 -6
- package/js/src/kucoinfutures.d.ts +2 -2
- package/js/src/lbank.js +3 -0
- package/js/src/mexc.d.ts +3 -3
- package/js/src/oceanex.js +1 -1
- package/js/src/okx.d.ts +5 -33
- package/js/src/okx.js +24 -10
- package/js/src/phemex.d.ts +3 -11
- package/js/src/phemex.js +3 -1
- package/js/src/pro/kucoin.js +11 -6
- package/js/src/wazirx.js +1 -1
- package/js/src/zonda.js +3 -0
- package/package.json +3 -2
- package/skip-tests.json +3 -3
package/js/src/hitbtc.js
CHANGED
|
@@ -1737,7 +1737,7 @@ export default class hitbtc extends Exchange {
|
|
|
1737
1737
|
}
|
|
1738
1738
|
[request, params] = this.handleUntilOption('till', request, params);
|
|
1739
1739
|
if (limit !== undefined) {
|
|
1740
|
-
request['limit'] = limit;
|
|
1740
|
+
request['limit'] = Math.min(limit, 1000);
|
|
1741
1741
|
}
|
|
1742
1742
|
const price = this.safeString(params, 'price');
|
|
1743
1743
|
params = this.omit(params, 'price');
|
|
@@ -3295,15 +3295,39 @@ export default class hitbtc extends Exchange {
|
|
|
3295
3295
|
});
|
|
3296
3296
|
}
|
|
3297
3297
|
parseMarginModification(data, market = undefined) {
|
|
3298
|
+
//
|
|
3299
|
+
// addMargin/reduceMargin
|
|
3300
|
+
//
|
|
3301
|
+
// {
|
|
3302
|
+
// "symbol": "BTCUSDT_PERP",
|
|
3303
|
+
// "type": "isolated",
|
|
3304
|
+
// "leverage": "8.00",
|
|
3305
|
+
// "created_at": "2022-03-30T23:34:27.161Z",
|
|
3306
|
+
// "updated_at": "2022-03-30T23:34:27.161Z",
|
|
3307
|
+
// "currencies": [
|
|
3308
|
+
// {
|
|
3309
|
+
// "code": "USDT",
|
|
3310
|
+
// "margin_balance": "7.000000000000",
|
|
3311
|
+
// "reserved_orders": "0",
|
|
3312
|
+
// "reserved_positions": "0"
|
|
3313
|
+
// }
|
|
3314
|
+
// ],
|
|
3315
|
+
// "positions": null
|
|
3316
|
+
// }
|
|
3317
|
+
//
|
|
3298
3318
|
const currencies = this.safeValue(data, 'currencies', []);
|
|
3299
3319
|
const currencyInfo = this.safeValue(currencies, 0);
|
|
3320
|
+
const datetime = this.safeString(data, 'updated_at');
|
|
3300
3321
|
return {
|
|
3301
3322
|
'info': data,
|
|
3323
|
+
'symbol': market['symbol'],
|
|
3302
3324
|
'type': undefined,
|
|
3303
3325
|
'amount': undefined,
|
|
3326
|
+
'total': undefined,
|
|
3304
3327
|
'code': this.safeString(currencyInfo, 'code'),
|
|
3305
|
-
'symbol': market['symbol'],
|
|
3306
3328
|
'status': undefined,
|
|
3329
|
+
'timestamp': this.parse8601(datetime),
|
|
3330
|
+
'datetime': datetime,
|
|
3307
3331
|
};
|
|
3308
3332
|
}
|
|
3309
3333
|
async reduceMargin(symbol, amount, params = {}) {
|
package/js/src/htx.js
CHANGED
|
@@ -2965,7 +2965,7 @@ export default class htx extends Exchange {
|
|
|
2965
2965
|
const untilSeconds = (until !== undefined) ? this.parseToInt(until / 1000) : undefined;
|
|
2966
2966
|
if (market['contract']) {
|
|
2967
2967
|
if (limit !== undefined) {
|
|
2968
|
-
request['size'] = limit; // when using limit: from & to are ignored
|
|
2968
|
+
request['size'] = Math.min(limit, 2000); // when using limit: from & to are ignored
|
|
2969
2969
|
// https://huobiapi.github.io/docs/usdt_swap/v1/en/#general-get-kline-data
|
|
2970
2970
|
}
|
|
2971
2971
|
else {
|
|
@@ -3057,7 +3057,7 @@ export default class htx extends Exchange {
|
|
|
3057
3057
|
[useHistorical, params] = this.handleOptionAndParams(params, 'fetchOHLCV', 'useHistoricalEndpointForSpot', true);
|
|
3058
3058
|
if (!useHistorical) {
|
|
3059
3059
|
if (limit !== undefined) {
|
|
3060
|
-
request['size'] = Math.min(
|
|
3060
|
+
request['size'] = Math.min(limit, 2000); // max 2000
|
|
3061
3061
|
}
|
|
3062
3062
|
response = await this.spotPublicGetMarketHistoryKline(this.extend(request, params));
|
|
3063
3063
|
}
|
package/js/src/huobijp.js
CHANGED
|
@@ -955,7 +955,7 @@ export default class huobijp extends Exchange {
|
|
|
955
955
|
'period': this.safeString(this.timeframes, timeframe, timeframe),
|
|
956
956
|
};
|
|
957
957
|
if (limit !== undefined) {
|
|
958
|
-
request['size'] = limit;
|
|
958
|
+
request['size'] = Math.min(limit, 2000);
|
|
959
959
|
}
|
|
960
960
|
const response = await this.marketGetHistoryKline(this.extend(request, params));
|
|
961
961
|
//
|
package/js/src/hyperliquid.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import Exchange from './abstract/hyperliquid.js';
|
|
2
|
-
import type { Market, TransferEntry, Balances, Int, OrderBook, OHLCV, Str, FundingRateHistory, Order, OrderType, OrderSide, Trade, Strings, Position, OrderRequest, Dict, Num } from './base/types.js';
|
|
2
|
+
import type { Market, TransferEntry, Balances, Int, OrderBook, OHLCV, Str, FundingRateHistory, Order, OrderType, OrderSide, Trade, Strings, Position, OrderRequest, Dict, Num, MarginModification } from './base/types.js';
|
|
3
3
|
/**
|
|
4
4
|
* @class hyperliquid
|
|
5
5
|
* @augments Exchange
|
|
@@ -9,6 +9,8 @@ export default class hyperliquid extends Exchange {
|
|
|
9
9
|
setSandboxMode(enabled: any): void;
|
|
10
10
|
fetchCurrencies(params?: {}): Promise<{}>;
|
|
11
11
|
fetchMarkets(params?: {}): Promise<Market[]>;
|
|
12
|
+
fetchSwapMarkets(params?: {}): Promise<Market[]>;
|
|
13
|
+
fetchSpotMarkets(params?: {}): Promise<Market[]>;
|
|
12
14
|
parseMarket(market: any): Market;
|
|
13
15
|
fetchBalance(params?: {}): Promise<Balances>;
|
|
14
16
|
fetchOrderBook(symbol: string, limit?: Int, params?: {}): Promise<OrderBook>;
|
|
@@ -68,9 +70,10 @@ export default class hyperliquid extends Exchange {
|
|
|
68
70
|
parsePosition(position: any, market?: Market): Position;
|
|
69
71
|
setMarginMode(marginMode: string, symbol?: Str, params?: {}): Promise<any>;
|
|
70
72
|
setLeverage(leverage: Int, symbol?: Str, params?: {}): Promise<any>;
|
|
71
|
-
addMargin(symbol: string, amount: any, params?: {}): Promise<
|
|
72
|
-
reduceMargin(symbol: string, amount: any, params?: {}): Promise<
|
|
73
|
-
modifyMarginHelper(symbol: string, amount: any, type: any, params?: {}): Promise<
|
|
73
|
+
addMargin(symbol: string, amount: any, params?: {}): Promise<MarginModification>;
|
|
74
|
+
reduceMargin(symbol: string, amount: any, params?: {}): Promise<MarginModification>;
|
|
75
|
+
modifyMarginHelper(symbol: string, amount: any, type: any, params?: {}): Promise<MarginModification>;
|
|
76
|
+
parseMarginModification(data: any, market?: Market): MarginModification;
|
|
74
77
|
transfer(code: string, amount: number, fromAccount: string, toAccount: string, params?: {}): Promise<TransferEntry>;
|
|
75
78
|
withdraw(code: string, amount: any, address: any, tag?: any, params?: {}): Promise<any>;
|
|
76
79
|
formatVaultAddress(address?: Str): string;
|
package/js/src/hyperliquid.js
CHANGED
|
@@ -29,7 +29,7 @@ export default class hyperliquid extends Exchange {
|
|
|
29
29
|
'pro': true,
|
|
30
30
|
'has': {
|
|
31
31
|
'CORS': undefined,
|
|
32
|
-
'spot':
|
|
32
|
+
'spot': true,
|
|
33
33
|
'margin': false,
|
|
34
34
|
'swap': true,
|
|
35
35
|
'future': true,
|
|
@@ -162,6 +162,10 @@ export default class hyperliquid extends Exchange {
|
|
|
162
162
|
'taker': this.parseNumber('0.00035'),
|
|
163
163
|
'maker': this.parseNumber('0.0001'),
|
|
164
164
|
},
|
|
165
|
+
'spot': {
|
|
166
|
+
'taker': this.parseNumber('0.00035'),
|
|
167
|
+
'maker': this.parseNumber('0.0001'),
|
|
168
|
+
},
|
|
165
169
|
},
|
|
166
170
|
'requiredCredentials': {
|
|
167
171
|
'apiKey': false,
|
|
@@ -187,6 +191,7 @@ export default class hyperliquid extends Exchange {
|
|
|
187
191
|
'precisionMode': TICK_SIZE,
|
|
188
192
|
'commonCurrencies': {},
|
|
189
193
|
'options': {
|
|
194
|
+
'defaultType': 'swap',
|
|
190
195
|
'sandboxMode': false,
|
|
191
196
|
'defaultSlippage': 0.05,
|
|
192
197
|
'zeroAddress': '0x0000000000000000000000000000000000000000',
|
|
@@ -257,6 +262,24 @@ export default class hyperliquid extends Exchange {
|
|
|
257
262
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
258
263
|
* @returns {object[]} an array of objects representing market data
|
|
259
264
|
*/
|
|
265
|
+
const rawPromises = [
|
|
266
|
+
this.fetchSwapMarkets(params),
|
|
267
|
+
this.fetchSpotMarkets(params),
|
|
268
|
+
];
|
|
269
|
+
const promises = await Promise.all(rawPromises);
|
|
270
|
+
const swapMarkets = promises[0];
|
|
271
|
+
const spotMarkets = promises[1];
|
|
272
|
+
return this.arrayConcat(swapMarkets, spotMarkets);
|
|
273
|
+
}
|
|
274
|
+
async fetchSwapMarkets(params = {}) {
|
|
275
|
+
/**
|
|
276
|
+
* @method
|
|
277
|
+
* @name hyperliquid#fetchMarkets
|
|
278
|
+
* @description retrieves data on all swap markets for hyperliquid
|
|
279
|
+
* @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/info-endpoint#retrieve-asset-contexts-includes-mark-price-current-funding-open-interest-etc
|
|
280
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
281
|
+
* @returns {object[]} an array of objects representing market data
|
|
282
|
+
*/
|
|
260
283
|
const request = {
|
|
261
284
|
'type': 'metaAndAssetCtxs',
|
|
262
285
|
};
|
|
@@ -302,6 +325,132 @@ export default class hyperliquid extends Exchange {
|
|
|
302
325
|
}
|
|
303
326
|
return this.parseMarkets(result);
|
|
304
327
|
}
|
|
328
|
+
async fetchSpotMarkets(params = {}) {
|
|
329
|
+
/**
|
|
330
|
+
* @method
|
|
331
|
+
* @name hyperliquid#fetchMarkets
|
|
332
|
+
* @description retrieves data on all spot markets for hyperliquid
|
|
333
|
+
* @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/info-endpoint#retrieve-asset-contexts-includes-mark-price-current-funding-open-interest-etc
|
|
334
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
335
|
+
* @returns {object[]} an array of objects representing market data
|
|
336
|
+
*/
|
|
337
|
+
const request = {
|
|
338
|
+
'type': 'spotMetaAndAssetCtxs',
|
|
339
|
+
};
|
|
340
|
+
const response = await this.publicPostInfo(this.extend(request, params));
|
|
341
|
+
//
|
|
342
|
+
// [
|
|
343
|
+
// {
|
|
344
|
+
// 'tokens': [
|
|
345
|
+
// {
|
|
346
|
+
// 'name': 'USDC',
|
|
347
|
+
// 'szDecimals': '8',
|
|
348
|
+
// 'weiDecimals': '8',
|
|
349
|
+
// },
|
|
350
|
+
// {
|
|
351
|
+
// 'name': 'PURR',
|
|
352
|
+
// 'szDecimals': '0',
|
|
353
|
+
// 'weiDecimals': '5',
|
|
354
|
+
// },
|
|
355
|
+
// ],
|
|
356
|
+
// 'universe': [
|
|
357
|
+
// {
|
|
358
|
+
// 'name': 'PURR/USDC',
|
|
359
|
+
// 'tokens': [
|
|
360
|
+
// 1,
|
|
361
|
+
// 0,
|
|
362
|
+
// ],
|
|
363
|
+
// },
|
|
364
|
+
// ],
|
|
365
|
+
// },
|
|
366
|
+
// [
|
|
367
|
+
// {
|
|
368
|
+
// 'dayNtlVlm': '264250385.14640012',
|
|
369
|
+
// 'markPx': '0.018314',
|
|
370
|
+
// 'midPx': '0.0182235',
|
|
371
|
+
// 'prevDayPx': '0.017427',
|
|
372
|
+
// },
|
|
373
|
+
// ],
|
|
374
|
+
// ];
|
|
375
|
+
//
|
|
376
|
+
const first = this.safeDict(response, 0, {});
|
|
377
|
+
const meta = this.safeList(first, 'universe', []);
|
|
378
|
+
const tokens = this.safeList(first, 'tokens', []);
|
|
379
|
+
const markets = [];
|
|
380
|
+
for (let i = 0; i < meta.length; i++) {
|
|
381
|
+
const market = this.safeDict(meta, i, {});
|
|
382
|
+
const marketName = this.safeString(market, 'name');
|
|
383
|
+
const marketParts = marketName.split('/');
|
|
384
|
+
const baseName = this.safeString(marketParts, 0);
|
|
385
|
+
const quoteId = this.safeString(marketParts, 1);
|
|
386
|
+
const base = this.safeCurrencyCode(baseName);
|
|
387
|
+
const quote = this.safeCurrencyCode(quoteId);
|
|
388
|
+
const symbol = base + '/' + quote;
|
|
389
|
+
const fees = this.safeDict(this.fees, 'spot', {});
|
|
390
|
+
const taker = this.safeNumber(fees, 'taker');
|
|
391
|
+
const maker = this.safeNumber(fees, 'maker');
|
|
392
|
+
const tokensPos = this.safeList(market, 'tokens', []);
|
|
393
|
+
const baseTokenPos = this.safeInteger(tokensPos, 0);
|
|
394
|
+
const quoteTokenPos = this.safeInteger(tokensPos, 1);
|
|
395
|
+
const baseTokenInfo = this.safeDict(tokens, baseTokenPos, {});
|
|
396
|
+
const quoteTokenInfo = this.safeDict(tokens, quoteTokenPos, {});
|
|
397
|
+
const baseDecimals = this.safeString(baseTokenInfo, 'szDecimals');
|
|
398
|
+
const quoteDecimals = this.safeInteger(quoteTokenInfo, 'szDecimals');
|
|
399
|
+
const baseId = this.numberToString(i + 10000);
|
|
400
|
+
markets.push(this.safeMarketStructure({
|
|
401
|
+
'id': baseId,
|
|
402
|
+
'symbol': symbol,
|
|
403
|
+
'base': base,
|
|
404
|
+
'quote': quote,
|
|
405
|
+
'settle': undefined,
|
|
406
|
+
'baseId': baseId,
|
|
407
|
+
'quoteId': quoteId,
|
|
408
|
+
'settleId': undefined,
|
|
409
|
+
'type': 'spot',
|
|
410
|
+
'spot': true,
|
|
411
|
+
'margin': undefined,
|
|
412
|
+
'swap': false,
|
|
413
|
+
'future': false,
|
|
414
|
+
'option': false,
|
|
415
|
+
'active': true,
|
|
416
|
+
'contract': false,
|
|
417
|
+
'linear': true,
|
|
418
|
+
'inverse': false,
|
|
419
|
+
'taker': taker,
|
|
420
|
+
'maker': maker,
|
|
421
|
+
'contractSize': undefined,
|
|
422
|
+
'expiry': undefined,
|
|
423
|
+
'expiryDatetime': undefined,
|
|
424
|
+
'strike': undefined,
|
|
425
|
+
'optionType': undefined,
|
|
426
|
+
'precision': {
|
|
427
|
+
'amount': this.parseNumber(this.parsePrecision(baseDecimals)),
|
|
428
|
+
'price': quoteDecimals, // significant digits
|
|
429
|
+
},
|
|
430
|
+
'limits': {
|
|
431
|
+
'leverage': {
|
|
432
|
+
'min': undefined,
|
|
433
|
+
'max': undefined,
|
|
434
|
+
},
|
|
435
|
+
'amount': {
|
|
436
|
+
'min': undefined,
|
|
437
|
+
'max': undefined,
|
|
438
|
+
},
|
|
439
|
+
'price': {
|
|
440
|
+
'min': undefined,
|
|
441
|
+
'max': undefined,
|
|
442
|
+
},
|
|
443
|
+
'cost': {
|
|
444
|
+
'min': undefined,
|
|
445
|
+
'max': undefined,
|
|
446
|
+
},
|
|
447
|
+
},
|
|
448
|
+
'created': undefined,
|
|
449
|
+
'info': market,
|
|
450
|
+
}));
|
|
451
|
+
}
|
|
452
|
+
return markets;
|
|
453
|
+
}
|
|
305
454
|
parseMarket(market) {
|
|
306
455
|
//
|
|
307
456
|
// {
|
|
@@ -400,12 +549,17 @@ export default class hyperliquid extends Exchange {
|
|
|
400
549
|
* @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/info-endpoint#retrieve-a-users-state
|
|
401
550
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
402
551
|
* @param {string} [params.user] user address, will default to this.walletAddress if not provided
|
|
552
|
+
* @param {string} [params.type] wallet type, ['spot', 'swap'], defaults to swap
|
|
403
553
|
* @returns {object} a [balance structure]{@link https://docs.ccxt.com/#/?id=balance-structure}
|
|
404
554
|
*/
|
|
405
555
|
let userAddress = undefined;
|
|
406
556
|
[userAddress, params] = this.handlePublicAddress('fetchBalance', params);
|
|
557
|
+
let type = undefined;
|
|
558
|
+
[type, params] = this.handleMarketTypeAndParams('fetchBalance', undefined, params);
|
|
559
|
+
const isSpot = (type === 'spot');
|
|
560
|
+
const reqType = (isSpot) ? 'spotClearinghouseState' : 'clearinghouseState';
|
|
407
561
|
const request = {
|
|
408
|
-
'type':
|
|
562
|
+
'type': reqType,
|
|
409
563
|
'user': userAddress,
|
|
410
564
|
};
|
|
411
565
|
const response = await this.publicPostInfo(this.extend(request, params));
|
|
@@ -428,7 +582,37 @@ export default class hyperliquid extends Exchange {
|
|
|
428
582
|
// "time": "1704261007014",
|
|
429
583
|
// "withdrawable": "100.0"
|
|
430
584
|
// }
|
|
585
|
+
// spot
|
|
586
|
+
//
|
|
587
|
+
// {
|
|
588
|
+
// "balances":[
|
|
589
|
+
// {
|
|
590
|
+
// "coin":"USDC",
|
|
591
|
+
// "hold":"0.0",
|
|
592
|
+
// "total":"1481.844"
|
|
593
|
+
// },
|
|
594
|
+
// {
|
|
595
|
+
// "coin":"PURR",
|
|
596
|
+
// "hold":"0.0",
|
|
597
|
+
// "total":"999.65004"
|
|
598
|
+
// }
|
|
599
|
+
// }
|
|
431
600
|
//
|
|
601
|
+
const balances = this.safeList(response, 'balances');
|
|
602
|
+
if (balances !== undefined) {
|
|
603
|
+
const spotBalances = { 'info': response };
|
|
604
|
+
for (let i = 0; i < balances.length; i++) {
|
|
605
|
+
const balance = balances[i];
|
|
606
|
+
const code = this.safeCurrencyCode(this.safeString(balance, 'coin'));
|
|
607
|
+
const account = this.account();
|
|
608
|
+
const total = this.safeString(balance, 'total');
|
|
609
|
+
const free = this.safeString(balance, 'hold');
|
|
610
|
+
account['total'] = total;
|
|
611
|
+
account['free'] = free;
|
|
612
|
+
spotBalances[code] = account;
|
|
613
|
+
}
|
|
614
|
+
return this.safeBalance(spotBalances);
|
|
615
|
+
}
|
|
432
616
|
const data = this.safeDict(response, 'marginSummary', {});
|
|
433
617
|
const result = {
|
|
434
618
|
'info': response,
|
|
@@ -954,6 +1138,7 @@ export default class hyperliquid extends Exchange {
|
|
|
954
1138
|
* @param {string} symbol unified symbol of the market the order was made in
|
|
955
1139
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
956
1140
|
* @param {string} [params.clientOrderId] client order id, (optional 128 bit hex string e.g. 0x1234567890abcdef1234567890abcdef)
|
|
1141
|
+
* @param {string} [params.vaultAddress] the vault address for order
|
|
957
1142
|
* @returns {object} An [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
958
1143
|
*/
|
|
959
1144
|
return await this.cancelOrders([id], symbol, params);
|
|
@@ -969,6 +1154,7 @@ export default class hyperliquid extends Exchange {
|
|
|
969
1154
|
* @param {string} [symbol] unified market symbol
|
|
970
1155
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
971
1156
|
* @param {string|string[]} [params.clientOrderId] client order ids, (optional 128 bit hex string e.g. 0x1234567890abcdef1234567890abcdef)
|
|
1157
|
+
* @param {string} [params.vaultAddress] the vault address
|
|
972
1158
|
* @returns {object} an list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
973
1159
|
*/
|
|
974
1160
|
this.checkRequiredCredentials();
|
|
@@ -1451,7 +1637,12 @@ export default class hyperliquid extends Exchange {
|
|
|
1451
1637
|
const coin = this.safeString(entry, 'coin');
|
|
1452
1638
|
let marketId = undefined;
|
|
1453
1639
|
if (coin !== undefined) {
|
|
1454
|
-
|
|
1640
|
+
if (coin.indexOf('/') > -1) {
|
|
1641
|
+
marketId = coin;
|
|
1642
|
+
}
|
|
1643
|
+
else {
|
|
1644
|
+
marketId = coin + '/USDC:USDC';
|
|
1645
|
+
}
|
|
1455
1646
|
}
|
|
1456
1647
|
if (this.safeString(entry, 'id') === undefined) {
|
|
1457
1648
|
market = this.safeMarket(marketId, undefined);
|
|
@@ -1935,10 +2126,27 @@ export default class hyperliquid extends Exchange {
|
|
|
1935
2126
|
// 'status': 'ok'
|
|
1936
2127
|
// }
|
|
1937
2128
|
//
|
|
1938
|
-
return response
|
|
1939
|
-
|
|
1940
|
-
|
|
1941
|
-
|
|
2129
|
+
return this.extend(this.parseMarginModification(response, market), {
|
|
2130
|
+
'code': this.safeString(response, 'status'),
|
|
2131
|
+
});
|
|
2132
|
+
}
|
|
2133
|
+
parseMarginModification(data, market = undefined) {
|
|
2134
|
+
//
|
|
2135
|
+
// {
|
|
2136
|
+
// 'type': 'default'
|
|
2137
|
+
// }
|
|
2138
|
+
//
|
|
2139
|
+
return {
|
|
2140
|
+
'info': data,
|
|
2141
|
+
'symbol': this.safeSymbol(undefined, market),
|
|
2142
|
+
'type': undefined,
|
|
2143
|
+
'amount': undefined,
|
|
2144
|
+
'total': undefined,
|
|
2145
|
+
'code': this.safeString(market, 'settle'),
|
|
2146
|
+
'status': undefined,
|
|
2147
|
+
'timestamp': undefined,
|
|
2148
|
+
'datetime': undefined,
|
|
2149
|
+
};
|
|
1942
2150
|
}
|
|
1943
2151
|
async transfer(code, amount, fromAccount, toAccount, params = {}) {
|
|
1944
2152
|
/**
|
|
@@ -1948,13 +2156,44 @@ export default class hyperliquid extends Exchange {
|
|
|
1948
2156
|
* @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/exchange-endpoint#l1-usdc-transfer
|
|
1949
2157
|
* @param {string} code unified currency code
|
|
1950
2158
|
* @param {float} amount amount to transfer
|
|
1951
|
-
* @param {string} fromAccount account to transfer from
|
|
1952
|
-
* @param {string} toAccount account to transfer to
|
|
2159
|
+
* @param {string} fromAccount account to transfer from *spot, swap*
|
|
2160
|
+
* @param {string} toAccount account to transfer to *swap, spot or address*
|
|
1953
2161
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
2162
|
+
* @param {string} [params.vaultAddress] the vault address for order
|
|
1954
2163
|
* @returns {object} a [transfer structure]{@link https://docs.ccxt.com/#/?id=transfer-structure}
|
|
1955
2164
|
*/
|
|
1956
2165
|
this.checkRequiredCredentials();
|
|
1957
2166
|
await this.loadMarkets();
|
|
2167
|
+
const isSandboxMode = this.safeBool(this.options, 'sandboxMode');
|
|
2168
|
+
const nonce = this.milliseconds();
|
|
2169
|
+
if (this.inArray(fromAccount, ['spot', 'swap', 'perp'])) {
|
|
2170
|
+
// handle swap <> spot account transfer
|
|
2171
|
+
if (!this.inArray(toAccount, ['spot', 'swap', 'perp'])) {
|
|
2172
|
+
throw new NotSupported(this.id + 'transfer() only support spot <> swap transfer');
|
|
2173
|
+
}
|
|
2174
|
+
const vaultAddress = this.formatVaultAddress(this.safeString(params, 'vaultAddress'));
|
|
2175
|
+
params = this.omit(params, 'vaultAddress');
|
|
2176
|
+
const toPerp = (toAccount === 'perp') || (toAccount === 'swap');
|
|
2177
|
+
const action = {
|
|
2178
|
+
'type': 'spotUser',
|
|
2179
|
+
'classTransfer': {
|
|
2180
|
+
'usdc': amount,
|
|
2181
|
+
'toPerp': toPerp,
|
|
2182
|
+
},
|
|
2183
|
+
};
|
|
2184
|
+
const signature = this.signL1Action(action, nonce, vaultAddress);
|
|
2185
|
+
const innerRequest = {
|
|
2186
|
+
'action': this.extend(action, params),
|
|
2187
|
+
'nonce': nonce,
|
|
2188
|
+
'signature': signature,
|
|
2189
|
+
};
|
|
2190
|
+
if (vaultAddress !== undefined) {
|
|
2191
|
+
innerRequest['vaultAddress'] = vaultAddress;
|
|
2192
|
+
}
|
|
2193
|
+
const transferResponse = await this.privatePostExchange(innerRequest);
|
|
2194
|
+
return transferResponse;
|
|
2195
|
+
}
|
|
2196
|
+
// handle sub-account/different account transfer
|
|
1958
2197
|
this.checkAddress(toAccount);
|
|
1959
2198
|
if (code !== undefined) {
|
|
1960
2199
|
code = code.toUpperCase();
|
|
@@ -1962,11 +2201,9 @@ export default class hyperliquid extends Exchange {
|
|
|
1962
2201
|
throw new NotSupported(this.id + 'withdraw() only support USDC');
|
|
1963
2202
|
}
|
|
1964
2203
|
}
|
|
1965
|
-
const isSandboxMode = this.safeBool(this.options, 'sandboxMode');
|
|
1966
|
-
const nonce = this.milliseconds();
|
|
1967
2204
|
const payload = {
|
|
1968
2205
|
'destination': toAccount,
|
|
1969
|
-
'amount':
|
|
2206
|
+
'amount': this.numberToString(amount),
|
|
1970
2207
|
'time': nonce,
|
|
1971
2208
|
};
|
|
1972
2209
|
const sig = this.buildTransferSig(payload);
|
package/js/src/idex.js
CHANGED
|
@@ -466,7 +466,7 @@ export default class idex extends Exchange {
|
|
|
466
466
|
request['start'] = since;
|
|
467
467
|
}
|
|
468
468
|
if (limit !== undefined) {
|
|
469
|
-
request['limit'] = limit;
|
|
469
|
+
request['limit'] = Math.min(limit, 1000);
|
|
470
470
|
}
|
|
471
471
|
const response = await this.publicGetCandles(this.extend(request, params));
|
|
472
472
|
if (Array.isArray(response)) {
|
package/js/src/krakenfutures.js
CHANGED
|
@@ -644,17 +644,13 @@ export default class krakenfutures extends Exchange {
|
|
|
644
644
|
if (limit === undefined) {
|
|
645
645
|
limit = 5000;
|
|
646
646
|
}
|
|
647
|
-
|
|
648
|
-
throw new BadRequest(this.id + ' fetchOHLCV() limit cannot exceed 5000');
|
|
649
|
-
}
|
|
647
|
+
limit = Math.min(limit, 5000);
|
|
650
648
|
const toTimestamp = this.sum(request['from'], limit * duration - 1);
|
|
651
649
|
const currentTimestamp = this.seconds();
|
|
652
650
|
request['to'] = Math.min(toTimestamp, currentTimestamp);
|
|
653
651
|
}
|
|
654
652
|
else if (limit !== undefined) {
|
|
655
|
-
|
|
656
|
-
throw new BadRequest(this.id + ' fetchOHLCV() limit cannot exceed 5000');
|
|
657
|
-
}
|
|
653
|
+
limit = Math.min(limit, 5000);
|
|
658
654
|
const duration = this.parseTimeframe(timeframe);
|
|
659
655
|
request['to'] = this.seconds();
|
|
660
656
|
request['from'] = this.parseToInt(request['to'] - (duration * limit));
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import kucoin from './abstract/kucoinfutures.js';
|
|
2
|
-
import type { TransferEntry, Int, OrderSide, OrderType, OHLCV, Order, Trade, OrderRequest, FundingHistory, Balances, Str, Ticker, Tickers, OrderBook, Transaction, Strings, Market, Currency, Num } from './base/types.js';
|
|
2
|
+
import type { TransferEntry, Int, OrderSide, OrderType, OHLCV, Order, Trade, OrderRequest, FundingHistory, Balances, Str, Ticker, Tickers, OrderBook, Transaction, Strings, Market, Currency, Num, MarginModification } from './base/types.js';
|
|
3
3
|
/**
|
|
4
4
|
* @class kucoinfutures
|
|
5
5
|
* @augments Exchange
|
|
@@ -37,7 +37,7 @@ export default class kucoinfutures extends kucoin {
|
|
|
37
37
|
createContractOrderRequest(symbol: string, type: OrderType, side: OrderSide, amount: number, price?: Num, params?: {}): any;
|
|
38
38
|
cancelOrder(id: string, symbol?: Str, params?: {}): Promise<any>;
|
|
39
39
|
cancelAllOrders(symbol?: Str, params?: {}): Promise<any>;
|
|
40
|
-
addMargin(symbol: string, amount: any, params?: {}): Promise<
|
|
40
|
+
addMargin(symbol: string, amount: any, params?: {}): Promise<MarginModification>;
|
|
41
41
|
parseMarginModification(info: any, market?: Market): {
|
|
42
42
|
info: any;
|
|
43
43
|
direction: any;
|
package/js/src/lbank.js
CHANGED
|
@@ -1003,6 +1003,9 @@ export default class lbank extends Exchange {
|
|
|
1003
1003
|
if (limit === undefined) {
|
|
1004
1004
|
limit = 100;
|
|
1005
1005
|
}
|
|
1006
|
+
else {
|
|
1007
|
+
limit = Math.min(limit, 2000);
|
|
1008
|
+
}
|
|
1006
1009
|
if (since === undefined) {
|
|
1007
1010
|
const duration = this.parseTimeframe(timeframe);
|
|
1008
1011
|
since = this.milliseconds() - duration * 1000 * limit;
|
package/js/src/mexc.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import Exchange from './abstract/mexc.js';
|
|
2
|
-
import type { TransferEntry, IndexType, Int, OrderSide, Balances, OrderType, OHLCV, FundingRateHistory, Position, OrderBook, OrderRequest, FundingHistory, Order, Str, Trade, Transaction, Ticker, Tickers, Strings, Market, Currency, Leverage, Num, Account } from './base/types.js';
|
|
2
|
+
import type { TransferEntry, IndexType, Int, OrderSide, Balances, OrderType, OHLCV, FundingRateHistory, Position, OrderBook, OrderRequest, FundingHistory, Order, Str, Trade, Transaction, Ticker, Tickers, Strings, Market, Currency, Leverage, Num, Account, MarginModification } from './base/types.js';
|
|
3
3
|
/**
|
|
4
4
|
* @class mexc
|
|
5
5
|
* @augments Exchange
|
|
@@ -59,8 +59,8 @@ export default class mexc extends Exchange {
|
|
|
59
59
|
fetchMyTrades(symbol?: Str, since?: Int, limit?: Int, params?: {}): Promise<Trade[]>;
|
|
60
60
|
fetchOrderTrades(id: string, symbol?: Str, since?: Int, limit?: Int, params?: {}): Promise<Trade[]>;
|
|
61
61
|
modifyMarginHelper(symbol: string, amount: any, addOrReduce: any, params?: {}): Promise<any>;
|
|
62
|
-
reduceMargin(symbol: string, amount: any, params?: {}): Promise<
|
|
63
|
-
addMargin(symbol: string, amount: any, params?: {}): Promise<
|
|
62
|
+
reduceMargin(symbol: string, amount: any, params?: {}): Promise<MarginModification>;
|
|
63
|
+
addMargin(symbol: string, amount: any, params?: {}): Promise<MarginModification>;
|
|
64
64
|
setLeverage(leverage: Int, symbol?: Str, params?: {}): Promise<any>;
|
|
65
65
|
fetchFundingHistory(symbol?: Str, since?: Int, limit?: Int, params?: {}): Promise<FundingHistory[]>;
|
|
66
66
|
parseFundingRate(contract: any, market?: Market): {
|
package/js/src/oceanex.js
CHANGED
|
@@ -797,7 +797,7 @@ export default class oceanex extends Exchange {
|
|
|
797
797
|
request['timestamp'] = since;
|
|
798
798
|
}
|
|
799
799
|
if (limit !== undefined) {
|
|
800
|
-
request['limit'] = limit;
|
|
800
|
+
request['limit'] = Math.min(limit, 10000);
|
|
801
801
|
}
|
|
802
802
|
const response = await this.publicPostK(this.extend(request, params));
|
|
803
803
|
const ohlcvs = this.safeList(response, 'data', []);
|
package/js/src/okx.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import Exchange from './abstract/okx.js';
|
|
2
|
-
import type { TransferEntry, Int, OrderSide, OrderType, Trade, OHLCV, Order, FundingRateHistory, OrderRequest, FundingHistory, Str, Transaction, Ticker, OrderBook, Balances, Tickers, Market, Greeks, Strings, MarketInterface, Currency, Leverage, Num, Account, OptionChain, Option } from './base/types.js';
|
|
2
|
+
import type { TransferEntry, Int, OrderSide, OrderType, Trade, OHLCV, Order, FundingRateHistory, OrderRequest, FundingHistory, Str, Transaction, Ticker, OrderBook, Balances, Tickers, Market, Greeks, Strings, MarketInterface, Currency, Leverage, Num, Account, OptionChain, Option, MarginModification } from './base/types.js';
|
|
3
3
|
/**
|
|
4
4
|
* @class okx
|
|
5
5
|
* @augments Exchange
|
|
@@ -202,38 +202,10 @@ export default class okx extends Exchange {
|
|
|
202
202
|
parseBorrowRateHistory(response: any, code: any, since: any, limit: any): any;
|
|
203
203
|
fetchBorrowRateHistories(codes?: any, since?: Int, limit?: Int, params?: {}): Promise<{}>;
|
|
204
204
|
fetchBorrowRateHistory(code: string, since?: Int, limit?: Int, params?: {}): Promise<any>;
|
|
205
|
-
modifyMarginHelper(symbol: string, amount: any, type: any, params?: {}): Promise<
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
code: string;
|
|
210
|
-
symbol: string;
|
|
211
|
-
status: string;
|
|
212
|
-
}>;
|
|
213
|
-
parseMarginModification(data: any, market?: Market): {
|
|
214
|
-
info: any;
|
|
215
|
-
type: string;
|
|
216
|
-
amount: number;
|
|
217
|
-
code: string;
|
|
218
|
-
symbol: string;
|
|
219
|
-
status: string;
|
|
220
|
-
};
|
|
221
|
-
reduceMargin(symbol: string, amount: any, params?: {}): Promise<{
|
|
222
|
-
info: any;
|
|
223
|
-
type: string;
|
|
224
|
-
amount: number;
|
|
225
|
-
code: string;
|
|
226
|
-
symbol: string;
|
|
227
|
-
status: string;
|
|
228
|
-
}>;
|
|
229
|
-
addMargin(symbol: string, amount: any, params?: {}): Promise<{
|
|
230
|
-
info: any;
|
|
231
|
-
type: string;
|
|
232
|
-
amount: number;
|
|
233
|
-
code: string;
|
|
234
|
-
symbol: string;
|
|
235
|
-
status: string;
|
|
236
|
-
}>;
|
|
205
|
+
modifyMarginHelper(symbol: string, amount: any, type: any, params?: {}): Promise<MarginModification>;
|
|
206
|
+
parseMarginModification(data: any, market?: Market): MarginModification;
|
|
207
|
+
reduceMargin(symbol: string, amount: any, params?: {}): Promise<MarginModification>;
|
|
208
|
+
addMargin(symbol: string, amount: any, params?: {}): Promise<MarginModification>;
|
|
237
209
|
fetchMarketLeverageTiers(symbol: string, params?: {}): Promise<any[]>;
|
|
238
210
|
parseMarketLeverageTiers(info: any, market?: Market): any[];
|
|
239
211
|
fetchBorrowInterest(code?: Str, symbol?: Str, since?: Int, limit?: Int, params?: {}): Promise<any>;
|