Skip to content

Commit

Permalink
Merge pull request #1848 from livepeer/nv/fee-cut
Browse files Browse the repository at this point in the history
cmd: use fee cut instead of fee share in the CLI
  • Loading branch information
kyriediculous committed Apr 28, 2021
2 parents 7a0fd1f + 0575c41 commit 60b297e
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 13 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG_PENDING.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

#### General

- \#1848 Use fee cut instead of fee share for user facing language in the CLI (@kyriediculous)

#### Broadcaster

#### Orchestrator
Expand Down
5 changes: 2 additions & 3 deletions cmd/livepeer_cli/wizard_bond.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,16 +34,15 @@ 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),
t.Address.Hex(),
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),
})
Expand Down
2 changes: 1 addition & 1 deletion cmd/livepeer_cli/wizard_stats.go
Original file line number Diff line number Diff line change
Expand Up @@ -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())},
}
Expand Down
25 changes: 16 additions & 9 deletions cmd/livepeer_cli/wizard_transcoder.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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")
Expand All @@ -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() {
Expand Down Expand Up @@ -268,3 +271,7 @@ func (w *wizard) showVoteChoices() {
}
wtr.Flush()
}

func flipPerc(perc *big.Int) *big.Int {
return new(big.Int).Sub(hundredPercent, perc)
}

0 comments on commit 60b297e

Please sign in to comment.