-
Notifications
You must be signed in to change notification settings - Fork 981
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
Implemented compounding inflation for native tokens. #1985
Conversation
0380ea2
to
640003c
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can do a more thorough review later, but looking now, nothing looks too out of the ordinary, I would like to see more what was changed, I should diff this against the mess of a current branch @juped and I worked on.
Was the solution just running some of the calculations only once instead of 4 times?
// Operations that happen exactly once for each token | ||
if denom == MaspDenom::Three { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Interesting, any reason why denom::Three
was chosen?
I guess before it would call this 4 times, causing issues?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think that the body of this conditional was called 4 times before. This denom == MaspDenom::Three
check became necessary to stop repetitions once I had moved the logic occurring before the for denom in token::MaspDenom::iter() {
loop into the for denom in token::MaspDenom::iter() {
loop. I made this movement as a matter of convenience, but I'm sure that there are other ways this logic could be structured.
I chose denom::Three
because the conditional's body modifies variables (namely total_reward
and normed_inflation
) that would affect the next iteration of for denom in token::MaspDenom::iter() {
. In the current context, the normed_inflation
can only be modified once we have finished working with the native token.
crate::types::uint::Uint::try_into( | ||
(inflation.raw_amount() * PRECISION) | ||
/ total_token_in_masp.raw_amount(), | ||
) | ||
.unwrap() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this any different? Otherwise I don't see much about this which is different
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Other than use of unsigned amounts, this code is probably the same as what's in the other branches/PRs.
a242c78
to
a625126
Compare
a625126
to
df09f26
Compare
In |
c0f2add
to
4270900
Compare
Hi! I assume you want this PR to be differentiated from
|
4270900
to
ce20a15
Compare
e33446b
to
8064a89
Compare
0147ea1
to
89aca83
Compare
…in inflation computations.
89aca83
to
2e3e640
Compare
* origin/murisi/compounding-rewards: Added changelog entry. Implemented a mul_div operation for Uints and reduced overflow risks in inflation computations. make token amounts in `RewardsController` of `Uint` type Increased the precision of MASP rewards. Integrated PD controller support. Implemented compounding inflation for native tokens.
* origin/murisi/compounding-rewards: Added changelog entry. Implemented a mul_div operation for Uints and reduced overflow risks in inflation computations. make token amounts in `RewardsController` of `Uint` type Increased the precision of MASP rewards. Integrated PD controller support. Implemented compounding inflation for native tokens.
* origin/murisi/compounding-rewards: Added changelog entry. Implemented a mul_div operation for Uints and reduced overflow risks in inflation computations. make token amounts in `RewardsController` of `Uint` type Increased the precision of MASP rewards. Integrated PD controller support. Implemented compounding inflation for native tokens.
Describe your changes
Implemented compounding inflation for native tokens and now use a PD-controller to determine inflation values. More specifically, the changes are as follows:
masp_incentives
integration test so that it no longer assumes fixed reward rates, but instead has PD-controller outputs hardcoded into it.i128
s.This PR is based on:
Indicate on which release or other PRs this topic is based on
v0.23.0
Checklist before merging to
draft