Get fees to claims

This commit is contained in:
2025-06-13 14:22:38 +07:00
parent 5188b5faec
commit 3f34c56968
13 changed files with 580 additions and 20 deletions

View File

@@ -1,5 +1,4 @@
using Managing.Application.Abstractions;
using Managing.Application.Abstractions.Repositories;
using Managing.Application.Abstractions.Repositories;
using Managing.Application.Abstractions.Services;
using Managing.Common;
using Managing.Domain.Accounts;
@@ -14,6 +13,7 @@ public class AccountService : IAccountService
private readonly IExchangeService _exchangeService;
private readonly IEvmManager _evmManager;
private readonly ICacheService _cacheService;
private readonly IWeb3ProxyService _web3ProxyService;
private readonly ILogger<AccountService> _logger;
public AccountService(
@@ -21,13 +21,15 @@ public class AccountService : IAccountService
ILogger<AccountService> logger,
IExchangeService exchangeService,
IEvmManager evmManager,
ICacheService cacheService)
ICacheService cacheService,
IWeb3ProxyService web3ProxyService)
{
_accountRepository = accountRepository;
_logger = logger;
_exchangeService = exchangeService;
_evmManager = evmManager;
_cacheService = cacheService;
_web3ProxyService = web3ProxyService;
}
public async Task<Account> CreateAccount(User user, Account request)
@@ -161,6 +163,38 @@ public class AccountService : IAccountService
return accounts;
}
public async Task<GmxClaimableSummary> GetGmxClaimableSummaryAsync(User user, string accountName)
{
// Get the account for the user
var account = await GetAccountByUser(user, accountName, true, false);
if (account == null)
{
throw new ArgumentException($"Account '{accountName}' not found for user '{user.Name}'");
}
// Ensure the account has a valid address/key
if (string.IsNullOrEmpty(account.Key))
{
throw new ArgumentException($"Account '{accountName}' does not have a valid address");
}
try
{
// Call the Web3ProxyService to get GMX claimable summary
var infrastructureResponse = await _web3ProxyService.GetGmxClaimableSummaryAsync(account.Key);
// Map from infrastructure model to domain model
return infrastructureResponse;
}
catch (Exception ex) when (!(ex is ArgumentException || ex is InvalidOperationException))
{
_logger.LogError(ex, "Error getting GMX claimable summary for account {AccountName} and user {UserName}",
accountName, user.Name);
throw new InvalidOperationException($"Failed to get GMX claimable summary: {ex.Message}", ex);
}
}
private void ManageProperties(bool hideSecrets, bool getBalance, Account account)
{
if (account != null)