ccxt 4.3.29__py2.py3-none-any.whl → 4.3.31__py2.py3-none-any.whl

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 (260) hide show
  1. ccxt/__init__.py +1 -1
  2. ccxt/abstract/binance.py +2 -0
  3. ccxt/abstract/binancecoinm.py +2 -0
  4. ccxt/abstract/binanceus.py +2 -0
  5. ccxt/abstract/binanceusdm.py +2 -0
  6. ccxt/ace.py +14 -14
  7. ccxt/alpaca.py +16 -16
  8. ccxt/ascendex.py +46 -46
  9. ccxt/async_support/__init__.py +1 -1
  10. ccxt/async_support/ace.py +14 -14
  11. ccxt/async_support/alpaca.py +16 -16
  12. ccxt/async_support/ascendex.py +46 -46
  13. ccxt/async_support/base/exchange.py +23 -23
  14. ccxt/async_support/base/ws/aiohttp_client.py +1 -0
  15. ccxt/async_support/base/ws/future.py +27 -29
  16. ccxt/async_support/bigone.py +32 -32
  17. ccxt/async_support/binance.py +105 -96
  18. ccxt/async_support/bingx.py +22 -22
  19. ccxt/async_support/bit2c.py +13 -13
  20. ccxt/async_support/bitbank.py +19 -19
  21. ccxt/async_support/bitbns.py +17 -17
  22. ccxt/async_support/bitfinex.py +24 -24
  23. ccxt/async_support/bitfinex2.py +142 -109
  24. ccxt/async_support/bitflyer.py +23 -23
  25. ccxt/async_support/bitget.py +76 -76
  26. ccxt/async_support/bithumb.py +20 -20
  27. ccxt/async_support/bitmart.py +55 -55
  28. ccxt/async_support/bitmex.py +41 -41
  29. ccxt/async_support/bitopro.py +30 -30
  30. ccxt/async_support/bitrue.py +37 -37
  31. ccxt/async_support/bitso.py +30 -30
  32. ccxt/async_support/bitstamp.py +31 -31
  33. ccxt/async_support/bitteam.py +26 -26
  34. ccxt/async_support/bitvavo.py +27 -27
  35. ccxt/async_support/bl3p.py +8 -8
  36. ccxt/async_support/blockchaincom.py +24 -24
  37. ccxt/async_support/blofin.py +37 -37
  38. ccxt/async_support/btcalpha.py +19 -19
  39. ccxt/async_support/btcbox.py +11 -11
  40. ccxt/async_support/btcmarkets.py +22 -22
  41. ccxt/async_support/btcturk.py +13 -13
  42. ccxt/async_support/bybit.py +96 -96
  43. ccxt/async_support/cex.py +21 -21
  44. ccxt/async_support/coinbase.py +53 -53
  45. ccxt/async_support/coinbaseexchange.py +29 -29
  46. ccxt/async_support/coinbaseinternational.py +32 -32
  47. ccxt/async_support/coincheck.py +14 -14
  48. ccxt/async_support/coinex.py +424 -448
  49. ccxt/async_support/coinlist.py +35 -35
  50. ccxt/async_support/coinmate.py +22 -22
  51. ccxt/async_support/coinmetro.py +22 -22
  52. ccxt/async_support/coinone.py +18 -18
  53. ccxt/async_support/coinsph.py +32 -32
  54. ccxt/async_support/coinspot.py +8 -8
  55. ccxt/async_support/cryptocom.py +43 -43
  56. ccxt/async_support/currencycom.py +33 -33
  57. ccxt/async_support/delta.py +35 -35
  58. ccxt/async_support/deribit.py +54 -54
  59. ccxt/async_support/digifinex.py +56 -56
  60. ccxt/async_support/exmo.py +34 -34
  61. ccxt/async_support/gate.py +60 -60
  62. ccxt/async_support/gemini.py +24 -24
  63. ccxt/async_support/hitbtc.py +51 -51
  64. ccxt/async_support/hollaex.py +29 -29
  65. ccxt/async_support/htx.py +73 -73
  66. ccxt/async_support/huobijp.py +30 -30
  67. ccxt/async_support/hyperliquid.py +58 -58
  68. ccxt/async_support/idex.py +33 -33
  69. ccxt/async_support/independentreserve.py +12 -12
  70. ccxt/async_support/indodax.py +21 -21
  71. ccxt/async_support/kraken.py +46 -51
  72. ccxt/async_support/krakenfutures.py +29 -29
  73. ccxt/async_support/kucoin.py +51 -51
  74. ccxt/async_support/kucoinfutures.py +33 -33
  75. ccxt/async_support/kuna.py +27 -27
  76. ccxt/async_support/latoken.py +27 -27
  77. ccxt/async_support/lbank.py +35 -35
  78. ccxt/async_support/luno.py +19 -19
  79. ccxt/async_support/lykke.py +20 -20
  80. ccxt/async_support/mercado.py +17 -17
  81. ccxt/async_support/mexc.py +64 -64
  82. ccxt/async_support/ndax.py +38 -38
  83. ccxt/async_support/novadax.py +26 -26
  84. ccxt/async_support/oceanex.py +21 -21
  85. ccxt/async_support/okcoin.py +35 -35
  86. ccxt/async_support/okx.py +85 -85
  87. ccxt/async_support/onetrading.py +32 -32
  88. ccxt/async_support/p2b.py +14 -14
  89. ccxt/async_support/paymium.py +12 -12
  90. ccxt/async_support/phemex.py +50 -50
  91. ccxt/async_support/poloniex.py +35 -35
  92. ccxt/async_support/poloniexfutures.py +25 -21
  93. ccxt/async_support/probit.py +30 -30
  94. ccxt/async_support/timex.py +22 -22
  95. ccxt/async_support/tokocrypto.py +26 -26
  96. ccxt/async_support/tradeogre.py +12 -12
  97. ccxt/async_support/upbit.py +28 -28
  98. ccxt/async_support/wavesexchange.py +33 -33
  99. ccxt/async_support/wazirx.py +21 -21
  100. ccxt/async_support/whitebit.py +80 -40
  101. ccxt/async_support/woo.py +51 -51
  102. ccxt/async_support/woofipro.py +46 -46
  103. ccxt/async_support/yobit.py +20 -20
  104. ccxt/async_support/zaif.py +12 -12
  105. ccxt/async_support/zonda.py +22 -22
  106. ccxt/base/exchange.py +39 -35
  107. ccxt/base/types.py +13 -0
  108. ccxt/bigone.py +32 -32
  109. ccxt/binance.py +105 -96
  110. ccxt/bingx.py +22 -22
  111. ccxt/bit2c.py +13 -13
  112. ccxt/bitbank.py +19 -19
  113. ccxt/bitbns.py +17 -17
  114. ccxt/bitfinex.py +24 -24
  115. ccxt/bitfinex2.py +142 -109
  116. ccxt/bitflyer.py +23 -23
  117. ccxt/bitget.py +76 -76
  118. ccxt/bithumb.py +20 -20
  119. ccxt/bitmart.py +55 -55
  120. ccxt/bitmex.py +41 -41
  121. ccxt/bitopro.py +30 -30
  122. ccxt/bitrue.py +37 -37
  123. ccxt/bitso.py +30 -30
  124. ccxt/bitstamp.py +31 -31
  125. ccxt/bitteam.py +26 -26
  126. ccxt/bitvavo.py +27 -27
  127. ccxt/bl3p.py +8 -8
  128. ccxt/blockchaincom.py +24 -24
  129. ccxt/blofin.py +37 -37
  130. ccxt/btcalpha.py +19 -19
  131. ccxt/btcbox.py +11 -11
  132. ccxt/btcmarkets.py +22 -22
  133. ccxt/btcturk.py +13 -13
  134. ccxt/bybit.py +96 -96
  135. ccxt/cex.py +21 -21
  136. ccxt/coinbase.py +53 -53
  137. ccxt/coinbaseexchange.py +29 -29
  138. ccxt/coinbaseinternational.py +32 -32
  139. ccxt/coincheck.py +14 -14
  140. ccxt/coinex.py +424 -448
  141. ccxt/coinlist.py +35 -35
  142. ccxt/coinmate.py +22 -22
  143. ccxt/coinmetro.py +22 -22
  144. ccxt/coinone.py +18 -18
  145. ccxt/coinsph.py +32 -32
  146. ccxt/coinspot.py +8 -8
  147. ccxt/cryptocom.py +43 -43
  148. ccxt/currencycom.py +33 -33
  149. ccxt/delta.py +35 -35
  150. ccxt/deribit.py +54 -54
  151. ccxt/digifinex.py +56 -56
  152. ccxt/exmo.py +34 -34
  153. ccxt/gate.py +60 -60
  154. ccxt/gemini.py +24 -24
  155. ccxt/hitbtc.py +51 -51
  156. ccxt/hollaex.py +29 -29
  157. ccxt/htx.py +73 -73
  158. ccxt/huobijp.py +30 -30
  159. ccxt/hyperliquid.py +58 -58
  160. ccxt/idex.py +33 -33
  161. ccxt/independentreserve.py +12 -12
  162. ccxt/indodax.py +21 -21
  163. ccxt/kraken.py +46 -51
  164. ccxt/krakenfutures.py +29 -29
  165. ccxt/kucoin.py +51 -51
  166. ccxt/kucoinfutures.py +33 -33
  167. ccxt/kuna.py +27 -27
  168. ccxt/latoken.py +27 -27
  169. ccxt/lbank.py +35 -35
  170. ccxt/luno.py +19 -19
  171. ccxt/lykke.py +20 -20
  172. ccxt/mercado.py +17 -17
  173. ccxt/mexc.py +64 -64
  174. ccxt/ndax.py +38 -38
  175. ccxt/novadax.py +26 -26
  176. ccxt/oceanex.py +21 -21
  177. ccxt/okcoin.py +35 -35
  178. ccxt/okx.py +85 -85
  179. ccxt/onetrading.py +32 -32
  180. ccxt/p2b.py +14 -14
  181. ccxt/paymium.py +12 -12
  182. ccxt/phemex.py +50 -50
  183. ccxt/poloniex.py +35 -35
  184. ccxt/poloniexfutures.py +25 -21
  185. ccxt/pro/__init__.py +1 -1
  186. ccxt/pro/alpaca.py +8 -8
  187. ccxt/pro/ascendex.py +4 -4
  188. ccxt/pro/binance.py +56 -56
  189. ccxt/pro/bingx.py +5 -5
  190. ccxt/pro/bitfinex.py +6 -6
  191. ccxt/pro/bitfinex2.py +10 -10
  192. ccxt/pro/bitget.py +17 -17
  193. ccxt/pro/bithumb.py +6 -6
  194. ccxt/pro/bitmart.py +8 -8
  195. ccxt/pro/bitmex.py +16 -16
  196. ccxt/pro/bitopro.py +4 -4
  197. ccxt/pro/bitrue.py +8 -8
  198. ccxt/pro/bitstamp.py +5 -5
  199. ccxt/pro/bitvavo.py +14 -14
  200. ccxt/pro/blockchaincom.py +7 -7
  201. ccxt/pro/bybit.py +12 -12
  202. ccxt/pro/cex.py +19 -19
  203. ccxt/pro/coinbase.py +2 -2
  204. ccxt/pro/coinbaseexchange.py +10 -10
  205. ccxt/pro/coinbaseinternational.py +4 -4
  206. ccxt/pro/coincheck.py +2 -2
  207. ccxt/pro/coinex.py +15 -15
  208. ccxt/pro/coinone.py +4 -4
  209. ccxt/pro/cryptocom.py +11 -11
  210. ccxt/pro/currencycom.py +4 -4
  211. ccxt/pro/deribit.py +9 -9
  212. ccxt/pro/exmo.py +9 -9
  213. ccxt/pro/gate.py +12 -12
  214. ccxt/pro/gemini.py +11 -11
  215. ccxt/pro/hitbtc.py +13 -13
  216. ccxt/pro/hollaex.py +6 -6
  217. ccxt/pro/htx.py +15 -15
  218. ccxt/pro/huobijp.py +16 -16
  219. ccxt/pro/hyperliquid.py +9 -9
  220. ccxt/pro/idex.py +12 -12
  221. ccxt/pro/independentreserve.py +2 -2
  222. ccxt/pro/kraken.py +14 -14
  223. ccxt/pro/krakenfutures.py +12 -12
  224. ccxt/pro/kucoin.py +12 -12
  225. ccxt/pro/kucoinfutures.py +16 -16
  226. ccxt/pro/lbank.py +12 -12
  227. ccxt/pro/luno.py +4 -4
  228. ccxt/pro/mexc.py +14 -14
  229. ccxt/pro/ndax.py +12 -12
  230. ccxt/pro/okcoin.py +6 -6
  231. ccxt/pro/okx.py +30 -30
  232. ccxt/pro/onetrading.py +13 -13
  233. ccxt/pro/p2b.py +2 -2
  234. ccxt/pro/phemex.py +9 -9
  235. ccxt/pro/poloniex.py +9 -9
  236. ccxt/pro/poloniexfutures.py +10 -10
  237. ccxt/pro/probit.py +8 -8
  238. ccxt/pro/upbit.py +1 -1
  239. ccxt/pro/wazirx.py +10 -10
  240. ccxt/pro/whitebit.py +8 -8
  241. ccxt/pro/woo.py +14 -14
  242. ccxt/pro/woofipro.py +14 -14
  243. ccxt/probit.py +30 -30
  244. ccxt/test/base/test_shared_methods.py +1 -0
  245. ccxt/timex.py +22 -22
  246. ccxt/tokocrypto.py +26 -26
  247. ccxt/tradeogre.py +12 -12
  248. ccxt/upbit.py +28 -28
  249. ccxt/wavesexchange.py +33 -33
  250. ccxt/wazirx.py +21 -21
  251. ccxt/whitebit.py +80 -40
  252. ccxt/woo.py +51 -51
  253. ccxt/woofipro.py +46 -46
  254. ccxt/yobit.py +20 -20
  255. ccxt/zaif.py +12 -12
  256. ccxt/zonda.py +22 -22
  257. {ccxt-4.3.29.dist-info → ccxt-4.3.31.dist-info}/METADATA +4 -4
  258. {ccxt-4.3.29.dist-info → ccxt-4.3.31.dist-info}/RECORD +260 -260
  259. {ccxt-4.3.29.dist-info → ccxt-4.3.31.dist-info}/WHEEL +0 -0
  260. {ccxt-4.3.29.dist-info → ccxt-4.3.31.dist-info}/top_level.txt +0 -0
