diff --git a/Dockerfile b/Dockerfile index 835f50d..eafa9ac 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,8 +1,8 @@ -FROM mcr.microsoft.com/dotnet/runtime:8.0.8 AS base +FROM mcr.microsoft.com/dotnet/runtime:9.0.0 AS base USER $APP_UID WORKDIR /app -FROM mcr.microsoft.com/dotnet/sdk:8.0.402 AS build +FROM mcr.microsoft.com/dotnet/sdk:9.0.100 AS build ARG BUILD_CONFIGURATION=Release ARG BUILD_NUMBER diff --git a/chainflip-lp/Configuration/BotConfiguration.cs b/chainflip-lp/Configuration/BotConfiguration.cs index 0501868..65777b1 100644 --- a/chainflip-lp/Configuration/BotConfiguration.cs +++ b/chainflip-lp/Configuration/BotConfiguration.cs @@ -1,5 +1,6 @@ namespace ChainflipLp.Configuration { + using System.Collections.Generic; using System.ComponentModel.DataAnnotations; using System.Diagnostics.CodeAnalysis; @@ -78,9 +79,21 @@ public bool? AnnounceTickChanges get; init; } + public int? AmountIgnoreLimit + { + get; init; + } + [Required] [NotNull] - public int? AmountIgnoreLimit + public List? Whitelist + { + get; init; + } + + [Required] + [NotNull] + public bool? NoWaitMode { get; init; } @@ -143,5 +156,10 @@ public int? MaxSellTick { get; init; } + + public int? AmountIgnoreLimit + { + get; init; + } } } \ No newline at end of file diff --git a/chainflip-lp/Model/OrderManager/CleanupDustOrders.cs b/chainflip-lp/Model/OrderManager/CleanupDustOrders.cs index 46a8b3b..bf51343 100644 --- a/chainflip-lp/Model/OrderManager/CleanupDustOrders.cs +++ b/chainflip-lp/Model/OrderManager/CleanupDustOrders.cs @@ -24,7 +24,8 @@ public partial class OrderManager "quote_asset": { "chain": "Ethereum", "asset": "USDC" }, "side": "REPLACE_SIDE", "id": "REPLACE_ID", - "sell_amount": "0" + "sell_amount": "0", + "wait_for": "REPLACE_WAIT_FOR" } } """; @@ -82,7 +83,8 @@ private async Task CleanupDustOrder( .Replace("REPLACE_CHAIN", chain) .Replace("REPLACE_ASSET", asset) .Replace("REPLACE_ID", order.Id) - .Replace("REPLACE_SIDE", side); + .Replace("REPLACE_SIDE", side) + .Replace("REPLACE_WAIT_FOR", _configuration.NoWaitMode.Value ? "NoWait" : "Finalized"); var response = await client.PostAsync( string.Empty, diff --git a/chainflip-lp/Model/OrderManager/OrderManager.cs b/chainflip-lp/Model/OrderManager/OrderManager.cs index d0a5e16..22f2ef1 100644 --- a/chainflip-lp/Model/OrderManager/OrderManager.cs +++ b/chainflip-lp/Model/OrderManager/OrderManager.cs @@ -90,7 +90,7 @@ private async Task NotifyTelegram( try { var message = await telegramClient - .SendMessageAsync( + .SendRequest( new SendMessageRequest { ChatId = new ChatId(_configuration.TelegramChannelId.Value), @@ -116,7 +116,7 @@ private async Task NotifyTelegram( return; await telegramClient - .SetMessageReactionAsync( + .SendRequest( new SetMessageReactionRequest { ChatId = new ChatId(_configuration.TelegramChannelId.Value), diff --git a/chainflip-lp/Model/OrderManager/PlaceBuyOrders.cs b/chainflip-lp/Model/OrderManager/PlaceBuyOrders.cs index daa8290..03213b3 100644 --- a/chainflip-lp/Model/OrderManager/PlaceBuyOrders.cs +++ b/chainflip-lp/Model/OrderManager/PlaceBuyOrders.cs @@ -31,7 +31,8 @@ public partial class OrderManager "tick": REPLACE_BUY_TICK, "amount_change": { "increase": "REPLACE_AMOUNT" - } + }, + "wait_for": "REPLACE_WAIT_FOR" } } """; @@ -159,7 +160,8 @@ private async Task PlaceBuyOrder( .Replace("REPLACE_ASSET", pool.Asset) .Replace("REPLACE_ID", GenerateAssetId(pool.Chain, pool.Asset, "buy")) .Replace("REPLACE_AMOUNT", balance) - .Replace("REPLACE_BUY_TICK", pool.MinBuyTick.Value.ToString()); + .Replace("REPLACE_BUY_TICK", pool.MinBuyTick.Value.ToString()) + .Replace("REPLACE_WAIT_FOR", _configuration.NoWaitMode.Value ? "NoWait" : "Finalized"); var response = await client.PostAsync( string.Empty, diff --git a/chainflip-lp/Model/OrderManager/PlaceSellOrders.cs b/chainflip-lp/Model/OrderManager/PlaceSellOrders.cs index 9f760c2..c42c8f5 100644 --- a/chainflip-lp/Model/OrderManager/PlaceSellOrders.cs +++ b/chainflip-lp/Model/OrderManager/PlaceSellOrders.cs @@ -27,7 +27,8 @@ public partial class OrderManager "tick": REPLACE_SELL_TICK, "amount_change": { "increase": "REPLACE_AMOUNT" - } + }, + "wait_for": "REPLACE_WAIT_FOR" } } """; @@ -88,7 +89,8 @@ private async Task PlaceSellOrder( .Replace("REPLACE_ASSET", pool.Asset) .Replace("REPLACE_ID", GenerateAssetId(pool.Chain, pool.Asset, "sell")) .Replace("REPLACE_AMOUNT", balance) - .Replace("REPLACE_SELL_TICK", pool.MinSellTick.Value.ToString()); + .Replace("REPLACE_SELL_TICK", pool.MinSellTick.Value.ToString()) + .Replace("REPLACE_WAIT_FOR", _configuration.NoWaitMode.Value ? "NoWait" : "Finalized"); var response = await client.PostAsync( string.Empty, diff --git a/chainflip-lp/Model/OrderManager/UpdateBuyOrders.cs b/chainflip-lp/Model/OrderManager/UpdateBuyOrders.cs index 54129c9..e8d675c 100644 --- a/chainflip-lp/Model/OrderManager/UpdateBuyOrders.cs +++ b/chainflip-lp/Model/OrderManager/UpdateBuyOrders.cs @@ -27,7 +27,8 @@ public partial class OrderManager "tick": REPLACE_BUY_TICK, "amount_change": { "increase": "0x0" - } + }, + "wait_for": "REPLACE_WAIT_FOR" } } """; @@ -40,13 +41,16 @@ private async Task UpdateBuyOrders( ITelegramBotClient telegramClient, CancellationToken cancellationToken) { + var amountIgnoreLimit = ourOrders.AmountIgnoreLimit ?? _configuration.AmountIgnoreLimit ?? 0; + var otherOrders = allPoolOrders .Where(x => x.Chain == ourOrders.Chain && x.Asset == ourOrders.Asset) .SelectMany(x => x.Buys) - .Where(x => x.Amount.ToNumeric() > _configuration.AmountIgnoreLimit.Value) + .Where(x => x.Amount.ToNumeric() > amountIgnoreLimit) .Where(x => x.LiquidityProvider != _configuration.LpAccount) + .Where(x => !_configuration.Whitelist.Contains(x.LiquidityProvider)) .Where(x => x.Tick <= ourOrders.MaxBuyTick) .ToList(); @@ -111,7 +115,8 @@ private async Task UpdateBuyOrder( .Replace("REPLACE_CHAIN", chain) .Replace("REPLACE_ASSET", asset) .Replace("REPLACE_ID", GenerateAssetId(chain, asset, "buy")) - .Replace("REPLACE_BUY_TICK", newTick.ToString()); + .Replace("REPLACE_BUY_TICK", newTick.ToString()) + .Replace("REPLACE_WAIT_FOR", _configuration.NoWaitMode.Value ? "NoWait" : "Finalized"); var response = await client.PostAsync( string.Empty, diff --git a/chainflip-lp/Model/OrderManager/UpdateSellOrders.cs b/chainflip-lp/Model/OrderManager/UpdateSellOrders.cs index 2f47786..b78fabd 100644 --- a/chainflip-lp/Model/OrderManager/UpdateSellOrders.cs +++ b/chainflip-lp/Model/OrderManager/UpdateSellOrders.cs @@ -27,7 +27,8 @@ public partial class OrderManager "tick": REPLACE_SELL_TICK, "amount_change": { "increase": "0x0" - } + }, + "wait_for": "REPLACE_WAIT_FOR" } } """; @@ -40,13 +41,16 @@ private async Task UpdateSellOrders( ITelegramBotClient telegramClient, CancellationToken cancellationToken) { + var amountIgnoreLimit = ourOrders.AmountIgnoreLimit ?? _configuration.AmountIgnoreLimit ?? 0; + var otherOrders = allPoolOrders .Where(x => x.Chain == ourOrders.Chain && x.Asset == ourOrders.Asset) .SelectMany(x => x.Sells) - .Where(x => x.Amount.ToNumeric() > _configuration.AmountIgnoreLimit.Value) + .Where(x => x.Amount.ToNumeric() > amountIgnoreLimit) .Where(x => x.LiquidityProvider != _configuration.LpAccount) + .Where(x => !_configuration.Whitelist.Contains(x.LiquidityProvider)) .Where(x => x.Tick >= ourOrders.MaxSellTick) .ToList(); @@ -111,7 +115,8 @@ private async Task UpdateSellOrder( .Replace("REPLACE_CHAIN", chain) .Replace("REPLACE_ASSET", asset) .Replace("REPLACE_ID", GenerateAssetId(chain, asset, "sell")) - .Replace("REPLACE_SELL_TICK", newTick.ToString()); + .Replace("REPLACE_SELL_TICK", newTick.ToString()) + .Replace("REPLACE_WAIT_FOR", _configuration.NoWaitMode.Value ? "NoWait" : "Finalized"); var response = await client.PostAsync( string.Empty, diff --git a/chainflip-lp/Model/PoolOrders/PoolOrders.cs b/chainflip-lp/Model/PoolOrders/PoolOrders.cs index dba197a..f34f1c7 100644 --- a/chainflip-lp/Model/PoolOrders/PoolOrders.cs +++ b/chainflip-lp/Model/PoolOrders/PoolOrders.cs @@ -17,6 +17,7 @@ public partial class PoolOrders public string Chain => _pool.Chain; public string Asset => _pool.Asset; + public int? AmountIgnoreLimit => _pool.AmountIgnoreLimit; public IEnumerable Buys => _poolOrders.Result.LimitOrders.Buys; diff --git a/chainflip-lp/Runner.cs b/chainflip-lp/Runner.cs index bf642f2..b27be83 100644 --- a/chainflip-lp/Runner.cs +++ b/chainflip-lp/Runner.cs @@ -96,6 +96,10 @@ await account.PlaceOrders( private async Task WaitForNextLoop(CancellationToken ct) { var delay = _configuration.QueryDelay.Value.RandomizeTime(); + + if (_configuration.NoWaitMode.Value) + delay = 4000; + _logger.LogInformation("Waiting {QueryDelay}ms for next check.", delay); await Task.Delay(delay, ct); } diff --git a/chainflip-lp/appsettings.json b/chainflip-lp/appsettings.json index 6b93416..679d74d 100644 --- a/chainflip-lp/appsettings.json +++ b/chainflip-lp/appsettings.json @@ -1,7 +1,13 @@ { "Bot": { "TelegramToken": "7085961150:AAEPMX3o5Lh99E2qg5iUh6ePmu6xM2jgYaI", - "AmountIgnoreLimit": 0 + "AmountIgnoreLimit": 0, + "NoWaitMode": "false", + "Whitelist": [ + "cFLBKavxvThwqLWNr7cTwtqhYD6jDqXM31d6QoTLvuK4X78ve", + "cFJYzUFU97Y849kbKvyj7br1CUumnbqWHJKDcfPFoKRqq6Zxz", + "cFN1G2P1ogDXGX897LrMv3XNRcTQ2pYbXWiaF9D7eqkAgS4aC" + ] }, "Serilog": { diff --git a/chainflip-lp/chainflip-lp.csproj b/chainflip-lp/chainflip-lp.csproj index 7e63fb8..f631262 100644 --- a/chainflip-lp/chainflip-lp.csproj +++ b/chainflip-lp/chainflip-lp.csproj @@ -2,8 +2,8 @@ latest - net8.0 - 8.0.8 + net9.0 + 9.0.0 true $(MSBuildProjectName) @@ -53,28 +53,28 @@ - + - - - - - - - - - - - - + + + + + + + + + + + + - - + + - + diff --git a/global.json b/global.json index 80756ae..3840163 100644 --- a/global.json +++ b/global.json @@ -1,8 +1,8 @@ { "sdk": { - "version": "8.0.402" + "version": "9.0.100" }, "clr": { - "version": "8.0.8" + "version": "9.0.0" } } \ No newline at end of file