From e8966c232c50a2eb068409afe6172e643d8ae934 Mon Sep 17 00:00:00 2001 From: Roman Date: Fri, 15 Apr 2022 12:37:06 -0400 Subject: [PATCH] rename to ExitSwapExactAmountOutExtension --- x/gamm/client/cli/cli_test.go | 108 +++++++++---------- x/gamm/keeper/msg_server.go | 2 +- x/gamm/keeper/pool_service.go | 6 +- x/gamm/keeper/pool_service_test.go | 2 +- x/gamm/pool-models/balancer/amm.go | 2 +- x/gamm/pool-models/balancer/balancer_pool.go | 2 +- x/gamm/types/pool.go | 10 +- 7 files changed, 66 insertions(+), 66 deletions(-) diff --git a/x/gamm/client/cli/cli_test.go b/x/gamm/client/cli/cli_test.go index e001dbd5a35..ed28b36706c 100644 --- a/x/gamm/client/cli/cli_test.go +++ b/x/gamm/client/cli/cli_test.go @@ -1069,69 +1069,69 @@ func (s *IntegrationTestSuite) TestGetCmdSpotPrice() { // } // } -func (s IntegrationTestSuite) TestNewSwapExactAmountInCmd() { - val := s.network.Validators[0] +// func (s IntegrationTestSuite) TestNewSwapExactAmountInCmd() { +// val := s.network.Validators[0] - info, _, err := val.ClientCtx.Keyring.NewMnemonic("NewSwapExactAmountIn", - keyring.English, sdk.FullFundraiserPath, keyring.DefaultBIP39Passphrase, hd.Secp256k1) - s.Require().NoError(err) +// info, _, err := val.ClientCtx.Keyring.NewMnemonic("NewSwapExactAmountIn", +// keyring.English, sdk.FullFundraiserPath, keyring.DefaultBIP39Passphrase, hd.Secp256k1) +// s.Require().NoError(err) - newAddr := sdk.AccAddress(info.GetPubKey().Address()) +// newAddr := sdk.AccAddress(info.GetPubKey().Address()) - _, err = banktestutil.MsgSendExec( - val.ClientCtx, - val.Address, - newAddr, - sdk.NewCoins(sdk.NewInt64Coin(s.cfg.BondDenom, 20000), sdk.NewInt64Coin("node0token", 20000)), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), - fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - osmoutils.DefaultFeeString(s.cfg), - ) - s.Require().NoError(err) +// _, err = banktestutil.MsgSendExec( +// val.ClientCtx, +// val.Address, +// newAddr, +// sdk.NewCoins(sdk.NewInt64Coin(s.cfg.BondDenom, 20000), sdk.NewInt64Coin("node0token", 20000)), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), +// fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), +// osmoutils.DefaultFeeString(s.cfg), +// ) +// s.Require().NoError(err) - testCases := []struct { - name string - args []string +// testCases := []struct { +// name string +// args []string - expectErr bool - respType proto.Message - expectedCode uint32 - }{ - { - "swap exact amount in", // osmosisd tx gamm swap-exact-amount-in 10stake 3 --swap-route-pool-ids=1 --swap-route-denoms=node0token --from=validator --keyring-backend=test --chain-id=testing --yes - []string{ - "10stake", "3", - fmt.Sprintf("--%s=%d", cli.FlagSwapRoutePoolIds, 1), - fmt.Sprintf("--%s=%s", cli.FlagSwapRouteDenoms, "node0token"), - fmt.Sprintf("--%s=%s", flags.FlagFrom, newAddr), - // common args - fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), - fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(10))).String()), - }, - false, &sdk.TxResponse{}, 0, - }, - } +// expectErr bool +// respType proto.Message +// expectedCode uint32 +// }{ +// { +// "swap exact amount in", // osmosisd tx gamm swap-exact-amount-in 10stake 3 --swap-route-pool-ids=1 --swap-route-denoms=node0token --from=validator --keyring-backend=test --chain-id=testing --yes +// []string{ +// "10stake", "3", +// fmt.Sprintf("--%s=%d", cli.FlagSwapRoutePoolIds, 1), +// fmt.Sprintf("--%s=%s", cli.FlagSwapRouteDenoms, "node0token"), +// fmt.Sprintf("--%s=%s", flags.FlagFrom, newAddr), +// // common args +// fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), +// fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), +// fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(10))).String()), +// }, +// false, &sdk.TxResponse{}, 0, +// }, +// } - for _, tc := range testCases { - tc := tc +// for _, tc := range testCases { +// tc := tc - s.Run(tc.name, func() { - cmd := cli.NewSwapExactAmountInCmd() - clientCtx := val.ClientCtx +// s.Run(tc.name, func() { +// cmd := cli.NewSwapExactAmountInCmd() +// clientCtx := val.ClientCtx - out, err := clitestutil.ExecTestCLICmd(clientCtx, cmd, tc.args) - if tc.expectErr { - s.Require().Error(err) - } else { - s.Require().NoError(err, out.String()) - s.Require().NoError(clientCtx.Codec.UnmarshalJSON(out.Bytes(), tc.respType), out.String()) +// out, err := clitestutil.ExecTestCLICmd(clientCtx, cmd, tc.args) +// if tc.expectErr { +// s.Require().Error(err) +// } else { +// s.Require().NoError(err, out.String()) +// s.Require().NoError(clientCtx.Codec.UnmarshalJSON(out.Bytes(), tc.respType), out.String()) - txResp := tc.respType.(*sdk.TxResponse) - s.Require().Equal(tc.expectedCode, txResp.Code, out.String()) - } - }) - } -} +// txResp := tc.respType.(*sdk.TxResponse) +// s.Require().Equal(tc.expectedCode, txResp.Code, out.String()) +// } +// }) +// } +// } func TestIntegrationTestSuite(t *testing.T) { suite.Run(t, new(IntegrationTestSuite)) diff --git a/x/gamm/keeper/msg_server.go b/x/gamm/keeper/msg_server.go index fb4749eaa90..ccf32342cf5 100644 --- a/x/gamm/keeper/msg_server.go +++ b/x/gamm/keeper/msg_server.go @@ -224,7 +224,7 @@ func (server msgServer) ExitSwapExternAmountOut(goCtx context.Context, msg *type return nil, err } - shareInAmount, err := server.keeper.ExitSwapExternAmountOut(ctx, sender, msg.PoolId, msg.TokenOut, msg.ShareInMaxAmount) + shareInAmount, err := server.keeper.ExitSwapExactAmountOut(ctx, sender, msg.PoolId, msg.TokenOut, msg.ShareInMaxAmount) if err != nil { return nil, err } diff --git a/x/gamm/keeper/pool_service.go b/x/gamm/keeper/pool_service.go index 99f8b84faeb..cb6e4e20458 100644 --- a/x/gamm/keeper/pool_service.go +++ b/x/gamm/keeper/pool_service.go @@ -395,7 +395,7 @@ func (k Keeper) ExitSwapShareAmountIn( return tokenOutAmount, nil } -func (k Keeper) ExitSwapExternAmountOut( +func (k Keeper) ExitSwapExactAmountOut( ctx sdk.Context, sender sdk.AccAddress, poolId uint64, @@ -407,12 +407,12 @@ func (k Keeper) ExitSwapExternAmountOut( return sdk.Int{}, err } - extendedPool, ok := pool.(types.PoolExitSwapExternAmountOutExtension) + extendedPool, ok := pool.(types.PoolExitSwapExactAmountOutExtension) if !ok { return sdk.Int{}, fmt.Errorf("pool with id %d does not support this kind of exit", poolId) } - shareInAmount, err = extendedPool.ExitSwapExternAmountOut(ctx, tokenOut, shareInMaxAmount) + shareInAmount, err = extendedPool.ExitSwapExactAmountOut(ctx, tokenOut, shareInMaxAmount) 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 e9dbdf7a446..63b49d28309 100644 --- a/x/gamm/keeper/pool_service_test.go +++ b/x/gamm/keeper/pool_service_test.go @@ -490,7 +490,7 @@ func (suite *KeeperTestSuite) TestActiveBalancerPool() { suite.Require().Error(err) _, err = suite.app.GAMMKeeper.ExitSwapShareAmountIn(suite.ctx, acc1, poolId, "foo", types.OneShare.MulRaw(10), sdk.ZeroInt()) suite.Require().Error(err) - _, err = suite.app.GAMMKeeper.ExitSwapExternAmountOut(suite.ctx, acc1, poolId, foocoin, sdk.NewInt(1000000000000000000)) + _, err = suite.app.GAMMKeeper.ExitSwapExactAmountOut(suite.ctx, acc1, poolId, foocoin, sdk.NewInt(1000000000000000000)) suite.Require().Error(err) } } diff --git a/x/gamm/pool-models/balancer/amm.go b/x/gamm/pool-models/balancer/amm.go index f86e14d0430..756a744b814 100644 --- a/x/gamm/pool-models/balancer/amm.go +++ b/x/gamm/pool-models/balancer/amm.go @@ -412,7 +412,7 @@ func calcPoolSharesInGivenSingleAssetOut( return sharesInFeeIncluded } -func (p *Pool) ExitSwapExternAmountOut( +func (p *Pool) ExitSwapExactAmountOut( ctx sdk.Context, tokenOut sdk.Coin, shareInMaxAmount sdk.Int, diff --git a/x/gamm/pool-models/balancer/balancer_pool.go b/x/gamm/pool-models/balancer/balancer_pool.go index c822030c5b7..7f2e08e7253 100644 --- a/x/gamm/pool-models/balancer/balancer_pool.go +++ b/x/gamm/pool-models/balancer/balancer_pool.go @@ -15,7 +15,7 @@ import ( var ( _ types.PoolI = &Pool{} - _ types.PoolExitSwapExternAmountOutExtension = &Pool{} + _ types.PoolExitSwapExactAmountOutExtension = &Pool{} ) // NewPool returns a weighted CPMM pool with the provided parameters, and initial assets. diff --git a/x/gamm/types/pool.go b/x/gamm/types/pool.go index d2ff46bea08..2a7b8dc0c5b 100644 --- a/x/gamm/types/pool.go +++ b/x/gamm/types/pool.go @@ -75,16 +75,16 @@ type PoolI interface { PokePool(blockTime time.Time) } -// PoolExitSwapExternAmountOutExtension is an extension of the PoolI +// PoolExitSwapExactAmountOutExtension is an extension of the PoolI // interface definiting an abstraction for pools that hold tokens. -// In addition, it supports ExitSwapExternAmountOut method. +// In addition, it supports ExitSwapExactAmountOut method. // See definition below. -type PoolExitSwapExternAmountOutExtension interface { +type PoolExitSwapExactAmountOutExtension interface { PoolI - // ExitSwapExternAmountOut removes liquidity from a specified pool with a maximum amount of LP shares (shareInMaxAmount) + // ExitSwapExactAmountOut removes liquidity from a specified pool with a maximum amount of LP shares (shareInMaxAmount) // and swaps to an exact amount of one of the token pairs (tokenOut) - ExitSwapExternAmountOut( + ExitSwapExactAmountOut( ctx sdk.Context, tokenOut sdk.Coin, shareInMaxAmount sdk.Int,