diff --git a/CHANGELOG.md b/CHANGELOG.md index a4cfe8810..3d68f914f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -34,6 +34,10 @@ Ref: https://keepachangelog.com/en/1.0.0/ # Changelog +### Bug Fixes + +- [685](https://github.com/persistenceOne/pstake-native/pull/685) Fix rebalancing to happen outside of unbonding epochs + ## [v2.6.0] - 2023-11-26 ### Features diff --git a/x/liquidstakeibc/keeper/hooks.go b/x/liquidstakeibc/keeper/hooks.go index 3cd5c8ab5..0ed85d0e6 100644 --- a/x/liquidstakeibc/keeper/hooks.go +++ b/x/liquidstakeibc/keeper/hooks.go @@ -886,16 +886,20 @@ func (k *Keeper) LSMWorkflow(ctx sdk.Context) { // RebalanceWorkflow tries to make redelegate transactions to host-chain to balance the delegations as per the weights. func (k Keeper) RebalanceWorkflow(ctx sdk.Context, epoch int64) { + k.Logger(ctx).Info("Running redelegation workflow.", "epoch", epoch) hcs := k.GetAllHostChains(ctx) for _, hc := range hcs { // skip unbonding epoch, as we do not want to redelegate tokens that might be going through unbond txn in same epoch. // nothing bad will happen even if we do as long as unbonding txns are triggered before redelegations. - if !liquidstakeibctypes.IsUnbondingEpoch(hc.UnbondingFactor, epoch) { - k.Logger(ctx).Info("redelegation epoch co-incides with unbonding epoch, skipping it") + if liquidstakeibctypes.IsUnbondingEpoch(hc.UnbondingFactor, epoch) { + k.Logger(ctx).Info("redelegation epoch co-incides with unbonding epoch, skipping it for", "chainID", hc.ChainId) continue } msgs := k.GenerateRedelegateMsgs(ctx, *hc) + if len(msgs) == 0 { + k.Logger(ctx).Info("no msgs to redelegate for", "chainID", hc.ChainId) + } // send one msg per ica for _, msg := range msgs { ibcSeq, err := k.GenerateAndExecuteICATx(ctx, hc.ConnectionId, hc.DelegationAccount.Owner, []proto.Message{msg})