diff --git a/simapp/app.go b/simapp/app.go index 4870dbe87d88..5addc4d01d40 100644 --- a/simapp/app.go +++ b/simapp/app.go @@ -268,7 +268,7 @@ func NewSimApp( ) app.MintKeeper = mintkeeper.NewKeeper( appCodec, keys[minttypes.StoreKey], app.GetSubspace(minttypes.ModuleName), &stakingKeeper, - app.AccountKeeper, app.BankKeeper, authtypes.FeeCollectorName, + nil, app.AccountKeeper, app.BankKeeper, authtypes.FeeCollectorName, ) app.DistrKeeper = distrkeeper.NewKeeper( appCodec, keys[distrtypes.StoreKey], app.GetSubspace(distrtypes.ModuleName), app.AccountKeeper, app.BankKeeper, diff --git a/x/mint/keeper/keeper.go b/x/mint/keeper/keeper.go index 51ade6abef63..e3a411881776 100644 --- a/x/mint/keeper/keeper.go +++ b/x/mint/keeper/keeper.go @@ -13,18 +13,19 @@ import ( // Keeper of the mint store type Keeper struct { - cdc codec.BinaryCodec - storeKey storetypes.StoreKey - paramSpace paramtypes.Subspace - stakingKeeper types.StakingKeeper - bankKeeper types.BankKeeper - feeCollectorName string + cdc codec.BinaryCodec + storeKey storetypes.StoreKey + paramSpace paramtypes.Subspace + stakingKeeper types.StakingKeeper + protocolStakingKeeper types.ProtocolStakingKeeper + bankKeeper types.BankKeeper + feeCollectorName string } // NewKeeper creates a new mint Keeper instance func NewKeeper( cdc codec.BinaryCodec, key storetypes.StoreKey, paramSpace paramtypes.Subspace, - sk types.StakingKeeper, ak types.AccountKeeper, bk types.BankKeeper, + sk types.StakingKeeper, psk types.ProtocolStakingKeeper, ak types.AccountKeeper, bk types.BankKeeper, feeCollectorName string, ) Keeper { // ensure mint module account is set @@ -38,12 +39,13 @@ func NewKeeper( } return Keeper{ - cdc: cdc, - storeKey: key, - paramSpace: paramSpace, - stakingKeeper: sk, - bankKeeper: bk, - feeCollectorName: feeCollectorName, + cdc: cdc, + storeKey: key, + paramSpace: paramSpace, + stakingKeeper: sk, + protocolStakingKeeper: psk, + bankKeeper: bk, + feeCollectorName: feeCollectorName, } } @@ -91,7 +93,18 @@ func (k Keeper) StakingTokenSupply(ctx sdk.Context) math.Int { // BondedRatio implements an alias call to the underlying staking keeper's // BondedRatio to be used in BeginBlocker. func (k Keeper) BondedRatio(ctx sdk.Context) sdk.Dec { - return k.stakingKeeper.BondedRatio(ctx) + totalSupply := k.stakingKeeper.StakingTokenSupply(ctx) + if !totalSupply.IsPositive() { + return sdk.ZeroDec() + } + + bondedTokens := sdk.NewDecFromInt(k.stakingKeeper.TotalBondedTokens(ctx)) + protocolBondedTokens := sdk.ZeroDec() + if k.protocolStakingKeeper != nil { + protocolBondedTokens = sdk.NewDecFromInt(k.protocolStakingKeeper.TotalBondedTokens(ctx)) + } + + return bondedTokens.Add(protocolBondedTokens).QuoInt(totalSupply) } // MintCoins implements an alias call to the underlying supply keeper's diff --git a/x/mint/types/expected_keepers.go b/x/mint/types/expected_keepers.go index 68fb5765bf6d..4a4ce2196c52 100644 --- a/x/mint/types/expected_keepers.go +++ b/x/mint/types/expected_keepers.go @@ -9,7 +9,12 @@ import ( // StakingKeeper defines the expected staking keeper type StakingKeeper interface { StakingTokenSupply(ctx sdk.Context) math.Int - BondedRatio(ctx sdk.Context) sdk.Dec + TotalBondedTokens(ctx sdk.Context) math.Int +} + +// ProtocolStakingKeeper defines the expected KYVE protocol staking keeper +type ProtocolStakingKeeper interface { + TotalBondedTokens(ctx sdk.Context) math.Int } // AccountKeeper defines the contract required for account APIs.