ccxt 4.4.26 → 4.4.28

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 (105) hide show
  1. package/README.md +133 -132
  2. package/dist/ccxt.browser.min.js +3 -3
  3. package/dist/cjs/ccxt.js +1 -1
  4. package/dist/cjs/src/ace.js +1 -1
  5. package/dist/cjs/src/alpaca.js +198 -5
  6. package/dist/cjs/src/ascendex.js +1 -1
  7. package/dist/cjs/src/base/Exchange.js +18 -0
  8. package/dist/cjs/src/bequant.js +1 -1
  9. package/dist/cjs/src/bigone.js +1 -1
  10. package/dist/cjs/src/binance.js +8 -1
  11. package/dist/cjs/src/binancecoinm.js +1 -1
  12. package/dist/cjs/src/binanceus.js +1 -1
  13. package/dist/cjs/src/binanceusdm.js +1 -1
  14. package/dist/cjs/src/bingx.js +25 -36
  15. package/dist/cjs/src/bit2c.js +1 -1
  16. package/dist/cjs/src/bitbank.js +1 -1
  17. package/dist/cjs/src/bitbns.js +1 -1
  18. package/dist/cjs/src/bitfinex.js +1 -1
  19. package/dist/cjs/src/bitfinex2.js +1 -1
  20. package/dist/cjs/src/bitflyer.js +1 -1
  21. package/dist/cjs/src/bitget.js +1 -1
  22. package/dist/cjs/src/bithumb.js +1 -1
  23. package/dist/cjs/src/bitmart.js +1 -1
  24. package/dist/cjs/src/bitmex.js +1 -1
  25. package/dist/cjs/src/bitopro.js +1 -1
  26. package/dist/cjs/src/bitrue.js +1 -1
  27. package/dist/cjs/src/bitso.js +1 -1
  28. package/dist/cjs/src/bitstamp.js +1 -1
  29. package/dist/cjs/src/bitteam.js +1 -1
  30. package/dist/cjs/src/bitvavo.js +1 -1
  31. package/dist/cjs/src/bl3p.js +1 -1
  32. package/dist/cjs/src/blockchaincom.js +1 -1
  33. package/dist/cjs/src/blofin.js +1 -1
  34. package/dist/cjs/src/btcalpha.js +1 -1
  35. package/dist/cjs/src/btcbox.js +1 -1
  36. package/dist/cjs/src/btcmarkets.js +1 -1
  37. package/dist/cjs/src/btcturk.js +1 -1
  38. package/dist/cjs/src/bybit.js +5 -1
  39. package/dist/cjs/src/coinbase.js +97 -11
  40. package/dist/cjs/src/coinex.js +1 -1
  41. package/dist/cjs/src/gate.js +22 -16
  42. package/dist/cjs/src/hyperliquid.js +21 -1
  43. package/dist/cjs/src/kraken.js +48 -35
  44. package/dist/cjs/src/lbank.js +100 -1
  45. package/dist/cjs/src/pro/binance.js +5 -7
  46. package/dist/cjs/src/pro/lbank.js +9 -4
  47. package/dist/cjs/src/wavesexchange.js +14 -2
  48. package/examples/js/cli.js +23 -3
  49. package/js/ccxt.d.ts +1 -1
  50. package/js/ccxt.js +1 -1
  51. package/js/src/abstract/alpaca.d.ts +2 -0
  52. package/js/src/abstract/binance.d.ts +7 -0
  53. package/js/src/abstract/binancecoinm.d.ts +7 -0
  54. package/js/src/abstract/binanceus.d.ts +7 -0
  55. package/js/src/abstract/binanceusdm.d.ts +7 -0
  56. package/js/src/ace.js +1 -1
  57. package/js/src/alpaca.d.ts +9 -1
  58. package/js/src/alpaca.js +198 -5
  59. package/js/src/ascendex.js +1 -1
  60. package/js/src/base/Exchange.d.ts +6 -0
  61. package/js/src/base/Exchange.js +18 -0
  62. package/js/src/bequant.js +1 -1
  63. package/js/src/bigone.js +1 -1
  64. package/js/src/binance.js +8 -1
  65. package/js/src/binancecoinm.js +1 -1
  66. package/js/src/binanceus.js +1 -1
  67. package/js/src/binanceusdm.js +1 -1
  68. package/js/src/bingx.js +25 -36
  69. package/js/src/bit2c.js +1 -1
  70. package/js/src/bitbank.js +1 -1
  71. package/js/src/bitbns.js +1 -1
  72. package/js/src/bitfinex.js +1 -1
  73. package/js/src/bitfinex2.js +1 -1
  74. package/js/src/bitflyer.js +1 -1
  75. package/js/src/bitget.js +1 -1
  76. package/js/src/bithumb.js +1 -1
  77. package/js/src/bitmart.js +1 -1
  78. package/js/src/bitmex.js +1 -1
  79. package/js/src/bitopro.js +1 -1
  80. package/js/src/bitrue.js +1 -1
  81. package/js/src/bitso.js +1 -1
  82. package/js/src/bitstamp.js +1 -1
  83. package/js/src/bitteam.js +1 -1
  84. package/js/src/bitvavo.js +1 -1
  85. package/js/src/bl3p.js +1 -1
  86. package/js/src/blockchaincom.js +1 -1
  87. package/js/src/blofin.js +1 -1
  88. package/js/src/btcalpha.js +1 -1
  89. package/js/src/btcbox.js +1 -1
  90. package/js/src/btcmarkets.js +1 -1
  91. package/js/src/btcturk.js +1 -1
  92. package/js/src/bybit.js +5 -1
  93. package/js/src/coinbase.d.ts +1 -0
  94. package/js/src/coinbase.js +97 -11
  95. package/js/src/coinex.js +1 -1
  96. package/js/src/gate.js +22 -16
  97. package/js/src/hyperliquid.d.ts +1 -0
  98. package/js/src/hyperliquid.js +21 -1
  99. package/js/src/kraken.js +48 -35
  100. package/js/src/lbank.d.ts +4 -1
  101. package/js/src/lbank.js +100 -1
  102. package/js/src/pro/binance.js +5 -7
  103. package/js/src/pro/lbank.js +9 -4
  104. package/js/src/wavesexchange.js +14 -2
  105. package/package.json +1 -1
