@@ -34,11 +34,16 @@ import (
3434 "github.com/cosmos/ibc-go/v7/modules/core/exported"
3535 ibctmmigrations "github.com/cosmos/ibc-go/v7/modules/light-clients/07-tendermint/migrations"
3636
37+ "github.com/sentinel-official/sentinelhub/v12/third_party/osmosis/x/poolmanager/client/queryproto"
38+ protorevtypes "github.com/sentinel-official/sentinelhub/v12/third_party/osmosis/x/protorev/types"
39+ oraclekeeper "github.com/sentinel-official/sentinelhub/v12/x/oracle/keeper"
3740 oracletypes "github.com/sentinel-official/sentinelhub/v12/x/oracle/types"
41+ v1oracletypes "github.com/sentinel-official/sentinelhub/v12/x/oracle/types/v1"
3842)
3943
4044const (
41- UpgradeName = "v12_0_0"
45+ preUpgradeProtocolVersion = 11
46+ UpgradeName = "v12_0_0"
4247)
4348
4449var (
@@ -57,6 +62,9 @@ func UpgradeHandler(
5762 cdc codec.Codec , mm * sdkmodule.Manager , configurator sdkmodule.Configurator , keepers Keepers ,
5863) upgradetypes.UpgradeHandler {
5964 return func (ctx sdk.Context , _ upgradetypes.Plan , fromVM sdkmodule.VersionMap ) (sdkmodule.VersionMap , error ) {
65+ versionSetter := keepers .UpgradeKeeper .GetVersionSetter ()
66+ versionSetter .SetProtocolVersion (preUpgradeProtocolVersion )
67+
6068 keyTables := map [string ]paramstypes.KeyTable {
6169 // Cosmos SDK subspaces
6270 authtypes .ModuleName : authtypes .ParamKeyTable (),
@@ -105,6 +113,13 @@ func UpgradeHandler(
105113 return nil , err
106114 }
107115
116+ mintParams := keepers .MintKeeper .GetParams (ctx )
117+
118+ mintParams .BlocksPerYear = (365.25 * 24 * 60 * 60 ) / 3
119+ if err := keepers .MintKeeper .SetParams (ctx , mintParams ); err != nil {
120+ return nil , err
121+ }
122+
108123 stakingParams := keepers .StakingKeeper .GetParams (ctx )
109124
110125 stakingParams .MinCommissionRate = sdkmath .LegacyNewDecWithPrec (5 , 2 )
@@ -147,6 +162,14 @@ func UpgradeHandler(
147162 return nil , err
148163 }
149164
165+ if err := setDenomMetadata (ctx , keepers .BankKeeper ); err != nil {
166+ return nil , err
167+ }
168+
169+ if err := setOracleAssets (ctx , keepers .OracleKeeper ); err != nil {
170+ return nil , err
171+ }
172+
150173 return newVM , nil
151174 }
152175}
@@ -308,7 +331,7 @@ func migrateFoundationAccount(
308331 ak .SetAccount (ctx , vestingAccount )
309332
310333 // Transfer spendable coins to new address
311- toAddr , err := sdk .AccAddressFromBech32 ("" )
334+ toAddr , err := sdk .AccAddressFromBech32 ("" ) // TODO: set addr
312335 if err != nil {
313336 return err
314337 }
@@ -323,3 +346,160 @@ func migrateFoundationAccount(
323346
324347 return nil
325348}
349+
350+ func setDenomMetadata (ctx sdk.Context , k bankkeeper.Keeper ) error {
351+ items := []banktypes.Metadata {
352+ {
353+ Description : "The native staking token of Sentinel Hub" ,
354+ DenomUnits : []* banktypes.DenomUnit {
355+ {Denom : "udvpn" , Exponent : 0 },
356+ {Denom : "mdvpn" , Exponent : 3 },
357+ {Denom : "dvpn" , Exponent : 6 },
358+ },
359+ Base : "udvpn" ,
360+ Display : "P2P" ,
361+ Name : "Sentinel" ,
362+ Symbol : "P2P" ,
363+ },
364+ {
365+ DenomUnits : []* banktypes.DenomUnit {
366+ {
367+ Denom : "ibc/A8C2D23A1E6F95DA4E48BA349667E322BD7A6C996D8A4AAE8BA72E190F3D1477" ,
368+ Exponent : 0 ,
369+ Aliases : []string {"uatom" },
370+ },
371+ },
372+ Base : "ibc/A8C2D23A1E6F95DA4E48BA349667E322BD7A6C996D8A4AAE8BA72E190F3D1477" ,
373+ Display : "ATOM" ,
374+ Name : "Cosmos" ,
375+ Symbol : "ATOM" ,
376+ },
377+ {
378+ DenomUnits : []* banktypes.DenomUnit {
379+ {
380+ Denom : "ibc/B1C0DDB14F25279A2026BC8794E12B259F8BDA546A3C5132CCAEE4431CE36783" ,
381+ Exponent : 0 ,
382+ Aliases : []string {"udec" },
383+ },
384+ },
385+ Base : "ibc/B1C0DDB14F25279A2026BC8794E12B259F8BDA546A3C5132CCAEE4431CE36783" ,
386+ Display : "DEC" ,
387+ Name : "Decentr" ,
388+ Symbol : "DEC" ,
389+ },
390+ {
391+ DenomUnits : []* banktypes.DenomUnit {
392+ {
393+ Denom : "ibc/ED07A3391A112B175915CD8FAF43A2DA8E4790EDE12566649D0C2F97716B8518" ,
394+ Exponent : 0 ,
395+ Aliases : []string {"uosmo" },
396+ },
397+ },
398+ Base : "ibc/ED07A3391A112B175915CD8FAF43A2DA8E4790EDE12566649D0C2F97716B8518" ,
399+ Display : "OSMO" ,
400+ Name : "Osmosis" ,
401+ Symbol : "OSMO" ,
402+ },
403+ {
404+ DenomUnits : []* banktypes.DenomUnit {
405+ {
406+ Denom : "ibc/31FEE1A2A9F9C01113F90BD0BBCCE8FD6BBB8585FAF109A2101827DD1D5B95B8" ,
407+ Exponent : 0 ,
408+ Aliases : []string {"uscrt" },
409+ },
410+ },
411+ Base : "ibc/31FEE1A2A9F9C01113F90BD0BBCCE8FD6BBB8585FAF109A2101827DD1D5B95B8" ,
412+ Display : "SCRT" ,
413+ Name : "Secret" ,
414+ Symbol : "SCRT" ,
415+ },
416+ }
417+
418+ for _ , item := range items {
419+ k .SetDenomMetaData (ctx , item )
420+ }
421+
422+ return nil
423+ }
424+
425+ func setOracleAssets (ctx sdk.Context , k oraclekeeper.Keeper ) error {
426+ // ATOM -> "ibc/27394FB092D2ECCD56123C74F36E4C1F926001CEADA9CA97EA622B25F41E5EB2"
427+ // DEC -> "ibc/9BCB27203424535B6230D594553F1659C77EC173E36D9CF4759E7186EE747E84"
428+ // OSMO -> "uosmo"
429+ // P2P -> "ibc/9712DBB13B9631EDFA9BF61B55F1B2D290B2ADB67E3A4EB3A875F3B6081B3B84"
430+ // SCRT -> "ibc/0954E1C28EB7AF5B72D24F3BC2B47BBB2FDF91BDDFD57B74B99E133AED40972A"
431+ // USDC -> "ibc/498A0751C798A0D9A389AA3691123DADA57DAA4FE165D5C75894505B876BA6E4"
432+ items := []v1oracletypes.Asset {
433+ {
434+ Denom : "udvpn" ,
435+ Decimals : 6 ,
436+ ProtoRevPoolRequest : protorevtypes.QueryGetProtoRevPoolRequest {
437+ BaseDenom : "ibc/498A0751C798A0D9A389AA3691123DADA57DAA4FE165D5C75894505B876BA6E4" ,
438+ OtherDenom : "ibc/9712DBB13B9631EDFA9BF61B55F1B2D290B2ADB67E3A4EB3A875F3B6081B3B84" ,
439+ },
440+ SpotPriceRequest : queryproto.SpotPriceRequest {
441+ BaseAssetDenom : "ibc/498A0751C798A0D9A389AA3691123DADA57DAA4FE165D5C75894505B876BA6E4" ,
442+ QuoteAssetDenom : "ibc/9712DBB13B9631EDFA9BF61B55F1B2D290B2ADB67E3A4EB3A875F3B6081B3B84" ,
443+ },
444+ SpotPrice : sdkmath .LegacyZeroDec (),
445+ },
446+ {
447+ Denom : "ibc/A8C2D23A1E6F95DA4E48BA349667E322BD7A6C996D8A4AAE8BA72E190F3D1477" ,
448+ Decimals : 6 ,
449+ ProtoRevPoolRequest : protorevtypes.QueryGetProtoRevPoolRequest {
450+ BaseDenom : "ibc/498A0751C798A0D9A389AA3691123DADA57DAA4FE165D5C75894505B876BA6E4" ,
451+ OtherDenom : "ibc/27394FB092D2ECCD56123C74F36E4C1F926001CEADA9CA97EA622B25F41E5EB2" ,
452+ },
453+ SpotPriceRequest : queryproto.SpotPriceRequest {
454+ BaseAssetDenom : "ibc/498A0751C798A0D9A389AA3691123DADA57DAA4FE165D5C75894505B876BA6E4" ,
455+ QuoteAssetDenom : "ibc/27394FB092D2ECCD56123C74F36E4C1F926001CEADA9CA97EA622B25F41E5EB2" ,
456+ },
457+ SpotPrice : sdkmath .LegacyZeroDec (),
458+ },
459+ {
460+ Denom : "ibc/B1C0DDB14F25279A2026BC8794E12B259F8BDA546A3C5132CCAEE4431CE36783" ,
461+ Decimals : 6 ,
462+ ProtoRevPoolRequest : protorevtypes.QueryGetProtoRevPoolRequest {
463+ BaseDenom : "ibc/498A0751C798A0D9A389AA3691123DADA57DAA4FE165D5C75894505B876BA6E4" ,
464+ OtherDenom : "ibc/9BCB27203424535B6230D594553F1659C77EC173E36D9CF4759E7186EE747E84" ,
465+ },
466+ SpotPriceRequest : queryproto.SpotPriceRequest {
467+ BaseAssetDenom : "ibc/498A0751C798A0D9A389AA3691123DADA57DAA4FE165D5C75894505B876BA6E4" ,
468+ QuoteAssetDenom : "ibc/9BCB27203424535B6230D594553F1659C77EC173E36D9CF4759E7186EE747E84" ,
469+ },
470+ SpotPrice : sdkmath .LegacyZeroDec (),
471+ },
472+ {
473+ Denom : "ibc/ED07A3391A112B175915CD8FAF43A2DA8E4790EDE12566649D0C2F97716B8518" ,
474+ Decimals : 6 ,
475+ ProtoRevPoolRequest : protorevtypes.QueryGetProtoRevPoolRequest {
476+ BaseDenom : "ibc/498A0751C798A0D9A389AA3691123DADA57DAA4FE165D5C75894505B876BA6E4" ,
477+ OtherDenom : "uosmo" ,
478+ },
479+ SpotPriceRequest : queryproto.SpotPriceRequest {
480+ BaseAssetDenom : "ibc/498A0751C798A0D9A389AA3691123DADA57DAA4FE165D5C75894505B876BA6E4" ,
481+ QuoteAssetDenom : "uosmo" ,
482+ },
483+ SpotPrice : sdkmath .LegacyZeroDec (),
484+ },
485+ {
486+ Denom : "ibc/31FEE1A2A9F9C01113F90BD0BBCCE8FD6BBB8585FAF109A2101827DD1D5B95B8" ,
487+ Decimals : 6 ,
488+ ProtoRevPoolRequest : protorevtypes.QueryGetProtoRevPoolRequest {
489+ BaseDenom : "ibc/498A0751C798A0D9A389AA3691123DADA57DAA4FE165D5C75894505B876BA6E4" ,
490+ OtherDenom : "ibc/0954E1C28EB7AF5B72D24F3BC2B47BBB2FDF91BDDFD57B74B99E133AED40972A" ,
491+ },
492+ SpotPriceRequest : queryproto.SpotPriceRequest {
493+ BaseAssetDenom : "ibc/498A0751C798A0D9A389AA3691123DADA57DAA4FE165D5C75894505B876BA6E4" ,
494+ QuoteAssetDenom : "ibc/0954E1C28EB7AF5B72D24F3BC2B47BBB2FDF91BDDFD57B74B99E133AED40972A" ,
495+ },
496+ SpotPrice : sdkmath .LegacyZeroDec (),
497+ },
498+ }
499+
500+ for _ , item := range items {
501+ k .SetAsset (ctx , item )
502+ }
503+
504+ return nil
505+ }
0 commit comments