From a503451323bb773a139abc13062d3c45a46ed42f Mon Sep 17 00:00:00 2001 From: jelysn Date: Fri, 1 Sep 2023 10:58:07 +0800 Subject: [PATCH] Resolve unit test on add/remove liquidity on oracle pool, and add more case on join pool --- x/amm/keeper/msg_server_exit_pool_test.go | 8 ++++---- x/amm/keeper/msg_server_join_pool_test.go | 25 +++++++++++++++++++++-- 2 files changed, 27 insertions(+), 6 deletions(-) diff --git a/x/amm/keeper/msg_server_exit_pool_test.go b/x/amm/keeper/msg_server_exit_pool_test.go index 09eda173d..343eeda76 100644 --- a/x/amm/keeper/msg_server_exit_pool_test.go +++ b/x/amm/keeper/msg_server_exit_pool_test.go @@ -79,8 +79,8 @@ func (suite *KeeperTestSuite) TestMsgServerExitPool() { }, shareInAmount: types.OneShare.Quo(sdk.NewInt(10)), tokenOutDenom: "uusdt", - minAmountsOut: sdk.Coins{sdk.NewInt64Coin("uusdt", 97368)}, - expSenderBalance: sdk.Coins{sdk.NewInt64Coin("uusdt", 97368)}, + minAmountsOut: sdk.Coins{sdk.NewInt64Coin("uusdt", 95114)}, + expSenderBalance: sdk.Coins{sdk.NewInt64Coin("uusdt", 95114)}, expPass: true, }, { @@ -100,8 +100,8 @@ func (suite *KeeperTestSuite) TestMsgServerExitPool() { }, shareInAmount: types.OneShare.Quo(sdk.NewInt(10)), tokenOutDenom: "uusdc", - minAmountsOut: sdk.Coins{sdk.NewInt64Coin("uusdc", 100000)}, - expSenderBalance: sdk.Coins{sdk.NewInt64Coin("uusdc", 100000)}, + minAmountsOut: sdk.Coins{sdk.NewInt64Coin("uusdc", 99197)}, + expSenderBalance: sdk.Coins{sdk.NewInt64Coin("uusdc", 99197)}, expPass: true, }, } { diff --git a/x/amm/keeper/msg_server_join_pool_test.go b/x/amm/keeper/msg_server_join_pool_test.go index 42abae6f4..498189187 100644 --- a/x/amm/keeper/msg_server_join_pool_test.go +++ b/x/amm/keeper/msg_server_join_pool_test.go @@ -78,7 +78,7 @@ func (suite *KeeperTestSuite) TestMsgServerJoinPool() { ThresholdWeightDifference: sdk.NewDecWithPrec(2, 1), // 20% FeeDenom: "uusdc", }, - shareOutAmount: sdk.NewInt(833333333333333333), // weight breaking fee + shareOutAmount: sdk.NewInt(694444166666666666), // weight breaking fee expSenderBalance: sdk.Coins{}, expTokenIn: sdk.Coins{sdk.NewInt64Coin("uusdt", 1000000)}, expPass: true, @@ -99,11 +99,32 @@ func (suite *KeeperTestSuite) TestMsgServerJoinPool() { ThresholdWeightDifference: sdk.NewDecWithPrec(2, 1), // 20% FeeDenom: "uusdc", }, - shareOutAmount: sdk.NewInt(1250000000000000000), // weight breaking fee + shareOutAmount: sdk.NewInt(805987500000000000), // weight recovery direction expSenderBalance: sdk.Coins{}, expTokenIn: sdk.Coins{sdk.NewInt64Coin("uusdt", 1000000)}, expPass: true, }, + { + desc: "oracle pool join - zero slippage add liquidity", + senderInitBalance: sdk.Coins{sdk.NewInt64Coin("uusdc", 1500000), sdk.NewInt64Coin("uusdt", 500000)}, + poolInitBalance: sdk.Coins{sdk.NewInt64Coin("uusdc", 1500000), sdk.NewInt64Coin("uusdt", 500000)}, + poolParams: types.PoolParams{ + SwapFee: sdk.ZeroDec(), + ExitFee: sdk.ZeroDec(), + UseOracle: true, + WeightBreakingFeeMultiplier: sdk.NewDecWithPrec(1, 0), // 1.00 + ExternalLiquidityRatio: sdk.NewDec(1), + LpFeePortion: sdk.ZeroDec(), + StakingFeePortion: sdk.ZeroDec(), + WeightRecoveryFeePortion: sdk.ZeroDec(), + ThresholdWeightDifference: sdk.NewDecWithPrec(2, 1), // 20% + FeeDenom: "uusdc", + }, + shareOutAmount: sdk.NewInt(2000000000000000000), + expSenderBalance: sdk.Coins{}, + expTokenIn: sdk.Coins{sdk.NewInt64Coin("uusdc", 1500000), sdk.NewInt64Coin("uusdt", 500000)}, + expPass: true, + }, } { suite.Run(tc.desc, func() { suite.SetupTest()