0g-chain/x/kavamint/spec/06_begin_block.md
Robert Pirtle 4c1524d7bc
Refactor community & inflation enhancements (#1428)
* refactor begin blocker to single func

* remove unused inflation keeper methods

* refactor to private keeper methods

* add testcase for failed mint due to invalid param

* add testcase for GetStakingApy()

* check for zero instead of empty

* actually test super long block time

* skip fund account for earn community proposals

* test x/community keeper GetModuleAccountBalance

* update x/kavamint begin block spec
2022-12-19 13:50:11 -08:00

22 lines
667 B
Markdown

<!--
order: 6
-->
# Begin Block
At the start of each block, new KAVA tokens are minted and distributed
```go
// BeginBlocker mints & distributes new tokens for the previous block.
func BeginBlocker(ctx sdk.Context, k Keeper) {
if err := k.AccumulateAndMintInflation(ctx); err != nil {
panic(err)
}
}
```
`AccumulateAndMintInflation` defines all sources of inflation from yearly APYs set via the parameters.
Those rates are converted to the effective rate of the yearly interest rate assuming it is
compounded once per second, for the number of seconds since the previous mint. See concepts for
more details on calculations & the defined sources of inflation.