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

Gamm Spec Out V3 - Modulize File Structure #541

Merged
merged 31 commits into from
Dec 21, 2021
Merged
Show file tree
Hide file tree
Changes from 23 commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
46620fb
Change proto Pool -> BalancerPool
mattverse Oct 4, 2021
a720994
Proto changes implementation
mattverse Oct 4, 2021
0a4b0f5
Change proto
mattverse Oct 7, 2021
d804fc6
Revert Pool Query from BalancerPool
mattverse Oct 7, 2021
ec54a65
Change method names accordingly
mattverse Oct 7, 2021
3e876f1
Adjust marshal.go to struct change
mattverse Oct 7, 2021
c7620c0
Fix test
mattverse Oct 8, 2021
ce85d2f
Revert Pool Params, remove Exitfee, Swapfee query
mattverse Oct 12, 2021
81f6b74
Merge branch 'mattverse/gamm-spec-out' into mattverse/gamm-spec-out-v2
mattverse Oct 12, 2021
6531615
Remove unused Yaml from gamm query import
mattverse Oct 13, 2021
c2759a6
Add Pool Params Query
mattverse Oct 13, 2021
389e8ca
Merge branch 'mattverse/gamm-spec-out' into mattverse/gamm-spec-out-v2
mattverse Oct 13, 2021
b188e17
Revert yaml import
mattverse Oct 13, 2021
0c51405
Revert marshal back to poolParams
mattverse Oct 13, 2021
9efed1a
WIP: move balancerPool.proto into pool-models folder
mattverse Oct 13, 2021
bfa6735
WIP: moving balancer_pool.go logic from types -> pool-models
mattverse Oct 13, 2021
a62b2e3
WIP: Change in file structure
mattverse Oct 14, 2021
58f4870
WIP: Changing packages
mattverse Oct 18, 2021
e6bcb00
Use types from balancer package
mattverse Oct 18, 2021
9a29cd6
Revert go mod back to original state
mattverse Oct 19, 2021
229bd59
Register Codec
mattverse Oct 20, 2021
35e5a06
WIP: Fixing CLI test
mattverse Oct 24, 2021
747813a
Fix proto Any field to Balancer specific
mattverse Oct 25, 2021
3d04a93
Remove BalancerPoolParamsI
mattverse Oct 25, 2021
8ec9a8d
Add switch cases to poolParams Query, clean up code
mattverse Oct 26, 2021
8ffe3e8
WIP Merging main
mattverse Dec 16, 2021
efdb376
Merge branch 'main' into mattverse/gamm-spec-out-v3
mattverse Dec 20, 2021
26981f9
Merge branch 'main' into mattverse/gamm-spec-out-v3.1
mattverse Dec 20, 2021
209ddd6
Fix type from proto
mattverse Dec 20, 2021
60b84e2
Cleanup code for test codes
mattverse Dec 21, 2021
eccdfee
Cleanup code for merge
mattverse Dec 21, 2021
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
132 changes: 132 additions & 0 deletions proto/osmosis/gamm/pool-models/balancer/balancerPool.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
syntax = "proto3";
package osmosis.gamm.poolmodels;
Copy link
Member

Choose a reason for hiding this comment

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

should this still be behind a v1beta1?

Copy link
Member Author

Choose a reason for hiding this comment

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

Are you referring to the entire file itself? If my understanding is right upon your question, pool-models is declared as a whole new package in gamm, thats where this is coming from.

Copy link
Member

Choose a reason for hiding this comment

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

I see, tbh I don't really understand the v1beta1 stuff. Lets make an issue for this question, and then ask regen folks post-holidays

Copy link
Member Author

Choose a reason for hiding this comment

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

haha. I'm supposing its just a legacy in structuring the proto files from the cosmos-sdk and that it does not have any additional functionallities. I didn't have any issues when I wasn't using v1beta1 as a package file structure, they should be good to be removed as well


