/
abci.go
33 lines (25 loc) · 1.1 KB
/
abci.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
package lockup
import (
abci "github.com/tendermint/tendermint/abci/types"
"github.com/osmosis-labs/osmosis/v12/x/lockup/keeper"
sdk "github.com/cosmos/cosmos-sdk/types"
)
// BeginBlocker is called on every block.
func BeginBlocker(ctx sdk.Context, req abci.RequestBeginBlock, k keeper.Keeper) {
}
// Called every block to automatically unlock matured locks.
func EndBlocker(ctx sdk.Context, k keeper.Keeper) []abci.ValidatorUpdate {
// disable automatic withdraw before specific block height
// it is actually for testing with legacy
MinBlockHeightToBeginAutoWithdrawing := int64(6)
if ctx.BlockHeight() < MinBlockHeightToBeginAutoWithdrawing {
return []abci.ValidatorUpdate{}
}
// delete synthetic locks matured before lockup deletion
k.DeleteAllMaturedSyntheticLocks(ctx)
// withdraw and delete locks
k.WithdrawAllMaturedLocks(ctx)
return []abci.ValidatorUpdate{}
}
// TODO: add invariant that no native lockup existent synthetic lockup exists by calling GetAllSyntheticLockups
// TODO: if superfluid does not delete synthetic lockup before native lockup deletion, it won't be able to be deleted