-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* PENDING.md; swap BeginBlocker ordering * Calculate inflation every block * Update x/mint spec * Reset distribution info bond height instead
- Loading branch information
Showing
11 changed files
with
93 additions
and
72 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,26 @@ | ||
package mint | ||
|
||
import ( | ||
"time" | ||
|
||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
) | ||
|
||
// Inflate every block, update inflation parameters once per hour | ||
func BeginBlocker(ctx sdk.Context, k Keeper) { | ||
|
||
blockTime := ctx.BlockHeader().Time | ||
// fetch stored minter & params | ||
minter := k.GetMinter(ctx) | ||
params := k.GetParams(ctx) | ||
|
||
mintedCoin := minter.BlockProvision(params) | ||
k.fck.AddCollectedFees(ctx, sdk.Coins{mintedCoin}) | ||
k.sk.InflateSupply(ctx, sdk.NewDecFromInt(mintedCoin.Amount)) | ||
|
||
if blockTime.Sub(minter.LastUpdate) < time.Hour { | ||
return | ||
} | ||
|
||
// adjust the inflation, hourly-provision rate every hour | ||
// recalculate inflation rate | ||
totalSupply := k.sk.TotalPower(ctx) | ||
bondedRatio := k.sk.BondedRatio(ctx) | ||
minter.Inflation = minter.NextInflationRate(params, bondedRatio) | ||
minter.AnnualProvisions = minter.NextAnnualProvisions(params, totalSupply) | ||
minter.LastUpdate = blockTime | ||
k.SetMinter(ctx, minter) | ||
|
||
// mint coins, add to collected fees, update supply | ||
mintedCoin := minter.BlockProvision(params) | ||
k.fck.AddCollectedFees(ctx, sdk.Coins{mintedCoin}) | ||
k.sk.InflateSupply(ctx, sdk.NewDecFromInt(mintedCoin.Amount)) | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters