Skip to content
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

Merged
merged 7 commits into from
Nov 6, 2024

Conversation

thomaspanf
Copy link
Member

Included in this PR:

  • New suggested RPL stake options in stake-rpl, because changing node.per.minipool.stake.minimum to 0 broke the old selection
Please choose an amount of RPL to stake:
1: 5% of borrowed ETH (276.648996 RPL) for one minipool?
2: 10% of borrowed ETH (553.297992 RPL) for one minipool?
3: 15% of borrowed ETH (829.946988 RPL) for one minipool?
  • Reintroduced the -y and -a flags to node deposit for users who automate minipool deposits (10/10 foresight)

  • node deposit and create-vacant-minipool uses a y/n confirmation rather than prompting for a selection:

// New
NOTE: You are about to make an 8 ETH deposit.
Would you like to continue? [y/n]
y

// Old
Please choose an amount of ETH to deposit:
1: 8 ETH
1

Copy link
Contributor

@jshufro jshufro left a 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

@thomaspanf
Copy link
Member Author

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!

Comment on lines 343 to 345
c.String("amount") != "5%" &&
c.String("amount") != "10%" &&
c.String("amount") != "15%" &&
Copy link
Contributor

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.

Copy link
Member Author

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.

rocketpool/api/network/rpl-price.go Outdated Show resolved Hide resolved
case 0:
if c.String("amount") != "" {
// Parse amount
depositAmount, err := strconv.ParseFloat(c.String("amount"), 64)
Copy link
Contributor

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

fmt.Sprintf("Your entire RPL balance (%.6f RPL)?", math.RoundDown(eth.WeiToEth(&rplBalance), 6)),
"A custom amount",
"A custom percentage",
Copy link
Contributor

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

Comment on lines 362 to 363
trimmedInput := strings.TrimSuffix(customInput, "%")
stakePercent, err := strconv.ParseFloat(trimmedInput, 64)
Copy link
Contributor

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

Copy link
Contributor

@jshufro jshufro left a 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.

@thomaspanf
Copy link
Member Author

Thanks for tightening this up! Looks good now.

Always a pleasure, thanks for the review!

@0xfornax 0xfornax merged commit c84d442 into master Nov 6, 2024
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants