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

added single pool query #4549

Merged
merged 26 commits into from
Mar 24, 2023
Merged
Show file tree
Hide file tree
Changes from 17 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
e87f1ce
added single pool query
nicolaslara Mar 9, 2023
7278e48
added changelog
nicolaslara Mar 9, 2023
149c32f
remove empty tests as they are invalid
nicolaslara Mar 9, 2023
ee46ae9
removed sender and made reserved
nicolaslara Mar 9, 2023
12ba6cf
remove and reserve unused sender
nicolaslara Mar 9, 2023
9fd94a0
removed sender
nicolaslara Mar 9, 2023
01d7ba5
actually remove sender
nicolaslara Mar 9, 2023
44679b2
querygen
nicolaslara Mar 9, 2023
e85903d
move impl to correct file
nicolaslara Mar 9, 2023
0569a5b
more flexible querygen
nicolaslara Mar 9, 2023
a760155
Update proto/osmosis/poolmanager/v1beta1/query.proto
nicolaslara Mar 15, 2023
65a00e1
Update proto/osmosis/poolmanager/v1beta1/query.proto
nicolaslara Mar 15, 2023
909f440
Update proto/osmosis/poolmanager/v1beta1/query.proto
nicolaslara Mar 15, 2023
5662ab3
Update proto/osmosis/poolmanager/v1beta1/query.proto
nicolaslara Mar 15, 2023
4866d00
Merge branch 'main' into nicolas/simple-swap-endpoint
nicolaslara Mar 15, 2023
95de2fe
protos
nicolaslara Mar 15, 2023
27115c2
added cli
nicolaslara Mar 15, 2023
bf8b9d4
fixed command parsing
nicolaslara Mar 15, 2023
a3c9056
single line
nicolaslara Mar 15, 2023
76a6293
lint
nicolaslara Mar 15, 2023
bf00a07
fix cli
nicolaslara Mar 16, 2023
e6f7ecc
Merge branch 'main' into nicolas/simple-swap-endpoint
nicolaslara Mar 20, 2023
8408858
run proto gen
nicolaslara Mar 20, 2023
2755382
added whitelisted query
nicolaslara Mar 20, 2023
5a7bf12
fix test for v15
nicolaslara Mar 20, 2023
79b8fd2
Merge branch 'main' into nicolas/simple-swap-endpoint
nicolaslara Mar 24, 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
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Misc Improvements

* [#4582](https://github.com/osmosis-labs/osmosis/pull/4582) Consistently generate build tags metadata, to return a comma-separated list without stray quotes. This affects the output from `version` CLI subcommand and server info API calls.
* [#4549](https://github.com/osmosis-labs/osmosis/pull/4549) Add single pool price estimate queries

### API Breaks

### API breaks

Expand Down
3 changes: 2 additions & 1 deletion cmd/querygen/templates/grpcTemplate.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,13 @@ type GrpcTemplate struct {

type GrpcQuery struct {
QueryName string
Response string
}

func GrpcTemplateFromQueryYml(queryYml QueryYml) GrpcTemplate {
GrpcQueries := []GrpcQuery{}
for queryName := range queryYml.Queries {
GrpcQueries = append(GrpcQueries, GrpcQuery{QueryName: queryName})
GrpcQueries = append(GrpcQueries, GrpcQuery{QueryName: queryName, Response: queryYml.Queries[queryName].ProtoWrapper.Response})
}
sort.Slice(GrpcQueries, func(i, j int) bool {
return GrpcQueries[i].QueryName > GrpcQueries[j].QueryName
Expand Down
2 changes: 1 addition & 1 deletion cmd/querygen/templates/grpc_template.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ var _ queryproto.QueryServer = Querier{}

func (q Querier) {{.QueryName}}(grpcCtx context.Context,
req *queryproto.{{.QueryName}}Request,
) (*queryproto.{{.QueryName}}Response, error) {
) ({{ if .Response }}{{.Response}}{{else}}*queryproto.{{.QueryName}}Response{{end}}, error) {
if req == nil {
return nil, status.Error(codes.InvalidArgument, "empty request")
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/querygen/templates/queryyml.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ type YmlQueryDescriptor struct {
type ProtoWrapperDescriptor struct {
DefaultValues map[string]string `yaml:"default_values"`
QueryFunc string `yaml:"query_func"`
Response string
Response string `yaml:"response"`
}

type CliDescriptor struct{}
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ go 1.19
require (
github.com/CosmWasm/wasmd v0.30.0
github.com/cosmos/cosmos-proto v1.0.0-alpha8
github.com/cosmos/cosmos-sdk v0.46.11
github.com/cosmos/cosmos-sdk v0.47.0
github.com/cosmos/go-bip39 v1.0.0
github.com/cosmos/ibc-go/v4 v4.3.0
github.com/gogo/protobuf v1.3.3
Expand Down
2 changes: 0 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -938,8 +938,6 @@ github.com/osmosis-labs/osmosis/osmomath v0.0.0-20230105183030-bccf5202f260 h1:+
github.com/osmosis-labs/osmosis/osmomath v0.0.0-20230105183030-bccf5202f260/go.mod h1:KrzYoNtnWUH75rj1XAsSR4nymlHFU7jeVOx7/1KMe0k=
github.com/osmosis-labs/osmosis/osmoutils v0.0.0-20230303084731-71ab5decdfa1 h1:PeBYW7Jze++bdl0PddxTVh/2xllNuu7Wol8cPEsnZXE=
github.com/osmosis-labs/osmosis/osmoutils v0.0.0-20230303084731-71ab5decdfa1/go.mod h1:fHfEDIHu347XE+64DISa7LJ5OOWpubz+6H28huZ90fo=
github.com/osmosis-labs/osmosis/x/epochs v0.0.0-20230220095848-f17c63bbb805 h1:O+LFSee2ru/a8ifv0VkpOimbPuQVaY0b69RtbbNHcKM=
github.com/osmosis-labs/osmosis/x/epochs v0.0.0-20230220095848-f17c63bbb805/go.mod h1:lJebPe8cmSTwXXuWmgSNc1S4Bobz9g3x05ZL4igbAAI=
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-20230201094300-e8bba2b45fd8 h1:Ov+gyEBpU2hJkLIFAHCcQZwehCSCXFNYzqQY1zJqSXk=
Expand Down
42 changes: 36 additions & 6 deletions proto/osmosis/poolmanager/v1beta1/query.proto
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,30 @@ service Query {
rpc EstimateSwapExactAmountIn(EstimateSwapExactAmountInRequest)
returns (EstimateSwapExactAmountInResponse) {
option (google.api.http).get =
"/osmosis/gamm/v1beta1/{pool_id}/estimate/swap_exact_amount_in";
"/osmosis/poolmanager/v1beta1/{pool_id}/estimate/swap_exact_amount_in";
}

rpc EstimateSinglePoolSwapExactAmountIn(
EstimateSinglePoolSwapExactAmountInRequest)
returns (EstimateSwapExactAmountInResponse) {
option (google.api.http).get =
"/osmosis/poolmanager/v1beta1/{pool_id}/estimate/"
"single_pool_swap_exact_amount_in";
nicolaslara marked this conversation as resolved.
Show resolved Hide resolved
}

// Estimates swap amount in given out.
rpc EstimateSwapExactAmountOut(EstimateSwapExactAmountOutRequest)
returns (EstimateSwapExactAmountOutResponse) {
option (google.api.http).get =
"/osmosis/gamm/v1beta1/{pool_id}/estimate/swap_exact_amount_out";
"/osmosis/poolmanager/v1beta1/{pool_id}/estimate/swap_exact_amount_out";
}

rpc EstimateSinglePoolSwapExactAmountOut(
EstimateSinglePoolSwapExactAmountOutRequest)
returns (EstimateSwapExactAmountOutResponse) {
option (google.api.http).get =
"/osmosis/poolmanager/v1beta1/{pool_id}/estimate_out/"
"single_pool_swap_exact_amount_out";
}

rpc NumPools(NumPoolsRequest) returns (NumPoolsResponse) {
Expand All @@ -45,8 +61,8 @@ message ParamsResponse { Params params = 1 [ (gogoproto.nullable) = false ]; }

//=============================== EstimateSwapExactAmountIn
message EstimateSwapExactAmountInRequest {
// TODO: CHANGE THIS TO RESERVED IN A PATCH RELEASE
string sender = 1 [ (gogoproto.moretags) = "yaml:\"sender\"" ];
reserved 1;
reserved "sender";
Comment on lines 80 to +82
Copy link
Member

@ValarDragon ValarDragon Mar 13, 2023

Choose a reason for hiding this comment

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

Is this query in the stargate whitelist? If so, then seems important to reason about if this would cause a state break on mainnet. My first pass thought is it wouldn't, and should be safe. This is because the only gas difference would come from the rust side. But the Rust side is fixed.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It is. It's also potentially used by contracts.

One place that may be state breaking is https://github.com/osmosis-labs/osmosis/pull/4549/files#diff-417b3334c7fd0aefd80aafa70e8feb77a81586dc63b266105aa25bad2ab09a2fL53. It was (unnecessarily) checking that the sender wasn't empty. So a call with an empty sender would've failed before and would pass now.

Copy link
Member

@mattverse mattverse Mar 15, 2023

Choose a reason for hiding this comment

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

good catch, this leads me to think that we might want to add queries included in stargate queries to e2e testing, since we can mistakenly merge a query PR and have it state breaking. Going to create an issue to track this and further discuss this

uint64 pool_id = 2 [ (gogoproto.moretags) = "yaml:\"pool_id\"" ];
string token_in = 3 [ (gogoproto.moretags) = "yaml:\"token_in\"" ];
repeated SwapAmountInRoute routes = 4 [
Expand All @@ -55,6 +71,13 @@ message EstimateSwapExactAmountInRequest {
];
}

message EstimateSinglePoolSwapExactAmountInRequest {
uint64 pool_id = 1 [ (gogoproto.moretags) = "yaml:\"pool_id\"" ];
string token_in = 2 [ (gogoproto.moretags) = "yaml:\"token_in\"" ];
string token_out_denom = 3
[ (gogoproto.moretags) = "yaml:\"token_out_denom\"" ];
}

message EstimateSwapExactAmountInResponse {
string token_out_amount = 1 [
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int",
Expand All @@ -65,8 +88,8 @@ message EstimateSwapExactAmountInResponse {

//=============================== EstimateSwapExactAmountOut
message EstimateSwapExactAmountOutRequest {
// TODO: CHANGE THIS TO RESERVED IN A PATCH RELEASE
string sender = 1 [ (gogoproto.moretags) = "yaml:\"sender\"" ];
reserved 1;
reserved "sender";
uint64 pool_id = 2 [ (gogoproto.moretags) = "yaml:\"pool_id\"" ];
repeated SwapAmountOutRoute routes = 3 [
(gogoproto.moretags) = "yaml:\"routes\"",
Expand All @@ -75,6 +98,13 @@ message EstimateSwapExactAmountOutRequest {
string token_out = 4 [ (gogoproto.moretags) = "yaml:\"token_out\"" ];
}

message EstimateSinglePoolSwapExactAmountOutRequest {
uint64 pool_id = 1 [ (gogoproto.moretags) = "yaml:\"pool_id\"" ];
string token_in_denom = 2
[ (gogoproto.moretags) = "yaml:\"token_in_denom\"" ];
string token_out = 3 [ (gogoproto.moretags) = "yaml:\"token_out\"" ];
}

message EstimateSwapExactAmountOutResponse {
string token_in_amount = 1 [
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int",
Expand Down
12 changes: 12 additions & 0 deletions proto/osmosis/poolmanager/v1beta1/query.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,18 @@ queries:
query_func: "k.EstimateSwapExactAmountOut"
cli:
cmd: "EstimateSwapExactAmountOut"
EstimateSinglePoolSwapExactAmountIn:
proto_wrapper:
query_func: "k.EstimateSinglePoolSwapExactAmountIn"
response: "*queryproto.EstimateSwapExactAmountInResponse"
cli:
cmd: "EstimateSinglePoolSwapExactAmountIn"
EstimateSinglePoolSwapExactAmountOut:
proto_wrapper:
query_func: "k.EstimateSinglePoolSwapExactAmountOutTEST"
response: "*queryproto.EstimateSwapExactAmountOutResponse"
cli:
cmd: "EstimateSinglePoolSwapExactAmountOut"
NumPools:
proto_wrapper:
query_func: "k.NumPools"
Expand Down
2 changes: 1 addition & 1 deletion proto/osmosis/poolmanager/v1beta1/swap_route.proto
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@ message SwapAmountInRoute {
message SwapAmountOutRoute {
uint64 pool_id = 1 [ (gogoproto.moretags) = "yaml:\"pool_id\"" ];
string token_in_denom = 2
[ (gogoproto.moretags) = "yaml:\"token_out_denom\"" ];
[ (gogoproto.moretags) = "yaml:\"token_in_denom\"" ];
}
42 changes: 36 additions & 6 deletions x/poolmanager/client/cli/cli_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,9 @@ func TestNewSwapExactAmountOutCmd(t *testing.T) {
desc, _ := cli.NewSwapExactAmountOutCmd()
tcs := map[string]osmocli.TxCliTestCase[*types.MsgSwapExactAmountOut]{
"swap exact amount out": {
Cmd: "10stake 20 --swap-route-pool-ids=1 --swap-route-denoms=node0token --from=" + testAddresses[0].String(),
Cmd: "10stake 20 --swap-route-pool-ids=1 --swap-route-denoms=node0token",
ExpectedMsg: &types.MsgSwapExactAmountOut{
Sender: testAddresses[0].String(),
Sender: "",
mattverse marked this conversation as resolved.
Show resolved Hide resolved
Routes: []types.SwapAmountOutRoute{{PoolId: 1, TokenInDenom: "node0token"}},
TokenInMaxAmount: sdk.NewIntFromUint64(20),
TokenOut: sdk.NewInt64Coin("stake", 10),
Expand Down Expand Up @@ -172,9 +172,9 @@ func TestNewSwapExactAmountInCmd(t *testing.T) {
desc, _ := cli.NewSwapExactAmountInCmd()
tcs := map[string]osmocli.TxCliTestCase[*types.MsgSwapExactAmountIn]{
"swap exact amount in": {
Cmd: "10stake 3 --swap-route-pool-ids=1 --swap-route-denoms=node0token --from=" + testAddresses[0].String(),
Cmd: "10stake 3 --swap-route-pool-ids=1 --swap-route-denoms=node0token",
ExpectedMsg: &types.MsgSwapExactAmountIn{
Sender: testAddresses[0].String(),
Sender: "",
Routes: []types.SwapAmountInRoute{{PoolId: 1, TokenOutDenom: "node0token"}},
TokenIn: sdk.NewInt64Coin("stake", 10),
TokenOutMinAmount: sdk.NewIntFromUint64(3),
Expand All @@ -201,7 +201,6 @@ func TestGetCmdEstimateSwapExactAmountIn(t *testing.T) {
"basic test": {
Cmd: "1 osm11vmx8jtggpd9u7qr0t8vxclycz85u925sazglr7 10stake --swap-route-pool-ids=2 --swap-route-denoms=node0token",
ExpectedQuery: &queryproto.EstimateSwapExactAmountInRequest{
Sender: "osm11vmx8jtggpd9u7qr0t8vxclycz85u925sazglr7",
PoolId: 1,
TokenIn: "10stake",
Routes: []types.SwapAmountInRoute{{PoolId: 2, TokenOutDenom: "node0token"}},
Expand All @@ -210,13 +209,13 @@ func TestGetCmdEstimateSwapExactAmountIn(t *testing.T) {
}
osmocli.RunQueryTestCases(t, desc, tcs)
}

func TestGetCmdEstimateSwapExactAmountOut(t *testing.T) {
desc, _ := cli.GetCmdEstimateSwapExactAmountOut()
tcs := map[string]osmocli.QueryCliTestCase[*queryproto.EstimateSwapExactAmountOutRequest]{
"basic test": {
Cmd: "1 osm11vmx8jtggpd9u7qr0t8vxclycz85u925sazglr7 10stake --swap-route-pool-ids=2 --swap-route-denoms=node0token",
ExpectedQuery: &queryproto.EstimateSwapExactAmountOutRequest{
Sender: "osm11vmx8jtggpd9u7qr0t8vxclycz85u925sazglr7",
PoolId: 1,
TokenOut: "10stake",
Routes: []types.SwapAmountOutRoute{{PoolId: 2, TokenInDenom: "node0token"}},
Expand All @@ -225,6 +224,37 @@ func TestGetCmdEstimateSwapExactAmountOut(t *testing.T) {
}
osmocli.RunQueryTestCases(t, desc, tcs)
}

func TestGetCmdEstimateSinglePoolSwapExactAmountIn(t *testing.T) {
desc, _ := cli.GetCmdEstimateSinglePoolSwapExactAmountIn()
tcs := map[string]osmocli.QueryCliTestCase[*queryproto.EstimateSinglePoolSwapExactAmountInRequest]{
"basic test": {
Cmd: "1 10stake node0token",
ExpectedQuery: &queryproto.EstimateSinglePoolSwapExactAmountInRequest{
PoolId: 1,
TokenIn: "10stake",
TokenOutDenom: "node0token",
},
},
}
osmocli.RunQueryTestCases(t, desc, tcs)
}

func TestGetCmdEstimateSinglePoolSwapExactAmountOut(t *testing.T) {
desc, _ := cli.GetCmdEstimateSinglePoolSwapExactAmountOut()
tcs := map[string]osmocli.QueryCliTestCase[*queryproto.EstimateSinglePoolSwapExactAmountOutRequest]{
"basic test": {
Cmd: "1 node0token 10stake",
ExpectedQuery: &queryproto.EstimateSinglePoolSwapExactAmountOutRequest{
PoolId: 1,
TokenInDenom: "node0token",
TokenOut: "10stake",
},
},
}
osmocli.RunQueryTestCases(t, desc, tcs)
}

func (s *IntegrationTestSuite) TestNewCreatePoolCmd() {
val := s.network.Validators[0]

Expand Down
36 changes: 30 additions & 6 deletions x/poolmanager/client/cli/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,19 @@ 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, GetCmdEstimateSinglePoolSwapExactAmountIn)
osmocli.AddQueryCmd(cmd, queryproto.NewQueryClient, GetCmdEstimateSinglePoolSwapExactAmountOut)

return cmd
}

// GetCmdEstimateSwapExactAmountIn returns estimation of output coin when amount of x token input.
func GetCmdEstimateSwapExactAmountIn() (*osmocli.QueryDescriptor, *queryproto.EstimateSwapExactAmountInRequest) {
return &osmocli.QueryDescriptor{
Use: "estimate-swap-exact-amount-in <poolID> <sender> <tokenIn>",
Use: "estimate-swap-exact-amount-in <poolID> <tokenIn>",
Short: "Query estimate-swap-exact-amount-in",
Long: `Query estimate-swap-exact-amount-in.{{.ExampleHeader}}
{{.CommandPrefix}} estimate-swap-exact-amount-in 1 osm11vmx8jtggpd9u7qr0t8vxclycz85u925sazglr7 1000stake --swap-route-pool-ids=2 --swap-route-pool-ids=3`,
{{.CommandPrefix}} estimate-swap-exact-amount-in 1 1000stake --swap-route-pool-ids=2 --swap-route-pool-ids=3`,
ParseQuery: EstimateSwapExactAmountInParseArgs,
Flags: osmocli.FlagDesc{RequiredFlags: []*flag.FlagSet{FlagSetMultihopSwapRoutes()}},
QueryFnName: "EstimateSwapExactAmountIn",
Expand All @@ -44,10 +46,10 @@ func GetCmdEstimateSwapExactAmountIn() (*osmocli.QueryDescriptor, *queryproto.Es
// GetCmdEstimateSwapExactAmountOut returns estimation of input coin to get exact amount of x token output.
func GetCmdEstimateSwapExactAmountOut() (*osmocli.QueryDescriptor, *queryproto.EstimateSwapExactAmountOutRequest) {
return &osmocli.QueryDescriptor{
Use: "estimate-swap-exact-amount-out <poolID> <sender> <tokenOut>",
Use: "estimate-swap-exact-amount-out <poolID> <tokenOut>",
Short: "Query estimate-swap-exact-amount-out",
Long: `Query estimate-swap-exact-amount-out.{{.ExampleHeader}}
{{.CommandPrefix}} estimate-swap-exact-amount-out 1 osm11vmx8jtggpd9u7qr0t8vxclycz85u925sazglr7 1000stake --swap-route-pool-ids=2 --swap-route-pool-ids=3`,
{{.CommandPrefix}} estimate-swap-exact-amount-out 1 1000stake --swap-route-pool-ids=2 --swap-route-pool-ids=3`,
ParseQuery: EstimateSwapExactAmountOutParseArgs,
Flags: osmocli.FlagDesc{RequiredFlags: []*flag.FlagSet{FlagSetMultihopSwapRoutes()}},
QueryFnName: "EstimateSwapExactAmountOut",
Expand Down Expand Up @@ -76,7 +78,6 @@ func EstimateSwapExactAmountInParseArgs(args []string, fs *flag.FlagSet) (proto.
}

return &queryproto.EstimateSwapExactAmountInRequest{
mattverse marked this conversation as resolved.
Show resolved Hide resolved
Sender: args[1], // TODO: where sender is used?
PoolId: uint64(poolID), // TODO: is this poolId used?
TokenIn: args[2],
Routes: routes,
Expand All @@ -95,9 +96,32 @@ func EstimateSwapExactAmountOutParseArgs(args []string, fs *flag.FlagSet) (proto
}

mattverse marked this conversation as resolved.
Show resolved Hide resolved
return &queryproto.EstimateSwapExactAmountOutRequest{
Sender: args[1], // TODO: where sender is used?
PoolId: uint64(poolID), // TODO: is this poolId used?
Routes: routes,
TokenOut: args[2],
}, nil
}

// GetCmdEstimateSinglePoolSwapExactAmountIn returns estimation of output coin when amount of x token input.
func GetCmdEstimateSinglePoolSwapExactAmountIn() (*osmocli.QueryDescriptor, *queryproto.EstimateSinglePoolSwapExactAmountInRequest) {
return &osmocli.QueryDescriptor{
Use: "estimate-single-pool-swap-exact-amount-in <poolID> <tokenIn> <tokenOutDenom>",
Short: "Query estimate-single-pool-swap-exact-amount-in",
Long: `Query estimate-single-pool-swap-exact-amount-in.{{.ExampleHeader}}
{{.CommandPrefix}} estimate-single-pool-swap-exact-amount-in 1 1000stake uosmo`,
QueryFnName: "EstimateSinglePoolSwapExactAmountIn",
CustomFlagOverrides: customRouterFlagOverride,
}, &queryproto.EstimateSinglePoolSwapExactAmountInRequest{}
}

// GetCmdEstimateSinglePoolSwapExactAmountOut returns estimation of input coin to get exact amount of x token output.
func GetCmdEstimateSinglePoolSwapExactAmountOut() (*osmocli.QueryDescriptor, *queryproto.EstimateSinglePoolSwapExactAmountOutRequest) {
return &osmocli.QueryDescriptor{
Use: "estimate-single-pool-swap-exact-amount-out <poolID> <tokenInDenom> <tokenOut>",
Short: "Query estimate-single-pool-swap-exact-amount-out",
Long: `Query estimate-single-pool-swap-exact-amount-out.{{.ExampleHeader}}
{{.CommandPrefix}} estimate-single-pool-swap-exact-amount-out 1 uosmo 1000stake`,
QueryFnName: "EstimateSinglePoolSwapExactAmountOut",
}, &queryproto.EstimateSinglePoolSwapExactAmountOutRequest{}

}
Loading