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

fix(auction) link rewards accounts #2516

Merged
merged 2 commits into from
May 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
20 changes: 11 additions & 9 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -478,14 +478,23 @@ func New(
distrtypes.ModuleName,
)

rewardsAuctionAccs := auctionmodule.SubAccounts()
app.AuctionKeeperB = auctionkeeper.NewBuilder(
appCodec,
keys[auction.StoreKey],
rewardsAuctionAccs,
app.BankKeeper,
app.UGovKeeperB.EmergencyGroup,
)

app.LeverageKeeper = leveragekeeper.NewKeeper(
appCodec,
keys[leveragetypes.ModuleName],
app.BankKeeper,
app.OracleKeeper,
app.UGovKeeperB.EmergencyGroup,
cast.ToBool(appOpts.Get(leveragetypes.FlagEnableLiquidatorQuery)),
authtypes.NewModuleAddress(metoken.ModuleName),
rewardsAuctionAccs.RewardsCollect,
)

app.LeverageKeeper.SetTokenHooks(app.OracleKeeper.Hooks())
Expand All @@ -505,14 +514,7 @@ func New(
app.LeverageKeeper,
app.OracleKeeper,
app.UGovKeeperB.EmergencyGroup,
)

app.AuctionKeeperB = auctionkeeper.NewBuilder(
appCodec,
keys[auction.StoreKey],
auctionmodule.SubAccounts(),
app.BankKeeper,
app.UGovKeeperB.EmergencyGroup,
rewardsAuctionAccs.RewardsCollect,
)

// register the staking hooks
Expand Down
7 changes: 4 additions & 3 deletions x/auction/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ type Builder struct {
storeKey storetypes.StoreKey
bank auction.BankKeeper
ugov ugov.EmergencyGroupBuilder
accs SubAccounts

Accs SubAccounts
}

