Skip to content

Commit

Permalink
Deprecate unused pool id field in swap estimate (#6530)
Browse files Browse the repository at this point in the history
* Deprecate unused pool id field in swap estimate

* Generated protofile changes

* Bring back pool id for single swaps

* Generated protofile changes

* Fix example

* Add changelog

* Add changelog

---------

Co-authored-by: github-actions <[email protected]>
  • Loading branch information
mattverse and github-actions authored Nov 5, 2023
1 parent fe7aa1e commit f2cd0d8
Show file tree
Hide file tree
Showing 5 changed files with 145 additions and 137 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### API Breaks

* [#6805](https://github.com/osmosis-labs/osmosis/pull/6805) return bucket index of the current tick from LiquidityPerTickRange query
* [#6530](https://github.com/osmosis-labs/osmosis/pull/6530) Improve error message when CL LP fails due to slippage bound hit.

### Bug Fixes

Expand Down
12 changes: 8 additions & 4 deletions proto/osmosis/poolmanager/v1beta1/query.proto
Original file line number Diff line number Diff line change
Expand Up @@ -144,15 +144,17 @@ message ParamsResponse { Params params = 1 [ (gogoproto.nullable) = false ]; }
message EstimateSwapExactAmountInRequest {
reserved 1;
reserved "sender";
uint64 pool_id = 2 [ (gogoproto.moretags) = "yaml:\"pool_id\"" ];
uint64 pool_id = 2
[ (gogoproto.moretags) = "yaml:\"pool_id\"", deprecated = true ];
string token_in = 3 [ (gogoproto.moretags) = "yaml:\"token_in\"" ];
repeated SwapAmountInRoute routes = 4 [
(gogoproto.moretags) = "yaml:\"routes\"",
(gogoproto.nullable) = false
];
}
message EstimateSwapExactAmountInWithPrimitiveTypesRequest {
uint64 pool_id = 1 [ (gogoproto.moretags) = "yaml:\"pool_id\"" ];
uint64 pool_id = 1
[ (gogoproto.moretags) = "yaml:\"pool_id\"", deprecated = true ];
string token_in = 2 [ (gogoproto.moretags) = "yaml:\"token_in\"" ];
repeated uint64 routes_pool_id = 3
[ (gogoproto.moretags) = "yaml:\"routes_pool_id\"" ];
Expand Down Expand Up @@ -180,7 +182,8 @@ message EstimateSwapExactAmountInResponse {
message EstimateSwapExactAmountOutRequest {
reserved 1;
reserved "sender";
uint64 pool_id = 2 [ (gogoproto.moretags) = "yaml:\"pool_id\"" ];
uint64 pool_id = 2
[ (gogoproto.moretags) = "yaml:\"pool_id\"", deprecated = true ];
repeated SwapAmountOutRoute routes = 3 [
(gogoproto.moretags) = "yaml:\"routes\"",
(gogoproto.nullable) = false
Expand All @@ -189,7 +192,8 @@ message EstimateSwapExactAmountOutRequest {
}

message EstimateSwapExactAmountOutWithPrimitiveTypesRequest {
uint64 pool_id = 1 [ (gogoproto.moretags) = "yaml:\"pool_id\"" ];
uint64 pool_id = 1
[ (gogoproto.moretags) = "yaml:\"pool_id\"", deprecated = true ];
repeated uint64 routes_pool_id = 2
[ (gogoproto.moretags) = "yaml:\"routes_pool_id\"" ];
repeated string routes_token_in_denom = 3
Expand Down
4 changes: 2 additions & 2 deletions x/poolmanager/client/cli/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ func GetCmdEstimateSwapExactAmountIn() (*osmocli.QueryDescriptor, *queryproto.Es
Use: "estimate-swap-exact-amount-in",
Short: "Query estimate-swap-exact-amount-in",
Long: `Query estimate-swap-exact-amount-in.{{.ExampleHeader}}
{{.CommandPrefix}} estimate-swap-exact-amount-in 1 1000stake --swap-route-pool-ids=2 --swap-route-pool-ids=3`,
{{.CommandPrefix}} estimate-swap-exact-amount-in 1000stake --swap-route-pool-ids=2 --swap-route-pool-ids=3`,
ParseQuery: EstimateSwapExactAmountInParseArgs,
Flags: osmocli.FlagDesc{RequiredFlags: []*flag.FlagSet{FlagSetMultihopSwapRoutes()}},
QueryFnName: "EstimateSwapExactAmountIn",
Expand All @@ -60,7 +60,7 @@ func GetCmdEstimateSwapExactAmountOut() (*osmocli.QueryDescriptor, *queryproto.E
Use: "estimate-swap-exact-amount-out",
Short: "Query estimate-swap-exact-amount-out",
Long: `Query estimate-swap-exact-amount-out.{{.ExampleHeader}}
{{.CommandPrefix}} estimate-swap-exact-amount-out 1 1000stake --swap-route-pool-ids=2 --swap-route-pool-ids=3`,
{{.CommandPrefix}} estimate-swap-exact-amount-out 1000stake --swap-route-pool-ids=2 --swap-route-pool-ids=3`,
ParseQuery: EstimateSwapExactAmountOutParseArgs,
Flags: osmocli.FlagDesc{RequiredFlags: []*flag.FlagSet{FlagSetMultihopSwapRoutes()}},
QueryFnName: "EstimateSwapExactAmountOut",
Expand Down
6 changes: 2 additions & 4 deletions x/poolmanager/client/query_proto_wrap.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,18 +153,16 @@ func (q Querier) EstimateSwapExactAmountOutWithPrimitiveTypes(ctx sdk.Context, r

func (q Querier) EstimateSinglePoolSwapExactAmountOut(ctx sdk.Context, req queryproto.EstimateSinglePoolSwapExactAmountOutRequest) (*queryproto.EstimateSwapExactAmountOutResponse, error) {
routeReq := &queryproto.EstimateSwapExactAmountOutRequest{
PoolId: req.PoolId,
TokenOut: req.TokenOut,
Routes: types.SwapAmountOutRoutes{{PoolId: req.PoolId, TokenInDenom: req.TokenInDenom}},
Routes: types.SwapAmountOutRoutes{{TokenInDenom: req.TokenInDenom, PoolId: req.PoolId}},
}
return q.EstimateSwapExactAmountOut(ctx, *routeReq)
}

func (q Querier) EstimateSinglePoolSwapExactAmountIn(ctx sdk.Context, req queryproto.EstimateSinglePoolSwapExactAmountInRequest) (*queryproto.EstimateSwapExactAmountInResponse, error) {
routeReq := &queryproto.EstimateSwapExactAmountInRequest{
PoolId: req.PoolId,
TokenIn: req.TokenIn,
Routes: types.SwapAmountInRoutes{{PoolId: req.PoolId, TokenOutDenom: req.TokenOutDenom}},
Routes: types.SwapAmountInRoutes{{TokenOutDenom: req.TokenOutDenom, PoolId: req.PoolId}},
}
return q.EstimateSwapExactAmountIn(ctx, *routeReq)
}
Expand Down
Loading

0 comments on commit f2cd0d8

Please sign in to comment.