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

WIP: Rounding debugging #3798

Closed
Changes from all commits
Commits
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
7 changes: 6 additions & 1 deletion x/distribution/keeper/delegation.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,12 @@ func (k Keeper) calculateDelegationRewards(ctx sdk.Context, val sdk.Validator, d
// introduce a correction factor in order to adjust for this inflation.
currentStake := del.GetShares().Mul(val.GetDelegatorShareExRate())
currentStakeF1 := val.GetTokens().ToDec().MulTruncate(del.GetShares()).QuoTruncate(val.GetDelegatorShares())
roundingCorrectionFactor := currentStake.QuoTruncate(currentStakeF1)
var roundingCorrectionFactor sdk.Dec
if currentStakeF1.IsZero() {
roundingCorrectionFactor = sdk.OneDec()
} else {
roundingCorrectionFactor = currentStake.QuoTruncate(currentStakeF1)
}

// iterate through slashes and withdraw with calculated staking for sub-intervals
// these offsets are dependent on *when* slashes happen - namely, in BeginBlock, after rewards are allocated...
Expand Down