Update migrations to include uatom IBC denom money market (#1132)

* add uatom ibc denom to money markets in hard migration

* add new money market to stability committee

* clean up

* update v0_16 migration test data

* add swp, uatom ibc denoms to hard gov committee

* update committee migration testdata

* update general migration test data

* specify committee ID with vars

* fix merge var rename bug

Co-authored-by: rhuairahrighairigh <ruaridh.odonnell@gmail.com>
This commit is contained in:
Denali Marsh 2022-01-15 01:12:23 +01:00 committed by GitHub
parent 2f9eb9ece1
commit 779f8081e7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 265 additions and 88 deletions

View File

@ -1892,30 +1892,11 @@
}
}
},
{
"type": "kava/MemberCommittee",
"value": {
"base_committee": {
"id": "3",
"description": "Kava God Committee (testing only)",
"members": ["kava1n96qpdfcz2m7y364ewk8srv9zuq6ucwduyjaag"],
"permissions": [
{
"type": "kava/GodPermission",
"value": {}
}
],
"vote_threshold": "0.500000000000000000",
"proposal_duration": "604800000000000",
"tally_option": "FirstPastThePost"
}
}
},
{
"type": "kava/TokenCommittee",
"value": {
"base_committee": {
"id": "4",
"id": "3",
"description": "Hard Governance Committee",
"members": ["kava1n96qpdfcz2m7y364ewk8srv9zuq6ucwduyjaag"],
"permissions": [
@ -2033,7 +2014,7 @@
"type": "kava/TokenCommittee",
"value": {
"base_committee": {
"id": "5",
"id": "4",
"description": "Swp Governance Committee",
"members": ["kava1n96qpdfcz2m7y364ewk8srv9zuq6ucwduyjaag"],
"permissions": [
@ -2078,6 +2059,25 @@
"quorum": "0.330000000000000000",
"tally_denom": "swp"
}
},
{
"type": "kava/MemberCommittee",
"value": {
"base_committee": {
"id": "5",
"description": "Kava God Committee (testing only)",
"members": ["kava1n96qpdfcz2m7y364ewk8srv9zuq6ucwduyjaag"],
"permissions": [
{
"type": "kava/GodPermission",
"value": {}
}
],
"vote_threshold": "0.500000000000000000",
"proposal_duration": "604800000000000",
"tally_option": "FirstPastThePost"
}
}
}
],
"next_proposal_id": "1",

View File

@ -401,6 +401,24 @@
},
"reserve_factor": "0.100000000000000000",
"keeper_reward_percentage": "0.010000000000000000"
},
{
"denom": "ibc/27394FB092D2ECCD56123C74F36E4C1F926001CEADA9CA97EA622B25F41E5EB2",
"borrow_limit": {
"has_max_limit": true,
"maximum_limit": "25000000000.000000000000000000",
"loan_to_value": "0.500000000000000000"
},
"spot_market_id": "atom:usd:30",
"conversion_factor": "1000000",
"interest_rate_model": {
"base_rate_apy": "0.000000000000000000",
"base_multiplier": "0.050000000000000000",
"kink": "0.800000000000000000",
"jump_multiplier": "5.000000000000000000"
},
"reserve_factor": "0.025000000000000000",
"keeper_reward_percentage": "0.020000000000000000"
}
],
"minimum_borrow_usd_value": "10.000000000000000000"
@ -1592,6 +1610,16 @@
"keeper_reward_percentage",
"reserve_factor"
]
},
{
"key": "denom",
"val": "ibc/27394FB092D2ECCD56123C74F36E4C1F926001CEADA9CA97EA622B25F41E5EB2",
"allowed_subparam_attr_changes": [
"borrow_limit",
"interest_rate_model",
"keeper_reward_percentage",
"reserve_factor"
]
}
]
}
@ -1618,24 +1646,10 @@
"tally_option": "TALLY_OPTION_FIRST_PAST_THE_POST"
}
},
{
"@type": "/kava.committee.v1beta1.MemberCommittee",
"base_committee": {
"id": "3",
"description": "Kava God Committee (testing only)",
"members": ["kava1n96qpdfcz2m7y364ewk8srv9zuq6ucwduyjaag"],
"permissions": [
{ "@type": "/kava.committee.v1beta1.GodPermission" }
],
"vote_threshold": "0.500000000000000000",
"proposal_duration": "604800s",
"tally_option": "TALLY_OPTION_FIRST_PAST_THE_POST"
}
},
{
"@type": "/kava.committee.v1beta1.TokenCommittee",
"base_committee": {
"id": "4",
"id": "3",
"description": "Hard Governance Committee",
"members": ["kava1n96qpdfcz2m7y364ewk8srv9zuq6ucwduyjaag"],
"permissions": [
@ -1747,6 +1761,28 @@
"reserve_factor",
"spot_market_id"
]
},
{
"key": "denom",
"val": "swp",
"allowed_subparam_attr_changes": [
"borrow_limit",
"interest_rate_model",
"keeper_reward_percentage",
"reserve_factor",
"spot_market_id"
]
},
{
"key": "denom",
"val": "ibc/27394FB092D2ECCD56123C74F36E4C1F926001CEADA9CA97EA622B25F41E5EB2",
"allowed_subparam_attr_changes": [
"borrow_limit",
"interest_rate_model",
"keeper_reward_percentage",
"reserve_factor",
"spot_market_id"
]
}
]
}
@ -1763,7 +1799,7 @@
{
"@type": "/kava.committee.v1beta1.TokenCommittee",
"base_committee": {
"id": "5",
"id": "4",
"description": "Swp Governance Committee",
"members": ["kava1n96qpdfcz2m7y364ewk8srv9zuq6ucwduyjaag"],
"permissions": [
@ -1803,6 +1839,20 @@
},
"quorum": "0.330000000000000000",
"tally_denom": "swp"
},
{
"@type": "/kava.committee.v1beta1.MemberCommittee",
"base_committee": {
"id": "5",
"description": "Kava God Committee (testing only)",
"members": ["kava1n96qpdfcz2m7y364ewk8srv9zuq6ucwduyjaag"],
"permissions": [
{ "@type": "/kava.committee.v1beta1.GodPermission" }
],
"vote_threshold": "0.500000000000000000",
"proposal_duration": "604800s",
"tally_option": "TALLY_OPTION_FIRST_PAST_THE_POST"
}
}
],
"proposals": [
@ -2127,10 +2177,7 @@
"create_localhost": false,
"next_client_sequence": "0",
"params": {
"allowed_clients": [
"06-solomachine",
"07-tendermint"
]
"allowed_clients": ["06-solomachine", "07-tendermint"]
}
},
"connection_genesis": {

View File

@ -21,6 +21,7 @@ import (
v016cdptypes "github.com/kava-labs/kava/x/cdp/types"
v015committee "github.com/kava-labs/kava/x/committee/legacy/v0_15"
v016committee "github.com/kava-labs/kava/x/committee/types"
v016hardMigration "github.com/kava-labs/kava/x/hard/legacy/v0_16"
v016hardtypes "github.com/kava-labs/kava/x/hard/types"
v015kavadist "github.com/kava-labs/kava/x/kavadist/legacy/v0_15"
v016kavadist "github.com/kava-labs/kava/x/kavadist/types"
@ -29,6 +30,11 @@ import (
v016pricefeedtypes "github.com/kava-labs/kava/x/pricefeed/types"
)
const (
KavaStabilityCommitteeID = 1
HardGovernanceCommitteeID = 3
)
// migrateWhitelist returns an string slice of json keys that should be whitelisted on the whitelist interface
func migrateWhitelist(whitelist interface{}, ignoredTag string) []string {
allowed := []string{}
@ -65,7 +71,7 @@ type subspaceKeyPair struct {
// migrateSubParamPermissions converts v15 SubParamChangePermissions to v16 ParamsChangePermission
func migrateSubParamPermissions(
permission v015committee.SubParamChangePermission,
isStabilityCommittee bool,
committeeID uint64,
oldPricefeedState v015pricefeed.GenesisState,
) *v016committee.ParamsChangePermission {
changes := v016committee.AllowedParamsChanges{}
@ -113,7 +119,7 @@ func migrateSubParamPermissions(
}
// add new requirement for stability committee
if isStabilityCommittee {
if committeeID == KavaStabilityCommitteeID {
requirement := v016committee.SubparamRequirement{
Key: "type",
Val: "swp-a",
@ -178,7 +184,7 @@ func migrateSubParamPermissions(
requirements = append(requirements, requirement)
}
if isStabilityCommittee {
if committeeID == KavaStabilityCommitteeID {
// Add permissions for existing pricefeed markets that are missing in allowed_markets
outer:
for _, oldPricefeedMarket := range oldPricefeedState.Params.Markets {
@ -233,7 +239,7 @@ func migrateSubParamPermissions(
}
// add new requirement for stability committee
if isStabilityCommittee {
if committeeID == KavaStabilityCommitteeID {
requirement := v016committee.SubparamRequirement{
Key: "denom",
Val: "swp",
@ -243,6 +249,37 @@ func migrateSubParamPermissions(
},
}
requirements = append(requirements, requirement)
requirementAtom := v016committee.SubparamRequirement{
Key: "denom",
Val: v016hardMigration.UATOM_IBC_DENOM,
AllowedSubparamAttrChanges: []string{
"borrow_limit", "interest_rate_model",
"keeper_reward_percentage", "reserve_factor",
},
}
requirements = append(requirements, requirementAtom)
} else if committeeID == HardGovernanceCommitteeID {
// add new requirement for Hard Governance committee
requirementSwp := v016committee.SubparamRequirement{
Key: "denom",
Val: "swp",
AllowedSubparamAttrChanges: []string{
"borrow_limit", "interest_rate_model", "keeper_reward_percentage",
"reserve_factor", "spot_market_id",
},
}
requirements = append(requirements, requirementSwp)
requirementUatom := v016committee.SubparamRequirement{
Key: "denom",
Val: v016hardMigration.UATOM_IBC_DENOM,
AllowedSubparamAttrChanges: []string{
"borrow_limit", "interest_rate_model", "keeper_reward_percentage",
"reserve_factor", "spot_market_id",
},
}
requirements = append(requirements, requirementUatom)
}
change.MultiSubparamsRequirements = requirements
@ -256,7 +293,7 @@ func migrateSubParamPermissions(
func migratePermission(
v015permission v015committee.Permission,
isStabilityCommittee bool,
committeeID uint64,
oldPricefeedState v015pricefeed.GenesisState,
) *codectypes.Any {
var protoProposal proto.Message
@ -289,7 +326,7 @@ func migratePermission(
}
case v015committee.SubParamChangePermission:
{
protoProposal = migrateSubParamPermissions(v015permission, isStabilityCommittee, oldPricefeedState)
protoProposal = migrateSubParamPermissions(v015permission, committeeID, oldPricefeedState)
}
default:
panic(fmt.Errorf("'%s' is not a valid permission", v015permission))
@ -324,8 +361,7 @@ func migrateCommittee(committee v015committee.Committee, oldPricefeedState v015p
{
permissions := make([]*codectypes.Any, len(committee.Permissions))
for i, permission := range committee.Permissions {
isStabilityCommittee := committee.GetID() == 1
permissions[i] = migratePermission(permission, isStabilityCommittee, oldPricefeedState)
permissions[i] = migratePermission(permission, committee.GetID(), oldPricefeedState)
}
protoProposal = &v016committee.MemberCommittee{
@ -344,7 +380,7 @@ func migrateCommittee(committee v015committee.Committee, oldPricefeedState v015p
{
permissions := make([]*codectypes.Any, len(committee.Permissions))
for i, permission := range committee.Permissions {
permissions[i] = migratePermission(permission, false, oldPricefeedState)
permissions[i] = migratePermission(permission, committee.GetID(), oldPricefeedState)
}
protoProposal = &v016committee.TokenCommittee{

View File

@ -403,30 +403,11 @@
}
}
},
{
"type": "kava/MemberCommittee",
"value": {
"base_committee": {
"id": "3",
"description": "Kava God Committee (testing only)",
"members": ["kava1n96qpdfcz2m7y364ewk8srv9zuq6ucwduyjaag"],
"permissions": [
{
"type": "kava/GodPermission",
"value": {}
}
],
"vote_threshold": "0.500000000000000000",
"proposal_duration": "604800000000000",
"tally_option": "FirstPastThePost"
}
}
},
{
"type": "kava/TokenCommittee",
"value": {
"base_committee": {
"id": "4",
"id": "3",
"description": "Hard Governance Committee",
"members": ["kava1n96qpdfcz2m7y364ewk8srv9zuq6ucwduyjaag"],
"permissions": [
@ -544,7 +525,7 @@
"type": "kava/TokenCommittee",
"value": {
"base_committee": {
"id": "5",
"id": "4",
"description": "Swp Governance Committee",
"members": ["kava1n96qpdfcz2m7y364ewk8srv9zuq6ucwduyjaag"],
"permissions": [
@ -589,6 +570,25 @@
"quorum": "0.330000000000000000",
"tally_denom": "swp"
}
},
{
"type": "kava/MemberCommittee",
"value": {
"base_committee": {
"id": "5",
"description": "Kava God Committee (testing only)",
"members": ["kava1n96qpdfcz2m7y364ewk8srv9zuq6ucwduyjaag"],
"permissions": [
{
"type": "kava/GodPermission",
"value": {}
}
],
"vote_threshold": "0.500000000000000000",
"proposal_duration": "604800000000000",
"tally_option": "FirstPastThePost"
}
}
}
],
"next_proposal_id": "1",

View File

@ -475,6 +475,16 @@
"keeper_reward_percentage",
"reserve_factor"
]
},
{
"key": "denom",
"val": "ibc/27394FB092D2ECCD56123C74F36E4C1F926001CEADA9CA97EA622B25F41E5EB2",
"allowed_subparam_attr_changes": [
"borrow_limit",
"interest_rate_model",
"keeper_reward_percentage",
"reserve_factor"
]
}
]
}
@ -501,22 +511,10 @@
"tally_option": "TALLY_OPTION_FIRST_PAST_THE_POST"
}
},
{
"@type": "/kava.committee.v1beta1.MemberCommittee",
"base_committee": {
"id": "3",
"description": "Kava God Committee (testing only)",
"members": ["kava1n96qpdfcz2m7y364ewk8srv9zuq6ucwduyjaag"],
"permissions": [{ "@type": "/kava.committee.v1beta1.GodPermission" }],
"vote_threshold": "0.500000000000000000",
"proposal_duration": "604800s",
"tally_option": "TALLY_OPTION_FIRST_PAST_THE_POST"
}
},
{
"@type": "/kava.committee.v1beta1.TokenCommittee",
"base_committee": {
"id": "4",
"id": "3",
"description": "Hard Governance Committee",
"members": ["kava1n96qpdfcz2m7y364ewk8srv9zuq6ucwduyjaag"],
"permissions": [
@ -628,6 +626,28 @@
"reserve_factor",
"spot_market_id"
]
},
{
"key": "denom",
"val": "swp",
"allowed_subparam_attr_changes": [
"borrow_limit",
"interest_rate_model",
"keeper_reward_percentage",
"reserve_factor",
"spot_market_id"
]
},
{
"key": "denom",
"val": "ibc/27394FB092D2ECCD56123C74F36E4C1F926001CEADA9CA97EA622B25F41E5EB2",
"allowed_subparam_attr_changes": [
"borrow_limit",
"interest_rate_model",
"keeper_reward_percentage",
"reserve_factor",
"spot_market_id"
]
}
]
}
@ -644,7 +664,7 @@
{
"@type": "/kava.committee.v1beta1.TokenCommittee",
"base_committee": {
"id": "5",
"id": "4",
"description": "Swp Governance Committee",
"members": ["kava1n96qpdfcz2m7y364ewk8srv9zuq6ucwduyjaag"],
"permissions": [
@ -684,6 +704,18 @@
},
"quorum": "0.330000000000000000",
"tally_denom": "swp"
},
{
"@type": "/kava.committee.v1beta1.MemberCommittee",
"base_committee": {
"id": "5",
"description": "Kava God Committee (testing only)",
"members": ["kava1n96qpdfcz2m7y364ewk8srv9zuq6ucwduyjaag"],
"permissions": [{ "@type": "/kava.committee.v1beta1.GodPermission" }],
"vote_threshold": "0.500000000000000000",
"proposal_duration": "604800s",
"tally_option": "TALLY_OPTION_FIRST_PAST_THE_POST"
}
}
],
"proposals": [

View File

@ -1,14 +1,19 @@
package v0_16
import (
sdk "github.com/cosmos/cosmos-sdk/types"
v015hard "github.com/kava-labs/kava/x/hard/legacy/v0_15"
v016hard "github.com/kava-labs/kava/x/hard/types"
)
// Denom generated via: echo -n transfer/channel-0/uatom | shasum -a 256 | awk '{printf "ibc/%s",toupper($1)}'
const UATOM_IBC_DENOM = "ibc/27394FB092D2ECCD56123C74F36E4C1F926001CEADA9CA97EA622B25F41E5EB2"
func migrateParams(params v015hard.Params) v016hard.Params {
moneyMarkets := make([]v016hard.MoneyMarket, len(params.MoneyMarkets))
for i, mm := range params.MoneyMarkets {
moneyMarkets[i] = v016hard.MoneyMarket{
var moneyMarkets []v016hard.MoneyMarket
for _, mm := range params.MoneyMarkets {
moneyMarket := v016hard.MoneyMarket{
Denom: mm.Denom,
BorrowLimit: v016hard.BorrowLimit{
HasMaxLimit: mm.BorrowLimit.HasMaxLimit,
@ -26,8 +31,29 @@ func migrateParams(params v015hard.Params) v016hard.Params {
ReserveFactor: mm.ReserveFactor,
KeeperRewardPercentage: mm.KeeperRewardPercentage,
}
moneyMarkets = append(moneyMarkets, moneyMarket)
}
atomMoneyMarket := v016hard.MoneyMarket{
Denom: UATOM_IBC_DENOM,
BorrowLimit: v016hard.BorrowLimit{
HasMaxLimit: true,
MaximumLimit: sdk.NewDec(25000000000),
LoanToValue: sdk.MustNewDecFromStr("0.5"),
},
SpotMarketID: "atom:usd:30",
ConversionFactor: sdk.NewInt(1000000),
InterestRateModel: v016hard.InterestRateModel{
BaseRateAPY: sdk.ZeroDec(),
BaseMultiplier: sdk.MustNewDecFromStr("0.05"),
Kink: sdk.MustNewDecFromStr("0.8"),
JumpMultiplier: sdk.NewDec(5),
},
ReserveFactor: sdk.MustNewDecFromStr("0.025"),
KeeperRewardPercentage: sdk.MustNewDecFromStr("0.02"),
}
moneyMarkets = append(moneyMarkets, atomMoneyMarket)
return v016hard.Params{
MoneyMarkets: moneyMarkets,
MinimumBorrowUSDValue: params.MinimumBorrowUSDValue,

View File

@ -132,6 +132,24 @@ func (s *migrateTestSuite) TestMigrate_GenState() {
ReserveFactor: sdk.MustNewDecFromStr("0.5"),
KeeperRewardPercentage: sdk.MustNewDecFromStr("0.6"),
},
{
Denom: UATOM_IBC_DENOM,
BorrowLimit: v016hard.BorrowLimit{
HasMaxLimit: true,
MaximumLimit: sdk.NewDec(25000000000),
LoanToValue: sdk.MustNewDecFromStr("0.5"),
},
SpotMarketID: "atom:usd:30",
ConversionFactor: sdk.NewInt(1000000),
InterestRateModel: v016hard.InterestRateModel{
BaseRateAPY: sdk.ZeroDec(),
BaseMultiplier: sdk.MustNewDecFromStr("0.05"),
Kink: sdk.MustNewDecFromStr("0.8"),
JumpMultiplier: sdk.NewDec(5),
},
ReserveFactor: sdk.MustNewDecFromStr("0.025"),
KeeperRewardPercentage: sdk.MustNewDecFromStr("0.02"),
},
},
},
PreviousAccumulationTimes: v016hard.GenesisAccumulationTimes{

View File

@ -36,6 +36,24 @@
},
"reserve_factor": "0.100000000000000000",
"keeper_reward_percentage": "0.010000000000000000"
},
{
"denom": "ibc/27394FB092D2ECCD56123C74F36E4C1F926001CEADA9CA97EA622B25F41E5EB2",
"borrow_limit": {
"has_max_limit": true,
"maximum_limit": "25000000000.000000000000000000",
"loan_to_value": "0.500000000000000000"
},
"spot_market_id": "atom:usd:30",
"conversion_factor": "1000000",
"interest_rate_model": {
"base_rate_apy": "0.000000000000000000",
"base_multiplier": "0.050000000000000000",
"kink": "0.800000000000000000",
"jump_multiplier": "5.000000000000000000"
},
"reserve_factor": "0.025000000000000000",
"keeper_reward_percentage": "0.020000000000000000"
}
],
"minimum_borrow_usd_value": "10.000000000000000000"