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

CLI: Query pools by coin denom #6766

Merged
merged 31 commits into from
Nov 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
eb4cebc
Add Cli query pools by denom
DongLieu Oct 24, 2023
a9df2c7
revert
DongLieu Oct 26, 2023
fc7cd18
minor
DongLieu Oct 26, 2023
a7601dc
Merge branch 'main' into dong/list-pools-by-denom
DongLieu Oct 26, 2023
59b9dfd
minor
DongLieu Oct 26, 2023
60cda3a
Update x/poolmanager/client/query_proto_wrap.go
DongLieu Oct 27, 2023
767245f
Update x/poolmanager/client/query_proto_wrap.go
DongLieu Oct 27, 2023
c7e97b4
Update x/poolmanager/router.go
DongLieu Oct 27, 2023
b6a1548
Update proto/osmosis/poolmanager/v1beta1/query.proto
DongLieu Oct 27, 2023
db8ab86
Update x/poolmanager/router.go
DongLieu Oct 27, 2023
a676097
Update proto/osmosis/poolmanager/v1beta1/query.proto
DongLieu Oct 27, 2023
d27e288
Update x/poolmanager/router.go
DongLieu Oct 27, 2023
ebda3b4
Update x/poolmanager/router.go
DongLieu Oct 27, 2023
49dcac4
minor and lint
DongLieu Oct 27, 2023
0f5179c
Use dynamic slice instead of Allocate the slice
DongLieu Oct 27, 2023
7c4a114
changelog
DongLieu Oct 27, 2023
bd8b379
make proto-gen
DongLieu Oct 27, 2023
0f53613
Merge branch 'main' into dong/list-pools-by-denom
DongLieu Nov 1, 2023
f8e710a
Merge branch 'main' into dong/list-pools-by-denom
DongLieu Nov 1, 2023
e22a244
lint proto
hieuvubk Nov 2, 2023
045fcac
Merge branch 'main' into dong/list-pools-by-denom
DongLieu Nov 2, 2023
3903673
Merge branch 'main' into dong/list-pools-by-denom
DongLieu Nov 5, 2023
182a261
add test
DongLieu Nov 5, 2023
18022fd
Update x/poolmanager/router_test.go
DongLieu Nov 7, 2023
dbaee05
Update x/poolmanager/router_test.go
DongLieu Nov 7, 2023
d8837d3
merge main and fix config
DongLieu Nov 7, 2023
51d4e04
make proto-all
DongLieu Nov 7, 2023
cdccac1
use a few poolType Concentrated
DongLieu Nov 7, 2023
b839255
Merge branch 'main' into dong/list-pools-by-denom
DongLieu Nov 8, 2023
42e668b
Merge branch 'main' into dong/list-pools-by-denom
DongLieu Nov 12, 2023
7fc45e0
Merge branch 'main' into dong/list-pools-by-denom
DongLieu Nov 15, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Features

