Use usdc balance instead usdc value for ensuring balance check

This commit is contained in:
2025-10-05 01:36:25 +07:00
parent 63683d6bdf
commit de0d042254
7 changed files with 72 additions and 96 deletions

View File

@@ -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;