From 584bd3d8ee6006f505ac968769d5416d5a83b537 Mon Sep 17 00:00:00 2001 From: Ehsan-saradar Date: Mon, 6 May 2024 14:07:00 +0330 Subject: [PATCH] Fix a possible bug --- x/liquidstake/keeper/rebalancing.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/x/liquidstake/keeper/rebalancing.go b/x/liquidstake/keeper/rebalancing.go index 27de57d4..fcc78385 100644 --- a/x/liquidstake/keeper/rebalancing.go +++ b/x/liquidstake/keeper/rebalancing.go @@ -262,7 +262,11 @@ func (k Keeper) AutocompoundStakingRewards(ctx sdk.Context, whitelistedValsMap t // subtract fee from accumulated rewards acRewards := k.GetAccumulatingRewards(ctx) - acRewards = acRewards.Sub(autocompoundFee.Amount) + if autocompoundFee.Amount.GTE(acRewards) { + acRewards = sdk.ZeroInt() + } else { + acRewards = acRewards.Sub(autocompoundFee.Amount) + } k.SetAccumulatingRewards(ctx, acRewards) ctx.EventManager().EmitEvents(sdk.Events{