Skip to content

Commit

Permalink
Merge pull request #288 from irisnet/fix-mt
Browse files Browse the repository at this point in the history
should be judged first
  • Loading branch information
aofengli authored Mar 10, 2022
2 parents e57d01c + 0837a95 commit 03a461a
Show file tree
Hide file tree
Showing 5 changed files with 273 additions and 262 deletions.
13 changes: 12 additions & 1 deletion modules/coinswap/simulation/operations.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,17 @@ func SimulateMsgAddLiquidity(k keeper.Keeper, ak types.AccountKeeper, bk types.B
if !maxToken.Amount.Sub(reservePool.AmountOf(maxToken.GetDenom()).Mul(exactStandardAmt).Quo(standardReserveAmt)).IsPositive() {
return simtypes.NoOpMsg(types.ModuleName, types.TypeMsgAddLiquidity, "insufficient funds"), nil, err
}

params := k.GetParams(ctx)
poolCreationFee := params.PoolCreationFee

spendTotal := poolCreationFee.Amount
if strings.EqualFold(poolCreationFee.Denom, standardDenom) {
spendTotal = spendTotal.Add(exactStandardAmt)
}
if spendable.AmountOf(poolCreationFee.Denom).LT(spendTotal) {
return simtypes.NoOpMsg(types.ModuleName, types.TypeMsgAddLiquidity, "insufficient funds"), nil, err
}
}

deadline := randDeadline(r)
Expand Down Expand Up @@ -433,7 +444,7 @@ func SimulateMsgRemoveLiquidity(k keeper.Keeper, ak types.AccountKeeper, bk type

func RandomSpendableToken(r *rand.Rand, spendableCoin sdk.Coins) sdk.Coin {
token := spendableCoin[r.Intn(len(spendableCoin))]
return sdk.NewCoin(token.Denom, simtypes.RandomAmount(r, token.Amount))
return sdk.NewCoin(token.Denom, simtypes.RandomAmount(r, token.Amount.QuoRaw(2)))
}

func RandomTotalToken(r *rand.Rand, coins sdk.Coins) sdk.Coin {
Expand Down
Loading

0 comments on commit 03a461a

Please sign in to comment.