Skip to content

Commit

Permalink
Min to utility always be 1 SD
Browse files Browse the repository at this point in the history
  • Loading branch information
batphonghan committed Mar 1, 2024
1 parent 63c4f42 commit 466e9d1
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
10 changes: 5 additions & 5 deletions stader-cli/node/utilize-sd.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down Expand Up @@ -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")
Expand Down
5 changes: 4 additions & 1 deletion stader-cli/validator/deposit.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
2 changes: 1 addition & 1 deletion stader/node/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down

0 comments on commit 466e9d1

Please sign in to comment.