diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 167c0c19305203ef81cca3141ee3731daac172b6..f679630a4149e2b58e5e4b90d9a9d82aa2c4723d 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 080720e6e6a8a6accec5441c98b86ad9af090380..9bf2ad570ec3040c476439e28b7a3af7bdad1575 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 99ec0d122f25376eb43b0d6202ec57e8596a46f0..3cb3595379e3696a4874de8907e258144da2afaa 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)