Skip to content

Commit 1fbb3fd

Browse files
committed
fix for 0 truncate and divisible by 0
1 parent 8369f3c commit 1fbb3fd

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

x/masterchef/keeper/abci.go

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import (
2222
func (k Keeper) BeginBlocker(ctx sdk.Context) error {
2323
params := k.parameterKeeper.GetParams(ctx)
2424
// convert balances in taker address to elys and burn them
25-
if ctx.BlockHeight()%int64(params.TakerFeeCollectionInterval) == 0 && params.EnableTakerFeeSwap {
25+
if params.EnableTakerFeeSwap && params.TakerFeeCollectionInterval > 0 && ctx.BlockHeight()%int64(params.TakerFeeCollectionInterval) == 0 {
2626
k.ProcessTakerFee(ctx)
2727
}
2828
return nil
@@ -244,11 +244,14 @@ func (k Keeper) UpdateLPRewards(ctx sdk.Context) error {
244244
Quo(edenDenomPrice)
245245

246246
// Use min amount (eden allocation from tokenomics and max apr based eden amount)
247+
newEdenAllocatedForPoolAmount := newEdenAllocatedForPool.Dec().TruncateInt()
247248
if pool.EnableEdenRewards {
248249
newEdenAllocatedForPool = poolShareEdenEnable.Mul(osmomath.BigDecFromSDKInt(lpsEdenAmount))
249250
newEdenAllocatedForPool = osmomath.MinBigDec(newEdenAllocatedForPool, poolMaxEdenAmount)
250-
if newEdenAllocatedForPool.IsPositive() {
251-
err = k.commitmentKeeper.MintCoins(ctx, types.ModuleName, sdk.Coins{sdk.NewCoin(ptypes.Eden, newEdenAllocatedForPool.Dec().TruncateInt())})
251+
252+
newEdenAllocatedForPoolAmount = newEdenAllocatedForPool.Dec().TruncateInt()
253+
if newEdenAllocatedForPoolAmount.IsPositive() {
254+
err = k.commitmentKeeper.MintCoins(ctx, types.ModuleName, sdk.Coins{sdk.NewCoin(ptypes.Eden, newEdenAllocatedForPoolAmount)})
252255
if err != nil {
253256
return err
254257
}
@@ -270,8 +273,8 @@ func (k Keeper) UpdateLPRewards(ctx sdk.Context) error {
270273
k.AddEdenInfo(ctx, newEdenAllocatedForPool)
271274

272275
// Distribute Eden
273-
if pool.EnableEdenRewards {
274-
k.UpdateAccPerShare(ctx, pool.PoolId, ptypes.Eden, newEdenAllocatedForPool.Dec().TruncateInt())
276+
if pool.EnableEdenRewards && newEdenAllocatedForPoolAmount.IsPositive() {
277+
k.UpdateAccPerShare(ctx, pool.PoolId, ptypes.Eden, newEdenAllocatedForPoolAmount)
275278
}
276279
// Distribute Gas fees + Dex rewards (USDC)
277280
k.UpdateAccPerShare(ctx, pool.PoolId, k.GetBaseCurrencyDenom(ctx), gasRewardsAllocatedForPool.Add(dexRewardsAllocatedForPool).Dec().TruncateInt())

0 commit comments

Comments
 (0)