Skip to content

Commit

Permalink
Changed the stake options to 5/10/15% borrowed ETH per minipool
Browse files Browse the repository at this point in the history
  • Loading branch information
thomaspanf committed Oct 31, 2024
1 parent 8f70882 commit f12f56c
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 34 deletions.
9 changes: 4 additions & 5 deletions rocketpool-cli/commands/node/commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ func RegisterCommands(app *cli.App, name string, aliases []string) {
&cli.StringFlag{
Name: amountFlag,
Aliases: []string{"a"},
Usage: "The amount of RPL to stake (also accepts 'min8' / 'max8' for 8-ETH minipools, 'min16' / 'max16' for 16-ETH minipools, or 'all' for all of your RPL)",
Usage: "The amount of RPL to stake (also accepts '5', '10', or '15' for 8-ETH minipools, or 'all' for all of your RPL)",
},
cliutils.YesFlag,
&cli.BoolFlag{
Expand All @@ -255,10 +255,9 @@ func RegisterCommands(app *cli.App, name string, aliases []string) {

// Validate flags
if c.String(amountFlag) != "" &&
c.String(amountFlag) != "min8" &&
c.String(amountFlag) != "max8" &&
c.String(amountFlag) != "min16" &&
c.String(amountFlag) != "max16" &&
c.String(amountFlag) != "5%" &&
c.String(amountFlag) != "10%" &&
c.String(amountFlag) != "15%" &&
c.String(amountFlag) != "all" {
if _, err := input.ValidatePositiveEthAmount("stake amount", c.String(amountFlag)); err != nil {
return err
Expand Down
2 changes: 1 addition & 1 deletion rocketpool-cli/commands/node/deposit.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const (
maxSlippageFlag string = "max-slippage"
saltFlag string = "salt"
defaultMaxNodeFeeSlippage float64 = 0.01 // 1% below current network fee
depositWarningMessage string = "NOTE: by creating a new minipool, your node will automatically initialize voting power to itself. If you would like to delegate your on-chain voting power, you should run the command `rocketpool pdao initialize-voting` before creating a new minipool."
depositWarningMessage string = "NOTE: By creating a new minipool, your node will automatically initialize voting power to itself. If you would like to delegate your on-chain voting power, you should run the command `rocketpool pdao initialize-voting` before creating a new minipool."
)

type deposit struct {
Expand Down
26 changes: 19 additions & 7 deletions rocketpool-cli/commands/node/stake-rpl.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import (

const (
swapFlag string = "swap"
stakeRPLWarningMessage string = "NOTE: by staking RPL, your node will automatically initialize voting power to itself. If you would like to delegate your on-chain voting power, you should run the command `rocketpool pdao initialize-voting` before staking RPL."
stakeRPLWarningMessage string = "NOTE: By staking RPL, your node will automatically initialize voting power to itself. If you would like to delegate your on-chain voting power, you should run the command `rocketpool pdao initialize-voting` before staking RPL."
)

func nodeStakeRpl(c *cli.Context) error {
Expand Down Expand Up @@ -68,8 +68,12 @@ func nodeStakeRpl(c *cli.Context) error {
// Get stake amount
var amountWei *big.Int
switch c.String(amountFlag) {
case "min8":
amountWei = priceResponse.Data.MinPer8EthMinipoolRplStake
case "5%":
amountWei = priceResponse.Data.FivePercentBorrowedRplStake
case "10%":
amountWei = priceResponse.Data.TenPercentBorrowedRplStake
case "15%":
amountWei = priceResponse.Data.FifteenPercentBorrowedRplStake
case "all":
amountWei = rplBalance
case "":
Expand Down Expand Up @@ -154,21 +158,29 @@ func nodeStakeRpl(c *cli.Context) error {

// Prompt the user for the amount of RPL to stake
func promptForRplAmount(priceResponse *api.NetworkRplPriceData, rplBalance *big.Int) (*big.Int, error) {
// Get min/max per minipool RPL stake amounts
minAmount8 := priceResponse.MinPer8EthMinipoolRplStake
// Get the RPL stake amounts for 5,10,15% borrowed ETH per LEB8
fivePercentBorrowedRplStake := priceResponse.FivePercentBorrowedRplStake
tenPercentBorrowedRplStake := priceResponse.TenPercentBorrowedRplStake
fifteenPercentBorrowedRplStake := priceResponse.FifteenPercentBorrowedRplStake

// Prompt for amount option
var amountWei *big.Int
amountOptions := []string{
fmt.Sprintf("The minimum minipool stake amount for an 8-ETH minipool (%.6f RPL)?", math.RoundUp(eth.WeiToEth(minAmount8), 6)),
fmt.Sprintf("5%% of borrowed ETH (%.6f RPL) for one minipool?", math.RoundUp(eth.WeiToEth(fivePercentBorrowedRplStake), 6)),
fmt.Sprintf("10%% of borrowed ETH (%.6f RPL) for one minipool?", math.RoundUp(eth.WeiToEth(tenPercentBorrowedRplStake), 6)),
fmt.Sprintf("15%% of borrowed ETH (%.6f RPL) for one minipool?", math.RoundUp(eth.WeiToEth(fifteenPercentBorrowedRplStake), 6)),
fmt.Sprintf("Your entire RPL balance (%.6f RPL)?", math.RoundDown(eth.WeiToEth(rplBalance), 6)),
"A custom amount",
}
selected, _ := utils.Select("Please choose an amount of RPL to stake:", amountOptions)
switch selected {
case 0:
amountWei = minAmount8
amountWei = fivePercentBorrowedRplStake
case 1:
amountWei = tenPercentBorrowedRplStake
case 2:
amountWei = fifteenPercentBorrowedRplStake
case 3:
amountWei = rplBalance
}

Expand Down
29 changes: 12 additions & 17 deletions rocketpool-daemon/api/network/rpl-price.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,26 +85,21 @@ func (c *networkPriceContext) GetState(mc *batch.MultiCaller) {
func (c *networkPriceContext) PrepareData(data *api.NetworkRplPriceData, opts *bind.TransactOpts) (types.ResponseStatus, error) {
var rplPrice *big.Int
_24Eth := eth.EthToWei(24)
_16Eth := eth.EthToWei(16)
var minPerMinipoolStake *big.Int

data.RplPriceBlock = c.networkMgr.PricesBlock.Formatted()
rplPrice = c.networkMgr.RplPrice.Raw()
minPerMinipoolStake = c.pSettings.Node.MinimumPerMinipoolStake.Raw()

// Min for LEB8s
minPer8EthMinipoolRplStake := big.NewInt(0)
minPer8EthMinipoolRplStake.Mul(_24Eth, minPerMinipoolStake) // Min is 10% of borrowed (24 ETH)
minPer8EthMinipoolRplStake.Div(minPer8EthMinipoolRplStake, rplPrice)
minPer8EthMinipoolRplStake.Add(minPer8EthMinipoolRplStake, big.NewInt(1))
data.MinPer8EthMinipoolRplStake = minPer8EthMinipoolRplStake

// Min for 16s
minPer16EthMinipoolRplStake := big.NewInt(0)
minPer16EthMinipoolRplStake.Mul(_16Eth, minPerMinipoolStake) // Min is 10% of borrowed (16 ETH)
minPer16EthMinipoolRplStake.Div(minPer16EthMinipoolRplStake, rplPrice)
minPer16EthMinipoolRplStake.Add(minPer16EthMinipoolRplStake, big.NewInt(1))
data.MinPer16EthMinipoolRplStake = minPer16EthMinipoolRplStake

// RPL stake amounts for 5,10,15% borrowed ETH per LEB8
fivePercentBorrowedPerMinipool := new(big.Int)
fivePercentBorrowedPerMinipool.SetString("50000000000000000", 10)

fivePercentBorrowedRplStake := big.NewInt(0)
fivePercentBorrowedRplStake.Mul(_24Eth, fivePercentBorrowedPerMinipool)
fivePercentBorrowedRplStake.Div(fivePercentBorrowedRplStake, rplPrice)
fivePercentBorrowedRplStake.Add(fivePercentBorrowedRplStake, big.NewInt(1))
data.FivePercentBorrowedRplStake = fivePercentBorrowedRplStake
data.TenPercentBorrowedRplStake = new(big.Int).Mul(fivePercentBorrowedRplStake, big.NewInt(2))
data.FifteenPercentBorrowedRplStake = new(big.Int).Mul(fivePercentBorrowedRplStake, big.NewInt(3))

// Update & return response
data.RplPrice = rplPrice
Expand Down
9 changes: 5 additions & 4 deletions shared/types/api/network.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,11 @@ type NetworkNodeFeeData struct {
}

type NetworkRplPriceData struct {
RplPrice *big.Int `json:"rplPrice"`
RplPriceBlock uint64 `json:"rplPriceBlock"`
MinPer8EthMinipoolRplStake *big.Int `json:"minPer8EthMinipoolRplStake"`
MinPer16EthMinipoolRplStake *big.Int `json:"minPer16EthMinipoolRplStake"`
RplPrice *big.Int `json:"rplPrice"`
RplPriceBlock uint64 `json:"rplPriceBlock"`
FivePercentBorrowedRplStake *big.Int `json:"fivePercentBorrowedRplStake"`
TenPercentBorrowedRplStake *big.Int `json:"tenPercentRplStake"`
FifteenPercentBorrowedRplStake *big.Int `json:"fifteenPercentRplStake"`
}

type NetworkStatsData struct {
Expand Down

0 comments on commit f12f56c

Please sign in to comment.