-
Notifications
You must be signed in to change notification settings - Fork 592
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(poolmanager): v2 SpotPrice query with 36 decimals (#6488)
* feat: make PoolModuleI CalculateSpotPrice API return BigDec * updates * clean up * updates * updates * feat(poolmaanger): v2 SpotPrice query with 36 decimals * changelog * clean up * Generated protofile changes * querygen updates * Update cmd/querygen/main.go --------- Co-authored-by: github-actions <github-actions@github.com> Co-authored-by: Adam Tucker <adam@osmosis.team> (cherry picked from commit b1bfa20) # Conflicts: # CHANGELOG.md
- Loading branch information
1 parent
7e39261
commit aac1a97
Showing
19 changed files
with
1,087 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 { | ||
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 | ||
]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.