Skip to content

Commit

Permalink
decouple params into separate file (#2490)
Browse files Browse the repository at this point in the history
  • Loading branch information
gsk967 authored Apr 12, 2024
1 parent 9673980 commit 839fdbf
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 16 deletions.
1 change: 0 additions & 1 deletion app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -1147,7 +1147,6 @@ func initParamsKeeper(
paramsKeeper.Subspace(ibcexported.ModuleName)
paramsKeeper.Subspace(icahosttypes.SubModuleName)
paramsKeeper.Subspace(packetforwardtypes.ModuleName).WithKeyTable(packetforwardtypes.ParamKeyTable())
paramsKeeper.Subspace(leveragetypes.ModuleName)
paramsKeeper.Subspace(oracletypes.ModuleName)
paramsKeeper.Subspace(wasmtypes.ModuleName)

Expand Down
21 changes: 21 additions & 0 deletions x/leverage/keeper/params.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package keeper

import (
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/umee-network/umee/v6/util/store"
"github.com/umee-network/umee/v6/x/leverage/types"
)

// SetParams sets the x/leverage module's parameters.
func (k Keeper) SetParams(ctx sdk.Context, params types.Params) error {
return store.SetValue(ctx.KVStore(k.storeKey), types.KeyParams, &params, "leverage params")
}

// GetParams gets the x/leverage module's parameters.
func (k Keeper) GetParams(ctx sdk.Context) types.Params {
params := store.GetValue[*types.Params](ctx.KVStore(k.storeKey), types.KeyParams, "leverage params")
if params == nil {
panic("params not initialized")
}
return *params
}
15 changes: 0 additions & 15 deletions x/leverage/keeper/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (
sdk "github.com/cosmos/cosmos-sdk/types"

"github.com/umee-network/umee/v6/util"
"github.com/umee-network/umee/v6/util/store"
"github.com/umee-network/umee/v6/x/leverage/types"
)

Expand Down Expand Up @@ -83,20 +82,6 @@ func (k Keeper) setStoredInt(ctx sdk.Context, key []byte, val sdkmath.Int, desc
return nil
}

// SetParams sets the x/leverage module's parameters.
func (k Keeper) SetParams(ctx sdk.Context, params types.Params) error {
return store.SetValue(ctx.KVStore(k.storeKey), types.KeyParams, &params, "leverage params")
}

// GetParams gets the x/leverage module's parameters.
func (k Keeper) GetParams(ctx sdk.Context) types.Params {
params := store.GetValue[*types.Params](ctx.KVStore(k.storeKey), types.KeyParams, "leverage params")
if params == nil {
panic("params not initialized")
}
return *params
}

// getAdjustedBorrow gets the adjusted amount borrowed by an address in a given denom.
// Returned value is non-negative.
func (k Keeper) getAdjustedBorrow(ctx sdk.Context, addr sdk.AccAddress, denom string) sdk.Dec {
Expand Down

0 comments on commit 839fdbf

Please sign in to comment.