From 8292d6f185e4e5f0e1b01ac4ec6e159df34d2a39 Mon Sep 17 00:00:00 2001 From: Madhur Shrimal Date: Thu, 6 Jun 2024 21:03:22 -0700 Subject: [PATCH] slashing command spec --- pkg/flags/flags.go | 69 ++++++++++++++++++++++++++ pkg/operator.go | 3 ++ pkg/operator/rewards.go | 19 +++++++ pkg/operator/rewards/show.go | 32 ++++++++++++ pkg/operator/stakeallocation.go | 20 ++++++++ pkg/operator/stakeallocation/show.go | 34 +++++++++++++ pkg/operator/stakeallocation/update.go | 38 ++++++++++++++ 7 files changed, 215 insertions(+) create mode 100644 pkg/flags/flags.go create mode 100644 pkg/operator/rewards.go create mode 100644 pkg/operator/rewards/show.go create mode 100644 pkg/operator/stakeallocation.go create mode 100644 pkg/operator/stakeallocation/show.go create mode 100644 pkg/operator/stakeallocation/update.go diff --git a/pkg/flags/flags.go b/pkg/flags/flags.go new file mode 100644 index 0000000..712f482 --- /dev/null +++ b/pkg/flags/flags.go @@ -0,0 +1,69 @@ +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{"a"}, + } + + OperatorSetsFlag = cli.StringSliceFlag{ + Name: "operator-sets", + Usage: "Comma separated list of operator sets", + Required: false, + Aliases: []string{"os"}, + } + + OperatorSetFlag = cli.StringFlag{ + Name: "operator-set", + Usage: "Operator set identifier", + Required: true, + Aliases: []string{"o"}, + } + + 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"}, + } + + AllocationPercentageFlag = cli.StringFlag{ + Name: "allocation-percentage", + Usage: "Allocation to update", + Required: true, + Aliases: []string{"a"}, + } + + 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"}, + } +) diff --git a/pkg/operator.go b/pkg/operator.go index 2f2b583..ee16603 100644 --- a/pkg/operator.go +++ b/pkg/operator.go @@ -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" ) @@ -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), }, } diff --git a/pkg/operator/rewards.go b/pkg/operator/rewards.go new file mode 100644 index 0000000..75e6f45 --- /dev/null +++ b/pkg/operator/rewards.go @@ -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), + }, + } +} diff --git a/pkg/operator/rewards/show.go b/pkg/operator/rewards/show.go new file mode 100644 index 0000000..2166b7e --- /dev/null +++ b/pkg/operator/rewards/show.go @@ -0,0 +1,32 @@ +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, + }, + } +} + +func showRewards(cCtx *cli.Context) error { + fmt.Println("unimplemented") + return nil +} diff --git a/pkg/operator/stakeallocation.go b/pkg/operator/stakeallocation.go new file mode 100644 index 0000000..11ac32b --- /dev/null +++ b/pkg/operator/stakeallocation.go @@ -0,0 +1,20 @@ +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), + }, + } +} diff --git a/pkg/operator/stakeallocation/show.go b/pkg/operator/stakeallocation/show.go new file mode 100644 index 0000000..5d50a50 --- /dev/null +++ b/pkg/operator/stakeallocation/show.go @@ -0,0 +1,34 @@ +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, + }, + } +} + +func showStakeAllocation(ctx *cli.Context) error { + fmt.Println("unimplemented") + return nil +} diff --git a/pkg/operator/stakeallocation/update.go b/pkg/operator/stakeallocation/update.go new file mode 100644 index 0000000..f9265a8 --- /dev/null +++ b/pkg/operator/stakeallocation/update.go @@ -0,0 +1,38 @@ +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.OperatorSetFlag, + &flags.DryRunFlag, + &flags.BroadcastFlag, + &flags.AllocationPercentageFlag, + &flags.StakeSourceFlag, + }, + } +} + +func updateStakeAllocation(ctx *cli.Context, p utils.Prompter) error { + fmt.Println("unimplemented") + return nil +}