ccxt 4.1.58 → 4.1.60

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 (73) hide show
  1. package/README.md +5 -5
  2. package/build.sh +2 -2
  3. package/dist/ccxt.browser.js +1017 -1031
  4. package/dist/ccxt.browser.min.js +2 -2
  5. package/dist/cjs/ccxt.js +1 -19
  6. package/dist/cjs/src/base/Exchange.js +45 -24
  7. package/dist/cjs/src/base/ws/Client.js +1 -1
  8. package/dist/cjs/src/binance.js +71 -22
  9. package/dist/cjs/src/bitget.js +74 -52
  10. package/dist/cjs/src/bitmart.js +10 -18
  11. package/dist/cjs/src/bitrue.js +1 -1
  12. package/dist/cjs/src/bybit.js +36 -33
  13. package/dist/cjs/src/coinbasepro.js +15 -0
  14. package/dist/cjs/src/coinex.js +25 -30
  15. package/dist/cjs/src/htx.js +82 -39
  16. package/dist/cjs/src/kucoin.js +209 -163
  17. package/dist/cjs/src/mexc.js +21 -118
  18. package/dist/cjs/src/okx.js +23 -17
  19. package/dist/cjs/src/pro/bitget.js +7 -0
  20. package/dist/cjs/src/pro/bitmart.js +7 -0
  21. package/dist/cjs/src/pro/bitvavo.js +9 -0
  22. package/dist/cjs/src/pro/bybit.js +9 -0
  23. package/dist/cjs/src/pro/htx.js +86 -61
  24. package/dist/cjs/src/pro/kucoin.js +7 -0
  25. package/dist/cjs/src/pro/mexc.js +9 -0
  26. package/js/ccxt.d.ts +2 -23
  27. package/js/ccxt.js +2 -16
  28. package/js/src/abstract/binance.d.ts +1 -0
  29. package/js/src/abstract/binancecoinm.d.ts +1 -0
  30. package/js/src/abstract/binanceus.d.ts +1 -0
  31. package/js/src/abstract/binanceusdm.d.ts +1 -0
  32. package/js/src/abstract/mexc.d.ts +0 -4
  33. package/js/src/base/Exchange.d.ts +9 -2
  34. package/js/src/base/Exchange.js +45 -24
  35. package/js/src/base/ws/Client.js +1 -1
  36. package/js/src/binance.d.ts +20 -2
  37. package/js/src/binance.js +71 -22
  38. package/js/src/bitget.d.ts +20 -2
  39. package/js/src/bitget.js +74 -52
  40. package/js/src/bitmart.d.ts +2 -2
  41. package/js/src/bitmart.js +10 -18
  42. package/js/src/bitrue.js +1 -1
  43. package/js/src/bybit.d.ts +2 -2
  44. package/js/src/bybit.js +36 -33
  45. package/js/src/coinbasepro.js +15 -0
  46. package/js/src/coinex.d.ts +2 -2
  47. package/js/src/coinex.js +25 -30
  48. package/js/src/htx.d.ts +5 -3
  49. package/js/src/htx.js +82 -39
  50. package/js/src/kucoin.d.ts +20 -2
  51. package/js/src/kucoin.js +209 -163
  52. package/js/src/mexc.d.ts +0 -11
  53. package/js/src/mexc.js +21 -118
  54. package/js/src/okx.d.ts +19 -2
  55. package/js/src/okx.js +23 -17
  56. package/js/src/pro/bitget.js +7 -0
  57. package/js/src/pro/bitmart.js +7 -0
  58. package/js/src/pro/bitvavo.js +9 -0
  59. package/js/src/pro/bybit.js +9 -0
  60. package/js/src/pro/htx.d.ts +2 -2
  61. package/js/src/pro/htx.js +86 -61
  62. package/js/src/pro/kucoin.js +7 -0
  63. package/js/src/pro/mexc.js +9 -0
  64. package/package.json +1 -1
  65. package/skip-tests.json +5 -1
  66. package/js/src/abstract/huobipro.d.ts +0 -547
  67. package/js/src/abstract/huobipro.js +0 -11
  68. package/js/src/abstract/mexc3.d.ts +0 -180
  69. package/js/src/abstract/mexc3.js +0 -11
  70. package/js/src/abstract/okex.d.ts +0 -280
  71. package/js/src/abstract/okex.js +0 -11
  72. package/js/src/abstract/okex5.d.ts +0 -280
  73. package/js/src/abstract/okex5.js +0 -11
