ccxt 4.5.44 → 4.5.46

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 (111) hide show
  1. package/README.md +9 -12
  2. package/dist/ccxt.browser.min.js +3 -3
  3. package/dist/cjs/ccxt.js +1 -12
  4. package/dist/cjs/src/abstract/kucoinfutures.js +1 -1
  5. package/dist/cjs/src/base/Exchange.js +39 -3
  6. package/dist/cjs/src/base/functions/encode.js +2 -2
  7. package/dist/cjs/src/base/functions/generic.js +8 -2
  8. package/dist/cjs/src/binance.js +11 -2
  9. package/dist/cjs/src/bitget.js +3 -1
  10. package/dist/cjs/src/bitmart.js +144 -21
  11. package/dist/cjs/src/bitrue.js +1 -1
  12. package/dist/cjs/src/bitteam.js +1 -1
  13. package/dist/cjs/src/btcbox.js +1 -1
  14. package/dist/cjs/src/bybit.js +58 -56
  15. package/dist/cjs/src/bydfi.js +102 -100
  16. package/dist/cjs/src/cex.js +1 -0
  17. package/dist/cjs/src/gate.js +264 -170
  18. package/dist/cjs/src/grvt.js +3 -2
  19. package/dist/cjs/src/hyperliquid.js +16 -5
  20. package/dist/cjs/src/kraken.js +4 -2
  21. package/dist/cjs/src/krakenfutures.js +1 -5
  22. package/dist/cjs/src/kucoin.js +4733 -972
  23. package/dist/cjs/src/kucoinfutures.js +14 -3434
  24. package/dist/cjs/src/lbank.js +1 -1
  25. package/dist/cjs/src/okx.js +75 -57
  26. package/dist/cjs/src/paradex.js +2 -6
  27. package/dist/cjs/src/poloniex.js +1 -1
  28. package/dist/cjs/src/pro/bydfi.js +19 -19
  29. package/dist/cjs/src/pro/gate.js +114 -53
  30. package/dist/cjs/src/pro/grvt.js +5 -3
  31. package/dist/cjs/src/pro/htx.js +4 -4
  32. package/dist/cjs/src/pro/kucoin.js +819 -178
  33. package/dist/cjs/src/pro/kucoinfutures.js +95 -1261
  34. package/dist/cjs/src/pro/mexc.js +10 -5
  35. package/dist/cjs/src/pro/okx.js +85 -40
  36. package/index.d.cts +2 -0
  37. package/js/ccxt.d.ts +2 -14
  38. package/js/ccxt.js +2 -10
  39. package/js/src/abstract/bitmart.d.ts +7 -0
  40. package/js/src/abstract/bydfi.d.ts +29 -29
  41. package/js/src/abstract/kraken.d.ts +1 -0
  42. package/js/src/abstract/kucoin.d.ts +46 -2
  43. package/js/src/abstract/kucoinfutures.d.ts +27 -11
  44. package/js/src/base/Exchange.d.ts +13 -1
  45. package/js/src/base/Exchange.js +39 -3
  46. package/js/src/base/functions/encode.js +2 -2
  47. package/js/src/base/functions/generic.js +9 -3
  48. package/js/src/binance.js +11 -2
  49. package/js/src/bitget.js +3 -1
  50. package/js/src/bitmart.d.ts +18 -4
  51. package/js/src/bitmart.js +144 -21
  52. package/js/src/bitrue.js +1 -1
  53. package/js/src/bitteam.js +1 -1
  54. package/js/src/btcbox.js +1 -1
  55. package/js/src/bybit.d.ts +1 -0
  56. package/js/src/bybit.js +58 -56
  57. package/js/src/bydfi.d.ts +31 -31
  58. package/js/src/bydfi.js +102 -100
  59. package/js/src/cex.js +2 -1
  60. package/js/src/gate.d.ts +125 -119
  61. package/js/src/gate.js +264 -170
  62. package/js/src/grvt.js +3 -2
  63. package/js/src/hyperliquid.d.ts +3 -1
  64. package/js/src/hyperliquid.js +16 -5
  65. package/js/src/kraken.js +4 -2
  66. package/js/src/krakenfutures.js +1 -5
  67. package/js/src/kucoin.d.ts +696 -100
  68. package/js/src/kucoin.js +4734 -973
  69. package/js/src/kucoinfutures.d.ts +4 -522
  70. package/js/src/kucoinfutures.js +14 -3434
  71. package/js/src/lbank.js +1 -1
  72. package/js/src/okx.d.ts +1 -0
  73. package/js/src/okx.js +75 -57
  74. package/js/src/paradex.d.ts +0 -1
  75. package/js/src/paradex.js +2 -6
  76. package/js/src/poloniex.js +1 -1
  77. package/js/src/pro/bydfi.d.ts +18 -18
  78. package/js/src/pro/bydfi.js +19 -19
  79. package/js/src/pro/gate.d.ts +30 -1
  80. package/js/src/pro/gate.js +114 -53
  81. package/js/src/pro/grvt.js +5 -3
  82. package/js/src/pro/htx.js +4 -4
  83. package/js/src/pro/kucoin.d.ts +70 -30
  84. package/js/src/pro/kucoin.js +821 -180
  85. package/js/src/pro/kucoinfutures.d.ts +17 -195
  86. package/js/src/pro/kucoinfutures.js +96 -1262
  87. package/js/src/pro/mexc.js +10 -5
  88. package/js/src/pro/okx.d.ts +1 -0
  89. package/js/src/pro/okx.js +85 -40
  90. package/package.json +2 -2
  91. package/dist/cjs/src/abstract/alp.js +0 -11
  92. package/dist/cjs/src/abstract/defx.js +0 -11
  93. package/dist/cjs/src/abstract/timex.js +0 -11
  94. package/dist/cjs/src/alp.js +0 -1059
  95. package/dist/cjs/src/defx.js +0 -2142
  96. package/dist/cjs/src/pro/defx.js +0 -866
  97. package/dist/cjs/src/timex.js +0 -1793
  98. package/js/src/abstract/alp.d.ts +0 -21
  99. package/js/src/abstract/alp.js +0 -5
  100. package/js/src/abstract/defx.d.ts +0 -72
  101. package/js/src/abstract/defx.js +0 -5
  102. package/js/src/abstract/timex.d.ts +0 -65
  103. package/js/src/abstract/timex.js +0 -5
  104. package/js/src/alp.d.ts +0 -209
  105. package/js/src/alp.js +0 -1052
  106. package/js/src/defx.d.ts +0 -348
  107. package/js/src/defx.js +0 -2135
  108. package/js/src/pro/defx.d.ts +0 -236
  109. package/js/src/pro/defx.js +0 -859
  110. package/js/src/timex.d.ts +0 -247
  111. package/js/src/timex.js +0 -1786
