From 309ae6c368eb685f4290339f1393da94e8486c4c Mon Sep 17 00:00:00 2001 From: Cosmic Vagabond <121588426+cosmic-vagabond@users.noreply.github.com> Date: Sat, 25 Nov 2023 07:58:41 +0100 Subject: [PATCH] fix: check if discount nil (#276) --- x/amm/keeper/apply_discount.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/x/amm/keeper/apply_discount.go b/x/amm/keeper/apply_discount.go index a59442265..55ba662b5 100644 --- a/x/amm/keeper/apply_discount.go +++ b/x/amm/keeper/apply_discount.go @@ -8,6 +8,12 @@ import ( // ApplyDiscount applies discount to swap fee if applicable func (k Keeper) ApplyDiscount(ctx sdk.Context, swapFee sdk.Dec, discount sdk.Dec, sender string) (sdk.Dec, sdk.Dec, error) { + // if discount is nil, return swap fee and zero discount + if discount.IsNil() { + return swapFee, sdk.ZeroDec(), nil + } + + // if discount is zero, return swap fee and zero discount if discount.IsZero() { return swapFee, sdk.ZeroDec(), nil }