Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature] Update treasury init genesis & oracle,market default params #272

Merged
merged 1 commit into from
Nov 18, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion x/market/alias.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ var (
ParmamStoreKeyTobinTax = types.ParmamStoreKeyTobinTax
DefaultBasePool = types.DefaultBasePool
DefaultPoolRecoveryPeriod = types.DefaultPoolRecoveryPeriod
DefaultTerraLiquidityRatio = types.DefaultTerraLiquidityRatio
DefaultMinSpread = types.DefaultMinSpread
DefaultTobinTax = types.DefaultTobinTax
)
Expand Down
9 changes: 4 additions & 5 deletions x/market/internal/types/params.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,10 @@ var (

// Default parameter values
var (
DefaultBasePool = sdk.NewDec(1000000 * core.MicroUnit) // 1000,000sdr = 1000,000,000,000usdr
DefaultPoolRecoveryPeriod = core.BlocksPerDay // 14,400
DefaultTerraLiquidityRatio = sdk.NewDecWithPrec(1, 2) // 1%
DefaultMinSpread = sdk.NewDecWithPrec(2, 2) // 2%
DefaultTobinTax = sdk.NewDecWithPrec(30, 4) // 0.3%
DefaultBasePool = sdk.NewDec(250000 * core.MicroUnit) // 250,000sdr = 250,000,000,000usdr
DefaultPoolRecoveryPeriod = core.BlocksPerDay // 14,400
DefaultMinSpread = sdk.NewDecWithPrec(2, 2) // 2%
DefaultTobinTax = sdk.NewDecWithPrec(25, 4) // 0.25%
)

var _ subspace.ParamSet = &Params{}
Expand Down
2 changes: 1 addition & 1 deletion x/oracle/internal/types/params.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ var (
// Default parameter values
const (
DefaultVotePeriod = core.BlocksPerMinute / 2 // 30 seconds
DefaultSlashWindow = core.BlocksPerHour / DefaultVotePeriod // window for a hour
DefaultSlashWindow = core.BlocksPerDay / DefaultVotePeriod // window for a day
DefaultRewardDistributionWindow = core.BlocksPerMonth / DefaultVotePeriod // window for a month
)

Expand Down
8 changes: 7 additions & 1 deletion x/treasury/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,15 @@ func InitGenesis(ctx sdk.Context, keeper Keeper, data GenesisState) {

keeper.SetTaxRate(ctx, data.TaxRate)
keeper.SetRewardWeight(ctx, data.RewardWeight)
keeper.SetEpochInitialIssuance(ctx, data.EpochInitialIssuance)
keeper.SetEpochTaxProceeds(ctx, data.TaxProceed)

// If EpochInitialIssuance is empty, we use current supply as epoch initial issuance
if data.EpochInitialIssuance.Empty() {
keeper.RecordEpochInitialIssuance(ctx)
} else {
keeper.SetEpochInitialIssuance(ctx, data.EpochInitialIssuance)
}

// store tax caps
for denom, taxCap := range data.TaxCaps {
keeper.SetTaxCap(ctx, denom, taxCap)
Expand Down
14 changes: 13 additions & 1 deletion x/treasury/genesis_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (

func TestExportInitGenesis(t *testing.T) {
input := keeper.CreateTestInput(t)
input.TreasuryKeeper.SetEpochInitialIssuance(input.Ctx, sdk.NewCoins(sdk.NewCoin("foo", sdk.NewInt(33))))
input.TreasuryKeeper.RecordEpochInitialIssuance(input.Ctx)
input.TreasuryKeeper.SetRewardWeight(input.Ctx, sdk.NewDec(1123))
input.TreasuryKeeper.SetTaxCap(input.Ctx, "foo", sdk.NewInt(1234))
input.TreasuryKeeper.SetTaxRate(input.Ctx, sdk.NewDec(5435))
Expand All @@ -32,4 +32,16 @@ func TestExportInitGenesis(t *testing.T) {
newGenesis := ExportGenesis(newInput.Ctx, newInput.TreasuryKeeper)

require.Equal(t, genesis, newGenesis)

// Make epoch initial issuance to zero
tmp := genesis.EpochInitialIssuance
genesis.EpochInitialIssuance = sdk.Coins{}

newInput = keeper.CreateTestInput(t)
InitGenesis(newInput.Ctx, newInput.TreasuryKeeper, genesis)
newGenesis = ExportGenesis(newInput.Ctx, newInput.TreasuryKeeper)

// Return back epoch initial issuance
genesis.EpochInitialIssuance = tmp
require.Equal(t, genesis, newGenesis)
}