-
Notifications
You must be signed in to change notification settings - Fork 602
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* feat(CL): swaprouter code gen (merge to `main`) * nolint
- Loading branch information
Showing
12 changed files
with
5,357 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
syntax = "proto3"; | ||
package osmosis.swaprouter.v1beta1; | ||
|
||
import "gogoproto/gogo.proto"; | ||
import "google/protobuf/any.proto"; | ||
import "cosmos_proto/cosmos.proto"; | ||
import "google/protobuf/duration.proto"; | ||
import "cosmos/base/v1beta1/coin.proto"; | ||
|
||
option go_package = "github.com/osmosis-labs/osmosis/v13/x/swaprouter/types"; | ||
|
||
// Params holds parameters for the swaprouter module | ||
message Params { | ||
repeated cosmos.base.v1beta1.Coin pool_creation_fee = 1 [ | ||
(gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins", | ||
(gogoproto.moretags) = "yaml:\"pool_creation_fee\"", | ||
(gogoproto.nullable) = false | ||
]; | ||
} | ||
|
||
// GenesisState defines the swaprouter module's genesis state. | ||
message GenesisState { | ||
// the next_pool_id | ||
uint64 next_pool_id = 1; | ||
// params is the container of swaprouter parameters. | ||
Params params = 2 [ (gogoproto.nullable) = false ]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
syntax = "proto3"; | ||
package osmosis.swaprouter.v1beta1; | ||
|
||
import "gogoproto/gogo.proto"; | ||
|
||
option go_package = "github.com/osmosis-labs/osmosis/v13/x/swaprouter/types"; | ||
|
||
// PoolType is an enumeration of all supported pool types. | ||
enum PoolType { | ||
option (gogoproto.goproto_enum_prefix) = false; | ||
|
||
// Balancer is the standard xy=k curve. Its pool model is defined in x/gamm. | ||
Balancer = 0; | ||
// Stableswap is the Solidly cfmm stable swap curve. Its pool model is defined | ||
// in x/gamm. | ||
StableSwap = 1; | ||
// Concentrated is the pool model specific to concentrated liquidity. It is | ||
// defined in x/concentrated-liquidity. | ||
Concentrated = 2; | ||
} | ||
|
||
// ModuleRouter defines a route encapsulating pool type. | ||
// It is used as the value of a mapping from pool id to the pool type, | ||
// allowing the swap router to know which module to route swaps to given the | ||
// pool id. | ||
message ModuleRoute { | ||
// pool_type specifies the type of the pool | ||
PoolType pool_type = 1; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
syntax = "proto3"; | ||
package osmosis.swaprouter.v1beta1; | ||
|
||
import "gogoproto/gogo.proto"; | ||
import "osmosis/swaprouter/v1beta1/genesis.proto"; | ||
import "osmosis/swaprouter/v1beta1/tx.proto"; | ||
|
||
import "cosmos/base/v1beta1/coin.proto"; | ||
import "cosmos/base/query/v1beta1/pagination.proto"; | ||
import "google/api/annotations.proto"; | ||
import "google/protobuf/any.proto"; | ||
import "cosmos_proto/cosmos.proto"; | ||
import "google/protobuf/timestamp.proto"; | ||
|
||
option go_package = "github.com/osmosis-labs/osmosis/v13/x/swaprouter/client/queryproto"; | ||
|
||
service Query { | ||
rpc Params(ParamsRequest) returns (ParamsResponse) { | ||
option (google.api.http).get = "/osmosis/swaprouter/v1beta1/Params"; | ||
} | ||
|
||
// Estimates swap amount out given in. | ||
rpc EstimateSwapExactAmountIn(EstimateSwapExactAmountInRequest) | ||
returns (EstimateSwapExactAmountInResponse) { | ||
option (google.api.http).get = | ||
"/osmosis/gamm/v1beta1/{pool_id}/estimate/swap_exact_amount_in"; | ||
} | ||
|
||
// 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"; | ||
} | ||
|
||
rpc NumPools(NumPoolsRequest) returns (NumPoolsResponse) { | ||
option (google.api.http).get = "/osmosis/swaprouter/v1beta1/num_pools"; | ||
} | ||
} | ||
|
||
//=============================== Params | ||
message ParamsRequest {} | ||
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\"" ]; | ||
uint64 pool_id = 2 [ (gogoproto.moretags) = "yaml:\"pool_id\"" ]; | ||
string token_in = 3 [ (gogoproto.moretags) = "yaml:\"token_in\"" ]; | ||
repeated SwapAmountInRoute routes = 4 [ | ||
(gogoproto.moretags) = "yaml:\"routes\"", | ||
(gogoproto.nullable) = false | ||
]; | ||
} | ||
|
||
message EstimateSwapExactAmountInResponse { | ||
string token_out_amount = 1 [ | ||
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", | ||
(gogoproto.moretags) = "yaml:\"token_out_amount\"", | ||
(gogoproto.nullable) = false | ||
]; | ||
} | ||
|
||
//=============================== EstimateSwapExactAmountOut | ||
message EstimateSwapExactAmountOutRequest { | ||
// TODO: CHANGE THIS TO RESERVED IN A PATCH RELEASE | ||
string sender = 1 [ (gogoproto.moretags) = "yaml:\"sender\"" ]; | ||
uint64 pool_id = 2 [ (gogoproto.moretags) = "yaml:\"pool_id\"" ]; | ||
repeated SwapAmountOutRoute routes = 3 [ | ||
(gogoproto.moretags) = "yaml:\"routes\"", | ||
(gogoproto.nullable) = false | ||
]; | ||
string token_out = 4 [ (gogoproto.moretags) = "yaml:\"token_out\"" ]; | ||
} | ||
|
||
message EstimateSwapExactAmountOutResponse { | ||
string token_in_amount = 1 [ | ||
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", | ||
(gogoproto.moretags) = "yaml:\"token_in_amount\"", | ||
(gogoproto.nullable) = false | ||
]; | ||
} | ||
|
||
//=============================== NumPools | ||
message NumPoolsRequest {} | ||
message NumPoolsResponse { | ||
uint64 num_pools = 1 [ (gogoproto.moretags) = "yaml:\"num_pools\"" ]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
keeper: | ||
path: "github.com/osmosis-labs/osmosis/v13/x/swaprouter" | ||
struct: "Keeper" | ||
client_path: "github.com/osmosis-labs/osmosis/v13/x/swaprouter/client" | ||
queries: | ||
Params: | ||
proto_wrapper: | ||
query_func: "k.GetParams" | ||
cli: | ||
cmd: "GetParams" | ||
EstimateSwapExactAmountIn: | ||
proto_wrapper: | ||
query_func: "k.EstimateSwapExactAmountIn" | ||
cli: | ||
cmd: "EstimateSwapExactAmountIn" | ||
EstimateSwapExactAmountOut: | ||
proto_wrapper: | ||
query_func: "k.EstimateSwapExactAmountOut" | ||
cli: | ||
cmd: "EstimateSwapExactAmountOut" | ||
NumPools: | ||
proto_wrapper: | ||
query_func: "k.NumPools" | ||
cli: | ||
cmd: "NumPools" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
syntax = "proto3"; | ||
package osmosis.swaprouter.v1beta1; | ||
|
||
import "gogoproto/gogo.proto"; | ||
import "cosmos/base/v1beta1/coin.proto"; | ||
|
||
option go_package = "github.com/osmosis-labs/osmosis/v13/x/swaprouter/types"; | ||
|
||
service Msg { | ||
rpc SwapExactAmountIn(MsgSwapExactAmountIn) | ||
returns (MsgSwapExactAmountInResponse); | ||
rpc SwapExactAmountOut(MsgSwapExactAmountOut) | ||
returns (MsgSwapExactAmountOutResponse); | ||
} | ||
|
||
// ===================== MsgSwapExactAmountIn | ||
message SwapAmountInRoute { | ||
uint64 pool_id = 1 [ (gogoproto.moretags) = "yaml:\"pool_id\"" ]; | ||
string token_out_denom = 2 | ||
[ (gogoproto.moretags) = "yaml:\"token_out_denom\"" ]; | ||
} | ||
|
||
message MsgSwapExactAmountIn { | ||
string sender = 1 [ (gogoproto.moretags) = "yaml:\"sender\"" ]; | ||
repeated SwapAmountInRoute routes = 2 [ (gogoproto.nullable) = false ]; | ||
cosmos.base.v1beta1.Coin token_in = 3 [ | ||
(gogoproto.moretags) = "yaml:\"token_in\"", | ||
(gogoproto.nullable) = false | ||
]; | ||
string token_out_min_amount = 4 [ | ||
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", | ||
(gogoproto.moretags) = "yaml:\"token_out_min_amount\"", | ||
(gogoproto.nullable) = false | ||
]; | ||
} | ||
|
||
message MsgSwapExactAmountInResponse { | ||
string token_out_amount = 1 [ | ||
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", | ||
(gogoproto.moretags) = "yaml:\"token_out_amount\"", | ||
(gogoproto.nullable) = false | ||
]; | ||
} | ||
|
||
// ===================== MsgSwapExactAmountOut | ||
message SwapAmountOutRoute { | ||
uint64 pool_id = 1 [ (gogoproto.moretags) = "yaml:\"pool_id\"" ]; | ||
string token_in_denom = 2 | ||
[ (gogoproto.moretags) = "yaml:\"token_out_denom\"" ]; | ||
} | ||
|
||
message MsgSwapExactAmountOut { | ||
string sender = 1 [ (gogoproto.moretags) = "yaml:\"sender\"" ]; | ||
repeated SwapAmountOutRoute routes = 2 [ (gogoproto.nullable) = false ]; | ||
string token_in_max_amount = 3 [ | ||
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", | ||
(gogoproto.moretags) = "yaml:\"token_in_max_amount\"", | ||
(gogoproto.nullable) = false | ||
]; | ||
cosmos.base.v1beta1.Coin token_out = 4 [ | ||
(gogoproto.moretags) = "yaml:\"token_out\"", | ||
(gogoproto.nullable) = false | ||
]; | ||
} | ||
|
||
message MsgSwapExactAmountOutResponse { | ||
string token_in_amount = 1 [ | ||
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", | ||
(gogoproto.moretags) = "yaml:\"token_in_amount\"", | ||
(gogoproto.nullable) = false | ||
]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
package grpc | ||
|
||
// THIS FILE IS GENERATED CODE, DO NOT EDIT | ||
// SOURCE AT `proto/osmosis/swaprouter/v1beta1/query.yml` | ||
|
||
import ( | ||
context "context" | ||
|
||
"google.golang.org/grpc/codes" | ||
"google.golang.org/grpc/status" | ||
|
||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
"github.com/osmosis-labs/osmosis/v13/x/swaprouter/client" | ||
"github.com/osmosis-labs/osmosis/v13/x/swaprouter/client/queryproto" | ||
) | ||
|
||
type Querier struct { | ||
Q client.Querier | ||
} | ||
|
||
var _ queryproto.QueryServer = Querier{} | ||
|
||
func (q Querier) Params(grpcCtx context.Context, | ||
req *queryproto.ParamsRequest, | ||
) (*queryproto.ParamsResponse, error) { | ||
if req == nil { | ||
return nil, status.Error(codes.InvalidArgument, "empty request") | ||
} | ||
ctx := sdk.UnwrapSDKContext(grpcCtx) | ||
return q.Q.Params(ctx, *req) | ||
} | ||
|
||
func (q Querier) NumPools(grpcCtx context.Context, | ||
req *queryproto.NumPoolsRequest, | ||
) (*queryproto.NumPoolsResponse, error) { | ||
if req == nil { | ||
return nil, status.Error(codes.InvalidArgument, "empty request") | ||
} | ||
ctx := sdk.UnwrapSDKContext(grpcCtx) | ||
return q.Q.NumPools(ctx, *req) | ||
} | ||
|
||
func (q Querier) EstimateSwapExactAmountOut(grpcCtx context.Context, | ||
req *queryproto.EstimateSwapExactAmountOutRequest, | ||
) (*queryproto.EstimateSwapExactAmountOutResponse, error) { | ||
if req == nil { | ||
return nil, status.Error(codes.InvalidArgument, "empty request") | ||
} | ||
ctx := sdk.UnwrapSDKContext(grpcCtx) | ||
return q.Q.EstimateSwapExactAmountOut(ctx, *req) | ||
} | ||
|
||
func (q Querier) EstimateSwapExactAmountIn(grpcCtx context.Context, | ||
req *queryproto.EstimateSwapExactAmountInRequest, | ||
) (*queryproto.EstimateSwapExactAmountInResponse, error) { | ||
if req == nil { | ||
return nil, status.Error(codes.InvalidArgument, "empty request") | ||
} | ||
ctx := sdk.UnwrapSDKContext(grpcCtx) | ||
return q.Q.EstimateSwapExactAmountIn(ctx, *req) | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package client | ||
|
||
import ( | ||
"math/big" | ||
|
||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
|
||
"github.com/osmosis-labs/osmosis/v13/x/swaprouter/client/queryproto" | ||
) | ||
|
||
// This file should evolve to being code gen'd, off of `proto/swaprouter/v1beta/query.yml` | ||
|
||
type Querier struct { | ||
} | ||
|
||
// nolint: unused | ||
var sdkIntMaxValue = sdk.NewInt(0) | ||
|
||
func init() { | ||
maxInt := big.NewInt(2) | ||
maxInt = maxInt.Exp(maxInt, big.NewInt(256), nil) | ||
|
||
_sdkIntMaxValue, ok := sdk.NewIntFromString(maxInt.Sub(maxInt, big.NewInt(1)).String()) | ||
if !ok { | ||
panic("Failed to calculate the max value of sdk.Int") | ||
} | ||
|
||
sdkIntMaxValue = _sdkIntMaxValue | ||
} | ||
|
||
func (q Querier) Params(ctx sdk.Context, | ||
req queryproto.ParamsRequest, | ||
) (*queryproto.ParamsResponse, error) { | ||
panic("not implemented") | ||
} | ||
|
||
// EstimateSwapExactAmountIn estimates input token amount for a swap. | ||
func (q Querier) EstimateSwapExactAmountIn(ctx sdk.Context, req queryproto.EstimateSwapExactAmountInRequest) (*queryproto.EstimateSwapExactAmountInResponse, error) { | ||
panic("not implemented") | ||
} | ||
|
||
// EstimateSwapExactAmountOut estimates token output amount for a swap. | ||
func (q Querier) EstimateSwapExactAmountOut(ctx sdk.Context, req queryproto.EstimateSwapExactAmountOutRequest) (*queryproto.EstimateSwapExactAmountOutResponse, error) { | ||
panic("not implemented") | ||
} | ||
|
||
// NumPools returns total number of pools. | ||
func (q Querier) NumPools(ctx sdk.Context, _ queryproto.NumPoolsRequest) (*queryproto.NumPoolsResponse, error) { | ||
panic("not implemented") | ||
} |
Oops, something went wrong.