-
Notifications
You must be signed in to change notification settings - Fork 44
/
keeper.go
82 lines (69 loc) · 2.87 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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
package keeper
import (
"cosmossdk.io/math"
custommint "github.com/aura-nw/aura/x/mint/types"
"github.com/cosmos/cosmos-sdk/codec"
storetypes "github.com/cosmos/cosmos-sdk/store/types"
sdk "github.com/cosmos/cosmos-sdk/types"
mintkeeper "github.com/cosmos/cosmos-sdk/x/mint/keeper"
)
// Keeper of the mint store
type Keeper struct {
mintkeeper.Keeper
bankKeeper custommint.BankKeeper
stakingKeeper custommint.StakingKeeper
auraKeeper custommint.AuraKeeper
}
// NewKeeper creates a new mint Keeper instance
func NewKeeper(
cdc codec.BinaryCodec, key storetypes.StoreKey,
sk custommint.StakingKeeper, ak custommint.AccountKeeper, bk custommint.BankKeeper,
auraKeeper custommint.AuraKeeper, feeCollectorName string, authority string,
) Keeper {
return Keeper{
Keeper: mintkeeper.NewKeeper(cdc, key, sk, ak, bk, feeCollectorName, authority),
bankKeeper: bk,
stakingKeeper: sk,
auraKeeper: auraKeeper,
}
}
func (k Keeper) GetSupply(ctx sdk.Context, denom string) math.Int {
return k.bankKeeper.GetSupply(ctx, denom).Amount
}
func (k Keeper) GetMaxSupply(ctx sdk.Context) string {
return k.auraKeeper.GetMaxSupply(ctx)
}
//func (k Keeper) GetExcludeCirculatingAddr(ctx sdk.Context) []sdk.AccAddress {
// return k.auraKeeper.GetExcludeCirculatingAddr(ctx)
//}
//func (k Keeper) GetExcludeCirculatingAmount(ctx sdk.Context, denom string) sdk.Coin {
// excludeAddrs := k.auraKeeper.GetExcludeCirculatingAddr(ctx)
// excludeAmount := sdk.NewInt64Coin(denom, 0)
// for _, addr := range excludeAddrs {
// k.Logger(ctx).Info("GetExcludeCirculatingAmount", "addr", addr.String())
// amount := k.bankKeeper.GetBalance(ctx, addr, denom)
// k.Logger(ctx).Info("GetExcludeCirculatingAmount", "amount", amount.Amount)
// k.Logger(ctx).Info("GetExcludeCirculatingAmount", "amountString", amount.String())
// excludeAmount = excludeAmount.Add(amount)
// k.Logger(ctx).Info("GetExcludeCirculatingAmount", "excludeAmount", excludeAmount.String())
// }
// return excludeAmount
//}
func (k Keeper) GetExcludeCirculatingAmount(ctx sdk.Context, denom string) sdk.Coin {
return k.bankKeeper.GetExcludeCirculatingAmount(ctx, denom)
}
// CustomStakingTokenSupply implements an alias call to the underlying staking keeper's
// CustomStakingTokenSupply to be used in BeginBlocker.
func (k Keeper) CustomStakingTokenSupply(ctx sdk.Context, excludeAmount math.Int) math.Int {
return k.stakingKeeper.StakingTokenSupply(ctx).Sub(excludeAmount)
}
// CustomBondedRatio implements an alias call to the underlying staking keeper's
// CustomBondedRatio to be used in BeginBlocker.
func (k Keeper) CustomBondedRatio(ctx sdk.Context, excludeAmount math.Int) math.LegacyDec {
stakeSupply := k.CustomStakingTokenSupply(ctx, excludeAmount)
if stakeSupply.IsPositive() {
totalBonded := k.stakingKeeper.TotalBondedTokens(ctx)
return math.LegacyNewDecFromInt(totalBonded).QuoInt(stakeSupply)
}
return sdk.ZeroDec()
}