-
Notifications
You must be signed in to change notification settings - Fork 81
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
Interest accrual API only with yearly rates #1221
Conversation
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.
@branan this is ready for a first iteration review. Currently, only the accrual pallet is compiling. If you agree with this structure, I will change the rest of the crates that are dependent on it.
Self-comments about the most tricky parts:
@branan, are you ok with this schema? Can I continue with this? |
Yeah, this looks good 👍 |
8bdab28
to
c9c2fa8
Compare
pallets/interest-accrual/src/lib.rs
Outdated
let four_decimals = T::InterestRate::saturating_from_integer(10000); | ||
ensure!( | ||
interest_rate_per_year < One::one() | ||
interest_rate_per_year <= T::InterestRate::saturating_from_integer(2) |
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.
This would require another issue to tackle correctly. This 2
comes because is the "maximum" reasonable value coming from pallet-loans
, which is a possible interest rate < 1
plus a penalty from [0, 1]
. Which in the worst cases could be near to 2
.
Theoretically, there is no upper bound for this, nevertheless, technically, the correct value that should be here is the maximum rate value that does not cause overflow after the whole life of centrifuge change accruing that rate (1000 years for example?).
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.
Maybe add a constant MAX_INTEREST_RATE = 2
, and add
// Possible interest rates < 1 plus a penalty from [0, 1]
// Which in the worst cases could be near to 2.
as a comment to this constant?
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.
Agree!
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 create an issue to fix this in the future: #1297
3444838
to
f077df9
Compare
If we get this merged before the release, we'll avoid these migrations in |
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.
LGTM!
pallets/interest-accrual/src/lib.rs
Outdated
let four_decimals = T::InterestRate::saturating_from_integer(10000); | ||
ensure!( | ||
interest_rate_per_year < One::one() | ||
interest_rate_per_year <= T::InterestRate::saturating_from_integer(2) |
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.
Maybe add a constant MAX_INTEREST_RATE = 2
, and add
// Possible interest rates < 1 plus a penalty from [0, 1]
// Which in the worst cases could be near to 2.
as a comment to this constant?
Description
Modify
InterestAccrual
to expose only aninterest_rate_per_year
parameter. No more interest rates per sec to handle. UI free from converting rates to show the correct yearly rates.Fixes #1189
Changes and Descriptions
interest-accrual
.pallet-loans
side, the type is the same but the value is stored diferently, so it will require a migration if centrifuge release is launched before this.InterestAccrual
trait.Requirements