This commit is contained in:
2025-09-24 01:19:10 +07:00
parent 40f3c66694
commit 9bdfb989c1
9 changed files with 202 additions and 419 deletions

View File

@@ -350,17 +350,20 @@ public class LiveTradingBotGrain : Grain, ILiveTradingBotGrain, IRemindable
try
{
var agentGrain = GrainFactory.GetGrain<IAgentGrain>(_state.State.User.Id);
var balanceCheckResult = await agentGrain.CheckAndEnsureEthBalanceAsync(_state.State.Identifier, _tradingBot.Account.Name);
var balanceCheckResult =
await agentGrain.CheckAndEnsureEthBalanceAsync(_state.State.Identifier, _tradingBot.Account.Name);
if (!balanceCheckResult.IsSuccessful)
{
// Log the specific reason for the failure
await _tradingBot.LogWarning($"Balance check failed: {balanceCheckResult.Message} (Reason: {balanceCheckResult.FailureReason})");
await _tradingBot.LogWarning(
$"Balance check failed: {balanceCheckResult.Message} (Reason: {balanceCheckResult.FailureReason})");
// Check if the bot should stop due to this failure
if (balanceCheckResult.ShouldStopBot)
{
await _tradingBot.LogWarning($"Stopping bot due to balance check failure: {balanceCheckResult.Message}");
await _tradingBot.LogWarning(
$"Stopping bot due to balance check failure: {balanceCheckResult.Message}");
await StopAsync();
return;
}
@@ -371,10 +374,6 @@ public class LiveTradingBotGrain : Grain, ILiveTradingBotGrain, IRemindable
return;
}
}
else
{
await _tradingBot.LogInformation($"Balance check successful: {balanceCheckResult.Message}");
}
}
catch (Exception ex)
{