You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
By doing a few simple data fetches, it's possible to show maximum vs. realized inflation.
1. Identify New Cycle Start & Max Inflation
When an event from pallet `Inflation, NewInflationConfiguration is emitted, it means a new cycle has started.
A snapshot of the total issuance is taken, and reward pools for the next cycle are calculated based on inflation parameters.
To replicate this, take the block BEFORE this even has happened, and calculate the max possible inflation.
first_block_in_the_cycle = <block at which event was detected>;
init_total_issuance = query.balances.totalIssuance();
max_inflation_rate = query.inflation.config.maxInflationRate();
max_inflation = init_total_issuance * max_inflation_rate;
2. Plot Max Inflation Line
The assumption here is that the max inflation rate will be linearly spread over the entire cycle.
X-axis contains blocks, while Y-axis contains total issuance.
The math is fairly simple:
cycle_length_in_blocks = <use runtime API to read this>;
cycle_progression = (x - first_block_in_the_cycle ) / cycle_length_in_blocks;// How much cycle has progressed, always between 0 and 1.max_inflation(x) = cycle_progression * max_inflation + init_total_issuance;
where x is the block number.
3. Plot Realized Inflation Line
This one is also fairly simple.
At any block within the cycle, we simply read the total issuance:
By doing a few simple data fetches, it's possible to show maximum vs. realized inflation.
1. Identify New Cycle Start & Max Inflation
When an event from pallet `Inflation, NewInflationConfiguration is emitted, it means a new cycle has started.
A snapshot of the total issuance is taken, and reward pools for the next cycle are calculated based on inflation parameters.
To replicate this, take the block BEFORE this even has happened, and calculate the max possible inflation.
2. Plot Max Inflation Line
The assumption here is that the max inflation rate will be linearly spread over the entire cycle.
X-axis contains blocks, while Y-axis contains total issuance.
The math is fairly simple:
where
x
is the block number.3. Plot Realized Inflation Line
This one is also fairly simple.
At any block within the cycle, we simply read the total issuance:
Using this number, and knowing the values from the 1st subchapter above, we can estimate the final inflation:
where
x
is the block number.4. Expected Result
The text was updated successfully, but these errors were encountered: