From 0575c41072a37b97c70fd4a01c1440fae55dbac0 Mon Sep 17 00:00:00 2001 From: Nico Vergauwen Date: Tue, 27 Apr 2021 00:11:32 +0200 Subject: [PATCH] cmd: use fee cut instead of fee share in the CLI --- CHANGELOG_PENDING.md | 2 ++ cmd/livepeer_cli/wizard_bond.go | 5 ++--- cmd/livepeer_cli/wizard_stats.go | 2 +- cmd/livepeer_cli/wizard_transcoder.go | 25 ++++++++++++++++--------- 4 files changed, 21 insertions(+), 13 deletions(-) diff --git a/CHANGELOG_PENDING.md b/CHANGELOG_PENDING.md index a7600f8fc9..bcd91dc3e3 100644 --- a/CHANGELOG_PENDING.md +++ b/CHANGELOG_PENDING.md @@ -6,6 +6,8 @@ #### General +- \#1848 Use fee cut instead of fee share for user facing language in the CLI (@kyriediculous) + #### Broadcaster #### Orchestrator diff --git a/cmd/livepeer_cli/wizard_bond.go b/cmd/livepeer_cli/wizard_bond.go index 3bc276a78b..9b20535d9c 100644 --- a/cmd/livepeer_cli/wizard_bond.go +++ b/cmd/livepeer_cli/wizard_bond.go @@ -34,8 +34,7 @@ func (w *wizard) registeredOrchestratorStats() map[int]common.Address { fmt.Println("+------------------------+") table := tablewriter.NewWriter(os.Stdout) - table.SetHeader([]string{"ID", "Address", "Active", "Delegated Stake", "Reward Cut (%)", "Fee Share (%)", "Service URI", "Price Per Pixel"}) - + table.SetHeader([]string{"ID", "Address", "Active", "Delegated Stake", "Reward Cut (%)", "Fee Cut (%)", "Service URI", "Price Per Pixel"}) for _, t := range orchestrators { table.Append([]string{ strconv.FormatInt(int64(nextId), 10), @@ -43,7 +42,7 @@ func (w *wizard) registeredOrchestratorStats() map[int]common.Address { strconv.FormatBool(t.Active), eth.FormatUnits(t.DelegatedStake, "LPT"), eth.FormatPerc(t.RewardCut), - eth.FormatPerc(t.FeeShare), + eth.FormatPerc(flipPerc(t.FeeShare)), t.ServiceURI, t.PricePerPixel.FloatString(3), }) diff --git a/cmd/livepeer_cli/wizard_stats.go b/cmd/livepeer_cli/wizard_stats.go index 05829cb0da..c55cd5f615 100644 --- a/cmd/livepeer_cli/wizard_stats.go +++ b/cmd/livepeer_cli/wizard_stats.go @@ -205,7 +205,7 @@ func (w *wizard) orchestratorStats() { {"Service URI", t.ServiceURI}, {"Delegated Stake", eth.FormatUnits(t.DelegatedStake, "LPT")}, {"Reward Cut (%)", eth.FormatPerc(t.RewardCut)}, - {"Fee Share (%)", eth.FormatPerc(t.FeeShare)}, + {"Fee Cut (%)", eth.FormatPerc(flipPerc(t.FeeShare))}, {"Last Reward Round", t.LastRewardRound.String()}, {"Base price per pixel", fmt.Sprintf("%v wei / %v pixels", priceInfo.Num(), priceInfo.Denom())}, } diff --git a/cmd/livepeer_cli/wizard_transcoder.go b/cmd/livepeer_cli/wizard_transcoder.go index 892c8e513d..e07a551bfe 100644 --- a/cmd/livepeer_cli/wizard_transcoder.go +++ b/cmd/livepeer_cli/wizard_transcoder.go @@ -18,6 +18,11 @@ import ( const defaultRPCPort = "8935" +const defaultRewardCut = float64(10) +const defaultFeeCut = float64(95) + +var hundredPercent = eth.FromPerc(100) + func (w *wizard) isOrchestrator() bool { isT := httpGet(fmt.Sprintf("http://%v:%v/IsOrchestrator", w.host, w.httpPort)) return isT == "true" @@ -36,24 +41,22 @@ func myHostPort() string { func (w *wizard) promptOrchestratorConfig() (float64, float64, int, int, string) { var ( blockRewardCut float64 - feeShare float64 + feeCut float64 ) orch, _, err := w.getOrchestratorInfo() if err != nil || orch == nil { - fmt.Println("unable to get current reward cut and fee share") - blockRewardCut = 0 - feeShare = 0 + fmt.Println("unable to get current reward cut and fee cut") } else { blockRewardCut = eth.ToPerc(orch.RewardCut) - feeShare = eth.ToPerc(orch.FeeShare) + feeCut = eth.ToPerc(flipPerc(orch.FeeShare)) } - fmt.Printf("Enter block reward cut percentage (current=%v default=10) - ", blockRewardCut) + fmt.Printf("Enter block reward cut percentage (current=%v default=%v) - ", blockRewardCut, defaultRewardCut) blockRewardCut = w.readDefaultFloat(blockRewardCut) - fmt.Printf("Enter fee share percentage (current=%v default=5) - ", feeShare) - feeShare = w.readDefaultFloat(feeShare) + fmt.Printf("Enter fee cut percentage (current=%v default=%v) - ", feeCut, defaultFeeCut) + feeCut = w.readDefaultFloat(feeCut) fmt.Println("Enter a transcoding base price in wei per pixels") fmt.Println("eg. 1 wei / 10 pixels = 0,1 wei per pixel") @@ -80,7 +83,7 @@ func (w *wizard) promptOrchestratorConfig() (float64, float64, int, int, string) return in, nil }) - return blockRewardCut, feeShare, pricePerUnit, pixelsPerUnit, serviceURI + return blockRewardCut, 100 - feeCut, pricePerUnit, pixelsPerUnit, serviceURI } func (w *wizard) activateOrchestrator() { @@ -268,3 +271,7 @@ func (w *wizard) showVoteChoices() { } wtr.Flush() } + +func flipPerc(perc *big.Int) *big.Int { + return new(big.Int).Sub(hundredPercent, perc) +}