-
Notifications
You must be signed in to change notification settings - Fork 170
/
keeper.go
52 lines (44 loc) · 1.45 KB
/
keeper.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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
package keeper
import (
"github.com/cosmos/cosmos-sdk/codec"
prefixstore "github.com/cosmos/cosmos-sdk/store/prefix"
storetypes "github.com/cosmos/cosmos-sdk/store/types"
sdk "github.com/cosmos/cosmos-sdk/types"
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
"github.com/tendermint/tendermint/libs/log"
"github.com/umee-network/umee/v5/x/incentive"
)
type Keeper struct {
cdc codec.Codec
storeKey storetypes.StoreKey
bankKeeper incentive.BankKeeper
leverageKeeper incentive.LeverageKeeper
}
func NewKeeper(
cdc codec.Codec,
storeKey storetypes.StoreKey,
bk incentive.BankKeeper,
lk incentive.LeverageKeeper,
) Keeper {
return Keeper{
cdc: cdc,
storeKey: storeKey,
bankKeeper: bk,
leverageKeeper: lk,
}
}
func (k Keeper) Logger(ctx sdk.Context) log.Logger {
return ctx.Logger().With("module", "x/"+incentive.ModuleName)
}
// ModuleBalance returns the amount of a given token held in the x/incentive module account
func (k Keeper) ModuleBalance(ctx sdk.Context, denom string) sdk.Coin {
amount := k.bankKeeper.SpendableCoins(ctx, authtypes.NewModuleAddress(incentive.ModuleName)).AmountOf(denom)
return sdk.NewCoin(denom, amount)
}
// KVStore returns the module's KVStore
func (k Keeper) KVStore(ctx sdk.Context) sdk.KVStore {
return ctx.KVStore(k.storeKey)
}
func (k Keeper) prefixStore(ctx sdk.Context, prefix []byte) sdk.KVStore {
return prefixstore.NewStore(ctx.KVStore(k.storeKey), prefix)
}