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.
- package/README.md +5 -5
- package/build.sh +2 -2
- package/dist/ccxt.browser.js +1017 -1031
- package/dist/ccxt.browser.min.js +2 -2
- package/dist/cjs/ccxt.js +1 -19
- package/dist/cjs/src/base/Exchange.js +45 -24
- package/dist/cjs/src/base/ws/Client.js +1 -1
- package/dist/cjs/src/binance.js +71 -22
- package/dist/cjs/src/bitget.js +74 -52
- package/dist/cjs/src/bitmart.js +10 -18
- package/dist/cjs/src/bitrue.js +1 -1
- package/dist/cjs/src/bybit.js +36 -33
- package/dist/cjs/src/coinbasepro.js +15 -0
- package/dist/cjs/src/coinex.js +25 -30
- package/dist/cjs/src/htx.js +82 -39
- package/dist/cjs/src/kucoin.js +209 -163
- package/dist/cjs/src/mexc.js +21 -118
- package/dist/cjs/src/okx.js +23 -17
- package/dist/cjs/src/pro/bitget.js +7 -0
- package/dist/cjs/src/pro/bitmart.js +7 -0
- package/dist/cjs/src/pro/bitvavo.js +9 -0
- package/dist/cjs/src/pro/bybit.js +9 -0
- package/dist/cjs/src/pro/htx.js +86 -61
- package/dist/cjs/src/pro/kucoin.js +7 -0
- package/dist/cjs/src/pro/mexc.js +9 -0
- package/js/ccxt.d.ts +2 -23
- package/js/ccxt.js +2 -16
- package/js/src/abstract/binance.d.ts +1 -0
- package/js/src/abstract/binancecoinm.d.ts +1 -0
- package/js/src/abstract/binanceus.d.ts +1 -0
- package/js/src/abstract/binanceusdm.d.ts +1 -0
- package/js/src/abstract/mexc.d.ts +0 -4
- package/js/src/base/Exchange.d.ts +9 -2
- package/js/src/base/Exchange.js +45 -24
- package/js/src/base/ws/Client.js +1 -1
- package/js/src/binance.d.ts +20 -2
- package/js/src/binance.js +71 -22
- package/js/src/bitget.d.ts +20 -2
- package/js/src/bitget.js +74 -52
- package/js/src/bitmart.d.ts +2 -2
- package/js/src/bitmart.js +10 -18
- package/js/src/bitrue.js +1 -1
- package/js/src/bybit.d.ts +2 -2
- package/js/src/bybit.js +36 -33
- package/js/src/coinbasepro.js +15 -0
- package/js/src/coinex.d.ts +2 -2
- package/js/src/coinex.js +25 -30
- package/js/src/htx.d.ts +5 -3
- package/js/src/htx.js +82 -39
- package/js/src/kucoin.d.ts +20 -2
- package/js/src/kucoin.js +209 -163
- package/js/src/mexc.d.ts +0 -11
- package/js/src/mexc.js +21 -118
- package/js/src/okx.d.ts +19 -2
- package/js/src/okx.js +23 -17
- package/js/src/pro/bitget.js +7 -0
- package/js/src/pro/bitmart.js +7 -0
- package/js/src/pro/bitvavo.js +9 -0
- package/js/src/pro/bybit.js +9 -0
- package/js/src/pro/htx.d.ts +2 -2
- package/js/src/pro/htx.js +86 -61
- package/js/src/pro/kucoin.js +7 -0
- package/js/src/pro/mexc.js +9 -0
- package/package.json +1 -1
- package/skip-tests.json +5 -1
- package/js/src/abstract/huobipro.d.ts +0 -547
- package/js/src/abstract/huobipro.js +0 -11
- package/js/src/abstract/mexc3.d.ts +0 -180
- package/js/src/abstract/mexc3.js +0 -11
- package/js/src/abstract/okex.d.ts +0 -280
- package/js/src/abstract/okex.js +0 -11
- package/js/src/abstract/okex5.d.ts +0 -280
- 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
|
-
'
|
|
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
|
-
'
|
|
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
|
|
2226
|
+
let response = undefined;
|
|
2225
2227
|
if (stop) {
|
|
2226
|
-
|
|
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
|
-
|
|
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
|
|
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
|
-
|
|
2296
|
+
request['tradeType'] = this.safeString(this.options['marginModes'], marginMode, 'TRADE');
|
|
2297
|
+
let response = undefined;
|
|
2292
2298
|
if (stop) {
|
|
2293
|
-
|
|
2299
|
+
response = await this.privateGetStopOrder(this.extend(request, query));
|
|
2294
2300
|
}
|
|
2295
2301
|
else if (hf) {
|
|
2296
2302
|
if (lowercaseStatus === 'active') {
|
|
2297
|
-
|
|
2303
|
+
response = await this.privateGetHfOrdersActive(this.extend(request, query));
|
|
2298
2304
|
}
|
|
2299
2305
|
else if (lowercaseStatus === 'done') {
|
|
2300
|
-
|
|
2306
|
+
response = await this.privateGetHfOrdersDone(this.extend(request, query));
|
|
2301
2307
|
}
|
|
2302
2308
|
}
|
|
2303
|
-
|
|
2304
|
-
|
|
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
|
|
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
|
-
|
|
2467
|
+
response = await this.privateGetHfOrdersClientOrderClientOid(this.extend(request, params));
|
|
2461
2468
|
}
|
|
2462
2469
|
else {
|
|
2463
|
-
|
|
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
|
-
|
|
2482
|
+
response = await this.privateGetStopOrderOrderId(this.extend(request, params));
|
|
2475
2483
|
}
|
|
2476
2484
|
else if (hf) {
|
|
2477
|
-
|
|
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 (
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
3228
|
-
|
|
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
|
-
|
|
3231
|
-
|
|
3232
|
-
|
|
3233
|
-
|
|
3234
|
-
|
|
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
|
-
|
|
3312
|
-
|
|
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
|
-
|
|
3315
|
-
|
|
3316
|
-
|
|
3317
|
-
|
|
3318
|
-
|
|
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
|
|
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
|
-
|
|
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
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
// "
|
|
3981
|
-
// "
|
|
3982
|
-
// "
|
|
3983
|
-
// "
|
|
3984
|
-
// "
|
|
3976
|
+
// "totalAssetOfQuoteCurrency": "0",
|
|
3977
|
+
// "totalLiabilityOfQuoteCurrency": "0",
|
|
3978
|
+
// "debtRatio": "0",
|
|
3979
|
+
// "status": "EFFECTIVE",
|
|
3980
|
+
// "accounts": [
|
|
3985
3981
|
// {
|
|
3986
|
-
// "
|
|
3987
|
-
// "
|
|
3988
|
-
// "
|
|
3989
|
-
// "
|
|
3990
|
-
// "liability": "
|
|
3991
|
-
// "
|
|
3992
|
-
// "
|
|
3993
|
-
// "
|
|
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": "
|
|
4011
|
-
// "status": "CLEAR",
|
|
4004
|
+
// "symbol": "MANA-USDT",
|
|
4012
4005
|
// "debtRatio": "0",
|
|
4006
|
+
// "status": "BORROW",
|
|
4013
4007
|
// "baseAsset": {
|
|
4014
|
-
// "currency": "
|
|
4015
|
-
// "
|
|
4016
|
-
// "
|
|
4017
|
-
// "
|
|
4018
|
-
// "
|
|
4019
|
-
// "
|
|
4020
|
-
// "
|
|
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
|
-
// "
|
|
4025
|
-
// "
|
|
4026
|
-
// "
|
|
4027
|
-
// "
|
|
4028
|
-
// "
|
|
4029
|
-
// "
|
|
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, '
|
|
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
|
-
// "
|
|
4046
|
-
// "
|
|
4047
|
-
// "
|
|
4048
|
-
// "
|
|
4049
|
-
// "liability": "
|
|
4050
|
-
// "
|
|
4051
|
-
// "
|
|
4052
|
-
// "
|
|
4053
|
-
//
|
|
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": "
|
|
4061
|
-
// "status": "CLEAR",
|
|
4056
|
+
// "symbol": "MANA-USDT",
|
|
4062
4057
|
// "debtRatio": "0",
|
|
4058
|
+
// "status": "BORROW",
|
|
4063
4059
|
// "baseAsset": {
|
|
4064
|
-
// "currency": "
|
|
4065
|
-
// "
|
|
4066
|
-
// "
|
|
4067
|
-
// "
|
|
4068
|
-
// "
|
|
4069
|
-
// "
|
|
4070
|
-
// "
|
|
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
|
-
// "
|
|
4075
|
-
// "
|
|
4076
|
-
// "
|
|
4077
|
-
// "
|
|
4078
|
-
// "
|
|
4079
|
-
// "
|
|
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, '
|
|
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
|
|
4114
|
+
async borrowCrossMargin(code, amount, params = {}) {
|
|
4115
4115
|
/**
|
|
4116
4116
|
* @method
|
|
4117
|
-
* @name kucoin#
|
|
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
|
|
4188
|
+
async repayCrossMargin(code, amount, params = {}) {
|
|
4166
4189
|
/**
|
|
4167
4190
|
* @method
|
|
4168
|
-
* @name kucoin#
|
|
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;
|