-
Notifications
You must be signed in to change notification settings - Fork 638
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
feat(poolmanager): v2 SpotPrice query with 36 decimals #6488
Changes from all commits
40734d5
a38a388
785834b
6ad4aff
27c2635
db82881
18b8168
344c709
a01f95a
a7bd310
6cce396
d2cf2ed
389ac92
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||
---|---|---|---|---|
@@ -0,0 +1,44 @@ | ||||
syntax = "proto3"; | ||||
package osmosis.poolmanager.v2; | ||||
|
||||
import "gogoproto/gogo.proto"; | ||||
|
||||
import "google/api/annotations.proto"; | ||||
import "google/protobuf/any.proto"; | ||||
import "cosmos_proto/cosmos.proto"; | ||||
import "google/protobuf/timestamp.proto"; | ||||
|
||||
option go_package = "github.com/osmosis-labs/osmosis/v19/x/poolmanager/client/queryprotov2"; | ||||
|
||||
service Query { | ||||
// SpotPriceV2 defines a gRPC query handler that returns the spot price given | ||||
// a base denomination and a quote denomination. | ||||
// The returned spot price has 36 decimal places. However, some of | ||||
// modules perform sig fig rounding so most of the rightmost decimals can be | ||||
// zeroes. | ||||
rpc SpotPriceV2(SpotPriceRequest) returns (SpotPriceResponse) { | ||||
option (google.api.http).get = | ||||
"/osmosis/poolmanager/v2/pools/{pool_id}/prices"; | ||||
} | ||||
} | ||||
|
||||
// SpotPriceRequest defines the gRPC request structure for a SpotPrice | ||||
// query. | ||||
message SpotPriceRequest { | ||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. shouldn't this also have a
same goes for There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. on the second thought, I guess it is fine, since we call it by specifying a package name, which has |
||||
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 BigDec. Ex) 10.203uatom | ||||
string spot_price = 1 [ | ||||
(gogoproto.customtype) = "github.com/osmosis-labs/osmosis/osmomath.BigDec", | ||||
(gogoproto.moretags) = "yaml:\"spot_price\"", | ||||
(gogoproto.nullable) = false | ||||
]; | ||||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
keeper: | ||
path: "github.com/osmosis-labs/osmosis/v19/x/poolmanager" | ||
struct: "Keeper" | ||
client_path: "github.com/osmosis-labs/osmosis/v19/x/poolmanager/client" | ||
queries: | ||
SpotPrice: | ||
proto_wrapper: | ||
query_func: "k.RouteCalculateSpotPrice" | ||
cli: | ||
cmd: "SpotPrice" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
package grpc | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It probably doesn't matter but the package should be the first line, are we able to modify the template to do this for all of the below? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Discussed offline and concluded that this is fine as long as no errors in the editor. This stems from this line in the template: Didn't find a trivial way to fix and concluded that it is fine to keep as is since the change is only cosmetic |
||
package grpc | ||
|
||
// THIS FILE IS GENERATED CODE, DO NOT EDIT | ||
// SOURCE AT `proto/osmosis/concentrated-liquidity/query.yml` | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
|
||
package grpcv2 | ||
|
||
// THIS FILE IS GENERATED CODE, DO NOT EDIT | ||
// SOURCE AT `proto/osmosis/poolmanager/v2/query.yml` | ||
|
||
import ( | ||
context "context" | ||
|
||
"google.golang.org/grpc/codes" | ||
"google.golang.org/grpc/status" | ||
|
||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
"github.com/osmosis-labs/osmosis/v19/x/poolmanager/client" | ||
"github.com/osmosis-labs/osmosis/v19/x/poolmanager/client/queryprotov2" | ||
) | ||
|
||
type Querier struct { | ||
Q client.QuerierV2 | ||
} | ||
|
||
var _ queryprotov2.QueryServer = Querier{} | ||
|
||
func (q Querier) SpotPriceV2(grpcCtx context.Context, | ||
req *queryprotov2.SpotPriceRequest, | ||
) (*queryprotov2.SpotPriceResponse, error) { | ||
if req == nil { | ||
return nil, status.Error(codes.InvalidArgument, "empty request") | ||
} | ||
ctx := sdk.UnwrapSDKContext(grpcCtx) | ||
return q.Q.SpotPriceV2(ctx, *req) | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Link