From 1e48d657dc6ee8f583e69fd486700f5eed2f7777 Mon Sep 17 00:00:00 2001 From: David Hintermann <David.Hintermann@ost.ch> Date: Mon, 2 Dec 2024 09:29:36 +0000 Subject: [PATCH] wip: prepare for tests --- .devcontainer/devcontainer.json | 4 +++- Frontend/Pages/Index.cshtml.cs | 11 ++++++++++- Frontend/Rebalancer.cs | 4 ++-- 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 167c0c1..f679630 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -9,7 +9,9 @@ "extensions": [ "ms-azuretools.vscode-docker", "ms-dotnettools.csdevkit", - "hbenl.vscode-test-explorer" + "hbenl.vscode-test-explorer", + "GitHub.copilot", + "GitHub.copilot-chat" ] } }, diff --git a/Frontend/Pages/Index.cshtml.cs b/Frontend/Pages/Index.cshtml.cs index 080720e..9bf2ad5 100644 --- a/Frontend/Pages/Index.cshtml.cs +++ b/Frontend/Pages/Index.cshtml.cs @@ -11,13 +11,15 @@ public class IndexModel : PageModel private readonly PoolV3Client _poolV3Client; private readonly ChainSettings _chainSettings; private readonly Account _account; + private readonly Rebalancer _rebalancer; - public IndexModel(ILogger<IndexModel> logger, Web3 web3, ChainSettings chainSettings, Account account) + public IndexModel(ILogger<IndexModel> logger, Web3 web3, ChainSettings chainSettings, Account account, Rebalancer rebalancer) { _logger = logger; _poolV3Client = new PoolV3Client(web3, chainSettings, account); _chainSettings = chainSettings; _account = account; + _rebalancer = rebalancer; } public void OnGet() @@ -42,5 +44,12 @@ public class IndexModel : PageModel { var amountRecieved = _poolV3Client.SwapAsync(fromTokenAddress!, toTokenAddress!, amount).Result; } + + if(Request.Query.ContainsKey("balancePool")){ + _rebalancer.MaintainPoolAsync().Wait(); + } + if(Request.Query.ContainsKey("balanceReserves")){ + _rebalancer.MaintainLiquidReservesAsync().Wait(); + } } } diff --git a/Frontend/Rebalancer.cs b/Frontend/Rebalancer.cs index 99ec0d1..3cb3595 100644 --- a/Frontend/Rebalancer.cs +++ b/Frontend/Rebalancer.cs @@ -124,7 +124,7 @@ public class Rebalancer } } - public async Task EnsureCoinSupplyMatchesRwaSupply() + public async Task EnsureCoinSupplyMatchesRwaSupplyAsync() { var rwaSupply = (decimal)_potatoStorage.SupplyWeight(); var tokenSupply = await _token0Client.TotalSupply(); @@ -145,7 +145,7 @@ public class Rebalancer if(burnable < shouldBurn){ _logger.LogError("Trigger rebalancing reserves and try again"); await MaintainLiquidReservesAsync(); - await EnsureCoinSupplyMatchesRwaSupply(); + await EnsureCoinSupplyMatchesRwaSupplyAsync(); } } else if (rwaSupply > tokenSupply) -- GitLab