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

slashing command spec #138

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
106 changes: 106 additions & 0 deletions pkg/flags/flags.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
package flags

import "github.com/urfave/cli/v2"

var (
ConfigurationFileFlag = cli.StringFlag{
Name: "configuration-file",
Usage: "Path to the configuration file",
Required: true,
Aliases: []string{"c"},
}

AvsAddressesFlag = cli.StringSliceFlag{
Name: "avs-addresses",
Usage: "Comma separated list of AVS addresses",
Required: false,
Aliases: []string{"as"},
}

AvsAddressFlag = cli.StringSliceFlag{
Name: "avs-address",
Usage: "an AVS address",
Required: true,
Aliases: []string{"a"},
}

OperatorSetsFlag = cli.StringSliceFlag{
Name: "operator-sets",
Usage: "Comma separated list of operator sets AVSAddress#OperatorSetId",
Required: false,
Aliases: []string{"ops"},
}

OperatorSetFlag = cli.StringFlag{
Name: "operator-set",
Usage: "Operator set identifier AVSAddress#OperatorSetId",
Required: true,
Aliases: []string{"op"},
}

NumberOfDaysFlag = cli.IntFlag{
Name: "number-of-days",
Usage: "Number of days to show rewards for. Negative values to view retroactive rewards.",
Required: false,
DefaultText: "21",
Aliases: []string{"n"},
}

DryRunFlag = cli.BoolFlag{
Name: "dry-run",
Usage: "Dry run the command",
Required: false,
Aliases: []string{"d"},
}

BroadcastFlag = cli.BoolFlag{
Name: "broadcast",
Usage: "Broadcast the transaction",
Required: false,
Aliases: []string{"b"},
}

AllocationBipsFlag = cli.StringFlag{
Name: "allocation-bips",
Usage: "Allocation to update",
Required: true,
Aliases: []string{"ap"},
}

StakeSourceFlag = cli.StringFlag{
Name: "stake-source",
Usage: "The source of stake in case of allocation. The destination of stake if deallocation. Options are 'slashable', 'nonslashable' or 'both'. ",
Required: true,
Aliases: []string{"s"},
}

ShowMagnitudesFlag = cli.StringFlag{
Name: "show-magnitudes",
Usage: "Show magnitudes of stake share",
Required: true,
Aliases: []string{"m"},
}

RebalanceFilePathFlag = cli.PathFlag{
Name: "rebalance-file-path",
Usage: `Path to the CSV file.
The CSV file should have the following columns: operator set,allocation percentage.
This file must have all the operator sets and their allocation percentages for a strategy.`,
Required: true,
Aliases: []string{"r"},
}

StrategyAddressFlag = cli.StringFlag{
Name: "strategy-address",
Usage: "Address of the strategy contract",
Required: true,
Aliases: []string{"sa"},
}

OutputFilePathFlag = cli.StringFlag{
Name: "output-file-path",
Usage: "Path to the output file. It will be in a CSV format",
Required: false,
Aliases: []string{"o"},
}
)
3 changes: 3 additions & 0 deletions pkg/operator.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package pkg
import (
"github.com/Layr-Labs/eigenlayer-cli/pkg/operator"
"github.com/Layr-Labs/eigenlayer-cli/pkg/utils"

"github.com/urfave/cli/v2"
)

