Skip to content

Commit

Permalink
fix: reward calc issue
Browse files Browse the repository at this point in the history
  • Loading branch information
kehiy committed Feb 5, 2024
1 parent fd12d69 commit d1e583f
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
2 changes: 1 addition & 1 deletion discord/handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ func rewardCalcCommandHandler(db *DiscordBot, s *discordgo.Session, i *discordgo
}

stake := i.ApplicationCommandData().Options[0].StringValue()
time := i.ApplicationCommandData().Options[0].StringValue()
time := i.ApplicationCommandData().Options[1].StringValue()

result, err := db.BotEngine.Run(fmt.Sprintf("calc-reward %v %v", stake, time))
if err != nil {
Expand Down
6 changes: 5 additions & 1 deletion engine/engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,10 @@ func (be *BotEngine) ClaimStatus() (int64, int64, int64, int64) {
}

func (be *BotEngine) RewardCalculate(stake int64, t string) (int64, string, int64, error) {
if stake < 1 || stake > 1_000 {
return 0, "", 0, errors.New("minimum of stake is 1 PAC and maximum is 1,000 PAC")
}

var blocks int64
time := t
switch t {
Expand All @@ -268,7 +272,7 @@ func (be *BotEngine) RewardCalculate(stake int64, t string) (int64, string, int6
}

reward := (stake * int64(blocks)) / int64(putils.ChangeToCoin(bi.TotalPower))
return reward, time, bi.TotalPower, nil
return reward, time, utils.AtomicToCoin(bi.TotalPower), nil
}

func (be *BotEngine) Stop() {
Expand Down
4 changes: 2 additions & 2 deletions engine/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,9 +128,9 @@ func (be *BotEngine) Run(input string) (string, error) {
return "", err
}

return fmt.Sprintf("You will get: %v PAC's reward, with %v stake 🔒 on your validator in one %s ⏰ with %v PAC total power ⚡ of committee."+
return fmt.Sprintf("Approximately you earn %v PAC's reward, with %v stake 🔒 on your validator in one %s ⏰ with %v PAC total power ⚡ of committee."+
"\n\n> Note📝: This is an estimation and the number can get changed by changes of your stake amount, total power and ...",
reward, stake, time, util.ChangeToString(totalPower)), nil
reward, stake, time, totalPower), nil

default:
return "", fmt.Errorf("unknown command: %s", cmd)
Expand Down

0 comments on commit d1e583f

Please sign in to comment.