Use usdc balance instead usdc value for ensuring balance check
This commit is contained in:
@@ -394,35 +394,28 @@ namespace Managing.Application.ManageBot
|
||||
var totalAllocatedForAccount = 0m;
|
||||
var usdcBalance = account.Balances.FirstOrDefault(b => b.TokenName == Ticker.USDC.ToString());
|
||||
|
||||
if (botsForUser.Any())
|
||||
foreach (var bot in botsForUser)
|
||||
{
|
||||
foreach (var bot in botsForUser)
|
||||
if (excludeIdentifier != default && bot.Identifier == excludeIdentifier)
|
||||
{
|
||||
if (excludeIdentifier != default && bot.Identifier == excludeIdentifier)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
var grain = _grainFactory.GetGrain<ILiveTradingBotGrain>(bot.Identifier);
|
||||
TradingBotConfig config;
|
||||
try
|
||||
{
|
||||
config = await grain.GetConfiguration();
|
||||
}
|
||||
catch
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (string.Equals(config.AccountName, account.Name, StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
totalAllocatedForAccount += config.BotTradingBalance;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
var grain = _grainFactory.GetGrain<ILiveTradingBotGrain>(bot.Identifier);
|
||||
TradingBotConfig config;
|
||||
try
|
||||
{
|
||||
config = await grain.GetConfiguration();
|
||||
}
|
||||
catch
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (string.Equals(config.AccountName, account.Name, StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
totalAllocatedForAccount += config.BotTradingBalance;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
totalAllocatedForAccount = usdcBalance?.Value ?? 0m;
|
||||
}
|
||||
|
||||
var usdcValue = usdcBalance?.Value ?? 0m;
|
||||
|
||||
Reference in New Issue
Block a user