@@ -25,7 +25,7 @@ class gate extends gate$1["default"] {
25
25
  'pro': true,
26
26
  'urls': {
27
27
  'logo': 'https://github.com/user-attachments/assets/64f988c5-07b6-4652-b5c1-679a6bf67c85',
28
- 'doc': 'https://www.gate.com/docs/developers/apiv4/en/',
28
+ 'doc': 'https://www.gate.com/docs/developers/apiv4/en',
29
29
  'www': 'https://gate.com',
30
30
  'api': {
31
31
  'public': {
@@ -1174,7 +1174,7 @@ class gate extends gate$1["default"] {
1174
1174
  * @name gate#loadUnifiedStatus
1175
1175
  * @param {object} [params] extra parameters specific to the exchange API endpoint
1176
1176
  * @description returns unifiedAccount so the user can check if the unified account is enabled
1177
- * @see https://www.gate.com/docs/developers/apiv4/#get-account-detail
1177
+ * @see https://www.gate.com/docs/developers/apiv4/#retrieve-user-account-information
1178
1178
  * @returns {boolean} true or false if the enabled unified account is enabled or not and sets the unifiedAccount option if it is undefined
1179
1179
  */
1180
1180
  async loadUnifiedStatus(params = {}) {
@@ -1212,7 +1212,7 @@ class gate extends gate$1["default"] {
1212
1212
  * @method
1213
1213
  * @name gate#fetchTime
1214
1214
  * @description fetches the current integer timestamp in milliseconds from the exchange server
1215
- * @see https://www.gate.com/docs/developers/apiv4/en/#get-server-current-time
1215
+ * @see https://www.gate.com/docs/developers/apiv4/#get-server-current-time
1216
1216
  * @param {object} [params] extra parameters specific to the exchange API endpoint
1217
1217
  * @returns {int} the current integer timestamp in milliseconds from the exchange server
1218
1218
  */
@@ -1302,11 +1302,11 @@ class gate extends gate$1["default"] {
1302
1302
  * @method
1303
1303
  * @name gate#fetchMarkets
1304
1304
  * @description retrieves data on all markets for gate
1305
- * @see https://www.gate.com/docs/developers/apiv4/en/#list-all-currency-pairs-supported // spot
1305
+ * @see https://www.gate.com/docs/developers/apiv4/#query-all-supported-currency-pairs // spot
1306
1306
  * @see https://www.gate.com/docs/developers/apiv4/en/#list-all-supported-currency-pairs-supported-in-margin-trading // margin
1307
- * @see https://www.gate.com/docs/developers/apiv4/en/#list-all-futures-contracts // swap
1308
- * @see https://www.gate.com/docs/developers/apiv4/en/#list-all-futures-contracts-2 // future
1309
- * @see https://www.gate.com/docs/developers/apiv4/en/#list-all-the-contracts-with-specified-underlying-and-expiration-time // option
1307
+ * @see https://www.gate.com/docs/developers/apiv4/en/#query-all-futures-contracts // swap
1308
+ * @see https://www.gate.com/docs/developers/apiv4/en/#query-all-futures-contracts-2 // future
1309
+ * @see https://www.gate.com/docs/developers/apiv4/en/#list-all-contracts-for-specified-underlying-and-expiration-date // option
1310
1310
  * @param {object} [params] extra parameters specific to the exchange API endpoint
1311
1311
  * @returns {object[]} an array of objects representing market data
1312
1312
  */
@@ -1940,7 +1940,7 @@ class gate extends gate$1["default"] {
1940
1940
  * @method
1941
1941
  * @name gate#fetchCurrencies
1942
1942
  * @description fetches all available currencies on an exchange
1943
- * @see https://www.gate.com/docs/developers/apiv4/en/#list-all-currencies-details
1943
+ * @see https://www.gate.com/docs/developers/apiv4/en/#query-all-currency-information
1944
1944
  * @param {object} [params] extra parameters specific to the exchange API endpoint
1945
1945
  * @returns {object} an associative dictionary of currencies
1946
1946
  */
@@ -2044,7 +2044,7 @@ class gate extends gate$1["default"] {
2044
2044
  * @method
2045
2045
  * @name gate#fetchFundingRate
2046
2046
  * @description fetch the current funding rate
2047
- * @see https://www.gate.com/docs/developers/apiv4/en/#get-a-single-contract
2047
+ * @see https://www.gate.com/docs/developers/apiv4/en/#query-single-contract-information
2048
2048
  * @param {string} symbol unified market symbol
2049
2049
  * @param {object} [params] extra parameters specific to the exchange API endpoint
2050
2050
  * @returns {object} a [funding rate structure]{@link https://docs.ccxt.com/?id=funding-rate-structure}
@@ -2107,7 +2107,7 @@ class gate extends gate$1["default"] {
2107
2107
  * @method
2108
2108
  * @name gate#fetchFundingRates
2109
2109
  * @description fetch the funding rate for multiple markets
2110
- * @see https://www.gate.com/docs/developers/apiv4/en/#list-all-futures-contracts
2110
+ * @see https://www.gate.com/docs/developers/apiv4/en/#query-all-futures-contracts
2111
2111
  * @param {string[]|undefined} symbols list of unified market symbols
2112
2112
  * @param {object} [params] extra parameters specific to the exchange API endpoint
2113
2113
  * @returns {object[]} a list of [funding rate structures]{@link https://docs.ccxt.com/?id=funding-rates-structure}, indexed by market symbols
@@ -2294,6 +2294,7 @@ class gate extends gate$1["default"] {
2294
2294
  * @method
2295
2295
  * @name gate#fetchDepositAddressesByNetwork
2296
2296
  * @description fetch a dictionary of addresses for a currency, indexed by network
2297
+ * @see https://www.gate.com/docs/developers/apiv4/en/#generate-currency-deposit-address
2297
2298
  * @param {string} code unified currency code of the currency for the deposit address
2298
2299
  * @param {object} [params] extra parameters specific to the api endpoint
2299
2300
  * @returns {object} a dictionary of [address structures]{@link https://docs.ccxt.com/?id=address-structure} indexed by the network
@@ -2353,7 +2354,7 @@ class gate extends gate$1["default"] {
2353
2354
  * @method
2354
2355
  * @name gate#fetchTradingFee
2355
2356
  * @description fetch the trading fees for a market
2356
- * @see https://www.gate.com/docs/developers/apiv4/en/#retrieve-personal-trading-fee
2357
+ * @see https://www.gate.com/docs/developers/apiv4/en/#query-personal-trading-fees
2357
2358
  * @param {string} symbol unified market symbol
2358
2359
  * @param {object} [params] extra parameters specific to the exchange API endpoint
2359
2360
  * @returns {object} a [fee structure]{@link https://docs.ccxt.com/?id=fee-structure}
@@ -2385,7 +2386,7 @@ class gate extends gate$1["default"] {
2385
2386
  * @method
2386
2387
  * @name gate#fetchTradingFees
2387
2388
  * @description fetch the trading fees for multiple markets
2388
- * @see https://www.gate.com/docs/developers/apiv4/en/#retrieve-personal-trading-fee
2389
+ * @see https://www.gate.com/docs/developers/apiv4/en/#query-personal-trading-fees
2389
2390
  * @param {object} [params] extra parameters specific to the exchange API endpoint
2390
2391
  * @returns {object} a dictionary of [fee structures]{@link https://docs.ccxt.com/?id=fee-structure} indexed by market symbols
2391
2392
  */
@@ -2452,7 +2453,7 @@ class gate extends gate$1["default"] {
2452
2453
  * @name gate#fetchTransactionFees
2453
2454
  * @deprecated
2454
2455
  * @description please use fetchDepositWithdrawFees instead
2455
- * @see https://www.gate.com/docs/developers/apiv4/en/#retrieve-withdrawal-status
2456
+ * @see https://www.gate.com/docs/developers/apiv4/en/#query-withdrawal-status
2456
2457
  * @param {string[]|undefined} codes list of unified currency codes
2457
2458
  * @param {object} [params] extra parameters specific to the exchange API endpoint
2458
2459
  * @returns {object} a list of [fee structures]{@link https://docs.ccxt.com/?id=fee-structure}
@@ -2511,7 +2512,7 @@ class gate extends gate$1["default"] {
2511
2512
  * @method
2512
2513
  * @name gate#fetchDepositWithdrawFees
2513
2514
  * @description fetch deposit and withdraw fees
2514
- * @see https://www.gate.com/docs/developers/apiv4/en/#retrieve-withdrawal-status
2515
+ * @see https://www.gate.com/docs/developers/apiv4/en/#query-withdrawal-status
2515
2516
  * @param {string[]|undefined} codes list of unified currency codes
2516
2517
  * @param {object} [params] extra parameters specific to the exchange API endpoint
2517
2518
  * @returns {object} a list of [fee structures]{@link https://docs.ccxt.com/?id=fee-structure}
@@ -2594,8 +2595,8 @@ class gate extends gate$1["default"] {
2594
2595
  * @method
2595
2596
  * @name gate#fetchFundingHistory
2596
2597
  * @description fetch the history of funding payments paid and received on this account
2597
- * @see https://www.gate.com/docs/developers/apiv4/en/#query-account-book-2
2598
- * @see https://www.gate.com/docs/developers/apiv4/en/#query-account-book-3
2598
+ * @see https://www.gate.com/docs/developers/apiv4/en/#query-futures-account-change-history
2599
+ * @see https://www.gate.com/docs/developers/apiv4/en/#query-futures-account-change-history-2
2599
2600
  * @param {string} symbol unified market symbol
2600
2601
  * @param {int} [since] the earliest time in ms to fetch funding history for
2601
2602
  * @param {int} [limit] the maximum number of funding history structures to retrieve
@@ -2681,10 +2682,10 @@ class gate extends gate$1["default"] {
2681
2682
  * @method
2682
2683
  * @name gate#fetchOrderBook
2683
2684
  * @description fetches information on open orders with bid (buy) and ask (sell) prices, volumes and other data
2684
- * @see https://www.gate.com/docs/developers/apiv4/en/#retrieve-order-book
2685
- * @see https://www.gate.com/docs/developers/apiv4/en/#futures-order-book
2686
- * @see https://www.gate.com/docs/developers/apiv4/en/#futures-order-book-2
2687
- * @see https://www.gate.com/docs/developers/apiv4/en/#options-order-book
2685
+ * @see https://www.gate.com/docs/developers/apiv4/en/#get-market-depth-information
2686
+ * @see https://www.gate.com/docs/developers/apiv4/en/#query-futures-market-depth-information
2687
+ * @see https://www.gate.com/docs/developers/apiv4/en/#query-futures-market-depth-information-2
2688
+ * @see https://www.gate.com/docs/developers/apiv4/en/#query-options-contract-order-book
2688
2689
  * @param {string} symbol unified symbol of the market to fetch the order book for
2689
2690
  * @param {int} [limit] the maximum amount of order book entries to return
2690
2691
  * @param {object} [params] extra parameters specific to the exchange API endpoint
@@ -2807,10 +2808,10 @@ class gate extends gate$1["default"] {
2807
2808
  * @method
2808
2809
  * @name gate#fetchTicker
2809
2810
  * @description fetches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
2810
- * @see https://www.gate.com/docs/developers/apiv4/en/#get-details-of-a-specifc-order
2811
- * @see https://www.gate.com/docs/developers/apiv4/en/#list-futures-tickers
2812
- * @see https://www.gate.com/docs/developers/apiv4/en/#list-futures-tickers-2
2813
- * @see https://www.gate.com/docs/developers/apiv4/en/#list-tickers-of-options-contracts
2811
+ * @see https://www.gate.com/docs/developers/apiv4/en/#get-currency-pair-ticker-information
2812
+ * @see https://www.gate.com/docs/developers/apiv4/en/#get-all-futures-trading-statistics
2813
+ * @see https://www.gate.com/docs/developers/apiv4/en/#get-all-futures-trading-statistics-2
2814
+ * @see https://www.gate.com/docs/developers/apiv4/en/#query-options-market-ticker-information
2814
2815
  * @param {string} symbol unified symbol of the market to fetch the ticker for
2815
2816
  * @param {object} [params] extra parameters specific to the exchange API endpoint
2816
2817
  * @returns {object} a [ticker structure]{@link https://docs.ccxt.com/?id=ticker-structure}
@@ -2971,10 +2972,10 @@ class gate extends gate$1["default"] {
2971
2972
  * @method
2972
2973
  * @name gate#fetchTickers
2973
2974
  * @description fetches price tickers for multiple markets, statistical information calculated over the past 24 hours for each market
2974
- * @see https://www.gate.com/docs/developers/apiv4/en/#get-details-of-a-specifc-order
2975
- * @see https://www.gate.com/docs/developers/apiv4/en/#list-futures-tickers
2976
- * @see https://www.gate.com/docs/developers/apiv4/en/#list-futures-tickers-2
2977
- * @see https://www.gate.com/docs/developers/apiv4/en/#list-tickers-of-options-contracts
2975
+ * @see https://www.gate.com/docs/developers/apiv4/en/#get-currency-pair-ticker-information
2976
+ * @see https://www.gate.com/docs/developers/apiv4/en/#get-all-futures-trading-statistics
2977
+ * @see https://www.gate.com/docs/developers/apiv4/en/#get-all-futures-trading-statistics-2
2978
+ * @see https://www.gate.com/docs/developers/apiv4/en/#query-options-market-ticker-information
2978
2979
  * @param {string[]|undefined} symbols unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
2979
2980
  * @param {object} [params] extra parameters specific to the exchange API endpoint
2980
2981
  * @returns {object} a dictionary of [ticker structures]{@link https://docs.ccxt.com/?id=ticker-structure}
@@ -3025,9 +3026,10 @@ class gate extends gate$1["default"] {
3025
3026
  /**
3026
3027
  * @method
3027
3028
  * @name gate#fetchBalance
3028
- * @see https://www.gate.com/docs/developers/apiv4/en/#margin-account-list
3029
3029
  * @see https://www.gate.com/docs/developers/apiv4/en/#get-unified-account-information
3030
3030
  * @see https://www.gate.com/docs/developers/apiv4/en/#list-spot-trading-accounts
3031
+ * @see https://www.gate.com/docs/developers/apiv4/en/#margin-account-list
3032
+ * @see https://www.gate.com/docs/developers/apiv4/en/#funding-account-list
3031
3033
  * @see https://www.gate.com/docs/developers/apiv4/en/#get-futures-account
3032
3034
  * @see https://www.gate.com/docs/developers/apiv4/en/#get-futures-account-2
3033
3035
  * @see https://www.gate.com/docs/developers/apiv4/en/#query-account-information
@@ -3327,10 +3329,10 @@ class gate extends gate$1["default"] {
3327
3329
  * @method
3328
3330
  * @name gateio#fetchOHLCV
3329
3331
  * @description fetches historical candlestick data containing the open, high, low, and close price, and the volume of a market
3330
- * @see https://www.gate.com/docs/developers/apiv4/en/#market-candlesticks // spot
3331
- * @see https://www.gate.com/docs/developers/apiv4/en/#get-futures-candlesticks // swap
3332
- * @see https://www.gate.com/docs/developers/apiv4/en/#market-candlesticks // future
3333
- * @see https://www.gate.com/docs/developers/apiv4/en/#get-options-candlesticks // option
3332
+ * @see https://www.gate.com/docs/developers/apiv4/en/#market-k-line-chart // spot
3333
+ * @see https://www.gate.com/docs/developers/apiv4/en/#futures-market-k-line-chart // swap
3334
+ * @see https://www.gate.com/docs/developers/apiv4/en/#futures-market-k-line-chart-2 // future
3335
+ * @see https://www.gate.com/docs/developers/apiv4/en/#options-contract-market-candlestick-chart // option
3334
3336
  * @param {string} symbol unified symbol of the market to fetch OHLCV data for
3335
3337
  * @param {string} timeframe the length of time each candle represents
3336
3338
  * @param {int} [since] timestamp in ms of the earliest candle to fetch
@@ -3417,7 +3419,7 @@ class gate extends gate$1["default"] {
3417
3419
  * @method
3418
3420
  * @name gate#fetchFundingRateHistory
3419
3421
  * @description fetches historical funding rate prices
3420
- * @see https://www.gate.com/docs/developers/apiv4/en/#funding-rate-history
3422
+ * @see https://www.gate.com/docs/developers/apiv4/en/#get-all-futures-trading-statistics
3421
3423
  * @param {string} symbol unified symbol of the market to fetch the funding rate history for
3422
3424
  * @param {int} [since] timestamp in ms of the earliest funding rate to fetch
3423
3425
  * @param {int} [limit] the maximum amount of [funding rate structures]{@link https://docs.ccxt.com/?id=funding-rate-history-structure} to fetch
@@ -3526,10 +3528,10 @@ class gate extends gate$1["default"] {
3526
3528
  * @method
3527
3529
  * @name gate#fetchTrades
3528
3530
  * @description get the list of most recent trades for a particular symbol
3529
- * @see https://www.gate.com/docs/developers/apiv4/en/#retrieve-market-trades
3530
- * @see https://www.gate.com/docs/developers/apiv4/en/#futures-trading-history
3531
- * @see https://www.gate.com/docs/developers/apiv4/en/#futures-trading-history-2
3532
- * @see https://www.gate.com/docs/developers/apiv4/en/#options-trade-history
3531
+ * @see https://www.gate.com/docs/developers/apiv4/en/#query-market-transaction-records
3532
+ * @see https://www.gate.com/docs/developers/apiv4/en/#futures-market-transaction-records
3533
+ * @see https://www.gate.com/docs/developers/apiv4/en/#futures-market-transaction-records-2
3534
+ * @see https://www.gate.com/docs/developers/apiv4/en/#market-trade-records
3533
3535
  * @param {string} symbol unified symbol of the market to fetch trades for
3534
3536
  * @param {int} [since] timestamp in ms of the earliest trade to fetch
3535
3537
  * @param {int} [limit] the maximum amount of trades to fetch
@@ -3641,10 +3643,10 @@ class gate extends gate$1["default"] {
3641
3643
  * @method
3642
3644
  * @name gate#fetchOrderTrades
3643
3645
  * @description fetch all the trades made from a single order
3644
- * @see https://www.gate.com/docs/developers/apiv4/en/#list-personal-trading-history
3645
- * @see https://www.gate.com/docs/developers/apiv4/en/#list-personal-trading-history-2
3646
- * @see https://www.gate.com/docs/developers/apiv4/en/#list-personal-trading-history-3
3647
- * @see https://www.gate.com/docs/developers/apiv4/en/#list-personal-trading-history-4
3646
+ * @see https://www.gate.com/docs/developers/apiv4/en/#query-personal-trading-records
3647
+ * @see https://www.gate.com/docs/developers/apiv4/en/#query-personal-trading-records-by-time-range
3648
+ * @see https://www.gate.com/docs/developers/apiv4/en/#query-personal-trading-records-3
3649
+ * @see https://www.gate.com/docs/developers/apiv4/en/#query-personal-trading-records-4
3648
3650
  * @param {string} id order id
3649
3651
  * @param {string} symbol unified market symbol
3650
3652
  * @param {int} [since] the earliest time in ms to fetch trades for
@@ -3683,10 +3685,10 @@ class gate extends gate$1["default"] {
3683
3685
  * @method
3684
3686
  * @name gate#fetchMyTrades
3685
3687
  * @description Fetch personal trading history
3686
- * @see https://www.gate.com/docs/developers/apiv4/en/#list-personal-trading-history
3687
- * @see https://www.gate.com/docs/developers/apiv4/en/#list-personal-trading-history-2
3688
- * @see https://www.gate.com/docs/developers/apiv4/en/#list-personal-trading-history-3
3689
- * @see https://www.gate.com/docs/developers/apiv4/en/#list-personal-trading-history-4
3688
+ * @see https://www.gate.com/docs/developers/apiv4/en/#query-personal-trading-records
3689
+ * @see https://www.gate.com/docs/developers/apiv4/en/#query-personal-trading-records-by-time-range
3690
+ * @see https://www.gate.com/docs/developers/apiv4/en/#query-personal-trading-records-3
3691
+ * @see https://www.gate.com/docs/developers/apiv4/en/#query-personal-trading-records-4
3690
3692
  * @param {string} symbol unified market symbol
3691
3693
  * @param {int} [since] the earliest time in ms to fetch trades for
3692
3694
  * @param {int} [limit] the maximum number of trades structures to retrieve
@@ -3995,7 +3997,7 @@ class gate extends gate$1["default"] {
3995
3997
  * @method
3996
3998
  * @name gate#fetchDeposits
3997
3999
  * @description fetch all deposits made to an account
3998
- * @see https://www.gate.com/docs/developers/apiv4/en/#retrieve-deposit-records
4000
+ * @see https://www.gate.com/docs/developers/apiv4/en/#get-deposit-records
3999
4001
  * @param {string} code unified currency code
4000
4002
  * @param {int} [since] the earliest time in ms to fetch deposits for
4001
4003
  * @param {int} [limit] the maximum number of deposits structures to retrieve
@@ -4033,7 +4035,7 @@ class gate extends gate$1["default"] {
4033
4035
  * @method
4034
4036
  * @name gate#fetchWithdrawals
4035
4037
  * @description fetch all withdrawals made from an account
4036
- * @see https://www.gate.com/docs/developers/apiv4/en/#retrieve-withdrawal-records
4038
+ * @see https://www.gate.com/docs/developers/apiv4/en/#get-withdrawal-records
4037
4039
  * @param {string} code unified currency code
4038
4040
  * @param {int} [since] the earliest time in ms to fetch withdrawals for
4039
4041
  * @param {int} [limit] the maximum number of withdrawals structures to retrieve
@@ -4252,11 +4254,11 @@ class gate extends gate$1["default"] {
4252
4254
  * @name gate#createOrder
4253
4255
  * @description Create an order on the exchange
4254
4256
  * @see https://www.gate.com/docs/developers/apiv4/en/#create-an-order
4255
- * @see https://www.gate.com/docs/developers/apiv4/en/#create-a-price-triggered-order
4256
- * @see https://www.gate.com/docs/developers/apiv4/en/#create-a-futures-order
4257
- * @see https://www.gate.com/docs/developers/apiv4/en/#create-a-price-triggered-order-2
4258
- * @see https://www.gate.com/docs/developers/apiv4/en/#create-a-futures-order-2
4259
- * @see https://www.gate.com/docs/developers/apiv4/en/#create-a-price-triggered-order-3
4257
+ * @see https://www.gate.com/docs/developers/apiv4/en/#create-price-triggered-order
4258
+ * @see https://www.gate.com/docs/developers/apiv4/en/#place-futures-order
4259
+ * @see https://www.gate.com/docs/developers/apiv4/en/#create-price-triggered-order-2
4260
+ * @see https://www.gate.com/docs/developers/apiv4/en/#place-futures-order-2
4261
+ * @see https://www.gate.com/docs/developers/apiv4/en/#create-price-triggered-order-3
4260
4262
  * @see https://www.gate.com/docs/developers/apiv4/en/#create-an-options-order
4261
4263
  * @param {string} symbol Unified CCXT market symbol
4262
4264
  * @param {string} type 'limit' or 'market' *"market" is contract only*
@@ -4429,9 +4431,8 @@ class gate extends gate$1["default"] {
4429
4431
  * @method
4430
4432
  * @name gate#createOrders
4431
4433
  * @description create a list of trade orders
4432
- * @see https://www.gate.com/docs/developers/apiv4/en/#get-a-single-order-2
4433
- * @see https://www.gate.com/docs/developers/apiv4/en/#create-a-batch-of-orders
4434
- * @see https://www.gate.com/docs/developers/apiv4/en/#create-a-batch-of-futures-orders
4434
+ * @see https://www.gate.com/docs/developers/apiv4/en/#batch-place-orders
4435
+ * @see https://www.gate.com/docs/developers/apiv4/en/#place-batch-futures-orders
4435
4436
  * @param {Array} orders list of orders to create, each object should contain the parameters required by createOrder, namely symbol, type, side, amount, price and params
4436
4437
  * @param {object} [params] extra parameters specific to the exchange API endpoint
4437
4438
  * @returns {object} an [order structure]{@link https://docs.ccxt.com/?id=order-structure}
@@ -4735,7 +4736,7 @@ class gate extends gate$1["default"] {
4735
4736
  if (!market['spot']) {
4736
4737
  throw new errors.NotSupported(this.id + ' createMarketBuyOrderWithCost() supports spot orders only');
4737
4738
  }
4738
- params['createMarketBuyOrderRequiresPrice'] = false;
4739
+ params = this.extend(params, { 'createMarketBuyOrderRequiresPrice': false });
4739
4740
  return await this.createOrder(symbol, 'market', 'buy', cost, undefined, params);
4740
4741
  }
4741
4742
  editOrderRequest(id, symbol, type, side, amount = undefined, price = undefined, params = {}) {
@@ -4785,8 +4786,8 @@ class gate extends gate$1["default"] {
4785
4786
  * @method
4786
4787
  * @name gate#editOrder
4787
4788
  * @description edit a trade order, gate currently only supports the modification of the price or amount fields
4788
- * @see https://www.gate.com/docs/developers/apiv4/en/#amend-an-order
4789
- * @see https://www.gate.com/docs/developers/apiv4/en/#amend-an-order-2
4789
+ * @see https://www.gate.com/docs/developers/apiv4/en/#amend-single-order
4790
+ * @see https://www.gate.com/docs/developers/apiv4/en/#amend-single-order-2
4790
4791
  * @param {string} id order id
4791
4792
  * @param {string} symbol unified symbol of the market to create an order in
4792
4793
  * @param {string} type 'market' or 'limit'
@@ -5020,6 +5021,42 @@ class gate extends gate$1["default"] {
5020
5021
  // order_type: '',
5021
5022
  // in_dual_mode: false,
5022
5023
  // parent_id: '0',
5024
+ //
5025
+ // unified spot: watchOrders
5026
+ //
5027
+ // {
5028
+ // "id": "1036717689726",
5029
+ // "text": "apiv4",
5030
+ // "create_time": "1774613210",
5031
+ // "update_time": "1774613210",
5032
+ // "currency_pair": "BTC_USDT",
5033
+ // "type": "limit",
5034
+ // "account": "unified",
5035
+ // "side": "buy",
5036
+ // "amount": "0.1",
5037
+ // "price": "200",
5038
+ // "time_in_force": "gtc",
5039
+ // "left": "0.1",
5040
+ // "filled_amount": "0",
5041
+ // "filled_total": "0",
5042
+ // "avg_deal_price": "0",
5043
+ // "fee": "0",
5044
+ // "fee_currency": "BTC",
5045
+ // "point_fee": "0",
5046
+ // "gt_fee": "0",
5047
+ // "rebated_fee": "0",
5048
+ // "rebated_fee_currency": "BTC",
5049
+ // "create_time_ms": "1774613210391",
5050
+ // "update_time_ms": "1774613210391",
5051
+ // "user": 10406147,
5052
+ // "event": "put",
5053
+ // "stp_id": 0,
5054
+ // "stp_act": "-",
5055
+ // "finish_as": "open",
5056
+ // "biz_info": "ch:ccxt",
5057
+ // "amend_text": "-"
5058
+ // }
5059
+ //
5023
5060
  const succeeded = this.safeBool(order, 'succeeded', true);
5024
5061
  if (!succeeded) {
5025
5062
  // cancelOrders response
@@ -5096,7 +5133,6 @@ class gate extends gate$1["default"] {
5096
5133
  }
5097
5134
  const exchangeSymbol = this.safeString2(order, 'currency_pair', 'market', contract);
5098
5135
  const symbol = this.safeSymbol(exchangeSymbol, market, '_', marketType);
5099
- // Everything below this(above return) is related to fees
5100
5136
  const fees = [];
5101
5137
  const gtFee = this.safeString(order, 'gt_fee');
5102
5138
  if (gtFee !== undefined) {
@@ -5125,7 +5161,7 @@ class gate extends gate$1["default"] {
5125
5161
  let remaining = Precise["default"].stringAbs(remainingString);
5126
5162
  // handle spot market buy
5127
5163
  const account = this.safeString(order, 'account'); // using this instead of market type because of the conflicting ids
5128
- if (account === 'spot') {
5164
+ if ((account === 'spot') || (account === 'unified')) {
5129
5165
  const averageString = this.safeString(order, 'avg_deal_price');
5130
5166
  average = this.parseNumber(averageString);
5131
5167
  if ((type === 'market') && (side === 'buy')) {
@@ -5204,10 +5240,13 @@ class gate extends gate$1["default"] {
5204
5240
  * @method
5205
5241
  * @name gate#fetchOrder
5206
5242
  * @description Retrieves information on an order
5207
- * @see https://www.gate.com/docs/developers/apiv4/en/#get-a-single-order
5208
- * @see https://www.gate.com/docs/developers/apiv4/en/#get-a-single-order-2
5209
- * @see https://www.gate.com/docs/developers/apiv4/en/#get-a-single-order-3
5210
- * @see https://www.gate.com/docs/developers/apiv4/en/#get-a-single-order-4
5243
+ * @see https://www.gate.com/docs/developers/apiv4/en/#query-single-order-details
5244
+ * @see https://www.gate.com/docs/developers/apiv4/en/#query-single-auto-order-details
5245
+ * @see https://www.gate.com/docs/developers/apiv4/en/#query-single-order-details-2
5246
+ * @see https://www.gate.com/docs/developers/apiv4/en/#query-single-auto-order-details-2
5247
+ * @see https://www.gate.com/docs/developers/apiv4/en/#query-single-order-details-3
5248
+ * @see https://www.gate.com/docs/developers/apiv4/en/#query-single-auto-order-details-3
5249
+ * @see https://www.gate.com/docs/developers/apiv4/en/#query-single-order-details-4
5211
5250
  * @param {string} id Order id
5212
5251
  * @param {string} symbol Unified market symbol, *required for spot and margin*
5213
5252
  * @param {object} [params] Parameters specified by the exchange api
@@ -5264,7 +5303,6 @@ class gate extends gate$1["default"] {
5264
5303
  * @name gate#fetchOpenOrders
5265
5304
  * @description fetch all unfilled currently open orders
5266
5305
  * @see https://www.gate.com/docs/developers/apiv4/en/#list-all-open-orders
5267
- * @see https://www.gate.com/docs/developers/apiv4/en/#retrieve-running-auto-order-list
5268
5306
  * @param {string} symbol unified market symbol
5269
5307
  * @param {int} [since] the earliest time in ms to fetch open orders for
5270
5308
  * @param {int} [limit] the maximum number of open orders structures to retrieve
@@ -5282,14 +5320,14 @@ class gate extends gate$1["default"] {
5282
5320
  * @method
5283
5321
  * @name gate#fetchClosedOrders
5284
5322
  * @description fetches information on multiple closed orders made by the user
5285
- * @see https://www.gate.com/docs/developers/apiv4/en/#list-orders
5286
- * @see https://www.gate.com/docs/developers/apiv4/en/#retrieve-running-auto-order-list
5287
- * @see https://www.gate.com/docs/developers/apiv4/en/#list-futures-orders
5288
- * @see https://www.gate.com/docs/developers/apiv4/en/#list-all-auto-orders
5289
- * @see https://www.gate.com/docs/developers/apiv4/en/#list-futures-orders-2
5290
- * @see https://www.gate.com/docs/developers/apiv4/en/#list-all-auto-orders-2
5323
+ * @see https://www.gate.com/en-eu/docs/developers/apiv4/#list-orders
5324
+ * @see https://www.gate.com/en-eu/docs/developers/apiv4/#retrieve-running-auto-order-list
5325
+ * @see https://www.gate.com/docs/developers/apiv4/en/#query-futures-order-list
5326
+ * @see https://www.gate.com/docs/developers/apiv4/en/#query-auto-order-list
5327
+ * @see https://www.gate.com/docs/developers/apiv4/en/#query-futures-order-list-2
5328
+ * @see https://www.gate.com/docs/developers/apiv4/en/#query-auto-order-list-2
5291
5329
  * @see https://www.gate.com/docs/developers/apiv4/en/#list-options-orders
5292
- * @see https://www.gate.com/docs/developers/apiv4/en/#list-futures-orders-by-time-range
5330
+ * @see https://www.gate.com/docs/developers/apiv4/en/#query-futures-order-list-by-time-range
5293
5331
  * @param {string} symbol unified market symbol of the market orders were made in
5294
5332
  * @param {int} [since] the earliest time in ms to fetch orders for
5295
5333
  * @param {int} [limit] the maximum number of order structures to retrieve
@@ -5585,10 +5623,13 @@ class gate extends gate$1["default"] {
5585
5623
  * @method
5586
5624
  * @name gate#cancelOrder
5587
5625
  * @description Cancels an open order
5588
- * @see https://www.gate.com/docs/developers/apiv4/en/#cancel-a-single-order
5589
- * @see https://www.gate.com/docs/developers/apiv4/en/#cancel-a-single-order-2
5590
- * @see https://www.gate.com/docs/developers/apiv4/en/#cancel-a-single-order-3
5591
- * @see https://www.gate.com/docs/developers/apiv4/en/#cancel-a-single-order-4
5626
+ * @see https://www.gate.com/docs/developers/apiv4/en/#cancel-single-order
5627
+ * @see https://www.gate.com/docs/developers/apiv4/en/#cancel-single-auto-order
5628
+ * @see https://www.gate.com/docs/developers/apiv4/en/#cancel-single-order-2
5629
+ * @see https://www.gate.com/docs/developers/apiv4/en/#cancel-single-auto-order-2
5630
+ * @see https://www.gate.com/docs/developers/apiv4/en/#cancel-single-order-3
5631
+ * @see https://www.gate.com/docs/developers/apiv4/en/#cancel-single-auto-order-3
5632
+ * @see https://www.gate.com/docs/developers/apiv4/en/#cancel-single-order-4
5592
5633
  * @param {string} id Order id
5593
5634
  * @param {string} symbol Unified market symbol
5594
5635
  * @param {object} [params] Parameters specified by the exchange api
@@ -5723,8 +5764,8 @@ class gate extends gate$1["default"] {
5723
5764
  * @method
5724
5765
  * @name gate#cancelOrders
5725
5766
  * @description cancel multiple orders
5726
- * @see https://www.gate.com/docs/developers/apiv4/en/#cancel-a-batch-of-orders-with-an-id-list
5727
- * @see https://www.gate.com/docs/developers/apiv4/en/#cancel-a-batch-of-orders-with-an-id-list-2
5767
+ * @see https://www.gate.com/docs/developers/apiv4/en/#cancel-batch-orders-by-specified-id-list
5768
+ * @see https://www.gate.com/docs/developers/apiv4/en/#cancel-batch-orders-by-specified-id-list-2
5728
5769
  * @param {string[]} ids order ids
5729
5770
  * @param {string} symbol unified symbol of the market the order was made in
5730
5771
  * @param {object} [params] extra parameters specific to the exchange API endpoint
@@ -5772,7 +5813,7 @@ class gate extends gate$1["default"] {
5772
5813
  * @method
5773
5814
  * @name gate#cancelOrdersForSymbols
5774
5815
  * @description cancel multiple orders for multiple symbols
5775
- * @see https://www.gate.com/docs/developers/apiv4/en/#cancel-a-batch-of-orders-with-an-id-list
5816
+ * @see https://www.gate.com/en-eu/docs/developers/apiv4/#cancel-a-batch-of-orders-with-an-id-list
5776
5817
  * @param {CancellationRequest[]} orders list of order ids with symbol, example [{"id": "a", "symbol": "BTC/USDT"}, {"id": "b", "symbol": "ETH/USDT"}]
5777
5818
  * @param {object} [params] extra parameters specific to the exchange API endpoint
5778
5819
  * @param {string[]} [params.clientOrderIds] client order ids
@@ -5813,9 +5854,12 @@ class gate extends gate$1["default"] {
5813
5854
  * @name gate#cancelAllOrders
5814
5855
  * @description cancel all open orders
5815
5856
  * @see https://www.gate.com/docs/developers/apiv4/en/#cancel-all-open-orders-in-specified-currency-pair
5816
- * @see https://www.gate.com/docs/developers/apiv4/en/#cancel-all-open-orders-matched
5817
- * @see https://www.gate.com/docs/developers/apiv4/en/#cancel-all-open-orders-matched-2
5818
- * @see https://www.gate.com/docs/developers/apiv4/en/#cancel-all-open-orders-matched-3
5857
+ * @see https://www.gate.com/docs/developers/apiv4/en/#cancel-all-auto-orders
5858
+ * @see https://www.gate.com/docs/developers/apiv4/en/#cancel-all-orders-with-open-status
5859
+ * @see https://www.gate.com/docs/developers/apiv4/en/#cancel-all-auto-orders-2
5860
+ * @see https://www.gate.com/docs/developers/apiv4/en/#cancel-all-orders-with-open-status-2
5861
+ * @see https://www.gate.com/docs/developers/apiv4/en/#cancel-all-auto-orders-3
5862
+ * @see https://www.gate.com/docs/developers/apiv4/en/#cancel-all-orders-with-open-status-3
5819
5863
  * @param {string} symbol unified market symbol, only orders in the market of this symbol are cancelled when symbol is not undefined
5820
5864
  * @param {object} [params] extra parameters specific to the exchange API endpoint
5821
5865
  * @param {bool} [params.unifiedAccount] set to true for canceling unified account orders
@@ -6199,8 +6243,8 @@ class gate extends gate$1["default"] {
6199
6243
  * @method
6200
6244
  * @name gate#fetchPosition
6201
6245
  * @description fetch data on an open contract position
6202
- * @see https://www.gate.com/docs/developers/apiv4/en/#get-single-position
6203
- * @see https://www.gate.com/docs/developers/apiv4/en/#get-single-position-2
6246
+ * @see https://www.gate.com/docs/developers/apiv4/en/#get-single-position-information
6247
+ * @see https://www.gate.com/docs/developers/apiv4/en/#get-single-position-information-2
6204
6248
  * @see https://www.gate.com/docs/developers/apiv4/en/#get-specified-contract-position
6205
6249
  * @param {string} symbol unified market symbol of the market the position is held in
6206
6250
  * @param {object} [params] extra parameters specific to the exchange API endpoint
@@ -6287,8 +6331,8 @@ class gate extends gate$1["default"] {
6287
6331
  * @method
6288
6332
  * @name gate#fetchPositions
6289
6333
  * @description fetch all open positions
6290
- * @see https://www.gate.com/docs/developers/apiv4/en/#list-all-positions-of-a-user
6291
- * @see https://www.gate.com/docs/developers/apiv4/en/#list-all-positions-of-a-user-2
6334
+ * @see https://www.gate.com/docs/developers/apiv4/en/#get-user-position-list
6335
+ * @see https://www.gate.com/docs/developers/apiv4/en/#get-user-position-list-2
6292
6336
  * @see https://www.gate.com/docs/developers/apiv4/en/#list-user-s-positions-of-specified-underlying
6293
6337
  * @param {string[]|undefined} symbols Not used by gate, but parsed internally by CCXT
6294
6338
  * @param {object} [params] extra parameters specific to the exchange API endpoint
@@ -6398,8 +6442,8 @@ class gate extends gate$1["default"] {
6398
6442
  * @method
6399
6443
  * @name gate#fetchLeverageTiers
6400
6444
  * @description retrieve information on the maximum leverage, and maintenance margin for trades of varying trade sizes
6401
- * @see https://www.gate.com/docs/developers/apiv4/en/#list-all-futures-contracts
6402
- * @see https://www.gate.com/docs/developers/apiv4/en/#list-all-futures-contracts-2
6445
+ * @see https://www.gate.com/docs/developers/apiv4/en/#query-all-futures-contracts
6446
+ * @see https://www.gate.com/docs/developers/apiv4/en/#query-all-futures-contracts-2
6403
6447
  * @param {string[]} [symbols] list of unified market symbols
6404
6448
  * @param {object} [params] extra parameters specific to the exchange API endpoint
6405
6449
  * @returns {object} a dictionary of [leverage tiers structures]{@link https://docs.ccxt.com/?id=leverage-tiers-structure}, indexed by market symbols
@@ -6519,7 +6563,8 @@ class gate extends gate$1["default"] {
6519
6563
  * @method
6520
6564
  * @name gate#fetchMarketLeverageTiers
6521
6565
  * @description retrieve information on the maximum leverage, and maintenance margin for trades of varying trade sizes for a single market
6522
- * @see https://www.gate.com/docs/developers/apiv4/en/#list-risk-limit-tiers
6566
+ * @see https://www.gate.com/docs/developers/apiv4/en/#query-risk-limit-tiers
6567
+ * @see https://www.gate.com/docs/developers/apiv4/en/#query-risk-limit-tiers-2
6523
6568
  * @param {string} symbol unified market symbol
6524
6569
  * @param {object} [params] extra parameters specific to the exchange API endpoint
6525
6570
  * @returns {object} a [leverage tiers structure]{@link https://docs.ccxt.com/?id=leverage-tiers-structure}
@@ -6532,18 +6577,24 @@ class gate extends gate$1["default"] {
6532
6577
  if (type !== 'future' && type !== 'swap') {
6533
6578
  throw new errors.BadRequest(this.id + ' fetchMarketLeverageTiers only supports swap and future');
6534
6579
  }
6535
- const response = await this.publicFuturesGetSettleRiskLimitTiers(this.extend(request, requestParams));
6536
- //
6537
- // [
6538
- // {
6539
- // "maintenance_rate": "0.004",
6540
- // "tier": 1,
6541
- // "initial_rate": "0.008",
6542
- // "leverage_max": "125",
6543
- // "risk_limit": "1000000"
6544
- // }
6545
- // ]
6546
- //
6580
+ let response = undefined;
6581
+ if (type === 'swap') {
6582
+ //
6583
+ // [
6584
+ // {
6585
+ // "maintenance_rate": "0.004",
6586
+ // "tier": 1,
6587
+ // "initial_rate": "0.008",
6588
+ // "leverage_max": "125",
6589
+ // "risk_limit": "1000000"
6590
+ // }
6591
+ // ]
6592
+ //
6593
+ response = await this.publicFuturesGetSettleRiskLimitTiers(this.extend(request, requestParams));
6594
+ }
6595
+ else {
6596
+ response = await this.publicDeliveryGetSettleRiskLimitTiers(this.extend(request, requestParams));
6597
+ }
6547
6598
  return this.parseMarketLeverageTiers(response, market);
6548
6599
  }
6549
6600
  parseEmulatedLeverageTiers(info, market = undefined) {
@@ -6611,9 +6662,9 @@ class gate extends gate$1["default"] {
6611
6662
  }
6612
6663
  /**
6613
6664
  * @method
6614
- * @name gate#repayMargin
6665
+ * @name gate#repayIsolatedMargin
6615
6666
  * @description repay borrowed margin and interest
6616
- * @see https://www.gate.com/docs/apiv4/en/#repay-a-loan
6667
+ * @see https://www.gate.com/docs/developers/apiv4/en/#borrow-or-repay-2
6617
6668
  * @param {string} symbol unified market symbol
6618
6669
  * @param {string} code unified currency code of the currency to repay
6619
6670
  * @param {float} amount the amount to repay
@@ -6642,7 +6693,6 @@ class gate extends gate$1["default"] {
6642
6693
  * @method
6643
6694
  * @name gate#repayCrossMargin
6644
6695
  * @description repay cross margin borrowed margin and interest
6645
- * @see https://www.gate.com/docs/developers/apiv4/en/#cross-margin-repayments
6646
6696
  * @see https://www.gate.com/docs/developers/apiv4/en/#borrow-or-repay
6647
6697
  * @param {string} code unified currency code of the currency to repay
6648
6698
  * @param {float} amount the amount to repay
@@ -6668,6 +6718,7 @@ class gate extends gate$1["default"] {
6668
6718
  response = await this.privateUnifiedPostLoans(this.extend(request, params));
6669
6719
  }
6670
6720
  else {
6721
+ // deprecated and not present in the exchange's docs but still works
6671
6722
  response = await this.privateMarginPostCrossRepayments(this.extend(request, params));
6672
6723
  response = this.safeDict(response, 0);
6673
6724
  //
@@ -6693,7 +6744,7 @@ class gate extends gate$1["default"] {
6693
6744
  * @method
6694
6745
  * @name gate#borrowIsolatedMargin
6695
6746
  * @description create a loan to borrow margin
6696
- * @see https://www.gate.com/docs/developers/apiv4/en/#marginuni
6747
+ * @see https://www.gate.com/docs/developers/apiv4/en/#borrow-or-repay-2
6697
6748
  * @param {string} symbol unified market symbol, required for isolated margin
6698
6749
  * @param {string} code unified currency code of the currency to borrow
6699
6750
  * @param {float} amount the amount to borrow
@@ -6736,15 +6787,14 @@ class gate extends gate$1["default"] {
6736
6787
  }
6737
6788
  /**
6738
6789
  * @method
6739
- * @name gate#borrowMargin
6790
+ * @name gate#borrowCrossMargin
6740
6791
  * @description create a loan to borrow margin
6741
- * @see https://www.gate.com/docs/apiv4/en/#create-a-cross-margin-borrow-loan
6742
6792
  * @see https://www.gate.com/docs/developers/apiv4/en/#borrow-or-repay
6743
6793
  * @param {string} code unified currency code of the currency to borrow
6744
6794
  * @param {float} amount the amount to borrow
6745
6795
  * @param {object} [params] extra parameters specific to the exchange API endpoint
6746
6796
  * @param {string} [params.rate] '0.0002' or '0.002' extra parameter required for isolated margin
6747
- * @param {boolean} [params.unifiedAccount] set to true for borrowing in the unified account
6797
+ * @param {boolean} [params.unifiedAccount] default true (set to false to use deprecated privateMarginPostCrossLoans method)
6748
6798
  * @returns {object} a [margin loan structure]{@link https://docs.ccxt.com/?id=margin-loan-structure}
6749
6799
  */
6750
6800
  async borrowCrossMargin(code, amount, params = {}) {
@@ -6763,6 +6813,8 @@ class gate extends gate$1["default"] {
6763
6813
  response = await this.privateUnifiedPostLoans(this.extend(request, params));
6764
6814
  }
6765
6815
  else {
6816
+ // deprecated and not present in the exchange's docs
6817
+ // returns {"label":"REQUEST_FORBIDDEN","message":"Request is forbidden"}
6766
6818
  response = await this.privateMarginPostCrossLoans(this.extend(request, params));
6767
6819
  //
6768
6820
  // {
@@ -6839,9 +6891,8 @@ class gate extends gate$1["default"] {
6839
6891
  * @method
6840
6892
  * @name gate#fetchBorrowInterest
6841
6893
  * @description fetch the interest owed by the user for borrowing currency for margin trading
6842
- * @see https://www.gate.com/docs/developers/apiv4/en/#list-interest-records
6843
- * @see https://www.gate.com/docs/developers/apiv4/en/#interest-records-for-the-cross-margin-account
6844
- * @see https://www.gate.com/docs/developers/apiv4/en/#list-interest-records-2
6894
+ * @see https://www.gate.com/docs/developers/apiv4/en/#query-interest-deduction-records
6895
+ * @see https://www.gate.com/docs/developers/apiv4/en/#query-interest-deduction-records-2
6845
6896
  * @param {string} [code] unified currency code
6846
6897
  * @param {string} [symbol] unified market symbol when fetching interest in isolated markets
6847
6898
  * @param {int} [since] the earliest time in ms to fetch borrow interest for
@@ -6885,6 +6936,7 @@ class gate extends gate$1["default"] {
6885
6936
  response = await this.privateMarginGetUniInterestRecords(this.extend(request, params));
6886
6937
  }
6887
6938
  else if (marginMode === 'cross') {
6939
+ // deprecated and not present in the exchange's docs but still works
6888
6940
  response = await this.privateMarginGetCrossInterestRecords(this.extend(request, params));
6889
6941
  }
6890
6942
  const interest = this.parseBorrowInterests(response, market);
@@ -7100,7 +7152,7 @@ class gate extends gate$1["default"] {
7100
7152
  * @method
7101
7153
  * @name gate#fetchOpenInterest
7102
7154
  * @description Retrieves the open interest of a currency
7103
- * @see https://www.gate.com/docs/developers/apiv4/en/#futures-stats
7155
+ * @see https://www.gate.com/docs/developers/apiv4/en/#futures-statistics
7104
7156
  * @param {string} symbol Unified CCXT market symbol
7105
7157
  * @param {string} timeframe "5m", "15m", "30m", "1h", "4h", "1d"
7106
7158
  * @param {int} [since] the time(ms) of the earliest record to retrieve as a unix timestamp
@@ -7188,7 +7240,7 @@ class gate extends gate$1["default"] {
7188
7240
  * @method
7189
7241
  * @name gate#fetchSettlementHistory
7190
7242
  * @description fetches historical settlement records
7191
- * @see https://www.gate.com/docs/developers/apiv4/en/#list-settlement-history-2
7243
+ * @see https://www.gate.com/docs/developers/apiv4/en/#list-settlement-history
7192
7244
  * @param {string} symbol unified market symbol of the settlement history, required on gate
7193
7245
  * @param {int} [since] timestamp in ms
7194
7246
  * @param {int} [limit] number of records
@@ -7238,7 +7290,8 @@ class gate extends gate$1["default"] {
7238
7290
  * @method
7239
7291
  * @name gate#fetchMySettlementHistory
7240
7292
  * @description fetches historical settlement records of the user
7241
- * @see https://www.gate.com/docs/developers/apiv4/en/#list-my-options-settlements
7293
+ * @see https://www.gate.com/docs/developers/apiv4/en/#query-personal-settlement-records
7294
+ * @see https://www.gate.com/docs/developers/apiv4/en/#query-settlement-records
7242
7295
  * @param {string} symbol unified market symbol of the settlement history
7243
7296
  * @param {int} [since] timestamp in ms
7244
7297
  * @param {int} [limit] number of records
@@ -7246,49 +7299,79 @@ class gate extends gate$1["default"] {
7246
7299
  * @returns {object[]} a list of [settlement history objects]
7247
7300
  */
7248
7301
  async fetchMySettlementHistory(symbol = undefined, since = undefined, limit = undefined, params = {}) {
7249
- if (symbol === undefined) {
7250
- throw new errors.ArgumentsRequired(this.id + ' fetchMySettlementHistory() requires a symbol argument');
7251
- }
7252
7302
  await this.loadMarkets();
7253
- const market = this.market(symbol);
7303
+ let market = undefined;
7304
+ if (symbol !== undefined) {
7305
+ market = this.market(symbol);
7306
+ symbol = market['symbol'];
7307
+ }
7254
7308
  let type = undefined;
7255
7309
  [type, params] = this.handleMarketTypeAndParams('fetchMySettlementHistory', market, params);
7256
- if (type !== 'option') {
7257
- throw new errors.NotSupported(this.id + ' fetchMySettlementHistory() supports option markets only');
7258
- }
7259
- const marketId = market['id'];
7260
- const optionParts = marketId.split('-');
7261
- const request = {
7262
- 'underlying': this.safeString(optionParts, 0),
7263
- 'contract': marketId,
7264
- };
7265
- if (since !== undefined) {
7266
- request['from'] = since;
7310
+ const isOption = type === 'option';
7311
+ const isFuture = type === 'future';
7312
+ if (!isOption && !isFuture) {
7313
+ throw new errors.NotSupported(this.id + ' fetchMySettlementHistory() supports option and future markets only');
7267
7314
  }
7315
+ const [request, query] = this.prepareRequest(market, type, params);
7268
7316
  if (limit !== undefined) {
7269
7317
  request['limit'] = limit;
7270
7318
  }
7271
- const response = await this.privateOptionsGetMySettlements(this.extend(request, params));
7272
- //
7273
- // [
7274
- // {
7275
- // "size": -1,
7276
- // "settle_profit": "0",
7277
- // "contract": "BTC_USDT-20220624-26000-C",
7278
- // "strike_price": "26000",
7279
- // "time": 1656057600,
7280
- // "settle_price": "20917.461281337048",
7281
- // "underlying": "BTC_USDT",
7282
- // "realised_pnl": "-0.00116042",
7283
- // "fee": "0"
7284
- // }
7285
- // ]
7286
- //
7319
+ let response = undefined;
7320
+ if (isFuture) {
7321
+ //
7322
+ // [
7323
+ // {
7324
+ // "time": 1548654951,
7325
+ // "contract": "BTC_USDT",
7326
+ // "size": 600,
7327
+ // "leverage": "25",
7328
+ // "margin": "0.006705256878",
7329
+ // "entry_price": "3536.123",
7330
+ // "settle_price": "3421.54",
7331
+ // "profit": "-6.87498",
7332
+ // "fee": "0.03079386"
7333
+ // }
7334
+ // ]
7335
+ //
7336
+ response = await this.privateDeliveryGetSettleSettlements(this.extend(request, query));
7337
+ }
7338
+ else {
7339
+ if (since !== undefined) {
7340
+ request['from'] = since;
7341
+ }
7342
+ if (market === undefined) {
7343
+ const underlying = this.safeString(params, 'underlying');
7344
+ if (underlying === undefined) {
7345
+ throw new errors.ArgumentsRequired(this.id + ' fetchMySettlementHistory() requires a symbol argument or an underlying parameter in params');
7346
+ }
7347
+ }
7348
+ else {
7349
+ const marketId = market['id'];
7350
+ const optionParts = marketId.split('-');
7351
+ request['underlying'] = this.safeString(optionParts, 0);
7352
+ }
7353
+ //
7354
+ // [
7355
+ // {
7356
+ // "size": -1,
7357
+ // "settle_profit": "0",
7358
+ // "contract": "BTC_USDT-20220624-26000-C",
7359
+ // "strike_price": "26000",
7360
+ // "time": 1656057600,
7361
+ // "settle_price": "20917.461281337048",
7362
+ // "underlying": "BTC_USDT",
7363
+ // "realised_pnl": "-0.00116042",
7364
+ // "fee": "0"
7365
+ // }
7366
+ // ]
7367
+ //
7368
+ response = await this.privateOptionsGetMySettlements(this.extend(request, params));
7369
+ }
7287
7370
  const result = this.safeValue(response, 'result', {});
7288
7371
  const data = this.safeValue(result, 'list', []);
7289
7372
  const settlements = this.parseSettlements(data, market);
7290
7373
  const sorted = this.sortBy(settlements, 'timestamp');
7291
- return this.filterBySymbolSinceLimit(sorted, market['symbol'], since, limit);
7374
+ return this.filterBySymbolSinceLimit(sorted, symbol, since, limit);
7292
7375
  }
7293
7376
  parseSettlement(settlement, market) {
7294
7377
  //
@@ -7303,7 +7386,7 @@ class gate extends gate$1["default"] {
7303
7386
  // "strike_price": "25000"
7304
7387
  // }
7305
7388
  //
7306
- // fetchMySettlementHistory
7389
+ // fetchMySettlementHistory option
7307
7390
  //
7308
7391
  // {
7309
7392
  // "size": -1,
@@ -7317,6 +7400,19 @@ class gate extends gate$1["default"] {
7317
7400
  // "fee": "0"
7318
7401
  // }
7319
7402
  //
7403
+ // fetchMySettlementHistory future
7404
+ // {
7405
+ // "time": 1548654951,
7406
+ // "contract": "BTC_USDT",
7407
+ // "size": 600,
7408
+ // "leverage": "25",
7409
+ // "margin": "0.006705256878",
7410
+ // "entry_price": "3536.123",
7411
+ // "settle_price": "3421.54",
7412
+ // "profit": "-6.87498",
7413
+ // "fee": "0.03079386"
7414
+ // }
7415
+ //
7320
7416
  const timestamp = this.safeTimestamp(settlement, 'time');
7321
7417
  const marketId = this.safeString(settlement, 'contract');
7322
7418
  return {
@@ -7368,11 +7464,11 @@ class gate extends gate$1["default"] {
7368
7464
  * @method
7369
7465
  * @name gate#fetchLedger
7370
7466
  * @description fetch the history of changes, actions done by the user or operations that altered the balance of the user
7371
- * @see https://www.gate.com/docs/developers/apiv4/en/#query-account-book
7372
- * @see https://www.gate.com/docs/developers/apiv4/en/#list-margin-account-balance-change-history
7373
- * @see https://www.gate.com/docs/developers/apiv4/en/#query-account-book-2
7374
- * @see https://www.gate.com/docs/developers/apiv4/en/#query-account-book-3
7375
- * @see https://www.gate.com/docs/developers/apiv4/en/#list-account-changing-history
7467
+ * @see https://www.gate.com/docs/developers/apiv4/en/#query-spot-account-transaction-history
7468
+ * @see https://www.gate.com/docs/developers/apiv4/en/#query-margin-account-balance-change-history
7469
+ * @see https://www.gate.com/docs/developers/apiv4/en/#query-futures-account-change-history
7470
+ * @see https://www.gate.com/docs/developers/apiv4/en/#query-futures-account-change-history-2
7471
+ * @see https://www.gate.com/docs/developers/apiv4/en/#query-account-change-history
7376
7472
  * @param {string} [code] unified currency code
7377
7473
  * @param {int} [since] timestamp in ms of the earliest ledger entry
7378
7474
  * @param {int} [limit] max number of ledger entries to return
@@ -7614,7 +7710,7 @@ class gate extends gate$1["default"] {
7614
7710
  * @method
7615
7711
  * @name gate#setPositionMode
7616
7712
  * @description set dual/hedged mode to true or false for a swap market, make sure all positions are closed and no orders are open before setting dual mode
7617
- * @see https://www.gate.com/docs/developers/apiv4/en/#enable-or-disable-dual-mode
7713
+ * @see https://www.gate.com/docs/developers/apiv4/en/#set-position-mode
7618
7714
  * @param {bool} hedged set to true to enable dual mode
7619
7715
  * @param {string|undefined} symbol if passed, dual mode is set for all markets with the same settle currency
7620
7716
  * @param {object} params extra parameters specific to the exchange API endpoint
@@ -7631,7 +7727,7 @@ class gate extends gate$1["default"] {
7631
7727
  * @method
7632
7728
  * @name gate#fetchUnderlyingAssets
7633
7729
  * @description fetches the market ids of underlying assets for a specific contract market type
7634
- * @see https://www.gate.com/docs/developers/apiv4/en/#list-all-underlyings
7730
+ * @see https://www.gate.com/docs/developers/apiv4/en/#list-all-underlying-assets
7635
7731
  * @param {object} [params] exchange specific params
7636
7732
  * @param {string} [params.type] the contract market type, 'option', 'swap' or 'future', the default is 'option'
7637
7733
  * @returns {object[]} a list of [underlying assets]{@link https://docs.ccxt.com/?id=underlying-assets-structure}
@@ -7670,7 +7766,7 @@ class gate extends gate$1["default"] {
7670
7766
  * @method
7671
7767
  * @name gate#fetchLiquidations
7672
7768
  * @description retrieves the public liquidations of a trading pair
7673
- * @see https://www.gate.com/docs/developers/apiv4/en/#retrieve-liquidation-history
7769
+ * @see https://www.gate.com/docs/developers/apiv4/en/#query-liquidation-order-history
7674
7770
  * @param {string} symbol unified CCXT market symbol
7675
7771
  * @param {int} [since] the earliest time in ms to fetch liquidations for
7676
7772
  * @param {int} [limit] the maximum number of liquidation structures to retrieve
@@ -7714,8 +7810,8 @@ class gate extends gate$1["default"] {
7714
7810
  * @method
7715
7811
  * @name gate#fetchMyLiquidations
7716
7812
  * @description retrieves the users liquidated positions
7717
- * @see https://www.gate.com/docs/developers/apiv4/en/#list-liquidation-history
7718
- * @see https://www.gate.com/docs/developers/apiv4/en/#list-liquidation-history-2
7813
+ * @see https://www.gate.com/docs/developers/apiv4/en/#query-liquidation-history
7814
+ * @see https://www.gate.com/docs/developers/apiv4/en/#query-liquidation-history-2
7719
7815
  * @see https://www.gate.com/docs/developers/apiv4/en/#list-user-s-liquidation-history-of-specified-underlying
7720
7816
  * @param {string} symbol unified CCXT market symbol
7721
7817
  * @param {int} [since] the earliest time in ms to fetch liquidations for
@@ -7881,7 +7977,7 @@ class gate extends gate$1["default"] {
7881
7977
  * @method
7882
7978
  * @name gate#fetchGreeks
7883
7979
  * @description fetches an option contracts greeks, financial metrics used to measure the factors that affect the price of an options contract
7884
- * @see https://www.gate.com/docs/developers/apiv4/en/#list-tickers-of-options-contracts
7980
+ * @see https://www.gate.com/docs/developers/apiv4/en/#query-options-market-ticker-information
7885
7981
  * @param {string} symbol unified symbol of the market to fetch greeks for
7886
7982
  * @param {object} [params] extra parameters specific to the exchange API endpoint
7887
7983
  * @returns {object} a [greeks structure]{@link https://docs.ccxt.com/?id=greeks-structure}
@@ -7974,8 +8070,8 @@ class gate extends gate$1["default"] {
7974
8070
  * @method
7975
8071
  * @name gate#closePosition
7976
8072
  * @description closes open positions for a market
7977
- * @see https://www.gate.com/docs/developers/apiv4/en/#create-a-futures-order
7978
- * @see https://www.gate.com/docs/developers/apiv4/en/#create-a-futures-order-2
8073
+ * @see https://www.gate.com/docs/developers/apiv4/en/#place-futures-order
8074
+ * @see https://www.gate.com/docs/developers/apiv4/en/#place-futures-order-2
7979
8075
  * @see https://www.gate.com/docs/developers/apiv4/en/#create-an-options-order
7980
8076
  * @param {string} symbol Unified CCXT market symbol
7981
8077
  * @param {string} side 'buy' or 'sell'
@@ -7997,8 +8093,7 @@ class gate extends gate$1["default"] {
7997
8093
  * @name gate#fetchLeverage
7998
8094
  * @description fetch the set leverage for a market
7999
8095
  * @see https://www.gate.com/docs/developers/apiv4/en/#get-unified-account-information
8000
- * @see https://www.gate.com/docs/developers/apiv4/en/#get-detail-of-lending-market
8001
- * @see https://www.gate.com/docs/developers/apiv4/en/#query-one-single-margin-currency-pair-deprecated
8096
+ * @see https://www.gate.com/docs/developers/apiv4/en/#get-lending-market-details
8002
8097
  * @param {string} symbol unified market symbol
8003
8098
  * @param {object} [params] extra parameters specific to the exchange API endpoint
8004
8099
  * @param {boolean} [params.unified] default false, set to true for fetching the unified accounts leverage
@@ -8029,7 +8124,7 @@ class gate extends gate$1["default"] {
8029
8124
  //
8030
8125
  }
8031
8126
  else {
8032
- response = await this.publicMarginGetCurrencyPairsCurrencyPair(this.extend(request, params));
8127
+ response = await this.publicMarginGetCurrencyPairsCurrencyPair(this.extend(request, params)); // deprecated
8033
8128
  //
8034
8129
  // {
8035
8130
  // "id": "BTC_USDT",
@@ -8107,7 +8202,6 @@ class gate extends gate$1["default"] {
8107
8202
  * @name gate#fetchLeverages
8108
8203
  * @description fetch the set leverage for all leverage markets, only spot margin is supported on gate
8109
8204
  * @see https://www.gate.com/docs/developers/apiv4/en/#list-lending-markets
8110
- * @see https://www.gate.com/docs/developers/apiv4/en/#list-all-supported-currency-pairs-supported-in-margin-trading-deprecated
8111
8205
  * @param {string[]} symbols a list of unified market symbols
8112
8206
  * @param {object} [params] extra parameters specific to the exchange API endpoint
8113
8207
  * @param {boolean} [params.unified] default false, set to true for fetching unified account leverages
@@ -8135,7 +8229,7 @@ class gate extends gate$1["default"] {
8135
8229
  //
8136
8230
  }
8137
8231
  else {
8138
- response = await this.publicMarginGetCurrencyPairs(params);
8232
+ response = await this.publicMarginGetCurrencyPairs(params); // deprecated
8139
8233
  //
8140
8234
  // [
8141
8235
  // {
@@ -8168,7 +8262,7 @@ class gate extends gate$1["default"] {
8168
8262
  * @method
8169
8263
  * @name gate#fetchOption
8170
8264
  * @description fetches option data that is commonly found in an option chain
8171
- * @see https://www.gate.com/docs/developers/apiv4/en/#query-specified-contract-detail
8265
+ * @see https://www.gate.com/docs/developers/apiv4/en/#query-specified-contract-details
8172
8266
  * @param {string} symbol unified market symbol
8173
8267
  * @param {object} [params] extra parameters specific to the exchange API endpoint
8174
8268
  * @returns {object} an [option chain structure]{@link https://docs.ccxt.com/?id=option-chain-structure}
@@ -8226,7 +8320,7 @@ class gate extends gate$1["default"] {
8226
8320
  * @method
8227
8321
  * @name gate#fetchOptionChain
8228
8322
  * @description fetches data for an underlying asset that is commonly found in an option chain
8229
- * @see https://www.gate.com/docs/developers/apiv4/en/#list-all-the-contracts-with-specified-underlying-and-expiration-time
8323
+ * @see https://www.gate.com/docs/developers/apiv4/en/#list-all-contracts-for-specified-underlying-and-expiration-date
8230
8324
  * @param {string} code base currency to fetch an option chain for
8231
8325
  * @param {object} [params] extra parameters specific to the exchange API endpoint
8232
8326
  * @param {string} [params.underlying] the underlying asset, can be obtained from fetchUnderlyingAssets ()
@@ -8352,8 +8446,8 @@ class gate extends gate$1["default"] {
8352
8446
  * @method
8353
8447
  * @name gate#fetchPositionsHistory
8354
8448
  * @description fetches historical positions
8355
- * @see https://www.gate.com/docs/developers/apiv4/#list-position-close-history
8356
- * @see https://www.gate.com/docs/developers/apiv4/#list-position-close-history-2
8449
+ * @see https://www.gate.com/docs/developers/apiv4/#query-position-close-history
8450
+ * @see https://www.gate.com/docs/developers/apiv4/#query-position-close-history-2
8357
8451
  * @param {string[]} symbols unified conract symbols, must all have the same settle currency and the same market type
8358
8452
  * @param {int} [since] the earliest time in ms to fetch positions for
8359
8453
  * @param {int} [limit] the maximum amount of records to fetch, default=1000