mirror of
https://github.com/0glabs/0g-chain.git
synced 2024-10-04 08:25:18 +00:00
29 lines
845 B
Go
29 lines
845 B
Go
|
package keeper
|
||
|
|
||
|
import (
|
||
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
||
|
cdptypes "github.com/kava-labs/kava/x/cdp/types"
|
||
|
)
|
||
|
|
||
|
// Hooks wrapper struct for hooks
|
||
|
type Hooks struct {
|
||
|
k Keeper
|
||
|
}
|
||
|
|
||
|
var _ cdptypes.CDPHooks = Hooks{}
|
||
|
|
||
|
// Hooks create new incentive hooks
|
||
|
func (k Keeper) Hooks() Hooks { return Hooks{k} }
|
||
|
|
||
|
// AfterCDPCreated function that runs after a cdp is created
|
||
|
func (h Hooks) AfterCDPCreated(ctx sdk.Context, cdp cdptypes.CDP) {
|
||
|
h.k.InitializeClaim(ctx, cdp)
|
||
|
}
|
||
|
|
||
|
// BeforeCDPModified function that runs before a cdp is modified
|
||
|
// note that this is called immediately after interest is synchronized, and so could potentially
|
||
|
// be called AfterCDPInterestUpdated or something like that, if we we're to expand the scope of cdp hooks
|
||
|
func (h Hooks) BeforeCDPModified(ctx sdk.Context, cdp cdptypes.CDP) {
|
||
|
h.k.SynchronizeReward(ctx, cdp)
|
||
|
}
|