Skip to content

Commit

Permalink
fix: add liquidity operation
Browse files Browse the repository at this point in the history
  • Loading branch information
poorphd committed Jul 26, 2024
1 parent 096d7d1 commit 332ff06
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions x/coinswap/simulation/operation.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,14 @@ func SimulateMsgAddLiquidity(k keeper.Keeper, ak types.AccountKeeper, bk types.B
"standardAmount should be positive",
), nil, nil
}
params := k.GetParams(ctx)
if exactStandardAmt.GTE(params.MaxStandardCoinPerPool) {
return simtypes.NoOpMsg(
types.ModuleName,
TypeMsgAddLiquidity,
"standardAmount should be less than MaxStandardCoinPerPool",
), nil, nil
}

maxToken, err = randToken(r, spendable)
if err != nil {
Expand Down Expand Up @@ -148,6 +156,25 @@ func SimulateMsgAddLiquidity(k keeper.Keeper, ak types.AccountKeeper, bk types.B
), nil, err
}

// check maxToken is registered in MaxSwapAmount
found := func(denom string) bool {
MaxSwapAmount := params.MaxSwapAmount
for _, coin := range MaxSwapAmount {
if coin.Denom == denom {
return true
}
}
return false
}(maxToken.Denom)

if !found {
return simtypes.NoOpMsg(
types.ModuleName,
TypeMsgAddLiquidity,
"maxToken is not registered in MaxSwapAmount",
), nil, err
}

poolID := types.GetPoolId(maxToken.Denom)
pool, has := k.GetPool(ctx, poolID)
if !has {
Expand Down

0 comments on commit 332ff06

Please sign in to comment.