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