Skip to content

Last try #2037

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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
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
16 changes: 16 additions & 0 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,10 @@ import (
// unnamed import of statik for openapi/swagger UI support
_ "github.com/sei-protocol/sei-chain/docs/swagger"
ssconfig "github.com/sei-protocol/sei-db/config"

mev "github.com/sei-protocol/sei-chain/x/mev"
mevkeeper "github.com/sei-protocol/sei-chain/x/mev/keeper"
mevtypes "github.com/sei-protocol/sei-chain/x/mev/types"
)

// this line is used by starport scaffolding # stargate/wasm/app/enabledProposals
Expand Down Expand Up @@ -330,6 +334,7 @@ type App struct {
WasmKeeper wasm.Keeper
OracleKeeper oraclekeeper.Keeper
EvmKeeper evmkeeper.Keeper
MevKeeper mevkeeper.Keeper

// make scoped keepers public for test purposes
ScopedIBCKeeper capabilitykeeper.ScopedKeeper
Expand Down Expand Up @@ -543,6 +548,13 @@ func New(
app.DistrKeeper,
)

keys[mevtypes.StoreKey] = storetypes.NewKVStoreKey(mevtypes.StoreKey)

app.MevKeeper = mevkeeper.NewKeeper(
appCodec,
keys[mevtypes.StoreKey],
)

// The last arguments can contain custom message handlers, and custom query handlers,
// if we want to allow any custom callbacks
supportedFeatures := "iterator,staking,stargate,sei"
Expand Down Expand Up @@ -747,6 +759,7 @@ func New(
tokenfactorymodule.NewAppModule(app.TokenFactoryKeeper, app.AccountKeeper, app.BankKeeper),
authzmodule.NewAppModule(appCodec, app.AuthzKeeper, app.AccountKeeper, app.BankKeeper, app.interfaceRegistry),
// this line is used by starport scaffolding # stargate/app/appModule
mev.NewAppModule(appCodec, app.MevKeeper),
)

// During begin block slashing happens after distr.BeginBlocker so that
Expand Down Expand Up @@ -778,6 +791,7 @@ func New(
wasm.ModuleName,
tokenfactorytypes.ModuleName,
acltypes.ModuleName,
mevtypes.ModuleName, // Add here
)

app.mm.SetOrderMidBlockers(
Expand Down Expand Up @@ -809,6 +823,7 @@ func New(
wasm.ModuleName,
tokenfactorytypes.ModuleName,
acltypes.ModuleName,
mevtypes.ModuleName, // Add here
)

// NOTE: The genutils module must occur after staking so that pools are
Expand Down Expand Up @@ -842,6 +857,7 @@ func New(
evmtypes.ModuleName,
acltypes.ModuleName,
// this line is used by starport scaffolding # stargate/app/initGenesis
mevtypes.ModuleName, // Add here
)

app.mm.RegisterInvariants(&app.CrisisKeeper)
Expand Down
19 changes: 19 additions & 0 deletions proto/mev/genesis.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
syntax = "proto3";
package seiprotocol.seichain.mev;

import "gogoproto/gogo.proto";

option go_package = "github.com/sei-protocol/sei-chain/x/mev/types";

// GenesisState defines the mev module's genesis state
message GenesisState {
option (gogoproto.equal) = false;
option (gogoproto.goproto_getters) = false;

Params params = 1 [(gogoproto.nullable) = false];
}

// Params defines the parameters for the mev module
message Params {
option (gogoproto.goproto_stringer) = false;
}
11 changes: 11 additions & 0 deletions proto/mev/params.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
syntax = "proto3";
package seiprotocol.seichain.mev;

import "gogoproto/gogo.proto";

option go_package = "github.com/sei-protocol/sei-chain/x/mev/types";

// Params defines the parameters for the mev module.
message Params {
option (gogoproto.goproto_stringer) = false;
}
24 changes: 24 additions & 0 deletions proto/mev/query.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
syntax = "proto3";
package seiprotocol.seichain.mev;

import "gogoproto/gogo.proto";
import "google/api/annotations.proto";
import "mev/params.proto";

option go_package = "github.com/sei-protocol/sei-chain/x/mev/types";

// Query defines the gRPC querier service.
service Query {
// Params returns the total set of mev parameters.
rpc Params(QueryParamsRequest) returns (QueryParamsResponse) {
option (google.api.http).get = "/sei-protocol/sei-chain/mev/params";
}
}

// QueryParamsRequest is the request type for the Query/Params RPC method.
message QueryParamsRequest {}

// QueryParamsResponse is the response type for the Query/Params RPC method.
message QueryParamsResponse {
Params params = 1 [(gogoproto.nullable) = false];
}
2 changes: 1 addition & 1 deletion readme.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Sei
# Sei with MEV by MEVVY!

![Banner!](assets/SeiLogo.png)

Expand Down
54 changes: 54 additions & 0 deletions x/mev/client/cli/query.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
package cli

import (
"fmt"

"github.com/spf13/cobra"

"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/client/flags"
"github.com/sei-protocol/sei-chain/x/mev/types"
)

// GetQueryCmd returns the cli query commands for this module
func GetQueryCmd(queryRoute string) *cobra.Command {
cmd := &cobra.Command{
Use: types.ModuleName,
Short: fmt.Sprintf("Querying commands for the %s module", types.ModuleName),
DisableFlagParsing: true,
SuggestionsMinimumDistance: 2,
RunE: client.ValidateCmd,
}

cmd.AddCommand(
GetParamsCmd(),
)

return cmd
}

func GetParamsCmd() *cobra.Command {
cmd := &cobra.Command{
Use: "params",
Short: "Query the current mev module parameters",
Args: cobra.NoArgs,
RunE: func(cmd *cobra.Command, args []string) error {
clientCtx, err := client.GetClientQueryContext(cmd)
if err != nil {
return err
}

queryClient := types.NewQueryClient(clientCtx)
res, err := queryClient.Params(cmd.Context(), &types.QueryParamsRequest{})
if err != nil {
return err
}

return clientCtx.PrintProto(&res.Params)
},
}

flags.AddQueryFlagsToCmd(cmd)

return cmd
}
27 changes: 27 additions & 0 deletions x/mev/client/cli/tx.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package cli

import (
"fmt"

"github.com/spf13/cobra"

"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/client/flags"
"github.com/cosmos/cosmos-sdk/client/tx"
"github.com/sei-protocol/sei-chain/x/mev/types"
)

// GetTxCmd returns the transaction commands for this module
func GetTxCmd() *cobra.Command {
cmd := &cobra.Command{
Use: types.ModuleName,
Short: fmt.Sprintf("%s transactions subcommands", types.ModuleName),
DisableFlagParsing: true,
SuggestionsMinimumDistance: 2,
RunE: client.ValidateCmd,
}

// Add tx commands here when needed

return cmd
}
18 changes: 18 additions & 0 deletions x/mev/keeper/grpc_query.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package keeper

import (
"context"

sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/sei-protocol/sei-chain/x/mev/types"
)

var _ types.QueryServer = Keeper{}

// Params implements the Query/Params gRPC method
func (k Keeper) Params(c context.Context, _ *types.QueryParamsRequest) (*types.QueryParamsResponse, error) {
ctx := sdk.UnwrapSDKContext(c)
params := k.GetParams(ctx)

return &types.QueryParamsResponse{Params: params}, nil
}
21 changes: 21 additions & 0 deletions x/mev/keeper/keeper.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package keeper

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

type Keeper struct {
cdc codec.BinaryCodec
storeKey sdk.StoreKey
}

func NewKeeper(
cdc codec.BinaryCodec,
storeKey sdk.StoreKey,
) Keeper {
return Keeper{
cdc: cdc,
storeKey: storeKey,
}
}
18 changes: 18 additions & 0 deletions x/mev/keeper/params.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package keeper

import (
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/sei-protocol/sei-chain/x/mev/types"
)

// GetParams returns the total set of mev parameters.
func (k Keeper) GetParams(ctx sdk.Context) types.Params {
var params types.Params
k.paramstore.GetParamSet(ctx, &params)
return params
}

// SetParams sets the mev parameters to the param space.
func (k Keeper) SetParams(ctx sdk.Context, params types.Params) {
k.paramstore.SetParamSet(ctx, &params)
}
Loading