package/js/src/kucoin.js CHANGED
@@ -34,7 +34,8 @@ export default class kucoin extends Exchange {
34
34
  'swap': false,
35
35
  'future': false,
36
36
  'option': false,
37
- 'borrowMargin': true,
37
+ 'borrowCrossMargin': true,
38
+ 'borrowIsolatedMargin': true,
38
39
  'cancelAllOrders': true,
39
40
  'cancelOrder': true,
40
41
  'createDepositAddress': true,
@@ -95,7 +96,8 @@ export default class kucoin extends Exchange {
95
96
  'fetchTransactionFee': true,
96
97
  'fetchTransfers': false,
97
98
  'fetchWithdrawals': true,
98
- 'repayMargin': true,
99
+ 'repayCrossMargin': true,
100
+ 'repayIsolatedMargin': true,
99
101
  'setLeverage': false,
100
102
  'setMarginMode': false,
101
103
  'setPositionMode': false,
@@ -2221,17 +2223,20 @@ export default class kucoin extends Exchange {
2221
2223
  throw new BadRequest(this.id + ' cancelAllOrders does not support isolated margin for stop orders');
2222
2224
  }
2223
2225
  }
2224
- let method = 'privateDeleteOrders';
2226
+ let response = undefined;
2225
2227
  if (stop) {
2226
- method = 'privateDeleteStopOrderCancel';
2228
+ response = await this.privateDeleteStopOrderCancel(this.extend(request, query));
2227
2229
  }
2228
2230
  else if (hf) {
2229
2231
  if (symbol === undefined) {
2230
2232
  throw new ArgumentsRequired(this.id + ' cancelAllOrders() requires a symbol parameter for hf orders');
2231
2233
  }
2232
- method = 'privateDeleteHfOrders';
2234
+ response = await this.privateDeleteHfOrders(this.extend(request, query));
2235
+ }
2236
+ else {
2237
+ response = await this.privateDeleteOrders(this.extend(request, query));
2233
2238
  }
2234
- return await this[method](this.extend(request, query));
2239
+ return response;
2235
2240
  }
