Skip to content

Commit

Permalink
Merge branch 'grarco/fix-pgf-stewards-funding' (#1999)
Browse files Browse the repository at this point in the history
* origin/grarco/fix-pgf-stewards-funding:
  Changelog #1999
  Fixes pgf inflation
  • Loading branch information
Fraccaman committed Oct 23, 2023
2 parents 3750365 + 05fbe1f commit 3ffc2d7
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 11 deletions.
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 @@ -801,13 +801,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 @@ -850,18 +853,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

0 comments on commit 3ffc2d7

Please sign in to comment.