Skip to content

Commit

Permalink
fix treasury comments (#267)
Browse files Browse the repository at this point in the history
  • Loading branch information
yys authored and dokwon committed Nov 12, 2019
1 parent 4025cd5 commit 157d778
Show file tree
Hide file tree
Showing 10 changed files with 32 additions and 32 deletions.
4 changes: 2 additions & 2 deletions x/treasury/abci.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ func EndBlocker(ctx sdk.Context, k Keeper) {

ctx.EventManager().EmitEvent(
sdk.NewEvent(types.EventTypePolichUpdate,
sdk.NewAttribute(types.AttributeKeyTax, taxRate.String()),
sdk.NewAttribute(types.AttributeKeyReward, rewardWeight.String()),
sdk.NewAttribute(types.AttributeKeyTaxRate, taxRate.String()),
sdk.NewAttribute(types.AttributeKeyRewardWeight, rewardWeight.String()),
sdk.NewAttribute(types.AttributeKeyTaxCap, taxCap.String()),
),
)
Expand Down
2 changes: 1 addition & 1 deletion x/treasury/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ func InitGenesis(ctx sdk.Context, keeper Keeper, data GenesisState) {
keeper.SetRewardWeight(ctx, int64(epoch), rewardWeight)
}

// store tax cap for SDT & LUNA(no tax)
// store tax caps
for denom, taxCap := range data.TaxCaps {
keeper.SetTaxCap(ctx, denom, taxCap)
}
Expand Down
4 changes: 2 additions & 2 deletions x/treasury/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ func NewTreasuryPolicyUpdateHandler(k Keeper) govtypes.Handler {
}
}

// handleTaxRateUpdateProposal is a handler for updating tax-rate
// handleTaxRateUpdateProposal is a handler for updating tax rate
func handleTaxRateUpdateProposal(ctx sdk.Context, k Keeper, p TaxRateUpdateProposal) sdk.Error {
taxPolicy := k.TaxPolicy(ctx)
taxRate := k.GetTaxRate(ctx, core.GetEpoch(ctx))
Expand All @@ -39,7 +39,7 @@ func handleTaxRateUpdateProposal(ctx sdk.Context, k Keeper, p TaxRateUpdatePropo
return nil
}

// handleRewardWeightUpdateProposal is a handler for updating reward-weight
// handleRewardWeightUpdateProposal is a handler for updating reward weight
func handleRewardWeightUpdateProposal(ctx sdk.Context, k Keeper, p RewardWeightUpdateProposal) sdk.Error {
rewardPolicy := k.RewardPolicy(ctx)
rewardWeight := k.GetRewardWeight(ctx, core.GetEpoch(ctx))
Expand Down
6 changes: 3 additions & 3 deletions x/treasury/internal/keeper/indicator.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,17 +59,17 @@ func MiningRewardForEpoch(ctx sdk.Context, k Keeper, epoch int64) sdk.Dec {
return taxRewards.Add(seigniorageRewards)
}

// TRL returns tax rewards / luna / epoch
// TRL returns tax rewards per luna at the epoch
func TRL(ctx sdk.Context, k Keeper, epoch int64) sdk.Dec {
return UnitLunaIndicator(ctx, k, epoch, TaxRewardsForEpoch)
}

// SRL returns Seigniorage rewards / luna / epoch
// SRL returns Seigniorage rewards per luna at the epoch
func SRL(ctx sdk.Context, k Keeper, epoch int64) sdk.Dec {
return UnitLunaIndicator(ctx, k, epoch, SeigniorageRewardsForEpoch)
}

// MRL returns mining rewards / luna / epoch
// MRL returns mining rewards per luna at the epoch
func MRL(ctx sdk.Context, k Keeper, epoch int64) sdk.Dec {
return UnitLunaIndicator(ctx, k, epoch, MiningRewardForEpoch)
}
Expand Down
26 changes: 13 additions & 13 deletions x/treasury/internal/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ func (k Keeper) Codespace() sdk.CodespaceType {
return k.codespace
}

// GetTaxRate loads the tax-rate
// GetTaxRate loads the tax rate
func (k Keeper) GetTaxRate(ctx sdk.Context, epoch int64) (taxRate sdk.Dec) {
store := ctx.KVStore(k.storeKey)
b := store.Get(types.GetTaxRateKey(epoch))
Expand All @@ -73,17 +73,17 @@ func (k Keeper) GetTaxRate(ctx sdk.Context, epoch int64) (taxRate sdk.Dec) {
return
}

// SetTaxRate sets the tax-rate
// SetTaxRate sets the tax rate
func (k Keeper) SetTaxRate(ctx sdk.Context, epoch int64, taxRate sdk.Dec) {
store := ctx.KVStore(k.storeKey)
b := k.cdc.MustMarshalBinaryLengthPrefixed(taxRate)
store.Set(types.GetTaxRateKey(epoch), b)
}

// ClearRewardWeights clear all rewardWeight
func (k Keeper) ClearRewardWeights(ctx sdk.Context) {
// ClearTaxRates clears all tax rate
func (k Keeper) ClearTaxRates(ctx sdk.Context) {
store := ctx.KVStore(k.storeKey)
iter := sdk.KVStorePrefixIterator(store, types.RewardWeightKey)
iter := sdk.KVStorePrefixIterator(store, types.TaxRateKey)
defer iter.Close()
for ; iter.Valid(); iter.Next() {
store.Delete(iter.Key())
Expand All @@ -109,24 +109,24 @@ func (k Keeper) SetRewardWeight(ctx sdk.Context, epoch int64, rewardWeight sdk.D
store.Set(types.GetRewardWeightKey(epoch), b)
}

// ClearTaxRates clear all taxRate
func (k Keeper) ClearTaxRates(ctx sdk.Context) {
// ClearRewardWeights clears all reward weight
func (k Keeper) ClearRewardWeights(ctx sdk.Context) {
store := ctx.KVStore(k.storeKey)
iter := sdk.KVStorePrefixIterator(store, types.TaxRateKey)
iter := sdk.KVStorePrefixIterator(store, types.RewardWeightKey)
defer iter.Close()
for ; iter.Valid(); iter.Next() {
store.Delete(iter.Key())
}
}

// SetTaxCap sets the Tax Cap. Denominated in integer units of the reference {denom}
// SetTaxCap sets the tax cap denominated in integer units of the reference {denom}
func (k Keeper) SetTaxCap(ctx sdk.Context, denom string, cap sdk.Int) {
store := ctx.KVStore(k.storeKey)
bz := k.cdc.MustMarshalBinaryLengthPrefixed(cap)
store.Set(types.GetTaxCapKey(denom), bz)
}

// GetTaxCap gets the Tax Cap. Denominated in integer units of the reference {denom}
// GetTaxCap gets the tax cap denominated in integer units of the reference {denom}
func (k Keeper) GetTaxCap(ctx sdk.Context, denom string) (taxCap sdk.Int) {
store := ctx.KVStore(k.storeKey)

Expand All @@ -140,7 +140,7 @@ func (k Keeper) GetTaxCap(ctx sdk.Context, denom string) (taxCap sdk.Int) {
return
}

// IterateTaxCap iterates tax caps
// IterateTaxCap iterates all tax cap
func (k Keeper) IterateTaxCap(ctx sdk.Context, handler func(denom string, taxCap sdk.Int) (stop bool)) {
store := ctx.KVStore(k.storeKey)
iter := sdk.KVStorePrefixIterator(store, types.TaxCapKey)
Expand Down Expand Up @@ -195,7 +195,7 @@ func (k Keeper) PeekTaxProceeds(ctx sdk.Context, epoch int64) (res sdk.Coins) {
return
}

// ClearTaxProceeds clears all taxProceeds
// ClearTaxProceeds clears all tax proceeds
func (k Keeper) ClearTaxProceeds(ctx sdk.Context) {
store := ctx.KVStore(k.storeKey)
iter := sdk.KVStorePrefixIterator(store, types.TaxProceedsKey)
Expand Down Expand Up @@ -238,7 +238,7 @@ func (k Keeper) GetHistoricalIssuance(ctx sdk.Context, epoch int64) (res sdk.Coi
return
}

// ClearHistoricalIssuance clears all taxProceeds
// ClearHistoricalIssuance clears all historical issuance
func (k Keeper) ClearHistoricalIssuance(ctx sdk.Context) {
store := ctx.KVStore(k.storeKey)
iter := sdk.KVStorePrefixIterator(store, types.HistoricalIssuanceKey)
Expand Down
8 changes: 4 additions & 4 deletions x/treasury/internal/keeper/params.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@ func (k Keeper) RewardPolicy(ctx sdk.Context) (res types.PolicyConstraints) {
return
}

// SeigniorageBurdenTarget nolint
// SeigniorageBurdenTarget defines fixed target for the Seigniorage Burden. Between 0 and 1.
func (k Keeper) SeigniorageBurdenTarget(ctx sdk.Context) (res sdk.Dec) {
k.paramSpace.Get(ctx, types.ParamStoreKeySeigniorageBurdenTarget, &res)
return
}

// MiningIncrement nolint
// MiningIncrement is a factor used to determine how fast MRL should grow over time
func (k Keeper) MiningIncrement(ctx sdk.Context) (res sdk.Dec) {
k.paramSpace.Get(ctx, types.ParamStoreKeyMiningIncrement, &res)
return
Expand All @@ -53,13 +53,13 @@ func (k Keeper) WindowProbation(ctx sdk.Context) (res int64) {
return
}

// GetParams returns the total set of market parameters.
// GetParams returns the total set of treasury parameters.
func (k Keeper) GetParams(ctx sdk.Context) (params types.Params) {
k.paramSpace.GetParamSet(ctx, &params)
return params
}

// SetParams sets the total set of market parameters.
// SetParams sets the total set of treasury parameters.
func (k Keeper) SetParams(ctx sdk.Context, params types.Params) {
k.paramSpace.SetParamSet(ctx, &params)
}
4 changes: 2 additions & 2 deletions x/treasury/internal/keeper/policy.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (

// UpdateTaxCap updates all denom's tax cap
func (k Keeper) UpdateTaxCap(ctx sdk.Context) sdk.Coins {
cap := k.GetParams(ctx).TaxPolicy.Cap
cap := sdk.NewDecCoinFromCoin(k.GetParams(ctx).TaxPolicy.Cap)
total := k.supplyKeeper.GetSupply(ctx).GetTotal()

var newCaps sdk.Coins
Expand All @@ -18,7 +18,7 @@ func (k Keeper) UpdateTaxCap(ctx sdk.Context) sdk.Coins {
continue
}

newDecCap, err := k.marketKeeper.ComputeInternalSwap(ctx, sdk.NewDecCoinFromCoin(cap), coin.Denom)
newDecCap, err := k.marketKeeper.ComputeInternalSwap(ctx, cap, coin.Denom)
if err == nil {
newCap, _ := newDecCap.TruncateDecimal()
newCaps = append(newCaps, newCap)
Expand Down
2 changes: 1 addition & 1 deletion x/treasury/internal/keeper/querier.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ func NewQuerier(keeper Keeper) sdk.Querier {
case types.QueryParameters:
return queryParameters(ctx, keeper)
default:
return nil, sdk.ErrUnknownRequest("unknown market query endpoint")
return nil, sdk.ErrUnknownRequest("unknown treasury query endpoint")
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion x/treasury/internal/keeper/seigniorage.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
core "github.com/terra-project/core/types"
)

// SettleSeigniorage computes seigniorage and distributes it to oracle and community-pool account
// SettleSeigniorage computes seigniorage and distributes it to oracle and distribution(community-pool) account
func (k Keeper) SettleSeigniorage(ctx sdk.Context) {
// Mint seigniorage for oracle and community pool
epoch := core.GetEpoch(ctx)
Expand Down
6 changes: 3 additions & 3 deletions x/treasury/internal/types/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ package types
const (
EventTypePolichUpdate = "policy_update"

AttributeKeyTax = "tax"
AttributeKeyReward = "reward"
AttributeKeyTaxCap = "tax_cap"
AttributeKeyTaxRate = "tax_rate"
AttributeKeyRewardWeight = "reward_weight"
AttributeKeyTaxCap = "tax_cap"
)

0 comments on commit 157d778

Please sign in to comment.