Skip to content

Commit

Permalink
add osmosis CL queries to third-party (#1651)
Browse files Browse the repository at this point in the history
* add osmosis CL queries to third-party

* use vendored osmomath
  • Loading branch information
Joe Bowman authored Jun 5, 2024
1 parent 5da957f commit 5a8d2b1
Show file tree
Hide file tree
Showing 3 changed files with 7,791 additions and 0 deletions.
337 changes: 337 additions & 0 deletions proto/osmosis/concentratedliquidity/poolmodel/query.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,337 @@
syntax = "proto3";
package osmosis.concentratedliquidity.v1beta1;

import "cosmos/base/query/v1beta1/pagination.proto";
import "cosmos/base/v1beta1/coin.proto";
import "cosmos_proto/cosmos.proto";
import "gogoproto/gogo.proto";
import "google/api/annotations.proto";
import "google/protobuf/any.proto";
import "osmosis/concentratedliquidity/params.proto";
import "osmosis/concentratedliquidity/poolmodel/position.proto";

option go_package = "github.com/quicksilver-zone/quicksilver/third-party-chains/osmosis-types/concentrated-liquidity/model";

service Query {
// Pools returns all concentrated liquidity pools
rpc Pools(PoolsRequest) returns (PoolsResponse) {
option (google.api.http).get = "/osmosis/concentratedliquidity/v1beta1/pools";
}

// Params returns concentrated liquidity module params.
rpc Params(ParamsRequest) returns (ParamsResponse) {
option (google.api.http).get = "/osmosis/concentratedliquidity/v1beta1/params";
}

// UserPositions returns all concentrated positions of some address.
rpc UserPositions(UserPositionsRequest) returns (UserPositionsResponse) {
option (google.api.http).get = "/osmosis/concentratedliquidity/v1beta1/positions/{address}";
}

// LiquidityPerTickRange returns the amount of liquidity per every tick range
// existing within the given pool
rpc LiquidityPerTickRange(LiquidityPerTickRangeRequest) returns (LiquidityPerTickRangeResponse) {
option (google.api.http).get = "/osmosis/concentratedliquidity/v1beta1/liquidity_per_tick_range";
}

// LiquidityNetInDirection returns liquidity net in the direction given.
// Uses the bound if specified, if not uses either min tick / max tick
// depending on the direction.
rpc LiquidityNetInDirection(LiquidityNetInDirectionRequest) returns (LiquidityNetInDirectionResponse) {
option (google.api.http).get =
"/osmosis/concentratedliquidity/v1beta1/"
"liquidity_net_in_direction";
}

// ClaimableSpreadRewards returns the amount of spread rewards that can be
// claimed by a position with the given id.
rpc ClaimableSpreadRewards(ClaimableSpreadRewardsRequest) returns (ClaimableSpreadRewardsResponse) {
option (google.api.http).get = "/osmosis/concentratedliquidity/v1beta1/claimable_spread_rewards";
}

// ClaimableIncentives returns the amount of incentives that can be claimed
// and how many would be forfeited by a position with the given id.
rpc ClaimableIncentives(ClaimableIncentivesRequest) returns (ClaimableIncentivesResponse) {
option (google.api.http).get = "/osmosis/concentratedliquidity/v1beta1/claimable_incentives";
}

// PositionById returns a position with the given id.
rpc PositionById(PositionByIdRequest) returns (PositionByIdResponse) {
option (google.api.http).get = "/osmosis/concentratedliquidity/v1beta1/position_by_id";
}

// // PoolAccumulatorRewards returns the pool-global accumulator rewards.
// // Contains spread factor rewards and uptime rewards.
// rpc PoolAccumulatorRewards(PoolAccumulatorRewardsRequest) returns
// (PoolAccumulatorRewardsResponse) {
// option (google.api.http).get =
// "/osmosis/concentratedliquidity/v1beta1/pool_accum_rewards";
// }

// // IncentiveRecords returns the incentive records for a given poolId
// rpc IncentiveRecords(IncentiveRecordsRequest) returns
// (IncentiveRecordsResponse) {
// option (google.api.http).get =
// "/osmosis/concentratedliquidity/v1beta1/incentive_records";
// }

// // TickAccumulatorTrackers returns the tick accumulator trackers.
// // Contains spread factor and uptime accumulator trackers.
// rpc TickAccumulatorTrackers(TickAccumulatorTrackersRequest) returns
// (TickAccumulatorTrackersResponse) {
// option (google.api.http).get =
// "/osmosis/concentratedliquidity/v1beta1/tick_accum_trackers";
// }

// CFMMPoolIdLinkFromConcentratedPoolId returns the pool id of the CFMM
// pool that is linked with the given concentrated pool.
rpc CFMMPoolIdLinkFromConcentratedPoolId(CFMMPoolIdLinkFromConcentratedPoolIdRequest) returns (CFMMPoolIdLinkFromConcentratedPoolIdResponse) {
option (google.api.http).get =
"/osmosis/concentratedliquidity/v1beta1/"
"cfmm_pool_id_link_from_concentrated/"
"{concentrated_pool_id}";
}

// UserUnbondingPositions returns the position and lock info of unbonding
// positions of the given address.
rpc UserUnbondingPositions(UserUnbondingPositionsRequest) returns (UserUnbondingPositionsResponse) {
option (google.api.http).get =
"/osmosis/concentratedliquidity/v1beta1/"
"user_unbonding_positions/"
"{address}";
}

// GetTotalLiquidity returns total liquidity across all cl pools.
rpc GetTotalLiquidity(GetTotalLiquidityRequest) returns (GetTotalLiquidityResponse) {
option (google.api.http).get = "/osmosis/concentratedliquidity/v1beta1/get_total_liquidity";
}

// NumNextInitializedTicks returns the provided number of next initialized
// ticks in the direction of swapping the token in denom.
rpc NumNextInitializedTicks(NumNextInitializedTicksRequest) returns (NumNextInitializedTicksResponse) {
option (google.api.http).get =
"/osmosis/concentratedliquidity/v1beta1/"
"num_next_initialized_ticks";
}
}

//=============================== UserPositions
message UserPositionsRequest {
string address = 1 [(gogoproto.moretags) = "yaml:\"address\""];
uint64 pool_id = 2 [(gogoproto.moretags) = "yaml:\"pool_id\""];
cosmos.base.query.v1beta1.PageRequest pagination = 3;
}

message UserPositionsResponse {
repeated FullPositionBreakdown positions = 1 [(gogoproto.nullable) = false];
cosmos.base.query.v1beta1.PageResponse pagination = 2;
}

//=============================== PositionById
message PositionByIdRequest {
uint64 position_id = 1 [(gogoproto.moretags) = "yaml:\"position_id\""];
}

message PositionByIdResponse {
FullPositionBreakdown position = 1 [(gogoproto.nullable) = false];
}

message NumPoolPositionsRequest {
uint64 pool_id = 1 [(gogoproto.moretags) = "yaml:\"pool_id\""];
}

message NumPoolPositionsResponse {
uint64 position_count = 1 [(gogoproto.moretags) = "yaml:\"position_count\""];
}

//=============================== Pools
message PoolsRequest {
// pagination defines an optional pagination for the request.
cosmos.base.query.v1beta1.PageRequest pagination = 2;
}
message PoolsResponse {
repeated google.protobuf.Any pools = 1 [(cosmos_proto.accepts_interface) = "PoolI"];

// pagination defines the pagination in the response.
cosmos.base.query.v1beta1.PageResponse pagination = 2;
}

//=============================== ModuleParams
message ParamsRequest {}
message ParamsResponse {
Params params = 1 [(gogoproto.nullable) = false];
}

message TickLiquidityNet {
string liquidity_net = 1 [
(gogoproto.customtype) = "cosmossdk.io/math.LegacyDec",
(gogoproto.moretags) = "yaml:\"liquidity_net\"",
(gogoproto.nullable) = false
];
int64 tick_index = 2 [(gogoproto.moretags) = "yaml:\"tick_index\""];
}

message LiquidityDepthWithRange {
string liquidity_amount = 1 [
(gogoproto.customtype) = "cosmossdk.io/math.LegacyDec",
(gogoproto.moretags) = "yaml:\"liquidity_net\"",
(gogoproto.nullable) = false
];
int64 lower_tick = 2 [(gogoproto.moretags) = "yaml:\"lower_tick\""];
int64 upper_tick = 3 [(gogoproto.moretags) = "yaml:\"upper_tick\""];
}

//=============================== LiquidityNetInDirection
message LiquidityNetInDirectionRequest {
uint64 pool_id = 1 [(gogoproto.moretags) = "yaml:\"pool_id\""];
string token_in = 2 [(gogoproto.moretags) = "yaml:\"token_in\""];
int64 start_tick = 3 [(gogoproto.moretags) = "yaml:\"start_tick\""];
bool use_cur_tick = 4 [(gogoproto.moretags) = "yaml:\"use_cur_tick\""];
int64 bound_tick = 5 [(gogoproto.moretags) = "yaml:\"bound_tick\""];
bool use_no_bound = 6 [(gogoproto.moretags) = "yaml:\"use_no_bound\""];
}
message LiquidityNetInDirectionResponse {
repeated TickLiquidityNet liquidity_depths = 1 [(gogoproto.nullable) = false];
int64 current_tick = 2;
string current_liquidity = 3 [
(gogoproto.customtype) = "cosmossdk.io/math.LegacyDec",
(gogoproto.moretags) = "yaml:\"current_liquidity\"",
(gogoproto.nullable) = false
];
string current_sqrt_price = 4 [
(gogoproto.customtype) =
"github.com/quicksilver-zone/quicksilver/"
"third-party-chains/osmosis-types/osmomath.BigDec"
,
(gogoproto.moretags) = "yaml:\"current_sqrt_price\"",
(gogoproto.nullable) = false
];
}

//=============================== LiquidityPerTickRange
message LiquidityPerTickRangeRequest {
uint64 pool_id = 1 [(gogoproto.moretags) = "yaml:\"pool_id\""];
}
message LiquidityPerTickRangeResponse {
repeated LiquidityDepthWithRange liquidity = 1 [(gogoproto.nullable) = false];

int64 bucket_index = 2 [(gogoproto.moretags) = "yaml:\"bucket_index\""];
}

// ===================== QueryClaimableSpreadRewards
message ClaimableSpreadRewardsRequest {
uint64 position_id = 1 [(gogoproto.moretags) = "yaml:\"position_id\""];
}

message ClaimableSpreadRewardsResponse {
repeated cosmos.base.v1beta1.Coin claimable_spread_rewards = 1 [
(gogoproto.moretags) = "yaml:\"claimable_spread_rewards\"",
(gogoproto.nullable) = false
];
}

// ===================== QueryClaimableIncentives
message ClaimableIncentivesRequest {
uint64 position_id = 1 [(gogoproto.moretags) = "yaml:\"position_id\""];
}

message ClaimableIncentivesResponse {
repeated cosmos.base.v1beta1.Coin claimable_incentives = 1 [
(gogoproto.moretags) = "yaml:\"claimable_incentives\"",
(gogoproto.nullable) = false
];
repeated cosmos.base.v1beta1.Coin forfeited_incentives = 2 [
(gogoproto.moretags) = "yaml:\"forfeited_incentives\"",
(gogoproto.nullable) = false
];
}

// // ===================== QueryPoolAccumulatorRewards
// message PoolAccumulatorRewardsRequest {
// uint64 pool_id = 1 [(gogoproto.moretags) = "yaml:\"pool_id\""];
// }

// message PoolAccumulatorRewardsResponse {
// repeated cosmos.base.v1beta1.DecCoin spread_reward_growth_global = 1 [
// (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.DecCoins",
// (gogoproto.nullable) = false
// ];
// repeated UptimeTracker uptime_growth_global = 2 [
// (gogoproto.moretags) = "yaml:\"uptime_growth_global\"",
// (gogoproto.nullable) = false
// ];
// }

// // ===================== QueryTickAccumulatorTrackers
// message TickAccumulatorTrackersRequest {
// uint64 pool_id = 1 [(gogoproto.moretags) = "yaml:\"pool_id\""];
// int64 tick_index = 2 [(gogoproto.moretags) = "yaml:\"tick_index\""];
// }

// message TickAccumulatorTrackersResponse {
// repeated cosmos.base.v1beta1.DecCoin
// spread_reward_growth_opposite_direction_of_last_traversal = 1 [
// (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.DecCoins",
// (gogoproto.nullable) = false
// ];
// repeated UptimeTracker uptime_trackers = 2 [
// (gogoproto.moretags) = "yaml:\"uptime_trackers\"",
// (gogoproto.nullable) = false
// ];
// }

// // ===================== QueryIncentiveRecords
// message IncentiveRecordsRequest {
// uint64 pool_id = 1 [(gogoproto.moretags) = "yaml:\"pool_id\""];
// cosmos.base.query.v1beta1.PageRequest pagination = 2;
// }

// message IncentiveRecordsResponse {
// repeated IncentiveRecord incentive_records = 1 [(gogoproto.nullable) =
// false];
// // pagination defines the pagination in the response.
// cosmos.base.query.v1beta1.PageResponse pagination = 2;
// }

//=============================== CFMMPoolIdLinkFromConcentratedPoolId
message CFMMPoolIdLinkFromConcentratedPoolIdRequest {
uint64 concentrated_pool_id = 1 [(gogoproto.moretags) = "yaml:\"concentrated_pool_id\""];
}

message CFMMPoolIdLinkFromConcentratedPoolIdResponse {
uint64 cfmm_pool_id = 1 [(gogoproto.moretags) = "yaml:\"cfmm_pool_id\""];
}

//=============================== UserUnbondingPositions
message UserUnbondingPositionsRequest {
string address = 1 [(gogoproto.moretags) = "yaml:\"address\""];
}

message UserUnbondingPositionsResponse {
repeated PositionWithPeriodLock positions_with_period_lock = 1 [(gogoproto.nullable) = false];
}

//=============================== GetTotalLiquidity
message GetTotalLiquidityRequest {}
message GetTotalLiquidityResponse {
repeated cosmos.base.v1beta1.Coin total_liquidity = 1 [
(gogoproto.nullable) = false,
(gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"
];
}

//=============================== NumNextInitializedTicks
message NumNextInitializedTicksRequest {
uint64 pool_id = 1 [(gogoproto.moretags) = "yaml:\"pool_id\""];
string token_in_denom = 2 [(gogoproto.moretags) = "yaml:\"token_in_denom\""];
uint64 num_next_initialized_ticks = 3 [(gogoproto.moretags) = "yaml:\"num_next_initialized_ticks\""];
}
message NumNextInitializedTicksResponse {
repeated TickLiquidityNet liquidity_depths = 1 [(gogoproto.nullable) = false];
int64 current_tick = 2;
string current_liquidity = 3 [
(gogoproto.customtype) = "cosmossdk.io/math.LegacyDec",
(gogoproto.moretags) = "yaml:\"current_liquidity\"",
(gogoproto.nullable) = false
];
}
Loading

0 comments on commit 5a8d2b1

Please sign in to comment.