Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ProtoRev: CLI, Msg, and Query Server #4214

Merged
merged 5 commits into from
Feb 6, 2023
Merged

Conversation

davidterpay
Copy link
Contributor

@davidterpay davidterpay commented Feb 2, 2023

What is the purpose of the change

This PR implements the query server, message server, and CLI (#3594.)

Brief Changelog

  • Implement the query server
  • Implement the message server
  • Implement CLI commands
  • Refactor some baseDenom code in accordance with changes to proto

Testing and Verifying

  • Added unit tests for Msg Server
  • Added unit tests for Query Server

Documentation and Release Note

Keeper Updates

State Object Description Key Values Store
BaseDenoms Tracks all of the base denominations that will be used to construct arbitrage routes []byte{3} []byte{[]BaseDenom{}} KV

Where BaseDenom looks like the following

// BaseDenom is a struct that contains the base denomination and the
// BaseDenom represents a single base denom that the module uses for its
// arbitrage trades. It contains the denom name alongside the step size of the
// binary search that is used to find the optimal swap amount
type BaseDenom struct {
	// The denom i.e. name of the base denom (ex. uosmo)
	Denom string `protobuf:"bytes,1,opt,name=denom,proto3" json:"denom,omitempty"`
	// The step size of the binary search that is used to find the optimal swap
	// amount
	StepSize github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,2,opt,name=step_size,json=stepSize,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"step_size"`
}

Queries

Verb Method Description
gRPC osmosis.v14.protorev.Query/Params Queries the parameters of the module
gRPC osmosis.v14.protorev.Query/GetProtoRevNumberOfTrades Queries the number of arbitrage trades the module has executed
gRPC osmosis.v14.protorev.Query/GetProtoRevProfitsByDenom Queries the profits of the module by denom
gRPC osmosis.v14.protorev.Query/GetProtoRevAllProfits Queries all of the profits from the module
gRPC osmosis.v14.protorev.Query/GetProtoRevStatisticsByRoute Queries the number of arbitrages and profits that have happened for a given route
gRPC osmosis.v14.protorev.Query/GetProtoRevAllRouteStatistics Queries all of pools that the module has arbitrage against and the number of trades and profits that have happened for each route
gRPC osmosis.v14.protorev.Query/GetProtoRevTokenPairArbRoutes Queries all of the hot routes that the module is currently arbitraging
gRPC osmosis.v14.protorev.Query/GetProtoRevAdminAccount Queries the admin account of the module
gRPC osmosis.v14.protorev.Query/GetProtoRevDeveloperAccount Queries the developer account of the module
gRPC osmosis.v14.protorev.Query/GetProtoRevPoolWeights Queries the pool weights of the module
gRPC osmosis.v14.protorev.Query/GetProtoRevMaxPoolPointsPerTx Queries the maximum pool points that can be consumed per transaction
gRPC osmosis.v14.protorev.Query/GetProtoRevMaxPoolPointsPerBlock Queries the maximum pool points that can be consumed per block
gRPC osmosis.v14.protorev.Query/GetProtoRevBaseDenoms Queries the base denoms of the module
gRPC osmosis.v14.protorev.Query/GetProtoRevEnabled Queries whether the module is enabled or not
GET /osmosis/v14/protorev/params Queries the parameters of the module
GET /osmosis/v14/protorev/number_of_trades Queries the number of arbitrage trades the module has executed
GET /osmosis/v14/protorev/profits_by_denom Queries the profits of the module by denom
GET /osmosis/v14/protorev/all_profits Queries all of the profits from the module
GET /osmosis/v14/protorev/statistics_by_route Queries the number of arbitrages and profits that have happened for a given route
GET /osmosis/v14/protorev/all_route_statistics Queries all of pools that the module has arbitrage against and the number of trades and profits that have happened for each route
GET /osmosis/v14/protorev/token_pair_arb_routes Queries all of the hot routes that the module is currently arbitraging
GET /osmosis/v14/protorev/admin_account Queries the admin account of the module
GET /osmosis/v14/protorev/developer_account Queries the developer account of the module
GET /osmosis/v14/protorev/pool_weights Queries the pool weights of the module
GET /osmosis/v14/protorev/max_pool_points_per_tx Queries the maximum pool points that can be consumed per transaction
GET /osmosis/v14/protorev/max_pool_points_per_block Queries the maximum pool points that can be consumed per block
GET /osmosis/v14/protorev/base_denoms Queries the base denoms of the module
GET /osmosis/v14/protorev/enabled Queries whether the module is enabled or not

Transactions

Verb Method Description
gRPC osmosis.v14.protorev.Msg/SetHotRoutes Sets the hot routes that will be explored when creating cyclic arbitrage routes. Can only be called by the admin account.
gRPC osmosis.v14.protorev.Msg/SetDeveloperAccount Sets the account that can withdraw a portion of the profit from the protorev module. This will be Skip's address once deployed. Can only be called by the admin account.
gRPC osmosis.v14.protorev.Msg/SetPoolWeights Sets the pool weights of the module. Can only be called by the admin account.
gRPC osmosis.v14.protorev.Msg/SetMaxPoolPointsPerTx Sets the maximum pool points that can be consumed per transaction. Can only be called by the admin account.
gRPC osmosis.v14.protorev.Msg/SetMaxPoolPointsPerBlock Sets the maximum pool points that can be consumed per block. Can only be called by the admin account.
gRPC osmosis.v14.protorev.Msg/SetBaseDenoms Sets the base denoms of the module. Can only be called by the admin account.
POST /osmosis/protorev/v1beta1/set_hot_routes Sets the hot routes that will be explored when creating cyclic arbitrage routes. Can only be called by the admin account.
POST /osmosis/protorev/v1beta1/set_developer_account Sets the account that can withdraw a portion of the profit from the protorev module. This will be Skip's address once deployed
POST /osmosis/protorev/v1beta1/set_pool_weights Sets the pool weights of the module. Can only be called by the admin account.
POST /osmosis/protorev/v1beta1/set_max_pool_points_per_tx Sets the maximum pool points that can be consumed per transaction. Can only be called by the admin account.
POST /osmosis/protorev/v1beta1/set_max_pool_points_per_block Sets the maximum pool points that can be consumed per block. Can only be called by the admin account.
POST /osmosis/protorev/v1beta1/set_base_denoms Sets the base denoms of the module. Can only be called by the admin account.

Messages

NewMsgSetDeveloperAccount
The admin account broadcasts a NewMsgSetDeveloperAccount to set the developer account.

Messsage stateless validation fails if:

  • The admin is not a valid bech32 address
  • The signature of the user does not match the admin account’s
  • The developer account is not a valid bech32 address

Message stateful validation fails if:

  • The admin is not set in state
  • The admin entered in the message does not match the admin on chain
  • The admin’s signatures are not the same

NewMsgSetHotRoutes
The admin account broadcasts a NewMsgSetHotRoutes to set the hot routes.

Message statless validation fails if:

  • The admin is not a valid bech32 address
  • The signature of the user does not match the admin account’s
  • The hot routes are not valid

Message stateful validation fails if:

  • The admin is not set in state
  • The admin entered in the message does not match the admin on chain
  • The admin’s signatures are not the same

NewMsgSetPoolWeights
The admin account broadcasts a NewMsgSetPoolWeights to set the pool weights. The pool weights roughly correspond to the execution time of a swap on that pool type (stable, balancer, concentrated).

Message stateless validation fails if:

  • The admin is not a valid bech32 address
  • Any of the pool weights are less than 1

Message stateful validation fails if:

  • The admin is not set in state
  • The admin’s signatures are not the same

NewMsgSetMaxPoolPointsPerTx
The admin account broadcasts a NewMsgSetMaxPoolPointsPerTx to set the maximum pool points that can be consumed per transaction.

Message stateless validation fails if:

  • The admin is not a valid bech32 address
  • MaxPoolPointsPerTx is outside of the valid range

Message stateful validation fails if:

  • The admin is not set in state
  • The admin’s signatures are not the same

NewMsgSetMaxPoolPointsPerBlock
The admin account broadcasts a NewMsgSetMaxPoolPointsPerBlock to set the maximum pool points that can be consumed per block.

Message stateless validation fails if:

  • The admin is not a valid bech32 address
  • MaxPoolPointsPerBlock is outside of the valid range

Message stateful validation fails if:

  • The admin is not set in state
  • The admin’s signatures are not the same

NewMsgSetBaseDenoms
The admin account broadcasts a NewMsgSetBaseDenoms to set the base denoms of the module. The base denoms are the denominations that the module will use to construct cyclic arbitrage routes. The order of the lists

Message stateless validation fails if:

  • The admin is not a valid bech32 address
  • Osmosis is not the first base denom in the list

@github-actions github-actions bot added the C:app-wiring Changes to the app folder label Feb 3, 2023
@github-actions github-actions bot added the C:CLI label Feb 3, 2023
@davidterpay davidterpay added the V:state/breaking State machine breaking PR label Feb 3, 2023
@davidterpay davidterpay requested a review from bpiv400 February 3, 2023 19:04
@davidterpay davidterpay mentioned this pull request Feb 3, 2023
8 tasks
@davidterpay davidterpay marked this pull request as ready for review February 3, 2023 20:11
Comment on lines +46 to +51
baseDenomPriorities := []*types.BaseDenom{
{
Denom: types.OsmosisDenomination,
StepSize: sdk.NewInt(1_000_000),
},
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe I'm misunderstanding the word "priorities", shouldn't this read from genesis state?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(probably best resolved in a followup PR)

Copy link
Member

@ValarDragon ValarDragon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM aside from init genesis comment

@ValarDragon
Copy link
Member

Lets address the init genesis comment in a followup issue

@ValarDragon ValarDragon merged commit bd109ca into main Feb 6, 2023
@ValarDragon ValarDragon deleted the cli-query-msg-protorev branch February 6, 2023 16:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C:app-wiring Changes to the app folder C:CLI V:state/breaking State machine breaking PR
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

2 participants