51 lines
1.5 KiB
Markdown
51 lines
1.5 KiB
Markdown
# Begin-Block
|
|
|
|
Minting parameters are recalculated and inflation
|
|
paid at the beginning of each block.
|
|
|
|
## NextInflationRate
|
|
|
|
The target annual inflation rate is recalculated each block.
|
|
The inflation is also subject to a rate change (positive or negative)
|
|
depending on the distance from the desired ratio (67%). The maximum rate change
|
|
possible is defined to be 13% per year, however the annual inflation is capped
|
|
as between 7% and 20%.
|
|
|
|
```
|
|
NextInflationRate(params Params, bondedRatio sdk.Dec) (inflation sdk.Dec) {
|
|
inflationRateChangePerYear = (1 - bondedRatio/params.GoalBonded) * params.InflationRateChange
|
|
inflationRateChange = inflationRateChangePerYear/blocksPerYr
|
|
|
|
// increase the new annual inflation for this next cycle
|
|
inflation += inflationRateChange
|
|
if inflation > params.InflationMax {
|
|
inflation = params.InflationMax
|
|
}
|
|
if inflation < params.InflationMin {
|
|
inflation = params.InflationMin
|
|
}
|
|
|
|
return inflation
|
|
```
|
|
|
|
## NextAnnualProvisions
|
|
|
|
Calculate the annual provisions based on current total supply and inflation
|
|
rate. This parameter is calculated once per block.
|
|
|
|
```
|
|
NextAnnualProvisions(params Params, totalSupply sdk.Dec) (provisions sdk.Dec) {
|
|
return Inflation * totalSupply
|
|
```
|
|
|
|
## BlockProvision
|
|
|
|
Calculate the provisions generated for each block based on current
|
|
annual provisions
|
|
|
|
```
|
|
BlockProvision(params Params) sdk.Coin {
|
|
provisionAmt = AnnualProvisions/ params.BlocksPerYear
|
|
return sdk.NewCoin(params.MintDenom, provisionAmt.Truncate())
|
|
```
|