diff --git a/Frontend/Marketplaces/PotatoMarketplaceMock.cs b/Frontend/Marketplaces/PotatoMarketplaceMock.cs index 5134cd904daa343a39dc3ac48433f9ae18a29e44..5f0666219b90dcc9b3d7230132f1ef9337a346a1 100644 --- a/Frontend/Marketplaces/PotatoMarketplaceMock.cs +++ b/Frontend/Marketplaces/PotatoMarketplaceMock.cs @@ -14,7 +14,7 @@ public class PotatoMarketplaceMock( string wethAddress ) : IPotatoMarketPlace { - private const double potatoKgChfPrice = 0.8; //2.02; // source: https://www.blw.admin.ch/blw/de/home/markt/marktbeobachtung/kartoffeln.html + private const double potatoKgChfPrice = 2.02; // source: https://www.blw.admin.ch/blw/de/home/markt/marktbeobachtung/kartoffeln.html private readonly Account account = marketplaceAccount; private readonly Web3 web3 = marketplaceWeb3Client; diff --git a/Frontend/Pages/Index.cshtml.cs b/Frontend/Pages/Index.cshtml.cs index 96342b8a0cd05e583941aad82c3ed70d4d3a56d7..eebbac73b727790683ad497acf33b13e5d82befa 100644 --- a/Frontend/Pages/Index.cshtml.cs +++ b/Frontend/Pages/Index.cshtml.cs @@ -28,47 +28,7 @@ public class IndexModel : PageModel public void OnGet() { - string? fromTokenAddress = null; - string? toTokenAddress = null; - decimal amount = 0; - - if (Request.Query.ContainsKey("swapROCToETH")) - { - fromTokenAddress = _chainSettings.TokenAddress; - toTokenAddress = _chainSettings.WethTokenAddress; - amount = decimal.Parse(Request.Query["swapROCToETH"]); - - }else if (Request.Query.ContainsKey("swapETHToROC")) - { - fromTokenAddress = _chainSettings.WethTokenAddress; - toTokenAddress = _chainSettings.TokenAddress; - amount = decimal.Parse(Request.Query["swapETHToROC"]); - } - if (amount > 0) - { - var amountRecieved = _poolV3Client.SwapAsync(fromTokenAddress!, toTokenAddress!, amount).Result; - } - - if(Request.Query.ContainsKey("balancePool")){ - _rebalancer.MaintainPoolAsync().Wait(); - } - if(Request.Query.ContainsKey("balanceReserves")){ - _rebalancer.MaintainLiquidReservesAsync().Wait(); - } - if(Request.Query.ContainsKey("testDebgger")){ - var breaked = true; - } - if(Request.Query.ContainsKey("ensureRWA")){ - _rebalancer.EnsureCoinSupplyMatchesRwaSupplyAsync().Wait(); - } - if(Request.Query.ContainsKey("buyRwa")){ - amount = decimal.Parse(Request.Query["buyRwa"]); - if(amount>0){ - _potatoStorage.AddPotatoes(new PotatoTransaction{Weight=(double)amount}).Wait(); - }else if(amount<0){ - _potatoStorage.RemovePotatoes((double)Math.Abs(amount)).Wait(); - } - } + } } diff --git a/Frontend/Rebalancer.cs b/Frontend/Rebalancer.cs index 665c5a40f918fa06d1fa6316cd34c86aa66016d7..2995137bbc59fc752bfd9d82937d640de358eabf 100644 --- a/Frontend/Rebalancer.cs +++ b/Frontend/Rebalancer.cs @@ -21,7 +21,7 @@ public class Rebalancer private readonly Account _account; private readonly string _contractAddress; private readonly PrometheusClient _prometheusClient; - private decimal _threshold = 0.01m; + private decimal _threshold = 0.005m; private PoolV3Client _pool; private readonly IPotatoMarketPlace _potatoMarket; private readonly ILogger<Rebalancer> _logger; diff --git a/grafana/dashboards/totalSupply.json b/grafana/dashboards/totalSupply.json index df2ac7f4c7bf04d77ae45bdda794f0f4567c2c14..d9c3f09a12aaf94fe61e66d7230e3be3b144b27b 100644 --- a/grafana/dashboards/totalSupply.json +++ b/grafana/dashboards/totalSupply.json @@ -244,51 +244,31 @@ "fieldConfig": { "defaults": { "color": { - "mode": "palette-classic" - }, - "custom": { - "axisBorderShow": false, - "axisCenteredZero": true, - "axisColorMode": "text", - "axisLabel": "", - "axisPlacement": "auto", - "barAlignment": 0, - "barWidthFactor": 0.6, - "drawStyle": "line", - "fillOpacity": 0, - "gradientMode": "none", - "hideFrom": { - "legend": false, - "tooltip": false, - "viz": false - }, - "insertNulls": false, - "lineInterpolation": "linear", - "lineWidth": 1, - "pointSize": 5, - "scaleDistribution": { - "type": "linear" - }, - "showPoints": "auto", - "spanNulls": false, - "stacking": { - "group": "A", - "mode": "none" - }, - "thresholdsStyle": { - "mode": "off" - } + "mode": "thresholds" }, "mappings": [], "thresholds": { - "mode": "percentage", + "mode": "absolute", "steps": [ { "color": "green", "value": null + }, + { + "color": "semi-dark-orange", + "value": -10000 + }, + { + "color": "semi-dark-green", + "value": -0.005 + }, + { + "color": "semi-dark-orange", + "value": 0.005 } ] - } + }, + "unit": "percentunit" }, "overrides": [] }, @@ -300,16 +280,21 @@ }, "id": 12, "options": { - "legend": { - "calcs": [], - "displayMode": "list", - "placement": "bottom", - "showLegend": true + "colorMode": "value", + "graphMode": "area", + "justifyMode": "auto", + "orientation": "auto", + "percentChangeColorMode": "standard", + "reduceOptions": { + "calcs": [ + "lastNotNull" + ], + "fields": "", + "values": false }, - "tooltip": { - "mode": "single", - "sort": "none" - } + "showPercentChange": false, + "textMode": "auto", + "wideLayout": true }, "pluginVersion": "11.3.0+security-01", "targets": [ @@ -319,97 +304,57 @@ "legendFormat": "current", "range": true, "refId": "A" - }, - { - "datasource": { - "type": "prometheus", - "uid": "PBFA97CFB590B2093" - }, - "editorMode": "code", - "expr": "avg_over_time(Marketplace_Potato_Price_ETH{}[2m]) * 1/avg_over_time(Uniswap_ROCWETH_price_WETH_per_ROC[2m])-1", - "hide": false, - "instant": false, - "legendFormat": "avg over 2min", - "range": true, - "refId": "B" } ], - "title": "ROC Price [kg Potato]", - "type": "timeseries" + "title": "Price Error", + "type": "stat" }, { "datasource": { "type": "prometheus", "uid": "PBFA97CFB590B2093" }, + "description": "Shows the distribution of the reserves to rebalance the pool price", "fieldConfig": { "defaults": { "color": { "mode": "palette-classic" }, "custom": { - "axisBorderShow": false, - "axisCenteredZero": false, - "axisColorMode": "text", - "axisLabel": "", - "axisPlacement": "auto", - "barAlignment": 0, - "barWidthFactor": 0.6, - "drawStyle": "line", - "fillOpacity": 0, - "gradientMode": "none", "hideFrom": { "legend": false, "tooltip": false, "viz": false - }, - "insertNulls": false, - "lineInterpolation": "linear", - "lineWidth": 1, - "pointSize": 5, - "scaleDistribution": { - "type": "linear" - }, - "showPoints": "auto", - "spanNulls": false, - "stacking": { - "group": "A", - "mode": "none" - }, - "thresholdsStyle": { - "mode": "off" } }, "mappings": [], - "thresholds": { - "mode": "absolute", - "steps": [ - { - "color": "green", - "value": null - }, - { - "color": "red", - "value": 80 - } - ] - } + "unit": "currencyCHF" }, "overrides": [] }, "gridPos": { - "h": 7, + "h": 14, "w": 6, "x": 12, "y": 8 }, - "id": 1, + "id": 11, "options": { "legend": { - "calcs": [], "displayMode": "list", "placement": "bottom", - "showLegend": false + "showLegend": true, + "values": [ + "percent" + ] + }, + "pieType": "pie", + "reduceOptions": { + "calcs": [ + "lastNotNull" + ], + "fields": "", + "values": false }, "tooltip": { "mode": "single", @@ -419,19 +364,13 @@ "pluginVersion": "11.3.0+security-01", "targets": [ { - "datasource": { - "type": "prometheus", - "uid": "PBFA97CFB590B2093" - }, - "disableTextWrap": false, - "editorMode": "builder", - "expr": "RoestiCoin_Supply_Total_ROC", - "fullMetaSearch": false, - "includeNullMetadata": true, - "legendFormat": "Total Supply of ROC", - "range": true, - "refId": "A", - "useBackend": false + "editorMode": "code", + "exemplar": false, + "expr": "Rebalancer_Reserves_ROC*Uniswap_ROCWETH_price_WETH_per_ROC*Marketplace_Ethereum_Price_CHF", + "instant": true, + "legendFormat": "Reserves ROC", + "range": false, + "refId": "A" }, { "datasource": { @@ -439,23 +378,23 @@ "uid": "PBFA97CFB590B2093" }, "editorMode": "code", - "expr": "Storage_Potato_Supply_Weight_kg", + "exemplar": false, + "expr": "Rebalancer_Reserves_ETH*Marketplace_Ethereum_Price_CHF", "hide": false, - "instant": false, - "legendFormat": "Potatos in Stock [kg]", - "range": true, + "instant": true, + "legendFormat": "Reserves (W)ETH", + "range": false, "refId": "B" } ], - "title": "Total Supply", - "type": "timeseries" + "title": "Rebalancer Reserves", + "type": "piechart" }, { "datasource": { "type": "prometheus", "uid": "PBFA97CFB590B2093" }, - "description": "How many kilograms of Potato we are holding per ROC. This should be always at 1kg/ROC", "fieldConfig": { "defaults": { "color": { @@ -517,13 +456,13 @@ "x": 18, "y": 8 }, - "id": 7, + "id": 1, "options": { "legend": { "calcs": [], "displayMode": "list", "placement": "bottom", - "showLegend": true + "showLegend": false }, "tooltip": { "mode": "single", @@ -533,78 +472,19 @@ "pluginVersion": "11.3.0+security-01", "targets": [ { - "editorMode": "code", - "expr": "Storage_Potato_Supply_Weight_kg / RoestiCoin_Supply_Total_ROC", - "legendFormat": "__auto", - "range": true, - "refId": "A" - } - ], - "title": "Available Potatos [kg] per ROC", - "type": "timeseries" - }, - { - "datasource": { - "type": "prometheus", - "uid": "PBFA97CFB590B2093" - }, - "description": "Shows the distribution of the reserves to rebalance the pool price", - "fieldConfig": { - "defaults": { - "color": { - "mode": "palette-classic" - }, - "custom": { - "hideFrom": { - "legend": false, - "tooltip": false, - "viz": false - } + "datasource": { + "type": "prometheus", + "uid": "PBFA97CFB590B2093" }, - "mappings": [], - "unit": "currencyCHF" - }, - "overrides": [] - }, - "gridPos": { - "h": 7, - "w": 6, - "x": 12, - "y": 15 - }, - "id": 11, - "options": { - "legend": { - "displayMode": "list", - "placement": "bottom", - "showLegend": true, - "values": [ - "percent" - ] - }, - "pieType": "pie", - "reduceOptions": { - "calcs": [ - "lastNotNull" - ], - "fields": "", - "values": false - }, - "tooltip": { - "mode": "single", - "sort": "none" - } - }, - "pluginVersion": "11.3.0+security-01", - "targets": [ - { - "editorMode": "code", - "exemplar": false, - "expr": "Rebalancer_Reserves_ROC*Uniswap_ROCWETH_price_WETH_per_ROC*Marketplace_Ethereum_Price_CHF", - "instant": true, - "legendFormat": "Reserves ROC", - "range": false, - "refId": "A" + "disableTextWrap": false, + "editorMode": "builder", + "expr": "RoestiCoin_Supply_Total_ROC", + "fullMetaSearch": false, + "includeNullMetadata": true, + "legendFormat": "Total Supply of ROC", + "range": true, + "refId": "A", + "useBackend": false }, { "datasource": { @@ -612,17 +492,16 @@ "uid": "PBFA97CFB590B2093" }, "editorMode": "code", - "exemplar": false, - "expr": "Rebalancer_Reserves_ETH*Marketplace_Ethereum_Price_CHF", + "expr": "Storage_Potato_Supply_Weight_kg", "hide": false, - "instant": true, - "legendFormat": "Reserves (W)ETH", - "range": false, + "instant": false, + "legendFormat": "Potatos in Stock [kg]", + "range": true, "refId": "B" } ], - "title": "Rebalancer Reserves", - "type": "piechart" + "title": "Total Supply", + "type": "timeseries" }, { "datasource": { @@ -875,11 +754,11 @@ }, "gridPos": { "h": 8, - "w": 12, + "w": 6, "x": 12, "y": 22 }, - "id": 8, + "id": 4, "options": { "legend": { "calcs": [], @@ -895,11 +774,15 @@ "pluginVersion": "11.3.0+security-01", "targets": [ { + "disableTextWrap": false, "editorMode": "code", - "expr": "avg_over_time(Marketplace_Ethereum_Price_CHF[5m])", - "legendFormat": "ETH in CHF averaged 5min", + "expr": "Marketplace_Ethereum_Price_CHF * Uniswap_ROCWETH_price_WETH_per_ROC", + "fullMetaSearch": false, + "includeNullMetadata": true, + "legendFormat": "price", "range": true, - "refId": "A" + "refId": "A", + "useBackend": false }, { "datasource": { @@ -907,10 +790,10 @@ "uid": "PBFA97CFB590B2093" }, "editorMode": "code", - "expr": "avg_over_time(Marketplace_Ethereum_Price_CHF[2m])", + "expr": "avg_over_time(Marketplace_Ethereum_Price_CHF[5m]) * avg_over_time(Uniswap_ROCWETH_price_WETH_per_ROC[5m])", "hide": false, "instant": false, - "legendFormat": "ETH in CHF averaged 2min", + "legendFormat": "Price average over 5 min", "range": true, "refId": "B" }, @@ -920,15 +803,15 @@ "uid": "PBFA97CFB590B2093" }, "editorMode": "code", - "expr": "Marketplace_Ethereum_Price_CHF", + "expr": "avg_over_time(Marketplace_Ethereum_Price_CHF[2m]) * avg_over_time(Uniswap_ROCWETH_price_WETH_per_ROC[2m])", "hide": false, "instant": false, - "legendFormat": "ETH in CHF", + "legendFormat": "Price average over 2 min", "range": true, "refId": "C" } ], - "title": "ETH price in CHF", + "title": "ROC Price in CHF", "type": "timeseries" }, { @@ -993,11 +876,11 @@ }, "gridPos": { "h": 8, - "w": 12, - "x": 0, - "y": 30 + "w": 6, + "x": 18, + "y": 22 }, - "id": 4, + "id": 8, "options": { "legend": { "calcs": [], @@ -1013,15 +896,11 @@ "pluginVersion": "11.3.0+security-01", "targets": [ { - "disableTextWrap": false, "editorMode": "code", - "expr": "Marketplace_Ethereum_Price_CHF * Uniswap_ROCWETH_price_WETH_per_ROC", - "fullMetaSearch": false, - "includeNullMetadata": true, - "legendFormat": "price", + "expr": "avg_over_time(Marketplace_Ethereum_Price_CHF[5m])", + "legendFormat": "ETH in CHF averaged 5min", "range": true, - "refId": "A", - "useBackend": false + "refId": "A" }, { "datasource": { @@ -1029,10 +908,10 @@ "uid": "PBFA97CFB590B2093" }, "editorMode": "code", - "expr": "avg_over_time(Marketplace_Ethereum_Price_CHF[5m]) * avg_over_time(Uniswap_ROCWETH_price_WETH_per_ROC[5m])", + "expr": "avg_over_time(Marketplace_Ethereum_Price_CHF[2m])", "hide": false, "instant": false, - "legendFormat": "Price average over 5 min", + "legendFormat": "ETH in CHF averaged 2min", "range": true, "refId": "B" }, @@ -1042,15 +921,15 @@ "uid": "PBFA97CFB590B2093" }, "editorMode": "code", - "expr": "avg_over_time(Marketplace_Ethereum_Price_CHF[2m]) * avg_over_time(Uniswap_ROCWETH_price_WETH_per_ROC[2m])", + "expr": "Marketplace_Ethereum_Price_CHF", "hide": false, "instant": false, - "legendFormat": "Price average over 2 min", + "legendFormat": "ETH in CHF", "range": true, "refId": "C" } ], - "title": "ROC Price in CHF", + "title": "ETH price in CHF", "type": "timeseries" } ], @@ -1066,7 +945,7 @@ }, "timepicker": {}, "timezone": "browser", - "title": "Total Supply of ROC", + "title": "ROC - RöstiCoin Overview Dashboard", "uid": "ce3nybz6khudcd", "version": 15, "weekStart": ""