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

Method parse_currency

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

Source from the content-addressed store, hash-verified

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

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