fix
This commit is contained in:
parent
4d4de3aa09
commit
3a9102e2af
|
@ -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)
|
||||
|
|
|
@ -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))
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue