Skip to content

Commit

Permalink
Merge branch 'main' into adam/special4
Browse files Browse the repository at this point in the history
  • Loading branch information
toteki authored Aug 5, 2023
2 parents fdc42bd + 58ca854 commit e22a1ba
Show file tree
Hide file tree
Showing 81 changed files with 1,212 additions and 2,293 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ Ref: https://keepachangelog.com/en/1.0.0/
- `/umee/ugov/v1/min-gas-price` --> `/umee/ugov/v1/min_gas_price`
- `/umee/ugov/v1/emergency-group` --> `/umee/ugov/v1/emergency_group`
- `/umee/uibc/v1/all-outflows` --> `/umee/uibc/v1/all_outflows`
- [2180](https://github.com/umee-network/umee/pull/2180) Rename leverage `Keeper.ExchangeToken -> ToUToken`, `Keeper.ExchangeUToken -> ToToken` and `Keeper.ExchangeUTokens -> ToTokens`.
- [2183](https://github.com/umee-network/umee/pull/2183) Move `ToUTokenDenom`, `StripUTokenDenom` and `HasUTokenPrefix` from `leverage/keeper` to `coin` package.

## [v5.1.0](https://github.com/umee-network/umee/releases/tag/v5.1.0) - 2023-07-07

Expand Down
5 changes: 3 additions & 2 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -644,7 +644,8 @@ func New(
availableCapabilities := "iterator,staking,stargate,cosmwasm_1_1,cosmwasm_1_2,umee"

// Register umee custom plugin to wasm
wasmOpts = append(uwasm.RegisterCustomPlugins(app.LeverageKeeper, app.OracleKeeper, app.IncentiveKeeper), wasmOpts...)
wasmOpts = append(uwasm.RegisterCustomPlugins(app.LeverageKeeper, app.OracleKeeper, app.IncentiveKeeper,
app.MetokenKeeperB), wasmOpts...)
// Register stargate queries
wasmOpts = append(wasmOpts, uwasm.RegisterStargateQueries(*bApp.GRPCQueryRouter(), appCodec)...)

Expand Down Expand Up @@ -674,7 +675,7 @@ func New(
skipGenesisInvariants := cast.ToBool(appOpts.Get(crisis.FlagSkipGenesisInvariants))

inflationClaculator := inflation.Calculator{
UgovKeeperB: app.UGovKeeperB,
UgovKeeperB: app.UGovKeeperB.Params,
MintKeeper: &app.MintKeeper,
}

Expand Down
10 changes: 0 additions & 10 deletions app/inflation/expected_keepers.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,9 @@ import (
"cosmossdk.io/math"
sdk "github.com/cosmos/cosmos-sdk/types"
minttypes "github.com/cosmos/cosmos-sdk/x/mint/types"

ugovkeeper "github.com/umee-network/umee/v5/x/ugov/keeper"
)

type MintKeeper interface {
StakingTokenSupply(ctx sdk.Context) math.Int
SetParams(ctx sdk.Context, params minttypes.Params)
}

type UGovKeeper interface {
ugovkeeper.IKeeper
}

type UGovBKeeperI interface {
ugovkeeper.BKeeperI
}
7 changes: 4 additions & 3 deletions app/inflation/inflation.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,18 @@ import (

"github.com/umee-network/umee/v5/util"
"github.com/umee-network/umee/v5/util/bpmath"
"github.com/umee-network/umee/v5/x/ugov"
)

type Calculator struct {
UgovKeeperB UGovBKeeperI
UgovKeeperB ugov.ParamsKeeperBuilder
MintKeeper MintKeeper
}

func (c Calculator) InflationRate(ctx sdk.Context, minter minttypes.Minter, mintParams minttypes.Params,
bondedRatio sdk.Dec) sdk.Dec {

ugovKeeper := c.UgovKeeperB.Keeper(&ctx)
ugovKeeper := c.UgovKeeperB(&ctx)
inflationParams := ugovKeeper.InflationParams()
maxSupplyAmount := inflationParams.MaxSupply.Amount

Expand All @@ -27,7 +28,7 @@ func (c Calculator) InflationRate(ctx sdk.Context, minter minttypes.Minter, mint
return sdk.ZeroDec()
}

cycleEnd := ugovKeeper.GetInflationCycleEnd()
cycleEnd := ugovKeeper.InflationCycleEnd()
if ctx.BlockTime().After(cycleEnd) {
// new inflation cycle is starting, so we need to update the inflation max and min rate
factor := bpmath.One - inflationParams.InflationReductionRate
Expand Down
30 changes: 13 additions & 17 deletions app/inflation/inflation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,16 @@ import (
sdk "github.com/cosmos/cosmos-sdk/types"
minttypes "github.com/cosmos/cosmos-sdk/x/mint/types"
"github.com/golang/mock/gomock"
"gotest.tools/v3/assert"

"github.com/umee-network/umee/v5/app/inflation"
mocks "github.com/umee-network/umee/v5/app/inflation/mocks"
appparams "github.com/umee-network/umee/v5/app/params"
"github.com/umee-network/umee/v5/tests/tsdk"
"github.com/umee-network/umee/v5/util/bpmath"
"github.com/umee-network/umee/v5/util/coin"
"github.com/umee-network/umee/v5/x/ugov"
"gotest.tools/v3/assert"
ugovmocks "github.com/umee-network/umee/v5/x/ugov/mocks"
)

func TestAdjustInflation(t *testing.T) {
Expand Down Expand Up @@ -203,31 +205,25 @@ func TestInflationRate(t *testing.T) {
}
for _, test := range tests {
t.Run(test.name, func(t *testing.T) {

ctrl := gomock.NewController(t)
// Create the mock MintKeeper and UgovKeeper
mockMintKeeper := mocks.NewMockMintKeeper(ctrl)
mockUGovBuilder := mocks.NewMockUGovBKeeperI(ctrl)
mockUGovKeeper := mocks.NewMockUGovKeeper(ctrl)

calc := inflation.Calculator{
MintKeeper: mockMintKeeper,
UgovKeeperB: mockUGovBuilder,
}
mockUGovKeeper := ugovmocks.NewMockParamsKeeper(ctrl)

// mockUGovBuilder returns the mockUGovKeeper
mockUGovBuilder.EXPECT().Keeper(gomock.Any()).Return(mockUGovKeeper)

// Set up the mock behavior for MintKeeper and UgovKeeper
mockUGovKeeper.EXPECT().InflationParams().Return(test.inflationParams(mockInflationParams))
mockMintKeeper.EXPECT().StakingTokenSupply(gomock.Any()).Return(test.totalSupply)
mockMintKeeper.EXPECT().SetParams(gomock.Any(), gomock.Any()).AnyTimes()
mockUGovKeeper.EXPECT().GetInflationCycleEnd().Return(test.cycleEndTime()).AnyTimes()

mockUGovKeeper.EXPECT().InflationParams().Return(test.inflationParams(mockInflationParams))
mockUGovKeeper.EXPECT().InflationCycleEnd().Return(test.cycleEndTime()).AnyTimes()
mockUGovKeeper.EXPECT().SetInflationCycleEnd(gomock.Any()).Return(nil).AnyTimes()

calc := inflation.Calculator{
MintKeeper: mockMintKeeper,
UgovKeeperB: ugovmocks.NewUgovParamsBuilder(mockUGovKeeper),
}
result := calc.InflationRate(test.ctx(), test.minter, test.mintParams(mintParams), test.bondedRatio)

assert.DeepEqual(t, test.expectedResult(test.minter.Inflation, test.bondedRatio, test.mintParams(mintParams)), result)
assert.DeepEqual(t,
test.expectedResult(test.minter.Inflation, test.bondedRatio, test.mintParams(mintParams)), result)
ctrl.Finish()
})
}
Expand Down
201 changes: 0 additions & 201 deletions app/inflation/mocks/keepers.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion app/wasm/custom_plugins.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"github.com/umee-network/umee/v5/app/wasm/query"
inckeeper "github.com/umee-network/umee/v5/x/incentive/keeper"
leveragekeeper "github.com/umee-network/umee/v5/x/leverage/keeper"
metokenkeeper "github.com/umee-network/umee/v5/x/metoken/keeper"
oraclekeeper "github.com/umee-network/umee/v5/x/oracle/keeper"
)

Expand All @@ -18,8 +19,9 @@ func RegisterCustomPlugins(
leverageKeeper leveragekeeper.Keeper,
oracleKeeper oraclekeeper.Keeper,
incentiveKeeper inckeeper.Keeper,
metokenBuilder metokenkeeper.Builder,
) []wasmkeeper.Option {
wasmQueryPlugin := query.NewQueryPlugin(leverageKeeper, oracleKeeper, incentiveKeeper)
wasmQueryPlugin := query.NewQueryPlugin(leverageKeeper, oracleKeeper, incentiveKeeper, metokenBuilder)
queryPluginOpt := wasmkeeper.WithQueryPlugins(&wasmkeeper.QueryPlugins{
Custom: wasmQueryPlugin.CustomQuerier(),
})
Expand Down
Loading

0 comments on commit e22a1ba

Please sign in to comment.