@@ -104,7 +104,7 @@ class bitopro extends bitopro$1 {
104
104
  '1M': '1M',
105
105
  },
106
106
  'urls': {
107
- 'logo': 'https://user-images.githubusercontent.com/1294454/158227251-3a92a220-9222-453c-9277-977c6677fe71.jpg',
107
+ 'logo': 'https://github.com/user-attachments/assets/affc6337-b95a-44bf-aacd-04f9722364f6',
108
108
  'api': {
109
109
  'rest': 'https://api.bitopro.com/v3',
110
110
  },
@@ -95,7 +95,7 @@ class bitrue extends bitrue$1 {
95
95
  '1w': '1W',
96
96
  },
97
97
  'urls': {
98
- 'logo': 'https://user-images.githubusercontent.com/1294454/139516488-243a830d-05dd-446b-91c6-c1f18fe30c63.jpg',
98
+ 'logo': 'https://github.com/user-attachments/assets/67abe346-1273-461a-bd7c-42fa32907c8e',
99
99
  'api': {
100
100
  'spot': 'https://www.bitrue.com/api',
101
101
  'fapi': 'https://fapi.bitrue.com/fapi',
@@ -96,7 +96,7 @@ class bitso extends bitso$1 {
96
96
  'withdraw': true,
97
97
  },
98
98
  'urls': {
99
- 'logo': 'https://user-images.githubusercontent.com/51840849/87295554-11f98280-c50e-11ea-80d6-15b3bafa8cbf.jpg',
99
+ 'logo': 'https://github.com/user-attachments/assets/178c8e56-9054-4107-b192-5e5053d4f975',
100
100
  'api': {
101
101
  'rest': 'https://bitso.com/api',
102
102
  },
@@ -94,7 +94,7 @@ class bitstamp extends bitstamp$1 {
94
94
  'withdraw': true,
95
95
  },
96
96
  'urls': {
97
- 'logo': 'https://user-images.githubusercontent.com/1294454/27786377-8c8ab57e-5fe9-11e7-8ea4-2b05b6bcceec.jpg',
97
+ 'logo': 'https://github.com/user-attachments/assets/d5480572-1fee-43cb-b900-d38c522d0024',
98
98
  'api': {
99
99
  'public': 'https://www.bitstamp.net/api',
100
100
  'private': 'https://www.bitstamp.net/api',
@@ -128,7 +128,7 @@ class bitteam extends bitteam$1 {
128
128
  '1d': '1D',
129
129
  },
130
130
  'urls': {
131
- 'logo': 'https://github.com/ccxt/ccxt/assets/43336371/cf71fe3d-b8b4-40f2-a906-907661b28793',
131
+ 'logo': 'https://github.com/user-attachments/assets/b41b5e0d-98e5-4bd3-8a6e-aeb230a4a135',
132
132
  'api': {
133
133
  'history': 'https://history.bit.team',
134
134
  'public': 'https://bit.team',
@@ -109,7 +109,7 @@ class bitvavo extends bitvavo$1 {
109
109
  '1d': '1d',
110
110
  },
111
111
  'urls': {
112
- 'logo': 'https://user-images.githubusercontent.com/1294454/169202626-bd130fc5-fcf9-41bb-8d97-6093225c73cd.jpg',
112
+ 'logo': 'https://github.com/user-attachments/assets/d213155c-8c71-4701-9bd5-45351febc2a8',
113
113
  'api': {
114
114
  'public': 'https://api.bitvavo.com',
115
115
  'private': 'https://api.bitvavo.com',
@@ -80,7 +80,7 @@ class bl3p extends bl3p$1 {
80
80
  'ws': false,
81
81
  },
82
82
  'urls': {
83
- 'logo': 'https://user-images.githubusercontent.com/1294454/28501752-60c21b82-6feb-11e7-818b-055ee6d0e754.jpg',
83
+ 'logo': 'https://github.com/user-attachments/assets/75aeb14e-cd48-43c8-8492-dff002dea0be',
84
84
  'api': {
85
85
  'rest': 'https://api.bl3p.eu',
86
86
  },
@@ -76,7 +76,7 @@ class blockchaincom extends blockchaincom$1 {
76
76
  },
77
77
  'timeframes': undefined,
78
78
  'urls': {
79
- 'logo': 'https://user-images.githubusercontent.com/1294454/147515585-1296e91b-7398-45e5-9d32-f6121538533f.jpeg',
79
+ 'logo': 'https://github.com/user-attachments/assets/975e3054-3399-4363-bcee-ec3c6d63d4e8',
80
80
  'test': {
81
81
  'public': 'https://testnet-api.delta.exchange',
82
82
  'private': 'https://testnet-api.delta.exchange',
@@ -153,7 +153,7 @@ class blofin extends blofin$1 {
153
153
  },
154
154
  'hostname': 'www.blofin.com',
155
155
  'urls': {
156
- 'logo': 'https://github.com/ccxt/ccxt/assets/43336371/255a7b29-341f-4d20-8342-fbfae4932807',
156
+ 'logo': 'https://github.com/user-attachments/assets/518cdf80-f05d-4821-a3e3-d48ceb41d73b',
157
157
  'api': {
158
158
  'rest': 'https://openapi.blofin.com',
159
159
  },
@@ -99,7 +99,7 @@ class btcalpha extends btcalpha$1 {
99
99
  '1d': 'D',
100
100
  },
101
101
  'urls': {
102
- 'logo': 'https://user-images.githubusercontent.com/1294454/42625213-dabaa5da-85cf-11e8-8f99-aa8f8f7699f0.jpg',
102
+ 'logo': 'https://github.com/user-attachments/assets/dce49f3a-61e5-4ba0-a2fe-41d192fd0e5d',
103
103
  'api': {
104
104
  'rest': 'https://btc-alpha.com/api',
105
105
  },
@@ -79,7 +79,7 @@ class btcbox extends btcbox$1 {
79
79
  'ws': false,
80
80
  },
81
81
  'urls': {
82
- 'logo': 'https://user-images.githubusercontent.com/51840849/87327317-98c55400-c53c-11ea-9a11-81f7d951cc74.jpg',
82
+ 'logo': 'https://github.com/user-attachments/assets/1e2cb499-8d0f-4f8f-9464-3c015cfbc76b',
83
83
  'api': {
84
84
  'rest': 'https://www.btcbox.co.jp/api',
85
85
  },
@@ -84,7 +84,7 @@ class btcmarkets extends btcmarkets$1 {
84
84
  'withdraw': true,
85
85
  },
86
86
  'urls': {
87
- 'logo': 'https://user-images.githubusercontent.com/51840849/89731817-b3fb8480-da52-11ea-817f-783b08aaf32b.jpg',
87
+ 'logo': 'https://github.com/user-attachments/assets/8c8d6907-3873-4cc4-ad20-e22fba28247e',
88
88
  'api': {
89
89
  'public': 'https://api.btcmarkets.net',
90
90
  'private': 'https://api.btcmarkets.net',
@@ -87,7 +87,7 @@ class btcturk extends btcturk$1 {
87
87
  '1y': '1 y',
88
88
  },
89
89
  'urls': {
90
- 'logo': 'https://user-images.githubusercontent.com/51840849/87153926-efbef500-c2c0-11ea-9842-05b63612c4b9.jpg',
90
+ 'logo': 'https://github.com/user-attachments/assets/10e0a238-9f60-4b06-9dda-edfc7602f1d6',
91
91
  'api': {
92
92
  'public': 'https://api.btcturk.com/api/v2',
93
93
  'private': 'https://api.btcturk.com/api/v1',
@@ -157,7 +157,7 @@ class bybit extends bybit$1 {
157
157
  'public': 'https://api-testnet.{hostname}',
158
158
  'private': 'https://api-testnet.{hostname}',
159
159
  },
160
- 'logo': 'https://user-images.githubusercontent.com/51840849/76547799-daff5b80-649e-11ea-87fb-3be9bac08954.jpg',
160
+ 'logo': 'https://github.com/user-attachments/assets/97a5d0b3-de10-423d-90e1-6620960025ed',
161
161
  'api': {
162
162
  'spot': 'https://api.{hostname}',
163
163
  'futures': 'https://api.{hostname}',
@@ -2583,6 +2583,10 @@ class bybit extends bybit$1 {
2583
2583
  //
2584
2584
  const data = this.safeDict(response, 'result', {});
2585
2585
  const tickerList = this.safeList(data, 'list', []);
2586
+ const timestamp = this.safeInteger(response, 'time');
2587
+ for (let i = 0; i < tickerList.length; i++) {
2588
+ tickerList[i]['timestamp'] = timestamp; // will be removed inside the parser
2589
+ }
2586
2590
  const result = this.parseFundingRates(tickerList);
2587
2591
  return this.filterByArray(result, 'symbol', symbols);
2588
2592
  }
@@ -79,6 +79,7 @@ class coinbase extends coinbase$1 {
79
79
  'fetchDepositAddresses': false,
80
80
  'fetchDepositAddressesByNetwork': true,
81
81
  'fetchDeposits': true,
82
+ 'fetchDepositsWithdrawals': true,
82
83
  'fetchFundingHistory': false,
83
84
  'fetchFundingRate': false,
84
85
  'fetchFundingRateHistory': false,
@@ -773,8 +774,15 @@ class coinbase extends coinbase$1 {
773
774
  * @param {int} [since] the earliest time in ms to fetch withdrawals for
774
775
  * @param {int} [limit] the maximum number of withdrawals structures to retrieve
775
776
  * @param {object} [params] extra parameters specific to the exchange API endpoint
777
+ * @param {string} [params.currencyType] "fiat" or "crypto"
776
778
  * @returns {object[]} a list of [transaction structures]{@link https://docs.ccxt.com/#/?id=transaction-structure}
777
779
  */
780
+ let currencyType = undefined;
781
+ [currencyType, params] = this.handleOptionAndParams(params, 'fetchWithdrawals', 'currencyType');
782
+ if (currencyType === 'crypto') {
783
+ const results = await this.fetchTransactionsWithMethod('v2PrivateGetAccountsAccountIdTransactions', code, since, limit, params);
784
+ return this.filterByArray(results, 'type', 'withdrawal', false);
785
+ }
778
786
  return await this.fetchTransactionsWithMethod('v2PrivateGetAccountsAccountIdWithdrawals', code, since, limit, params);
779
787
  }
780
788
  async fetchDeposits(code = undefined, since = undefined, limit = undefined, params = {}) {
@@ -787,10 +795,33 @@ class coinbase extends coinbase$1 {
787
795
  * @param {int} [since] the earliest time in ms to fetch deposits for
788
796
  * @param {int} [limit] the maximum number of deposits structures to retrieve
789
797
  * @param {object} [params] extra parameters specific to the exchange API endpoint
798
+ * @param {string} [params.currencyType] "fiat" or "crypto"
790
799
  * @returns {object[]} a list of [transaction structures]{@link https://docs.ccxt.com/#/?id=transaction-structure}
791
800
  */
801
+ let currencyType = undefined;
802
+ [currencyType, params] = this.handleOptionAndParams(params, 'fetchWithdrawals', 'currencyType');
803
+ if (currencyType === 'crypto') {
804
+ const results = await this.fetchTransactionsWithMethod('v2PrivateGetAccountsAccountIdTransactions', code, since, limit, params);
805
+ return this.filterByArray(results, 'type', 'deposit', false);
806
+ }
792
807
  return await this.fetchTransactionsWithMethod('v2PrivateGetAccountsAccountIdDeposits', code, since, limit, params);
793
808
  }
809
+ async fetchDepositsWithdrawals(code = undefined, since = undefined, limit = undefined, params = {}) {
810
+ /**
811
+ * @method
812
+ * @name coinbase#fetchDepositsWithdrawals
813
+ * @description fetch history of deposits and withdrawals
814
+ * @see https://docs.cdp.coinbase.com/coinbase-app/docs/api-transactions
815
+ * @param {string} [code] unified currency code for the currency of the deposit/withdrawals, default is undefined
816
+ * @param {int} [since] timestamp in ms of the earliest deposit/withdrawal, default is undefined
817
+ * @param {int} [limit] max number of deposit/withdrawals to return, default = 50, Min: 1, Max: 100
818
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
819
+ * @returns {object} a list of [transaction structure]{@link https://docs.ccxt.com/#/?id=transaction-structure}
820
+ */
821
+ await this.loadMarkets();
822
+ const results = await this.fetchTransactionsWithMethod('v2PrivateGetAccountsAccountIdTransactions', code, since, limit, params);
823
+ return this.filterByArray(results, 'type', ['deposit', 'withdrawal'], false);
824
+ }
794
825
  parseTransactionStatus(status) {
795
826
  const statuses = {
796
827
  'created': 'pending',
@@ -914,18 +945,62 @@ class coinbase extends coinbase$1 {
914
945
  // "hide_native_amount": false
915
946
  // }
916
947
  //
948
+ //
949
+ // crypto deposit & withdrawal (using `/transactions` endpoint)
950
+ // {
951
+ // "amount": {
952
+ // "amount": "0.00014200", (negative for withdrawal)
953
+ // "currency": "BTC"
954
+ // },
955
+ // "created_at": "2024-03-29T15:48:30Z",
956
+ // "id": "0031a605-241d-514d-a97b-d4b99f3225d3",
957
+ // "idem": "092a979b-017e-4403-940a-2ca57811f442", // field present only in case of withdrawal
958
+ // "native_amount": {
959
+ // "amount": "9.85", (negative for withdrawal)
960
+ // "currency": "USD"
961
+ // },
962
+ // "network": {
963
+ // "status": "pending", // if status is `off_blockchain` then no more other fields are present in this object
964
+ // "hash": "5jYuvrNsvX2DZoMnzGYzVpYxJLfYu4GSK3xetG1H5LHrSovsuFCFYdFMwNRoiht3s6fBk92MM8QLLnz65xuEFTrE",
965
+ // "network_name": "solana",
966
+ // "transaction_fee": {
967
+ // "amount": "0.000100000",
968
+ // "currency": "SOL"
969
+ // }
970
+ // },
971
+ // "resource": "transaction",
972
+ // "resource_path": "/v2/accounts/dc504b1c-248e-5b68-a3b0-b991f7fa84e6/transactions/0031a605-241d-514d-a97b-d4b99f3225d3",
973
+ // "status": "completed",
974
+ // "type": "send",
975
+ // "from": { // in some cases, field might be present for deposit
976
+ // "id": "7fd10cd7-b091-5cee-ba41-c29e49a7cccf",
977
+ // "name": "Coinbase",
978
+ // "resource": "user"
979
+ // },
980
+ // "to": { // field only present for withdrawal
981
+ // "address": "5HA12BNthAvBwNYARYf9y5MqqCpB4qhCNFCs1Qw48ACE",
982
+ // "resource": "address"
983
+ // },
984
+ // "description": "C3 - One Time BTC Credit . Reference Case # 123.", // in some cases, field might be present for deposit
985
+ // }
986
+ //
917
987
  const transactionType = this.safeString(transaction, 'type');
918
988
  let amountAndCurrencyObject = undefined;
919
989
  let feeObject = undefined;
990
+ const network = this.safeDict(transaction, 'network', {});
920
991
  if (transactionType === 'send') {
921
- const network = this.safeDict(transaction, 'network', {});
922
- amountAndCurrencyObject = this.safeDict(network, 'transaction_amount', {});
992
+ amountAndCurrencyObject = this.safeDict(network, 'transaction_amount');
923
993
  feeObject = this.safeDict(network, 'transaction_fee', {});
924
994
  }
925
995
  else {
926
- amountAndCurrencyObject = this.safeDict(transaction, 'subtotal', {});
996
+ amountAndCurrencyObject = this.safeDict(transaction, 'subtotal');
927
997
  feeObject = this.safeDict(transaction, 'fee', {});
928
998
  }
999
+ if (amountAndCurrencyObject === undefined) {
1000
+ amountAndCurrencyObject = this.safeDict(transaction, 'amount');
1001
+ }
1002
+ const amountString = this.safeString(amountAndCurrencyObject, 'amount');
1003
+ const amountStringAbs = Precise["default"].stringAbs(amountString);
929
1004
  let status = this.parseTransactionStatus(this.safeString(transaction, 'status'));
930
1005
  if (status === undefined) {
931
1006
  const committed = this.safeBool(transaction, 'committed');
@@ -935,23 +1010,34 @@ class coinbase extends coinbase$1 {
935
1010
  const currencyId = this.safeString(amountAndCurrencyObject, 'currency');
936
1011
  const feeCurrencyId = this.safeString(feeObject, 'currency');
937
1012
  const datetime = this.safeString(transaction, 'created_at');
938
- const toObject = this.safeDict(transaction, 'to', {});
939
- const toAddress = this.safeString(toObject, 'address');
1013
+ const resource = this.safeString(transaction, 'resource');
1014
+ let type = resource;
1015
+ if (!this.inArray(type, ['deposit', 'withdrawal'])) {
1016
+ if (Precise["default"].stringGt(amountString, '0')) {
1017
+ type = 'deposit';
1018
+ }
1019
+ else if (Precise["default"].stringLt(amountString, '0')) {
1020
+ type = 'withdrawal';
1021
+ }
1022
+ }
1023
+ const toObject = this.safeDict(transaction, 'to');
1024
+ const addressTo = this.safeString(toObject, 'address');
1025
+ const networkId = this.safeString(network, 'network_name');
940
1026
  return {
941
1027
  'info': transaction,
942
1028
  'id': id,
943
- 'txid': id,
1029
+ 'txid': this.safeString(network, 'hash', id),
944
1030
  'timestamp': this.parse8601(datetime),
945
1031
  'datetime': datetime,
946
- 'network': undefined,
947
- 'address': toAddress,
948
- 'addressTo': toAddress,
1032
+ 'network': this.networkIdToCode(networkId),
1033
+ 'address': addressTo,
1034
+ 'addressTo': addressTo,
949
1035
  'addressFrom': undefined,
950
1036
  'tag': undefined,
951
1037
  'tagTo': undefined,
952
1038
  'tagFrom': undefined,
953
- 'type': this.safeString(transaction, 'resource'),
954
- 'amount': this.safeNumber(amountAndCurrencyObject, 'amount'),
1039
+ 'type': type,
1040
+ 'amount': this.parseNumber(amountStringAbs),
955
1041
  'currency': this.safeCurrencyCode(currencyId, currency),
956
1042
  'status': status,
957
1043
  'updated': this.parse8601(this.safeString(transaction, 'updated_at')),
@@ -4958,7 +4958,7 @@ class coinex extends coinex$1 {
4958
4958
  await this.loadMarkets();
4959
4959
  const currency = this.currency(code);
4960
4960
  const amountToPrecision = this.currencyToPrecision(code, amount);
4961
- const accountsByType = this.safeDict(this.options, 'accountsById', {});
4961
+ const accountsByType = this.safeDict(this.options, 'accountsByType', {});
4962
4962
  const fromId = this.safeString(accountsByType, fromAccount, fromAccount);
4963
4963
  const toId = this.safeString(accountsByType, toAccount, toAccount);
4964
4964
  const request = {
@@ -906,22 +906,28 @@ class gate extends gate$1 {
906
906
  */
907
907
  const unifiedAccount = this.safeBool(this.options, 'unifiedAccount');
908
908
  if (unifiedAccount === undefined) {
909
- const response = await this.privateAccountGetDetail(params);
910
- //
911
- // {
912
- // "user_id": 10406147,
913
- // "ip_whitelist": [],
914
- // "currency_pairs": [],
915
- // "key": {
916
- // "mode": 1
917
- // },
918
- // "tier": 0,
919
- // "tier_expire_time": "0001-01-01T00:00:00Z",
920
- // "copy_trading_role": 0
921
- // }
922
- //
923
- const result = this.safeDict(response, 'key', {});
924
- this.options['unifiedAccount'] = this.safeInteger(result, 'mode') === 2;
909
+ try {
910
+ //
911
+ // {
912
+ // "user_id": 10406147,
913
+ // "ip_whitelist": [],
914
+ // "currency_pairs": [],
915
+ // "key": {
916
+ // "mode": 1
917
+ // },
918
+ // "tier": 0,
919
+ // "tier_expire_time": "0001-01-01T00:00:00Z",
920
+ // "copy_trading_role": 0
921
+ // }
922
+ //
923
+ const response = await this.privateAccountGetDetail(params);
924
+ const result = this.safeDict(response, 'key', {});
925
+ this.options['unifiedAccount'] = this.safeInteger(result, 'mode') === 2;
926
+ }
927
+ catch (e) {
928
+ // if the request fails, the unifiedAccount is disabled
929
+ this.options['unifiedAccount'] = false;
930
+ }
925
931
  }
926
932
  }
927
933
  async upgradeUnifiedTradeAccount(params = {}) {
@@ -150,7 +150,17 @@ class hyperliquid extends hyperliquid$1 {
150
150
  'api': {
151
151
  'public': {
152
152
  'post': {
153
- 'info': 1,
153
+ 'info': {
154
+ 'cost': 20,
155
+ 'byType': {
156
+ 'l2Book': 2,
157
+ 'allMids': 2,
158
+ 'clearinghouseState': 2,
159
+ 'orderStatus': 2,
160
+ 'spotClearinghouseState': 2,
161
+ 'exchangeStatus': 2,
162
+ },
163
+ },
154
164
  },
155
165
  },
156
166
  'private': {
@@ -3028,6 +3038,16 @@ class hyperliquid extends hyperliquid$1 {
3028
3038
  }
3029
3039
  return { 'url': url, 'method': method, 'body': body, 'headers': headers };
3030
3040
  }
3041
+ calculateRateLimiterCost(api, method, path, params, config = {}) {
3042
+ if (('byType' in config) && ('type' in params)) {
3043
+ const type = params['type'];
3044
+ const byType = config['byType'];
3045
+ if (type in byType) {
3046
+ return byType[type];
3047
+ }
3048
+ }
3049
+ return this.safeValue(config, 'cost', 1);
3050
+ }
3031
3051
  parseCreateOrderArgs(symbol, type, side, amount, price = undefined, params = {}) {
3032
3052
  const market = this.market(symbol);
3033
3053
  const vaultAddress = this.safeString(params, 'vaultAddress');
@@ -1489,7 +1489,7 @@ class kraken extends kraken$1 {
1489
1489
  // {
1490
1490
  // "error": [],
1491
1491
  // "result": {
1492
- // "descr": { order: 'buy 0.02100000 ETHUSDT @ limit 330.00' },
1492
+ // "descr": { order: 'buy 0.02100000 ETHUSDT @ limit 330.00' }, // see more examples in "parseOrder"
1493
1493
  // "txid": [ 'OEKVV2-IH52O-TPL6GZ' ]
1494
1494
  // }
1495
1495
  // }
@@ -1555,9 +1555,10 @@ class kraken extends kraken$1 {
1555
1555
  }
1556
1556
  parseOrderType(status) {
1557
1557
  const statuses = {
1558
+ // we dont add "space" delimited orders here (eg. stop loss) because they need separate parsing
1558
1559
  'take-profit': 'market',
1559
- 'stop-loss-limit': 'limit',
1560
1560
  'stop-loss': 'market',
1561
+ 'stop-loss-limit': 'limit',
1561
1562
  'take-profit-limit': 'limit',
1562
1563
  'trailing-stop-limit': 'limit',
1563
1564
  };
@@ -1565,30 +1566,19 @@ class kraken extends kraken$1 {
1565
1566
  }
1566
1567
  parseOrder(order, market = undefined) {
1567
1568
  //
1568
- // createOrder for regular orders
1569
+ // createOrder
1569
1570
  //
1570
1571
  // {
1571
- // "descr": { order: 'buy 0.02100000 ETHUSDT @ limit 330.00' },
1572
+ // "descr": {
1573
+ // "order": "buy 0.02100000 ETHUSDT @ limit 330.00" // limit orders
1574
+ // "buy 0.12345678 ETHUSDT @ market" // market order
1575
+ // "sell 0.28002676 ETHUSDT @ stop loss 0.0123 -> limit 0.0.1222" // stop order
1576
+ // "sell 0.00100000 ETHUSDT @ stop loss 2677.00 -> limit 2577.00 with 5:1 leverage"
1577
+ // "buy 0.10000000 LTCUSDT @ take profit 75.00000 -> limit 74.00000"
1578
+ // "sell 10.00000000 XRPEUR @ trailing stop +50.0000%" // trailing stop
1579
+ // },
1572
1580
  // "txid": [ 'OEKVV2-IH52O-TPL6GZ' ]
1573
1581
  // }
1574
- // {
1575
- // "txid": [ "TX_ID_HERE" ],
1576
- // "descr": { "order":"buy 0.12345678 ETHEUR @ market" },
1577
- // }
1578
- //
1579
- //
1580
- // createOrder for stop orders
1581
- //
1582
- // {
1583
- // "txid":["OSILNC-VQI5Q-775ZDQ"],
1584
- // "descr":{"order":"sell 167.28002676 ADAXBT @ stop loss 0.00003280 -> limit 0.00003212"}
1585
- // }
1586
- //
1587
- //
1588
- // {
1589
- // "txid":["OVHMJV-BZW2V-6NZFWF"],
1590
- // "descr":{"order":"sell 0.00100000 ETHUSD @ stop loss 2677.00 -> limit 2577.00 with 5:1 leverage"}
1591
- // }
1592
1582
  //
1593
1583
  // editOrder
1594
1584
  //
@@ -1668,27 +1658,34 @@ class kraken extends kraken$1 {
1668
1658
  orderDescription = this.safeString(order, 'descr');
1669
1659
  }
1670
1660
  let side = undefined;
1671
- let type = undefined;
1661
+ let rawType = undefined;
1672
1662
  let marketId = undefined;
1673
1663
  let price = undefined;
1674
1664
  let amount = undefined;
1675
- let stopPrice = undefined;
1665
+ let triggerPrice = undefined;
1676
1666
  if (orderDescription !== undefined) {
1677
1667
  const parts = orderDescription.split(' ');
1678
1668
  side = this.safeString(parts, 0);
1679
1669
  amount = this.safeString(parts, 1);
1680
1670
  marketId = this.safeString(parts, 2);
1681
- type = this.safeString(parts, 4);
1682
- if (type === 'stop') {
1683
- stopPrice = this.safeString(parts, 6);
1671
+ const part4 = this.safeString(parts, 4);
1672
+ const part5 = this.safeString(parts, 5);
1673
+ if (part4 === 'limit' || part4 === 'market') {
1674
+ rawType = part4; // eg, limit, market
1675
+ }
1676
+ else {
1677
+ rawType = part4 + ' ' + part5; // eg. stop loss, take profit, trailing stop
1678
+ }
1679
+ if (rawType === 'stop loss' || rawType === 'take profit') {
1680
+ triggerPrice = this.safeString(parts, 6);
1684
1681
  price = this.safeString(parts, 9);
1685
1682
  }
1686
- else if (type === 'limit') {
1683
+ else if (rawType === 'limit') {
1687
1684
  price = this.safeString(parts, 5);
1688
1685
  }
1689
1686
  }
1690
1687
  side = this.safeString(description, 'type', side);
1691
- type = this.safeString(description, 'ordertype', type);
1688
+ rawType = this.safeString(description, 'ordertype', rawType); // orderType has dash, e.g. trailing-stop
1692
1689
  marketId = this.safeString(description, 'pair', marketId);
1693
1690
  const foundMarket = this.findMarketByAltnameOrId(marketId);
1694
1691
  let symbol = undefined;
@@ -1753,17 +1750,33 @@ class kraken extends kraken$1 {
1753
1750
  trades.push(rawTrade);
1754
1751
  }
1755
1752
  }
1756
- stopPrice = this.omitZero(this.safeString(order, 'stopprice', stopPrice));
1753
+ // as mentioned in #24192 PR, this field is not something consistent/actual
1754
+ // triggerPrice = this.omitZero (this.safeString (order, 'stopprice', triggerPrice));
1757
1755
  let stopLossPrice = undefined;
1758
1756
  let takeProfitPrice = undefined;
1759
- if (type.startsWith('take-profit')) {
1757
+ // the dashed strings are not provided from fields (eg. fetch order)
1758
+ // while spaced strings from "order" sentence (when other fields not available)
1759
+ if (rawType.startsWith('take-profit')) {
1760
1760
  takeProfitPrice = this.safeString(description, 'price');
1761
1761
  price = this.omitZero(this.safeString(description, 'price2'));
1762
1762
  }
1763
- else if (type.startsWith('stop-loss')) {
1763
+ else if (rawType.startsWith('stop-loss')) {
1764
1764
  stopLossPrice = this.safeString(description, 'price');
1765
1765
  price = this.omitZero(this.safeString(description, 'price2'));
1766
1766
  }
1767
+ else if (rawType === 'take profit') {
1768
+ takeProfitPrice = triggerPrice;
1769
+ }
1770
+ else if (rawType === 'stop loss') {
1771
+ stopLossPrice = triggerPrice;
1772
+ }
1773
+ let finalType = this.parseOrderType(rawType);
1774
+ // unlike from endpoints which provide eg: "take-profit-limit"
1775
+ // for "space-delimited" orders we dont have market/limit suffixes, their format is
1776
+ // eg: `stop loss > limit 123`, so we need to parse them manually
1777
+ if (this.inArray(finalType, ['stop loss', 'take profit'])) {
1778
+ finalType = (price === undefined) ? 'market' : 'limit';
1779
+ }
1767
1780
  return this.safeOrder({
1768
1781
  'id': id,
1769
1782
  'clientOrderId': clientOrderId,
@@ -1773,13 +1786,13 @@ class kraken extends kraken$1 {
1773
1786
  'lastTradeTimestamp': undefined,
1774
1787
  'status': status,
1775
1788
  'symbol': symbol,
1776
- 'type': this.parseOrderType(type),
1789
+ 'type': finalType,
1777
1790
  'timeInForce': undefined,
1778
1791
  'postOnly': isPostOnly,
1779
1792
  'side': side,
1780
1793
  'price': price,
1781
- 'stopPrice': stopPrice,
1782
- 'triggerPrice': stopPrice,
1794
+ 'stopPrice': triggerPrice,
1795
+ 'triggerPrice': triggerPrice,
1783
1796
  'takeProfitPrice': takeProfitPrice,
1784
1797
  'stopLossPrice': stopLossPrice,
1785
1798
  'cost': undefined,