Fix restart/start if not account with the first account of the user

This commit is contained in:
2025-10-12 16:08:12 +07:00
parent 176573ddd1
commit ff74296c26
4 changed files with 61 additions and 7 deletions

View File

@@ -43,11 +43,21 @@ namespace Managing.Application.ManageBot
$"Bot trading balance must be greater than {Constants.GMX.Config.MinimumPositionAmount}");
}
var account = await _accountService.GetAccount(request.Config.AccountName, true, true);
if (account == null)
Account account;
if (string.IsNullOrEmpty(request.Config.AccountName))
{
throw new Exception($"Account {request.Config.AccountName} not found");
// Fallback: Get the first account for the user
var userAccounts = await _accountService.GetAccountsByUserAsync(request.User, true, true);
var firstAccount = userAccounts.FirstOrDefault();
if (firstAccount == null)
{
throw new InvalidOperationException($"User '{request.User.Name}' has no accounts configured.");
}
account = firstAccount;
}
else
{
account = await _accountService.GetAccount(request.Config.AccountName, true, true);
}
// Check balances for EVM/GMX V2 accounts before starting