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

x/incentives: clean up AfterEpochEnd distribution hook #2008

Open
Tracked by #4622
czarcas7ic opened this issue Jul 9, 2022 · 0 comments
Open
Tracked by #4622

x/incentives: clean up AfterEpochEnd distribution hook #2008

czarcas7ic opened this issue Jul 9, 2022 · 0 comments

Comments

@czarcas7ic
Copy link
Member

Background

Within the incentives AfterEpochEnd hook, we iterate through all active gauges and remove synthetic non-perpetual gauges. This is because they are distributed elsewhere in the superfluid module.

// AfterEpochEnd is the epoch end hook.
func (k Keeper) AfterEpochEnd(ctx sdk.Context, epochIdentifier string, epochNumber int64) {
params := k.GetParams(ctx)
if epochIdentifier == params.DistrEpochIdentifier {
// begin distribution if it's start time
gauges := k.GetUpcomingGauges(ctx)
for _, gauge := range gauges {
if !ctx.BlockTime().Before(gauge.StartTime) {
if err := k.moveUpcomingGaugeToActiveGauge(ctx, gauge); err != nil {
panic(err)
}
}
}
// distribute due to epoch event
ctx.EventManager().IncreaseCapacity(2e6)
gauges = k.GetActiveGauges(ctx)
// only distribute to active gauges that are for native denoms
// or non-perpetual and for synthetic denoms.
// We distribute to perpetual synthetic denoms elsewhere in superfluid.
// TODO: This method of doing is a bit of hack, should clean this up later.
// TODO: Discuss/Create issue for the above.
distrGauges := []types.Gauge{}
for _, gauge := range gauges {
isSynthetic := lockuptypes.IsSyntheticDenom(gauge.DistributeTo.Denom)
if !(isSynthetic && gauge.IsPerpetual) {
distrGauges = append(distrGauges, gauge)
}
}
_, err := k.Distribute(ctx, distrGauges)
if err != nil {
panic(err)
}
}
}

Suggested Design

I am currently unsure if the ultimate desired outcome is to handle all distribution logic here and remove the synthetic distribution from superfluid. Will need further input from others.

Acceptance Criteria

  • Hack removed from the AfterEpochEnd hook
  • All existing tests should pass
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Needs Triage 🔍
Development

No branches or pull requests

2 participants