Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: move validator update to hourly epoch #782

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -589,6 +589,7 @@ func NewpStakeApp(
app.EpochsKeeper.SetHooks(
epochstypes.NewMultiEpochHooks(
app.LiquidStakeIBCKeeper.NewEpochHooks(),
app.LiquidStakeKeeper.EpochHooks(),
app.RatesyncKeeper.EpochHooks(),
),
)
Expand Down
37 changes: 37 additions & 0 deletions x/liquidstake/keeper/hooks.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package keeper

import (
sdk "github.com/cosmos/cosmos-sdk/types"
epochstypes "github.com/persistenceOne/persistence-sdk/v2/x/epochs/types"

liquidstake "github.com/persistenceOne/pstake-native/v2/x/liquidstake/types"
)

type EpochHooks struct {
k Keeper
}

var _ epochstypes.EpochHooks = EpochHooks{}

func (k Keeper) EpochHooks() EpochHooks {
return EpochHooks{k}
}

func (h EpochHooks) BeforeEpochStart(ctx sdk.Context, epochIdentifier string, epochNumber int64) error {
return h.k.BeforeEpochStart(ctx, epochIdentifier, epochNumber)
}

func (h EpochHooks) AfterEpochEnd(_ sdk.Context, _ string, _ int64) error {
// Nothing to do
return nil
}

func (k Keeper) BeforeEpochStart(ctx sdk.Context, epochIdentifier string, epochNumber int64) error {

Check failure on line 30 in x/liquidstake/keeper/hooks.go

View workflow job for this annotation

GitHub Actions / lint

File is not `gofumpt`-ed with `-extra` (gofumpt)
// Update the liquid validator set at the start of each epoch
if epochIdentifier == liquidstake.AutocompoundEpoch {
k.AutocompoundStakingRewards(ctx, liquidstake.GetWhitelistedValsMap(k.GetParams(ctx).WhitelistedValidators))
}

return nil
}
2 changes: 0 additions & 2 deletions x/liquidstake/keeper/rebalancing.go
Original file line number Diff line number Diff line change
Expand Up @@ -220,8 +220,6 @@ func (k Keeper) UpdateLiquidValidatorSet(ctx sdk.Context) (redelegations []types
}
}

k.AutocompoundStakingRewards(ctx, whitelistedValsMap)

return redelegations
}

Expand Down
3 changes: 3 additions & 0 deletions x/liquidstake/types/keys.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ const (

// QuerierRoute is the querier route for the liquidstake module
QuerierRoute = ModuleName

// Epoch identifiers
AutocompoundEpoch = "hour"
)

var (
Expand Down
Loading