2236
2241
  async fetchOrdersByStatus(status, symbol = undefined, since = undefined, limit = undefined, params = {}) {
2237
2242
  /**
@@ -2288,20 +2293,22 @@ export default class kucoin extends Exchange {
2288
2293
  if (until) {
2289
2294
  request['endAt'] = until;
2290
2295
  }
2291
- let method = 'privateGetOrders';
2296
+ request['tradeType'] = this.safeString(this.options['marginModes'], marginMode, 'TRADE');
2297
+ let response = undefined;
2292
2298
  if (stop) {
2293
- method = 'privateGetStopOrder';
2299
+ response = await this.privateGetStopOrder(this.extend(request, query));
2294
2300
  }
2295
2301
  else if (hf) {
2296
2302
  if (lowercaseStatus === 'active') {
2297
- method = 'privateGetHfOrdersActive';
2303
+ response = await this.privateGetHfOrdersActive(this.extend(request, query));
2298
2304
  }
2299
2305
  else if (lowercaseStatus === 'done') {
2300
- method = 'privateGetHfOrdersDone';
2306
+ response = await this.privateGetHfOrdersDone(this.extend(request, query));
2301
2307
  }
2302
2308
  }
2303
- request['tradeType'] = this.safeString(this.options['marginModes'], marginMode, 'TRADE');
2304
- const response = await this[method](this.extend(request, query));
2309
+ else {
2310
+ response = await this.privateGetOrders(this.extend(request, query));
2311
+ }
2305
2312
  //
2306
2313
  // {
2307
2314
  // "code": "200000",
@@ -2446,21 +2453,21 @@ export default class kucoin extends Exchange {
2446
2453
  }
2447
2454
  request['symbol'] = market['id'];
2448
2455
  }
2449
- params = this.omit(params, ['stop', 'hf']);
2450
- let method = 'privateGetOrdersOrderId';
2456
+ params = this.omit(params, ['stop', 'hf', 'clientOid', 'clientOrderId']);
2457
+ let response = undefined;
2451
2458
  if (clientOrderId !== undefined) {
2452
2459
  request['clientOid'] = clientOrderId;
2453
2460
  if (stop) {
2454
- method = 'privateGetStopOrderQueryOrderByClientOid';
2455
2461
  if (symbol !== undefined) {
2456
2462
  request['symbol'] = market['id'];
2457
2463
  }
2464
+ response = await this.privateGetStopOrderQueryOrderByClientOid(this.extend(request, params));
2458
2465
  }
2459
2466
  else if (hf) {
2460
- method = 'privateGetHfOrdersClientOrderClientOid';
2467
+ response = await this.privateGetHfOrdersClientOrderClientOid(this.extend(request, params));
2461
2468
  }
2462
2469
  else {
2463
- method = 'privateGetOrderClientOrderClientOid';
2470
+ response = await this.privateGetOrderClientOrderClientOid(this.extend(request, params));
2464
2471
  }
2465
2472
  }
2466
2473
  else {
@@ -2470,18 +2477,19 @@ export default class kucoin extends Exchange {
2470
2477
  if (id === undefined) {
2471
2478
  throw new InvalidOrder(this.id + ' fetchOrder() requires an order id');
2472
2479
  }
2480
+ request['orderId'] = id;
2473
2481
  if (stop) {
2474
- method = 'privateGetStopOrderOrderId';
2482
+ response = await this.privateGetStopOrderOrderId(this.extend(request, params));
2475
2483
  }
2476
2484
  else if (hf) {
2477
- method = 'privateGetHfOrdersOrderId';
2485
+ response = await this.privateGetHfOrdersOrderId(this.extend(request, params));
2486
+ }
2487
+ else {
2488
+ response = await this.privateGetOrdersOrderId(this.extend(request, params));
2478
2489
  }
2479
- request['orderId'] = id;
2480
2490
  }
2481
- params = this.omit(params, ['clientOid', 'clientOrderId']);
2482
- const response = await this[method](this.extend(request, params));
2483
2491
  let responseData = this.safeValue(response, 'data');
2484
- if (method === 'privateGetStopOrderQueryOrderByClientOid') {
2492
+ if (Array.isArray(responseData)) {
2485
2493
  responseData = this.safeValue(responseData, 0);
2486
2494
  }
2487
2495
  return this.parseOrder(responseData, market);
@@ -2723,10 +2731,12 @@ export default class kucoin extends Exchange {
2723
2731
  if (limit !== undefined) {
2724
2732
  request['pageSize'] = limit;
2725
2733
  }
2726
- let method = this.options['fetchMyTradesMethod'];
2734
+ const method = this.options['fetchMyTradesMethod'];
2727
2735
  let parseResponseData = false;
2736
+ let response = undefined;
2737
+ [request, params] = this.handleUntilOption('endAt', request, params);
2728
2738
  if (hf) {
2729
- method = 'privateGetHfFills';
2739
+ response = await this.privateGetHfFills(this.extend(request, params));
2730
2740
  }
2731
2741
  else if (method === 'private_get_fills') {
2732
2742
  // does not return trades earlier than 2019-02-18T00:00:00Z
@@ -2734,26 +2744,18 @@ export default class kucoin extends Exchange {
2734
2744
  // only returns trades up to one week after the since param
2735
2745
  request['startAt'] = since;
2736
2746
  }
2747
+ response = await this.privateGetFills(this.extend(request, params));
2737
2748
  }
2738
2749
  else if (method === 'private_get_limit_fills') {
2739
2750
  // does not return trades earlier than 2019-02-18T00:00:00Z
2740
2751
  // takes no params
2741
2752
  // only returns first 1000 trades (not only "in the last 24 hours" as stated in the docs)
2742
2753
  parseResponseData = true;
2743
- }
2744
- else if (method === 'private_get_hist_orders') {
2745
- // despite that this endpoint is called `HistOrders`
2746
- // it returns historical trades instead of orders
2747
- // returns trades earlier than 2019-02-18T00:00:00Z only
2748
- if (since !== undefined) {
2749
- request['startAt'] = this.parseToInt(since / 1000);
2750
- }
2754
+ response = await this.privateGetLimitFills(this.extend(request, params));
2751
2755
  }
2752
2756
  else {
2753
2757
  throw new ExchangeError(this.id + ' fetchMyTradesMethod() invalid method');
2754
2758
  }
2755
- [request, params] = this.handleUntilOption('endAt', request, params);
2756
- const response = await this[method](this.extend(request, params));
2757
2759
  //
2758
2760
  // {
2759
2761
  // "currentPage": 1,
@@ -3196,8 +3198,6 @@ export default class kucoin extends Exchange {
3196
3198
  /**
3197
3199
  * @method
3198
3200
  * @name kucoin#fetchDeposits
3199
- * @see https://docs.kucoin.com/#get-deposit-list
3200
- * @see https://docs.kucoin.com/#get-v1-historical-deposits-list
3201
3201
  * @description fetch all deposits made to an account
3202
3202
  * @see https://docs.kucoin.com/#get-deposit-list
3203
3203
  * @see https://docs.kucoin.com/#get-v1-historical-deposits-list
@@ -3224,19 +3224,19 @@ export default class kucoin extends Exchange {
3224
3224
  if (limit !== undefined) {
3225
3225
  request['pageSize'] = limit;
3226
3226
  }
3227
- let method = 'privateGetDeposits';
3228
- if (since !== undefined) {
3227
+ [request, params] = this.handleUntilOption('endAt', request, params);
3228
+ let response = undefined;
3229
+ if (since !== undefined && since < 1550448000000) {
3229
3230
  // if since is earlier than 2019-02-18T00:00:00Z
3230
- if (since < 1550448000000) {
3231
- request['startAt'] = this.parseToInt(since / 1000);
3232
- method = 'privateGetHistDeposits';
3233
- }
3234
- else {
3231
+ request['startAt'] = this.parseToInt(since / 1000);
3232
+ response = await this.privateGetHistDeposits(this.extend(request, params));
3233
+ }
3234
+ else {
3235
+ if (since !== undefined) {
3235
3236
  request['startAt'] = since;
3236
3237
  }
3238
+ response = await this.privateGetDeposits(this.extend(request, params));
3237
3239
  }
3238
- [request, params] = this.handleUntilOption('endAt', request, params);
3239
- const response = await this[method](this.extend(request, params));
3240
3240
  //
3241
3241
  // {
3242
3242
  // "code": "200000",
@@ -3308,19 +3308,19 @@ export default class kucoin extends Exchange {
3308
3308
  if (limit !== undefined) {
3309
3309
  request['pageSize'] = limit;
3310
3310
  }
3311
- let method = 'privateGetWithdrawals';
3312
- if (since !== undefined) {
3311
+ [request, params] = this.handleUntilOption('endAt', request, params);
3312
+ let response = undefined;
3313
+ if (since !== undefined && since < 1550448000000) {
3313
3314
  // if since is earlier than 2019-02-18T00:00:00Z
3314
- if (since < 1550448000000) {
3315
- request['startAt'] = this.parseToInt(since / 1000);
3316
- method = 'privateGetHistWithdrawals';
3317
- }
3318
- else {
3315
+ request['startAt'] = this.parseToInt(since / 1000);
3316
+ response = await this.privateGetHistWithdrawals(this.extend(request, params));
3317
+ }
3318
+ else {
3319
+ if (since !== undefined) {
3319
3320
  request['startAt'] = since;
3320
3321
  }
3322
+ response = await this.privateGetWithdrawals(this.extend(request, params));
3321
3323
  }
3322
- [request, params] = this.handleUntilOption('endAt', request, params);
3323
- const response = await this[method](this.extend(request, params));
3324
3324
  //
3325
3325
  // {
3326
3326
  // "code": "200000",
@@ -3397,26 +3397,26 @@ export default class kucoin extends Exchange {
3397
3397
  const type = this.safeString(accountsByType, requestedType, requestedType);
3398
3398
  params = this.omit(params, 'type');
3399
3399
  const [marginMode, query] = this.handleMarginModeAndParams('fetchBalance', params);
3400
- let method = 'privateGetAccounts';
3400
+ let response = undefined;
3401
3401
  const request = {};
3402
3402
  const isolated = (marginMode === 'isolated') || (type === 'isolated');
3403
3403
  const cross = (marginMode === 'cross') || (type === 'cross');
3404
3404
  if (isolated) {
3405
- method = 'privateGetIsolatedAccounts';
3406
3405
  if (currency !== undefined) {
3407
3406
  request['balanceCurrency'] = currency['id'];
3408
3407
  }
3408
+ response = await this.privateGetIsolatedAccounts(this.extend(request, query));
3409
3409
  }
3410
3410
  else if (cross) {
3411
- method = 'privateGetMarginAccount';
3411
+ response = await this.privateGetMarginAccount(this.extend(request, query));
3412
3412
  }
3413
3413
  else {
3414
3414
  if (currency !== undefined) {
3415
3415
  request['currency'] = currency['id'];
3416
3416
  }
3417
3417
  request['type'] = type;
3418
+ response = await this.privateGetAccounts(this.extend(request, query));
3418
3419
  }
3419
- const response = await this[method](this.extend(request, query));
3420
3420
  //
3421
3421
  // Spot and Cross
3422
3422
  //
@@ -3956,43 +3956,37 @@ export default class kucoin extends Exchange {
3956
3956
  marginMode = 'cross'; // cross as default marginMode
3957
3957
  }
3958
3958
  const request = {};
3959
- let method = 'privateGetMarginBorrowOutstanding';
3959
+ let response = undefined;
3960
+ if (code !== undefined) {
3961
+ const currency = this.currency(code);
3962
+ request['quoteCurrency'] = currency['id'];
3963
+ }
3960
3964
  if (marginMode === 'isolated') {
3961
- if (code !== undefined) {
3962
- const currency = this.currency(code);
3963
- request['balanceCurrency'] = currency['id'];
3964
- }
3965
- method = 'privateGetIsolatedAccounts';
3965
+ response = await this.privateGetIsolatedAccounts(this.extend(request, params));
3966
3966
  }
3967
3967
  else {
3968
- if (code !== undefined) {
3969
- const currency = this.currency(code);
3970
- request['currency'] = currency['id'];
3971
- }
3968
+ response = await this.privateGetMarginAccounts(this.extend(request, params));
3972
3969
  }
3973
- const response = await this[method](this.extend(request, params));
3974
3970
  //
3975
3971
  // Cross
3976
3972
  //
3977
3973
  // {
3978
3974
  // "code": "200000",
3979
3975
  // "data": {
3980
- // "currentPage": 1,
3981
- // "pageSize": 10,
3982
- // "totalNum": 1,
3983
- // "totalPage": 1,
3984
- // "items": [
3976
+ // "totalAssetOfQuoteCurrency": "0",
3977
+ // "totalLiabilityOfQuoteCurrency": "0",
3978
+ // "debtRatio": "0",
3979
+ // "status": "EFFECTIVE",
3980
+ // "accounts": [
3985
3981
  // {
3986
- // "tradeId": "62e1e320ff219600013b44e2",
3987
- // "currency": "USDT",
3988
- // "principal": "100",
3989
- // "accruedInterest": "0.00016667",
3990
- // "liability": "100.00016667",
3991
- // "repaidSize": "0",
3992
- // "dailyIntRate": "0.00004",
3993
- // "term": 7,
3994
- // "createdAt": 1658970912000,
3995
- // "maturityTime": 1659575713000
3982
+ // "currency": "1INCH",
3983
+ // "total": "0",
3984
+ // "available": "0",
3985
+ // "hold": "0",
3986
+ // "liability": "0",
3987
+ // "maxBorrowSize": "0",
3988
+ // "borrowEnabled": true,
3989
+ // "transferInEnabled": true
3996
3990
  // }
3997
3991
  // ]
3998
3992
  // }
@@ -4007,34 +4001,38 @@ export default class kucoin extends Exchange {
4007
4001
  // "liabilityConversionBalance": "0.01480001",
4008
4002
  // "assets": [
4009
4003
  // {
4010
- // "symbol": "NKN-USDT",
4011
- // "status": "CLEAR",
4004
+ // "symbol": "MANA-USDT",
4012
4005
  // "debtRatio": "0",
4006
+ // "status": "BORROW",
4013
4007
  // "baseAsset": {
4014
- // "currency": "NKN",
4015
- // "totalBalance": "0",
4016
- // "holdBalance": "0",
4017
- // "availableBalance": "0",
4018
- // "liability": "0",
4019
- // "interest": "0",
4020
- // "borrowableAmount": "0"
4008
+ // "currency": "MANA",
4009
+ // "borrowEnabled": true,
4010
+ // "repayEnabled": true,
4011
+ // "transferEnabled": true,
4012
+ // "borrowed": "0",
4013
+ // "totalAsset": "0",
4014
+ // "available": "0",
4015
+ // "hold": "0",
4016
+ // "maxBorrowSize": "1000"
4021
4017
  // },
4022
4018
  // "quoteAsset": {
4023
4019
  // "currency": "USDT",
4024
- // "totalBalance": "0",
4025
- // "holdBalance": "0",
4026
- // "availableBalance": "0",
4027
- // "liability": "0",
4028
- // "interest": "0",
4029
- // "borrowableAmount": "0"
4020
+ // "borrowEnabled": true,
4021
+ // "repayEnabled": true,
4022
+ // "transferEnabled": true,
4023
+ // "borrowed": "0",
4024
+ // "totalAsset": "0",
4025
+ // "available": "0",
4026
+ // "hold": "0",
4027
+ // "maxBorrowSize": "50000"
4030
4028
  // }
4031
- // },
4029
+ // }
4032
4030
  // ]
4033
4031
  // }
4034
4032
  // }
4035
4033
  //
4036
4034
  const data = this.safeValue(response, 'data', {});
4037
- const assets = (marginMode === 'isolated') ? this.safeValue(data, 'assets', []) : this.safeValue(data, 'items', []);
4035
+ const assets = (marginMode === 'isolated') ? this.safeValue(data, 'assets', []) : this.safeValue(data, 'accounts', []);
4038
4036
  return this.parseBorrowInterests(assets, undefined);
4039
4037
  }
4040
4038
  parseBorrowInterest(info, market = undefined) {
@@ -4042,43 +4040,45 @@ export default class kucoin extends Exchange {
4042
4040
  // Cross
4043
4041
  //
4044
4042
  // {
4045
- // "tradeId": "62e1e320ff219600013b44e2",
4046
- // "currency": "USDT",
4047
- // "principal": "100",
4048
- // "accruedInterest": "0.00016667",
4049
- // "liability": "100.00016667",
4050
- // "repaidSize": "0",
4051
- // "dailyIntRate": "0.00004",
4052
- // "term": 7,
4053
- // "createdAt": 1658970912000,
4054
- // "maturityTime": 1659575713000
4055
- // },
4043
+ // "currency": "1INCH",
4044
+ // "total": "0",
4045
+ // "available": "0",
4046
+ // "hold": "0",
4047
+ // "liability": "0",
4048
+ // "maxBorrowSize": "0",
4049
+ // "borrowEnabled": true,
4050
+ // "transferInEnabled": true
4051
+ // }
4056
4052
  //
4057
4053
  // Isolated
4058
4054
  //
4059
4055
  // {
4060
- // "symbol": "BTC-USDT",
4061
- // "status": "CLEAR",
4056
+ // "symbol": "MANA-USDT",
4062
4057
  // "debtRatio": "0",
4058
+ // "status": "BORROW",
4063
4059
  // "baseAsset": {
4064
- // "currency": "BTC",
4065
- // "totalBalance": "0",
4066
- // "holdBalance": "0",
4067
- // "availableBalance": "0",
4068
- // "liability": "0",
4069
- // "interest": "0",
4070
- // "borrowableAmount": "0.0592"
4060
+ // "currency": "MANA",
4061
+ // "borrowEnabled": true,
4062
+ // "repayEnabled": true,
4063
+ // "transferEnabled": true,
4064
+ // "borrowed": "0",
4065
+ // "totalAsset": "0",
4066
+ // "available": "0",
4067
+ // "hold": "0",
4068
+ // "maxBorrowSize": "1000"
4071
4069
  // },
4072
4070
  // "quoteAsset": {
4073
4071
  // "currency": "USDT",
4074
- // "totalBalance": "149.99991731",
4075
- // "holdBalance": "0",
4076
- // "availableBalance": "149.99991731",
4077
- // "liability": "0",
4078
- // "interest": "0",
4079
- // "borrowableAmount": "1349"
4072
+ // "borrowEnabled": true,
4073
+ // "repayEnabled": true,
4074
+ // "transferEnabled": true,
4075
+ // "borrowed": "0",
4076
+ // "totalAsset": "0",
4077
+ // "available": "0",
4078
+ // "hold": "0",
4079
+ // "maxBorrowSize": "50000"
4080
4080
  // }
4081
- // },
4081
+ // }
4082
4082
  //
4083
4083
  const marketId = this.safeString(info, 'symbol');
4084
4084
  const marginMode = (marketId === undefined) ? 'cross' : 'isolated';
@@ -4095,7 +4095,7 @@ export default class kucoin extends Exchange {
4095
4095
  currencyId = this.safeString(isolatedBase, 'currency');
4096
4096
  }
4097
4097
  else {
4098
- amountBorrowed = this.safeNumber(info, 'principal');
4098
+ amountBorrowed = this.safeNumber(info, 'liability');
4099
4099
  interest = this.safeNumber(info, 'accruedInterest');
4100
4100
  currencyId = this.safeString(info, 'currency');
4101
4101
  }
@@ -4111,41 +4111,64 @@ export default class kucoin extends Exchange {
4111
4111
  'info': info,
4112
4112
  };
4113
4113
  }
4114
- async borrowMargin(code, amount, symbol = undefined, params = {}) {
4114
+ async borrowCrossMargin(code, amount, params = {}) {
4115
4115
  /**
4116
4116
  * @method
4117
- * @name kucoin#borrowMargin
4117
+ * @name kucoin#borrowCrossMargin
4118
4118
  * @description create a loan to borrow margin
4119
4119
  * @see https://docs.kucoin.com/#1-margin-borrowing
4120
4120
  * @param {string} code unified currency code of the currency to borrow
4121
4121
  * @param {float} amount the amount to borrow
4122
+ * @param {object} [params] extra parameters specific to the kucoin api endpoints
4123
+ * @param {string} [params.timeInForce] either IOC or FOK
4124
+ * @returns {object} a [margin loan structure]{@link https://docs.ccxt.com/#/?id=margin-loan-structure}
4125
+ */
4126
+ await this.loadMarkets();
4127
+ const currency = this.currency(code);
4128
+ const request = {
4129
+ 'currency': currency['id'],
4130
+ 'size': this.currencyToPrecision(code, amount),
4131
+ 'timeInForce': 'FOK',
4132
+ };
4133
+ const response = await this.privatePostMarginBorrow(this.extend(request, params));
4134
+ //
4135
+ // {
4136
+ // "success": true,
4137
+ // "code": "200",
4138
+ // "msg": "success",
4139
+ // "retry": false,
4140
+ // "data": {
4141
+ // "orderNo": "5da6dba0f943c0c81f5d5db5",
4142
+ // "actualSize": 10
4143
+ // }
4144
+ // }
4145
+ //
4146
+ const data = this.safeValue(response, 'data', {});
4147
+ return this.parseMarginLoan(data, currency);
4148
+ }
4149
+ async borrowIsolatedMargin(symbol, code, amount, params = {}) {
4150
+ /**
4151
+ * @method
4152
+ * @name kucoin#borrowIsolatedMargin
4153
+ * @description create a loan to borrow margin
4154
+ * @see https://docs.kucoin.com/#1-margin-borrowing
4122
4155
  * @param {string} symbol unified market symbol, required for isolated margin
4156
+ * @param {string} code unified currency code of the currency to borrow
4157
+ * @param {float} amount the amount to borrow
4123
4158
  * @param {object} [params] extra parameters specific to the kucoin api endpoints
4124
4159
  * @param {string} [params.timeInForce] either IOC or FOK
4125
- * @param {string} [params.marginMode] 'cross' or 'isolated' default is 'cross'
4126
4160
  * @returns {object} a [margin loan structure]{@link https://docs.ccxt.com/#/?id=margin-loan-structure}
4127
4161
  */
4128
- const marginMode = this.safeString(params, 'marginMode'); // cross or isolated
4129
- const isIsolated = marginMode === 'isolated';
4130
- params = this.omit(params, 'marginMode');
4131
- this.checkRequiredMarginArgument('borrowMargin', symbol, marginMode);
4132
4162
  await this.loadMarkets();
4163
+ const market = this.market(symbol);
4133
4164
  const currency = this.currency(code);
4134
4165
  const request = {
4135
4166
  'currency': currency['id'],
4136
4167
  'size': this.currencyToPrecision(code, amount),
4168
+ 'symbol': market['id'],
4169
+ 'timeInForce': 'FOK',
4170
+ 'isIsolated': true,
4137
4171
  };
4138
- const timeInForce = this.safeStringN(params, ['timeInForce', 'type', 'borrowStrategy'], 'IOC');
4139
- if (isIsolated) {
4140
- if (symbol === undefined) {
4141
- throw new ArgumentsRequired(this.id + ' borrowMargin() requires a symbol parameter for isolated margin');
4142
- }
4143
- const market = this.market(symbol);
4144
- request['symbol'] = market['id'];
4145
- request['isIsolated'] = true;
4146
- }
4147
- params = this.omit(params, ['timeInForce', 'type', 'borrowStrategy']);
4148
- request['timeInForce'] = timeInForce;
4149
4172
  const response = await this.privatePostMarginBorrow(this.extend(request, params));
4150
4173
  //
4151
4174
  // {
@@ -4162,37 +4185,60 @@ export default class kucoin extends Exchange {
4162
4185
  const data = this.safeValue(response, 'data', {});
4163
4186
  return this.parseMarginLoan(data, currency);
4164
4187
  }
4165
- async repayMargin(code, amount, symbol = undefined, params = {}) {
4188
+ async repayCrossMargin(code, amount, params = {}) {
4166
4189
  /**
4167
4190
  * @method
4168
- * @name kucoin#repayMargin
4191
+ * @name kucoin#repayCrossMargin
4169
4192
  * @description repay borrowed margin and interest
4170
4193
  * @see https://docs.kucoin.com/#2-repayment
4171
4194
  * @param {string} code unified currency code of the currency to repay
4172
4195
  * @param {float} amount the amount to repay
4196
+ * @param {object} [params] extra parameters specific to the kucoin api endpoints
4197
+ * @returns {object} a [margin loan structure]{@link https://docs.ccxt.com/#/?id=margin-loan-structure}
4198
+ */
4199
+ await this.loadMarkets();
4200
+ const currency = this.currency(code);
4201
+ const request = {
4202
+ 'currency': currency['id'],
4203
+ 'size': this.currencyToPrecision(code, amount),
4204
+ };
4205
+ const response = await this.privatePostMarginRepay(this.extend(request, params));
4206
+ //
4207
+ // {
4208
+ // "success": true,
4209
+ // "code": "200",
4210
+ // "msg": "success",
4211
+ // "retry": false,
4212
+ // "data": {
4213
+ // "orderNo": "5da6dba0f943c0c81f5d5db5",
4214
+ // "actualSize": 10
4215
+ // }
4216
+ // }
4217
+ //
4218
+ const data = this.safeValue(response, 'data', {});
4219
+ return this.parseMarginLoan(data, currency);
4220
+ }
4221
+ async repayIsolatedMargin(symbol, code, amount, params = {}) {
4222
+ /**
4223
+ * @method
4224
+ * @name kucoin#repayIsolatedMargin
4225
+ * @description repay borrowed margin and interest
4226
+ * @see https://docs.kucoin.com/#2-repayment
4173
4227
  * @param {string} symbol unified market symbol
4228
+ * @param {string} code unified currency code of the currency to repay
4229
+ * @param {float} amount the amount to repay
4174
4230
  * @param {object} [params] extra parameters specific to the kucoin api endpoints
4175
- * @param {string} [params.marginMode] 'cross' or 'isolated' default is 'cross'
4176
4231
  * @returns {object} a [margin loan structure]{@link https://docs.ccxt.com/#/?id=margin-loan-structure}
4177
4232
  */
4178
- const marginMode = this.safeString(params, 'marginMode'); // cross or isolated
4179
- const isIsolated = marginMode === 'isolated';
4180
- params = this.omit(params, 'marginMode');
4181
- this.checkRequiredMarginArgument('repayMargin', symbol, marginMode);
4182
4233
  await this.loadMarkets();
4234
+ const market = this.market(symbol);
4183
4235
  const currency = this.currency(code);
4184
4236
  const request = {
4185
4237
  'currency': currency['id'],
4186
4238
  'size': this.currencyToPrecision(code, amount),
4239
+ 'symbol': market['id'],
4240
+ 'isIsolated': true,
4187
4241
  };
4188
- if (isIsolated) {
4189
- if (symbol === undefined) {
4190
- throw new ArgumentsRequired(this.id + ' repayMargin() requires a symbol parameter for isolated margin');
4191
- }
4192
- const market = this.market(symbol);
4193
- request['symbol'] = market['id'];
4194
- request['isIsolated'] = true;
4195
- }
4196
4242
  const response = await this.privatePostMarginRepay(this.extend(request, params));
4197
4243
  //
4198
4244
  // {
package/js/src/mexc.d.ts CHANGED
@@ -159,8 +159,6 @@ export default class mexc extends Exchange {
159
159
  info: any;
160
160
  hedged: boolean;
161
161
  }>;
162
- borrowMargin(code: string, amount: any, symbol?: Str, params?: {}): Promise<any>;
163
- repayMargin(code: string, amount: any, symbol?: Str, params?: {}): Promise<any>;
164
162
  fetchTransactionFees(codes?: any, params?: {}): Promise<{
165
163
  withdraw: {};
166
164
  deposit: {};
@@ -174,15 +172,6 @@ export default class mexc extends Exchange {
174
172
  parseTransactionFee(transaction: any, currency?: Currency): {};
175
173
  fetchDepositWithdrawFees(codes?: Strings, params?: {}): Promise<any>;
176
174
  parseDepositWithdrawFee(fee: any, currency?: Currency): any;
177
- parseMarginLoan(info: any, currency?: Currency): {
178
- id: string;
179
- currency: string;
180
- amount: any;
181
- symbol: any;
182
- timestamp: any;
183
- datetime: any;
184
- info: any;
185
- };
186
175
  handleMarginModeAndParams(methodName: any, params?: {}, defaultValue?: any): any[];
187
176
  sign(path: any, api?: string, method?: string, params?: {}, headers?: any, body?: any): {
188
177
  url: any;