Skip to content

Commit

Permalink
fix: undelegate non-cross delegation
Browse files Browse the repository at this point in the history
  • Loading branch information
j75689 committed Nov 27, 2023
1 parent 4b947b0 commit 64ec7a9
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions x/stake/endblock.go
Original file line number Diff line number Diff line change
Expand Up @@ -290,10 +290,9 @@ func handleRefundStake(ctx sdk.Context, k keeper.Keeper) sdk.Events {

for ; iterator.Valid(); iterator.Next() {
delegation := types.MustUnmarshalDelegation(k.CDC(), iterator.Key(), iterator.Value())
validator := bscValidatorsMap[delegation.ValidatorAddr.String()]
amount := validator.TokensFromShares(delegation.GetShares()).RawInt()
if delegation.CrossStake {
validator := bscValidatorsMap[delegation.ValidatorAddr.String()]
amount := validator.TokensFromShares(delegation.GetShares()).RawInt()

relayFeeCalc := fees.GetCalculator(types.CrossDistributeUndelegatedRelayFee)
if relayFeeCalc == nil {
ctx.Logger().Error("no fee calculator of distributeUndelegated")
Expand All @@ -312,6 +311,13 @@ func handleRefundStake(ctx sdk.Context, k keeper.Keeper) sdk.Events {
SideChainId: k.ScKeeper.BscSideChainId(ctx),
}, k)
refundEvents = refundEvents.AppendEvents(result.Events)
} else {
result := handleMsgUndelegate(ctx, types.MsgUndelegate{
DelegatorAddr: delegation.DelegatorAddr,
ValidatorAddr: delegation.ValidatorAddr,
Amount: sdk.NewCoin(boundDenom, amount),
}, k)
refundEvents = refundEvents.AppendEvents(result.Events)
}
count++
if count >= maxProcessedRefundCount {
Expand Down

0 comments on commit 64ec7a9

Please sign in to comment.