From aae8c097fbc895308c18e93d84871f6e07971dfe Mon Sep 17 00:00:00 2001 From: David Terpay <35130517+davidterpay@users.noreply.github.com> Date: Tue, 6 Dec 2022 14:17:54 -0600 Subject: [PATCH 1/3] ProtoRev: Proto code and Init scaffolding code (#3587) * Configuring protorev in osmosis app + adding proto code * generating proto code + adding types implementations * implementing msg and gov types * clean up + adding a few more test cases * styling fixes * lint fixes * Updating URLs for queries and msg server to v13 * Refactor of pool statistics + errors * proto update * proto updates (snake casing for fields) * refactoring params to standard implementation * proposal handler upgrade for protorev --- app/keepers/keepers.go | 11 + app/keepers/modules.go | 2 + app/modules.go | 5 + proto/osmosis/protorev/v1beta1/genesis.proto | 16 + proto/osmosis/protorev/v1beta1/gov.proto | 32 + proto/osmosis/protorev/v1beta1/params.proto | 12 + proto/osmosis/protorev/v1beta1/protorev.proto | 57 + proto/osmosis/protorev/v1beta1/query.proto | 149 + proto/osmosis/protorev/v1beta1/tx.proto | 48 + x/protorev/client/cli/query.go | 1 + x/protorev/genesis.go | 27 + x/protorev/keeper/keeper.go | 57 + x/protorev/keeper/params.go | 18 + x/protorev/module.go | 171 ++ x/protorev/types/codec.go | 44 + x/protorev/types/expected_keepers.go | 38 + x/protorev/types/genesis.go | 74 + x/protorev/types/genesis.pb.go | 391 +++ x/protorev/types/genesis_test.go | 93 + x/protorev/types/gov.go | 91 + x/protorev/types/gov.pb.go | 710 +++++ x/protorev/types/gov_test.go | 72 + x/protorev/types/keys.go | 12 + x/protorev/types/msg.go | 126 + x/protorev/types/msg_test.go | 136 + x/protorev/types/params.go | 50 + x/protorev/types/params.pb.go | 311 ++ x/protorev/types/protorev.pb.go | 1261 ++++++++ x/protorev/types/query.pb.go | 2730 +++++++++++++++++ x/protorev/types/query.pb.gw.go | 579 ++++ x/protorev/types/token_pair_arb_routes.go | 69 + x/protorev/types/tx.pb.go | 992 ++++++ x/protorev/types/tx.pb.gw.go | 254 ++ x/protorev/types/utils.go | 32 + 34 files changed, 8671 insertions(+) create mode 100644 proto/osmosis/protorev/v1beta1/genesis.proto create mode 100644 proto/osmosis/protorev/v1beta1/gov.proto create mode 100644 proto/osmosis/protorev/v1beta1/params.proto create mode 100644 proto/osmosis/protorev/v1beta1/protorev.proto create mode 100644 proto/osmosis/protorev/v1beta1/query.proto create mode 100644 proto/osmosis/protorev/v1beta1/tx.proto create mode 100644 x/protorev/client/cli/query.go create mode 100644 x/protorev/genesis.go create mode 100644 x/protorev/keeper/keeper.go create mode 100644 x/protorev/keeper/params.go create mode 100644 x/protorev/module.go create mode 100644 x/protorev/types/codec.go create mode 100644 x/protorev/types/expected_keepers.go create mode 100644 x/protorev/types/genesis.go create mode 100644 x/protorev/types/genesis.pb.go create mode 100644 x/protorev/types/genesis_test.go create mode 100644 x/protorev/types/gov.go create mode 100644 x/protorev/types/gov.pb.go create mode 100644 x/protorev/types/gov_test.go create mode 100644 x/protorev/types/keys.go create mode 100644 x/protorev/types/msg.go create mode 100644 x/protorev/types/msg_test.go create mode 100644 x/protorev/types/params.go create mode 100644 x/protorev/types/params.pb.go create mode 100644 x/protorev/types/protorev.pb.go create mode 100644 x/protorev/types/query.pb.go create mode 100644 x/protorev/types/query.pb.gw.go create mode 100644 x/protorev/types/token_pair_arb_routes.go create mode 100644 x/protorev/types/tx.pb.go create mode 100644 x/protorev/types/tx.pb.gw.go create mode 100644 x/protorev/types/utils.go diff --git a/app/keepers/keepers.go b/app/keepers/keepers.go index f62a5594101..9a7ab5643a5 100644 --- a/app/keepers/keepers.go +++ b/app/keepers/keepers.go @@ -68,6 +68,8 @@ import ( poolincentives "github.com/osmosis-labs/osmosis/v13/x/pool-incentives" poolincentiveskeeper "github.com/osmosis-labs/osmosis/v13/x/pool-incentives/keeper" poolincentivestypes "github.com/osmosis-labs/osmosis/v13/x/pool-incentives/types" + protorevkeeper "github.com/osmosis-labs/osmosis/v13/x/protorev/keeper" + protorevtypes "github.com/osmosis-labs/osmosis/v13/x/protorev/types" "github.com/osmosis-labs/osmosis/v13/x/superfluid" superfluidkeeper "github.com/osmosis-labs/osmosis/v13/x/superfluid/keeper" superfluidtypes "github.com/osmosis-labs/osmosis/v13/x/superfluid/types" @@ -112,6 +114,7 @@ type AppKeepers struct { LockupKeeper *lockupkeeper.Keeper EpochsKeeper *epochskeeper.Keeper IncentivesKeeper *incentiveskeeper.Keeper + ProtoRevKeeper *protorevkeeper.Keeper MintKeeper *mintkeeper.Keeper PoolIncentivesKeeper *poolincentiveskeeper.Keeper TxFeesKeeper *txfeeskeeper.Keeper @@ -263,6 +266,12 @@ func (appKeepers *AppKeepers) InitNormalKeepers( appKeepers.EpochsKeeper = epochskeeper.NewKeeper(appKeepers.keys[epochstypes.StoreKey]) + protorevKeeper := protorevkeeper.NewKeeper( + appCodec, appKeepers.keys[protorevtypes.StoreKey], + appKeepers.GetSubspace(protorevtypes.ModuleName), + appKeepers.AccountKeeper, appKeepers.BankKeeper, appKeepers.GAMMKeeper, appKeepers.EpochsKeeper) + appKeepers.ProtoRevKeeper = &protorevKeeper + txFeesKeeper := txfeeskeeper.NewKeeper( appKeepers.AccountKeeper, appKeepers.BankKeeper, @@ -505,6 +514,7 @@ func (appKeepers *AppKeepers) initParamsKeeper(appCodec codec.BinaryCodec, legac paramsKeeper.Subspace(incentivestypes.ModuleName) paramsKeeper.Subspace(lockuptypes.ModuleName) paramsKeeper.Subspace(poolincentivestypes.ModuleName) + paramsKeeper.Subspace(protorevtypes.ModuleName) paramsKeeper.Subspace(superfluidtypes.ModuleName) paramsKeeper.Subspace(gammtypes.ModuleName) paramsKeeper.Subspace(wasm.ModuleName) @@ -605,5 +615,6 @@ func KVStoreKeys() []string { wasm.StoreKey, tokenfactorytypes.StoreKey, valsetpreftypes.StoreKey, + protorevtypes.StoreKey, } } diff --git a/app/keepers/modules.go b/app/keepers/modules.go index 4a66a433464..42c1242a219 100644 --- a/app/keepers/modules.go +++ b/app/keepers/modules.go @@ -37,6 +37,7 @@ import ( "github.com/osmosis-labs/osmosis/v13/x/mint" poolincentives "github.com/osmosis-labs/osmosis/v13/x/pool-incentives" poolincentivesclient "github.com/osmosis-labs/osmosis/v13/x/pool-incentives/client" + "github.com/osmosis-labs/osmosis/v13/x/protorev" superfluid "github.com/osmosis-labs/osmosis/v13/x/superfluid" superfluidclient "github.com/osmosis-labs/osmosis/v13/x/superfluid/client" "github.com/osmosis-labs/osmosis/v13/x/tokenfactory" @@ -81,6 +82,7 @@ var AppModuleBasics = []module.AppModuleBasic{ vesting.AppModuleBasic{}, gamm.AppModuleBasic{}, twapmodule.AppModuleBasic{}, + protorev.AppModuleBasic{}, txfees.AppModuleBasic{}, incentives.AppModuleBasic{}, lockup.AppModuleBasic{}, diff --git a/app/modules.go b/app/modules.go index 8308fb7f2ce..a1ca237fc7f 100644 --- a/app/modules.go +++ b/app/modules.go @@ -61,6 +61,8 @@ import ( minttypes "github.com/osmosis-labs/osmosis/v13/x/mint/types" poolincentives "github.com/osmosis-labs/osmosis/v13/x/pool-incentives" poolincentivestypes "github.com/osmosis-labs/osmosis/v13/x/pool-incentives/types" + "github.com/osmosis-labs/osmosis/v13/x/protorev" + protorevtypes "github.com/osmosis-labs/osmosis/v13/x/protorev/types" superfluid "github.com/osmosis-labs/osmosis/v13/x/superfluid" superfluidtypes "github.com/osmosis-labs/osmosis/v13/x/superfluid/types" "github.com/osmosis-labs/osmosis/v13/x/tokenfactory" @@ -88,6 +90,7 @@ var moduleAccountPermissions = map[string][]string{ ibctransfertypes.ModuleName: {authtypes.Minter, authtypes.Burner}, gammtypes.ModuleName: {authtypes.Minter, authtypes.Burner}, incentivestypes.ModuleName: {authtypes.Minter, authtypes.Burner}, + protorevtypes.ModuleName: {authtypes.Minter, authtypes.Burner}, lockuptypes.ModuleName: {authtypes.Minter, authtypes.Burner}, poolincentivestypes.ModuleName: nil, superfluidtypes.ModuleName: {authtypes.Minter, authtypes.Burner}, @@ -133,6 +136,7 @@ func appModules( app.RawIcs20TransferAppModule, gamm.NewAppModule(appCodec, *app.GAMMKeeper, app.AccountKeeper, app.BankKeeper), twapmodule.NewAppModule(*app.TwapKeeper), + protorev.NewAppModule(appCodec, *app.ProtoRevKeeper, app.AccountKeeper, app.BankKeeper, app.EpochsKeeper, app.GAMMKeeper), txfees.NewAppModule(*app.TxFeesKeeper), incentives.NewAppModule(*app.IncentivesKeeper, app.AccountKeeper, app.BankKeeper, app.EpochsKeeper), lockup.NewAppModule(*app.LockupKeeper, app.AccountKeeper, app.BankKeeper), @@ -208,6 +212,7 @@ func OrderInitGenesis(allModuleNames []string) []string { ibchost.ModuleName, icatypes.ModuleName, gammtypes.ModuleName, + protorevtypes.ModuleName, twaptypes.ModuleName, txfeestypes.ModuleName, genutiltypes.ModuleName, diff --git a/proto/osmosis/protorev/v1beta1/genesis.proto b/proto/osmosis/protorev/v1beta1/genesis.proto new file mode 100644 index 00000000000..b8514f49ddf --- /dev/null +++ b/proto/osmosis/protorev/v1beta1/genesis.proto @@ -0,0 +1,16 @@ +syntax = "proto3"; +package osmosis.protorev.v1beta1; + +import "gogoproto/gogo.proto"; +import "osmosis/protorev/v1beta1/protorev.proto"; +import "osmosis/protorev/v1beta1/params.proto"; + +option go_package = "github.com/osmosis-labs/osmosis/v13/x/protorev/types"; + +// GenesisState defines the protorev module's genesis state. +message GenesisState { + // Module Parameters + Params params = 1 [ (gogoproto.nullable) = false ]; + // Hot routes that are configured on genesis + repeated TokenPairArbRoutes token_pairs = 2 [ (gogoproto.nullable) = false ]; +} \ No newline at end of file diff --git a/proto/osmosis/protorev/v1beta1/gov.proto b/proto/osmosis/protorev/v1beta1/gov.proto new file mode 100644 index 00000000000..b73033f69a4 --- /dev/null +++ b/proto/osmosis/protorev/v1beta1/gov.proto @@ -0,0 +1,32 @@ +syntax = "proto3"; +package osmosis.protorev.v1beta1; + +import "gogoproto/gogo.proto"; +import "osmosis/protorev/v1beta1/protorev.proto"; + +option go_package = "github.com/osmosis-labs/osmosis/v13/x/protorev/types"; + +// SetProtoRevEnabledProposal is a gov Content type to update whether the +// protorev module is enabled +message SetProtoRevEnabledProposal { + option (gogoproto.equal) = true; + option (gogoproto.goproto_getters) = false; + option (gogoproto.goproto_stringer) = false; + + string title = 1; + string description = 2; + bool enabled = 3; +} + +// SetProtoRevAdminAccountProposal is a gov Content type to set the admin +// account that will receive permissions to alter hot routes and set the +// developer address that will be receiving a share of profits from the module +message SetProtoRevAdminAccountProposal { + option (gogoproto.equal) = true; + option (gogoproto.goproto_getters) = false; + option (gogoproto.goproto_stringer) = false; + + string title = 1; + string description = 2; + string account = 3; +} \ No newline at end of file diff --git a/proto/osmosis/protorev/v1beta1/params.proto b/proto/osmosis/protorev/v1beta1/params.proto new file mode 100644 index 00000000000..7e05c3299cd --- /dev/null +++ b/proto/osmosis/protorev/v1beta1/params.proto @@ -0,0 +1,12 @@ +syntax = "proto3"; +package osmosis.protorev.v1beta1; + +import "gogoproto/gogo.proto"; + +option go_package = "github.com/osmosis-labs/osmosis/v13/x/protorev/types"; + +// Params defines the parameters for the module. +message Params { + // Boolean whether the module is going to be enabled + bool enabled = 1; +} \ No newline at end of file diff --git a/proto/osmosis/protorev/v1beta1/protorev.proto b/proto/osmosis/protorev/v1beta1/protorev.proto new file mode 100644 index 00000000000..7c7a0256083 --- /dev/null +++ b/proto/osmosis/protorev/v1beta1/protorev.proto @@ -0,0 +1,57 @@ +syntax = "proto3"; +package osmosis.protorev.v1beta1; + +import "cosmos_proto/cosmos.proto"; +import "gogoproto/gogo.proto"; + +import "cosmos/base/v1beta1/coin.proto"; + +option go_package = "github.com/osmosis-labs/osmosis/v13/x/protorev/types"; + +// TokenPairArbRoutes tracks all of the hot routes for a given pair of tokens +message TokenPairArbRoutes { + option (gogoproto.equal) = true; + + // Stores all of the possible hot paths for a given pair of tokens + repeated Route arb_routes = 1; + // Token denomination of the first asset + string token_in = 2; + // Token denomination of the second asset + string token_out = 3; +} + +// Route is a hot route for a given pair of tokens +message Route { + option (gogoproto.equal) = true; + + // The pool IDs that are travered in the directed cyclic graph (traversed left + // -> right) + repeated Trade trades = 1; +} + +// Trade is a single trade in a route +message Trade { + option (gogoproto.equal) = true; + + // The pool IDs that are travered in the directed cyclic graph (traversed left + // -> right) + uint64 pool = 1; + // The denom of token A that is traded + string token_in = 2; + // The denom of token B that is traded + string token_out = 3; +} + +// PoolStatistics contains the number of trades the module has executed after a +// swap on a given pool and the profits from the trades +message PoolStatistics { + // profits is the total profit from all trades on this pool + repeated cosmos.base.v1beta1.Coin profits = 1; + // number_of_trades is the number of trades the module has executed + string number_of_trades = 2 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", + (gogoproto.nullable) = false + ]; + // pool_id is the id of the pool + uint64 pool_id = 3; +} \ No newline at end of file diff --git a/proto/osmosis/protorev/v1beta1/query.proto b/proto/osmosis/protorev/v1beta1/query.proto new file mode 100644 index 00000000000..8da837174fb --- /dev/null +++ b/proto/osmosis/protorev/v1beta1/query.proto @@ -0,0 +1,149 @@ +syntax = "proto3"; +package osmosis.protorev.v1beta1; + +import "gogoproto/gogo.proto"; +import "google/api/annotations.proto"; +import "cosmos/base/query/v1beta1/pagination.proto"; +import "osmosis/protorev/v1beta1/params.proto"; +import "osmosis/protorev/v1beta1/protorev.proto"; + +import "cosmos/base/v1beta1/coin.proto"; + +option go_package = "github.com/osmosis-labs/osmosis/v13/x/protorev/types"; + +// Query defines the gRPC querier service. +service Query { + // Params queries the parameters of the module. + rpc Params(QueryParamsRequest) returns (QueryParamsResponse) { + option (google.api.http).get = "/osmosis/v13/protorev/params"; + } + + // GetProtoRevNumberOfTrades queries the number of arbitrage trades the module + // has executed + rpc GetProtoRevNumberOfTrades(QueryGetProtoRevNumberOfTradesRequest) + returns (QueryGetProtoRevNumberOfTradesResponse) { + option (google.api.http).get = "/osmosis/v13/protorev/number_of_trades"; + } + + // GetProtoRevProfitsByDenom queries the profits of the module by denom + rpc GetProtoRevProfitsByDenom(QueryGetProtoRevProfitsByDenomRequest) + returns (QueryGetProtoRevProfitsByDenomResponse) { + option (google.api.http).get = "/osmosis/v13/protorev/profits_by_denom"; + } + + // GetProtoRevAllProfits queries all of the profits from the module + rpc GetProtoRevAllProfits(QueryGetProtoRevAllProfitsRequest) + returns (QueryGetProtoRevAllProfitsResponse) { + option (google.api.http).get = "/osmosis/v13/protorev/all_profits"; + } + + // GetProtoRevStatisticsByPool queries the number of arbitrages and profits + // that have been executed for a given pool + rpc GetProtoRevStatisticsByPool(QueryGetProtoRevStatisticsByPoolRequest) + returns (QueryGetProtoRevStatisticsByPoolResponse) { + option (google.api.http).get = "/osmosis/v13/protorev/statistics_by_pool"; + } + + // GetProtoRevAllStatistics queries all of pools that the module has arbitrage + // against and the number of trades and profits that have been executed for + // each pool + rpc GetProtoRevAllStatistics(QueryGetProtoRevAllStatisticsRequest) + returns (QueryGetProtoRevAllStatisticsResponse) { + option (google.api.http).get = "/osmosis/v13/protorev/all_statistics"; + } + + // GetProtoRevTokenPairArbRoutes queries all of the hot routes that the module + // is currently arbitraging + rpc GetProtoRevTokenPairArbRoutes(QueryGetProtoRevTokenPairArbRoutesRequest) + returns (QueryGetProtoRevTokenPairArbRoutesResponse) { + option (google.api.http).get = + "/osmosis/v13/protorev/token_pair_arb_routes"; + } +} + +// QueryParamsRequest is request type for the Query/Params RPC method. +message QueryParamsRequest {} + +// QueryParamsResponse is response type for the Query/Params RPC method. +message QueryParamsResponse { + // params holds all the parameters of this module. + Params params = 1 [ (gogoproto.nullable) = false ]; +} + +// QueryGetProtoRevNumberOfTradesRequest is request type for the +// Query/GetProtoRevNumberOfTrades RPC method. +message QueryGetProtoRevNumberOfTradesRequest {} + +// QueryGetProtoRevNumberOfTradesResponse is response type for the +// Query/GetProtoRevNumberOfTrades RPC method. +message QueryGetProtoRevNumberOfTradesResponse { + // number_of_trades is the number of trades the module has executed + string number_of_trades = 1 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", + (gogoproto.nullable) = false + ]; +} + +// QueryGetProtoRevProfitsByDenomRequest is request type for the +// Query/GetProtoRevProfitsByDenom RPC method. +message QueryGetProtoRevProfitsByDenomRequest { + // denom is the denom to query profits by + string denom = 1; +} + +// QueryGetProtoRevProfitsByDenomResponse is response type for the +// Query/GetProtoRevProfitsByDenom RPC method. +message QueryGetProtoRevProfitsByDenomResponse { + // profit is the profits of the module by the selected denom + cosmos.base.v1beta1.Coin profit = 1; +} + +// QueryGetProtoRevAllProfitsRequest is request type for the +// Query/GetProtoRevAllProfits RPC method. +message QueryGetProtoRevAllProfitsRequest {} + +// QueryGetProtoRevAllProfitsResponse is response type for the +// Query/GetProtoRevAllProfits RPC method. +message QueryGetProtoRevAllProfitsResponse { + // profits is a list of all of the profits from the module + repeated cosmos.base.v1beta1.Coin profits = 1; +} + +// QueryGetProtoRevStatisticsByPoolRequest is request type for the +// Query/GetProtoRevStatisticsByPool RPC method. +message QueryGetProtoRevStatisticsByPoolRequest { + // pool_id is the pool id to query statistics by + uint64 pool_id = 1; +} + +// QueryGetProtoRevStatisticsByPoolResponse is response type for the +// Query/GetProtoRevStatisticsByPool RPC method. +message QueryGetProtoRevStatisticsByPoolResponse { + // statistics contains the number of trades the module has executed after a + // swap on a given pool and the profits from the trades + PoolStatistics statistics = 1; +} + +// QueryGetProtoRevAllStatisticsRequest is request type for the +// Query/GetProtoRevAllStatistics RPC method. +message QueryGetProtoRevAllStatisticsRequest {} + +// QueryGetProtoRevAllStatisticsResponse is response type for the +// Query/GetProtoRevAllStatistics RPC method. +message QueryGetProtoRevAllStatisticsResponse { + // statistics contains the number of trades the module has executed after a + // swap on a given pool and the profits from the trades for all pools + repeated PoolStatistics statistics = 1 [ (gogoproto.nullable) = false ]; +} + +// QueryGetProtoRevTokenPairArbRoutesRequest is request type for the +// Query/GetProtoRevTokenPairArbRoutes RPC method. +message QueryGetProtoRevTokenPairArbRoutesRequest {} + +// QueryGetProtoRevTokenPairArbRoutesResponse is response type for the +// Query/GetProtoRevTokenPairArbRoutes RPC method. +message QueryGetProtoRevTokenPairArbRoutesResponse { + // routes is a list of all of the hot routes that the module is currently + // arbitraging + repeated TokenPairArbRoutes routes = 1; +} \ No newline at end of file diff --git a/proto/osmosis/protorev/v1beta1/tx.proto b/proto/osmosis/protorev/v1beta1/tx.proto new file mode 100644 index 00000000000..dca2fcfbdf3 --- /dev/null +++ b/proto/osmosis/protorev/v1beta1/tx.proto @@ -0,0 +1,48 @@ +syntax = "proto3"; +package osmosis.protorev.v1beta1; + +import "gogoproto/gogo.proto"; +import "google/api/annotations.proto"; +import "osmosis/protorev/v1beta1/protorev.proto"; + +option go_package = "github.com/osmosis-labs/osmosis/v13/x/protorev/types"; + +service Msg { + // SetHotRoutes sets the hot routes that will be explored when creating + // cyclic arbitrage routes. Can only be called by the admin account. + rpc SetHotRoutes(MsgSetHotRoutes) returns (MsgSetHotRoutesResponse) { + option (google.api.http).post = "/osmosis/v13/protorev/set_hot_routes"; + }; + + // SetDeveloperAccount sets the account that can withdraw a portion of the + // profits from the protorev module. This will be Skip's address. + rpc SetDeveloperAccount(MsgSetDeveloperAccount) + returns (MsgSetDeveloperAccountResponse) { + option (google.api.http).post = + "/osmosis/v13/protorev/set_developer_account"; + }; +} + +// MsgSetHotRoutes defines the Msg/SetHotRoutes request type. +message MsgSetHotRoutes { + // admin is the account that is authorized to set the hot routes. + string admin = 1; + // hot_routes is the list of hot routes to set. + repeated TokenPairArbRoutes hot_routes = 2; +} + +// MsgSetHotRoutesResponse defines the Msg/SetHotRoutes response type. +message MsgSetHotRoutesResponse {} + +// MsgSetDeveloperAccount defines the Msg/SetDeveloperAccount request type. +message MsgSetDeveloperAccount { + // admin is the account that is authorized to set the developer account. + string admin = 1; + // developer_account is the account that will receive a portion of the profits + // from the protorev module. + string developer_account = 2; +} + +// MsgSetDeveloperAccountResponse defines the Msg/SetDeveloperAccount response +// type. +message MsgSetDeveloperAccountResponse {} \ No newline at end of file diff --git a/x/protorev/client/cli/query.go b/x/protorev/client/cli/query.go new file mode 100644 index 00000000000..7f1e458cd3a --- /dev/null +++ b/x/protorev/client/cli/query.go @@ -0,0 +1 @@ +package cli diff --git a/x/protorev/genesis.go b/x/protorev/genesis.go new file mode 100644 index 00000000000..0f6159b722a --- /dev/null +++ b/x/protorev/genesis.go @@ -0,0 +1,27 @@ +package protorev + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + + "github.com/osmosis-labs/osmosis/v13/x/protorev/keeper" + "github.com/osmosis-labs/osmosis/v13/x/protorev/types" +) + +// InitGenesis initializes the module's state from a provided genesis state. +func InitGenesis(ctx sdk.Context, k keeper.Keeper, genState types.GenesisState) { + // Perform stateless validation on the genesis state + if err := genState.Validate(); err != nil { + panic(err) + } + + // Init module parameters + k.SetParams(ctx, genState.Params) +} + +// ExportGenesis returns the module's exported genesis +func ExportGenesis(ctx sdk.Context, k keeper.Keeper) *types.GenesisState { + genesis := types.DefaultGenesis() + genesis.Params = k.GetParams(ctx) + + return genesis +} diff --git a/x/protorev/keeper/keeper.go b/x/protorev/keeper/keeper.go new file mode 100644 index 00000000000..65585f1bf6f --- /dev/null +++ b/x/protorev/keeper/keeper.go @@ -0,0 +1,57 @@ +package keeper + +import ( + "fmt" + + "github.com/cosmos/cosmos-sdk/codec" + storetypes "github.com/cosmos/cosmos-sdk/store/types" + + sdk "github.com/cosmos/cosmos-sdk/types" + paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" + "github.com/tendermint/tendermint/libs/log" + + "github.com/osmosis-labs/osmosis/v13/x/protorev/types" +) + +type ( + Keeper struct { + cdc codec.BinaryCodec + storeKey storetypes.StoreKey + paramstore paramtypes.Subspace + + accountKeeper types.AccountKeeper + bankKeeper types.BankKeeper + gammKeeper types.GAMMKeeper + epochKeeper types.EpochKeeper + } +) + +func NewKeeper( + cdc codec.BinaryCodec, + storeKey sdk.StoreKey, + ps paramtypes.Subspace, + accountKeeper types.AccountKeeper, + bankKeeper types.BankKeeper, + gammKeeper types.GAMMKeeper, + epochKeeper types.EpochKeeper, + +) Keeper { + // set KeyTable if it has not already been set + if !ps.HasKeyTable() { + ps = ps.WithKeyTable(types.ParamKeyTable()) + } + + return Keeper{ + cdc: cdc, + storeKey: storeKey, + paramstore: ps, + accountKeeper: accountKeeper, + bankKeeper: bankKeeper, + gammKeeper: gammKeeper, + epochKeeper: epochKeeper, + } +} + +func (k Keeper) Logger(ctx sdk.Context) log.Logger { + return ctx.Logger().With("module", fmt.Sprintf("x/%s", types.ModuleName)) +} diff --git a/x/protorev/keeper/params.go b/x/protorev/keeper/params.go new file mode 100644 index 00000000000..ae4dc65f473 --- /dev/null +++ b/x/protorev/keeper/params.go @@ -0,0 +1,18 @@ +package keeper + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + + "github.com/osmosis-labs/osmosis/v13/x/protorev/types" +) + +// GetParams get all parameters as types.Params +func (k Keeper) GetParams(ctx sdk.Context) (params types.Params) { + k.paramstore.GetParamSet(ctx, ¶ms) + return params +} + +// SetParams set the params +func (k Keeper) SetParams(ctx sdk.Context, params types.Params) { + k.paramstore.SetParamSet(ctx, ¶ms) +} diff --git a/x/protorev/module.go b/x/protorev/module.go new file mode 100644 index 00000000000..6bb5dd77e8e --- /dev/null +++ b/x/protorev/module.go @@ -0,0 +1,171 @@ +package protorev + +import ( + "context" + "encoding/json" + "fmt" + + "github.com/gorilla/mux" + "github.com/grpc-ecosystem/grpc-gateway/runtime" + "github.com/spf13/cobra" + + abci "github.com/tendermint/tendermint/abci/types" + + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/codec" + cdctypes "github.com/cosmos/cosmos-sdk/codec/types" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/module" + + "github.com/osmosis-labs/osmosis/v13/x/protorev/keeper" + "github.com/osmosis-labs/osmosis/v13/x/protorev/types" +) + +var ( + _ module.AppModule = AppModule{} + _ module.AppModuleBasic = AppModuleBasic{} +) + +// ---------------------------------------------------------------------------- +// AppModuleBasic +// ---------------------------------------------------------------------------- + +// AppModuleBasic implements the AppModuleBasic interface that defines the independent methods a Cosmos SDK module needs to implement. +type AppModuleBasic struct { + cdc codec.BinaryCodec +} + +func NewAppModuleBasic(cdc codec.BinaryCodec) AppModuleBasic { + return AppModuleBasic{cdc: cdc} +} + +// Name returns the name of the module as a string +func (AppModuleBasic) Name() string { + return types.ModuleName +} + +// RegisterLegacyAminoCodec registers the amino codec for the module, which is used to marshal and unmarshal structs to/from []byte in order to persist them in the module's KVStore +func (AppModuleBasic) RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { + types.RegisterCodec(cdc) +} + +// RegisterInterfaces registers a module's interface types and their concrete implementations as proto.Message +func (a AppModuleBasic) RegisterInterfaces(reg cdctypes.InterfaceRegistry) { + types.RegisterInterfaces(reg) +} + +// DefaultGenesis returns a default GenesisState for the module, marshalled to json.RawMessage. The default GenesisState need to be defined by the module developer and is primarily used for testing +func (a AppModuleBasic) DefaultGenesis(cdc codec.JSONCodec) json.RawMessage { + return cdc.MustMarshalJSON(types.DefaultGenesis()) +} + +// ValidateGenesis used to validate the GenesisState, given in its json.RawMessage form +func (AppModuleBasic) ValidateGenesis(cdc codec.JSONCodec, config client.TxEncodingConfig, bz json.RawMessage) error { + var genState types.GenesisState + if err := cdc.UnmarshalJSON(bz, &genState); err != nil { + return fmt.Errorf("failed to unmarshal %s genesis state: %w", types.ModuleName, err) + } + return genState.Validate() +} + +// RegisterGRPCGatewayRoutes registers the gRPC Gateway routes for the module +func (AppModuleBasic) RegisterGRPCGatewayRoutes(clientCtx client.Context, mux *runtime.ServeMux) { + err := types.RegisterQueryHandlerClient(context.Background(), mux, types.NewQueryClient(clientCtx)) + if err != nil { + panic(err) + } +} + +// GetTxCmd returns the root Tx command for the module. The subcommands of this root command are used by end-users to generate new transactions containing messages defined in the module +func (a AppModuleBasic) GetTxCmd() *cobra.Command { + return nil +} + +// GetQueryCmd returns the root query command for the module. The subcommands of this root command are used by end-users to generate new queries to the subset of the state defined by the module +func (AppModuleBasic) GetQueryCmd() *cobra.Command { + return nil +} + +// ---------------------------------------------------------------------------- +// AppModule +// ---------------------------------------------------------------------------- + +// AppModule implements the AppModule interface that defines the inter-dependent methods that modules need to implement +type AppModule struct { + AppModuleBasic + + keeper keeper.Keeper + accountKeeper types.AccountKeeper + bankKeeper types.BankKeeper + epochKeeper types.EpochKeeper + gammKeeper types.GAMMKeeper +} + +func NewAppModule( + cdc codec.Codec, + keeper keeper.Keeper, + accountKeeper types.AccountKeeper, + bankKeeper types.BankKeeper, + epochKeeper types.EpochKeeper, + gammKeeper types.GAMMKeeper, +) AppModule { + return AppModule{ + AppModuleBasic: NewAppModuleBasic(cdc), + keeper: keeper, + accountKeeper: accountKeeper, + bankKeeper: bankKeeper, + epochKeeper: epochKeeper, + gammKeeper: gammKeeper, + } +} + +// Deprecated: use RegisterServices +func (am AppModule) Route() sdk.Route { return sdk.Route{} } + +// Deprecated: use RegisterServices +func (AppModule) QuerierRoute() string { return types.RouterKey } + +// Deprecated: use RegisterServices +func (am AppModule) LegacyQuerierHandler(_ *codec.LegacyAmino) sdk.Querier { + return func(sdk.Context, []string, abci.RequestQuery) ([]byte, error) { + return nil, fmt.Errorf("legacy querier not supported for the x/%s module", types.ModuleName) + } +} + +// RegisterServices registers a gRPC query service to respond to the module-specific gRPC queries +func (am AppModule) RegisterServices(cfg module.Configurator) { +} + +func (a AppModuleBasic) RegisterRESTRoutes(ctx client.Context, r *mux.Router) { +} + +// RegisterInvariants registers the invariants of the module. If an invariant deviates from its predicted value, the InvariantRegistry triggers appropriate logic (most often the chain will be halted) +func (am AppModule) RegisterInvariants(_ sdk.InvariantRegistry) {} + +// InitGenesis performs the module's genesis initialization. It returns no validator updates. +func (am AppModule) InitGenesis(ctx sdk.Context, cdc codec.JSONCodec, gs json.RawMessage) []abci.ValidatorUpdate { + var genState types.GenesisState + // Initialize global index to index in genesis state + cdc.MustUnmarshalJSON(gs, &genState) + + InitGenesis(ctx, am.keeper, genState) + + return []abci.ValidatorUpdate{} +} + +// ExportGenesis returns the module's exported genesis state as raw JSON bytes. +func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONCodec) json.RawMessage { + genState := ExportGenesis(ctx, am.keeper) + return cdc.MustMarshalJSON(genState) +} + +// ConsensusVersion is a sequence number for state-breaking change of the module. It should be incremented on each consensus-breaking change introduced by the module. To avoid wrong/empty versions, the initial version should be set to 1 +func (AppModule) ConsensusVersion() uint64 { return 1 } + +// BeginBlock contains the logic that is automatically triggered at the beginning of each block +func (am AppModule) BeginBlock(_ sdk.Context, _ abci.RequestBeginBlock) {} + +// EndBlock contains the logic that is automatically triggered at the end of each block +func (am AppModule) EndBlock(_ sdk.Context, _ abci.RequestEndBlock) []abci.ValidatorUpdate { + return []abci.ValidatorUpdate{} +} diff --git a/x/protorev/types/codec.go b/x/protorev/types/codec.go new file mode 100644 index 00000000000..70ec5ad53d5 --- /dev/null +++ b/x/protorev/types/codec.go @@ -0,0 +1,44 @@ +package types + +import ( + "github.com/cosmos/cosmos-sdk/codec" + cdctypes "github.com/cosmos/cosmos-sdk/codec/types" + sdk "github.com/cosmos/cosmos-sdk/types" + govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" + + "github.com/cosmos/cosmos-sdk/types/msgservice" +) + +var ( + amino = codec.NewLegacyAmino() + ModuleCdc = codec.NewProtoCodec(cdctypes.NewInterfaceRegistry()) +) + +const ( + setHotRoutes = "osmosis/MsgSetHotRoutes" + setDeveloperAccount = "osmosis/MsgSetDeveloperAccount" +) + +func init() { + RegisterCodec(amino) + amino.Seal() +} + +func RegisterCodec(cdc *codec.LegacyAmino) { + cdc.RegisterConcrete(&MsgSetHotRoutes{}, setHotRoutes, nil) + cdc.RegisterConcrete(&MsgSetDeveloperAccount{}, setDeveloperAccount, nil) +} + +func RegisterInterfaces(registry cdctypes.InterfaceRegistry) { + registry.RegisterImplementations((*sdk.Msg)(nil), + &MsgSetHotRoutes{}, + &MsgSetDeveloperAccount{}, + ) + registry.RegisterImplementations( + (*govtypes.Content)(nil), + &SetProtoRevEnabledProposal{}, + &SetProtoRevAdminAccountProposal{}, + ) + + msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc) +} diff --git a/x/protorev/types/expected_keepers.go b/x/protorev/types/expected_keepers.go new file mode 100644 index 00000000000..7f08e72bbac --- /dev/null +++ b/x/protorev/types/expected_keepers.go @@ -0,0 +1,38 @@ +package types + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + + epochtypes "github.com/osmosis-labs/osmosis/v13/x/epochs/types" + gammtypes "github.com/osmosis-labs/osmosis/v13/x/gamm/types" +) + +// AccountKeeper defines the account contract that must be fulfilled when +// creating a x/protorev keeper. +type AccountKeeper interface { + GetModuleAddress(moduleName string) sdk.AccAddress +} + +// BankKeeper defines the banking contract that must be fulfilled when +// creating a x/protorev keeper. +type BankKeeper interface { + SendCoinsFromModuleToAccount(ctx sdk.Context, senderModule string, recipientAddr sdk.AccAddress, amt sdk.Coins) error + MintCoins(ctx sdk.Context, moduleName string, amt sdk.Coins) error + BurnCoins(ctx sdk.Context, name string, amt sdk.Coins) error +} + +// GAMMKeeper defines the Gamm contract that must be fulfilled when +// creating a x/protorev keeper. +type GAMMKeeper interface { + GetPoolAndPoke(ctx sdk.Context, poolId uint64) (gammtypes.PoolI, error) + GetPoolsAndPoke(ctx sdk.Context) (res []gammtypes.PoolI, err error) + GetPoolDenoms(ctx sdk.Context, poolId uint64) ([]string, error) + SwapExactAmountIn(ctx sdk.Context, sender sdk.AccAddress, poolId uint64, tokenIn sdk.Coin, tokenOutDenom string, tokenOutMinAmount sdk.Int) (sdk.Int, error) + MultihopSwapExactAmountIn(ctx sdk.Context, sender sdk.AccAddress, routes []gammtypes.SwapAmountInRoute, tokenIn sdk.Coin, tokenOutMinAmount sdk.Int) (tokenOutAmount sdk.Int, err error) +} + +// EpochKeeper defines the Epoch contract that must be fulfilled when +// creating a x/protorev keeper. +type EpochKeeper interface { + GetEpochInfo(ctx sdk.Context, identifier string) epochtypes.EpochInfo +} diff --git a/x/protorev/types/genesis.go b/x/protorev/types/genesis.go new file mode 100644 index 00000000000..5eef2806f28 --- /dev/null +++ b/x/protorev/types/genesis.go @@ -0,0 +1,74 @@ +package types + +import ( + "fmt" + + sdk "github.com/cosmos/cosmos-sdk/types" +) + +// InputAmountList contains a list of input amounts to test when creating the optimal amount to swap in the +// binary search method +var InputAmountList []sdk.Int + +// AtomDenomination stores the native denom name for Atom on chain used for route building +var AtomDenomination string = "ibc/27394FB092D2ECCD56123C74F36E4C1F926001CEADA9CA97EA622B25F41E5EB2" + +// OsmosisDenomination stores the native denom name for Osmosis on chain used for route building +var OsmosisDenomination string = "uosmo" + +type TokenPair struct { + TokenA string + TokenB string +} + +// DefaultGenesis returns the default genesis state +func DefaultGenesis() *GenesisState { + return &GenesisState{ + Params: DefaultParams(), + TokenPairs: []TokenPairArbRoutes{}, + } +} + +// Validate performs basic genesis state validation returning an error upon any failure. +func (gs GenesisState) Validate() error { + // Validate entered routes + if err := gs.CheckRoutes(); err != nil { + return err + } + + return gs.Params.Validate() +} + +func init() { + // Init all of the input amounts + InputAmountList = make([]sdk.Int, 0) + for i := 0; i < 1000000000; i += 100000 { + InputAmountList = append(InputAmountList, sdk.NewInt(int64(i))) + } +} + +// Routes entered into the genesis state must start and end with the same denomination and +// the denomination must be Osmo or Atom. Additionally, there cannot be duplicate routes (same +// token pairs). +func (gs GenesisState) CheckRoutes() error { + seenTokenPairs := make(map[TokenPair]bool) + for _, tokenPairArbRoutes := range gs.TokenPairs { + // Validate the arb routes + if err := tokenPairArbRoutes.Validate(); err != nil { + return err + } + + tokenPair := TokenPair{ + TokenA: tokenPairArbRoutes.TokenIn, + TokenB: tokenPairArbRoutes.TokenOut, + } + // Validate that the token pair is unique + if _, ok := seenTokenPairs[tokenPair]; ok { + return fmt.Errorf("duplicate token pair: %s", tokenPair) + } + + seenTokenPairs[tokenPair] = true + } + + return nil +} diff --git a/x/protorev/types/genesis.pb.go b/x/protorev/types/genesis.pb.go new file mode 100644 index 00000000000..bcc6b882250 --- /dev/null +++ b/x/protorev/types/genesis.pb.go @@ -0,0 +1,391 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: osmosis/protorev/v1beta1/genesis.proto + +package types + +import ( + fmt "fmt" + _ "github.com/gogo/protobuf/gogoproto" + proto "github.com/gogo/protobuf/proto" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +// GenesisState defines the protorev module's genesis state. +type GenesisState struct { + // Module Parameters + Params Params `protobuf:"bytes,1,opt,name=params,proto3" json:"params"` + // Hot routes that are configured on genesis + TokenPairs []TokenPairArbRoutes `protobuf:"bytes,2,rep,name=token_pairs,json=tokenPairs,proto3" json:"token_pairs"` +} + +func (m *GenesisState) Reset() { *m = GenesisState{} } +func (m *GenesisState) String() string { return proto.CompactTextString(m) } +func (*GenesisState) ProtoMessage() {} +func (*GenesisState) Descriptor() ([]byte, []int) { + return fileDescriptor_3c77fc2da5752af2, []int{0} +} +func (m *GenesisState) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *GenesisState) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_GenesisState.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *GenesisState) XXX_Merge(src proto.Message) { + xxx_messageInfo_GenesisState.Merge(m, src) +} +func (m *GenesisState) XXX_Size() int { + return m.Size() +} +func (m *GenesisState) XXX_DiscardUnknown() { + xxx_messageInfo_GenesisState.DiscardUnknown(m) +} + +var xxx_messageInfo_GenesisState proto.InternalMessageInfo + +func (m *GenesisState) GetParams() Params { + if m != nil { + return m.Params + } + return Params{} +} + +func (m *GenesisState) GetTokenPairs() []TokenPairArbRoutes { + if m != nil { + return m.TokenPairs + } + return nil +} + +func init() { + proto.RegisterType((*GenesisState)(nil), "osmosis.protorev.v1beta1.GenesisState") +} + +func init() { + proto.RegisterFile("osmosis/protorev/v1beta1/genesis.proto", fileDescriptor_3c77fc2da5752af2) +} + +var fileDescriptor_3c77fc2da5752af2 = []byte{ + // 260 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x52, 0xcb, 0x2f, 0xce, 0xcd, + 0x2f, 0xce, 0x2c, 0xd6, 0x2f, 0x28, 0xca, 0x2f, 0xc9, 0x2f, 0x4a, 0x2d, 0xd3, 0x2f, 0x33, 0x4c, + 0x4a, 0x2d, 0x49, 0x34, 0xd4, 0x4f, 0x4f, 0xcd, 0x4b, 0x2d, 0xce, 0x2c, 0xd6, 0x03, 0x4b, 0x08, + 0x49, 0x40, 0xd5, 0xe9, 0xc1, 0xd4, 0xe9, 0x41, 0xd5, 0x49, 0x89, 0xa4, 0xe7, 0xa7, 0xe7, 0x83, + 0x45, 0xf5, 0x41, 0x2c, 0x88, 0x02, 0x29, 0x75, 0x9c, 0xe6, 0xc2, 0x0d, 0x80, 0x28, 0x54, 0xc5, + 0xad, 0x30, 0xb1, 0x28, 0x31, 0x17, 0x6a, 0xa1, 0xd2, 0x62, 0x46, 0x2e, 0x1e, 0x77, 0x88, 0x8b, + 0x82, 0x4b, 0x12, 0x4b, 0x52, 0x85, 0xec, 0xb8, 0xd8, 0x20, 0x0a, 0x24, 0x18, 0x15, 0x18, 0x35, + 0xb8, 0x8d, 0x14, 0xf4, 0x70, 0xb9, 0x50, 0x2f, 0x00, 0xac, 0xce, 0x89, 0xe5, 0xc4, 0x3d, 0x79, + 0x86, 0x20, 0xa8, 0x2e, 0xa1, 0x60, 0x2e, 0xee, 0x92, 0xfc, 0xec, 0xd4, 0xbc, 0xf8, 0x82, 0xc4, + 0xcc, 0xa2, 0x62, 0x09, 0x26, 0x05, 0x66, 0x0d, 0x6e, 0x23, 0x1d, 0xdc, 0x86, 0x84, 0x80, 0x14, + 0x07, 0x24, 0x66, 0x16, 0x39, 0x16, 0x25, 0x05, 0xe5, 0x97, 0x96, 0xa4, 0xc2, 0x0c, 0xe4, 0x2a, + 0x81, 0xc9, 0x14, 0x3b, 0xf9, 0x9d, 0x78, 0x24, 0xc7, 0x78, 0xe1, 0x91, 0x1c, 0xe3, 0x83, 0x47, + 0x72, 0x8c, 0x13, 0x1e, 0xcb, 0x31, 0x5c, 0x78, 0x2c, 0xc7, 0x70, 0xe3, 0xb1, 0x1c, 0x43, 0x94, + 0x49, 0x7a, 0x66, 0x49, 0x46, 0x69, 0x92, 0x5e, 0x72, 0x7e, 0xae, 0x3e, 0xd4, 0x0e, 0xdd, 0x9c, + 0xc4, 0xa4, 0x62, 0x18, 0x47, 0xbf, 0xcc, 0xd0, 0x58, 0xbf, 0x02, 0x11, 0x08, 0x25, 0x95, 0x05, + 0xa9, 0xc5, 0x49, 0x6c, 0x60, 0xbe, 0x31, 0x20, 0x00, 0x00, 0xff, 0xff, 0x90, 0xb9, 0x5f, 0x13, + 0xa6, 0x01, 0x00, 0x00, +} + +func (m *GenesisState) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *GenesisState) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.TokenPairs) > 0 { + for iNdEx := len(m.TokenPairs) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.TokenPairs[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + } + { + size, err := m.Params.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + return len(dAtA) - i, nil +} + +func encodeVarintGenesis(dAtA []byte, offset int, v uint64) int { + offset -= sovGenesis(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *GenesisState) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.Params.Size() + n += 1 + l + sovGenesis(uint64(l)) + if len(m.TokenPairs) > 0 { + for _, e := range m.TokenPairs { + l = e.Size() + n += 1 + l + sovGenesis(uint64(l)) + } + } + return n +} + +func sovGenesis(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozGenesis(x uint64) (n int) { + return sovGenesis(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *GenesisState) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: GenesisState: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: GenesisState: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Params", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthGenesis + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Params.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field TokenPairs", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthGenesis + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.TokenPairs = append(m.TokenPairs, TokenPairArbRoutes{}) + if err := m.TokenPairs[len(m.TokenPairs)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipGenesis(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthGenesis + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipGenesis(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowGenesis + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowGenesis + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowGenesis + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthGenesis + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupGenesis + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthGenesis + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthGenesis = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowGenesis = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupGenesis = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/protorev/types/genesis_test.go b/x/protorev/types/genesis_test.go new file mode 100644 index 00000000000..363a2ddf918 --- /dev/null +++ b/x/protorev/types/genesis_test.go @@ -0,0 +1,93 @@ +package types_test + +import ( + "testing" + + "github.com/stretchr/testify/require" + + "github.com/osmosis-labs/osmosis/v13/x/protorev/types" +) + +func TestGenesisStateValidate(t *testing.T) { + trade1 := types.NewTrade(1, "a", "b") + trade2 := types.NewTrade(2, "b", "c") + routes := types.NewRoutes([]*types.Trade{&trade1, &trade2}) + + invalidSearchRoutes := []types.TokenPairArbRoutes{ + types.NewTokenPairArbRoutes([]*types.Route{&routes}, "a", "b"), + } + + cases := []struct { + description string + genState *types.GenesisState + valid bool + }{ + { + description: "Default parameters with no routes", + genState: &types.GenesisState{ + Params: types.DefaultParams(), + }, + valid: true, + }, + { + description: "Default parameters with valid routes", + genState: &types.GenesisState{ + Params: types.DefaultParams(), + TokenPairs: []types.TokenPairArbRoutes{types.CreateSeacherRoutes(3, types.OsmosisDenomination, "ethereum", types.AtomDenomination, types.AtomDenomination)}, + }, + valid: true, + }, + { + description: "Default parameters with invalid routes (duplicate token pairs)", + genState: &types.GenesisState{ + Params: types.DefaultParams(), + TokenPairs: []types.TokenPairArbRoutes{types.CreateSeacherRoutes(3, types.OsmosisDenomination, "ethereum", types.AtomDenomination, types.AtomDenomination), types.CreateSeacherRoutes(3, types.OsmosisDenomination, "ethereum", types.AtomDenomination, types.AtomDenomination)}, + }, + valid: false, + }, + { + description: "Default parameters with nil routes", + genState: &types.GenesisState{ + Params: types.DefaultParams(), + TokenPairs: []types.TokenPairArbRoutes{types.NewTokenPairArbRoutes(nil, "a", "b")}, + }, + valid: false, + }, + { + description: "Default parameters with invalid routes (4 pool route)", + genState: &types.GenesisState{ + Params: types.DefaultParams(), + TokenPairs: invalidSearchRoutes, + }, + valid: false, + }, + { + description: "Default parameters with invalid routes (mismatch in and out denoms)", + genState: &types.GenesisState{ + Params: types.DefaultParams(), + TokenPairs: []types.TokenPairArbRoutes{types.CreateSeacherRoutes(3, types.OsmosisDenomination, "ethereum", types.AtomDenomination, types.OsmosisDenomination)}, + }, + valid: false, + }, + { + description: "Default parameters with invalid routes (invalid in arb denom)", + genState: &types.GenesisState{ + Params: types.DefaultParams(), + TokenPairs: []types.TokenPairArbRoutes{types.CreateSeacherRoutes(3, types.OsmosisDenomination, "ethereum", "juno", "juno")}, + }, + valid: false, + }, + } + + for _, tc := range cases { + t.Run(tc.description, func(t *testing.T) { + err := tc.genState.Validate() + + if tc.valid { + require.NoError(t, err) + } else { + require.Error(t, err) + } + }) + } +} diff --git a/x/protorev/types/gov.go b/x/protorev/types/gov.go new file mode 100644 index 00000000000..1083ea653a8 --- /dev/null +++ b/x/protorev/types/gov.go @@ -0,0 +1,91 @@ +package types + +import ( + fmt "fmt" + + sdk "github.com/cosmos/cosmos-sdk/types" + + govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" +) + +const ( + ProposalTypeSetProtoRevEnabled = "SetProtoRevEnabledProposal" + ProposalTypeSetProtoRevAdminAccount = "SetProtoRevAdminAccountProposal" +) + +func init() { + govtypes.RegisterProposalType(ProposalTypeSetProtoRevEnabled) + govtypes.RegisterProposalTypeCodec(&SetProtoRevEnabledProposal{}, "osmosis/SetProtoRevEnabledProposal") + govtypes.RegisterProposalType(ProposalTypeSetProtoRevAdminAccount) + govtypes.RegisterProposalTypeCodec(&SetProtoRevAdminAccountProposal{}, "osmosis/SetProtoRevAdminAccountProposal") +} + +var ( + _ govtypes.Content = &SetProtoRevEnabledProposal{} + _ govtypes.Content = &SetProtoRevAdminAccountProposal{} +) + +// ---------------- Interface for SetProtoRevEnabledProposal ---------------- // +func NewSetProtoRevEnabledProposal(title, description string, enabled bool) govtypes.Content { + return &SetProtoRevEnabledProposal{title, description, enabled} +} + +func (p *SetProtoRevEnabledProposal) GetTitle() string { return p.Title } + +func (p *SetProtoRevEnabledProposal) GetDescription() string { return p.Description } + +func (p *SetProtoRevEnabledProposal) ProposalRoute() string { return RouterKey } + +func (p *SetProtoRevEnabledProposal) ProposalType() string { + return ProposalTypeSetProtoRevEnabled +} + +func (p *SetProtoRevEnabledProposal) ValidateBasic() error { + err := govtypes.ValidateAbstract(p) + if err != nil { + return err + } + + return ValidateBoolean(p.Enabled) +} + +func (p SetProtoRevEnabledProposal) String() string { + return fmt.Sprintf(`Set ProtoRev Enabled Proposal: + Title: %s + Description: %s + ProtoRev Enabled: %+v + `, p.Title, p.Description, p.Enabled) +} + +// ---------------- Interface for SetProtoRevAdminAccountProposal ---------------- // +func NewSetProtoRevAdminAccountProposal(title, description string, account string) govtypes.Content { + return &SetProtoRevAdminAccountProposal{title, description, account} +} + +func (p *SetProtoRevAdminAccountProposal) GetTitle() string { return p.Title } + +func (p *SetProtoRevAdminAccountProposal) GetDescription() string { return p.Description } + +func (p *SetProtoRevAdminAccountProposal) ProposalRoute() string { return RouterKey } + +func (p *SetProtoRevAdminAccountProposal) ProposalType() string { + return ProposalTypeSetProtoRevAdminAccount +} + +func (p *SetProtoRevAdminAccountProposal) ValidateBasic() error { + err := govtypes.ValidateAbstract(p) + if err != nil { + return err + } + + _, err = sdk.AccAddressFromBech32(p.Account) + return err +} + +func (p SetProtoRevAdminAccountProposal) String() string { + return fmt.Sprintf(`Set ProtoRev Admin Account Proposal: + Title: %s + Description: %s + ProtoRev Admin Account: %+v + `, p.Title, p.Description, p.Account) +} diff --git a/x/protorev/types/gov.pb.go b/x/protorev/types/gov.pb.go new file mode 100644 index 00000000000..77126f65a73 --- /dev/null +++ b/x/protorev/types/gov.pb.go @@ -0,0 +1,710 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: osmosis/protorev/v1beta1/gov.proto + +package types + +import ( + fmt "fmt" + _ "github.com/gogo/protobuf/gogoproto" + proto "github.com/gogo/protobuf/proto" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +// SetProtoRevEnabledProposal is a gov Content type to update whether the +// protorev module is enabled +type SetProtoRevEnabledProposal struct { + Title string `protobuf:"bytes,1,opt,name=title,proto3" json:"title,omitempty"` + Description string `protobuf:"bytes,2,opt,name=description,proto3" json:"description,omitempty"` + Enabled bool `protobuf:"varint,3,opt,name=enabled,proto3" json:"enabled,omitempty"` +} + +func (m *SetProtoRevEnabledProposal) Reset() { *m = SetProtoRevEnabledProposal{} } +func (*SetProtoRevEnabledProposal) ProtoMessage() {} +func (*SetProtoRevEnabledProposal) Descriptor() ([]byte, []int) { + return fileDescriptor_e1f85ff7f3eaf8bb, []int{0} +} +func (m *SetProtoRevEnabledProposal) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *SetProtoRevEnabledProposal) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_SetProtoRevEnabledProposal.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *SetProtoRevEnabledProposal) XXX_Merge(src proto.Message) { + xxx_messageInfo_SetProtoRevEnabledProposal.Merge(m, src) +} +func (m *SetProtoRevEnabledProposal) XXX_Size() int { + return m.Size() +} +func (m *SetProtoRevEnabledProposal) XXX_DiscardUnknown() { + xxx_messageInfo_SetProtoRevEnabledProposal.DiscardUnknown(m) +} + +var xxx_messageInfo_SetProtoRevEnabledProposal proto.InternalMessageInfo + +// SetProtoRevAdminAccountProposal is a gov Content type to set the admin +// account that will receive permissions to alter hot routes and set the +// developer address that will be receiving a share of profits from the module +type SetProtoRevAdminAccountProposal struct { + Title string `protobuf:"bytes,1,opt,name=title,proto3" json:"title,omitempty"` + Description string `protobuf:"bytes,2,opt,name=description,proto3" json:"description,omitempty"` + Account string `protobuf:"bytes,3,opt,name=account,proto3" json:"account,omitempty"` +} + +func (m *SetProtoRevAdminAccountProposal) Reset() { *m = SetProtoRevAdminAccountProposal{} } +func (*SetProtoRevAdminAccountProposal) ProtoMessage() {} +func (*SetProtoRevAdminAccountProposal) Descriptor() ([]byte, []int) { + return fileDescriptor_e1f85ff7f3eaf8bb, []int{1} +} +func (m *SetProtoRevAdminAccountProposal) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *SetProtoRevAdminAccountProposal) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_SetProtoRevAdminAccountProposal.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *SetProtoRevAdminAccountProposal) XXX_Merge(src proto.Message) { + xxx_messageInfo_SetProtoRevAdminAccountProposal.Merge(m, src) +} +func (m *SetProtoRevAdminAccountProposal) XXX_Size() int { + return m.Size() +} +func (m *SetProtoRevAdminAccountProposal) XXX_DiscardUnknown() { + xxx_messageInfo_SetProtoRevAdminAccountProposal.DiscardUnknown(m) +} + +var xxx_messageInfo_SetProtoRevAdminAccountProposal proto.InternalMessageInfo + +func init() { + proto.RegisterType((*SetProtoRevEnabledProposal)(nil), "osmosis.protorev.v1beta1.SetProtoRevEnabledProposal") + proto.RegisterType((*SetProtoRevAdminAccountProposal)(nil), "osmosis.protorev.v1beta1.SetProtoRevAdminAccountProposal") +} + +func init() { + proto.RegisterFile("osmosis/protorev/v1beta1/gov.proto", fileDescriptor_e1f85ff7f3eaf8bb) +} + +var fileDescriptor_e1f85ff7f3eaf8bb = []byte{ + // 286 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x52, 0xca, 0x2f, 0xce, 0xcd, + 0x2f, 0xce, 0x2c, 0xd6, 0x2f, 0x28, 0xca, 0x2f, 0xc9, 0x2f, 0x4a, 0x2d, 0xd3, 0x2f, 0x33, 0x4c, + 0x4a, 0x2d, 0x49, 0x34, 0xd4, 0x4f, 0xcf, 0x2f, 0xd3, 0x03, 0x0b, 0x0a, 0x49, 0x40, 0xd5, 0xe8, + 0xc1, 0xd4, 0xe8, 0x41, 0xd5, 0x48, 0x89, 0xa4, 0xe7, 0xa7, 0xe7, 0x83, 0x45, 0xf5, 0x41, 0x2c, + 0x88, 0x02, 0x29, 0x75, 0x9c, 0x66, 0xc2, 0x0d, 0x00, 0x33, 0x94, 0x6a, 0xb8, 0xa4, 0x82, 0x53, + 0x4b, 0x02, 0x40, 0xec, 0xa0, 0xd4, 0x32, 0xd7, 0xbc, 0xc4, 0xa4, 0x9c, 0xd4, 0x94, 0x80, 0xa2, + 0xfc, 0x82, 0xfc, 0xe2, 0xc4, 0x1c, 0x21, 0x11, 0x2e, 0xd6, 0x92, 0xcc, 0x92, 0x9c, 0x54, 0x09, + 0x46, 0x05, 0x46, 0x0d, 0xce, 0x20, 0x08, 0x47, 0x48, 0x81, 0x8b, 0x3b, 0x25, 0xb5, 0x38, 0xb9, + 0x28, 0xb3, 0xa0, 0x24, 0x33, 0x3f, 0x4f, 0x82, 0x09, 0x2c, 0x87, 0x2c, 0x24, 0x24, 0xc1, 0xc5, + 0x9e, 0x0a, 0x31, 0x4a, 0x82, 0x59, 0x81, 0x51, 0x83, 0x23, 0x08, 0xc6, 0xb5, 0xe2, 0xe9, 0x58, + 0x20, 0xcf, 0x30, 0x63, 0x81, 0x3c, 0xc3, 0x8b, 0x05, 0xf2, 0x8c, 0x4a, 0x8d, 0x8c, 0x5c, 0xf2, + 0x48, 0xd6, 0x3b, 0xa6, 0xe4, 0x66, 0xe6, 0x39, 0x26, 0x27, 0xe7, 0x97, 0xe6, 0x95, 0x50, 0xc3, + 0x0d, 0x89, 0x10, 0xa3, 0xc0, 0x6e, 0xe0, 0x0c, 0x82, 0x71, 0x51, 0xdd, 0xe0, 0xe4, 0x77, 0xe2, + 0x91, 0x1c, 0xe3, 0x85, 0x47, 0x72, 0x8c, 0x0f, 0x1e, 0xc9, 0x31, 0x4e, 0x78, 0x2c, 0xc7, 0x70, + 0xe1, 0xb1, 0x1c, 0xc3, 0x8d, 0xc7, 0x72, 0x0c, 0x51, 0x26, 0xe9, 0x99, 0x25, 0x19, 0xa5, 0x49, + 0x7a, 0xc9, 0xf9, 0xb9, 0xfa, 0xd0, 0xf0, 0xd4, 0xcd, 0x49, 0x4c, 0x2a, 0x86, 0x71, 0xf4, 0xcb, + 0x0c, 0x8d, 0xf5, 0x2b, 0x10, 0x41, 0x5c, 0x52, 0x59, 0x90, 0x5a, 0x9c, 0xc4, 0x06, 0xe6, 0x1b, + 0x03, 0x02, 0x00, 0x00, 0xff, 0xff, 0xd2, 0x9d, 0x1b, 0x4a, 0xd7, 0x01, 0x00, 0x00, +} + +func (this *SetProtoRevEnabledProposal) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*SetProtoRevEnabledProposal) + if !ok { + that2, ok := that.(SetProtoRevEnabledProposal) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + if this.Title != that1.Title { + return false + } + if this.Description != that1.Description { + return false + } + if this.Enabled != that1.Enabled { + return false + } + return true +} +func (this *SetProtoRevAdminAccountProposal) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*SetProtoRevAdminAccountProposal) + if !ok { + that2, ok := that.(SetProtoRevAdminAccountProposal) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + if this.Title != that1.Title { + return false + } + if this.Description != that1.Description { + return false + } + if this.Account != that1.Account { + return false + } + return true +} +func (m *SetProtoRevEnabledProposal) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *SetProtoRevEnabledProposal) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *SetProtoRevEnabledProposal) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Enabled { + i-- + if m.Enabled { + dAtA[i] = 1 + } else { + dAtA[i] = 0 + } + i-- + dAtA[i] = 0x18 + } + if len(m.Description) > 0 { + i -= len(m.Description) + copy(dAtA[i:], m.Description) + i = encodeVarintGov(dAtA, i, uint64(len(m.Description))) + i-- + dAtA[i] = 0x12 + } + if len(m.Title) > 0 { + i -= len(m.Title) + copy(dAtA[i:], m.Title) + i = encodeVarintGov(dAtA, i, uint64(len(m.Title))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *SetProtoRevAdminAccountProposal) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *SetProtoRevAdminAccountProposal) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *SetProtoRevAdminAccountProposal) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Account) > 0 { + i -= len(m.Account) + copy(dAtA[i:], m.Account) + i = encodeVarintGov(dAtA, i, uint64(len(m.Account))) + i-- + dAtA[i] = 0x1a + } + if len(m.Description) > 0 { + i -= len(m.Description) + copy(dAtA[i:], m.Description) + i = encodeVarintGov(dAtA, i, uint64(len(m.Description))) + i-- + dAtA[i] = 0x12 + } + if len(m.Title) > 0 { + i -= len(m.Title) + copy(dAtA[i:], m.Title) + i = encodeVarintGov(dAtA, i, uint64(len(m.Title))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func encodeVarintGov(dAtA []byte, offset int, v uint64) int { + offset -= sovGov(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *SetProtoRevEnabledProposal) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Title) + if l > 0 { + n += 1 + l + sovGov(uint64(l)) + } + l = len(m.Description) + if l > 0 { + n += 1 + l + sovGov(uint64(l)) + } + if m.Enabled { + n += 2 + } + return n +} + +func (m *SetProtoRevAdminAccountProposal) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Title) + if l > 0 { + n += 1 + l + sovGov(uint64(l)) + } + l = len(m.Description) + if l > 0 { + n += 1 + l + sovGov(uint64(l)) + } + l = len(m.Account) + if l > 0 { + n += 1 + l + sovGov(uint64(l)) + } + return n +} + +func sovGov(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozGov(x uint64) (n int) { + return sovGov(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *SetProtoRevEnabledProposal) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGov + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: SetProtoRevEnabledProposal: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: SetProtoRevEnabledProposal: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Title", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGov + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthGov + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthGov + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Title = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Description", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGov + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthGov + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthGov + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Description = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Enabled", wireType) + } + var v int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGov + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.Enabled = bool(v != 0) + default: + iNdEx = preIndex + skippy, err := skipGov(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthGov + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *SetProtoRevAdminAccountProposal) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGov + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: SetProtoRevAdminAccountProposal: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: SetProtoRevAdminAccountProposal: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Title", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGov + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthGov + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthGov + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Title = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Description", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGov + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthGov + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthGov + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Description = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Account", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGov + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthGov + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthGov + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Account = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipGov(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthGov + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipGov(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowGov + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowGov + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowGov + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthGov + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupGov + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthGov + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthGov = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowGov = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupGov = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/protorev/types/gov_test.go b/x/protorev/types/gov_test.go new file mode 100644 index 00000000000..6ca130b3a7f --- /dev/null +++ b/x/protorev/types/gov_test.go @@ -0,0 +1,72 @@ +package types_test + +import ( + "testing" + + "github.com/stretchr/testify/suite" + + "github.com/osmosis-labs/osmosis/v13/app/apptesting" + "github.com/osmosis-labs/osmosis/v13/x/protorev/types" +) + +type GovTestSuite struct { + suite.Suite +} + +func TestGovTestSuite(t *testing.T) { + suite.Run(t, new(GovTestSuite)) +} + +func (suite *GovTestSuite) TestGovKeysTypes() { + suite.Require().Equal("SetProtoRevEnabledProposal", (&types.SetProtoRevEnabledProposal{}).ProposalType()) + suite.Require().Equal("SetProtoRevAdminAccountProposal", (&types.SetProtoRevAdminAccountProposal{}).ProposalType()) +} + +func (suite *GovTestSuite) TestEnableProposal() { + testCases := []struct { + description string + enabled bool + }{ + { + description: "enabled", + enabled: true, + }, + { + description: "disabled", + enabled: false, + }, + } + + for _, tc := range testCases { + proposal := types.NewSetProtoRevEnabledProposal("title", "description", tc.enabled) + suite.Require().Equal(tc.enabled, proposal.(*types.SetProtoRevEnabledProposal).Enabled) + } +} + +func (suite *GovTestSuite) TestAdminAccountProposal() { + testCases := []struct { + description string + address string + pass bool + }{ + { + description: "valid address", + address: apptesting.CreateRandomAccounts(1)[0].String(), + pass: true, + }, + { + description: "invalid address", + address: "invalid", + pass: false, + }, + } + + for _, tc := range testCases { + proposal := types.NewSetProtoRevAdminAccountProposal("title", "description", tc.address) + if tc.pass { + suite.Require().NoError(proposal.ValidateBasic()) + } else { + suite.Require().Error(proposal.ValidateBasic()) + } + } +} diff --git a/x/protorev/types/keys.go b/x/protorev/types/keys.go new file mode 100644 index 00000000000..4cb38539228 --- /dev/null +++ b/x/protorev/types/keys.go @@ -0,0 +1,12 @@ +package types + +const ( + // ModuleName defines the module name + ModuleName = "protorev" + + // StoreKey defines the primary module store key + StoreKey = ModuleName + + // RouterKey defines the module's message routing key + RouterKey = ModuleName +) diff --git a/x/protorev/types/msg.go b/x/protorev/types/msg.go new file mode 100644 index 00000000000..df65e6dd39c --- /dev/null +++ b/x/protorev/types/msg.go @@ -0,0 +1,126 @@ +package types + +import ( + "fmt" + + sdk "github.com/cosmos/cosmos-sdk/types" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" +) + +var ( + _ sdk.Msg = &MsgSetHotRoutes{} + _ sdk.Msg = &MsgSetDeveloperAccount{} +) + +const ( + TypeMsgSetHotRoutes = "set_hot_routes" + TypeMsgSetDeveloperAccount = "set_developer_account" +) + +// ---------------------- Interface for MsgSetHotRoutes ---------------------- // +// NewMsgSetHotRoutes creates a new MsgSetHotRoutes instance +func NewMsgSetHotRoutes(admin string, tokenPairArbRoutes []*TokenPairArbRoutes) *MsgSetHotRoutes { + return &MsgSetHotRoutes{ + Admin: admin, + HotRoutes: tokenPairArbRoutes, + } +} + +// Route returns the name of the module +func (msg MsgSetHotRoutes) Route() string { + return RouterKey +} + +// Type returns the type of the message +func (msg MsgSetHotRoutes) Type() string { + return TypeMsgSetHotRoutes +} + +// ValidateBasic validates the MsgSetHotRoutes +func (msg MsgSetHotRoutes) ValidateBasic() error { + // Account must be a valid bech32 address + _, err := sdk.AccAddressFromBech32(msg.Admin) + if err != nil { + return sdkerrors.Wrap(err, "invalid admin address (must be bech32)") + } + + // Each token pair arb route must be valid + seenTokenPairs := make(map[TokenPair]bool) + for _, tokenPairArbRoutes := range msg.HotRoutes { + // Validate the arb routes + if err := tokenPairArbRoutes.Validate(); err != nil { + return err + } + + tokenPair := TokenPair{ + TokenA: tokenPairArbRoutes.TokenIn, + TokenB: tokenPairArbRoutes.TokenOut, + } + // Validate that the token pair is unique + if _, ok := seenTokenPairs[tokenPair]; ok { + return fmt.Errorf("duplicate token pair: %s", tokenPair) + } + + seenTokenPairs[tokenPair] = true + } + + return nil +} + +// GetSignBytes encodes the message for signing +func (msg MsgSetHotRoutes) GetSignBytes() []byte { + return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&msg)) +} + +// GetSigners defines whose signature is required +func (msg MsgSetHotRoutes) GetSigners() []sdk.AccAddress { + addr := sdk.MustAccAddressFromBech32(msg.Admin) + return []sdk.AccAddress{addr} +} + +// ---------------------- Interface for MsgSetDeveloperAccount ---------------------- // +// NewMsgSetDeveloperAccount creates a new MsgSetDeveloperAccount instance +func NewMsgSetDeveloperAccount(admin string, developerAccount string) *MsgSetDeveloperAccount { + return &MsgSetDeveloperAccount{ + Admin: admin, + DeveloperAccount: developerAccount, + } +} + +// Route returns the name of the module +func (msg MsgSetDeveloperAccount) Route() string { + return RouterKey +} + +// Type returns the type of the message +func (msg MsgSetDeveloperAccount) Type() string { + return TypeMsgSetDeveloperAccount +} + +// ValidateBasic validates the MsgSetDeveloperAccount +func (msg MsgSetDeveloperAccount) ValidateBasic() error { + // Account must be a valid bech32 address + _, err := sdk.AccAddressFromBech32(msg.Admin) + if err != nil { + return sdkerrors.Wrap(err, "invalid admin address (must be bech32)") + } + + // Account must be a valid bech32 address + _, err = sdk.AccAddressFromBech32(msg.DeveloperAccount) + if err != nil { + return sdkerrors.Wrap(err, "invalid developer account address (must be bech32)") + } + + return nil +} + +// GetSignBytes encodes the message for signing +func (msg MsgSetDeveloperAccount) GetSignBytes() []byte { + return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&msg)) +} + +// GetSigners defines whose signature is required +func (msg MsgSetDeveloperAccount) GetSigners() []sdk.AccAddress { + addr := sdk.MustAccAddressFromBech32(msg.Admin) + return []sdk.AccAddress{addr} +} diff --git a/x/protorev/types/msg_test.go b/x/protorev/types/msg_test.go new file mode 100644 index 00000000000..188e778d82d --- /dev/null +++ b/x/protorev/types/msg_test.go @@ -0,0 +1,136 @@ +package types_test + +import ( + "testing" + + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/stretchr/testify/suite" + "github.com/tendermint/tendermint/crypto/ed25519" + + "github.com/osmosis-labs/osmosis/v13/x/protorev/types" +) + +type MsgsTestSuite struct { + suite.Suite +} + +func TestMsgsTestSuite(t *testing.T) { + suite.Run(t, new(MsgsTestSuite)) +} + +func (suite *MsgsTestSuite) TestMsgSetHotRoutes() { + validArbRoutes := types.CreateSeacherRoutes(3, types.OsmosisDenomination, "ethereum", types.AtomDenomination, types.AtomDenomination) + + notThreePoolArbRoutes := types.CreateSeacherRoutes(3, types.OsmosisDenomination, "ethereum", types.AtomDenomination, types.AtomDenomination) + extraTrade := types.NewTrade(100000, "a", "b") + notThreePoolArbRoutes.ArbRoutes = append(notThreePoolArbRoutes.ArbRoutes, &types.Route{[]*types.Trade{&extraTrade}}) + + invalidArbDenoms := types.CreateSeacherRoutes(3, types.OsmosisDenomination, "ethereum", "juno", "juno") + mismatchedDenoms := types.CreateSeacherRoutes(3, types.OsmosisDenomination, "ethereum", types.AtomDenomination, types.OsmosisDenomination) + cases := []struct { + description string + admin string + hotRoutes []*types.TokenPairArbRoutes + pass bool + }{ + { + "Invalid message (invalid admin)", + "admin", + []*types.TokenPairArbRoutes{}, + false, + }, + { + "Valid message (no arb routes)", + createAccount().String(), + []*types.TokenPairArbRoutes{}, + true, + }, + { + "Valid message (with arb routes)", + createAccount().String(), + []*types.TokenPairArbRoutes{&validArbRoutes}, + true, + }, + { + "Invalid message (with duplicate arb routes)", + createAccount().String(), + []*types.TokenPairArbRoutes{&validArbRoutes, &validArbRoutes}, + false, + }, + { + "Invalid message (with invalid arb routes)", + createAccount().String(), + []*types.TokenPairArbRoutes{¬ThreePoolArbRoutes}, + false, + }, + { + "Invalid message (with invalid arb denoms)", + createAccount().String(), + []*types.TokenPairArbRoutes{&invalidArbDenoms}, + false, + }, + { + "Invalid message (with mismatched arb denoms)", + createAccount().String(), + []*types.TokenPairArbRoutes{&mismatchedDenoms}, + false, + }, + } + + for _, tc := range cases { + suite.Run(tc.description, func() { + msg := types.NewMsgSetHotRoutes(tc.admin, tc.hotRoutes) + err := msg.ValidateBasic() + if tc.pass { + suite.Require().NoError(err) + } else { + suite.Require().Error(err) + } + }) + } +} + +func (suite *MsgsTestSuite) TestMsgSetDeveloperAccount() { + cases := []struct { + description string + admin string + developer string + pass bool + }{ + { + "Invalid message (invalid admin)", + "admin", + createAccount().String(), + false, + }, + { + "Invalid message (invalid developer)", + createAccount().String(), + "developer", + false, + }, + { + "Valid message", + createAccount().String(), + createAccount().String(), + true, + }, + } + + for _, tc := range cases { + suite.Run(tc.description, func() { + msg := types.NewMsgSetDeveloperAccount(tc.admin, tc.developer) + err := msg.ValidateBasic() + if tc.pass { + suite.Require().NoError(err) + } else { + suite.Require().Error(err) + } + }) + } +} + +func createAccount() sdk.AccAddress { + pk := ed25519.GenPrivKey().PubKey() + return sdk.AccAddress(pk.Address()) +} diff --git a/x/protorev/types/params.go b/x/protorev/types/params.go new file mode 100644 index 00000000000..73cd8596f9d --- /dev/null +++ b/x/protorev/types/params.go @@ -0,0 +1,50 @@ +package types + +import ( + "fmt" + + paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" +) + +var ( + DefaultEnableModule = true + + ParamStoreKeyEnableModule = []byte("EnableProtoRevModule") +) + +// ParamKeyTable the param key table for launch module +func ParamKeyTable() paramtypes.KeyTable { + return paramtypes.NewKeyTable().RegisterParamSet(&Params{}) +} + +// NewParams creates a new Params instance +func NewParams(enable bool) Params { + return Params{ + Enabled: enable, + } +} + +// DefaultParams returns a default set of parameters +func DefaultParams() Params { + return NewParams(DefaultEnableModule) +} + +// ParamSetPairs get the params.ParamSet +func (p *Params) ParamSetPairs() paramtypes.ParamSetPairs { + return paramtypes.ParamSetPairs{ + paramtypes.NewParamSetPair(ParamStoreKeyEnableModule, &p.Enabled, ValidateBoolean), + } +} + +// Validate validates the set of params +func (p Params) Validate() error { + return nil +} + +func ValidateBoolean(i interface{}) error { + _, ok := i.(bool) + if !ok { + return fmt.Errorf("invalid parameter type: %T", i) + } + return nil +} diff --git a/x/protorev/types/params.pb.go b/x/protorev/types/params.pb.go new file mode 100644 index 00000000000..8c840bf8294 --- /dev/null +++ b/x/protorev/types/params.pb.go @@ -0,0 +1,311 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: osmosis/protorev/v1beta1/params.proto + +package types + +import ( + fmt "fmt" + _ "github.com/gogo/protobuf/gogoproto" + proto "github.com/gogo/protobuf/proto" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +// Params defines the parameters for the module. +type Params struct { + // Boolean whether the module is going to be enabled + Enabled bool `protobuf:"varint,1,opt,name=enabled,proto3" json:"enabled,omitempty"` +} + +func (m *Params) Reset() { *m = Params{} } +func (m *Params) String() string { return proto.CompactTextString(m) } +func (*Params) ProtoMessage() {} +func (*Params) Descriptor() ([]byte, []int) { + return fileDescriptor_72168e5a5a65ae7e, []int{0} +} +func (m *Params) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *Params) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_Params.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *Params) XXX_Merge(src proto.Message) { + xxx_messageInfo_Params.Merge(m, src) +} +func (m *Params) XXX_Size() int { + return m.Size() +} +func (m *Params) XXX_DiscardUnknown() { + xxx_messageInfo_Params.DiscardUnknown(m) +} + +var xxx_messageInfo_Params proto.InternalMessageInfo + +func (m *Params) GetEnabled() bool { + if m != nil { + return m.Enabled + } + return false +} + +func init() { + proto.RegisterType((*Params)(nil), "osmosis.protorev.v1beta1.Params") +} + +func init() { + proto.RegisterFile("osmosis/protorev/v1beta1/params.proto", fileDescriptor_72168e5a5a65ae7e) +} + +var fileDescriptor_72168e5a5a65ae7e = []byte{ + // 177 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x52, 0xcd, 0x2f, 0xce, 0xcd, + 0x2f, 0xce, 0x2c, 0xd6, 0x2f, 0x28, 0xca, 0x2f, 0xc9, 0x2f, 0x4a, 0x2d, 0xd3, 0x2f, 0x33, 0x4c, + 0x4a, 0x2d, 0x49, 0x34, 0xd4, 0x2f, 0x48, 0x2c, 0x4a, 0xcc, 0x2d, 0xd6, 0x03, 0x8b, 0x0b, 0x49, + 0x40, 0x95, 0xe9, 0xc1, 0x94, 0xe9, 0x41, 0x95, 0x49, 0x89, 0xa4, 0xe7, 0xa7, 0xe7, 0x83, 0x45, + 0xf5, 0x41, 0x2c, 0x88, 0x02, 0x25, 0x25, 0x2e, 0xb6, 0x00, 0xb0, 0x7e, 0x21, 0x09, 0x2e, 0xf6, + 0xd4, 0xbc, 0xc4, 0xa4, 0x9c, 0xd4, 0x14, 0x09, 0x46, 0x05, 0x46, 0x0d, 0x8e, 0x20, 0x18, 0xd7, + 0xc9, 0xef, 0xc4, 0x23, 0x39, 0xc6, 0x0b, 0x8f, 0xe4, 0x18, 0x1f, 0x3c, 0x92, 0x63, 0x9c, 0xf0, + 0x58, 0x8e, 0xe1, 0xc2, 0x63, 0x39, 0x86, 0x1b, 0x8f, 0xe5, 0x18, 0xa2, 0x4c, 0xd2, 0x33, 0x4b, + 0x32, 0x4a, 0x93, 0xf4, 0x92, 0xf3, 0x73, 0xf5, 0xa1, 0x16, 0xeb, 0xe6, 0x24, 0x26, 0x15, 0xc3, + 0x38, 0xfa, 0x65, 0x86, 0xc6, 0xfa, 0x15, 0x08, 0x27, 0x97, 0x54, 0x16, 0xa4, 0x16, 0x27, 0xb1, + 0x81, 0xf9, 0xc6, 0x80, 0x00, 0x00, 0x00, 0xff, 0xff, 0x4c, 0x45, 0xbb, 0x7a, 0xd3, 0x00, 0x00, + 0x00, +} + +func (m *Params) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *Params) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *Params) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Enabled { + i-- + if m.Enabled { + dAtA[i] = 1 + } else { + dAtA[i] = 0 + } + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func encodeVarintParams(dAtA []byte, offset int, v uint64) int { + offset -= sovParams(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *Params) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Enabled { + n += 2 + } + return n +} + +func sovParams(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozParams(x uint64) (n int) { + return sovParams(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *Params) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowParams + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: Params: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Params: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Enabled", wireType) + } + var v int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowParams + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.Enabled = bool(v != 0) + default: + iNdEx = preIndex + skippy, err := skipParams(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthParams + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipParams(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowParams + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowParams + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowParams + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthParams + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupParams + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthParams + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthParams = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowParams = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupParams = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/protorev/types/protorev.pb.go b/x/protorev/types/protorev.pb.go new file mode 100644 index 00000000000..e65c06a072a --- /dev/null +++ b/x/protorev/types/protorev.pb.go @@ -0,0 +1,1261 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: osmosis/protorev/v1beta1/protorev.proto + +package types + +import ( + fmt "fmt" + _ "github.com/cosmos/cosmos-proto" + github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types" + types "github.com/cosmos/cosmos-sdk/types" + _ "github.com/gogo/protobuf/gogoproto" + proto "github.com/gogo/protobuf/proto" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +// TokenPairArbRoutes tracks all of the hot routes for a given pair of tokens +type TokenPairArbRoutes struct { + // Stores all of the possible hot paths for a given pair of tokens + ArbRoutes []*Route `protobuf:"bytes,1,rep,name=arb_routes,json=arbRoutes,proto3" json:"arb_routes,omitempty"` + // Token denomination of the first asset + TokenIn string `protobuf:"bytes,2,opt,name=token_in,json=tokenIn,proto3" json:"token_in,omitempty"` + // Token denomination of the second asset + TokenOut string `protobuf:"bytes,3,opt,name=token_out,json=tokenOut,proto3" json:"token_out,omitempty"` +} + +func (m *TokenPairArbRoutes) Reset() { *m = TokenPairArbRoutes{} } +func (m *TokenPairArbRoutes) String() string { return proto.CompactTextString(m) } +func (*TokenPairArbRoutes) ProtoMessage() {} +func (*TokenPairArbRoutes) Descriptor() ([]byte, []int) { + return fileDescriptor_1e9f2391fd9fec01, []int{0} +} +func (m *TokenPairArbRoutes) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *TokenPairArbRoutes) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_TokenPairArbRoutes.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *TokenPairArbRoutes) XXX_Merge(src proto.Message) { + xxx_messageInfo_TokenPairArbRoutes.Merge(m, src) +} +func (m *TokenPairArbRoutes) XXX_Size() int { + return m.Size() +} +func (m *TokenPairArbRoutes) XXX_DiscardUnknown() { + xxx_messageInfo_TokenPairArbRoutes.DiscardUnknown(m) +} + +var xxx_messageInfo_TokenPairArbRoutes proto.InternalMessageInfo + +func (m *TokenPairArbRoutes) GetArbRoutes() []*Route { + if m != nil { + return m.ArbRoutes + } + return nil +} + +func (m *TokenPairArbRoutes) GetTokenIn() string { + if m != nil { + return m.TokenIn + } + return "" +} + +func (m *TokenPairArbRoutes) GetTokenOut() string { + if m != nil { + return m.TokenOut + } + return "" +} + +// Route is a hot route for a given pair of tokens +type Route struct { + // The pool IDs that are travered in the directed cyclic graph (traversed left + // -> right) + Trades []*Trade `protobuf:"bytes,1,rep,name=trades,proto3" json:"trades,omitempty"` +} + +func (m *Route) Reset() { *m = Route{} } +func (m *Route) String() string { return proto.CompactTextString(m) } +func (*Route) ProtoMessage() {} +func (*Route) Descriptor() ([]byte, []int) { + return fileDescriptor_1e9f2391fd9fec01, []int{1} +} +func (m *Route) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *Route) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_Route.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *Route) XXX_Merge(src proto.Message) { + xxx_messageInfo_Route.Merge(m, src) +} +func (m *Route) XXX_Size() int { + return m.Size() +} +func (m *Route) XXX_DiscardUnknown() { + xxx_messageInfo_Route.DiscardUnknown(m) +} + +var xxx_messageInfo_Route proto.InternalMessageInfo + +func (m *Route) GetTrades() []*Trade { + if m != nil { + return m.Trades + } + return nil +} + +// Trade is a single trade in a route +type Trade struct { + // The pool IDs that are travered in the directed cyclic graph (traversed left + // -> right) + Pool uint64 `protobuf:"varint,1,opt,name=pool,proto3" json:"pool,omitempty"` + // The denom of token A that is traded + TokenIn string `protobuf:"bytes,2,opt,name=token_in,json=tokenIn,proto3" json:"token_in,omitempty"` + // The denom of token B that is traded + TokenOut string `protobuf:"bytes,3,opt,name=token_out,json=tokenOut,proto3" json:"token_out,omitempty"` +} + +func (m *Trade) Reset() { *m = Trade{} } +func (m *Trade) String() string { return proto.CompactTextString(m) } +func (*Trade) ProtoMessage() {} +func (*Trade) Descriptor() ([]byte, []int) { + return fileDescriptor_1e9f2391fd9fec01, []int{2} +} +func (m *Trade) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *Trade) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_Trade.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *Trade) XXX_Merge(src proto.Message) { + xxx_messageInfo_Trade.Merge(m, src) +} +func (m *Trade) XXX_Size() int { + return m.Size() +} +func (m *Trade) XXX_DiscardUnknown() { + xxx_messageInfo_Trade.DiscardUnknown(m) +} + +var xxx_messageInfo_Trade proto.InternalMessageInfo + +func (m *Trade) GetPool() uint64 { + if m != nil { + return m.Pool + } + return 0 +} + +func (m *Trade) GetTokenIn() string { + if m != nil { + return m.TokenIn + } + return "" +} + +func (m *Trade) GetTokenOut() string { + if m != nil { + return m.TokenOut + } + return "" +} + +// PoolStatistics contains the number of trades the module has executed after a +// swap on a given pool and the profits from the trades +type PoolStatistics struct { + // profits is the total profit from all trades on this pool + Profits []*types.Coin `protobuf:"bytes,1,rep,name=profits,proto3" json:"profits,omitempty"` + // number_of_trades is the number of trades the module has executed + NumberOfTrades github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,2,opt,name=number_of_trades,json=numberOfTrades,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"number_of_trades"` + // pool_id is the id of the pool + PoolId uint64 `protobuf:"varint,3,opt,name=pool_id,json=poolId,proto3" json:"pool_id,omitempty"` +} + +func (m *PoolStatistics) Reset() { *m = PoolStatistics{} } +func (m *PoolStatistics) String() string { return proto.CompactTextString(m) } +func (*PoolStatistics) ProtoMessage() {} +func (*PoolStatistics) Descriptor() ([]byte, []int) { + return fileDescriptor_1e9f2391fd9fec01, []int{3} +} +func (m *PoolStatistics) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *PoolStatistics) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_PoolStatistics.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *PoolStatistics) XXX_Merge(src proto.Message) { + xxx_messageInfo_PoolStatistics.Merge(m, src) +} +func (m *PoolStatistics) XXX_Size() int { + return m.Size() +} +func (m *PoolStatistics) XXX_DiscardUnknown() { + xxx_messageInfo_PoolStatistics.DiscardUnknown(m) +} + +var xxx_messageInfo_PoolStatistics proto.InternalMessageInfo + +func (m *PoolStatistics) GetProfits() []*types.Coin { + if m != nil { + return m.Profits + } + return nil +} + +func (m *PoolStatistics) GetPoolId() uint64 { + if m != nil { + return m.PoolId + } + return 0 +} + +func init() { + proto.RegisterType((*TokenPairArbRoutes)(nil), "osmosis.protorev.v1beta1.TokenPairArbRoutes") + proto.RegisterType((*Route)(nil), "osmosis.protorev.v1beta1.Route") + proto.RegisterType((*Trade)(nil), "osmosis.protorev.v1beta1.Trade") + proto.RegisterType((*PoolStatistics)(nil), "osmosis.protorev.v1beta1.PoolStatistics") +} + +func init() { + proto.RegisterFile("osmosis/protorev/v1beta1/protorev.proto", fileDescriptor_1e9f2391fd9fec01) +} + +var fileDescriptor_1e9f2391fd9fec01 = []byte{ + // 428 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x52, 0xcf, 0x8a, 0xd3, 0x40, + 0x18, 0xcf, 0xb8, 0xd9, 0xd6, 0x8e, 0xb0, 0xc8, 0x20, 0x98, 0xae, 0x90, 0x94, 0x3d, 0x68, 0x2f, + 0x3b, 0xa1, 0x56, 0x10, 0x3c, 0x08, 0xae, 0x20, 0xf4, 0xe2, 0x2e, 0xe3, 0x1e, 0xd4, 0x4b, 0x98, + 0x49, 0xd2, 0x3a, 0x6c, 0x9b, 0x2f, 0xcc, 0x4c, 0x8a, 0xbe, 0x85, 0xf8, 0x04, 0x3e, 0x86, 0x8f, + 0xb0, 0xc7, 0x3d, 0x8a, 0x87, 0x45, 0xda, 0x8b, 0x8f, 0x21, 0x99, 0x99, 0x46, 0x2f, 0x82, 0xb0, + 0xa7, 0x7c, 0xbf, 0x3f, 0xf3, 0x7d, 0xbf, 0x6f, 0x26, 0xf8, 0x11, 0xe8, 0x15, 0x68, 0xa9, 0xd3, + 0x5a, 0x81, 0x01, 0x55, 0xae, 0xd3, 0xf5, 0x44, 0x94, 0x86, 0x4f, 0x3a, 0x82, 0xda, 0x82, 0x44, + 0xde, 0x48, 0x3b, 0xde, 0x1b, 0x0f, 0x87, 0xb9, 0x95, 0x32, 0x2b, 0xa4, 0x0e, 0x38, 0xd7, 0xe1, + 0xbd, 0x05, 0x2c, 0xc0, 0xf1, 0x6d, 0xe5, 0xd9, 0xd8, 0x79, 0x52, 0xc1, 0x75, 0xd9, 0x8d, 0xcb, + 0x41, 0x56, 0x4e, 0x3f, 0xfa, 0x82, 0x30, 0x39, 0x87, 0x8b, 0xb2, 0x3a, 0xe3, 0x52, 0xbd, 0x50, + 0x82, 0x41, 0x63, 0x4a, 0x4d, 0x9e, 0x63, 0xcc, 0x95, 0xc8, 0x94, 0x45, 0x11, 0x1a, 0xed, 0x8d, + 0xef, 0x3c, 0x4e, 0xe8, 0xbf, 0x62, 0x51, 0x7b, 0x8a, 0x0d, 0x78, 0x77, 0x7e, 0x88, 0x6f, 0x9b, + 0xb6, 0x6b, 0x26, 0xab, 0xe8, 0xd6, 0x08, 0x8d, 0x07, 0xac, 0x6f, 0xf1, 0xac, 0x22, 0x0f, 0xf0, + 0xc0, 0x49, 0xd0, 0x98, 0x68, 0xcf, 0x6a, 0xce, 0x7b, 0xda, 0x98, 0x67, 0xe1, 0xaf, 0xaf, 0x09, + 0x3a, 0x7a, 0x85, 0xf7, 0x6d, 0x1f, 0xf2, 0x14, 0xf7, 0x8c, 0xe2, 0xc5, 0xff, 0x44, 0x38, 0x6f, + 0x7d, 0xcc, 0xdb, 0x7d, 0x9f, 0x77, 0x78, 0xdf, 0xd2, 0x84, 0xe0, 0xb0, 0x06, 0x58, 0x46, 0x68, + 0x84, 0xc6, 0x21, 0xb3, 0xf5, 0x0d, 0x23, 0x7e, 0x43, 0xf8, 0xe0, 0x0c, 0x60, 0xf9, 0xc6, 0x70, + 0x23, 0xb5, 0x91, 0xb9, 0x26, 0x53, 0xdc, 0xaf, 0x15, 0xcc, 0xa5, 0xd9, 0xa5, 0x1d, 0x52, 0xff, + 0x40, 0xed, 0xe5, 0x77, 0x41, 0x5f, 0x82, 0xac, 0xd8, 0xce, 0x49, 0xde, 0xe2, 0xbb, 0x55, 0xb3, + 0x12, 0xa5, 0xca, 0x60, 0x9e, 0xf9, 0x5d, 0x6d, 0x9a, 0x13, 0x7a, 0x79, 0x9d, 0x04, 0x3f, 0xae, + 0x93, 0x87, 0x0b, 0x69, 0x3e, 0x34, 0x82, 0xe6, 0xb0, 0xf2, 0x0f, 0xee, 0x3f, 0xc7, 0xba, 0xb8, + 0x48, 0xcd, 0xa7, 0xba, 0xd4, 0x74, 0x56, 0x19, 0x76, 0xe0, 0xfa, 0x9c, 0xce, 0xed, 0xca, 0x9a, + 0xdc, 0xc7, 0xfd, 0x76, 0xcf, 0x4c, 0x16, 0x76, 0x85, 0x90, 0xf5, 0x5a, 0x38, 0x2b, 0x4e, 0x5e, + 0x5f, 0x6e, 0x62, 0x74, 0xb5, 0x89, 0xd1, 0xcf, 0x4d, 0x8c, 0x3e, 0x6f, 0xe3, 0xe0, 0x6a, 0x1b, + 0x07, 0xdf, 0xb7, 0x71, 0xf0, 0xfe, 0xc9, 0x5f, 0xa3, 0xfc, 0x45, 0x1f, 0x2f, 0xb9, 0xd0, 0x3b, + 0x90, 0xae, 0x27, 0xd3, 0xf4, 0xe3, 0x9f, 0xdf, 0xd7, 0x0e, 0x17, 0x3d, 0x8b, 0xa7, 0xbf, 0x03, + 0x00, 0x00, 0xff, 0xff, 0xfc, 0xf5, 0x62, 0xae, 0xdf, 0x02, 0x00, 0x00, +} + +func (this *TokenPairArbRoutes) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*TokenPairArbRoutes) + if !ok { + that2, ok := that.(TokenPairArbRoutes) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + if len(this.ArbRoutes) != len(that1.ArbRoutes) { + return false + } + for i := range this.ArbRoutes { + if !this.ArbRoutes[i].Equal(that1.ArbRoutes[i]) { + return false + } + } + if this.TokenIn != that1.TokenIn { + return false + } + if this.TokenOut != that1.TokenOut { + return false + } + return true +} +func (this *Route) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*Route) + if !ok { + that2, ok := that.(Route) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + if len(this.Trades) != len(that1.Trades) { + return false + } + for i := range this.Trades { + if !this.Trades[i].Equal(that1.Trades[i]) { + return false + } + } + return true +} +func (this *Trade) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*Trade) + if !ok { + that2, ok := that.(Trade) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + if this.Pool != that1.Pool { + return false + } + if this.TokenIn != that1.TokenIn { + return false + } + if this.TokenOut != that1.TokenOut { + return false + } + return true +} +func (m *TokenPairArbRoutes) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *TokenPairArbRoutes) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *TokenPairArbRoutes) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.TokenOut) > 0 { + i -= len(m.TokenOut) + copy(dAtA[i:], m.TokenOut) + i = encodeVarintProtorev(dAtA, i, uint64(len(m.TokenOut))) + i-- + dAtA[i] = 0x1a + } + if len(m.TokenIn) > 0 { + i -= len(m.TokenIn) + copy(dAtA[i:], m.TokenIn) + i = encodeVarintProtorev(dAtA, i, uint64(len(m.TokenIn))) + i-- + dAtA[i] = 0x12 + } + if len(m.ArbRoutes) > 0 { + for iNdEx := len(m.ArbRoutes) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.ArbRoutes[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintProtorev(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + } + return len(dAtA) - i, nil +} + +func (m *Route) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *Route) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *Route) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Trades) > 0 { + for iNdEx := len(m.Trades) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Trades[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintProtorev(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + } + return len(dAtA) - i, nil +} + +func (m *Trade) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *Trade) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *Trade) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.TokenOut) > 0 { + i -= len(m.TokenOut) + copy(dAtA[i:], m.TokenOut) + i = encodeVarintProtorev(dAtA, i, uint64(len(m.TokenOut))) + i-- + dAtA[i] = 0x1a + } + if len(m.TokenIn) > 0 { + i -= len(m.TokenIn) + copy(dAtA[i:], m.TokenIn) + i = encodeVarintProtorev(dAtA, i, uint64(len(m.TokenIn))) + i-- + dAtA[i] = 0x12 + } + if m.Pool != 0 { + i = encodeVarintProtorev(dAtA, i, uint64(m.Pool)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func (m *PoolStatistics) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *PoolStatistics) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *PoolStatistics) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.PoolId != 0 { + i = encodeVarintProtorev(dAtA, i, uint64(m.PoolId)) + i-- + dAtA[i] = 0x18 + } + { + size := m.NumberOfTrades.Size() + i -= size + if _, err := m.NumberOfTrades.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintProtorev(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + if len(m.Profits) > 0 { + for iNdEx := len(m.Profits) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Profits[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintProtorev(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + } + return len(dAtA) - i, nil +} + +func encodeVarintProtorev(dAtA []byte, offset int, v uint64) int { + offset -= sovProtorev(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *TokenPairArbRoutes) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.ArbRoutes) > 0 { + for _, e := range m.ArbRoutes { + l = e.Size() + n += 1 + l + sovProtorev(uint64(l)) + } + } + l = len(m.TokenIn) + if l > 0 { + n += 1 + l + sovProtorev(uint64(l)) + } + l = len(m.TokenOut) + if l > 0 { + n += 1 + l + sovProtorev(uint64(l)) + } + return n +} + +func (m *Route) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.Trades) > 0 { + for _, e := range m.Trades { + l = e.Size() + n += 1 + l + sovProtorev(uint64(l)) + } + } + return n +} + +func (m *Trade) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Pool != 0 { + n += 1 + sovProtorev(uint64(m.Pool)) + } + l = len(m.TokenIn) + if l > 0 { + n += 1 + l + sovProtorev(uint64(l)) + } + l = len(m.TokenOut) + if l > 0 { + n += 1 + l + sovProtorev(uint64(l)) + } + return n +} + +func (m *PoolStatistics) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.Profits) > 0 { + for _, e := range m.Profits { + l = e.Size() + n += 1 + l + sovProtorev(uint64(l)) + } + } + l = m.NumberOfTrades.Size() + n += 1 + l + sovProtorev(uint64(l)) + if m.PoolId != 0 { + n += 1 + sovProtorev(uint64(m.PoolId)) + } + return n +} + +func sovProtorev(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozProtorev(x uint64) (n int) { + return sovProtorev(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *TokenPairArbRoutes) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowProtorev + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: TokenPairArbRoutes: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: TokenPairArbRoutes: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ArbRoutes", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowProtorev + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthProtorev + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthProtorev + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ArbRoutes = append(m.ArbRoutes, &Route{}) + if err := m.ArbRoutes[len(m.ArbRoutes)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field TokenIn", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowProtorev + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthProtorev + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthProtorev + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.TokenIn = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field TokenOut", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowProtorev + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthProtorev + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthProtorev + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.TokenOut = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipProtorev(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthProtorev + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *Route) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowProtorev + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: Route: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Route: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Trades", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowProtorev + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthProtorev + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthProtorev + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Trades = append(m.Trades, &Trade{}) + if err := m.Trades[len(m.Trades)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipProtorev(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthProtorev + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *Trade) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowProtorev + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: Trade: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Trade: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Pool", wireType) + } + m.Pool = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowProtorev + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Pool |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field TokenIn", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowProtorev + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthProtorev + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthProtorev + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.TokenIn = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field TokenOut", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowProtorev + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthProtorev + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthProtorev + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.TokenOut = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipProtorev(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthProtorev + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *PoolStatistics) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowProtorev + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: PoolStatistics: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: PoolStatistics: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Profits", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowProtorev + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthProtorev + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthProtorev + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Profits = append(m.Profits, &types.Coin{}) + if err := m.Profits[len(m.Profits)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field NumberOfTrades", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowProtorev + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthProtorev + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthProtorev + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.NumberOfTrades.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field PoolId", wireType) + } + m.PoolId = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowProtorev + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.PoolId |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipProtorev(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthProtorev + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipProtorev(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowProtorev + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowProtorev + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowProtorev + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthProtorev + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupProtorev + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthProtorev + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthProtorev = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowProtorev = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupProtorev = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/protorev/types/query.pb.go b/x/protorev/types/query.pb.go new file mode 100644 index 00000000000..441ab70205a --- /dev/null +++ b/x/protorev/types/query.pb.go @@ -0,0 +1,2730 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: osmosis/protorev/v1beta1/query.proto + +package types + +import ( + context "context" + fmt "fmt" + github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types" + types "github.com/cosmos/cosmos-sdk/types" + _ "github.com/cosmos/cosmos-sdk/types/query" + _ "github.com/gogo/protobuf/gogoproto" + grpc1 "github.com/gogo/protobuf/grpc" + proto "github.com/gogo/protobuf/proto" + _ "google.golang.org/genproto/googleapis/api/annotations" + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +// QueryParamsRequest is request type for the Query/Params RPC method. +type QueryParamsRequest struct { +} + +func (m *QueryParamsRequest) Reset() { *m = QueryParamsRequest{} } +func (m *QueryParamsRequest) String() string { return proto.CompactTextString(m) } +func (*QueryParamsRequest) ProtoMessage() {} +func (*QueryParamsRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_f5e7ac9973cce389, []int{0} +} +func (m *QueryParamsRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryParamsRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryParamsRequest.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *QueryParamsRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryParamsRequest.Merge(m, src) +} +func (m *QueryParamsRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryParamsRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryParamsRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryParamsRequest proto.InternalMessageInfo + +// QueryParamsResponse is response type for the Query/Params RPC method. +type QueryParamsResponse struct { + // params holds all the parameters of this module. + Params Params `protobuf:"bytes,1,opt,name=params,proto3" json:"params"` +} + +func (m *QueryParamsResponse) Reset() { *m = QueryParamsResponse{} } +func (m *QueryParamsResponse) String() string { return proto.CompactTextString(m) } +func (*QueryParamsResponse) ProtoMessage() {} +func (*QueryParamsResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_f5e7ac9973cce389, []int{1} +} +func (m *QueryParamsResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryParamsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryParamsResponse.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *QueryParamsResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryParamsResponse.Merge(m, src) +} +func (m *QueryParamsResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryParamsResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryParamsResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryParamsResponse proto.InternalMessageInfo + +func (m *QueryParamsResponse) GetParams() Params { + if m != nil { + return m.Params + } + return Params{} +} + +// QueryGetProtoRevNumberOfTradesRequest is request type for the +// Query/GetProtoRevNumberOfTrades RPC method. +type QueryGetProtoRevNumberOfTradesRequest struct { +} + +func (m *QueryGetProtoRevNumberOfTradesRequest) Reset() { *m = QueryGetProtoRevNumberOfTradesRequest{} } +func (m *QueryGetProtoRevNumberOfTradesRequest) String() string { return proto.CompactTextString(m) } +func (*QueryGetProtoRevNumberOfTradesRequest) ProtoMessage() {} +func (*QueryGetProtoRevNumberOfTradesRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_f5e7ac9973cce389, []int{2} +} +func (m *QueryGetProtoRevNumberOfTradesRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryGetProtoRevNumberOfTradesRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryGetProtoRevNumberOfTradesRequest.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *QueryGetProtoRevNumberOfTradesRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryGetProtoRevNumberOfTradesRequest.Merge(m, src) +} +func (m *QueryGetProtoRevNumberOfTradesRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryGetProtoRevNumberOfTradesRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryGetProtoRevNumberOfTradesRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryGetProtoRevNumberOfTradesRequest proto.InternalMessageInfo + +// QueryGetProtoRevNumberOfTradesResponse is response type for the +// Query/GetProtoRevNumberOfTrades RPC method. +type QueryGetProtoRevNumberOfTradesResponse struct { + // number_of_trades is the number of trades the module has executed + NumberOfTrades github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,1,opt,name=number_of_trades,json=numberOfTrades,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"number_of_trades"` +} + +func (m *QueryGetProtoRevNumberOfTradesResponse) Reset() { + *m = QueryGetProtoRevNumberOfTradesResponse{} +} +func (m *QueryGetProtoRevNumberOfTradesResponse) String() string { return proto.CompactTextString(m) } +func (*QueryGetProtoRevNumberOfTradesResponse) ProtoMessage() {} +func (*QueryGetProtoRevNumberOfTradesResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_f5e7ac9973cce389, []int{3} +} +func (m *QueryGetProtoRevNumberOfTradesResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryGetProtoRevNumberOfTradesResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryGetProtoRevNumberOfTradesResponse.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *QueryGetProtoRevNumberOfTradesResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryGetProtoRevNumberOfTradesResponse.Merge(m, src) +} +func (m *QueryGetProtoRevNumberOfTradesResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryGetProtoRevNumberOfTradesResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryGetProtoRevNumberOfTradesResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryGetProtoRevNumberOfTradesResponse proto.InternalMessageInfo + +// QueryGetProtoRevProfitsByDenomRequest is request type for the +// Query/GetProtoRevProfitsByDenom RPC method. +type QueryGetProtoRevProfitsByDenomRequest struct { + // denom is the denom to query profits by + Denom string `protobuf:"bytes,1,opt,name=denom,proto3" json:"denom,omitempty"` +} + +func (m *QueryGetProtoRevProfitsByDenomRequest) Reset() { *m = QueryGetProtoRevProfitsByDenomRequest{} } +func (m *QueryGetProtoRevProfitsByDenomRequest) String() string { return proto.CompactTextString(m) } +func (*QueryGetProtoRevProfitsByDenomRequest) ProtoMessage() {} +func (*QueryGetProtoRevProfitsByDenomRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_f5e7ac9973cce389, []int{4} +} +func (m *QueryGetProtoRevProfitsByDenomRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryGetProtoRevProfitsByDenomRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryGetProtoRevProfitsByDenomRequest.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *QueryGetProtoRevProfitsByDenomRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryGetProtoRevProfitsByDenomRequest.Merge(m, src) +} +func (m *QueryGetProtoRevProfitsByDenomRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryGetProtoRevProfitsByDenomRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryGetProtoRevProfitsByDenomRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryGetProtoRevProfitsByDenomRequest proto.InternalMessageInfo + +func (m *QueryGetProtoRevProfitsByDenomRequest) GetDenom() string { + if m != nil { + return m.Denom + } + return "" +} + +// QueryGetProtoRevProfitsByDenomResponse is response type for the +// Query/GetProtoRevProfitsByDenom RPC method. +type QueryGetProtoRevProfitsByDenomResponse struct { + // profit is the profits of the module by the selected denom + Profit *types.Coin `protobuf:"bytes,1,opt,name=profit,proto3" json:"profit,omitempty"` +} + +func (m *QueryGetProtoRevProfitsByDenomResponse) Reset() { + *m = QueryGetProtoRevProfitsByDenomResponse{} +} +func (m *QueryGetProtoRevProfitsByDenomResponse) String() string { return proto.CompactTextString(m) } +func (*QueryGetProtoRevProfitsByDenomResponse) ProtoMessage() {} +func (*QueryGetProtoRevProfitsByDenomResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_f5e7ac9973cce389, []int{5} +} +func (m *QueryGetProtoRevProfitsByDenomResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryGetProtoRevProfitsByDenomResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryGetProtoRevProfitsByDenomResponse.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *QueryGetProtoRevProfitsByDenomResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryGetProtoRevProfitsByDenomResponse.Merge(m, src) +} +func (m *QueryGetProtoRevProfitsByDenomResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryGetProtoRevProfitsByDenomResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryGetProtoRevProfitsByDenomResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryGetProtoRevProfitsByDenomResponse proto.InternalMessageInfo + +func (m *QueryGetProtoRevProfitsByDenomResponse) GetProfit() *types.Coin { + if m != nil { + return m.Profit + } + return nil +} + +// QueryGetProtoRevAllProfitsRequest is request type for the +// Query/GetProtoRevAllProfits RPC method. +type QueryGetProtoRevAllProfitsRequest struct { +} + +func (m *QueryGetProtoRevAllProfitsRequest) Reset() { *m = QueryGetProtoRevAllProfitsRequest{} } +func (m *QueryGetProtoRevAllProfitsRequest) String() string { return proto.CompactTextString(m) } +func (*QueryGetProtoRevAllProfitsRequest) ProtoMessage() {} +func (*QueryGetProtoRevAllProfitsRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_f5e7ac9973cce389, []int{6} +} +func (m *QueryGetProtoRevAllProfitsRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryGetProtoRevAllProfitsRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryGetProtoRevAllProfitsRequest.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *QueryGetProtoRevAllProfitsRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryGetProtoRevAllProfitsRequest.Merge(m, src) +} +func (m *QueryGetProtoRevAllProfitsRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryGetProtoRevAllProfitsRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryGetProtoRevAllProfitsRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryGetProtoRevAllProfitsRequest proto.InternalMessageInfo + +// QueryGetProtoRevAllProfitsResponse is response type for the +// Query/GetProtoRevAllProfits RPC method. +type QueryGetProtoRevAllProfitsResponse struct { + // profits is a list of all of the profits from the module + Profits []*types.Coin `protobuf:"bytes,1,rep,name=profits,proto3" json:"profits,omitempty"` +} + +func (m *QueryGetProtoRevAllProfitsResponse) Reset() { *m = QueryGetProtoRevAllProfitsResponse{} } +func (m *QueryGetProtoRevAllProfitsResponse) String() string { return proto.CompactTextString(m) } +func (*QueryGetProtoRevAllProfitsResponse) ProtoMessage() {} +func (*QueryGetProtoRevAllProfitsResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_f5e7ac9973cce389, []int{7} +} +func (m *QueryGetProtoRevAllProfitsResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryGetProtoRevAllProfitsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryGetProtoRevAllProfitsResponse.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *QueryGetProtoRevAllProfitsResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryGetProtoRevAllProfitsResponse.Merge(m, src) +} +func (m *QueryGetProtoRevAllProfitsResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryGetProtoRevAllProfitsResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryGetProtoRevAllProfitsResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryGetProtoRevAllProfitsResponse proto.InternalMessageInfo + +func (m *QueryGetProtoRevAllProfitsResponse) GetProfits() []*types.Coin { + if m != nil { + return m.Profits + } + return nil +} + +// QueryGetProtoRevStatisticsByPoolRequest is request type for the +// Query/GetProtoRevStatisticsByPool RPC method. +type QueryGetProtoRevStatisticsByPoolRequest struct { + // pool_id is the pool id to query statistics by + PoolId uint64 `protobuf:"varint,1,opt,name=pool_id,json=poolId,proto3" json:"pool_id,omitempty"` +} + +func (m *QueryGetProtoRevStatisticsByPoolRequest) Reset() { + *m = QueryGetProtoRevStatisticsByPoolRequest{} +} +func (m *QueryGetProtoRevStatisticsByPoolRequest) String() string { return proto.CompactTextString(m) } +func (*QueryGetProtoRevStatisticsByPoolRequest) ProtoMessage() {} +func (*QueryGetProtoRevStatisticsByPoolRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_f5e7ac9973cce389, []int{8} +} +func (m *QueryGetProtoRevStatisticsByPoolRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryGetProtoRevStatisticsByPoolRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryGetProtoRevStatisticsByPoolRequest.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *QueryGetProtoRevStatisticsByPoolRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryGetProtoRevStatisticsByPoolRequest.Merge(m, src) +} +func (m *QueryGetProtoRevStatisticsByPoolRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryGetProtoRevStatisticsByPoolRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryGetProtoRevStatisticsByPoolRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryGetProtoRevStatisticsByPoolRequest proto.InternalMessageInfo + +func (m *QueryGetProtoRevStatisticsByPoolRequest) GetPoolId() uint64 { + if m != nil { + return m.PoolId + } + return 0 +} + +// QueryGetProtoRevStatisticsByPoolResponse is response type for the +// Query/GetProtoRevStatisticsByPool RPC method. +type QueryGetProtoRevStatisticsByPoolResponse struct { + // statistics contains the number of trades the module has executed after a + // swap on a given pool and the profits from the trades + Statistics *PoolStatistics `protobuf:"bytes,1,opt,name=statistics,proto3" json:"statistics,omitempty"` +} + +func (m *QueryGetProtoRevStatisticsByPoolResponse) Reset() { + *m = QueryGetProtoRevStatisticsByPoolResponse{} +} +func (m *QueryGetProtoRevStatisticsByPoolResponse) String() string { return proto.CompactTextString(m) } +func (*QueryGetProtoRevStatisticsByPoolResponse) ProtoMessage() {} +func (*QueryGetProtoRevStatisticsByPoolResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_f5e7ac9973cce389, []int{9} +} +func (m *QueryGetProtoRevStatisticsByPoolResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryGetProtoRevStatisticsByPoolResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryGetProtoRevStatisticsByPoolResponse.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *QueryGetProtoRevStatisticsByPoolResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryGetProtoRevStatisticsByPoolResponse.Merge(m, src) +} +func (m *QueryGetProtoRevStatisticsByPoolResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryGetProtoRevStatisticsByPoolResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryGetProtoRevStatisticsByPoolResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryGetProtoRevStatisticsByPoolResponse proto.InternalMessageInfo + +func (m *QueryGetProtoRevStatisticsByPoolResponse) GetStatistics() *PoolStatistics { + if m != nil { + return m.Statistics + } + return nil +} + +// QueryGetProtoRevAllStatisticsRequest is request type for the +// Query/GetProtoRevAllStatistics RPC method. +type QueryGetProtoRevAllStatisticsRequest struct { +} + +func (m *QueryGetProtoRevAllStatisticsRequest) Reset() { *m = QueryGetProtoRevAllStatisticsRequest{} } +func (m *QueryGetProtoRevAllStatisticsRequest) String() string { return proto.CompactTextString(m) } +func (*QueryGetProtoRevAllStatisticsRequest) ProtoMessage() {} +func (*QueryGetProtoRevAllStatisticsRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_f5e7ac9973cce389, []int{10} +} +func (m *QueryGetProtoRevAllStatisticsRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryGetProtoRevAllStatisticsRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryGetProtoRevAllStatisticsRequest.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *QueryGetProtoRevAllStatisticsRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryGetProtoRevAllStatisticsRequest.Merge(m, src) +} +func (m *QueryGetProtoRevAllStatisticsRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryGetProtoRevAllStatisticsRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryGetProtoRevAllStatisticsRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryGetProtoRevAllStatisticsRequest proto.InternalMessageInfo + +// QueryGetProtoRevAllStatisticsResponse is response type for the +// Query/GetProtoRevAllStatistics RPC method. +type QueryGetProtoRevAllStatisticsResponse struct { + // statistics contains the number of trades the module has executed after a + // swap on a given pool and the profits from the trades for all pools + Statistics []PoolStatistics `protobuf:"bytes,1,rep,name=statistics,proto3" json:"statistics"` +} + +func (m *QueryGetProtoRevAllStatisticsResponse) Reset() { *m = QueryGetProtoRevAllStatisticsResponse{} } +func (m *QueryGetProtoRevAllStatisticsResponse) String() string { return proto.CompactTextString(m) } +func (*QueryGetProtoRevAllStatisticsResponse) ProtoMessage() {} +func (*QueryGetProtoRevAllStatisticsResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_f5e7ac9973cce389, []int{11} +} +func (m *QueryGetProtoRevAllStatisticsResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryGetProtoRevAllStatisticsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryGetProtoRevAllStatisticsResponse.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *QueryGetProtoRevAllStatisticsResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryGetProtoRevAllStatisticsResponse.Merge(m, src) +} +func (m *QueryGetProtoRevAllStatisticsResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryGetProtoRevAllStatisticsResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryGetProtoRevAllStatisticsResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryGetProtoRevAllStatisticsResponse proto.InternalMessageInfo + +func (m *QueryGetProtoRevAllStatisticsResponse) GetStatistics() []PoolStatistics { + if m != nil { + return m.Statistics + } + return nil +} + +// QueryGetProtoRevTokenPairArbRoutesRequest is request type for the +// Query/GetProtoRevTokenPairArbRoutes RPC method. +type QueryGetProtoRevTokenPairArbRoutesRequest struct { +} + +func (m *QueryGetProtoRevTokenPairArbRoutesRequest) Reset() { + *m = QueryGetProtoRevTokenPairArbRoutesRequest{} +} +func (m *QueryGetProtoRevTokenPairArbRoutesRequest) String() string { + return proto.CompactTextString(m) +} +func (*QueryGetProtoRevTokenPairArbRoutesRequest) ProtoMessage() {} +func (*QueryGetProtoRevTokenPairArbRoutesRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_f5e7ac9973cce389, []int{12} +} +func (m *QueryGetProtoRevTokenPairArbRoutesRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryGetProtoRevTokenPairArbRoutesRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryGetProtoRevTokenPairArbRoutesRequest.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *QueryGetProtoRevTokenPairArbRoutesRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryGetProtoRevTokenPairArbRoutesRequest.Merge(m, src) +} +func (m *QueryGetProtoRevTokenPairArbRoutesRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryGetProtoRevTokenPairArbRoutesRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryGetProtoRevTokenPairArbRoutesRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryGetProtoRevTokenPairArbRoutesRequest proto.InternalMessageInfo + +// QueryGetProtoRevTokenPairArbRoutesResponse is response type for the +// Query/GetProtoRevTokenPairArbRoutes RPC method. +type QueryGetProtoRevTokenPairArbRoutesResponse struct { + // routes is a list of all of the hot routes that the module is currently + // arbitraging + Routes []*TokenPairArbRoutes `protobuf:"bytes,1,rep,name=routes,proto3" json:"routes,omitempty"` +} + +func (m *QueryGetProtoRevTokenPairArbRoutesResponse) Reset() { + *m = QueryGetProtoRevTokenPairArbRoutesResponse{} +} +func (m *QueryGetProtoRevTokenPairArbRoutesResponse) String() string { + return proto.CompactTextString(m) +} +func (*QueryGetProtoRevTokenPairArbRoutesResponse) ProtoMessage() {} +func (*QueryGetProtoRevTokenPairArbRoutesResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_f5e7ac9973cce389, []int{13} +} +func (m *QueryGetProtoRevTokenPairArbRoutesResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryGetProtoRevTokenPairArbRoutesResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryGetProtoRevTokenPairArbRoutesResponse.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *QueryGetProtoRevTokenPairArbRoutesResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryGetProtoRevTokenPairArbRoutesResponse.Merge(m, src) +} +func (m *QueryGetProtoRevTokenPairArbRoutesResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryGetProtoRevTokenPairArbRoutesResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryGetProtoRevTokenPairArbRoutesResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryGetProtoRevTokenPairArbRoutesResponse proto.InternalMessageInfo + +func (m *QueryGetProtoRevTokenPairArbRoutesResponse) GetRoutes() []*TokenPairArbRoutes { + if m != nil { + return m.Routes + } + return nil +} + +func init() { + proto.RegisterType((*QueryParamsRequest)(nil), "osmosis.protorev.v1beta1.QueryParamsRequest") + proto.RegisterType((*QueryParamsResponse)(nil), "osmosis.protorev.v1beta1.QueryParamsResponse") + proto.RegisterType((*QueryGetProtoRevNumberOfTradesRequest)(nil), "osmosis.protorev.v1beta1.QueryGetProtoRevNumberOfTradesRequest") + proto.RegisterType((*QueryGetProtoRevNumberOfTradesResponse)(nil), "osmosis.protorev.v1beta1.QueryGetProtoRevNumberOfTradesResponse") + proto.RegisterType((*QueryGetProtoRevProfitsByDenomRequest)(nil), "osmosis.protorev.v1beta1.QueryGetProtoRevProfitsByDenomRequest") + proto.RegisterType((*QueryGetProtoRevProfitsByDenomResponse)(nil), "osmosis.protorev.v1beta1.QueryGetProtoRevProfitsByDenomResponse") + proto.RegisterType((*QueryGetProtoRevAllProfitsRequest)(nil), "osmosis.protorev.v1beta1.QueryGetProtoRevAllProfitsRequest") + proto.RegisterType((*QueryGetProtoRevAllProfitsResponse)(nil), "osmosis.protorev.v1beta1.QueryGetProtoRevAllProfitsResponse") + proto.RegisterType((*QueryGetProtoRevStatisticsByPoolRequest)(nil), "osmosis.protorev.v1beta1.QueryGetProtoRevStatisticsByPoolRequest") + proto.RegisterType((*QueryGetProtoRevStatisticsByPoolResponse)(nil), "osmosis.protorev.v1beta1.QueryGetProtoRevStatisticsByPoolResponse") + proto.RegisterType((*QueryGetProtoRevAllStatisticsRequest)(nil), "osmosis.protorev.v1beta1.QueryGetProtoRevAllStatisticsRequest") + proto.RegisterType((*QueryGetProtoRevAllStatisticsResponse)(nil), "osmosis.protorev.v1beta1.QueryGetProtoRevAllStatisticsResponse") + proto.RegisterType((*QueryGetProtoRevTokenPairArbRoutesRequest)(nil), "osmosis.protorev.v1beta1.QueryGetProtoRevTokenPairArbRoutesRequest") + proto.RegisterType((*QueryGetProtoRevTokenPairArbRoutesResponse)(nil), "osmosis.protorev.v1beta1.QueryGetProtoRevTokenPairArbRoutesResponse") +} + +func init() { + proto.RegisterFile("osmosis/protorev/v1beta1/query.proto", fileDescriptor_f5e7ac9973cce389) +} + +var fileDescriptor_f5e7ac9973cce389 = []byte{ + // 829 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x56, 0x5d, 0x4f, 0xd3, 0x50, + 0x18, 0x5e, 0x05, 0x46, 0x3c, 0x26, 0xc6, 0x1c, 0x31, 0x42, 0xc5, 0x02, 0x65, 0x8c, 0xf1, 0xb1, + 0xd6, 0x31, 0xef, 0x54, 0x90, 0x41, 0xa2, 0xdc, 0xe0, 0xac, 0x98, 0xf8, 0x71, 0xd1, 0xb4, 0x5b, + 0x99, 0x0d, 0x5d, 0x4f, 0x69, 0xbb, 0xe9, 0x6e, 0xb9, 0xf5, 0xc6, 0xc4, 0xdf, 0xe3, 0x3d, 0xde, + 0x18, 0x12, 0x13, 0x63, 0xbc, 0x40, 0x03, 0xfe, 0x0e, 0x63, 0x7a, 0xfa, 0x76, 0x1f, 0x5d, 0xbb, + 0x0f, 0xb8, 0xda, 0xce, 0x39, 0xcf, 0xfb, 0xbc, 0xcf, 0xf3, 0x9e, 0xf6, 0x49, 0x51, 0x8a, 0x38, + 0x55, 0xe2, 0xe8, 0x8e, 0x68, 0xd9, 0xc4, 0x25, 0xb6, 0x56, 0x17, 0xeb, 0x39, 0x55, 0x73, 0x95, + 0x9c, 0x78, 0x58, 0xd3, 0xec, 0x86, 0x40, 0xb7, 0xf1, 0x24, 0xa0, 0x84, 0x00, 0x25, 0x00, 0x8a, + 0x9d, 0xa8, 0x90, 0x0a, 0xa1, 0xbb, 0xa2, 0xf7, 0xcf, 0x07, 0xb0, 0xd3, 0x15, 0x42, 0x2a, 0x86, + 0x26, 0x2a, 0x96, 0x2e, 0x2a, 0xa6, 0x49, 0x5c, 0xc5, 0xd5, 0x89, 0x09, 0xe5, 0xec, 0x72, 0x89, + 0xd2, 0x89, 0xaa, 0xe2, 0x68, 0x7e, 0x9b, 0x66, 0x53, 0x4b, 0xa9, 0xe8, 0x26, 0x05, 0x03, 0x76, + 0x21, 0x56, 0x9f, 0xa5, 0xd8, 0x4a, 0x35, 0xa0, 0x5c, 0x8c, 0x87, 0x05, 0x8a, 0x7d, 0x20, 0xd7, + 0xde, 0x3b, 0xc0, 0x94, 0x88, 0x0e, 0xfd, 0xf8, 0x09, 0x84, 0x9f, 0x7b, 0x8a, 0x8a, 0x94, 0x5d, + 0xd2, 0x0e, 0x6b, 0x9a, 0xe3, 0xf2, 0x2f, 0xd1, 0xcd, 0x8e, 0x5d, 0xc7, 0x22, 0xa6, 0xa3, 0xe1, + 0x75, 0x94, 0xf4, 0x55, 0x4c, 0x32, 0xb3, 0x4c, 0xe6, 0xda, 0xda, 0xac, 0x10, 0x37, 0x27, 0xc1, + 0xaf, 0x2c, 0x8c, 0x1e, 0x9f, 0xce, 0x24, 0x24, 0xa8, 0xe2, 0x17, 0xd1, 0x02, 0xa5, 0x7d, 0xa2, + 0xb9, 0x45, 0xaf, 0x40, 0xd2, 0xea, 0xbb, 0xb5, 0xaa, 0xaa, 0xd9, 0xcf, 0xf6, 0xf7, 0x6c, 0xa5, + 0xac, 0x35, 0xfb, 0x1f, 0x31, 0x28, 0xdd, 0x0f, 0x09, 0x9a, 0x5e, 0xa1, 0x1b, 0x26, 0x3d, 0x91, + 0xc9, 0xbe, 0xec, 0xd2, 0x33, 0xaa, 0xee, 0x6a, 0x41, 0xf0, 0x7a, 0xff, 0x3a, 0x9d, 0x49, 0x57, + 0x74, 0xf7, 0x5d, 0x4d, 0x15, 0x4a, 0xa4, 0x2a, 0xc2, 0x34, 0xfc, 0x9f, 0xac, 0x53, 0x3e, 0x10, + 0xdd, 0x86, 0xa5, 0x39, 0xc2, 0x8e, 0xe9, 0x4a, 0xd7, 0xcd, 0x8e, 0x0e, 0xfc, 0xa3, 0x6e, 0xb5, + 0x45, 0x9b, 0xec, 0xeb, 0xae, 0x53, 0x68, 0x6c, 0x6b, 0x26, 0xa9, 0x82, 0x5a, 0x3c, 0x81, 0xc6, + 0xca, 0xde, 0xda, 0xef, 0x2b, 0xf9, 0x0b, 0xfe, 0x6d, 0xb7, 0x85, 0x70, 0x39, 0x58, 0xc8, 0xa1, + 0xa4, 0x45, 0x4f, 0x60, 0xac, 0x53, 0x82, 0xaf, 0x4f, 0xf0, 0x2e, 0xad, 0x39, 0xd1, 0x2d, 0xa2, + 0x9b, 0x12, 0x00, 0xf9, 0x79, 0x34, 0x17, 0x26, 0xdf, 0x34, 0x0c, 0xe0, 0x0f, 0xa6, 0xf8, 0x1a, + 0xf1, 0xbd, 0x40, 0xd0, 0x3d, 0x8f, 0xc6, 0x7d, 0x52, 0x6f, 0x6e, 0x23, 0xbd, 0xdb, 0x07, 0x48, + 0xbe, 0x80, 0x16, 0xc3, 0xd4, 0x2f, 0xbc, 0x87, 0xde, 0x71, 0xf5, 0x92, 0x53, 0x68, 0x14, 0x09, + 0x31, 0x82, 0xe9, 0xdc, 0x46, 0xe3, 0x16, 0x21, 0x86, 0xac, 0x97, 0xa9, 0xbd, 0x51, 0x29, 0xe9, + 0x2d, 0x77, 0xca, 0xbc, 0x8b, 0x32, 0xfd, 0x39, 0x40, 0xe4, 0x53, 0x84, 0x9c, 0xe6, 0x19, 0x8c, + 0x29, 0xd3, 0xe3, 0xe9, 0x23, 0xc4, 0x68, 0x71, 0x49, 0x6d, 0xb5, 0x7c, 0x1a, 0xa5, 0x22, 0x86, + 0xd2, 0x06, 0x86, 0xe1, 0xbd, 0xef, 0xbe, 0xfd, 0x10, 0x0e, 0xa4, 0xed, 0x86, 0xa4, 0x8d, 0x0c, + 0x23, 0x0d, 0x5e, 0x90, 0x76, 0x81, 0x2b, 0x68, 0x29, 0xdc, 0x78, 0x8f, 0x1c, 0x68, 0x66, 0x51, + 0xd1, 0xed, 0x4d, 0x5b, 0x95, 0x48, 0xcd, 0x6d, 0xbd, 0x28, 0x36, 0x5a, 0x1e, 0x04, 0x0c, 0x52, + 0xb7, 0x51, 0xd2, 0xa6, 0x3b, 0x20, 0x73, 0x35, 0x5e, 0x66, 0x04, 0x0b, 0xd4, 0xae, 0xfd, 0x43, + 0x68, 0x8c, 0x36, 0xc5, 0x1f, 0x19, 0x94, 0xf4, 0x5f, 0x74, 0xdc, 0x83, 0xaa, 0x3b, 0x5f, 0xd8, + 0xec, 0x80, 0x68, 0x5f, 0x37, 0x9f, 0x3a, 0xfa, 0xfe, 0xf7, 0xf3, 0x15, 0x0e, 0x4f, 0x8b, 0x41, + 0xec, 0xd5, 0x73, 0xf9, 0x56, 0xf4, 0xf9, 0xe9, 0x82, 0xbf, 0x31, 0x68, 0x2a, 0x36, 0x2f, 0xf0, + 0x46, 0x9f, 0x96, 0xfd, 0x32, 0x89, 0x7d, 0x7c, 0x71, 0x02, 0xb0, 0x21, 0x50, 0x1b, 0x19, 0x9c, + 0x8e, 0xb6, 0x11, 0x8e, 0xb1, 0xb0, 0xa1, 0xce, 0xf4, 0x18, 0xc6, 0x50, 0x64, 0x6c, 0x0d, 0x63, + 0x28, 0x3a, 0xb8, 0xfa, 0x19, 0x82, 0xb0, 0x90, 0xd5, 0x86, 0x4c, 0x23, 0x11, 0x7f, 0x61, 0xd0, + 0xad, 0xc8, 0x30, 0xc2, 0x0f, 0x06, 0xd7, 0xd2, 0x95, 0x73, 0xec, 0xc3, 0x8b, 0x15, 0x83, 0x89, + 0x25, 0x6a, 0x62, 0x1e, 0xcf, 0x45, 0x9b, 0x50, 0x0c, 0x43, 0x06, 0x23, 0xf8, 0x07, 0x83, 0xee, + 0xf4, 0x48, 0x2b, 0xbc, 0x39, 0xb8, 0x90, 0x98, 0xb4, 0x64, 0x0b, 0x97, 0xa1, 0x00, 0x47, 0xf7, + 0xa8, 0xa3, 0x65, 0x9c, 0x89, 0x76, 0xd4, 0xca, 0x1a, 0xef, 0x66, 0xbc, 0x30, 0xc6, 0x5f, 0x19, + 0x34, 0x19, 0x17, 0x74, 0x78, 0x7d, 0xa8, 0xf1, 0x76, 0x25, 0x29, 0xbb, 0x71, 0xe1, 0x7a, 0xf0, + 0xb3, 0x4a, 0xfd, 0xa4, 0x71, 0x2a, 0xfe, 0x86, 0x5a, 0x9e, 0xf0, 0x6f, 0x06, 0xdd, 0xed, 0x19, + 0x87, 0x78, 0x6b, 0x70, 0x41, 0xb1, 0xc9, 0xcb, 0x6e, 0x5f, 0x8e, 0x04, 0xac, 0xe5, 0xa9, 0xb5, + 0x2c, 0x5e, 0x89, 0xb6, 0xe6, 0x7a, 0x95, 0xb2, 0xa5, 0xe8, 0xb6, 0xac, 0xd8, 0xaa, 0xec, 0x07, + 0x70, 0x61, 0xf7, 0xf8, 0x8c, 0x63, 0x4e, 0xce, 0x38, 0xe6, 0xcf, 0x19, 0xc7, 0x7c, 0x3a, 0xe7, + 0x12, 0x27, 0xe7, 0x5c, 0xe2, 0xe7, 0x39, 0x97, 0x78, 0x73, 0xbf, 0xed, 0x53, 0x07, 0x08, 0xb3, + 0x86, 0xa2, 0x3a, 0x1d, 0xec, 0x1f, 0xda, 0xf8, 0xbd, 0x8f, 0x1f, 0x35, 0x49, 0xd7, 0xf9, 0xff, + 0x01, 0x00, 0x00, 0xff, 0xff, 0xd9, 0xe8, 0xcf, 0xe3, 0x1c, 0x0b, 0x00, 0x00, +} + +// Reference imports to suppress errors if they are not otherwise used. +var _ context.Context +var _ grpc.ClientConn + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +const _ = grpc.SupportPackageIsVersion4 + +// QueryClient is the client API for Query service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. +type QueryClient interface { + // Params queries the parameters of the module. + Params(ctx context.Context, in *QueryParamsRequest, opts ...grpc.CallOption) (*QueryParamsResponse, error) + // GetProtoRevNumberOfTrades queries the number of arbitrage trades the module + // has executed + GetProtoRevNumberOfTrades(ctx context.Context, in *QueryGetProtoRevNumberOfTradesRequest, opts ...grpc.CallOption) (*QueryGetProtoRevNumberOfTradesResponse, error) + // GetProtoRevProfitsByDenom queries the profits of the module by denom + GetProtoRevProfitsByDenom(ctx context.Context, in *QueryGetProtoRevProfitsByDenomRequest, opts ...grpc.CallOption) (*QueryGetProtoRevProfitsByDenomResponse, error) + // GetProtoRevAllProfits queries all of the profits from the module + GetProtoRevAllProfits(ctx context.Context, in *QueryGetProtoRevAllProfitsRequest, opts ...grpc.CallOption) (*QueryGetProtoRevAllProfitsResponse, error) + // GetProtoRevStatisticsByPool queries the number of arbitrages and profits + // that have been executed for a given pool + GetProtoRevStatisticsByPool(ctx context.Context, in *QueryGetProtoRevStatisticsByPoolRequest, opts ...grpc.CallOption) (*QueryGetProtoRevStatisticsByPoolResponse, error) + // GetProtoRevAllStatistics queries all of pools that the module has arbitrage + // against and the number of trades and profits that have been executed for + // each pool + GetProtoRevAllStatistics(ctx context.Context, in *QueryGetProtoRevAllStatisticsRequest, opts ...grpc.CallOption) (*QueryGetProtoRevAllStatisticsResponse, error) + // GetProtoRevTokenPairArbRoutes queries all of the hot routes that the module + // is currently arbitraging + GetProtoRevTokenPairArbRoutes(ctx context.Context, in *QueryGetProtoRevTokenPairArbRoutesRequest, opts ...grpc.CallOption) (*QueryGetProtoRevTokenPairArbRoutesResponse, error) +} + +type queryClient struct { + cc grpc1.ClientConn +} + +func NewQueryClient(cc grpc1.ClientConn) QueryClient { + return &queryClient{cc} +} + +func (c *queryClient) Params(ctx context.Context, in *QueryParamsRequest, opts ...grpc.CallOption) (*QueryParamsResponse, error) { + out := new(QueryParamsResponse) + err := c.cc.Invoke(ctx, "/osmosis.protorev.v1beta1.Query/Params", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *queryClient) GetProtoRevNumberOfTrades(ctx context.Context, in *QueryGetProtoRevNumberOfTradesRequest, opts ...grpc.CallOption) (*QueryGetProtoRevNumberOfTradesResponse, error) { + out := new(QueryGetProtoRevNumberOfTradesResponse) + err := c.cc.Invoke(ctx, "/osmosis.protorev.v1beta1.Query/GetProtoRevNumberOfTrades", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *queryClient) GetProtoRevProfitsByDenom(ctx context.Context, in *QueryGetProtoRevProfitsByDenomRequest, opts ...grpc.CallOption) (*QueryGetProtoRevProfitsByDenomResponse, error) { + out := new(QueryGetProtoRevProfitsByDenomResponse) + err := c.cc.Invoke(ctx, "/osmosis.protorev.v1beta1.Query/GetProtoRevProfitsByDenom", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *queryClient) GetProtoRevAllProfits(ctx context.Context, in *QueryGetProtoRevAllProfitsRequest, opts ...grpc.CallOption) (*QueryGetProtoRevAllProfitsResponse, error) { + out := new(QueryGetProtoRevAllProfitsResponse) + err := c.cc.Invoke(ctx, "/osmosis.protorev.v1beta1.Query/GetProtoRevAllProfits", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *queryClient) GetProtoRevStatisticsByPool(ctx context.Context, in *QueryGetProtoRevStatisticsByPoolRequest, opts ...grpc.CallOption) (*QueryGetProtoRevStatisticsByPoolResponse, error) { + out := new(QueryGetProtoRevStatisticsByPoolResponse) + err := c.cc.Invoke(ctx, "/osmosis.protorev.v1beta1.Query/GetProtoRevStatisticsByPool", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *queryClient) GetProtoRevAllStatistics(ctx context.Context, in *QueryGetProtoRevAllStatisticsRequest, opts ...grpc.CallOption) (*QueryGetProtoRevAllStatisticsResponse, error) { + out := new(QueryGetProtoRevAllStatisticsResponse) + err := c.cc.Invoke(ctx, "/osmosis.protorev.v1beta1.Query/GetProtoRevAllStatistics", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *queryClient) GetProtoRevTokenPairArbRoutes(ctx context.Context, in *QueryGetProtoRevTokenPairArbRoutesRequest, opts ...grpc.CallOption) (*QueryGetProtoRevTokenPairArbRoutesResponse, error) { + out := new(QueryGetProtoRevTokenPairArbRoutesResponse) + err := c.cc.Invoke(ctx, "/osmosis.protorev.v1beta1.Query/GetProtoRevTokenPairArbRoutes", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// QueryServer is the server API for Query service. +type QueryServer interface { + // Params queries the parameters of the module. + Params(context.Context, *QueryParamsRequest) (*QueryParamsResponse, error) + // GetProtoRevNumberOfTrades queries the number of arbitrage trades the module + // has executed + GetProtoRevNumberOfTrades(context.Context, *QueryGetProtoRevNumberOfTradesRequest) (*QueryGetProtoRevNumberOfTradesResponse, error) + // GetProtoRevProfitsByDenom queries the profits of the module by denom + GetProtoRevProfitsByDenom(context.Context, *QueryGetProtoRevProfitsByDenomRequest) (*QueryGetProtoRevProfitsByDenomResponse, error) + // GetProtoRevAllProfits queries all of the profits from the module + GetProtoRevAllProfits(context.Context, *QueryGetProtoRevAllProfitsRequest) (*QueryGetProtoRevAllProfitsResponse, error) + // GetProtoRevStatisticsByPool queries the number of arbitrages and profits + // that have been executed for a given pool + GetProtoRevStatisticsByPool(context.Context, *QueryGetProtoRevStatisticsByPoolRequest) (*QueryGetProtoRevStatisticsByPoolResponse, error) + // GetProtoRevAllStatistics queries all of pools that the module has arbitrage + // against and the number of trades and profits that have been executed for + // each pool + GetProtoRevAllStatistics(context.Context, *QueryGetProtoRevAllStatisticsRequest) (*QueryGetProtoRevAllStatisticsResponse, error) + // GetProtoRevTokenPairArbRoutes queries all of the hot routes that the module + // is currently arbitraging + GetProtoRevTokenPairArbRoutes(context.Context, *QueryGetProtoRevTokenPairArbRoutesRequest) (*QueryGetProtoRevTokenPairArbRoutesResponse, error) +} + +// UnimplementedQueryServer can be embedded to have forward compatible implementations. +type UnimplementedQueryServer struct { +} + +func (*UnimplementedQueryServer) Params(ctx context.Context, req *QueryParamsRequest) (*QueryParamsResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Params not implemented") +} +func (*UnimplementedQueryServer) GetProtoRevNumberOfTrades(ctx context.Context, req *QueryGetProtoRevNumberOfTradesRequest) (*QueryGetProtoRevNumberOfTradesResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method GetProtoRevNumberOfTrades not implemented") +} +func (*UnimplementedQueryServer) GetProtoRevProfitsByDenom(ctx context.Context, req *QueryGetProtoRevProfitsByDenomRequest) (*QueryGetProtoRevProfitsByDenomResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method GetProtoRevProfitsByDenom not implemented") +} +func (*UnimplementedQueryServer) GetProtoRevAllProfits(ctx context.Context, req *QueryGetProtoRevAllProfitsRequest) (*QueryGetProtoRevAllProfitsResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method GetProtoRevAllProfits not implemented") +} +func (*UnimplementedQueryServer) GetProtoRevStatisticsByPool(ctx context.Context, req *QueryGetProtoRevStatisticsByPoolRequest) (*QueryGetProtoRevStatisticsByPoolResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method GetProtoRevStatisticsByPool not implemented") +} +func (*UnimplementedQueryServer) GetProtoRevAllStatistics(ctx context.Context, req *QueryGetProtoRevAllStatisticsRequest) (*QueryGetProtoRevAllStatisticsResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method GetProtoRevAllStatistics not implemented") +} +func (*UnimplementedQueryServer) GetProtoRevTokenPairArbRoutes(ctx context.Context, req *QueryGetProtoRevTokenPairArbRoutesRequest) (*QueryGetProtoRevTokenPairArbRoutesResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method GetProtoRevTokenPairArbRoutes not implemented") +} + +func RegisterQueryServer(s grpc1.Server, srv QueryServer) { + s.RegisterService(&_Query_serviceDesc, srv) +} + +func _Query_Params_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryParamsRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).Params(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/osmosis.protorev.v1beta1.Query/Params", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).Params(ctx, req.(*QueryParamsRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Query_GetProtoRevNumberOfTrades_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryGetProtoRevNumberOfTradesRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).GetProtoRevNumberOfTrades(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/osmosis.protorev.v1beta1.Query/GetProtoRevNumberOfTrades", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).GetProtoRevNumberOfTrades(ctx, req.(*QueryGetProtoRevNumberOfTradesRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Query_GetProtoRevProfitsByDenom_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryGetProtoRevProfitsByDenomRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).GetProtoRevProfitsByDenom(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/osmosis.protorev.v1beta1.Query/GetProtoRevProfitsByDenom", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).GetProtoRevProfitsByDenom(ctx, req.(*QueryGetProtoRevProfitsByDenomRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Query_GetProtoRevAllProfits_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryGetProtoRevAllProfitsRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).GetProtoRevAllProfits(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/osmosis.protorev.v1beta1.Query/GetProtoRevAllProfits", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).GetProtoRevAllProfits(ctx, req.(*QueryGetProtoRevAllProfitsRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Query_GetProtoRevStatisticsByPool_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryGetProtoRevStatisticsByPoolRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).GetProtoRevStatisticsByPool(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/osmosis.protorev.v1beta1.Query/GetProtoRevStatisticsByPool", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).GetProtoRevStatisticsByPool(ctx, req.(*QueryGetProtoRevStatisticsByPoolRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Query_GetProtoRevAllStatistics_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryGetProtoRevAllStatisticsRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).GetProtoRevAllStatistics(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/osmosis.protorev.v1beta1.Query/GetProtoRevAllStatistics", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).GetProtoRevAllStatistics(ctx, req.(*QueryGetProtoRevAllStatisticsRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Query_GetProtoRevTokenPairArbRoutes_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryGetProtoRevTokenPairArbRoutesRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).GetProtoRevTokenPairArbRoutes(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/osmosis.protorev.v1beta1.Query/GetProtoRevTokenPairArbRoutes", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).GetProtoRevTokenPairArbRoutes(ctx, req.(*QueryGetProtoRevTokenPairArbRoutesRequest)) + } + return interceptor(ctx, in, info, handler) +} + +var _Query_serviceDesc = grpc.ServiceDesc{ + ServiceName: "osmosis.protorev.v1beta1.Query", + HandlerType: (*QueryServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "Params", + Handler: _Query_Params_Handler, + }, + { + MethodName: "GetProtoRevNumberOfTrades", + Handler: _Query_GetProtoRevNumberOfTrades_Handler, + }, + { + MethodName: "GetProtoRevProfitsByDenom", + Handler: _Query_GetProtoRevProfitsByDenom_Handler, + }, + { + MethodName: "GetProtoRevAllProfits", + Handler: _Query_GetProtoRevAllProfits_Handler, + }, + { + MethodName: "GetProtoRevStatisticsByPool", + Handler: _Query_GetProtoRevStatisticsByPool_Handler, + }, + { + MethodName: "GetProtoRevAllStatistics", + Handler: _Query_GetProtoRevAllStatistics_Handler, + }, + { + MethodName: "GetProtoRevTokenPairArbRoutes", + Handler: _Query_GetProtoRevTokenPairArbRoutes_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "osmosis/protorev/v1beta1/query.proto", +} + +func (m *QueryParamsRequest) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *QueryParamsRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryParamsRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *QueryParamsResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *QueryParamsResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryParamsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size, err := m.Params.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + return len(dAtA) - i, nil +} + +func (m *QueryGetProtoRevNumberOfTradesRequest) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *QueryGetProtoRevNumberOfTradesRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryGetProtoRevNumberOfTradesRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *QueryGetProtoRevNumberOfTradesResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *QueryGetProtoRevNumberOfTradesResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryGetProtoRevNumberOfTradesResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size := m.NumberOfTrades.Size() + i -= size + if _, err := m.NumberOfTrades.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + return len(dAtA) - i, nil +} + +func (m *QueryGetProtoRevProfitsByDenomRequest) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *QueryGetProtoRevProfitsByDenomRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryGetProtoRevProfitsByDenomRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Denom) > 0 { + i -= len(m.Denom) + copy(dAtA[i:], m.Denom) + i = encodeVarintQuery(dAtA, i, uint64(len(m.Denom))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *QueryGetProtoRevProfitsByDenomResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *QueryGetProtoRevProfitsByDenomResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryGetProtoRevProfitsByDenomResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Profit != nil { + { + size, err := m.Profit.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *QueryGetProtoRevAllProfitsRequest) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *QueryGetProtoRevAllProfitsRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryGetProtoRevAllProfitsRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *QueryGetProtoRevAllProfitsResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *QueryGetProtoRevAllProfitsResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryGetProtoRevAllProfitsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Profits) > 0 { + for iNdEx := len(m.Profits) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Profits[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + } + return len(dAtA) - i, nil +} + +func (m *QueryGetProtoRevStatisticsByPoolRequest) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *QueryGetProtoRevStatisticsByPoolRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryGetProtoRevStatisticsByPoolRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.PoolId != 0 { + i = encodeVarintQuery(dAtA, i, uint64(m.PoolId)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func (m *QueryGetProtoRevStatisticsByPoolResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *QueryGetProtoRevStatisticsByPoolResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryGetProtoRevStatisticsByPoolResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Statistics != nil { + { + size, err := m.Statistics.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *QueryGetProtoRevAllStatisticsRequest) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *QueryGetProtoRevAllStatisticsRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryGetProtoRevAllStatisticsRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *QueryGetProtoRevAllStatisticsResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *QueryGetProtoRevAllStatisticsResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryGetProtoRevAllStatisticsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Statistics) > 0 { + for iNdEx := len(m.Statistics) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Statistics[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + } + return len(dAtA) - i, nil +} + +func (m *QueryGetProtoRevTokenPairArbRoutesRequest) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *QueryGetProtoRevTokenPairArbRoutesRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryGetProtoRevTokenPairArbRoutesRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *QueryGetProtoRevTokenPairArbRoutesResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *QueryGetProtoRevTokenPairArbRoutesResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryGetProtoRevTokenPairArbRoutesResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Routes) > 0 { + for iNdEx := len(m.Routes) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Routes[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + } + return len(dAtA) - i, nil +} + +func encodeVarintQuery(dAtA []byte, offset int, v uint64) int { + offset -= sovQuery(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *QueryParamsRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *QueryParamsResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.Params.Size() + n += 1 + l + sovQuery(uint64(l)) + return n +} + +func (m *QueryGetProtoRevNumberOfTradesRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *QueryGetProtoRevNumberOfTradesResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.NumberOfTrades.Size() + n += 1 + l + sovQuery(uint64(l)) + return n +} + +func (m *QueryGetProtoRevProfitsByDenomRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Denom) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryGetProtoRevProfitsByDenomResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Profit != nil { + l = m.Profit.Size() + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryGetProtoRevAllProfitsRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *QueryGetProtoRevAllProfitsResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.Profits) > 0 { + for _, e := range m.Profits { + l = e.Size() + n += 1 + l + sovQuery(uint64(l)) + } + } + return n +} + +func (m *QueryGetProtoRevStatisticsByPoolRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.PoolId != 0 { + n += 1 + sovQuery(uint64(m.PoolId)) + } + return n +} + +func (m *QueryGetProtoRevStatisticsByPoolResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Statistics != nil { + l = m.Statistics.Size() + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryGetProtoRevAllStatisticsRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *QueryGetProtoRevAllStatisticsResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.Statistics) > 0 { + for _, e := range m.Statistics { + l = e.Size() + n += 1 + l + sovQuery(uint64(l)) + } + } + return n +} + +func (m *QueryGetProtoRevTokenPairArbRoutesRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *QueryGetProtoRevTokenPairArbRoutesResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.Routes) > 0 { + for _, e := range m.Routes { + l = e.Size() + n += 1 + l + sovQuery(uint64(l)) + } + } + return n +} + +func sovQuery(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozQuery(x uint64) (n int) { + return sovQuery(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *QueryParamsRequest) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: QueryParamsRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryParamsRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryParamsResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: QueryParamsResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryParamsResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Params", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Params.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryGetProtoRevNumberOfTradesRequest) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: QueryGetProtoRevNumberOfTradesRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryGetProtoRevNumberOfTradesRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryGetProtoRevNumberOfTradesResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: QueryGetProtoRevNumberOfTradesResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryGetProtoRevNumberOfTradesResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field NumberOfTrades", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.NumberOfTrades.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryGetProtoRevProfitsByDenomRequest) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: QueryGetProtoRevProfitsByDenomRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryGetProtoRevProfitsByDenomRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Denom", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Denom = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryGetProtoRevProfitsByDenomResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: QueryGetProtoRevProfitsByDenomResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryGetProtoRevProfitsByDenomResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Profit", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Profit == nil { + m.Profit = &types.Coin{} + } + if err := m.Profit.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryGetProtoRevAllProfitsRequest) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: QueryGetProtoRevAllProfitsRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryGetProtoRevAllProfitsRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryGetProtoRevAllProfitsResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: QueryGetProtoRevAllProfitsResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryGetProtoRevAllProfitsResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Profits", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Profits = append(m.Profits, &types.Coin{}) + if err := m.Profits[len(m.Profits)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryGetProtoRevStatisticsByPoolRequest) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: QueryGetProtoRevStatisticsByPoolRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryGetProtoRevStatisticsByPoolRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field PoolId", wireType) + } + m.PoolId = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.PoolId |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryGetProtoRevStatisticsByPoolResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: QueryGetProtoRevStatisticsByPoolResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryGetProtoRevStatisticsByPoolResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Statistics", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Statistics == nil { + m.Statistics = &PoolStatistics{} + } + if err := m.Statistics.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryGetProtoRevAllStatisticsRequest) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: QueryGetProtoRevAllStatisticsRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryGetProtoRevAllStatisticsRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryGetProtoRevAllStatisticsResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: QueryGetProtoRevAllStatisticsResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryGetProtoRevAllStatisticsResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Statistics", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Statistics = append(m.Statistics, PoolStatistics{}) + if err := m.Statistics[len(m.Statistics)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryGetProtoRevTokenPairArbRoutesRequest) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: QueryGetProtoRevTokenPairArbRoutesRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryGetProtoRevTokenPairArbRoutesRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryGetProtoRevTokenPairArbRoutesResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: QueryGetProtoRevTokenPairArbRoutesResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryGetProtoRevTokenPairArbRoutesResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Routes", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Routes = append(m.Routes, &TokenPairArbRoutes{}) + if err := m.Routes[len(m.Routes)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipQuery(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowQuery + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowQuery + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowQuery + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthQuery + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupQuery + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthQuery + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthQuery = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowQuery = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupQuery = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/protorev/types/query.pb.gw.go b/x/protorev/types/query.pb.gw.go new file mode 100644 index 00000000000..9555a6cafd5 --- /dev/null +++ b/x/protorev/types/query.pb.gw.go @@ -0,0 +1,579 @@ +// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT. +// source: osmosis/protorev/v1beta1/query.proto + +/* +Package types is a reverse proxy. + +It translates gRPC into RESTful JSON APIs. +*/ +package types + +import ( + "context" + "io" + "net/http" + + "github.com/golang/protobuf/descriptor" + "github.com/golang/protobuf/proto" + "github.com/grpc-ecosystem/grpc-gateway/runtime" + "github.com/grpc-ecosystem/grpc-gateway/utilities" + "google.golang.org/grpc" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/grpclog" + "google.golang.org/grpc/metadata" + "google.golang.org/grpc/status" +) + +// Suppress "imported and not used" errors +var _ codes.Code +var _ io.Reader +var _ status.Status +var _ = runtime.String +var _ = utilities.NewDoubleArray +var _ = descriptor.ForMessage +var _ = metadata.Join + +func request_Query_Params_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryParamsRequest + var metadata runtime.ServerMetadata + + msg, err := client.Params(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_Params_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryParamsRequest + var metadata runtime.ServerMetadata + + msg, err := server.Params(ctx, &protoReq) + return msg, metadata, err + +} + +func request_Query_GetProtoRevNumberOfTrades_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryGetProtoRevNumberOfTradesRequest + var metadata runtime.ServerMetadata + + msg, err := client.GetProtoRevNumberOfTrades(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_GetProtoRevNumberOfTrades_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryGetProtoRevNumberOfTradesRequest + var metadata runtime.ServerMetadata + + msg, err := server.GetProtoRevNumberOfTrades(ctx, &protoReq) + return msg, metadata, err + +} + +var ( + filter_Query_GetProtoRevProfitsByDenom_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} +) + +func request_Query_GetProtoRevProfitsByDenom_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryGetProtoRevProfitsByDenomRequest + var metadata runtime.ServerMetadata + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_GetProtoRevProfitsByDenom_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := client.GetProtoRevProfitsByDenom(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_GetProtoRevProfitsByDenom_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryGetProtoRevProfitsByDenomRequest + var metadata runtime.ServerMetadata + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_GetProtoRevProfitsByDenom_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := server.GetProtoRevProfitsByDenom(ctx, &protoReq) + return msg, metadata, err + +} + +func request_Query_GetProtoRevAllProfits_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryGetProtoRevAllProfitsRequest + var metadata runtime.ServerMetadata + + msg, err := client.GetProtoRevAllProfits(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_GetProtoRevAllProfits_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryGetProtoRevAllProfitsRequest + var metadata runtime.ServerMetadata + + msg, err := server.GetProtoRevAllProfits(ctx, &protoReq) + return msg, metadata, err + +} + +var ( + filter_Query_GetProtoRevStatisticsByPool_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} +) + +func request_Query_GetProtoRevStatisticsByPool_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryGetProtoRevStatisticsByPoolRequest + var metadata runtime.ServerMetadata + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_GetProtoRevStatisticsByPool_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := client.GetProtoRevStatisticsByPool(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_GetProtoRevStatisticsByPool_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryGetProtoRevStatisticsByPoolRequest + var metadata runtime.ServerMetadata + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_GetProtoRevStatisticsByPool_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := server.GetProtoRevStatisticsByPool(ctx, &protoReq) + return msg, metadata, err + +} + +func request_Query_GetProtoRevAllStatistics_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryGetProtoRevAllStatisticsRequest + var metadata runtime.ServerMetadata + + msg, err := client.GetProtoRevAllStatistics(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_GetProtoRevAllStatistics_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryGetProtoRevAllStatisticsRequest + var metadata runtime.ServerMetadata + + msg, err := server.GetProtoRevAllStatistics(ctx, &protoReq) + return msg, metadata, err + +} + +func request_Query_GetProtoRevTokenPairArbRoutes_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryGetProtoRevTokenPairArbRoutesRequest + var metadata runtime.ServerMetadata + + msg, err := client.GetProtoRevTokenPairArbRoutes(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_GetProtoRevTokenPairArbRoutes_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryGetProtoRevTokenPairArbRoutesRequest + var metadata runtime.ServerMetadata + + msg, err := server.GetProtoRevTokenPairArbRoutes(ctx, &protoReq) + return msg, metadata, err + +} + +// RegisterQueryHandlerServer registers the http handlers for service Query to "mux". +// UnaryRPC :call QueryServer directly. +// StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. +// Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterQueryHandlerFromEndpoint instead. +func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, server QueryServer) error { + + mux.Handle("GET", pattern_Query_Params_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Query_Params_0(rctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_Params_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_GetProtoRevNumberOfTrades_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Query_GetProtoRevNumberOfTrades_0(rctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_GetProtoRevNumberOfTrades_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_GetProtoRevProfitsByDenom_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Query_GetProtoRevProfitsByDenom_0(rctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_GetProtoRevProfitsByDenom_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_GetProtoRevAllProfits_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Query_GetProtoRevAllProfits_0(rctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_GetProtoRevAllProfits_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_GetProtoRevStatisticsByPool_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Query_GetProtoRevStatisticsByPool_0(rctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_GetProtoRevStatisticsByPool_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_GetProtoRevAllStatistics_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Query_GetProtoRevAllStatistics_0(rctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_GetProtoRevAllStatistics_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_GetProtoRevTokenPairArbRoutes_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Query_GetProtoRevTokenPairArbRoutes_0(rctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_GetProtoRevTokenPairArbRoutes_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + return nil +} + +// RegisterQueryHandlerFromEndpoint is same as RegisterQueryHandler but +// automatically dials to "endpoint" and closes the connection when "ctx" gets done. +func RegisterQueryHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) { + conn, err := grpc.Dial(endpoint, opts...) + if err != nil { + return err + } + defer func() { + if err != nil { + if cerr := conn.Close(); cerr != nil { + grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) + } + return + } + go func() { + <-ctx.Done() + if cerr := conn.Close(); cerr != nil { + grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) + } + }() + }() + + return RegisterQueryHandler(ctx, mux, conn) +} + +// RegisterQueryHandler registers the http handlers for service Query to "mux". +// The handlers forward requests to the grpc endpoint over "conn". +func RegisterQueryHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error { + return RegisterQueryHandlerClient(ctx, mux, NewQueryClient(conn)) +} + +// RegisterQueryHandlerClient registers the http handlers for service Query +// to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "QueryClient". +// Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "QueryClient" +// doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in +// "QueryClient" to call the correct interceptors. +func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, client QueryClient) error { + + mux.Handle("GET", pattern_Query_Params_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_Query_Params_0(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_Params_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_GetProtoRevNumberOfTrades_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_Query_GetProtoRevNumberOfTrades_0(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_GetProtoRevNumberOfTrades_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_GetProtoRevProfitsByDenom_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_Query_GetProtoRevProfitsByDenom_0(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_GetProtoRevProfitsByDenom_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_GetProtoRevAllProfits_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_Query_GetProtoRevAllProfits_0(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_GetProtoRevAllProfits_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_GetProtoRevStatisticsByPool_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_Query_GetProtoRevStatisticsByPool_0(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_GetProtoRevStatisticsByPool_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_GetProtoRevAllStatistics_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_Query_GetProtoRevAllStatistics_0(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_GetProtoRevAllStatistics_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_GetProtoRevTokenPairArbRoutes_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_Query_GetProtoRevTokenPairArbRoutes_0(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_GetProtoRevTokenPairArbRoutes_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + return nil +} + +var ( + pattern_Query_Params_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"osmosis", "v13", "protorev", "params"}, "", runtime.AssumeColonVerbOpt(false))) + + pattern_Query_GetProtoRevNumberOfTrades_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"osmosis", "v13", "protorev", "number_of_trades"}, "", runtime.AssumeColonVerbOpt(false))) + + pattern_Query_GetProtoRevProfitsByDenom_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"osmosis", "v13", "protorev", "profits_by_denom"}, "", runtime.AssumeColonVerbOpt(false))) + + pattern_Query_GetProtoRevAllProfits_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"osmosis", "v13", "protorev", "all_profits"}, "", runtime.AssumeColonVerbOpt(false))) + + pattern_Query_GetProtoRevStatisticsByPool_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"osmosis", "v13", "protorev", "statistics_by_pool"}, "", runtime.AssumeColonVerbOpt(false))) + + pattern_Query_GetProtoRevAllStatistics_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"osmosis", "v13", "protorev", "all_statistics"}, "", runtime.AssumeColonVerbOpt(false))) + + pattern_Query_GetProtoRevTokenPairArbRoutes_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"osmosis", "v13", "protorev", "token_pair_arb_routes"}, "", runtime.AssumeColonVerbOpt(false))) +) + +var ( + forward_Query_Params_0 = runtime.ForwardResponseMessage + + forward_Query_GetProtoRevNumberOfTrades_0 = runtime.ForwardResponseMessage + + forward_Query_GetProtoRevProfitsByDenom_0 = runtime.ForwardResponseMessage + + forward_Query_GetProtoRevAllProfits_0 = runtime.ForwardResponseMessage + + forward_Query_GetProtoRevStatisticsByPool_0 = runtime.ForwardResponseMessage + + forward_Query_GetProtoRevAllStatistics_0 = runtime.ForwardResponseMessage + + forward_Query_GetProtoRevTokenPairArbRoutes_0 = runtime.ForwardResponseMessage +) diff --git a/x/protorev/types/token_pair_arb_routes.go b/x/protorev/types/token_pair_arb_routes.go new file mode 100644 index 00000000000..a4c3879ed52 --- /dev/null +++ b/x/protorev/types/token_pair_arb_routes.go @@ -0,0 +1,69 @@ +package types + +import ( + "fmt" +) + +// Creates a new TokenPairArbRoutes object +func NewTokenPairArbRoutes(routes []*Route, tokenA, tokenB string) TokenPairArbRoutes { + return TokenPairArbRoutes{ + ArbRoutes: routes, + TokenIn: tokenA, + TokenOut: tokenB, + } +} + +func (tp *TokenPairArbRoutes) Validate() error { + // Validate that the token pair is valid + if tp.TokenIn == "" || tp.TokenOut == "" { + return fmt.Errorf("token names cannot be empty") + } + + // The list cannot be nil + if tp.ArbRoutes == nil { + return fmt.Errorf("the list of routes cannot be nil") + } + + // Iterate through all of the possible routes for this pool + for _, route := range tp.ArbRoutes { + if len(route.Trades) != 3 { + return fmt.Errorf("there must be exactly 3 trades in a route") + } + + // In denoms must match either osmo or atom + if route.Trades[0].TokenIn != AtomDenomination && route.Trades[0].TokenIn != OsmosisDenomination { + return fmt.Errorf("the first trade must have either osmo or atom as the in denom") + } + + // Out and in denoms must match + if route.Trades[0].TokenIn != route.Trades[2].TokenOut { + return fmt.Errorf("the first and last trades must have matching denoms") + } + + uniquePools := make(map[uint64]bool) + for _, trade := range route.Trades { + uniquePools[trade.Pool] = true + } + + // There must be at least three pools hops for it to be a valid route + if len(uniquePools) != 3 { + return fmt.Errorf("There must be exactly 3 unique pools in a route") + } + } + + return nil +} + +func NewRoutes(trades []*Trade) Route { + return Route{ + Trades: trades, + } +} + +func NewTrade(pool uint64, tokenA, tokenB string) Trade { + return Trade{ + Pool: pool, + TokenIn: tokenA, + TokenOut: tokenB, + } +} diff --git a/x/protorev/types/tx.pb.go b/x/protorev/types/tx.pb.go new file mode 100644 index 00000000000..47b30a0040b --- /dev/null +++ b/x/protorev/types/tx.pb.go @@ -0,0 +1,992 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: osmosis/protorev/v1beta1/tx.proto + +package types + +import ( + context "context" + fmt "fmt" + _ "github.com/gogo/protobuf/gogoproto" + grpc1 "github.com/gogo/protobuf/grpc" + proto "github.com/gogo/protobuf/proto" + _ "google.golang.org/genproto/googleapis/api/annotations" + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +// MsgSetHotRoutes defines the Msg/SetHotRoutes request type. +type MsgSetHotRoutes struct { + // admin is the account that is authorized to set the hot routes. + Admin string `protobuf:"bytes,1,opt,name=admin,proto3" json:"admin,omitempty"` + // hot_routes is the list of hot routes to set. + HotRoutes []*TokenPairArbRoutes `protobuf:"bytes,2,rep,name=hot_routes,json=hotRoutes,proto3" json:"hot_routes,omitempty"` +} + +func (m *MsgSetHotRoutes) Reset() { *m = MsgSetHotRoutes{} } +func (m *MsgSetHotRoutes) String() string { return proto.CompactTextString(m) } +func (*MsgSetHotRoutes) ProtoMessage() {} +func (*MsgSetHotRoutes) Descriptor() ([]byte, []int) { + return fileDescriptor_2783dce032fc6954, []int{0} +} +func (m *MsgSetHotRoutes) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgSetHotRoutes) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgSetHotRoutes.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *MsgSetHotRoutes) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgSetHotRoutes.Merge(m, src) +} +func (m *MsgSetHotRoutes) XXX_Size() int { + return m.Size() +} +func (m *MsgSetHotRoutes) XXX_DiscardUnknown() { + xxx_messageInfo_MsgSetHotRoutes.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgSetHotRoutes proto.InternalMessageInfo + +func (m *MsgSetHotRoutes) GetAdmin() string { + if m != nil { + return m.Admin + } + return "" +} + +func (m *MsgSetHotRoutes) GetHotRoutes() []*TokenPairArbRoutes { + if m != nil { + return m.HotRoutes + } + return nil +} + +// MsgSetHotRoutesResponse defines the Msg/SetHotRoutes response type. +type MsgSetHotRoutesResponse struct { +} + +func (m *MsgSetHotRoutesResponse) Reset() { *m = MsgSetHotRoutesResponse{} } +func (m *MsgSetHotRoutesResponse) String() string { return proto.CompactTextString(m) } +func (*MsgSetHotRoutesResponse) ProtoMessage() {} +func (*MsgSetHotRoutesResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_2783dce032fc6954, []int{1} +} +func (m *MsgSetHotRoutesResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgSetHotRoutesResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgSetHotRoutesResponse.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *MsgSetHotRoutesResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgSetHotRoutesResponse.Merge(m, src) +} +func (m *MsgSetHotRoutesResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgSetHotRoutesResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgSetHotRoutesResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgSetHotRoutesResponse proto.InternalMessageInfo + +// MsgSetDeveloperAccount defines the Msg/SetDeveloperAccount request type. +type MsgSetDeveloperAccount struct { + // admin is the account that is authorized to set the developer account. + Admin string `protobuf:"bytes,1,opt,name=admin,proto3" json:"admin,omitempty"` + // developer_account is the account that will receive a portion of the profits + // from the protorev module. + DeveloperAccount string `protobuf:"bytes,2,opt,name=developer_account,json=developerAccount,proto3" json:"developer_account,omitempty"` +} + +func (m *MsgSetDeveloperAccount) Reset() { *m = MsgSetDeveloperAccount{} } +func (m *MsgSetDeveloperAccount) String() string { return proto.CompactTextString(m) } +func (*MsgSetDeveloperAccount) ProtoMessage() {} +func (*MsgSetDeveloperAccount) Descriptor() ([]byte, []int) { + return fileDescriptor_2783dce032fc6954, []int{2} +} +func (m *MsgSetDeveloperAccount) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgSetDeveloperAccount) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgSetDeveloperAccount.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *MsgSetDeveloperAccount) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgSetDeveloperAccount.Merge(m, src) +} +func (m *MsgSetDeveloperAccount) XXX_Size() int { + return m.Size() +} +func (m *MsgSetDeveloperAccount) XXX_DiscardUnknown() { + xxx_messageInfo_MsgSetDeveloperAccount.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgSetDeveloperAccount proto.InternalMessageInfo + +func (m *MsgSetDeveloperAccount) GetAdmin() string { + if m != nil { + return m.Admin + } + return "" +} + +func (m *MsgSetDeveloperAccount) GetDeveloperAccount() string { + if m != nil { + return m.DeveloperAccount + } + return "" +} + +// MsgSetDeveloperAccountResponse defines the Msg/SetDeveloperAccount response +// type. +type MsgSetDeveloperAccountResponse struct { +} + +func (m *MsgSetDeveloperAccountResponse) Reset() { *m = MsgSetDeveloperAccountResponse{} } +func (m *MsgSetDeveloperAccountResponse) String() string { return proto.CompactTextString(m) } +func (*MsgSetDeveloperAccountResponse) ProtoMessage() {} +func (*MsgSetDeveloperAccountResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_2783dce032fc6954, []int{3} +} +func (m *MsgSetDeveloperAccountResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgSetDeveloperAccountResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgSetDeveloperAccountResponse.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *MsgSetDeveloperAccountResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgSetDeveloperAccountResponse.Merge(m, src) +} +func (m *MsgSetDeveloperAccountResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgSetDeveloperAccountResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgSetDeveloperAccountResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgSetDeveloperAccountResponse proto.InternalMessageInfo + +func init() { + proto.RegisterType((*MsgSetHotRoutes)(nil), "osmosis.protorev.v1beta1.MsgSetHotRoutes") + proto.RegisterType((*MsgSetHotRoutesResponse)(nil), "osmosis.protorev.v1beta1.MsgSetHotRoutesResponse") + proto.RegisterType((*MsgSetDeveloperAccount)(nil), "osmosis.protorev.v1beta1.MsgSetDeveloperAccount") + proto.RegisterType((*MsgSetDeveloperAccountResponse)(nil), "osmosis.protorev.v1beta1.MsgSetDeveloperAccountResponse") +} + +func init() { proto.RegisterFile("osmosis/protorev/v1beta1/tx.proto", fileDescriptor_2783dce032fc6954) } + +var fileDescriptor_2783dce032fc6954 = []byte{ + // 401 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x91, 0xcf, 0x4a, 0xeb, 0x40, + 0x14, 0xc6, 0x9b, 0x94, 0x7b, 0xa1, 0x73, 0x2f, 0xdc, 0x6b, 0x2c, 0x1a, 0x83, 0x84, 0x1a, 0x44, + 0x2b, 0x6d, 0x13, 0xd3, 0xba, 0x70, 0x5b, 0x71, 0x21, 0x48, 0x45, 0xa2, 0x2b, 0x5d, 0x94, 0x49, + 0x3b, 0xa4, 0xc1, 0x36, 0x27, 0x64, 0xa6, 0xa1, 0x6e, 0x7d, 0x02, 0xc1, 0x9d, 0x0f, 0xe2, 0x33, + 0xb8, 0x2c, 0xb8, 0x11, 0xdc, 0x48, 0xeb, 0x83, 0x88, 0x93, 0xa6, 0xa5, 0xb1, 0x41, 0xdd, 0xcd, + 0x9f, 0xdf, 0xf9, 0xbe, 0xef, 0x9c, 0x83, 0x36, 0x80, 0xf6, 0x80, 0xba, 0xd4, 0xf0, 0x03, 0x60, + 0x10, 0x90, 0xd0, 0x08, 0x4d, 0x9b, 0x30, 0x6c, 0x1a, 0x6c, 0xa0, 0xf3, 0x37, 0x49, 0x9e, 0x20, + 0x7a, 0x8c, 0xe8, 0x13, 0x44, 0xc9, 0x3b, 0xe0, 0x00, 0x7f, 0x35, 0x3e, 0x4e, 0x11, 0xa0, 0xac, + 0x3b, 0x00, 0x4e, 0x97, 0x18, 0xd8, 0x77, 0x0d, 0xec, 0x79, 0xc0, 0x30, 0x73, 0xc1, 0x9b, 0x94, + 0x2b, 0xdb, 0xa9, 0x86, 0x53, 0x79, 0x7e, 0xd0, 0x18, 0xfa, 0xd7, 0xa0, 0xce, 0x19, 0x61, 0x47, + 0xc0, 0x2c, 0xe8, 0x33, 0x42, 0xa5, 0x3c, 0xfa, 0x85, 0xdb, 0x3d, 0xd7, 0x93, 0x85, 0x82, 0x50, + 0xcc, 0x59, 0xd1, 0x45, 0x3a, 0x46, 0xa8, 0x03, 0xac, 0x19, 0x70, 0x46, 0x16, 0x0b, 0xd9, 0xe2, + 0x9f, 0x6a, 0x59, 0x4f, 0x0b, 0xad, 0x9f, 0xc3, 0x15, 0xf1, 0x4e, 0xb1, 0x1b, 0xd4, 0x03, 0x3b, + 0xd2, 0xb5, 0x72, 0x9d, 0xd8, 0x42, 0x5b, 0x43, 0xab, 0x09, 0x57, 0x8b, 0x50, 0x1f, 0x3c, 0x4a, + 0xb4, 0x4b, 0xb4, 0x12, 0x7d, 0x1d, 0x92, 0x90, 0x74, 0xc1, 0x27, 0x41, 0xbd, 0xd5, 0x82, 0xbe, + 0xc7, 0x52, 0x72, 0x95, 0xd0, 0x52, 0x3b, 0x26, 0x9b, 0x38, 0x42, 0x65, 0x91, 0x13, 0xff, 0xdb, + 0x09, 0x09, 0xad, 0x80, 0xd4, 0xc5, 0xe2, 0xb1, 0x7d, 0xf5, 0x45, 0x44, 0xd9, 0x06, 0x75, 0xa4, + 0x7b, 0x01, 0xfd, 0x9d, 0x9b, 0xca, 0x4e, 0x7a, 0xaf, 0x89, 0x56, 0x14, 0xf3, 0xdb, 0xe8, 0xb4, + 0xeb, 0xf2, 0xcd, 0xd3, 0xdb, 0x9d, 0xb8, 0xa5, 0x6d, 0x1a, 0xf1, 0xe2, 0x42, 0xb3, 0x36, 0x5b, + 0x1e, 0x25, 0xac, 0x39, 0x9b, 0xbe, 0xf4, 0x20, 0xa0, 0xe5, 0x45, 0x13, 0xda, 0xfd, 0xca, 0x38, + 0x59, 0xa1, 0xec, 0xff, 0xb4, 0x62, 0x9a, 0xb8, 0xc6, 0x13, 0x57, 0xb4, 0x52, 0x7a, 0xe2, 0x4f, + 0x7b, 0x39, 0x38, 0x79, 0x1c, 0xa9, 0xc2, 0x70, 0xa4, 0x0a, 0xaf, 0x23, 0x55, 0xb8, 0x1d, 0xab, + 0x99, 0xe1, 0x58, 0xcd, 0x3c, 0x8f, 0xd5, 0xcc, 0xc5, 0x9e, 0xe3, 0xb2, 0x4e, 0xdf, 0xd6, 0x5b, + 0xd0, 0x8b, 0x05, 0x2b, 0x5d, 0x6c, 0xd3, 0x39, 0xf5, 0xc1, 0x4c, 0x9f, 0x5d, 0xfb, 0x84, 0xda, + 0xbf, 0xf9, 0xbd, 0xf6, 0x1e, 0x00, 0x00, 0xff, 0xff, 0x16, 0x39, 0x91, 0x33, 0x60, 0x03, 0x00, + 0x00, +} + +// Reference imports to suppress errors if they are not otherwise used. +var _ context.Context +var _ grpc.ClientConn + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +const _ = grpc.SupportPackageIsVersion4 + +// MsgClient is the client API for Msg service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. +type MsgClient interface { + // SetHotRoutes sets the hot routes that will be explored when creating + // cyclic arbitrage routes. Can only be called by the admin account. + SetHotRoutes(ctx context.Context, in *MsgSetHotRoutes, opts ...grpc.CallOption) (*MsgSetHotRoutesResponse, error) + // SetDeveloperAccount sets the account that can withdraw a portion of the + // profits from the protorev module. This will be Skip's address. + SetDeveloperAccount(ctx context.Context, in *MsgSetDeveloperAccount, opts ...grpc.CallOption) (*MsgSetDeveloperAccountResponse, error) +} + +type msgClient struct { + cc grpc1.ClientConn +} + +func NewMsgClient(cc grpc1.ClientConn) MsgClient { + return &msgClient{cc} +} + +func (c *msgClient) SetHotRoutes(ctx context.Context, in *MsgSetHotRoutes, opts ...grpc.CallOption) (*MsgSetHotRoutesResponse, error) { + out := new(MsgSetHotRoutesResponse) + err := c.cc.Invoke(ctx, "/osmosis.protorev.v1beta1.Msg/SetHotRoutes", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *msgClient) SetDeveloperAccount(ctx context.Context, in *MsgSetDeveloperAccount, opts ...grpc.CallOption) (*MsgSetDeveloperAccountResponse, error) { + out := new(MsgSetDeveloperAccountResponse) + err := c.cc.Invoke(ctx, "/osmosis.protorev.v1beta1.Msg/SetDeveloperAccount", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// MsgServer is the server API for Msg service. +type MsgServer interface { + // SetHotRoutes sets the hot routes that will be explored when creating + // cyclic arbitrage routes. Can only be called by the admin account. + SetHotRoutes(context.Context, *MsgSetHotRoutes) (*MsgSetHotRoutesResponse, error) + // SetDeveloperAccount sets the account that can withdraw a portion of the + // profits from the protorev module. This will be Skip's address. + SetDeveloperAccount(context.Context, *MsgSetDeveloperAccount) (*MsgSetDeveloperAccountResponse, error) +} + +// UnimplementedMsgServer can be embedded to have forward compatible implementations. +type UnimplementedMsgServer struct { +} + +func (*UnimplementedMsgServer) SetHotRoutes(ctx context.Context, req *MsgSetHotRoutes) (*MsgSetHotRoutesResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method SetHotRoutes not implemented") +} +func (*UnimplementedMsgServer) SetDeveloperAccount(ctx context.Context, req *MsgSetDeveloperAccount) (*MsgSetDeveloperAccountResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method SetDeveloperAccount not implemented") +} + +func RegisterMsgServer(s grpc1.Server, srv MsgServer) { + s.RegisterService(&_Msg_serviceDesc, srv) +} + +func _Msg_SetHotRoutes_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgSetHotRoutes) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).SetHotRoutes(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/osmosis.protorev.v1beta1.Msg/SetHotRoutes", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).SetHotRoutes(ctx, req.(*MsgSetHotRoutes)) + } + return interceptor(ctx, in, info, handler) +} + +func _Msg_SetDeveloperAccount_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgSetDeveloperAccount) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).SetDeveloperAccount(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/osmosis.protorev.v1beta1.Msg/SetDeveloperAccount", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).SetDeveloperAccount(ctx, req.(*MsgSetDeveloperAccount)) + } + return interceptor(ctx, in, info, handler) +} + +var _Msg_serviceDesc = grpc.ServiceDesc{ + ServiceName: "osmosis.protorev.v1beta1.Msg", + HandlerType: (*MsgServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "SetHotRoutes", + Handler: _Msg_SetHotRoutes_Handler, + }, + { + MethodName: "SetDeveloperAccount", + Handler: _Msg_SetDeveloperAccount_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "osmosis/protorev/v1beta1/tx.proto", +} + +func (m *MsgSetHotRoutes) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *MsgSetHotRoutes) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgSetHotRoutes) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.HotRoutes) > 0 { + for iNdEx := len(m.HotRoutes) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.HotRoutes[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + } + if len(m.Admin) > 0 { + i -= len(m.Admin) + copy(dAtA[i:], m.Admin) + i = encodeVarintTx(dAtA, i, uint64(len(m.Admin))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgSetHotRoutesResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *MsgSetHotRoutesResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgSetHotRoutesResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *MsgSetDeveloperAccount) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *MsgSetDeveloperAccount) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgSetDeveloperAccount) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.DeveloperAccount) > 0 { + i -= len(m.DeveloperAccount) + copy(dAtA[i:], m.DeveloperAccount) + i = encodeVarintTx(dAtA, i, uint64(len(m.DeveloperAccount))) + i-- + dAtA[i] = 0x12 + } + if len(m.Admin) > 0 { + i -= len(m.Admin) + copy(dAtA[i:], m.Admin) + i = encodeVarintTx(dAtA, i, uint64(len(m.Admin))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgSetDeveloperAccountResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *MsgSetDeveloperAccountResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgSetDeveloperAccountResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func encodeVarintTx(dAtA []byte, offset int, v uint64) int { + offset -= sovTx(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *MsgSetHotRoutes) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Admin) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + if len(m.HotRoutes) > 0 { + for _, e := range m.HotRoutes { + l = e.Size() + n += 1 + l + sovTx(uint64(l)) + } + } + return n +} + +func (m *MsgSetHotRoutesResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *MsgSetDeveloperAccount) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Admin) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.DeveloperAccount) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + return n +} + +func (m *MsgSetDeveloperAccountResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func sovTx(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozTx(x uint64) (n int) { + return sovTx(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *MsgSetHotRoutes) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: MsgSetHotRoutes: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgSetHotRoutes: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Admin", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Admin = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field HotRoutes", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.HotRoutes = append(m.HotRoutes, &TokenPairArbRoutes{}) + if err := m.HotRoutes[len(m.HotRoutes)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgSetHotRoutesResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: MsgSetHotRoutesResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgSetHotRoutesResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgSetDeveloperAccount) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: MsgSetDeveloperAccount: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgSetDeveloperAccount: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Admin", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Admin = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field DeveloperAccount", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.DeveloperAccount = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgSetDeveloperAccountResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: MsgSetDeveloperAccountResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgSetDeveloperAccountResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipTx(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowTx + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowTx + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowTx + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthTx + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupTx + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthTx + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthTx = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowTx = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupTx = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/protorev/types/tx.pb.gw.go b/x/protorev/types/tx.pb.gw.go new file mode 100644 index 00000000000..665f12cc1f9 --- /dev/null +++ b/x/protorev/types/tx.pb.gw.go @@ -0,0 +1,254 @@ +// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT. +// source: osmosis/protorev/v1beta1/tx.proto + +/* +Package types is a reverse proxy. + +It translates gRPC into RESTful JSON APIs. +*/ +package types + +import ( + "context" + "io" + "net/http" + + "github.com/golang/protobuf/descriptor" + "github.com/golang/protobuf/proto" + "github.com/grpc-ecosystem/grpc-gateway/runtime" + "github.com/grpc-ecosystem/grpc-gateway/utilities" + "google.golang.org/grpc" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/grpclog" + "google.golang.org/grpc/metadata" + "google.golang.org/grpc/status" +) + +// Suppress "imported and not used" errors +var _ codes.Code +var _ io.Reader +var _ status.Status +var _ = runtime.String +var _ = utilities.NewDoubleArray +var _ = descriptor.ForMessage +var _ = metadata.Join + +var ( + filter_Msg_SetHotRoutes_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} +) + +func request_Msg_SetHotRoutes_0(ctx context.Context, marshaler runtime.Marshaler, client MsgClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq MsgSetHotRoutes + var metadata runtime.ServerMetadata + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Msg_SetHotRoutes_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := client.SetHotRoutes(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Msg_SetHotRoutes_0(ctx context.Context, marshaler runtime.Marshaler, server MsgServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq MsgSetHotRoutes + var metadata runtime.ServerMetadata + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Msg_SetHotRoutes_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := server.SetHotRoutes(ctx, &protoReq) + return msg, metadata, err + +} + +var ( + filter_Msg_SetDeveloperAccount_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} +) + +func request_Msg_SetDeveloperAccount_0(ctx context.Context, marshaler runtime.Marshaler, client MsgClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq MsgSetDeveloperAccount + var metadata runtime.ServerMetadata + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Msg_SetDeveloperAccount_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := client.SetDeveloperAccount(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Msg_SetDeveloperAccount_0(ctx context.Context, marshaler runtime.Marshaler, server MsgServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq MsgSetDeveloperAccount + var metadata runtime.ServerMetadata + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Msg_SetDeveloperAccount_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := server.SetDeveloperAccount(ctx, &protoReq) + return msg, metadata, err + +} + +// RegisterMsgHandlerServer registers the http handlers for service Msg to "mux". +// UnaryRPC :call MsgServer directly. +// StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. +// Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterMsgHandlerFromEndpoint instead. +func RegisterMsgHandlerServer(ctx context.Context, mux *runtime.ServeMux, server MsgServer) error { + + mux.Handle("POST", pattern_Msg_SetHotRoutes_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Msg_SetHotRoutes_0(rctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Msg_SetHotRoutes_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("POST", pattern_Msg_SetDeveloperAccount_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Msg_SetDeveloperAccount_0(rctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Msg_SetDeveloperAccount_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + return nil +} + +// RegisterMsgHandlerFromEndpoint is same as RegisterMsgHandler but +// automatically dials to "endpoint" and closes the connection when "ctx" gets done. +func RegisterMsgHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) { + conn, err := grpc.Dial(endpoint, opts...) + if err != nil { + return err + } + defer func() { + if err != nil { + if cerr := conn.Close(); cerr != nil { + grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) + } + return + } + go func() { + <-ctx.Done() + if cerr := conn.Close(); cerr != nil { + grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) + } + }() + }() + + return RegisterMsgHandler(ctx, mux, conn) +} + +// RegisterMsgHandler registers the http handlers for service Msg to "mux". +// The handlers forward requests to the grpc endpoint over "conn". +func RegisterMsgHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error { + return RegisterMsgHandlerClient(ctx, mux, NewMsgClient(conn)) +} + +// RegisterMsgHandlerClient registers the http handlers for service Msg +// to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "MsgClient". +// Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "MsgClient" +// doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in +// "MsgClient" to call the correct interceptors. +func RegisterMsgHandlerClient(ctx context.Context, mux *runtime.ServeMux, client MsgClient) error { + + mux.Handle("POST", pattern_Msg_SetHotRoutes_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_Msg_SetHotRoutes_0(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Msg_SetHotRoutes_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("POST", pattern_Msg_SetDeveloperAccount_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_Msg_SetDeveloperAccount_0(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Msg_SetDeveloperAccount_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + return nil +} + +var ( + pattern_Msg_SetHotRoutes_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"osmosis", "v13", "protorev", "set_hot_routes"}, "", runtime.AssumeColonVerbOpt(false))) + + pattern_Msg_SetDeveloperAccount_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"osmosis", "v13", "protorev", "set_developer_account"}, "", runtime.AssumeColonVerbOpt(false))) +) + +var ( + forward_Msg_SetHotRoutes_0 = runtime.ForwardResponseMessage + + forward_Msg_SetDeveloperAccount_0 = runtime.ForwardResponseMessage +) diff --git a/x/protorev/types/utils.go b/x/protorev/types/utils.go new file mode 100644 index 00000000000..3083a3e88a1 --- /dev/null +++ b/x/protorev/types/utils.go @@ -0,0 +1,32 @@ +package types + +// Checks if the matching variable matches one of the tokens and if so returns the other and true +func CheckMatchAndReturnOther(tokenA, tokenB, match string) (string, bool) { + if tokenA == match { + return tokenB, true + } else if tokenB == match { + return tokenA, true + } + return "", false +} + +func CreateSeacherRoutes(numRoutes int, swapIn, swapOut, tokenInDenom, tokenOutDenom string) TokenPairArbRoutes { + routes := make([]*Route, numRoutes) + for i := 0; i < numRoutes; i++ { + trades := make([]*Trade, 3) + + firstTrade := NewTrade(0, tokenInDenom, swapIn) + trades[0] = &firstTrade + + secondTrade := NewTrade(1, swapIn, swapOut) + trades[1] = &secondTrade + + thirdTrade := NewTrade(2, swapOut, tokenOutDenom) + trades[2] = &thirdTrade + + newRoutes := NewRoutes(trades) + routes[i] = &newRoutes + } + + return NewTokenPairArbRoutes(routes, swapIn, swapOut) +} From 223ae75d9d7dbbe305dd506932c759922e161000 Mon Sep 17 00:00:00 2001 From: David Terpay <35130517+davidterpay@users.noreply.github.com> Date: Fri, 9 Dec 2022 13:26:33 -0600 Subject: [PATCH 2/3] Protorev Basic Keeper + Epoch Hook (#3646) * setting up the keys for trading stores * trading store getters and setters * keeper testing * configuring epoch hook in app + implementing the hook + genesis state update * epoch testing * clean up docs + test suite * lint fixes * more documentation * updating token pair keys, refactoring deletion to use the same wrapper func, and moving around epoch code * creating a helper func to update the highest liquidity pools * renaming helper function --- app/keepers/keepers.go | 1 + x/protorev/genesis.go | 18 + x/protorev/keeper/epoch_hook.go | 117 +++++ x/protorev/keeper/epoch_hook_test.go | 80 +++ x/protorev/keeper/keeper_test.go | 710 +++++++++++++++++++++++++++ x/protorev/keeper/protorev.go | 137 ++++++ x/protorev/keeper/protorev_test.go | 171 +++++++ x/protorev/types/keys.go | 33 ++ x/protorev/types/utils.go | 2 +- 9 files changed, 1268 insertions(+), 1 deletion(-) create mode 100644 x/protorev/keeper/epoch_hook.go create mode 100644 x/protorev/keeper/epoch_hook_test.go create mode 100644 x/protorev/keeper/keeper_test.go create mode 100644 x/protorev/keeper/protorev.go create mode 100644 x/protorev/keeper/protorev_test.go diff --git a/app/keepers/keepers.go b/app/keepers/keepers.go index 9a7ab5643a5..f09606f249a 100644 --- a/app/keepers/keepers.go +++ b/app/keepers/keepers.go @@ -576,6 +576,7 @@ func (appKeepers *AppKeepers) SetupHooks() { appKeepers.SuperfluidKeeper.Hooks(), appKeepers.IncentivesKeeper.Hooks(), appKeepers.MintKeeper.Hooks(), + appKeepers.ProtoRevKeeper.EpochHooks(), ), ) diff --git a/x/protorev/genesis.go b/x/protorev/genesis.go index 0f6159b722a..3546dc850f6 100644 --- a/x/protorev/genesis.go +++ b/x/protorev/genesis.go @@ -16,6 +16,24 @@ func InitGenesis(ctx sdk.Context, k keeper.Keeper, genState types.GenesisState) // Init module parameters k.SetParams(ctx, genState.Params) + + // Update the pools on genesis + if err := k.UpdatePools(ctx); err != nil { + panic(err) + } + + // Init all of the searcher routes + for _, tokenPairArbRoutes := range genState.TokenPairs { + err := tokenPairArbRoutes.Validate() + if err != nil { + panic(err) + } + + _, err = k.SetTokenPairArbRoutes(ctx, tokenPairArbRoutes.TokenIn, tokenPairArbRoutes.TokenOut, &tokenPairArbRoutes) + if err != nil { + panic(err) + } + } } // ExportGenesis returns the module's exported genesis diff --git a/x/protorev/keeper/epoch_hook.go b/x/protorev/keeper/epoch_hook.go new file mode 100644 index 00000000000..5c431c84eba --- /dev/null +++ b/x/protorev/keeper/epoch_hook.go @@ -0,0 +1,117 @@ +package keeper + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + + epochstypes "github.com/osmosis-labs/osmosis/v13/x/epochs/types" + "github.com/osmosis-labs/osmosis/v13/x/protorev/types" +) + +type EpochHooks struct { + k Keeper +} + +// Struct used to track the pool with the highest liquidity +type LiquidityPoolStruct struct { + Liquidity sdk.Int + PoolId uint64 +} + +var ( + _ epochstypes.EpochHooks = EpochHooks{} +) + +func (k Keeper) EpochHooks() epochstypes.EpochHooks { + return EpochHooks{k} +} + +// BeforeEpochStart is the epoch start hook. +func (h EpochHooks) BeforeEpochStart(ctx sdk.Context, epochIdentifier string, epochNumber int64) error { + return nil +} + +// AfterEpochEnd is the epoch end hook. The module will update all of the pools in the store that are +// used for trading. +func (h EpochHooks) AfterEpochEnd(ctx sdk.Context, epochIdentifier string, epochNumber int64) error { + switch epochIdentifier { + case "week": + // Update the pools in the store + return h.k.UpdatePools(ctx) + } + return nil +} + +// Update pools requests the highest liquidity pools from the gamm module and updates the pools in the store +func (k Keeper) UpdatePools(ctx sdk.Context) error { + // Reset the pools in the store + k.DeleteAllAtomPools(ctx) + k.DeleteAllOsmoPools(ctx) + + // Get the highest liquidity pools + osmoPools, atomPools, err := k.GetHighestLiquidityPools(ctx) + if err != nil { + return err + } + + // Update the pools in the store + for token, poolInfo := range osmoPools { + k.SetOsmoPool(ctx, token, poolInfo.PoolId) + } + for token, poolInfo := range atomPools { + k.SetAtomPool(ctx, token, poolInfo.PoolId) + } + + return nil +} + +// GetHighestLiquidityPools returns the highest liquidity pools for pools that have Osmo or Atom +// and Osmo/Atom +func (k Keeper) GetHighestLiquidityPools(ctx sdk.Context) (map[string]LiquidityPoolStruct, map[string]LiquidityPoolStruct, error) { + // Get all pools + pools, err := k.gammKeeper.GetPoolsAndPoke(ctx) + if err != nil { + return nil, nil, err + } + + osmoPools := make(map[string]LiquidityPoolStruct) + atomPools := make(map[string]LiquidityPoolStruct) + + // Iterate through all pools and find valid matches + for _, pool := range pools { + coins := pool.GetTotalPoolLiquidity(ctx) + + // Pool must be active and the number of coins must be 2 + if pool.IsActive(ctx) && len(coins) == 2 { + tokenA := coins[0] + tokenB := coins[1] + + newPool := LiquidityPoolStruct{ + PoolId: pool.GetId(), + Liquidity: tokenA.Amount.Mul(tokenB.Amount), + } + + // Check if there is a match with osmo + if otherDenom, match := types.CheckOsmoAtomDenomMatch(tokenA.Denom, tokenB.Denom, types.OsmosisDenomination); match { + k.updateHighestLiquidityPool(otherDenom, osmoPools, newPool) + } + + // Check if there is a match with atom + if otherDenom, match := types.CheckOsmoAtomDenomMatch(tokenA.Denom, tokenB.Denom, types.AtomDenomination); match { + k.updateHighestLiquidityPool(otherDenom, atomPools, newPool) + } + } + } + + return osmoPools, atomPools, nil +} + +// updateHighestLiquidityPool updates the pool with the highest liquidity for either osmo or atom +func (k Keeper) updateHighestLiquidityPool(denom string, pool map[string]LiquidityPoolStruct, newPool LiquidityPoolStruct) { + if currPool, ok := pool[denom]; !ok { + pool[denom] = newPool + } else { + if newPool.Liquidity.GT(currPool.Liquidity) { + pool[denom] = newPool + } + } +} diff --git a/x/protorev/keeper/epoch_hook_test.go b/x/protorev/keeper/epoch_hook_test.go new file mode 100644 index 00000000000..b45bf347f77 --- /dev/null +++ b/x/protorev/keeper/epoch_hook_test.go @@ -0,0 +1,80 @@ +package keeper_test + +import ( + "fmt" + + "github.com/osmosis-labs/osmosis/v13/x/protorev/types" +) + +// TestEpochHook tests that the epoch hook is correctly setting the pool IDs for the osmo and atom pools. +// The epoch hook is run after the pools are set and committed in keeper_test.go. All of the pools are initialized in the setup function in keeper_test.go +// and are available in the suite.pools variable. The pools are filtered to only include the pools that +// have osmo or atom as one of the assets. The pools are then filtered again to only include the pools that +// have the highest liquidity. The pools are then checked to see if the pool IDs are correctly set in the +// osmo and atom stores. +func (suite *KeeperTestSuite) TestEpochHook() { + // All of the pools initialized in the setup function are available in keeper_test.go + // akash <-> types.OsmosisDenomination + // juno <-> types.OsmosisDenomination + // ethereum <-> types.OsmosisDenomination + // bitcoin <-> types.OsmosisDenomination + // canto <-> types.OsmosisDenomination + // and so on... + expectedToSee := make(map[string]Pool) + for _, pool := range suite.pools { + + // Module currently limited to two asset pools + // Instantiate asset and amounts for the pool + if len(pool.PoolAssets) == 2 { + pool.Asset1 = pool.PoolAssets[0].Token.Denom + pool.Amount1 = pool.PoolAssets[0].Token.Amount + pool.Asset2 = pool.PoolAssets[1].Token.Denom + pool.Amount2 = pool.PoolAssets[1].Token.Amount + } + + if pool.Asset1 == types.OsmosisDenomination || pool.Asset2 == types.OsmosisDenomination || pool.Asset1 == types.AtomDenomination || pool.Asset2 == types.AtomDenomination { + // create a key that is a combination of asset1 and asset2 in alphabetical order + key := fmt.Sprintf("%s-%s", pool.Asset1, pool.Asset2) + if pool.Asset1 > pool.Asset2 { + key = fmt.Sprintf("%s-%s", pool.Asset2, pool.Asset1) + } + + if storedPool, ok := expectedToSee[key]; !ok { + expectedToSee[key] = pool + } else { + liquidity := pool.Amount1.Mul(pool.Amount2) + if liquidity.GT(storedPool.Amount1.Mul(storedPool.Amount2)) { + expectedToSee[key] = pool + } + } + } + } + + // The epoch hook is run after the pools are set and committed so all that must be done is the stores must be checked if they are correctly set + for _, pool := range expectedToSee { + foundEitherOne := false + // Check if there is a match with osmo + if otherDenom, match := types.CheckOsmoAtomDenomMatch(pool.Asset1, pool.Asset2, types.OsmosisDenomination); match { + poolId, err := suite.App.AppKeepers.ProtoRevKeeper.GetOsmoPool(suite.Ctx, otherDenom) + + // pool ID must exist + suite.Require().NoError(err) + suite.Require().Equal(pool.PoolId, poolId) + + foundEitherOne = true + } + + // Check if there is a match with atom + if otherDenom, match := types.CheckOsmoAtomDenomMatch(pool.Asset1, pool.Asset2, types.AtomDenomination); match { + poolId, err := suite.App.AppKeepers.ProtoRevKeeper.GetAtomPool(suite.Ctx, otherDenom) + + // pool ID must exist + suite.Require().NoError(err) + suite.Require().Equal(poolId, poolId) + + foundEitherOne = true + } + + suite.Require().True(foundEitherOne) + } +} diff --git a/x/protorev/keeper/keeper_test.go b/x/protorev/keeper/keeper_test.go new file mode 100644 index 00000000000..02f2f88d863 --- /dev/null +++ b/x/protorev/keeper/keeper_test.go @@ -0,0 +1,710 @@ +package keeper_test + +import ( + "math/big" + "testing" + + "github.com/cosmos/cosmos-sdk/client" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/stretchr/testify/suite" + + "github.com/osmosis-labs/osmosis/v13/app/apptesting" + "github.com/osmosis-labs/osmosis/v13/x/protorev/types" + + "github.com/osmosis-labs/osmosis/v13/x/gamm/pool-models/balancer" + balancertypes "github.com/osmosis-labs/osmosis/v13/x/gamm/pool-models/balancer" + "github.com/osmosis-labs/osmosis/v13/x/gamm/pool-models/stableswap" + + osmosisapp "github.com/osmosis-labs/osmosis/v13/app" +) + +type KeeperTestSuite struct { + apptesting.KeeperTestHelper + + clientCtx client.Context + queryClient types.QueryClient + + pools []Pool + stableSwapPools []StableSwapPool + balances sdk.Coins + tokenPairArbRoutes []*types.TokenPairArbRoutes + adminAccount sdk.AccAddress +} + +type Pool struct { + PoolAssets []balancertypes.PoolAsset + Asset1 string + Asset2 string + Amount1 sdk.Int + Amount2 sdk.Int + SwapFee sdk.Dec + ExitFee sdk.Dec + PoolId uint64 +} + +type StableSwapPool struct { + initialLiquidity sdk.Coins + poolParams stableswap.PoolParams + scalingFactors []uint64 +} + +func TestKeeperTestSuite(t *testing.T) { + suite.Run(t, new(KeeperTestSuite)) +} + +func (suite *KeeperTestSuite) SetupTest() { + suite.Setup() + + encodingConfig := osmosisapp.MakeEncodingConfig() + suite.clientCtx = client.Context{}. + WithInterfaceRegistry(encodingConfig.InterfaceRegistry). + WithTxConfig(encodingConfig.TxConfig). + WithLegacyAmino(encodingConfig.Amino). + WithJSONCodec(encodingConfig.Marshaler) + + // Set default configuration for testing + suite.balances = sdk.NewCoins( + sdk.NewCoin(types.OsmosisDenomination, sdk.NewInt(9000000000000000000)), + sdk.NewCoin(types.AtomDenomination, sdk.NewInt(9000000000000000000)), + sdk.NewCoin("akash", sdk.NewInt(9000000000000000000)), + sdk.NewCoin("bitcoin", sdk.NewInt(9000000000000000000)), + sdk.NewCoin("canto", sdk.NewInt(9000000000000000000)), + sdk.NewCoin("ethereum", sdk.NewInt(9000000000000000000)), + sdk.NewCoin("juno", sdk.NewInt(9000000000000000000)), + sdk.NewCoin("ibc/0EF15DF2F02480ADE0BB6E85D9EBB5DAEA2836D3860E9F97F9AADE4F57A31AA0", sdk.NewInt(9000000000000000000)), + sdk.NewCoin("ibc/BE1BB42D4BE3C30D50B68D7C41DB4DFCE9678E8EF8C539F6E6A9345048894FCC", sdk.NewInt(9000000000000000000)), + sdk.NewCoin("ibc/D189335C6E4A68B513C10AB227BF1C1D38C746766278BA3EEB4FB14124F1D858", sdk.NewInt(9000000000000000000)), + sdk.NewCoin("ibc/0E43EDE2E2A3AFA36D0CD38BDDC0B49FECA64FA426A82E102F304E430ECF46EE", sdk.NewIntFromBigInt(big.NewInt(1).Mul(big.NewInt(9000000000000000000), big.NewInt(10000)))), + sdk.NewCoin("ibc/8242AD24008032E457D2E12D46588FD39FB54FB29680C6C7663D296B383C37C4", sdk.NewInt(9000000000000000000)), + sdk.NewCoin("usdc", sdk.NewInt(9000000000000000000)), + sdk.NewCoin("usdt", sdk.NewInt(9000000000000000000)), + sdk.NewCoin("busd", sdk.NewInt(9000000000000000000)), + sdk.NewCoin("ibc/A0CC0CF735BFB30E730C70019D4218A1244FF383503FF7579C9201AB93CA9293", sdk.NewInt(9000000000000000000)), + ) + suite.fundAllAccountsWith() + suite.Commit() + + // Init pools + suite.setUpPools() + suite.Commit() + + // Init search routes + suite.setUpTokenPairRoutes() + suite.Commit() +} + +// setUpPools sets up the pools needed for testing +// This creates several assets and pools between most of them (used in testing throughout the module) +// akash <-> types.OsmosisDenomination +// juno <-> types.OsmosisDenomination +// ethereum <-> types.OsmosisDenomination +// bitcoin <-> types.OsmosisDenomination +// canto <-> types.OsmosisDenomination +// and so on.... +func (suite *KeeperTestSuite) setUpPools() { + // Create any necessary sdk.Ints that require string conversion + pool28Amount1, ok := sdk.NewIntFromString("6170367464346955818920") + suite.Require().True(ok) + + // Init pools + suite.pools = []Pool{ + { // Pool 1 + PoolAssets: []balancertypes.PoolAsset{ + { + Token: sdk.NewCoin("akash", sdk.NewInt(1000)), + Weight: sdk.NewInt(1), + }, + { + Token: sdk.NewCoin(types.AtomDenomination, sdk.NewInt(1000)), + Weight: sdk.NewInt(1), + }, + }, + SwapFee: sdk.NewDecWithPrec(0, 2), + ExitFee: sdk.NewDecWithPrec(0, 2), + PoolId: 1, + }, + { // Pool 2 + PoolAssets: []balancertypes.PoolAsset{ + { + Token: sdk.NewCoin("juno", sdk.NewInt(1000)), + Weight: sdk.NewInt(1), + }, + { + Token: sdk.NewCoin(types.AtomDenomination, sdk.NewInt(1000)), + Weight: sdk.NewInt(1), + }, + }, + SwapFee: sdk.NewDecWithPrec(0, 2), + ExitFee: sdk.NewDecWithPrec(0, 2), + PoolId: 2, + }, + { // Pool 3 + PoolAssets: []balancertypes.PoolAsset{ + { + Token: sdk.NewCoin("ethereum", sdk.NewInt(1000)), + Weight: sdk.NewInt(1), + }, + { + Token: sdk.NewCoin(types.AtomDenomination, sdk.NewInt(1000)), + Weight: sdk.NewInt(1), + }, + }, + SwapFee: sdk.NewDecWithPrec(0, 2), + ExitFee: sdk.NewDecWithPrec(0, 2), + PoolId: 3, + }, + { // Pool 4 + PoolAssets: []balancertypes.PoolAsset{ + { + Token: sdk.NewCoin("bitcoin", sdk.NewInt(1000)), + Weight: sdk.NewInt(1), + }, + { + Token: sdk.NewCoin(types.AtomDenomination, sdk.NewInt(1000)), + Weight: sdk.NewInt(1), + }, + }, + SwapFee: sdk.NewDecWithPrec(0, 2), + ExitFee: sdk.NewDecWithPrec(0, 2), + PoolId: 4, + }, + { // Pool 5 + PoolAssets: []balancertypes.PoolAsset{ + { + Token: sdk.NewCoin("canto", sdk.NewInt(1000)), + Weight: sdk.NewInt(1), + }, + { + Token: sdk.NewCoin(types.AtomDenomination, sdk.NewInt(1000)), + Weight: sdk.NewInt(1), + }, + }, + SwapFee: sdk.NewDecWithPrec(0, 2), + ExitFee: sdk.NewDecWithPrec(0, 2), + PoolId: 5, + }, + { // Pool 6 + PoolAssets: []balancertypes.PoolAsset{ + { + Token: sdk.NewCoin(types.OsmosisDenomination, sdk.NewInt(1000)), + Weight: sdk.NewInt(1), + }, + { + Token: sdk.NewCoin(types.AtomDenomination, sdk.NewInt(1000)), + Weight: sdk.NewInt(1), + }, + }, + SwapFee: sdk.NewDecWithPrec(0, 2), + ExitFee: sdk.NewDecWithPrec(0, 2), + PoolId: 6, + }, + { // Pool 7 + PoolAssets: []balancertypes.PoolAsset{ + { + Token: sdk.NewCoin("akash", sdk.NewInt(1000)), + Weight: sdk.NewInt(1), + }, + { + Token: sdk.NewCoin(types.OsmosisDenomination, sdk.NewInt(1000)), + Weight: sdk.NewInt(1), + }, + }, + SwapFee: sdk.NewDecWithPrec(0, 2), + ExitFee: sdk.NewDecWithPrec(0, 2), + PoolId: 7, + }, + { // Pool 8 + PoolAssets: []balancertypes.PoolAsset{ + { + Token: sdk.NewCoin("juno", sdk.NewInt(1000)), + Weight: sdk.NewInt(1), + }, + { + Token: sdk.NewCoin(types.OsmosisDenomination, sdk.NewInt(1000)), + Weight: sdk.NewInt(1), + }, + }, + SwapFee: sdk.NewDecWithPrec(0, 2), + ExitFee: sdk.NewDecWithPrec(0, 2), + PoolId: 8, + }, + { // Pool 9 + PoolAssets: []balancertypes.PoolAsset{ + { + Token: sdk.NewCoin("ethereum", sdk.NewInt(1000)), + Weight: sdk.NewInt(1), + }, + { + Token: sdk.NewCoin(types.OsmosisDenomination, sdk.NewInt(1000)), + Weight: sdk.NewInt(1), + }, + }, + SwapFee: sdk.NewDecWithPrec(0, 2), + ExitFee: sdk.NewDecWithPrec(0, 2), + PoolId: 9, + }, + { // Pool 10 + PoolAssets: []balancertypes.PoolAsset{ + { + Token: sdk.NewCoin("bitcoin", sdk.NewInt(1000)), + Weight: sdk.NewInt(1), + }, + { + Token: sdk.NewCoin(types.OsmosisDenomination, sdk.NewInt(1000)), + Weight: sdk.NewInt(1), + }, + }, + SwapFee: sdk.NewDecWithPrec(0, 2), + ExitFee: sdk.NewDecWithPrec(0, 2), + PoolId: 10, + }, + { // Pool 11 + PoolAssets: []balancertypes.PoolAsset{ + { + Token: sdk.NewCoin("canto", sdk.NewInt(1000)), + Weight: sdk.NewInt(1), + }, + { + Token: sdk.NewCoin(types.OsmosisDenomination, sdk.NewInt(1000)), + Weight: sdk.NewInt(1), + }, + }, + SwapFee: sdk.NewDecWithPrec(0, 2), + ExitFee: sdk.NewDecWithPrec(0, 2), + PoolId: 11, + }, + { // Pool 12 + PoolAssets: []balancertypes.PoolAsset{ + { + Token: sdk.NewCoin("akash", sdk.NewInt(1000)), + Weight: sdk.NewInt(1), + }, + { + Token: sdk.NewCoin("juno", sdk.NewInt(1000)), + Weight: sdk.NewInt(1), + }, + }, + SwapFee: sdk.NewDecWithPrec(0, 2), + ExitFee: sdk.NewDecWithPrec(0, 2), + PoolId: 12, + }, + { // Pool 13 + PoolAssets: []balancertypes.PoolAsset{ + { + Token: sdk.NewCoin("akash", sdk.NewInt(1000)), + Weight: sdk.NewInt(1), + }, + { + Token: sdk.NewCoin("ethereum", sdk.NewInt(1000)), + Weight: sdk.NewInt(1), + }, + }, + SwapFee: sdk.NewDecWithPrec(0, 2), + ExitFee: sdk.NewDecWithPrec(0, 2), + PoolId: 13, + }, + { // Pool 14 + PoolAssets: []balancertypes.PoolAsset{ + { + Token: sdk.NewCoin("akash", sdk.NewInt(1000)), + Weight: sdk.NewInt(1), + }, + { + Token: sdk.NewCoin("bitcoin", sdk.NewInt(1000)), + Weight: sdk.NewInt(1), + }, + }, + SwapFee: sdk.NewDecWithPrec(0, 2), + ExitFee: sdk.NewDecWithPrec(0, 2), + PoolId: 14, + }, + { // Pool 15 + PoolAssets: []balancertypes.PoolAsset{ + { + Token: sdk.NewCoin("akash", sdk.NewInt(1000)), + Weight: sdk.NewInt(1), + }, + { + Token: sdk.NewCoin("canto", sdk.NewInt(1000)), + Weight: sdk.NewInt(1), + }, + }, + SwapFee: sdk.NewDecWithPrec(0, 2), + ExitFee: sdk.NewDecWithPrec(0, 2), + PoolId: 15, + }, + { // Pool 16 + PoolAssets: []balancertypes.PoolAsset{ + { + Token: sdk.NewCoin("juno", sdk.NewInt(1000)), + Weight: sdk.NewInt(1), + }, + { + Token: sdk.NewCoin("ethereum", sdk.NewInt(1000)), + Weight: sdk.NewInt(1), + }, + }, + SwapFee: sdk.NewDecWithPrec(0, 2), + ExitFee: sdk.NewDecWithPrec(0, 2), + PoolId: 16, + }, + { // Pool 17 + PoolAssets: []balancertypes.PoolAsset{ + { + Token: sdk.NewCoin("juno", sdk.NewInt(1000)), + Weight: sdk.NewInt(1), + }, + { + Token: sdk.NewCoin("bitcoin", sdk.NewInt(1000)), + Weight: sdk.NewInt(1), + }, + }, + SwapFee: sdk.NewDecWithPrec(0, 2), + ExitFee: sdk.NewDecWithPrec(0, 2), + PoolId: 17, + }, + { // Pool 18 + PoolAssets: []balancertypes.PoolAsset{ + { + Token: sdk.NewCoin("juno", sdk.NewInt(1000)), + Weight: sdk.NewInt(1), + }, + { + Token: sdk.NewCoin("canto", sdk.NewInt(1000)), + Weight: sdk.NewInt(1), + }, + }, + SwapFee: sdk.NewDecWithPrec(0, 2), + ExitFee: sdk.NewDecWithPrec(0, 2), + PoolId: 18, + }, + { // Pool 19 + PoolAssets: []balancertypes.PoolAsset{ + { + Token: sdk.NewCoin("ethereum", sdk.NewInt(1000)), + Weight: sdk.NewInt(1), + }, + { + Token: sdk.NewCoin("bitcoin", sdk.NewInt(1000)), + Weight: sdk.NewInt(1), + }, + }, + SwapFee: sdk.NewDecWithPrec(0, 2), + ExitFee: sdk.NewDecWithPrec(0, 2), + PoolId: 19, + }, + { // Pool 20 + PoolAssets: []balancertypes.PoolAsset{ + { + Token: sdk.NewCoin("ethereum", sdk.NewInt(1000)), + Weight: sdk.NewInt(1), + }, + { + Token: sdk.NewCoin("canto", sdk.NewInt(1000)), + Weight: sdk.NewInt(1), + }, + }, + SwapFee: sdk.NewDecWithPrec(0, 2), + ExitFee: sdk.NewDecWithPrec(0, 2), + PoolId: 20, + }, + { // Pool 21 + PoolAssets: []balancertypes.PoolAsset{ + { + Token: sdk.NewCoin("bitcoin", sdk.NewInt(1000)), + Weight: sdk.NewInt(1), + }, + { + Token: sdk.NewCoin("canto", sdk.NewInt(1000)), + Weight: sdk.NewInt(1), + }, + }, + SwapFee: sdk.NewDecWithPrec(0, 2), + ExitFee: sdk.NewDecWithPrec(0, 2), + PoolId: 21, + }, + { // Pool 22 + PoolAssets: []balancertypes.PoolAsset{ + { + Token: sdk.NewCoin("ibc/BE1BB42D4BE3C30D50B68D7C41DB4DFCE9678E8EF8C539F6E6A9345048894FCC", sdk.NewInt(18986995439401)), + Weight: sdk.NewInt(1), + }, + { + Token: sdk.NewCoin(types.OsmosisDenomination, sdk.NewInt(191801648570)), + Weight: sdk.NewInt(1), + }, + }, + SwapFee: sdk.NewDecWithPrec(2, 3), + ExitFee: sdk.NewDecWithPrec(0, 2), + PoolId: 22, + }, + { // Pool 23 + PoolAssets: []balancertypes.PoolAsset{ + { + Token: sdk.NewCoin("ibc/0EF15DF2F02480ADE0BB6E85D9EBB5DAEA2836D3860E9F97F9AADE4F57A31AA0", sdk.NewInt(72765460013038)), + Weight: sdk.NewInt(1), + }, + { + Token: sdk.NewCoin("ibc/BE1BB42D4BE3C30D50B68D7C41DB4DFCE9678E8EF8C539F6E6A9345048894FCC", sdk.NewInt(596032233122)), + Weight: sdk.NewInt(1), + }, + }, + SwapFee: sdk.NewDecWithPrec(535, 5), + ExitFee: sdk.NewDecWithPrec(0, 2), + PoolId: 23, + }, + { // Pool 24 + PoolAssets: []balancertypes.PoolAsset{ + { + Token: sdk.NewCoin("ibc/0EF15DF2F02480ADE0BB6E85D9EBB5DAEA2836D3860E9F97F9AADE4F57A31AA0", sdk.NewInt(165624820984787)), + Weight: sdk.NewInt(1), + }, + { + Token: sdk.NewCoin(types.OsmosisDenomination, sdk.NewInt(13901565323)), + Weight: sdk.NewInt(1), + }, + }, + SwapFee: sdk.NewDecWithPrec(2, 3), + ExitFee: sdk.NewDecWithPrec(0, 2), + PoolId: 24, + }, + { // Pool 25 + PoolAssets: []balancertypes.PoolAsset{ + { + Token: sdk.NewCoin(types.AtomDenomination, sdk.NewInt(165624820984787)), + Weight: sdk.NewInt(1), + }, + { + Token: sdk.NewCoin(types.OsmosisDenomination, sdk.NewInt(139015653231902)), + Weight: sdk.NewInt(1), + }, + }, + SwapFee: sdk.NewDecWithPrec(2, 3), + ExitFee: sdk.NewDecWithPrec(0, 2), + PoolId: 25, + }, + { // Pool 26 + PoolAssets: []balancertypes.PoolAsset{ + { + Token: sdk.NewCoin("ibc/BE1BB42D4BE3C30D50B68D7C41DB4DFCE9678E8EF8C539F6E6A9345048894FCC", sdk.NewInt(13305396712237)), + Weight: sdk.NewInt(50), + }, + { + Token: sdk.NewCoin(types.OsmosisDenomination, sdk.NewInt(171274446980)), + Weight: sdk.NewInt(50), + }, + }, + SwapFee: sdk.NewDecWithPrec(2, 3), + ExitFee: sdk.NewDecWithPrec(0, 2), + PoolId: 26, + }, + { // Pool 27 + PoolAssets: []balancertypes.PoolAsset{ + { + Token: sdk.NewCoin("ibc/D189335C6E4A68B513C10AB227BF1C1D38C746766278BA3EEB4FB14124F1D858", sdk.NewInt(15766179414665)), + Weight: sdk.NewInt(50), + }, + { + Token: sdk.NewCoin(types.OsmosisDenomination, sdk.NewInt(13466662920841)), + Weight: sdk.NewInt(50), + }, + }, + SwapFee: sdk.NewDecWithPrec(2, 3), + ExitFee: sdk.NewDecWithPrec(0, 2), + PoolId: 27, + }, + { // Pool 28 + PoolAssets: []balancertypes.PoolAsset{ + { + Token: sdk.NewCoin("ibc/0E43EDE2E2A3AFA36D0CD38BDDC0B49FECA64FA426A82E102F304E430ECF46EE", pool28Amount1), + Weight: sdk.NewInt(25), + }, + { + Token: sdk.NewCoin("ibc/8242AD24008032E457D2E12D46588FD39FB54FB29680C6C7663D296B383C37C4", sdk.NewInt(6073813312)), + Weight: sdk.NewInt(25), + }, + { + Token: sdk.NewCoin("ibc/BE1BB42D4BE3C30D50B68D7C41DB4DFCE9678E8EF8C539F6E6A9345048894FCC", sdk.NewInt(403568175601)), + Weight: sdk.NewInt(25), + }, + { + Token: sdk.NewCoin("ibc/D189335C6E4A68B513C10AB227BF1C1D38C746766278BA3EEB4FB14124F1D858", sdk.NewInt(6120465766)), + Weight: sdk.NewInt(25), + }, + }, + SwapFee: sdk.NewDecWithPrec(4, 4), + ExitFee: sdk.NewDecWithPrec(0, 2), + PoolId: 28, + }, + { // Pool 29 + PoolAssets: []balancertypes.PoolAsset{ + { + Token: sdk.NewCoin("uosmo", sdk.NewInt(1000000000)), + Weight: sdk.NewInt(1), + }, + { + Token: sdk.NewCoin("usdc", sdk.NewInt(2000000000)), + Weight: sdk.NewInt(1), + }, + }, + SwapFee: sdk.NewDecWithPrec(2, 3), + ExitFee: sdk.NewDecWithPrec(0, 2), + PoolId: 29, + }, + { // Pool 30 + PoolAssets: []balancertypes.PoolAsset{ + { + Token: sdk.NewCoin("uosmo", sdk.NewInt(1000000000)), + Weight: sdk.NewInt(1), + }, + { + Token: sdk.NewCoin("busd", sdk.NewInt(1000000000)), + Weight: sdk.NewInt(1), + }, + }, + SwapFee: sdk.NewDecWithPrec(2, 3), + ExitFee: sdk.NewDecWithPrec(0, 2), + PoolId: 30, + }, + { // Pool 31 + PoolAssets: []balancertypes.PoolAsset{ + { + Token: sdk.NewCoin("ibc/0E43EDE2E2A3AFA36D0CD38BDDC0B49FECA64FA426A82E102F304E430ECF46EE", pool28Amount1), // Amount didn't change on mainnet + Weight: sdk.NewInt(25), + }, + { + Token: sdk.NewCoin("ibc/8242AD24008032E457D2E12D46588FD39FB54FB29680C6C7663D296B383C37C4", sdk.NewInt(6073813312)), + Weight: sdk.NewInt(25), + }, + { + Token: sdk.NewCoin("ibc/BE1BB42D4BE3C30D50B68D7C41DB4DFCE9678E8EF8C539F6E6A9345048894FCC", sdk.NewInt(403523315860)), + Weight: sdk.NewInt(25), + }, + { + Token: sdk.NewCoin("ibc/D189335C6E4A68B513C10AB227BF1C1D38C746766278BA3EEB4FB14124F1D858", sdk.NewInt(6121181710)), + Weight: sdk.NewInt(25), + }, + }, + SwapFee: sdk.NewDecWithPrec(4, 4), + ExitFee: sdk.NewDecWithPrec(0, 2), + PoolId: 31, + }, + { // Pool 32 + PoolAssets: []balancertypes.PoolAsset{ + { + Token: sdk.NewCoin("ibc/A0CC0CF735BFB30E730C70019D4218A1244FF383503FF7579C9201AB93CA9293", sdk.NewInt(23583984695)), + Weight: sdk.NewInt(70), + }, + { + Token: sdk.NewCoin("ibc/BE1BB42D4BE3C30D50B68D7C41DB4DFCE9678E8EF8C539F6E6A9345048894FCC", sdk.NewInt(381295003769)), + Weight: sdk.NewInt(30), + }, + }, + SwapFee: sdk.NewDecWithPrec(3, 3), + ExitFee: sdk.NewDecWithPrec(0, 2), + PoolId: 32, + }, + { // Pool 33 + PoolAssets: []balancertypes.PoolAsset{ + { + Token: sdk.NewCoin("ibc/A0CC0CF735BFB30E730C70019D4218A1244FF383503FF7579C9201AB93CA9293", sdk.NewInt(41552173575)), + Weight: sdk.NewInt(70), + }, + { + Token: sdk.NewCoin("ibc/D189335C6E4A68B513C10AB227BF1C1D38C746766278BA3EEB4FB14124F1D858", sdk.NewInt(10285796639)), + Weight: sdk.NewInt(30), + }, + }, + SwapFee: sdk.NewDecWithPrec(3, 3), + ExitFee: sdk.NewDecWithPrec(0, 2), + PoolId: 33, + }, + } + + for _, pool := range suite.pools { + suite.createGAMMPool(pool.PoolAssets, pool.SwapFee, pool.ExitFee) + } + + suite.stableSwapPools = []StableSwapPool{ + { // Pool 34 + initialLiquidity: sdk.NewCoins( + sdk.NewCoin("usdc", sdk.NewInt(1000000000000000)), + sdk.NewCoin("usdt", sdk.NewInt(1000000000000000)), + sdk.NewCoin("busd", sdk.NewInt(1000000000000000)), + ), + poolParams: stableswap.PoolParams{ + SwapFee: sdk.NewDecWithPrec(1, 4), + ExitFee: sdk.NewDecWithPrec(0, 2), + }, + scalingFactors: []uint64{1, 1, 1}, + }} + + for _, pool := range suite.stableSwapPools { + suite.createStableswapPool(pool.initialLiquidity, pool.poolParams, pool.scalingFactors) + } + + // Set all of the pool info into the stores + suite.App.AppKeepers.ProtoRevKeeper.EpochHooks().AfterEpochEnd(suite.Ctx, "week", 1) +} + +// createStableswapPool creates a stableswap pool with the given pool assets and params +func (suite *KeeperTestSuite) createStableswapPool(initialLiquidity sdk.Coins, poolParams stableswap.PoolParams, scalingFactors []uint64) { + _, err := suite.App.GAMMKeeper.CreatePool( + suite.Ctx, + stableswap.NewMsgCreateStableswapPool(suite.TestAccs[1], poolParams, initialLiquidity, scalingFactors, "")) + suite.Require().NoError(err) +} + +// createGAMMPool creates a balancer pool with the given pool assets and params +func (suite *KeeperTestSuite) createGAMMPool(poolAssets []balancertypes.PoolAsset, swapFee, exitFee sdk.Dec) uint64 { + poolParams := balancertypes.PoolParams{ + SwapFee: swapFee, + ExitFee: exitFee, + } + + return suite.prepareCustomBalancerPool(poolAssets, poolParams) +} + +// prepareCustomBalancerPool creates a custom balancer pool with the given pool assets and params +func (suite *KeeperTestSuite) prepareCustomBalancerPool( + poolAssets []balancertypes.PoolAsset, + poolParams balancer.PoolParams, +) uint64 { + poolID, err := suite.App.GAMMKeeper.CreatePool( + suite.Ctx, + balancer.NewMsgCreateBalancerPool(suite.TestAccs[1], poolParams, poolAssets, ""), + ) + suite.Require().NoError(err) + + return poolID +} + +// fundAllAccountsWith funds all the test accounts with the same amount of tokens +func (suite *KeeperTestSuite) fundAllAccountsWith() { + for _, acc := range suite.TestAccs { + suite.FundAcc(acc, suite.balances) + } +} + +// setUpTokenPairRoutes sets up the searcher routes for testing +func (suite *KeeperTestSuite) setUpTokenPairRoutes() { + atomAkash := types.NewTrade(0, types.AtomDenomination, "akash") + akashBitcoin := types.NewTrade(14, "akash", "bitcoin") + atomBitcoin := types.NewTrade(4, "bitcoin", types.AtomDenomination) + + suite.tokenPairArbRoutes = []*types.TokenPairArbRoutes{ + { + TokenIn: "akash", + TokenOut: types.AtomDenomination, + ArbRoutes: []*types.Route{ + { + Trades: []*types.Trade{&atomAkash, &akashBitcoin, &atomBitcoin}, + }, + }, + }, + } + + for _, tokenPair := range suite.tokenPairArbRoutes { + suite.App.AppKeepers.ProtoRevKeeper.SetTokenPairArbRoutes(suite.Ctx, tokenPair.TokenIn, tokenPair.TokenOut, tokenPair) + } +} diff --git a/x/protorev/keeper/protorev.go b/x/protorev/keeper/protorev.go new file mode 100644 index 00000000000..a3711e8795f --- /dev/null +++ b/x/protorev/keeper/protorev.go @@ -0,0 +1,137 @@ +package keeper + +import ( + "fmt" + + "github.com/osmosis-labs/osmosis/v13/x/protorev/types" + + "github.com/cosmos/cosmos-sdk/store/prefix" + sdk "github.com/cosmos/cosmos-sdk/types" +) + +// ---------------------- Trading Stores ---------------------- // + +// GetTokenPairArbRoutes returns the token pair arb routes given two denoms +func (k Keeper) GetTokenPairArbRoutes(ctx sdk.Context, tokenA, tokenB string) (*types.TokenPairArbRoutes, error) { + store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefixTokenPairRoutes) + key := types.GetKeyPrefixRouteForTokenPair(tokenA, tokenB) + + bz := store.Get(key) + if len(bz) == 0 { + return nil, fmt.Errorf("no routes found for token pair %s-%s", tokenA, tokenB) + } + + tokenPairArbRoutes := &types.TokenPairArbRoutes{} + err := tokenPairArbRoutes.Unmarshal(bz) + if err != nil { + return nil, err + } + + return tokenPairArbRoutes, nil +} + +// GetAllTokenPairArbRoutes returns all the token pair arb routes +func (k Keeper) GetAllTokenPairArbRoutes(ctx sdk.Context) ([]*types.TokenPairArbRoutes, error) { + routes := make([]*types.TokenPairArbRoutes, 0) + + store := ctx.KVStore(k.storeKey) + iterator := sdk.KVStorePrefixIterator(store, types.KeyPrefixTokenPairRoutes) + + defer iterator.Close() + for ; iterator.Valid(); iterator.Next() { + tokenPairArbRoutes := &types.TokenPairArbRoutes{} + err := tokenPairArbRoutes.Unmarshal(iterator.Value()) + if err != nil { + return nil, err + } + + routes = append(routes, tokenPairArbRoutes) + } + + return routes, nil +} + +// SetTokenPairArbRoutes sets the token pair arb routes given two denoms +func (k Keeper) SetTokenPairArbRoutes(ctx sdk.Context, tokenA, tokenB string, tokenPair *types.TokenPairArbRoutes) (*types.TokenPairArbRoutes, error) { + store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefixTokenPairRoutes) + key := types.GetKeyPrefixRouteForTokenPair(tokenA, tokenB) + + bz, err := tokenPair.Marshal() + if err != nil { + return tokenPair, err + } + + store.Set(key, bz) + + return tokenPair, nil +} + +// DeleteAllTokenPairArbRoutes deletes all the token pair arb routes +func (k Keeper) DeleteAllTokenPairArbRoutes(ctx sdk.Context) { + k.DeleteAllEntriesForKeyPrefix(ctx, types.KeyPrefixTokenPairRoutes) +} + +// GetOsmoPool returns the pool id of the Osmo pool for the given denom paired with Osmo +func (k Keeper) GetOsmoPool(ctx sdk.Context, denom string) (uint64, error) { + store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefixOsmoPools) + key := types.GetKeyPrefixOsmoPool(denom) + + bz := store.Get(key) + if len(bz) == 0 { + return 0, fmt.Errorf("no osmo pool for denom %s", denom) + } + + poolId := sdk.BigEndianToUint64(bz) + return poolId, nil +} + +// SetOsmoPool sets the pool id of the Osmo pool for the given denom paired with Osmo +func (k Keeper) SetOsmoPool(ctx sdk.Context, denom string, poolId uint64) { + store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefixOsmoPools) + key := types.GetKeyPrefixOsmoPool(denom) + + store.Set(key, sdk.Uint64ToBigEndian(poolId)) +} + +// DeleteAllOsmoPools deletes all the Osmo pools from modules store +func (k Keeper) DeleteAllOsmoPools(ctx sdk.Context) { + k.DeleteAllEntriesForKeyPrefix(ctx, types.KeyPrefixOsmoPools) +} + +// GetAtomPool returns the pool id of the Atom pool for the given denom paired with Atom +func (k Keeper) GetAtomPool(ctx sdk.Context, denom string) (uint64, error) { + store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefixAtomPools) + key := types.GetKeyPrefixAtomPool(denom) + + bz := store.Get(key) + if len(bz) == 0 { + return 0, fmt.Errorf("no atom pool for denom %s", denom) + } + + poolId := sdk.BigEndianToUint64(bz) + return poolId, nil +} + +// SetAtomPool sets the pool id of the Atom pool for the given denom paired with Atom +func (k Keeper) SetAtomPool(ctx sdk.Context, denom string, poolId uint64) { + store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefixAtomPools) + key := types.GetKeyPrefixAtomPool(denom) + + store.Set(key, sdk.Uint64ToBigEndian(poolId)) +} + +// DeleteAllAtomPools deletes all the Atom pools from modules store +func (k Keeper) DeleteAllAtomPools(ctx sdk.Context) { + k.DeleteAllEntriesForKeyPrefix(ctx, types.KeyPrefixAtomPools) +} + +// DeleteAllEntriesForKeyPrefix deletes all the entries from the store for the given key prefix +func (k Keeper) DeleteAllEntriesForKeyPrefix(ctx sdk.Context, keyPrefix []byte) { + store := ctx.KVStore(k.storeKey) + iterator := sdk.KVStorePrefixIterator(store, keyPrefix) + + defer iterator.Close() + for ; iterator.Valid(); iterator.Next() { + store.Delete(iterator.Key()) + } +} diff --git a/x/protorev/keeper/protorev_test.go b/x/protorev/keeper/protorev_test.go new file mode 100644 index 00000000000..87e0e4b90af --- /dev/null +++ b/x/protorev/keeper/protorev_test.go @@ -0,0 +1,171 @@ +package keeper_test + +import "github.com/osmosis-labs/osmosis/v13/x/protorev/types" + +// TestGetAtomPool tests the GetAtomPool function. +func (suite *KeeperTestSuite) TestGetAtomPool() { + cases := []struct { + description string + denom string + expectedPool uint64 + exists bool + }{ + { + description: "Atom pool exists for denom Akash", + denom: "akash", + expectedPool: 1, + exists: true, + }, + { + description: "Atom pool exists for denom juno", + denom: "juno", + expectedPool: 2, + exists: true, + }, + { + description: "Atom pool exists for denom juno with different casing", + denom: "JuNo", + expectedPool: 2, + exists: false, + }, + { + description: "Atom pool exists for denom Ethereum", + denom: "ethereum", + expectedPool: 3, + exists: true, + }, + { + description: "Atom pool does not exist for denom doge", + denom: "doge", + expectedPool: 0, + exists: false, + }, + } + + for _, tc := range cases { + suite.Run(tc.description, func() { + pool, err := suite.App.ProtoRevKeeper.GetAtomPool(suite.Ctx, tc.denom) + + if tc.exists { + suite.Require().NoError(err) + suite.Require().Equal(tc.expectedPool, pool) + } else { + suite.Require().Error(err) + } + }) + } +} + +// TestDeleteAllAtomPools tests the DeleteAllAtomPools function. +func (suite *KeeperTestSuite) TestDeleteAllAtomPools() { + suite.App.AppKeepers.ProtoRevKeeper.DeleteAllAtomPools(suite.Ctx) + + // Iterate through all of the pools and check if any paired with Atom exist + for _, pool := range suite.pools { + if otherDenom, match := types.CheckOsmoAtomDenomMatch(pool.Asset1, pool.Asset2, types.AtomDenomination); match { + _, err := suite.App.AppKeepers.ProtoRevKeeper.GetAtomPool(suite.Ctx, otherDenom) + suite.Require().Error(err) + } + } +} + +// TestGetOsmoPool tests the GetOsmoPool function. +func (suite *KeeperTestSuite) TestGetOsmoPool() { + cases := []struct { + description string + denom string + expectedPool uint64 + exists bool + }{ + { + description: "Osmo pool exists for denom Akash", + denom: "akash", + expectedPool: 7, + exists: true, + }, + { + description: "Osmo pool exists for denom juno", + denom: "juno", + expectedPool: 8, + exists: true, + }, + { + description: "Empty string returns error", + denom: "", + expectedPool: 0, + exists: false, + }, + } + + for _, tc := range cases { + suite.Run(tc.description, func() { + pool, err := suite.App.ProtoRevKeeper.GetOsmoPool(suite.Ctx, tc.denom) + + if tc.exists { + suite.Require().NoError(err) + suite.Require().Equal(tc.expectedPool, pool) + } else { + suite.Require().Error(err) + } + }) + } + +} + +// TestDeleteAllOsmoPools tests the DeleteAllOsmoPools function. +func (suite *KeeperTestSuite) TestDeleteAllOsmoPools() { + suite.App.AppKeepers.ProtoRevKeeper.DeleteAllOsmoPools(suite.Ctx) + + // Iterate through all of the pools and check if any paired with Osmo exist + for _, pool := range suite.pools { + if otherDenom, match := types.CheckOsmoAtomDenomMatch(pool.Asset1, pool.Asset2, types.OsmosisDenomination); match { + _, err := suite.App.AppKeepers.ProtoRevKeeper.GetOsmoPool(suite.Ctx, otherDenom) + suite.Require().Error(err) + } + } +} + +// TestGetTokenPairArbRoutes tests the GetTokenPairArbRoutes function. +func (suite *KeeperTestSuite) TestGetTokenPairArbRoutes() { + // Tests that we can properly retrieve all of the routes that were set up + for _, tokenPair := range suite.tokenPairArbRoutes { + tokenPairArbRoutes, err := suite.App.ProtoRevKeeper.GetTokenPairArbRoutes(suite.Ctx, tokenPair.TokenIn, tokenPair.TokenOut) + + suite.Require().NoError(err) + suite.Require().Equal(tokenPair, tokenPairArbRoutes) + } + + // Testing to see if we will not find a route that does not exist + _, err := suite.App.ProtoRevKeeper.GetTokenPairArbRoutes(suite.Ctx, "osmo", "abc") + suite.Require().Error(err) +} + +// TestGetAllTokenPairArbRoutes tests the GetAllTokenPairArbRoutes function. +func (suite *KeeperTestSuite) TestGetAllTokenPairArbRoutes() { + // Tests that we can properly retrieve all of the routes that were set up + tokenPairArbRoutes, err := suite.App.ProtoRevKeeper.GetAllTokenPairArbRoutes(suite.Ctx) + + suite.Require().NoError(err) + + suite.Require().Equal(len(suite.tokenPairArbRoutes), len(tokenPairArbRoutes)) + suite.Require().Equal(suite.tokenPairArbRoutes, tokenPairArbRoutes) +} + +// TestDeleteAllTokenPairArbRoutes tests the DeleteAllTokenPairArbRoutes function. +func (suite *KeeperTestSuite) TestDeleteAllTokenPairArbRoutes() { + // Tests that we can properly retrieve all of the routes that were set up + tokenPairArbRoutes, err := suite.App.ProtoRevKeeper.GetAllTokenPairArbRoutes(suite.Ctx) + + suite.Require().NoError(err) + suite.Require().Equal(len(suite.tokenPairArbRoutes), len(tokenPairArbRoutes)) + suite.Require().Equal(suite.tokenPairArbRoutes, tokenPairArbRoutes) + + // Delete all routes + suite.App.ProtoRevKeeper.DeleteAllTokenPairArbRoutes(suite.Ctx) + + // Test after deletion + tokenPairArbRoutes, err = suite.App.ProtoRevKeeper.GetAllTokenPairArbRoutes(suite.Ctx) + + suite.Require().NoError(err) + suite.Require().Equal(0, len(tokenPairArbRoutes)) +} diff --git a/x/protorev/types/keys.go b/x/protorev/types/keys.go index 4cb38539228..2cc35420eaf 100644 --- a/x/protorev/types/keys.go +++ b/x/protorev/types/keys.go @@ -10,3 +10,36 @@ const ( // RouterKey defines the module's message routing key RouterKey = ModuleName ) + +const ( + prefixTokenPairRoutes = iota + 1 + prefixOsmoPools + prefixAtomPools +) + +var ( + // -------------- Keys for trading stores -------------- // + // KeyPrefixTokenPairRoutes is the prefix for the TokenPairArbRoutes store + KeyPrefixTokenPairRoutes = []byte{prefixTokenPairRoutes} + + // KeyPrefixOsmoPools is the prefix for the osmo pool store + KeyPrefixOsmoPools = []byte{prefixOsmoPools} + + // KeyPrefixAtomPools is the prefix for the atom pool store + KeyPrefixAtomPools = []byte{prefixAtomPools} +) + +// Returns the key needed to fetch the osmo pool for a given denom +func GetKeyPrefixOsmoPool(denom string) []byte { + return append(KeyPrefixOsmoPools, []byte(denom)...) +} + +// Returns the key needed to fetch the atom pool for a given denom +func GetKeyPrefixAtomPool(denom string) []byte { + return append(KeyPrefixAtomPools, []byte(denom)...) +} + +// Returns the key needed to fetch the tokenPair routes for a given pair of tokens +func GetKeyPrefixRouteForTokenPair(tokenA, tokenB string) []byte { + return append(KeyPrefixTokenPairRoutes, []byte(tokenA+"|"+tokenB)...) +} diff --git a/x/protorev/types/utils.go b/x/protorev/types/utils.go index 3083a3e88a1..00c3a097690 100644 --- a/x/protorev/types/utils.go +++ b/x/protorev/types/utils.go @@ -1,7 +1,7 @@ package types // Checks if the matching variable matches one of the tokens and if so returns the other and true -func CheckMatchAndReturnOther(tokenA, tokenB, match string) (string, bool) { +func CheckOsmoAtomDenomMatch(tokenA, tokenB, match string) (string, bool) { if tokenA == match { return tokenB, true } else if tokenB == match { From 077deff5e7a246f770f9e4ffcda392a38eed9dac Mon Sep 17 00:00:00 2001 From: davidterpay Date: Fri, 9 Dec 2022 13:54:59 -0600 Subject: [PATCH 3/3] adding protorev in v14 upgrade --- app/upgrades/v14/constants.go | 3 ++- x/protorev/types/expected_keepers.go | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/app/upgrades/v14/constants.go b/app/upgrades/v14/constants.go index 6f55ec0d39d..34066950e30 100644 --- a/app/upgrades/v14/constants.go +++ b/app/upgrades/v14/constants.go @@ -4,6 +4,7 @@ import ( store "github.com/cosmos/cosmos-sdk/store/types" "github.com/osmosis-labs/osmosis/v13/app/upgrades" + protorevtypes "github.com/osmosis-labs/osmosis/v13/x/protorev/types" valsetpreftypes "github.com/osmosis-labs/osmosis/v13/x/valset-pref/types" ) @@ -14,7 +15,7 @@ var Upgrade = upgrades.Upgrade{ UpgradeName: UpgradeName, CreateUpgradeHandler: CreateUpgradeHandler, StoreUpgrades: store.StoreUpgrades{ - Added: []string{valsetpreftypes.StoreKey}, + Added: []string{valsetpreftypes.StoreKey, protorevtypes.StoreKey}, Deleted: []string{}, }, } diff --git a/x/protorev/types/expected_keepers.go b/x/protorev/types/expected_keepers.go index 7f08e72bbac..df2d12a6813 100644 --- a/x/protorev/types/expected_keepers.go +++ b/x/protorev/types/expected_keepers.go @@ -24,8 +24,8 @@ type BankKeeper interface { // GAMMKeeper defines the Gamm contract that must be fulfilled when // creating a x/protorev keeper. type GAMMKeeper interface { - GetPoolAndPoke(ctx sdk.Context, poolId uint64) (gammtypes.PoolI, error) - GetPoolsAndPoke(ctx sdk.Context) (res []gammtypes.PoolI, err error) + GetPoolAndPoke(ctx sdk.Context, poolId uint64) (gammtypes.CFMMPoolI, error) + GetPoolsAndPoke(ctx sdk.Context) (res []gammtypes.CFMMPoolI, err error) GetPoolDenoms(ctx sdk.Context, poolId uint64) ([]string, error) SwapExactAmountIn(ctx sdk.Context, sender sdk.AccAddress, poolId uint64, tokenIn sdk.Coin, tokenOutDenom string, tokenOutMinAmount sdk.Int) (sdk.Int, error) MultihopSwapExactAmountIn(ctx sdk.Context, sender sdk.AccAddress, routes []gammtypes.SwapAmountInRoute, tokenIn sdk.Coin, tokenOutMinAmount sdk.Int) (tokenOutAmount sdk.Int, err error)