-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
322 additions
and
99 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package restaking | ||
|
||
import ( | ||
"time" | ||
|
||
"github.com/cosmos/cosmos-sdk/telemetry" | ||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
|
||
"github.com/milkyway-labs/milkyway/x/restaking/keeper" | ||
"github.com/milkyway-labs/milkyway/x/restaking/types" | ||
) | ||
|
||
// EndBlocker is called every block and is responsible for maturing unbonding delegations | ||
func EndBlocker(ctx sdk.Context, k *keeper.Keeper) error { | ||
defer telemetry.ModuleMeasureSince(types.ModuleName, time.Now(), telemetry.MetricKeyEndBlocker) | ||
|
||
return k.CompleteMatureUnbondingDelegations(ctx) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package keeper | ||
|
||
import ( | ||
"fmt" | ||
|
||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
|
||
"github.com/milkyway-labs/milkyway/x/restaking/types" | ||
) | ||
|
||
// CompleteMatureUnbondingDelegations runs the endblocker logic for delegations | ||
func (k *Keeper) CompleteMatureUnbondingDelegations(ctx sdk.Context) error { | ||
// Remove all mature unbonding delegations from the ubd queue. | ||
matureUnbonds := k.DequeueAllMatureUBDQueue(ctx, ctx.BlockHeader().Time) | ||
for _, data := range matureUnbonds { | ||
|
||
balances, err := k.CompleteUnbonding(ctx, data) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
ctx.EventManager().EmitEvent( | ||
sdk.NewEvent( | ||
types.EventTypeCompleteUnbonding, | ||
sdk.NewAttribute(sdk.AttributeKeyAmount, balances.String()), | ||
sdk.NewAttribute(types.AttributeUnbondingDelegationType, data.UnbondingDelegationType.String()), | ||
sdk.NewAttribute(types.AttributeTargetID, fmt.Sprintf("%d", data.TargetID)), | ||
sdk.NewAttribute(types.AttributeKeyDelegator, data.DelegatorAddress), | ||
), | ||
) | ||
} | ||
|
||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.