Skip to content

Commit

Permalink
feat: move meToken out of experimental (#2269)
Browse files Browse the repository at this point in the history
* move meToken out of experimental

* pr comments

* lint and test

* t

* typo
  • Loading branch information
kosegor authored Oct 2, 2023
1 parent 08de8d2 commit ce876d2
Show file tree
Hide file tree
Showing 8 changed files with 39 additions and 61 deletions.
54 changes: 21 additions & 33 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -198,10 +198,9 @@ func init() {
ugovmodule.AppModuleBasic{},
wasm.AppModuleBasic{},
incentivemodule.AppModuleBasic{},
metokenmodule.AppModuleBasic{},
}
if Experimental {
moduleBasics = append(moduleBasics, metokenmodule.AppModuleBasic{})
}
// if Experimental {}

ModuleBasics = module.NewBasicManager(moduleBasics...)

Expand All @@ -224,13 +223,9 @@ func init() {
oracletypes.ModuleName: nil,
uibc.ModuleName: nil,
ugov.ModuleName: nil,
metoken.ModuleName: {authtypes.Minter, authtypes.Burner},
}

if Experimental {
maccPerms[metoken.ModuleName] = []string{
authtypes.Minter, authtypes.Burner,
}
}
// if Experimental {}
}

// UmeeApp defines the ABCI application for the Umee network as an extension of
Expand Down Expand Up @@ -343,10 +338,9 @@ func New(
bech32ibctypes.StoreKey, uibc.StoreKey, ugov.StoreKey,
wasm.StoreKey,
incentive.StoreKey,
metoken.StoreKey,
}
if Experimental {
storeKeys = append(storeKeys, metoken.StoreKey)
}
// if Experimental {}

keys := sdk.NewKVStoreKeys(storeKeys...)
tkeys := sdk.NewTransientStoreKeys(paramstypes.TStoreKey)
Expand Down Expand Up @@ -499,16 +493,14 @@ func New(
)
app.LeverageKeeper.SetBondHooks(app.IncentiveKeeper.BondHooks())

if Experimental {
app.MetokenKeeperB = metokenkeeper.NewKeeperBuilder(
appCodec,
keys[metoken.StoreKey],
app.BankKeeper,
app.LeverageKeeper,
app.OracleKeeper,
app.UGovKeeperB.EmergencyGroup,
)
}
app.MetokenKeeperB = metokenkeeper.NewKeeperBuilder(
appCodec,
keys[metoken.StoreKey],
app.BankKeeper,
app.LeverageKeeper,
app.OracleKeeper,
app.UGovKeeperB.EmergencyGroup,
)

// register the staking hooks
// NOTE: stakingKeeper above is passed by reference, so that it will contain these hooks
Expand Down Expand Up @@ -738,11 +730,9 @@ func New(
ugovmodule.NewAppModule(appCodec, app.UGovKeeperB),
wasm.NewAppModule(app.appCodec, &app.WasmKeeper, app.StakingKeeper, app.AccountKeeper, app.BankKeeper),
incentivemodule.NewAppModule(appCodec, app.IncentiveKeeper, app.BankKeeper, app.LeverageKeeper),
metokenmodule.NewAppModule(appCodec, app.MetokenKeeperB),
}
if Experimental {
appModules = append(appModules, metokenmodule.NewAppModule(appCodec, app.MetokenKeeperB))

}
// if Experimental {}

app.mm = module.NewManager(appModules...)