import "cosmos_proto/cosmos.proto";
import "gogoproto/gogo.proto";

import "google/protobuf/duration.proto";
import "google/protobuf/timestamp.proto";

import "cosmos/auth/v1beta1/auth.proto";
import "cosmos/base/v1beta1/coin.proto";

import "osmosis/gamm/v1beta1/pool.proto";

option go_package = "github.com/osmosis-labs/osmosis/x/gamm/pool-models/balancer";

// Parameters for changing the weights in a balancer pool smoothly from
// a start weight and end weight over a period of time.
// Currently, the only smooth change supported is linear changing between
// the two weights, but more types may be added in the future.
// When these parameters are set, the weight w(t) for pool time `t` is the
// following:
// t <= start_time: w(t) = initial_pool_weights
// start_time < t <= start_time + duration:
// w(t) = initial_pool_weights + (t - start_time) *
// (target_pool_weights - initial_pool_weights) / (duration)
// t > start_time + duration: w(t) = target_pool_weights
message SmoothWeightChangeParams {
// The start time for beginning the weight change.
// If a parameter change / pool instantiation leaves this blank,
// it should be generated by the state_machine as the current time.
google.protobuf.Timestamp start_time = 1 [
(gogoproto.stdtime) = true,
(gogoproto.nullable) = false,
(gogoproto.moretags) = "yaml:\"start_time\""
];
// Duration for the weights to change over
google.protobuf.Duration duration = 2 [
(gogoproto.nullable) = false,
(gogoproto.stdduration) = true,
(gogoproto.jsontag) = "duration,omitempty",
(gogoproto.moretags) = "yaml:\"duration\""
];
// The initial pool weights. These are copied from the pool's settings
// at the time of weight change instantiation.
// The amount PoolAsset.token.amount field is ignored if present,
// future type refactorings should just have a type with the denom & weight
// here.
repeated osmosis.gamm.v1beta1.PoolAsset initialPoolWeights = 3 [
(gogoproto.moretags) = "yaml:\"initial_pool_weights\"",
(gogoproto.nullable) = false
];
// The target pool weights. The pool weights will change linearly with respect
// to time between start_time, and start_time + duration. The amount
// PoolAsset.token.amount field is ignored if present, future type
// refactorings should just have a type with the denom & weight here.
repeated osmosis.gamm.v1beta1.PoolAsset targetPoolWeights = 4 [
(gogoproto.moretags) = "yaml:\"target_pool_weights\"",
(gogoproto.nullable) = false
];
// Intermediate variable for the 'slope' of pool weights. This is equal to
// (target_pool_weights - initial_pool_weights) / (duration)
// TODO: Work out precision, and decide if this is good to add
// repeated PoolAsset poolWeightSlope = 5 [
// (gogoproto.moretags) = "yaml:\"pool_weight_slope\"",
// (gogoproto.nullable) = false
// ];
}

// BalancerPoolParams defined the parameters that will be managed by the pool
// governance in the future. This params are not managed by the chain
// governanace. Instead they will be managed by the token holders of the pool.
mattverse marked this conversation as resolved.
Show resolved Hide resolved
// The pool's token holders are specified in future_pool_governor.
message BalancerPoolParams {
string swapFee = 1 [
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec",
(gogoproto.moretags) = "yaml:\"swap_fee\"",
(gogoproto.nullable) = false
];
string exitFee = 2 [
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec",
(gogoproto.moretags) = "yaml:\"exit_fee\"",
(gogoproto.nullable) = false
];
SmoothWeightChangeParams smoothWeightChangeParams = 3 [
(gogoproto.moretags) = "yaml:\"smooth_weight_change_params\"",
(gogoproto.nullable) = true
];
}

