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

fix: Improve Stake Time Calculation Accuracy #119

Closed
wants to merge 18 commits into from
Closed
Changes from 1 commit
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
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
6 changes: 4 additions & 2 deletions engine/command/blockchain/blockchain.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"github.com/pagu-project/Pagu/client"
"github.com/pagu-project/Pagu/engine/command"
"github.com/pagu-project/Pagu/utils"
// "github.com/pagu-project/Pagu/utils"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove this line.

)

const (
Expand Down Expand Up @@ -114,11 +115,12 @@ func (bc *Blockchain) calcRewardHandler(cmd command.Command, _ command.AppID, _

rewardInt := stake * blocks / int(amount.Amount(bi.TotalPower).ToPAC())

reward := amount.Amount(rewardInt)
// convert from nanoPac to PAC.
totalPowerInPAC := bi.TotalPower / 1_000_000_000
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@izikdepth please one time read and check amount.Amount functions.
Avoid using bare operation here.


return cmd.SuccessfulResult("Approximately you earn %v PAC reward, with %v PAC stake 🔒 on your validator in one %s ⏰ with %s total power ⚡ of committee."+
"\n\n> Note📝: This number is just an estimation. It will vary depending on your stake amount and total network power.",
utils.FormatNumber(int64(reward)), utils.FormatNumber(int64(stake)), duration, utils.FormatNumber(int64(amount.Amount(bi.TotalPower).ToPAC())))
rewardInt, strconv.Itoa(stake), duration, utils.FormatNumber(totalPowerInPAC))
}

func (bc *Blockchain) calcFeeHandler(cmd command.Command, _ command.AppID, _ string, args ...string) command.CommandResult {
Expand Down
Loading