Get fees to claims
This commit is contained in:
@@ -1,10 +0,0 @@
|
||||
namespace Managing.Infrastructure.Evm.Abstractions
|
||||
{
|
||||
public interface IWeb3ProxyService
|
||||
{
|
||||
Task<T> CallPrivyServiceAsync<T>(string endpoint, object payload);
|
||||
Task<T> GetPrivyServiceAsync<T>(string endpoint, object payload = null);
|
||||
Task<T> CallGmxServiceAsync<T>(string endpoint, object payload);
|
||||
Task<T> GetGmxServiceAsync<T>(string endpoint, object payload = null);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace Managing.Infrastructure.Evm.Models.Proxy;
|
||||
|
||||
public class ClaimableFundingFees
|
||||
{
|
||||
[JsonProperty("totalUsdc")] public double TotalUsdc { get; set; }
|
||||
}
|
||||
|
||||
public class ClaimableUiFees
|
||||
{
|
||||
[JsonProperty("totalUsdc")] public double TotalUsdc { get; set; }
|
||||
}
|
||||
|
||||
public class Data
|
||||
{
|
||||
[JsonProperty("claimableFundingFees")] public ClaimableFundingFees ClaimableFundingFees { get; set; }
|
||||
|
||||
[JsonProperty("claimableUiFees")] public ClaimableUiFees ClaimableUiFees { get; set; }
|
||||
|
||||
[JsonProperty("rebateStats")] public RebateStats RebateStats { get; set; }
|
||||
}
|
||||
|
||||
public class RebateStats
|
||||
{
|
||||
[JsonProperty("totalRebateUsdc")] public double TotalRebateUsdc { get; set; }
|
||||
|
||||
[JsonProperty("discountUsdc")] public double DiscountUsdc { get; set; }
|
||||
|
||||
[JsonProperty("rebateFactor")] public double RebateFactor { get; set; }
|
||||
|
||||
[JsonProperty("discountFactor")] public double DiscountFactor { get; set; }
|
||||
}
|
||||
|
||||
public class ClaimingFeesResponse
|
||||
{
|
||||
[JsonProperty("success")] public bool Success { get; set; }
|
||||
|
||||
[JsonProperty("data")] public Data Data { get; set; }
|
||||
}
|
||||
@@ -1,9 +1,11 @@
|
||||
using System.Net.Http.Json;
|
||||
using Managing.Infrastructure.Evm.Abstractions;
|
||||
using Microsoft.Extensions.Options;
|
||||
using System.Text;
|
||||
using System.Text.Json;
|
||||
using System.Web;
|
||||
using Managing.Application.Abstractions.Services;
|
||||
using Managing.Domain.Accounts;
|
||||
using Managing.Infrastructure.Evm.Models.Proxy;
|
||||
using Microsoft.Extensions.Options;
|
||||
|
||||
namespace Managing.Infrastructure.Evm.Services
|
||||
{
|
||||
@@ -146,6 +148,38 @@ namespace Managing.Infrastructure.Evm.Services
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<GmxClaimableSummary> GetGmxClaimableSummaryAsync(string account)
|
||||
{
|
||||
var payload = new { account };
|
||||
var response = await GetGmxServiceAsync<ClaimingFeesResponse>("/claimable-summary", payload);
|
||||
|
||||
|
||||
if (response.Data == null)
|
||||
{
|
||||
throw new Web3ProxyException("GMX claimable summary data is null");
|
||||
}
|
||||
|
||||
// Map from Web3Proxy response model to domain model
|
||||
return new GmxClaimableSummary
|
||||
{
|
||||
ClaimableFundingFees = new FundingFeesData
|
||||
{
|
||||
TotalUsdc = response.Data.ClaimableFundingFees.TotalUsdc
|
||||
},
|
||||
ClaimableUiFees = new UiFeesData
|
||||
{
|
||||
TotalUsdc = response.Data.ClaimableUiFees.TotalUsdc
|
||||
},
|
||||
RebateStats = new RebateStatsData
|
||||
{
|
||||
TotalRebateUsdc = response.Data.RebateStats.TotalRebateUsdc,
|
||||
DiscountUsdc = response.Data.RebateStats.DiscountUsdc,
|
||||
RebateFactor = response.Data.RebateStats.RebateFactor,
|
||||
DiscountFactor = response.Data.RebateStats.DiscountFactor
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
private async Task HandleErrorResponse(HttpResponseMessage response)
|
||||
{
|
||||
var statusCode = (int)response.StatusCode;
|
||||
@@ -198,7 +232,7 @@ namespace Managing.Infrastructure.Evm.Services
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
var queryString = new System.Text.StringBuilder("?");
|
||||
var queryString = new StringBuilder("?");
|
||||
bool isFirst = true;
|
||||
|
||||
foreach (var prop in properties)
|
||||
|
||||
Reference in New Issue
Block a user