Skip to content

Commit

Permalink
agasg
Browse files Browse the repository at this point in the history
  • Loading branch information
rigelrozanski committed Aug 15, 2018
1 parent 360eb75 commit 37ed3b1
Showing 1 changed file with 25 additions and 15 deletions.
40 changes: 25 additions & 15 deletions docs/spec/distribution/transactions.md
Original file line number Diff line number Diff line change
Expand Up @@ -149,18 +149,6 @@ func (vd ValidatorDistribution) UpdateTotalDelAccum(height int64, totalDelShares
vd.TotalDelAccum += totalDelShares * blocks
```

### Get delegator accum

Each delegation has a passively calculated accumulation factor to specify its
entitlement to the rewards from a validator. `Accum` is used to passively
calculate each bonds entitled rewards from the `Validator.Pool`.

```
func (dd DelegatorDist) Accum(height int64, delegatorShares Dec) Dec
blocks = height - dd.WithdrawalHeight
return delegatorShares * blocks
```

### Global pool to validator pool

Everytime a validator or delegator make a withdraw or the validator is the
Expand All @@ -177,6 +165,7 @@ func (vd ValidatorDistribution) TakeAccum(g Global, height int64, totalBonded, v
accum = blocks * vdTokens
withdrawalTokens := g.Pool * accum / g.TotalValAccum

g.TotalValAccum -= accumm
vd.Pool += withdrawalTokens
g.Pool -= withdrawalTokens

Expand All @@ -191,10 +180,18 @@ are subject to commission rate from the owner of the validator.

```
func (dd DelegatorDist) WithdrawalRewards(g Global, vd ValidatorDistribution,
height int64, totalBonded, vdTokens Dec) g Global
height int64, totalBonded, vdTokens, totalDelShares, commissionRate Dec) (g Global, withdrawn Dec)

vd.TakeAccum(g, height, totalBonded, vdTokens)
vd.UpdateTotalDelAccum(height, totalDelShares)
g = vd.TakeAccum(g, height, totalBonded, vdTokens)

blocks = height - dd.WithdrawalHeight
accum = delegatorShares * blocks * (1 - commissionRate)

withdrawalTokens := vd.Pool * accum / cd.TotalDelAccum
vd.Pool -= withdrawalTokens
vd.TotalDelAccum -= accum
return withdrawalTokens

```

Expand All @@ -204,5 +201,18 @@ Similar to a delegator's entitlement, but with recipient shares based on the
commission portion of bonded tokens.

```
TODO
func (dd DelegatorDist) WithdrawalCommission(g Global, vd ValidatorDistribution,
height int64, totalBonded, vdTokens, totalDelShares, commissionRate Dec) g Global

vd.UpdateTotalDelAccum(height, totalDelShares)
g = vd.TakeAccum(g, height, totalBonded, vdTokens)

blocks = height - vd.CommissionWithdrawalHeight
accum = delegatorShares * blocks * (commissionRate)

withdrawalTokens := vd.Pool * accum / cd.TotalDelAccum

vd.Pool -= withdrawalTokens
vd.TotalDelAccum -= accum

```

0 comments on commit 37ed3b1

Please sign in to comment.