diff --git a/app/app.go b/app/app.go index be1a82f2..3c9f0526 100644 --- a/app/app.go +++ b/app/app.go @@ -378,6 +378,7 @@ func New( // nolint:funlen // app new cosmos func &app.AccountKeeper, &app.DistrKeeper, &app.GovKeeper, + &app.MintKeeper, &app.StakingKeeper, ) diff --git a/x/dao/abci.go b/x/dao/abci.go index cba119f8..65d1b37b 100644 --- a/x/dao/abci.go +++ b/x/dao/abci.go @@ -36,5 +36,9 @@ func endBlocker(ctx sdk.Context, k keeper.Keeper) (err error) { } } + if err = k.InflateDao(ctx); err != nil { + return err + } + return err } diff --git a/x/dao/keeper/keeper.go b/x/dao/keeper/keeper.go index 6a41da0f..5266d280 100644 --- a/x/dao/keeper/keeper.go +++ b/x/dao/keeper/keeper.go @@ -22,6 +22,7 @@ type ( accountKeeper types.AccountKeeper distributionKeeper types.DistributionKeeper govKeeper types.GovKeeper + mintKeeper types.MintKeeper stakingKeeper types.StakingKeeper } ) @@ -36,6 +37,7 @@ func NewKeeper( accountKeeper types.AccountKeeper, distributionKeeper types.DistributionKeeper, govKeeper types.GovKeeper, + mintKeeper types.MintKeeper, stakingKeeper types.StakingKeeper, ) *Keeper { // set KeyTable if it has not already been set @@ -57,6 +59,7 @@ func NewKeeper( accountKeeper: accountKeeper, distributionKeeper: distributionKeeper, govKeeper: govKeeper, + mintKeeper: mintKeeper, stakingKeeper: stakingKeeper, } } diff --git a/x/dao/keeper/mint.go b/x/dao/keeper/mint.go new file mode 100644 index 00000000..aa647378 --- /dev/null +++ b/x/dao/keeper/mint.go @@ -0,0 +1,27 @@ +package keeper + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + + "github.com/onomyprotocol/onomy/x/dao/types" +) + +// VoteAbstain votes abstain on all the proposals from the DAO account. +func (k Keeper) InflateDao(ctx sdk.Context) (err error) { + daoAddr := k.accountKeeper.GetModuleAddress(types.ModuleName) + daoBalance := k.bankKeeper.GetBalance(ctx, daoAddr, "nom") + minter := k.mintKeeper.GetMinter(ctx) + params := k.mintKeeper.GetParams(ctx) + minter.AnnualProvisions = minter.NextAnnualProvisions(params, daoBalance.Amount) + + // mint coins, update supply + mintedCoin := minter.BlockProvision(params) + mintedCoins := sdk.NewCoins(mintedCoin) + + err = k.bankKeeper.MintCoins(ctx, types.ModuleName, mintedCoins) + if err != nil { + panic(err) + } + + return err +} diff --git a/x/dao/types/expected_keepers.go b/x/dao/types/expected_keepers.go index db42a369..4b1c14d9 100644 --- a/x/dao/types/expected_keepers.go +++ b/x/dao/types/expected_keepers.go @@ -3,6 +3,7 @@ package types import ( sdk "github.com/cosmos/cosmos-sdk/types" govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" + minttypes "github.com/cosmos/cosmos-sdk/x/mint/types" paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" ) @@ -24,6 +25,7 @@ type AccountKeeper interface { // BankKeeper defines the contract needed to be fulfilled for banking and supply dependencies. type BankKeeper interface { GetAllBalances(sdk.Context, sdk.AccAddress) sdk.Coins + GetBalance(ctx sdk.Context, addr sdk.AccAddress, denom string) sdk.Coin SendCoinsFromAccountToModule(sdk.Context, sdk.AccAddress, string, sdk.Coins) error SendCoinsFromModuleToAccount(sdk.Context, string, sdk.AccAddress, sdk.Coins) error SendCoinsFromModuleToModule(ctx sdk.Context, senderPool, recipientPool string, amt sdk.Coins) error @@ -43,6 +45,12 @@ type GovKeeper interface { IterateProposals(sdk.Context, func(proposal govtypes.Proposal) bool) } +// MintKeeper expected mint keeper. +type MintKeeper interface { + GetMinter(ctx sdk.Context) (minter minttypes.Minter) + GetParams(ctx sdk.Context) (params minttypes.Params) +} + // StakingKeeper expected staking keeper. type StakingKeeper interface { BondDenom(sdk.Context) string