-
Notifications
You must be signed in to change notification settings - Fork 4.1k
feat(x/mint): Add max supply param #19896
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 4 commits
e71305d
c7c5b8b
bd96c8e
a37274f
5b02031
d2b775f
6686b8d
ddad9ff
d38635b
2d98d3a
2bd62a5
7068d0d
6134cc5
9b68d58
f48ac00
71d9fb0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -37,19 +37,42 @@ func (k Keeper) BeginBlocker(ctx context.Context, ic types.InflationCalculationF | |
| return err | ||
| } | ||
|
|
||
| // update minter's inflation and annual provisions | ||
| minter.Inflation = ic(ctx, minter, params, bondedRatio) | ||
| minter.AnnualProvisions = minter.NextAnnualProvisions(params, totalStakingSupply) | ||
| if err = k.Minter.Set(ctx, minter); err != nil { | ||
| return err | ||
| } | ||
|
|
||
| // mint coins, update supply | ||
| // calculate minted coins | ||
| mintedCoin := minter.BlockProvision(params) | ||
| mintedCoins := sdk.NewCoins(mintedCoin) | ||
|
|
||
| err = k.MintCoins(ctx, mintedCoins) | ||
| if err != nil { | ||
| return err | ||
| maxSupply := params.MaxSupply | ||
| // if maxSupply is not infinite, check against max_supply parameter | ||
| if !maxSupply.IsZero() { | ||
| if totalStakingSupply.Add(mintedCoins.AmountOf(params.MintDenom)).GT(maxSupply) { | ||
|
||
| // calculate the difference between maxSupply and totalStakingSupply | ||
| diff := maxSupply.Sub(totalStakingSupply) | ||
|
||
| // mint the difference | ||
| diffCoin := sdk.NewCoin(params.MintDenom, diff) | ||
Check warningCode scanning / CodeQL Panic in BeginBock or EndBlock consensus methods
path flow from Begin/EndBlock to a panic call
|
||
| diffCoins := sdk.NewCoins(diffCoin) | ||
Check warningCode scanning / CodeQL Panic in BeginBock or EndBlock consensus methods
path flow from Begin/EndBlock to a panic call
|
||
|
|
||
| // mint coins | ||
| if err := k.MintCoins(ctx, diffCoins); err != nil { | ||
|
||
| return err | ||
| } | ||
| mintedCoin = mintedCoin.Sub(diffCoin) | ||
|
||
| mintedCoins = sdk.NewCoins(mintedCoin) | ||
likhita-809 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| } | ||
| } | ||
|
|
||
| // mint coins if maxSupply is infinite or total staking supply is less than maxSupply | ||
| if maxSupply.IsZero() || totalStakingSupply.LT(maxSupply) { | ||
likhita-809 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| // mint coins | ||
| if err := k.MintCoins(ctx, mintedCoins); err != nil { | ||
Check warningCode scanning / CodeQL Panic in BeginBock or EndBlock consensus methods
path flow from Begin/EndBlock to a panic call
path flow from Begin/EndBlock to a panic call
path flow from Begin/EndBlock to a panic call
path flow from Begin/EndBlock to a panic call
path flow from Begin/EndBlock to a panic call
|
||
| return err | ||
| } | ||
| } | ||
|
|
||
| // send the minted coins to the fee collector account | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.