private async Task <IList <BalanceIssueDto> > FindBalancesWithIssues()
        {
            var balanceIssues = new List <BalanceIssueDto>();

            var balanceWarnings = await _balanceWarningRepository.GetBalancesWarnings();

            var balancesWallets = balanceWarnings.Select(x => x.ClientId).Distinct()
                                  .ToDictionary(x => x, x => _balancesClient.GetClientBalances(x));

            var tasks = balancesWallets.Values.Cast <Task>().ToList();
            await Task.WhenAll(tasks);

            var balances = new Dictionary <string, ClientBalanceResponseModel>();

            foreach (var balanceWallet in balancesWallets)
            {
                foreach (var balance in balanceWallet.Value.Result)
                {
                    balances[GetBalanceDictionaryKey(balanceWallet.Key, balance.AssetId)] = balance;
                }
            }

            foreach (var balanceWarning in balanceWarnings)
            {
                var key = GetBalanceDictionaryKey(balanceWarning.ClientId, balanceWarning.AssetId);

                var isBalanceFound = balances.TryGetValue(key, out var balance);

                if (isBalanceFound && balance.Balance < balanceWarning.MinBalance ||
                    !isBalanceFound && balanceWarning.MinBalance > 0)
                {
                    balanceIssues.Add(new BalanceIssueDto
                    {
                        ClientId   = balanceWarning.ClientId,
                        AssetId    = balanceWarning.AssetId,
                        Name       = balanceWarning.Name,
                        AssetName  = balanceWarning.AssetName,
                        Balance    = balance?.Balance ?? 0,
                        MinBalance = balanceWarning.MinBalance
                    });
                }
            }

            return(balanceIssues);
        }
 public async Task <IReadOnlyList <IBalanceWarning> > GetBalancesWarningsAsync()
 {
     return(await _balanceWarningRepository.GetBalancesWarnings());
 }