diff --git a/modules/apps/101-interchain-swap/keeper/msg_server_multi_asset_withdraw.go b/modules/apps/101-interchain-swap/keeper/msg_server_multi_asset_withdraw.go index 5abe4bc8..a19196b9 100644 --- a/modules/apps/101-interchain-swap/keeper/msg_server_multi_asset_withdraw.go +++ b/modules/apps/101-interchain-swap/keeper/msg_server_multi_asset_withdraw.go @@ -21,6 +21,11 @@ func (k msgServer) MultiAssetWithdraw(goCtx context.Context, msg *types.MsgMulti return nil, errorsmod.Wrapf(types.ErrFailedDeposit, "invalid denom in local withdraw message:%s", msg.PoolToken.Denom) } + tokenBalance := k.bankKeeper.GetBalance(ctx, sdk.AccAddress(msg.Receiver), msg.PoolId) + if tokenBalance.Amount.LT(msg.PoolToken.Amount) { + return nil, errorsmod.Wrapf(types.ErrFailedDeposit, "sender don't have enough pool token amount:%s", msg.PoolToken.Amount) + } + // PoolCoin.Denom is just poolID. pool, found := k.GetInterchainLiquidityPool(ctx, msg.PoolToken.Denom) diff --git a/modules/apps/101-interchain-swap/types/market_test.go b/modules/apps/101-interchain-swap/types/market_test.go index f83070e6..393f8ac4 100644 --- a/modules/apps/101-interchain-swap/types/market_test.go +++ b/modules/apps/101-interchain-swap/types/market_test.go @@ -229,8 +229,8 @@ func TestSingleDeposit(t *testing.T) { // } func TestSwap(t *testing.T) { - const initialX = 4000000 // USDT - const initialY = 2000 // ETH + const initialX = 550000000000 // USDT + const initialY = 550000000000 // ETH // create mock pool denoms := []string{"a", "b"} poolId := GetPoolId("test", "test", denoms) @@ -274,7 +274,7 @@ func TestSwap(t *testing.T) { ) out, err := amm.LeftSwap(types.Coin{ Denom: denoms[0], - Amount: types.NewInt(100), + Amount: types.NewInt(5000), }, denoms[1])