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

chore: rename UMEE token to UX token part1 #2328

Merged
merged 27 commits into from
Feb 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
9a8d82f
bank: rename UMEE token to UX
robert-zaremba Nov 16, 2023
e1c9319
migration
robert-zaremba Nov 16, 2023
bfc47d2
use new token BaseName and introduce IBCBaseName
robert-zaremba Nov 16, 2023
06762bd
Revert "use new token BaseName and introduce IBCBaseName"
robert-zaremba Nov 17, 2023
c9bedd9
rename
robert-zaremba Nov 17, 2023
ecdf28b
Merge branch 'main' into robert/ux-token
robert-zaremba Nov 17, 2023
e3ec745
typo
robert-zaremba Nov 17, 2023
942bb8e
update denom validation regexp
robert-zaremba Nov 17, 2023
169f1c5
rollback UX symbol to UMEE
robert-zaremba Nov 20, 2023
15d81a4
Merge branch 'main' into robert/ux-token
robert-zaremba Nov 20, 2023
27ce256
Merge branch 'main' into robert/ux-token
robert-zaremba Jan 3, 2024
51bd4b1
updates
robert-zaremba Jan 3, 2024
14dcc13
lint
robert-zaremba Jan 3, 2024
964d8a2
lint
robert-zaremba Jan 3, 2024
2c67224
Merge branch 'main' into robert/ux-token
robert-zaremba Feb 8, 2024
d311dc7
Merge remote-tracking branch 'origin/main' into robert/ux-token
robert-zaremba Feb 8, 2024
35b76ab
use DeepEquals
robert-zaremba Feb 8, 2024
f62e63a
fix leverage tests
robert-zaremba Feb 8, 2024
1621e95
fix oracle cli tests
robert-zaremba Feb 8, 2024
c54c3be
fix oracle tests
robert-zaremba Feb 8, 2024
8ac9978
lint
robert-zaremba Feb 8, 2024
2f31a79
lint
robert-zaremba Feb 8, 2024
587266e
lint
robert-zaremba Feb 8, 2024
4dc18fd
Merge branch 'main' into robert/ux-token
robert-zaremba Feb 8, 2024
d32e6c8
update linter settings
robert-zaremba Feb 8, 2024
99f7f16
test
robert-zaremba Feb 8, 2024
8458588
oracle tests: use LegacyDisplayDenom
robert-zaremba Feb 8, 2024
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
2 changes: 1 addition & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,6 @@ linters-settings:
- name: time-naming
- name: unexported-return
- name: unreachable-code
- name: unused-parameter
# - name: unused-parameter
robert-zaremba marked this conversation as resolved.
Show resolved Hide resolved
- name: var-declaration
- name: var-naming
2 changes: 1 addition & 1 deletion .revive.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ confidence = 0
[rule.time-naming]
[rule.unexported-return]
[rule.unreachable-code]
[rule.unused-parameter]
#[rule.unused-parameter]
[rule.var-declaration]
[rule.var-naming]

Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ Ref: https://keepachangelog.com/en/1.0.0/

### Improvements

