From 30f5f8de6edd2f142793542bb1bfde7ce2a53797 Mon Sep 17 00:00:00 2001 From: Daniel McCartney Date: Thu, 24 Oct 2024 01:14:04 -0700 Subject: [PATCH] feat: cleanup negative more in NS and describe deposits required --- web/src/pages/NodeSetPage.js | 256 ++++++++++++++++++++++++++++------- 1 file changed, 210 insertions(+), 46 deletions(-) diff --git a/web/src/pages/NodeSetPage.js b/web/src/pages/NodeSetPage.js index 218e101..191e9e6 100644 --- a/web/src/pages/NodeSetPage.js +++ b/web/src/pages/NodeSetPage.js @@ -8,8 +8,10 @@ import { CardContent, CardHeader, Chip, + CircularProgress, Divider, Grid, + Paper, Stack, Tooltip, Typography, @@ -514,11 +516,12 @@ function NodeSetMiniPoolsColumn() { let rplStakedInEth = rplStake ?.mul(rplEthPrice) .div(ethers.utils.parseEther("1")); - let { data: minipoolsInOrder } = useK.SuperNodeAccount.Find.MinipoolCreated({ - args: [null, null], - from: 0, - to: "latest", - }); + let { isLoading, data: minipoolsInOrder } = + useK.SuperNodeAccount.Find.MinipoolCreated({ + args: [null, null], + from: 0, + to: "latest", + }); let minipools = _.reverse(_.clone(minipoolsInOrder || [])); let activeMinipools = minipools || []; let maxMinipoolCountByRpl = rplStakedInEth @@ -539,6 +542,33 @@ function NodeSetMiniPoolsColumn() { .div(ethers.utils.parseEther("24")) .toNumber(); let moreMinipoolCountByRpl = maxMinipoolCountByRpl - activeMinipools.length; + let rplPerMinipool = ethers.utils + .parseEther("24") + .mul(minimumStakeRatio || ethers.utils.parseEther("1")) + .div(rplEthPrice || ethers.utils.parseEther("1")); + let moreRplRequiredForAnother = + moreMinipoolCountByRpl > 0 + ? ethers.constants.Zero + : ethers.utils + .parseEther("24") + .mul(activeMinipools.length + 1) + .mul(minimumStakeRatio || ethers.utils.parseEther("1")) + .div(ethers.utils.parseEther("1")) + .sub(rplStakedInEth || ethers.utils.parseEther("1")) + .mul(ethers.utils.parseEther("1")) + .div(rplEthPrice || ethers.utils.parseEther("1")); + let moreXREthRequiredForAnother = + moreMinipoolCountByXREth > 0 + ? ethers.constants.Zero + : ethers.utils + .parseEther("8") + .sub(xREthBalance?.value || ethers.constants.Zero); + let moreREthRequiredForAnother = + moreMinipoolCountByREth > 0 + ? ethers.constants.Zero + : ethers.utils + .parseEther("24") + .sub(rEthBalance?.value || ethers.constants.Zero); let moreMinipoolCount = Math.min( moreMinipoolCountByXREth, moreMinipoolCountByREth, @@ -682,9 +712,17 @@ function NodeSetMiniPoolsColumn() { sx={{ cursor: "inherit" }} component="span" size="small" - label={Number( - activeMinipools.length - ).toLocaleString()} + label={ + isLoading ? ( + + ) : ( + Number(activeMinipools.length).toLocaleString() + ) + } /> + ) : ( + operators.length + ) + } /> - + more from available deposits @@ -881,7 +933,6 @@ function NodeSetMiniPoolsColumn() { - + - + @@ -947,7 +1002,6 @@ function NodeSetMiniPoolsColumn() { - + - + @@ -1015,7 +1073,7 @@ function NodeSetMiniPoolsColumn() { - + - + - - - more @ - - - - % borrow limit - + + + + more @ + + + + % borrow limit + + + + +      ≈ + + + + {isLoading || moreMinipoolCount > 0 || ( + + + + deposits required for the next minipool + + + {moreRplRequiredForAnother.gt(0) && ( + + + + from + + + + )} + {moreXREthRequiredForAnother.gt(0) && ( + + + + from + + + + )} + {moreREthRequiredForAnother.gt(0) && ( + + + + from + + + rETH + + + )} + + + + )}