Add single time swap + fetch balance cache in AgentGrain

This commit is contained in:
2025-09-21 23:41:27 +07:00
parent 8afe80ca0e
commit 6aad2834a9
5 changed files with 369 additions and 59 deletions

View File

@@ -1,4 +1,5 @@
using Managing.Application.Abstractions.Models;
using Managing.Application.Bots.Models;
using Orleans.Concurrency;
namespace Managing.Application.Abstractions.Grains
@@ -39,5 +40,14 @@ namespace Managing.Application.Abstractions.Grains
/// <param name="updateEvent">The update event from the stream</param>]
[OneWay]
Task OnAgentSummaryUpdateAsync(AgentSummaryUpdateEvent updateEvent);
/// <summary>
/// Coordinates ETH balance checking and swapping for all bots under this agent.
/// Uses cached balance data to reduce external API calls and ensures only one swap operation happens at a time.
/// </summary>
/// <param name="requestingBotId">The bot requesting the ETH balance check</param>
/// <param name="accountName">The account name to check balances for</param>
/// <returns>BalanceCheckResult indicating the status and reason for any failure</returns>
Task<BalanceCheckResult> CheckAndEnsureEthBalanceAsync(Guid requestingBotId, string accountName);
}
}