From 30af22b50b6cc40bb8db28e2cba7947529227d9a Mon Sep 17 00:00:00 2001 From: Denali Marsh Date: Mon, 16 Aug 2021 18:34:30 +0200 Subject: [PATCH] Initial kava 8 migration (#985) * add swap module, update incentive * add swapRewardPeriods to incentive * add TODOs * add text change permissions to hard, swap coms * rename variable to clarify delegation rewards * remove placeholder swp incentives Co-authored-by: karzak --- migrate/v0_15/incentive.go | 16 ++++++++-------- migrate/v0_15/migrate.go | 15 ++++++++++++--- 2 files changed, 20 insertions(+), 11 deletions(-) diff --git a/migrate/v0_15/incentive.go b/migrate/v0_15/incentive.go index 5d68c31b..ff59f139 100644 --- a/migrate/v0_15/incentive.go +++ b/migrate/v0_15/incentive.go @@ -37,7 +37,7 @@ func Incentive(incentiveGS v0_14incentive.GenesisState) v0_15incentive.GenesisSt MonthsLockup: 12, Factor: sdk.OneDec(), }, - }, // TODO set the correct multipliers + }, }, } @@ -48,23 +48,23 @@ func Incentive(incentiveGS v0_14incentive.GenesisState) v0_15incentive.GenesisSt usdxMintingRewardPeriods = append(usdxMintingRewardPeriods, usdxMintingRewardPeriod) } - hardDelegatorRewardPeriods := v0_15incentive.MultiRewardPeriods{} + delegatorRewardPeriods := v0_15incentive.MultiRewardPeriods{} for _, rp := range incentiveGS.Params.HardDelegatorRewardPeriods { - rewardsPerSecond := sdk.NewCoins(rp.RewardsPerSecond, SwpRewardsPerSecond) - hardDelegatorRewardPeriod := v0_15incentive.NewMultiRewardPeriod(rp.Active, + rewardsPerSecond := sdk.NewCoins(rp.RewardsPerSecond, SwpDelegatorRewardsPerSecond) + delegatorRewardPeriod := v0_15incentive.NewMultiRewardPeriod(rp.Active, rp.CollateralType, rp.Start, rp.End, rewardsPerSecond) - hardDelegatorRewardPeriods = append(hardDelegatorRewardPeriods, hardDelegatorRewardPeriod) + delegatorRewardPeriods = append(delegatorRewardPeriods, delegatorRewardPeriod) } - swapRewardPeriods := v0_15incentive.DefaultMultiRewardPeriods - // TODO add expected swap reward periods + // TODO: finalize swap reward pool IDs, rewards per second, start/end times. Should swap rewards start active? + swapRewardPeriods := v0_15incentive.MultiRewardPeriods{} // Build new params from migrated values params := v0_15incentive.NewParams( usdxMintingRewardPeriods, migrateMultiRewardPeriods(incentiveGS.Params.HardSupplyRewardPeriods), migrateMultiRewardPeriods(incentiveGS.Params.HardBorrowRewardPeriods), - hardDelegatorRewardPeriods, + delegatorRewardPeriods, swapRewardPeriods, newMultipliers, incentiveGS.Params.ClaimEnd, diff --git a/migrate/v0_15/migrate.go b/migrate/v0_15/migrate.go index 64680584..e177aec5 100644 --- a/migrate/v0_15/migrate.go +++ b/migrate/v0_15/migrate.go @@ -28,7 +28,9 @@ var ( ChainID = "kava-8" // TODO: update SWP reward per second amount before production // TODO: add swap tokens to kavadist module account - SwpRewardsPerSecond = sdk.NewCoin("swp", sdk.OneInt()) + // TODO: update SWP reward per second amount before production + SwpDelegatorRewardsPerSecond = sdk.NewCoin("swp", sdk.OneInt()) + SwpLiquidityProviderRewardsPerSecond = sdk.NewCoin("swp", sdk.OneInt()) ) // Migrate translates a genesis file from kava v0.14 format to kava v0.15 format @@ -269,6 +271,9 @@ func Committee(genesisState v0_14committee.GenesisState) v0_15committee.GenesisS newHardSubParamPermissions.AllowedMoneyMarkets = newMoneyMarketParams newHardCommitteePermissions = append(newHardCommitteePermissions, newHardSubParamPermissions) + // Text permissions + newHardCommitteePermissions = append(newHardCommitteePermissions, v0_15committee.TextPermission{}) + // Set hard governance committee permissions permissionedHardGovCom := hardGovCom.SetPermissions(newHardCommitteePermissions) committees = append(committees, permissionedHardGovCom) @@ -282,7 +287,7 @@ func Committee(genesisState v0_14committee.GenesisState) v0_15committee.GenesisS []v0_15committee.Permission{}, swpGovThreshold, swpGovDuration, v0_15committee.Deadline, swpGovQuorum, "swp") - // Add swap money market committee permissions + // Add swap committee permissions var newSwapCommitteePermissions []v0_15committee.Permission var newSwapSubParamPermissions v0_15committee.SubParamChangePermission @@ -294,8 +299,12 @@ func Committee(genesisState v0_14committee.GenesisState) v0_15committee.GenesisS v0_15committee.AllowedParam{Subspace: "incentive", Key: "SwapRewardPeriods"}, } newSwapSubParamPermissions.AllowedParams = swpAllowedParams - newSwpCommitteePermissions := append(newSwapCommitteePermissions, newSwapSubParamPermissions) + + // Text permissions + newSwpCommitteePermissions = append(newSwpCommitteePermissions, v0_15committee.TextPermission{}) + + // Set swap governance committee permissions permissionedSwapGovCom := swpGovCom.SetPermissions(newSwpCommitteePermissions) committees = append(committees, permissionedSwapGovCom)