Fix restart/start if not account with the first account of the user
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user