From d143d8397b434f5ca66f0025fa96def9e5e11177 Mon Sep 17 00:00:00 2001 From: Dev Ojha Date: Wed, 23 Mar 2022 10:45:20 -0500 Subject: [PATCH] Follow-on cleanup to Gamm Refactor (#1129) * Delete obsolete math.go * Delete Legacy pool interface * Refactor event creation to types/events.go * Move pool_asset from types to balancer * Move constants for balancer pool weight verification * Add godocs that Bez pointed out! --- app/apptesting/test_suite.go | 6 +- osmomath/math.go | 10 + .../pool-models/balancer/balancerPool.proto | 19 +- .../gamm/pool-models/balancer/tx.proto | 1 - proto/osmosis/gamm/v1beta1/pool.proto | 30 - proto/osmosis/gamm/v1beta1/query.proto | 14 +- x/gamm/client/cli/query.go | 43 -- x/gamm/client/cli/tx.go | 8 +- x/gamm/genesis_test.go | 9 +- x/gamm/keeper/gas_test.go | 6 +- x/gamm/keeper/grpc_query.go | 19 - x/gamm/keeper/invariants.go | 2 +- x/gamm/keeper/keeper.go | 38 -- x/gamm/keeper/keeper_test.go | 3 +- x/gamm/keeper/marshal_bench_test.go | 7 +- x/gamm/keeper/math.go | 203 ------ x/gamm/keeper/math_test.go | 280 --------- x/gamm/keeper/pool.go | 5 +- x/gamm/keeper/pool_service.go | 6 +- x/gamm/keeper/pool_service_test.go | 21 +- x/gamm/keeper/share.go | 4 +- x/gamm/keeper/swap.go | 2 +- .../pool-models/balancer/balancerPool.pb.go | 352 +++++++++-- x/gamm/pool-models/balancer/balancer_pool.go | 98 +-- .../balancer/balancer_pool_test.go | 59 +- x/gamm/pool-models/balancer/constants.go | 20 + x/gamm/pool-models/balancer/marshal.go | 16 +- x/gamm/pool-models/balancer/marshal_test.go | 7 +- x/gamm/pool-models/balancer/msgs.go | 2 +- x/gamm/pool-models/balancer/msgs_test.go | 6 +- .../balancer}/pool_asset.go | 7 +- x/gamm/pool-models/balancer/tx.pb.go | 67 +- x/gamm/simulation/operations.go | 10 +- x/gamm/types/events.go | 37 ++ x/gamm/types/pool.go | 48 -- x/gamm/types/pool.pb.go | 377 ----------- x/gamm/types/query.pb.go | 592 +++--------------- x/gamm/types/query.pb.gw.go | 98 --- x/gamm/types/tx.pb.go | 10 +- x/pool-incentives/keeper/keeper_test.go | 2 +- x/superfluid/keeper/gov/gov_test.go | 5 +- x/superfluid/keeper/keeper_test.go | 4 +- x/txfees/keeper/keeper_test.go | 9 +- 43 files changed, 660 insertions(+), 1902 deletions(-) delete mode 100644 proto/osmosis/gamm/v1beta1/pool.proto delete mode 100644 x/gamm/keeper/math.go delete mode 100644 x/gamm/keeper/math_test.go create mode 100644 x/gamm/pool-models/balancer/constants.go rename x/gamm/{types => pool-models/balancer}/pool_asset.go (94%) delete mode 100644 x/gamm/types/pool.pb.go diff --git a/app/apptesting/test_suite.go b/app/apptesting/test_suite.go index d26d9278783..176ecb3dd17 100644 --- a/app/apptesting/test_suite.go +++ b/app/apptesting/test_suite.go @@ -154,15 +154,15 @@ func (keeperTestHelper *KeeperTestHelper) SetupGammPoolsWithBondDenomMultiplier( defaultFutureGovernor = "" // pool assets - defaultFooAsset gammtypes.PoolAsset = gammtypes.PoolAsset{ + defaultFooAsset balancer.PoolAsset = balancer.PoolAsset{ Weight: sdk.NewInt(100), Token: sdk.NewCoin(bondDenom, uosmoAmount), } - defaultBarAsset gammtypes.PoolAsset = gammtypes.PoolAsset{ + defaultBarAsset balancer.PoolAsset = balancer.PoolAsset{ Weight: sdk.NewInt(100), Token: sdk.NewCoin(token, sdk.NewInt(10000)), } - poolAssets []gammtypes.PoolAsset = []gammtypes.PoolAsset{defaultFooAsset, defaultBarAsset} + poolAssets []balancer.PoolAsset = []balancer.PoolAsset{defaultFooAsset, defaultBarAsset} ) poolId, err := keeperTestHelper.App.GAMMKeeper.CreateBalancerPool(keeperTestHelper.Ctx, acc1, balancer.PoolParams{ diff --git a/osmomath/math.go b/osmomath/math.go index 765485d751d..ed0c2801c8a 100644 --- a/osmomath/math.go +++ b/osmomath/math.go @@ -16,6 +16,16 @@ var one_half sdk.Dec = sdk.MustNewDecFromStr("0.5") var one sdk.Dec = sdk.OneDec() var two sdk.Dec = sdk.MustNewDecFromStr("2") +// Returns the internal "power precision". +// All fractional exponentiation in osmosis is expected to be accurate up to +// powPrecision. +// *technically* the error term can be greater than this powPrecision, +// but for small bases this bound applies. See comments in the PowApprox function +// for more detail. +func GetPowPrecision() sdk.Dec { + return powPrecision.Clone() +} + /*********************************************************/ // AbsDifferenceWithSign returns | a - b |, (a - b).sign() diff --git a/proto/osmosis/gamm/pool-models/balancer/balancerPool.proto b/proto/osmosis/gamm/pool-models/balancer/balancerPool.proto index eac1be4a0aa..f1a92e3f00a 100644 --- a/proto/osmosis/gamm/pool-models/balancer/balancerPool.proto +++ b/proto/osmosis/gamm/pool-models/balancer/balancerPool.proto @@ -11,8 +11,6 @@ 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/v7/x/gamm/pool-models/balancer"; // Parameters for changing the weights in a balancer pool smoothly from @@ -89,6 +87,23 @@ message PoolParams { ]; } +// Pool asset is an internal struct that combines the amount of the +// token in the pool, and its balancer weight. +// This is an awkward packaging of data, +// and should be revisited in a future state migration. +message PoolAsset { + // Coins we are talking about, + // the denomination must be unique amongst all PoolAssets for this pool. + cosmos.base.v1beta1.Coin token = 1 + [ (gogoproto.moretags) = "yaml:\"token\"", (gogoproto.nullable) = false ]; + // Weight that is not normalized. This weight must be less than 2^50 + string weight = 2 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", + (gogoproto.moretags) = "yaml:\"weight\"", + (gogoproto.nullable) = false + ]; +} + message Pool { option (gogoproto.goproto_getters) = false; option (gogoproto.goproto_stringer) = false; diff --git a/proto/osmosis/gamm/pool-models/balancer/tx.proto b/proto/osmosis/gamm/pool-models/balancer/tx.proto index 02951704214..9063c5a06af 100644 --- a/proto/osmosis/gamm/pool-models/balancer/tx.proto +++ b/proto/osmosis/gamm/pool-models/balancer/tx.proto @@ -3,7 +3,6 @@ package osmosis.gamm.v1beta1; import "gogoproto/gogo.proto"; import "osmosis/gamm/pool-models/balancer/balancerPool.proto"; -import "osmosis/gamm/v1beta1/pool.proto"; option go_package = "github.com/osmosis-labs/osmosis/v7/x/gamm/pool-models/balancer"; diff --git a/proto/osmosis/gamm/v1beta1/pool.proto b/proto/osmosis/gamm/v1beta1/pool.proto deleted file mode 100644 index 9fa42651ee7..00000000000 --- a/proto/osmosis/gamm/v1beta1/pool.proto +++ /dev/null @@ -1,30 +0,0 @@ -syntax = "proto3"; -package osmosis.gamm.v1beta1; - -import "gogoproto/gogo.proto"; - -import "cosmos/base/v1beta1/coin.proto"; - -option go_package = "github.com/osmosis-labs/osmosis/v7/x/gamm/types"; - -message PoolAsset { - // Coins we are talking about, - // the denomination must be unique amongst all PoolAssets for this pool. - cosmos.base.v1beta1.Coin token = 1 - [ (gogoproto.moretags) = "yaml:\"token\"", (gogoproto.nullable) = false ]; - // Weight that is not normalized. This weight must be less than 2^50 - string weight = 2 [ - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", - (gogoproto.moretags) = "yaml:\"weight\"", - (gogoproto.nullable) = false - ]; - - // Weight that is normalized s.t. the sum of all pool assets' weights - // equals 1. If the user provides this value, it is ignored. This should only - // ever be set by the state machine. This is left as a TODO for a future PR. - // string normalizedWeight = 3 [ - // (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", - // (gogoproto.moretags) = "yaml:\"normalized_weight\"", - // (gogoproto.nullable) = true - // ]; -} diff --git a/proto/osmosis/gamm/v1beta1/query.proto b/proto/osmosis/gamm/v1beta1/query.proto index 6530a6b5f65..6be1ffebdb4 100644 --- a/proto/osmosis/gamm/v1beta1/query.proto +++ b/proto/osmosis/gamm/v1beta1/query.proto @@ -3,7 +3,6 @@ package osmosis.gamm.v1beta1; import "gogoproto/gogo.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"; @@ -38,10 +37,7 @@ service Query { option (google.api.http).get = "/osmosis/gamm/v1beta1/pools/{poolId}/total_shares"; } - rpc PoolAssets(QueryPoolAssetsRequest) returns (QueryPoolAssetsResponse) { - option (google.api.http).get = - "/osmosis/gamm/v1beta1/pools/{poolId}/tokens"; - } + rpc SpotPrice(QuerySpotPriceRequest) returns (QuerySpotPriceResponse) { option (google.api.http).get = "/osmosis/gamm/v1beta1/pools/{poolId}/prices"; @@ -104,14 +100,6 @@ message QueryTotalSharesResponse { ]; } -//=============================== PoolAssets -message QueryPoolAssetsRequest { - uint64 poolId = 1 [ (gogoproto.moretags) = "yaml:\"pool_id\"" ]; -} -message QueryPoolAssetsResponse { - repeated PoolAsset poolAssets = 1 [ (gogoproto.nullable) = false ]; -} - //=============================== SpotPrice message QuerySpotPriceRequest { uint64 poolId = 1 [ (gogoproto.moretags) = "yaml:\"pool_id\"" ]; diff --git a/x/gamm/client/cli/query.go b/x/gamm/client/cli/query.go index 4f7e2c2a9d2..dad88d3114e 100644 --- a/x/gamm/client/cli/query.go +++ b/x/gamm/client/cli/query.go @@ -31,7 +31,6 @@ func GetQueryCmd() *cobra.Command { GetCmdNumPools(), GetCmdPoolParams(), GetCmdTotalShares(), - GetCmdPoolAssets(), GetCmdSpotPrice(), GetCmdQueryTotalLiquidity(), GetCmdEstimateSwapExactAmountIn(), @@ -315,48 +314,6 @@ $ %s query gamm total-liquidity return cmd } -// GetCmdPoolAssets return pool-assets for a pool -func GetCmdPoolAssets() *cobra.Command { - cmd := &cobra.Command{ - Use: "pool-assets ", - Short: "Query pool-assets", - Long: strings.TrimSpace( - fmt.Sprintf(`Query pool assets. -Example: -$ %s query gamm pool-assets 1 -`, - version.AppName, - ), - ), - Args: cobra.ExactArgs(1), - RunE: func(cmd *cobra.Command, args []string) error { - clientCtx, err := client.GetClientQueryContext(cmd) - if err != nil { - return err - } - queryClient := types.NewQueryClient(clientCtx) - - poolID, err := strconv.Atoi(args[0]) - if err != nil { - return err - } - - res, err := queryClient.PoolAssets(cmd.Context(), &types.QueryPoolAssetsRequest{ - PoolId: uint64(poolID), - }) - if err != nil { - return err - } - - return clientCtx.PrintProto(res) - }, - } - - flags.AddQueryFlagsToCmd(cmd) - - return cmd -} - // GetCmdSpotPrice returns spot price func GetCmdSpotPrice() *cobra.Command { cmd := &cobra.Command{ diff --git a/x/gamm/client/cli/tx.go b/x/gamm/client/cli/tx.go index 5616ad251fa..a512d1e8ce3 100644 --- a/x/gamm/client/cli/tx.go +++ b/x/gamm/client/cli/tx.go @@ -363,14 +363,14 @@ func NewBuildCreateBalancerPoolMsg(clientCtx client.Context, txf tx.Factory, fs return txf, nil, err } - var poolAssets []types.PoolAsset + var poolAssets []balancer.PoolAsset for i := 0; i < len(poolAssetCoins); i++ { if poolAssetCoins[i].Denom != deposit[i].Denom { return txf, nil, errors.New("deposit tokens and token weights should have same denom order") } - poolAssets = append(poolAssets, types.PoolAsset{ + poolAssets = append(poolAssets, balancer.PoolAsset{ Weight: poolAssetCoins[i].Amount.RoundInt(), Token: deposit[i], }) @@ -399,14 +399,14 @@ func NewBuildCreateBalancerPoolMsg(clientCtx client.Context, txf tx.Factory, fs return txf, nil, err } - var targetPoolAssets []types.PoolAsset + var targetPoolAssets []balancer.PoolAsset for i := 0; i < len(targetPoolAssetCoins); i++ { if targetPoolAssetCoins[i].Denom != poolAssetCoins[i].Denom { return txf, nil, errors.New("initial pool weights and target pool weights should have same denom order") } - targetPoolAssets = append(targetPoolAssets, types.PoolAsset{ + targetPoolAssets = append(targetPoolAssets, balancer.PoolAsset{ Weight: targetPoolAssetCoins[i].Amount.RoundInt(), Token: deposit[i], // TODO: This doesn't make sense. Should only use denom, not an sdk.Coin diff --git a/x/gamm/genesis_test.go b/x/gamm/genesis_test.go index 703ed1c53b0..ba2daad90c4 100644 --- a/x/gamm/genesis_test.go +++ b/x/gamm/genesis_test.go @@ -8,7 +8,6 @@ import ( osmoapp "github.com/osmosis-labs/osmosis/v7/app" "github.com/osmosis-labs/osmosis/v7/x/gamm" "github.com/osmosis-labs/osmosis/v7/x/gamm/pool-models/balancer" - "github.com/osmosis-labs/osmosis/v7/x/gamm/types" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "github.com/tendermint/tendermint/crypto/ed25519" @@ -22,7 +21,7 @@ import ( // balancerPool, err := balancer.NewBalancerPool(1, balancer.PoolParams{ // SwapFee: sdk.NewDecWithPrec(1, 2), // ExitFee: sdk.NewDecWithPrec(1, 2), -// }, []types.PoolAsset{ +// }, []balancerbalancer.PoolAsset{ // { // Weight: sdk.NewInt(1), // Token: sdk.NewInt64Coin(sdk.DefaultBondDenom, 10), @@ -79,7 +78,7 @@ func TestGammExportGenesis(t *testing.T) { _, err = app.GAMMKeeper.CreateBalancerPool(ctx, acc1, balancer.PoolParams{ SwapFee: sdk.NewDecWithPrec(1, 2), ExitFee: sdk.NewDecWithPrec(1, 2), - }, []types.PoolAsset{{ + }, []balancer.PoolAsset{{ Weight: sdk.NewInt(100), Token: sdk.NewCoin("foo", sdk.NewInt(10000)), }, { @@ -91,7 +90,7 @@ func TestGammExportGenesis(t *testing.T) { _, err = app.GAMMKeeper.CreateBalancerPool(ctx, acc1, balancer.PoolParams{ SwapFee: sdk.NewDecWithPrec(1, 2), ExitFee: sdk.NewDecWithPrec(1, 2), - }, []types.PoolAsset{{ + }, []balancer.PoolAsset{{ Weight: sdk.NewInt(70), Token: sdk.NewCoin("foo", sdk.NewInt(10000)), }, { @@ -123,7 +122,7 @@ func TestMarshalUnmarshalGenesis(t *testing.T) { _, err = app.GAMMKeeper.CreateBalancerPool(ctx, acc1, balancer.PoolParams{ SwapFee: sdk.NewDecWithPrec(1, 2), ExitFee: sdk.NewDecWithPrec(1, 2), - }, []types.PoolAsset{{ + }, []balancer.PoolAsset{{ Weight: sdk.NewInt(100), Token: sdk.NewCoin("foo", sdk.NewInt(10000)), }, { diff --git a/x/gamm/keeper/gas_test.go b/x/gamm/keeper/gas_test.go index 2e0a7afac29..83dbea4d728 100644 --- a/x/gamm/keeper/gas_test.go +++ b/x/gamm/keeper/gas_test.go @@ -6,7 +6,7 @@ import ( "github.com/cosmos/cosmos-sdk/simapp" sdk "github.com/cosmos/cosmos-sdk/types" - balanacertypes "github.com/osmosis-labs/osmosis/v7/x/gamm/pool-models/balancer" + balancertypes "github.com/osmosis-labs/osmosis/v7/x/gamm/pool-models/balancer" "github.com/osmosis-labs/osmosis/v7/x/gamm/types" ) @@ -103,7 +103,7 @@ func (suite *KeeperTestSuite) TestRepeatedJoinPoolDistinctDenom() { err = simapp.FundAccount(suite.app.BankKeeper, suite.ctx, defaultAddr, coins) suite.Require().NoError(err) - defaultPoolParams := balanacertypes.PoolParams{ + defaultPoolParams := balancertypes.PoolParams{ SwapFee: sdk.NewDec(0), ExitFee: sdk.NewDec(0), } @@ -115,7 +115,7 @@ func (suite *KeeperTestSuite) TestRepeatedJoinPoolDistinctDenom() { err = simapp.FundAccount(suite.app.BankKeeper, suite.ctx, defaultAddr, coins) suite.Require().NoError(err) - poolAssets := []types.PoolAsset{ + poolAssets := []balancertypes.PoolAsset{ { Weight: sdk.NewInt(100), Token: sdk.NewCoin(prevRandToken, sdk.NewInt(10)), diff --git a/x/gamm/keeper/grpc_query.go b/x/gamm/keeper/grpc_query.go index de534094b17..fcd4dfa6e70 100644 --- a/x/gamm/keeper/grpc_query.go +++ b/x/gamm/keeper/grpc_query.go @@ -166,25 +166,6 @@ func (k Keeper) TotalShares(ctx context.Context, req *types.QueryTotalSharesRequ }, nil } -// TODO: Fix -func (k Keeper) PoolAssets(ctx context.Context, req *types.QueryPoolAssetsRequest) (*types.QueryPoolAssetsResponse, error) { - if req == nil { - return nil, status.Error(codes.InvalidArgument, "empty request") - } - - return nil, status.Error(codes.Unimplemented, "unimplemented") - - // sdkCtx := sdk.UnwrapSDKContext(ctx) - - // pool, err := k.GetPool(sdkCtx, req.PoolId) - // if err != nil { - // return nil, status.Error(codes.Internal, err.Error()) - // } - // return &types.QueryPoolAssetsResponse{ - // PoolAssets: pool.GetAllPoolAssets(), - // }, nil -} - func (k Keeper) SpotPrice(ctx context.Context, req *types.QuerySpotPriceRequest) (*types.QuerySpotPriceResponse, error) { if req == nil { return nil, status.Error(codes.InvalidArgument, "empty request") diff --git a/x/gamm/keeper/invariants.go b/x/gamm/keeper/invariants.go index 28e676ac0a7..6aa34977874 100644 --- a/x/gamm/keeper/invariants.go +++ b/x/gamm/keeper/invariants.go @@ -90,7 +90,7 @@ func genericPow(base, exp sdk.Dec) sdk.Dec { if !base.GTE(sdk.NewDec(2)) { return osmomath.Pow(base, exp) } - return osmomath.PowApprox(sdk.OneDec().Quo(base), exp.Neg(), powPrecision) + return osmomath.PowApprox(sdk.OneDec().Quo(base), exp.Neg(), osmomath.GetPowPrecision()) } // constantChange returns the multiplicative factor difference in the pool constant, between two different pools. diff --git a/x/gamm/keeper/keeper.go b/x/gamm/keeper/keeper.go index e02b39cf5e1..a7e15bff2f9 100644 --- a/x/gamm/keeper/keeper.go +++ b/x/gamm/keeper/keeper.go @@ -2,7 +2,6 @@ package keeper import ( "fmt" - "strconv" "github.com/cosmos/cosmos-sdk/codec" sdk "github.com/cosmos/cosmos-sdk/types" @@ -60,43 +59,6 @@ func NewKeeper(cdc codec.BinaryCodec, storeKey sdk.StoreKey, paramSpace paramtyp } } -func (k *Keeper) createSwapEvent(ctx sdk.Context, sender sdk.AccAddress, poolId uint64, input sdk.Coins, output sdk.Coins) { - ctx.EventManager().EmitEvents(sdk.Events{ - sdk.NewEvent( - types.TypeEvtTokenSwapped, - sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory), - sdk.NewAttribute(sdk.AttributeKeySender, sender.String()), - sdk.NewAttribute(types.AttributeKeyPoolId, strconv.FormatUint(poolId, 10)), - sdk.NewAttribute(types.AttributeKeyTokensIn, input.String()), - sdk.NewAttribute(types.AttributeKeyTokensOut, output.String()), - ), - }) -} - -func (k *Keeper) createAddLiquidityEvent(ctx sdk.Context, sender sdk.AccAddress, poolId uint64, liquidity sdk.Coins) { - ctx.EventManager().EmitEvents(sdk.Events{ - sdk.NewEvent( - types.TypeEvtPoolJoined, - sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory), - sdk.NewAttribute(sdk.AttributeKeySender, sender.String()), - sdk.NewAttribute(types.AttributeKeyPoolId, strconv.FormatUint(poolId, 10)), - sdk.NewAttribute(types.AttributeKeyTokensIn, liquidity.String()), - ), - }) -} - -func (k *Keeper) createRemoveLiquidityEvent(ctx sdk.Context, sender sdk.AccAddress, poolId uint64, liquidity sdk.Coins) { - ctx.EventManager().EmitEvents(sdk.Events{ - sdk.NewEvent( - types.TypeEvtPoolExited, - sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory), - sdk.NewAttribute(sdk.AttributeKeySender, sender.String()), - sdk.NewAttribute(types.AttributeKeyPoolId, strconv.FormatUint(poolId, 10)), - sdk.NewAttribute(types.AttributeKeyTokensOut, liquidity.String()), - ), - }) -} - // Set the gamm hooks func (k *Keeper) SetHooks(gh types.GammHooks) *Keeper { if k.hooks != nil { diff --git a/x/gamm/keeper/keeper_test.go b/x/gamm/keeper/keeper_test.go index ac2ebc05651..c7beb1094b4 100644 --- a/x/gamm/keeper/keeper_test.go +++ b/x/gamm/keeper/keeper_test.go @@ -15,6 +15,7 @@ import ( "github.com/osmosis-labs/osmosis/v7/app" "github.com/osmosis-labs/osmosis/v7/x/gamm/pool-models/balancer" + balancertypes "github.com/osmosis-labs/osmosis/v7/x/gamm/pool-models/balancer" "github.com/osmosis-labs/osmosis/v7/x/gamm/types" ) @@ -59,7 +60,7 @@ func (suite *KeeperTestSuite) prepareBalancerPoolWithPoolParams(PoolParams balan } } - poolId, err := suite.app.GAMMKeeper.CreateBalancerPool(suite.ctx, acc1, PoolParams, []types.PoolAsset{ + poolId, err := suite.app.GAMMKeeper.CreateBalancerPool(suite.ctx, acc1, PoolParams, []balancertypes.PoolAsset{ { Weight: sdk.NewInt(100), Token: sdk.NewCoin("foo", sdk.NewInt(5000000)), diff --git a/x/gamm/keeper/marshal_bench_test.go b/x/gamm/keeper/marshal_bench_test.go index 6754cc0a9c2..fc5a04d0516 100644 --- a/x/gamm/keeper/marshal_bench_test.go +++ b/x/gamm/keeper/marshal_bench_test.go @@ -9,17 +9,18 @@ import ( simtypes "github.com/cosmos/cosmos-sdk/types/simulation" "github.com/osmosis-labs/osmosis/v7/app" "github.com/osmosis-labs/osmosis/v7/x/gamm/pool-models/balancer" + balancertypes "github.com/osmosis-labs/osmosis/v7/x/gamm/pool-models/balancer" gammtypes "github.com/osmosis-labs/osmosis/v7/x/gamm/types" ) -func genPoolAssets(r *rand.Rand) []gammtypes.PoolAsset { +func genPoolAssets(r *rand.Rand) []balancertypes.PoolAsset { denoms := []string{"IBC/0123456789ABCDEF012346789ABCDEF", "IBC/denom56789ABCDEF012346789ABCDEF"} - assets := []gammtypes.PoolAsset{} + assets := []balancertypes.PoolAsset{} for _, denom := range denoms { amt, _ := simtypes.RandPositiveInt(r, sdk.NewIntWithDecimal(1, 40)) reserveAmt := sdk.NewCoin(denom, amt) weight := sdk.NewInt(r.Int63n(9) + 1) - assets = append(assets, gammtypes.PoolAsset{Token: reserveAmt, Weight: weight}) + assets = append(assets, balancertypes.PoolAsset{Token: reserveAmt, Weight: weight}) } return assets diff --git a/x/gamm/keeper/math.go b/x/gamm/keeper/math.go deleted file mode 100644 index 7d3bf67d45d..00000000000 --- a/x/gamm/keeper/math.go +++ /dev/null @@ -1,203 +0,0 @@ -package keeper - -import ( - "github.com/osmosis-labs/osmosis/v7/osmomath" - - sdk "github.com/cosmos/cosmos-sdk/types" -) - -// Don't EVER change after initializing -// TODO: Analyze choice here -var powPrecision, _ = sdk.NewDecFromStr("0.00000001") - -// Singletons -var zero sdk.Dec = sdk.ZeroDec() -var one_half sdk.Dec = sdk.MustNewDecFromStr("0.5") -var one sdk.Dec = sdk.OneDec() -var two sdk.Dec = sdk.MustNewDecFromStr("2") - -// calcSpotPrice returns the spot price of the pool -// This is the weight-adjusted balance of the tokens in the pool. -// so spot_price = (B_in / W_in) / (B_out / W_out) -func calcSpotPrice( - tokenBalanceIn, - tokenWeightIn, - tokenBalanceOut, - tokenWeightOut sdk.Dec, -) sdk.Dec { - number := tokenBalanceIn.Quo(tokenWeightIn) - denom := tokenBalanceOut.Quo(tokenWeightOut) - ratio := number.Quo(denom) - - return ratio -} - -// calcSpotPriceWithSwapFee returns the spot price of the pool accounting for -// the input taken by the swap fee. -// This is the weight-adjusted balance of the tokens in the pool. -// so spot_price = (B_in / W_in) / (B_out / W_out) -// and spot_price_with_fee = spot_price / (1 - swapfee) -func calcSpotPriceWithSwapFee( - tokenBalanceIn, - tokenWeightIn, - tokenBalanceOut, - tokenWeightOut, - swapFee sdk.Dec, -) sdk.Dec { - spotPrice := calcSpotPrice(tokenBalanceIn, tokenWeightIn, tokenBalanceOut, tokenWeightOut) - // Q: Why is this not just (1 - swapfee) - // A: Its because its being applied to the other asset. - // TODO: write this up more coherently - // 1 / (1 - swapfee) - scale := sdk.OneDec().Quo(sdk.OneDec().Sub(swapFee)) - - return spotPrice.Mul(scale) -} - -// solveConstantFunctionInvariant solves the constant function of an AMM -// that determines the relationship between the differences of two sides -// of assets inside the pool. -// For fixed balanceXBefore, balanceXAfter, weightX, balanceY, weightY, -// we could deduce the balanceYDelta, calculated by: -// balanceYDelta = balanceY * (1 - (balanceXBefore/balanceXAfter)^(weightX/weightY)) -// balanceYDelta is positive when the balance liquidity decreases. -// balanceYDelta is negative when the balance liquidity increases. -func solveConstantFunctionInvariant( - tokenBalanceFixedBefore, - tokenBalanceFixedAfter, - tokenWeightFixed, - tokenBalanceUnknownBefore, - tokenWeightUnknown sdk.Dec, -) sdk.Dec { - // weightRatio = (weightX/weightY) - weightRatio := tokenWeightFixed.Quo(tokenWeightUnknown) - - // y = balanceXBefore/balanceYAfter - y := tokenBalanceFixedBefore.Quo(tokenBalanceFixedAfter) - - // amountY = balanceY * (1 - (y ^ weightRatio)) - foo := osmomath.Pow(y, weightRatio) - multiplier := sdk.OneDec().Sub(foo) - return tokenBalanceUnknownBefore.Mul(multiplier) -} - -// calcOutGivenIn calculates token to be swapped out given -// the provided amount, fee deducted, using solveConstantFunctionInvariant -func calcOutGivenIn( - tokenBalanceIn, - tokenWeightIn, - tokenBalanceOut, - tokenWeightOut, - tokenAmountIn, - swapFee sdk.Dec, -) sdk.Dec { - // deduct swapfee on the in asset - tokenAmountInAfterFee := tokenAmountIn.Mul(sdk.OneDec().Sub(swapFee)) - // delta balanceOut is positive(tokens inside the pool decreases) - tokenAmountOut := solveConstantFunctionInvariant(tokenBalanceIn, tokenBalanceIn.Add(tokenAmountInAfterFee), tokenWeightIn, tokenBalanceOut, tokenWeightOut) - return tokenAmountOut -} - -// calcInGivenOut calculates token to be provided, fee added, -// given the swapped out amount, using solveConstantFunctionInvariant -func calcInGivenOut( - tokenBalanceIn, - tokenWeightIn, - tokenBalanceOut, - tokenWeightOut, - tokenAmountOut, - swapFee sdk.Dec, -) sdk.Dec { - // delta balanceIn is negative(amount of tokens inside the pool increases) - tokenAmountIn := solveConstantFunctionInvariant(tokenBalanceOut, tokenBalanceOut.Sub(tokenAmountOut), tokenWeightOut, tokenBalanceIn, tokenWeightIn).Neg() - // We deduct a swap fee on the input asset. The swap happens by following the invariant curve on the input * (1 - swap fee) - // and then the swap fee is added to the pool. - // Thus in order to give X amount out, we solve the invariant for the invariant input. However invariant input = (1 - swapfee) * trade input. - // Therefore we divide by (1 - swapfee) here - tokenAmountInBeforeFee := tokenAmountIn.Quo(sdk.OneDec().Sub(swapFee)) - return tokenAmountInBeforeFee - -} - -func feeRatio( - normalizedWeight, - swapFee sdk.Dec, -) sdk.Dec { - zar := (sdk.OneDec().Sub(normalizedWeight)).Mul(swapFee) - return sdk.OneDec().Sub(zar) -} - -// calcSingleInGivenPoolOut calculates token to be provided, fee added, -// given the swapped out shares amount, using solveConstantFunctionInvariant -func calcSingleInGivenPoolOut( - tokenBalanceIn, - normalizedTokenWeightIn, - poolSupply, - poolAmountOut, - swapFee sdk.Dec, -) sdk.Dec { - // delta balanceIn is negative(tokens inside the pool increases) - // pool weight is always 1 - tokenAmountIn := solveConstantFunctionInvariant(poolSupply.Add(poolAmountOut), poolSupply, sdk.OneDec(), tokenBalanceIn, normalizedTokenWeightIn).Neg() - // deduct swapfee on the in asset - tokenAmountInBeforeFee := tokenAmountIn.Quo(feeRatio(normalizedTokenWeightIn, swapFee)) - return tokenAmountInBeforeFee -} - -// pAo -func calcPoolOutGivenSingleIn( - tokenBalanceIn, - normalizedTokenWeightIn, - poolSupply, - tokenAmountIn, - swapFee sdk.Dec, -) sdk.Dec { - // deduct swapfee on the in asset - tokenAmountInAfterFee := tokenAmountIn.Mul(feeRatio(normalizedTokenWeightIn, swapFee)) - // delta poolSupply is negative(total pool shares increases) - // pool weight is always 1 - poolAmountOut := solveConstantFunctionInvariant(tokenBalanceIn.Add(tokenAmountInAfterFee), tokenBalanceIn, normalizedTokenWeightIn, poolSupply, sdk.OneDec()).Neg() - return poolAmountOut -} - -// tAo -func calcSingleOutGivenPoolIn( - tokenBalanceOut, - normalizedTokenWeightOut, - poolSupply, - poolAmountIn, - swapFee sdk.Dec, - exitFee sdk.Dec, -) sdk.Dec { - // charge exit fee on the pool token side - // pAiAfterExitFee = pAi*(1-exitFee) - poolAmountInAfterExitFee := poolAmountIn.Mul(sdk.OneDec().Sub(exitFee)) - - // delta balanceOut is positive(tokens inside the pool decreases) - // pool weight is always 1 - tokenAmountOut := solveConstantFunctionInvariant(poolSupply.Sub(poolAmountInAfterExitFee), poolSupply, sdk.OneDec(), tokenBalanceOut, normalizedTokenWeightOut) - // deduct - tokenAmountOutAfterFee := tokenAmountOut.Mul(feeRatio(normalizedTokenWeightOut, swapFee)) - return tokenAmountOutAfterFee -} - -// pAi -func calcPoolInGivenSingleOut( - tokenBalanceOut, - normalizedTokenWeightOut, - poolSupply, - tokenAmountOut, - swapFee sdk.Dec, - exitFee sdk.Dec, -) sdk.Dec { - tokenAmountOutBeforeFee := tokenAmountOut.Quo(feeRatio(normalizedTokenWeightOut, swapFee)) - - // delta poolSupply is positive(total pool shares decreases) - // pool weight is always 1 - poolAmountIn := solveConstantFunctionInvariant(tokenBalanceOut.Sub(tokenAmountOutBeforeFee), tokenBalanceOut, normalizedTokenWeightOut, poolSupply, sdk.OneDec()) - - // charge exit fee on the pool token side - // pAi = pAiAfterExitFee/(1-exitFee) - poolAmountInBeforeFee := poolAmountIn.Quo(sdk.OneDec().Sub(exitFee)) - return poolAmountInBeforeFee -} diff --git a/x/gamm/keeper/math_test.go b/x/gamm/keeper/math_test.go deleted file mode 100644 index 133569e4903..00000000000 --- a/x/gamm/keeper/math_test.go +++ /dev/null @@ -1,280 +0,0 @@ -package keeper - -import ( - "math/rand" - "testing" - - sdk "github.com/cosmos/cosmos-sdk/types" - - "github.com/stretchr/testify/require" -) - -func TestCalcSpotPrice(t *testing.T) { - tc := tc(t, "100", "0.1", "200", "0.3", "", "0", "0", "0") - - actual_spot_price := calcSpotPrice(tc.tokenBalanceIn, tc.tokenWeightIn, tc.tokenBalanceOut, tc.tokenWeightOut) - // s = (100/.1) / (200 / .3) = (1000) / (2000 / 3) = 1.5 - expected_spot_price, err := sdk.NewDecFromStr("1.5") - require.NoError(t, err) - - // assert that the spot prices are within the error margin from one another. - require.True( - t, - expected_spot_price.Sub(actual_spot_price).Abs().LTE(powPrecision), - "expected value & actual value's difference should less than precision", - ) - -} - -// TODO: Create test vectors with balancer contract -func TestCalcSpotPriceWithSwapFee(t *testing.T) { - tc := tc(t, "100", "0.1", "200", "0.3", "", "0", "0.01", "0") - - s := calcSpotPriceWithSwapFee(tc.tokenBalanceIn, tc.tokenWeightIn, tc.tokenBalanceOut, tc.tokenWeightOut, tc.swapFee) - - expectedDec, err := sdk.NewDecFromStr("1.51515151") - require.NoError(t, err) - - require.True( - t, - expectedDec.Sub(s).Abs().LTE(powPrecision), - "expected value & actual value's difference should less than precision", - ) - -} - -func TestCalcOutGivenIn(t *testing.T) { - tc := tc(t, "100", "0.1", "200", "0.3", "", "0", "0.01", "0") - - tokenAmountIn, err := sdk.NewDecFromStr("40") - require.NoError(t, err) - - s := tc.calcOutGivenIn(tokenAmountIn) - - expectedDec, err := sdk.NewDecFromStr("21.0487006") - require.NoError(t, err) - - require.True( - t, - expectedDec.Sub(s).Abs().LTE(powPrecision.MulInt64(10000)), - "expected value & actual value's difference should less than precision*10000", - ) - -} - -func TestCalcInGivenOut(t *testing.T) { - tc := tc(t, "100", "0.1", "200", "0.3", "", "0", "0.01", "0") - tokenAmountOut, err := sdk.NewDecFromStr("70") - require.NoError(t, err) - - s := tc.calcInGivenOut(tokenAmountOut) - - expectedDec, err := sdk.NewDecFromStr("266.8009177") - require.NoError(t, err) - - require.True( - t, - expectedDec.Sub(s).Abs().LTE(powPrecision.MulInt64(10)), - "expected value & actual value's difference should less than precision*10", - ) -} - -func TestCalcPoolOutGivenSingleIn(t *testing.T) { - tc := tc(t, "100", "0.2", "200", "0.8", "1", "300", "0.15", "0") - - tokenAmountIn, err := sdk.NewDecFromStr("40") - require.NoError(t, err) - - s := tc.calcPoolOutGivenSingleIn(tokenAmountIn) - - expectedDec, err := sdk.NewDecFromStr("18.6519592") - require.NoError(t, err) - - require.True( - t, - expectedDec.Sub(s).Abs().LTE(powPrecision.MulInt64(10000)), - "expected value & actual value's difference should less than precision*10000", - ) -} - -/* -func TestCalcSingleInGivenPoolOut(t *testing.T) { - - tokenBalanceIn, err := sdk.NewDecFromStr("100") - require.NoError(t, err) - tokenWeightIn, err := sdk.NewDecFromStr("0.2") - require.NoError(t, err) - poolSupply, err := sdk.NewDecFromStr("300") - require.NoError(t, err) - totalWeight, err := sdk.NewDecFromStr("1") - require.NoError(t, err) - poolAmountOut, err := sdk.NewDecFromStr("70") - require.NoError(t, err) - swapFee, err := sdk.NewDecFromStr("0.15") - require.NoError(t, err) - - normalizedWeight := tokenWeightIn.Quo(totalWeight) - s := calcSingleInGivenPoolOut(tokenBalanceIn, normalizedWeight, poolSupply, poolAmountOut, swapFee) - - expectedDec, err := sdk.NewDecFromStr(".") - require.NoError(t, err) - - require.True( - t, - expectedDec.Sub(s).Abs().LTE(powPrecision.MulInt64(10000)), - "expected value & actual value's difference should less than precision*10000", - ) -} -*/ - -func TestCalcSingleOutGivenPoolIn(t *testing.T) { - tc := tc(t, "100", "0.2", "200", "0.8", "1", "300", "0.15", "0") - poolAmountIn, err := sdk.NewDecFromStr("40") - require.NoError(t, err) - - s := tc.calcSingleOutGivenPoolIn(poolAmountIn) - - expectedDec, err := sdk.NewDecFromStr("31.77534976") - require.NoError(t, err) - - require.True( - t, - expectedDec.Sub(s).Abs().LTE(powPrecision.MulInt64(10000)), - "expected value & actual value's difference should less than precision*10000", - ) -} - -func TestCalcPoolInGivenSingleOut(t *testing.T) { - tc := tc(t, "100", "0.2", "200", "0.8", "1", "300", "0.15", "0") - - tokenAmountOut, err := sdk.NewDecFromStr("70") - require.NoError(t, err) - - s := tc.calcPoolInGivenSingleOut(tokenAmountOut) - - expectedDec, err := sdk.NewDecFromStr("90.29092777") - require.NoError(t, err) - - require.True( - t, - expectedDec.Sub(s).Abs().LTE(powPrecision.MulInt64(10000)), - "expected value & actual value's difference should less than precision*10000", - ) -} - -type testCase struct { - tokenBalanceIn, tokenWeightIn sdk.Dec - tokenBalanceOut, tokenWeightOut sdk.Dec - totalWeight sdk.Dec - poolSupply sdk.Dec - swapFee, exitFee sdk.Dec -} - -func (tc testCase) reverse() testCase { - return testCase{ - tc.tokenBalanceOut, tc.tokenWeightOut, - tc.tokenBalanceIn, tc.tokenWeightIn, - tc.totalWeight, - tc.poolSupply, - tc.swapFee, tc.exitFee, - } -} - -func tc(t *testing.T, tokenBalanceIn, tokenWeightIn, tokenBalanceOut, tokenWeightOut, totalWeight, poolSupply, swapFee, exitFee string) (res testCase) { - var err error - res.tokenBalanceIn, err = sdk.NewDecFromStr(tokenBalanceIn) - require.NoError(t, err) - res.tokenWeightIn, err = sdk.NewDecFromStr(tokenWeightIn) - require.NoError(t, err) - res.tokenBalanceOut, err = sdk.NewDecFromStr(tokenBalanceOut) - require.NoError(t, err) - res.tokenWeightOut, err = sdk.NewDecFromStr(tokenWeightOut) - require.NoError(t, err) - if totalWeight == "" { - res.totalWeight = res.tokenWeightIn.Add(res.tokenWeightOut) - } else { - res.totalWeight, err = sdk.NewDecFromStr(totalWeight) - } - require.NoError(t, err) - res.poolSupply, err = sdk.NewDecFromStr(poolSupply) - require.NoError(t, err) - res.swapFee, err = sdk.NewDecFromStr(swapFee) - require.NoError(t, err) - res.exitFee, err = sdk.NewDecFromStr(exitFee) - require.NoError(t, err) - - return -} - -func randtc(t *testing.T, swapFee, exitFee sdk.Dec) (res testCase) { - res.tokenBalanceIn = sdk.NewInt(rand.Int63()).ToDec() - res.tokenWeightIn = sdk.NewInt(rand.Int63n(90) + 10).ToDec() - res.tokenBalanceOut = sdk.NewInt(rand.Int63()).ToDec() - res.tokenWeightOut = sdk.NewInt(rand.Int63n(90) + 10).ToDec() - res.totalWeight = res.tokenWeightIn.Add(res.tokenWeightOut) - res.poolSupply = sdk.NewInt(rand.Int63()).ToDec() - res.swapFee = swapFee - res.exitFee = exitFee - return -} - -func (tc testCase) calcInGivenOut(amount sdk.Dec) sdk.Dec { - return calcInGivenOut(tc.tokenBalanceIn, tc.tokenWeightIn, tc.tokenBalanceOut, tc.tokenWeightOut, amount, tc.swapFee) -} - -func (tc testCase) calcOutGivenIn(amount sdk.Dec) sdk.Dec { - return calcOutGivenIn(tc.tokenBalanceIn, tc.tokenWeightIn, tc.tokenBalanceOut, tc.tokenWeightOut, amount, tc.swapFee) -} - -func (tc testCase) calcPoolOutGivenSingleIn(amount sdk.Dec) sdk.Dec { - return calcPoolOutGivenSingleIn(tc.tokenBalanceIn, tc.tokenWeightIn.Quo(tc.totalWeight), tc.poolSupply, amount, tc.swapFee) -} - -func (tc testCase) calcPoolInGivenSingleOut(amount sdk.Dec) sdk.Dec { - return calcPoolInGivenSingleOut(tc.tokenBalanceOut, tc.tokenWeightOut.Quo(tc.totalWeight), tc.poolSupply, amount, tc.swapFee, tc.exitFee) -} - -func (tc testCase) calcSingleInGivenPoolOut(amount sdk.Dec) sdk.Dec { - return calcSingleInGivenPoolOut(tc.tokenBalanceIn, tc.tokenWeightIn.Quo(tc.totalWeight), tc.poolSupply, amount, tc.swapFee) -} - -func (tc testCase) calcSingleOutGivenPoolIn(amount sdk.Dec) sdk.Dec { - return calcSingleOutGivenPoolIn(tc.tokenBalanceOut, tc.tokenWeightOut.Quo(tc.totalWeight), tc.poolSupply, amount, tc.swapFee, tc.exitFee) -} - -func equalWithError(t *testing.T, x, y sdk.Dec, precision int64) { - require.True(t, x.Quo(y).Sub(sdk.OneDec()).Abs().LTE(sdk.OneDec().Quo(sdk.NewInt(precision).ToDec())), - "Not equal within error margin with difference %s: %s, %s", x.Quo(y).Sub(sdk.OneDec()), x, y) -} - -func TestCalcInverseInvariant(t *testing.T) { - tcs := make([]testCase, 10000) - for i := range tcs { - tcs[i] = randtc(t, sdk.NewInt(rand.Int63n(100)).ToDec().Quo(sdk.NewInt(1000).ToDec()), sdk.NewInt(rand.Int63n(100)).ToDec().Quo(sdk.NewInt(500).ToDec())) - } - - for _, tc := range tcs { - for i := 0; i < 10; i++ { - amount := sdk.NewInt(rand.Int63n(tc.tokenBalanceIn.TruncateInt().Int64() / 20)).ToDec() - - { - amountOut := tc.calcOutGivenIn(amount) - amount2 := tc.calcInGivenOut(amountOut) - equalWithError(t, amount, amount2, 100000) - } - - { - shareOut := tc.calcPoolOutGivenSingleIn(amount) - amount2 := tc.calcSingleInGivenPoolOut(shareOut) - equalWithError(t, amount, amount2, 100000) - } - - { - amountOut := sdk.NewInt(rand.Int63n(tc.tokenBalanceOut.TruncateInt().Int64() / 20)).ToDec() - shareIn := tc.calcPoolInGivenSingleOut(amountOut) - amount2 := tc.calcSingleOutGivenPoolIn(shareIn) - equalWithError(t, amountOut, amount2, 100000) - } - } - } -} diff --git a/x/gamm/keeper/pool.go b/x/gamm/keeper/pool.go index 00ed70992e3..037eff11013 100644 --- a/x/gamm/keeper/pool.go +++ b/x/gamm/keeper/pool.go @@ -42,7 +42,8 @@ func (k Keeper) GetPool(ctx sdk.Context, poolId uint64) (types.PoolI, error) { return pool, nil } -func (k Keeper) GetPoolForSwap(ctx sdk.Context, poolId uint64) (types.PoolI, error) { +// Get pool, and check if the pool is active / allowed to be swapped against +func (k Keeper) getPoolForSwap(ctx sdk.Context, poolId uint64) (types.PoolI, error) { pool, err := k.GetPool(ctx, poolId) if err != nil { return &balancer.Pool{}, err @@ -197,7 +198,7 @@ func (k Keeper) DeletePool(ctx sdk.Context, poolId uint64) error { // newBalancerPool is an internal function that creates a new Balancer Pool object with the provided // parameters, initial assets, and future governor. -func (k Keeper) newBalancerPool(ctx sdk.Context, balancerPoolParams balancer.PoolParams, assets []types.PoolAsset, futureGovernor string) (types.PoolI, error) { +func (k Keeper) newBalancerPool(ctx sdk.Context, balancerPoolParams balancer.PoolParams, assets []balancer.PoolAsset, futureGovernor string) (types.PoolI, error) { poolId := k.GetNextPoolNumberAndIncrement(ctx) pool, err := balancer.NewBalancerPool(poolId, balancerPoolParams, assets, futureGovernor, ctx.BlockTime()) diff --git a/x/gamm/keeper/pool_service.go b/x/gamm/keeper/pool_service.go index 569270edecd..6f12f43db82 100644 --- a/x/gamm/keeper/pool_service.go +++ b/x/gamm/keeper/pool_service.go @@ -31,7 +31,7 @@ func (k Keeper) CreateBalancerPool( ctx sdk.Context, sender sdk.AccAddress, BalancerPoolParams balancer.PoolParams, - poolAssets []types.PoolAsset, + poolAssets []balancer.PoolAsset, futurePoolGovernor string, ) (uint64, error) { if len(poolAssets) < types.MinPoolAssets { @@ -196,7 +196,7 @@ func (k Keeper) JoinSwapExactAmountIn( tokensIn sdk.Coins, shareOutMinAmount sdk.Int, ) (shareOutAmount sdk.Int, err error) { - pool, err := k.GetPoolForSwap(ctx, poolId) + pool, err := k.getPoolForSwap(ctx, poolId) if err != nil { return sdk.Int{}, err } @@ -228,7 +228,7 @@ func (k Keeper) JoinSwapShareAmountOut( shareOutAmount sdk.Int, tokenInMaxAmount sdk.Int, ) (tokenInAmount sdk.Int, err error) { - pool, err := k.GetPoolForSwap(ctx, poolId) + pool, err := k.getPoolForSwap(ctx, poolId) if err != nil { return sdk.Int{}, err } diff --git a/x/gamm/keeper/pool_service_test.go b/x/gamm/keeper/pool_service_test.go index 4494c97afc2..d3040da64bb 100644 --- a/x/gamm/keeper/pool_service_test.go +++ b/x/gamm/keeper/pool_service_test.go @@ -7,6 +7,7 @@ import ( "github.com/cosmos/cosmos-sdk/simapp" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/osmosis-labs/osmosis/v7/x/gamm/pool-models/balancer" + balancertypes "github.com/osmosis-labs/osmosis/v7/x/gamm/pool-models/balancer" "github.com/osmosis-labs/osmosis/v7/x/gamm/types" ) @@ -20,16 +21,16 @@ var ( defaultFutureGovernor = "" // pool assets - defaultFooAsset types.PoolAsset = types.PoolAsset{ + defaultFooAsset = balancertypes.PoolAsset{ Weight: sdk.NewInt(100), Token: sdk.NewCoin("foo", sdk.NewInt(10000)), } - defaultBarAsset types.PoolAsset = types.PoolAsset{ + defaultBarAsset = balancertypes.PoolAsset{ Weight: sdk.NewInt(100), Token: sdk.NewCoin("bar", sdk.NewInt(10000)), } - defaultPoolAssets []types.PoolAsset = []types.PoolAsset{defaultFooAsset, defaultBarAsset} - defaultAcctFunds sdk.Coins = sdk.NewCoins( + defaultPoolAssets = []balancertypes.PoolAsset{defaultFooAsset, defaultBarAsset} + defaultAcctFunds sdk.Coins = sdk.NewCoins( sdk.NewCoin("uosmo", sdk.NewInt(10000000000)), sdk.NewCoin("foo", sdk.NewInt(10000000)), sdk.NewCoin("bar", sdk.NewInt(10000000)), @@ -111,7 +112,7 @@ func (suite *KeeperTestSuite) TestCreateBalancerPool() { _, err := keeper.CreateBalancerPool(suite.ctx, acc1, balancer.PoolParams{ SwapFee: sdk.NewDecWithPrec(1, 2), ExitFee: sdk.NewDecWithPrec(1, 2), - }, []types.PoolAsset{}, defaultFutureGovernor) + }, []balancertypes.PoolAsset{}, defaultFutureGovernor) suite.Require().Error(err, "can't create the pool with empty PoolAssets") }, }, { @@ -120,7 +121,7 @@ func (suite *KeeperTestSuite) TestCreateBalancerPool() { _, err := keeper.CreateBalancerPool(suite.ctx, acc1, balancer.PoolParams{ SwapFee: sdk.NewDecWithPrec(1, 2), ExitFee: sdk.NewDecWithPrec(1, 2), - }, []types.PoolAsset{{ + }, []balancertypes.PoolAsset{{ Weight: sdk.NewInt(0), Token: sdk.NewCoin("foo", sdk.NewInt(10000)), }, { @@ -135,7 +136,7 @@ func (suite *KeeperTestSuite) TestCreateBalancerPool() { _, err := keeper.CreateBalancerPool(suite.ctx, acc1, balancer.PoolParams{ SwapFee: sdk.NewDecWithPrec(1, 2), ExitFee: sdk.NewDecWithPrec(1, 2), - }, []types.PoolAsset{{ + }, []balancertypes.PoolAsset{{ Weight: sdk.NewInt(-1), Token: sdk.NewCoin("foo", sdk.NewInt(10000)), }, { @@ -150,7 +151,7 @@ func (suite *KeeperTestSuite) TestCreateBalancerPool() { _, err := keeper.CreateBalancerPool(suite.ctx, acc1, balancer.PoolParams{ SwapFee: sdk.NewDecWithPrec(1, 2), ExitFee: sdk.NewDecWithPrec(1, 2), - }, []types.PoolAsset{{ + }, []balancertypes.PoolAsset{{ Weight: sdk.NewInt(100), Token: sdk.NewCoin("foo", sdk.NewInt(0)), }, { @@ -165,7 +166,7 @@ func (suite *KeeperTestSuite) TestCreateBalancerPool() { _, err := keeper.CreateBalancerPool(suite.ctx, acc1, balancer.PoolParams{ SwapFee: sdk.NewDecWithPrec(1, 2), ExitFee: sdk.NewDecWithPrec(1, 2), - }, []types.PoolAsset{{ + }, []balancertypes.PoolAsset{{ Weight: sdk.NewInt(100), Token: sdk.Coin{ Denom: "foo", @@ -183,7 +184,7 @@ func (suite *KeeperTestSuite) TestCreateBalancerPool() { _, err := keeper.CreateBalancerPool(suite.ctx, acc1, balancer.PoolParams{ SwapFee: sdk.NewDecWithPrec(1, 2), ExitFee: sdk.NewDecWithPrec(1, 2), - }, []types.PoolAsset{{ + }, []balancertypes.PoolAsset{{ Weight: sdk.NewInt(100), Token: sdk.NewCoin("foo", sdk.NewInt(10000)), }, { diff --git a/x/gamm/keeper/share.go b/x/gamm/keeper/share.go index 0b52312e15a..bcd2b6004ac 100644 --- a/x/gamm/keeper/share.go +++ b/x/gamm/keeper/share.go @@ -22,7 +22,7 @@ func (k Keeper) applyJoinPoolStateChange(ctx sdk.Context, pool types.PoolI, join return err } - k.createAddLiquidityEvent(ctx, joiner, pool.GetId(), joinCoins) + ctx.EventManager().EmitEvent(types.CreateAddLiquidityEvent(ctx, joiner, pool.GetId(), joinCoins)) k.hooks.AfterJoinPool(ctx, joiner, pool.GetId(), joinCoins, numShares) k.RecordTotalLiquidityIncrease(ctx, joinCoins) return nil @@ -44,7 +44,7 @@ func (k Keeper) applyExitPoolStateChange(ctx sdk.Context, pool types.PoolI, exit return err } - k.createRemoveLiquidityEvent(ctx, exiter, pool.GetId(), exitCoins) + ctx.EventManager().EmitEvent(types.CreateRemoveLiquidityEvent(ctx, exiter, pool.GetId(), exitCoins)) k.hooks.AfterExitPool(ctx, exiter, pool.GetId(), numShares, exitCoins) k.RecordTotalLiquidityDecrease(ctx, exitCoins) return nil diff --git a/x/gamm/keeper/swap.go b/x/gamm/keeper/swap.go index 81f60c14ef1..c434196b32d 100644 --- a/x/gamm/keeper/swap.go +++ b/x/gamm/keeper/swap.go @@ -142,7 +142,7 @@ func (k Keeper) updatePoolForSwap( return err } - k.createSwapEvent(ctx, sender, pool.GetId(), tokensIn, tokensOut) + ctx.EventManager().EmitEvent(types.CreateSwapEvent(ctx, sender, pool.GetId(), tokensIn, tokensOut)) k.hooks.AfterSwap(ctx, sender, pool.GetId(), tokensIn, tokensOut) k.RecordTotalLiquidityIncrease(ctx, tokensIn) k.RecordTotalLiquidityDecrease(ctx, tokensOut) diff --git a/x/gamm/pool-models/balancer/balancerPool.pb.go b/x/gamm/pool-models/balancer/balancerPool.pb.go index 1822eb0b1ff..d30c40d2882 100644 --- a/x/gamm/pool-models/balancer/balancerPool.pb.go +++ b/x/gamm/pool-models/balancer/balancerPool.pb.go @@ -8,12 +8,11 @@ package balancer import ( fmt "fmt" github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types" - types1 "github.com/cosmos/cosmos-sdk/types" + types "github.com/cosmos/cosmos-sdk/types" _ "github.com/cosmos/cosmos-sdk/x/auth/types" _ "github.com/gogo/protobuf/gogoproto" proto "github.com/gogo/protobuf/proto" github_com_gogo_protobuf_types "github.com/gogo/protobuf/types" - types "github.com/osmosis-labs/osmosis/v7/x/gamm/types" _ "github.com/regen-network/cosmos-proto" _ "google.golang.org/protobuf/types/known/durationpb" _ "google.golang.org/protobuf/types/known/timestamppb" @@ -58,12 +57,12 @@ type SmoothWeightChangeParams struct { // The amount PoolAsset.token.amount field is ignored if present, // future type refactorings should just have a type with the denom & weight // here. - InitialPoolWeights []types.PoolAsset `protobuf:"bytes,3,rep,name=initialPoolWeights,proto3" json:"initialPoolWeights" yaml:"initial_pool_weights"` + InitialPoolWeights []PoolAsset `protobuf:"bytes,3,rep,name=initialPoolWeights,proto3" json:"initialPoolWeights" yaml:"initial_pool_weights"` // 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. - TargetPoolWeights []types.PoolAsset `protobuf:"bytes,4,rep,name=targetPoolWeights,proto3" json:"targetPoolWeights" yaml:"target_pool_weights"` + TargetPoolWeights []PoolAsset `protobuf:"bytes,4,rep,name=targetPoolWeights,proto3" json:"targetPoolWeights" yaml:"target_pool_weights"` } func (m *SmoothWeightChangeParams) Reset() { *m = SmoothWeightChangeParams{} } @@ -113,14 +112,14 @@ func (m *SmoothWeightChangeParams) GetDuration() time.Duration { return 0 } -func (m *SmoothWeightChangeParams) GetInitialPoolWeights() []types.PoolAsset { +func (m *SmoothWeightChangeParams) GetInitialPoolWeights() []PoolAsset { if m != nil { return m.InitialPoolWeights } return nil } -func (m *SmoothWeightChangeParams) GetTargetPoolWeights() []types.PoolAsset { +func (m *SmoothWeightChangeParams) GetTargetPoolWeights() []PoolAsset { if m != nil { return m.TargetPoolWeights } @@ -177,6 +176,58 @@ func (m *PoolParams) GetSmoothWeightChangeParams() *SmoothWeightChangeParams { return nil } +// Pool asset is an internal struct that combines the amount of the +// token in the pool, and its balancer weight. +// This is an awkward packaging of data, +// and should be revisited in a future state migration. +type PoolAsset struct { + // Coins we are talking about, + // the denomination must be unique amongst all PoolAssets for this pool. + Token types.Coin `protobuf:"bytes,1,opt,name=token,proto3" json:"token" yaml:"token"` + // Weight that is not normalized. This weight must be less than 2^50 + Weight github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,2,opt,name=weight,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"weight" yaml:"weight"` +} + +func (m *PoolAsset) Reset() { *m = PoolAsset{} } +func (m *PoolAsset) String() string { return proto.CompactTextString(m) } +func (*PoolAsset) ProtoMessage() {} +func (*PoolAsset) Descriptor() ([]byte, []int) { + return fileDescriptor_7e991f749f68c2a4, []int{2} +} +func (m *PoolAsset) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *PoolAsset) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_PoolAsset.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *PoolAsset) XXX_Merge(src proto.Message) { + xxx_messageInfo_PoolAsset.Merge(m, src) +} +func (m *PoolAsset) XXX_Size() int { + return m.Size() +} +func (m *PoolAsset) XXX_DiscardUnknown() { + xxx_messageInfo_PoolAsset.DiscardUnknown(m) +} + +var xxx_messageInfo_PoolAsset proto.InternalMessageInfo + +func (m *PoolAsset) GetToken() types.Coin { + if m != nil { + return m.Token + } + return types.Coin{} +} + type Pool struct { Address string `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty" yaml:"address"` Id uint64 `protobuf:"varint,2,opt,name=id,proto3" json:"id,omitempty"` @@ -192,10 +243,10 @@ type Pool struct { // TODO: Further improve these docs FuturePoolGovernor string `protobuf:"bytes,4,opt,name=future_pool_governor,json=futurePoolGovernor,proto3" json:"future_pool_governor,omitempty" yaml:"future_pool_governor"` // sum of all LP tokens sent out - TotalShares types1.Coin `protobuf:"bytes,5,opt,name=totalShares,proto3" json:"totalShares" yaml:"total_shares"` + TotalShares types.Coin `protobuf:"bytes,5,opt,name=totalShares,proto3" json:"totalShares" yaml:"total_shares"` // These are assumed to be sorted by denomiation. // They contain the pool asset and the information about the weight - PoolAssets []types.PoolAsset `protobuf:"bytes,6,rep,name=poolAssets,proto3" json:"poolAssets" yaml:"pool_assets"` + PoolAssets []PoolAsset `protobuf:"bytes,6,rep,name=poolAssets,proto3" json:"poolAssets" yaml:"pool_assets"` // sum of all non-normalized pool weights TotalWeight github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,7,opt,name=totalWeight,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"totalWeight" yaml:"total_weight"` } @@ -203,7 +254,7 @@ type Pool struct { func (m *Pool) Reset() { *m = Pool{} } func (*Pool) ProtoMessage() {} func (*Pool) Descriptor() ([]byte, []int) { - return fileDescriptor_7e991f749f68c2a4, []int{2} + return fileDescriptor_7e991f749f68c2a4, []int{3} } func (m *Pool) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -235,6 +286,7 @@ var xxx_messageInfo_Pool proto.InternalMessageInfo func init() { proto.RegisterType((*SmoothWeightChangeParams)(nil), "osmosis.gamm.v1beta1.SmoothWeightChangeParams") proto.RegisterType((*PoolParams)(nil), "osmosis.gamm.v1beta1.PoolParams") + proto.RegisterType((*PoolAsset)(nil), "osmosis.gamm.v1beta1.PoolAsset") proto.RegisterType((*Pool)(nil), "osmosis.gamm.v1beta1.Pool") } @@ -243,56 +295,59 @@ func init() { } var fileDescriptor_7e991f749f68c2a4 = []byte{ - // 775 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x95, 0xcd, 0x4e, 0xdb, 0x4a, - 0x14, 0xc7, 0xe3, 0x24, 0xc0, 0x65, 0x90, 0xb8, 0x62, 0x2e, 0x0b, 0x13, 0x74, 0x63, 0xe4, 0x4a, - 0x15, 0xaa, 0x88, 0x2d, 0x68, 0xa5, 0x4a, 0x2c, 0x2a, 0x11, 0x68, 0x2b, 0x76, 0xd4, 0x54, 0x2a, - 0x2a, 0x0b, 0x6b, 0x92, 0x0c, 0x8e, 0x55, 0x3b, 0xe3, 0x7a, 0x26, 0x7c, 0xbc, 0x41, 0x97, 0xac, - 0x2a, 0x96, 0xbc, 0x42, 0xa5, 0xbe, 0x43, 0x59, 0xa2, 0xae, 0xaa, 0x2e, 0x4c, 0x05, 0xbb, 0x2e, - 0xf3, 0x04, 0xd5, 0xcc, 0x1c, 0x87, 0x34, 0x24, 0x12, 0x55, 0x57, 0xf1, 0xcc, 0x9c, 0xf3, 0x3b, - 0xff, 0xf3, 0x31, 0x13, 0xf4, 0x84, 0xf1, 0x98, 0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, 0xa2, 0x2e, 0x00, - 0x37, 0x27, 0xef, 0x77, 0x51, 0x2a, 0x80, 0xc7, 0x1a, 0xaf, 0x12, 0x20, 0x8a, 0x00, 0x95, 0xd0, - 0x38, 0x1c, 0x80, 0x6c, 0xdd, 0x52, 0x73, 0x4a, 0x15, 0xe0, 0xf9, 0x1f, 0x4c, 0xec, 0x76, 0x47, - 0x0c, 0x67, 0xa1, 0x67, 0x27, 0xcf, 0x42, 0x93, 0xd7, 0xe7, 0x3e, 0x9c, 0x5b, 0x85, 0xb3, 0x73, - 0xab, 0xf0, 0xf5, 0x73, 0x6d, 0x42, 0xea, 0xdc, 0xae, 0xef, 0x5d, 0x5c, 0x57, 0x8d, 0xcb, 0xeb, - 0xaa, 0xf1, 0xe3, 0xba, 0x6a, 0x9c, 0xde, 0x54, 0x0b, 0x97, 0x37, 0xd5, 0xc2, 0xb7, 0x9b, 0x6a, - 0xe1, 0xed, 0xb3, 0x81, 0xc0, 0x90, 0x68, 0x2d, 0x22, 0x0d, 0x9e, 0x2f, 0xdc, 0xc3, 0xa7, 0xee, - 0xf1, 0xf8, 0x7f, 0xad, 0xc6, 0xa4, 0x7a, 0x28, 0x1f, 0xff, 0x0a, 0x00, 0x00, 0xff, 0xff, 0x8d, - 0xd7, 0xef, 0xcf, 0xe1, 0x06, 0x00, 0x00, + // 821 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x95, 0xcf, 0x6f, 0xe3, 0x44, + 0x14, 0xc7, 0xe3, 0x24, 0x6d, 0xe9, 0x14, 0x16, 0x75, 0xc8, 0xc1, 0xcd, 0x8a, 0xb8, 0x1a, 0x24, + 0xb4, 0x42, 0x1b, 0x5b, 0x5d, 0x90, 0x90, 0xf6, 0x00, 0xda, 0x6c, 0x0b, 0xea, 0xad, 0xb8, 0x48, + 0xad, 0xe8, 0xc1, 0x9a, 0x24, 0x53, 0xc7, 0xaa, 0xed, 0x31, 0x9e, 0x49, 0x7f, 0xfc, 0x07, 0x1c, + 0x7b, 0x42, 0x3d, 0xf6, 0xce, 0x09, 0x89, 0xff, 0x81, 0x1e, 0x2b, 0x4e, 0x88, 0x83, 0x8b, 0xda, + 0x1b, 0xc7, 0xfc, 0x05, 0x68, 0x66, 0x9e, 0xd3, 0x90, 0x26, 0xa2, 0xd5, 0x9e, 0x9a, 0x99, 0x79, + 0xef, 0xf3, 0xbe, 0xf3, 0xde, 0x77, 0x5c, 0xf4, 0x05, 0x17, 0x09, 0x17, 0x91, 0xf0, 0x42, 0x9a, + 0x24, 0x5e, 0xc6, 0x79, 0xdc, 0x4e, 0x78, 0x9f, 0xc5, 0xc2, 0xeb, 0xd2, 0x98, 0xa6, 0x3d, 0x96, + 0x8f, 0x7f, 0xec, 0x70, 0x1e, 0xbb, 0x59, 0xce, 0x25, 0xc7, 0x0d, 0xc8, 0x72, 0x55, 0x96, 0x7b, + 0xbc, 0xd1, 0x65, 0x92, 0x6e, 0x34, 0xd7, 0x7a, 0x7a, 0x3b, 0xd0, 0x31, 0x9e, 0x59, 0x98, 0x84, + 0x66, 0x23, 0xe4, 0x21, 0x37, 0xfb, 0xea, 0x17, 0xec, 0xb6, 0x42, 0xce, 0xc3, 0x98, 0x79, 0x7a, + 0xd5, 0x1d, 0x1e, 0x7a, 0xfd, 0x61, 0x4e, 0x65, 0xc4, 0x53, 0x38, 0x77, 0xa6, 0xcf, 0x65, 0x94, + 0x30, 0x21, 0x69, 0x92, 0x95, 0x00, 0x53, 0xc4, 0xa3, 0x43, 0x39, 0xf0, 0x40, 0x86, 0x5e, 0x4c, + 0x9d, 0x77, 0xa9, 0x60, 0xe3, 0xf3, 0x1e, 0x8f, 0xa0, 0x00, 0xf9, 0xbd, 0x86, 0xec, 0xdd, 0x84, + 0x73, 0x39, 0xd8, 0x63, 0x51, 0x38, 0x90, 0x6f, 0x07, 0x34, 0x0d, 0xd9, 0x0e, 0xcd, 0x69, 0x22, + 0xf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, 0x69, 0x57, 0x94, 0x0b, 0xef, 0xf8, 0x4b, 0xef, 0x74, 0xfe, 0xbf, + 0xd0, 0xee, 0xa2, 0xfe, 0xac, 0x7f, 0xfe, 0x6f, 0x00, 0x00, 0x00, 0xff, 0xff, 0xe8, 0x95, 0xe6, + 0x20, 0x6e, 0x07, 0x00, 0x00, } func (m *SmoothWeightChangeParams) Marshal() (dAtA []byte, err error) { @@ -417,6 +472,49 @@ func (m *PoolParams) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } +func (m *PoolAsset) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *PoolAsset) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *PoolAsset) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size := m.Weight.Size() + i -= size + if _, err := m.Weight.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintBalancerPool(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + { + size, err := m.Token.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintBalancerPool(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + return len(dAtA) - i, nil +} + func (m *Pool) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) @@ -556,6 +654,19 @@ func (m *PoolParams) Size() (n int) { return n } +func (m *PoolAsset) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.Token.Size() + n += 1 + l + sovBalancerPool(uint64(l)) + l = m.Weight.Size() + n += 1 + l + sovBalancerPool(uint64(l)) + return n +} + func (m *Pool) Size() (n int) { if m == nil { return 0 @@ -718,7 +829,7 @@ func (m *SmoothWeightChangeParams) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.InitialPoolWeights = append(m.InitialPoolWeights, types.PoolAsset{}) + m.InitialPoolWeights = append(m.InitialPoolWeights, PoolAsset{}) if err := m.InitialPoolWeights[len(m.InitialPoolWeights)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } @@ -752,7 +863,7 @@ func (m *SmoothWeightChangeParams) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.TargetPoolWeights = append(m.TargetPoolWeights, types.PoolAsset{}) + m.TargetPoolWeights = append(m.TargetPoolWeights, PoolAsset{}) if err := m.TargetPoolWeights[len(m.TargetPoolWeights)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } @@ -932,6 +1043,123 @@ func (m *PoolParams) Unmarshal(dAtA []byte) error { } return nil } +func (m *PoolAsset) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowBalancerPool + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: PoolAsset: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: PoolAsset: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Token", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowBalancerPool + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthBalancerPool + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthBalancerPool + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Token.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Weight", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowBalancerPool + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthBalancerPool + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthBalancerPool + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Weight.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipBalancerPool(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthBalancerPool + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func (m *Pool) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -1139,7 +1367,7 @@ func (m *Pool) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.PoolAssets = append(m.PoolAssets, types.PoolAsset{}) + m.PoolAssets = append(m.PoolAssets, PoolAsset{}) if err := m.PoolAssets[len(m.PoolAssets)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } diff --git a/x/gamm/pool-models/balancer/balancer_pool.go b/x/gamm/pool-models/balancer/balancer_pool.go index 53b9f339de0..3111b6b9136 100644 --- a/x/gamm/pool-models/balancer/balancer_pool.go +++ b/x/gamm/pool-models/balancer/balancer_pool.go @@ -21,7 +21,7 @@ var _ types.PoolI = &Pool{} // * 2 <= len(assets) <= 8 // * FutureGovernor is valid // * poolID doesn't already exist -func NewBalancerPool(poolId uint64, balancerPoolParams PoolParams, assets []types.PoolAsset, futureGovernor string, blockTime time.Time) (Pool, error) { +func NewBalancerPool(poolId uint64, balancerPoolParams PoolParams, assets []PoolAsset, futureGovernor string, blockTime time.Time) (Pool, error) { poolAddr := types.NewPoolAddress(poolId) // pool thats created up to ensuring the assets and params are valid. @@ -74,7 +74,7 @@ func (pa Pool) GetSwapFee(_ sdk.Context) sdk.Dec { } func (pa Pool) GetTotalLpBalances(_ sdk.Context) sdk.Coins { - return types.PoolAssetsCoins(pa.PoolAssets) + return PoolAssetsCoins(pa.PoolAssets) } func (pa Pool) GetExitFee(_ sdk.Context) sdk.Dec { @@ -106,14 +106,14 @@ func (pa *Pool) SubTotalShares(amt sdk.Int) { // If the same denom's PoolAsset exists, will return error. // The list of PoolAssets must be sorted. This is done to enable fast searching for a PoolAsset by denomination. // TODO: Unify story for validation of []PoolAsset, some is here, some is in CreatePool.ValidateBasic() -func (pa *Pool) setInitialPoolAssets(PoolAssets []types.PoolAsset) error { +func (pa *Pool) setInitialPoolAssets(PoolAssets []PoolAsset) error { exists := make(map[string]bool) for _, asset := range pa.PoolAssets { exists[asset.Token.Denom] = true } newTotalWeight := pa.TotalWeight - scaledPoolAssets := make([]types.PoolAsset, 0, len(PoolAssets)) + scaledPoolAssets := make([]PoolAsset, 0, len(PoolAssets)) // TODO: Refactor this into PoolAsset.validate() for _, asset := range PoolAssets { @@ -132,7 +132,7 @@ func (pa *Pool) setInitialPoolAssets(PoolAssets []types.PoolAsset) error { exists[asset.Token.Denom] = true // Scale weight from the user provided weight to the correct internal weight - asset.Weight = asset.Weight.MulRaw(types.GuaranteedWeightPrecision) + asset.Weight = asset.Weight.MulRaw(GuaranteedWeightPrecision) scaledPoolAssets = append(scaledPoolAssets, asset) newTotalWeight = newTotalWeight.Add(asset.Weight) } @@ -141,21 +141,35 @@ func (pa *Pool) setInitialPoolAssets(PoolAssets []types.PoolAsset) error { // Furthermore, consider changing the underlying data type to allow in-place modification if the // number of PoolAssets is expected to be large. pa.PoolAssets = append(pa.PoolAssets, scaledPoolAssets...) - types.SortPoolAssetsByDenom(pa.PoolAssets) + SortPoolAssetsByDenom(pa.PoolAssets) pa.TotalWeight = newTotalWeight return nil } +// ValidateUserSpecifiedWeight ensures that a weight that is provided from user-input anywhere +// for creating a pool obeys the expected guarantees. +// Namely, that the weight is in the range [1, MaxUserSpecifiedWeight) +func ValidateUserSpecifiedWeight(weight sdk.Int) error { + if !weight.IsPositive() { + return sdkerrors.Wrap(types.ErrNotPositiveWeight, weight.String()) + } + + if weight.GTE(MaxUserSpecifiedWeight) { + return sdkerrors.Wrap(types.ErrWeightTooLarge, weight.String()) + } + return nil +} + // setInitialPoolParams -func (pa *Pool) setInitialPoolParams(params PoolParams, sortedAssets []types.PoolAsset, curBlockTime time.Time) error { +func (pa *Pool) setInitialPoolParams(params PoolParams, sortedAssets []PoolAsset, curBlockTime time.Time) error { pa.PoolParams = params if params.SmoothWeightChangeParams != nil { // set initial assets - initialWeights := make([]types.PoolAsset, len(sortedAssets)) + initialWeights := make([]PoolAsset, len(sortedAssets)) for i, v := range sortedAssets { - initialWeights[i] = types.PoolAsset{ + initialWeights[i] = PoolAsset{ Weight: v.Weight, Token: sdk.Coin{Denom: v.Token.Denom, Amount: sdk.ZeroInt()}, } @@ -164,16 +178,16 @@ func (pa *Pool) setInitialPoolParams(params PoolParams, sortedAssets []types.Poo // sort target weights by denom targetPoolWeights := params.SmoothWeightChangeParams.TargetPoolWeights - types.SortPoolAssetsByDenom(targetPoolWeights) + SortPoolAssetsByDenom(targetPoolWeights) // scale target pool weights by GuaranteedWeightPrecision for i, v := range targetPoolWeights { - err := types.ValidateUserSpecifiedWeight(v.Weight) + err := ValidateUserSpecifiedWeight(v.Weight) if err != nil { return err } - pa.PoolParams.SmoothWeightChangeParams.TargetPoolWeights[i] = types.PoolAsset{ - Weight: v.Weight.MulRaw(types.GuaranteedWeightPrecision), + pa.PoolParams.SmoothWeightChangeParams.TargetPoolWeights[i] = PoolAsset{ + Weight: v.Weight.MulRaw(GuaranteedWeightPrecision), Token: v.Token, } } @@ -191,19 +205,19 @@ func (pa *Pool) setInitialPoolParams(params PoolParams, sortedAssets []types.Poo // GetPoolAssets returns the denom's PoolAsset, If the PoolAsset doesn't exist, will return error. // As above, it will search the denom's PoolAsset by using binary search. // So, it is important to make sure that the PoolAssets are sorted. -func (pa Pool) GetPoolAsset(denom string) (types.PoolAsset, error) { +func (pa Pool) GetPoolAsset(denom string) (PoolAsset, error) { _, asset, err := pa.getPoolAssetAndIndex(denom) return asset, err } // Returns a pool asset, and its index. If err != nil, then the index will be valid. -func (pa Pool) getPoolAssetAndIndex(denom string) (int, types.PoolAsset, error) { +func (pa Pool) getPoolAssetAndIndex(denom string) (int, PoolAsset, error) { if denom == "" { - return -1, types.PoolAsset{}, fmt.Errorf("you tried to find the PoolAsset with empty denom") + return -1, PoolAsset{}, fmt.Errorf("you tried to find the PoolAsset with empty denom") } if len(pa.PoolAssets) == 0 { - return -1, types.PoolAsset{}, fmt.Errorf("can't find the PoolAsset (%s)", denom) + return -1, PoolAsset{}, fmt.Errorf("can't find the PoolAsset (%s)", denom) } i := sort.Search(len(pa.PoolAssets), func(i int) bool { @@ -214,20 +228,20 @@ func (pa Pool) getPoolAssetAndIndex(denom string) (int, types.PoolAsset, error) }) if i < 0 || i >= len(pa.PoolAssets) { - return -1, types.PoolAsset{}, fmt.Errorf("can't find the PoolAsset (%s)", denom) + return -1, PoolAsset{}, fmt.Errorf("can't find the PoolAsset (%s)", denom) } if pa.PoolAssets[i].Token.Denom != denom { - return -1, types.PoolAsset{}, fmt.Errorf("can't find the PoolAsset (%s)", denom) + return -1, PoolAsset{}, fmt.Errorf("can't find the PoolAsset (%s)", denom) } return i, pa.PoolAssets[i], nil } func (p Pool) parsePoolAssetsByDenoms(tokenADenom, tokenBDenom string) ( - Aasset types.PoolAsset, Basset types.PoolAsset, err error) { - Aasset, found1 := types.GetPoolAssetByDenom(p.PoolAssets, tokenADenom) - Basset, found2 := types.GetPoolAssetByDenom(p.PoolAssets, tokenBDenom) + Aasset PoolAsset, Basset PoolAsset, err error) { + Aasset, found1 := GetPoolAssetByDenom(p.PoolAssets, tokenADenom) + Basset, found2 := GetPoolAssetByDenom(p.PoolAssets, tokenBDenom) if !(found1 && found2) { return Aasset, Basset, errors.New("one of the provided pool denoms does not exist in pool") } @@ -235,7 +249,7 @@ func (p Pool) parsePoolAssetsByDenoms(tokenADenom, tokenBDenom string) ( } func (p Pool) parsePoolAssets(tokensA sdk.Coins, tokenBDenom string) ( - tokenA sdk.Coin, Aasset types.PoolAsset, Basset types.PoolAsset, err error) { + tokenA sdk.Coin, Aasset PoolAsset, Basset PoolAsset, err error) { if len(tokensA) != 1 { return tokenA, Aasset, Basset, errors.New("expected tokensB to be of length one") } @@ -244,7 +258,7 @@ func (p Pool) parsePoolAssets(tokensA sdk.Coins, tokenBDenom string) ( } func (p Pool) parsePoolAssetsCoins(tokensA sdk.Coins, tokensB sdk.Coins) ( - Aasset types.PoolAsset, Basset types.PoolAsset, err error) { + Aasset PoolAsset, Basset PoolAsset, err error) { if len(tokensB) != 1 { return Aasset, Basset, errors.New("expected tokensA to be of length one") } @@ -310,8 +324,8 @@ func (pa *Pool) addToPoolAssetBalances(coins sdk.Coins) error { return nil } -func (pa Pool) GetPoolAssets(denoms ...string) ([]types.PoolAsset, error) { - result := make([]types.PoolAsset, 0, len(denoms)) +func (pa Pool) GetPoolAssets(denoms ...string) ([]PoolAsset, error) { + result := make([]PoolAsset, 0, len(denoms)) for _, denom := range denoms { PoolAsset, err := pa.GetPoolAsset(denom) @@ -325,8 +339,8 @@ func (pa Pool) GetPoolAssets(denoms ...string) ([]types.PoolAsset, error) { return result, nil } -func (pa Pool) GetAllPoolAssets() []types.PoolAsset { - copyslice := make([]types.PoolAsset, len(pa.PoolAssets)) +func (pa Pool) GetAllPoolAssets() []PoolAsset { + copyslice := make([]PoolAsset, len(pa.PoolAssets)) copy(copyslice, pa.PoolAssets) return copyslice } @@ -342,7 +356,7 @@ func (pa Pool) GetAllPoolAssets() []types.PoolAsset { // TODO: (post-launch) If newWeights excludes an existing denomination, // remove the weight from the pool, and figure out something to do // with any remaining coin. -func (pa *Pool) updateAllWeights(newWeights []types.PoolAsset) { +func (pa *Pool) updateAllWeights(newWeights []PoolAsset) { if len(pa.PoolAssets) != len(newWeights) { panic("updateAllWeights called with invalid input, len(newWeights) != len(existingWeights)") } @@ -445,7 +459,7 @@ func (pa Pool) IsActive(curBlockTime time.Time) bool { return true } -func (params PoolParams) Validate(poolWeights []types.PoolAsset) error { +func (params PoolParams) Validate(poolWeights []PoolAsset) error { if params.ExitFee.IsNegative() { return types.ErrNegativeExitFee } @@ -470,14 +484,14 @@ func (params PoolParams) Validate(poolWeights []types.PoolAsset) error { } // Validate all user specified weights for _, v := range targetWeights { - err := types.ValidateUserSpecifiedWeight(v.Weight) + err := ValidateUserSpecifiedWeight(v.Weight) if err != nil { return err } } // Ensure that all the target weight denoms are same as pool asset weights - sortedTargetPoolWeights := types.SortPoolAssetsOutOfPlaceByDenom(targetWeights) - sortedPoolWeights := types.SortPoolAssetsOutOfPlaceByDenom(poolWeights) + sortedTargetPoolWeights := SortPoolAssetsOutOfPlaceByDenom(targetWeights) + sortedPoolWeights := SortPoolAssetsOutOfPlaceByDenom(poolWeights) for i, v := range sortedPoolWeights { if sortedTargetPoolWeights[i].Token.Denom != v.Token.Denom { return types.ErrPoolParamsInvalidDenom @@ -551,8 +565,8 @@ func ValidateFutureGovernor(governor string) error { // It assumes that both pool assets have the same token denominations, // with the denominations in the same order. // Returned weights can (and probably will have some) be negative. -func subPoolAssetWeights(base []types.PoolAsset, other []types.PoolAsset) []types.PoolAsset { - weightDifference := make([]types.PoolAsset, len(base)) +func subPoolAssetWeights(base []PoolAsset, other []PoolAsset) []PoolAsset { + weightDifference := make([]PoolAsset, len(base)) // TODO: Consider deleting these panics for performance if len(base) != len(other) { panic("subPoolAssetWeights called with invalid input, len(base) != len(other)") @@ -564,7 +578,7 @@ func subPoolAssetWeights(base []types.PoolAsset, other []types.PoolAsset) []type i, asset.Token.Denom, other[i].Token.Denom)) } curWeightDiff := asset.Weight.Sub(other[i].Weight) - weightDifference[i] = types.PoolAsset{Token: asset.Token, Weight: curWeightDiff} + weightDifference[i] = PoolAsset{Token: asset.Token, Weight: curWeightDiff} } return weightDifference } @@ -573,8 +587,8 @@ func subPoolAssetWeights(base []types.PoolAsset, other []types.PoolAsset) []type // It assumes that both pool assets have the same token denominations, // with the denominations in the same order. // Returned weights can be negative. -func addPoolAssetWeights(base []types.PoolAsset, other []types.PoolAsset) []types.PoolAsset { - weightSum := make([]types.PoolAsset, len(base)) +func addPoolAssetWeights(base []PoolAsset, other []PoolAsset) []PoolAsset { + weightSum := make([]PoolAsset, len(base)) // TODO: Consider deleting these panics for performance if len(base) != len(other) { panic("addPoolAssetWeights called with invalid input, len(base) != len(other)") @@ -586,20 +600,20 @@ func addPoolAssetWeights(base []types.PoolAsset, other []types.PoolAsset) []type i, asset.Token.Denom, other[i].Token.Denom)) } curWeightSum := asset.Weight.Add(other[i].Weight) - weightSum[i] = types.PoolAsset{Token: asset.Token, Weight: curWeightSum} + weightSum[i] = PoolAsset{Token: asset.Token, Weight: curWeightSum} } return weightSum } // assumes 0 < d < 1 -func poolAssetsMulDec(base []types.PoolAsset, d sdk.Dec) []types.PoolAsset { - newWeights := make([]types.PoolAsset, len(base)) +func poolAssetsMulDec(base []PoolAsset, d sdk.Dec) []PoolAsset { + newWeights := make([]PoolAsset, len(base)) for i, asset := range base { // TODO: This can adversarially panic at the moment! (as can Pool.TotalWeight) // Ensure this won't be able to panic in the future PR where we bound // each assets weight, and add precision newWeight := d.MulInt(asset.Weight).RoundInt() - newWeights[i] = types.PoolAsset{Token: asset.Token, Weight: newWeight} + newWeights[i] = PoolAsset{Token: asset.Token, Weight: newWeight} } return newWeights } diff --git a/x/gamm/pool-models/balancer/balancer_pool_test.go b/x/gamm/pool-models/balancer/balancer_pool_test.go index 1d8c2f9046a..ba9701a9023 100644 --- a/x/gamm/pool-models/balancer/balancer_pool_test.go +++ b/x/gamm/pool-models/balancer/balancer_pool_test.go @@ -8,7 +8,6 @@ import ( "github.com/stretchr/testify/require" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/osmosis-labs/osmosis/v7/x/gamm/types" ) var ( @@ -22,14 +21,14 @@ var ( defaultFutureGovernor = "" defaultCurBlockTime = time.Unix(1618700000, 0) // - dummyPoolAssets = []types.PoolAsset{} + dummyPoolAssets = []PoolAsset{} wantErr = true noErr = false ) // Expected is un-scaled func testTotalWeight(t *testing.T, expected sdk.Int, pool Pool) { - scaledExpected := expected.MulRaw(types.GuaranteedWeightPrecision) + scaledExpected := expected.MulRaw(GuaranteedWeightPrecision) require.Equal(t, scaledExpected.String(), pool.GetTotalWeight().String()) @@ -81,7 +80,7 @@ func TestBalancerPoolParams(t *testing.T) { func TestBalancerPoolUpdatePoolAssetBalance(t *testing.T) { var poolId uint64 = 10 - initialAssets := []types.PoolAsset{ + initialAssets := []PoolAsset{ { Weight: sdk.NewInt(100), Token: sdk.NewCoin("test1", sdk.NewInt(50000)), @@ -106,14 +105,14 @@ func TestBalancerPoolUpdatePoolAssetBalance(t *testing.T) { // TODO: This test actually just needs to be refactored to not be doing this, and just // create a different pool each time. - err = pacc.setInitialPoolAssets([]types.PoolAsset{{ + err = pacc.setInitialPoolAssets([]PoolAsset{{ Weight: sdk.NewInt(-1), Token: sdk.NewCoin("negativeWeight", sdk.NewInt(50000)), }}) require.Error(t, err) - err = pacc.setInitialPoolAssets([]types.PoolAsset{{ + err = pacc.setInitialPoolAssets([]PoolAsset{{ Weight: sdk.NewInt(0), Token: sdk.NewCoin("zeroWeight", sdk.NewInt(50000)), }}) @@ -143,12 +142,12 @@ func TestBalancerPoolAssetsWeightAndTokenBalance(t *testing.T) { // TODO: Add more cases // asset names should be i ascending order, starting from test1 tests := []struct { - assets []types.PoolAsset + assets []PoolAsset shouldErr bool }{ // weight 0 { - []types.PoolAsset{ + []PoolAsset{ { Weight: sdk.NewInt(0), Token: sdk.NewCoin("test1", sdk.NewInt(50000)), @@ -158,7 +157,7 @@ func TestBalancerPoolAssetsWeightAndTokenBalance(t *testing.T) { }, // negative weight { - []types.PoolAsset{ + []PoolAsset{ { Weight: sdk.NewInt(-1), Token: sdk.NewCoin("test1", sdk.NewInt(50000)), @@ -168,7 +167,7 @@ func TestBalancerPoolAssetsWeightAndTokenBalance(t *testing.T) { }, // 0 token amount { - []types.PoolAsset{ + []PoolAsset{ { Weight: sdk.NewInt(100), Token: sdk.NewCoin("test1", sdk.NewInt(0)), @@ -178,7 +177,7 @@ func TestBalancerPoolAssetsWeightAndTokenBalance(t *testing.T) { }, // negative token amount { - []types.PoolAsset{ + []PoolAsset{ { Weight: sdk.NewInt(100), Token: sdk.Coin{ @@ -191,7 +190,7 @@ func TestBalancerPoolAssetsWeightAndTokenBalance(t *testing.T) { }, // total weight 300 { - []types.PoolAsset{ + []PoolAsset{ { Weight: sdk.NewInt(200), Token: sdk.NewCoin("test2", sdk.NewInt(50000)), @@ -205,7 +204,7 @@ func TestBalancerPoolAssetsWeightAndTokenBalance(t *testing.T) { }, // two of the same token { - []types.PoolAsset{ + []PoolAsset{ { Weight: sdk.NewInt(200), Token: sdk.NewCoin("test2", sdk.NewInt(50000)), @@ -223,7 +222,7 @@ func TestBalancerPoolAssetsWeightAndTokenBalance(t *testing.T) { }, // total weight 7300 { - []types.PoolAsset{ + []PoolAsset{ { Weight: sdk.NewInt(200), Token: sdk.NewCoin("test2", sdk.NewInt(50000)), @@ -271,7 +270,7 @@ func TestGetBalancerPoolAssets(t *testing.T) { // and fails for things not in it. denomNotInPool := "xyzCoin" - assets := []types.PoolAsset{ + assets := []PoolAsset{ { Weight: sdk.NewInt(200), Token: sdk.NewCoin("test2", sdk.NewInt(50000)), @@ -318,7 +317,7 @@ func TestLBPParamsEmptyStartTime(t *testing.T) { // sets its start time to be the first start time it is called on defaultDuration := 100 * time.Second - initialPoolAssets := []types.PoolAsset{ + initialPoolAssets := []PoolAsset{ { Weight: sdk.NewInt(1), Token: sdk.NewCoin("asset1", sdk.NewInt(1000)), @@ -331,7 +330,7 @@ func TestLBPParamsEmptyStartTime(t *testing.T) { params := SmoothWeightChangeParams{ Duration: defaultDuration, - TargetPoolWeights: []types.PoolAsset{ + TargetPoolWeights: []PoolAsset{ { Weight: sdk.NewInt(1), Token: sdk.NewCoin("asset1", sdk.NewInt(0)), @@ -361,7 +360,7 @@ func TestBalancerPoolPokeTokenWeights(t *testing.T) { defaultStartTime := time.Unix(1618703511, 0) defaultStartTimeUnix := defaultStartTime.Unix() defaultDuration := 100 * time.Second - floatGuaranteedPrecison := float64(types.GuaranteedWeightPrecision) + floatGuaranteedPrecison := float64(GuaranteedWeightPrecision) // testCases don't need to be ordered by time. but the blockTime should be // less than the end time of the SmoothWeightChange. Testing past the end time @@ -386,7 +385,7 @@ func TestBalancerPoolPokeTokenWeights(t *testing.T) { params: SmoothWeightChangeParams{ StartTime: defaultStartTime, Duration: defaultDuration, - InitialPoolWeights: []types.PoolAsset{ + InitialPoolWeights: []PoolAsset{ { Weight: sdk.NewInt(1), Token: sdk.NewCoin("asset1", sdk.NewInt(0)), @@ -396,7 +395,7 @@ func TestBalancerPoolPokeTokenWeights(t *testing.T) { Token: sdk.NewCoin("asset2", sdk.NewInt(0)), }, }, - TargetPoolWeights: []types.PoolAsset{ + TargetPoolWeights: []PoolAsset{ { Weight: sdk.NewInt(1), Token: sdk.NewCoin("asset1", sdk.NewInt(0)), @@ -412,16 +411,16 @@ func TestBalancerPoolPokeTokenWeights(t *testing.T) { // Halfway through at 50 seconds elapsed blockTime: time.Unix(defaultStartTimeUnix+50, 0), expectedWeights: []sdk.Int{ - sdk.NewInt(1 * types.GuaranteedWeightPrecision), + sdk.NewInt(1 * GuaranteedWeightPrecision), // Halfway between 1 & 2 - sdk.NewInt(3 * types.GuaranteedWeightPrecision / 2), + sdk.NewInt(3 * GuaranteedWeightPrecision / 2), }, }, { // Quarter way through at 25 seconds elapsed blockTime: time.Unix(defaultStartTimeUnix+25, 0), expectedWeights: []sdk.Int{ - sdk.NewInt(1 * types.GuaranteedWeightPrecision), + sdk.NewInt(1 * GuaranteedWeightPrecision), // Quarter way between 1 & 2 = 1.25 sdk.NewInt(int64(1.25 * floatGuaranteedPrecison)), }, @@ -434,7 +433,7 @@ func TestBalancerPoolPokeTokenWeights(t *testing.T) { params: SmoothWeightChangeParams{ StartTime: defaultStartTime, Duration: defaultDuration, - InitialPoolWeights: []types.PoolAsset{ + InitialPoolWeights: []PoolAsset{ { Weight: sdk.NewInt(2), Token: sdk.NewCoin("asset1", sdk.NewInt(0)), @@ -444,7 +443,7 @@ func TestBalancerPoolPokeTokenWeights(t *testing.T) { Token: sdk.NewCoin("asset2", sdk.NewInt(0)), }, }, - TargetPoolWeights: []types.PoolAsset{ + TargetPoolWeights: []PoolAsset{ { Weight: sdk.NewInt(4), Token: sdk.NewCoin("asset1", sdk.NewInt(0)), @@ -461,9 +460,9 @@ func TestBalancerPoolPokeTokenWeights(t *testing.T) { blockTime: time.Unix(defaultStartTimeUnix+50, 0), expectedWeights: []sdk.Int{ // Halfway between 2 & 4 - sdk.NewInt(6 * types.GuaranteedWeightPrecision / 2), + sdk.NewInt(6 * GuaranteedWeightPrecision / 2), // Halfway between 1 & 2 - sdk.NewInt(3 * types.GuaranteedWeightPrecision / 2), + sdk.NewInt(3 * GuaranteedWeightPrecision / 2), }, }, { @@ -489,7 +488,7 @@ func TestBalancerPoolPokeTokenWeights(t *testing.T) { initialWeights := make([]sdk.Int, len(params.InitialPoolWeights)) finalWeights := make([]sdk.Int, len(params.TargetPoolWeights)) for i, v := range params.InitialPoolWeights { - initialWeights[i] = v.Weight.MulRaw(types.GuaranteedWeightPrecision) + initialWeights[i] = v.Weight.MulRaw(GuaranteedWeightPrecision) } for i, v := range params.TargetPoolWeights { // Doesn't need to be scaled, due to this being done already in param initialization, @@ -527,9 +526,9 @@ func TestBalancerPoolPokeTokenWeights(t *testing.T) { for poolNum, tc := range tests { paramsCopy := tc.params // First we create the initial pool assets we will use - initialPoolAssets := make([]types.PoolAsset, len(paramsCopy.InitialPoolWeights)) + initialPoolAssets := make([]PoolAsset, len(paramsCopy.InitialPoolWeights)) for i, asset := range paramsCopy.InitialPoolWeights { - assetCopy := types.PoolAsset{ + assetCopy := PoolAsset{ Weight: asset.Weight, Token: sdk.NewInt64Coin(asset.Token.Denom, 10000), } diff --git a/x/gamm/pool-models/balancer/constants.go b/x/gamm/pool-models/balancer/constants.go new file mode 100644 index 00000000000..ed733539c92 --- /dev/null +++ b/x/gamm/pool-models/balancer/constants.go @@ -0,0 +1,20 @@ +package balancer + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" +) + +var ( + // Pool creators can specify a weight in [1, MaxUserSpecifiedWeight) + // for every token in the balancer pool. + // + // The weight used in the balancer equation is then creator-specified-weight * GuaranteedWeightPrecision. + // This is done so that LBP's / smooth weight changes can actually happen smoothly, + // without complex precision loss / edge effects. + MaxUserSpecifiedWeight sdk.Int = sdk.NewIntFromUint64(1 << 20) + // Scaling factor for every weight. The pool weight is: + // weight_in_MsgCreateBalancerPool * GuaranteedWeightPrecision + // + // This is done so that smooth weight changes have enough precision to actually be smooth. + GuaranteedWeightPrecision int64 = 1 << 30 +) diff --git a/x/gamm/pool-models/balancer/marshal.go b/x/gamm/pool-models/balancer/marshal.go index 273ebee9202..e967ef1ffec 100644 --- a/x/gamm/pool-models/balancer/marshal.go +++ b/x/gamm/pool-models/balancer/marshal.go @@ -4,18 +4,16 @@ import ( "encoding/json" sdk "github.com/cosmos/cosmos-sdk/types" - - "github.com/osmosis-labs/osmosis/v7/x/gamm/types" ) type balancerPoolPretty struct { - Address sdk.AccAddress `json:"address" yaml:"address"` - Id uint64 `json:"id" yaml:"id"` - PoolParams PoolParams `json:"pool_params" yaml:"pool_params"` - FuturePoolGovernor string `json:"future_pool_governor" yaml:"future_pool_governor"` - TotalWeight sdk.Dec `json:"total_weight" yaml:"total_weight"` - TotalShares sdk.Coin `json:"total_shares" yaml:"total_shares"` - PoolAssets []types.PoolAsset `json:"pool_assets" yaml:"pool_assets"` + Address sdk.AccAddress `json:"address" yaml:"address"` + Id uint64 `json:"id" yaml:"id"` + PoolParams PoolParams `json:"pool_params" yaml:"pool_params"` + FuturePoolGovernor string `json:"future_pool_governor" yaml:"future_pool_governor"` + TotalWeight sdk.Dec `json:"total_weight" yaml:"total_weight"` + TotalShares sdk.Coin `json:"total_shares" yaml:"total_shares"` + PoolAssets []PoolAsset `json:"pool_assets" yaml:"pool_assets"` } func (pa Pool) String() string { diff --git a/x/gamm/pool-models/balancer/marshal_test.go b/x/gamm/pool-models/balancer/marshal_test.go index 19e424614a7..c079598207e 100644 --- a/x/gamm/pool-models/balancer/marshal_test.go +++ b/x/gamm/pool-models/balancer/marshal_test.go @@ -9,10 +9,9 @@ import ( "github.com/stretchr/testify/require" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/osmosis-labs/osmosis/v7/x/gamm/types" ) -var ymlAssetTest = []types.PoolAsset{ +var ymlAssetTest = []PoolAsset{ { Weight: sdk.NewInt(200), Token: sdk.NewCoin("test2", sdk.NewInt(50000)), @@ -26,7 +25,7 @@ var ymlAssetTest = []types.PoolAsset{ func TestPoolJson(t *testing.T) { var poolId uint64 = 10 - jsonAssetTest := []types.PoolAsset{ + jsonAssetTest := []PoolAsset{ { Weight: sdk.NewInt(200), Token: sdk.NewCoin("test2", sdk.NewInt(50000)), @@ -69,7 +68,7 @@ func TestPoolProtoMarshal(t *testing.T) { require.Equal(t, pool2.PoolParams.ExitFee, defaultExitFee) require.Equal(t, pool2.FuturePoolGovernor, "") require.Equal(t, pool2.TotalShares, sdk.Coin{Denom: "gamm/pool/10", Amount: sdk.ZeroInt()}) - require.Equal(t, pool2.PoolAssets, []types.PoolAsset{ + require.Equal(t, pool2.PoolAssets, []PoolAsset{ { Token: sdk.Coin{ Denom: "test1", diff --git a/x/gamm/pool-models/balancer/msgs.go b/x/gamm/pool-models/balancer/msgs.go index bb6b53cc8d7..b5921dd9cfd 100644 --- a/x/gamm/pool-models/balancer/msgs.go +++ b/x/gamm/pool-models/balancer/msgs.go @@ -22,7 +22,7 @@ func (msg MsgCreateBalancerPool) ValidateBasic() error { return sdkerrors.Wrapf(sdkerrors.ErrInvalidAddress, "Invalid sender address (%s)", err) } - err = types.ValidateUserSpecifiedPoolAssets(msg.PoolAssets) + err = ValidateUserSpecifiedPoolAssets(msg.PoolAssets) if err != nil { return err } diff --git a/x/gamm/pool-models/balancer/msgs_test.go b/x/gamm/pool-models/balancer/msgs_test.go index bfd3ebaf57b..c0d556994c9 100644 --- a/x/gamm/pool-models/balancer/msgs_test.go +++ b/x/gamm/pool-models/balancer/msgs_test.go @@ -19,7 +19,7 @@ func TestMsgCreateBalancerPool(t *testing.T) { invalidAddr := sdk.AccAddress("invalid") createMsg := func(after func(msg MsgCreateBalancerPool) MsgCreateBalancerPool) MsgCreateBalancerPool { - testPoolAsset := []types.PoolAsset{ + testPoolAsset := []PoolAsset{ { Weight: sdk.NewInt(100), Token: sdk.NewCoin("test", sdk.NewInt(100)), @@ -88,7 +88,7 @@ func TestMsgCreateBalancerPool(t *testing.T) { { name: "has no PoolAsset2", msg: createMsg(func(msg MsgCreateBalancerPool) MsgCreateBalancerPool { - msg.PoolAssets = []types.PoolAsset{} + msg.PoolAssets = []PoolAsset{} return msg }), expectPass: false, @@ -96,7 +96,7 @@ func TestMsgCreateBalancerPool(t *testing.T) { { name: "has one Pool Asset", msg: createMsg(func(msg MsgCreateBalancerPool) MsgCreateBalancerPool { - msg.PoolAssets = []types.PoolAsset{ + msg.PoolAssets = []PoolAsset{ msg.PoolAssets[0], } return msg diff --git a/x/gamm/types/pool_asset.go b/x/gamm/pool-models/balancer/pool_asset.go similarity index 94% rename from x/gamm/types/pool_asset.go rename to x/gamm/pool-models/balancer/pool_asset.go index 1742af906d9..40ebc3b99f9 100644 --- a/x/gamm/types/pool_asset.go +++ b/x/gamm/pool-models/balancer/pool_asset.go @@ -1,4 +1,4 @@ -package types +package balancer import ( "fmt" @@ -7,6 +7,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + "github.com/osmosis-labs/osmosis/v7/x/gamm/types" "gopkg.in/yaml.v2" ) @@ -78,12 +79,12 @@ func SortPoolAssetsByDenom(assets []PoolAsset) { func ValidateUserSpecifiedPoolAssets(assets []PoolAsset) error { // The pool must be swapping between at least two assets if len(assets) < 2 { - return ErrTooFewPoolAssets + return types.ErrTooFewPoolAssets } // TODO: Add the limit of binding token to the pool params? if len(assets) > 8 { - return sdkerrors.Wrapf(ErrTooManyPoolAssets, "%d", len(assets)) + return sdkerrors.Wrapf(types.ErrTooManyPoolAssets, "%d", len(assets)) } for _, asset := range assets { diff --git a/x/gamm/pool-models/balancer/tx.pb.go b/x/gamm/pool-models/balancer/tx.pb.go index 90bc8cea2b3..7824fc666f5 100644 --- a/x/gamm/pool-models/balancer/tx.pb.go +++ b/x/gamm/pool-models/balancer/tx.pb.go @@ -9,7 +9,6 @@ import ( _ "github.com/gogo/protobuf/gogoproto" grpc1 "github.com/gogo/protobuf/grpc" proto "github.com/gogo/protobuf/proto" - types "github.com/osmosis-labs/osmosis/v7/x/gamm/types" grpc "google.golang.org/grpc" codes "google.golang.org/grpc/codes" status "google.golang.org/grpc/status" @@ -31,10 +30,10 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package // ===================== MsgCreatePool type MsgCreateBalancerPool struct { - Sender string `protobuf:"bytes,1,opt,name=sender,proto3" json:"sender,omitempty" yaml:"sender"` - PoolParams *PoolParams `protobuf:"bytes,2,opt,name=poolParams,proto3" json:"poolParams,omitempty" yaml:"pool_params"` - PoolAssets []types.PoolAsset `protobuf:"bytes,3,rep,name=poolAssets,proto3" json:"poolAssets"` - FuturePoolGovernor string `protobuf:"bytes,4,opt,name=future_pool_governor,json=futurePoolGovernor,proto3" json:"future_pool_governor,omitempty" yaml:"future_pool_governor"` + Sender string `protobuf:"bytes,1,opt,name=sender,proto3" json:"sender,omitempty" yaml:"sender"` + PoolParams *PoolParams `protobuf:"bytes,2,opt,name=poolParams,proto3" json:"poolParams,omitempty" yaml:"pool_params"` + PoolAssets []PoolAsset `protobuf:"bytes,3,rep,name=poolAssets,proto3" json:"poolAssets"` + FuturePoolGovernor string `protobuf:"bytes,4,opt,name=future_pool_governor,json=futurePoolGovernor,proto3" json:"future_pool_governor,omitempty" yaml:"future_pool_governor"` } func (m *MsgCreateBalancerPool) Reset() { *m = MsgCreateBalancerPool{} } @@ -84,7 +83,7 @@ func (m *MsgCreateBalancerPool) GetPoolParams() *PoolParams { return nil } -func (m *MsgCreateBalancerPool) GetPoolAssets() []types.PoolAsset { +func (m *MsgCreateBalancerPool) GetPoolAssets() []PoolAsset { if m != nil { return m.PoolAssets } @@ -152,33 +151,33 @@ func init() { } var fileDescriptor_26dfff9c7e076bd8 = []byte{ - // 412 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x92, 0xc1, 0xea, 0xd3, 0x30, - 0x1c, 0xc7, 0xdb, 0x6d, 0x54, 0xcc, 0xf0, 0x60, 0x98, 0x52, 0x26, 0x36, 0xa5, 0x5e, 0xa6, 0xb2, - 0x86, 0x6d, 0x82, 0xe0, 0x41, 0xb0, 0x4e, 0x64, 0x87, 0xc1, 0xec, 0x69, 0x78, 0x19, 0xe9, 0x1a, - 0xeb, 0xa0, 0x6d, 0x4a, 0xd2, 0x95, 0x79, 0xf0, 0x1d, 0x7c, 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0xd9, 0x1d, 0xf5, 0xa7, 0xe8, 0xb6, 0x59, 0x72, 0x4e, 0xef, 0x98, 0x23, 0xc5, 0xbd, 0x0a, - 0xc2, 0x4f, 0x60, 0xf0, 0x65, 0x9f, 0xee, 0x39, 0xdd, 0xc8, 0x4e, 0x01, 0xcb, 0x28, 0x8f, 0x19, - 0xd7, 0x7b, 0x72, 0x32, 0x74, 0xc9, 0xd1, 0x93, 0x6a, 0x23, 0x6d, 0x94, 0xe5, 0xc2, 0xaa, 0x5c, - 0x76, 0xf8, 0xd8, 0x14, 0xe7, 0xe0, 0x69, 0xeb, 0xb9, 0xb9, 0x54, 0x24, 0x2c, 0x16, 0x14, 0x3e, - 0x03, 0xf7, 0xa4, 0x66, 0xe7, 0xcb, 0x03, 0xec, 0x39, 0xa0, 0xc8, 0x91, 0x56, 0x22, 0x8b, 0xb9, - 0xab, 0x95, 0xbf, 0x16, 0xfe, 0xf4, 0x3b, 0xe8, 0x2e, 0x45, 0x00, 0x33, 0x00, 0x5b, 0x6e, 0xe0, - 0x65, 0xfb, 0xa0, 0xad, 0x6d, 0x87, 0xb3, 0x3b, 0xc0, 0xcd, 0x1e, 0x9d, 0xf5, 0xb1, 0x30, 0xd4, - 0x53, 0x61, 0xa8, 0xbf, 0x0b, 0x43, 0xfd, 0x71, 0x36, 0x94, 0xd3, 0xd9, 0x50, 0x7e, 0x9d, 0x0d, - 0xe5, 0xf3, 0xdb, 0x60, 0x97, 0x7e, 0xdd, 0x7b, 0xf6, 0x96, 0x45, 0xb8, 0x16, 0x8f, 0x43, 0xe2, - 0x89, 0xe6, 0x03, 0x67, 0xaf, 0xf1, 0xe1, 0xf6, 0x5b, 0xf4, 0x34, 0xf9, 0xbc, 0x66, 0x7f, 0x02, - 0x00, 0x00, 0xff, 0xff, 0xff, 0xae, 0x1d, 0x7d, 0x0f, 0x03, 0x00, 0x00, + // 408 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00,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5a, 0x4b, 0x1a, 0xa2, 0xa3, 0x71, 0x3f, 0xc0, 0x2e, 0xaf, 0x3e, 0x50, + 0xfa, 0x13, 0x6d, 0xce, 0xaf, 0x9a, 0xab, 0x88, 0xf5, 0x1a, 0x3d, 0x05, 0x00, 0x00, 0xff, 0xff, + 0x66, 0xb1, 0xa1, 0xc1, 0xee, 0x02, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -534,7 +533,7 @@ func (m *MsgCreateBalancerPool) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.PoolAssets = append(m.PoolAssets, types.PoolAsset{}) + m.PoolAssets = append(m.PoolAssets, PoolAsset{}) if err := m.PoolAssets[len(m.PoolAssets)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } diff --git a/x/gamm/simulation/operations.go b/x/gamm/simulation/operations.go index b66177b041b..6dbbbb01a13 100644 --- a/x/gamm/simulation/operations.go +++ b/x/gamm/simulation/operations.go @@ -84,23 +84,23 @@ func genFuturePoolGovernor(r *rand.Rand, addr sdk.Address, tokenList []string) s } } -func genPoolAssets(r *rand.Rand, acct simtypes.Account, coins sdk.Coins) []types.PoolAsset { +func genPoolAssets(r *rand.Rand, acct simtypes.Account, coins sdk.Coins) []balancer.PoolAsset { // selecting random number between [2, Min(coins.Len, 6)] numCoins := 2 + r.Intn(Min(coins.Len(), 6)-1) denomIndices := r.Perm(coins.Len()) - assets := []types.PoolAsset{} + assets := []balancer.PoolAsset{} for _, denomIndex := range denomIndices[:numCoins] { denom := coins[denomIndex].Denom amt, _ := simtypes.RandPositiveInt(r, coins[denomIndex].Amount.QuoRaw(100)) reserveAmt := sdk.NewCoin(denom, amt) weight := sdk.NewInt(r.Int63n(9) + 1) - assets = append(assets, types.PoolAsset{Token: reserveAmt, Weight: weight}) + assets = append(assets, balancer.PoolAsset{Token: reserveAmt, Weight: weight}) } return assets } -func genBalancerPoolParams(r *rand.Rand, blockTime time.Time, assets []types.PoolAsset) balancer.PoolParams { +func genBalancerPoolParams(r *rand.Rand, blockTime time.Time, assets []balancer.PoolAsset) balancer.PoolParams { // swapFeeInt := int64(r.Intn(1e5)) // swapFee := sdk.NewDecWithPrec(swapFeeInt, 6) @@ -167,7 +167,7 @@ func SimulateMsgCreateBalancerPool(ak stakingTypes.AccountKeeper, bk stakingType FuturePoolGovernor: "", } - spentCoins := types.PoolAssetsCoins(poolAssets) + spentCoins := balancer.PoolAssetsCoins(poolAssets) txGen := simappparams.MakeTestEncodingConfig().TxConfig return osmo_simulation.GenAndDeliverTxWithRandFees( diff --git a/x/gamm/types/events.go b/x/gamm/types/events.go index baed080cf77..e65c07f42d1 100644 --- a/x/gamm/types/events.go +++ b/x/gamm/types/events.go @@ -1,5 +1,11 @@ package types +import ( + "strconv" + + sdk "github.com/cosmos/cosmos-sdk/types" +) + const ( TypeEvtPoolJoined = "pool_joined" TypeEvtPoolExited = "pool_exited" @@ -12,3 +18,34 @@ const ( AttributeKeyTokensIn = "tokens_in" AttributeKeyTokensOut = "tokens_out" ) + +func CreateSwapEvent(ctx sdk.Context, sender sdk.AccAddress, poolId uint64, input sdk.Coins, output sdk.Coins) sdk.Event { + return sdk.NewEvent( + TypeEvtTokenSwapped, + sdk.NewAttribute(sdk.AttributeKeyModule, AttributeValueCategory), + sdk.NewAttribute(sdk.AttributeKeySender, sender.String()), + sdk.NewAttribute(AttributeKeyPoolId, strconv.FormatUint(poolId, 10)), + sdk.NewAttribute(AttributeKeyTokensIn, input.String()), + sdk.NewAttribute(AttributeKeyTokensOut, output.String()), + ) +} + +func CreateAddLiquidityEvent(ctx sdk.Context, sender sdk.AccAddress, poolId uint64, liquidity sdk.Coins) sdk.Event { + return sdk.NewEvent( + TypeEvtPoolJoined, + sdk.NewAttribute(sdk.AttributeKeyModule, AttributeValueCategory), + sdk.NewAttribute(sdk.AttributeKeySender, sender.String()), + sdk.NewAttribute(AttributeKeyPoolId, strconv.FormatUint(poolId, 10)), + sdk.NewAttribute(AttributeKeyTokensIn, liquidity.String()), + ) +} + +func CreateRemoveLiquidityEvent(ctx sdk.Context, sender sdk.AccAddress, poolId uint64, liquidity sdk.Coins) sdk.Event { + return sdk.NewEvent( + TypeEvtPoolExited, + sdk.NewAttribute(sdk.AttributeKeyModule, AttributeValueCategory), + sdk.NewAttribute(sdk.AttributeKeySender, sender.String()), + sdk.NewAttribute(AttributeKeyPoolId, strconv.FormatUint(poolId, 10)), + sdk.NewAttribute(AttributeKeyTokensOut, liquidity.String()), + ) +} diff --git a/x/gamm/types/pool.go b/x/gamm/types/pool.go index 96bc7692de2..c8d6caa985d 100644 --- a/x/gamm/types/pool.go +++ b/x/gamm/types/pool.go @@ -4,7 +4,6 @@ import ( "time" sdk "github.com/cosmos/cosmos-sdk/types" - sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" proto "github.com/gogo/protobuf/proto" "github.com/osmosis-labs/osmosis/v7/v043_temp/address" ) @@ -36,7 +35,6 @@ type PoolI interface { // expected to Set the pool into state as well. ApplySwap(ctx sdk.Context, tokenIn sdk.Coins, tokenOut sdk.Coins) error - // TODO: Swap base and quote asset around, so that it makes more sense later SpotPrice(ctx sdk.Context, baseAssetDenom string, quoteAssetDenom string) (sdk.Dec, error) // JoinPool joins the pool, and uses all of the tokensIn provided. @@ -47,53 +45,7 @@ type PoolI interface { ExitPool(ctx sdk.Context, numShares sdk.Int, exitFee sdk.Dec) (exitedCoins sdk.Coins, err error) } -// LegacyPoolI defines an interface for pools that hold tokens. -type LegacyPoolI interface { - proto.Message - - GetAddress() sdk.AccAddress - String() string - - GetId() uint64 - GetPoolSwapFee() sdk.Dec - GetPoolExitFee() sdk.Dec - GetTotalWeight() sdk.Int - GetTotalShares() sdk.Coin - AddTotalShares(amt sdk.Int) - SubTotalShares(amt sdk.Int) - GetPoolAsset(denom string) (PoolAsset, error) - // UpdatePoolAssetBalance updates the balances for - // the token with denomination coin.denom - UpdatePoolAssetBalance(coin sdk.Coin) error - // UpdatePoolAssetBalances calls UpdatePoolAssetBalance - // on each constituent coin. - UpdatePoolAssetBalances(coins sdk.Coins) error - GetPoolAssets(denoms ...string) ([]PoolAsset, error) - GetAllPoolAssets() []PoolAsset - PokeTokenWeights(blockTime time.Time) - GetTokenWeight(denom string) (sdk.Int, error) - GetTokenBalance(denom string) (sdk.Int, error) - NumAssets() int - IsActive(curBlockTime time.Time) bool -} - -var ( - MaxUserSpecifiedWeight sdk.Int = sdk.NewIntFromUint64(1 << 20) - GuaranteedWeightPrecision int64 = 1 << 30 -) - func NewPoolAddress(poolId uint64) sdk.AccAddress { key := append([]byte("pool"), sdk.Uint64ToBigEndian(poolId)...) return address.Module(ModuleName, key) } - -func ValidateUserSpecifiedWeight(weight sdk.Int) error { - if !weight.IsPositive() { - return sdkerrors.Wrap(ErrNotPositiveWeight, weight.String()) - } - - if weight.GTE(MaxUserSpecifiedWeight) { - return sdkerrors.Wrap(ErrWeightTooLarge, weight.String()) - } - return nil -} diff --git a/x/gamm/types/pool.pb.go b/x/gamm/types/pool.pb.go deleted file mode 100644 index 68a46da3696..00000000000 --- a/x/gamm/types/pool.pb.go +++ /dev/null @@ -1,377 +0,0 @@ -// Code generated by protoc-gen-gogo. DO NOT EDIT. -// source: osmosis/gamm/v1beta1/pool.proto - -package types - -import ( - fmt "fmt" - github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types" - types "github.com/cosmos/cosmos-sdk/types" - _ "github.com/gogo/protobuf/gogoproto" - proto "github.com/gogo/protobuf/proto" - io "io" - math "math" - math_bits "math/bits" -) - -// Reference imports to suppress errors if they are not otherwise used. -var _ = proto.Marshal -var _ = fmt.Errorf -var _ = math.Inf - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the proto package it is being compiled against. -// A compilation error at this line likely means your copy of the -// proto package needs to be updated. -const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package - -type PoolAsset struct { - // Coins we are talking about, - // the denomination must be unique amongst all PoolAssets for this pool. - Token types.Coin `protobuf:"bytes,1,opt,name=token,proto3" json:"token" yaml:"token"` - // Weight that is not normalized. This weight must be less than 2^50 - Weight github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,2,opt,name=weight,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"weight" yaml:"weight"` -} - -func (m *PoolAsset) Reset() { *m = PoolAsset{} } -func (m *PoolAsset) String() string { return proto.CompactTextString(m) } -func (*PoolAsset) ProtoMessage() {} -func (*PoolAsset) Descriptor() ([]byte, []int) { - return fileDescriptor_e5ab9bc6d45f98ce, []int{0} -} -func (m *PoolAsset) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *PoolAsset) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_PoolAsset.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *PoolAsset) XXX_Merge(src proto.Message) { - xxx_messageInfo_PoolAsset.Merge(m, src) -} -func (m *PoolAsset) XXX_Size() int { - return m.Size() -} -func (m *PoolAsset) XXX_DiscardUnknown() { - xxx_messageInfo_PoolAsset.DiscardUnknown(m) -} - -var xxx_messageInfo_PoolAsset proto.InternalMessageInfo - -func (m *PoolAsset) GetToken() types.Coin { - if m != nil { - return m.Token - } - return types.Coin{} -} - -func init() { - proto.RegisterType((*PoolAsset)(nil), "osmosis.gamm.v1beta1.PoolAsset") -} - -func init() { proto.RegisterFile("osmosis/gamm/v1beta1/pool.proto", fileDescriptor_e5ab9bc6d45f98ce) } - -var fileDescriptor_e5ab9bc6d45f98ce = []byte{ - // 286 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0xcf, 0x2f, 0xce, 0xcd, - 0x2f, 0x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 0x7a, 0x9e, 0x79, 0x25, 0x9f, 0xee, 0xc9, 0xf3, - 0x42, 0x8c, 0x85, 0x98, 0xa2, 0x14, 0x04, 0x35, 0xce, 0xc9, 0xf3, 0xc4, 0x23, 0x39, 0xc6, 0x0b, - 0x8f, 0xe4, 0x18, 0x1f, 0x3c, 0x92, 0x63, 0x9c, 0xf0, 0x58, 0x8e, 0xe1, 0xc2, 0x63, 0x39, 0x86, - 0x1b, 0x8f, 0xe5, 0x18, 0xa2, 0xf4, 0x91, 0x8c, 0x86, 0x06, 0x8f, 0x6e, 0x4e, 0x62, 0x52, 0x31, - 0x8c, 0xa3, 0x5f, 0x66, 0xae, 0x5f, 0x01, 0x09, 0x51, 0xb0, 0x3d, 0x49, 0x6c, 0x60, 0xff, 0x1b, - 0x03, 0x02, 0x00, 0x00, 0xff, 0xff, 0x64, 0x99, 0x81, 0xef, 0x6e, 0x01, 0x00, 0x00, -} - -func (m *PoolAsset) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *PoolAsset) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *PoolAsset) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - { - size := m.Weight.Size() - i -= size - if _, err := m.Weight.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - i = encodeVarintPool(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x12 - { - size, err := m.Token.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintPool(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - return len(dAtA) - i, nil -} - -func encodeVarintPool(dAtA []byte, offset int, v uint64) int { - offset -= sovPool(v) - base := offset - for v >= 1<<7 { - dAtA[offset] = uint8(v&0x7f | 0x80) - v >>= 7 - offset++ - } - dAtA[offset] = uint8(v) - return base -} -func (m *PoolAsset) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = m.Token.Size() - n += 1 + l + sovPool(uint64(l)) - l = m.Weight.Size() - n += 1 + l + sovPool(uint64(l)) - return n -} - -func sovPool(x uint64) (n int) { - return (math_bits.Len64(x|1) + 6) / 7 -} -func sozPool(x uint64) (n int) { - return sovPool(uint64((x << 1) ^ uint64((int64(x) >> 63)))) -} -func (m *PoolAsset) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowPool - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: PoolAsset: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: PoolAsset: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Token", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowPool - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthPool - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthPool - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.Token.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Weight", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowPool - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthPool - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthPool - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.Weight.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipPool(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthPool - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func skipPool(dAtA []byte) (n int, err error) { - l := len(dAtA) - iNdEx := 0 - depth := 0 - for iNdEx < l { - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowPool - } - if iNdEx >= l { - return 0, io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= (uint64(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - wireType := int(wire & 0x7) - switch wireType { - case 0: - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowPool - } - if iNdEx >= l { - return 0, io.ErrUnexpectedEOF - } - iNdEx++ - if dAtA[iNdEx-1] < 0x80 { - break - } - } - case 1: - iNdEx += 8 - case 2: - var length int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowPool - } - if iNdEx >= l { - return 0, io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - length |= (int(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - if length < 0 { - return 0, ErrInvalidLengthPool - } - iNdEx += length - case 3: - depth++ - case 4: - if depth == 0 { - return 0, ErrUnexpectedEndOfGroupPool - } - depth-- - case 5: - iNdEx += 4 - default: - return 0, fmt.Errorf("proto: illegal wireType %d", wireType) - } - if iNdEx < 0 { - return 0, ErrInvalidLengthPool - } - if depth == 0 { - return iNdEx, nil - } - } - return 0, io.ErrUnexpectedEOF -} - -var ( - ErrInvalidLengthPool = fmt.Errorf("proto: negative length found during unmarshaling") - ErrIntOverflowPool = fmt.Errorf("proto: integer overflow") - ErrUnexpectedEndOfGroupPool = fmt.Errorf("proto: unexpected end of group") -) diff --git a/x/gamm/types/query.pb.go b/x/gamm/types/query.pb.go index 0f15565e7c4..b4c0ee9317b 100644 --- a/x/gamm/types/query.pb.go +++ b/x/gamm/types/query.pb.go @@ -481,108 +481,18 @@ func (m *QueryTotalSharesResponse) GetTotalShares() types1.Coin { return types1.Coin{} } -//=============================== PoolAssets -type QueryPoolAssetsRequest struct { - PoolId uint64 `protobuf:"varint,1,opt,name=poolId,proto3" json:"poolId,omitempty" yaml:"pool_id"` -} - -func (m *QueryPoolAssetsRequest) Reset() { *m = QueryPoolAssetsRequest{} } -func (m *QueryPoolAssetsRequest) String() string { return proto.CompactTextString(m) } -func (*QueryPoolAssetsRequest) ProtoMessage() {} -func (*QueryPoolAssetsRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_d9a717df9ca609ef, []int{10} -} -func (m *QueryPoolAssetsRequest) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *QueryPoolAssetsRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_QueryPoolAssetsRequest.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *QueryPoolAssetsRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryPoolAssetsRequest.Merge(m, src) -} -func (m *QueryPoolAssetsRequest) XXX_Size() int { - return m.Size() -} -func (m *QueryPoolAssetsRequest) XXX_DiscardUnknown() { - xxx_messageInfo_QueryPoolAssetsRequest.DiscardUnknown(m) -} - -var xxx_messageInfo_QueryPoolAssetsRequest proto.InternalMessageInfo - -func (m *QueryPoolAssetsRequest) GetPoolId() uint64 { - if m != nil { - return m.PoolId - } - return 0 -} - -type QueryPoolAssetsResponse struct { - PoolAssets []PoolAsset `protobuf:"bytes,1,rep,name=poolAssets,proto3" json:"poolAssets"` -} - -func (m *QueryPoolAssetsResponse) Reset() { *m = QueryPoolAssetsResponse{} } -func (m *QueryPoolAssetsResponse) String() string { return proto.CompactTextString(m) } -func (*QueryPoolAssetsResponse) ProtoMessage() {} -func (*QueryPoolAssetsResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_d9a717df9ca609ef, []int{11} -} -func (m *QueryPoolAssetsResponse) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *QueryPoolAssetsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_QueryPoolAssetsResponse.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *QueryPoolAssetsResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryPoolAssetsResponse.Merge(m, src) -} -func (m *QueryPoolAssetsResponse) XXX_Size() int { - return m.Size() -} -func (m *QueryPoolAssetsResponse) XXX_DiscardUnknown() { - xxx_messageInfo_QueryPoolAssetsResponse.DiscardUnknown(m) -} - -var xxx_messageInfo_QueryPoolAssetsResponse proto.InternalMessageInfo - -func (m *QueryPoolAssetsResponse) GetPoolAssets() []PoolAsset { - if m != nil { - return m.PoolAssets - } - return nil -} - //=============================== SpotPrice type QuerySpotPriceRequest struct { PoolId uint64 `protobuf:"varint,1,opt,name=poolId,proto3" json:"poolId,omitempty" yaml:"pool_id"` TokenInDenom string `protobuf:"bytes,2,opt,name=tokenInDenom,proto3" json:"tokenInDenom,omitempty" yaml:"token_in_denom"` TokenOutDenom string `protobuf:"bytes,3,opt,name=tokenOutDenom,proto3" json:"tokenOutDenom,omitempty" yaml:"token_out_denom"` - WithSwapFee bool `protobuf:"varint,4,opt,name=withSwapFee,proto3" json:"withSwapFee,omitempty" yaml:"with_swap_fee"` } func (m *QuerySpotPriceRequest) Reset() { *m = QuerySpotPriceRequest{} } func (m *QuerySpotPriceRequest) String() string { return proto.CompactTextString(m) } func (*QuerySpotPriceRequest) ProtoMessage() {} func (*QuerySpotPriceRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_d9a717df9ca609ef, []int{12} + return fileDescriptor_d9a717df9ca609ef, []int{10} } func (m *QuerySpotPriceRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -632,13 +542,6 @@ func (m *QuerySpotPriceRequest) GetTokenOutDenom() string { return "" } -func (m *QuerySpotPriceRequest) GetWithSwapFee() bool { - if m != nil { - return m.WithSwapFee - } - return false -} - type QuerySpotPriceResponse struct { // String of the Dec. Ex) 10.203uatom SpotPrice string `protobuf:"bytes,1,opt,name=spotPrice,proto3" json:"spotPrice,omitempty" yaml:"spot_price"` @@ -648,7 +551,7 @@ func (m *QuerySpotPriceResponse) Reset() { *m = QuerySpotPriceResponse{} func (m *QuerySpotPriceResponse) String() string { return proto.CompactTextString(m) } func (*QuerySpotPriceResponse) ProtoMessage() {} func (*QuerySpotPriceResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_d9a717df9ca609ef, []int{13} + return fileDescriptor_d9a717df9ca609ef, []int{11} } func (m *QuerySpotPriceResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -696,7 +599,7 @@ func (m *QuerySwapExactAmountInRequest) Reset() { *m = QuerySwapExactAmo func (m *QuerySwapExactAmountInRequest) String() string { return proto.CompactTextString(m) } func (*QuerySwapExactAmountInRequest) ProtoMessage() {} func (*QuerySwapExactAmountInRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_d9a717df9ca609ef, []int{14} + return fileDescriptor_d9a717df9ca609ef, []int{12} } func (m *QuerySwapExactAmountInRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -761,7 +664,7 @@ func (m *QuerySwapExactAmountInResponse) Reset() { *m = QuerySwapExactAm func (m *QuerySwapExactAmountInResponse) String() string { return proto.CompactTextString(m) } func (*QuerySwapExactAmountInResponse) ProtoMessage() {} func (*QuerySwapExactAmountInResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_d9a717df9ca609ef, []int{15} + return fileDescriptor_d9a717df9ca609ef, []int{13} } func (m *QuerySwapExactAmountInResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -802,7 +705,7 @@ func (m *QuerySwapExactAmountOutRequest) Reset() { *m = QuerySwapExactAm func (m *QuerySwapExactAmountOutRequest) String() string { return proto.CompactTextString(m) } func (*QuerySwapExactAmountOutRequest) ProtoMessage() {} func (*QuerySwapExactAmountOutRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_d9a717df9ca609ef, []int{16} + return fileDescriptor_d9a717df9ca609ef, []int{14} } func (m *QuerySwapExactAmountOutRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -867,7 +770,7 @@ func (m *QuerySwapExactAmountOutResponse) Reset() { *m = QuerySwapExactA func (m *QuerySwapExactAmountOutResponse) String() string { return proto.CompactTextString(m) } func (*QuerySwapExactAmountOutResponse) ProtoMessage() {} func (*QuerySwapExactAmountOutResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_d9a717df9ca609ef, []int{17} + return fileDescriptor_d9a717df9ca609ef, []int{15} } func (m *QuerySwapExactAmountOutResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -903,7 +806,7 @@ func (m *QueryTotalLiquidityRequest) Reset() { *m = QueryTotalLiquidityR func (m *QueryTotalLiquidityRequest) String() string { return proto.CompactTextString(m) } func (*QueryTotalLiquidityRequest) ProtoMessage() {} func (*QueryTotalLiquidityRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_d9a717df9ca609ef, []int{18} + return fileDescriptor_d9a717df9ca609ef, []int{16} } func (m *QueryTotalLiquidityRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -940,7 +843,7 @@ func (m *QueryTotalLiquidityResponse) Reset() { *m = QueryTotalLiquidity func (m *QueryTotalLiquidityResponse) String() string { return proto.CompactTextString(m) } func (*QueryTotalLiquidityResponse) ProtoMessage() {} func (*QueryTotalLiquidityResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_d9a717df9ca609ef, []int{19} + return fileDescriptor_d9a717df9ca609ef, []int{17} } func (m *QueryTotalLiquidityResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -987,8 +890,6 @@ func init() { proto.RegisterType((*QueryPoolParamsResponse)(nil), "osmosis.gamm.v1beta1.QueryPoolParamsResponse") proto.RegisterType((*QueryTotalSharesRequest)(nil), "osmosis.gamm.v1beta1.QueryTotalSharesRequest") proto.RegisterType((*QueryTotalSharesResponse)(nil), "osmosis.gamm.v1beta1.QueryTotalSharesResponse") - proto.RegisterType((*QueryPoolAssetsRequest)(nil), "osmosis.gamm.v1beta1.QueryPoolAssetsRequest") - proto.RegisterType((*QueryPoolAssetsResponse)(nil), "osmosis.gamm.v1beta1.QueryPoolAssetsResponse") proto.RegisterType((*QuerySpotPriceRequest)(nil), "osmosis.gamm.v1beta1.QuerySpotPriceRequest") proto.RegisterType((*QuerySpotPriceResponse)(nil), "osmosis.gamm.v1beta1.QuerySpotPriceResponse") proto.RegisterType((*QuerySwapExactAmountInRequest)(nil), "osmosis.gamm.v1beta1.QuerySwapExactAmountInRequest") @@ -1002,90 +903,85 @@ func init() { func init() { proto.RegisterFile("osmosis/gamm/v1beta1/query.proto", fileDescriptor_d9a717df9ca609ef) } var fileDescriptor_d9a717df9ca609ef = []byte{ - // 1326 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x57, 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, 0x04, - 0x07, 0x5c, 0xdf, 0x9b, 0x20, 0x28, 0x68, 0x14, 0x67, 0x92, 0x9f, 0xfe, 0xd4, 0x56, 0x47, 0x68, - 0x2c, 0x28, 0xc2, 0xcd, 0xce, 0x8e, 0x17, 0xda, 0x87, 0xd1, 0x41, 0x49, 0x0f, 0x7f, 0x86, 0xe4, - 0xbb, 0xcf, 0x71, 0x9f, 0xcf, 0x68, 0xdf, 0xbc, 0xa2, 0xae, 0x0e, 0x07, 0x86, 0x4d, 0x92, 0xe7, - 0x1f, 0xfe, 0xf6, 0xf7, 0xa3, 0xe9, 0x33, 0xf8, 0x94, 0xd1, 0x77, 0x84, 0xe4, 0xf8, 0x4b, 0x05, - 0x1d, 0x8a, 0x66, 0x00, 0x7c, 0x76, 0x40, 0xed, 0xae, 0x01, 0x42, 0x3d, 0x37, 0x12, 0x16, 0xa8, - 0xac, 0x48, 0x2a, 0xcf, 0x61, 0xad, 0x37, 0x95, 0x78, 0xac, 0xc0, 0x3f, 0x28, 0xe8, 0x68, 0xda, - 0x33, 0x7c, 0x7e, 0xc0, 0x46, 0x3d, 0xdd, 0x57, 0xd7, 0xc7, 0xc8, 0x00, 0x82, 0x05, 0x49, 0x70, - 0x05, 0xbf, 0xd8, 0x9b, 0x60, 0xf8, 0x62, 0xc7, 0x06, 0xe2, 0x2f, 0x14, 0x34, 0x13, 0x74, 0x88, - 0x97, 0x87, 0xb8, 0x11, 0x51, 0x5a, 0x19, 0x8a, 0x03, 0x22, 0x6b, 0x92, 0xc8, 0x32, 0x7e, 0x61, - 0x80, 0x69, 0xc6, 0xa7, 0xe1, 0x1d, 0xf1, 0x00, 0x7f, 0xaf, 0x20, 0xd4, 0x19, 0x98, 0xf0, 0xda, - 0x90, 0x5d, 0x52, 0xd3, 0x99, 0x5a, 0x18, 0x11, 0x0d, 0xcc, 0x36, 0x24, 0xb3, 0x02, 0x3e, 0x37, - 0x0a, 0x33, 0x23, 0x1c, 0xc6, 0xf0, 0x8f, 0x0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a, 0x75, 0xab, 0xc2, 0xe3, - 0xfd, 0xee, 0xbd, 0x62, 0xdc, 0x0f, 0x37, 0x95, 0x0f, 0x5a, 0x65, 0x56, 0xfe, 0xe1, 0xb5, 0xf1, - 0x6f, 0x00, 0x00, 0x00, 0xff, 0xff, 0xae, 0x6a, 0x1e, 0x71, 0x09, 0x11, 0x00, 0x00, + // 1248 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x97, 0xc1, 0x6f, 0x1b, 0xc5, + 0x17, 0xc7, 0xb3, 0xa9, 0x93, 0x5f, 0x3d, 0xf9, 0x35, 0x24, 0xd3, 0x24, 0x75, 0x36, 0x8d, 0x37, + 0x0c, 0x90, 0x84, 0x34, 0xde, 0x6d, 0x1a, 0x2a, 0x04, 0xa2, 0x85, 0x9a, 0xa4, 0xad, 0x11, 0x90, + 0xb0, 0x41, 0x80, 0xe0, 0x60, 0xad, 0xe3, 0xc5, 0x59, 0xc5, 0xde, 0xd9, 0x78, 0x66, 0x9b, 0x58, + 0xa8, 0x42, 0xaa, 0xc4, 0x8d, 0x03, 0xa8, 0xdc, 0x40, 0x9c, 0x90, 0x90, 0x38, 0xf3, 0x47, 0x54, + 0x88, 0x43, 0x10, 0x07, 0x10, 0x07, 0x83, 0x12, 0xfe, 0x02, 0xdf, 0x91, 0xd0, 0xce, 0xbc, 0x5d, + 0xaf, 0x1d, 0xc7, 0x76, 0x22, 0x71, 0x4a, 0x76, 0xde, 0xf7, 0xbd, 0xf9, 0xbc, 0xf7, 0x76, 0xe7, + 0x8d, 0xd1, 0x1c, 0x65, 0x15, 0xca, 0x1c, 0x66, 0x94, 0xac, 0x4a, 0xc5, 0x78, 0xb0, 0x52, 0xb0, + 0xb9, 0xb5, 0x62, 0xec, 0xf9, 0x76, 0xb5, 0xa6, 0x7b, 0x55, 0xca, 0x29, 0x9e, 0x00, 0x85, 0x1e, + 0x28, 0x74, 0x50, 0xa8, 0x13, 0x25, 0x5a, 0xa2, 0x42, 0x60, 0x04, 0xff, 0x49, 0xad, 0x3a, 0xdb, + 0x31, 0x1a, 0x3f, 0x00, 0x73, 0x7a, 0x5b, 0xd8, 0x8d, 0x82, 0xc5, 0xec, 0xc8, 0xba, 0x4d, 0x1d, + 0x17, 0xec, 0x4b, 0x71, 0xbb, 0x60, 0x88, 0x54, 0x9e, 0x55, 0x72, 0x5c, 0x8b, 0x3b, 0x34, 0xd4, + 0x5e, 0x2d, 0x51, 0x5a, 0x2a, 0xdb, 0x86, 0xe5, 0x39, 0x86, 0xe5, 0xba, 0x94, 0x0b, 0x23, 0x03, + 0xeb, 0x34, 0x58, 0xc5, 0x53, 0xc1, 0xff, 0xd8, 0xb0, 0xdc, 0x5a, 0x68, 0x92, 0x9b, 0xe4, 0x25, + 0xbc, 0x7c, 0x90, 0x26, 0x72, 0x1b, 0x8d, 0xbd, 0x13, 0xec, 0xba, 0x49, 0x69, 0xd9, 0xb4, 0xf7, + 0x7c, 0x9b, 0x71, 0xbc, 0x84, 0x86, 0x3d, 0x4a, 0xcb, 0xb9, 0x62, 0x4a, 0x99, 0x53, 0x16, 0x13, + 0x59, 0xdc, 0xa8, 0x6b, 0xa3, 0x35, 0xab, 0x52, 0x7e, 0x99, 0x04, 0xeb, 0x79, 0xa7, 0x48, 0x4c, + 0x50, 0x90, 0xfb, 0x68, 0x3c, 0xe6, 0xcf, 0x3c, 0xea, 0x32, 0x1b, 0xaf, 0xa2, 0x44, 0x60, 0x16, + 0xee, 0x23, 0x37, 0x26, 0x74, 0x49, 0xa6, 0x87, 0x64, 0xfa, 0x1d, 0xb7, 0x96, 0x4d, 0xfe, 0xf4, + 0x63, 0x66, 0x28, 0xf0, 0xca, 0x99, 0x42, 0x4c, 0x3e, 0x8a, 0x45, 0x62, 0x21, 0xca, 0x5d, 0x84, + 0x9a, 0x65, 0x48, 0x0d, 0x8a, 0x78, 0xf3, 0x3a, 0x64, 0x10, 0xd4, 0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c3, 0x8c, 0xef, 0x1d, 0x76, 0x0f, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -1107,7 +1003,6 @@ type QueryClient interface { Pool(ctx context.Context, in *QueryPoolRequest, opts ...grpc.CallOption) (*QueryPoolResponse, error) PoolParams(ctx context.Context, in *QueryPoolParamsRequest, opts ...grpc.CallOption) (*QueryPoolParamsResponse, error) TotalShares(ctx context.Context, in *QueryTotalSharesRequest, opts ...grpc.CallOption) (*QueryTotalSharesResponse, error) - PoolAssets(ctx context.Context, in *QueryPoolAssetsRequest, opts ...grpc.CallOption) (*QueryPoolAssetsResponse, error) SpotPrice(ctx context.Context, in *QuerySpotPriceRequest, opts ...grpc.CallOption) (*QuerySpotPriceResponse, error) // Estimate the swap. EstimateSwapExactAmountIn(ctx context.Context, in *QuerySwapExactAmountInRequest, opts ...grpc.CallOption) (*QuerySwapExactAmountInResponse, error) @@ -1176,15 +1071,6 @@ func (c *queryClient) TotalShares(ctx context.Context, in *QueryTotalSharesReque return out, nil } -func (c *queryClient) PoolAssets(ctx context.Context, in *QueryPoolAssetsRequest, opts ...grpc.CallOption) (*QueryPoolAssetsResponse, error) { - out := new(QueryPoolAssetsResponse) - err := c.cc.Invoke(ctx, "/osmosis.gamm.v1beta1.Query/PoolAssets", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - func (c *queryClient) SpotPrice(ctx context.Context, in *QuerySpotPriceRequest, opts ...grpc.CallOption) (*QuerySpotPriceResponse, error) { out := new(QuerySpotPriceResponse) err := c.cc.Invoke(ctx, "/osmosis.gamm.v1beta1.Query/SpotPrice", in, out, opts...) @@ -1221,7 +1107,6 @@ type QueryServer interface { Pool(context.Context, *QueryPoolRequest) (*QueryPoolResponse, error) PoolParams(context.Context, *QueryPoolParamsRequest) (*QueryPoolParamsResponse, error) TotalShares(context.Context, *QueryTotalSharesRequest) (*QueryTotalSharesResponse, error) - PoolAssets(context.Context, *QueryPoolAssetsRequest) (*QueryPoolAssetsResponse, error) SpotPrice(context.Context, *QuerySpotPriceRequest) (*QuerySpotPriceResponse, error) // Estimate the swap. EstimateSwapExactAmountIn(context.Context, *QuerySwapExactAmountInRequest) (*QuerySwapExactAmountInResponse, error) @@ -1250,9 +1135,6 @@ func (*UnimplementedQueryServer) PoolParams(ctx context.Context, req *QueryPoolP func (*UnimplementedQueryServer) TotalShares(ctx context.Context, req *QueryTotalSharesRequest) (*QueryTotalSharesResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method TotalShares not implemented") } -func (*UnimplementedQueryServer) PoolAssets(ctx context.Context, req *QueryPoolAssetsRequest) (*QueryPoolAssetsResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method PoolAssets not implemented") -} func (*UnimplementedQueryServer) SpotPrice(ctx context.Context, req *QuerySpotPriceRequest) (*QuerySpotPriceResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method SpotPrice not implemented") } @@ -1375,24 +1257,6 @@ func _Query_TotalShares_Handler(srv interface{}, ctx context.Context, dec func(i return interceptor(ctx, in, info, handler) } -func _Query_PoolAssets_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(QueryPoolAssetsRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(QueryServer).PoolAssets(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/osmosis.gamm.v1beta1.Query/PoolAssets", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(QueryServer).PoolAssets(ctx, req.(*QueryPoolAssetsRequest)) - } - return interceptor(ctx, in, info, handler) -} - func _Query_SpotPrice_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(QuerySpotPriceRequest) if err := dec(in); err != nil { @@ -1475,10 +1339,6 @@ var _Query_serviceDesc = grpc.ServiceDesc{ MethodName: "TotalShares", Handler: _Query_TotalShares_Handler, }, - { - MethodName: "PoolAssets", - Handler: _Query_PoolAssets_Handler, - }, { MethodName: "SpotPrice", Handler: _Query_SpotPrice_Handler, @@ -1818,71 +1678,6 @@ func (m *QueryTotalSharesResponse) MarshalToSizedBuffer(dAtA []byte) (int, error return len(dAtA) - i, nil } -func (m *QueryPoolAssetsRequest) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *QueryPoolAssetsRequest) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *QueryPoolAssetsRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.PoolId != 0 { - i = encodeVarintQuery(dAtA, i, uint64(m.PoolId)) - i-- - dAtA[i] = 0x8 - } - return len(dAtA) - i, nil -} - -func (m *QueryPoolAssetsResponse) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *QueryPoolAssetsResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *QueryPoolAssetsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.PoolAssets) > 0 { - for iNdEx := len(m.PoolAssets) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.PoolAssets[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintQuery(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - } - } - return len(dAtA) - i, nil -} - func (m *QuerySpotPriceRequest) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) @@ -1903,16 +1698,6 @@ func (m *QuerySpotPriceRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l - if m.WithSwapFee { - i-- - if m.WithSwapFee { - dAtA[i] = 1 - } else { - dAtA[i] = 0 - } - i-- - dAtA[i] = 0x20 - } if len(m.TokenOutDenom) > 0 { i -= len(m.TokenOutDenom) copy(dAtA[i:], m.TokenOutDenom) @@ -2340,33 +2125,6 @@ func (m *QueryTotalSharesResponse) Size() (n int) { return n } -func (m *QueryPoolAssetsRequest) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.PoolId != 0 { - n += 1 + sovQuery(uint64(m.PoolId)) - } - return n -} - -func (m *QueryPoolAssetsResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if len(m.PoolAssets) > 0 { - for _, e := range m.PoolAssets { - l = e.Size() - n += 1 + l + sovQuery(uint64(l)) - } - } - return n -} - func (m *QuerySpotPriceRequest) Size() (n int) { if m == nil { return 0 @@ -2384,9 +2142,6 @@ func (m *QuerySpotPriceRequest) Size() (n int) { if l > 0 { n += 1 + l + sovQuery(uint64(l)) } - if m.WithSwapFee { - n += 2 - } return n } @@ -3294,159 +3049,6 @@ func (m *QueryTotalSharesResponse) Unmarshal(dAtA []byte) error { } return nil } -func (m *QueryPoolAssetsRequest) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: QueryPoolAssetsRequest: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: QueryPoolAssetsRequest: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field PoolId", wireType) - } - m.PoolId = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.PoolId |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - default: - iNdEx = preIndex - skippy, err := skipQuery(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthQuery - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *QueryPoolAssetsResponse) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: QueryPoolAssetsResponse: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: QueryPoolAssetsResponse: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field PoolAssets", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthQuery - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthQuery - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.PoolAssets = append(m.PoolAssets, PoolAsset{}) - if err := m.PoolAssets[len(m.PoolAssets)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipQuery(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthQuery - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} func (m *QuerySpotPriceRequest) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -3559,26 +3161,6 @@ func (m *QuerySpotPriceRequest) Unmarshal(dAtA []byte) error { } m.TokenOutDenom = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex - case 4: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field WithSwapFee", wireType) - } - var v int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - v |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - m.WithSwapFee = bool(v != 0) default: iNdEx = preIndex skippy, err := skipQuery(dAtA[iNdEx:]) diff --git a/x/gamm/types/query.pb.gw.go b/x/gamm/types/query.pb.gw.go index a33763ce2aa..a6f0b4b23f6 100644 --- a/x/gamm/types/query.pb.gw.go +++ b/x/gamm/types/query.pb.gw.go @@ -265,60 +265,6 @@ func local_request_Query_TotalShares_0(ctx context.Context, marshaler runtime.Ma } -func request_Query_PoolAssets_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryPoolAssetsRequest - var metadata runtime.ServerMetadata - - var ( - val string - ok bool - err error - _ = err - ) - - val, ok = pathParams["poolId"] - if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "poolId") - } - - protoReq.PoolId, err = runtime.Uint64(val) - - if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "poolId", err) - } - - msg, err := client.PoolAssets(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err - -} - -func local_request_Query_PoolAssets_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryPoolAssetsRequest - var metadata runtime.ServerMetadata - - var ( - val string - ok bool - err error - _ = err - ) - - val, ok = pathParams["poolId"] - if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "poolId") - } - - protoReq.PoolId, err = runtime.Uint64(val) - - if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "poolId", err) - } - - msg, err := server.PoolAssets(ctx, &protoReq) - return msg, metadata, err - -} - var ( filter_Query_SpotPrice_0 = &utilities.DoubleArray{Encoding: map[string]int{"poolId": 0}, Base: []int{1, 1, 0}, Check: []int{0, 1, 2}} ) @@ -661,26 +607,6 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv }) - mux.Handle("GET", pattern_Query_PoolAssets_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := local_request_Query_PoolAssets_0(rctx, inboundMarshaler, server, req, pathParams) - ctx = runtime.NewServerMetadataContext(ctx, md) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - - forward_Query_PoolAssets_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - mux.Handle("GET", pattern_Query_SpotPrice_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() @@ -902,26 +828,6 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie }) - mux.Handle("GET", pattern_Query_PoolAssets_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - rctx, err := runtime.AnnotateContext(ctx, mux, req) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := request_Query_PoolAssets_0(rctx, inboundMarshaler, client, req, pathParams) - ctx = runtime.NewServerMetadataContext(ctx, md) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - - forward_Query_PoolAssets_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - mux.Handle("GET", pattern_Query_SpotPrice_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() @@ -998,8 +904,6 @@ var ( pattern_Query_TotalShares_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4, 2, 5}, []string{"osmosis", "gamm", "v1beta1", "pools", "poolId", "total_shares"}, "", runtime.AssumeColonVerbOpt(true))) - pattern_Query_PoolAssets_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4, 2, 5}, []string{"osmosis", "gamm", "v1beta1", "pools", "poolId", "tokens"}, "", runtime.AssumeColonVerbOpt(true))) - pattern_Query_SpotPrice_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4, 2, 5}, []string{"osmosis", "gamm", "v1beta1", "pools", "poolId", "prices"}, "", runtime.AssumeColonVerbOpt(true))) pattern_Query_EstimateSwapExactAmountIn_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3, 2, 4, 2, 5}, []string{"osmosis", "gamm", "v1beta1", "poolId", "estimate", "swap_exact_amount_in"}, "", runtime.AssumeColonVerbOpt(true))) @@ -1020,8 +924,6 @@ var ( forward_Query_TotalShares_0 = runtime.ForwardResponseMessage - forward_Query_PoolAssets_0 = runtime.ForwardResponseMessage - forward_Query_SpotPrice_0 = runtime.ForwardResponseMessage forward_Query_EstimateSwapExactAmountIn_0 = runtime.ForwardResponseMessage diff --git a/x/gamm/types/tx.pb.go b/x/gamm/types/tx.pb.go index a46e8c10509..79ba0b422b3 100644 --- a/x/gamm/types/tx.pb.go +++ b/x/gamm/types/tx.pb.go @@ -31,6 +31,7 @@ var _ = math.Inf const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package // ===================== MsgJoinPool +// This is really MsgJoinPoolNoSwap type MsgJoinPool struct { Sender string `protobuf:"bytes,1,opt,name=sender,proto3" json:"sender,omitempty" yaml:"sender"` PoolId uint64 `protobuf:"varint,2,opt,name=poolId,proto3" json:"poolId,omitempty" yaml:"pool_id"` @@ -529,10 +530,13 @@ func (m *MsgSwapExactAmountOutResponse) XXX_DiscardUnknown() { var xxx_messageInfo_MsgSwapExactAmountOutResponse proto.InternalMessageInfo // ===================== MsgJoinSwapExternAmountIn +// TODO: Rename to MsgJoinSwapExactAmountIn type MsgJoinSwapExternAmountIn struct { - Sender string `protobuf:"bytes,1,opt,name=sender,proto3" json:"sender,omitempty" yaml:"sender"` - PoolId uint64 `protobuf:"varint,2,opt,name=poolId,proto3" json:"poolId,omitempty" yaml:"pool_id"` - TokenIn types.Coin `protobuf:"bytes,3,opt,name=tokenIn,proto3" json:"tokenIn" yaml:"token_in"` + Sender string `protobuf:"bytes,1,opt,name=sender,proto3" json:"sender,omitempty" yaml:"sender"` + PoolId uint64 `protobuf:"varint,2,opt,name=poolId,proto3" json:"poolId,omitempty" yaml:"pool_id"` + TokenIn types.Coin `protobuf:"bytes,3,opt,name=tokenIn,proto3" json:"tokenIn" yaml:"token_in"` + // reserved 3; + // reserved "token_in"; ShareOutMinAmount github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,4,opt,name=shareOutMinAmount,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"shareOutMinAmount" yaml:"share_out_min_amount"` } diff --git a/x/pool-incentives/keeper/keeper_test.go b/x/pool-incentives/keeper/keeper_test.go index f1bff7078b6..895d27e6848 100644 --- a/x/pool-incentives/keeper/keeper_test.go +++ b/x/pool-incentives/keeper/keeper_test.go @@ -62,7 +62,7 @@ func (suite *KeeperTestSuite) prepareBalancerPoolWithPoolParams(PoolParams balan } } - poolId, err := suite.app.GAMMKeeper.CreateBalancerPool(suite.ctx, acc1, PoolParams, []gammtypes.PoolAsset{ + poolId, err := suite.app.GAMMKeeper.CreateBalancerPool(suite.ctx, acc1, PoolParams, []balancer.PoolAsset{ { Weight: sdk.NewInt(100), Token: sdk.NewCoin("foo", sdk.NewInt(5000000)), diff --git a/x/superfluid/keeper/gov/gov_test.go b/x/superfluid/keeper/gov/gov_test.go index d0a0dd77c41..6fa7608ebbb 100644 --- a/x/superfluid/keeper/gov/gov_test.go +++ b/x/superfluid/keeper/gov/gov_test.go @@ -5,7 +5,6 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/osmosis-labs/osmosis/v7/x/gamm/pool-models/balancer" - gammtypes "github.com/osmosis-labs/osmosis/v7/x/gamm/types" minttypes "github.com/osmosis-labs/osmosis/v7/x/mint/types" "github.com/osmosis-labs/osmosis/v7/x/superfluid/keeper/gov" @@ -15,10 +14,10 @@ import ( func (suite *KeeperTestSuite) createGammPool(denoms []string) uint64 { coins := suite.app.GAMMKeeper.GetParams(suite.ctx).PoolCreationFee - poolAssets := []gammtypes.PoolAsset{} + poolAssets := []balancer.PoolAsset{} for _, denom := range denoms { coins = coins.Add(sdk.NewInt64Coin(denom, 1000000000000000000)) - poolAssets = append(poolAssets, gammtypes.PoolAsset{ + poolAssets = append(poolAssets, balancer.PoolAsset{ Weight: sdk.NewInt(100), Token: sdk.NewCoin(denom, sdk.NewInt(1000000000000000000)), }) diff --git a/x/superfluid/keeper/keeper_test.go b/x/superfluid/keeper/keeper_test.go index 22ff8b97659..06b551968e4 100644 --- a/x/superfluid/keeper/keeper_test.go +++ b/x/superfluid/keeper/keeper_test.go @@ -97,10 +97,10 @@ func CreateRandomAccounts(numAccts int) []sdk.AccAddress { func (suite *KeeperTestSuite) createGammPool(denoms []string) uint64 { coins := suite.App.GAMMKeeper.GetParams(suite.Ctx).PoolCreationFee - poolAssets := []gammtypes.PoolAsset{} + poolAssets := []balancer.PoolAsset{} for _, denom := range denoms { coins = coins.Add(sdk.NewInt64Coin(denom, 1000000000000000000)) - poolAssets = append(poolAssets, gammtypes.PoolAsset{ + poolAssets = append(poolAssets, balancer.PoolAsset{ Weight: sdk.NewInt(100), Token: sdk.NewCoin(denom, sdk.NewInt(1000000000000000000)), }) diff --git a/x/txfees/keeper/keeper_test.go b/x/txfees/keeper/keeper_test.go index 6643b41fdc2..12f9771e52e 100644 --- a/x/txfees/keeper/keeper_test.go +++ b/x/txfees/keeper/keeper_test.go @@ -14,8 +14,7 @@ import ( tmproto "github.com/tendermint/tendermint/proto/tendermint/types" "github.com/osmosis-labs/osmosis/v7/app" - balancertypes "github.com/osmosis-labs/osmosis/v7/x/gamm/pool-models/balancer" - gammtypes "github.com/osmosis-labs/osmosis/v7/x/gamm/types" + "github.com/osmosis-labs/osmosis/v7/x/gamm/pool-models/balancer" "github.com/osmosis-labs/osmosis/v7/x/txfees/types" ) @@ -83,7 +82,7 @@ func (suite *KeeperTestSuite) ExecuteUpgradeFeeTokenProposal(feeToken string, po func (suite *KeeperTestSuite) PreparePoolWithAssets(asset1, asset2 sdk.Coin) uint64 { return suite.preparePool( - []gammtypes.PoolAsset{ + []balancer.PoolAsset{ { Weight: sdk.NewInt(1), Token: asset1, @@ -96,11 +95,11 @@ func (suite *KeeperTestSuite) PreparePoolWithAssets(asset1, asset2 sdk.Coin) uin ) } -func (suite *KeeperTestSuite) preparePool(assets []gammtypes.PoolAsset) uint64 { +func (suite *KeeperTestSuite) preparePool(assets []balancer.PoolAsset) uint64 { suite.Require().Len(assets, 2) poolId, err := suite.app.GAMMKeeper.CreateBalancerPool(suite.ctx, acc1, - balancertypes.PoolParams{ + balancer.PoolParams{ SwapFee: sdk.NewDec(0), ExitFee: sdk.NewDec(0), }, assets, "")