From a462dd3f0509f7096fa51ffe3b2ca32d97c412b9 Mon Sep 17 00:00:00 2001 From: vishnukumavat Date: Mon, 6 Nov 2023 15:35:09 +0530 Subject: [PATCH] disallow rewards distribution for disabled pools --- x/liquidity/keeper/rewards.go | 5 +++++ x/rewards/keeper/gauge.go | 5 ++++- x/rewards/types/errors.go | 1 + 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/x/liquidity/keeper/rewards.go b/x/liquidity/keeper/rewards.go index 8d297ef05..3054cb7b6 100644 --- a/x/liquidity/keeper/rewards.go +++ b/x/liquidity/keeper/rewards.go @@ -1,6 +1,7 @@ package keeper import ( + "fmt" "math" "strconv" "time" @@ -169,6 +170,10 @@ func (k Keeper) GetFarmingRewardsData(ctx sdk.Context, appID uint64, coinsToDist pair := deserializerKit.Pair pool := deserializerKit.Pool + if pool.Disabled { + return nil, sdkerrors.Wrap(types.ErrDisabledPool, fmt.Sprintf("pool is disabled : %d", pool.Id)) + } + asset, err := k.GetAssetWhoseOraclePriceExists(ctx, pair.QuoteCoinDenom, pair.BaseCoinDenom) if err != nil { return nil, err diff --git a/x/rewards/keeper/gauge.go b/x/rewards/keeper/gauge.go index d36965b82..e0a6f1577 100644 --- a/x/rewards/keeper/gauge.go +++ b/x/rewards/keeper/gauge.go @@ -95,10 +95,13 @@ func (k Keeper) ValidateMsgCreateGaugeLiquidityMetaData(ctx sdk.Context, appID u if poolID == kind.LiquidityMetaData.PoolId { return sdkerrors.Wrap(types.ErrSamePoolID, fmt.Sprintf("pool id : %d", poolID)) } - _, found := k.liquidityKeeper.GetPool(ctx, appID, poolID) + pool, found := k.liquidityKeeper.GetPool(ctx, appID, poolID) if !found { return sdkerrors.Wrap(types.ErrInvalidPoolID, fmt.Sprintf("invalid child pool id : %d", poolID)) } + if pool.Disabled { + return sdkerrors.Wrap(types.ErrDisabledPool, fmt.Sprintf("pool is disabled : %d", poolID)) + } } return nil diff --git a/x/rewards/types/errors.go b/x/rewards/types/errors.go index f8c38526e..93c6d7f09 100644 --- a/x/rewards/types/errors.go +++ b/x/rewards/types/errors.go @@ -27,4 +27,5 @@ var ( ErrInvalidAppID = sdkerrors.Register(ModuleName, 1117, "invalid app id") ErrInternalRewardsNotFound = sdkerrors.Register(ModuleName, 1118, "Internal rewards not found") ErrStablemintVaultFound = sdkerrors.Register(ModuleName, 1119, "Can't give reward to stablemint vault") + ErrDisabledPool = sdkerrors.Register(ModuleName, 1120, "diabled pool") )