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
Pools: use Rate
represented as 18 decimals
#1520
Conversation
assert_eq!(pool.reserve.total, 758968368969420653250); | ||
assert_eq!( | ||
pool.tranches.residual_top_slice()[SENIOR_TRANCHE_INDEX as usize].reserve, | ||
251031631030579346631 | ||
251031631030579346511 | ||
); | ||
assert_eq!( | ||
pool.reserve.total + senior_price.saturating_mul_int(250 * CURRENCY), | ||
1010 * CURRENCY + 1 // TODO: Fix rounding issue with FixedPointNumberExtension | ||
1009999999999999999750 // TODO: Fix rounding issue with FixedPointNumberExtension | ||
); |
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.
After separating the pool rate into 18 and 27 decimals, I found these tests magic values has changed. I do not know where they come from (probably from calculating prices in tranches), but I'm not able to answer why they change in that way.
It changes in the last decimals, so it probably is an accumulated rounding issue with some pow()
or similar.
@@ -1032,6 +1032,7 @@ parameter_types! { | |||
impl pallet_pool_system::Config for Runtime { | |||
type AssetRegistry = OrmlAssetRegistry; | |||
type Balance = Balance; | |||
type BalanceRatio = Quantity; |
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 named it as BalanceRatio
because it is how the generic is called in some places in pool_system. But I do not feel well with any naming 😆, neither Quantity
or Ratio
. Probably we should refactor this with better naming in another PR.
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.
The current changes LGTM.
I was wondering about pool_registry::Config::Rate
which is still set to Rate
but does not seem to be used apart from the ModifyPoolMock
?! Maybe we can remove it.
@@ -1166,33 +1167,6 @@ impl PoolUpdateGuard for UpdateGuard { | |||
} | |||
} | |||
|
|||
pub struct CurrencyPriceSource; |
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 is not used
Yeah, I also notice that. Probably, it can be removed, but not sure if it's there for a pending future change (?) @mustermeiszer |
9287acd
to
a7ec39d
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.
Changes look good. The test magic values. I do not know...
pallets/pool-system/src/impls.rs
Outdated
@@ -55,13 +54,13 @@ impl<T: Config> PoolInspect<T::AccountId, T::CurrencyId> for Pallet<T> { | |||
impl<T: Config> TrancheTokenPrice<T::AccountId, T::CurrencyId> for Pallet<T> { | |||
type Moment = Moment; | |||
type PoolId = T::PoolId; | |||
type Rate = T::Rate; | |||
type Rate = T::BalanceRatio; |
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 would also rename taht
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.
Done!
Artifact from the refactor with Bastian I guess. We are not planing on havin |
Ok, if compiles with all features, I think it's ready |
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.
Reapproving
Description
This PR changes the internal
Rate
representation for pool_system (and derivatives)Changes and Descriptions
Rate
byRatio
orQuantity
where it should be used.Rate
ofpool_system
split intoBalanceRatio
(18 decimals for prices) andRate
(27 decimals for interest rates).StorageVersion
forpool_system
andinvestments
and update the value to1
.pool_system
storages foraltair
¢rifuge
runtimes.investments
storages foraltair
¢rifuge
runtimes.--> IMPORTANT: Should we nuke also
liquidity_pools
andliquidity_pools_gateway
? It seems the storage is not still used.Testing
algol
Comand:
Output:
altair
Comand:
Output:
catalyst
Command:
Output:
centrifuge
Command:
Output: