From 9303268408bbd6d115f6df2a2f1caf6ebf11a2b8 Mon Sep 17 00:00:00 2001 From: Roman Date: Wed, 22 Mar 2023 18:21:35 -0400 Subject: [PATCH] feat(CL): x/poolmanager spot price query for concentrated liquidity (#4682) * feat(CL): x/poolmanager spot price query * changelog * Update x/poolmanager/client/query_proto_wrap.go * Update x/poolmanager/client/cli/query.go * Update x/poolmanager/client/cli/query.go * Update go.mod --------- Co-authored-by: p0mvn --- CHANGELOG.md | 1 + go.mod | 2 +- go.sum | 4 +- proto/osmosis/gamm/v2/query.proto | 12 +- proto/osmosis/poolmanager/v1beta1/query.proto | 24 + proto/osmosis/poolmanager/v1beta1/query.yml | 5 + x/gamm/client/cli/query.go | 8 +- x/gamm/keeper/grpc_query.go | 4 + x/gamm/v2types/query.pb.go | 78 +-- x/poolmanager/client/cli/query.go | 10 + x/poolmanager/client/grpc/grpc_query.go | 10 + x/poolmanager/client/query_proto_wrap.go | 20 + x/poolmanager/client/queryproto/query.pb.go | 602 ++++++++++++++++-- .../client/queryproto/query.pb.gw.go | 119 ++++ 14 files changed, 786 insertions(+), 113 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 13e58821946..b5f29ffe574 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -54,6 +54,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 * [#4336](https://github.com/osmosis-labs/osmosis/pull/4336) Move epochs module into its own go.mod * [#4658](https://github.com/osmosis-labs/osmosis/pull/4658) Deprecate x/gamm Pool query. The new one is located in x/poolmanager. +* [#4682](https://github.com/osmosis-labs/osmosis/pull/4682) Deprecate x/gamm SpotPrice v2 query. The new one is located in x/poolmanager. ## v15.0.0 diff --git a/go.mod b/go.mod index 71dd96cc67d..bd23cd17266 100644 --- a/go.mod +++ b/go.mod @@ -20,7 +20,7 @@ require ( github.com/ory/dockertest/v3 v3.9.1 github.com/osmosis-labs/go-mutesting v0.0.0-20221208041716-b43bcd97b3b3 github.com/osmosis-labs/osmosis/osmomath v0.0.3-dev.0.20230316203321-2edd49875f80 - github.com/osmosis-labs/osmosis/osmoutils v0.0.0-20230317232332-81bd3c5ef0c2 + github.com/osmosis-labs/osmosis/osmoutils v0.0.0-20230320210812-4f37fbb5d1ef github.com/osmosis-labs/osmosis/x/epochs v0.0.0-20230313084619-8d291c1d9813 github.com/osmosis-labs/osmosis/x/ibc-hooks v0.0.0-20230316203321-2edd49875f80 github.com/pkg/errors v0.9.1 diff --git a/go.sum b/go.sum index c760f69fe15..edd2a1e47d5 100644 --- a/go.sum +++ b/go.sum @@ -935,8 +935,8 @@ github.com/osmosis-labs/go-mutesting v0.0.0-20221208041716-b43bcd97b3b3 h1:Ylmch github.com/osmosis-labs/go-mutesting v0.0.0-20221208041716-b43bcd97b3b3/go.mod h1:lV6KnqXYD/ayTe7310MHtM3I2q8Z6bBfMAi+bhwPYtI= github.com/osmosis-labs/osmosis/osmomath v0.0.3-dev.0.20230316203321-2edd49875f80 h1:MqSb3Q5Uqb2r3PcyijgFL0lcIe57PqncqyfkRtyyn6E= github.com/osmosis-labs/osmosis/osmomath v0.0.3-dev.0.20230316203321-2edd49875f80/go.mod h1:PT796t7vS3STUWYikgwzY9e7jhLo0N/hwZf4R6haj0o= -github.com/osmosis-labs/osmosis/osmoutils v0.0.0-20230317232332-81bd3c5ef0c2 h1:syLNakfGKE9SjReHzcE8B0vWaykxKeno10uOyHi+0aI= -github.com/osmosis-labs/osmosis/osmoutils v0.0.0-20230317232332-81bd3c5ef0c2/go.mod h1:spcwVLt51T9NAUpFb+W0UKO7e9mwF5K/hc3nTrmGoP4= +github.com/osmosis-labs/osmosis/osmoutils v0.0.0-20230320210812-4f37fbb5d1ef h1:4V0HxAtcOJSavt8F3F8wuwpUaBAp9QYkI1FKqziDAXo= +github.com/osmosis-labs/osmosis/osmoutils v0.0.0-20230320210812-4f37fbb5d1ef/go.mod h1:spcwVLt51T9NAUpFb+W0UKO7e9mwF5K/hc3nTrmGoP4= github.com/osmosis-labs/osmosis/x/epochs v0.0.0-20230313084619-8d291c1d9813 h1:OVT8hqFET8DkAeiSUs5h2nTg1uZFU6kPRP2sDWzVm/o= github.com/osmosis-labs/osmosis/x/epochs v0.0.0-20230313084619-8d291c1d9813/go.mod h1:lJebPe8cmSTwXXuWmgSNc1S4Bobz9g3x05ZL4igbAAI= github.com/osmosis-labs/osmosis/x/ibc-hooks v0.0.0-20230316203321-2edd49875f80 h1:8gZdQsLkU0XOJ43xlzr1ig9fTVqgdZcoGbLL0ZnUzZs= diff --git a/proto/osmosis/gamm/v2/query.proto b/proto/osmosis/gamm/v2/query.proto index 0d68d991293..12c97ca0c2d 100644 --- a/proto/osmosis/gamm/v2/query.proto +++ b/proto/osmosis/gamm/v2/query.proto @@ -13,16 +13,16 @@ import "cosmos_proto/cosmos.proto"; option go_package = "github.com/osmosis-labs/osmosis/v15/x/gamm/v2types"; service Query { - // SpotPrice defines a gRPC query handler that returns the spot price given - // a base denomination and a quote denomination. + // Deprecated: please use alternate in x/poolmanager rpc SpotPrice(QuerySpotPriceRequest) returns (QuerySpotPriceResponse) { + option deprecated = true; option (google.api.http).get = "/osmosis/gamm/v2/pools/{pool_id}/prices"; } } -// QuerySpotPriceRequest defines the gRPC request structure for a SpotPrice -// query. +// Deprecated: please use alternate in x/poolmanager message QuerySpotPriceRequest { + option deprecated = true; uint64 pool_id = 1 [ (gogoproto.moretags) = "yaml:\"pool_id\"" ]; string base_asset_denom = 2 [ (gogoproto.moretags) = "yaml:\"base_asset_denom\"" ]; @@ -30,9 +30,9 @@ message QuerySpotPriceRequest { [ (gogoproto.moretags) = "yaml:\"quote_asset_denom\"" ]; } -// QuerySpotPriceResponse defines the gRPC response structure for a SpotPrice -// query. +// Depreacted: please use alternate in x/poolmanager message QuerySpotPriceResponse { + option deprecated = true; // String of the Dec. Ex) 10.203uatom string spot_price = 1 [ (gogoproto.moretags) = "yaml:\"spot_price\"" ]; } diff --git a/proto/osmosis/poolmanager/v1beta1/query.proto b/proto/osmosis/poolmanager/v1beta1/query.proto index ea554bccf40..e2b784a3961 100644 --- a/proto/osmosis/poolmanager/v1beta1/query.proto +++ b/proto/osmosis/poolmanager/v1beta1/query.proto @@ -49,6 +49,13 @@ service Query { rpc AllPools(AllPoolsRequest) returns (AllPoolsResponse) { option (google.api.http).get = "/osmosis/poolmanager/v1beta1/all-pools"; } + + // SpotPrice defines a gRPC query handler that returns the spot price given + // a base denomination and a quote denomination. + rpc SpotPrice(SpotPriceRequest) returns (SpotPriceResponse) { + option (google.api.http).get = + "/osmosis/poolmanager/pools/{pool_id}/prices"; + } } //=============================== Params @@ -117,3 +124,20 @@ message AllPoolsResponse { repeated google.protobuf.Any pools = 1 [ (cosmos_proto.accepts_interface) = "PoolI" ]; } + +// SpotPriceRequest defines the gRPC request structure for a SpotPrice +// query. +message SpotPriceRequest { + uint64 pool_id = 1 [ (gogoproto.moretags) = "yaml:\"pool_id\"" ]; + string base_asset_denom = 2 + [ (gogoproto.moretags) = "yaml:\"base_asset_denom\"" ]; + string quote_asset_denom = 3 + [ (gogoproto.moretags) = "yaml:\"quote_asset_denom\"" ]; +} + +// SpotPriceResponse defines the gRPC response structure for a SpotPrice +// query. +message SpotPriceResponse { + // String of the Dec. Ex) 10.203uatom + string spot_price = 1 [ (gogoproto.moretags) = "yaml:\"spot_price\"" ]; +} diff --git a/proto/osmosis/poolmanager/v1beta1/query.yml b/proto/osmosis/poolmanager/v1beta1/query.yml index 192da8fe447..a69ac9ba17c 100644 --- a/proto/osmosis/poolmanager/v1beta1/query.yml +++ b/proto/osmosis/poolmanager/v1beta1/query.yml @@ -33,3 +33,8 @@ queries: query_func: "k.AllPools" cli: cmd: "AllPools" + SpotPrice: + proto_wrapper: + query_func: "k.RouteCalculateSpotPrice" + cli: + cmd: "SpotPrice" diff --git a/x/gamm/client/cli/query.go b/x/gamm/client/cli/query.go index 107756d90ea..0273eed2d55 100644 --- a/x/gamm/client/cli/query.go +++ b/x/gamm/client/cli/query.go @@ -194,7 +194,7 @@ Example: ) } -//nolint:staticcheck +// Deprecated: use alternate in x/poolmanager. func GetCmdSpotPrice() (*osmocli.QueryDescriptor, *types.QuerySpotPriceRequest) { return &osmocli.QueryDescriptor{ Use: "spot-price [quote-asset-denom] [base-asset-denom]", @@ -204,8 +204,7 @@ func GetCmdSpotPrice() (*osmocli.QueryDescriptor, *types.QuerySpotPriceRequest) `}, &types.QuerySpotPriceRequest{} } -// GetCmdEstimateSwapExactAmountIn returns estimation of output coin when amount of x token input. -// nolint: staticcheck +// Deprecated: use alternate in x/poolmanager. func GetCmdEstimateSwapExactAmountIn() (*osmocli.QueryDescriptor, *types.QuerySwapExactAmountInRequest) { return &osmocli.QueryDescriptor{ Use: "estimate-swap-exact-amount-in ", @@ -219,8 +218,7 @@ func GetCmdEstimateSwapExactAmountIn() (*osmocli.QueryDescriptor, *types.QuerySw }, &types.QuerySwapExactAmountInRequest{} } -// GetCmdEstimateSwapExactAmountOut returns estimation of input coin to get exact amount of x token output. -// nolint: staticcheck +// Deprecated: use alternate in x/poolmanager. func GetCmdEstimateSwapExactAmountOut() (*osmocli.QueryDescriptor, *types.QuerySwapExactAmountOutRequest) { return &osmocli.QueryDescriptor{ Use: "estimate-swap-exact-amount-out ", diff --git a/x/gamm/keeper/grpc_query.go b/x/gamm/keeper/grpc_query.go index 7c012fd799c..1201b954ce1 100644 --- a/x/gamm/keeper/grpc_query.go +++ b/x/gamm/keeper/grpc_query.go @@ -382,6 +382,8 @@ func (q Querier) SpotPrice(ctx context.Context, req *types.QuerySpotPriceRequest }, nil } +// Deeprecated: use alternate in x/poolmanager +// nolint: staticcheck func (q QuerierV2) SpotPrice(ctx context.Context, req *v2types.QuerySpotPriceRequest) (*v2types.QuerySpotPriceResponse, error) { if req == nil { return nil, status.Error(codes.InvalidArgument, "empty request") @@ -402,6 +404,8 @@ func (q QuerierV2) SpotPrice(ctx context.Context, req *v2types.QuerySpotPriceReq return nil, status.Error(codes.Internal, err.Error()) } + // Deeprecated: use alternate in x/poolmanager + // nolint: staticcheck return &v2types.QuerySpotPriceResponse{ SpotPrice: sp.String(), }, nil diff --git a/x/gamm/v2types/query.pb.go b/x/gamm/v2types/query.pb.go index d75d4a84df7..25c07751ae4 100644 --- a/x/gamm/v2types/query.pb.go +++ b/x/gamm/v2types/query.pb.go @@ -34,8 +34,9 @@ var _ = math.Inf // proto package needs to be updated. const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package -// QuerySpotPriceRequest defines the gRPC request structure for a SpotPrice -// query. +// Deprecated: please use alternate in x/poolmanager +// +// Deprecated: Do not use. type QuerySpotPriceRequest struct { PoolId uint64 `protobuf:"varint,1,opt,name=pool_id,json=poolId,proto3" json:"pool_id,omitempty" yaml:"pool_id"` BaseAssetDenom string `protobuf:"bytes,2,opt,name=base_asset_denom,json=baseAssetDenom,proto3" json:"base_asset_denom,omitempty" yaml:"base_asset_denom"` @@ -96,8 +97,9 @@ func (m *QuerySpotPriceRequest) GetQuoteAssetDenom() string { return "" } -// QuerySpotPriceResponse defines the gRPC response structure for a SpotPrice -// query. +// Depreacted: please use alternate in x/poolmanager +// +// Deprecated: Do not use. type QuerySpotPriceResponse struct { // String of the Dec. Ex) 10.203uatom SpotPrice string `protobuf:"bytes,1,opt,name=spot_price,json=spotPrice,proto3" json:"spot_price,omitempty" yaml:"spot_price"` @@ -151,36 +153,37 @@ func init() { func init() { proto.RegisterFile("osmosis/gamm/v2/query.proto", fileDescriptor_49ff000e88fc374c) } var fileDescriptor_49ff000e88fc374c = []byte{ - // 459 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x84, 0x92, 0x41, 0x8b, 0x13, 0x31, - 0x14, 0xc7, 0x9b, 0x55, 0x57, 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- 0x5d, 0xd9, 0xfb, 0xf7, 0xdc, 0x3e, 0x12, 0xfb, 0xcf, 0xbe, 0x2e, 0x3c, 0x72, 0xb2, 0xf0, 0xc8, - 0xcf, 0x85, 0x47, 0x3e, 0x2d, 0xbd, 0xc6, 0xc9, 0xd2, 0x6b, 0xfc, 0x58, 0x7a, 0x8d, 0xd7, 0xbd, - 0x24, 0xd5, 0x6f, 0x8b, 0x38, 0x18, 0x40, 0x56, 0xc9, 0xee, 0x8c, 0x44, 0x8c, 0x6b, 0xf3, 0xb4, - 0x7b, 0x9f, 0x1f, 0x57, 0x7e, 0x3d, 0x53, 0x12, 0xe3, 0x4d, 0x3b, 0x16, 0x77, 0x7f, 0x07, 0x00, - 0x00, 0xff, 0xff, 0xd3, 0xd6, 0x08, 0x46, 0x1b, 0x03, 0x00, 0x00, + // 468 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x84, 0x92, 0x41, 0x6f, 0xd3, 0x30, + 0x14, 0xc7, 0xeb, 0x02, 0x43, 0xf5, 0x61, 0x63, 0x16, 0x83, 0xd2, 0x8d, 0x74, 0xca, 0x81, 0x0d, + 0x10, 0xb1, 0x1a, 0xe0, 0xb2, 0x1b, 0x15, 0x48, 0x20, 0x71, 0x80, 0x70, 0xe3, 0x12, 0x39, 0xad, + 0x09, 0x96, 0x9a, 0x3c, 0xb7, 0x76, 0xaa, 0x55, 0x88, 0x0b, 0x27, 0x8e, 0x93, 0xb8, 0xf1, 0x89, + 0x38, 0x4e, 0xe2, 0x02, 0x97, 0x0a, 0xb5, 0x7c, 0x82, 0x7e, 0x02, 0x64, 0x3b, 0xe9, 0x58, 0x40, + 0xda, 0x2d, 0x7e, 0xbf, 0xbf, 0xff, 0xff, 0xf7, 0x9c, 0x87, 0x77, 0x41, 0x65, 0xa0, 0x84, 0xa2, + 0x29, 0xcb, 0x32, 0x3a, 0x0d, 0xe9, 0xb8, 0xe0,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// Reference imports to suppress errors if they are not otherwise used. @@ -195,8 +198,7 @@ const _ = grpc.SupportPackageIsVersion4 // // 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 { - // SpotPrice defines a gRPC query handler that returns the spot price given - // a base denomination and a quote denomination. + // Deprecated: please use alternate in x/poolmanager SpotPrice(ctx context.Context, in *QuerySpotPriceRequest, opts ...grpc.CallOption) (*QuerySpotPriceResponse, error) } @@ -208,6 +210,7 @@ func NewQueryClient(cc grpc1.ClientConn) QueryClient { return &queryClient{cc} } +// Deprecated: Do not use. func (c *queryClient) SpotPrice(ctx context.Context, in *QuerySpotPriceRequest, opts ...grpc.CallOption) (*QuerySpotPriceResponse, error) { out := new(QuerySpotPriceResponse) err := c.cc.Invoke(ctx, "/osmosis.gamm.v2.Query/SpotPrice", in, out, opts...) @@ -219,8 +222,7 @@ func (c *queryClient) SpotPrice(ctx context.Context, in *QuerySpotPriceRequest, // QueryServer is the server API for Query service. type QueryServer interface { - // SpotPrice defines a gRPC query handler that returns the spot price given - // a base denomination and a quote denomination. + // Deprecated: please use alternate in x/poolmanager SpotPrice(context.Context, *QuerySpotPriceRequest) (*QuerySpotPriceResponse, error) } diff --git a/x/poolmanager/client/cli/query.go b/x/poolmanager/client/cli/query.go index 827cf6e2fe4..73706444699 100644 --- a/x/poolmanager/client/cli/query.go +++ b/x/poolmanager/client/cli/query.go @@ -23,6 +23,7 @@ func GetQueryCmd() *cobra.Command { osmocli.AddQueryCmd(cmd, queryproto.NewQueryClient, GetCmdNumPools) osmocli.AddQueryCmd(cmd, queryproto.NewQueryClient, GetCmdEstimateSwapExactAmountIn) osmocli.AddQueryCmd(cmd, queryproto.NewQueryClient, GetCmdEstimateSwapExactAmountOut) + osmocli.AddQueryCmd(cmd, queryproto.NewQueryClient, GetCmdSpotPrice) return cmd } @@ -73,6 +74,15 @@ func GetCmdPool() (*osmocli.QueryDescriptor, *queryproto.PoolRequest) { {{.CommandPrefix}} pool 1`}, &queryproto.PoolRequest{} } +func GetCmdSpotPrice() (*osmocli.QueryDescriptor, *queryproto.SpotPriceRequest) { + return &osmocli.QueryDescriptor{ + Use: "spot-price [quote-asset-denom] [base-asset-denom]", + Short: "Query spot-price", + Long: `Query spot-price +{{.CommandPrefix}} spot-price 1 uosmo ibc/27394FB092D2ECCD56123C74F36E4C1F926001CEADA9CA97EA622B25F41E5EB2 +`}, &queryproto.SpotPriceRequest{} +} + func EstimateSwapExactAmountInParseArgs(args []string, fs *flag.FlagSet) (proto.Message, error) { poolID, err := strconv.Atoi(args[0]) if err != nil { diff --git a/x/poolmanager/client/grpc/grpc_query.go b/x/poolmanager/client/grpc/grpc_query.go index 48d5a645be8..7af5536db54 100644 --- a/x/poolmanager/client/grpc/grpc_query.go +++ b/x/poolmanager/client/grpc/grpc_query.go @@ -20,6 +20,16 @@ type Querier struct { var _ queryproto.QueryServer = Querier{} +func (q Querier) SpotPrice(grpcCtx context.Context, + req *queryproto.SpotPriceRequest, +) (*queryproto.SpotPriceResponse, error) { + if req == nil { + return nil, status.Error(codes.InvalidArgument, "empty request") + } + ctx := sdk.UnwrapSDKContext(grpcCtx) + return q.Q.SpotPrice(ctx, *req) +} + func (q Querier) Pool(grpcCtx context.Context, req *queryproto.PoolRequest, ) (*queryproto.PoolResponse, error) { diff --git a/x/poolmanager/client/query_proto_wrap.go b/x/poolmanager/client/query_proto_wrap.go index 869164d1466..1ea3a0b2568 100644 --- a/x/poolmanager/client/query_proto_wrap.go +++ b/x/poolmanager/client/query_proto_wrap.go @@ -122,3 +122,23 @@ func (q Querier) AllPools(ctx sdk.Context, req queryproto.AllPoolsRequest) (*que Pools: anyPools, }, nil } + +// SpotPrice returns the spot price of the pool with the given quote and base asset denoms. +func (q Querier) SpotPrice(ctx sdk.Context, req queryproto.SpotPriceRequest) (*queryproto.SpotPriceResponse, error) { + if req.BaseAssetDenom == "" { + return nil, status.Error(codes.InvalidArgument, "invalid base asset denom") + } + + if req.QuoteAssetDenom == "" { + return nil, status.Error(codes.InvalidArgument, "invalid quote asset denom") + } + + sp, err := q.K.RouteCalculateSpotPrice(ctx, req.PoolId, req.QuoteAssetDenom, req.BaseAssetDenom) + if err != nil { + return nil, status.Error(codes.Internal, err.Error()) + } + + return &queryproto.SpotPriceResponse{ + SpotPrice: sp.String(), + }, err +} diff --git a/x/poolmanager/client/queryproto/query.pb.go b/x/poolmanager/client/queryproto/query.pb.go index 3350768e460..996f0bd7dc5 100644 --- a/x/poolmanager/client/queryproto/query.pb.go +++ b/x/poolmanager/client/queryproto/query.pb.go @@ -590,6 +590,115 @@ func (m *AllPoolsResponse) GetPools() []*types1.Any { return nil } +// SpotPriceRequest defines the gRPC request structure for a SpotPrice +// query. +type SpotPriceRequest struct { + PoolId uint64 `protobuf:"varint,1,opt,name=pool_id,json=poolId,proto3" json:"pool_id,omitempty" yaml:"pool_id"` + BaseAssetDenom string `protobuf:"bytes,2,opt,name=base_asset_denom,json=baseAssetDenom,proto3" json:"base_asset_denom,omitempty" yaml:"base_asset_denom"` + QuoteAssetDenom string `protobuf:"bytes,3,opt,name=quote_asset_denom,json=quoteAssetDenom,proto3" json:"quote_asset_denom,omitempty" yaml:"quote_asset_denom"` +} + +func (m *SpotPriceRequest) Reset() { *m = SpotPriceRequest{} } +func (m *SpotPriceRequest) String() string { return proto.CompactTextString(m) } +func (*SpotPriceRequest) ProtoMessage() {} +func (*SpotPriceRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_6256a4106f701b7d, []int{12} +} +func (m *SpotPriceRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *SpotPriceRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_SpotPriceRequest.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 *SpotPriceRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_SpotPriceRequest.Merge(m, src) +} +func (m *SpotPriceRequest) XXX_Size() int { + return m.Size() +} +func (m *SpotPriceRequest) XXX_DiscardUnknown() { + xxx_messageInfo_SpotPriceRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_SpotPriceRequest proto.InternalMessageInfo + +func (m *SpotPriceRequest) GetPoolId() uint64 { + if m != nil { + return m.PoolId + } + return 0 +} + +func (m *SpotPriceRequest) GetBaseAssetDenom() string { + if m != nil { + return m.BaseAssetDenom + } + return "" +} + +func (m *SpotPriceRequest) GetQuoteAssetDenom() string { + if m != nil { + return m.QuoteAssetDenom + } + return "" +} + +// SpotPriceResponse defines the gRPC response structure for a SpotPrice +// query. +type SpotPriceResponse struct { + // String of the Dec. Ex) 10.203uatom + SpotPrice string `protobuf:"bytes,1,opt,name=spot_price,json=spotPrice,proto3" json:"spot_price,omitempty" yaml:"spot_price"` +} + +func (m *SpotPriceResponse) Reset() { *m = SpotPriceResponse{} } +func (m *SpotPriceResponse) String() string { return proto.CompactTextString(m) } +func (*SpotPriceResponse) ProtoMessage() {} +func (*SpotPriceResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_6256a4106f701b7d, []int{13} +} +func (m *SpotPriceResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *SpotPriceResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_SpotPriceResponse.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 *SpotPriceResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_SpotPriceResponse.Merge(m, src) +} +func (m *SpotPriceResponse) XXX_Size() int { + return m.Size() +} +func (m *SpotPriceResponse) XXX_DiscardUnknown() { + xxx_messageInfo_SpotPriceResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_SpotPriceResponse proto.InternalMessageInfo + +func (m *SpotPriceResponse) GetSpotPrice() string { + if m != nil { + return m.SpotPrice + } + return "" +} + func init() { proto.RegisterType((*ParamsRequest)(nil), "osmosis.poolmanager.v1beta1.ParamsRequest") proto.RegisterType((*ParamsResponse)(nil), "osmosis.poolmanager.v1beta1.ParamsResponse") @@ -603,6 +712,8 @@ func init() { proto.RegisterType((*PoolResponse)(nil), "osmosis.poolmanager.v1beta1.PoolResponse") proto.RegisterType((*AllPoolsRequest)(nil), "osmosis.poolmanager.v1beta1.AllPoolsRequest") proto.RegisterType((*AllPoolsResponse)(nil), "osmosis.poolmanager.v1beta1.AllPoolsResponse") + proto.RegisterType((*SpotPriceRequest)(nil), "osmosis.poolmanager.v1beta1.SpotPriceRequest") + proto.RegisterType((*SpotPriceResponse)(nil), "osmosis.poolmanager.v1beta1.SpotPriceResponse") } func init() { @@ -610,67 +721,76 @@ func init() { } var fileDescriptor_6256a4106f701b7d = []byte{ - // 957 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x56, 0x41, 0x6f, 0x1b, 0x45, - 0x14, 0xce, 0x26, 0x8e, 0x9b, 0x4c, 0x48, 0x9c, 0x0e, 0x01, 0x5c, 0x83, 0xec, 0x30, 0x85, 0xe2, - 0x34, 0xf1, 0xae, 0x9c, 0xd2, 0x4b, 0xa5, 0xa6, 0xc4, 0x55, 0x10, 0xbe, 0xd0, 0xb2, 0xbd, 0x21, - 0x15, 0x6b, 0xec, 0x0c, 0xcb, 0xaa, 0xbb, 0x33, 0x5b, 0xcf, 0x6c, 0x1b, 0x0b, 0x71, 0xe1, 0xc6, - 0xa5, 0x02, 0x21, 0x01, 0x3f, 0x82, 0x23, 0x3f, 0xa2, 0xe2, 0x54, 0x89, 0x0b, 0xe2, 0x60, 0x41, - 0x02, 0x7f, 0xc0, 0xbf, 0x00, 0xed, 0xcc, 0xdb, 0xb5, 0x63, 0x29, 0x1b, 0x37, 0x88, 0x93, 0xc7, - 0x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x33, 0xa2, 0x81, 0xb1, 0xad, 0x19, 0xd7, 0xf1, 0xb5, 0xdc, 0x2b, - 0x96, 0xf9, 0x02, 0xfe, 0xce, 0x42, 0x85, 0xa4, 0x02, 0xae, 0xe7, 0x5f, 0xe4, 0xb1, 0x61, 0x54, - 0xb6, 0x66, 0x40, 0x02, 0x9b, 0xf7, 0x35, 0x1b, 0x1b, 0xef, 0xe4, 0xb2, 0xd1, 0x4c, 0xc6, 0x62, - 0x6a, 0xb5, 0xd2, 0x07, 0x7e, 0x8e, 0x5a, 0x53, 0x3e, 0x72, 0x8e, 0x5a, 0xd3, 0xae, 0x31, 0xa3, - 0x5a, 0x34, 0x08, 0x1a, 0x9a, 0x63, 0xeb, 0xe1, 0xf3, 0xe3, 0xaa, 0xf5, 0xe2, 0xb8, 0x6a, 0xfd, - 0x79, 0x5c, 0xb5, 0xbe, 0x3d, 0xa9, 0xce, 0xbd, 0x38, 0xa9, 0xce, 0xfd, 0x7e, 0x52, 0x9d, 0xfb, - 0xf4, 0xee, 0x84, 0xff, 0x43, 0xad, 0x46, 0x40, 0xbb, 0x32, 0x2b, 0xfc, 0xa4, 0x79, 0xd3, 0x39, - 0x3a, 0x55, 0xbe, 0x17, 0xf8, 0x8c, 0x2b, 0xf3, 0x9f, 0xd1, 0xd8, 0x54, 0x51, 0x7f, 0xdc, 0xf8, - 0x37, 0x00, 0x00, 0xff, 0xff, 0xd1, 0x71, 0x54, 0xa2, 0x4f, 0x0b, 0x00, 0x00, + // 1096 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x56, 0x4f, 0x6f, 0x1b, 0xc5, + 0x1b, 0xce, 0x26, 0x8e, 0x1b, 0x4f, 0x7e, 0x89, 0x9d, 0xf9, 0xa5, 0xe0, 0xba, 0x95, 0x1d, 0xa6, + 0x50, 0x92, 0x26, 0xde, 0x55, 0x92, 0xf6, 0x52, 0xa9, 0x29, 0x71, 0x09, 0xaa, 0x2f, 0x34, 0x6c, + 0x6e, 0x48, 0x65, 0x35, 0x71, 0x06, 0xb3, 0xea, 0xee, 0xcc, 0xc6, 0x33, 0xdb, 0xc6, 0x42, 0x5c, + 0xb8, 0x71, 0xa9, 0x40, 0x48, 0xc0, 0x8d, 0x2f, 0xc1, 0x87, 0xa8, 0x38, 0xa0, 0x48, 0x5c, 0x10, + 0x07, 0x0b, 0x12, 0xf8, 0x02, 0xfe, 0x04, 0x68, 0xfe, 0xec, 0xda, 0x31, 0x64, 0xe3, 0x06, 0x71, + 0xf2, 0x7a, 0xde, 0xe7, 0x7d, 0xe7, 0x79, 0x9f, 0x77, 0xf6, 0x99, 0x05, 0x6f, 0x33, 0x1e, 0x32, + 0xee, 0x73, 0x27, 0x62, 0x2c, 0x08, 0x31, 0xc5, 0x6d, 0xd2, 0x71, 0x9e, 0xad, 0xef, 0x13, 0x81, + 0xd7, 0x9d, 0xc3, 0x98, 0x74, 0xba, 0x76, 0xd4, 0x61, 0x82, 0xc1, 0xeb, 0x06, 0x68, 0x0f, 0x01, + 0x6d, 0x03, 0xac, 0x2c, 0xb6, 0x59, 0x9b, 0x29, 0x9c, 0x23, 0x9f, 0x74, 0x4a, 0x65, 0x25, 0xab, + 0x76, 0x9b, 0x50, 0xa2, 0xca, 0x29, 0xe8, 0x9b, 0x59, 0x50, 0x71, 0x64, 0x50, 0x6b, 0x59, 0x28, + 0xfe, 0x1c, 0x47, 0x5e, 0x87, 0xc5, 0x82, 0x18, 0x74, 0xb5, 0xa5, 0xe0, 0xce, 0x3e, 0xe6, 0x24, + 0x45, 0xb5, 0x98, 0x4f, 0x4d, 0xfc, 0xf6, 0x70, 0x5c, 0xb5, 0x9a, 0xa2, 0x22, 0xdc, 0xf6, 0x29, + 0x16, 0x3e, 0x4b, 0xb0, 0x37, 0xda, 0x8c, 0xb5, 0x03, 0xe2, 0xe0, 0xc8, 0x77, 0x30, 0xa5, 0x4c, + 0xa8, 0x60, 0xc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, 0xee, + 0x80, 0xd2, 0x60, 0xc9, 0x10, 0x5b, 0x07, 0x05, 0x1a, 0x87, 0x9e, 0xd4, 0x4f, 0xbf, 0xbd, 0xb9, + 0xe1, 0x96, 0xd3, 0x10, 0x72, 0x67, 0xa8, 0x49, 0x45, 0xf7, 0xc0, 0xac, 0x7c, 0x48, 0x86, 0x3d, + 0x34, 0x41, 0xeb, 0xa2, 0x09, 0xa2, 0x87, 0xe0, 0x7f, 0x3a, 0xd7, 0x6c, 0xbf, 0x09, 0x72, 0x32, + 0x62, 0x7c, 0x63, 0xd1, 0xd6, 0x66, 0x64, 0x27, 0x66, 0x64, 0x6f, 0xd3, 0x6e, 0xa3, 0xf0, 0xe3, + 0x0f, 0xf5, 0x69, 0x99, 0xd5, 0x74, 0x15, 0x18, 0x6d, 0x81, 0xe2, 0x76, 0x10, 0x0c, 0xb7, 0xf6, + 0x6a, 0x24, 0x9a, 0xa0, 0x34, 0xc8, 0x37, 0x44, 0xee, 0x82, 0xe9, 0x44, 0x83, 0xa9, 0x71, 0x98, + 0x68, 0x34, 0x3a, 0xb6, 0x40, 0x69, 0x2f, 0x62, 0x62, 0xb7, 0xe3, 0xb7, 0xc8, 0x65, 0xc8, 0xc0, + 0x1d, 0x50, 0x92, 0xd6, 0xef, 0x61, 0xce, 0x89, 0xf0, 0x0e, 0x08, 0x65, 0xa1, 0x7a, 0x13, 0x0a, + 0x8d, 0xeb, 0x83, 0x17, 0x73, 0x14, 0x81, 0xdc, 0x79, 0xb9, 0xb4, 0x2d, 0x57, 0xde, 0x95, 0x0b, + 0xf0, 0x11, 0x58, 0x38, 0x8c, 0x99, 0x38, 0x5b, 0x47, 0x7b, 0xd9, 0x8d, 0x7e, 0xaf, 0x56, 0xd6, + 0x75, 0xfe, 0x06, 0x41, 0x6e, 0x51, 0xad, 0x0d, 0x2a, 0xa1, 0x26, 0x58, 0x18, 0xea, 0xc8, 0xc8, + 0x73, 0x07, 0x00, 0x1e, 0x31, 0xe1, 0x45, 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 0x95, 0x31, 0x90, 0x86, + 0xcd, 0x1d, 0xc5, 0xc6, 0x86, 0x6b, 0x99, 0x6c, 0x14, 0x93, 0x81, 0x98, 0x4a, 0xad, 0xc4, 0xfe, + 0x2e, 0x50, 0x6b, 0xc4, 0x65, 0x2f, 0x50, 0x6b, 0xd4, 0x53, 0xc7, 0x54, 0x0b, 0x07, 0x41, 0x5d, + 0xab, 0xf5, 0xbd, 0x05, 0x0a, 0xa9, 0xf5, 0xc0, 0xec, 0xcd, 0x46, 0x4d, 0xb7, 0x62, 0x8f, 0x0b, + 0x37, 0xe4, 0x36, 0x15, 0xb9, 0x3a, 0x5c, 0xfd, 0x47, 0x72, 0x23, 0xa2, 0x39, 0xca, 0xdb, 0x78, + 0xe3, 0xc9, 0xcb, 0x93, 0xaa, 0x75, 0x7c, 0x52, 0xb5, 0x7e, 0x3b, 0xa9, 0x5a, 0x5f, 0x9e, 0x56, + 0x27, 0x8e, 0x4f, 0xab, 0x13, 0xbf, 0x9c, 0x56, 0x27, 0x3e, 0x7c, 0x38, 0x74, 0x7f, 0x9b, 0x82, + 0xf5, 0x00, 0xef, 0xf3, 0xb4, 0xfa, 0xb3, 0xf5, 0xbb, 0xce, 0xd1, 0x99, 0x3d, 0x5a, 0x81, 0x4f, + 0xa8, 0xd0, 0xdf, 0xfc, 0xfa, 0x9a, 0xc9, 0xab, 0x9f, 0xcd, 0xbf, 0x02, 0x00, 0x00, 0xff, 0xff, + 0x31, 0xe5, 0x33, 0xa9, 0x0f, 0x0d, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -696,6 +816,9 @@ type QueryClient interface { Pool(ctx context.Context, in *PoolRequest, opts ...grpc.CallOption) (*PoolResponse, error) // AllPools returns all pools on the Osmosis chain sorted by IDs. AllPools(ctx context.Context, in *AllPoolsRequest, opts ...grpc.CallOption) (*AllPoolsResponse, error) + // SpotPrice defines a gRPC query handler that returns the spot price given + // a base denomination and a quote denomination. + SpotPrice(ctx context.Context, in *SpotPriceRequest, opts ...grpc.CallOption) (*SpotPriceResponse, error) } type queryClient struct { @@ -760,6 +883,15 @@ func (c *queryClient) AllPools(ctx context.Context, in *AllPoolsRequest, opts .. return out, nil } +func (c *queryClient) SpotPrice(ctx context.Context, in *SpotPriceRequest, opts ...grpc.CallOption) (*SpotPriceResponse, error) { + out := new(SpotPriceResponse) + err := c.cc.Invoke(ctx, "/osmosis.poolmanager.v1beta1.Query/SpotPrice", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + // QueryServer is the server API for Query service. type QueryServer interface { Params(context.Context, *ParamsRequest) (*ParamsResponse, error) @@ -773,6 +905,9 @@ type QueryServer interface { Pool(context.Context, *PoolRequest) (*PoolResponse, error) // AllPools returns all pools on the Osmosis chain sorted by IDs. AllPools(context.Context, *AllPoolsRequest) (*AllPoolsResponse, error) + // SpotPrice defines a gRPC query handler that returns the spot price given + // a base denomination and a quote denomination. + SpotPrice(context.Context, *SpotPriceRequest) (*SpotPriceResponse, error) } // UnimplementedQueryServer can be embedded to have forward compatible implementations. @@ -797,6 +932,9 @@ func (*UnimplementedQueryServer) Pool(ctx context.Context, req *PoolRequest) (*P func (*UnimplementedQueryServer) AllPools(ctx context.Context, req *AllPoolsRequest) (*AllPoolsResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method AllPools not implemented") } +func (*UnimplementedQueryServer) SpotPrice(ctx context.Context, req *SpotPriceRequest) (*SpotPriceResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method SpotPrice not implemented") +} func RegisterQueryServer(s grpc1.Server, srv QueryServer) { s.RegisterService(&_Query_serviceDesc, srv) @@ -910,6 +1048,24 @@ func _Query_AllPools_Handler(srv interface{}, ctx context.Context, dec func(inte return interceptor(ctx, in, info, handler) } +func _Query_SpotPrice_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(SpotPriceRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).SpotPrice(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/osmosis.poolmanager.v1beta1.Query/SpotPrice", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).SpotPrice(ctx, req.(*SpotPriceRequest)) + } + return interceptor(ctx, in, info, handler) +} + var _Query_serviceDesc = grpc.ServiceDesc{ ServiceName: "osmosis.poolmanager.v1beta1.Query", HandlerType: (*QueryServer)(nil), @@ -938,6 +1094,10 @@ var _Query_serviceDesc = grpc.ServiceDesc{ MethodName: "AllPools", Handler: _Query_AllPools_Handler, }, + { + MethodName: "SpotPrice", + Handler: _Query_SpotPrice_Handler, + }, }, Streams: []grpc.StreamDesc{}, Metadata: "osmosis/poolmanager/v1beta1/query.proto", @@ -1356,6 +1516,78 @@ func (m *AllPoolsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } +func (m *SpotPriceRequest) 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 *SpotPriceRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *SpotPriceRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.QuoteAssetDenom) > 0 { + i -= len(m.QuoteAssetDenom) + copy(dAtA[i:], m.QuoteAssetDenom) + i = encodeVarintQuery(dAtA, i, uint64(len(m.QuoteAssetDenom))) + i-- + dAtA[i] = 0x1a + } + if len(m.BaseAssetDenom) > 0 { + i -= len(m.BaseAssetDenom) + copy(dAtA[i:], m.BaseAssetDenom) + i = encodeVarintQuery(dAtA, i, uint64(len(m.BaseAssetDenom))) + i-- + dAtA[i] = 0x12 + } + if m.PoolId != 0 { + i = encodeVarintQuery(dAtA, i, uint64(m.PoolId)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func (m *SpotPriceResponse) 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 *SpotPriceResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *SpotPriceResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.SpotPrice) > 0 { + i -= len(m.SpotPrice) + copy(dAtA[i:], m.SpotPrice) + i = encodeVarintQuery(dAtA, i, uint64(len(m.SpotPrice))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + func encodeVarintQuery(dAtA []byte, offset int, v uint64) int { offset -= sovQuery(v) base := offset @@ -1534,6 +1766,39 @@ func (m *AllPoolsResponse) Size() (n int) { return n } +func (m *SpotPriceRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.PoolId != 0 { + n += 1 + sovQuery(uint64(m.PoolId)) + } + l = len(m.BaseAssetDenom) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + l = len(m.QuoteAssetDenom) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *SpotPriceResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.SpotPrice) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + func sovQuery(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } @@ -2602,6 +2867,221 @@ func (m *AllPoolsResponse) Unmarshal(dAtA []byte) error { } return nil } +func (m *SpotPriceRequest) 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: SpotPriceRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: SpotPriceRequest: 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 + } + } + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field BaseAssetDenom", 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.BaseAssetDenom = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field QuoteAssetDenom", 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.QuoteAssetDenom = 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 *SpotPriceResponse) 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: SpotPriceResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: SpotPriceResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field SpotPrice", 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.SpotPrice = 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 skipQuery(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0 diff --git a/x/poolmanager/client/queryproto/query.pb.gw.go b/x/poolmanager/client/queryproto/query.pb.gw.go index d6a4c27bf60..9e78b4e101c 100644 --- a/x/poolmanager/client/queryproto/query.pb.gw.go +++ b/x/poolmanager/client/queryproto/query.pb.gw.go @@ -303,6 +303,78 @@ func local_request_Query_AllPools_0(ctx context.Context, marshaler runtime.Marsh } +var ( + filter_Query_SpotPrice_0 = &utilities.DoubleArray{Encoding: map[string]int{"pool_id": 0}, Base: []int{1, 1, 0}, Check: []int{0, 1, 2}} +) + +func request_Query_SpotPrice_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq SpotPriceRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["pool_id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "pool_id") + } + + protoReq.PoolId, err = runtime.Uint64(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "pool_id", err) + } + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_SpotPrice_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := client.SpotPrice(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_SpotPrice_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq SpotPriceRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["pool_id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "pool_id") + } + + protoReq.PoolId, err = runtime.Uint64(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "pool_id", err) + } + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_SpotPrice_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := server.SpotPrice(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. @@ -447,6 +519,29 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv }) + mux.Handle("GET", pattern_Query_SpotPrice_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_SpotPrice_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_SpotPrice_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + return nil } @@ -608,6 +703,26 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie }) + mux.Handle("GET", pattern_Query_SpotPrice_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_SpotPrice_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_SpotPrice_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + return nil } @@ -623,6 +738,8 @@ var ( pattern_Query_Pool_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4}, []string{"osmosis", "poolmanager", "v1beta1", "pools", "pool_id"}, "", runtime.AssumeColonVerbOpt(false))) pattern_Query_AllPools_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"osmosis", "poolmanager", "v1beta1", "all-pools"}, "", runtime.AssumeColonVerbOpt(false))) + + pattern_Query_SpotPrice_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3, 2, 4}, []string{"osmosis", "poolmanager", "pools", "pool_id", "prices"}, "", runtime.AssumeColonVerbOpt(false))) ) var ( @@ -637,4 +754,6 @@ var ( forward_Query_Pool_0 = runtime.ForwardResponseMessage forward_Query_AllPools_0 = runtime.ForwardResponseMessage + + forward_Query_SpotPrice_0 = runtime.ForwardResponseMessage )