MCPcopy Create free account
hub / github.com/ccxt/ccxt / parse_currency

Method parse_currency

python/ccxt/htx.py:3284–3349  ·  view source on GitHub ↗
(self, rawCurrency: dict)

Source from the content-addressed store, hash-verified

3282 return self.parse_currencies(data)
3283
3284 def parse_currency(self, rawCurrency: dict) -> Currency:
3285 if not ('networkNamesByChainIds' in self.options):
3286 self.options['networkNamesByChainIds'] = {}
3287 if not ('networkChainIdsByNames' in self.options):
3288 self.options['networkChainIdsByNames'] = {}
3289 currencyId = self.safe_string(rawCurrency, 'currency')
3290 code = self.safe_currency_code(currencyId)
3291 assetType = self.safe_string(rawCurrency, 'assetType')
3292 type = 'crypto' if (assetType == '1') else 'fiat'
3293 self.options['networkChainIdsByNames'][code] = {}
3294 chains = self.safe_list(rawCurrency, 'chains', [])
3295 networks = {}
3296 for j in range(0, len(chains)):
3297 chainEntry = chains[j]
3298 uniqueChainId = self.safe_string(chainEntry, 'chain') # i.e. usdterc20, trc20usdt ...
3299 title = self.safe_string_2(chainEntry, 'baseChain', 'displayName') # baseChain and baseChainProtocol are together existent or inexistent in entries, but baseChain is preferred. when they are both inexistent, then we use generic displayName
3300 self.options['networkChainIdsByNames'][code][title] = uniqueChainId
3301 self.options['networkNamesByChainIds'][uniqueChainId] = title
3302 networkCode = self.network_id_to_code(uniqueChainId, code)
3303 networks[networkCode] = {
3304 'info': chainEntry,
3305 'id': uniqueChainId,
3306 'network': networkCode,
3307 'limits': {
3308 'deposit': {
3309 'min': self.safe_number(chainEntry, 'minDepositAmt'),
3310 'max': None,
3311 },
3312 'withdraw': {
3313 'min': self.safe_number(chainEntry, 'minWithdrawAmt'),
3314 'max': self.safe_number(chainEntry, 'maxWithdrawAmt'),
3315 },
3316 },
3317 'active': None,
3318 'deposit': self.safe_string(chainEntry, 'depositStatus') == 'allowed',
3319 'withdraw': self.safe_string(chainEntry, 'withdrawStatus') == 'allowed',
3320 'fee': self.safe_number(chainEntry, 'transactFeeWithdraw'),
3321 'precision': self.parse_number(self.parse_precision(self.safe_string(chainEntry, 'withdrawPrecision'))),
3322 }
3323 return self.safe_currency_structure({
3324 'info': rawCurrency,
3325 'code': code,
3326 'id': currencyId,
3327 'active': self.safe_string(rawCurrency, 'instStatus') == 'normal',
3328 'deposit': None,
3329 'withdraw': None,
3330 'fee': None,
3331 'name': None,
3332 'type': type,
3333 'limits': {
3334 'amount': {
3335 'min': None,
3336 'max': None,
3337 },
3338 'withdraw': {
3339 'min': None,
3340 'max': None,
3341 },

Callers

nothing calls this directly

Calls 10

network_id_to_codeMethod · 0.95
safe_stringMethod · 0.80
safe_listMethod · 0.80
safe_string_2Method · 0.80
safe_numberMethod · 0.80
parse_numberMethod · 0.80
parse_precisionMethod · 0.80
rangeFunction · 0.50
safe_currency_codeMethod · 0.45

Tested by

no test coverage detected