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:
@@ -506,7 +506,7 @@ public class EvmManager : IEvmManager
|
||||
return lastCandles.Last();
|
||||
}
|
||||
|
||||
public async Task<PrivyInitAddressResponse> InitAddress(string publicAddress)
|
||||
public async Task<PrivyInitAddressResponse> InitAddressForGMX(string publicAddress)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
@@ -9,7 +9,7 @@ public static class PriceExtensions
|
||||
{
|
||||
public static List<Candle> GetCandles(this Round[] prices, Timeframe timeframe, Ticker ticker)
|
||||
{
|
||||
int timezoneOffset = - (int)(new DateTimeOffset(DateTime.UtcNow).Offset.TotalSeconds);
|
||||
int timezoneOffset = -(int)(new DateTimeOffset(DateTime.UtcNow).Offset.TotalSeconds);
|
||||
var CHART_PERIODS = new Dictionary<Timeframe, int>
|
||||
{
|
||||
{ Timeframe.FiveMinutes, 60 * 5 },
|
||||
@@ -53,6 +53,7 @@ public static class PriceExtensions
|
||||
h = Math.Max(o, c);
|
||||
l = Math.Min(o, c);
|
||||
}
|
||||
|
||||
c = decimal.Parse(current.Value);
|
||||
h = Math.Max(h, c);
|
||||
l = Math.Min(l, c);
|
||||
@@ -69,7 +70,7 @@ public static class PriceExtensions
|
||||
Low = x.Low,
|
||||
Timeframe = x.Timeframe,
|
||||
Exchange = TradingExchanges.Evm,
|
||||
Ticker = ticker.ToString()
|
||||
Ticker = ticker
|
||||
}).ToList();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -174,7 +174,7 @@ public static class GmxMappers
|
||||
Low = Convert.ToDecimal(price.l),
|
||||
Close = Convert.ToDecimal(price.c),
|
||||
Exchange = TradingExchanges.Evm,
|
||||
Ticker = ticker.ToString(),
|
||||
Ticker = ticker,
|
||||
Timeframe = timeframe
|
||||
};
|
||||
}
|
||||
|
||||
@@ -122,7 +122,7 @@ internal static class GmxV2Mappers
|
||||
Low = Convert.ToDecimal(marketPrices[3]),
|
||||
Close = Convert.ToDecimal(marketPrices[4]),
|
||||
Exchange = TradingExchanges.Evm,
|
||||
Ticker = ticker.ToString(),
|
||||
Ticker = ticker,
|
||||
Timeframe = timeframe
|
||||
};
|
||||
}
|
||||
|
||||
@@ -29,12 +29,14 @@ public class Gbc : ISubgraphPrices
|
||||
var unixTimeframe = timeframe.GetUnixInterval();
|
||||
var start = startDate.ToUnixTimestamp();
|
||||
var end = DateTime.UtcNow.ToUnixTimestamp();
|
||||
var feedCondition = $@"{{ tokenAddress: ""_{tickerContract}"", interval: ""_{unixTimeframe}"", timestamp_gte: {start}, timestamp_lte: {end} }}";
|
||||
var feedCondition =
|
||||
$@"{{ tokenAddress: ""_{tickerContract}"", interval: ""_{unixTimeframe}"", timestamp_gte: {start}, timestamp_lte: {end} }}";
|
||||
|
||||
// Fetching prices from graphql ticker
|
||||
for (int i = 0; i < batchMax; i++)
|
||||
{
|
||||
var query = $"{{ pricefeeds(first: {batchSize}, skip: {i * batchSize}, orderBy: timestamp, orderDirection: desc, where: {feedCondition} ) {{ timestamp,o,h,l,c}} }}";
|
||||
var query =
|
||||
$"{{ pricefeeds(first: {batchSize}, skip: {i * batchSize}, orderBy: timestamp, orderDirection: desc, where: {feedCondition} ) {{ timestamp,o,h,l,c}} }}";
|
||||
var graphQuery = new GraphQLRequest
|
||||
{
|
||||
Query = query
|
||||
@@ -75,7 +77,7 @@ public class Gbc : ISubgraphPrices
|
||||
Low = FormatPrice(ohlc.L),
|
||||
Close = FormatPrice(ohlc.C),
|
||||
Exchange = TradingExchanges.Evm,
|
||||
Ticker = ticker.ToString(),
|
||||
Ticker = ticker,
|
||||
Timeframe = timeframe
|
||||
};
|
||||
}
|
||||
@@ -92,7 +94,8 @@ public class Gbc : ISubgraphPrices
|
||||
|
||||
public Task<IEnumerable<Ticker>> GetTickers()
|
||||
{
|
||||
var tickers = new List<Ticker>() {
|
||||
var tickers = new List<Ticker>()
|
||||
{
|
||||
Ticker.BTC,
|
||||
Ticker.LINK,
|
||||
Ticker.ETH,
|
||||
@@ -101,4 +104,4 @@ public class Gbc : ISubgraphPrices
|
||||
|
||||
return Task.FromResult(tickers.AsEnumerable());
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user