message BalancerPool {
option (gogoproto.goproto_getters) = false;
option (gogoproto.goproto_stringer) = false;
option (cosmos_proto.implements_interface) = "PoolI";

string address = 1 [ (gogoproto.moretags) = "yaml:\"address\"" ];
uint64 id = 2;

BalancerPoolParams poolParams = 3 [
(gogoproto.moretags) = "yaml:\"balancer_pool_params\"",
(gogoproto.nullable) = false
];

// This string specifies who will govern the pool in the future.
// Valid forms of this are:
// {token name},{duration}
// {duration}
// where {token name} if specified is the token which determines the
// governor, and if not specified is the LP token for this pool.duration is
// a time specified as 0w,1w,2w, etc. which specifies how long the token
// would need to be locked up to count in governance. 0w means no lockup.
// TODO: Further improve these docs
string future_pool_governor = 4
[ (gogoproto.moretags) = "yaml:\"future_pool_governor\"" ];
// sum of all LP tokens sent out
cosmos.base.v1beta1.Coin totalShares = 5 [
(gogoproto.moretags) = "yaml:\"total_shares\"",
(gogoproto.nullable) = false
];
// These are assumed to be sorted by denomiation.
// They contain the pool asset and the information about the weight
repeated osmosis.gamm.v1beta1.PoolAsset poolAssets = 6 [
(gogoproto.moretags) = "yaml:\"pool_assets\"",
(gogoproto.nullable) = false
];
// sum of all non-normalized pool weights
string totalWeight = 7 [
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int",
(gogoproto.moretags) = "yaml:\"total_weight\"",
(gogoproto.nullable) = false
];
}
32 changes: 32 additions & 0 deletions proto/osmosis/gamm/pool-models/balancer/tx.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
syntax = "proto3";
package osmosis.gamm.poolmodels;

import "gogoproto/gogo.proto";
import "google/protobuf/any.proto";
import "osmosis/gamm/pool-models/balancer/balancerPool.proto";
import "cosmos/base/v1beta1/coin.proto";

import "osmosis/gamm/v1beta1/pool.proto";

option go_package = "github.com/osmosis-labs/osmosis/x/gamm/pool-models/balancer";

service Msg {
rpc CreateBalancerPool(MsgCreateBalancerPool)
returns (MsgCreateBalancerPoolResponse);
}

// ===================== MsgCreatePool
message MsgCreateBalancerPool {
string sender = 1 [ (gogoproto.moretags) = "yaml:\"sender\"" ];

BalancerPoolParams poolParams = 2
[ (gogoproto.moretags) = "yaml:\"pool_params\"" ];

repeated osmosis.gamm.v1beta1.PoolAsset poolAssets = 3
[ (gogoproto.nullable) = false ];

string future_pool_governor = 4
[ (gogoproto.moretags) = "yaml:\"future_pool_governor\"" ];
}

message MsgCreateBalancerPoolResponse {}
19 changes: 9 additions & 10 deletions proto/osmosis/gamm/v1beta1/genesis.proto
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,19 @@ import "cosmos/base/v1beta1/coin.proto";

// Params holds parameters for the incentives 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
];
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
];
}


option go_package = "github.com/osmosis-labs/osmosis/x/gamm/types";

// GenesisState defines the gamm module's genesis state.
message GenesisState {
repeated google.protobuf.Any pools = 1
[ (cosmos_proto.accepts_interface) = "PoolI" ];
uint64 next_pool_number = 2;
Params params = 3 [ (gogoproto.nullable) = false ];
repeated google.protobuf.Any pools = 1
[ (cosmos_proto.accepts_interface) = "PoolI" ];
uint64 next_pool_number = 2;
Params params = 3 [ (gogoproto.nullable) = false ];
}
117 changes: 0 additions & 117 deletions proto/osmosis/gamm/v1beta1/pool.proto
Original file line number Diff line number Diff line change
Expand Up @@ -33,120 +33,3 @@ message PoolAsset {
// (gogoproto.nullable) = true
// ];
}

