Skip to content

Commit

Permalink
Resolve unit test on add/remove liquidity on oracle pool, and add mor…
Browse files Browse the repository at this point in the history
…e case on join pool
  • Loading branch information
jelysn committed Sep 1, 2023
1 parent a0b3d35 commit a503451
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 6 deletions.
8 changes: 4 additions & 4 deletions x/amm/keeper/msg_server_exit_pool_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
{
Expand All @@ -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,
},
} {
Expand Down
25 changes: 23 additions & 2 deletions x/amm/keeper/msg_server_join_pool_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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()
Expand Down

0 comments on commit a503451

Please sign in to comment.