@@ -6,7 +6,7 @@
6
6
  from ccxt.async_support.base.exchange import Exchange
7
7
  from ccxt.abstract.coinex import ImplicitAPI
8
8
  import asyncio
9
- from ccxt.base.types import Balances, Currencies, Currency, Int, IsolatedBorrowRate, IsolatedBorrowRates, Leverage, Leverages, MarginModification, Market, Num, Order, OrderRequest, OrderSide, OrderType, Position, Str, Strings, Ticker, Tickers, Trade, TradingFeeInterface, TradingFees, Transaction, TransferEntry, TransferEntries
9
+ from ccxt.base.types import Balances, Currencies, Currency, Int, IsolatedBorrowRate, Leverage, Leverages, LeverageTier, LeverageTiers, MarginModification, Market, Num, Order, OrderRequest, OrderSide, OrderType, Position, Str, Strings, Ticker, Tickers, Trade, TradingFeeInterface, TradingFees, Transaction, TransferEntry, TransferEntries
10
10
  from typing import List
11
11
  from ccxt.base.errors import ExchangeError
12
12
  from ccxt.base.errors import AuthenticationError
@@ -82,15 +82,15 @@ class coinex(Exchange, ImplicitAPI):
82
82
  'fetchDepositAddressByNetwork': False,
83
83
  'fetchDepositAddresses': False,
84
84
  'fetchDeposits': True,
85
- 'fetchDepositWithdrawFee': 'emulated',
86
- 'fetchDepositWithdrawFees': True,
85
+ 'fetchDepositWithdrawFee': True,
86
+ 'fetchDepositWithdrawFees': False,
87
87
  'fetchFundingHistory': True,
88
88
  'fetchFundingRate': True,
89
89
  'fetchFundingRateHistory': True,
90
90
  'fetchFundingRates': True,
91
91
  'fetchIndexOHLCV': False,
92
92
  'fetchIsolatedBorrowRate': True,
93
- 'fetchIsolatedBorrowRates': True,
93
+ 'fetchIsolatedBorrowRates': False,
94
94
  'fetchLeverage': 'emulated',
95
95
  'fetchLeverages': True,
96
96
  'fetchLeverageTiers': True,
@@ -567,7 +567,7 @@ class coinex(Exchange, ImplicitAPI):
567
567
  #
568
568
  data = self.safe_value(response, 'data', [])
569
569
  coins = list(data.keys())
570
- result = {}
570
+ result: dict = {}
571
571
  for i in range(0, len(coins)):
572
572
  coin = coins[i]
573
573
  currency = data[coin]
@@ -628,7 +628,7 @@ class coinex(Exchange, ImplicitAPI):
628
628
  if precisionString is not None:
629
629
  minPrecisionString = precisionString if (minPrecisionString is None) else Precise.string_min(precisionString, minPrecisionString)
630
630
  networks = self.safe_value(result[code], 'networks', {})