// Parameters for changing the weights in a balancer pool smoothly from
// a start weight and end weight over a period of time.
// Currently, the only smooth change supported is linear changing between
// the two weights, but more types may be added in the future.
// When these parameters are set, the weight w(t) for pool time `t` is the
// following:
// t <= start_time: w(t) = initial_pool_weights
// start_time < t <= start_time + duration:
// w(t) = initial_pool_weights + (t - start_time) *
// (target_pool_weights - initial_pool_weights) / (duration)
// t > start_time + duration: w(t) = target_pool_weights
message SmoothWeightChangeParams {
// The start time for beginning the weight change.
// If a parameter change / pool instantiation leaves this blank,
// it should be generated by the state_machine as the current time.
google.protobuf.Timestamp start_time = 1 [
(gogoproto.stdtime) = true,
(gogoproto.nullable) = false,
(gogoproto.moretags) = "yaml:\"start_time\""
];
// Duration for the weights to change over
google.protobuf.Duration duration = 2 [
(gogoproto.nullable) = false,
(gogoproto.stdduration) = true,
(gogoproto.jsontag) = "duration,omitempty",
(gogoproto.moretags) = "yaml:\"duration\""
];
// The initial pool weights. These are copied from the pool's settings
// at the time of weight change instantiation.
// The amount PoolAsset.token.amount field is ignored if present,
// future type refactorings should just have a type with the denom & weight
// here.
repeated PoolAsset initialPoolWeights = 3 [
(gogoproto.moretags) = "yaml:\"initial_pool_weights\"",
(gogoproto.nullable) = false
];
// The target pool weights. The pool weights will change linearly with respect
// to time between start_time, and start_time + duration. The amount
// PoolAsset.token.amount field is ignored if present, future type
// refactorings should just have a type with the denom & weight here.
repeated PoolAsset targetPoolWeights = 4 [
(gogoproto.moretags) = "yaml:\"target_pool_weights\"",
(gogoproto.nullable) = false
];
// Intermediate variable for the 'slope' of pool weights. This is equal to
// (target_pool_weights - initial_pool_weights) / (duration)
// TODO: Work out precision, and decide if this is good to add
// repeated PoolAsset poolWeightSlope = 5 [
// (gogoproto.moretags) = "yaml:\"pool_weight_slope\"",
// (gogoproto.nullable) = false
// ];
}

// PoolParams defined the parameters that will be managed by the pool governance
// in the future. This params are not managed by the chain governanace.
// Instead they will be managed by the token holders of the pool.
// The pool's token holders are specified in future_pool_governor.
message PoolParams {
string swapFee = 1 [
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec",
(gogoproto.moretags) = "yaml:\"swap_fee\"",
(gogoproto.nullable) = false
];
string exitFee = 2 [
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec",
(gogoproto.moretags) = "yaml:\"exit_fee\"",
(gogoproto.nullable) = false
];
//
SmoothWeightChangeParams smoothWeightChangeParams = 3 [
(gogoproto.moretags) = "yaml:\"smooth_weight_change_params\"",
(gogoproto.nullable) = true
];
}

message Pool {
option (gogoproto.goproto_getters) = false;
option (gogoproto.goproto_stringer) = false;
option (cosmos_proto.implements_interface) = "PoolI";

string address = 1 [ (gogoproto.moretags) = "yaml:\"address\"" ];
uint64 id = 2;
PoolParams poolParams = 3 [
(gogoproto.moretags) = "yaml:\"pool_params\"",
(gogoproto.nullable) = false
];
// This string specifies who will govern the pool in the future.
// Valid forms of this are:
// {token name},{duration}
// {duration}
// where {token name} if specified is the token which determines the governor,
// and if not specified is the LP token for this pool.
// duration is a time specified as 0w,1w,2w, etc. which specifies how long the
// token would need to be locked up to count in governance. 0w means no
// lockup.
// TODO: Further improve these docs
string future_pool_governor = 4
[ (gogoproto.moretags) = "yaml:\"future_pool_governor\"" ];
// sum of all LP tokens sent out
cosmos.base.v1beta1.Coin totalShares = 5 [
(gogoproto.moretags) = "yaml:\"total_shares\"",
(gogoproto.nullable) = false
];
// These are assumed to be sorted by denomiation.
// They contain the pool asset and the information about the weight
repeated PoolAsset poolAssets = 6 [
(gogoproto.moretags) = "yaml:\"pool_assets\"",
(gogoproto.nullable) = false
];
// sum of all non-normalized pool weights
string totalWeight = 7 [
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int",
(gogoproto.moretags) = "yaml:\"total_weight\"",
(gogoproto.nullable) = false
];
}
9 changes: 5 additions & 4 deletions proto/osmosis/gamm/v1beta1/query.proto
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@ syntax = "proto3";
package osmosis.gamm.v1beta1;

