Skip to content

Commit

Permalink
Update message
Browse files Browse the repository at this point in the history
  • Loading branch information
batphonghan committed Mar 4, 2024
1 parent d3870e3 commit 194d41e
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 12 deletions.
6 changes: 3 additions & 3 deletions stader-cli/node/claim-rewards.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,14 @@ func ClaimRewards(c *cli.Context) error {
// if withdrawableInEth < claimsBalance, then there is an existing utilization position
if canClaimRewardsResponse.ClaimsBalance.Cmp(canClaimRewardsResponse.WithdrawableInEth) != 0 {
if sdStatus.SdUtilizerLatestBalance.Cmp(big.NewInt(0)) > 0 {
fmt.Printf("You currently have an existing SD Utilization Position of %s. Based on the current Health Factor, you can claim upto %s", eth.DisplayAmountInUnits(sdStatusResponse.SDStatus.SdUtilizerLatestBalance, "sd"), 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 <amount of SD to be repaid>.\n")
fmt.Printf("You currently have an existing SD Utilization Position of %s. Based on the current Health Factor, you can claim %s at the moment, and the remaining ETH can be claimed after closing the Utilization Position", eth.DisplayAmountInUnits(sdStatusResponse.SDStatus.SdUtilizerLatestBalance, "sd"), eth.DisplayAmountInUnits(canClaimRewardsResponse.WithdrawableInEth, "eth"))

if !cliutils.Confirm("Do you wish to proceed?\n\n") {
fmt.Println("Cancelled.")
return nil
}

fmt.Printf("Note: Please repay your utilized SD by using the following command to claim the remaining ETH: stader-cli sd repay --amount <amount of SD to be repaid>.\n")
}
}

Expand Down
2 changes: 1 addition & 1 deletion stader-cli/node/repay-sd.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ func repaySD(c *cli.Context) error {
}

// Prompt for confirmation
if !cliutils.Confirm(fmt.Sprintf("Are you sure you want to repay %s from your Operator Address and close your Utilization Position? ", eth.DisplayAmountInUnits(amountWei, "sd"))) {
if !cliutils.Confirm(fmt.Sprintf("Are you sure you want to repay %s from your Operator Address?", eth.DisplayAmountInUnits(amountWei, "sd"))) {
fmt.Printf("Cancelled\n")
return nil
}
Expand Down
14 changes: 8 additions & 6 deletions stader-cli/node/utilize-sd.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,21 +40,23 @@ func utilizeSD(c *cli.Context) error {
}

if sdStatusResponse.SDStatus.AlreadyLiquidated {
fmt.Printf("Your node is in liquidation process")
fmt.Printf("Your node is under the liquidation process and you can not utilize SD at the moment.")
return nil
}

healthFactor := eth.WeiToEth(sdStatusResponse.SDStatus.HealthFactor)
if healthFactor < 1 {
fmt.Printf(
"The Operator has a Health Factor of %.6f. \nNote: Please ensure your Health Factor is greater than 1 to avoid liquidations.\n\n",
"Your node has a Health Factor of %.6f which is less than 1 and you can not utilize SD at the moment. Please repay your utilize SD and ensure your Health Factor is greater than 1 to avoid liquidation.\n\n",
healthFactor)

fmt.Printf("Note: Please repay your utilized SD by using the following command: stader-cli sd repay --amount <amount of SD to be repaid>.\n")

return nil
}

if sdStatusResponse.SDStatus.SdCollateralRequireAmount.Cmp(big.NewInt(0)) == 0 {
fmt.Printf("Please add a validator to your node first before utilizing SD from a Utility Pool. Execute the following command to add a validator to your node: ~/bin/stader-cli validator deposit --num-validators <number of validators you wish to add> \n")
fmt.Printf("Please add a validator to your node first before utilizing SD from the SD Utility Pool. Execute the following command to add a validator to your node: ~/bin/stader-cli validator deposit --num-validators <number of validators you wish to add> \n")
return nil
}

Expand All @@ -79,7 +81,7 @@ func utilizeSD(c *cli.Context) error {
rate := sdStatusResponse.SDStatus.UtilizationRate
// Prompt for confirmation
if !(c.Bool("yes") || cliutils.Confirm(fmt.Sprintf(
"Are you sure you want to use %s from the utility pool?.\nNote: A Utilization fee of %s%s will be applied to the utilized SD from the utility pool.", eth.DisplayAmountInUnits(amountWei, "sd"), rate.String(), "%"))) {
"Are you sure you want to use %s from the SD Utility Pool?.\nNote: A Utilization fee of %s%s will be applied to the utilized SD from the SD Utility Pool.", eth.DisplayAmountInUnits(amountWei, "sd"), rate.String(), "%"))) {
fmt.Println("Cancelled.")
return nil
}
Expand All @@ -96,7 +98,7 @@ func utilizeSD(c *cli.Context) error {
}

// Log & return
fmt.Printf("Successfully deposited %s to the collateral contract by utilizing SD from the Utility Pool.\n", eth.DisplayAmountInUnits(amountWei, "sd"))
fmt.Printf("Successfully deposited %s to the collateral contract by utilizing SD from the SD Utility Pool.\n", eth.DisplayAmountInUnits(amountWei, "sd"))

return nil
}
Expand Down Expand Up @@ -126,7 +128,7 @@ func GetMaxUtility(sdStatus *api.SdStatusResponse) *big.Int {
func PromptChooseUtilityAmount(sdStatus *api.SdStatusResponse, minUtility, maxUtility *big.Int) (*big.Int, error) {
// 1. If the pool had enough SD
if minUtility.Cmp(sdStatus.PoolAvailableSDBalance) > 0 {
return nil, errors.New("There is not sufficient free SD in the Utility Pool for utilization at the moment. Please try again later when there is enough free SD in the Utility Pool")
return nil, errors.New("There is not sufficient free SD in the SD Utility Pool for utilization at the moment. Please try again later when there is enough free SD in the SD Utility Pool")
}

// 2. If user had enough Eth
Expand Down
3 changes: 2 additions & 1 deletion stader-cli/node/withdraw-sd.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ func WithdrawSd(c *cli.Context) error {
}

if canWithdrawSdResponse.InsufficientSdCollateral {
//TODO: show 200% in SD
fmt.Println("Not enough excess SD collateral to withdraw")
return nil
}
Expand Down Expand Up @@ -95,7 +96,7 @@ func WithdrawSd(c *cli.Context) error {
// withdraw request amount lesser than the Utilization Position

if !hasUtilizePosition {
fmt.Printf("Successfully withdrawn %s Collateral. \n", eth.DisplayAmountInUnits(amountWei, "sd"))
fmt.Printf("Successfully withdrawn %s collateral. \n", eth.DisplayAmountInUnits(amountWei, "sd"))

return nil
}
Expand Down
2 changes: 1 addition & 1 deletion stader-cli/validator/deposit.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ func nodeDeposit(c *cli.Context) error {
return nil
}

fmt.Println("Continue with create validator...")
fmt.Println("Validator creation process initiate, please wait...")
}

canNodeDepositResponse, err := staderClient.CanNodeDeposit(baseAmount, utilityAmount, big.NewInt(int64(numValidators)), true)
Expand Down

0 comments on commit 194d41e

Please sign in to comment.