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
package/js/src/gate.js CHANGED
@@ -20,7 +20,7 @@ export default class gate extends Exchange {
20
20
  'pro': true,
21
21
  'urls': {
22
22
  'logo': 'https://github.com/user-attachments/assets/64f988c5-07b6-4652-b5c1-679a6bf67c85',
23
- 'doc': 'https://www.gate.com/docs/developers/apiv4/en/',
23
+ 'doc': 'https://www.gate.com/docs/developers/apiv4/en',
24
24
  'www': 'https://gate.com',
25
25
  'api': {
26
26
  'public': {
@@ -1169,7 +1169,7 @@ export default class gate extends Exchange {
1169
1169
  * @name gate#loadUnifiedStatus
1170
1170
  * @param {object} [params] extra parameters specific to the exchange API endpoint
1171
1171
  * @description returns unifiedAccount so the user can check if the unified account is enabled
1172
- * @see https://www.gate.com/docs/developers/apiv4/#get-account-detail
1172
+ * @see https://www.gate.com/docs/developers/apiv4/#retrieve-user-account-information
1173
1173
  * @returns {boolean} true or false if the enabled unified account is enabled or not and sets the unifiedAccount option if it is undefined
1174
1174
  */
1175
1175
  async loadUnifiedStatus(params = {}) {
@@ -1207,7 +1207,7 @@ export default class gate extends Exchange {
1207
1207
  * @method
1208
1208
  * @name gate#fetchTime
1209
1209
  * @description fetches the current integer timestamp in milliseconds from the exchange server
1210
- * @see https://www.gate.com/docs/developers/apiv4/en/#get-server-current-time
1210
+ * @see https://www.gate.com/docs/developers/apiv4/#get-server-current-time
1211
1211
  * @param {object} [params] extra parameters specific to the exchange API endpoint
1212
1212
  * @returns {int} the current integer timestamp in milliseconds from the exchange server
1213
1213
  */
@@ -1297,11 +1297,11 @@ export default class gate extends Exchange {
1297
1297
  * @method
1298
1298
  * @name gate#fetchMarkets
1299
1299
  * @description retrieves data on all markets for gate
1300
- * @see https://www.gate.com/docs/developers/apiv4/en/#list-all-currency-pairs-supported // spot
1300
+ * @see https://www.gate.com/docs/developers/apiv4/#query-all-supported-currency-pairs // spot
1301
1301
  * @see https://www.gate.com/docs/developers/apiv4/en/#list-all-supported-currency-pairs-supported-in-margin-trading // margin
1302
- * @see https://www.gate.com/docs/developers/apiv4/en/#list-all-futures-contracts // swap
1303
- * @see https://www.gate.com/docs/developers/apiv4/en/#list-all-futures-contracts-2 // future
1304
- * @see https://www.gate.com/docs/developers/apiv4/en/#list-all-the-contracts-with-specified-underlying-and-expiration-time // option
1302
+ * @see https://www.gate.com/docs/developers/apiv4/en/#query-all-futures-contracts // swap
1303
+ * @see https://www.gate.com/docs/developers/apiv4/en/#query-all-futures-contracts-2 // future
1304
+ * @see https://www.gate.com/docs/developers/apiv4/en/#list-all-contracts-for-specified-underlying-and-expiration-date // option
1305
1305
  * @param {object} [params] extra parameters specific to the exchange API endpoint
1306
1306
  * @returns {object[]} an array of objects representing market data
1307
1307
  */
@@ -1935,7 +1935,7 @@ export default class gate extends Exchange {
1935
1935
  * @method
1936
1936
  * @name gate#fetchCurrencies
1937
1937
  * @description fetches all available currencies on an exchange
1938
- * @see https://www.gate.com/docs/developers/apiv4/en/#list-all-currencies-details
1938
+ * @see https://www.gate.com/docs/developers/apiv4/en/#query-all-currency-information
1939
1939
  * @param {object} [params] extra parameters specific to the exchange API endpoint
1940
1940
  * @returns {object} an associative dictionary of currencies
1941
1941
  */
@@ -2039,7 +2039,7 @@ export default class gate extends Exchange {
2039
2039
  * @method
2040
2040
  * @name gate#fetchFundingRate
2041
2041
  * @description fetch the current funding rate
2042
- * @see https://www.gate.com/docs/developers/apiv4/en/#get-a-single-contract
2042
+ * @see https://www.gate.com/docs/developers/apiv4/en/#query-single-contract-information
2043
2043
  * @param {string} symbol unified market symbol
2044
2044
  * @param {object} [params] extra parameters specific to the exchange API endpoint
2045
2045
  * @returns {object} a [funding rate structure]{@link https://docs.ccxt.com/?id=funding-rate-structure}
@@ -2102,7 +2102,7 @@ export default class gate extends Exchange {
2102
2102
  * @method
2103
2103
  * @name gate#fetchFundingRates
2104
2104
  * @description fetch the funding rate for multiple markets
2105
- * @see https://www.gate.com/docs/developers/apiv4/en/#list-all-futures-contracts
2105
+ * @see https://www.gate.com/docs/developers/apiv4/en/#query-all-futures-contracts
2106
2106
  * @param {string[]|undefined} symbols list of unified market symbols
2107
2107
  * @param {object} [params] extra parameters specific to the exchange API endpoint
2108
2108
  * @returns {object[]} a list of [funding rate structures]{@link https://docs.ccxt.com/?id=funding-rates-structure}, indexed by market symbols
@@ -2289,6 +2289,7 @@ export default class gate extends Exchange {
2289
2289
  * @method
2290
2290
  * @name gate#fetchDepositAddressesByNetwork
2291
2291
  * @description fetch a dictionary of addresses for a currency, indexed by network
2292
+ * @see https://www.gate.com/docs/developers/apiv4/en/#generate-currency-deposit-address
2292
2293
  * @param {string} code unified currency code of the currency for the deposit address
2293
2294
  * @param {object} [params] extra parameters specific to the api endpoint
2294
2295
  * @returns {object} a dictionary of [address structures]{@link https://docs.ccxt.com/?id=address-structure} indexed by the network
@@ -2348,7 +2349,7 @@ export default class gate extends Exchange {
2348
2349
  * @method
2349
2350
  * @name gate#fetchTradingFee
2350
2351
  * @description fetch the trading fees for a market
2351
- * @see https://www.gate.com/docs/developers/apiv4/en/#retrieve-personal-trading-fee
2352
+ * @see https://www.gate.com/docs/developers/apiv4/en/#query-personal-trading-fees
2352
2353
  * @param {string} symbol unified market symbol
2353
2354
  * @param {object} [params] extra parameters specific to the exchange API endpoint
2354
2355
  * @returns {object} a [fee structure]{@link https://docs.ccxt.com/?id=fee-structure}
@@ -2380,7 +2381,7 @@ export default class gate extends Exchange {
2380
2381
  * @method
2381
2382
  * @name gate#fetchTradingFees
2382
2383
  * @description fetch the trading fees for multiple markets
2383
- * @see https://www.gate.com/docs/developers/apiv4/en/#retrieve-personal-trading-fee
2384
+ * @see https://www.gate.com/docs/developers/apiv4/en/#query-personal-trading-fees
2384
2385
  * @param {object} [params] extra parameters specific to the exchange API endpoint
2385
2386
  * @returns {object} a dictionary of [fee structures]{@link https://docs.ccxt.com/?id=fee-structure} indexed by market symbols
2386
2387
  */
@@ -2447,7 +2448,7 @@ export default class gate extends Exchange {
2447
2448
  * @name gate#fetchTransactionFees
2448
2449
  * @deprecated
2449
2450
  * @description please use fetchDepositWithdrawFees instead
2450
- * @see https://www.gate.com/docs/developers/apiv4/en/#retrieve-withdrawal-status
2451
+ * @see https://www.gate.com/docs/developers/apiv4/en/#query-withdrawal-status
2451
2452
  * @param {string[]|undefined} codes list of unified currency codes
2452
2453
  * @param {object} [params] extra parameters specific to the exchange API endpoint
2453
2454
  * @returns {object} a list of [fee structures]{@link https://docs.ccxt.com/?id=fee-structure}
@@ -2506,7 +2507,7 @@ export default class gate extends Exchange {
2506
2507
  * @method
2507
2508
  * @name gate#fetchDepositWithdrawFees
2508
2509
  * @description fetch deposit and withdraw fees
2509
- * @see https://www.gate.com/docs/developers/apiv4/en/#retrieve-withdrawal-status
2510
+ * @see https://www.gate.com/docs/developers/apiv4/en/#query-withdrawal-status
2510
2511
  * @param {string[]|undefined} codes list of unified currency codes
2511
2512
  * @param {object} [params] extra parameters specific to the exchange API endpoint
2512
2513
  * @returns {object} a list of [fee structures]{@link https://docs.ccxt.com/?id=fee-structure}
@@ -2589,8 +2590,8 @@ export default class gate extends Exchange {
2589
2590
  * @method
2590
2591
  * @name gate#fetchFundingHistory
2591
2592
  * @description fetch the history of funding payments paid and received on this account
2592
- * @see https://www.gate.com/docs/developers/apiv4/en/#query-account-book-2
2593
- * @see https://www.gate.com/docs/developers/apiv4/en/#query-account-book-3
2593
+ * @see https://www.gate.com/docs/developers/apiv4/en/#query-futures-account-change-history
2594
+ * @see https://www.gate.com/docs/developers/apiv4/en/#query-futures-account-change-history-2
2594
2595
  * @param {string} symbol unified market symbol
2595
2596
  * @param {int} [since] the earliest time in ms to fetch funding history for
2596
2597
  * @param {int} [limit] the maximum number of funding history structures to retrieve
@@ -2676,10 +2677,10 @@ export default class gate extends Exchange {
2676
2677
  * @method
2677
2678
  * @name gate#fetchOrderBook
2678
2679
  * @description fetches information on open orders with bid (buy) and ask (sell) prices, volumes and other data
2679
- * @see https://www.gate.com/docs/developers/apiv4/en/#retrieve-order-book
2680
- * @see https://www.gate.com/docs/developers/apiv4/en/#futures-order-book
2681
- * @see https://www.gate.com/docs/developers/apiv4/en/#futures-order-book-2
2682
- * @see https://www.gate.com/docs/developers/apiv4/en/#options-order-book
2680
+ * @see https://www.gate.com/docs/developers/apiv4/en/#get-market-depth-information
2681
+ * @see https://www.gate.com/docs/developers/apiv4/en/#query-futures-market-depth-information
2682
+ * @see https://www.gate.com/docs/developers/apiv4/en/#query-futures-market-depth-information-2
2683
+ * @see https://www.gate.com/docs/developers/apiv4/en/#query-options-contract-order-book
2683
2684
  * @param {string} symbol unified symbol of the market to fetch the order book for
2684
2685
  * @param {int} [limit] the maximum amount of order book entries to return
2685
2686
  * @param {object} [params] extra parameters specific to the exchange API endpoint
@@ -2802,10 +2803,10 @@ export default class gate extends Exchange {
2802
2803
  * @method
2803
2804
  * @name gate#fetchTicker
2804
2805
  * @description fetches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
2805
- * @see https://www.gate.com/docs/developers/apiv4/en/#get-details-of-a-specifc-order
2806
- * @see https://www.gate.com/docs/developers/apiv4/en/#list-futures-tickers
2807
- * @see https://www.gate.com/docs/developers/apiv4/en/#list-futures-tickers-2
2808
- * @see https://www.gate.com/docs/developers/apiv4/en/#list-tickers-of-options-contracts
2806
+ * @see https://www.gate.com/docs/developers/apiv4/en/#get-currency-pair-ticker-information
2807
+ * @see https://www.gate.com/docs/developers/apiv4/en/#get-all-futures-trading-statistics
2808
+ * @see https://www.gate.com/docs/developers/apiv4/en/#get-all-futures-trading-statistics-2
2809
+ * @see https://www.gate.com/docs/developers/apiv4/en/#query-options-market-ticker-information
2809
2810
  * @param {string} symbol unified symbol of the market to fetch the ticker for
2810
2811
  * @param {object} [params] extra parameters specific to the exchange API endpoint
2811
2812
  * @returns {object} a [ticker structure]{@link https://docs.ccxt.com/?id=ticker-structure}
@@ -2966,10 +2967,10 @@ export default class gate extends Exchange {
2966
2967
  * @method
2967
2968
  * @name gate#fetchTickers
2968
2969
  * @description fetches price tickers for multiple markets, statistical information calculated over the past 24 hours for each market
2969
- * @see https://www.gate.com/docs/developers/apiv4/en/#get-details-of-a-specifc-order
2970
- * @see https://www.gate.com/docs/developers/apiv4/en/#list-futures-tickers
2971
- * @see https://www.gate.com/docs/developers/apiv4/en/#list-futures-tickers-2
2972
- * @see https://www.gate.com/docs/developers/apiv4/en/#list-tickers-of-options-contracts
2970
+ * @see https://www.gate.com/docs/developers/apiv4/en/#get-currency-pair-ticker-information
2971
+ * @see https://www.gate.com/docs/developers/apiv4/en/#get-all-futures-trading-statistics
2972
+ * @see https://www.gate.com/docs/developers/apiv4/en/#get-all-futures-trading-statistics-2
2973
+ * @see https://www.gate.com/docs/developers/apiv4/en/#query-options-market-ticker-information
2973
2974
  * @param {string[]|undefined} symbols unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
2974
2975
  * @param {object} [params] extra parameters specific to the exchange API endpoint
2975
2976
  * @returns {object} a dictionary of [ticker structures]{@link https://docs.ccxt.com/?id=ticker-structure}
@@ -3020,9 +3021,10 @@ export default class gate extends Exchange {
3020
3021
  /**
3021
3022
  * @method
3022
3023
  * @name gate#fetchBalance
3023
- * @see https://www.gate.com/docs/developers/apiv4/en/#margin-account-list
3024
3024
  * @see https://www.gate.com/docs/developers/apiv4/en/#get-unified-account-information
3025
3025
  * @see https://www.gate.com/docs/developers/apiv4/en/#list-spot-trading-accounts
3026
+ * @see https://www.gate.com/docs/developers/apiv4/en/#margin-account-list
3027
+ * @see https://www.gate.com/docs/developers/apiv4/en/#funding-account-list
3026
3028
  * @see https://www.gate.com/docs/developers/apiv4/en/#get-futures-account
3027
3029
  * @see https://www.gate.com/docs/developers/apiv4/en/#get-futures-account-2
3028
3030
  * @see https://www.gate.com/docs/developers/apiv4/en/#query-account-information
@@ -3322,10 +3324,10 @@ export default class gate extends Exchange {
3322
3324
  * @method
3323
3325
  * @name gateio#fetchOHLCV
3324
3326
  * @description fetches historical candlestick data containing the open, high, low, and close price, and the volume of a market
3325
- * @see https://www.gate.com/docs/developers/apiv4/en/#market-candlesticks // spot
3326
- * @see https://www.gate.com/docs/developers/apiv4/en/#get-futures-candlesticks // swap
3327
- * @see https://www.gate.com/docs/developers/apiv4/en/#market-candlesticks // future
3328
- * @see https://www.gate.com/docs/developers/apiv4/en/#get-options-candlesticks // option
3327
+ * @see https://www.gate.com/docs/developers/apiv4/en/#market-k-line-chart // spot
3328
+ * @see https://www.gate.com/docs/developers/apiv4/en/#futures-market-k-line-chart // swap
3329
+ * @see https://www.gate.com/docs/developers/apiv4/en/#futures-market-k-line-chart-2 // future
3330
+ * @see https://www.gate.com/docs/developers/apiv4/en/#options-contract-market-candlestick-chart // option
3329
3331
  * @param {string} symbol unified symbol of the market to fetch OHLCV data for
3330
3332
  * @param {string} timeframe the length of time each candle represents
3331
3333
  * @param {int} [since] timestamp in ms of the earliest candle to fetch
@@ -3412,7 +3414,7 @@ export default class gate extends Exchange {
3412
3414
  * @method
3413
3415
  * @name gate#fetchFundingRateHistory
3414
3416
  * @description fetches historical funding rate prices
3415
- * @see https://www.gate.com/docs/developers/apiv4/en/#funding-rate-history
3417
+ * @see https://www.gate.com/docs/developers/apiv4/en/#get-all-futures-trading-statistics
3416
3418
  * @param {string} symbol unified symbol of the market to fetch the funding rate history for
3417
3419
  * @param {int} [since] timestamp in ms of the earliest funding rate to fetch
3418
3420
  * @param {int} [limit] the maximum amount of [funding rate structures]{@link https://docs.ccxt.com/?id=funding-rate-history-structure} to fetch
@@ -3521,10 +3523,10 @@ export default class gate extends Exchange {
3521
3523
  * @method
3522
3524
  * @name gate#fetchTrades
3523
3525
  * @description get the list of most recent trades for a particular symbol
3524
- * @see https://www.gate.com/docs/developers/apiv4/en/#retrieve-market-trades
3525
- * @see https://www.gate.com/docs/developers/apiv4/en/#futures-trading-history
3526
- * @see https://www.gate.com/docs/developers/apiv4/en/#futures-trading-history-2
3527
- * @see https://www.gate.com/docs/developers/apiv4/en/#options-trade-history
3526
+ * @see https://www.gate.com/docs/developers/apiv4/en/#query-market-transaction-records
3527
+ * @see https://www.gate.com/docs/developers/apiv4/en/#futures-market-transaction-records
3528
+ * @see https://www.gate.com/docs/developers/apiv4/en/#futures-market-transaction-records-2
3529
+ * @see https://www.gate.com/docs/developers/apiv4/en/#market-trade-records
3528
3530
  * @param {string} symbol unified symbol of the market to fetch trades for
3529
3531
  * @param {int} [since] timestamp in ms of the earliest trade to fetch
3530
3532
  * @param {int} [limit] the maximum amount of trades to fetch
@@ -3636,10 +3638,10 @@ export default class gate extends Exchange {
3636
3638
  * @method
3637
3639
  * @name gate#fetchOrderTrades
3638
3640
  * @description fetch all the trades made from a single order
3639
- * @see https://www.gate.com/docs/developers/apiv4/en/#list-personal-trading-history
3640
- * @see https://www.gate.com/docs/developers/apiv4/en/#list-personal-trading-history-2
3641
- * @see https://www.gate.com/docs/developers/apiv4/en/#list-personal-trading-history-3
3642
- * @see https://www.gate.com/docs/developers/apiv4/en/#list-personal-trading-history-4
3641
+ * @see https://www.gate.com/docs/developers/apiv4/en/#query-personal-trading-records
3642
+ * @see https://www.gate.com/docs/developers/apiv4/en/#query-personal-trading-records-by-time-range
3643
+ * @see https://www.gate.com/docs/developers/apiv4/en/#query-personal-trading-records-3
3644
+ * @see https://www.gate.com/docs/developers/apiv4/en/#query-personal-trading-records-4
3643
3645
  * @param {string} id order id
3644
3646
  * @param {string} symbol unified market symbol
3645
3647
  * @param {int} [since] the earliest time in ms to fetch trades for
@@ -3678,10 +3680,10 @@ export default class gate extends Exchange {
3678
3680
  * @method
3679
3681
  * @name gate#fetchMyTrades
3680
3682
  * @description Fetch personal trading history
3681
- * @see https://www.gate.com/docs/developers/apiv4/en/#list-personal-trading-history
3682
- * @see https://www.gate.com/docs/developers/apiv4/en/#list-personal-trading-history-2
3683
- * @see https://www.gate.com/docs/developers/apiv4/en/#list-personal-trading-history-3
3684
- * @see https://www.gate.com/docs/developers/apiv4/en/#list-personal-trading-history-4
3683
+ * @see https://www.gate.com/docs/developers/apiv4/en/#query-personal-trading-records
3684
+ * @see https://www.gate.com/docs/developers/apiv4/en/#query-personal-trading-records-by-time-range
3685
+ * @see https://www.gate.com/docs/developers/apiv4/en/#query-personal-trading-records-3
3686
+ * @see https://www.gate.com/docs/developers/apiv4/en/#query-personal-trading-records-4
3685
3687
  * @param {string} symbol unified market symbol
3686
3688
  * @param {int} [since] the earliest time in ms to fetch trades for
3687
3689
  * @param {int} [limit] the maximum number of trades structures to retrieve
@@ -3990,7 +3992,7 @@ export default class gate extends Exchange {
3990
3992
  * @method
3991
3993
  * @name gate#fetchDeposits
3992
3994
  * @description fetch all deposits made to an account
3993
- * @see https://www.gate.com/docs/developers/apiv4/en/#retrieve-deposit-records
3995
+ * @see https://www.gate.com/docs/developers/apiv4/en/#get-deposit-records
3994
3996
  * @param {string} code unified currency code
3995
3997
  * @param {int} [since] the earliest time in ms to fetch deposits for
3996
3998
  * @param {int} [limit] the maximum number of deposits structures to retrieve
@@ -4028,7 +4030,7 @@ export default class gate extends Exchange {
4028
4030
  * @method
4029
4031
  * @name gate#fetchWithdrawals
4030
4032
  * @description fetch all withdrawals made from an account
4031
- * @see https://www.gate.com/docs/developers/apiv4/en/#retrieve-withdrawal-records
4033
+ * @see https://www.gate.com/docs/developers/apiv4/en/#get-withdrawal-records
4032
4034
  * @param {string} code unified currency code
4033
4035
  * @param {int} [since] the earliest time in ms to fetch withdrawals for
4034
4036
  * @param {int} [limit] the maximum number of withdrawals structures to retrieve
@@ -4247,11 +4249,11 @@ export default class gate extends Exchange {
4247
4249
  * @name gate#createOrder
4248
4250
  * @description Create an order on the exchange
4249
4251
  * @see https://www.gate.com/docs/developers/apiv4/en/#create-an-order
4250
- * @see https://www.gate.com/docs/developers/apiv4/en/#create-a-price-triggered-order
4251
- * @see https://www.gate.com/docs/developers/apiv4/en/#create-a-futures-order
4252
- * @see https://www.gate.com/docs/developers/apiv4/en/#create-a-price-triggered-order-2
4253
- * @see https://www.gate.com/docs/developers/apiv4/en/#create-a-futures-order-2
4254
- * @see https://www.gate.com/docs/developers/apiv4/en/#create-a-price-triggered-order-3
4252
+ * @see https://www.gate.com/docs/developers/apiv4/en/#create-price-triggered-order
4253
+ * @see https://www.gate.com/docs/developers/apiv4/en/#place-futures-order
4254
+ * @see https://www.gate.com/docs/developers/apiv4/en/#create-price-triggered-order-2
4255
+ * @see https://www.gate.com/docs/developers/apiv4/en/#place-futures-order-2
4256
+ * @see https://www.gate.com/docs/developers/apiv4/en/#create-price-triggered-order-3
4255
4257
  * @see https://www.gate.com/docs/developers/apiv4/en/#create-an-options-order
4256
4258
  * @param {string} symbol Unified CCXT market symbol
4257
4259
  * @param {string} type 'limit' or 'market' *"market" is contract only*
@@ -4424,9 +4426,8 @@ export default class gate extends Exchange {
4424
4426
  * @method
4425
4427
  * @name gate#createOrders
4426
4428
  * @description create a list of trade orders
4427
- * @see https://www.gate.com/docs/developers/apiv4/en/#get-a-single-order-2
4428
- * @see https://www.gate.com/docs/developers/apiv4/en/#create-a-batch-of-orders
4429
- * @see https://www.gate.com/docs/developers/apiv4/en/#create-a-batch-of-futures-orders
4429
+ * @see https://www.gate.com/docs/developers/apiv4/en/#batch-place-orders
4430
+ * @see https://www.gate.com/docs/developers/apiv4/en/#place-batch-futures-orders
4430
4431
  * @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
4431
4432
  * @param {object} [params] extra parameters specific to the exchange API endpoint
4432
4433
  * @returns {object} an [order structure]{@link https://docs.ccxt.com/?id=order-structure}
@@ -4730,7 +4731,7 @@ export default class gate extends Exchange {
4730
4731
  if (!market['spot']) {
4731
4732
  throw new NotSupported(this.id + ' createMarketBuyOrderWithCost() supports spot orders only');
4732
4733
  }
4733
- params['createMarketBuyOrderRequiresPrice'] = false;
4734
+ params = this.extend(params, { 'createMarketBuyOrderRequiresPrice': false });
4734
4735
  return await this.createOrder(symbol, 'market', 'buy', cost, undefined, params);
4735
4736
  }
4736
4737
  editOrderRequest(id, symbol, type, side, amount = undefined, price = undefined, params = {}) {
@@ -4780,8 +4781,8 @@ export default class gate extends Exchange {
4780
4781
  * @method
4781
4782
  * @name gate#editOrder
4782
4783
  * @description edit a trade order, gate currently only supports the modification of the price or amount fields
4783
- * @see https://www.gate.com/docs/developers/apiv4/en/#amend-an-order
4784
- * @see https://www.gate.com/docs/developers/apiv4/en/#amend-an-order-2
4784
+ * @see https://www.gate.com/docs/developers/apiv4/en/#amend-single-order
4785
+ * @see https://www.gate.com/docs/developers/apiv4/en/#amend-single-order-2
4785
4786
  * @param {string} id order id
4786
4787
  * @param {string} symbol unified symbol of the market to create an order in
4787
4788
  * @param {string} type 'market' or 'limit'
@@ -5015,6 +5016,42 @@ export default class gate extends Exchange {
5015
5016
  // order_type: '',
5016
5017
  // in_dual_mode: false,
5017
5018
  // parent_id: '0',
5019
+ //
5020
+ // unified spot: watchOrders
5021
+ //
5022
+ // {
5023
+ // "id": "1036717689726",
5024
+ // "text": "apiv4",
5025
+ // "create_time": "1774613210",
5026
+ // "update_time": "1774613210",
5027
+ // "currency_pair": "BTC_USDT",
5028
+ // "type": "limit",
5029
+ // "account": "unified",
5030
+ // "side": "buy",
5031
+ // "amount": "0.1",
5032
+ // "price": "200",
5033
+ // "time_in_force": "gtc",
5034
+ // "left": "0.1",
5035
+ // "filled_amount": "0",
5036
+ // "filled_total": "0",
5037
+ // "avg_deal_price": "0",
5038
+ // "fee": "0",
5039
+ // "fee_currency": "BTC",
5040
+ // "point_fee": "0",
5041
+ // "gt_fee": "0",
5042
+ // "rebated_fee": "0",
5043
+ // "rebated_fee_currency": "BTC",
5044
+ // "create_time_ms": "1774613210391",
5045
+ // "update_time_ms": "1774613210391",
5046
+ // "user": 10406147,
5047
+ // "event": "put",
5048
+ // "stp_id": 0,
5049
+ // "stp_act": "-",
5050
+ // "finish_as": "open",
5051
+ // "biz_info": "ch:ccxt",
5052
+ // "amend_text": "-"
5053
+ // }
5054
+ //
5018
5055
  const succeeded = this.safeBool(order, 'succeeded', true);
5019
5056
  if (!succeeded) {
5020
5057
  // cancelOrders response
@@ -5091,7 +5128,6 @@ export default class gate extends Exchange {
5091
5128
  }
5092
5129
  const exchangeSymbol = this.safeString2(order, 'currency_pair', 'market', contract);
5093
5130
  const symbol = this.safeSymbol(exchangeSymbol, market, '_', marketType);
5094
- // Everything below this(above return) is related to fees
5095
5131
  const fees = [];
5096
5132
  const gtFee = this.safeString(order, 'gt_fee');
5097
5133
  if (gtFee !== undefined) {
@@ -5120,7 +5156,7 @@ export default class gate extends Exchange {
5120
5156
  let remaining = Precise.stringAbs(remainingString);
5121
5157
  // handle spot market buy
5122
5158
  const account = this.safeString(order, 'account'); // using this instead of market type because of the conflicting ids
5123
- if (account === 'spot') {
5159
+ if ((account === 'spot') || (account === 'unified')) {
5124
5160
  const averageString = this.safeString(order, 'avg_deal_price');
5125
5161
  average = this.parseNumber(averageString);
5126
5162
  if ((type === 'market') && (side === 'buy')) {
@@ -5199,10 +5235,13 @@ export default class gate extends Exchange {
5199
5235
  * @method
5200
5236
  * @name gate#fetchOrder
5201
5237
  * @description Retrieves information on an order
5202
- * @see https://www.gate.com/docs/developers/apiv4/en/#get-a-single-order
5203
- * @see https://www.gate.com/docs/developers/apiv4/en/#get-a-single-order-2
5204
- * @see https://www.gate.com/docs/developers/apiv4/en/#get-a-single-order-3
5205
- * @see https://www.gate.com/docs/developers/apiv4/en/#get-a-single-order-4
5238
+ * @see https://www.gate.com/docs/developers/apiv4/en/#query-single-order-details
5239
+ * @see https://www.gate.com/docs/developers/apiv4/en/#query-single-auto-order-details
5240
+ * @see https://www.gate.com/docs/developers/apiv4/en/#query-single-order-details-2
5241
+ * @see https://www.gate.com/docs/developers/apiv4/en/#query-single-auto-order-details-2
5242
+ * @see https://www.gate.com/docs/developers/apiv4/en/#query-single-order-details-3
5243
+ * @see https://www.gate.com/docs/developers/apiv4/en/#query-single-auto-order-details-3
5244
+ * @see https://www.gate.com/docs/developers/apiv4/en/#query-single-order-details-4
5206
5245
  * @param {string} id Order id
5207
5246
  * @param {string} symbol Unified market symbol, *required for spot and margin*
5208
5247
  * @param {object} [params] Parameters specified by the exchange api
@@ -5259,7 +5298,6 @@ export default class gate extends Exchange {
5259
5298
  * @name gate#fetchOpenOrders
5260
5299
  * @description fetch all unfilled currently open orders
5261
5300
  * @see https://www.gate.com/docs/developers/apiv4/en/#list-all-open-orders
5262
- * @see https://www.gate.com/docs/developers/apiv4/en/#retrieve-running-auto-order-list
5263
5301
  * @param {string} symbol unified market symbol
5264
5302
  * @param {int} [since] the earliest time in ms to fetch open orders for
5265
5303
  * @param {int} [limit] the maximum number of open orders structures to retrieve
@@ -5277,14 +5315,14 @@ export default class gate extends Exchange {
5277
5315
  * @method
5278
5316
  * @name gate#fetchClosedOrders
5279
5317
  * @description fetches information on multiple closed orders made by the user
5280
- * @see https://www.gate.com/docs/developers/apiv4/en/#list-orders
5281
- * @see https://www.gate.com/docs/developers/apiv4/en/#retrieve-running-auto-order-list
5282
- * @see https://www.gate.com/docs/developers/apiv4/en/#list-futures-orders
5283
- * @see https://www.gate.com/docs/developers/apiv4/en/#list-all-auto-orders
5284
- * @see https://www.gate.com/docs/developers/apiv4/en/#list-futures-orders-2
5285
- * @see https://www.gate.com/docs/developers/apiv4/en/#list-all-auto-orders-2
5318
+ * @see https://www.gate.com/en-eu/docs/developers/apiv4/#list-orders
5319
+ * @see https://www.gate.com/en-eu/docs/developers/apiv4/#retrieve-running-auto-order-list
5320
+ * @see https://www.gate.com/docs/developers/apiv4/en/#query-futures-order-list
5321
+ * @see https://www.gate.com/docs/developers/apiv4/en/#query-auto-order-list
5322
+ * @see https://www.gate.com/docs/developers/apiv4/en/#query-futures-order-list-2
5323
+ * @see https://www.gate.com/docs/developers/apiv4/en/#query-auto-order-list-2
5286
5324
  * @see https://www.gate.com/docs/developers/apiv4/en/#list-options-orders
5287
- * @see https://www.gate.com/docs/developers/apiv4/en/#list-futures-orders-by-time-range
5325
+ * @see https://www.gate.com/docs/developers/apiv4/en/#query-futures-order-list-by-time-range
5288
5326
  * @param {string} symbol unified market symbol of the market orders were made in
5289
5327
  * @param {int} [since] the earliest time in ms to fetch orders for
5290
5328
  * @param {int} [limit] the maximum number of order structures to retrieve
@@ -5580,10 +5618,13 @@ export default class gate extends Exchange {
5580
5618
  * @method
5581
5619
  * @name gate#cancelOrder
5582
5620
  * @description Cancels an open order
5583
- * @see https://www.gate.com/docs/developers/apiv4/en/#cancel-a-single-order
5584
- * @see https://www.gate.com/docs/developers/apiv4/en/#cancel-a-single-order-2
5585
- * @see https://www.gate.com/docs/developers/apiv4/en/#cancel-a-single-order-3
5586
- * @see https://www.gate.com/docs/developers/apiv4/en/#cancel-a-single-order-4
5621
+ * @see https://www.gate.com/docs/developers/apiv4/en/#cancel-single-order
5622
+ * @see https://www.gate.com/docs/developers/apiv4/en/#cancel-single-auto-order
5623
+ * @see https://www.gate.com/docs/developers/apiv4/en/#cancel-single-order-2
5624
+ * @see https://www.gate.com/docs/developers/apiv4/en/#cancel-single-auto-order-2
5625
+ * @see https://www.gate.com/docs/developers/apiv4/en/#cancel-single-order-3
5626
+ * @see https://www.gate.com/docs/developers/apiv4/en/#cancel-single-auto-order-3
5627
+ * @see https://www.gate.com/docs/developers/apiv4/en/#cancel-single-order-4
5587
5628
  * @param {string} id Order id
5588
5629
  * @param {string} symbol Unified market symbol
5589
5630
  * @param {object} [params] Parameters specified by the exchange api
@@ -5718,8 +5759,8 @@ export default class gate extends Exchange {
5718
5759
  * @method
5719
5760
  * @name gate#cancelOrders
5720
5761
  * @description cancel multiple orders
5721
- * @see https://www.gate.com/docs/developers/apiv4/en/#cancel-a-batch-of-orders-with-an-id-list
5722
- * @see https://www.gate.com/docs/developers/apiv4/en/#cancel-a-batch-of-orders-with-an-id-list-2
5762
+ * @see https://www.gate.com/docs/developers/apiv4/en/#cancel-batch-orders-by-specified-id-list
5763
+ * @see https://www.gate.com/docs/developers/apiv4/en/#cancel-batch-orders-by-specified-id-list-2
5723
5764
  * @param {string[]} ids order ids
5724
5765
  * @param {string} symbol unified symbol of the market the order was made in
5725
5766
  * @param {object} [params] extra parameters specific to the exchange API endpoint
@@ -5767,7 +5808,7 @@ export default class gate extends Exchange {
5767
5808
  * @method
5768
5809
  * @name gate#cancelOrdersForSymbols
5769
5810
  * @description cancel multiple orders for multiple symbols
5770
- * @see https://www.gate.com/docs/developers/apiv4/en/#cancel-a-batch-of-orders-with-an-id-list
5811
+ * @see https://www.gate.com/en-eu/docs/developers/apiv4/#cancel-a-batch-of-orders-with-an-id-list
5771
5812
  * @param {CancellationRequest[]} orders list of order ids with symbol, example [{"id": "a", "symbol": "BTC/USDT"}, {"id": "b", "symbol": "ETH/USDT"}]
5772
5813
  * @param {object} [params] extra parameters specific to the exchange API endpoint
5773
5814
  * @param {string[]} [params.clientOrderIds] client order ids
@@ -5808,9 +5849,12 @@ export default class gate extends Exchange {
5808
5849
  * @name gate#cancelAllOrders
5809
5850
  * @description cancel all open orders
5810
5851
  * @see https://www.gate.com/docs/developers/apiv4/en/#cancel-all-open-orders-in-specified-currency-pair
5811
- * @see https://www.gate.com/docs/developers/apiv4/en/#cancel-all-open-orders-matched
5812
- * @see https://www.gate.com/docs/developers/apiv4/en/#cancel-all-open-orders-matched-2
5813
- * @see https://www.gate.com/docs/developers/apiv4/en/#cancel-all-open-orders-matched-3
5852
+ * @see https://www.gate.com/docs/developers/apiv4/en/#cancel-all-auto-orders
5853
+ * @see https://www.gate.com/docs/developers/apiv4/en/#cancel-all-orders-with-open-status
5854
+ * @see https://www.gate.com/docs/developers/apiv4/en/#cancel-all-auto-orders-2
5855
+ * @see https://www.gate.com/docs/developers/apiv4/en/#cancel-all-orders-with-open-status-2
5856
+ * @see https://www.gate.com/docs/developers/apiv4/en/#cancel-all-auto-orders-3
5857
+ * @see https://www.gate.com/docs/developers/apiv4/en/#cancel-all-orders-with-open-status-3
5814
5858
  * @param {string} symbol unified market symbol, only orders in the market of this symbol are cancelled when symbol is not undefined
5815
5859
  * @param {object} [params] extra parameters specific to the exchange API endpoint
5816
5860
  * @param {bool} [params.unifiedAccount] set to true for canceling unified account orders
@@ -6194,8 +6238,8 @@ export default class gate extends Exchange {
6194
6238
  * @method
6195
6239
  * @name gate#fetchPosition
6196
6240
  * @description fetch data on an open contract position
6197
- * @see https://www.gate.com/docs/developers/apiv4/en/#get-single-position
6198
- * @see https://www.gate.com/docs/developers/apiv4/en/#get-single-position-2
6241
+ * @see https://www.gate.com/docs/developers/apiv4/en/#get-single-position-information
6242
+ * @see https://www.gate.com/docs/developers/apiv4/en/#get-single-position-information-2
6199
6243
  * @see https://www.gate.com/docs/developers/apiv4/en/#get-specified-contract-position
6200
6244
  * @param {string} symbol unified market symbol of the market the position is held in
6201
6245
  * @param {object} [params] extra parameters specific to the exchange API endpoint
@@ -6282,8 +6326,8 @@ export default class gate extends Exchange {
6282
6326
  * @method
6283
6327
  * @name gate#fetchPositions
6284
6328
  * @description fetch all open positions
6285
- * @see https://www.gate.com/docs/developers/apiv4/en/#list-all-positions-of-a-user
6286
- * @see https://www.gate.com/docs/developers/apiv4/en/#list-all-positions-of-a-user-2
6329
+ * @see https://www.gate.com/docs/developers/apiv4/en/#get-user-position-list
6330
+ * @see https://www.gate.com/docs/developers/apiv4/en/#get-user-position-list-2
6287
6331
  * @see https://www.gate.com/docs/developers/apiv4/en/#list-user-s-positions-of-specified-underlying
6288
6332
  * @param {string[]|undefined} symbols Not used by gate, but parsed internally by CCXT
6289
6333
  * @param {object} [params] extra parameters specific to the exchange API endpoint
@@ -6393,8 +6437,8 @@ export default class gate extends Exchange {
6393
6437
  * @method
6394
6438
  * @name gate#fetchLeverageTiers
6395
6439
  * @description retrieve information on the maximum leverage, and maintenance margin for trades of varying trade sizes
6396
- * @see https://www.gate.com/docs/developers/apiv4/en/#list-all-futures-contracts
6397
- * @see https://www.gate.com/docs/developers/apiv4/en/#list-all-futures-contracts-2
6440
+ * @see https://www.gate.com/docs/developers/apiv4/en/#query-all-futures-contracts
6441
+ * @see https://www.gate.com/docs/developers/apiv4/en/#query-all-futures-contracts-2
6398
6442
  * @param {string[]} [symbols] list of unified market symbols
6399
6443
  * @param {object} [params] extra parameters specific to the exchange API endpoint
6400
6444
  * @returns {object} a dictionary of [leverage tiers structures]{@link https://docs.ccxt.com/?id=leverage-tiers-structure}, indexed by market symbols
@@ -6514,7 +6558,8 @@ export default class gate extends Exchange {
6514
6558
  * @method
6515
6559
  * @name gate#fetchMarketLeverageTiers
6516
6560
  * @description retrieve information on the maximum leverage, and maintenance margin for trades of varying trade sizes for a single market
6517
- * @see https://www.gate.com/docs/developers/apiv4/en/#list-risk-limit-tiers
6561
+ * @see https://www.gate.com/docs/developers/apiv4/en/#query-risk-limit-tiers
6562
+ * @see https://www.gate.com/docs/developers/apiv4/en/#query-risk-limit-tiers-2
6518
6563
  * @param {string} symbol unified market symbol
6519
6564
  * @param {object} [params] extra parameters specific to the exchange API endpoint
6520
6565
  * @returns {object} a [leverage tiers structure]{@link https://docs.ccxt.com/?id=leverage-tiers-structure}
@@ -6527,18 +6572,24 @@ export default class gate extends Exchange {
6527
6572
  if (type !== 'future' && type !== 'swap') {
6528
6573
  throw new BadRequest(this.id + ' fetchMarketLeverageTiers only supports swap and future');
6529
6574
  }
6530
- const response = await this.publicFuturesGetSettleRiskLimitTiers(this.extend(request, requestParams));
6531
- //
6532
- // [
6533
- // {
6534
- // "maintenance_rate": "0.004",
6535
- // "tier": 1,
6536
- // "initial_rate": "0.008",
6537
- // "leverage_max": "125",
6538
- // "risk_limit": "1000000"
6539
- // }
6540
- // ]
6541
- //
6575
+ let response = undefined;
6576
+ if (type === 'swap') {
6577
+ //
6578
+ // [
6579
+ // {
6580
+ // "maintenance_rate": "0.004",
6581
+ // "tier": 1,
6582
+ // "initial_rate": "0.008",
6583
+ // "leverage_max": "125",
6584
+ // "risk_limit": "1000000"
6585
+ // }
6586
+ // ]
6587
+ //
6588
+ response = await this.publicFuturesGetSettleRiskLimitTiers(this.extend(request, requestParams));
6589
+ }
6590
+ else {
6591
+ response = await this.publicDeliveryGetSettleRiskLimitTiers(this.extend(request, requestParams));
6592
+ }
6542
6593
  return this.parseMarketLeverageTiers(response, market);
6543
6594
  }
6544
6595
  parseEmulatedLeverageTiers(info, market = undefined) {
@@ -6606,9 +6657,9 @@ export default class gate extends Exchange {
6606
6657
  }
6607
6658
  /**
6608
6659
  * @method
6609
- * @name gate#repayMargin
6660
+ * @name gate#repayIsolatedMargin
6610
6661
  * @description repay borrowed margin and interest
6611
- * @see https://www.gate.com/docs/apiv4/en/#repay-a-loan
6662
+ * @see https://www.gate.com/docs/developers/apiv4/en/#borrow-or-repay-2
6612
6663
  * @param {string} symbol unified market symbol
6613
6664
  * @param {string} code unified currency code of the currency to repay
6614
6665
  * @param {float} amount the amount to repay
@@ -6637,7 +6688,6 @@ export default class gate extends Exchange {
6637
6688
  * @method
6638
6689
  * @name gate#repayCrossMargin
6639
6690
  * @description repay cross margin borrowed margin and interest
6640
- * @see https://www.gate.com/docs/developers/apiv4/en/#cross-margin-repayments
6641
6691
  * @see https://www.gate.com/docs/developers/apiv4/en/#borrow-or-repay
6642
6692
  * @param {string} code unified currency code of the currency to repay
6643
6693
  * @param {float} amount the amount to repay
@@ -6663,6 +6713,7 @@ export default class gate extends Exchange {
6663
6713
  response = await this.privateUnifiedPostLoans(this.extend(request, params));
6664
6714
  }
6665
6715
  else {
6716
+ // deprecated and not present in the exchange's docs but still works
6666
6717
  response = await this.privateMarginPostCrossRepayments(this.extend(request, params));
6667
6718
  response = this.safeDict(response, 0);
6668
6719
  //
@@ -6688,7 +6739,7 @@ export default class gate extends Exchange {
6688
6739
  * @method
6689
6740
  * @name gate#borrowIsolatedMargin
6690
6741
  * @description create a loan to borrow margin
6691
- * @see https://www.gate.com/docs/developers/apiv4/en/#marginuni
6742
+ * @see https://www.gate.com/docs/developers/apiv4/en/#borrow-or-repay-2
6692
6743
  * @param {string} symbol unified market symbol, required for isolated margin
6693
6744
  * @param {string} code unified currency code of the currency to borrow
6694
6745
  * @param {float} amount the amount to borrow
@@ -6731,15 +6782,14 @@ export default class gate extends Exchange {
6731
6782
  }
6732
6783
  /**
6733
6784
  * @method
6734
- * @name gate#borrowMargin
6785
+ * @name gate#borrowCrossMargin
6735
6786
  * @description create a loan to borrow margin
6736
- * @see https://www.gate.com/docs/apiv4/en/#create-a-cross-margin-borrow-loan
6737
6787
  * @see https://www.gate.com/docs/developers/apiv4/en/#borrow-or-repay
6738
6788
  * @param {string} code unified currency code of the currency to borrow
6739
6789
  * @param {float} amount the amount to borrow
6740
6790
  * @param {object} [params] extra parameters specific to the exchange API endpoint
6741
6791
  * @param {string} [params.rate] '0.0002' or '0.002' extra parameter required for isolated margin
6742
- * @param {boolean} [params.unifiedAccount] set to true for borrowing in the unified account
6792
+ * @param {boolean} [params.unifiedAccount] default true (set to false to use deprecated privateMarginPostCrossLoans method)
6743
6793
  * @returns {object} a [margin loan structure]{@link https://docs.ccxt.com/?id=margin-loan-structure}
6744
6794
  */
6745
6795
  async borrowCrossMargin(code, amount, params = {}) {
@@ -6758,6 +6808,8 @@ export default class gate extends Exchange {
6758
6808
  response = await this.privateUnifiedPostLoans(this.extend(request, params));
6759
6809
  }
6760
6810
  else {
6811
+ // deprecated and not present in the exchange's docs
6812
+ // returns {"label":"REQUEST_FORBIDDEN","message":"Request is forbidden"}
6761
6813
  response = await this.privateMarginPostCrossLoans(this.extend(request, params));
6762
6814
  //
6763
6815
  // {
@@ -6834,9 +6886,8 @@ export default class gate extends Exchange {
6834
6886
  * @method
6835
6887
  * @name gate#fetchBorrowInterest
6836
6888
  * @description fetch the interest owed by the user for borrowing currency for margin trading
6837
- * @see https://www.gate.com/docs/developers/apiv4/en/#list-interest-records
6838
- * @see https://www.gate.com/docs/developers/apiv4/en/#interest-records-for-the-cross-margin-account
6839
- * @see https://www.gate.com/docs/developers/apiv4/en/#list-interest-records-2
6889
+ * @see https://www.gate.com/docs/developers/apiv4/en/#query-interest-deduction-records
6890
+ * @see https://www.gate.com/docs/developers/apiv4/en/#query-interest-deduction-records-2
6840
6891
  * @param {string} [code] unified currency code
6841
6892
  * @param {string} [symbol] unified market symbol when fetching interest in isolated markets
6842
6893
  * @param {int} [since] the earliest time in ms to fetch borrow interest for
@@ -6880,6 +6931,7 @@ export default class gate extends Exchange {
6880
6931
  response = await this.privateMarginGetUniInterestRecords(this.extend(request, params));
6881
6932
  }
6882
6933
  else if (marginMode === 'cross') {
6934
+ // deprecated and not present in the exchange's docs but still works
6883
6935
  response = await this.privateMarginGetCrossInterestRecords(this.extend(request, params));
6884
6936
  }
6885
6937
  const interest = this.parseBorrowInterests(response, market);
@@ -7095,7 +7147,7 @@ export default class gate extends Exchange {
7095
7147
  * @method
7096
7148
  * @name gate#fetchOpenInterest
7097
7149
  * @description Retrieves the open interest of a currency
7098
- * @see https://www.gate.com/docs/developers/apiv4/en/#futures-stats
7150
+ * @see https://www.gate.com/docs/developers/apiv4/en/#futures-statistics
7099
7151
  * @param {string} symbol Unified CCXT market symbol
7100
7152
  * @param {string} timeframe "5m", "15m", "30m", "1h", "4h", "1d"
7101
7153
  * @param {int} [since] the time(ms) of the earliest record to retrieve as a unix timestamp
@@ -7183,7 +7235,7 @@ export default class gate extends Exchange {
7183
7235
  * @method
7184
7236
  * @name gate#fetchSettlementHistory
7185
7237
  * @description fetches historical settlement records
7186
- * @see https://www.gate.com/docs/developers/apiv4/en/#list-settlement-history-2
7238
+ * @see https://www.gate.com/docs/developers/apiv4/en/#list-settlement-history
7187
7239
  * @param {string} symbol unified market symbol of the settlement history, required on gate
7188
7240
  * @param {int} [since] timestamp in ms
7189
7241
  * @param {int} [limit] number of records
@@ -7233,7 +7285,8 @@ export default class gate extends Exchange {
7233
7285
  * @method
7234
7286
  * @name gate#fetchMySettlementHistory
7235
7287
  * @description fetches historical settlement records of the user
7236
- * @see https://www.gate.com/docs/developers/apiv4/en/#list-my-options-settlements
7288
+ * @see https://www.gate.com/docs/developers/apiv4/en/#query-personal-settlement-records
7289
+ * @see https://www.gate.com/docs/developers/apiv4/en/#query-settlement-records
7237
7290
  * @param {string} symbol unified market symbol of the settlement history
7238
7291
  * @param {int} [since] timestamp in ms
7239
7292
  * @param {int} [limit] number of records
@@ -7241,49 +7294,79 @@ export default class gate extends Exchange {
7241
7294
  * @returns {object[]} a list of [settlement history objects]
7242
7295
  */
7243
7296
  async fetchMySettlementHistory(symbol = undefined, since = undefined, limit = undefined, params = {}) {
7244
- if (symbol === undefined) {
7245
- throw new ArgumentsRequired(this.id + ' fetchMySettlementHistory() requires a symbol argument');
7246
- }
7247
7297
  await this.loadMarkets();
7248
- const market = this.market(symbol);
7298
+ let market = undefined;
7299
+ if (symbol !== undefined) {
7300
+ market = this.market(symbol);
7301
+ symbol = market['symbol'];
7302
+ }
7249
7303
  let type = undefined;
7250
7304
  [type, params] = this.handleMarketTypeAndParams('fetchMySettlementHistory', market, params);
7251
- if (type !== 'option') {
7252
- throw new NotSupported(this.id + ' fetchMySettlementHistory() supports option markets only');
7253
- }
7254
- const marketId = market['id'];
7255
- const optionParts = marketId.split('-');
7256
- const request = {
7257
- 'underlying': this.safeString(optionParts, 0),
7258
- 'contract': marketId,
7259
- };
7260
- if (since !== undefined) {
7261
- request['from'] = since;
7305
+ const isOption = type === 'option';
7306
+ const isFuture = type === 'future';
7307
+ if (!isOption && !isFuture) {
7308
+ throw new NotSupported(this.id + ' fetchMySettlementHistory() supports option and future markets only');
7262
7309
  }
7310
+ const [request, query] = this.prepareRequest(market, type, params);
7263
7311
  if (limit !== undefined) {
7264
7312
  request['limit'] = limit;
7265
7313
  }
7266
- const response = await this.privateOptionsGetMySettlements(this.extend(request, params));
7267
- //
7268
- // [
7269
- // {
7270
- // "size": -1,
7271
- // "settle_profit": "0",
7272
- // "contract": "BTC_USDT-20220624-26000-C",
7273
- // "strike_price": "26000",
7274
- // "time": 1656057600,
7275
- // "settle_price": "20917.461281337048",
7276
- // "underlying": "BTC_USDT",
7277
- // "realised_pnl": "-0.00116042",
7278
- // "fee": "0"
7279
- // }
7280
- // ]
7281
- //
7314
+ let response = undefined;
7315
+ if (isFuture) {
7316
+ //
7317
+ // [
7318
+ // {
7319
+ // "time": 1548654951,
7320
+ // "contract": "BTC_USDT",
7321
+ // "size": 600,
7322
+ // "leverage": "25",
7323
+ // "margin": "0.006705256878",
7324
+ // "entry_price": "3536.123",
7325
+ // "settle_price": "3421.54",
7326
+ // "profit": "-6.87498",
7327
+ // "fee": "0.03079386"
7328
+ // }
7329
+ // ]
7330
+ //
7331
+ response = await this.privateDeliveryGetSettleSettlements(this.extend(request, query));
7332
+ }
7333
+ else {
7334
+ if (since !== undefined) {
7335
+ request['from'] = since;
7336
+ }
7337
+ if (market === undefined) {
7338
+ const underlying = this.safeString(params, 'underlying');
7339
+ if (underlying === undefined) {
7340
+ throw new ArgumentsRequired(this.id + ' fetchMySettlementHistory() requires a symbol argument or an underlying parameter in params');
7341
+ }
7342
+ }
7343
+ else {
7344
+ const marketId = market['id'];
7345
+ const optionParts = marketId.split('-');
7346
+ request['underlying'] = this.safeString(optionParts, 0);
7347
+ }
7348
+ //
7349
+ // [
7350
+ // {
7351
+ // "size": -1,
7352
+ // "settle_profit": "0",
7353
+ // "contract": "BTC_USDT-20220624-26000-C",
7354
+ // "strike_price": "26000",
7355
+ // "time": 1656057600,
7356
+ // "settle_price": "20917.461281337048",
7357
+ // "underlying": "BTC_USDT",
7358
+ // "realised_pnl": "-0.00116042",
7359
+ // "fee": "0"
7360
+ // }
7361
+ // ]
7362
+ //
7363
+ response = await this.privateOptionsGetMySettlements(this.extend(request, params));
7364
+ }
7282
7365
  const result = this.safeValue(response, 'result', {});
7283
7366
  const data = this.safeValue(result, 'list', []);
7284
7367
  const settlements = this.parseSettlements(data, market);
7285
7368
  const sorted = this.sortBy(settlements, 'timestamp');
7286
- return this.filterBySymbolSinceLimit(sorted, market['symbol'], since, limit);
7369
+ return this.filterBySymbolSinceLimit(sorted, symbol, since, limit);
7287
7370
  }
7288
7371
  parseSettlement(settlement, market) {
7289
7372
  //
@@ -7298,7 +7381,7 @@ export default class gate extends Exchange {
7298
7381
  // "strike_price": "25000"
7299
7382
  // }
7300
7383
  //
7301
- // fetchMySettlementHistory
7384
+ // fetchMySettlementHistory option
7302
7385
  //
7303
7386
  // {
7304
7387
  // "size": -1,
@@ -7312,6 +7395,19 @@ export default class gate extends Exchange {
7312
7395
  // "fee": "0"
7313
7396
  // }
7314
7397
  //
7398
+ // fetchMySettlementHistory future
7399
+ // {
7400
+ // "time": 1548654951,
7401
+ // "contract": "BTC_USDT",
7402
+ // "size": 600,
7403
+ // "leverage": "25",
7404
+ // "margin": "0.006705256878",
7405
+ // "entry_price": "3536.123",
7406
+ // "settle_price": "3421.54",
7407
+ // "profit": "-6.87498",
7408
+ // "fee": "0.03079386"
7409
+ // }
7410
+ //
7315
7411
  const timestamp = this.safeTimestamp(settlement, 'time');
7316
7412
  const marketId = this.safeString(settlement, 'contract');
7317
7413
  return {
@@ -7363,11 +7459,11 @@ export default class gate extends Exchange {
7363
7459
  * @method
7364
7460
  * @name gate#fetchLedger
7365
7461
  * @description fetch the history of changes, actions done by the user or operations that altered the balance of the user
7366
- * @see https://www.gate.com/docs/developers/apiv4/en/#query-account-book
7367
- * @see https://www.gate.com/docs/developers/apiv4/en/#list-margin-account-balance-change-history
7368
- * @see https://www.gate.com/docs/developers/apiv4/en/#query-account-book-2
7369
- * @see https://www.gate.com/docs/developers/apiv4/en/#query-account-book-3
7370
- * @see https://www.gate.com/docs/developers/apiv4/en/#list-account-changing-history
7462
+ * @see https://www.gate.com/docs/developers/apiv4/en/#query-spot-account-transaction-history
7463
+ * @see https://www.gate.com/docs/developers/apiv4/en/#query-margin-account-balance-change-history
7464
+ * @see https://www.gate.com/docs/developers/apiv4/en/#query-futures-account-change-history
7465
+ * @see https://www.gate.com/docs/developers/apiv4/en/#query-futures-account-change-history-2
7466
+ * @see https://www.gate.com/docs/developers/apiv4/en/#query-account-change-history
7371
7467
  * @param {string} [code] unified currency code
7372
7468
  * @param {int} [since] timestamp in ms of the earliest ledger entry
7373
7469
  * @param {int} [limit] max number of ledger entries to return
@@ -7609,7 +7705,7 @@ export default class gate extends Exchange {
7609
7705
  * @method
7610
7706
  * @name gate#setPositionMode
7611
7707
  * @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
7612
- * @see https://www.gate.com/docs/developers/apiv4/en/#enable-or-disable-dual-mode
7708
+ * @see https://www.gate.com/docs/developers/apiv4/en/#set-position-mode
7613
7709
  * @param {bool} hedged set to true to enable dual mode
7614
7710
  * @param {string|undefined} symbol if passed, dual mode is set for all markets with the same settle currency
7615
7711
  * @param {object} params extra parameters specific to the exchange API endpoint
@@ -7626,7 +7722,7 @@ export default class gate extends Exchange {
7626
7722
  * @method
7627
7723
  * @name gate#fetchUnderlyingAssets
7628
7724
  * @description fetches the market ids of underlying assets for a specific contract market type
7629
- * @see https://www.gate.com/docs/developers/apiv4/en/#list-all-underlyings
7725
+ * @see https://www.gate.com/docs/developers/apiv4/en/#list-all-underlying-assets
7630
7726
  * @param {object} [params] exchange specific params
7631
7727
  * @param {string} [params.type] the contract market type, 'option', 'swap' or 'future', the default is 'option'
7632
7728
  * @returns {object[]} a list of [underlying assets]{@link https://docs.ccxt.com/?id=underlying-assets-structure}
@@ -7665,7 +7761,7 @@ export default class gate extends Exchange {
7665
7761
  * @method
7666
7762
  * @name gate#fetchLiquidations
7667
7763
  * @description retrieves the public liquidations of a trading pair
7668
- * @see https://www.gate.com/docs/developers/apiv4/en/#retrieve-liquidation-history
7764
+ * @see https://www.gate.com/docs/developers/apiv4/en/#query-liquidation-order-history
7669
7765
  * @param {string} symbol unified CCXT market symbol
7670
7766
  * @param {int} [since] the earliest time in ms to fetch liquidations for
7671
7767
  * @param {int} [limit] the maximum number of liquidation structures to retrieve
@@ -7709,8 +7805,8 @@ export default class gate extends Exchange {
7709
7805
  * @method
7710
7806
  * @name gate#fetchMyLiquidations
7711
7807
  * @description retrieves the users liquidated positions
7712
- * @see https://www.gate.com/docs/developers/apiv4/en/#list-liquidation-history
7713
- * @see https://www.gate.com/docs/developers/apiv4/en/#list-liquidation-history-2
7808
+ * @see https://www.gate.com/docs/developers/apiv4/en/#query-liquidation-history
7809
+ * @see https://www.gate.com/docs/developers/apiv4/en/#query-liquidation-history-2
7714
7810
  * @see https://www.gate.com/docs/developers/apiv4/en/#list-user-s-liquidation-history-of-specified-underlying
7715
7811
  * @param {string} symbol unified CCXT market symbol
7716
7812
  * @param {int} [since] the earliest time in ms to fetch liquidations for
@@ -7876,7 +7972,7 @@ export default class gate extends Exchange {
7876
7972
  * @method
7877
7973
  * @name gate#fetchGreeks
7878
7974
  * @description fetches an option contracts greeks, financial metrics used to measure the factors that affect the price of an options contract
7879
- * @see https://www.gate.com/docs/developers/apiv4/en/#list-tickers-of-options-contracts
7975
+ * @see https://www.gate.com/docs/developers/apiv4/en/#query-options-market-ticker-information
7880
7976
  * @param {string} symbol unified symbol of the market to fetch greeks for
7881
7977
  * @param {object} [params] extra parameters specific to the exchange API endpoint
7882
7978
  * @returns {object} a [greeks structure]{@link https://docs.ccxt.com/?id=greeks-structure}
@@ -7969,8 +8065,8 @@ export default class gate extends Exchange {
7969
8065
  * @method
7970
8066
  * @name gate#closePosition
7971
8067
  * @description closes open positions for a market
7972
- * @see https://www.gate.com/docs/developers/apiv4/en/#create-a-futures-order
7973
- * @see https://www.gate.com/docs/developers/apiv4/en/#create-a-futures-order-2
8068
+ * @see https://www.gate.com/docs/developers/apiv4/en/#place-futures-order
8069
+ * @see https://www.gate.com/docs/developers/apiv4/en/#place-futures-order-2
7974
8070
  * @see https://www.gate.com/docs/developers/apiv4/en/#create-an-options-order
7975
8071
  * @param {string} symbol Unified CCXT market symbol
7976
8072
  * @param {string} side 'buy' or 'sell'
@@ -7992,8 +8088,7 @@ export default class gate extends Exchange {
7992
8088
  * @name gate#fetchLeverage
7993
8089
  * @description fetch the set leverage for a market
7994
8090
  * @see https://www.gate.com/docs/developers/apiv4/en/#get-unified-account-information
7995
- * @see https://www.gate.com/docs/developers/apiv4/en/#get-detail-of-lending-market
7996
- * @see https://www.gate.com/docs/developers/apiv4/en/#query-one-single-margin-currency-pair-deprecated
8091
+ * @see https://www.gate.com/docs/developers/apiv4/en/#get-lending-market-details
7997
8092
  * @param {string} symbol unified market symbol
7998
8093
  * @param {object} [params] extra parameters specific to the exchange API endpoint
7999
8094
  * @param {boolean} [params.unified] default false, set to true for fetching the unified accounts leverage
@@ -8024,7 +8119,7 @@ export default class gate extends Exchange {
8024
8119
  //
8025
8120
  }
8026
8121
  else {
8027
- response = await this.publicMarginGetCurrencyPairsCurrencyPair(this.extend(request, params));
8122
+ response = await this.publicMarginGetCurrencyPairsCurrencyPair(this.extend(request, params)); // deprecated
8028
8123
  //
8029
8124
  // {
8030
8125
  // "id": "BTC_USDT",
@@ -8102,7 +8197,6 @@ export default class gate extends Exchange {
8102
8197
  * @name gate#fetchLeverages
8103
8198
  * @description fetch the set leverage for all leverage markets, only spot margin is supported on gate
8104
8199
  * @see https://www.gate.com/docs/developers/apiv4/en/#list-lending-markets
8105
- * @see https://www.gate.com/docs/developers/apiv4/en/#list-all-supported-currency-pairs-supported-in-margin-trading-deprecated
8106
8200
  * @param {string[]} symbols a list of unified market symbols
8107
8201
  * @param {object} [params] extra parameters specific to the exchange API endpoint
8108
8202
  * @param {boolean} [params.unified] default false, set to true for fetching unified account leverages
@@ -8130,7 +8224,7 @@ export default class gate extends Exchange {
8130
8224
  //
8131
8225
  }
8132
8226
  else {
8133
- response = await this.publicMarginGetCurrencyPairs(params);
8227
+ response = await this.publicMarginGetCurrencyPairs(params); // deprecated
8134
8228
  //
8135
8229
  // [
8136
8230
  // {
@@ -8163,7 +8257,7 @@ export default class gate extends Exchange {
8163
8257
  * @method
8164
8258
  * @name gate#fetchOption
8165
8259
  * @description fetches option data that is commonly found in an option chain
8166
- * @see https://www.gate.com/docs/developers/apiv4/en/#query-specified-contract-detail
8260
+ * @see https://www.gate.com/docs/developers/apiv4/en/#query-specified-contract-details
8167
8261
  * @param {string} symbol unified market symbol
8168
8262
  * @param {object} [params] extra parameters specific to the exchange API endpoint
8169
8263
  * @returns {object} an [option chain structure]{@link https://docs.ccxt.com/?id=option-chain-structure}
@@ -8221,7 +8315,7 @@ export default class gate extends Exchange {
8221
8315
  * @method
8222
8316
  * @name gate#fetchOptionChain
8223
8317
  * @description fetches data for an underlying asset that is commonly found in an option chain
8224
- * @see https://www.gate.com/docs/developers/apiv4/en/#list-all-the-contracts-with-specified-underlying-and-expiration-time
8318
+ * @see https://www.gate.com/docs/developers/apiv4/en/#list-all-contracts-for-specified-underlying-and-expiration-date
8225
8319
  * @param {string} code base currency to fetch an option chain for
8226
8320
  * @param {object} [params] extra parameters specific to the exchange API endpoint
8227
8321
  * @param {string} [params.underlying] the underlying asset, can be obtained from fetchUnderlyingAssets ()
@@ -8347,8 +8441,8 @@ export default class gate extends Exchange {
8347
8441
  * @method
8348
8442
  * @name gate#fetchPositionsHistory
8349
8443
  * @description fetches historical positions
8350
- * @see https://www.gate.com/docs/developers/apiv4/#list-position-close-history
8351
- * @see https://www.gate.com/docs/developers/apiv4/#list-position-close-history-2
8444
+ * @see https://www.gate.com/docs/developers/apiv4/#query-position-close-history
8445
+ * @see https://www.gate.com/docs/developers/apiv4/#query-position-close-history-2
8352
8446
  * @param {string[]} symbols unified conract symbols, must all have the same settle currency and the same market type
8353
8447
  * @param {int} [since] the earliest time in ms to fetch positions for
8354
8448
  * @param {int} [limit] the maximum amount of records to fetch, default=1000