Add ETH and USDC balance check before start/restart bot and autoswap

This commit is contained in:
2025-09-23 14:03:46 +07:00
parent d13ac9fd21
commit 40f3c66694
23 changed files with 847 additions and 284 deletions

View File

@@ -13,7 +13,7 @@ namespace Managing.Infrastructure.Evm.Models.Proxy
/// </summary>
[JsonPropertyName("success")]
public bool Success { get; set; }
/// <summary>
/// Error message if not successful
/// </summary>
@@ -44,25 +44,25 @@ namespace Managing.Infrastructure.Evm.Models.Proxy
/// </summary>
[JsonPropertyName("type")]
public string Type { get; set; }
/// <summary>
/// Error message
/// </summary>
[JsonPropertyName("message")]
public string Message { get; set; }
/// <summary>
/// Error stack trace
/// </summary>
[JsonPropertyName("stack")]
public string Stack { get; set; }
/// <summary>
/// HTTP status code (added by service)
/// </summary>
[JsonIgnore]
public int StatusCode { get; set; }
/// <summary>
/// Returns a formatted error message with type and message
/// </summary>
@@ -90,7 +90,7 @@ namespace Managing.Infrastructure.Evm.Models.Proxy
/// The error details from the API
/// </summary>
public Web3ProxyError Error { get; }
/// <summary>
/// Simple error message from API
/// </summary>
@@ -100,12 +100,12 @@ namespace Managing.Infrastructure.Evm.Models.Proxy
/// Creates a new Web3ProxyException from a structured error
/// </summary>
/// <param name="error">The error details</param>
public Web3ProxyException(Web3ProxyError error)
public Web3ProxyException(Web3ProxyError error)
: base(error?.Message ?? "An error occurred in the Web3Proxy API")
{
Error = error;
}
/// <summary>
/// Creates a new Web3ProxyException from a simple error message
/// </summary>
@@ -121,7 +121,7 @@ namespace Managing.Infrastructure.Evm.Models.Proxy
/// </summary>
/// <param name="message">Custom error message</param>
/// <param name="error">The error details</param>
public Web3ProxyException(string message, Web3ProxyError error)
public Web3ProxyException(string message, Web3ProxyError error)
: base(message)
{
Error = error;
@@ -151,4 +151,28 @@ namespace Managing.Infrastructure.Evm.Models.Proxy
[JsonPropertyName("balances")]
public List<Balance> Balances { get; set; }
}
}
/// <summary>
/// Response model for gas fee information
/// </summary>
public class GasFeeResponse : Web3ProxyResponse
{
/// <summary>
/// Estimated gas fee in USD
/// </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; }
}
}