Skip to content
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

Fixes pgf inflation #1999

Merged
merged 2 commits into from
Oct 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- Fixed the pgf stewards reward to be constant regardless of the number of
stewards. ([\#1999](https://github.com/anoma/namada/pull/1999))
16 changes: 5 additions & 11 deletions apps/src/lib/node/ledger/shell/finalize_block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -828,13 +828,16 @@ where
pgf_parameters.pgf_inflation_rate / Dec::from(epochs_per_year);
let pgf_inflation = Dec::from(total_tokens) * pgf_pd_rate;

let stewards = pgf::get_stewards(&self.wl_storage)?;
let pgf_stewards_pd_rate =
pgf_parameters.stewards_inflation_rate / Dec::from(epochs_per_year);
let pgf_steward_inflation =
Dec::from(total_tokens) * pgf_stewards_pd_rate;
let total_pgf_stewards_inflation =
pgf_steward_inflation * Dec::from(stewards.len());

let pgf_inflation_amount =
token::Amount::from(pgf_inflation + pgf_steward_inflation);
token::Amount::from(pgf_inflation + total_pgf_stewards_inflation);

credit_tokens(
&mut self.wl_storage,
Expand Down Expand Up @@ -877,18 +880,9 @@ where
}

// Pgf steward inflation
let stewards = pgf::get_stewards(&self.wl_storage)?;

let pgf_steward_reward = match stewards.len() {
0 => Dec::zero(),
_ => pgf_steward_inflation
.trunc_div(&Dec::from(stewards.len()))
.unwrap_or_default(),
};

for steward in stewards {
for (address, percentage) in steward.reward_distribution {
let pgf_steward_reward = pgf_steward_reward
let pgf_steward_reward = pgf_steward_inflation
.checked_mul(&percentage)
.unwrap_or_default();
let reward_amount = token::Amount::from(pgf_steward_reward);
Expand Down