ccxt 4.5.18 → 4.5.20

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 (152) hide show
  1. package/README.md +7 -6
  2. package/dist/ccxt.browser.min.js +40 -16
  3. package/dist/cjs/_virtual/index.cjs.js +1459 -9
  4. package/dist/cjs/ccxt.js +8 -2
  5. package/dist/cjs/src/abstract/dydx.js +11 -0
  6. package/dist/cjs/src/base/Exchange.js +164 -10
  7. package/dist/cjs/src/base/ws/Client.js +3 -1
  8. package/dist/cjs/src/binance.js +8 -1
  9. package/dist/cjs/src/bingx.js +20 -0
  10. package/dist/cjs/src/bitget.js +43 -41
  11. package/dist/cjs/src/bybit.js +21 -23
  12. package/dist/cjs/src/deribit.js +6 -0
  13. package/dist/cjs/src/dydx.js +2454 -0
  14. package/dist/cjs/src/gate.js +4 -4
  15. package/dist/cjs/src/hibachi.js +1 -1
  16. package/dist/cjs/src/hyperliquid.js +207 -9
  17. package/dist/cjs/src/kucoin.js +711 -109
  18. package/dist/cjs/src/mexc.js +2 -3
  19. package/dist/cjs/src/pro/binance.js +59 -144
  20. package/dist/cjs/src/pro/dydx.js +418 -0
  21. package/dist/cjs/src/pro/kraken.js +4 -3
  22. package/dist/cjs/src/pro/xt.js +218 -4
  23. package/dist/cjs/src/protobuf/mexc/compiled.cjs.js +1 -0
  24. package/dist/cjs/src/static_dependencies/dydx-v4-client/cosmos/base/v1beta1/coin.js +56 -0
  25. package/dist/cjs/src/static_dependencies/dydx-v4-client/cosmos/crypto/multisig/v1beta1/multisig.js +56 -0
  26. package/dist/cjs/src/static_dependencies/dydx-v4-client/cosmos/crypto/secp256k1/keys.js +48 -0
  27. package/dist/cjs/src/static_dependencies/dydx-v4-client/cosmos/tx/signing/v1beta1/signing.js +343 -0
  28. package/dist/cjs/src/static_dependencies/dydx-v4-client/cosmos/tx/v1beta1/tx.js +717 -0
  29. package/dist/cjs/src/static_dependencies/dydx-v4-client/dydxprotocol/accountplus/tx.js +60 -0
  30. package/dist/cjs/src/static_dependencies/dydx-v4-client/dydxprotocol/clob/clob_pair.js +45 -0
  31. package/dist/cjs/src/static_dependencies/dydx-v4-client/dydxprotocol/clob/order.js +380 -0
  32. package/dist/cjs/src/static_dependencies/dydx-v4-client/dydxprotocol/clob/order_removals.js +72 -0
  33. package/dist/cjs/src/static_dependencies/dydx-v4-client/dydxprotocol/clob/tx.js +211 -0
  34. package/dist/cjs/src/static_dependencies/dydx-v4-client/dydxprotocol/sending/transfer.js +195 -0
  35. package/dist/cjs/src/static_dependencies/dydx-v4-client/dydxprotocol/sending/tx.js +49 -0
  36. package/dist/cjs/src/static_dependencies/dydx-v4-client/dydxprotocol/subaccounts/subaccount.js +57 -0
  37. package/dist/cjs/src/static_dependencies/dydx-v4-client/google/protobuf/any.js +56 -0
  38. package/dist/cjs/src/static_dependencies/dydx-v4-client/helpers.js +79 -0
  39. package/dist/cjs/src/static_dependencies/dydx-v4-client/long/index.cjs.js +9 -0
  40. package/dist/cjs/src/static_dependencies/dydx-v4-client/onboarding.js +59 -0
  41. package/dist/cjs/src/static_dependencies/dydx-v4-client/registry.js +39 -0
  42. package/dist/cjs/src/static_dependencies/noble-hashes/pbkdf2.js +69 -0
  43. package/dist/cjs/src/static_dependencies/noble-hashes/ripemd160.js +108 -0
  44. package/dist/cjs/src/static_dependencies/noble-hashes/utils.js +50 -1
  45. package/dist/cjs/src/static_dependencies/scure-base/index.js +29 -0
  46. package/dist/cjs/src/static_dependencies/scure-bip32/index.js +278 -0
  47. package/dist/cjs/src/static_dependencies/scure-bip39/index.js +97 -0
  48. package/dist/cjs/src/static_dependencies/scure-bip39/wordlists/english.js +2060 -0
  49. package/dist/cjs/src/static_dependencies/zklink/zklink-sdk-web.js +2 -0
  50. package/dist/cjs/src/toobit.js +2 -1
  51. package/js/ccxt.d.ts +8 -2
  52. package/js/ccxt.js +6 -2
  53. package/js/src/abstract/binance.d.ts +7 -0
  54. package/js/src/abstract/binancecoinm.d.ts +7 -0
  55. package/js/src/abstract/binanceus.d.ts +7 -0
  56. package/js/src/abstract/binanceusdm.d.ts +7 -0
  57. package/js/src/abstract/bitget.d.ts +1 -0
  58. package/js/src/abstract/dydx.d.ts +61 -0
  59. package/js/src/abstract/dydx.js +11 -0
  60. package/js/src/abstract/kucoin.d.ts +1 -1
  61. package/js/src/abstract/kucoinfutures.d.ts +1 -1
  62. package/js/src/base/Exchange.d.ts +7 -0
  63. package/js/src/base/Exchange.js +163 -10
  64. package/js/src/base/ws/Client.js +3 -1
  65. package/js/src/binance.js +8 -1
  66. package/js/src/bingx.js +20 -0
  67. package/js/src/bitget.d.ts +3 -3
  68. package/js/src/bitget.js +43 -41
  69. package/js/src/bybit.d.ts +3 -3
  70. package/js/src/bybit.js +21 -23
  71. package/js/src/deribit.js +6 -0
  72. package/js/src/dydx.d.ts +364 -0
  73. package/js/src/dydx.js +2453 -0
  74. package/js/src/gate.d.ts +2 -2
  75. package/js/src/gate.js +4 -4
  76. package/js/src/hibachi.js +1 -1
  77. package/js/src/hyperliquid.d.ts +17 -0
  78. package/js/src/hyperliquid.js +207 -9
  79. package/js/src/kucoin.d.ts +48 -1
  80. package/js/src/kucoin.js +711 -109
  81. package/js/src/mexc.js +2 -3
  82. package/js/src/pro/binance.d.ts +2 -2
  83. package/js/src/pro/binance.js +59 -144
  84. package/js/src/pro/dydx.d.ts +81 -0
  85. package/js/src/pro/dydx.js +417 -0
  86. package/js/src/pro/kraken.js +4 -3
  87. package/js/src/pro/xt.d.ts +85 -2
  88. package/js/src/pro/xt.js +218 -4
  89. package/js/src/static_dependencies/dydx-v4-client/cosmos/base/v1beta1/coin.d.ts +90 -0
  90. package/js/src/static_dependencies/dydx-v4-client/cosmos/base/v1beta1/coin.js +163 -0
  91. package/js/src/static_dependencies/dydx-v4-client/cosmos/crypto/multisig/keys.d.ts +26 -0
  92. package/js/src/static_dependencies/dydx-v4-client/cosmos/crypto/multisig/keys.js +51 -0
  93. package/js/src/static_dependencies/dydx-v4-client/cosmos/crypto/multisig/v1beta1/multisig.d.ts +48 -0
  94. package/js/src/static_dependencies/dydx-v4-client/cosmos/crypto/multisig/v1beta1/multisig.js +85 -0
  95. package/js/src/static_dependencies/dydx-v4-client/cosmos/crypto/secp256k1/keys.d.ts +40 -0
  96. package/js/src/static_dependencies/dydx-v4-client/cosmos/crypto/secp256k1/keys.js +77 -0
  97. package/js/src/static_dependencies/dydx-v4-client/cosmos/tx/signing/v1beta1/signing.d.ts +162 -0
  98. package/js/src/static_dependencies/dydx-v4-client/cosmos/tx/signing/v1beta1/signing.js +329 -0
  99. package/js/src/static_dependencies/dydx-v4-client/cosmos/tx/v1beta1/tx.d.ts +460 -0
  100. package/js/src/static_dependencies/dydx-v4-client/cosmos/tx/v1beta1/tx.js +698 -0
  101. package/js/src/static_dependencies/dydx-v4-client/dydxprotocol/accountplus/tx.d.ts +127 -0
  102. package/js/src/static_dependencies/dydx-v4-client/dydxprotocol/accountplus/tx.js +286 -0
  103. package/js/src/static_dependencies/dydx-v4-client/dydxprotocol/clob/block_rate_limit_config.d.ts +66 -0
  104. package/js/src/static_dependencies/dydx-v4-client/dydxprotocol/clob/block_rate_limit_config.js +109 -0
  105. package/js/src/static_dependencies/dydx-v4-client/dydxprotocol/clob/clob_pair.d.ts +127 -0
  106. package/js/src/static_dependencies/dydx-v4-client/dydxprotocol/clob/clob_pair.js +257 -0
  107. package/js/src/static_dependencies/dydx-v4-client/dydxprotocol/clob/equity_tier_limit_config.d.ts +48 -0
  108. package/js/src/static_dependencies/dydx-v4-client/dydxprotocol/clob/equity_tier_limit_config.js +93 -0
  109. package/js/src/static_dependencies/dydx-v4-client/dydxprotocol/clob/finalize_block.d.ts +23 -0
  110. package/js/src/static_dependencies/dydx-v4-client/dydxprotocol/clob/finalize_block.js +43 -0
  111. package/js/src/static_dependencies/dydx-v4-client/dydxprotocol/clob/liquidations.d.ts +92 -0
  112. package/js/src/static_dependencies/dydx-v4-client/dydxprotocol/clob/liquidations.js +164 -0
  113. package/js/src/static_dependencies/dydx-v4-client/dydxprotocol/clob/liquidations_config.d.ts +124 -0
  114. package/js/src/static_dependencies/dydx-v4-client/dydxprotocol/clob/liquidations_config.js +196 -0
  115. package/js/src/static_dependencies/dydx-v4-client/dydxprotocol/clob/matches.d.ts +159 -0
  116. package/js/src/static_dependencies/dydx-v4-client/dydxprotocol/clob/matches.js +324 -0
  117. package/js/src/static_dependencies/dydx-v4-client/dydxprotocol/clob/order.d.ts +546 -0
  118. package/js/src/static_dependencies/dydx-v4-client/dydxprotocol/clob/order.js +872 -0
  119. package/js/src/static_dependencies/dydx-v4-client/dydxprotocol/clob/order_removals.d.ts +84 -0
  120. package/js/src/static_dependencies/dydx-v4-client/dydxprotocol/clob/order_removals.js +181 -0
  121. package/js/src/static_dependencies/dydx-v4-client/dydxprotocol/clob/tx.d.ts +397 -0
  122. package/js/src/static_dependencies/dydx-v4-client/dydxprotocol/clob/tx.js +757 -0
  123. package/js/src/static_dependencies/dydx-v4-client/dydxprotocol/sending/transfer.d.ts +120 -0
  124. package/js/src/static_dependencies/dydx-v4-client/dydxprotocol/sending/transfer.js +246 -0
  125. package/js/src/static_dependencies/dydx-v4-client/dydxprotocol/sending/tx.d.ts +79 -0
  126. package/js/src/static_dependencies/dydx-v4-client/dydxprotocol/sending/tx.js +147 -0
  127. package/js/src/static_dependencies/dydx-v4-client/dydxprotocol/subaccounts/asset_position.d.ts +32 -0
  128. package/js/src/static_dependencies/dydx-v4-client/dydxprotocol/subaccounts/asset_position.js +59 -0
  129. package/js/src/static_dependencies/dydx-v4-client/dydxprotocol/subaccounts/perpetual_position.d.ts +34 -0
  130. package/js/src/static_dependencies/dydx-v4-client/dydxprotocol/subaccounts/perpetual_position.js +66 -0
  131. package/js/src/static_dependencies/dydx-v4-client/dydxprotocol/subaccounts/subaccount.d.ts +62 -0
  132. package/js/src/static_dependencies/dydx-v4-client/dydxprotocol/subaccounts/subaccount.js +111 -0
  133. package/js/src/static_dependencies/dydx-v4-client/google/protobuf/any.d.ts +207 -0
  134. package/js/src/static_dependencies/dydx-v4-client/google/protobuf/any.js +50 -0
  135. package/js/src/static_dependencies/dydx-v4-client/helpers.d.ts +82 -0
  136. package/js/src/static_dependencies/dydx-v4-client/helpers.js +172 -0
  137. package/js/src/static_dependencies/dydx-v4-client/long/index.cjs +1473 -0
  138. package/js/src/static_dependencies/dydx-v4-client/long/index.d.cts +2 -0
  139. package/js/src/static_dependencies/dydx-v4-client/onboarding.d.ts +35 -0
  140. package/js/src/static_dependencies/dydx-v4-client/onboarding.js +56 -0
  141. package/js/src/static_dependencies/dydx-v4-client/registry.d.ts +7 -0
  142. package/js/src/static_dependencies/dydx-v4-client/registry.js +36 -0
  143. package/js/src/static_dependencies/noble-hashes/utils.d.ts +1 -0
  144. package/js/src/static_dependencies/noble-hashes/utils.js +4 -0
  145. package/js/src/static_dependencies/scure-bip32/index.d.ts +49 -0
  146. package/js/src/static_dependencies/scure-bip32/index.js +295 -0
  147. package/js/src/static_dependencies/scure-bip39/index.d.ts +54 -0
  148. package/js/src/static_dependencies/scure-bip39/index.js +140 -0
  149. package/js/src/static_dependencies/scure-bip39/wordlists/english.d.ts +1 -0
  150. package/js/src/static_dependencies/scure-bip39/wordlists/english.js +2054 -0
  151. package/js/src/toobit.js +2 -1
  152. package/package.json +9 -3