Expand All @@ -16,6 +17,8 @@ func OperatorCmd(p utils.Prompter) *cli.Command {
operator.RegisterCmd(p),
operator.StatusCmd(p),
operator.UpdateCmd(p),
operator.StakeAllocationCmd(p),
operator.RewardsCmd(p),
},
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/operator/keys/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ func GetOperatorIdFromBLSPubKey(pubKey string) (string, error) {
// ```
//
// This code just parser this string:
// E([498211989701534593628498974128726712526336918939770789545660245177948853517,19434346619705907282579203143605058653932187676054178921788041096426532277474])
// E([498211989701534593628498974128726712526336918939770789545660245177948853517,19434346619705907282579203143605058653932187676054178921788041096426532277474])

if pubKey == "O" {
return "", fmt.Errorf("pubKey is Infinity")
Expand Down
19 changes: 19 additions & 0 deletions pkg/operator/rewards.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package operator

import (
"github.com/Layr-Labs/eigenlayer-cli/pkg/operator/rewards"
"github.com/Layr-Labs/eigenlayer-cli/pkg/utils"

"github.com/urfave/cli/v2"
)

func RewardsCmd(p utils.Prompter) *cli.Command {
return &cli.Command{
Name: "rewards",
Usage: "Rewards commands",
Hidden: true,
Subcommands: []*cli.Command{
rewards.ShowCmd(p),
},
}
}
33 changes: 33 additions & 0 deletions pkg/operator/rewards/show.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package rewards

import (
"fmt"

"github.com/Layr-Labs/eigenlayer-cli/pkg/flags"
"github.com/Layr-Labs/eigenlayer-cli/pkg/telemetry"
"github.com/Layr-Labs/eigenlayer-cli/pkg/utils"

"github.com/urfave/cli/v2"
)

func ShowCmd(p utils.Prompter) *cli.Command {
return &cli.Command{
Name: "show",
Aliases: []string{"s"},
Usage: "Show rewards",
After: telemetry.AfterRunAction(),
Action: showRewards,
Flags: []cli.Flag{
&flags.ConfigurationFileFlag,
&flags.NumberOfDaysFlag,
&flags.OperatorSetsFlag,
&flags.AvsAddressesFlag,
&flags.OutputFilePathFlag,
},
}
}

func showRewards(cCtx *cli.Context) error {
fmt.Println("unimplemented")
return nil
}
21 changes: 21 additions & 0 deletions pkg/operator/stakeallocation.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package operator

import (
"github.com/Layr-Labs/eigenlayer-cli/pkg/operator/stakeallocation"
"github.com/Layr-Labs/eigenlayer-cli/pkg/utils"

"github.com/urfave/cli/v2"
)

func StakeAllocationCmd(p utils.Prompter) *cli.Command {
return &cli.Command{
Name: "stake-allocation",
Usage: "Stake allocation commands",
Hidden: true,
Subcommands: []*cli.Command{
stakeallocation.ShowCmd(p),
stakeallocation.UpdateCmd(p),
stakeallocation.RebalanceCmd(p),
},
}
}
42 changes: 42 additions & 0 deletions pkg/operator/stakeallocation/rebalance.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package stakeallocation

import (
"fmt"

"github.com/Layr-Labs/eigenlayer-cli/pkg/flags"
"github.com/Layr-Labs/eigenlayer-cli/pkg/telemetry"
"github.com/Layr-Labs/eigenlayer-cli/pkg/utils"
"github.com/urfave/cli/v2"
)

func RebalanceCmd(p utils.Prompter) *cli.Command {
return &cli.Command{
Name: "rebalance",
Aliases: []string{"r"},
Usage: "Rebalance stake allocation",
Description: `
Rebalance the stake allocation for the operator for a particular strategy.
This CSV file requires the following columns for only one stragegy:
avs address,operator set,allocation bips
Example:
0xabcd,1,10
0x1234,2,15
`,
Action: rebalanceStakeAllocation,
After: telemetry.AfterRunAction(),
Flags: []cli.Flag{
&flags.ConfigurationFileFlag,
&flags.StrategyAddressFlag,
&flags.ShowMagnitudesFlag,
&flags.RebalanceFilePathFlag,
&flags.DryRunFlag,
&flags.BroadcastFlag,
&flags.OutputFilePathFlag,
},
}
}

func rebalanceStakeAllocation(ctx *cli.Context) error {
fmt.Println("unimplemented")
return nil
}
35 changes: 35 additions & 0 deletions pkg/operator/stakeallocation/show.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package stakeallocation

import (
"fmt"

"github.com/Layr-Labs/eigenlayer-cli/pkg/flags"
"github.com/Layr-Labs/eigenlayer-cli/pkg/telemetry"
"github.com/Layr-Labs/eigenlayer-cli/pkg/utils"

"github.com/urfave/cli/v2"
)

func ShowCmd(p utils.Prompter) *cli.Command {
return &cli.Command{
Name: "show",
Aliases: []string{"s"},
Usage: "Show stake allocation",
Description: `
Show the stake allocation for the operator
`,
Action: showStakeAllocation,
After: telemetry.AfterRunAction(),
Flags: []cli.Flag{
&flags.ConfigurationFileFlag,
&flags.AvsAddressesFlag,
&flags.OperatorSetsFlag,
&flags.OutputFilePathFlag,
},
}
}

func showStakeAllocation(ctx *cli.Context) error {
fmt.Println("unimplemented")
return nil
}
42 changes: 42 additions & 0 deletions pkg/operator/stakeallocation/update.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package stakeallocation

import (
"fmt"

"github.com/Layr-Labs/eigenlayer-cli/pkg/flags"
"github.com/Layr-Labs/eigenlayer-cli/pkg/telemetry"
"github.com/Layr-Labs/eigenlayer-cli/pkg/utils"
"github.com/urfave/cli/v2"
)

func UpdateCmd(p utils.Prompter) *cli.Command {
return &cli.Command{
Name: "update",
Aliases: []string{"u"},
Usage: "Update stake allocation",
Description: `
Update the stake allocation for the operator
`,
Action: func(context *cli.Context) error {
return updateStakeAllocation(context, p)
},
After: telemetry.AfterRunAction(),
Flags: []cli.Flag{
&flags.ConfigurationFileFlag,
&flags.AvsAddressFlag,
&flags.OperatorSetFlag,
&flags.StrategyAddressFlag,
&flags.AllocationBipsFlag,
&flags.StakeSourceFlag,
&flags.ShowMagnitudesFlag,
&flags.DryRunFlag,
&flags.BroadcastFlag,
&flags.OutputFilePathFlag,
},
}
}

func updateStakeAllocation(ctx *cli.Context, p utils.Prompter) error {
fmt.Println("unimplemented")
return nil
}
Loading
Loading