-
Notifications
You must be signed in to change notification settings - Fork 114
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
V1 Improved node deposit
and node stake-rpl
flow
#694
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Allow percents but make the user pass -a 5%
instead of -a 5
, otherwise it's a POLA violation when someone passes -a 5
and it stakes 5% instead of 5 RPL
TIL what a POLA violation is. Nice catch, thank you Patches! |
rocketpool-cli/node/commands.go
Outdated
c.String("amount") != "5%" && | ||
c.String("amount") != "10%" && | ||
c.String("amount") != "15%" && |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we drop the magic values and just use strings.EndsWith(c.String("amount"), "%")
to determine if a percentage was passed? Then parse it and the actual amount.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good call. The latest commit allows for custom percentages passed through as CLI flags and additionally as an option within the command.
483ccbd
to
240fea4
Compare
case 0: | ||
if c.String("amount") != "" { | ||
// Parse amount | ||
depositAmount, err := strconv.ParseFloat(c.String("amount"), 64) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i feel like amount
for a deposit is not a float. it's either 8 or 16, in practice
rocketpool-cli/node/stake-rpl.go
Outdated
fmt.Sprintf("Your entire RPL balance (%.6f RPL)?", math.RoundDown(eth.WeiToEth(&rplBalance), 6)), | ||
"A custom amount", | ||
"A custom percentage", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's fold this into "A custom amount"...
Again, just tell the user to either enter an amount of rpl or a precentage of borrowed eth, and check if there's a %
suffix
rocketpool-cli/node/stake-rpl.go
Outdated
trimmedInput := strings.TrimSuffix(customInput, "%") | ||
stakePercent, err := strconv.ParseFloat(trimmedInput, 64) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is fine but just for edification purposes, fmt.Sscanf may be more semantic, ie https://go.dev/play/p/BVofq8L4EpC
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for tightening this up! Looks good now.
Always a pleasure, thanks for the review! |
Included in this PR:
stake-rpl
, because changingnode.per.minipool.stake.minimum
to 0 broke the old selectionReintroduced the
-y
and-a
flags tonode deposit
for users who automate minipool deposits (10/10 foresight)node deposit
andcreate-vacant-minipool
uses ay/n
confirmation rather than prompting for a selection: