* changelog * ... * decimal func working * decimal complete, untested * fixing tests * decimal compile errors resolved * test compile errors * precision multiplier test * 1% laptop battery * fixed TestNewDecFromStr * equalities working * fix bankers round chop * ... * working, some decimal issues resolved * fix rounding error * rounding works * decimal works * ... * deleted rational * rational conversion working * revert changelog * code compiles (not tests) * went through all NewDec, made sure they were converted from NewRat properly * test debugging * all testing bugs besides the json marshalling fixed * json unmarshal * lint * document update * fix lcd test * cli test fix * mostly undo Dece -> Rate * val comments * Efficiency improvements This now caches all of the precision multipliers (as they were all used in non-mutative functions), and caches the precisionInt calculation. (Now it just copies the already calculated value) * Cache another precisionInt() call. * Improve banker rounding efficiency * remove defer, make negation in-place. * chris val comments * bez comments * Aditya comments * ... * val comments * rebasing start * ... * compiling * tests pass * cli fix * anton, cwgoes, val comments * val and jae comments * type * undo reuse quo
73 lines
2.6 KiB
Go
73 lines
2.6 KiB
Go
package stake
|
|
|
|
import (
|
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
|
)
|
|
|
|
// burn burn burn
|
|
func BurnFeeHandler(ctx sdk.Context, _ sdk.Tx, collectedFees sdk.Coins) {}
|
|
|
|
//// Handle fee distribution to the validators and delegators
|
|
//func (k Keeper) FeeHandler(ctx sdk.Context, collectedFees sdk.Coins) {
|
|
//pool := k.GetPool(ctx)
|
|
//params := k.GetParams(ctx)
|
|
|
|
//// XXX determine
|
|
//candidate := NewCandidate(addrs[0], pks[0], Description{})
|
|
|
|
//// calculate the proposer reward
|
|
//precommitPower := k.GetTotalPrecommitVotingPower(ctx)
|
|
//toProposer := coinsMulRat(collectedFees, (sdk.NewDec(1, 100).Add(sdk.NewDec(4, 100).Mul(precommitPower).Quo(pool.BondedShares))))
|
|
//candidate.ProposerRewardPool = candidate.ProposerRewardPool.Plus(toProposer)
|
|
|
|
//toReservePool := coinsMulRat(collectedFees, params.ReservePoolFee)
|
|
//pool.FeeReservePool = pool.FeeReservePool.Plus(toReservePool)
|
|
|
|
//distributedReward := (collectedFees.Minus(toProposer)).Minus(toReservePool)
|
|
//pool.FeePool = pool.FeePool.Plus(distributedReward)
|
|
//pool.FeeSumReceived = pool.FeeSumReceived.Plus(distributedReward)
|
|
//pool.FeeRecent = distributedReward
|
|
|
|
//// lastly update the FeeRecent term
|
|
//pool.FeeRecent = collectedFees
|
|
|
|
//k.setPool(ctx, pool)
|
|
//}
|
|
|
|
//func coinsMulRat(coins sdk.Coins, rat sdk.Dec) sdk.Coins {
|
|
//var res sdk.Coins
|
|
//for _, coin := range coins {
|
|
//coinMulAmt := rat.Mul(sdk.NewDec(coin.Amount)).Evaluate()
|
|
//coinMul := sdk.Coins{{coin.Denom, coinMulAmt}}
|
|
//res = res.Plus(coinMul)
|
|
//}
|
|
//return res
|
|
//}
|
|
|
|
////____________________________________________________________________________-
|
|
|
|
//// calculate adjustment changes for a candidate at a height
|
|
//func CalculateAdjustmentChange(candidate Candidate, pool Pool, denoms []string, height int64) (Candidate, Pool) {
|
|
|
|
//heightRat := sdk.NewDec(height)
|
|
//lastHeightRat := sdk.NewDec(height - 1)
|
|
//candidateFeeCount := candidate.BondedShares.Mul(heightRat)
|
|
//poolFeeCount := pool.BondedShares.Mul(heightRat)
|
|
|
|
//for i, denom := range denoms {
|
|
//poolFeeSumReceived := sdk.NewDec(pool.FeeSumReceived.AmountOf(denom))
|
|
//poolFeeRecent := sdk.NewDec(pool.FeeRecent.AmountOf(denom))
|
|
//// calculate simple and projected pools
|
|
//simplePool := candidateFeeCount.Quo(poolFeeCount).Mul(poolFeeSumReceived)
|
|
//calc1 := candidate.PrevBondedShares.Mul(lastHeightRat).Quo(pool.PrevBondedShares.Mul(lastHeightRat)).Mul(poolFeeRecent)
|
|
//calc2 := candidate.BondedShares.Quo(pool.BondedShares).Mul(poolFeeRecent)
|
|
//projectedPool := calc1.Add(calc2)
|
|
|
|
//AdjustmentChange := simplePool.Sub(projectedPool)
|
|
//candidate.FeeAdjustments[i] = candidate.FeeAdjustments[i].Add(AdjustmentChange)
|
|
//pool.FeeAdjustments[i] = pool.FeeAdjustments[i].Add(AdjustmentChange)
|
|
//}
|
|
|
|
//return candidate, pool
|
|
//}
|