@@ -67,8 +67,8 @@ class kucoin extends kucoin$1["default"] {
67
67
  'fetchDepositWithdrawFee': true,
68
68
  'fetchDepositWithdrawFees': true,
69
69
  'fetchFundingHistory': false,
70
- 'fetchFundingRate': false,
71
- 'fetchFundingRateHistory': false,
70
+ 'fetchFundingRate': true,
71
+ 'fetchFundingRateHistory': true,
72
72
  'fetchFundingRates': false,
73
73
  'fetchIndexOHLCV': false,
74
74
  'fetchIsolatedBorrowRate': false,
@@ -470,7 +470,7 @@ class kucoin extends kucoin$1["default"] {
470
470
  'market/funding-rate': 2,
471
471
  'market/funding-rate-history': 5,
472
472
  'market/cross-config': 25,
473
- 'market/server/status': 3,
473
+ 'server/status': 3,
474
474
  },
475
475
  },
476
476
  },
@@ -1128,22 +1128,49 @@ class kucoin extends kucoin$1["default"] {
1128
1128
  * @name kucoin#fetchStatus
1129
1129
  * @description the latest known information on the availability of the exchange API
1130
1130
  * @see https://docs.kucoin.com/#service-status
1131
+ * @see https://www.kucoin.com/docs-new/rest/ua/get-service-status
1131
1132
  * @param {object} [params] extra parameters specific to the exchange API endpoint
1133
+ * @param {boolean} [params.uta] set to true for the unified trading account (uta), defaults to false
1134
+ * @param {string} [params.tradeType] *uta only* set to SPOT or FUTURES
1132
1135
  * @returns {object} a [status structure]{@link https://docs.ccxt.com/#/?id=exchange-status-structure}
1133
1136
  */
1134
1137
  async fetchStatus(params = {}) {
1135
- const response = await this.publicGetStatus(params);
1136
- //
1137
- // {
1138
- // "code":"200000",
1139
- // "data":{
1140
- // "status":"open", //open, close, cancelonly
1141
- // "msg":"upgrade match engine" //remark for operation
1142
- // }
1143
- // }
1144
- //
1138
+ let uta = undefined;
1139
+ [uta, params] = this.handleOptionAndParams(params, 'fetchStatus', 'uta', false);
1140
+ let response = undefined;
1141
+ if (uta) {
1142
+ const defaultType = this.safeString(this.options, 'defaultType', 'spot');
1143
+ const defaultTradeType = (defaultType === 'spot') ? 'SPOT' : 'FUTURES';
1144
+ const tradeType = this.safeStringUpper(params, 'tradeType', defaultTradeType);
1145
+ const request = {
1146
+ 'tradeType': tradeType,
1147
+ };
1148
+ response = await this.utaGetServerStatus(this.extend(request, params));
1149
+ //
1150
+ // {
1151
+ // "code": "200000",
1152
+ // "data": {
1153
+ // "tradeType": "SPOT",
1154
+ // "serverStatus": "open",
1155
+ // "msg": ""
1156
+ // }
1157
+ // }
1158
+ //
1159
+ }
1160
+ else {
1161
+ response = await this.publicGetStatus(params);
1162
+ //
1163
+ // {
1164
+ // "code":"200000",
1165
+ // "data":{
1166
+ // "status":"open", //open, close, cancelonly
1167
+ // "msg":"upgrade match engine" //remark for operation
1168
+ // }
1169
+ // }
1170
+ //
1171
+ }
1145
1172
  const data = this.safeDict(response, 'data', {});
1146
- const status = this.safeString(data, 'status');
1173
+ const status = this.safeString2(data, 'status', 'serverStatus');
1147
1174
  return {
1148
1175
  'status': (status === 'open') ? 'ok' : 'maintenance',
1149
1176
  'updated': undefined,
@@ -1159,11 +1186,17 @@ class kucoin extends kucoin$1["default"] {
1159
1186
  * @see https://docs.kucoin.com/#get-symbols-list-deprecated
1160
1187
  * @see https://docs.kucoin.com/#get-all-tickers
1161
1188
  * @param {object} [params] extra parameters specific to the exchange API endpoint
1189
+ * @param {boolean} [params.uta] set to true for the unified trading account (uta), defaults to false
1162
1190
  * @returns {object[]} an array of objects representing market data
1163
1191
  */
1164
1192
  async fetchMarkets(params = {}) {
1165
1193
  let fetchTickersFees = undefined;
1166
1194
  [fetchTickersFees, params] = this.handleOptionAndParams(params, 'fetchMarkets', 'fetchTickersFees', true);
1195
+ let uta = undefined;
1196
+ [uta, params] = this.handleOptionAndParams(params, 'fetchMarkets', 'uta', false);
1197
+ if (uta) {
1198
+ return await this.fetchUtaMarkets(params);
1199
+ }
1167
1200
  const promises = [];
1168
1201
  promises.push(this.publicGetSymbols(params));
1169
1202
  //
@@ -1348,6 +1381,189 @@ class kucoin extends kucoin$1["default"] {
1348
1381
  }
1349
1382
  return result;
1350
1383
  }
1384
+ async fetchUtaMarkets(params = {}) {
1385
+ const promises = [];
1386
+ promises.push(this.utaGetMarketInstrument(this.extend(params, { 'tradeType': 'SPOT' })));
1387
+ //
1388
+ // {
1389
+ // "code": "200000",
1390
+ // "data": {
1391
+ // "tradeType": "SPOT",
1392
+ // "list": [
1393
+ // {
1394
+ // "symbol": "AVA-USDT",
1395
+ // "name": "AVA-USDT",
1396
+ // "baseCurrency": "AVA",
1397
+ // "quoteCurrency": "USDT",
1398
+ // "market": "USDS",
1399
+ // "minBaseOrderSize": "0.1",
1400
+ // "minQuoteOrderSize": "0.1",
1401
+ // "maxBaseOrderSize": "10000000000",
1402
+ // "maxQuoteOrderSize": "99999999",
1403
+ // "baseOrderStep": "0.01",
1404
+ // "quoteOrderStep": "0.0001",
1405
+ // "tickSize": "0.0001",
1406
+ // "feeCurrency": "USDT",
1407
+ // "tradingStatus": "1",
1408
+ // "marginMode": "2",
1409
+ // "priceLimitRatio": "0.05",
1410
+ // "feeCategory": 1,
1411
+ // "makerFeeCoefficient": "1.00",
1412
+ // "takerFeeCoefficient": "1.00",
1413
+ // "st": false
1414
+ // },
1415
+ // ]
1416
+ // }
1417
+ // }
1418
+ //
1419
+ promises.push(this.utaGetMarketInstrument(this.extend(params, { 'tradeType': 'FUTURES' })));
1420
+ //
1421
+ // {
1422
+ // "code": "200000",
1423
+ // "data": {
1424
+ // "tradeType": "FUTURES",
1425
+ // "list": [
1426
+ // {
1427
+ // "symbol": "XBTUSDTM",
1428
+ // "baseCurrency": "XBT",
1429
+ // "quoteCurrency": "USDT",
1430
+ // "maxBaseOrderSize": "1000000",
1431
+ // "tickSize": "0.1",
1432
+ // "tradingStatus": "1",
1433
+ // "settlementCurrency": "USDT",
1434
+ // "contractType": "0",
1435
+ // "isInverse": false,
1436
+ // "launchTime": 1585555200000,
1437
+ // "expiryTime": null,
1438
+ // "settlementTime": null,
1439
+ // "maxPrice": "1000000.0",
1440
+ // "lotSize": "1",
1441
+ // "unitSize": "0.001",
1442
+ // "makerFeeRate": "0.00020",
1443
+ // "takerFeeRate": "0.00060",
1444
+ // "settlementFeeRate": null,
1445
+ // "maxLeverage": 125,
1446
+ // "indexSourceExchanges": ["okex","binance","kucoin","bybit","bitmart","gateio"],
1447
+ // "k": "490.0",
1448
+ // "m": "300.0",
1449
+ // "f": "1.3",
1450
+ // "mmrLimit": "0.3",
1451
+ // "mmrLevConstant": "125.0"
1452
+ // },
1453
+ // ]
1454
+ // }
1455
+ // }
1456
+ //
1457
+ const responses = await Promise.all(promises);
1458
+ const data = this.safeDict(responses[0], 'data', {});
1459
+ const contractData = this.safeDict(responses[1], 'data', {});
1460
+ const spotData = this.safeList(data, 'list', []);
1461
+ const contractSymbolsData = this.safeList(contractData, 'list', []);
1462
+ const symbolsData = this.arrayConcat(spotData, contractSymbolsData);
1463
+ const result = [];
1464
+ for (let i = 0; i < symbolsData.length; i++) {
1465
+ const market = symbolsData[i];
1466
+ const id = this.safeString(market, 'symbol');
1467
+ const baseId = this.safeString(market, 'baseCurrency');
1468
+ const quoteId = this.safeString(market, 'quoteCurrency');
1469
+ const settleId = this.safeString(market, 'settlementCurrency');
1470
+ const base = this.safeCurrencyCode(baseId);
1471
+ const quote = this.safeCurrencyCode(quoteId);
1472
+ const settle = this.safeCurrencyCode(settleId);
1473
+ const hasMargin = this.safeString(market, 'marginMode');
1474
+ const isMarginable = (hasMargin === '1') ? true : false;
1475
+ let symbol = base + '/' + quote;
1476
+ if (settle !== undefined) {
1477
+ symbol += ':' + settle;
1478
+ }
1479
+ const contractType = this.safeString(market, 'contractType');
1480
+ const expiry = this.safeInteger(market, 'expiryTime');
1481
+ const active = this.safeString(market, 'tradingStatus');
1482
+ let type = undefined;
1483
+ let spot = false;
1484
+ let swap = false;
1485
+ let future = false;
1486
+ let contract = false;
1487
+ let linear = false;
1488
+ let inverse = false;
1489
+ if (contractType !== undefined) {
1490
+ contract = true;
1491
+ if (quote === settle) {
1492
+ linear = true;
1493
+ }
1494
+ else {
1495
+ inverse = true;
1496
+ }
1497
+ if (contractType === '0') {
1498
+ type = 'swap';
1499
+ swap = true;
1500
+ }
1501
+ else {
1502
+ type = 'future';
1503
+ future = true;
1504
+ }
1505
+ }
1506
+ else {
1507
+ type = 'spot';
1508
+ spot = true;
1509
+ }
1510
+ result.push({
1511
+ 'id': id,
1512
+ 'symbol': symbol,
1513
+ 'base': base,
1514
+ 'quote': quote,
1515
+ 'settle': settle,
1516
+ 'baseId': baseId,
1517
+ 'quoteId': quoteId,
1518
+ 'settleId': settleId,
1519
+ 'type': type,
1520
+ 'spot': spot,
1521
+ 'margin': isMarginable,
1522
+ 'swap': swap,
1523
+ 'future': future,
1524
+ 'option': false,
1525
+ 'active': (active === '1'),
1526
+ 'contract': contract,
1527
+ 'linear': linear,
1528
+ 'inverse': inverse,
1529
+ 'taker': this.safeNumber(market, 'makerFeeRate'),
1530
+ 'maker': this.safeNumber(market, 'takerFeeRate'),
1531
+ 'contractSize': this.safeNumber(market, 'unitSize'),
1532
+ 'expiry': expiry,
1533
+ 'expiryDatetime': this.iso8601(expiry),
1534
+ 'strike': undefined,
1535
+ 'optionType': undefined,
1536
+ 'precision': {
1537
+ 'amount': this.safeNumber(market, 'lotSize'),
1538
+ 'price': this.safeNumber(market, 'tickSize'),
1539
+ },
1540
+ 'limits': {
1541
+ 'leverage': {
1542
+ 'min': undefined,
1543
+ 'max': this.safeInteger(market, 'maxLeverage'),
1544
+ },
1545
+ 'amount': {
1546
+ 'min': this.safeNumber(market, 'minBaseOrderSize'),
1547
+ 'max': this.safeNumber(market, 'maxBaseOrderSize'),
1548
+ },
1549
+ 'price': {
1550
+ 'min': undefined,
1551
+ 'max': this.safeNumber(market, 'maxPrice'),
1552
+ },
1553
+ 'cost': {
1554
+ 'min': this.safeNumber(market, 'minQuoteOrderSize'),
1555
+ 'max': this.safeNumber(market, 'maxQuoteOrderSize'),
1556
+ },
1557
+ },
1558
+ 'created': this.safeInteger(market, 'launchTime'),
1559
+ 'info': market,
1560
+ });
1561
+ }
1562
+ if (this.options['adjustForTimeDifference']) {
1563
+ await this.loadTimeDifference();
1564
+ }
1565
+ return result;
1566
+ }
1351
1567
  /**
1352
1568
  * @method
1353
1569
  * @name kucoin#loadMigrationStatus
@@ -1754,17 +1970,35 @@ class kucoin extends kucoin$1["default"] {
1754
1970
  // "time": 1634641777363
1755
1971
  // }
1756
1972
  //
1973
+ // uta
1974
+ //
1975
+ // {
1976
+ // "symbol": "BTC-USDT",
1977
+ // "name": "BTC-USDT",
1978
+ // "bestBidSize": "0.69207954",
1979
+ // "bestBidPrice": "110417.5",
1980
+ // "bestAskSize": "0.08836606",
1981
+ // "bestAskPrice": "110417.6",
1982
+ // "lastPrice": "110417.5",
1983
+ // "size": "0.00016",
1984
+ // "open": "110105.1",
1985
+ // "high": "110838.9",
1986
+ // "low": "109705.5",
1987
+ // "baseVolume": "1882.10069442",
1988
+ // "quoteVolume": "207325626.822922498"
1989
+ // }
1990
+ //
1757
1991
  let percentage = this.safeString(ticker, 'changeRate');
1758
1992
  if (percentage !== undefined) {
1759
1993
  percentage = Precise["default"].stringMul(percentage, '100');
1760
1994
  }
1761
- let last = this.safeString2(ticker, 'last', 'lastTradedPrice');
1995
+ let last = this.safeStringN(ticker, ['last', 'lastTradedPrice', 'lastPrice']);
1762
1996
  last = this.safeString(ticker, 'price', last);
1763
1997
  const marketId = this.safeString(ticker, 'symbol');
1764
1998
  market = this.safeMarket(marketId, market, '-');
1765
1999
  const symbol = market['symbol'];
1766
- const baseVolume = this.safeString(ticker, 'vol');
1767
- const quoteVolume = this.safeString(ticker, 'volValue');
2000
+ const baseVolume = this.safeString2(ticker, 'vol', 'baseVolume');
2001
+ const quoteVolume = this.safeString2(ticker, 'volValue', 'quoteVolume');
1768
2002
  const timestamp = this.safeIntegerN(ticker, ['time', 'datetime', 'timePoint']);
1769
2003
  return this.safeTicker({
1770
2004
  'symbol': symbol,
@@ -1772,9 +2006,9 @@ class kucoin extends kucoin$1["default"] {
1772
2006
  'datetime': this.iso8601(timestamp),
1773
2007
  'high': this.safeString(ticker, 'high'),
1774
2008
  'low': this.safeString(ticker, 'low'),
1775
- 'bid': this.safeString2(ticker, 'buy', 'bestBid'),
2009
+ 'bid': this.safeStringN(ticker, ['buy', 'bestBid', 'bestBidPrice']),
1776
2010
  'bidVolume': this.safeString(ticker, 'bestBidSize'),
1777
- 'ask': this.safeString2(ticker, 'sell', 'bestAsk'),
2011
+ 'ask': this.safeStringN(ticker, ['sell', 'bestAsk', 'bestAskPrice']),
1778
2012
  'askVolume': this.safeString(ticker, 'bestAskSize'),
1779
2013
  'vwap': undefined,
1780
2014
  'open': this.safeString(ticker, 'open'),
@@ -1795,45 +2029,103 @@ class kucoin extends kucoin$1["default"] {
1795
2029
  * @name kucoin#fetchTickers
1796
2030
  * @description fetches price tickers for multiple markets, statistical information calculated over the past 24 hours for each market
1797
2031
  * @see https://docs.kucoin.com/#get-all-tickers
2032
+ * @see https://www.kucoin.com/docs-new/rest/ua/get-ticker
1798
2033
  * @param {string[]|undefined} symbols unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
1799
2034
  * @param {object} [params] extra parameters specific to the exchange API endpoint
2035
+ * @param {boolean} [params.uta] set to true for the unified trading account (uta), defaults to false
2036
+ * @param {string} [params.tradeType] *uta only* set to SPOT or FUTURES
1800
2037
  * @returns {object} a dictionary of [ticker structures]{@link https://docs.ccxt.com/#/?id=ticker-structure}
1801
2038
  */
1802
2039
  async fetchTickers(symbols = undefined, params = {}) {
1803
2040
  await this.loadMarkets();
2041
+ const request = {};
1804
2042
  symbols = this.marketSymbols(symbols);
1805
- const response = await this.publicGetMarketAllTickers(params);
1806
- //
1807
- // {
1808
- // "code": "200000",
1809
- // "data": {
1810
- // "time":1602832092060,
1811
- // "ticker":[
1812
- // {
1813
- // "symbol": "BTC-USDT", // symbol
1814
- // "symbolName":"BTC-USDT", // Name of trading pairs, it would change after renaming
1815
- // "buy": "11328.9", // bestAsk
1816
- // "sell": "11329", // bestBid
1817
- // "changeRate": "-0.0055", // 24h change rate
1818
- // "changePrice": "-63.6", // 24h change price
1819
- // "high": "11610", // 24h highest price
1820
- // "low": "11200", // 24h lowest price
1821
- // "vol": "2282.70993217", // 24h volume,the aggregated trading volume in BTC
1822
- // "volValue": "25984946.157790431", // 24h total, the trading volume in quote currency of last 24 hours
1823
- // "last": "11328.9", // last price
1824
- // "averagePrice": "11360.66065903", // 24h average transaction price yesterday
1825
- // "takerFeeRate": "0.001", // Basic Taker Fee
1826
- // "makerFeeRate": "0.001", // Basic Maker Fee
1827
- // "takerCoefficient": "1", // Taker Fee Coefficient
1828
- // "makerCoefficient": "1" // Maker Fee Coefficient
1829
- // }
1830
- // ]
1831
- // }
1832
- // }
1833
- //
2043
+ let uta = undefined;
2044
+ [uta, params] = this.handleOptionAndParams(params, 'fetchTickers', 'uta', false);
2045
+ let response = undefined;
2046
+ if (uta) {
2047
+ if (symbols !== undefined) {
2048
+ const symbol = this.safeString(symbols, 0);
2049
+ const market = this.market(symbol);
2050
+ let type = undefined;
2051
+ [type, params] = this.handleMarketTypeAndParams('fetchTickers', market, params);
2052
+ if (type === 'spot') {
2053
+ request['tradeType'] = 'SPOT';
2054
+ }
2055
+ else {
2056
+ request['tradeType'] = 'FUTURES';
2057
+ }
2058
+ }
2059
+ else {
2060
+ const tradeType = this.safeStringUpper(params, 'tradeType');
2061
+ if (tradeType === undefined) {
2062
+ throw new errors.ArgumentsRequired(this.id + ' fetchTickers() requires a tradeType parameter for uta, either SPOT or FUTURES');
2063
+ }
2064
+ request['tradeType'] = tradeType;
2065
+ params = this.omit(params, 'tradeType');
2066
+ }
2067
+ response = await this.utaGetMarketTicker(this.extend(request, params));
2068
+ //
2069
+ // {
2070
+ // "code": "200000",
2071
+ // "data": {
2072
+ // "tradeType": "SPOT",
2073
+ // "ts": 1762061290067,
2074
+ // "list": [
2075
+ // {
2076
+ // "symbol": "BTC-USDT",
2077
+ // "name": "BTC-USDT",
2078
+ // "bestBidSize": "0.69207954",
2079
+ // "bestBidPrice": "110417.5",
2080
+ // "bestAskSize": "0.08836606",
2081
+ // "bestAskPrice": "110417.6",
2082
+ // "lastPrice": "110417.5",
2083
+ // "size": "0.00016",
2084
+ // "open": "110105.1",
2085
+ // "high": "110838.9",
2086
+ // "low": "109705.5",
2087
+ // "baseVolume": "1882.10069442",
2088
+ // "quoteVolume": "207325626.822922498"
2089
+ // }
2090
+ // ]
2091
+ // }
2092
+ // }
2093
+ //
2094
+ }
2095
+ else {
2096
+ response = await this.publicGetMarketAllTickers(params);
2097
+ //
2098
+ // {
2099
+ // "code": "200000",
2100
+ // "data": {
2101
+ // "time":1602832092060,
2102
+ // "ticker":[
2103
+ // {
2104
+ // "symbol": "BTC-USDT", // symbol
2105
+ // "symbolName":"BTC-USDT", // Name of trading pairs, it would change after renaming
2106
+ // "buy": "11328.9", // bestAsk
2107
+ // "sell": "11329", // bestBid
2108
+ // "changeRate": "-0.0055", // 24h change rate
2109
+ // "changePrice": "-63.6", // 24h change price
2110
+ // "high": "11610", // 24h highest price
2111
+ // "low": "11200", // 24h lowest price
2112
+ // "vol": "2282.70993217", // 24h volume,the aggregated trading volume in BTC
2113
+ // "volValue": "25984946.157790431", // 24h total, the trading volume in quote currency of last 24 hours
2114
+ // "last": "11328.9", // last price
2115
+ // "averagePrice": "11360.66065903", // 24h average transaction price yesterday
2116
+ // "takerFeeRate": "0.001", // Basic Taker Fee
2117
+ // "makerFeeRate": "0.001", // Basic Maker Fee
2118
+ // "takerCoefficient": "1", // Taker Fee Coefficient
2119
+ // "makerCoefficient": "1" // Maker Fee Coefficient
2120
+ // }
2121
+ // ]
2122
+ // }
2123
+ // }
2124
+ //
2125
+ }
1834
2126
  const data = this.safeDict(response, 'data', {});
1835
- const tickers = this.safeList(data, 'ticker', []);
1836
- const time = this.safeInteger(data, 'time');
2127
+ const tickers = this.safeList2(data, 'ticker', 'list', []);
2128
+ const time = this.safeInteger2(data, 'time', 'ts');
1837
2129
  const result = {};
1838
2130
  for (let i = 0; i < tickers.length; i++) {
1839
2131
  tickers[i]['time'] = time;
@@ -1866,8 +2158,10 @@ class kucoin extends kucoin$1["default"] {
1866
2158
  * @name kucoin#fetchTicker
1867
2159
  * @description fetches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
1868
2160
  * @see https://docs.kucoin.com/#get-24hr-stats
2161
+ * @see https://www.kucoin.com/docs-new/rest/ua/get-ticker
1869
2162
  * @param {string} symbol unified symbol of the market to fetch the ticker for
1870
2163
  * @param {object} [params] extra parameters specific to the exchange API endpoint
2164
+ * @param {boolean} [params.uta] set to true for the unified trading account (uta), defaults to false
1871
2165
  * @returns {object} a [ticker structure]{@link https://docs.ccxt.com/#/?id=ticker-structure}
1872
2166
  */
1873
2167
  async fetchTicker(symbol, params = {}) {
@@ -1876,32 +2170,78 @@ class kucoin extends kucoin$1["default"] {
1876
2170
  const request = {
1877
2171
  'symbol': market['id'],
1878
2172
  };
1879
- const response = await this.publicGetMarketStats(this.extend(request, params));
1880
- //
1881
- // {
1882
- // "code": "200000",
1883
- // "data": {
1884
- // "time": 1602832092060, // time
1885
- // "symbol": "BTC-USDT", // symbol
1886
- // "buy": "11328.9", // bestAsk
1887
- // "sell": "11329", // bestBid
1888
- // "changeRate": "-0.0055", // 24h change rate
1889
- // "changePrice": "-63.6", // 24h change price
1890
- // "high": "11610", // 24h highest price
1891
- // "low": "11200", // 24h lowest price
1892
- // "vol": "2282.70993217", // 24h volume,the aggregated trading volume in BTC
1893
- // "volValue": "25984946.157790431", // 24h total, the trading volume in quote currency of last 24 hours
1894
- // "last": "11328.9", // last price
1895
- // "averagePrice": "11360.66065903", // 24h average transaction price yesterday
1896
- // "takerFeeRate": "0.001", // Basic Taker Fee
1897
- // "makerFeeRate": "0.001", // Basic Maker Fee
1898
- // "takerCoefficient": "1", // Taker Fee Coefficient
1899
- // "makerCoefficient": "1" // Maker Fee Coefficient
1900
- // }
1901
- // }
1902
- //
1903
- const data = this.safeDict(response, 'data', {});
1904
- return this.parseTicker(data, market);
2173
+ let uta = undefined;
2174
+ [uta, params] = this.handleOptionAndParams(params, 'fetchTicker', 'uta', false);
2175
+ let response = undefined;
2176
+ let result = undefined;
2177
+ if (uta) {
2178
+ let type = undefined;
2179
+ [type, params] = this.handleMarketTypeAndParams('fetchTicker', market, params);
2180
+ if (type === 'spot') {
2181
+ request['tradeType'] = 'SPOT';
2182
+ }
2183
+ else {
2184
+ request['tradeType'] = 'FUTURES';
2185
+ }
2186
+ response = await this.utaGetMarketTicker(this.extend(request, params));
2187
+ //
2188
+ // {
2189
+ // "code": "200000",
2190
+ // "data": {
2191
+ // "tradeType": "SPOT",
2192
+ // "ts": 1762061290067,
2193
+ // "list": [
2194
+ // {
2195
+ // "symbol": "BTC-USDT",
2196
+ // "name": "BTC-USDT",
2197
+ // "bestBidSize": "0.69207954",
2198
+ // "bestBidPrice": "110417.5",
2199
+ // "bestAskSize": "0.08836606",
2200
+ // "bestAskPrice": "110417.6",
2201
+ // "lastPrice": "110417.5",
2202
+ // "size": "0.00016",
2203
+ // "open": "110105.1",
2204
+ // "high": "110838.9",
2205
+ // "low": "109705.5",
2206
+ // "baseVolume": "1882.10069442",
2207
+ // "quoteVolume": "207325626.822922498"
2208
+ // }
2209
+ // ]
2210
+ // }
2211
+ // }
2212
+ //
2213
+ const data = this.safeDict(response, 'data', {});
2214
+ const resultList = this.safeList(data, 'list', []);
2215
+ result = this.safeDict(resultList, 0, {});
2216
+ }
2217
+ else {
2218
+ response = await this.publicGetMarketStats(this.extend(request, params));
2219
+ //
2220
+ // {
2221
+ // "code": "200000",
2222
+ // "data": {
2223
+ // "time": 1602832092060, // time
2224
+ // "symbol": "BTC-USDT", // symbol
2225
+ // "buy": "11328.9", // bestAsk
2226
+ // "sell": "11329", // bestBid
2227
+ // "changeRate": "-0.0055", // 24h change rate
2228
+ // "changePrice": "-63.6", // 24h change price
2229
+ // "high": "11610", // 24h highest price
2230
+ // "low": "11200", // 24h lowest price
2231
+ // "vol": "2282.70993217", // 24h volume,the aggregated trading volume in BTC
2232
+ // "volValue": "25984946.157790431", // 24h total, the trading volume in quote currency of last 24 hours
2233
+ // "last": "11328.9", // last price
2234
+ // "averagePrice": "11360.66065903", // 24h average transaction price yesterday
2235
+ // "takerFeeRate": "0.001", // Basic Taker Fee
2236
+ // "makerFeeRate": "0.001", // Basic Maker Fee
2237
+ // "takerCoefficient": "1", // Taker Fee Coefficient
2238
+ // "makerCoefficient": "1" // Maker Fee Coefficient
2239
+ // }
2240
+ // }
2241
+ //
2242
+ result = this.safeDict(response, 'data', {});
2243
+ }
2244
+ return this.parseTicker(result, market);
1905
2245
  }
1906
2246
  /**
1907
2247
  * @method
@@ -1949,11 +2289,13 @@ class kucoin extends kucoin$1["default"] {
1949
2289
  * @name kucoin#fetchOHLCV
1950
2290
  * @description fetches historical candlestick data containing the open, high, low, and close price, and the volume of a market
1951
2291
  * @see https://docs.kucoin.com/#get-klines
2292
+ * @see https://www.kucoin.com/docs-new/rest/ua/get-klines
1952
2293
  * @param {string} symbol unified symbol of the market to fetch OHLCV data for
1953
2294
  * @param {string} timeframe the length of time each candle represents
1954
2295
  * @param {int} [since] timestamp in ms of the earliest candle to fetch
1955
2296
  * @param {int} [limit] the maximum amount of candles to fetch
1956
2297
  * @param {object} [params] extra parameters specific to the exchange API endpoint
2298
+ * @param {boolean} [params.uta] set to true for the unified trading account (uta), defaults to false
1957
2299
  * @param {boolean} [params.paginate] default false, when true will automatically paginate by calling this endpoint multiple times. See in the docs all the [availble parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
1958
2300
  * @returns {int[][]} A list of candles ordered as timestamp, open, high, low, close, volume
1959
2301
  */
@@ -1968,7 +2310,6 @@ class kucoin extends kucoin$1["default"] {
1968
2310
  const marketId = market['id'];
1969
2311
  const request = {
1970
2312
  'symbol': marketId,
1971
- 'type': this.safeString(this.timeframes, timeframe, timeframe),
1972
2313
  };
1973
2314
  const duration = this.parseTimeframe(timeframe) * 1000;
1974
2315
  let endAt = this.milliseconds(); // required param
@@ -1988,19 +2329,54 @@ class kucoin extends kucoin$1["default"] {
1988
2329
  request['startAt'] = this.parseToInt(Math.floor(since / 1000));
1989
2330
  }
1990
2331
  request['endAt'] = this.parseToInt(Math.floor(endAt / 1000));
1991
- const response = await this.publicGetMarketCandles(this.extend(request, params));
1992
- //
1993
- // {
1994
- // "code":"200000",
1995
- // "data":[
1996
- // ["1591517700","0.025078","0.025069","0.025084","0.025064","18.9883256","0.4761861079404"],
1997
- // ["1591516800","0.025089","0.025079","0.025089","0.02506","99.4716622","2.494143499081"],
1998
- // ["1591515900","0.025079","0.02509","0.025091","0.025068","59.83701271","1.50060885172798"],
1999
- // ]
2000
- // }
2001
- //
2002
- const data = this.safeList(response, 'data', []);
2003
- return this.parseOHLCVs(data, market, timeframe, since, limit);
2332
+ let uta = undefined;
2333
+ [uta, params] = this.handleOptionAndParams(params, 'fetchOHLCV', 'uta', false);
2334
+ let response = undefined;
2335
+ let result = undefined;
2336
+ if (uta) {
2337
+ let type = undefined;
2338
+ [type, params] = this.handleMarketTypeAndParams('fetchOHLCV', market, params);
2339
+ if (type === 'spot') {
2340
+ request['tradeType'] = 'SPOT';
2341
+ }
2342
+ else {
2343
+ request['tradeType'] = 'FUTURES';
2344
+ }
2345
+ request['interval'] = this.safeString(this.timeframes, timeframe, timeframe);
2346
+ response = await this.utaGetMarketKline(this.extend(request, params));
2347
+ //
2348
+ // {
2349
+ // "code": "200000",
2350
+ // "data": {
2351
+ // "tradeType": "SPOT",
2352
+ // "symbol": "BTC-USDT",
2353
+ // "list": [
2354
+ // ["1762240200","104581.4","104527.1","104620.1","104526.4","5.57665554","583263.661804122"],
2355
+ // ["1762240140","104565.6","104581.3","104601.7","104511.3","6.48505114","677973.775916968"],
2356
+ // ["1762240080","104621.5","104571.3","104704.7","104571.3","14.51713618","1519468.954060838"]
2357
+ // ]
2358
+ // }
2359
+ // }
2360
+ //
2361
+ const data = this.safeDict(response, 'data', {});
2362
+ result = this.safeList(data, 'list', []);
2363
+ }
2364
+ else {
2365
+ request['type'] = this.safeString(this.timeframes, timeframe, timeframe);
2366
+ response = await this.publicGetMarketCandles(this.extend(request, params));
2367
+ //
2368
+ // {
2369
+ // "code":"200000",
2370
+ // "data":[
2371
+ // ["1591517700","0.025078","0.025069","0.025084","0.025064","18.9883256","0.4761861079404"],
2372
+ // ["1591516800","0.025089","0.025079","0.025089","0.02506","99.4716622","2.494143499081"],
2373
+ // ["1591515900","0.025079","0.02509","0.025091","0.025068","59.83701271","1.50060885172798"],
2374
+ // ]
2375
+ // }
2376
+ //
2377
+ result = this.safeList(response, 'data', []);
2378
+ }
2379
+ return this.parseOHLCVs(result, market, timeframe, since, limit);
2004
2380
  }
2005
2381
  /**
2006
2382
  * @method
@@ -2146,9 +2522,11 @@ class kucoin extends kucoin$1["default"] {
2146
2522
  * @description fetches information on open orders with bid (buy) and ask (sell) prices, volumes and other data
2147
2523
  * @see https://www.kucoin.com/docs/rest/spot-trading/market-data/get-part-order-book-aggregated-
2148
2524
  * @see https://www.kucoin.com/docs/rest/spot-trading/market-data/get-full-order-book-aggregated-
2525
+ * @see https://www.kucoin.com/docs-new/rest/ua/get-orderbook
2149
2526
  * @param {string} symbol unified symbol of the market to fetch the order book for
2150
2527
  * @param {int} [limit] the maximum amount of order book entries to return
2151
2528
  * @param {object} [params] extra parameters specific to the exchange API endpoint
2529
+ * @param {boolean} [params.uta] set to true for the unified trading account (uta), defaults to false
2152
2530
  * @returns {object} A dictionary of [order book structures]{@link https://docs.ccxt.com/#/?id=order-book-structure} indexed by market symbols
2153
2531
  */
2154
2532
  async fetchOrderBook(symbol, limit = undefined, params = {}) {
@@ -2157,8 +2535,44 @@ class kucoin extends kucoin$1["default"] {
2157
2535
  const level = this.safeInteger(params, 'level', 2);
2158
2536
  const request = { 'symbol': market['id'] };
2159
2537
  const isAuthenticated = this.checkRequiredCredentials(false);
2538
+ let uta = undefined;
2539
+ [uta, params] = this.handleOptionAndParams(params, 'fetchOrderBook', 'uta', false);
2160
2540
  let response = undefined;
2161
- if (!isAuthenticated || limit !== undefined) {
2541
+ if (uta) {
2542
+ if (limit === undefined) {
2543
+ throw new errors.ArgumentsRequired(this.id + ' fetchOrderBook() requires a limit argument for uta, either 20, 50, 100 or FULL');
2544
+ }
2545
+ request['limit'] = limit;
2546
+ request['symbol'] = market['id'];
2547
+ let type = undefined;
2548
+ [type, params] = this.handleMarketTypeAndParams('fetchOrderBook', market, params);
2549
+ if (type === 'spot') {
2550
+ request['tradeType'] = 'SPOT';
2551
+ }
2552
+ else {
2553
+ request['tradeType'] = 'FUTURES';
2554
+ }
2555
+ response = await this.utaGetMarketOrderbook(this.extend(request, params));
2556
+ //
2557
+ // {
2558
+ // "code": "200000",
2559
+ // "data": {
2560
+ // "tradeType": "SPOT",
2561
+ // "symbol": "BTC-USDT",
2562
+ // "sequence": "23136002402",
2563
+ // "bids": [
2564
+ // ["104700","10.25940068"],
2565
+ // ["104698.9","0.00057076"],
2566
+ // ],
2567
+ // "asks": [
2568
+ // ["104700.1","1.4082106"],
2569
+ // ["104700.5","0.02866269"],
2570
+ // ]
2571
+ // }
2572
+ // }
2573
+ //
2574
+ }
2575
+ else if (!isAuthenticated || limit !== undefined) {
2162
2576
  if (level === 2) {
2163
2577
  request['level'] = level;
2164
2578
  if (limit !== undefined) {
@@ -3346,10 +3760,12 @@ class kucoin extends kucoin$1["default"] {
3346
3760
  * @name kucoin#fetchTrades
3347
3761
  * @description get the list of most recent trades for a particular symbol
3348
3762
  * @see https://www.kucoin.com/docs/rest/spot-trading/market-data/get-trade-histories
3763
+ * @see https://www.kucoin.com/docs-new/rest/ua/get-trades
3349
3764
  * @param {string} symbol unified symbol of the market to fetch trades for
3350
3765
  * @param {int} [since] timestamp in ms of the earliest trade to fetch
3351
3766
  * @param {int} [limit] the maximum amount of trades to fetch
3352
3767
  * @param {object} [params] extra parameters specific to the exchange API endpoint
3768
+ * @param {boolean} [params.uta] set to true for the unified trading account (uta), defaults to false
3353
3769
  * @returns {Trade[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=public-trades}
3354
3770
  */
3355
3771
  async fetchTrades(symbol, since = undefined, limit = undefined, params = {}) {
@@ -3365,22 +3781,59 @@ class kucoin extends kucoin$1["default"] {
3365
3781
  // if (limit !== undefined) {
3366
3782
  // request['pageSize'] = limit;
3367
3783
  // }
3368
- const response = await this.publicGetMarketHistories(this.extend(request, params));
3369
- //
3370
- // {
3371
- // "code": "200000",
3372
- // "data": [
3373
- // {
3374
- // "sequence": "1548764654235",
3375
- // "side": "sell",
3376
- // "size":"0.6841354",
3377
- // "price":"0.03202",
3378
- // "time":1548848575203567174
3379
- // }
3380
- // ]
3381
- // }
3382
- //
3383
- const trades = this.safeList(response, 'data', []);
3784
+ let uta = undefined;
3785
+ [uta, params] = this.handleOptionAndParams(params, 'fetchTrades', 'uta', false);
3786
+ let response = undefined;
3787
+ let trades = undefined;
3788
+ if (uta) {
3789
+ let type = undefined;
3790
+ [type, params] = this.handleMarketTypeAndParams('fetchTrades', market, params);
3791
+ if (type === 'spot') {
3792
+ request['tradeType'] = 'SPOT';
3793
+ }
3794
+ else {
3795
+ request['tradeType'] = 'FUTURES';
3796
+ }
3797
+ response = await this.utaGetMarketTrade(this.extend(request, params));
3798
+ //
3799
+ // {
3800
+ // "code": "200000",
3801
+ // "data": {
3802
+ // "tradeType": "SPOT",
3803
+ // "list": [
3804
+ // {
3805
+ // "sequence": "18746044393340932",
3806
+ // "tradeId": "18746044393340932",
3807
+ // "price": "104355.6",
3808
+ // "size": "0.00011886",
3809
+ // "side": "sell",
3810
+ // "ts": 1762242540829000000
3811
+ // },
3812
+ // ]
3813
+ // }
3814
+ // }
3815
+ //
3816
+ const data = this.safeDict(response, 'data', {});
3817
+ trades = this.safeList(data, 'list', []);
3818
+ }
3819
+ else {
3820
+ response = await this.publicGetMarketHistories(this.extend(request, params));
3821
+ //
3822
+ // {
3823
+ // "code": "200000",
3824
+ // "data": [
3825
+ // {
3826
+ // "sequence": "1548764654235",
3827
+ // "side": "sell",
3828
+ // "size":"0.6841354",
3829
+ // "price":"0.03202",
3830
+ // "time":1548848575203567174
3831
+ // }
3832
+ // ]
3833
+ // }
3834
+ //
3835
+ trades = this.safeList(response, 'data', []);
3836
+ }
3384
3837
  return this.parseTrades(trades, market, since, limit);
3385
3838
  }
3386
3839
  parseTrade(trade, market = undefined) {
@@ -3460,12 +3913,23 @@ class kucoin extends kucoin$1["default"] {
3460
3913
  // "id":"5c4d389e4c8c60413f78e2e5",
3461
3914
  // }
3462
3915
  //
3916
+ // uta fetchTrades
3917
+ //
3918
+ // {
3919
+ // "sequence": "18746044393340932",
3920
+ // "tradeId": "18746044393340932",
3921
+ // "price": "104355.6",
3922
+ // "size": "0.00011886",
3923
+ // "side": "sell",
3924
+ // "ts": 1762242540829000000
3925
+ // }
3926
+ //
3463
3927
  const marketId = this.safeString(trade, 'symbol');
3464
3928
  market = this.safeMarket(marketId, market, '-');
3465
3929
  const id = this.safeString2(trade, 'tradeId', 'id');
3466
3930
  const orderId = this.safeString(trade, 'orderId');
3467
3931
  const takerOrMaker = this.safeString(trade, 'liquidity');
3468
- let timestamp = this.safeInteger(trade, 'time');
3932
+ let timestamp = this.safeInteger2(trade, 'time', 'ts');
3469
3933
  if (timestamp !== undefined) {
3470
3934
  timestamp = this.parseToInt(timestamp / 1000000);
3471
3935
  }
@@ -5086,6 +5550,140 @@ class kucoin extends kucoin$1["default"] {
5086
5550
  request['isIsolated'] = (marginMode === 'isolated');
5087
5551
  return await this.privatePostPositionUpdateUserLeverage(this.extend(request, params));
5088
5552
  }
5553
+ /**
5554
+ * @method
5555
+ * @name kucoin#fetchFundingRate
5556
+ * @description fetch the current funding rate
5557
+ * @see https://www.kucoin.com/docs-new/rest/ua/get-current-funding-rate
5558
+ * @param {string} symbol unified market symbol
5559
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
5560
+ * @returns {object} a [funding rate structure]{@link https://docs.ccxt.com/#/?id=funding-rate-structure}
5561
+ */
5562
+ async fetchFundingRate(symbol, params = {}) {
5563
+ await this.loadMarkets();
5564
+ const market = this.market(symbol);
5565
+ const request = {
5566
+ 'symbol': market['id'],
5567
+ };
5568
+ const response = await this.utaGetMarketFundingRate(this.extend(request, params));
5569
+ //
5570
+ // {
5571
+ // "code": "200000",
5572
+ // "data": {
5573
+ // "symbol": ".XBTUSDTMFPI8H",
5574
+ // "nextFundingRate": 7.4E-5,
5575
+ // "fundingTime": 1762444800000,
5576
+ // "fundingRateCap": 0.003,
5577
+ // "fundingRateFloor": -0.003
5578
+ // }
5579
+ // }
5580
+ //
5581
+ const data = this.safeDict(response, 'data', {});
5582
+ return this.parseFundingRate(data, market);
5583
+ }
5584
+ parseFundingRate(data, market = undefined) {
5585
+ //
5586
+ // {
5587
+ // "symbol": ".XBTUSDTMFPI8H",
5588
+ // "nextFundingRate": 7.4E-5,
5589
+ // "fundingTime": 1762444800000,
5590
+ // "fundingRateCap": 0.003,
5591
+ // "fundingRateFloor": -0.003
5592
+ // }
5593
+ //
5594
+ const fundingTimestamp = this.safeInteger(data, 'fundingTime');
5595
+ const marketId = this.safeString(data, 'symbol');
5596
+ return {
5597
+ 'info': data,
5598
+ 'symbol': this.safeSymbol(marketId, market, undefined, 'contract'),
5599
+ 'markPrice': undefined,
5600
+ 'indexPrice': undefined,
5601
+ 'interestRate': undefined,
5602
+ 'estimatedSettlePrice': undefined,
5603
+ 'timestamp': undefined,
5604
+ 'datetime': undefined,
5605
+ 'fundingRate': this.safeNumber(data, 'nextFundingRate'),
5606
+ 'fundingTimestamp': fundingTimestamp,
5607
+ 'fundingDatetime': this.iso8601(fundingTimestamp),
5608
+ 'nextFundingRate': undefined,
5609
+ 'nextFundingTimestamp': undefined,
5610
+ 'nextFundingDatetime': undefined,
5611
+ 'previousFundingRate': undefined,
5612
+ 'previousFundingTimestamp': undefined,
5613
+ 'previousFundingDatetime': undefined,
5614
+ 'interval': undefined,
5615
+ };
5616
+ }
5617
+ /**
5618
+ * @method
5619
+ * @name kucoin#fetchFundingRateHistory
5620
+ * @description fetches historical funding rate prices
5621
+ * @see https://www.kucoin.com/docs-new/rest/ua/get-history-funding-rate
5622
+ * @param {string} symbol unified symbol of the market to fetch the funding rate history for
5623
+ * @param {int} [since] not used by kucuoinfutures
5624
+ * @param {int} [limit] the maximum amount of [funding rate structures]{@link https://docs.ccxt.com/#/?id=funding-rate-history-structure} to fetch
5625
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
5626
+ * @param {int} [params.until] end time in ms
5627
+ * @returns {object[]} a list of [funding rate structures]{@link https://docs.ccxt.com/#/?id=funding-rate-history-structure}
5628
+ */
5629
+ async fetchFundingRateHistory(symbol = undefined, since = undefined, limit = undefined, params = {}) {
5630
+ if (symbol === undefined) {
5631
+ throw new errors.ArgumentsRequired(this.id + ' fetchFundingRateHistory() requires a symbol argument');
5632
+ }
5633
+ if (since === undefined) {
5634
+ throw new errors.ArgumentsRequired(this.id + ' fetchFundingRateHistory() requires a since argument');
5635
+ }
5636
+ await this.loadMarkets();
5637
+ const market = this.market(symbol);
5638
+ const request = {
5639
+ 'symbol': market['id'],
5640
+ };
5641
+ const until = this.safeInteger(params, 'until');
5642
+ params = this.omit(params, 'until');
5643
+ if (since !== undefined) {
5644
+ request['startAt'] = since;
5645
+ if (until === undefined) {
5646
+ request['endAt'] = this.milliseconds();
5647
+ }
5648
+ }
5649
+ if (until !== undefined) {
5650
+ request['endAt'] = until;
5651
+ }
5652
+ const response = await this.utaGetMarketFundingRateHistory(this.extend(request, params));
5653
+ //
5654
+ // {
5655
+ // "code": "200000",
5656
+ // "data": {
5657
+ // "symbol": "XBTUSDTM",
5658
+ // "list": [
5659
+ // {
5660
+ // "fundingRate": 7.6E-5,
5661
+ // "ts": 1706097600000
5662
+ // },
5663
+ // ]
5664
+ // }
5665
+ // }
5666
+ //
5667
+ const data = this.safeDict(response, 'data', {});
5668
+ const result = this.safeList(data, 'list', []);
5669
+ return this.parseFundingRateHistories(result, market, since, limit);
5670
+ }
5671
+ parseFundingRateHistory(info, market = undefined) {
5672
+ //
5673
+ // {
5674
+ // "fundingRate": 7.6E-5,
5675
+ // "ts": 1706097600000
5676
+ // }
5677
+ //
5678
+ const timestamp = this.safeInteger(info, 'ts');
5679
+ return {
5680
+ 'info': info,
5681
+ 'symbol': this.safeSymbol(undefined, market),
5682
+ 'fundingRate': this.safeNumber(info, 'fundingRate'),
5683
+ 'timestamp': timestamp,
5684
+ 'datetime': this.iso8601(timestamp),
5685
+ };
5686
+ }
5089
5687
  sign(path, api = 'public', method = 'GET', params = {}, headers = undefined, body = undefined) {
5090
5688
  //
5091
5689
  // the v2 URL is https://openapi-v2.kucoin.com/api/v1/endpoint
@@ -5105,8 +5703,12 @@ class kucoin extends kucoin$1["default"] {
5105
5703
  if (api === 'earn') {
5106
5704
  endpoint = '/api/v1/' + this.implodeParams(path, params);
5107
5705
  }
5706
+ let isUtaPrivate = false;
5108
5707
  if (api === 'uta') {
5109
5708
  endpoint = '/api/ua/v1/' + this.implodeParams(path, params);
5709
+ if (path === 'market/orderbook') {
5710
+ isUtaPrivate = true;
5711
+ }
5110
5712
  }
5111
5713
  const query = this.omit(params, this.extractParams(path));
5112
5714
  let endpart = '';
@@ -5127,7 +5729,7 @@ class kucoin extends kucoin$1["default"] {
5127
5729
  const isPrivate = (api === 'private');
5128
5730
  const isBroker = (api === 'broker');
5129
5731
  const isEarn = (api === 'earn');
5130
- if (isPrivate || isFuturePrivate || isBroker || isEarn) {
5732
+ if (isPrivate || isFuturePrivate || isBroker || isEarn || isUtaPrivate) {
5131
5733
  this.checkRequiredCredentials();
5132
5734
  const timestamp = this.nonce().toString();
5133
5735
  headers = this.extend({