This commit is contained in:
rigelrozanski 2018-10-04 03:34:10 -04:00
parent 4d4de3aa09
commit 3a9102e2af
3 changed files with 4 additions and 4 deletions

View File

@ -37,8 +37,8 @@ func (di DelegatorDistInfo) WithdrawRewards(fp FeePool, vi ValidatorDistInfo,
blocks := height - di.WithdrawalHeight
di.WithdrawalHeight = height
accum := delegatorShares.Mul(sdk.NewDec(blocks))
withdrawalTokens := vi.Pool.MulDec(accum.Quo(vi.DelAccum.Accum))
remainingTokens := vi.Pool.MulDec(sdk.OneDec().Sub(accum.Quo(vi.DelAccum.Accum)))
withdrawalTokens := vi.Pool.MulDec(accum).QuoDec(vi.DelAccum.Accum)
remainingTokens := vi.Pool.Minus(withdrawalTokens)
vi.Pool = remainingTokens
vi.DelAccum.Accum = vi.DelAccum.Accum.Sub(accum)

View File

@ -52,5 +52,5 @@ func TestWithdrawRewards(t *testing.T) {
assert.True(sdk.DecEq(t, sdk.NewDec(1800), fp.Pool[0].Amount))
assert.True(sdk.DecEq(t, sdk.NewDec(49), vi.Pool[0].Amount))
assert.True(sdk.DecEq(t, sdk.NewDec(4), vi.PoolCommission[0].Amount))
assert.True(sdk.DecEq(t, sdk.NewDec(147), rewardRecv2[0].Amount))
assert.True(sdk.DecEq(t, sdk.NewDec(98), rewardRecv2[0].Amount))
}

View File

@ -49,7 +49,7 @@ func (vi ValidatorDistInfo) TakeFeePoolRewards(fp FeePool, height int64, totalBo
remainingTokens := fp.Pool.Minus(withdrawalTokens)
commission := withdrawalTokens.MulDec(commissionRate)
afterCommission := withdrawalTokens.MulDec(sdk.OneDec().Sub(commissionRate))
afterCommission := withdrawalTokens.Minus(commission)
fp.ValAccum.Accum = fp.ValAccum.Accum.Sub(accum)
fp.Pool = remainingTokens