From f006bcff375aa75b0bcfdfe340391b98d64a5f9c Mon Sep 17 00:00:00 2001 From: Bharath Vedartham Date: Thu, 4 Jan 2024 20:05:11 +0530 Subject: [PATCH 1/8] refactor display --- build-release.sh | 4 +-- shared/types/api/node.go | 1 + shared/version.go | 4 +-- stader-cli/node/claim-rewards.go | 9 +++--- stader-cli/node/status.go | 55 ++++++++------------------------ stader-lib/utils/eth/units.go | 19 +++++++++++ stader/api/node/claim-rewards.go | 2 ++ 7 files changed, 44 insertions(+), 50 deletions(-) diff --git a/build-release.sh b/build-release.sh index 8606a2ed2..048369316 100755 --- a/build-release.sh +++ b/build-release.sh @@ -27,8 +27,8 @@ # === Functions === # ================= -DOCKER_ACCOUNT=staderlabs -S3_BUCKET=stader-cli-permissionless/eth/releases/stader-node-build/permissionless +DOCKER_ACCOUNT=staderdev +S3_BUCKET=stader-cli-beta # Print a failure message to stderr and exit fail() { diff --git a/shared/types/api/node.go b/shared/types/api/node.go index 7477aeb78..0021356f3 100644 --- a/shared/types/api/node.go +++ b/shared/types/api/node.go @@ -410,6 +410,7 @@ type ClaimRewards struct { Error string `json:"error"` OperatorRewardsBalance *big.Int `json:"operatorRewardsBalance"` OperatorRewardAddress common.Address `json:"operatorRewardAddress"` + RewardsClaimed *big.Int `json:"rewardsClaimed"` TxHash common.Hash `json:"txHash"` } diff --git a/shared/version.go b/shared/version.go index 3e99892f2..2f4f82103 100644 --- a/shared/version.go +++ b/shared/version.go @@ -20,8 +20,8 @@ along with this program. If not, see . package shared const BinaryBucket string = "/stader-node-build/permissionless" -const DockerAccount string = "staderlabs" -const StaderVersion string = "1.4.4" +const DockerAccount string = "staderdev" +const StaderVersion string = "1.5.7-up-test" const Logo string = ` _____ _ _ _ _ 𝅺 diff --git a/stader-cli/node/claim-rewards.go b/stader-cli/node/claim-rewards.go index 3c243b2a7..95a1b240f 100644 --- a/stader-cli/node/claim-rewards.go +++ b/stader-cli/node/claim-rewards.go @@ -7,7 +7,6 @@ import ( "github.com/stader-labs/stader-node/shared/services/gas" "github.com/stader-labs/stader-node/shared/services/stader" cliutils "github.com/stader-labs/stader-node/shared/utils/cli" - "github.com/stader-labs/stader-node/shared/utils/math" "github.com/stader-labs/stader-node/stader-lib/utils/eth" "github.com/urfave/cli" ) @@ -50,9 +49,9 @@ func ClaimRewards(c *cli.Context) error { if sdStatusResponse.SDStatus.SdUtilizerLatestBalance.Cmp(big.NewInt(0)) > 0 { totalFee := sdStatus.AccumulatedInterest - fmt.Printf("You need to first pay %f and close the utilization position to get back your funds. Execute the following command to repay your utilized SD stader-cli repay-sd --amount \n", eth.WeiToEth(totalFee)) + fmt.Printf("You need to first pay %s and close the utilization position to get back your funds. Execute the following command to repay your utilized SD stader-cli repay-sd --amount \n", eth.DisplayAmountInUnits(totalFee, "sd")) - fmt.Printf("Based on the current Health Factor, you can claim upto %.6f ETH.\n", eth.WeiToEth(canClaimRewardsResponse.WithdrawableInEth)) + fmt.Printf("Based on the current Health Factor, you can claim upto %s.\n", eth.DisplayAmountInUnits(canClaimRewardsResponse.WithdrawableInEth, "eth")) fmt.Printf("Note: Please repay your utilized SD by using the following command to claim the remaining ETH: stader-cli sd repay --amount .\n\n") } @@ -75,13 +74,13 @@ func ClaimRewards(c *cli.Context) error { if err != nil { return err } - fmt.Printf("Withdrawing %.6f ETH Rewards to Operator Reward Address: %s\n\n", math.RoundDown(eth.WeiToEth(res.OperatorRewardsBalance), 6), res.OperatorRewardAddress) + fmt.Printf("Withdrawing %s Rewards to Operator Reward Address: %s\n\n", eth.DisplayAmountInUnits(res.RewardsClaimed, "eth"), res.OperatorRewardAddress) cliutils.PrintTransactionHash(staderClient, res.TxHash) if _, err = staderClient.WaitForTransaction(res.TxHash); err != nil { return err } // Log & return - fmt.Printf("Successful withdrawal of %.6f ETH to Operator Reward Address: %s\n\n", math.RoundDown(eth.WeiToEth(res.OperatorRewardsBalance), 6), res.OperatorRewardAddress) + fmt.Printf("Successful withdrawal of %s to Operator Reward Address: %s\n\n", eth.DisplayAmountInUnits(res.RewardsClaimed, "eth"), res.OperatorRewardAddress) return nil } diff --git a/stader-cli/node/status.go b/stader-cli/node/status.go index a713f1a9e..904a9f94e 100644 --- a/stader-cli/node/status.go +++ b/stader-cli/node/status.go @@ -115,18 +115,11 @@ func getNodeStatus(c *cli.Context) error { } if status.OperatorRewardCollectorBalance.Cmp(big.NewInt(0)) > 0 { - val, denom := eth.WeiToEthWithValCheck(status.OperatorRewardCollectorBalance) - if denom == "eth" { - fmt.Printf( - "The Operator has aggregated total claims of %.6f ETH in the claim vault\n", - math.RoundDown(val, 6)) - fmt.Printf("To transfer the claims to your operator reward address use the %sstader-cli node claim-rewards%s command\n\n", log.ColorGreen, log.ColorReset) - } else { - fmt.Printf( - "The Operator has aggregated total claims of %.6f gwei in the claim vault\n", - math.RoundDown(val, 6)) - fmt.Printf("To transfer the claims to your operator reward address use the %sstader-cli node claim-rewards%s command\n\n", log.ColorGreen, log.ColorReset) - } + fmt.Printf( + "The Operator has aggregated total claims of %s in the claim vault\n", + eth.DisplayAmountInUnits(status.OperatorRewardCollectorBalance, "eth")) + fmt.Printf("To transfer the claims to your operator reward address use the %sstader-cli node claim-rewards%s command\n\n", log.ColorGreen, log.ColorReset) + } fmt.Printf( @@ -182,42 +175,22 @@ func getNodeStatus(c *cli.Context) error { math.RoundDown(eth.WeiToEth(sdStatus.SdUtilizedBalance), eth.Decimal)) if totalRegisteredValidators.Cmp(big.NewInt(0)) != 0 { - val, denom := eth.WeiToEthWithValCheck(sdStatus.SdCollateralRequireAmount) - if denom == "eth" { - fmt.Printf( - "Note: For the %d validator, the minimum SD collateral should be %.6f SD (%s) to be eligible for the SD rewards. Please ensure that the SD collateral percentage is greater than %s. The SD collateral snapshots are taken daily at a random block, and if the SD collateral value falls below the %s limit, the node operator will not earn SD rewards for that day.\n\n", - totalRegisteredValidators, - math.RoundDown(val, eth.Decimal), - "10%", "10%", "10%") - } else { - fmt.Printf( - "Note: For the %d validator, the minimum (gwei) SD collateral should be %.6f SD (%s) to be eligible for the SD rewards. Please ensure that the SD collateral percentage is greater than %s. The SD collateral snapshots are taken daily at a random block, and if the SD collateral value falls below the %s limit, the node operator will not earn SD rewards for that day.\n\n", - totalRegisteredValidators, - math.RoundDown(val, eth.Decimal), - "10%", "10%", "10%") - } + fmt.Printf( + "Note: For the %d validator, the minimum SD collateral should be %s (%s) to be eligible for the SD rewards. Please ensure that the SD collateral percentage is greater than %s. The SD collateral snapshots are taken daily at a random block, and if the SD collateral value falls below the %s limit, the node operator will not earn SD rewards for that day.\n\n", + totalRegisteredValidators, + eth.DisplayAmountInUnits(sdStatus.SdCollateralRequireAmount, "sd"), + "10%", "10%", "10%") + } else { fmt.Println("") } fmt.Printf("%s=== SD utilization Details ===%s\n", log.ColorGreen, log.ColorReset) - val, denom := eth.WeiToEthWithValCheck(sdStatus.SdUtilizedBalance) - if denom == "eth" { - fmt.Printf("The Operator has utilized %.6f SD from the Utility Pool.\n\n", - math.RoundDown(val, eth.Decimal)) - } else { - fmt.Printf("The Operator has utilized %.6f gwei SD from the Utility Pool.\n\n", math.RoundDown(val, eth.Decimal)) - } + fmt.Printf("The Operator has utilized %s from the Utility Pool.\n\n", eth.DisplayAmountInUnits(sdStatus.SdUtilizedBalance, "eth")) - val, denom = eth.WeiToEthWithValCheck(sdStatus.SdUtilizedBalance) - if denom == "eth" { - fmt.Printf("The Operator has a current Utilization Position of %.6f SD. (including the utilization fee)\n Note: For repayment of your utilized SD, please use the `stader-cli node repay-sd ` command.\n\n", - math.RoundDown(val, eth.Decimal)) - } else { - fmt.Printf("The Operator has a current Utilization Position of %.6f gwei SD. (including the utilization fee)\n Note: For repayment of your utilized SD, please use the `stader-cli node repay-sd ` command.\n\n", - math.RoundDown(val, eth.Decimal)) - } + fmt.Printf("The Operator has a current Utilization Position of %s. (including the utilization fee)\n Note: For repayment of your utilized SD, please use the `stader-cli node repay-sd ` command.\n\n", + eth.DisplayAmountInUnits(sdStatus.SdUtilizerLatestBalance, "sd")) maxUtilizable := new(big.Int).Sub(sdStatus.SdMaxUtilizableAmount, sdStatus.SdUtilizerLatestBalance) if maxUtilizable.Cmp(sdStatus.PoolAvailableSDBalance) > 0 { diff --git a/stader-lib/utils/eth/units.go b/stader-lib/utils/eth/units.go index 2593051a0..bfaf8b2c0 100644 --- a/stader-lib/utils/eth/units.go +++ b/stader-lib/utils/eth/units.go @@ -43,6 +43,25 @@ func WeiToEthWithValCheck(wei *big.Int) (float64, string) { return WeiToEth(wei), "eth" } +func DisplayAmountInUnits(wei *big.Int, denom string) string { + gweiDenom := " gwei" + if denom == "SD" { + gweiDenom = " gwei SD" + } + regDenom := " ETH" + if denom == "SD" { + regDenom = " SD" + } + + if wei == nil { + return "" + } + if wei.Cmp(big.NewInt(Threshold)) < 0 { + return strconv.FormatFloat(WeiToGwei(wei), 'f', -1, 64) + gweiDenom + } + return strconv.FormatFloat(WeiToEth(wei), 'f', -1, 64) + regDenom +} + // Convert wei to eth func WeiToEth(wei *big.Int) float64 { var weiFloat big.Float diff --git a/stader/api/node/claim-rewards.go b/stader/api/node/claim-rewards.go index c43f1ccfb..bccea548a 100644 --- a/stader/api/node/claim-rewards.go +++ b/stader/api/node/claim-rewards.go @@ -141,6 +141,7 @@ func ClaimRewards(c *cli.Context) (*api.ClaimRewards, error) { if err != nil { return nil, err } + response.RewardsClaimed = operatorRewardsBalance } else { totalWithdrawableEth := operatorRewardsBalance if operatorRewardsBalance.Cmp(withdrawableInEth) > 0 { @@ -150,6 +151,7 @@ func ClaimRewards(c *cli.Context) (*api.ClaimRewards, error) { if err != nil { return nil, err } + response.RewardsClaimed = totalWithdrawableEth } response.TxHash = tx.Hash() From edfaa0fd3c6463b83b31e3a1fa9337dfbfc35018 Mon Sep 17 00:00:00 2001 From: Bharath Vedartham Date: Thu, 4 Jan 2024 20:18:02 +0530 Subject: [PATCH 2/8] update precision --- stader-lib/utils/eth/units.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/stader-lib/utils/eth/units.go b/stader-lib/utils/eth/units.go index bfaf8b2c0..08a40f7df 100644 --- a/stader-lib/utils/eth/units.go +++ b/stader-lib/utils/eth/units.go @@ -57,9 +57,9 @@ func DisplayAmountInUnits(wei *big.Int, denom string) string { return "" } if wei.Cmp(big.NewInt(Threshold)) < 0 { - return strconv.FormatFloat(WeiToGwei(wei), 'f', -1, 64) + gweiDenom + return strconv.FormatFloat(WeiToGwei(wei), 'f', 2, 64) + gweiDenom } - return strconv.FormatFloat(WeiToEth(wei), 'f', -1, 64) + regDenom + return strconv.FormatFloat(WeiToEth(wei), 'f', 2, 64) + regDenom } // Convert wei to eth From ee3623b4f2fca25338c4aa3d60cde06cbb8cbdaa Mon Sep 17 00:00:00 2001 From: Bharath Vedartham Date: Thu, 4 Jan 2024 20:28:16 +0530 Subject: [PATCH 3/8] revert build info --- build-release.sh | 4 ++-- shared/version.go | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/build-release.sh b/build-release.sh index 048369316..8606a2ed2 100755 --- a/build-release.sh +++ b/build-release.sh @@ -27,8 +27,8 @@ # === Functions === # ================= -DOCKER_ACCOUNT=staderdev -S3_BUCKET=stader-cli-beta +DOCKER_ACCOUNT=staderlabs +S3_BUCKET=stader-cli-permissionless/eth/releases/stader-node-build/permissionless # Print a failure message to stderr and exit fail() { diff --git a/shared/version.go b/shared/version.go index 2f4f82103..3e99892f2 100644 --- a/shared/version.go +++ b/shared/version.go @@ -20,8 +20,8 @@ along with this program. If not, see . package shared const BinaryBucket string = "/stader-node-build/permissionless" -const DockerAccount string = "staderdev" -const StaderVersion string = "1.5.7-up-test" +const DockerAccount string = "staderlabs" +const StaderVersion string = "1.4.4" const Logo string = ` _____ _ _ _ _ 𝅺 From 94641d73200c00f893638dccd8809ebe7eb71d2d Mon Sep 17 00:00:00 2001 From: Bharath Vedartham Date: Thu, 4 Jan 2024 21:13:17 +0530 Subject: [PATCH 4/8] refactor --- stader-cli/node/claim-rewards.go | 7 ++++++- stader-cli/node/utilize-sd.go | 5 ++--- stader-cli/validator/deposit.go | 4 ++-- stader-cli/validator/send-cl-rewards.go | 6 +++--- stader-cli/validator/status.go | 5 +++-- 5 files changed, 16 insertions(+), 11 deletions(-) diff --git a/stader-cli/node/claim-rewards.go b/stader-cli/node/claim-rewards.go index 95a1b240f..53312b9c9 100644 --- a/stader-cli/node/claim-rewards.go +++ b/stader-cli/node/claim-rewards.go @@ -53,7 +53,12 @@ func ClaimRewards(c *cli.Context) error { fmt.Printf("Based on the current Health Factor, you can claim upto %s.\n", eth.DisplayAmountInUnits(canClaimRewardsResponse.WithdrawableInEth, "eth")) - fmt.Printf("Note: Please repay your utilized SD by using the following command to claim the remaining ETH: stader-cli sd repay --amount .\n\n") + fmt.Printf("Note: Please repay your utilized SD by using the following command to claim the remaining ETH: stader-cli sd repay --amount .\n") + + if !cliutils.Confirm("Are you sure you want to proceed?\n\n") { + fmt.Println("Cancelled.") + return nil + } } } diff --git a/stader-cli/node/utilize-sd.go b/stader-cli/node/utilize-sd.go index 92add83d2..a4a5c93dd 100644 --- a/stader-cli/node/utilize-sd.go +++ b/stader-cli/node/utilize-sd.go @@ -9,7 +9,6 @@ import ( "github.com/stader-labs/stader-node/shared/services/stader" "github.com/stader-labs/stader-node/shared/types/api" cliutils "github.com/stader-labs/stader-node/shared/utils/cli" - "github.com/stader-labs/stader-node/shared/utils/math" "github.com/stader-labs/stader-node/stader-lib/utils/eth" "github.com/stader-labs/stader-node/stader-lib/utils/sd" "github.com/urfave/cli" @@ -61,7 +60,7 @@ func utilizeSD(c *cli.Context) error { // Prompt for confirmation if !(c.Bool("yes") || cliutils.Confirm(fmt.Sprintf( - "Are you sure you want to use %f SD from the utility pool? (y/n). Note: A Utilization fee of %.6f APR will be applied to the utilized SD from the utility pool.\n", eth.WeiToEth(amountWei), 0.5))) { + "Are you sure you want to use %s from the utility pool? (y/n). Note: A Utilization fee of %.6f APR will be applied to the utilized SD from the utility pool.\n", eth.DisplayAmountInUnits(amountWei, "sd"), 0.5))) { fmt.Println("Cancelled.") return nil } @@ -78,7 +77,7 @@ func utilizeSD(c *cli.Context) error { } // Log & return - fmt.Printf("Successfully deposited %.6f SD by utilizing SD from the Utility Pool.\n", math.RoundDown(eth.WeiToEth(amountWei), 6)) + fmt.Printf("Successfully deposited %s to the collateral contract by utilizing SD from the Utility Pool.\n", eth.DisplayAmountInUnits(amountWei, "sd")) return nil } diff --git a/stader-cli/validator/deposit.go b/stader-cli/validator/deposit.go index 61ce9a132..8acc8646c 100644 --- a/stader-cli/validator/deposit.go +++ b/stader-cli/validator/deposit.go @@ -97,7 +97,7 @@ func nodeDeposit(c *cli.Context) error { return err } - if !cliutils.Confirm(fmt.Sprintf("Are you sure you want to use %f SD from the Utility Pool? [Y/N] \nNote: A Utilization Fee of %s%s APR will be applied to the utilized SD from the Utility Pool. ", eth.WeiToEth(utilityAmount), sdStatus.UtilizationRate.String(), "%")) { + if !cliutils.Confirm(fmt.Sprintf("Are you sure you want to use %s from the Utility Pool? [Y/N] \nNote: A Utilization Fee of %s%s APR will be applied to the utilized SD from the Utility Pool. ", eth.DisplayAmountInUnits(utilityAmount, "sd"), sdStatus.UtilizationRate.String(), "%")) { fmt.Printf("Cancelled\n") return nil } @@ -112,7 +112,7 @@ func nodeDeposit(c *cli.Context) error { return nil } - if !cliutils.Confirm(fmt.Sprintf("Are you sure you want to deposit %f SD as collateral?", eth.WeiToEth(selfBondAmount))) { + if !cliutils.Confirm(fmt.Sprintf("Are you sure you want to deposit %s as collateral?", eth.DisplayAmountInUnits(selfBondAmount, "sd"))) { fmt.Printf("Cancelled\n") return nil } diff --git a/stader-cli/validator/send-cl-rewards.go b/stader-cli/validator/send-cl-rewards.go index 607ad9397..fb61bef2e 100644 --- a/stader-cli/validator/send-cl-rewards.go +++ b/stader-cli/validator/send-cl-rewards.go @@ -2,11 +2,11 @@ package validator import ( "fmt" + "github.com/stader-labs/stader-node/shared/services/gas" "github.com/stader-labs/stader-node/shared/services/stader" cliutils "github.com/stader-labs/stader-node/shared/utils/cli" - "github.com/stader-labs/stader-node/shared/utils/math" "github.com/stader-labs/stader-node/stader-lib/types" "github.com/stader-labs/stader-node/stader-lib/utils/eth" "github.com/urfave/cli" @@ -68,14 +68,14 @@ func SendClRewards(c *cli.Context, validatorPubKey types.ValidatorPubkey) error return err } - fmt.Printf("Sending %.6f CL Rewards to Claim vault\n\n", math.RoundDown(eth.WeiToEth(res.ClRewardsAmount), 6)) + fmt.Printf("Sending %s CL Rewards to Claim vault\n\n", eth.DisplayAmountInUnits(res.ClRewardsAmount, "eth")) cliutils.PrintTransactionHash(staderClient, res.TxHash) if _, err = staderClient.WaitForTransaction(res.TxHash); err != nil { return err } // Log & return - fmt.Printf("Sent %.6f CL Rewards to Claim vault\n\n", math.RoundDown(eth.WeiToEth(res.ClRewardsAmount), 6)) + fmt.Printf("Sent %s CL Rewards to Claim vault\n\n", eth.DisplayAmountInUnits(res.ClRewardsAmount, "eth")) return nil } diff --git a/stader-cli/validator/status.go b/stader-cli/validator/status.go index e93b9ed92..bb39fc9d8 100644 --- a/stader-cli/validator/status.go +++ b/stader-cli/validator/status.go @@ -2,6 +2,8 @@ package validator import ( "fmt" + "math/big" + "github.com/stader-labs/stader-node/shared/services/stader" cliutils "github.com/stader-labs/stader-node/shared/utils/cli" "github.com/stader-labs/stader-node/shared/utils/log" @@ -9,7 +11,6 @@ import ( "github.com/stader-labs/stader-node/stader-lib/types" "github.com/stader-labs/stader-node/stader-lib/utils/eth" "github.com/urfave/cli" - "math/big" ) func getValidatorStatus(c *cli.Context) error { @@ -72,7 +73,7 @@ func getValidatorStatus(c *cli.Context) error { fmt.Printf("-Validator Status: %s\n", validatorInfo.StatusToDisplay) if validatorInfo.WithdrawVaultRewardBalance.Int64() > 0 && !validatorInfo.CrossedRewardsThreshold { fmt.Printf("\n") - fmt.Printf("-Validator Consensus Layer Rewards: %.6f\n\n", math.RoundDown(eth.WeiToEth(validatorInfo.WithdrawVaultRewardBalance), 18)) + fmt.Printf("-Validator Consensus Layer Rewards: %s\n\n", eth.DisplayAmountInUnits(validatorInfo.WithdrawVaultRewardBalance, "eth")) } else if validatorInfo.CrossedRewardsThreshold { fmt.Println("If you have exited the validator, Please wait for Stader Oracles to settle your funds!") fmt.Println("If you have not exited the validator. Please reach out Stader Developers in discord for more information") From b3a835d789e6d502ae5fddac1072099d1336132d Mon Sep 17 00:00:00 2001 From: Bharath Vedartham Date: Thu, 4 Jan 2024 21:20:36 +0530 Subject: [PATCH 5/8] refactor repay-sd --- stader-cli/node/repay-sd.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/stader-cli/node/repay-sd.go b/stader-cli/node/repay-sd.go index ed8f40fcb..1393585c8 100644 --- a/stader-cli/node/repay-sd.go +++ b/stader-cli/node/repay-sd.go @@ -67,7 +67,7 @@ func repaySD(c *cli.Context) error { // 1. Check if repay more than need if amountWei.Cmp(sdStatus.SdUtilizerLatestBalance) > 0 { - fmt.Printf("Repayment amount greater than the Utilization position. Your current Utilization Position is %0.6f \n", eth.WeiToEth(sdStatus.SdUtilizerLatestBalance)) + fmt.Printf("Repayment amount greater than the Utilization position. Your current Utilization Position is %s \n", eth.DisplayAmountInUnits(sdStatus.SdUtilizerLatestBalance, "sd")) return nil } @@ -84,7 +84,7 @@ func repaySD(c *cli.Context) error { } if allowance.Allowance.Cmp(amountWei) < 0 { - fmt.Printf("Before repaying the SD, you must first give the utility contract approval to interact with your SD. Amount to approve: %.6f\n", eth.WeiToEth(amountWei)) + fmt.Printf("Before repaying the SD, you must first give the utility contract approval to interact with your SD. Amount to approve: %s\n", eth.DisplayAmountInUnits(amountWei, "sd")) err = nodeApproveUtilitySd(c, amountInString) if err != nil { @@ -104,7 +104,7 @@ func repaySD(c *cli.Context) error { // Prompt for confirmation if !(c.Bool("yes") || cliutils.Confirm(fmt.Sprintf( - "Are you sure you want to repay %0.6f SD from your Operator Address and reduce or close your Utilization Position?", eth.WeiToEth(amountWei)))) { + "Are you sure you want to repay %s from your Operator Address and reduce or close your Utilization Position?", eth.DisplayAmountInUnits(amountWei, "sd")))) { fmt.Println("Cancelled.") return nil } @@ -121,7 +121,7 @@ func repaySD(c *cli.Context) error { } remainUtilize := new(big.Int).Sub(sdStatus.SdUtilizerLatestBalance, amountWei) - fmt.Printf("Repayment of %.6f SD successful. Current Utilization Position: %.6f SD.\n", eth.WeiToEth(amountWei), eth.WeiToEth(remainUtilize)) + fmt.Printf("Repayment of %s successful. Current Utilization Position: %s.\n", eth.DisplayAmountInUnits(amountWei, "sd"), eth.DisplayAmountInUnits(remainUtilize, "sd")) return nil } From 59ecb254425d2c32bbc13ed71f9e99f30003349f Mon Sep 17 00:00:00 2001 From: Bharath Vedartham Date: Thu, 4 Jan 2024 21:38:09 +0530 Subject: [PATCH 6/8] refactor withdraw-sd --- stader-cli/node/withdraw-sd.go | 24 ++++++++---------------- 1 file changed, 8 insertions(+), 16 deletions(-) diff --git a/stader-cli/node/withdraw-sd.go b/stader-cli/node/withdraw-sd.go index d408cdf3d..6f1a97a2c 100644 --- a/stader-cli/node/withdraw-sd.go +++ b/stader-cli/node/withdraw-sd.go @@ -8,7 +8,6 @@ import ( "github.com/stader-labs/stader-node/shared/services/gas" "github.com/stader-labs/stader-node/shared/services/stader" cliutils "github.com/stader-labs/stader-node/shared/utils/cli" - "github.com/stader-labs/stader-node/shared/utils/math" "github.com/stader-labs/stader-node/stader-lib/utils/eth" "github.com/urfave/cli" ) @@ -54,14 +53,7 @@ func WithdrawSd(c *cli.Context) error { hasUtilizePosition := sdStatusResponse.SDStatus.SdUtilizerLatestBalance.Cmp(big.NewInt(0)) != 0 if hasUtilizePosition { - val, denom := eth.WeiToEthWithValCheck(sdStatusResponse.SDStatus.SdUtilizerLatestBalance) - confirm := false - if denom == "gwei" { - confirm = cliutils.Confirm(fmt.Sprintf("You have an existing Utilization Position of %.6f gwei SD. The excess SD collateral you are trying to withdraw will be used to repay the utilized SD.\n Do you wish to proceed?", math.RoundDown(val, 6))) - } else { - confirm = cliutils.Confirm(fmt.Sprintf("You have an existing Utilization Position of %.6f SD. The excess SD collateral you are trying to withdraw will be used to repay the utilized SD.\n Do you wish to proceed?", math.RoundDown(val, 6))) - } - if !confirm { + if !cliutils.Confirm(fmt.Sprintf("You have an existing Utilization Position of %s. The excess SD collateral you are trying to withdraw will be used to repay the utilized SD.\n Do you wish to proceed?", eth.DisplayAmountInUnits(sdStatusResponse.SDStatus.SdUtilizerLatestBalance, "sd"))) { fmt.Println("Cancelled.") return nil } @@ -75,7 +67,7 @@ func WithdrawSd(c *cli.Context) error { // Prompt for confirmation if !(c.Bool("yes") || cliutils.Confirm(fmt.Sprintf( - "Are you sure you want to withdraw %.6f SD from the collateral contract?", math.RoundDown(eth.WeiToEth(amountWei), 6)))) { + "Are you sure you want to withdraw %s from the collateral contract?", eth.DisplayAmountInUnits(amountWei, "sd")))) { fmt.Println("Cancelled.") return nil } @@ -85,7 +77,7 @@ func WithdrawSd(c *cli.Context) error { return err } - fmt.Printf("Withdrawing %s SD from the collateral contract.\n", amountInString) + fmt.Printf("Withdrawing %s from the collateral contract.\n", eth.DisplayAmountInUnits(amountWei, "sd")) cliutils.PrintTransactionHash(staderClient, res.TxHash) if _, err = staderClient.WaitForTransaction(res.TxHash); err != nil { return err @@ -101,18 +93,18 @@ func WithdrawSd(c *cli.Context) error { // withdraw request amount lesser than the Utilization Position if !hasUtilizePosition { - fmt.Printf("Successfully withdrawn %.6f SD Collateral. \n", math.RoundDown(eth.WeiToEth(amountWei), 6)) + fmt.Printf("Successfully withdrawn %s Collateral. \n", eth.DisplayAmountInUnits(amountWei, "sd")) return nil } if remainUtilize.Cmp(big.NewInt(0)) > 0 { - fmt.Printf("Successfully withdrawn %.6f SD Collateral. \n", math.RoundDown(eth.WeiToEth(amountWei), 6)) - fmt.Printf("Current Utilization Position: %.6f SD \nCurrent SD collateral: %.6f SD\n", math.RoundDown(eth.WeiToEth(remainUtilize), 6), math.RoundDown(eth.WeiToEth(remainCollateral), 6)) + fmt.Printf("Successfully withdrawn %s Collateral. \n", eth.DisplayAmountInUnits(amountWei, "sd")) + fmt.Printf("Current Utilization Position: %s\nCurrent SD collateral: %s\n", eth.DisplayAmountInUnits(remainUtilize, "sd"), eth.DisplayAmountInUnits(remainCollateral, "sd")) } else { // withdraw request amount greater than the Utilization Position - fmt.Printf("Repayment of %.6f SD successful using the excess SD Collateral.\n", math.RoundDown(eth.WeiToEth(amountWei), 6)) - fmt.Printf("The remaining %.6f SD has been sent to your Operator Reward Address\n", math.RoundDown(eth.WeiToEth(new(big.Int).Abs(remainUtilize)), 6)) + fmt.Printf("Repayment of %s successful using the excess SD Collateral.\n", eth.DisplayAmountInUnits(amountWei, "sd")) + fmt.Printf("The remaining %s has been sent to your Operator Reward Address\n", eth.DisplayAmountInUnits(new(big.Int).Abs(remainUtilize), "sd")) } return nil From 9e562c2a01cd9b5aba45bcb54476301cf96e67fa Mon Sep 17 00:00:00 2001 From: Bharath Vedartham Date: Fri, 5 Jan 2024 15:21:06 +0530 Subject: [PATCH 7/8] refactor remaining places --- stader-cli/node/claim-sp-rewards.go | 12 ++++----- stader-cli/node/deposit-sd.go | 7 +++--- stader-cli/node/send-el-rewards.go | 5 ++-- stader-cli/node/send.go | 2 +- stader-cli/node/status.go | 38 ++++++++++++++--------------- 5 files changed, 30 insertions(+), 34 deletions(-) diff --git a/stader-cli/node/claim-sp-rewards.go b/stader-cli/node/claim-sp-rewards.go index edf0c61b9..71ee4a401 100644 --- a/stader-cli/node/claim-sp-rewards.go +++ b/stader-cli/node/claim-sp-rewards.go @@ -158,7 +158,7 @@ func ClaimSpRewards(c *cli.Context) error { depositSd := false if totalClaimableSd.Cmp(big.NewInt(0)) > 0 { - fmt.Printf("You will claim %f SD and %f ETH with the following selection - cycles %v\n\n", eth.WeiToEth(totalClaimableSd), eth.WeiToEth(totalClaimableEth), cyclesToClaimArray) + fmt.Printf("You will claim %s and %s with the following selection - cycles %v\n\n", eth.DisplayAmountInUnits(totalClaimableSd, "sd"), eth.DisplayAmountInUnits(totalClaimableEth, "eth"), cyclesToClaimArray) fmt.Printf("Your ETH rewards will be sent to your Reward Address\n") fmt.Printf("For SD rewards, you can claim all the rewards to your Reward Address or redeposit them as SD collateral to earn more rewards\n") @@ -169,13 +169,13 @@ func ClaimSpRewards(c *cli.Context) error { option := cliutils.Prompt("", "^(1|2)$", "Please enter a valid option") if option == "1" { if !cliutils.Confirm(fmt.Sprintf( - "Are you sure you want to claim %f ETH and %f SD for cycles %v to your reward address?", eth.WeiToEth(totalClaimableEth), eth.WeiToEth(totalClaimableSd), cyclesToClaimArray)) { + "Are you sure you want to claim %s and %s for cycles %v to your reward address?", eth.DisplayAmountInUnits(totalClaimableEth, "eth"), eth.DisplayAmountInUnits(totalClaimableSd, "sd"), cyclesToClaimArray)) { fmt.Println("Claim Cancelled.") return nil } } else if option == "2" { if !cliutils.Confirm(fmt.Sprintf( - "Your %f ETH rewards will be sent to your Reward Address.\nFor your %f SD rewards, are you sure you want to re-deposit it as SD collateral for additional earnings?", eth.WeiToEth(totalClaimableEth), eth.WeiToEth(totalClaimableSd))) { + "Your %s rewards will be sent to your Reward Address.\nFor your %s rewards, are you sure you want to re-deposit it as SD collateral for additional earnings?", eth.DisplayAmountInUnits(totalClaimableEth, "eth"), eth.DisplayAmountInUnits(totalClaimableSd, "sd"))) { fmt.Println("Claim Cancelled.") return nil } @@ -216,12 +216,12 @@ func ClaimSpRewards(c *cli.Context) error { fmt.Printf("Transaction Successful\n") if depositSd { - fmt.Printf("%f ETH rewards have been sent to your Reward Address and %f SD rewards have been re-deposited as SD collateral\n", eth.WeiToEth(totalClaimableEth), eth.WeiToEth(totalClaimableSd)) + fmt.Printf("%s rewards have been sent to your Reward Address and %s rewards have been re-deposited as SD collateral\n", eth.DisplayAmountInUnits(totalClaimableEth, "eth"), eth.DisplayAmountInUnits(totalClaimableSd, "sd")) } else { if totalClaimableSd.Cmp(big.NewInt(0)) <= 0 { - fmt.Printf("%f ETH rewards have been sent to your Reward Address\n", eth.WeiToEth(totalClaimableEth)) + fmt.Printf("%s rewards have been sent to your Reward Address\n", eth.DisplayAmountInUnits(totalClaimableEth, "eth")) } else { - fmt.Printf("%f SD rewards and %f ETH rewards have been sent to your Reward Address\n", eth.WeiToEth(totalClaimableSd), eth.WeiToEth(totalClaimableEth)) + fmt.Printf("%s rewards and %s rewards have been sent to your Reward Address\n", eth.DisplayAmountInUnits(totalClaimableSd, "sd"), eth.DisplayAmountInUnits(totalClaimableEth, "eth")) } } diff --git a/stader-cli/node/deposit-sd.go b/stader-cli/node/deposit-sd.go index c1fd4f787..d985ffec0 100644 --- a/stader-cli/node/deposit-sd.go +++ b/stader-cli/node/deposit-sd.go @@ -11,7 +11,6 @@ import ( "github.com/stader-labs/stader-node/shared/services/gas" "github.com/stader-labs/stader-node/shared/services/stader" cliutils "github.com/stader-labs/stader-node/shared/utils/cli" - "github.com/stader-labs/stader-node/shared/utils/math" ) func nodeDepositSd(c *cli.Context) error { @@ -61,7 +60,7 @@ func DepositSdWithAmount(staderClient *stader.Client, amountWei *big.Int, autoCo } if allowance.Allowance.Cmp(amountWei) < 0 { - fmt.Println("Before depositing SD, you must first give the collateral contract approval to interact with your SD. Amount to approve: ", eth.WeiToEth(amountWei)) + fmt.Println("Before depositing SD, you must first give the collateral contract approval to interact with your SD. Amount to approve: ", eth.DisplayAmountInUnits(amountWei, "sd")) err = nodeApproveSdWithAmountAndAddress(staderClient, amountWei, contracts.SdCollateralContract, autoConfirm, nonce) if err != nil { return err @@ -90,7 +89,7 @@ func DepositSdWithAmount(staderClient *stader.Client, amountWei *big.Int, autoCo } // Prompt for confirmation - if !(autoConfirm || cliutils.Confirm(fmt.Sprintf("Are you sure you want to deposit %f SD as collateral?", math.RoundDown(eth.WeiToEth(amountWei), 6)))) { + if !(autoConfirm || cliutils.Confirm(fmt.Sprintf("Are you sure you want to deposit %s as collateral?", eth.DisplayAmountInUnits(amountWei, "sd")))) { fmt.Println("Cancelled.") return nil } @@ -108,7 +107,7 @@ func DepositSdWithAmount(staderClient *stader.Client, amountWei *big.Int, autoCo } // Log & return - fmt.Printf("Successfully deposited %.6f SD.\n", math.RoundDown(eth.WeiToEth(amountWei), 6)) + fmt.Printf("Successfully deposited %s.\n", eth.DisplayAmountInUnits(amountWei, "sd")) return nil } diff --git a/stader-cli/node/send-el-rewards.go b/stader-cli/node/send-el-rewards.go index fe3cebe76..ef83edbef 100644 --- a/stader-cli/node/send-el-rewards.go +++ b/stader-cli/node/send-el-rewards.go @@ -6,7 +6,6 @@ import ( "github.com/stader-labs/stader-node/shared/services/gas" "github.com/stader-labs/stader-node/shared/services/stader" cliutils "github.com/stader-labs/stader-node/shared/utils/cli" - "github.com/stader-labs/stader-node/shared/utils/math" "github.com/stader-labs/stader-node/stader-lib/utils/eth" "github.com/urfave/cli" ) @@ -53,13 +52,13 @@ func SendElRewards(c *cli.Context) error { if err != nil { return err } - fmt.Printf("Sending %.6f EL Rewards to Claim Vault\n\n", math.RoundDown(eth.WeiToEth(res.ElRewardsAmount), 6)) + fmt.Printf("Sending %s EL Rewards to Claim Vault\n\n", eth.DisplayAmountInUnits(res.ElRewardsAmount, "eth")) cliutils.PrintTransactionHash(staderClient, res.TxHash) if _, err = staderClient.WaitForTransaction(res.TxHash); err != nil { return err } // Log & return - fmt.Printf("Sent %.6f EL Rewards to Claim Vault\n\n", math.RoundDown(eth.WeiToEth(res.ElRewardsAmount), 6)) + fmt.Printf("Sent %s EL Rewards to Claim Vault\n\n", eth.DisplayAmountInUnits(res.ElRewardsAmount, "eth")) return nil } diff --git a/stader-cli/node/send.go b/stader-cli/node/send.go index 3763bd492..24ad6753e 100644 --- a/stader-cli/node/send.go +++ b/stader-cli/node/send.go @@ -78,7 +78,7 @@ func nodeSend(c *cli.Context, amount float64, token string, toAddressOrENS strin } // Prompt for confirmation - if !(c.Bool("yes") || cliutils.Confirm(fmt.Sprintf("Are you sure you want to send %.6f %s to %s? This action cannot be undone!", math.RoundDown(eth.WeiToEth(amountWei), 6), token, toAddressString))) { + if !(c.Bool("yes") || cliutils.Confirm(fmt.Sprintf("Are you sure you want to send %.6f %s to %s? This action cannot be undone!", eth.WeiToEth(amountWei), token, toAddressString))) { fmt.Println("Cancelled.") return nil } diff --git a/stader-cli/node/status.go b/stader-cli/node/status.go index 904a9f94e..48249e202 100644 --- a/stader-cli/node/status.go +++ b/stader-cli/node/status.go @@ -7,7 +7,6 @@ import ( "github.com/stader-labs/stader-node/shared/services/stader" cliutils "github.com/stader-labs/stader-node/shared/utils/cli" "github.com/stader-labs/stader-node/shared/utils/log" - "github.com/stader-labs/stader-node/shared/utils/math" "github.com/stader-labs/stader-node/stader-lib/utils/eth" "github.com/urfave/cli" ) @@ -97,18 +96,18 @@ func getNodeStatus(c *cli.Context) error { } if totalUnclaimedSocializingPoolSd.Cmp(big.NewInt(0)) > 0 { - fmt.Printf("The Operator has %.6f SD as unclaimed SD rewards. To claim SD rewards using the %sstader-cli node claim-sp-rewards%s command\n\n", math.RoundDown(eth.WeiToEth(totalUnclaimedSocializingPoolSd), 18), log.ColorGreen, log.ColorReset) + fmt.Printf("The Operator has %s as unclaimed SD rewards. To claim SD rewards using the %sstader-cli node claim-sp-rewards%s command\n\n", eth.DisplayAmountInUnits(totalUnclaimedSocializingPoolSd, "sd"), log.ColorGreen, log.ColorReset) } if totalUnclaimedSocializingPoolEth.Cmp(big.NewInt(0)) > 0 { - fmt.Printf("The Operator has %.6f ETH as unclaimed Socializing Pool EL rewards. To claim Socialized EL rewards using the %sstader-cli node claim-sp-rewards%s command\n\n", math.RoundDown(eth.WeiToEth(totalUnclaimedSocializingPoolEth), 18), log.ColorGreen, log.ColorReset) + fmt.Printf("The Operator has %s as unclaimed Socializing Pool EL rewards. To claim Socialized EL rewards using the %sstader-cli node claim-sp-rewards%s command\n\n", eth.DisplayAmountInUnits(totalUnclaimedSocializingPoolEth, "eth"), log.ColorGreen, log.ColorReset) } if status.OperatorELRewardsAddressBalance.Cmp(big.NewInt(0)) > 0 { fmt.Printf( - "The Operator has a total of %.6f ETH as EL rewards for all validators.\n"+ + "The Operator has a total of %s as EL rewards for all validators.\n"+ "These rewards are sent to the claim vault periodically by Stader.\n"+ - "Once it is sent to the claim vault, the operator can use the %sstader-cli node claim-rewards%s command to claim EL rewards to their operator reward address\n", math.RoundDown(eth.WeiToEth(status.OperatorELRewardsAddressBalance), 6), log.ColorGreen, log.ColorReset) + "Once it is sent to the claim vault, the operator can use the %sstader-cli node claim-rewards%s command to claim EL rewards to their operator reward address\n", eth.DisplayAmountInUnits(status.OperatorELRewardsAddressBalance, "eth"), log.ColorGreen, log.ColorReset) fmt.Println("If the operator wishes to claim EL rewards by themselves, follow these steps:") fmt.Printf("1. Use the %sstader-cli node send-el-rewards%s command to claim the EL rewards\n", log.ColorGreen, log.ColorReset) fmt.Printf("2. Use the %sstader-cli node claim-rewards%s command to claim the EL rewards from the claim vault to your operator reward address\n\n", log.ColorGreen, log.ColorReset) @@ -119,7 +118,6 @@ func getNodeStatus(c *cli.Context) error { "The Operator has aggregated total claims of %s in the claim vault\n", eth.DisplayAmountInUnits(status.OperatorRewardCollectorBalance, "eth")) fmt.Printf("To transfer the claims to your operator reward address use the %sstader-cli node claim-rewards%s command\n\n", log.ColorGreen, log.ColorReset) - } fmt.Printf( @@ -130,17 +128,17 @@ func getNodeStatus(c *cli.Context) error { fmt.Printf("%s=== Account and Balances ===%s\n", log.ColorGreen, log.ColorReset) fmt.Printf( - "The Operator %s%s%s has a balance of %.6f ETH.\n\n", + "The Operator %s%s%s has a balance of %s.\n\n", log.ColorBlue, status.AccountAddress, log.ColorReset, - math.RoundDown(eth.WeiToEth(status.AccountBalances.ETH), 6)) + eth.DisplayAmountInUnits(status.AccountBalances.ETH, "eth")) fmt.Printf( - "The Operator %s%s%s has a balance of %.6f SD.\n\n", + "The Operator %s%s%s has a balance of %s.\n\n", log.ColorBlue, status.AccountAddress, log.ColorReset, - math.RoundDown(eth.WeiToEth(status.AccountBalances.Sd), 18)) + eth.DisplayAmountInUnits(status.AccountBalances.Sd, "sd")) fmt.Printf( "The Operator has a deposited %d ETH as collateral.\n\n", @@ -163,16 +161,16 @@ func getNodeStatus(c *cli.Context) error { } fmt.Printf( - "The Operator has a deposited %.6f SD (%.6f%s) as collateral. Below is the break-up: \n", - math.RoundDown(eth.WeiToEth(totalCollateral), 18), collateralPct, "%") + "The Operator has a deposited %s (%.6f%s) as collateral. Below is the break-up: \n", + eth.DisplayAmountInUnits(totalCollateral, "sd"), collateralPct, "%") fmt.Printf( - "Self-bonded: %.6f SD \n", - math.RoundDown(eth.WeiToEth(sdStatus.SdCollateralCurrentAmount), eth.Decimal)) + "Self-bonded: %s \n", + eth.DisplayAmountInUnits(sdStatus.SdCollateralCurrentAmount, "sd")) fmt.Printf( - "Utilized from the Utility Pool: %.6f SD.\n", - math.RoundDown(eth.WeiToEth(sdStatus.SdUtilizedBalance), eth.Decimal)) + "Utilized from the Utility Pool: %s.\n", + eth.DisplayAmountInUnits(sdStatus.SdUtilizedBalance, "sd")) if totalRegisteredValidators.Cmp(big.NewInt(0)) != 0 { fmt.Printf( @@ -201,16 +199,16 @@ func getNodeStatus(c *cli.Context) error { } fmt.Printf( - "The Operator can utilize upto %.6f SD more.\nNote: The Operator can utilize a maximum of 1 ETH worth SD per validator.\n\n", - eth.WeiToEth(maxUtilizable)) + "The Operator can utilize upto %s SD more.\nNote: The Operator can utilize a maximum of 1 ETH worth SD per validator.\n\n", + eth.DisplayAmountInUnits(maxUtilizable, "sd")) fmt.Printf( "The Operator has a Health Factor of %s. \nNote: Please ensure your Health Factor is greater than 1 to avoid liquidations.\n\n", sdStatus.HealthFactor.String()) fmt.Printf( - "The Utility Pool currently has a balance of %.6f SD.\n\n", - math.RoundDown(eth.WeiToEth(sdStatus.PoolAvailableSDBalance), eth.Decimal)) + "The Utility Pool currently has a balance of %s.\n\n", + eth.DisplayAmountInUnits(sdStatus.PoolAvailableSDBalance, "sd")) return nil } From 4913520e47cdf8e9f39dc65109ba5cae1036ae28 Mon Sep 17 00:00:00 2001 From: Bharath Vedartham Date: Fri, 5 Jan 2024 16:01:56 +0530 Subject: [PATCH 8/8] only display health factor if there is some utilized balance --- stader-cli/node/status.go | 12 +++++++----- stader-lib/utils/eth/units.go | 4 ++-- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/stader-cli/node/status.go b/stader-cli/node/status.go index 48249e202..1f8bb544d 100644 --- a/stader-cli/node/status.go +++ b/stader-cli/node/status.go @@ -185,7 +185,7 @@ func getNodeStatus(c *cli.Context) error { fmt.Printf("%s=== SD utilization Details ===%s\n", log.ColorGreen, log.ColorReset) - fmt.Printf("The Operator has utilized %s from the Utility Pool.\n\n", eth.DisplayAmountInUnits(sdStatus.SdUtilizedBalance, "eth")) + fmt.Printf("The Operator has utilized %s from the Utility Pool.\n\n", eth.DisplayAmountInUnits(sdStatus.SdUtilizedBalance, "sd")) fmt.Printf("The Operator has a current Utilization Position of %s. (including the utilization fee)\n Note: For repayment of your utilized SD, please use the `stader-cli node repay-sd ` command.\n\n", eth.DisplayAmountInUnits(sdStatus.SdUtilizerLatestBalance, "sd")) @@ -199,12 +199,14 @@ func getNodeStatus(c *cli.Context) error { } fmt.Printf( - "The Operator can utilize upto %s SD more.\nNote: The Operator can utilize a maximum of 1 ETH worth SD per validator.\n\n", + "The Operator can utilize upto %s more.\nNote: The Operator can utilize a maximum of 1 ETH worth SD per validator.\n\n", eth.DisplayAmountInUnits(maxUtilizable, "sd")) - fmt.Printf( - "The Operator has a Health Factor of %s. \nNote: Please ensure your Health Factor is greater than 1 to avoid liquidations.\n\n", - sdStatus.HealthFactor.String()) + if sdStatus.SdUtilizedBalance.Cmp(big.NewInt(0)) == 0 { + fmt.Printf( + "The Operator has a Health Factor of %s. \nNote: Please ensure your Health Factor is greater than 1 to avoid liquidations.\n\n", + sdStatus.HealthFactor.String()) + } fmt.Printf( "The Utility Pool currently has a balance of %s.\n\n", diff --git a/stader-lib/utils/eth/units.go b/stader-lib/utils/eth/units.go index 08a40f7df..4815ad025 100644 --- a/stader-lib/utils/eth/units.go +++ b/stader-lib/utils/eth/units.go @@ -45,11 +45,11 @@ func WeiToEthWithValCheck(wei *big.Int) (float64, string) { func DisplayAmountInUnits(wei *big.Int, denom string) string { gweiDenom := " gwei" - if denom == "SD" { + if denom == "sd" { gweiDenom = " gwei SD" } regDenom := " ETH" - if denom == "SD" { + if denom == "sd" { regDenom = " SD" }