using Managing.Application.Bots.Models; using Orleans.Concurrency; namespace Managing.Application.Abstractions.Grains { public interface IAgentGrain : IGrainWithIntegerKey { /// /// Initializes the agent grain with user-specific data. /// /// The ID of the user (used as grain key). /// The display name of the agent. [OneWay] Task InitializeAsync(int userId, string agentName); /// /// Updates only the agent name without recalculating summary. /// /// The new agent name. [OneWay] Task UpdateAgentNameAsync(string agentName); /// /// Registers a new bot with this agent. /// [OneWay] Task RegisterBotAsync(Guid botId); /// /// Unregisters a bot from this agent. /// [OneWay] Task UnregisterBotAsync(Guid botId); /// /// Handles position opened events for real-time agent summary updates. /// /// The position opened event [OneWay] Task OnPositionOpenedAsync(PositionOpenEvent evt); /// /// Handles position closed events for real-time agent summary updates. /// /// The position closed event [OneWay] Task OnPositionClosedAsync(PositionClosedEvent evt); /// /// Handles position update events for real-time PnL and status updates. /// /// The position update event [OneWay] Task OnPositionUpdatedAsync(PositionUpdatedEvent evt); /// /// 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. /// /// The bot requesting the ETH balance check /// The account name to check balances for /// BalanceCheckResult indicating the status and reason for any failure Task CheckAndEnsureEthBalanceAsync(Guid requestingBotId, string accountName); /// /// Forces an update of the agent summary. /// [OneWay] Task ForceUpdateSummary(); /// /// Triggers balance tracking data insertion when a bot starts/restarts. /// This captures the balance change related to botsAllocationUsdValue. /// [OneWay] Task TrackBalanceOnBotStartAsync(); } }