import "gogoproto/gogo.proto";
import "osmosis/gamm/v1beta1/pool.proto";

import "osmosis/gamm/v1beta1/tx.proto";
import "osmosis/gamm/v1beta1/pool.proto";

import "cosmos/base/v1beta1/coin.proto";
import "cosmos/base/query/v1beta1/pagination.proto";
import "google/api/annotations.proto";
Expand Down Expand Up @@ -32,6 +34,7 @@ service Query {
option (google.api.http).get =
"/osmosis/gamm/v1beta1/pools/{poolId}/params";
}

rpc TotalShares(QueryTotalSharesRequest) returns (QueryTotalSharesResponse) {
option (google.api.http).get =
"/osmosis/gamm/v1beta1/pools/{poolId}/total_shares";
Expand Down Expand Up @@ -89,9 +92,7 @@ message QueryNumPoolsResponse {
message QueryPoolParamsRequest {
uint64 poolId = 1 [ (gogoproto.moretags) = "yaml:\"pool_id\"" ];
}
message QueryPoolParamsResponse {
PoolParams params = 1 [ (gogoproto.nullable) = false ];
}
message QueryPoolParamsResponse { google.protobuf.Any params = 1; }
ValarDragon marked this conversation as resolved.
Show resolved Hide resolved

//=============================== TotalShares
message QueryTotalSharesRequest {
Expand Down
20 changes: 1 addition & 19 deletions proto/osmosis/gamm/v1beta1/tx.proto
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,12 @@ syntax = "proto3";
package osmosis.gamm.v1beta1;

import "gogoproto/gogo.proto";
import "osmosis/gamm/v1beta1/pool.proto";
import "google/protobuf/any.proto";
import "cosmos/base/v1beta1/coin.proto";

option go_package = "github.com/osmosis-labs/osmosis/x/gamm/types";

service Msg {
rpc CreatePool(MsgCreatePool) returns (MsgCreatePoolResponse);
rpc JoinPool(MsgJoinPool) returns (MsgJoinPoolResponse);
rpc ExitPool(MsgExitPool) returns (MsgExitPoolResponse);
rpc SwapExactAmountIn(MsgSwapExactAmountIn)
Expand All @@ -25,23 +24,6 @@ service Msg {
returns (MsgExitSwapShareAmountInResponse);
}

// ===================== MsgCreatePool
message MsgCreatePool {
string sender = 1 [ (gogoproto.moretags) = "yaml:\"sender\"" ];

PoolParams poolParams = 2 [
(gogoproto.moretags) = "yaml:\"pool_params\"",
(gogoproto.nullable) = false
];

repeated PoolAsset poolAssets = 3 [ (gogoproto.nullable) = false ];

string future_pool_governor = 4
[ (gogoproto.moretags) = "yaml:\"future_pool_governor\"" ];
}

message MsgCreatePoolResponse {}

// ===================== MsgJoinPool
message MsgJoinPool {
string sender = 1 [ (gogoproto.moretags) = "yaml:\"sender\"" ];
Expand Down
Loading