Add ETH and USDC balance check before start/restart bot and autoswap

This commit is contained in:
2025-09-23 14:03:46 +07:00
parent d13ac9fd21
commit 40f3c66694
23 changed files with 847 additions and 284 deletions

View File

@@ -6,6 +6,7 @@ using Managing.Application.Trading.Commands;
using Managing.Application.Trading.Handlers;
using Managing.Common;
using Managing.Core;
using Managing.Core.Exceptions;
using Managing.Domain.Accounts;
using Managing.Domain.Bots;
using Managing.Domain.Candles;
@@ -822,6 +823,17 @@ public class TradingBotBase : ITradingBot
return null;
}
catch (InsufficientFundsException ex)
{
// Handle insufficient funds errors with user-friendly messaging
SetSignalStatus(signal.Identifier, SignalStatus.Expired);
await LogWarning(ex.UserMessage);
// Log the technical details for debugging
Logger.LogError(ex, "Insufficient funds error for signal {SignalId}: {ErrorMessage}", signal.Identifier, ex.Message);
return null;
}
catch (Exception ex)
{
SetSignalStatus(signal.Identifier, SignalStatus.Expired);