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

Get underlying assets of tick range #6595

Closed
wants to merge 15 commits into from
24 changes: 24 additions & 0 deletions proto/osmosis/concentrated-liquidity/query.proto
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,13 @@ service Query {
option (google.api.http).get = "/osmosis/concentratedliquidity/v1beta1/"
"num_next_initialized_ticks";
}

// TickRangeUnderlyingAssets returns uderlying asset of a tick range
rpc TickRangeUnderlyingAssets(TickRangeUnderlyingAssetsRequest)
returns (TickRangeUnderlyingAssetsResponse) {
option (google.api.http).get = "/osmosis/concentratedliquidity/v1beta1/"
"tick_range_underlying_assets";
}
}

//=============================== UserPositions
Expand Down Expand Up @@ -345,4 +352,21 @@ message NumNextInitializedTicksResponse {
(gogoproto.moretags) = "yaml:\"current_liquidity\"",
(gogoproto.nullable) = false
];
}

////=============================== TickRangeUnderlyingAssets
message TickRangeUnderlyingAssetsRequest {
uint64 pool_id = 1 [ (gogoproto.moretags) = "yaml:\"pool_id\"" ];
int64 lower_tick = 2 [ (gogoproto.moretags) = "yaml:\"lower_tick\"" ];
int64 upper_tick = 3 [ (gogoproto.moretags) = "yaml:\"upper_tick\"" ];
}
message TickRangeUnderlyingAssetsResponse {
cosmos.base.v1beta1.Coin token0 = 1 [
(gogoproto.nullable) = false,
(gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coin"
];
cosmos.base.v1beta1.Coin token1 = 2 [
(gogoproto.nullable) = false,
(gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coin"
];
}
9 changes: 9 additions & 0 deletions x/concentrated-liquidity/client/query_proto_wrap.go
Original file line number Diff line number Diff line change
Expand Up @@ -318,3 +318,12 @@ func (q Querier) NumNextInitializedTicks(ctx sdk.Context, req clquery.NumNextIni

return &clquery.NumNextInitializedTicksResponse{LiquidityDepths: liquidityDepths, CurrentLiquidity: pool.GetLiquidity(), CurrentTick: pool.GetCurrentTick()}, nil
}

// TickRangeUnderlyingAssets returns uderlying asset of a tick range
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
// TickRangeUnderlyingAssets returns uderlying asset of a tick range
// TickRangeUnderlyingAssets returns underlying asset of a tick range

func (q Querier) TickRangeUnderlyingAssets(ctx sdk.Context, req clquery.TickRangeUnderlyingAssetsRequest) (*clquery.TickRangeUnderlyingAssetsResponse, error) {
if req.PoolId == 0 {
Copy link
Member

Choose a reason for hiding this comment

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

Lets move all checks into one place for code sanity please, I think we can move this check to query.go

return nil, status.Error(codes.InvalidArgument, "pool id is zero")
}

return &clquery.TickRangeUnderlyingAssetsResponse{}, nil
}
Loading