* [#6766](https://github.com/osmosis-labs/osmosis/pull/6766) CLI: Query pool by coin denom
* [#6468](https://github.com/osmosis-labs/osmosis/pull/6468) feat: remove osmo multihop discount
* [#6420](https://github.com/osmosis-labs/osmosis/pull/6420) feat[CL]: Creates a governance set whitelist of addresses that can bypass the normal pool creation restrictions on concentrated liquidity pools
* [#6623](https://github.com/osmosis-labs/osmosis/pull/6420) feat: transfer cl positions to new owner
Expand Down
17 changes: 17 additions & 0 deletions proto/osmosis/poolmanager/v1beta1/query.proto
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,12 @@ service Query {
rpc AllPools(AllPoolsRequest) returns (AllPoolsResponse) {
option (google.api.http).get = "/osmosis/poolmanager/v1beta1/all-pools";
}
// ListPoolsByDenom return all pools by denom
rpc ListPoolsByDenom(ListPoolsByDenomRequest)
returns (ListPoolsByDenomResponse) {
option (google.api.http).get =
"/osmosis/poolmanager/v1beta1/list-pools-by-denom";
}

// SpotPrice defines a gRPC query handler that returns the spot price given
// a base denomination and a quote denomination.
Expand Down Expand Up @@ -238,6 +244,17 @@ message AllPoolsResponse {
[ (cosmos_proto.accepts_interface) = "PoolI" ];
}

// =======================================================
// ListPoolsByDenomRequest
message ListPoolsByDenomRequest {
string denom = 1 [ (gogoproto.moretags) = "yaml:\"denom\"" ];
}

message ListPoolsByDenomResponse {
repeated google.protobuf.Any pools = 1
[ (cosmos_proto.accepts_interface) = "PoolI" ];
}
// ==========================================================
// SpotPriceRequest defines the gRPC request structure for a SpotPrice
// query.
message SpotPriceRequest {
Expand Down
2 changes: 1 addition & 1 deletion scripts/setup_superfluid.sh
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,4 @@ sleep 7
osmosisd tx gov vote 1 yes --from=validator1 --keyring-backend=test --chain-id=testing --yes --home=$HOME/.osmosisd/validator1
sleep 7
osmosisd tx gov vote 1 yes --from=validator2 --keyring-backend=test --chain-id=testing --yes --home=$HOME/.osmosisd/validator2
sleep 7
sleep 7
10 changes: 10 additions & 0 deletions x/poolmanager/client/cli/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ func GetQueryCmd() *cobra.Command {
osmocli.AddQueryCmd(cmd, queryproto.NewQueryClient, GetCmdTotalVolumeForPool)
osmocli.AddQueryCmd(cmd, queryproto.NewQueryClient, GetCmdTradingPairTakerFee)
osmocli.AddQueryCmd(cmd, queryproto.NewQueryClient, GetCmdEstimateTradeBasedOnPriceImpact)
osmocli.AddQueryCmd(cmd, queryproto.NewQueryClient, GetCmdListPoolsByDenom)
cmd.AddCommand(
osmocli.GetParams[*queryproto.ParamsRequest](
types.ModuleName, queryproto.NewQueryClient),
Expand Down Expand Up @@ -105,6 +106,15 @@ func GetCmdSpotPrice() (*osmocli.QueryDescriptor, *queryproto.SpotPriceRequest)
`,
}, &queryproto.SpotPriceRequest{}
}
func GetCmdListPoolsByDenom() (*osmocli.QueryDescriptor, *queryproto.ListPoolsByDenomRequest) {
return &osmocli.QueryDescriptor{
Use: "list-pools-by-denom",
Short: "Query list-pools-by-denom",
Long: `Query list-pools-by-denom
{{.CommandPrefix}} list-pools-by-denom uosmo
`,
}, &queryproto.ListPoolsByDenomRequest{}
}

func EstimateSwapExactAmountInParseArgs(args []string, fs *flag.FlagSet) (proto.Message, error) {
poolID, err := strconv.Atoi(args[0])
Expand Down
10 changes: 10 additions & 0 deletions x/poolmanager/client/grpc/grpc_query.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,16 @@ func (q Querier) SpotPrice(grpcCtx context.Context,
return q.Q.SpotPrice(ctx, *req)
}

func (q Querier) ListPoolsByDenom(grpcCtx context.Context,
req *queryproto.ListPoolsByDenomRequest,
) (*queryproto.ListPoolsByDenomResponse, error) {
if req == nil {
return nil, status.Error(codes.InvalidArgument, "empty request")
}
ctx := sdk.UnwrapSDKContext(grpcCtx)
return q.Q.ListPoolsByDenom(ctx, *req)
}

func (q Querier) Pool(grpcCtx context.Context,
req *queryproto.PoolRequest,
) (*queryproto.PoolResponse, error) {
Expand Down
24 changes: 24 additions & 0 deletions x/poolmanager/client/query_proto_wrap.go
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,30 @@ func (q Querier) AllPools(ctx sdk.Context, req queryproto.AllPoolsRequest) (*que
}, nil
}

// ListPoolsByDenom returns a list of pools filtered by denom
func (q Querier) ListPoolsByDenom(ctx sdk.Context, req queryproto.ListPoolsByDenomRequest) (*queryproto.ListPoolsByDenomResponse, error) {
if req.Denom == "" {
return nil, status.Error(codes.InvalidArgument, "invalid denom")
}
pools, err := q.K.ListPoolsByDenom(ctx, req.Denom)
if err != nil {
return nil, status.Error(codes.Internal, err.Error())
}

var anyPools []*codectypes.Any
for _, pool := range pools {
any, err := codectypes.NewAnyWithValue(pool.AsSerializablePool())
if err != nil {
return nil, err
}
anyPools = append(anyPools, any)
}

return &queryproto.ListPoolsByDenomResponse{
Pools: anyPools,
}, nil
}

// SpotPrice returns the spot price of the pool with the given quote and base asset denoms. 18 decimals.
func (q Querier) SpotPrice(ctx sdk.Context, req queryproto.SpotPriceRequest) (*queryproto.SpotPriceResponse, error) {
if req.BaseAssetDenom == "" {
Expand Down
Loading