From 83fa45666b4c5315659a95d24462157eb0dfa2a4 Mon Sep 17 00:00:00 2001 From: jgo121 Date: Wed, 11 Oct 2023 08:32:38 +0800 Subject: [PATCH] Implement codebase to use AutocompoundIntervalNumBlocks property on autocompounding reward distribution codebase --- x/multistaking/keeper/delegation.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/x/multistaking/keeper/delegation.go b/x/multistaking/keeper/delegation.go index 185ea7fd..a9e1a44a 100644 --- a/x/multistaking/keeper/delegation.go +++ b/x/multistaking/keeper/delegation.go @@ -206,6 +206,10 @@ func (k Keeper) IncreasePoolRewards(ctx sdk.Context, pool types.StakingPool, rew // autocompound rewards rewards := k.GetDelegatorRewards(ctx, delegator) compoundInfo := k.GetCompoundInfoByAddress(ctx, delegator.String()) + properties := k.govKeeper.GetNetworkProperties(ctx) + if compoundInfo.LastExecBlock+properties.AutocompoundIntervalNumBlocks > uint64(ctx.BlockHeight()) { + continue + } autoCompoundRewards := sdk.Coins{} if compoundInfo.AllDenom { autoCompoundRewards = rewards @@ -234,6 +238,8 @@ func (k Keeper) IncreasePoolRewards(ctx sdk.Context, pool types.StakingPool, rew if err != nil { panic(err) } + compoundInfo.LastExecBlock = uint64(ctx.BlockHeight()) + k.SetCompoundInfo(ctx, compoundInfo) } } }