private async Task <IReadOnlyList <BalanceRecord> > GetInUsdAsync(ICollection <BalanceRecord> balanceRecords) { var balanceRecordsInUsd = (await _rateCalculatorClient.GetAmountInBaseAsync(balanceRecords, Usd)).ToList(); if (balanceRecords.Count != balanceRecordsInUsd.Count) { throw new InvalidOperationException("Wrong number of USD balances is returned. " + $"Balance records in request: {balanceRecords.Count}, " + $"balance records in response: {balanceRecordsInUsd.Count}"); } return(balanceRecordsInUsd); }
public async Task <(double convertedAmount, string assetId)> ConvertAsync(string assetFrom, double amount) { var defaultAsset = _settingsService.GetDefaultAsset(); if (assetFrom == defaultAsset) { return(amount, defaultAsset); } var convertedAmount = await _rateCalculatorClient.GetAmountInBaseAsync(assetFrom, amount, defaultAsset); if (amount != 0 && convertedAmount == 0) { _log.Warning($"Conversion from {amount} {assetFrom} to {defaultAsset} resulted in 0."); } return(convertedAmount, defaultAsset); }
public async Task <(string assetTo, double convertedAmount)> ConvertAsync( string assetFrom, string assetTo, double amount, bool forceConvesion = false) { if (assetFrom == assetTo || IsNotConvertible(assetFrom) && !forceConvesion) { return(assetFrom, amount); } double convertedAmount = await _rateCalculatorClient.GetAmountInBaseAsync(assetFrom, amount, assetTo); if (amount != 0 && convertedAmount == 0) { _log.Warning( nameof(ConvertAsync), $"Conversion from {amount} {assetFrom} to {assetTo} resulted in 0."); } return(assetTo, convertedAmount); }
private async Task <double> GetAmountInOperationAssetAsync(string tierAssetId, string assetId, double amount) { return(tierAssetId == assetId ? amount : await _rateCalculatorClient.GetAmountInBaseAsync(tierAssetId, amount, assetId)); }
private async Task <double> GetAmountAsync(string assetId, double amount, string baseAssetId) { return(assetId == baseAssetId ? amount : await _rateCalculatorClient.GetAmountInBaseAsync(assetId, amount, baseAssetId)); }