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/dist/cjs/src/kucoin.js
CHANGED
|
@@ -31,7 +31,8 @@ class kucoin extends kucoin$1 {
|
|
|
31
31
|
'swap': false,
|
|
32
32
|
'future': false,
|
|
33
33
|
'option': false,
|
|
34
|
-
'
|
|
34
|
+
'borrowCrossMargin': true,
|
|
35
|
+
'borrowIsolatedMargin': true,
|
|
35
36
|
'cancelAllOrders': true,
|
|
36
37
|
'cancelOrder': true,
|
|
37
38
|
'createDepositAddress': true,
|
|
@@ -92,7 +93,8 @@ class kucoin extends kucoin$1 {
|
|
|
92
93
|
'fetchTransactionFee': true,
|
|
93
94
|
'fetchTransfers': false,
|
|
94
95
|
'fetchWithdrawals': true,
|
|
95
|
-
'
|
|
96
|
+
'repayCrossMargin': true,
|
|
97
|
+
'repayIsolatedMargin': true,
|
|
96
98
|
'setLeverage': false,
|
|
97
99
|
'setMarginMode': false,
|
|
98
100
|
'setPositionMode': false,
|
|
@@ -2218,17 +2220,20 @@ class kucoin extends kucoin$1 {
|
|
|
2218
2220
|
throw new errors.BadRequest(this.id + ' cancelAllOrders does not support isolated margin for stop orders');
|
|
2219
2221
|
}
|
|
2220
2222
|
}
|
|
2221
|
-
let
|
|
2223
|
+
let response = undefined;
|
|
2222
2224
|
if (stop) {
|
|
2223
|
-
|
|
2225
|
+
response = await this.privateDeleteStopOrderCancel(this.extend(request, query));
|
|
2224
2226
|
}
|
|
2225
2227
|
else if (hf) {
|
|
2226
2228
|
if (symbol === undefined) {
|
|
2227
2229
|
throw new errors.ArgumentsRequired(this.id + ' cancelAllOrders() requires a symbol parameter for hf orders');
|
|
2228
2230
|
}
|
|
2229
|
-
|
|
2231
|
+
response = await this.privateDeleteHfOrders(this.extend(request, query));
|
|
2232
|
+
}
|
|
2233
|
+
else {
|
|
2234
|
+
response = await this.privateDeleteOrders(this.extend(request, query));
|
|
2230
2235
|
}
|
|
2231
|
-
return
|
|
2236
|
+
return response;
|
|
2232
2237
|
}
|
|
2233
2238
|
async fetchOrdersByStatus(status, symbol = undefined, since = undefined, limit = undefined, params = {}) {
|
|
2234
2239
|
/**
|
|
@@ -2285,20 +2290,22 @@ class kucoin extends kucoin$1 {
|
|
|
2285
2290
|
if (until) {
|
|
2286
2291
|
request['endAt'] = until;
|
|
2287
2292
|
}
|
|
2288
|
-
|
|
2293
|
+
request['tradeType'] = this.safeString(this.options['marginModes'], marginMode, 'TRADE');
|
|
2294
|
+
let response = undefined;
|
|
2289
2295
|
if (stop) {
|
|
2290
|
-
|
|
2296
|
+
response = await this.privateGetStopOrder(this.extend(request, query));
|
|
2291
2297
|
}
|
|
2292
2298
|
else if (hf) {
|
|
2293
2299
|
if (lowercaseStatus === 'active') {
|
|
2294
|
-
|
|
2300
|
+
response = await this.privateGetHfOrdersActive(this.extend(request, query));
|
|
2295
2301
|
}
|
|
2296
2302
|
else if (lowercaseStatus === 'done') {
|
|
2297
|
-
|
|
2303
|
+
response = await this.privateGetHfOrdersDone(this.extend(request, query));
|
|
2298
2304
|
}
|
|
2299
2305
|
}
|
|
2300
|
-
|
|
2301
|
-
|
|
2306
|
+
else {
|
|
2307
|
+
response = await this.privateGetOrders(this.extend(request, query));
|
|
2308
|
+
}
|
|
2302
2309
|
//
|
|
2303
2310
|
// {
|
|
2304
2311
|
// "code": "200000",
|
|
@@ -2443,21 +2450,21 @@ class kucoin extends kucoin$1 {
|
|
|
2443
2450
|
}
|
|
2444
2451
|
request['symbol'] = market['id'];
|
|
2445
2452
|
}
|
|
2446
|
-
params = this.omit(params, ['stop', 'hf']);
|
|
2447
|
-
let
|
|
2453
|
+
params = this.omit(params, ['stop', 'hf', 'clientOid', 'clientOrderId']);
|
|
2454
|
+
let response = undefined;
|
|
2448
2455
|
if (clientOrderId !== undefined) {
|
|
2449
2456
|
request['clientOid'] = clientOrderId;
|
|
2450
2457
|
if (stop) {
|
|
2451
|
-
method = 'privateGetStopOrderQueryOrderByClientOid';
|
|
2452
2458
|
if (symbol !== undefined) {
|
|
2453
2459
|
request['symbol'] = market['id'];
|
|
2454
2460
|
}
|
|
2461
|
+
response = await this.privateGetStopOrderQueryOrderByClientOid(this.extend(request, params));
|
|
2455
2462
|
}
|
|
2456
2463
|
else if (hf) {
|
|
2457
|
-
|
|
2464
|
+
response = await this.privateGetHfOrdersClientOrderClientOid(this.extend(request, params));
|
|
2458
2465
|
}
|
|
2459
2466
|
else {
|
|
2460
|
-
|
|
2467
|
+
response = await this.privateGetOrderClientOrderClientOid(this.extend(request, params));
|
|
2461
2468
|
}
|
|
2462
2469
|
}
|
|
2463
2470
|
else {
|
|
@@ -2467,18 +2474,19 @@ class kucoin extends kucoin$1 {
|
|
|
2467
2474
|
if (id === undefined) {
|
|
2468
2475
|
throw new errors.InvalidOrder(this.id + ' fetchOrder() requires an order id');
|
|
2469
2476
|
}
|
|
2477
|
+
request['orderId'] = id;
|
|
2470
2478
|
if (stop) {
|
|
2471
|
-
|
|
2479
|
+
response = await this.privateGetStopOrderOrderId(this.extend(request, params));
|
|
2472
2480
|
}
|
|
2473
2481
|
else if (hf) {
|
|
2474
|
-
|
|
2482
|
+
response = await this.privateGetHfOrdersOrderId(this.extend(request, params));
|
|
2483
|
+
}
|
|
2484
|
+
else {
|
|
2485
|
+
response = await this.privateGetOrdersOrderId(this.extend(request, params));
|
|
2475
2486
|
}
|
|
2476
|
-
request['orderId'] = id;
|
|
2477
2487
|
}
|
|
2478
|
-
params = this.omit(params, ['clientOid', 'clientOrderId']);
|
|
2479
|
-
const response = await this[method](this.extend(request, params));
|
|
2480
2488
|
let responseData = this.safeValue(response, 'data');
|
|
2481
|
-
if (
|
|
2489
|
+
if (Array.isArray(responseData)) {
|
|
2482
2490
|
responseData = this.safeValue(responseData, 0);
|
|
2483
2491
|
}
|
|
2484
2492
|
return this.parseOrder(responseData, market);
|
|
@@ -2720,10 +2728,12 @@ class kucoin extends kucoin$1 {
|
|
|
2720
2728
|
if (limit !== undefined) {
|
|
2721
2729
|
request['pageSize'] = limit;
|
|
2722
2730
|
}
|
|
2723
|
-
|
|
2731
|
+
const method = this.options['fetchMyTradesMethod'];
|
|
2724
2732
|
let parseResponseData = false;
|
|
2733
|
+
let response = undefined;
|
|
2734
|
+
[request, params] = this.handleUntilOption('endAt', request, params);
|
|
2725
2735
|
if (hf) {
|
|
2726
|
-
|
|
2736
|
+
response = await this.privateGetHfFills(this.extend(request, params));
|
|
2727
2737
|
}
|
|
2728
2738
|
else if (method === 'private_get_fills') {
|
|
2729
2739
|
// does not return trades earlier than 2019-02-18T00:00:00Z
|
|
@@ -2731,26 +2741,18 @@ class kucoin extends kucoin$1 {
|
|
|
2731
2741
|
// only returns trades up to one week after the since param
|
|
2732
2742
|
request['startAt'] = since;
|
|
2733
2743
|
}
|
|
2744
|
+
response = await this.privateGetFills(this.extend(request, params));
|
|
2734
2745
|
}
|
|
2735
2746
|
else if (method === 'private_get_limit_fills') {
|
|
2736
2747
|
// does not return trades earlier than 2019-02-18T00:00:00Z
|
|
2737
2748
|
// takes no params
|
|
2738
2749
|
// only returns first 1000 trades (not only "in the last 24 hours" as stated in the docs)
|
|
2739
2750
|
parseResponseData = true;
|
|
2740
|
-
|
|
2741
|
-
else if (method === 'private_get_hist_orders') {
|
|
2742
|
-
// despite that this endpoint is called `HistOrders`
|
|
2743
|
-
// it returns historical trades instead of orders
|
|
2744
|
-
// returns trades earlier than 2019-02-18T00:00:00Z only
|
|
2745
|
-
if (since !== undefined) {
|
|
2746
|
-
request['startAt'] = this.parseToInt(since / 1000);
|
|
2747
|
-
}
|
|
2751
|
+
response = await this.privateGetLimitFills(this.extend(request, params));
|
|
2748
2752
|
}
|
|
2749
2753
|
else {
|
|
2750
2754
|
throw new errors.ExchangeError(this.id + ' fetchMyTradesMethod() invalid method');
|
|
2751
2755
|
}
|
|
2752
|
-
[request, params] = this.handleUntilOption('endAt', request, params);
|
|
2753
|
-
const response = await this[method](this.extend(request, params));
|
|
2754
2756
|
//
|
|
2755
2757
|
// {
|
|
2756
2758
|
// "currentPage": 1,
|
|
@@ -3193,8 +3195,6 @@ class kucoin extends kucoin$1 {
|
|
|
3193
3195
|
/**
|
|
3194
3196
|
* @method
|
|
3195
3197
|
* @name kucoin#fetchDeposits
|
|
3196
|
-
* @see https://docs.kucoin.com/#get-deposit-list
|
|
3197
|
-
* @see https://docs.kucoin.com/#get-v1-historical-deposits-list
|
|
3198
3198
|
* @description fetch all deposits made to an account
|
|
3199
3199
|
* @see https://docs.kucoin.com/#get-deposit-list
|
|
3200
3200
|
* @see https://docs.kucoin.com/#get-v1-historical-deposits-list
|
|
@@ -3221,19 +3221,19 @@ class kucoin extends kucoin$1 {
|
|
|
3221
3221
|
if (limit !== undefined) {
|
|
3222
3222
|
request['pageSize'] = limit;
|
|
3223
3223
|
}
|
|
3224
|
-
|
|
3225
|
-
|
|
3224
|
+
[request, params] = this.handleUntilOption('endAt', request, params);
|
|
3225
|
+
let response = undefined;
|
|
3226
|
+
if (since !== undefined && since < 1550448000000) {
|
|
3226
3227
|
// if since is earlier than 2019-02-18T00:00:00Z
|
|
3227
|
-
|
|
3228
|
-
|
|
3229
|
-
|
|
3230
|
-
|
|
3231
|
-
|
|
3228
|
+
request['startAt'] = this.parseToInt(since / 1000);
|
|
3229
|
+
response = await this.privateGetHistDeposits(this.extend(request, params));
|
|
3230
|
+
}
|
|
3231
|
+
else {
|
|
3232
|
+
if (since !== undefined) {
|
|
3232
3233
|
request['startAt'] = since;
|
|
3233
3234
|
}
|
|
3235
|
+
response = await this.privateGetDeposits(this.extend(request, params));
|
|
3234
3236
|
}
|
|
3235
|
-
[request, params] = this.handleUntilOption('endAt', request, params);
|
|
3236
|
-
const response = await this[method](this.extend(request, params));
|
|
3237
3237
|
//
|
|
3238
3238
|
// {
|
|
3239
3239
|
// "code": "200000",
|
|
@@ -3305,19 +3305,19 @@ class kucoin extends kucoin$1 {
|
|
|
3305
3305
|
if (limit !== undefined) {
|
|
3306
3306
|
request['pageSize'] = limit;
|
|
3307
3307
|
}
|
|
3308
|
-
|
|
3309
|
-
|
|
3308
|
+
[request, params] = this.handleUntilOption('endAt', request, params);
|
|
3309
|
+
let response = undefined;
|
|
3310
|
+
if (since !== undefined && since < 1550448000000) {
|
|
3310
3311
|
// if since is earlier than 2019-02-18T00:00:00Z
|
|
3311
|
-
|
|
3312
|
-
|
|
3313
|
-
|
|
3314
|
-
|
|
3315
|
-
|
|
3312
|
+
request['startAt'] = this.parseToInt(since / 1000);
|
|
3313
|
+
response = await this.privateGetHistWithdrawals(this.extend(request, params));
|
|
3314
|
+
}
|
|
3315
|
+
else {
|
|
3316
|
+
if (since !== undefined) {
|
|
3316
3317
|
request['startAt'] = since;
|
|
3317
3318
|
}
|
|
3319
|
+
response = await this.privateGetWithdrawals(this.extend(request, params));
|
|
3318
3320
|
}
|
|
3319
|
-
[request, params] = this.handleUntilOption('endAt', request, params);
|
|
3320
|
-
const response = await this[method](this.extend(request, params));
|
|
3321
3321
|
//
|
|
3322
3322
|
// {
|
|
3323
3323
|
// "code": "200000",
|
|
@@ -3394,26 +3394,26 @@ class kucoin extends kucoin$1 {
|
|
|
3394
3394
|
const type = this.safeString(accountsByType, requestedType, requestedType);
|
|
3395
3395
|
params = this.omit(params, 'type');
|
|
3396
3396
|
const [marginMode, query] = this.handleMarginModeAndParams('fetchBalance', params);
|
|
3397
|
-
let
|
|
3397
|
+
let response = undefined;
|
|
3398
3398
|
const request = {};
|
|
3399
3399
|
const isolated = (marginMode === 'isolated') || (type === 'isolated');
|
|
3400
3400
|
const cross = (marginMode === 'cross') || (type === 'cross');
|
|
3401
3401
|
if (isolated) {
|
|
3402
|
-
method = 'privateGetIsolatedAccounts';
|
|
3403
3402
|
if (currency !== undefined) {
|
|
3404
3403
|
request['balanceCurrency'] = currency['id'];
|
|
3405
3404
|
}
|
|
3405
|
+
response = await this.privateGetIsolatedAccounts(this.extend(request, query));
|
|
3406
3406
|
}
|
|
3407
3407
|
else if (cross) {
|
|
3408
|
-
|
|
3408
|
+
response = await this.privateGetMarginAccount(this.extend(request, query));
|
|
3409
3409
|
}
|
|
3410
3410
|
else {
|
|
3411
3411
|
if (currency !== undefined) {
|
|
3412
3412
|
request['currency'] = currency['id'];
|
|
3413
3413
|
}
|
|
3414
3414
|
request['type'] = type;
|
|
3415
|
+
response = await this.privateGetAccounts(this.extend(request, query));
|
|
3415
3416
|
}
|
|
3416
|
-
const response = await this[method](this.extend(request, query));
|
|
3417
3417
|
//
|
|
3418
3418
|
// Spot and Cross
|
|
3419
3419
|
//
|
|
@@ -3953,43 +3953,37 @@ class kucoin extends kucoin$1 {
|
|
|
3953
3953
|
marginMode = 'cross'; // cross as default marginMode
|
|
3954
3954
|
}
|
|
3955
3955
|
const request = {};
|
|
3956
|
-
let
|
|
3956
|
+
let response = undefined;
|
|
3957
|
+
if (code !== undefined) {
|
|
3958
|
+
const currency = this.currency(code);
|
|
3959
|
+
request['quoteCurrency'] = currency['id'];
|
|
3960
|
+
}
|
|
3957
3961
|
if (marginMode === 'isolated') {
|
|
3958
|
-
|
|
3959
|
-
const currency = this.currency(code);
|
|
3960
|
-
request['balanceCurrency'] = currency['id'];
|
|
3961
|
-
}
|
|
3962
|
-
method = 'privateGetIsolatedAccounts';
|
|
3962
|
+
response = await this.privateGetIsolatedAccounts(this.extend(request, params));
|
|
3963
3963
|
}
|
|
3964
3964
|
else {
|
|
3965
|
-
|
|
3966
|
-
const currency = this.currency(code);
|
|
3967
|
-
request['currency'] = currency['id'];
|
|
3968
|
-
}
|
|
3965
|
+
response = await this.privateGetMarginAccounts(this.extend(request, params));
|
|
3969
3966
|
}
|
|
3970
|
-
const response = await this[method](this.extend(request, params));
|
|
3971
3967
|
//
|
|
3972
3968
|
// Cross
|
|
3973
3969
|
//
|
|
3974
3970
|
// {
|
|
3975
3971
|
// "code": "200000",
|
|
3976
3972
|
// "data": {
|
|
3977
|
-
// "
|
|
3978
|
-
// "
|
|
3979
|
-
// "
|
|
3980
|
-
// "
|
|
3981
|
-
// "
|
|
3973
|
+
// "totalAssetOfQuoteCurrency": "0",
|
|
3974
|
+
// "totalLiabilityOfQuoteCurrency": "0",
|
|
3975
|
+
// "debtRatio": "0",
|
|
3976
|
+
// "status": "EFFECTIVE",
|
|
3977
|
+
// "accounts": [
|
|
3982
3978
|
// {
|
|
3983
|
-
// "
|
|
3984
|
-
// "
|
|
3985
|
-
// "
|
|
3986
|
-
// "
|
|
3987
|
-
// "liability": "
|
|
3988
|
-
// "
|
|
3989
|
-
// "
|
|
3990
|
-
// "
|
|
3991
|
-
// "createdAt": 1658970912000,
|
|
3992
|
-
// "maturityTime": 1659575713000
|
|
3979
|
+
// "currency": "1INCH",
|
|
3980
|
+
// "total": "0",
|
|
3981
|
+
// "available": "0",
|
|
3982
|
+
// "hold": "0",
|
|
3983
|
+
// "liability": "0",
|
|
3984
|
+
// "maxBorrowSize": "0",
|
|
3985
|
+
// "borrowEnabled": true,
|
|
3986
|
+
// "transferInEnabled": true
|
|
3993
3987
|
// }
|
|
3994
3988
|
// ]
|
|
3995
3989
|
// }
|
|
@@ -4004,34 +3998,38 @@ class kucoin extends kucoin$1 {
|
|
|
4004
3998
|
// "liabilityConversionBalance": "0.01480001",
|
|
4005
3999
|
// "assets": [
|
|
4006
4000
|
// {
|
|
4007
|
-
// "symbol": "
|
|
4008
|
-
// "status": "CLEAR",
|
|
4001
|
+
// "symbol": "MANA-USDT",
|
|
4009
4002
|
// "debtRatio": "0",
|
|
4003
|
+
// "status": "BORROW",
|
|
4010
4004
|
// "baseAsset": {
|
|
4011
|
-
// "currency": "
|
|
4012
|
-
// "
|
|
4013
|
-
// "
|
|
4014
|
-
// "
|
|
4015
|
-
// "
|
|
4016
|
-
// "
|
|
4017
|
-
// "
|
|
4005
|
+
// "currency": "MANA",
|
|
4006
|
+
// "borrowEnabled": true,
|
|
4007
|
+
// "repayEnabled": true,
|
|
4008
|
+
// "transferEnabled": true,
|
|
4009
|
+
// "borrowed": "0",
|
|
4010
|
+
// "totalAsset": "0",
|
|
4011
|
+
// "available": "0",
|
|
4012
|
+
// "hold": "0",
|
|
4013
|
+
// "maxBorrowSize": "1000"
|
|
4018
4014
|
// },
|
|
4019
4015
|
// "quoteAsset": {
|
|
4020
4016
|
// "currency": "USDT",
|
|
4021
|
-
// "
|
|
4022
|
-
// "
|
|
4023
|
-
// "
|
|
4024
|
-
// "
|
|
4025
|
-
// "
|
|
4026
|
-
// "
|
|
4017
|
+
// "borrowEnabled": true,
|
|
4018
|
+
// "repayEnabled": true,
|
|
4019
|
+
// "transferEnabled": true,
|
|
4020
|
+
// "borrowed": "0",
|
|
4021
|
+
// "totalAsset": "0",
|
|
4022
|
+
// "available": "0",
|
|
4023
|
+
// "hold": "0",
|
|
4024
|
+
// "maxBorrowSize": "50000"
|
|
4027
4025
|
// }
|
|
4028
|
-
// }
|
|
4026
|
+
// }
|
|
4029
4027
|
// ]
|
|
4030
4028
|
// }
|
|
4031
4029
|
// }
|
|
4032
4030
|
//
|
|
4033
4031
|
const data = this.safeValue(response, 'data', {});
|
|
4034
|
-
const assets = (marginMode === 'isolated') ? this.safeValue(data, 'assets', []) : this.safeValue(data, '
|
|
4032
|
+
const assets = (marginMode === 'isolated') ? this.safeValue(data, 'assets', []) : this.safeValue(data, 'accounts', []);
|
|
4035
4033
|
return this.parseBorrowInterests(assets, undefined);
|
|
4036
4034
|
}
|
|
4037
4035
|
parseBorrowInterest(info, market = undefined) {
|
|
@@ -4039,43 +4037,45 @@ class kucoin extends kucoin$1 {
|
|
|
4039
4037
|
// Cross
|
|
4040
4038
|
//
|
|
4041
4039
|
// {
|
|
4042
|
-
// "
|
|
4043
|
-
// "
|
|
4044
|
-
// "
|
|
4045
|
-
// "
|
|
4046
|
-
// "liability": "
|
|
4047
|
-
// "
|
|
4048
|
-
// "
|
|
4049
|
-
// "
|
|
4050
|
-
//
|
|
4051
|
-
// "maturityTime": 1659575713000
|
|
4052
|
-
// },
|
|
4040
|
+
// "currency": "1INCH",
|
|
4041
|
+
// "total": "0",
|
|
4042
|
+
// "available": "0",
|
|
4043
|
+
// "hold": "0",
|
|
4044
|
+
// "liability": "0",
|
|
4045
|
+
// "maxBorrowSize": "0",
|
|
4046
|
+
// "borrowEnabled": true,
|
|
4047
|
+
// "transferInEnabled": true
|
|
4048
|
+
// }
|
|
4053
4049
|
//
|
|
4054
4050
|
// Isolated
|
|
4055
4051
|
//
|
|
4056
4052
|
// {
|
|
4057
|
-
// "symbol": "
|
|
4058
|
-
// "status": "CLEAR",
|
|
4053
|
+
// "symbol": "MANA-USDT",
|
|
4059
4054
|
// "debtRatio": "0",
|
|
4055
|
+
// "status": "BORROW",
|
|
4060
4056
|
// "baseAsset": {
|
|
4061
|
-
// "currency": "
|
|
4062
|
-
// "
|
|
4063
|
-
// "
|
|
4064
|
-
// "
|
|
4065
|
-
// "
|
|
4066
|
-
// "
|
|
4067
|
-
// "
|
|
4057
|
+
// "currency": "MANA",
|
|
4058
|
+
// "borrowEnabled": true,
|
|
4059
|
+
// "repayEnabled": true,
|
|
4060
|
+
// "transferEnabled": true,
|
|
4061
|
+
// "borrowed": "0",
|
|
4062
|
+
// "totalAsset": "0",
|
|
4063
|
+
// "available": "0",
|
|
4064
|
+
// "hold": "0",
|
|
4065
|
+
// "maxBorrowSize": "1000"
|
|
4068
4066
|
// },
|
|
4069
4067
|
// "quoteAsset": {
|
|
4070
4068
|
// "currency": "USDT",
|
|
4071
|
-
// "
|
|
4072
|
-
// "
|
|
4073
|
-
// "
|
|
4074
|
-
// "
|
|
4075
|
-
// "
|
|
4076
|
-
// "
|
|
4069
|
+
// "borrowEnabled": true,
|
|
4070
|
+
// "repayEnabled": true,
|
|
4071
|
+
// "transferEnabled": true,
|
|
4072
|
+
// "borrowed": "0",
|
|
4073
|
+
// "totalAsset": "0",
|
|
4074
|
+
// "available": "0",
|
|
4075
|
+
// "hold": "0",
|
|
4076
|
+
// "maxBorrowSize": "50000"
|
|
4077
4077
|
// }
|
|
4078
|
-
// }
|
|
4078
|
+
// }
|
|
4079
4079
|
//
|
|
4080
4080
|
const marketId = this.safeString(info, 'symbol');
|
|
4081
4081
|
const marginMode = (marketId === undefined) ? 'cross' : 'isolated';
|
|
@@ -4092,7 +4092,7 @@ class kucoin extends kucoin$1 {
|
|
|
4092
4092
|
currencyId = this.safeString(isolatedBase, 'currency');
|
|
4093
4093
|
}
|
|
4094
4094
|
else {
|
|
4095
|
-
amountBorrowed = this.safeNumber(info, '
|
|
4095
|
+
amountBorrowed = this.safeNumber(info, 'liability');
|
|
4096
4096
|
interest = this.safeNumber(info, 'accruedInterest');
|
|
4097
4097
|
currencyId = this.safeString(info, 'currency');
|
|
4098
4098
|
}
|
|
@@ -4108,41 +4108,64 @@ class kucoin extends kucoin$1 {
|
|
|
4108
4108
|
'info': info,
|
|
4109
4109
|
};
|
|
4110
4110
|
}
|
|
4111
|
-
async
|
|
4111
|
+
async borrowCrossMargin(code, amount, params = {}) {
|
|
4112
4112
|
/**
|
|
4113
4113
|
* @method
|
|
4114
|
-
* @name kucoin#
|
|
4114
|
+
* @name kucoin#borrowCrossMargin
|
|
4115
4115
|
* @description create a loan to borrow margin
|
|
4116
4116
|
* @see https://docs.kucoin.com/#1-margin-borrowing
|
|
4117
4117
|
* @param {string} code unified currency code of the currency to borrow
|
|
4118
4118
|
* @param {float} amount the amount to borrow
|
|
4119
|
+
* @param {object} [params] extra parameters specific to the kucoin api endpoints
|
|
4120
|
+
* @param {string} [params.timeInForce] either IOC or FOK
|
|
4121
|
+
* @returns {object} a [margin loan structure]{@link https://docs.ccxt.com/#/?id=margin-loan-structure}
|
|
4122
|
+
*/
|
|
4123
|
+
await this.loadMarkets();
|
|
4124
|
+
const currency = this.currency(code);
|
|
4125
|
+
const request = {
|
|
4126
|
+
'currency': currency['id'],
|
|
4127
|
+
'size': this.currencyToPrecision(code, amount),
|
|
4128
|
+
'timeInForce': 'FOK',
|
|
4129
|
+
};
|
|
4130
|
+
const response = await this.privatePostMarginBorrow(this.extend(request, params));
|
|
4131
|
+
//
|
|
4132
|
+
// {
|
|
4133
|
+
// "success": true,
|
|
4134
|
+
// "code": "200",
|
|
4135
|
+
// "msg": "success",
|
|
4136
|
+
// "retry": false,
|
|
4137
|
+
// "data": {
|
|
4138
|
+
// "orderNo": "5da6dba0f943c0c81f5d5db5",
|
|
4139
|
+
// "actualSize": 10
|
|
4140
|
+
// }
|
|
4141
|
+
// }
|
|
4142
|
+
//
|
|
4143
|
+
const data = this.safeValue(response, 'data', {});
|
|
4144
|
+
return this.parseMarginLoan(data, currency);
|
|
4145
|
+
}
|
|
4146
|
+
async borrowIsolatedMargin(symbol, code, amount, params = {}) {
|
|
4147
|
+
/**
|
|
4148
|
+
* @method
|
|
4149
|
+
* @name kucoin#borrowIsolatedMargin
|
|
4150
|
+
* @description create a loan to borrow margin
|
|
4151
|
+
* @see https://docs.kucoin.com/#1-margin-borrowing
|
|
4119
4152
|
* @param {string} symbol unified market symbol, required for isolated margin
|
|
4153
|
+
* @param {string} code unified currency code of the currency to borrow
|
|
4154
|
+
* @param {float} amount the amount to borrow
|
|
4120
4155
|
* @param {object} [params] extra parameters specific to the kucoin api endpoints
|
|
4121
4156
|
* @param {string} [params.timeInForce] either IOC or FOK
|
|
4122
|
-
* @param {string} [params.marginMode] 'cross' or 'isolated' default is 'cross'
|
|
4123
4157
|
* @returns {object} a [margin loan structure]{@link https://docs.ccxt.com/#/?id=margin-loan-structure}
|
|
4124
4158
|
*/
|
|
4125
|
-
const marginMode = this.safeString(params, 'marginMode'); // cross or isolated
|
|
4126
|
-
const isIsolated = marginMode === 'isolated';
|
|
4127
|
-
params = this.omit(params, 'marginMode');
|
|
4128
|
-
this.checkRequiredMarginArgument('borrowMargin', symbol, marginMode);
|
|
4129
4159
|
await this.loadMarkets();
|
|
4160
|
+
const market = this.market(symbol);
|
|
4130
4161
|
const currency = this.currency(code);
|
|
4131
4162
|
const request = {
|
|
4132
4163
|
'currency': currency['id'],
|
|
4133
4164
|
'size': this.currencyToPrecision(code, amount),
|
|
4165
|
+
'symbol': market['id'],
|
|
4166
|
+
'timeInForce': 'FOK',
|
|
4167
|
+
'isIsolated': true,
|
|
4134
4168
|
};
|
|
4135
|
-
const timeInForce = this.safeStringN(params, ['timeInForce', 'type', 'borrowStrategy'], 'IOC');
|
|
4136
|
-
if (isIsolated) {
|
|
4137
|
-
if (symbol === undefined) {
|
|
4138
|
-
throw new errors.ArgumentsRequired(this.id + ' borrowMargin() requires a symbol parameter for isolated margin');
|
|
4139
|
-
}
|
|
4140
|
-
const market = this.market(symbol);
|
|
4141
|
-
request['symbol'] = market['id'];
|
|
4142
|
-
request['isIsolated'] = true;
|
|
4143
|
-
}
|
|
4144
|
-
params = this.omit(params, ['timeInForce', 'type', 'borrowStrategy']);
|
|
4145
|
-
request['timeInForce'] = timeInForce;
|
|
4146
4169
|
const response = await this.privatePostMarginBorrow(this.extend(request, params));
|
|
4147
4170
|
//
|
|
4148
4171
|
// {
|
|
@@ -4159,37 +4182,60 @@ class kucoin extends kucoin$1 {
|
|
|
4159
4182
|
const data = this.safeValue(response, 'data', {});
|
|
4160
4183
|
return this.parseMarginLoan(data, currency);
|
|
4161
4184
|
}
|
|
4162
|
-
async
|
|
4185
|
+
async repayCrossMargin(code, amount, params = {}) {
|
|
4163
4186
|
/**
|
|
4164
4187
|
* @method
|
|
4165
|
-
* @name kucoin#
|
|
4188
|
+
* @name kucoin#repayCrossMargin
|
|
4166
4189
|
* @description repay borrowed margin and interest
|
|
4167
4190
|
* @see https://docs.kucoin.com/#2-repayment
|
|
4168
4191
|
* @param {string} code unified currency code of the currency to repay
|
|
4169
4192
|
* @param {float} amount the amount to repay
|
|
4193
|
+
* @param {object} [params] extra parameters specific to the kucoin api endpoints
|
|
4194
|
+
* @returns {object} a [margin loan structure]{@link https://docs.ccxt.com/#/?id=margin-loan-structure}
|
|
4195
|
+
*/
|
|
4196
|
+
await this.loadMarkets();
|
|
4197
|
+
const currency = this.currency(code);
|
|
4198
|
+
const request = {
|
|
4199
|
+
'currency': currency['id'],
|
|
4200
|
+
'size': this.currencyToPrecision(code, amount),
|
|
4201
|
+
};
|
|
4202
|
+
const response = await this.privatePostMarginRepay(this.extend(request, params));
|
|
4203
|
+
//
|
|
4204
|
+
// {
|
|
4205
|
+
// "success": true,
|
|
4206
|
+
// "code": "200",
|
|
4207
|
+
// "msg": "success",
|
|
4208
|
+
// "retry": false,
|
|
4209
|
+
// "data": {
|
|
4210
|
+
// "orderNo": "5da6dba0f943c0c81f5d5db5",
|
|
4211
|
+
// "actualSize": 10
|
|
4212
|
+
// }
|
|
4213
|
+
// }
|
|
4214
|
+
//
|
|
4215
|
+
const data = this.safeValue(response, 'data', {});
|
|
4216
|
+
return this.parseMarginLoan(data, currency);
|
|
4217
|
+
}
|
|
4218
|
+
async repayIsolatedMargin(symbol, code, amount, params = {}) {
|
|
4219
|
+
/**
|
|
4220
|
+
* @method
|
|
4221
|
+
* @name kucoin#repayIsolatedMargin
|
|
4222
|
+
* @description repay borrowed margin and interest
|
|
4223
|
+
* @see https://docs.kucoin.com/#2-repayment
|
|
4170
4224
|
* @param {string} symbol unified market symbol
|
|
4225
|
+
* @param {string} code unified currency code of the currency to repay
|
|
4226
|
+
* @param {float} amount the amount to repay
|
|
4171
4227
|
* @param {object} [params] extra parameters specific to the kucoin api endpoints
|
|
4172
|
-
* @param {string} [params.marginMode] 'cross' or 'isolated' default is 'cross'
|
|
4173
4228
|
* @returns {object} a [margin loan structure]{@link https://docs.ccxt.com/#/?id=margin-loan-structure}
|
|
4174
4229
|
*/
|
|
4175
|
-
const marginMode = this.safeString(params, 'marginMode'); // cross or isolated
|
|
4176
|
-
const isIsolated = marginMode === 'isolated';
|
|
4177
|
-
params = this.omit(params, 'marginMode');
|
|
4178
|
-
this.checkRequiredMarginArgument('repayMargin', symbol, marginMode);
|
|
4179
4230
|
await this.loadMarkets();
|
|
4231
|
+
const market = this.market(symbol);
|
|
4180
4232
|
const currency = this.currency(code);
|
|
4181
4233
|
const request = {
|
|
4182
4234
|
'currency': currency['id'],
|
|
4183
4235
|
'size': this.currencyToPrecision(code, amount),
|
|
4236
|
+
'symbol': market['id'],
|
|
4237
|
+
'isIsolated': true,
|
|
4184
4238
|
};
|
|
4185
|
-
if (isIsolated) {
|
|
4186
|
-
if (symbol === undefined) {
|
|
4187
|
-
throw new errors.ArgumentsRequired(this.id + ' repayMargin() requires a symbol parameter for isolated margin');
|
|
4188
|
-
}
|
|
4189
|
-
const market = this.market(symbol);
|
|
4190
|
-
request['symbol'] = market['id'];
|
|
4191
|
-
request['isIsolated'] = true;
|
|
4192
|
-
}
|
|
4193
4239
|
const response = await this.privatePostMarginRepay(this.extend(request, params));
|
|
4194
4240
|
//
|
|
4195
4241
|
// {
|