diff --git a/CHANGELOG.md b/CHANGELOG.md index 405f64acb73..318d638e2d6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -64,6 +64,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 * [#1539] Superfluid: Combine superfluid and staking query on querying delegation by delegator ### Bug Fixes + +* [1930](https://github.com/osmosis-labs/osmosis/pull/1930) Ensure you can't `JoinPoolNoSwap` tokens that are not in the pool * [1700](https://github.com/osmosis-labs/osmosis/pull/1700) Upgrade sdk fork with missing snapshot manager fix. * [1716](https://github.com/osmosis-labs/osmosis/pull/1716) Fix secondary over-LP shares bug with uneven swap amounts in `CalcJoinPoolShares`. * [1759](https://github.com/osmosis-labs/osmosis/pull/1759) Fix pagination filter in incentives query. diff --git a/x/gamm/keeper/pool_service.go b/x/gamm/keeper/pool_service.go index d8e82c3bc55..094eea0f4a5 100644 --- a/x/gamm/keeper/pool_service.go +++ b/x/gamm/keeper/pool_service.go @@ -203,6 +203,9 @@ func (k Keeper) JoinPoolNoSwap( if !(neededLpLiquidity.DenomsSubsetOf(tokenInMaxs) && tokenInMaxs.IsAllGTE(neededLpLiquidity)) { return sdkerrors.Wrapf(types.ErrLimitMaxAmount, "TokenInMaxs is less than the needed LP liquidity to this JoinPoolNoSwap,"+ " upperbound: %v, needed %v", tokenInMaxs, neededLpLiquidity) + } else if !(tokenInMaxs.DenomsSubsetOf(neededLpLiquidity)) { + return sdkerrors.Wrapf(types.ErrDenomNotFoundInPool, "TokenInMaxs includes tokens that are not part of the target pool,"+ + " input tokens: %v, pool tokens %v", tokenInMaxs, neededLpLiquidity) } } diff --git a/x/gamm/keeper/pool_service_test.go b/x/gamm/keeper/pool_service_test.go index e556754314f..850faa886aa 100644 --- a/x/gamm/keeper/pool_service_test.go +++ b/x/gamm/keeper/pool_service_test.go @@ -316,6 +316,18 @@ func (suite *KeeperTestSuite) TestJoinPoolNoSwap() { suite.Require().Equal("15000bar,15000foo", liquidity.String()) }, }, + { + fn: func(poolId uint64) { + keeper := suite.App.GAMMKeeper + // Test the "tokenInMaxs" with an additional invalid denom + // In this case, to get the 50 * OneShare amount of share token, the foo, bar token are expected to be provided as 5000 amounts. + // The test input has the correct amount for each, but also includes an incorrect denom that should cause an error + err := keeper.JoinPoolNoSwap(suite.Ctx, suite.TestAccs[1], poolId, types.OneShare.MulRaw(50), sdk.Coins{ + sdk.NewCoin("bar", sdk.NewInt(5000)), sdk.NewCoin("foo", sdk.NewInt(5000)), sdk.NewCoin("baz", sdk.NewInt(5000)), + }) + suite.Require().Error(err) + }, + }, } for _, test := range tests {