From 466e9d11344bdfc75b7c0bc969d30697daf756c8 Mon Sep 17 00:00:00 2001 From: batphonghan Date: Fri, 1 Mar 2024 21:10:01 +0700 Subject: [PATCH] Min to utility always be 1 SD --- stader-cli/node/utilize-sd.go | 10 +++++----- stader-cli/validator/deposit.go | 5 ++++- stader/node/node.go | 2 +- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/stader-cli/node/utilize-sd.go b/stader-cli/node/utilize-sd.go index d32fca73..d88f77fe 100644 --- a/stader-cli/node/utilize-sd.go +++ b/stader-cli/node/utilize-sd.go @@ -58,7 +58,10 @@ func utilizeSD(c *cli.Context) error { return nil } - amountWei, err := PromptChooseUtilityAmount(sdStatusResponse.SDStatus) + minUtility := eth.EthToWei(1) + maxUtility := GetMaxUtility(sdStatusResponse.SDStatus) + + amountWei, err := PromptChooseUtilityAmount(sdStatusResponse.SDStatus, minUtility, maxUtility) if err != nil { return err } @@ -120,10 +123,7 @@ func GetMaxUtility(sdStatus *api.SdStatusResponse) *big.Int { return maxUtility } -func PromptChooseUtilityAmount(sdStatus *api.SdStatusResponse) (*big.Int, error) { - minUtility := GetMinUtility(sdStatus) - maxUtility := GetMaxUtility(sdStatus) - +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") diff --git a/stader-cli/validator/deposit.go b/stader-cli/validator/deposit.go index a86e5476..4b7b850b 100644 --- a/stader-cli/validator/deposit.go +++ b/stader-cli/validator/deposit.go @@ -106,7 +106,10 @@ func nodeDeposit(c *cli.Context) error { switch i { case 0: - utilityAmount, err = node.PromptChooseUtilityAmount(sdStatus) + minUtility := node.GetMinUtility(sdStatus) + maxUtility := node.GetMaxUtility(sdStatus) + + utilityAmount, err = node.PromptChooseUtilityAmount(sdStatus, minUtility, maxUtility) if err != nil { return err } diff --git a/stader/node/node.go b/stader/node/node.go index 1fbd00d5..bd6de7cd 100644 --- a/stader/node/node.go +++ b/stader/node/node.go @@ -471,7 +471,7 @@ func run(c *cli.Context) error { if response.Success { infoLog.Println("Successfully sent the NodeDiversity message") } else { - errorLog.Println("Failed to send the NodeDiversity message with err: %s\n", response.Error) + errorLog.Printf("Failed to send the NodeDiversity message with err: %s\n", response.Error) } infoLog.Println("Done checking node diversity metrics")