func NewBuilder(cdc codec.BinaryCodec,
Expand All @@ -28,15 +29,15 @@ func NewBuilder(cdc codec.BinaryCodec,
b auction.BankKeeper,
ugov ugov.EmergencyGroupBuilder) Builder {

return Builder{cdc: cdc, storeKey: key, accs: accs,
return Builder{cdc: cdc, storeKey: key, Accs: accs,
bank: b, ugov: ugov}
}

func (kb Builder) Keeper(ctx *sdk.Context) Keeper {
return Keeper{
store: ctx.KVStore(kb.storeKey),
cdc: kb.cdc,
accs: kb.accs,
accs: kb.Accs,
bank: kb.bank,
ugov: kb.ugov(ctx),

Expand Down
5 changes: 2 additions & 3 deletions x/leverage/keeper/internal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,9 @@ import (
"github.com/cosmos/cosmos-sdk/codec"
storetypes "github.com/cosmos/cosmos-sdk/store/types"
sdk "github.com/cosmos/cosmos-sdk/types"
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"

"github.com/umee-network/umee/v6/tests/accs"
"github.com/umee-network/umee/v6/x/leverage/types"
"github.com/umee-network/umee/v6/x/metoken"
ugovmocks "github.com/umee-network/umee/v6/x/ugov/mocks"
)

Expand All @@ -34,7 +33,7 @@ func NewTestKeeper(
ok,
ugovmocks.NewSimpleEmergencyGroupBuilder(),
enableLiquidatorQuery,
authtypes.NewModuleAddress(metoken.ModuleName),
accs.GenerateAddr("auction.Rewards"),
)
return k, TestKeeper{&k}
}
Expand Down
6 changes: 3 additions & 3 deletions x/leverage/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ type Keeper struct {
oracleKeeper types.OracleKeeper
ugov ugov.EmergencyGroupBuilder
liquidatorQueryEnabled bool
meTokenAddr sdk.AccAddress
rewardsAuction sdk.AccAddress

tokenHooks []types.TokenHooks
bondHooks []types.BondHooks
Expand All @@ -34,7 +34,7 @@ func NewKeeper(
o types.OracleKeeper,
ugov ugov.EmergencyGroupBuilder,
enableLiquidatorQuery bool,
meTokenAddr sdk.AccAddress,
rewardsAuction sdk.AccAddress,
) Keeper {
return Keeper{
cdc: cdc,
Expand All @@ -43,7 +43,7 @@ func NewKeeper(
oracleKeeper: o,
ugov: ugov,
liquidatorQueryEnabled: enableLiquidatorQuery,
meTokenAddr: meTokenAddr,
rewardsAuction: rewardsAuction,
}
}

Expand Down
6 changes: 3 additions & 3 deletions x/metoken/keeper/intest/keeper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,20 +54,20 @@ func initTestSuite(t *testing.T, registry []metoken.Index, balances []metoken.In
AnyTimes()
oracleMock.EXPECT().SetExchangeRate(gomock.Any(), gomock.Any(), gomock.Any()).AnyTimes()

kb := keeper.NewBuilder(
app.MetokenKeeperB = keeper.NewBuilder(
app.AppCodec(),
app.GetKey(metoken.ModuleName),
app.BankKeeper,
app.LeverageKeeper,
oracleMock,
app.UGovKeeperB.EmergencyGroup,
app.AuctionKeeperB.Accs.RewardsCollect,
)
app.MetokenKeeperB = kb

genState := metoken.DefaultGenesisState()
genState.Registry = registry
genState.Balances = balances
kb.Keeper(&ctx).InitGenesis(*genState)
app.MetokenKeeperB.Keeper(&ctx).InitGenesis(*genState)

queryHelper := baseapp.NewQueryServerTestHelper(ctx, app.InterfaceRegistry())
metoken.RegisterQueryServer(queryHelper, keeper.NewQuerier(app.MetokenKeeperB))
Expand Down
4 changes: 4 additions & 0 deletions x/metoken/keeper/intest/msg_server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -616,6 +616,7 @@ func TestMsgServer_Swap_Depegging(t *testing.T) {
app.LeverageKeeper,
oracleMock,
app.UGovKeeperB.EmergencyGroup,
app.AuctionKeeperB.Accs.RewardsCollect,
)
app.MetokenKeeperB = kb
msgServer = keeper.NewMsgServerImpl(app.MetokenKeeperB)
Expand Down Expand Up @@ -714,6 +715,7 @@ func TestMsgServer_Swap_Depegging(t *testing.T) {
app.LeverageKeeper,
oracleMock,
app.UGovKeeperB.EmergencyGroup,
app.AuctionKeeperB.Accs.RewardsCollect,
)
app.MetokenKeeperB = kb
msgServer = keeper.NewMsgServerImpl(app.MetokenKeeperB)
Expand Down Expand Up @@ -1357,6 +1359,7 @@ func TestMsgServer_Redeem_Depegging(t *testing.T) {
app.LeverageKeeper,
oracleMock,
app.UGovKeeperB.EmergencyGroup,
app.AuctionKeeperB.Accs.RewardsCollect,
)
app.MetokenKeeperB = kb
msgServer = keeper.NewMsgServerImpl(app.MetokenKeeperB)
Expand Down Expand Up @@ -1456,6 +1459,7 @@ func TestMsgServer_Redeem_Depegging(t *testing.T) {
app.LeverageKeeper,
oracleMock,
app.UGovKeeperB.EmergencyGroup,
app.AuctionKeeperB.Accs.RewardsCollect,
)
app.MetokenKeeperB = kb
msgServer = keeper.NewMsgServerImpl(app.MetokenKeeperB)
Expand Down
5 changes: 5 additions & 0 deletions x/metoken/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ type Builder struct {
leverageKeeper metoken.LeverageKeeper
oracleKeeper metoken.OracleKeeper
ugov ugov.EmergencyGroupBuilder
rewardsAuction sdk.AccAddress
}

// NewBuilder returns Builder object.
Expand All @@ -28,6 +29,7 @@ func NewBuilder(
leverageKeeper metoken.LeverageKeeper,
oracleKeeper metoken.OracleKeeper,
ugov ugov.EmergencyGroupBuilder,
rewardsAuction sdk.AccAddress,
) Builder {
return Builder{
cdc: cdc,
Expand All @@ -36,6 +38,7 @@ func NewBuilder(
leverageKeeper: leverageKeeper,
oracleKeeper: oracleKeeper,
ugov: ugov,
rewardsAuction: rewardsAuction,
}
}

Expand All @@ -46,6 +49,7 @@ type Keeper struct {
leverageKeeper metoken.LeverageKeeper
oracleKeeper metoken.OracleKeeper
ugov ugov.EmergencyGroupBuilder
rewardsAuction sdk.AccAddress

// TODO: ctx should be removed when we migrate leverageKeeper and oracleKeeper
ctx *sdk.Context
Expand All @@ -60,6 +64,7 @@ func (b Builder) Keeper(ctx *sdk.Context) Keeper {
leverageKeeper: b.leverageKeeper,
oracleKeeper: b.oracleKeeper,
ugov: b.ugov,
rewardsAuction: b.rewardsAuction,
ctx: ctx,
}
}
Expand Down
3 changes: 2 additions & 1 deletion x/metoken/keeper/unit_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
storetypes "github.com/cosmos/cosmos-sdk/store/types"
"github.com/stretchr/testify/require"

"github.com/umee-network/umee/v6/tests/accs"
"github.com/umee-network/umee/v6/tests/tsdk"
"github.com/umee-network/umee/v6/x/metoken"
"github.com/umee-network/umee/v6/x/metoken/mocks"
Expand All @@ -19,7 +20,7 @@ func initSimpleKeeper(t *testing.T) Keeper {
interfaceRegistry := types.NewInterfaceRegistry()
cdc := codec.NewProtoCodec(interfaceRegistry)
storeKey := storetypes.NewMemoryStoreKey("metoken")
kb := NewBuilder(cdc, storeKey, nil, nil, nil, nil)
kb := NewBuilder(cdc, storeKey, nil, nil, nil, nil, accs.GenerateAddr("auction.Rewards"))
ctx, _ := tsdk.NewCtxOneStore(t, storeKey)

k := kb.Keeper(&ctx)
Expand Down
Loading