Price reminder and init approval

* Start price reminder grain

* Add config and init grain at startup

* Save init wallet when already init
This commit is contained in:
Oda
2025-09-13 02:29:14 +07:00
committed by GitHub
parent da50b30344
commit 56b4f14eb3
69 changed files with 2373 additions and 701 deletions

View File

@@ -0,0 +1,19 @@
using Managing.Domain.Candles;
using Orleans;
namespace Managing.Application.Abstractions.Grains;
/// <summary>
/// Orleans grain interface for candle storage and retrieval.
/// This grain manages in-memory historical candle data with state persistence
/// and subscribes to price streams for real-time updates.
/// </summary>
public interface ICandleStoreGrain : IGrainWithStringKey
{
/// <summary>
/// Gets the current list of historical candles (up to 500 most recent)
/// </summary>
/// <returns>List of candles ordered by date</returns>
Task<List<Candle>> GetCandlesAsync();
}

View File

@@ -0,0 +1,19 @@
using Orleans;
namespace Managing.Application.Abstractions.Grains;
/// <summary>
/// Orleans grain interface for daily price fetching operations.
/// This stateless worker grain handles fetching daily price data from external APIs
/// and publishing to Orleans streams.
/// </summary>
public interface IPriceFetcher1DayGrain : IGrainWithIntegerKey
{
/// <summary>
/// Fetches daily price data for all supported exchange/ticker combinations
/// and publishes new candles to their respective streams.
/// </summary>
/// <returns>True if the operation completed successfully, false otherwise</returns>
Task<bool> FetchAndPublishPricesAsync();
}

View File

@@ -0,0 +1,19 @@
using Orleans;
namespace Managing.Application.Abstractions.Grains;
/// <summary>
/// Orleans grain interface for 1-hour price fetching operations.
/// This stateless worker grain handles fetching 1-hour price data from external APIs
/// and publishing to Orleans streams.
/// </summary>
public interface IPriceFetcher1HourGrain : IGrainWithIntegerKey
{
/// <summary>
/// Fetches 1-hour price data for all supported exchange/ticker combinations
/// and publishes new candles to their respective streams.
/// </summary>
/// <returns>True if the operation completed successfully, false otherwise</returns>
Task<bool> FetchAndPublishPricesAsync();
}

View File

@@ -0,0 +1,19 @@
using Orleans;
namespace Managing.Application.Abstractions.Grains;
/// <summary>
/// Orleans grain interface for 4-hour price fetching operations.
/// This stateless worker grain handles fetching 4-hour price data from external APIs
/// and publishing to Orleans streams.
/// </summary>
public interface IPriceFetcher4HourGrain : IGrainWithIntegerKey
{
/// <summary>
/// Fetches 4-hour price data for all supported exchange/ticker combinations
/// and publishes new candles to their respective streams.
/// </summary>
/// <returns>True if the operation completed successfully, false otherwise</returns>
Task<bool> FetchAndPublishPricesAsync();
}

View File

@@ -0,0 +1,18 @@
using Orleans;
namespace Managing.Application.Abstractions.Grains;
/// <summary>
/// Orleans grain interface for 5-minute price fetching operations.
/// This stateless worker grain handles fetching 5-minute price data from external APIs
/// and publishing to Orleans streams.
/// </summary>
public partial interface IPriceFetcher5MinGrain : IGrainWithIntegerKey
{
/// <summary>
/// Fetches 5-minute price data for all supported exchange/ticker combinations
/// and publishes new candles to their respective streams.
/// </summary>
/// <returns>True if the operation completed successfully, false otherwise</returns>
Task<bool> FetchAndPublishPricesAsync();
}

View File

@@ -7,6 +7,7 @@ public interface IAccountRepository
Task<Account> GetAccountByNameAsync(string name);
Task<Account> GetAccountByKeyAsync(string key);
Task InsertAccountAsync(Account account);
Task UpdateAccountAsync(Account account);
void DeleteAccountByName(string name);
Task<IEnumerable<Account>> GetAccountsAsync();
}

View File

@@ -27,7 +27,7 @@ public interface IEvmManager
decimal GetVolume(SubgraphProvider subgraphProvider, Ticker ticker);
Task<List<Ticker>> GetAvailableTicker();
Task<Candle> GetCandle(Ticker ticker);
Task<PrivyInitAddressResponse> InitAddress(string publicAddress);
Task<PrivyInitAddressResponse> InitAddressForGMX(string publicAddress);
Task<bool> Send(Chain chain, Ticker ticker, decimal amount, string publicAddress, string privateKey,
string receiverAddress);

View File

@@ -34,4 +34,6 @@ public interface IAccountService
Task<SwapInfos> SendTokenAsync(User user, string accountName, string recipientAddress, Ticker ticker,
decimal amount, int? chainId = null);
Task<List<ExchangeApprovalStatus>> GetExchangeApprovalStatusAsync(User user);
}

View File

@@ -1,7 +0,0 @@
namespace Managing.Application.Abstractions.Services;
public interface IStreamService
{
Task SubscribeCandle();
Task UnSubscribeCandle();
}

View File

@@ -38,7 +38,7 @@ public interface ITradingService
Task<IEnumerable<Position>> GetAllDatabasePositionsAsync();
Task<IEnumerable<Position>> GetPositionsByInitiatorIdentifierAsync(Guid initiatorIdentifier);
Task<IEnumerable<Position>> GetPositionsByInitiatorIdentifiersAsync(IEnumerable<Guid> initiatorIdentifiers);
Task<PrivyInitAddressResponse> InitPrivyWallet(string publicAddress);
Task<PrivyInitAddressResponse> InitPrivyWallet(string publicAddress, TradingExchanges tradingExchange);
// Synth API integration methods
Task<SignalValidationResult> ValidateSynthSignalAsync(LightSignal signal, decimal currentPrice,