Skip to content

Commit

Permalink
- fix subtraction leading to negative amount
Browse files Browse the repository at this point in the history
  • Loading branch information
StrathCole committed Nov 7, 2024
1 parent 0f2fd74 commit f286f6d
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions custom/auth/ante/fee.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,13 +179,17 @@ func (fd FeeDecorator) checkDeductFee(ctx sdk.Context, feeTx sdk.FeeTx, taxes sd
deductFees := feesOrTax.Sub(taxes...) // feesOrTax can never be lower than taxes
if !nonTaxableTaxes.IsZero() {
// if we have non-taxable taxes, we need to subtract them from the fees to be deducted
deductFees = deductFees.Sub(nonTaxableTaxes...)

// add the non-taxable taxes to the events
events = append(events, sdk.NewEvent(
taxtypes.EventTypeTaxRefund,
sdk.NewAttribute(taxtypes.AttributeKeyTaxAmount, nonTaxableTaxes.String()),
))
for _, coin := range nonTaxableTaxes {
if deductFees.AmountOf(coin.Denom).GTE(coin.Amount) {
deductFees = deductFees.Sub(coin)

// add the non-taxable taxes to the events
events = append(events, sdk.NewEvent(
taxtypes.EventTypeTaxRefund,
sdk.NewAttribute(taxtypes.AttributeKeyTaxAmount, coin.String()),
))
}
}
}

ctx = ctx.WithValue(taxtypes.ContextKeyTaxDue, taxes).WithValue(taxtypes.ContextKeyTaxPayer, deductFeesFrom.String())
Expand Down

0 comments on commit f286f6d

Please sign in to comment.