Expand Down Expand Up @@ -780,6 +770,7 @@ func New(
ugov.ModuleName,
wasm.ModuleName,
incentive.ModuleName,
metoken.ModuleName,
}
endBlockers := []string{
crisistypes.ModuleName,
Expand All @@ -798,6 +789,7 @@ func New(
ugov.ModuleName,
wasm.ModuleName,
incentive.ModuleName,
metoken.ModuleName,
}

// NOTE: The genutils module must occur after staking so that pools are
Expand All @@ -822,6 +814,7 @@ func New(
ugov.ModuleName,
wasm.ModuleName,
incentive.ModuleName,
metoken.ModuleName,
}
orderMigrations := []string{
capabilitytypes.ModuleName, authtypes.ModuleName, banktypes.ModuleName, distrtypes.ModuleName,
Expand All @@ -838,14 +831,9 @@ func New(
ugov.ModuleName,
wasm.ModuleName,
incentive.ModuleName,
metoken.ModuleName,
}

if Experimental {
beginBlockers = append(beginBlockers, metoken.ModuleName)
endBlockers = append(endBlockers, metoken.ModuleName)
initGenesis = append(initGenesis, metoken.ModuleName)
orderMigrations = append(orderMigrations, metoken.ModuleName)
}
// if Experimental {}

app.mm.SetOrderBeginBlockers(beginBlockers...)
app.mm.SetOrderEndBlockers(endBlockers...)
Expand Down
6 changes: 1 addition & 5 deletions app/wasm/test/cosmwasm_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ package wasm_test

import (
"testing"

"github.com/umee-network/umee/v6/app"
)

func TestCosmwasm(t *testing.T) {
Expand All @@ -24,9 +22,7 @@ func TestCosmwasm(t *testing.T) {
its.TestOracleQueries()
its.TestLeverageTxs()
its.TestIncentiveQueries()
if app.Experimental {
its.TestMetokenQueries()
}
its.TestMetokenQueries()

// stargate queries
its.TestStargateQueries()
Expand Down
5 changes: 0 additions & 5 deletions tests/e2e/e2e_metoken_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
sdk "github.com/cosmos/cosmos-sdk/types"
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"

"github.com/umee-network/umee/v6/app"
"github.com/umee-network/umee/v6/tests/grpc"
ltypes "github.com/umee-network/umee/v6/x/leverage/types"
"github.com/umee-network/umee/v6/x/metoken"
Expand All @@ -21,10 +20,6 @@ func (s *E2ETest) TestMetokenSwapAndRedeem() {
s.Require().NoError(err)
expectedBalance := mocks.EmptyUSDIndexBalances(mocks.MeUSDDenom)

if app.Experimental {
s.T().Skip("Skipping tests for experimental module x/metoken")
}

s.Run(
"create_stable_index", func() {
tokens := []ltypes.Token{
Expand Down
3 changes: 0 additions & 3 deletions x/metoken/keeper/intest/grpc_query_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
//go:build experimental
// +build experimental

package intest

import (
Expand Down
3 changes: 0 additions & 3 deletions x/metoken/keeper/intest/interest_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
//go:build experimental
// +build experimental

package intest

import (
Expand Down
4 changes: 1 addition & 3 deletions x/metoken/keeper/intest/keeper_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
//go:build experimental
// +build experimental

package intest

import (
Expand Down Expand Up @@ -62,6 +59,7 @@ func initTestSuite(t *testing.T, registry []metoken.Index, balances []metoken.In
app.BankKeeper,
app.LeverageKeeper,
oracleMock,
app.UGovKeeperB.EmergencyGroup,
)
app.MetokenKeeperB = kb

Expand Down
22 changes: 16 additions & 6 deletions x/metoken/keeper/intest/msg_server_test.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
//go:build experimental
// +build experimental

package intest

import (
"fmt"
"testing"

"github.com/golang/mock/gomock"
Expand Down Expand Up @@ -250,6 +248,9 @@ func TestMsgServer_Swap_NonStableAssets_DiffExponents(t *testing.T) {
require.NoError(err)

// verify the outputs of swap function
if tc.name == "valid - swap 1.435125562353141231 ETH" {
fmt.Printf("\n")
}
resp, err := msgServer.Swap(ctx, msg)
require.NoError(err, tc.name)

Expand Down Expand Up @@ -612,6 +613,7 @@ func TestMsgServer_Swap_Depegging(t *testing.T) {
app.BankKeeper,
app.LeverageKeeper,
oracleMock,
app.UGovKeeperB.EmergencyGroup,
)
app.MetokenKeeperB = kb
msgServer = keeper.NewMsgServerImpl(app.MetokenKeeperB)
Expand Down Expand Up @@ -708,6 +710,7 @@ func TestMsgServer_Swap_Depegging(t *testing.T) {
app.BankKeeper,
app.LeverageKeeper,
oracleMock,
app.UGovKeeperB.EmergencyGroup,
)
app.MetokenKeeperB = kb
msgServer = keeper.NewMsgServerImpl(app.MetokenKeeperB)
Expand Down Expand Up @@ -898,11 +901,12 @@ func verifySwap(

assetExponentFactorVsMeToken, err := metoken.ExponentFactor(assetPrice.Exponent, prices.Exponent)
assert.NilError(t, err)
rate := exchangeRate.Mul(assetExponentFactorVsMeToken)

// expected_metokens = amount_to_swap * exchange_rate * exponent_factor
expectedMeTokens := sdk.NewCoin(
meTokenDenom,
exchangeRate.MulInt(amountToSwap).Mul(assetExponentFactorVsMeToken).TruncateInt(),
rate.MulInt(amountToSwap).TruncateInt(),
)

// calculating reserved and leveraged
Expand Down Expand Up @@ -1350,6 +1354,7 @@ func TestMsgServer_Redeem_Depegging(t *testing.T) {
app.BankKeeper,
app.LeverageKeeper,
oracleMock,
app.UGovKeeperB.EmergencyGroup,
)
app.MetokenKeeperB = kb
msgServer = keeper.NewMsgServerImpl(app.MetokenKeeperB)
Expand Down Expand Up @@ -1446,6 +1451,7 @@ func TestMsgServer_Redeem_Depegging(t *testing.T) {
app.BankKeeper,
app.LeverageKeeper,
oracleMock,
app.UGovKeeperB.EmergencyGroup,
)
app.MetokenKeeperB = kb
msgServer = keeper.NewMsgServerImpl(app.MetokenKeeperB)
Expand Down Expand Up @@ -1861,8 +1867,12 @@ func TestMsgServer_GovUpdateRegistry(t *testing.T) {
}{
{
"invalid authority",
metoken.NewMsgGovUpdateRegistry("invalid_authority", nil, nil),
"invalid_authority",
metoken.NewMsgGovUpdateRegistry(
"umee156hsyuvssklaekm57qy0pcehlfhzpclclaadwq",
nil,
[]metoken.Index{existingIndex},
),
"unauthorized",
},
{
"invalid - empty add and update indexes",
Expand Down
3 changes: 0 additions & 3 deletions x/metoken/keeper/intest/reserves_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
//go:build experimental
// +build experimental

package intest

import (
Expand Down

0 comments on commit ce876d2

Please sign in to comment.