Skip to content

Commit

Permalink
fixed staking reward removal at last exit
Browse files Browse the repository at this point in the history
  • Loading branch information
faneaatiku committed Mar 26, 2024
1 parent 5366796 commit 7416b2d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
5 changes: 4 additions & 1 deletion x/rewards/keeper/msg_server_exit_staking.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,10 @@ func (k msgServer) ExitStaking(goCtx context.Context, msg *types.MsgExitStaking)
stakingReward.StakedAmount = remainingStakedAmount.String()
k.SetStakingReward(ctx, stakingReward)
} else {
k.RemoveStakingReward(ctx, stakingReward.RewardId)
//if this staking reward is finished (all funds were distributed and payouts executed) we should remove it
if stakingReward.Payouts >= stakingReward.Duration {
k.RemoveStakingReward(ctx, stakingReward.RewardId)
}
}

return &types.MsgExitStakingResponse{}, nil
Expand Down
2 changes: 1 addition & 1 deletion x/rewards/keeper/staking_reward_distribution.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ func (k Keeper) getDistributeRewardHandler() func(ctx sdk.Context, reward types.
err := k.distributeStakingRewards(&sr, sr.PrizeAmount)
if err != nil {
logger.Error(err.Error())
stop = true
stop = false
return
}

Expand Down

0 comments on commit 7416b2d

Please sign in to comment.