Disable savings incentives (#1320)

* allow nil hooks by using keeper methods

* disable calls to incentive from savings

* disable claim msg to prevent calls to sync claim
This commit is contained in:
Ruaridh 2022-09-29 21:18:06 +01:00 committed by GitHub
parent 6626915ca8
commit c773d874ae
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 8 additions and 20 deletions

View File

@ -666,7 +666,7 @@ func NewApp(
app.swapKeeper = *swapKeeper.SetHooks(app.incentiveKeeper.Hooks()) app.swapKeeper = *swapKeeper.SetHooks(app.incentiveKeeper.Hooks())
app.cdpKeeper = *cdpKeeper.SetHooks(cdptypes.NewMultiCDPHooks(app.incentiveKeeper.Hooks())) app.cdpKeeper = *cdpKeeper.SetHooks(cdptypes.NewMultiCDPHooks(app.incentiveKeeper.Hooks()))
app.hardKeeper = *hardKeeper.SetHooks(hardtypes.NewMultiHARDHooks(app.incentiveKeeper.Hooks())) app.hardKeeper = *hardKeeper.SetHooks(hardtypes.NewMultiHARDHooks(app.incentiveKeeper.Hooks()))
app.savingsKeeper = *savingsKeeper.SetHooks(savingstypes.NewMultiSavingsHooks(app.incentiveKeeper.Hooks())) app.savingsKeeper = savingsKeeper // savings incentive hooks disabled
app.earnKeeper = *earnKeeper.SetHooks(app.incentiveKeeper.Hooks()) app.earnKeeper = *earnKeeper.SetHooks(app.incentiveKeeper.Hooks())
// create gov keeper with router // create gov keeper with router

View File

@ -172,12 +172,12 @@ func (h Hooks) BeforePoolDepositModified(ctx sdk.Context, poolID string, deposit
// AfterSavingsDepositCreated function that runs after a deposit is created // AfterSavingsDepositCreated function that runs after a deposit is created
func (h Hooks) AfterSavingsDepositCreated(ctx sdk.Context, deposit savingstypes.Deposit) { func (h Hooks) AfterSavingsDepositCreated(ctx sdk.Context, deposit savingstypes.Deposit) {
h.k.InitializeSavingsReward(ctx, deposit) // h.k.InitializeSavingsReward(ctx, deposit)
} }
// BeforeSavingsDepositModified function that runs before a deposit is modified // BeforeSavingsDepositModified function that runs before a deposit is modified
func (h Hooks) BeforeSavingsDepositModified(ctx sdk.Context, deposit savingstypes.Deposit, incomingDenoms []string) { func (h Hooks) BeforeSavingsDepositModified(ctx sdk.Context, deposit savingstypes.Deposit, incomingDenoms []string) {
h.k.SynchronizeSavingsReward(ctx, deposit, incomingDenoms) // h.k.SynchronizeSavingsReward(ctx, deposit, incomingDenoms)
} }
// ------------------- Earn Module Hooks ------------------- // ------------------- Earn Module Hooks -------------------

View File

@ -4,6 +4,7 @@ import (
"context" "context"
sdk "github.com/cosmos/cosmos-sdk/types" sdk "github.com/cosmos/cosmos-sdk/types"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
"github.com/kava-labs/kava/x/incentive/types" "github.com/kava-labs/kava/x/incentive/types"
) )
@ -92,23 +93,10 @@ func (k msgServer) ClaimSwapReward(goCtx context.Context, msg *types.MsgClaimSwa
} }
func (k msgServer) ClaimSavingsReward(goCtx context.Context, msg *types.MsgClaimSavingsReward) (*types.MsgClaimSavingsRewardResponse, error) { func (k msgServer) ClaimSavingsReward(goCtx context.Context, msg *types.MsgClaimSavingsReward) (*types.MsgClaimSavingsRewardResponse, error) {
ctx := sdk.UnwrapSDKContext(goCtx) err := sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "savings claims disabled")
sender, err := sdk.AccAddressFromBech32(msg.Sender)
if err != nil {
return nil, err return nil, err
} }
for _, selection := range msg.DenomsToClaim {
err := k.keeper.ClaimSavingsReward(ctx, sender, sender, selection.Denom, selection.MultiplierName)
if err != nil {
return nil, err
}
}
return &types.MsgClaimSavingsRewardResponse{}, nil
}
func (k msgServer) ClaimEarnReward(goCtx context.Context, msg *types.MsgClaimEarnReward) (*types.MsgClaimEarnRewardResponse, error) { func (k msgServer) ClaimEarnReward(goCtx context.Context, msg *types.MsgClaimEarnReward) (*types.MsgClaimEarnRewardResponse, error) {
ctx := sdk.UnwrapSDKContext(goCtx) ctx := sdk.UnwrapSDKContext(goCtx)

View File

@ -24,14 +24,14 @@ func (k Keeper) Deposit(ctx sdk.Context, depositor sdk.AccAddress, coins sdk.Coi
deposit := types.NewDeposit(depositor, coins) deposit := types.NewDeposit(depositor, coins)
if foundDeposit { if foundDeposit {
deposit.Amount = deposit.Amount.Add(currDeposit.Amount...) deposit.Amount = deposit.Amount.Add(currDeposit.Amount...)
k.hooks.BeforeSavingsDepositModified(ctx, deposit, setDifference(getDenoms(coins), getDenoms(deposit.Amount))) k.BeforeSavingsDepositModified(ctx, deposit, setDifference(getDenoms(coins), getDenoms(deposit.Amount)))
} }
k.SetDeposit(ctx, deposit) k.SetDeposit(ctx, deposit)
if !foundDeposit { if !foundDeposit {
k.hooks.AfterSavingsDepositCreated(ctx, deposit) k.AfterSavingsDepositCreated(ctx, deposit)
} }
ctx.EventManager().EmitEvent( ctx.EventManager().EmitEvent(