Skip to content

Commit

Permalink
feat: auction module (#2470)
Browse files Browse the repository at this point in the history
* feat: reards auction proto

* lint

* update genesis

* fix

* add usd rewards

* update params

* add events

* update genesis

* update

* feat: auction module

* module wiring

* syntax

* comment

* fix app keys

* fix codec
  • Loading branch information
robert-zaremba authored Mar 25, 2024
1 parent 764a5c4 commit 7be3d59
Show file tree
Hide file tree
Showing 9 changed files with 318 additions and 10 deletions.
43 changes: 33 additions & 10 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,9 @@ import (
uwasm "github.com/umee-network/umee/v6/app/wasm"
"github.com/umee-network/umee/v6/swagger"
"github.com/umee-network/umee/v6/util/genmap"
"github.com/umee-network/umee/v6/x/auction"
auctionkeeper "github.com/umee-network/umee/v6/x/auction/keeper"
auctionmodule "github.com/umee-network/umee/v6/x/auction/module"
"github.com/umee-network/umee/v6/x/incentive"
incentivekeeper "github.com/umee-network/umee/v6/x/incentive/keeper"
incentivemodule "github.com/umee-network/umee/v6/x/incentive/module"
Expand Down Expand Up @@ -200,11 +203,13 @@ func init() {
ica.AppModuleBasic{},
// intertx.AppModuleBasic{},
// ibcfee.AppModuleBasic{},

leverage.AppModuleBasic{},
oracle.AppModuleBasic{},
uibcmodule.AppModuleBasic{},
ugovmodule.AppModuleBasic{},
wasm.AppModuleBasic{},
auctionmodule.AppModuleBasic{},
incentivemodule.AppModuleBasic{},
metokenmodule.AppModuleBasic{},
packetforward.AppModuleBasic{},
Expand All @@ -228,11 +233,12 @@ func init() {
leveragetypes.ModuleName: {authtypes.Minter, authtypes.Burner},
wasmtypes.ModuleName: {authtypes.Burner},

auction.ModuleName: nil,
incentive.ModuleName: nil,
metoken.ModuleName: {authtypes.Minter, authtypes.Burner},
oracletypes.ModuleName: nil,
uibc.ModuleName: nil,
ugov.ModuleName: nil,
metoken.ModuleName: {authtypes.Minter, authtypes.Burner},
uibc.ModuleName: nil,
}
// if Experimental {}
}
Expand Down Expand Up @@ -279,11 +285,13 @@ type UmeeApp struct {
PacketForwardKeeper *packetforwardkeeper.Keeper
ICAHostKeeper icahostkeeper.Keeper
LeverageKeeper leveragekeeper.Keeper
IncentiveKeeper incentivekeeper.Keeper
OracleKeeper oraclekeeper.Keeper
UIbcQuotaKeeperB uibcquota.Builder
UGovKeeperB ugovkeeper.Builder
MetokenKeeperB metokenkeeper.Builder

AuctionKeeperB auctionkeeper.Builder
IncentiveKeeper incentivekeeper.Keeper
MetokenKeeperB metokenkeeper.Builder
OracleKeeper oraclekeeper.Keeper
UGovKeeperB ugovkeeper.Builder
UIbcQuotaKeeperB uibcquota.Builder

// make scoped keepers public for testing purposes
ScopedIBCKeeper capabilitykeeper.ScopedKeeper
Expand Down Expand Up @@ -335,12 +343,17 @@ func New(
evidencetypes.StoreKey, capabilitytypes.StoreKey,
authzkeeper.StoreKey, nftkeeper.StoreKey, group.StoreKey,
ibcexported.StoreKey, ibctransfertypes.StoreKey, icahosttypes.StoreKey,
leveragetypes.StoreKey, oracletypes.StoreKey, packetforwardtypes.StoreKey,
uibc.StoreKey, ugov.StoreKey,
packetforwardtypes.StoreKey,
wasmtypes.StoreKey,
consensusparamstypes.StoreKey, crisistypes.StoreKey,

auction.StoreKey,
incentive.StoreKey,
leveragetypes.StoreKey,
metoken.StoreKey,
consensusparamstypes.StoreKey, crisistypes.StoreKey,
oracletypes.StoreKey,
ugov.StoreKey,
uibc.StoreKey,
}
// if Experimental {}

Expand Down Expand Up @@ -503,6 +516,11 @@ func New(
app.UGovKeeperB.EmergencyGroup,
)

app.AuctionKeeperB = auctionkeeper.NewBuilder(
appCodec,
keys[auction.StoreKey],
)

// register the staking hooks
// NOTE: stakingKeeper above is passed by reference, so that it will contain these hooks
app.StakingKeeper.SetHooks(
Expand Down Expand Up @@ -734,6 +752,7 @@ func New(
wasm.NewAppModule(app.appCodec, &app.WasmKeeper, app.StakingKeeper, app.AccountKeeper, app.BankKeeper, app.MsgServiceRouter(), app.GetSubspace(wasmtypes.ModuleName)), //nolint: lll
incentivemodule.NewAppModule(appCodec, app.IncentiveKeeper, app.BankKeeper, app.LeverageKeeper),
metokenmodule.NewAppModule(appCodec, app.MetokenKeeperB),
auctionmodule.NewAppModule(appCodec, app.AuctionKeeperB, app.BankKeeper),
}
// if Experimental {}

Expand Down Expand Up @@ -774,6 +793,7 @@ func New(
ugov.ModuleName,
wasmtypes.ModuleName,
incentive.ModuleName,
auction.ModuleName,
}
endBlockers := []string{
crisistypes.ModuleName,
Expand All @@ -793,6 +813,7 @@ func New(
ugov.ModuleName,
wasmtypes.ModuleName,
incentive.ModuleName,
auction.ModuleName,
}

// NOTE: The genutils module must occur after staking so that pools are
Expand All @@ -818,6 +839,7 @@ func New(
wasmtypes.ModuleName,
incentive.ModuleName,
metoken.ModuleName,
auction.ModuleName,
}
orderMigrations := []string{
capabilitytypes.ModuleName, authtypes.ModuleName, banktypes.ModuleName, distrtypes.ModuleName,
Expand All @@ -835,6 +857,7 @@ func New(
wasmtypes.ModuleName,
incentive.ModuleName,
metoken.ModuleName,
auction.ModuleName,
}
// if Experimental {}

Expand Down
42 changes: 42 additions & 0 deletions x/auction/codec.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package auction

import (
"github.com/cosmos/cosmos-sdk/codec"
cdctypes "github.com/cosmos/cosmos-sdk/codec/types"
cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec"
sdk "github.com/cosmos/cosmos-sdk/types"
// "github.com/cosmos/cosmos-sdk/types/msgservice"
)

// Amino codecs
// Note, the ModuleCdc should ONLY be used in certain instances of tests and for JSON
// encoding as Amino is still used for that purpose.
var (
amino = codec.NewLegacyAmino()
ModuleCdc = codec.NewAminoCodec(amino)
)

func init() {
RegisterLegacyAminoCodec(amino)
cryptocodec.RegisterCrypto(amino)
amino.Seal()
}

// RegisterLegacyAminoCodec registers the necessary x/uibc interfaces and
// concrete types on the provided LegacyAmino codec. These types are used for
// Amino JSON serialization.
func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) {
cdc.RegisterConcrete(&MsgGovSetRewardsParams{}, "umee/auction/MsgGovSetRewardsParams", nil)
cdc.RegisterConcrete(&MsgRewardsBid{}, "umee/auction/MsgRewardsBid", nil)
}

func RegisterInterfaces(registry cdctypes.InterfaceRegistry) {
registry.RegisterImplementations(
(*sdk.Msg)(nil),
// &MsgGovSetRewardsParams{},
// &MsgRewardsBid{},
)

// TODO
// msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc)
}
4 changes: 4 additions & 0 deletions x/auction/expected_keepers.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package auction

// TODO: create a shared interface for bank keeper in /sdkutils
type BankKeeper interface{}
12 changes: 12 additions & 0 deletions x/auction/genesis.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package auction

// DefaultGenesis creates a default genesis state
func DefaultGenesis() *GenesisState {
// TODO
return &GenesisState{}
}

func (gs *GenesisState) Validate() error {
// TODO
return nil
}
14 changes: 14 additions & 0 deletions x/auction/keeper/genesis.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package keeper

import (
"github.com/umee-network/umee/v6/x/auction"
)

func (k Keeper) ExportGenesis() *auction.GenesisState {
// TODO
return &auction.GenesisState{}
}

func (k Keeper) InitGenesis(*auction.GenesisState) {
// TODO
}
26 changes: 26 additions & 0 deletions x/auction/keeper/keeper.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package keeper

import (
"github.com/cosmos/cosmos-sdk/codec"
storetypes "github.com/cosmos/cosmos-sdk/store/types"
sdk "github.com/cosmos/cosmos-sdk/types"
)

type Builder struct {
cdc codec.Codec
storeKey storetypes.StoreKey
}

func NewBuilder(cdc codec.Codec, key storetypes.StoreKey) Builder {
return Builder{cdc: cdc, storeKey: key}
}

func (kb Builder) Keeper(ctx *sdk.Context) Keeper {
return Keeper{
ctx: ctx,
}
}

type Keeper struct {
ctx *sdk.Context
}
9 changes: 9 additions & 0 deletions x/auction/keys.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package auction

const (
// ModuleName defines the module name
ModuleName = "auction"

// StoreKey defines the primary module store key
StoreKey = ModuleName
)
19 changes: 19 additions & 0 deletions x/auction/module/genesis.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package module

import (
sdk "github.com/cosmos/cosmos-sdk/types"

"github.com/umee-network/umee/v6/x/incentive"
"github.com/umee-network/umee/v6/x/incentive/keeper"
)

// InitGenesis initializes the x/incentive module's state from a provided genesis
// state.
func InitGenesis(ctx sdk.Context, k keeper.Keeper, genState incentive.GenesisState) {
k.InitGenesis(ctx, genState)
}

// ExportGenesis returns the x/incentive module's exported genesis state.
func ExportGenesis(ctx sdk.Context, k keeper.Keeper) *incentive.GenesisState {
return k.ExportGenesis(ctx)
}
Loading

0 comments on commit 7be3d59

Please sign in to comment.