-
Notifications
You must be signed in to change notification settings - Fork 77
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
Fix default timestamp for portfolio valuation #1359
Conversation
impl<T: Config> Default for PortfolioValuation<T> { | ||
fn default() -> Self { | ||
Self { | ||
value: T::Balance::zero(), | ||
last_updated: T::Time::now().as_secs(), | ||
} | ||
} | ||
} |
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.
No longer created with 0 by default
@mustermeiszer @offerijns It's not clear what should be the |
I agree it should be the created time. |
The intent of this commit is to add a fast fix, but if we can wait until the next release where Oracle Valuation fixes this well is better not to merge this PR |
Close it because the fix is already in #1311 |
Description
The
last_updated
field of portfolio valuation is only updating when the valuations are computed. This is ok, nevertheless, if a loan is added to a pool, and modified, it will affect the portfolio valuation without updating thelast_updated
, which by default will be created with0
instead ofnow()
This means that if some entity call
nav()
, before computing once the portfolio valuation, it will obtain an incorrect time (?). Not sure if this is a possible case or if we always call theupdate_portfolio_valuation()
at least once.Until I see it, the
pool-system
is protected when closing the epoch giving anNAVTooOld
error, but that means the epoch can not be closed (unlessupdate_porfolio_valuation()
is called).If it is a security issue, I understand we need to deliver a fix soon. In case not, and we can live with it, this will be fixed properly in the Oracle Valuation PR