631
- network = {
631
+ network: dict = {
632
632
  'info': currency,
633
633
  'id': networkId,
634
634
  'network': networkId,
@@ -936,7 +936,7 @@ class coinex(Exchange, ImplicitAPI):
936
936
  """
937
937
  await self.load_markets()
938
938
  market = self.market(symbol)
939
- request = {
939
+ request: dict = {
940
940
  'market': market['id'],
941
941
  }
942
942
  response = None
@@ -1100,7 +1100,7 @@ class coinex(Exchange, ImplicitAPI):
1100
1100
  market = self.market(symbol)
1101
1101
  if limit is None:
1102
1102
  limit = 20 # default
1103
- request = {
1103
+ request: dict = {
1104
1104
  'market': market['id'],
1105
1105
  'limit': limit,
1106
1106
  'interval': '0',
@@ -1165,7 +1165,7 @@ class coinex(Exchange, ImplicitAPI):
1165
1165
  timestamp = self.safe_integer(depth, 'updated_at')
1166
1166
  return self.parse_order_book(depth, symbol, timestamp)
1167
1167
 
1168
- def parse_trade(self, trade, market: Market = None) -> Trade:
1168
+ def parse_trade(self, trade: dict, market: Market = None) -> Trade:
1169
1169
  #
1170
1170
  # Spot and Swap fetchTrades(public)
1171
1171
  #
@@ -1237,7 +1237,7 @@ class coinex(Exchange, ImplicitAPI):
1237
1237
  """
1238
1238
  await self.load_markets()
1239
1239
  market = self.market(symbol)
1240
- request = {
1240
+ request: dict = {
1241
1241
  'market': market['id'],
1242
1242
  # 'last_id': 0,
1243
1243
  }
@@ -1278,7 +1278,7 @@ class coinex(Exchange, ImplicitAPI):
1278
1278
  """
1279
1279
  await self.load_markets()
1280
1280
  market = self.market(symbol)
1281
- request = {
1281
+ request: dict = {
1282
1282
  'market': market['id'],
1283
1283
  }
1284
1284
  response = None
@@ -1389,7 +1389,7 @@ class coinex(Exchange, ImplicitAPI):
1389
1389
  # }
1390
1390
  #
1391
1391
  data = self.safe_list(response, 'data', [])
1392
- result = {}
1392
+ result: dict = {}
1393
1393
  for i in range(0, len(data)):
1394
1394
  entry = data[i]
1395
1395
  marketId = self.safe_string(entry, 'market')
@@ -1398,7 +1398,7 @@ class coinex(Exchange, ImplicitAPI):
1398
1398
  result[symbol] = self.parse_trading_fee(entry, market)
1399
1399
  return result
1400
1400
 
1401
- def parse_trading_fee(self, fee, market: Market = None) -> TradingFeeInterface:
1401
+ def parse_trading_fee(self, fee: dict, market: Market = None) -> TradingFeeInterface:
1402
1402
  marketId = self.safe_value(fee, 'market')
1403
1403
  symbol = self.safe_symbol(marketId, market)
1404
1404
  return {
@@ -1446,7 +1446,7 @@ class coinex(Exchange, ImplicitAPI):
1446
1446
  """
1447
1447
  await self.load_markets()
1448
1448
  market = self.market(symbol)
1449
- request = {
1449
+ request: dict = {
1450
1450
  'market': market['id'],
1451
1451
  'period': self.safe_string(self.timeframes, timeframe, timeframe),
1452
1452
  }
@@ -1514,7 +1514,7 @@ class coinex(Exchange, ImplicitAPI):
1514
1514
  # "message": "OK"
1515
1515
  # }
1516
1516
  #
1517
- result = {'info': response}
1517
+ result: dict = {'info': response}
1518
1518
  balances = self.safe_list(response, 'data', [])
1519
1519
  for i in range(0, len(balances)):
1520
1520
  entry = balances[i]
@@ -1549,7 +1549,7 @@ class coinex(Exchange, ImplicitAPI):
1549
1549
  # "message": "OK"
1550
1550
  # }
1551
1551
  #
1552
- result = {'info': response}
1552
+ result: dict = {'info': response}
1553
1553
  balances = self.safe_list(response, 'data', [])
1554
1554
  for i in range(0, len(balances)):
1555
1555
  entry = balances[i]
@@ -1580,7 +1580,7 @@ class coinex(Exchange, ImplicitAPI):
1580
1580
  # "message": "OK"
1581
1581
  # }
1582
1582
  #
1583
- result = {'info': response}
1583
+ result: dict = {'info': response}
1584
1584
  balances = self.safe_list(response, 'data', [])
1585
1585
  for i in range(0, len(balances)):
1586
1586
  entry = balances[i]
@@ -1608,7 +1608,7 @@ class coinex(Exchange, ImplicitAPI):
1608
1608
  # "message": "OK"
1609
1609
  # }
1610
1610
  #
1611
- result = {'info': response}
1611
+ result: dict = {'info': response}
1612
1612
  balances = self.safe_list(response, 'data', [])
1613
1613
  for i in range(0, len(balances)):
1614
1614
  entry = balances[i]
@@ -1646,8 +1646,8 @@ class coinex(Exchange, ImplicitAPI):
1646
1646
  else:
1647
1647
  return await self.fetch_spot_balance(params)
1648
1648
 
1649
- def parse_order_status(self, status):
1650
- statuses = {
1649
+ def parse_order_status(self, status: Str):
1650
+ statuses: dict = {
1651
1651
  'rejected': 'rejected',
1652
1652
  'open': 'open',
1653
1653
  'not_deal': 'open',
@@ -1657,7 +1657,7 @@ class coinex(Exchange, ImplicitAPI):
1657
1657
  }
1658
1658
  return self.safe_string(statuses, status, status)
1659
1659
 
1660
- def parse_order(self, order, market: Market = None) -> Order:
1660
+ def parse_order(self, order: dict, market: Market = None) -> Order:
1661
1661
  #
1662
1662
  # Spot and Margin createOrder, createOrders, editOrder, cancelOrders, cancelOrder, fetchOpenOrders
1663
1663
  #
@@ -1952,7 +1952,7 @@ class coinex(Exchange, ImplicitAPI):
1952
1952
  if reduceOnly:
1953
1953
  if not market['swap']:
1954
1954
  raise InvalidOrder(self.id + ' createOrder() does not support reduceOnly for ' + market['type'] + ' orders, reduceOnly orders are supported for swap markets only')
1955
- request = {
1955
+ request: dict = {
1956
1956
  'market': market['id'],
1957
1957
  }
1958
1958
  if clientOrderId is None:
@@ -2298,7 +2298,7 @@ class coinex(Exchange, ImplicitAPI):
2298
2298
  orderRequest = self.create_order_request(marketId, type, side, amount, price, orderParams)
2299
2299
  ordersRequests.append(orderRequest)
2300
2300
  market = self.market(symbol)
2301
- request = {
2301
+ request: dict = {
2302
2302
  'market': market['id'],
2303
2303
  'orders': ordersRequests,
2304
2304
  }
@@ -2457,7 +2457,7 @@ class coinex(Exchange, ImplicitAPI):
2457
2457
  raise ArgumentsRequired(self.id + ' cancelOrders() requires a symbol argument')
2458
2458
  await self.load_markets()
2459
2459
  market = self.market(symbol)
2460
- request = {
2460
+ request: dict = {
2461
2461
  'market': market['id'],
2462
2462
  }
2463
2463
  stop = self.safe_bool_2(params, 'stop', 'trigger')
@@ -2632,7 +2632,7 @@ class coinex(Exchange, ImplicitAPI):
2632
2632
  raise ArgumentsRequired(self.id + ' editOrder() requires a symbol argument')
2633
2633
  await self.load_markets()
2634
2634
  market = self.market(symbol)
2635
- request = {
2635
+ request: dict = {
2636
2636
  'market': market['id'],
2637
2637
  }
2638
2638
  if amount is not None:
@@ -2768,7 +2768,7 @@ class coinex(Exchange, ImplicitAPI):
2768
2768
  market = self.market(symbol)
2769
2769
  isTriggerOrder = self.safe_bool_2(params, 'stop', 'trigger')
2770
2770
  swap = market['swap']
2771
- request = {
2771
+ request: dict = {
2772
2772
  'market': market['id'],
2773
2773
  }
2774
2774
  marginMode = None
@@ -3039,7 +3039,7 @@ class coinex(Exchange, ImplicitAPI):
3039
3039
  raise ArgumentsRequired(self.id + ' cancelAllOrders() requires a symbol argument')
3040
3040
  await self.load_markets()
3041
3041
  market = self.market(symbol)
3042
- request = {
3042
+ request: dict = {
3043
3043
  'market': market['id'],
3044
3044
  }
3045
3045
  response = None
@@ -3075,7 +3075,7 @@ class coinex(Exchange, ImplicitAPI):
3075
3075
  raise ArgumentsRequired(self.id + ' fetchOrder() requires a symbol argument')
3076
3076
  await self.load_markets()
3077
3077
  market = self.market(symbol)
3078
- request = {
3078
+ request: dict = {
3079
3079
  'market': market['id'],
3080
3080
  'order_id': self.parse_to_numeric(id),
3081
3081
  }
@@ -3161,7 +3161,7 @@ class coinex(Exchange, ImplicitAPI):
3161
3161
  :returns Order[]: a list of `order structures <https://docs.ccxt.com/#/?id=order-structure>`
3162
3162
  """
3163
3163
  await self.load_markets()
3164
- request = {}
3164
+ request: dict = {}
3165
3165
  market = None
3166
3166
  if symbol is not None:
3167
3167
  market = self.market(symbol)
@@ -3497,7 +3497,7 @@ class coinex(Exchange, ImplicitAPI):
3497
3497
  if network is None:
3498
3498
  raise ArgumentsRequired(self.id + ' createDepositAddress() requires a network parameter')
3499
3499
  params = self.omit(params, 'network')
3500
- request = {
3500
+ request: dict = {
3501
3501
  'ccy': currency['id'],
3502
3502
  'chain': self.network_code_to_id(network, currency['code']),
3503
3503
  }
@@ -3536,7 +3536,7 @@ class coinex(Exchange, ImplicitAPI):
3536
3536
  raise ArgumentsRequired(self.id + ' fetchDepositAddress() ' + code + ' requires a network parameter')
3537
3537
  if not (network in networks):
3538
3538
  raise ExchangeError(self.id + ' fetchDepositAddress() ' + network + ' network not supported for ' + code)
3539
- request = {
3539
+ request: dict = {
3540
3540
  'ccy': currency['id'],
3541
3541
  'chain': network,
3542
3542
  }
@@ -3616,7 +3616,7 @@ class coinex(Exchange, ImplicitAPI):
3616
3616
  raise ArgumentsRequired(self.id + ' fetchMyTrades() requires a symbol argument')
3617
3617
  await self.load_markets()
3618
3618
  market = self.market(symbol)
3619
- request = {
3619
+ request: dict = {
3620
3620
  'market': market['id'],
3621
3621
  }
3622
3622
  if limit is not None:
@@ -3694,7 +3694,7 @@ class coinex(Exchange, ImplicitAPI):
3694
3694
  defaultMethod = None
3695
3695
  defaultMethod, params = self.handle_option_and_params(params, 'fetchPositions', 'method', 'v2PrivateGetFuturesPendingPosition')
3696
3696
  symbols = self.market_symbols(symbols)
3697
- request = {
3697
+ request: dict = {
3698
3698
  'market_type': 'FUTURES',
3699
3699
  }
3700
3700
  market = None
@@ -3773,7 +3773,7 @@ class coinex(Exchange, ImplicitAPI):
3773
3773
  """
3774
3774
  await self.load_markets()
3775
3775
  market = self.market(symbol)
3776
- request = {
3776
+ request: dict = {
3777
3777
  'market_type': 'FUTURES',
3778
3778
  'market': market['id'],
3779
3779
  }
@@ -3824,7 +3824,7 @@ class coinex(Exchange, ImplicitAPI):
3824
3824
  data = self.safe_list(response, 'data', [])
3825
3825
  return self.parse_position(data[0], market)
3826
3826
 
3827
- def parse_position(self, position, market: Market = None):
3827
+ def parse_position(self, position: dict, market: Market = None):
3828
3828
  #
3829
3829
  # {
3830
3830
  # "position_id": 305891033,
@@ -3918,7 +3918,7 @@ class coinex(Exchange, ImplicitAPI):
3918
3918
  raise ArgumentsRequired(self.id + ' setMarginMode() requires a leverage parameter')
3919
3919
  if (leverage < 1) or (leverage > maxLeverage):
3920
3920
  raise BadRequest(self.id + ' setMarginMode() leverage should be between 1 and ' + str(maxLeverage) + ' for ' + symbol)
3921
- request = {
3921
+ request: dict = {
3922
3922
  'market': market['id'],
3923
3923
  'market_type': 'FUTURES',
3924
3924
  'margin_mode': marginMode,
@@ -3958,7 +3958,7 @@ class coinex(Exchange, ImplicitAPI):
3958
3958
  maxLeverage = self.safe_integer(market['limits']['leverage'], 'max', 100)
3959
3959
  if (leverage < minLeverage) or (leverage > maxLeverage):
3960
3960
  raise BadRequest(self.id + ' setLeverage() leverage should be between ' + str(minLeverage) + ' and ' + str(maxLeverage) + ' for ' + symbol)
3961
- request = {
3961
+ request: dict = {
3962
3962
  'market': market['id'],
3963
3963
  'market_type': 'FUTURES',
3964
3964
  'margin_mode': marginMode,
@@ -3976,7 +3976,7 @@ class coinex(Exchange, ImplicitAPI):
3976
3976
  # }
3977
3977
  #
3978
3978
 
3979
- async def fetch_leverage_tiers(self, symbols: Strings = None, params={}):
3979
+ async def fetch_leverage_tiers(self, symbols: Strings = None, params={}) -> LeverageTiers:
3980
3980
  """
3981
3981
  retrieve information on the maximum leverage, and maintenance margin for trades of varying trade sizes
3982
3982
  :see: https://docs.coinex.com/api/v2/futures/market/http/list-market-position-level
@@ -3985,7 +3985,7 @@ class coinex(Exchange, ImplicitAPI):
3985
3985
  :returns dict: a dictionary of `leverage tiers structures <https://docs.ccxt.com/#/?id=leverage-tiers-structure>`, indexed by market symbols
3986
3986
  """
3987
3987
  await self.load_markets()
3988
- request = {}
3988
+ request: dict = {}
3989
3989
  if symbols is not None:
3990
3990
  marketIds = self.market_ids(symbols)
3991
3991
  request['market'] = ','.join(marketIds)
@@ -4018,7 +4018,7 @@ class coinex(Exchange, ImplicitAPI):
4018
4018
  data = self.safe_list(response, 'data', [])
4019
4019
  return self.parse_leverage_tiers(data, symbols, 'market')
4020
4020
 
4021
- def parse_market_leverage_tiers(self, info, market: Market = None):
4021
+ def parse_market_leverage_tiers(self, info, market: Market = None) -> List[LeverageTier]:
4022
4022
  tiers = []
4023
4023
  brackets = self.safe_list(info, 'level', [])
4024
4024
  minNotional = 0
@@ -4046,7 +4046,7 @@ class coinex(Exchange, ImplicitAPI):
4046
4046
  requestAmount = rawAmount
4047
4047
  if addOrReduce == 'reduce':
4048
4048
  requestAmount = Precise.string_neg(rawAmount)
4049
- request = {
4049
+ request: dict = {
4050
4050
  'market': market['id'],
4051
4051
  'market_type': 'FUTURES',
4052
4052
  'amount': requestAmount,
@@ -4205,7 +4205,7 @@ class coinex(Exchange, ImplicitAPI):
4205
4205
  raise ArgumentsRequired(self.id + ' fetchFundingHistory() requires a symbol argument')
4206
4206
  await self.load_markets()
4207
4207
  market = self.market(symbol)
4208
- request = {
4208
+ request: dict = {
4209
4209
  'market': market['id'],
4210
4210
  'market_type': 'FUTURES',
4211
4211
  }
@@ -4266,7 +4266,7 @@ class coinex(Exchange, ImplicitAPI):
4266
4266
  market = self.market(symbol)
4267
4267
  if not market['swap']:
4268
4268
  raise BadSymbol(self.id + ' fetchFundingRate() supports swap contracts only')
4269
- request = {
4269
+ request: dict = {
4270
4270
  'market': market['id'],
4271
4271
  }
4272
4272
  response = await self.v2PublicGetFuturesFundingRate(self.extend(request, params))
@@ -4340,7 +4340,7 @@ class coinex(Exchange, ImplicitAPI):
4340
4340
  """
4341
4341
  await self.load_markets()
4342
4342
  symbols = self.market_symbols(symbols)
4343
- request = {}
4343
+ request: dict = {}
4344
4344
  market = None
4345
4345
  if symbols is not None:
4346
4346
  symbol = self.safe_value(symbols, 0)
@@ -4392,7 +4392,7 @@ class coinex(Exchange, ImplicitAPI):
4392
4392
  params = self.omit(params, 'network')
4393
4393
  if tag:
4394
4394
  address = address + ':' + tag
4395
- request = {
4395
+ request: dict = {
4396
4396
  'coin_type': currency['id'],
4397
4397
  'coin_address': address, # must be authorized, inter-user transfer by a registered mobile phone number or an email address is supported
4398
4398
  'actual_amount': float(self.number_to_string(amount)), # the actual amount without fees, https://www.coinex.com/fees
@@ -4423,7 +4423,7 @@ class coinex(Exchange, ImplicitAPI):
4423
4423
  return self.parse_transaction(transaction, currency)
4424
4424
 
4425
4425
  def parse_transaction_status(self, status):
4426
- statuses = {
4426
+ statuses: dict = {
4427
4427
  'audit': 'pending',
4428
4428
  'pass': 'pending',
4429
4429
  'processing': 'pending',
@@ -4455,7 +4455,7 @@ class coinex(Exchange, ImplicitAPI):
4455
4455
  if paginate:
4456
4456
  return await self.fetch_paginated_call_deterministic('fetchFundingRateHistory', symbol, since, limit, '8h', params, 1000)
4457
4457
  market = self.market(symbol)
4458
- request = {
4458
+ request: dict = {
4459
4459
  'market': market['id'],
4460
4460
  }
4461
4461
  if since is not None:
@@ -4498,111 +4498,102 @@ class coinex(Exchange, ImplicitAPI):
4498
4498
  sorted = self.sort_by(rates, 'timestamp')
4499
4499
  return self.filter_by_symbol_since_limit(sorted, market['symbol'], since, limit)
4500
4500
 
4501
- def parse_transaction(self, transaction, currency: Currency = None) -> Transaction:
4501
+ def parse_transaction(self, transaction: dict, currency: Currency = None) -> Transaction:
4502
4502
  #
4503
4503
  # fetchDeposits
4504
4504
  #
4505
- # {
4506
- # "coin_deposit_id": 32555985,
4507
- # "create_time": 1673325495,
4508
- # "amount": "12.71",
4509
- # "amount_display": "12.71",
4510
- # "diff_amount": "0",
4511
- # "min_amount": "0",
4512
- # "actual_amount": "12.71",
4513
- # "actual_amount_display": "12.71",
4514
- # "confirmations": 35,
4515
- # "tx_id": "0x57f1c92cc10b48316e2bf5faf230694fec2174e7744c1562a9a88b9c1e585f56",
4516
- # "tx_id_display": "0x57f1c92cc10b48316e2bf5faf230694fec2174e7744c1562a9a88b9c1e585f56",
4517
- # "coin_address": "0xe7a3831c56836f466b6a6268cff4fc852cf4b738",
4518
- # "coin_address_display": "0xe7a3****f4b738",
4519
- # "add_explorer": "https://bscscan.com/address/0xe7a3831c56836f466b6a6268cff4fc852cf4b738",
4520
- # "coin_type": "USDT",
4521
- # "smart_contract_name": "BSC",
4522
- # "transfer_method": "onchain",
4523
- # "status": "finish",
4524
- # "status_display": "finish",
4525
- # "remark": "",
4526
- # "explorer": "https://bscscan.com/tx/0x57f1c92cc10b48316e2bf5faf230694fec2174e7744c1562a9a88b9c1e585f56"
4527
- # }
4505
+ # {
4506
+ # "deposit_id": 5173806,
4507
+ # "created_at": 1714021652557,
4508
+ # "tx_id": "d9f47d2550397c635cb89a8963118f8fe78ef048bc8b6f0caaeaa7dc6",
4509
+ # "tx_id_display": "",
4510
+ # "ccy": "USDT",
4511
+ # "chain": "TRC20",
4512
+ # "deposit_method": "ON_CHAIN",
4513
+ # "amount": "30",
4514
+ # "actual_amount": "",
4515
+ # "to_address": "TYewD2pVWDUwfNr9A",
4516
+ # "confirmations": 20,
4517
+ # "status": "FINISHED",
4518
+ # "tx_explorer_url": "https://tronscan.org/#/transaction",
4519
+ # "to_addr_explorer_url": "https://tronscan.org/#/address",
4520
+ # "remark": ""
4521
+ # }
4528
4522
  #
4529
4523
  # fetchWithdrawals
4530
4524
  #
4531
- # {
4532
- # "coin_withdraw_id": 20076836,
4533
- # "create_time": 1673325776,
4534
- # "actual_amount": "0.029",
4535
- # "actual_amount_display": "0.029",
4536
- # "amount": "0.03",
4537
- # "amount_display": "0.03",
4538
- # "coin_address": "MBhJcc3r5b3insc7QxyvEPtf31NqUdJpAb",
4539
- # "app_coin_address_display": "MBh****pAb",
4540
- # "coin_address_display": "MBhJcc****UdJpAb",
4541
- # "add_explorer": "https://explorer.viawallet.com/ltc/address/MBhJcc3r5b3insc7QxyvEPtf31NqUdJpAb",
4542
- # "coin_type": "LTC",
4543
- # "confirmations": 7,
4544
- # "explorer": "https://explorer.viawallet.com/ltc/tx/a0aa082132619b8a499b87e7d5bc3c508e0227104f5202ae26b695bb4cb7fbf9",
4545
- # "fee": "0",
4546
- # "remark": "",
4547
- # "smart_contract_name": "",
4548
- # "status": "finish",
4549
- # "status_display": "finish",
4550
- # "transfer_method": "onchain",
4551
- # "tx_fee": "0.001",
4552
- # "tx_id": "a0aa082132619b8a499b87e7d5bc3c508e0227104f5202ae26b695bb4cb7fbf9"
4553
- # }
4554
- #
4555
- id = self.safe_string_2(transaction, 'coin_withdraw_id', 'coin_deposit_id')
4556
- address = self.safe_string(transaction, 'coin_address')
4557
- tag = self.safe_string(transaction, 'remark') # set but unused
4525
+ # {
4526
+ # "withdraw_id": 259364,
4527
+ # "created_at": 1701323541548,
4528
+ # "withdraw_method": "ON_CHAIN",
4529
+ # "ccy": "USDT",
4530
+ # "amount": "23.845744",
4531
+ # "actual_amount": "22.445744",
4532
+ # "chain": "TRC20",
4533
+ # "tx_fee": "1.4",
4534
+ # "fee_asset": "USDT",
4535
+ # "fee_amount": "1.4",
4536
+ # "to_address": "T8t5i2454dhdhnnnGdi49vMbihvY",
4537
+ # "memo": "",
4538
+ # "tx_id": "1237623941964de9954ed2e36640228d78765c1026",
4539
+ # "confirmations": 18,
4540
+ # "explorer_address_url": "https://tronscan.org/#/address",
4541
+ # "explorer_tx_url": "https://tronscan.org/#/transaction",
4542
+ # "remark": "",
4543
+ # "status": "finished"
4544
+ # }
4545
+ #
4546
+ address = self.safe_string(transaction, 'to_address')
4547
+ tag = self.safe_string(transaction, 'memo')
4558
4548
  if tag is not None:
4559
4549
  if len(tag) < 1:
4560
4550
  tag = None
4561
- txid = self.safe_value(transaction, 'tx_id')
4551
+ remark = self.safe_string(transaction, 'remark')
4552
+ if remark is not None:
4553
+ if len(remark) < 1:
4554
+ remark = None
4555
+ txid = self.safe_string(transaction, 'tx_id')
4562
4556
  if txid is not None:
4563
4557
  if len(txid) < 1:
4564
4558
  txid = None
4565
- currencyId = self.safe_string(transaction, 'coin_type')
4559
+ currencyId = self.safe_string(transaction, 'ccy')
4566
4560
  code = self.safe_currency_code(currencyId, currency)
4567
- timestamp = self.safe_timestamp(transaction, 'create_time')
4568
- type = 'withdrawal' if ('coin_withdraw_id' in transaction) else 'deposit'
4569
- status = self.parse_transaction_status(self.safe_string(transaction, 'status'))
4570
- networkId = self.safe_string(transaction, 'smart_contract_name')
4571
- amount = self.safe_number(transaction, 'actual_amount')
4561
+ timestamp = self.safe_integer(transaction, 'created_at')
4562
+ type = 'withdrawal' if ('withdraw_id' in transaction) else 'deposit'
4563
+ networkId = self.safe_string(transaction, 'chain')
4572
4564
  feeCost = self.safe_string(transaction, 'tx_fee')
4573
- transferMethod = self.safe_string(transaction, 'transfer_method')
4565
+ transferMethod = self.safe_string_lower_2(transaction, 'withdraw_method', 'deposit_method')
4574
4566
  internal = transferMethod == 'local'
4575
- addressTo = None
4576
- addressFrom = None
4567
+ amount = self.safe_number(transaction, 'actual_amount')
4568
+ if amount is None:
4569
+ amount = self.safe_number(transaction, 'amount')
4577
4570
  if type == 'deposit':
4578
4571
  feeCost = '0'
4579
- addressTo = address
4580
- else:
4581
- addressFrom = address
4572
+ feeCurrencyId = self.safe_string(transaction, 'fee_asset')
4582
4573
  fee = {
4583
4574
  'cost': self.parse_number(feeCost),
4584
- 'currency': code,
4575
+ 'currency': self.safe_currency_code(feeCurrencyId),
4585
4576
  }
4586
4577
  return {
4587
4578
  'info': transaction,
4588
- 'id': id,
4579
+ 'id': self.safe_string_2(transaction, 'withdraw_id', 'deposit_id'),
4589
4580
  'txid': txid,
4590
4581
  'timestamp': timestamp,
4591
4582
  'datetime': self.iso8601(timestamp),
4592
4583
  'network': self.network_id_to_code(networkId),
4593
4584
  'address': address,
4594
- 'addressTo': None,
4585
+ 'addressTo': address,
4595
4586
  'addressFrom': None,
4596
4587
  'tag': tag,
4597
- 'tagTo': addressTo,
4598
- 'tagFrom': addressFrom,
4588
+ 'tagTo': None,
4589
+ 'tagFrom': None,
4599
4590
  'type': type,
4600
- 'amount': self.parse_number(amount),
4591
+ 'amount': amount,
4601
4592
  'currency': code,
4602
- 'status': status,
4593
+ 'status': self.parse_transaction_status(self.safe_string(transaction, 'status')),
4603
4594
  'updated': None,
4604
4595
  'fee': fee,
4605
- 'comment': None,
4596
+ 'comment': remark,
4606
4597
  'internal': internal,
4607
4598
  }
4608
4599
 
@@ -4624,7 +4615,7 @@ class coinex(Exchange, ImplicitAPI):
4624
4615
  accountsByType = self.safe_dict(self.options, 'accountsById', {})
4625
4616
  fromId = self.safe_string(accountsByType, fromAccount, fromAccount)
4626
4617
  toId = self.safe_string(accountsByType, toAccount, toAccount)
4627
- request = {
4618
+ request: dict = {
4628
4619
  'ccy': currency['id'],
4629
4620
  'amount': amountToPrecision,
4630
4621
  'from_account_type': fromId,
@@ -4653,7 +4644,7 @@ class coinex(Exchange, ImplicitAPI):
4653
4644
  })
4654
4645
 
4655
4646
  def parse_transfer_status(self, status):
4656
- statuses = {
4647
+ statuses: dict = {
4657
4648
  '0': 'ok',
4658
4649
  'SUCCESS': 'ok',
4659
4650
  'OK': 'ok',
@@ -4694,7 +4685,7 @@ class coinex(Exchange, ImplicitAPI):
4694
4685
  if code is None:
4695
4686
  raise ArgumentsRequired(self.id + ' fetchTransfers() requires a code argument')
4696
4687
  currency = self.currency(code)
4697
- request = {
4688
+ request: dict = {
4698
4689
  'ccy': currency['id'],
4699
4690
  }
4700
4691
  marginMode = None
@@ -4735,154 +4726,135 @@ class coinex(Exchange, ImplicitAPI):
4735
4726
  async def fetch_withdrawals(self, code: Str = None, since: Int = None, limit: Int = None, params={}) -> List[Transaction]:
4736
4727
  """
4737
4728
  fetch all withdrawals made from an account
4738
- :see: https://viabtc.github.io/coinex_api_en_doc/spot/#docsspot002_account026_withdraw_list
4739
- :param str code: unified currency code
4729
+ :see: https://docs.coinex.com/api/v2/assets/deposit-withdrawal/http/list-withdrawal-history
4730
+ :param str [code]: unified currency code
4740
4731
  :param int [since]: the earliest time in ms to fetch withdrawals for
4741
- :param int [limit]: the maximum number of withdrawals structures to retrieve
4732
+ :param int [limit]: the maximum number of withdrawal structures to retrieve
4742
4733
  :param dict [params]: extra parameters specific to the exchange API endpoint
4743
4734
  :returns dict[]: a list of `transaction structures <https://docs.ccxt.com/#/?id=transaction-structure>`
4744
4735
  """
4745
- request = {}
4736
+ await self.load_markets()
4737
+ request: dict = {}
4746
4738
  currency = None
4747
4739
  if code is not None:
4748
- await self.load_markets()
4749
4740
  currency = self.currency(code)
4750
- request['coin_type'] = currency['id']
4741
+ request['ccy'] = currency['id']
4751
4742
  if limit is not None:
4752
- request['Limit'] = limit
4753
- response = await self.v1PrivateGetBalanceCoinWithdraw(self.extend(request, params))
4754
- #
4755
- # {
4756
- # "code": 0,
4757
- # "data": {
4758
- # "has_next": False,
4759
- # "curr_page": 1,
4760
- # "count": 1,
4761
- # "data": [
4762
- # {
4763
- # "coin_withdraw_id": 20076836,
4764
- # "create_time": 1673325776,
4765
- # "actual_amount": "0.029",
4766
- # "actual_amount_display": "0.029",
4767
- # "amount": "0.03",
4768
- # "amount_display": "0.03",
4769
- # "coin_address": "MBhJcc3r5b3insc7QxyvEPtf31NqUdJpAb",
4770
- # "app_coin_address_display": "MBh****pAb",
4771
- # "coin_address_display": "MBhJcc****UdJpAb",
4772
- # "add_explorer": "https://explorer.viawallet.com/ltc/address/MBhJcc3r5b3insc7QxyvEPtf31NqUdJpAb",
4773
- # "coin_type": "LTC",
4774
- # "confirmations": 7,
4775
- # "explorer": "https://explorer.viawallet.com/ltc/tx/a0aa082132619b8a499b87e7d5bc3c508e0227104f5202ae26b695bb4cb7fbf9",
4776
- # "fee": "0",
4777
- # "remark": "",
4778
- # "smart_contract_name": "",
4779
- # "status": "finish",
4780
- # "status_display": "finish",
4781
- # "transfer_method": "onchain",
4782
- # "tx_fee": "0.001",
4783
- # "tx_id": "a0aa082132619b8a499b87e7d5bc3c508e0227104f5202ae26b695bb4cb7fbf9"
4784
- # }
4785
- # ],
4786
- # "total": 1,
4787
- # "total_page": 1
4788
- # },
4789
- # "message": "Success"
4790
- # }
4743
+ request['limit'] = limit
4744
+ response = await self.v2PrivateGetAssetsWithdraw(self.extend(request, params))
4791
4745
  #
4792
- data = self.safe_value(response, 'data')
4793
- if not isinstance(data, list):
4794
- data = self.safe_value(data, 'data', [])
4746
+ # {
4747
+ # "data": [
4748
+ # {
4749
+ # "withdraw_id": 259364,
4750
+ # "created_at": 1701323541548,
4751
+ # "withdraw_method": "ON_CHAIN",
4752
+ # "ccy": "USDT",
4753
+ # "amount": "23.845744",
4754
+ # "actual_amount": "22.445744",
4755
+ # "chain": "TRC20",
4756
+ # "tx_fee": "1.4",
4757
+ # "fee_asset": "USDT",
4758
+ # "fee_amount": "1.4",
4759
+ # "to_address": "T8t5i2454dhdhnnnGdi49vMbihvY",
4760
+ # "memo": "",
4761
+ # "tx_id": "1237623941964de9954ed2e36640228d78765c1026",
4762
+ # "confirmations": 18,
4763
+ # "explorer_address_url": "https://tronscan.org/#/address",
4764
+ # "explorer_tx_url": "https://tronscan.org/#/transaction",
4765
+ # "remark": "",
4766
+ # "status": "finished"
4767
+ # },
4768
+ # ],
4769
+ # "pagination": {
4770
+ # "total": 9,
4771
+ # "has_next": True
4772
+ # },
4773
+ # "code": 0,
4774
+ # "message": "OK"
4775
+ # }
4776
+ #
4777
+ data = self.safe_list(response, 'data', [])
4795
4778
  return self.parse_transactions(data, currency, since, limit)
4796
4779
 
4797
4780
  async def fetch_deposits(self, code: Str = None, since: Int = None, limit: Int = None, params={}) -> List[Transaction]:
4798
4781
  """
4799
4782
  fetch all deposits made to an account
4800
- :see: https://viabtc.github.io/coinex_api_en_doc/spot/#docsspot002_account009_deposit_list
4801
- :param str code: unified currency code
4783
+ :see: https://docs.coinex.com/api/v2/assets/deposit-withdrawal/http/list-deposit-history
4784
+ :param str [code]: unified currency code
4802
4785
  :param int [since]: the earliest time in ms to fetch deposits for
4803
- :param int [limit]: the maximum number of deposits structures to retrieve
4786
+ :param int [limit]: the maximum number of deposit structures to retrieve
4804
4787
  :param dict [params]: extra parameters specific to the exchange API endpoint
4805
4788
  :returns dict[]: a list of `transaction structures <https://docs.ccxt.com/#/?id=transaction-structure>`
4806
4789
  """
4807
- request = {}
4790
+ await self.load_markets()
4791
+ request: dict = {}
4808
4792
  currency = None
4809
4793
  if code is not None:
4810
- await self.load_markets()
4811
4794
  currency = self.currency(code)
4812
- request['coin_type'] = currency['id']
4795
+ request['ccy'] = currency['id']
4813
4796
  if limit is not None:
4814
- request['Limit'] = limit
4815
- response = await self.v1PrivateGetBalanceCoinDeposit(self.extend(request, params))
4816
- #
4817
- # {
4818
- # "code": 0,
4819
- # "data": {
4820
- # "has_next": False,
4821
- # "curr_page": 1,
4822
- # "count": 1,
4823
- # "data": [
4824
- # {
4825
- # "coin_deposit_id": 32555985,
4826
- # "create_time": 1673325495,
4827
- # "amount": "12.71",
4828
- # "amount_display": "12.71",
4829
- # "diff_amount": "0",
4830
- # "min_amount": "0",
4831
- # "actual_amount": "12.71",
4832
- # "actual_amount_display": "12.71",
4833
- # "confirmations": 35,
4834
- # "tx_id": "0x57f1c92cc10b48316e2bf5faf230694fec2174e7744c1562a9a88b9c1e585f56",
4835
- # "tx_id_display": "0x57f1c92cc10b48316e2bf5faf230694fec2174e7744c1562a9a88b9c1e585f56",
4836
- # "coin_address": "0xe7a3831c56836f466b6a6268cff4fc852cf4b738",
4837
- # "coin_address_display": "0xe7a3****f4b738",
4838
- # "add_explorer": "https://bscscan.com/address/0xe7a3831c56836f466b6a6268cff4fc852cf4b738",
4839
- # "coin_type": "USDT",
4840
- # "smart_contract_name": "BSC",
4841
- # "transfer_method": "onchain",
4842
- # "status": "finish",
4843
- # "status_display": "finish",
4844
- # "remark": "",
4845
- # "explorer": "https://bscscan.com/tx/0x57f1c92cc10b48316e2bf5faf230694fec2174e7744c1562a9a88b9c1e585f56"
4846
- # }
4847
- # ],
4848
- # "total": 1,
4849
- # "total_page": 1
4850
- # },
4851
- # "message": "Success"
4852
- # }
4797
+ request['limit'] = limit
4798
+ response = await self.v2PrivateGetAssetsDepositHistory(self.extend(request, params))
4853
4799
  #
4854
- data = self.safe_value(response, 'data')
4855
- if not isinstance(data, list):
4856
- data = self.safe_value(data, 'data', [])
4800
+ # {
4801
+ # "data": [
4802
+ # {
4803
+ # "deposit_id": 5173806,
4804
+ # "created_at": 1714021652557,
4805
+ # "tx_id": "d9f47d2550397c635cb89a8963118f8fe78ef048bc8b6f0caaeaa7dc6",
4806
+ # "tx_id_display": "",
4807
+ # "ccy": "USDT",
4808
+ # "chain": "TRC20",
4809
+ # "deposit_method": "ON_CHAIN",
4810
+ # "amount": "30",
4811
+ # "actual_amount": "",
4812
+ # "to_address": "TYewD2pVWDUwfNr9A",
4813
+ # "confirmations": 20,
4814
+ # "status": "FINISHED",
4815
+ # "tx_explorer_url": "https://tronscan.org/#/transaction",
4816
+ # "to_addr_explorer_url": "https://tronscan.org/#/address",
4817
+ # "remark": ""
4818
+ # },
4819
+ # ],
4820
+ # "paginatation": {
4821
+ # "total": 8,
4822
+ # "has_next": True
4823
+ # },
4824
+ # "code": 0,
4825
+ # "message": "OK"
4826
+ # }
4827
+ #
4828
+ data = self.safe_list(response, 'data', [])
4857
4829
  return self.parse_transactions(data, currency, since, limit)
4858
4830
 
4859
4831
  def parse_isolated_borrow_rate(self, info, market: Market = None) -> IsolatedBorrowRate:
4860
4832
  #
4861
4833
  # {
4862
4834
  # "market": "BTCUSDT",
4835
+ # "ccy": "USDT",
4863
4836
  # "leverage": 10,
4864
- # "BTC": {
4865
- # "min_amount": "0.002",
4866
- # "max_amount": "200",
4867
- # "day_rate": "0.001"
4868
- # },
4869
- # "USDT": {
4870
- # "min_amount": "60",
4871
- # "max_amount": "5000000",
4872
- # "day_rate": "0.001"
4873
- # }
4874
- # },
4837
+ # "min_amount": "60",
4838
+ # "max_amount": "500000",
4839
+ # "daily_interest_rate": "0.001"
4840
+ # }
4875
4841
  #
4876
4842
  marketId = self.safe_string(info, 'market')
4877
4843
  market = self.safe_market(marketId, market, None, 'spot')
4878
- baseInfo = self.safe_value(info, market['baseId'])
4879
- quoteInfo = self.safe_value(info, market['quoteId'])
4844
+ currency = self.safe_string(info, 'ccy')
4845
+ rate = self.safe_number(info, 'daily_interest_rate')
4846
+ baseRate = None
4847
+ quoteRate = None
4848
+ if currency == market['baseId']:
4849
+ baseRate = rate
4850
+ elif currency == market['quoteId']:
4851
+ quoteRate = rate
4880
4852
  return {
4881
4853
  'symbol': market['symbol'],
4882
4854
  'base': market['base'],
4883
- 'baseRate': self.safe_number(baseInfo, 'day_rate'),
4855
+ 'baseRate': baseRate,
4884
4856
  'quote': market['quote'],
4885
- 'quoteRate': self.safe_number(quoteInfo, 'day_rate'),
4857
+ 'quoteRate': quoteRate,
4886
4858
  'period': 86400000,
4887
4859
  'timestamp': None,
4888
4860
  'datetime': None,
@@ -4892,153 +4864,116 @@ class coinex(Exchange, ImplicitAPI):
4892
4864
  async def fetch_isolated_borrow_rate(self, symbol: str, params={}) -> IsolatedBorrowRate:
4893
4865
  """
4894
4866
  fetch the rate of interest to borrow a currency for margin trading
4895
- :see: https://viabtc.github.io/coinex_api_en_doc/spot/#docsspot002_account007_margin_account_settings
4867
+ :see: https://docs.coinex.com/api/v2/assets/loan-flat/http/list-margin-interest-limit
4896
4868
  :param str symbol: unified symbol of the market to fetch the borrow rate for
4897
4869
  :param dict [params]: extra parameters specific to the exchange API endpoint
4870
+ :param str params['code']: unified currency code
4898
4871
  :returns dict: an `isolated borrow rate structure <https://docs.ccxt.com/#/?id=isolated-borrow-rate-structure>`
4899
4872
  """
4900
4873
  await self.load_markets()
4874
+ code = self.safe_string(params, 'code')
4875
+ if code is None:
4876
+ raise ArgumentsRequired(self.id + ' fetchIsolatedBorrowRate() requires a code parameter')
4877
+ params = self.omit(params, 'code')
4878
+ currency = self.currency(code)
4901
4879
  market = self.market(symbol)
4902
- request = {
4880
+ request: dict = {
4903
4881
  'market': market['id'],
4882
+ 'ccy': currency['id'],
4904
4883
  }
4905
- response = await self.v1PrivateGetMarginConfig(self.extend(request, params))
4884
+ response = await self.v2PrivateGetAssetsMarginInterestLimit(self.extend(request, params))
4906
4885
  #
4907
4886
  # {
4908
4887
  # "code": 0,
4909
4888
  # "data": {
4910
4889
  # "market": "BTCUSDT",
4890
+ # "ccy": "USDT",
4911
4891
  # "leverage": 10,
4912
- # "BTC": {
4913
- # "min_amount": "0.002",
4914
- # "max_amount": "200",
4915
- # "day_rate": "0.001"
4916
- # },
4917
- # "USDT": {
4918
- # "min_amount": "60",
4919
- # "max_amount": "5000000",
4920
- # "day_rate": "0.001"
4921
- # }
4892
+ # "min_amount": "60",
4893
+ # "max_amount": "500000",
4894
+ # "daily_interest_rate": "0.001"
4922
4895
  # },
4923
- # "message": "Success"
4896
+ # "message": "OK"
4924
4897
  # }
4925
4898
  #
4926
- data = self.safe_value(response, 'data', {})
4899
+ data = self.safe_dict(response, 'data', {})
4927
4900
  return self.parse_isolated_borrow_rate(data, market)
4928
4901
 
4929
- async def fetch_isolated_borrow_rates(self, params={}) -> IsolatedBorrowRates:
4902
+ async def fetch_borrow_interest(self, code: Str = None, symbol: Str = None, since: Int = None, limit: Int = None, params={}):
4930
4903
  """
4931
- fetch the borrow interest rates of all currencies
4932
- :see: https://viabtc.github.io/coinex_api_en_doc/spot/#docsspot002_account007_margin_account_settings
4904
+ fetch the interest owed by the user for borrowing currency for margin trading
4905
+ :see: https://docs.coinex.com/api/v2/assets/loan-flat/http/list-margin-borrow-history
4906
+ :param str [code]: unified currency code
4907
+ :param str [symbol]: unified market symbol when fetch interest in isolated markets
4908
+ :param int [since]: the earliest time in ms to fetch borrrow interest for
4909
+ :param int [limit]: the maximum number of structures to retrieve
4933
4910
  :param dict [params]: extra parameters specific to the exchange API endpoint
4934
- :returns dict: a list of `isolated borrow rate structures <https://github.com/ccxt/ccxt/wiki/Manual#isolated-borrow-rate-structure>`
4911
+ :returns dict[]: a list of `borrow interest structures <https://docs.ccxt.com/#/?id=borrow-interest-structure>`
4935
4912
  """
4936
4913
  await self.load_markets()
4937
- response = await self.v1PrivateGetMarginConfig(params)
4938
- #
4939
- # {
4940
- # "code": 0,
4941
- # "data": [
4942
- # {
4943
- # "market": "BTCUSDT",
4944
- # "leverage": 10,
4945
- # "BTC": {
4946
- # "min_amount": "0.002",
4947
- # "max_amount": "200",
4948
- # "day_rate": "0.001"
4949
- # },
4950
- # "USDT": {
4951
- # "min_amount": "60",
4952
- # "max_amount": "5000000",
4953
- # "day_rate": "0.001"
4954
- # }
4955
- # },
4956
- # ],
4957
- # "message": "Success"
4958
- # }
4959
- #
4960
- data = self.safe_value(response, 'data', [])
4961
- return self.parse_isolated_borrow_rates(data)
4962
-
4963
- async def fetch_borrow_interest(self, code: Str = None, symbol: Str = None, since: Int = None, limit: Int = None, params={}):
4964
- await self.load_markets()
4965
- request = {}
4914
+ request: dict = {}
4966
4915
  market = None
4967
4916
  if symbol is not None:
4968
4917
  market = self.market(symbol)
4969
4918
  request['market'] = market['id']
4970
4919
  if limit is not None:
4971
4920
  request['limit'] = limit
4972
- response = await self.v1PrivateGetMarginLoanHistory(self.extend(request, params))
4921
+ response = await self.v2PrivateGetAssetsMarginBorrowHistory(self.extend(request, params))
4973
4922
  #
4974
4923
  # {
4975
- # "code": 0,
4976
- # "data": {
4977
- # "page": 1,
4978
- # "limit": 10,
4979
- # "total": 1,
4980
- # "has_next": False,
4981
- # "curr_page": 1,
4982
- # "count": 1,
4983
- # "data": [
4984
- # {
4985
- # "loan_id": 2616357,
4986
- # "create_time": 1654214027,
4987
- # "market_type": "BTCUSDT",
4988
- # "coin_type": "BTC",
4989
- # "day_rate": "0.001",
4990
- # "loan_amount": "0.0144",
4991
- # "interest_amount": "0",
4992
- # "unflat_amount": "0",
4993
- # "expire_time": 1655078027,
4994
- # "is_renew": True,
4995
- # "status": "finish"
4996
- # }
4997
- # ],
4998
- # "total_page": 1
4924
+ # "data": [
4925
+ # {
4926
+ # "borrow_id": 2642934,
4927
+ # "created_at": 1654761016000,
4928
+ # "market": "BTCUSDT",
4929
+ # "ccy": "USDT",
4930
+ # "daily_interest_rate": "0.001",
4931
+ # "expired_at": 1655625016000,
4932
+ # "borrow_amount": "100",
4933
+ # "to_repaied_amount": "0",
4934
+ # "is_auto_renew": False,
4935
+ # "status": "finish"
4936
+ # },
4937
+ # ],
4938
+ # "pagination": {
4939
+ # "total": 4,
4940
+ # "has_next": True
4999
4941
  # },
5000
- # "message": "Success"
4942
+ # "code": 0,
4943
+ # "message": "OK"
5001
4944
  # }
5002
4945
  #
5003
- data = self.safe_value(response, 'data', {})
5004
- rows = self.safe_value(data, 'data', [])
4946
+ rows = self.safe_value(response, 'data', [])
5005
4947
  interest = self.parse_borrow_interests(rows, market)
5006
4948
  return self.filter_by_currency_since_limit(interest, code, since, limit)
5007
4949
 
5008
- def parse_borrow_interest(self, info, market: Market = None):
4950
+ def parse_borrow_interest(self, info: dict, market: Market = None):
5009
4951
  #
5010
4952
  # {
5011
- # "loan_id": 2616357,
5012
- # "create_time": 1654214027,
5013
- # "market_type": "BTCUSDT",
5014
- # "coin_type": "BTC",
5015
- # "day_rate": "0.001",
5016
- # "loan_amount": "0.0144",
5017
- # "interest_amount": "0",
5018
- # "unflat_amount": "0",
5019
- # "expire_time": 1655078027,
5020
- # "is_renew": True,
4953
+ # "borrow_id": 2642934,
4954
+ # "created_at": 1654761016000,
4955
+ # "market": "BTCUSDT",
4956
+ # "ccy": "USDT",
4957
+ # "daily_interest_rate": "0.001",
4958
+ # "expired_at": 1655625016000,
4959
+ # "borrow_amount": "100",
4960
+ # "to_repaied_amount": "0",
4961
+ # "is_auto_renew": False,
5021
4962
  # "status": "finish"
5022
4963
  # }
5023
4964
  #
5024
- marketId = self.safe_string(info, 'market_type')
4965
+ marketId = self.safe_string(info, 'market')
5025
4966
  market = self.safe_market(marketId, market, None, 'spot')
5026
- symbol = self.safe_string(market, 'symbol')
5027
- timestamp = self.safe_timestamp(info, 'expire_time')
5028
- unflatAmount = self.safe_string(info, 'unflat_amount')
5029
- loanAmount = self.safe_string(info, 'loan_amount')
5030
- interest = Precise.string_sub(unflatAmount, loanAmount)
5031
- if unflatAmount == '0':
5032
- interest = None
4967
+ timestamp = self.safe_integer(info, 'expired_at')
5033
4968
  return {
5034
4969
  'account': None, # deprecated
5035
- 'symbol': symbol,
4970
+ 'symbol': market['symbol'],
5036
4971
  'marginMode': 'isolated',
5037
4972
  'marginType': None, # deprecated
5038
- 'currency': self.safe_currency_code(self.safe_string(info, 'coin_type')),
5039
- 'interest': self.parse_number(interest),
5040
- 'interestRate': self.safe_number(info, 'day_rate'),
5041
- 'amountBorrowed': self.parse_number(loanAmount),
4973
+ 'currency': self.safe_currency_code(self.safe_string(info, 'ccy')),
4974
+ 'interest': self.safe_number(info, 'to_repaied_amount'),
4975
+ 'interestRate': self.safe_number(info, 'daily_interest_rate'),
4976
+ 'amountBorrowed': self.safe_number(info, 'borrow_amount'),
5042
4977
  'timestamp': timestamp, # expiry time
5043
4978
  'datetime': self.iso8601(timestamp),
5044
4979
  'info': info,
@@ -5047,32 +4982,43 @@ class coinex(Exchange, ImplicitAPI):
5047
4982
  async def borrow_isolated_margin(self, symbol: str, code: str, amount: float, params={}):
5048
4983
  """
5049
4984
  create a loan to borrow margin
5050
- :see: https://viabtc.github.io/coinex_api_en_doc/spot/#docsspot002_account017_margin_loan
4985
+ :see: https://docs.coinex.com/api/v2/assets/loan-flat/http/margin-borrow
5051
4986
  :param str symbol: unified market symbol, required for coinex
5052
4987
  :param str code: unified currency code of the currency to borrow
5053
4988
  :param float amount: the amount to borrow
5054
4989
  :param dict [params]: extra parameters specific to the exchange API endpoint
4990
+ :param boolean [params.isAutoRenew]: whether to renew the margin loan automatically or not, default is False
5055
4991
  :returns dict: a `margin loan structure <https://docs.ccxt.com/#/?id=margin-loan-structure>`
5056
4992
  """
5057
4993
  await self.load_markets()
5058
4994
  market = self.market(symbol)
5059
4995
  currency = self.currency(code)
5060
- request = {
4996
+ isAutoRenew = self.safe_bool_2(params, 'isAutoRenew', 'is_auto_renew', False)
4997
+ params = self.omit(params, 'isAutoRenew')
4998
+ request: dict = {
5061
4999
  'market': market['id'],
5062
- 'coin_type': currency['id'],
5063
- 'amount': self.currency_to_precision(code, amount),
5000
+ 'ccy': currency['id'],
5001
+ 'borrow_amount': self.currency_to_precision(code, amount),
5002
+ 'is_auto_renew': isAutoRenew,
5064
5003
  }
5065
- response = await self.v1PrivatePostMarginLoan(self.extend(request, params))
5004
+ response = await self.v2PrivatePostAssetsMarginBorrow(self.extend(request, params))
5066
5005
  #
5067
5006
  # {
5068
5007
  # "code": 0,
5069
5008
  # "data": {
5070
- # "loan_id": 1670
5009
+ # "borrow_id": 13784021,
5010
+ # "market": "BTCUSDT",
5011
+ # "ccy": "USDT",
5012
+ # "daily_interest_rate": "0.001",
5013
+ # "expired_at": 1717299948340,
5014
+ # "borrow_amount": "60",
5015
+ # "to_repaied_amount": "60.0025",
5016
+ # "status": "loan"
5071
5017
  # },
5072
- # "message": "Success"
5018
+ # "message": "OK"
5073
5019
  # }
5074
5020
  #
5075
- data = self.safe_value(response, 'data', {})
5021
+ data = self.safe_dict(response, 'data', {})
5076
5022
  transaction = self.parse_margin_loan(data, currency)
5077
5023
  return self.extend(transaction, {
5078
5024
  'amount': amount,
@@ -5082,149 +5028,179 @@ class coinex(Exchange, ImplicitAPI):
5082
5028
  async def repay_isolated_margin(self, symbol: str, code: str, amount, params={}):
5083
5029
  """
5084
5030
  repay borrowed margin and interest
5085
- :see: https://viabtc.github.io/coinex_api_en_doc/spot/#docsspot002_account018_margin_flat
5031
+ :see: https://docs.coinex.com/api/v2/assets/loan-flat/http/margin-repay
5086
5032
  :param str symbol: unified market symbol, required for coinex
5087
5033
  :param str code: unified currency code of the currency to repay
5088
5034
  :param float amount: the amount to repay
5089
5035
  :param dict [params]: extra parameters specific to the exchange API endpoint
5090
- :param str [params.loan_id]: extra parameter that is not required
5036
+ :param str [params.borrow_id]: extra parameter that is not required
5091
5037
  :returns dict: a `margin loan structure <https://docs.ccxt.com/#/?id=margin-loan-structure>`
5092
5038
  """
5093
5039
  await self.load_markets()
5094
5040
  market = self.market(symbol)
5095
5041
  currency = self.currency(code)
5096
- request = {
5042
+ request: dict = {
5097
5043
  'market': market['id'],
5098
- 'coin_type': currency['id'],
5044
+ 'ccy': currency['id'],
5099
5045
  'amount': self.currency_to_precision(code, amount),
5100
5046
  }
5101
- response = await self.v1PrivatePostMarginFlat(self.extend(request, params))
5047
+ response = await self.v2PrivatePostAssetsMarginRepay(self.extend(request, params))
5102
5048
  #
5103
5049
  # {
5104
5050
  # "code": 0,
5105
- # "data": null,
5106
- # "message": "Success"
5051
+ # "data": {},
5052
+ # "message": "OK"
5107
5053
  # }
5108
5054
  #
5109
- transaction = self.parse_margin_loan(response, currency)
5055
+ data = self.safe_dict(response, 'data', {})
5056
+ transaction = self.parse_margin_loan(data, currency)
5110
5057
  return self.extend(transaction, {
5111
5058
  'amount': amount,
5112
5059
  'symbol': symbol,
5113
5060
  })
5114
5061
 
5115
5062
  def parse_margin_loan(self, info, currency: Currency = None):
5116
- #
5117
- # borrowMargin
5118
- #
5119
- # {
5120
- # "loan_id": 1670
5121
- # }
5122
- #
5123
- # repayMargin
5124
5063
  #
5125
5064
  # {
5126
- # "code": 0,
5127
- # "data": null,
5128
- # "message": "Success"
5065
+ # "borrow_id": 13784021,
5066
+ # "market": "BTCUSDT",
5067
+ # "ccy": "USDT",
5068
+ # "daily_interest_rate": "0.001",
5069
+ # "expired_at": 1717299948340,
5070
+ # "borrow_amount": "60",
5071
+ # "to_repaied_amount": "60.0025",
5072
+ # "status": "loan"
5129
5073
  # }
5130
5074
  #
5075
+ currencyId = self.safe_string(info, 'ccy')
5076
+ marketId = self.safe_string(info, 'market')
5077
+ timestamp = self.safe_integer(info, 'expired_at')
5131
5078
  return {
5132
- 'id': self.safe_integer(info, 'loan_id'),
5133
- 'currency': self.safe_currency_code(None, currency),
5134
- 'amount': None,
5135
- 'symbol': None,
5136
- 'timestamp': None,
5137
- 'datetime': None,
5079
+ 'id': self.safe_integer(info, 'borrow_id'),
5080
+ 'currency': self.safe_currency_code(currencyId, currency),
5081
+ 'amount': self.safe_string(info, 'borrow_amount'),
5082
+ 'symbol': self.safe_symbol(marketId, None, None, 'spot'),
5083
+ 'timestamp': timestamp,
5084
+ 'datetime': self.iso8601(timestamp),
5138
5085
  'info': info,
5139
5086
  }
5140
5087
 
5141
- async def fetch_deposit_withdraw_fees(self, codes: Strings = None, params={}):
5088
+ async def fetch_deposit_withdraw_fee(self, code: str, params={}):
5142
5089
  """
5143
- fetch deposit and withdraw fees
5144
- :see: https://viabtc.github.io/coinex_api_en_doc/spot/#docsspot001_market010_asset_config
5145
- :param str[]|None codes: list of unified currency codes
5090
+ fetch the fee for deposits and withdrawals
5091
+ :see: https://docs.coinex.com/api/v2/assets/deposit-withdrawal/http/get-deposit-withdrawal-config
5092
+ :param str code: unified currency code
5146
5093
  :param dict [params]: extra parameters specific to the exchange API endpoint
5147
- :returns dict[]: a list of `fees structures <https://docs.ccxt.com/#/?id=fee-structure>`
5094
+ :returns dict: a `fee structure <https://docs.ccxt.com/#/?id=fee-structure>`
5148
5095
  """
5149
5096
  await self.load_markets()
5150
- request = {}
5151
- if codes is not None:
5152
- codesLength = len(codes)
5153
- if codesLength == 1:
5154
- request['coin_type'] = self.safe_value(codes, 0)
5155
- response = await self.v1PublicGetCommonAssetConfig(self.extend(request, params))
5156
- #
5157
- # {
5158
- # "code": 0,
5159
- # "data": {
5160
- # "CET-CSC": {
5161
- # "asset": "CET",
5162
- # "chain": "CSC",
5163
- # "can_deposit": True,
5164
- # "can_withdraw ": False,
5165
- # "deposit_least_amount": "1",
5166
- # "withdraw_least_amount": "1",
5167
- # "withdraw_tx_fee": "0.1"
5168
- # },
5169
- # "CET-ERC20": {
5170
- # "asset": "CET",
5171
- # "chain": "ERC20",
5172
- # "can_deposit": True,
5173
- # "can_withdraw": False,
5174
- # "deposit_least_amount": "14",
5175
- # "withdraw_least_amount": "14",
5176
- # "withdraw_tx_fee": "14"
5177
- # }
5178
- # },
5179
- # "message": "Success"
5180
- # }
5181
- #
5182
- return self.parse_deposit_withdraw_fees(response, codes)
5097
+ currency = self.currency(code)
5098
+ request: dict = {
5099
+ 'ccy': currency['id'],
5100
+ }
5101
+ response = await self.v2PrivateGetAssetsDepositWithdrawConfig(self.extend(request, params))
5102
+ #
5103
+ # {
5104
+ # "code": 0,
5105
+ # "data": {
5106
+ # "asset": {
5107
+ # "ccy": "USDT",
5108
+ # "deposit_enabled": True,
5109
+ # "withdraw_enabled": True,
5110
+ # "inter_transfer_enabled": True,
5111
+ # "is_st": False
5112
+ # },
5113
+ # "chains": [
5114
+ # {
5115
+ # "chain": "TRC20",
5116
+ # "min_deposit_amount": "2.4",
5117
+ # "min_withdraw_amount": "2.4",
5118
+ # "deposit_enabled": True,
5119
+ # "withdraw_enabled": True,
5120
+ # "deposit_delay_minutes": 0,
5121
+ # "safe_confirmations": 10,
5122
+ # "irreversible_confirmations": 20,
5123
+ # "deflation_rate": "0",
5124
+ # "withdrawal_fee": "2.4",
5125
+ # "withdrawal_precision": 6,
5126
+ # "memo": "",
5127
+ # "is_memo_required_for_deposit": False,
5128
+ # "explorer_asset_url": "https://tronscan.org/#/token20/TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t"
5129
+ # },
5130
+ # ]
5131
+ # },
5132
+ # "message": "OK"
5133
+ # }
5134
+ #
5135
+ data = self.safe_dict(response, 'data', {})
5136
+ return self.parse_deposit_withdraw_fee(data, currency)
5183
5137
 
5184
- def parse_deposit_withdraw_fees(self, response, codes=None, currencyIdKey=None):
5185
- depositWithdrawFees = {}
5186
- codes = self.market_codes(codes)
5187
- data = self.safe_value(response, 'data')
5188
- currencyIds = list(data.keys())
5189
- for i in range(0, len(currencyIds)):
5190
- entry = currencyIds[i]
5191
- splitEntry = entry.split('-')
5192
- feeInfo = data[currencyIds[i]]
5193
- currencyId = self.safe_string(feeInfo, 'asset')
5194
- currency = self.safe_currency(currencyId)
5195
- code = self.safe_string(currency, 'code')
5196
- if (codes is None) or (self.in_array(code, codes)):
5197
- depositWithdrawFee = self.safe_value(depositWithdrawFees, code)
5198
- if depositWithdrawFee is None:
5199
- depositWithdrawFees[code] = self.deposit_withdraw_fee({})
5200
- depositWithdrawFees[code]['info'][entry] = feeInfo
5201
- networkId = self.safe_string(splitEntry, 1)
5202
- withdrawFee = self.safe_value(feeInfo, 'withdraw_tx_fee')
5203
- withdrawResult = {
5204
- 'fee': withdrawFee,
5205
- 'percentage': False if (withdrawFee is not None) else None,
5206
- }
5207
- depositResult = {
5208
- 'fee': None,
5209
- 'percentage': None,
5210
- }
5211
- if networkId is not None:
5212
- networkCode = self.network_id_to_code(networkId)
5213
- depositWithdrawFees[code]['networks'][networkCode] = {
5214
- 'withdraw': withdrawResult,
5215
- 'deposit': depositResult,
5138
+ def parse_deposit_withdraw_fee(self, fee, currency: Currency = None):
5139
+ #
5140
+ # {
5141
+ # "asset": {
5142
+ # "ccy": "USDT",
5143
+ # "deposit_enabled": True,
5144
+ # "withdraw_enabled": True,
5145
+ # "inter_transfer_enabled": True,
5146
+ # "is_st": False
5147
+ # },
5148
+ # "chains": [
5149
+ # {
5150
+ # "chain": "TRC20",
5151
+ # "min_deposit_amount": "2.4",
5152
+ # "min_withdraw_amount": "2.4",
5153
+ # "deposit_enabled": True,
5154
+ # "withdraw_enabled": True,
5155
+ # "deposit_delay_minutes": 0,
5156
+ # "safe_confirmations": 10,
5157
+ # "irreversible_confirmations": 20,
5158
+ # "deflation_rate": "0",
5159
+ # "withdrawal_fee": "2.4",
5160
+ # "withdrawal_precision": 6,
5161
+ # "memo": "",
5162
+ # "is_memo_required_for_deposit": False,
5163
+ # "explorer_asset_url": "https://tronscan.org/#/token20/TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t"
5164
+ # },
5165
+ # ]
5166
+ # }
5167
+ #
5168
+ result: dict = {
5169
+ 'info': fee,
5170
+ 'withdraw': {
5171
+ 'fee': None,
5172
+ 'percentage': None,
5173
+ },
5174
+ 'deposit': {
5175
+ 'fee': None,
5176
+ 'percentage': None,
5177
+ },
5178
+ 'networks': {},
5179
+ }
5180
+ chains = self.safe_list(fee, 'chains', [])
5181
+ asset = self.safe_dict(fee, 'asset', {})
5182
+ for i in range(0, len(chains)):
5183
+ entry = chains[i]
5184
+ isWithdrawEnabled = self.safe_bool(entry, 'withdraw_enabled')
5185
+ if isWithdrawEnabled:
5186
+ result['withdraw']['fee'] = self.safe_number(entry, 'withdrawal_fee')
5187
+ result['withdraw']['percentage'] = False
5188
+ networkId = self.safe_string(entry, 'chain')
5189
+ if networkId:
5190
+ networkCode = self.network_id_to_code(networkId, self.safe_string(asset, 'ccy'))
5191
+ result['networks'][networkCode] = {
5192
+ 'withdraw': {
5193
+ 'fee': self.safe_number(entry, 'withdrawal_fee'),
5194
+ 'percentage': False,
5195
+ },
5196
+ 'deposit': {
5197
+ 'fee': None,
5198
+ 'percentage': None,
5199
+ },
5216
5200
  }
5217
- else:
5218
- depositWithdrawFees[code]['withdraw'] = withdrawResult
5219
- depositWithdrawFees[code]['deposit'] = depositResult
5220
- depositWithdrawCodes = list(depositWithdrawFees.keys())
5221
- for i in range(0, len(depositWithdrawCodes)):
5222
- code = depositWithdrawCodes[i]
5223
- currency = self.currency(code)
5224
- depositWithdrawFees[code] = self.assign_default_deposit_withdraw_fees(depositWithdrawFees[code], currency)
5225
- return depositWithdrawFees
5201
+ return result
5226
5202
 
5227
- async def fetch_leverages(self, symbols: List[str] = None, params={}) -> Leverages:
5203
+ async def fetch_leverages(self, symbols: Strings = None, params={}) -> Leverages:
5228
5204
  """
5229
5205
  fetch the set leverage for all contract and margin markets
5230
5206
  :see: https://viabtc.github.io/coinex_api_en_doc/spot/#docsspot002_account007_margin_account_settings
@@ -5292,7 +5268,7 @@ class coinex(Exchange, ImplicitAPI):
5292
5268
  """
5293
5269
  await self.load_markets()
5294
5270
  market = self.market(symbol)
5295
- request = {
5271
+ request: dict = {
5296
5272
  'market_type': 'FUTURES',
5297
5273
  'market': market['id'],
5298
5274
  }
@@ -5495,7 +5471,7 @@ class coinex(Exchange, ImplicitAPI):
5495
5471
  if positionId is None:
5496
5472
  raise ArgumentsRequired(self.id + ' fetchMarginAdjustmentHistory() requires a positionId parameter')
5497
5473
  market = self.market(symbol)
5498
- request = {
5474
+ request: dict = {
5499
5475
  'market': market['id'],
5500
5476
  'market_type': 'FUTURES',
5501
5477
  'position_id': positionId,