public static ExchangeMetaData adaptMetaData( BitfinexAccountFeesResponse accountFeesResponse, ExchangeMetaData metaData) { Map<Currency, CurrencyMetaData> currencies = metaData.getCurrencies(); final Map<Currency, BigDecimal> withdrawFees = accountFeesResponse.getWithdraw(); withdrawFees.forEach( (currency, withdrawalFee) -> { CurrencyMetaData newMetaData = new CurrencyMetaData( // Currency should have at least the scale of the withdrawalFee currencies.get(currency) == null ? withdrawalFee.scale() : Math.max(withdrawalFee.scale(), currencies.get(currency).getScale()), withdrawalFee); currencies.put(currency, newMetaData); }); return metaData; }
static ExchangeMetaData adaptToExchangeMetaData( HuobiAssetPair[] assetPairs, HuobiAsset[] assets, ExchangeMetaData staticMetaData) { HuobiUtils.setHuobiAssets(assets); HuobiUtils.setHuobiAssetPairs(assetPairs); Map<CurrencyPair, CurrencyPairMetaData> pairsMetaData = staticMetaData.getCurrencyPairs(); Map<CurrencyPair, CurrencyPairMetaData> pairs = new HashMap<>(); for (HuobiAssetPair assetPair : assetPairs) { CurrencyPair pair = adaptCurrencyPair(assetPair.getKey()); pairs.put(pair, adaptPair(assetPair, pairsMetaData.getOrDefault(pair, null))); } Map<Currency, CurrencyMetaData> currenciesMetaData = staticMetaData.getCurrencies(); Map<Currency, CurrencyMetaData> currencies = new HashMap<>(); for (HuobiAsset asset : assets) { Currency currency = adaptCurrency(asset.getAsset()); CurrencyMetaData metadata = currenciesMetaData.getOrDefault(currency, null); BigDecimal withdrawalFee = metadata == null ? null : metadata.getWithdrawalFee(); int scale = metadata == null ? 8 : metadata.getScale(); currencies.put(currency, new CurrencyMetaData(scale, withdrawalFee)); } return new ExchangeMetaData(pairs, currencies, null, null, false); }
public static ExchangeMetaData adaptMetaData( BitfinexAccountFeesResponse accountFeesResponse, ExchangeMetaData metaData) { Map<Currency, CurrencyMetaData> currencies = metaData.getCurrencies(); final Map<Currency, BigDecimal> withdrawFees = accountFeesResponse.getWithdraw(); withdrawFees.forEach( (currency, withdrawalFee) -> { CurrencyMetaData newMetaData = new CurrencyMetaData( // Currency should have at least the scale of the withdrawalFee currencies.get(currency) == null ? withdrawalFee.scale() : Math.max(withdrawalFee.scale(), currencies.get(currency).getScale()), withdrawalFee); currencies.put(currency, newMetaData); }); return metaData; }