- [2328](https://github.com/umee-network/umee/pull/2328) Add UX and `uux` denom aliases for UMEE.
- [2388](https://github.com/umee-network/umee/pull/2388) Adjust interest rate algorithm and associated token parameter validation rules.

### Bug Fixes
Expand Down
23 changes: 1 addition & 22 deletions app/modules.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,28 +33,7 @@ type BankModule struct {

// DefaultGenesis returns custom Umee x/bank module genesis state.
func (BankModule) DefaultGenesis(cdc codec.JSONCodec) json.RawMessage {
umeeMetadata := banktypes.Metadata{
Description: "The native staking token of the Umee network.",
Base: appparams.BondDenom,
Name: appparams.DisplayDenom,
Display: appparams.DisplayDenom,
Symbol: appparams.DisplayDenom,
DenomUnits: []*banktypes.DenomUnit{
{
Denom: appparams.BondDenom,
Exponent: 0,
Aliases: []string{
"microumee",
},
},
{
Denom: appparams.DisplayDenom,
Exponent: 6,
Aliases: []string{},
},
},
}

umeeMetadata := appparams.UmeeTokenMetadata()
genState := banktypes.DefaultGenesisState()
genState.DenomMetadata = append(genState.DenomMetadata, umeeMetadata)

Expand Down
38 changes: 36 additions & 2 deletions app/params/app_settings.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,22 @@
"log"

sdk "github.com/cosmos/cosmos-sdk/types"
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
)

const (
// Name defines the application name of the Umee network.
Name = "umee"

// BondDenom defines the native staking token denomination.
BondDenom = "uumee"
// NOTE: it is used by IBC, and must not change to avoid token migration in all IBC chains.
BondDenom = "uumee"
BaseExtraDenom = "uux"

// DisplayDenom defines the name, symbol, and display value of the umee token.
DisplayDenom = "UMEE"
DisplayDenom = "UX"
// Old display name. We renamed UMEE to UX.
LegacyDisplayDenom = "UMEE"

// DefaultGasLimit - set to the same value as cosmos-sdk flags.DefaultGasLimit
// this value is currently only used in tests.
Expand All @@ -36,4 +41,33 @@
if AccountAddressPrefix != Name {
log.Fatal("AccountAddresPrefix must equal Name")
}

sdk.SetCoinDenomRegex(func() string {
// allow "ux" token. Modify the default regexp to allow 2 character long denoms.
return `[a-zA-Z][a-zA-Z0-9/:._-]{1,127}`
})
}

// UmeeTokenMetadata creates bank Metadata for the UX token
func UmeeTokenMetadata() banktypes.Metadata {
return banktypes.Metadata{
Description: "The native staking token of the Umee network.",
Base: BondDenom, // NOTE: must not change
Name: DisplayDenom,
Display: DisplayDenom,
Symbol: LegacyDisplayDenom,
DenomUnits: []*banktypes.DenomUnit{

Check warning on line 59 in app/params/app_settings.go

View check run for this annotation

Codecov / codecov/patch

app/params/app_settings.go#L52-L59

Added lines #L52 - L59 were not covered by tests
{
Denom: BondDenom,
Exponent: 0,
Aliases: []string{
"microumee", BaseExtraDenom,
},
}, {
Denom: DisplayDenom,
Exponent: 6,
Aliases: []string{LegacyDisplayDenom},
},
},

Check warning on line 71 in app/params/app_settings.go

View check run for this annotation

Codecov / codecov/patch

app/params/app_settings.go#L61-L71

Added lines #L61 - L71 were not covered by tests
}
}
17 changes: 17 additions & 0 deletions app/params/app_settings_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package params

import (
"testing"

sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/stretchr/testify/assert"
)

func TestDenoms(t *testing.T) {
assert := assert.New(t)

assert.NoError(sdk.ValidateDenom(BondDenom))
assert.NoError(sdk.ValidateDenom(BaseExtraDenom))
assert.NoError(sdk.ValidateDenom(DisplayDenom))
assert.NoError(sdk.ValidateDenom(LegacyDisplayDenom))
robert-zaremba marked this conversation as resolved.
Show resolved Hide resolved
}
1 change: 1 addition & 0 deletions app/params/prefix.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
)

// AccountAddressPrefix defines the Umee network's Bech32 address prefix.
// NOTE: this must not be changed.
const AccountAddressPrefix = "umee"

// Account specific Bech32 prefixes.
Expand Down
7 changes: 4 additions & 3 deletions app/test_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -249,8 +249,9 @@ func IntegrationTestNetworkConfig() network.Config {
if err := cdc.UnmarshalJSON(appGenState[leveragetypes.ModuleName], &leverageGenState); err != nil {
panic(err)
}
um := params.UmeeTokenMetadata()
leverageGenState.Registry = []leveragetypes.Token{
fixtures.Token(params.BondDenom, params.DisplayDenom, 6),
fixtures.Token(um.Base, um.Symbol, 6),
}

bz, err := cdc.MarshalJSON(&leverageGenState)
Expand All @@ -269,12 +270,12 @@ func IntegrationTestNetworkConfig() network.Config {
// are not running a price-feeder.
oracleGenState.Params.VotePeriod = 1000
oracleGenState.ExchangeRates = append(oracleGenState.ExchangeRates, oracletypes.NewDenomExchangeRate(
params.DisplayDenom, sdk.MustNewDecFromStr("34.21"), time.Now()))
params.LegacyDisplayDenom, sdk.MustNewDecFromStr("34.21"), time.Now()))
// Set mock historic medians to satisfy leverage module's 24 median requirement
for i := 1; i <= 24; i++ {
median := oracletypes.Price{
ExchangeRateTuple: oracletypes.NewExchangeRateTuple(
params.DisplayDenom,
params.LegacyDisplayDenom,
sdk.MustNewDecFromStr("34.21"),
),
BlockNum: uint64(i),
Expand Down
14 changes: 10 additions & 4 deletions app/upgrades.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import (
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types"

appparams "github.com/umee-network/umee/v6/app/params"
"github.com/umee-network/umee/v6/util"
leveragetypes "github.com/umee-network/umee/v6/x/leverage/types"
)
Expand Down Expand Up @@ -47,15 +48,20 @@ func (app UmeeApp) RegisterUpgradeHandlers() {
app.registerOutdatedPlaceholderUpgrade("v6.1")
app.registerOutdatedPlaceholderUpgrade("v6.2")
app.registerUpgrade("v6.3", upgradeInfo)

robert-zaremba marked this conversation as resolved.
Show resolved Hide resolved
app.registerUpgrade6_4(upgradeInfo)
}

func (app *UmeeApp) registerUpgrade6_4(_ upgradetypes.Plan) {
planName := "v6.4"

app.UpgradeKeeper.SetUpgradeHandler(planName,
func(ctx sdk.Context, plan upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) {
func(ctx sdk.Context, _ upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) {
printPlanName(planName, ctx.Logger())
// Add UX denom aliases to metadata
app.BankKeeper.SetDenomMetaData(ctx, appparams.UmeeTokenMetadata())

// migrate leverage token settings
tokens := app.LeverageKeeper.GetAllRegisteredTokens(ctx)
for _, token := range tokens {
// this will allow existing interest rate curves to pass new Token validation
Expand All @@ -79,7 +85,7 @@ func (app *UmeeApp) registerUpgrade6_0(upgradeInfo upgradetypes.Plan) {
util.Panic(err)

app.UpgradeKeeper.SetUpgradeHandler(planName,
func(ctx sdk.Context, plan upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) {
func(ctx sdk.Context, _ upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) {
printPlanName(planName, ctx.Logger())
if err := app.LeverageKeeper.SetParams(ctx, leveragetypes.DefaultParams()); err != nil {
return fromVM, err
Expand All @@ -100,7 +106,7 @@ func (app *UmeeApp) registerUpgrade4_3(upgradeInfo upgradetypes.Plan) {
const planName = "v4.3"
app.UpgradeKeeper.SetUpgradeHandler(planName, onlyModuleMigrations(app, planName))
app.UpgradeKeeper.SetUpgradeHandler(planName,
func(ctx sdk.Context, plan upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) {
func(ctx sdk.Context, _ upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) {
ctx.Logger().Info("Upgrade handler execution", "name", planName)

// set the ICS27 consensus version so InitGenesis is not run
Expand Down Expand Up @@ -145,7 +151,7 @@ func (app *UmeeApp) registerUpgrade4_3(upgradeInfo upgradetypes.Plan) {
}

func onlyModuleMigrations(app *UmeeApp, planName string) upgradetypes.UpgradeHandler {
return func(ctx sdk.Context, plan upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) {
return func(ctx sdk.Context, _ upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) {
printPlanName(planName, ctx.Logger())
ctx.Logger().Info("-----------------------------\n-----------------------------")
ctx.Logger().Info("Upgrade handler execution", "name", planName)
Expand Down
2 changes: 1 addition & 1 deletion app/wasm/query/whitelist.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ func setWhitelistedQuery(queryPath string, protoType codec.ProtoMarshaler) {

func GetStargateWhitelistedPaths() (keys []string) {
// Iterate over the map and collect the keys
stargateWhitelist.Range(func(key, value interface{}) bool {
stargateWhitelist.Range(func(key, _ interface{}) bool {
keyStr, ok := key.(string)
if !ok {
panic("key is not a string")
Expand Down
3 changes: 2 additions & 1 deletion tests/cli/suite.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@ func (s *E2ESuite) RunQuery(tq TestQuery) {

err = clientCtx.Codec.UnmarshalJSON(out.Bytes(), tq.Response)
assert.NilError(s.T, err, tq.Name)
assert.Equal(s.T, tq.ExpectedResponse.String(), tq.Response.String(), tq.Name)
s.T.Log("query test name: ", tq.Name)
assert.DeepEqual(s.T, tq.ExpectedResponse, tq.Response)
}
}

Expand Down
3 changes: 2 additions & 1 deletion tests/e2e/setup/setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -214,8 +214,9 @@ func (s *E2ETestSuite) initGenesis() {
var leverageGenState leveragetypes.GenesisState
s.Require().NoError(s.cdc.UnmarshalJSON(appGenState[leveragetypes.ModuleName], &leverageGenState))

tm := appparams.UmeeTokenMetadata()
leverageGenState.Registry = append(leverageGenState.Registry,
fixtures.Token(appparams.BondDenom, appparams.DisplayDenom, 6),
fixtures.Token(tm.Base, tm.Symbol, 6),
fixtures.Token(ATOMBaseDenom, ATOM, uint32(ATOMExponent)),
)

Expand Down
8 changes: 4 additions & 4 deletions x/leverage/client/tests/tests.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ func (s *IntegrationTests) TestLeverageScenario() {
Response: &types.QueryRegisteredTokensResponse{},
ExpectedResponse: &types.QueryRegisteredTokensResponse{
Registry: []types.Token{
fixtures.Token(appparams.BondDenom, appparams.DisplayDenom, 6),
fixtures.Token(appparams.BondDenom, appparams.LegacyDisplayDenom, 6),
},
},
ErrMsg: "",
Expand All @@ -113,7 +113,7 @@ func (s *IntegrationTests) TestLeverageScenario() {
Response: &types.QueryRegisteredTokensResponse{},
ExpectedResponse: &types.QueryRegisteredTokensResponse{
Registry: []types.Token{
fixtures.Token(appparams.BondDenom, appparams.DisplayDenom, 6),
fixtures.Token(appparams.BondDenom, appparams.LegacyDisplayDenom, 6),
},
},
ErrMsg: "",
Expand All @@ -126,12 +126,12 @@ func (s *IntegrationTests) TestLeverageScenario() {
},
Response: &types.QueryMarketSummaryResponse{},
ExpectedResponse: &types.QueryMarketSummaryResponse{
SymbolDenom: "UMEE",
SymbolDenom: appparams.LegacyDisplayDenom,
Exponent: 6,
OraclePrice: &oracleSymbolPrice,
OracleHistoricPrice: &oracleSymbolPrice,
UTokenExchangeRate: sdk.OneDec(),
// Borrow rate * (1.52 - ReserveFactor - OracleRewardFactor)
// Borrow rate * (1 - ReserveFactor - OracleRewardFactor)
// 1.52 * (1 - 0.2 - 0.01) = 1.2008
Supply_APY: sdk.MustNewDecFromStr("1.2008"),
// This is an edge case technically - when effective supply, meaning
Expand Down
14 changes: 7 additions & 7 deletions x/leverage/simulation/operations.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ func WeightedOperations(
func SimulateMsgSupply(ak simulation.AccountKeeper, bk bankkeeper.Keeper) simtypes.Operation {
return func(
r *rand.Rand, app *baseapp.BaseApp, ctx sdk.Context,
accs []simtypes.Account, chainID string,
accs []simtypes.Account, _ string,
) (simtypes.OperationMsg, []simtypes.FutureOperation, error) {
from, c, skip := randomSupplyFields(r, ctx, accs, bk)
if skip {
Expand All @@ -141,7 +141,7 @@ func SimulateMsgSupply(ak simulation.AccountKeeper, bk bankkeeper.Keeper) simtyp
func SimulateMsgWithdraw(ak simulation.AccountKeeper, bk bankkeeper.Keeper, lk keeper.Keeper) simtypes.Operation {
return func(
r *rand.Rand, app *baseapp.BaseApp, ctx sdk.Context,
accs []simtypes.Account, chainID string,
accs []simtypes.Account, _ string,
) (simtypes.OperationMsg, []simtypes.FutureOperation, error) {
from, withdrawUToken, skip := randomWithdrawFields(r, ctx, accs, bk, lk)
if skip {
Expand All @@ -159,7 +159,7 @@ func SimulateMsgWithdraw(ak simulation.AccountKeeper, bk bankkeeper.Keeper, lk k
func SimulateMsgBorrow(ak simulation.AccountKeeper, bk bankkeeper.Keeper, lk keeper.Keeper) simtypes.Operation {
return func(
r *rand.Rand, app *baseapp.BaseApp, ctx sdk.Context,
accs []simtypes.Account, chainID string,
accs []simtypes.Account, _ string,
) (simtypes.OperationMsg, []simtypes.FutureOperation, error) {
from, token, skip := randomBorrowFields(r, ctx, accs, lk)
if skip {
Expand All @@ -180,7 +180,7 @@ func SimulateMsgCollateralize(
) simtypes.Operation {
return func(
r *rand.Rand, app *baseapp.BaseApp, ctx sdk.Context,
accs []simtypes.Account, chainID string,
accs []simtypes.Account, _ string,
) (simtypes.OperationMsg, []simtypes.FutureOperation, error) {
from, collateral, skip := randomCollateralizeFields(r, ctx, accs, bk)
if skip {
Expand All @@ -202,7 +202,7 @@ func SimulateMsgDecollateralize(
) simtypes.Operation {
return func(
r *rand.Rand, app *baseapp.BaseApp, ctx sdk.Context,
accs []simtypes.Account, chainID string,
accs []simtypes.Account, _ string,
) (simtypes.OperationMsg, []simtypes.FutureOperation, error) {
from, collateral, skip := randomDecollateralizeFields(r, ctx, accs, lk)
if skip {
Expand All @@ -220,7 +220,7 @@ func SimulateMsgDecollateralize(
func SimulateMsgRepay(ak simulation.AccountKeeper, bk bankkeeper.Keeper, lk keeper.Keeper) simtypes.Operation {
return func(
r *rand.Rand, app *baseapp.BaseApp, ctx sdk.Context,
accs []simtypes.Account, chainID string,
accs []simtypes.Account, _ string,
) (simtypes.OperationMsg, []simtypes.FutureOperation, error) {
from, repayToken, skip := randomRepayFields(r, ctx, accs, lk)
if skip {
Expand All @@ -238,7 +238,7 @@ func SimulateMsgRepay(ak simulation.AccountKeeper, bk bankkeeper.Keeper, lk keep
func SimulateMsgLiquidate(ak simulation.AccountKeeper, bk bankkeeper.Keeper, lk keeper.Keeper) simtypes.Operation {
return func(
r *rand.Rand, app *baseapp.BaseApp, ctx sdk.Context,
accs []simtypes.Account, chainID string,
accs []simtypes.Account, _ string,
) (simtypes.OperationMsg, []simtypes.FutureOperation, error) {
liquidator, borrower, repaymentToken, rewardDenom, skip := randomLiquidateFields(r, ctx, accs, lk)
if skip {
Expand Down
5 changes: 3 additions & 2 deletions x/leverage/types/token.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,9 +159,10 @@ func (t Token) BorrowFactor() sdk.Dec {
}

func defaultUmeeToken() Token {
tm := appparams.UmeeTokenMetadata()
return Token{
BaseDenom: appparams.BondDenom,
SymbolDenom: "UMEE",
BaseDenom: tm.Base,
SymbolDenom: tm.Symbol, // SymbolDenom should not change
Exponent: 6,
EnableMsgSupply: true,
EnableMsgBorrow: true,
Expand Down
2 changes: 1 addition & 1 deletion x/oracle/abci_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import (
)

const (
displayDenom string = appparams.DisplayDenom
displayDenom string = appparams.LegacyDisplayDenom
bondDenom string = appparams.BondDenom
)

Expand Down
2 changes: 1 addition & 1 deletion x/oracle/client/tests/suite.go
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ func (s *IntegrationTestSuite) TestQueryExchangeRates() {
s.Require().NoError(clientCtx.Codec.UnmarshalJSON(out.Bytes(), &res))

s.Require().Len(res.ExchangeRates, 1)
s.Require().Equal(res.ExchangeRates[0].Denom, appparams.DisplayDenom)
s.Require().Equal(res.ExchangeRates[0].Denom, appparams.LegacyDisplayDenom)
s.Require().False(res.ExchangeRates[0].Amount.IsZero())
}

Expand Down
2 changes: 1 addition & 1 deletion x/oracle/keeper/grpc_query_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ func (s *IntegrationTestSuite) TestQuerier_AggregatePrevotes() {
func (s *IntegrationTestSuite) TestQuerier_AggregateVote() {
var tuples types.ExchangeRateTuples
tuples = append(tuples, types.ExchangeRateTuple{
Denom: appparams.DisplayDenom,
Denom: appparams.LegacyDisplayDenom,
ExchangeRate: sdk.ZeroDec(),
})

Expand Down
2 changes: 1 addition & 1 deletion x/oracle/keeper/hooks_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ func (s *IntegrationTestSuite) TestHooks_AfterTokenRegistered() {
// require that an existing token does not change the accept list
h.AfterTokenRegistered(s.ctx, leveragetypes.Token{
BaseDenom: appparams.BondDenom,
SymbolDenom: appparams.DisplayDenom,
SymbolDenom: appparams.LegacyDisplayDenom,
Exponent: 6,
})
s.Require().Len(s.app.OracleKeeper.AcceptList(s.ctx), 1)
Expand Down
Loading
Loading