Fix get Gas fees + position direction list
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
using System.Text.Json.Serialization;
|
||||
using Managing.Domain.Accounts;
|
||||
using Managing.Domain.Evm;
|
||||
|
||||
namespace Managing.Infrastructure.Evm.Models.Proxy
|
||||
{
|
||||
@@ -158,21 +159,10 @@ namespace Managing.Infrastructure.Evm.Models.Proxy
|
||||
public class GasFeeResponse : Web3ProxyResponse
|
||||
{
|
||||
/// <summary>
|
||||
/// Estimated gas fee in USD
|
||||
/// Gas fee data object
|
||||
/// </summary>
|
||||
[JsonPropertyName("estimatedGasFeeUsd")]
|
||||
public double? EstimatedGasFeeUsd { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Current ETH price in USD
|
||||
/// </summary>
|
||||
[JsonPropertyName("ethPrice")]
|
||||
public double? EthPrice { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gas price in Gwei
|
||||
/// </summary>
|
||||
[JsonPropertyName("gasPriceGwei")]
|
||||
public double? GasPriceGwei { get; set; }
|
||||
[JsonPropertyName("data")]
|
||||
public GasFeeData? Data { get; set; }
|
||||
}
|
||||
|
||||
}
|
||||
@@ -7,6 +7,7 @@ using System.Web;
|
||||
using Managing.Application.Abstractions.Services;
|
||||
using Managing.Core.Exceptions;
|
||||
using Managing.Domain.Accounts;
|
||||
using Managing.Domain.Evm;
|
||||
using Managing.Infrastructure.Evm.Models.Proxy;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Microsoft.Extensions.Options;
|
||||
@@ -408,7 +409,34 @@ namespace Managing.Infrastructure.Evm.Services
|
||||
throw new Web3ProxyException($"Gas fee request failed: {response.Error}");
|
||||
}
|
||||
|
||||
return (decimal)(response.EstimatedGasFeeUsd ?? 0);
|
||||
if (response.Data is null)
|
||||
{
|
||||
throw new Web3ProxyException("Gas fee data is null");
|
||||
}
|
||||
|
||||
return (decimal)(response.Data.EstimatedGasFeeUsd ?? 0);
|
||||
}
|
||||
|
||||
public async Task<GasFeeData> GetGasFeeDataAsync()
|
||||
{
|
||||
var response = await GetGmxServiceAsync<GasFeeResponse>("/gas-fee", null);
|
||||
|
||||
if (response == null)
|
||||
{
|
||||
throw new Web3ProxyException("Gas fee response is null");
|
||||
}
|
||||
|
||||
if (!response.Success)
|
||||
{
|
||||
throw new Web3ProxyException($"Gas fee request failed: {response.Error}");
|
||||
}
|
||||
|
||||
if (response.Data is null)
|
||||
{
|
||||
throw new Web3ProxyException("Gas fee data is null");
|
||||
}
|
||||
|
||||
return response.Data;
|
||||
}
|
||||
|
||||
private async Task HandleErrorResponse(HttpResponseMessage response)
|
||||
|
||||
Reference in New Issue
Block a user