Skip to content

Commit

Permalink
fix: do not charge relayerFee for auto cross undelegate after SecondS…
Browse files Browse the repository at this point in the history
…unsetFork (#379)

* fix: do not charge relayerFee for auto cross undelegate after SecondSunsetFork

* fix: FeeCalculator
  • Loading branch information
j75689 authored Jan 15, 2024
1 parent 14aa8ec commit 80c11fe
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion x/stake/keeper/delegation.go
Original file line number Diff line number Diff line change
Expand Up @@ -871,14 +871,21 @@ func (k Keeper) ValidateUnbondAmount(
func (k Keeper) crossDistributeUndelegated(ctx sdk.Context, delAddr sdk.AccAddress, valAddr sdk.ValAddress) (sdk.Events, sdk.Error) {
denom := k.BondDenom(ctx)
amount := k.BankKeeper.GetCoins(ctx, delAddr).AmountOf(denom)
relayFeeCalc := fees.GetCalculator(types.CrossDistributeUndelegatedRelayFee)

var relayFeeCalc fees.FeeCalculator
if sdk.IsUpgrade(sdk.SecondSunsetFork) && k.IsAutoUnDelegate(ctx, delAddr, valAddr) {
relayFeeCalc = fees.FreeFeeCalculator()
} else {
relayFeeCalc = fees.GetCalculator(types.CrossDistributeUndelegatedRelayFee)
}
if relayFeeCalc == nil {
return sdk.Events{}, ErrNoFeeCalculator
}
relayFee := relayFeeCalc(nil)
if relayFee.Tokens.AmountOf(denom) >= amount {
return sdk.Events{}, ErrNotEnoughRelayerFeeForCrossPkg
}

bscRelayFee := bsc.ConvertBCAmountToBSCAmount(relayFee.Tokens.AmountOf(denom))
bscTransferAmount := new(big.Int).Sub(bsc.ConvertBCAmountToBSCAmount(amount), bscRelayFee)

Expand Down

0 comments on commit 80c11fe

Please sign in to comment.